Patch #: 59 Type: cleanup Priority: medium Modification: rationalise the pi_addmulti() calls Submitted: David Hornsby Archived: munnari.OZ.AU mac/cap.patches/cap60.patch059 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch059' Summary: remove extra argument, delete unnecessary open File: cap60/support/ethertalk/aarpd.c File: cap60/support/ethertalk/senetp.c File: cap60/support/ethertalk/snitp.c File: cap60/support/ethertalk/spfiltp.c *** support/ethertalk/aarpd.c.orig Tue Aug 27 20:59:07 1991 --- support/ethertalk/aarpd.c Thu Sep 12 02:09:53 1991 *************** *** 163,169 **** bzero(null_ether, sizeof(null_ether)); #ifdef PHASE2 strncpy(ifreq.ifr_name, interface, sizeof(ifreq.ifr_name)); ! if (pi_addmulti(-1, e_broad, (caddr_t)&ifreq) < 0) { fprintf(stderr, "Can't add multicast address!\n"); exit(1); } --- 163,169 ---- bzero(null_ether, sizeof(null_ether)); #ifdef PHASE2 strncpy(ifreq.ifr_name, interface, sizeof(ifreq.ifr_name)); ! if (pi_addmulti(e_broad, (caddr_t)&ifreq) < 0) { fprintf(stderr, "Can't add multicast address!\n"); exit(1); } *************** *** 559,565 **** exit(1); } strncpy(ifreq.ifr_name, interface, sizeof(ifreq.ifr_name)); ! if (pi_addmulti(-1, zmcaddr, (caddr_t)&ifreq) < 0) { fprintf(stderr, "Can't add zone multicast address!\n"); exit(1); } --- 559,565 ---- exit(1); } strncpy(ifreq.ifr_name, interface, sizeof(ifreq.ifr_name)); ! if (pi_addmulti(zmcaddr, (caddr_t)&ifreq) < 0) { fprintf(stderr, "Can't add zone multicast address!\n"); exit(1); } *** support/ethertalk/senetp.c.orig Tue Aug 20 23:43:57 1991 --- support/ethertalk/senetp.c Thu Sep 12 02:09:57 1991 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1991/08/20 13:43:12 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/senetp.c,v 2.6 1991/08/20 13:43:12 djh Rel djh $"; ! static char revision[] = "$Revision: 2.6 $"; /* * senetp.c - Simple "protocol" level interface to enet --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1991/09/11 16:09:29 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/senetp.c,v 2.7 1991/09/11 16:09:29 djh Rel djh $"; ! static char revision[] = "$Revision: 2.7 $"; /* * senetp.c - Simple "protocol" level interface to enet *************** *** 236,243 **** * add a multicast address to the interface */ int ! pi_addmulti(s, multi, ifr) ! int s; char *multi; struct ifreq *ifr; { --- 236,242 ---- * add a multicast address to the interface */ int ! pi_addmulti(multi, ifr) char *multi; struct ifreq *ifr; { *************** *** 246,261 **** sprintf(device, "/dev/%s", interface); - if (s < 0) { - /* get clone */ - if ((s = open(device, O_RDWR)) < 0) { - perror("open: /dev/enetXX"); - return(-1); - } - } - ifr->ifr_addr.sa_family = AF_UNSPEC; bcopy(multi, ifr->ifr_addr.sa_data, EHRD); /* place the "real" interface name (ie0, le0 etc.) into ifr */ if (pi_ifname(device, ifr) < 0) exit(1); --- 245,253 ---- sprintf(device, "/dev/%s", interface); ifr->ifr_addr.sa_family = AF_UNSPEC; bcopy(multi, ifr->ifr_addr.sa_data, EHRD); + /* place the "real" interface name (ie0, le0 etc.) into ifr */ if (pi_ifname(device, ifr) < 0) exit(1); *************** *** 274,281 **** return(-1); } close(sock); ! ! return(s); } /* --- 266,272 ---- return(-1); } close(sock); ! return(0); } /* *** support/ethertalk/snitp.c.orig Wed Aug 28 03:09:42 1991 --- support/ethertalk/snitp.c Thu Sep 12 02:10:00 1991 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1991/08/27 17:09:17 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/snitp.c,v 2.7 1991/08/27 17:09:17 djh Rel djh $"; ! static char revision[] = "$Revision: 2.7 $"; /* * snitp.c - Simple "protocol" level interface to Streams based NIT --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1991/09/11 16:09:29 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/snitp.c,v 2.8 1991/09/11 16:09:29 djh Rel djh $"; ! static char revision[] = "$Revision: 2.8 $"; /* * snitp.c - Simple "protocol" level interface to Streams based NIT *************** *** 203,239 **** * add a multicast address to the interface */ int ! pi_addmulti(s, multi, ifr) ! int s; char *multi; struct ifreq *ifr; { int sock; - struct strioctl si; - if (s < 0) { - /* get a new clone */ - if ((s = open(DEV_NIT, O_RDWR)) < 0) { - perror(DEV_NIT); - return(-1); - } - /* set up messages */ - if (ioctl(s, I_SRDOPT, (char *)RMSGD) < 0) { /* want messages */ - perror("ioctl: discretem"); - return(-1); - } - /* bind */ - si.ic_cmd = NIOCBIND; /* bind to underlying interface */ - si.ic_timout = 10; - si.ic_len = sizeof(*ifr); - si.ic_dp = (caddr_t)ifr; - if (ioctl(s, I_STR, (caddr_t)&si) < 0) { - perror(DEV_NIT); - return(-1); - } - /* flush read queue */ - ioctl(s, I_FLUSH, (char *)FLUSHR); - } ifr->ifr_addr.sa_family = AF_UNSPEC; bcopy(multi, ifr->ifr_addr.sa_data, EHRD); /* --- 203,214 ---- * add a multicast address to the interface */ int ! pi_addmulti(multi, ifr) char *multi; struct ifreq *ifr; { int sock; ifr->ifr_addr.sa_family = AF_UNSPEC; bcopy(multi, ifr->ifr_addr.sa_data, EHRD); /* *************** *** 250,256 **** return(-1); } close(sock); ! return(s); } #endif PHASE2 --- 225,231 ---- return(-1); } close(sock); ! return(0); } #endif PHASE2 *** support/ethertalk/spfiltp.c.orig Mon Jul 1 19:04:03 1991 --- support/ethertalk/spfiltp.c Thu Sep 12 02:10:02 1991 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1991/07/01 09:03:32 $"; ! static char rcsident[] = "$Header: /local/mulga/mac/src/cap60/support/ethertalk/RCS/spfiltp.c,v 2.3 1991/07/01 09:03:32 djh Rel djh $"; ! static char revision[] = "$Revision: 2.3 $"; /* * spfiltp.c - Simple "protocol" level interface to Ultrix packetfilter --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1991/09/11 16:09:29 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/spfiltp.c,v 2.4 1991/09/11 16:09:29 djh Rel djh $"; ! static char revision[] = "$Revision: 2.4 $"; /* * spfiltp.c - Simple "protocol" level interface to Ultrix packetfilter *************** *** 193,226 **** * add a multicast address to the interface */ int ! pi_addmulti(s, multi, ifr) ! int s; char *multi; struct ifreq *ifr; { int sock; ! if (s < 0) { ! if ((s = pfopen(interface, O_RDWR)) < 0) { ! perror("pfopen()"); ! return(-1); ! } ! /* flush read queue */ ! ioctl(s, EIOCFLUSH, 0); } - /* * get the real interface name (interface may be generic "pf0") * */ ! if (ioctl(s, EIOCIFNAME, ifr) < 0) { perror("EIOCIFNAME"); return(-1); } ifr->ifr_addr.sa_family = AF_UNSPEC; bcopy(multi, ifr->ifr_addr.sa_data, EHRD); - /* * open a socket, temporarily, to use for SIOC* ioctls * --- 193,220 ---- * add a multicast address to the interface */ int ! pi_addmulti(multi, ifr) char *multi; struct ifreq *ifr; { int sock; ! if ((sock = pfopen(interface, O_RDWR)) < 0) { ! perror("pfopen()"); ! return(-1); } /* * get the real interface name (interface may be generic "pf0") * */ ! if (ioctl(sock, EIOCIFNAME, ifr) < 0) { perror("EIOCIFNAME"); return(-1); } + close(sock); ifr->ifr_addr.sa_family = AF_UNSPEC; bcopy(multi, ifr->ifr_addr.sa_data, EHRD); /* * open a socket, temporarily, to use for SIOC* ioctls * *************** *** 237,243 **** } close(sock); ! return(s); } #endif PHASE2 --- 231,237 ---- } close(sock); ! return(0); } #endif PHASE2 *** README.orig Thu Sep 12 02:11:45 1991 --- README Thu Sep 12 02:12:18 1991 *************** *** 3,9 **** (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 58, September 1991 Introduction ------------ --- 3,9 ---- (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 59, September 1991 Introduction ------------