Patch #: 7 Type: update Priority: medium Modification: add support for Berkeley Packet Filter Modification: add support for 386BSD/FreeBSD (Phase 1) Modification: add support for DEC Alpha OSF/1 Modification: minor fixes to Solaris 2.N support Submitted: Dave Matthews Submitted: David Hornsby Submitted: Perry The Cynic Archived: munnari.OZ.AU mac/cap.patches/arns.patch007 Application: 'cd arns; patch -p < arns.patch007' *** arns.c.orig Fri Dec 10 00:38:04 1993 --- arns.c Fri Dec 10 00:30:43 1993 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.6 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.7 $ * */ *************** *** 246,253 **** * add Phase 2 multicast address (after fork()) * */ ! if (phase == 2) eth_addmulti(etfd, interface, maddr); /* * initialization for select() --- 246,258 ---- * add Phase 2 multicast address (after fork()) * */ ! if (phase == 2) { eth_addmulti(etfd, interface, maddr); + #ifdef SOLARIS + if (multiopen) + eth_addmulti(aarpfd, interface, maddr); + #endif SOLARIS + } /* * initialization for select() *** arns.h.orig Fri Dec 10 00:38:04 1993 --- arns.h Fri Dec 10 00:22:56 1993 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.8 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.9 $ * */ *************** *** 34,42 **** #endif /* AIX */ #include #include ! #ifndef sony_news #include ! #endif /* sony_news */ #include #include #include --- 34,42 ---- #endif /* AIX */ #include #include ! #if (!(defined(sony_news) || defined(__386BSD__))) #include ! #endif /* sony_news || __386BSD__ */ #include #include #include *************** *** 44,49 **** --- 44,63 ---- #ifdef NeXT #include #endif /* NeXT */ + + /* map compatible functions */ + + #ifdef SOLARIS + #define MAPFUNCS + #endif /* SOLARIS */ + + #ifdef MAPFUNCS + #define bcopy(a,b,s) memcpy((char *)(b),(char *)(a),(s)) + #define bcmp(a,b,s) memcmp((char *)(a),(char *)(b),(s)) + #define bzero(a,s) memset((char *)(a),0,(s)) + #define rindex(s,c) strrchr((char *)(s),(c)) + #define index(s,c) strchr((char *)(s),(c)) + #endif MAPFUNCS /* misc numbers */ *** pf.c.orig Tue Mar 9 14:11:30 1993 --- pf.c Fri Dec 10 00:21:38 1993 *************** *** 15,29 **** * Supports: * SunOS Network InterFace Tap (SNITPF) * DEC ULTRIX Packet Filter (UPFILT) * Stanford Ethernet Packet Filter (ENETPF) * Solaris STREAMS Data Link Provider Interface (DLPIPF) * SGI IRIX SNOOP PF for promisc, DRAIN PF for non-promisc * Sony NEWS-OS 4.N rawether (RAWETH) [Phase 1 only for 4.0] * Hewlett Packard HP-UX Link Level Access (LLAPF) * AIX Ethernet Device (AIXETH) * * $Author: djh $ ! * $Revision: 1.8 $ * */ --- 15,31 ---- * Supports: * SunOS Network InterFace Tap (SNITPF) * DEC ULTRIX Packet Filter (UPFILT) + * DEC OSF/Alpha Packet Filter (UPFILT) * Stanford Ethernet Packet Filter (ENETPF) * Solaris STREAMS Data Link Provider Interface (DLPIPF) * SGI IRIX SNOOP PF for promisc, DRAIN PF for non-promisc * Sony NEWS-OS 4.N rawether (RAWETH) [Phase 1 only for 4.0] * Hewlett Packard HP-UX Link Level Access (LLAPF) + * Berkeley Packet Filter (BPFILT) * AIX Ethernet Device (AIXETH) * * $Author: djh $ ! * $Revision: 1.13 $ * */ *************** *** 30,35 **** --- 32,38 ---- #ifdef SOLARIS #define DLPIPF + #define MAPFUNCS #endif SOLARIS #ifdef sun *************** *** 48,53 **** --- 51,60 ---- #endif BPFILT #endif ultrix + #ifdef __alpha + #define UPFILT + #endif __alpha + #ifdef sony_news #define RAWETH #endif sony_news *************** *** 56,61 **** --- 63,72 ---- #define AIXETH #endif AIX + #ifdef __386BSD__ + #define BPFILT + #endif __386BSD__ + #include #include #include *************** *** 86,91 **** --- 97,103 ---- #endif ENETPF #ifdef BPFILT + #include #include #endif BPFILT *************** *** 139,144 **** --- 151,169 ---- #include /* + * map compatible functions + * + */ + + #ifdef MAPFUNCS + #define bcopy(a,b,l) memcpy((char *)(b),(char *)(a),(l)) + #define bcmp(a,b,l) memcmp((char *)(a),(char *)(b),(l)) + #define bzero(a,l) memset((char *)(a),0,(l)) + #define rindex(s,c) strrchr((char *)(s),(c)) + #define index(s,c) strchr((char *)(s),(c)) + #endif MAPFUNCS + + /* * select common modules * */ *************** *** 159,165 **** --- 184,192 ---- #ifdef BPFILT #define USE_WRITEV #define USE_GIFADDR + #ifndef __386BSD__ /* no multicast support, yet */ #define USE_SADDMULTI + #endif __386BSD__ #endif BPFILT #ifdef UPFILT *************** *** 186,191 **** --- 213,220 ---- #ifdef AIXETH #endif AIXETH + #define READBUFSIZ 1600 + /* * variables * *************** *** 200,205 **** --- 229,238 ---- long dlpibuf[MAXDLBUF]; #endif DLPIPF + #if (defined(sgi) || defined(BPFILT)) + char ibuf[READBUFSIZ]; + #endif /* sgi || BPFILT */ + struct ifreq ifr; extern int errno; extern int promisc; *************** *** 302,308 **** /* label file descriptor with ethernet type */ bind_req.dl_primitive = DL_BIND_REQ; ! bind_req.dl_sap = (typ == 2) ? 0 : protocol; bind_req.dl_max_conind = 0; bind_req.dl_service_mode = DL_CLDLS; bind_req.dl_conn_mgmt = 0; --- 335,341 ---- /* label file descriptor with ethernet type */ bind_req.dl_primitive = DL_BIND_REQ; ! bind_req.dl_sap = (typ == 2) ? 16 : protocol; bind_req.dl_max_conind = 0; bind_req.dl_service_mode = DL_CLDLS; bind_req.dl_conn_mgmt = 0; *************** *** 414,419 **** --- 447,476 ---- #ifdef BPFILT + { struct bpf_version vers; + u_int pf_bufsize = READBUFSIZ; + + /* check the version number */ + if ((ioctl(s, BIOCVERSION, &vers)) < 0) { + perror("BIOCVERSION"); + return(-1); + } + if (vers.bv_major != BPF_MAJOR_VERSION + || vers.bv_minor < BPF_MINOR_VERSION) { + fprintf(stderr, "Incompatible BPF version\n"); + return(-1); + } + /* we have to read EXACTLY the buffer size */ + if ((ioctl(s, BIOCSBLEN, &pf_bufsize)) < 0) { + perror("BIOCSBLEN"); + return(-1); + } + if (pf_bufsize != READBUFSIZ) { + fprintf(stderr, "Can't set exact BPF buffer size\n"); + return(-1); + } + } + /* bind to interface */ if (ioctl(s, BIOCSETIF, (caddr_t)&ifr) < 0) { perror("BIOCSETIF"); return(-1); *************** *** 582,588 **** #ifdef USE_PFILT #define s_offset(structp, element) (&(((structp)0)->element)) ! bzero(&pf, sizeof(pf)); pf.Pf_Priority = 128; offset = ((int)s_offset(struct ether_header *, ether_type))/sizeof(u_short); if (typ == 2) /* EtherTalk Phase 2 */ --- 639,645 ---- #ifdef USE_PFILT #define s_offset(structp, element) (&(((structp)0)->element)) ! bzero((char *)&pf, sizeof(pf)); pf.Pf_Priority = 128; offset = ((int)s_offset(struct ether_header *, ether_type))/sizeof(u_short); if (typ == 2) /* EtherTalk Phase 2 */ *************** *** 645,666 **** #ifdef BPFILT ! static struct bpf_insn insns[] = { ! BPF_STMT(LdHOp, 12), ! BPF_JUMP(EQOp, htons(prot), 1, 6), ! BPF_STMT(LdHOp, 12), ! BPF_JUMP(EQOp, htons(0x0800), 1, 3), ! BPF_STMT(LdHOp, 42), ! BPF_JUMP(EQOp, htons(0xface), 1, 2), ! BPF_STMT(RetOp, 1), ! BPF_STMT(RetOp, 0) ! }; ! static struct bpf_program filter = { ! sizeof(insns)/sizeof(struct bpf_insn), ! insns ! }; ! if (ioctl(s, BIOCSETF, (caddr_t)&filter) < 0) { perror("BIOCSETF"); return(-1); } --- 702,774 ---- #ifdef BPFILT ! /* ! * Dave Matthews ! * dcjm@dcs.ed.ac.uk ! * dave@prolingua.co.uk ! * ! */ ! #define PROG_SIZE 7 ! int ppf = 0; ! struct bpf_program pf; ! struct bpf_insn pf_insns[PROG_SIZE]; ! extern int errno; ! ! #define s_offset(structp, element) (&(((structp)0)->element)) ! ! offset = ((int)s_offset(struct ether_header *, ether_type)); ! ! if (typ == 2) /* EtherTalk Phase 2 */ ! offset += 8; /* 2 bytes length + 6 bytes of 802.2 and SNAP */ ! ! pf_insns[ppf].code = BPF_LD+BPF_H+BPF_ABS; ! pf_insns[ppf].jt = 0; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = offset; ! ppf++; ! ! pf_insns[ppf].code = BPF_JMP+BPF_JEQ+BPF_K; ! pf_insns[ppf].jt = 1; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = prot; ! ppf++; ! ! pf_insns[ppf].code = BPF_RET+BPF_K; /* Fail */ ! pf_insns[ppf].jt = 0; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = 0; ! ppf++; ! ! if (typ == 0) { /* IPtalk */ ! pf_insns[ppf].code = BPF_LD+BPF_H+BPF_ABS; ! pf_insns[ppf].jt = 0; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = offset+30; ! ppf++; ! ! pf_insns[ppf].code = BPF_JMP+BPF_JEQ+BPF_K; ! pf_insns[ppf].jt = 1; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = 0xface; ! ppf++; ! ! pf_insns[ppf].code = BPF_RET+BPF_K; /* Fail */ ! pf_insns[ppf].jt = 0; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = 0; ! ppf++; ! } ! pf_insns[ppf].code = BPF_RET+BPF_K; /* Success */ ! pf_insns[ppf].jt = 0; ! pf_insns[ppf].jf = 0; ! pf_insns[ppf].k = (u_int)-1; ! ppf++; ! ! pf.bf_len = ppf; ! pf.bf_insns = pf_insns; ! ! if (ioctl(s, BIOCSETF, &pf) < 0) { perror("BIOCSETF"); return(-1); } *************** *** 775,781 **** perror("SIOCGIFADDR"); return(-1); } ! #ifdef sgi sa = (struct sockaddr *)&ifr.ifr_data; #else sgi sa = (struct sockaddr *)ifr.ifr_data; --- 883,889 ---- perror("SIOCGIFADDR"); return(-1); } ! #if (defined(sgi) || defined(__386BSD__)) sa = (struct sockaddr *)&ifr.ifr_data; #else sgi sa = (struct sockaddr *)ifr.ifr_data; *************** *** 860,866 **** int eth_addmulti(s, interface, addr) int s; ! char *interface, *addr; { int sock; --- 968,975 ---- int eth_addmulti(s, interface, addr) int s; ! char *interface; ! u_char *addr; { int sock; *************** *** 884,890 **** #endif ENETPF ifr.ifr_addr.sa_family = AF_UNSPEC; ! bcopy(addr, ifr.ifr_addr.sa_data, 6); /* * open a socket, temporarily, to use for SIOC* ioctls --- 993,999 ---- #endif ENETPF ifr.ifr_addr.sa_family = AF_UNSPEC; ! bcopy((char *)addr, ifr.ifr_addr.sa_data, 6); /* * open a socket, temporarily, to use for SIOC* ioctls *************** *** 981,987 **** int eth_delmulti(s, interface, addr) int s; ! char *interface, *addr; { int sock; --- 1090,1097 ---- int eth_delmulti(s, interface, addr) int s; ! char *interface; ! u_char *addr; { int sock; *************** *** 1005,1011 **** #endif ENETPF ifr.ifr_addr.sa_family = AF_UNSPEC; ! bcopy(addr, ifr.ifr_addr.sa_data, 6); /* * open a socket, temporarily, to use for SIOC* ioctls --- 1115,1121 ---- #endif ENETPF ifr.ifr_addr.sa_family = AF_UNSPEC; ! bcopy((char *)addr, ifr.ifr_addr.sa_data, 6); /* * open a socket, temporarily, to use for SIOC* ioctls *************** *** 1133,1142 **** u_char *buf; { #ifdef sgi u_char *p; int cc, off; - char ibuf[1600]; struct snoopheader *sh; if (promisc) --- 1243,1271 ---- u_char *buf; { + #ifdef BPFILT + int cc; + struct bpf_hdr *bp; + + /* must read EXACTLY the buffer size */ + if ((cc = read(fd, ibuf, sizeof(ibuf))) <= 0) + return(cc); + + bp = (struct bpf_hdr *)ibuf; + cc = bp->bh_caplen; + + if (cc > len) + cc = len; + + bcopy(ibuf+bp->bh_hdrlen, (char *)buf, cc); + + return(cc); + #endif BPFILT + + #ifdef sgi u_char *p; int cc, off; struct snoopheader *sh; if (promisc) *************** *** 1152,1159 **** if (cc > len) cc = len; - bcopy(ibuf+off, buf, cc); return(cc); #endif sgi --- 1281,1289 ---- if (cc > len) cc = len; + bcopy(ibuf+off, (char *)buf, cc); + return(cc); #endif sgi *************** *** 1172,1184 **** } if (fis.vtype != off) return(-1); ! bcopy(fis.value.s, buf, off); return(cc+off); #endif hpux ! #ifndef sgi ! return(read(fd, buf, len)); ! #endif sgi } /* --- 1302,1314 ---- } if (fis.vtype != off) return(-1); ! bcopy(fis.value.s, (char *)buf, off); return(cc+off); #endif hpux ! #if (!(defined(sgi) || defined(BPFILT))) ! return(read(fd, (char *)buf, len)); ! #endif /* sgi || BPFILT */ } /* *************** *** 1197,1203 **** struct strbuf pbuf, dbuf; sa.sa_family = AF_UNSPEC; ! bcopy(buf, sa.sa_data, sizeof(sa.sa_data)); pbuf.len = sizeof(struct sockaddr); pbuf.buf = (char *) &sa; dbuf.len = len-14; --- 1327,1333 ---- struct strbuf pbuf, dbuf; sa.sa_family = AF_UNSPEC; ! bcopy((char *)buf, (char *)sa.sa_data, sizeof(sa.sa_data)); pbuf.len = sizeof(struct sockaddr); pbuf.buf = (char *) &sa; dbuf.len = len-14; *** Makefile.orig Fri Dec 10 02:11:02 1993 --- Makefile Fri Dec 10 02:11:59 1993 *************** *** 1,39 **** # # A Remote Network Server for AppleTalk # ! # Copyright (c) 1992, The University of Melbourne # djh@munnari.OZ.AU # # ! # Most supported hosts do not require special CFLAG settings # # The defines for specific packet filters are # -DSNITPF SUN NIT PF (default) # -DUPFILT ULTRIX PF (default) # -DENETPF ENET PF # # For Sony NEWS OS4.2 or later to allow use of EtherTalk Phase 2 # CFLAGS=-Dsony_phaseII # # For IBM RS6000 AIX, Phase 1 or Phase 2 # CFLAGS=-DAIX # # For SUN Solaris 2.N, Phase 1 or Phase 2 # CFLAGS=-DSOLARIS # # For NeXT # CFLAGS=-bsd -O # CFLAGS= all: arns arnsrd arns: arns.o pf.o ddp.o aarp.o ! cc -o arns arns.o pf.o ddp.o aarp.o arnsrd: arnsrd.o ! cc -o arnsrd arnsrd.o arns.o: arns.c arns.h --- 1,49 ---- # # A Remote Network Server for AppleTalk # ! # Copyright (c) 1992-1993, The University of Melbourne # djh@munnari.OZ.AU # # ! # Most supported hosts do not require special CFLAG or LIBS settings # # The defines for specific packet filters are # -DSNITPF SUN NIT PF (default) # -DUPFILT ULTRIX PF (default) + # -DBPFILT BERKELEY PF # -DENETPF ENET PF # # For Sony NEWS OS4.2 or later to allow use of EtherTalk Phase 2 # CFLAGS=-Dsony_phaseII + # LIBS= # # For IBM RS6000 AIX, Phase 1 or Phase 2 # CFLAGS=-DAIX + # LIBS= # # For SUN Solaris 2.N, Phase 1 or Phase 2 # CFLAGS=-DSOLARIS + # LIBS=-lsocket -lnsl # + # For 386BSD, FreeBSD + # CFLAGS=-DBPFILT + # LIBS= + # # For NeXT # CFLAGS=-bsd -O + # LIBS= # CFLAGS= + LIBS= all: arns arnsrd arns: arns.o pf.o ddp.o aarp.o ! cc -o arns arns.o pf.o ddp.o aarp.o ${LIBS} arnsrd: arnsrd.o ! cc -o arnsrd arnsrd.o ${LIBS} arns.o: arns.c arns.h *** README.orig Fri Dec 10 02:11:06 1993 --- README Fri Dec 10 02:17:09 1993 *************** *** 5,11 **** The University of Melbourne djh@munnari.OZ.AU January, 1992 ! version 1.6 ARNS is 'A Remote Network Server' package for AppleTalk that allows a --- 5,11 ---- The University of Melbourne djh@munnari.OZ.AU January, 1992 ! version 1.7 ARNS is 'A Remote Network Server' package for AppleTalk that allows a *************** *** 28,38 **** The ARNS server currently supports Phase 1 and Phase 2 EtherTalk networks ! on SUN, DEC ULTRIX, SGI IRIX, Sony NEWS 4.2, HP-UX 8.07 and IBM RS6000 AIX ! workstations, and Phase 1 only on Sony NEWS pre-4.2 workstations. Security ! for access to the server is provided with an optional server password and/or ! username & password pair. Access can be restricted to clients that appear ! on an IP address filter list. The server may only be run by a UNIX superuser. ARNS provides specific services on behalf of its connected clients: --- 28,39 ---- The ARNS server currently supports Phase 1 and Phase 2 EtherTalk networks ! on SUN, DEC ULTRIX/Alpha, SGI IRIX, Sony NEWS 4.2, HP-UX 8.07 and IBM RS6000 ! AIX workstations, and Phase 1 only on Sony NEWS pre-4.2 and 386BSD/FreeBSD ! workstations. Security for access to the server is provided with an optional ! server password and/or username & password pair. Access can be restricted to ! clients that appear on an IP address filter list. The server may only be ! run by a UNIX superuser. ARNS provides specific services on behalf of its connected clients: *************** *** 250,255 **** --- 251,289 ---- If you use the interfaces named in 'netstat -i' you may receive the message "en1: A file or directory in the path name does not exist." Instead, use the network interfaces named "ent0" or "ent1" etc. + + If "netstat -i" shows interfaces called en0 and et0, then your RS6000 system + is configured to run with 802.3 Ethernet (the "et0" adapter) and you will not + be able to run UAR with EtherTalk Phase 2. + + Unless you really need 802.3 Ethernet support, it is safe to turn off the + "et0" interface. This is done using + + smit tcpip + + Select the following menu items + + Further Configuration + Network Interfaces + Network Interface Selection + Remove a Network Interface + et0 IEEE 802.3 Ethernet Network Interface + + You may have to reboot the machine afterwards. + + -------------------------------------------- + Notes for DEC Alpha OSF/1 release 1.3 users: + + You MUST manually set the define for LIBS=pfopen.o in the Makefile + and copy /usr/lib/examples/packetfilter/pfopen.c to the UAR directory. + + ----------------------- + Notes for 386BSD users: + + You must install the Berkeley Packet Filter on your system and define + -DBPFILT in the CFLAGS= line in the Makefile. At this stage, 386BSD + supports only Phase 1 EtherTalk due to limitations in multicast support + in the 386BSD ethernet driver. -------------------------- Notes for Sony NEWS users: