Patch #: 17 Type: update Priority: low Modification: update support for Linux (based on 1.3.96 kernel) Submitted: David Hornsby Archived: munnari.OZ.AU mac/cap.patches/uar.1.0.patch17 Application: 'cd uar; patch -p < uar.1.0.patch17' *** aarp.c.orig Mon Sep 25 09:16:42 1995 --- aarp.c Sun May 19 14:54:05 1996 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.2 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.3 $ * */ *************** *** 126,131 **** --- 126,141 ---- drop(uarBadPacketHdr); function = (pkt[6] << 8) | pkt[7]; + + #ifdef linux + /* + * 1.3.96 kernel reverses function bytes + * + */ + if (ntohs(function) >= AARPReq + && ntohs(function) <= AARPProbe) + function = ntohs(function); + #endif /* linux */ switch (function) { case AARPProbe: *** ddp.c.orig Mon Sep 25 09:17:00 1995 --- ddp.c Sun May 19 14:54:17 1996 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.4 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.5 $ * */ *************** *** 231,236 **** --- 231,248 ---- pd.hop = ((pkt[0] & 0x3c) >> 2); pktlen = ((pkt[0] & 0x03) << 8) | pkt[1]; + + #ifdef linux + /* + * 1.3.96 kernel sometime reverses length bytes + * this is a temporary hack ... + * + */ + if ((len+22) > 60 && pktlen != len) { + pd.hop = ((pkt[1] & 0x3c) >> 2); + pktlen = ((pkt[1] & 0x03) << 8) | pkt[0]; + } + #endif /* linux */ if (pktlen > len) drop(ddpTooShortErrors); *** rtmp.c.orig Mon Sep 25 09:18:21 1995 --- rtmp.c Sun May 19 14:54:30 1996 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.5 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.6 $ * */ *************** *** 834,840 **** zit = rtmp->zitlist; while (zit != ZITNULL) { if (znum > 0) ! fprintf(r, "%42s", ""); fprintf(r, " %s\n", zit->zone->name+1); zit = zit->next; znum++; --- 834,840 ---- zit = rtmp->zitlist; while (zit != ZITNULL) { if (znum > 0) ! fprintf(r, "%44s", ""); fprintf(r, " %s\n", zit->zone->name+1); zit = zit->next; znum++; *** uar.c.orig Mon Sep 25 09:17:54 1995 --- uar.c Sun May 19 14:54:43 1996 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.7 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.8 $ * */ *************** *** 623,629 **** return; } ! tm = localtime(&tn.tv_sec); fprintf(log, "%2d/%02d/%02d %02d:%02d:%02d ", tm->tm_year, tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); --- 623,629 ---- return; } ! tm = localtime((time_t *)&tn.tv_sec); fprintf(log, "%2d/%02d/%02d %02d:%02d:%02d ", tm->tm_year, tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); *** zip.c.orig Mon Sep 25 09:17:39 1995 --- zip.c Sun May 19 14:54:54 1996 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.6 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.7 $ * */ *************** *** 218,227 **** q = NETNULL; while (p != NETNULL) { if (p->net_lo == rtmp->net_lo ! && p->net_hi == rtmp->net_hi) return; ! if (p->net_lo >= rtmp->net_lo) break; q = p; p = p->next; --- 218,233 ---- q = NETNULL; while (p != NETNULL) { + /* + * this looks a little weird but protects + * us against morons who configure ranges + * with different start or end values. + * + */ if (p->net_lo == rtmp->net_lo ! || p->net_hi == rtmp->net_hi) return; ! if (p->net_lo > rtmp->net_lo) break; q = p; p = p->next; *** pf.c.orig Mon Sep 25 07:29:00 1995 --- pf.c Sun May 19 21:29:01 1996 *************** *** 26,32 **** * Linux SOCK_PACKET * * $Author: djh $ ! * $Revision: 1.20 $ * */ --- 26,32 ---- * Linux SOCK_PACKET * * $Author: djh $ ! * $Revision: 1.21 $ * */ *************** *** 98,104 **** --- 98,106 ---- #include #include #include + #ifndef linux #include + #endif linux #include *************** *** 174,183 **** #include #endif AIXETH ! #ifndef SOLARIS #include #include ! #endif SOLARIS #ifdef __NetBSD__ #include --- 176,185 ---- #include #endif AIXETH ! #if (!(defined(SOLARIS) || defined(linux))) #include #include ! #endif SOLARIS || linux #ifdef __NetBSD__ #include *************** *** 192,198 **** #ifdef linux #include ! #include #endif linux #include --- 194,200 ---- #ifdef linux #include ! #include #endif linux #include *************** *** 320,327 **** #ifdef linux struct socklist { struct sockaddr sa; ! } socklist[32 /* ZZ */]; #endif linux struct ifreq ifr; --- 322,330 ---- #ifdef linux struct socklist { + int iflen; struct sockaddr sa; ! } socklist[32]; #endif linux struct ifreq ifr; *************** *** 510,526 **** #ifdef linux { u_short prot; ! prot = ((typ == 2) ? htons(ETH_P_ALL) : htons(protocol)); if ((s = socket(AF_INET, SOCK_PACKET, prot)) < 0) { perror(interface); return(-1); } - /* ZZ */ if (s >= 32) { ! fprintf(stderr, "OOPS: socket() returned %d\n", s); return(-1); } - /* ZZ */ } #endif linux --- 513,527 ---- #ifdef linux { u_short prot; ! prot = ((typ == 2) ? htons(ETH_P_802_2) : htons(protocol)); if ((s = socket(AF_INET, SOCK_PACKET, prot)) < 0) { perror(interface); return(-1); } if (s >= 32) { ! close(s); return(-1); } } #endif linux *************** *** 711,718 **** #ifdef linux ! /* record socket interface name */ strncpy(socklist[s].sa.sa_data, interface, sizeof(socklist[s].sa.sa_data)); #endif linux return(s); --- 712,720 ---- #ifdef linux ! /* record socket interface name and length */ strncpy(socklist[s].sa.sa_data, interface, sizeof(socklist[s].sa.sa_data)); + socklist[s].iflen = strlen(interface); #endif linux return(s); *************** *** 1176,1186 **** perror("SIOCGIFHWADDR"); return(-1); } - #ifdef OLD_SIOCGIFHWADDR memcpy((char *)addr, ifr.ifr_hwaddr.sa_data, 6); - #else OLD_SIOCGIFHWADDR - memcpy((char *)addr, ifr.ifr_hwaddr, 6); - #endif OLD_SIOCGIFHWADDR #endif linux return(0); --- 1178,1184 ---- *************** *** 1574,1602 **** #ifdef linux int fromlen; struct sockaddr sa; ! /* ! * this is slightly less than optimal due to Linux SOCK_PACKET limitations ! * ! */ RDS[0].dataLen = 0; fromlen = sizeof(struct sockaddr); - #ifdef USE_MSG_PEEK - if ((cc = recvfrom(fd, (char *)buf, 22, MSG_PEEK, &sa, &fromlen)) <= 0) - return(cc); - #else USE_MSG_PEEK if ((cc = recvfrom(fd, (char *)buf, len, 0, &sa, &fromlen)) <= 0) return(cc); - #endif USE_MSG_PEEK - - /* check if right interface */ - if (strcmp(sa.sa_data, socklist[fd].sa.sa_data)) - return(0); ! #ifdef USE_MSG_PEEK ! if ((cc = recvfrom(fd, (char *)buf, len, 0, NULL, NULL)) <= 0) ! return(cc); ! #endif USE_MSG_PEEK RDS[0].dataLen = cc; RDS[0].dataPtr = buf; --- 1572,1588 ---- #ifdef linux int fromlen; struct sockaddr sa; ! RDS[0].dataLen = 0; fromlen = sizeof(struct sockaddr); if ((cc = recvfrom(fd, (char *)buf, len, 0, &sa, &fromlen)) <= 0) return(cc); ! /* check if from right interface */ ! for (i = socklist[fd].iflen-1; i >= 0; i--) ! if (sa.sa_data[i] != socklist[fd].sa.sa_data[i]) ! return(0); RDS[0].dataLen = cc; RDS[0].dataPtr = buf; *** README.orig Mon Sep 25 08:43:10 1995 --- README Sun May 19 20:48:23 1996 *************** *** 4,10 **** The University of Melbourne djh@munnari.OZ.AU October, 1993 ! version 1.0.16 --- 4,10 ---- The University of Melbourne djh@munnari.OZ.AU October, 1993 ! version 1.0.17 *************** *** 18,24 **** UAR currently supports Phase 1 and Phase 2 EtherTalk networks connected to SUN SunOS/Solaris, DEC ULTRIX/Alpha, SGI IRIX, Sony NEWS 4.2, HP-UX ! 8.07, IBM RS6000 AIX, Linux 1.1.74, BSDI BSD/386 1.1, NetBSD 1.0 and FreeBSD 2.0 workstations, and Phase 1 only on Sony NEWS pre-4.2 and 386BSD/FreeBSD 1.0 workstations. --- 18,24 ---- UAR currently supports Phase 1 and Phase 2 EtherTalk networks connected to SUN SunOS/Solaris, DEC ULTRIX/Alpha, SGI IRIX, Sony NEWS 4.2, HP-UX ! 8.07, IBM RS6000 AIX, Linux 1.3.96, BSDI BSD/386 1.1, NetBSD 1.0 and FreeBSD 2.0 workstations, and Phase 1 only on Sony NEWS pre-4.2 and 386BSD/FreeBSD 1.0 workstations. *************** *** 28,34 **** NOTICE ! Copyright (c) 1993-1995, The University of Melbourne. All Rights Reserved. --- 28,34 ---- NOTICE ! Copyright (c) 1993-1996, The University of Melbourne. All Rights Reserved. *************** *** 408,420 **** to define -DFreeBSD_SWAP_BUG in the Makefile. -------------------------- ! (edited ARNS version, as of July '93 UAR is untested on Sony NEWS) Yasuaki Honda Sony Computer Science Laboratory Inc. honda@csl.sony.co.jp - - Notes for Sony NEWS users: You may know that recently Sony Corp. released NEWS-OS4.2 which supports AppleTalk protocols. UAR runs on both NEWS-OS4.2 and pre-4.2 NEWS-OS that --- 408,418 ---- to define -DFreeBSD_SWAP_BUG in the Makefile. -------------------------- ! Notes for Sony NEWS users: Yasuaki Honda Sony Computer Science Laboratory Inc. honda@csl.sony.co.jp You may know that recently Sony Corp. released NEWS-OS4.2 which supports AppleTalk protocols. UAR runs on both NEWS-OS4.2 and pre-4.2 NEWS-OS that