From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,aaa640cd1569a2cd,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-03-28 17:20:50 PST Path: nntp.gmd.de!dearn!blekul11!ccsdec1.ufsia.ac.be!reks.uia.ac.be!idefix.CS.kuleuven.ac.be! Belgium.EU.net!EU.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!news.mit.edu!brian From: brian@kokom.mit.edu (Brian McAllister) Newsgroups: comp.unix.osf.osf1 Subject: How to delete multicasts ? Date: 28 Mar 1995 23:34:19 GMT Organization: Bates LINAC, MIT Message-ID: NNTP-Posting-Host: kokom.mit.edu 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