Patch #: 58 Type: operational change Priority: none Modification: Add support for UAB on Sony NEWS systems Submitted: TAYA Shin'ichiro Archived: munnari.OZ.AU mac/cap.patches/cap60.patch058 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch058' Summary: add Configure support and srawetherp.c interface File: cap60/Configure File: cap60/support/uab/aarp.c File: cap60/support/uab/ethertalk.c File: cap60/support/uab/srawetherp.c *** Configure.orig Sun Sep 1 01:23:40 1991 --- Configure Sun Sep 1 14:23:05 1991 *************** *** 1,7 **** #!/bin/sh ! # $Author: djh $ $Date: 1991/08/31 15:23:27 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.25 1991/08/31 15:23:27 djh Rel djh $ ! # $Revision: 2.25 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # --- 1,7 ---- #!/bin/sh ! # $Author: djh $ $Date: 1991/09/01 04:22:47 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.27 1991/09/01 04:22:47 djh Rel djh $ ! # $Revision: 2.27 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # *************** *** 201,206 **** --- 201,214 ---- fi fi fi + # Sony NEWS + if [ -z "${osdefault}" ]; then + echo "Checking for Sony NEWS" + if [ -d /usr/sony/bin ]; then + echo "Sony NEWS" + osdefault="newsos" + fi + fi # Default if [ -z "${osdefault}" ]; then echo "Establishing default as BSD" *************** *** 241,246 **** --- 249,255 ---- "next") valid=1;; "dynix") valid=1;; "irix") valid=1;; + "newsos") valid=1;; "?"|*) if [ "${os}" != "?" ]; then echo "unknown type ${os}, valid are:" *************** *** 260,265 **** --- 269,275 ---- echo " next - NeXT/MACH"; echo " dynix - Sequent Balance" echo " irix - Silicon Graphics IRIS/IRIX" + echo " newsos - Sony NEWS" ;; esac done *************** *** 292,297 **** --- 302,311 ---- uabsupport=1 ethersupport=0 ;; + "newsos") + uabsupport=1 + ethersupport=0 + ;; *) uabsupport=0 ethersupport=0 *************** *** 335,340 **** --- 349,357 ---- "irix") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[snooppf.o])";; + "newsos") + echo "OK, setting things up for UAB." + uabpobjs="define([uabpobjs],[srawetherp.o])";; "sunos") echo $newl "Have you installed the 'enet' driver (no) ? " read ans *************** *** 589,595 **** done if [ $result -ne 0 ]; then case ${os} in ! "ultrix40"|"ultrix20"|"ultrix12"|"bsd"|"encore") ${EDITOR-vi} m4.features ;; *) --- 606,612 ---- done if [ $result -ne 0 ]; then case ${os} in ! "ultrix40"|"ultrix20"|"ultrix12"|"bsd"|"encore"|"newsos") ${EDITOR-vi} m4.features ;; *) *************** *** 809,814 **** --- 826,832 ---- # "next" - NeXT/MACH # "dynix" - Sequent Balance # "irix" - Silicon Graphics IRIS-4D/IRIX + # "newsos" - Sony NEWS # Warning: hpux, pyr are hardcoded in some of the makefiles (sorry) # MAJOR CONFIGURATION *************** *** 1052,1057 **** --- 1070,1076 ---- ifelse(os,[next],[define([osname],[NeXT/MACH])]) ifelse(os,[dynix],[define([osname],[Sequent Balance])]) ifelse(os,[irix],[define([osname],[Silicon Graphics IRIS/IRIX])]) + ifelse(os,[newsos],[define([osname],[Sony NEWS])]) # define([cflags],ifdef([selfdefinetypes],[-D_TYPES],[])) define([cflags],concat(cflags,ifdef([usebyteswap],[ -DBYTESWAPPED],[]))) *** support/uab/aarp.c.orig Wed May 29 22:28:53 1991 --- support/uab/aarp.c Sun Sep 1 15:38:52 1991 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1991/05/29 12:28:45 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/aarp.c,v 2.3 1991/05/29 12:28:45 djh Rel djh $"; ! static char revision[] = "$Revision: 2.3 $"; /* * aarp.c - AppleTalk Address Resolution Protocol handler --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1991/09/01 05:38:41 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/aarp.c,v 2.4 1991/09/01 05:38:41 djh Rel djh $"; ! static char revision[] = "$Revision: 2.4 $"; /* * aarp.c - AppleTalk Address Resolution Protocol handler *************** *** 71,77 **** --- 71,81 ---- export int aarp_resolve(); export int aarp_insert(); export int aarp_acquire_etalk_node(); + #ifdef sony_news + int aarp_listener(); + #else sony_news private aarp_listener(); + #endif sony_news private AARP_ENTRY *aarp_find_free_etalk_node(); private probe_and_request_driver(); private void aarp_probed(); *************** *** 328,333 **** --- 332,340 ---- relTimeout(aarptab_scan, 0, &tv, TRUE); } + #ifdef sony_news + ph = devno; + #else sony_news #ifdef AARPD if ((ph = pi_open(ETHERTYPE_AARP, -1, dev, devno)) < 0) { #else AARPD *************** *** 336,341 **** --- 343,350 ---- logit(L_UERR|LOG_LOG,"pi_open: aarp_init"); return(NULL); } + #endif sony_news + if ((aih = (AI_HANDLE *)malloc(sizeof(AI_HANDLE))) == NULL) goto giveup; if ((aih->ai_nodes = (struct ai_host_node *) *************** *** 352,359 **** --- 361,372 ---- if ((pi_get_ethernet_address(ph, aih->ai_eaddr)) < 0) goto giveup; + #ifdef sony_news + logit(LOG_BASE,"Ethernet address is %02x:%02x:%02x:%02x:%02x:%02x", + #else sony_news logit(LOG_BASE,"Ethernet address for %s%d is %02x:%02x:%02x:%02x:%02x:%02x", dev, devno, + #endif sony_news aih->ai_eaddr[0], aih->ai_eaddr[1], aih->ai_eaddr[2], aih->ai_eaddr[3], aih->ai_eaddr[4], aih->ai_eaddr[5]); *************** *** 362,369 **** --- 375,385 ---- goto giveup; aih->ai_accesses = 0; /* no access to table yet */ + #ifndef sony_news /* establish listener now */ pi_listener(aih->ai_ph, aarp_listener, (caddr_t)aih); + #endif sony_news + return((caddr_t)aih); giveup: if (ph >= 0) *************** *** 549,559 **** --- 565,583 ---- } /*ARGSUSED*/ + #ifdef sony_news + aarp_listener(fd, aih, proth, buf, len) + #else sony_news private aarp_listener(fd, aih, proth) + #endif sony_news int fd; /* dummy */ AI_HANDLE *aih; int proth; + #ifdef sony_news + u_char *buf; + int len; + #endif sony_news { struct ethertalkaddr *dpa, *spa; byte *sha; *************** *** 563,570 **** --- 587,598 ---- /* note, we use read protocol because we cannot trust incoming etalk */ /* addresses from DLI on Ultrix if sent to broadcast */ + #ifdef sony_news + bcopy(buf, &arp, sizeof(arp)); + #else sony_news if (pi_read(aih->ai_ph, &arp, sizeof(arp)) < 0) return; + #endif sony_news if (ntohs(arp.arp_hrd) != ARPHRD_ETHER || /* not ethernet? */ ntohs(arp.arp_pro) != ETHERTYPE_APPLETALK || /* not appletalk? */ *************** *** 580,586 **** --- 608,618 ---- /* copy these because sunos4.0 they are struct's rather than arrays */ /* and we need to take the address and hate the way the warning */ /* messages come up, besides saves us a bit on dereferncing */ + #ifdef sony_news + sha = (byte *)&(arp.arp_sha[0]); + #else sony_news sha = (byte *)&arp.arp_sha; + #endif sony_news /* check dummy bytes? */ /* this is the first one of these, so ... the reason we have an & */ *************** *** 723,729 **** --- 755,765 ---- probe->aaph_arp.arp_op = htons(ARPOP_PROBE); probe->aaph_arp.arp_hln = EHRD; probe->aaph_arp.arp_pln = ETPL; + #ifdef sony_news + bcopy((caddr_t)aih->ai_eaddr, (caddr_t)&(probe->aaph_arp.arp_sha[0]), EHRD); + #else sony_news bcopy((caddr_t)aih->ai_eaddr, (caddr_t)&probe->aaph_arp.arp_sha, EHRD); + #endif sony_news bcopy((caddr_t)initial_node, (caddr_t)probe->aaph_arp.arp_spa, ETPL); bcopy((caddr_t)initial_node, (caddr_t)probe->aaph_arp.arp_tpa, ETPL); *************** *** 808,815 **** --- 844,856 ---- bcopy(&aphandle->aaph_arp, abuf+8, sizeof(struct ether_arp)); if (pi_write(aih->ai_ph, abuf, sizeof(abuf), b_eaddr) < 0) #else PHASE2 + #ifdef sony_news if (pi_write(aih->ai_ph,&aphandle->aaph_arp, sizeof(struct ether_arp), + b_eaddr, ETHERTYPE_AARP) < 0) + #else sony_news + if (pi_write(aih->ai_ph,&aphandle->aaph_arp, sizeof(struct ether_arp), b_eaddr) < 0) + #endif sony_news #endif PHASE2 logit(LOG_BASE|L_UERR, "pi_write failed: aarp driver"); /* setup timeout to next (relative timeout) */ *************** *** 872,879 **** --- 913,925 ---- char abuf[sizeof(struct ether_arp)+8]; #endif PHASE2 + #ifdef sony_news + sha = (caddr_t)&(arp->arp_sha[0]); /* need & because can be struct */ + tha = (caddr_t)&(arp->arp_tha[0]); + #else sony_news sha = (caddr_t)&arp->arp_sha; /* need & because can be struct */ tha = (caddr_t)&arp->arp_tha; + #endif sony_news bcopy(sha, tha, EHRD); bcopy((caddr_t)arp->arp_spa, (caddr_t)arp->arp_tpa, ETPL); *************** *** 885,891 **** --- 931,941 ---- bcopy(arp, abuf+8, sizeof(struct ether_arp)); if (pi_write(aih->ai_ph, abuf, sizeof(abuf), tha) < 0) { #else PHASE2 + #ifdef sony_news + if (pi_write(aih->ai_ph, arp, sizeof(*arp), tha, ETHERTYPE_AARP) < 0) { + #else sony_news if (pi_write(aih->ai_ph, arp, sizeof(*arp), tha) < 0) { + #endif sony_news #endif PHASE2 logit(LOG_LOG|L_UERR, "etsend"); } *************** *** 937,943 **** --- 987,997 ---- bcopy((caddr_t)&snode->aae_pa, (caddr_t)ap->aaph_arp.arp_spa, sizeof(struct ethertalkaddr)); #else + #ifdef sony_news + bcopy((caddr_t)aih->ai_eaddr, (caddr_t)&(ap->aaph_arp.arp_sha[0]), EHRD); + #else sony_news bcopy((caddr_t)aih->ai_eaddr, (caddr_t)&ap->aaph_arp.arp_sha, EHRD); + #endif sony_news /* grab any source protocol address (on right interface already!) */ { int i = aih->ai_numnode; struct ai_host_node *an = aih->ai_nodes; *** support/uab/ethertalk.c.orig Wed Mar 13 21:39:39 1991 --- support/uab/ethertalk.c Sun Sep 1 16:14:13 1991 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 91/03/13 20:39:26 $"; ! static char rcsident[] = "$Header: ethertalk.c,v 2.2 91/03/13 20:39:26 djh Exp $"; ! static char revision[] = "$Revision: 2.2 $"; /* * ethertalk.c - ethertalk interface --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1991/09/01 06:13:59 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/ethertalk.c,v 2.3 1991/09/01 06:13:59 djh Rel djh $"; ! static char revision[] = "$Revision: 2.3 $"; /* * ethertalk.c - ethertalk interface *************** *** 36,41 **** --- 36,44 ---- #include #include #include + #ifdef sony_news + #include + #endif sony_news #include *************** *** 47,52 **** --- 50,59 ---- #include "ddpport.h" /* describes a ddp port to "lap" */ #include "log.h" + #ifdef sony_news + #include "aarp_defs.h" + #endif sony_news + /* some logging ideas */ #define LOG_LOG 0 #define LOG_PRIMARY 1 *************** *** 158,164 **** --- 165,175 ---- eh->eh_ph = etph; /* init for a single node */ + #ifdef sony_news + eh->eh_ah = (caddr_t)aarp_init("", etph, 1); + #else sony_news eh->eh_ah = (caddr_t)aarp_init(id->id_intf, id->id_intfno, 1); + #endif sony_news if (eh->eh_ah == NULL) { logit(LOG_LOG|L_UERR, "aarp_init"); pi_close(etph); *************** *** 279,284 **** --- 290,299 ---- /* phew */ } + #ifdef sony_news + u_char recv_buf[ETHERMTU]; + #endif sony_news + /* * listen to incoming ethertalk packets and handle them * *************** *** 300,317 **** --- 315,352 ---- struct ethertalk_handle *eh = PORT_GETLOCAL(port, struct ethertalk_handle *); int *stats = eh->eh_stats; int ddpnode; + #ifdef sony_news + int idx = 0; + #endif sony_news iov[0].iov_base = (caddr_t)&ea; iov[0].iov_len = sizeof(ea); + #ifdef sony_news + iov[1].iov_base = (caddr_t)recv_buf; + iov[1].iov_len = ETHERMTU; + if ((cc = pi_readv(etph, iov, 2)) < 0) { + #else sony_news iov[1].iov_base = (caddr_t)⪅ iov[1].iov_len = lapSize; iov[2].iov_base = (caddr_t)rbuf; iov[2].iov_len = sizeof(rbuf); if ((cc = pi_readv(etph, iov, 3)) < 0) { + #endif sony_news logit(LOG_LOG|L_UERR, "pi_readv: ethertalk_listener"); stats[ES_ERR_INPUT]++; /* input error */ return(cc); } + #ifdef sony_news + if (ea.etype == ETHERTYPE_AARP) + return(aarp_listener(fd, ((E_HANDLE *)(port->p_local_data))->eh_ah, + etph, recv_buf, cc)); + if (ea.etype != ETHERTYPE_APPLETALK) + return(-1); + idx = 0; + bcopy(&(recv_buf[idx]), &lap, lapSize); + idx += lapSize; + bcopy(&(recv_buf[idx]), rbuf, cc-idx); + #endif sony_news /* eat the packet and drop it */ if (eh->eh_state != ELAP_READY) /* drop */ return(cc); *************** *** 453,459 **** --- 488,499 ---- iov[1].iov_base = (caddr_t)header; iov[2].iov_len = dlen; iov[2].iov_base = (caddr_t)data; + #ifdef sony_news + if ((i = pi_writev(eh->eh_ph, iov, (dlen == 0) ? 2 : 3, eaddr, + ETHERTYPE_APPLETALK)) < 0) { + #else sony_news if ((i = pi_writev(eh->eh_ph, iov, (dlen == 0) ? 2 : 3, eaddr)) < 0) { + #endif sony_news stats[ES_ERR_OUTPUT]++; return(i); } *** support/uab/srawetherp.c.orig Sun Sep 1 16:19:42 1991 --- support/uab/srawetherp.c Sun Sep 1 16:25:01 1991 *************** *** 0 **** --- 1,282 ---- + static char rcsid[] = "$Author: djh $ $Date: 1991/09/01 06:24:45 $"; + static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/srawetherp.c,v 2.1 1991/09/01 06:24:45 djh Rel djh $"; + static char revision[] = "$Revision: 2.1 $"; + + /* + * srawether.c - Simple "protocol" level interface to Rawether + * NEWS-OS 4.0 + * + * TAYA Shin'ichiro + * + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include + + #include + #include "proto_intf.h" + + typedef struct ephandle { /* ethernet protocol driver handle */ + int inuse; /* true if inuse */ + int socket; /* file descriptor of socket */ + int protocol; /* ethernet protocol */ + } EPHANDLE; + + private inited = FALSE; + + private EPHANDLE ephlist[MAXOPENPROT]; + + /* + * setup for particular device devno + * all pi_open's will go this device + */ + export + pi_setup() + { + int i; + + if (!inited) { + for (i = 0 ; i < MAXOPENPROT; i++) + ephlist[i].inuse = FALSE; + (void)init_fdlistening(); + inited = TRUE; /* don't forget now */ + } + return(TRUE); + } + + /* + * Open up a protocol handle: + * user level data: + * file descriptor + * protocol + * + * returns -1 and ephandle == NULL if memory allocation problems + * returns -1 for other errors + * return edx > 0 for okay + */ + export int + pi_open(protocol, dev, devno) + int protocol; + char *dev; + int devno; + { + struct ephandle *eph; + char devnamebuf[100]; /* room for device name */ + int s; + int i; + + for (i = 0; i < MAXOPENPROT; i++) { + if (!ephlist[i].inuse) + break; + } + if (i == MAXOPENPROT) + return(0); /* nothing */ + eph = &ephlist[i]; /* find handle */ + + sprintf(devnamebuf, "%s%d",dev,devno); + if ((s = init_rawether( devnamebuf, protocol)) < 0) { + return(-1); + } + + eph->inuse = TRUE; + eph->socket = s; + eph->protocol = protocol; + return(i+1); /* skip zero */ + } + + /* returns TRUE if machine will see own broadcasts */ + export int + pi_delivers_self_broadcasts() + { + return(FALSE); + } + + export int + pi_close(edx) + int edx; + { + if (edx < 1 || edx > MAXOPENPROT || !ephlist[edx-1].inuse) + return(-1); + fdunlisten(ephlist[edx-1].socket); /* toss listener */ + close(ephlist[edx-1].socket); + ephlist[edx-1].inuse = 0; + return(0); + } + + /* + * Initialize rawether on a particular protocol type + * + * Runs in promiscous mode for now. + * + * Return: socket if no error, < 0 o.w. + */ + private int + init_rawether(name, protocol) + char *name; + u_short protocol; + { + int s, type; + + /* get clone */ + if ((s = open(name, O_RDWR)) < 0) { + perror(name); + return(-1); + } + type = ETHER_ALL; + if(ioctl(s, ETHERIOCSTYPE, &type) < 0){ + perror("ioctl"); + return (-1); + } + + return(s); + } + + export int + pi_get_ethernet_address(edx,ea) + int edx; + u_char *ea; + { + struct sockaddr *sa; + struct ephandle *eph; + + if (edx < 1 || edx > MAXOPENPROT || !ephlist[edx-1].inuse) + return(-1); + + eph = &ephlist[edx-1]; + + if(ioctl(eph->socket, ETHERIOCGADDR, ea) != 0){ + perror("ioctl: SIOCGIFADDR"); + exit(1); + } + + return(0); + } + + export + pi_listener(edx, listener, arg) + int edx; + int (*listener)(); + caddr_t arg; + { + if (edx < 1 || edx > MAXOPENPROT || !ephlist[edx-1].inuse) + return(-1); + + fdlistener(ephlist[edx-1].socket, listener, arg, edx); + } + + /* + * cheat - iov[0] == struct etherheader + * + */ + export int + pi_readv(edx, iov, iovlen) + int edx; + struct iovec *iov; + int iovlen; + { + struct ephandle *eph ; + int cc; + + if (edx < 1 || edx > MAXOPENPROT) + return(-1); + eph = &ephlist[edx-1]; + if (!eph->inuse) + return(-1); + if ((cc = readv(eph->socket, iov, iovlen)) < 0) { + perror("abread"); + return(cc); + } + return(cc); + } + + export int + pi_read(edx, buf, bufsiz) + int edx; + caddr_t buf; + int bufsiz; + { + struct iovec iov[2]; + struct ethernet_addresses ea; + int cc; + + iov[0].iov_base = (caddr_t)&ea; + iov[0].iov_len = sizeof(ea); + iov[1].iov_base = (caddr_t)buf; + iov[1].iov_len = bufsiz; + cc = pi_readv(edx, iov, 2); + return(cc - sizeof(ea)); + } + + u_char pi_write_buf[ETHERMTU]; + + export int + pi_write(edx, buf, buflen, eaddr, protocol) + int edx; + caddr_t buf; + int buflen; + char *eaddr; + int protocol; + { + struct ephandle *eph; + struct ether_header eh; + int l; + + if (edx < 1 || edx > MAXOPENPROT || eaddr == NULL) + return(-1); + + eph = &ephlist[edx-1]; + if (!eph->inuse) + return(-1); + + bcopy(eaddr, &(eh.ether_dhost[0]), sizeof(eh.ether_dhost)); + eh.ether_type =protocol; + bcopy(&eh, pi_write_buf, sizeof(struct ether_header)); + bcopy(buf, &pi_write_buf[sizeof(struct ether_header)], buflen); + + l = (buflen > ETHERMIN ? buflen : ETHERMIN) + sizeof(struct ether_header); + + if(write(eph->socket, pi_write_buf, l) < 0){ + return(-1); + } + return(buflen); + } + + private char ebuf[2000]; /* big enough */ + + export int + pi_writev(edx, iov, iovlen, eaddr, protocol) + int edx; + struct iovec *iov; + int iovlen; + unsigned char eaddr[6]; + int protocol; + { + int i; + char *p; + int len; + + if (edx < 1 || edx > MAXOPENPROT || eaddr == NULL) + return(-1); + if (!ephlist[edx-1].inuse) + return(-1); + + for (len = 0, p = ebuf, i = 0 ; i < iovlen ; i++) + if (iov[i].iov_base && iov[i].iov_len >= 0) { + bcopy(iov[i].iov_base, p, iov[i].iov_len); + p += iov[i].iov_len; /* advance */ + len += iov[i].iov_len; /* advance */ + } + return(pi_write(edx, ebuf, len, eaddr, protocol)); + } *** README.orig Sun Sep 1 16:27:05 1991 --- README Sun Sep 1 16:28:06 1991 *************** *** 3,9 **** (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 57, September 1991 Introduction ------------ --- 3,9 ---- (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 58, September 1991 Introduction ------------