* How to delete multicasts ?
@ 1995-03-28 23:34 Brian McAllister
0 siblings, 0 replies; only message in thread
From: Brian McAllister @ 1995-03-28 23:34 UTC (permalink / raw)
Problem: How to delete a multicast address under OSF/1 ?
I have software that was written for Ultrix that we are porting to
OSF/1. We are supporting a home-brewed network protocol using the DLI
interface.
In particular, we have data that is multicast to up to 64 different
addresses. These addresses are added and deleted dynamically in order
to reduce the communications load on a particular machine.
Under Ultrix, this was done using ioctl() with the SIOCADDMULTI and
SIOCDELMULTI options. Under OSF/1 V3.0 (and 2.0), using SIOCADDMULTI
seems to have no effect.
I was able to enable multicast reception using setsockopt(), with the
DLI_MULTICAST option. Using ioctl() with SIOCDELMULTI does stop the
reception of multicasts to the specified address. Unfortunately, it
then seems to be impossible to re-enable them without closing the
socket (which is not a useful option).
I suspect that some state information may be lost because I am mixing
different mechanisms (ioctl and setsockopt).
So, my questions are:
1) Is there any way to delete a multicast using setsockopt() ?
2) Why doesn't ioctl() with SIOCADDMULTI work ?
==================================================
Here's the code:
typedef struct {
int id;
struct sockaddr_dl info;
} socket_info;
socket_info *network_open(char *device,int newflags,int type)
{
int flags;
int net_socket;
int device_number;
char device_name[20];
socket_info *sock;
if (sscanf(device,"%2s%d",device_name,&device_number) != 2)
return(NULL);
sock = (socket_info *)malloc(sizeof(socket_info));
if ((sock->id=socket(AF_DLI,SOCK_DGRAM,DLPROTO_DLI)) < 0) {
perror("Error getting socket");
return(NULL);
}
sock->info.dli_family = AF_DLI;
strcpy(sock->info.dli_device.dli_devname,device_name);
sock->info.dli_device.dli_devnumber = device_number;
sock->info.dli_substructype = DLI_ETHERNET;
sock->info.choose_addr.dli_eaddr.dli_ioctlflg = DLI_EXCLUSIVE;
sock->info.choose_addr.dli_eaddr.dli_protype = type;
bzero(sock->info.choose_addr.dli_eaddr.dli_target,DLI_EADDRSIZE);
bzero(sock->info.choose_addr.dli_eaddr.dli_dest,DLI_EADDRSIZE);
if (bind(sock->id,&sock->info,sizeof(sock->info)) != 0) {
perror("Error binding socket");
return(NULL);
}
if (newflags != 0) {
if ((flags=fcntl(sock->id,F_GETFL,0)) == -1) {
perror("Error getting flags");
return(NULL);
}
flags |= newflags;
if (fcntl(sock->id,F_SETFL,flags) == -1) {
perror("Error setting flags");
return(NULL);
}
}
return(sock);
}
int add_multicast(socket_info *sock,unsigned char *addr)
{
#if defined __osf__
struct ifreq ifr;
ifr.ifr_ifru.ifru_addr.sa_family = AF_DLI;
sprintf(ifr.ifr_name,"%s%d",sock->info.dli_device.dli_devname,
sock->info.dli_device.dli_devnumber);
bcopy(addr,ifr.ifr_ifru.ifru_addr.sa_data,DLI_EADDRSIZE);
return(ioctl(sock->id,SIOCADDMULTI,&ifr));
#elif defined ultrix
return(setsockopt(sock->id, DLPROTO_DLI, DLI_MULTICAST, addr, DLI_EADDRSIZE));
#endif
}
int delete_multicast(socket_info *sock,unsigned char *addr)
{
struct ifreq ifr;
ifr.ifr_ifru.ifru_addr.sa_family = AF_DLI;
sprintf(ifr.ifr_name,"%s%d",sock->info.dli_device.dli_devname,
sock->info.dli_device.dli_devnumber);
bcopy(addr,ifr.ifr_ifru.ifru_addr.sa_data,DLI_EADDRSIZE);
return(ioctl(sock->id,SIOCDELMULTI,&ifr));
}
--
----
Brian McAllister Internet: mcallister@mit.edu
BITNET: BRIAN@MITBATES
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1995-03-28 23:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-03-28 23:34 How to delete multicasts ? Brian McAllister
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox