Patch #: 6 Type: code maintenance Priority: medium Submitted: David Hornsby Modification: fix AARPResponse code/add dumppacket/fix doc. Modification: add Mac character case comparison/vacuum code Modification: ignore routers with different network numbers Archived: munnari.OZ.AU mac/cap.patches/arns.patch006 Application: 'cd arns; patch -p < arns.patch006' *** README.orig Tue Mar 9 18:14:48 1993 --- README Mon Apr 19 22:06:39 1993 *************** *** 5,11 **** The University of Melbourne djh@munnari.OZ.AU January, 1992 ! version 1.5 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.6 ARNS is 'A Remote Network Server' package for AppleTalk that allows a *************** *** 55,60 **** --- 55,61 ---- An ARNS client may open a UDP/IP connection directly to the server or via a TCP/IP stream to an ARNS/TCP relay daemon (arnsrd) running on the ARNS host. + 'arnsrd' is an inetd(8) client and is started only in response to a TCP link connection request. Delivery between arnsrd and the ARNS server is via the loopback interface using UDP/IP. A similar mechanism could be used for other *************** *** 71,77 **** and System 7.0 Macintosh Operating Systems. ! ARNS SERVER vers 1.1 RESTRICTIONS: The ARNS server has been tested under SunOS 4.1.1, DEC ULTRIX 4.2, SGI IRIX 3.3.3 and 4.0.4, Sony NEWS 4.N, IBM AIX 3.1.5 and HP-UX 8.07. Under ULTRIX --- 72,78 ---- and System 7.0 Macintosh Operating Systems. ! ARNS SERVER RESTRICTIONS: The ARNS server has been tested under SunOS 4.1.1, DEC ULTRIX 4.2, SGI IRIX 3.3.3 and 4.0.4, Sony NEWS 4.N, IBM AIX 3.1.5 and HP-UX 8.07. Under ULTRIX *************** *** 98,105 **** arns 384/tcp # AppleTalk Network Server ! To install the ARNS server, compile arns and install it in /usr/local/etc. ! The arguments to arns are as follows: -d number bit positions in print debugging messages for various subsystems. For details see arns.h. --- 99,107 ---- arns 384/tcp # AppleTalk Network Server ! To install the ARNS server, 'make arns' and install it in /usr/local/etc. ! The ARNS server should normally be started from /etc/rc.local or the CAP ! startup file start-cap-servers. The arguments to arns are as follows: -d number bit positions in print debugging messages for various subsystems. For details see arns.h. *************** *** 123,132 **** arns -l logfile -f filter -i ie0 -2 -p yoicks The filter list file may be edited at any time, a SIGHUP signal sent to the arns process causes the list to be reread when the next connection ! is attempted. A filter list contains IP network masks that are applied ! to incoming connections and a +/- indicator to describe the permission. IE: # --- 125,135 ---- arns -l logfile -f filter -i ie0 -2 -p yoicks + The filter list file contains IP network masks that are applied to + incoming connections and a */+/- indicator to describe the permission. The filter list file may be edited at any time, a SIGHUP signal sent to the arns process causes the list to be reread when the next connection ! is attempted. IE: # *************** *** 133,148 **** # A Remote Network Server for AppleTalk # IP Address Access Filter List # ! # + IP_ADDR permit ! # - IP_ADDR deny # # signal SIGHUP causes list to be reread # ! # arnsrd relay daemon + 127.0.0.1 ! # macs on specific subnets ! + 192.43.207.255 ! # anybody on campus + 128.250.255.255 # nobody else - 255.255.255.255 --- 136,161 ---- # A Remote Network Server for AppleTalk # IP Address Access Filter List # ! # The filter list consists of a single character mode, an IP mask and ! # optional IP address. If the latter is included, the mask is applied ! # to the incoming IP address and tested against the provided address. ! # Otherwise the incoming IP address must be unchanged by the mask. # + # Modes: + # + # * IP_MASK [ IP_ADDR ] permit access, no password required + # + IP_MASK [ IP_ADDR ] permit access, demand password + # - IP_MASK [ IP_ADDR ] deny access + # # signal SIGHUP causes list to be reread # ! # arnsrd relay daemon or localhost + 127.0.0.1 ! # any mac on a specific subnet ! + 255.255.255.0 192.43.207.0 ! # no password required for connections from ariel ! * 128.250.255.255 128.250.20.3 ! # anybody else on campus, they need a password + 128.250.255.255 # nobody else - 255.255.255.255 *************** *** 153,159 **** line of the form "- 255.255.255.255" at the end of the filter file. ! To install arnsrd, add the following line to /etc/inetd.conf arns stream tcp nowait root /usr/local/etc/arnsrd arnsrd --- 166,173 ---- line of the form "- 255.255.255.255" at the end of the filter file. ! To install the TCP/IP relay daemon, 'make arnsrd' and install it in ! /usr/local/etc. Add the following line to /etc/inetd.conf arns stream tcp nowait root /usr/local/etc/arnsrd arnsrd *************** *** 161,169 **** arns stream tcp nowait root /usr/local/etc/arnsrd arnsrd -f filt ! Install the arnsrd binary as /usr/local/etc/arnsrd and, as root, send ! a SIGHUP to the inetd process. On BSD-type systems, the status of the ! arnsrd process can be obtained from a ps(1) listing (ala sendmail). The format is of the output is "-arns hostname (X/Y T) (arnsrd)" where 'hostname' is the name or IP address of the client making the TCP --- 175,182 ---- arns stream tcp nowait root /usr/local/etc/arnsrd arnsrd -f filt ! As root, send a SIGHUP to the inetd process. On BSD-type systems, the status ! of the arnsrd process can be obtained from a ps(1) listing (ala sendmail). The format is of the output is "-arns hostname (X/Y T) (arnsrd)" where 'hostname' is the name or IP address of the client making the TCP *************** *** 183,195 **** ARNS ASYNC CLIENT ! The UNIX end of the async appletalk connection is "async". Compile and ! install in /usr/local/bin (or /usr/local/cap) for use by any user. The ! source requires no special installation or host services and can therefore ! be transported to and compiled on any BSD UNIX host to provide AppleTalk ! connectivity for travellers. NB: async is currently incompatible with the ! connection methods used by the original async package, you may wish to call ! this binary async2. Usage is async [-ltu] [ servername ] --- 196,208 ---- ARNS ASYNC CLIENT ! The UNIX end of the async appletalk connection is "async". 'make async' ! and install in /usr/local/bin (or /usr/local/cap) for use by any user. ! The source requires no special installation or host services and can ! therefore be transported to and compiled on any BSD UNIX host to provide ! AppleTalk connectivity for travellers. NB: async is currently incompatible ! with the connection methods used by the original async package, you may wish ! to call this binary async2. Usage is async [-ltu] [ servername ] *************** *** 219,230 **** NOTICE ! Copyright (c) 1992, The University of Melbourne. All rights reserved. ! Permission to redistribute or use any part of this software for any purpose ! other than as part of the ARNS distribution must be obtained in writing from ! the copyright owner. This software is supplied "as is" without express or ! implied warranty. May not be resold. ------------------------ Notes for IBM AIX users: --- 232,246 ---- NOTICE ! Copyright (c) 1992, The University of Melbourne. ! All Rights Reserved. Permission to publicly redistribute this package ! or to use any part of this software for any purpose, other than that ! intended by the original distribution, *must* be obtained in writing ! from the copyright owner. + This software is supplied "as is" without express or implied warranty. + + djh@munnari.OZ.AU ------------------------ Notes for IBM AIX users: *** aarp.c.orig Mon Sep 21 17:08:53 1992 --- aarp.c Sat May 1 23:50:34 1993 *************** *** 5,22 **** * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * ! * This software is supplied "as is" without express ! * or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1 $ * */ --- 5,21 ---- * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * ! * This software is supplied "as is" without express or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.2 $ * */ *************** *** 41,54 **** */ void ! aarp(buf) register u_char *buf; { register u_char *pkt; register u_char *addr; u_char dstNode, srcNode; u_short dstNet, srcNet, function; addr = buf+6; /* ethernet source */ switch (phase) { --- 40,58 ---- */ void ! aarp(buf, len) register u_char *buf; + int len; { register u_char *pkt; register u_char *addr; u_char dstNode, srcNode; u_short dstNet, srcNet, function; + void aarpRespond(); + if (debug & PKTDEBUG) + dumppacket(buf, len); + addr = buf+6; /* ethernet source */ switch (phase) { *************** *** 105,117 **** break; case AARPResp: /* could be response to lookup or probe */ ! bcopy(pkt+18, nodeTab[dstNode].eaddr, 6); ! nodeTab[dstNode].aarpState = AARP_VALID; ! nodeTab[dstNode].aarpCount = 0; if (debug & AARPDEBUG) { ! addr = nodeTab[dstNode].eaddr; fprintf(stderr,"AARP: node %02x %02x:%02x:%02x:%02x:%02x:%02x\n", ! dstNode,addr[0],addr[1],addr[2],addr[3],addr[4],addr[5]); } break; default: --- 109,121 ---- break; case AARPResp: /* could be response to lookup or probe */ ! bcopy(pkt+8, nodeTab[srcNode].eaddr, 6); ! nodeTab[srcNode].aarpState = AARP_VALID; ! nodeTab[srcNode].aarpCount = 0; if (debug & AARPDEBUG) { ! addr = nodeTab[srcNode].eaddr; fprintf(stderr,"AARP: node %02x %02x:%02x:%02x:%02x:%02x:%02x\n", ! srcNode,addr[0],addr[1],addr[2],addr[3],addr[4],addr[5]); } break; default: *************** *** 126,132 **** * AARP glean * */ - if (srcNet == 0 || srcNet == thisNet) { if (nodeTab[srcNode].connType == ARNS_UNUSED || nodeTab[srcNode].connType == ARNS_ETALK) { --- 130,135 ---- *************** *** 141,146 **** --- 144,150 ---- } } } + return; } *************** *** 158,163 **** --- 162,168 ---- nodeTab[node].aarpCount = 10; nodeTab[node].aarpState = AARP_PENDING; nodeTab[node].aarpFunction = function; + return; } *************** *** 166,172 **** * */ ! int aarpRespond(dstNode, dstNet, addr, reqNode) u_char dstNode; u_short dstNet; --- 171,177 ---- * */ ! void aarpRespond(dstNode, dstNet, addr, reqNode) u_char dstNode; u_short dstNet; *************** *** 175,180 **** --- 180,186 ---- { register u_char *pkt; u_char buf[128]; + void aarpWrite(); switch (phase) { case 1: *************** *** 188,194 **** pkt = buf+22; /* ethernet header data */ pkt[24] = 0; /* must be zero */ pkt[25] = dstNet >> 8; /* dst network */ ! pkt[26] = dstNet&0xff; /* dst network */ pkt[27] = dstNode; /* dst protocol address */ break; default: --- 194,200 ---- pkt = buf+22; /* ethernet header data */ pkt[24] = 0; /* must be zero */ pkt[25] = dstNet >> 8; /* dst network */ ! pkt[26] = dstNet & 0xff; /* dst network */ pkt[27] = dstNode; /* dst protocol address */ break; default: *************** *** 205,210 **** --- 211,218 ---- } aarpWrite(buf, reqNode, AARPResp); + + return; } /* *************** *** 219,226 **** u_short function; { register u_char *pkt; ! u_char buf[128]; ! u_char *addr; switch (phase) { case 1: --- 227,234 ---- u_short function; { register u_char *pkt; ! u_char buf[128], *addr; ! void aarpWrite(); switch (phase) { case 1: *************** *** 235,241 **** pkt = buf+22; /* ethernet header data */ pkt[24] = 0; /* must be zero */ pkt[25] = dstNet >> 8; /* dst network */ ! pkt[26] = dstNet&0xff; /* dst network */ pkt[27] = dstNode; /* dst protocol address */ addr = maddr; /* multicast enet addr */ break; --- 243,249 ---- pkt = buf+22; /* ethernet header data */ pkt[24] = 0; /* must be zero */ pkt[25] = dstNet >> 8; /* dst network */ ! pkt[26] = dstNet & 0xff; /* dst network */ pkt[27] = dstNode; /* dst protocol address */ addr = maddr; /* multicast enet addr */ break; *************** *** 254,259 **** --- 262,269 ---- } aarpWrite(buf, (function == AARPProbe) ? dstNode : thisNode, function); + + return; } /* *************** *** 263,269 **** * */ ! int aarpWrite(buf, srcNode, function) register u_char *buf; u_char srcNode; --- 273,279 ---- * */ ! void aarpWrite(buf, srcNode, function) register u_char *buf; u_char srcNode; *************** *** 270,276 **** u_short function; { register u_char *pkt; ! short i, len; switch (phase) { case 1: --- 280,286 ---- u_short function; { register u_char *pkt; ! short len; switch (phase) { case 1: *************** *** 287,293 **** pkt = buf+22; /* ethernet header data */ pkt[14] = 0; /* must be zero */ pkt[15] = thisNet >> 8; /* src network */ ! pkt[16] = thisNet&0xff; /* src network */ pkt[17] = srcNode; /* src protocol address */ buf[12] = 0x00; /* 802.3 header length */ buf[13] = 0x24; /* 802.3 header length */ --- 297,303 ---- pkt = buf+22; /* ethernet header data */ pkt[14] = 0; /* must be zero */ pkt[15] = thisNet >> 8; /* src network */ ! pkt[16] = thisNet & 0xff; /* src network */ pkt[17] = srcNode; /* src protocol address */ buf[12] = 0x00; /* 802.3 header length */ buf[13] = 0x24; /* 802.3 header length */ *************** *** 315,321 **** pkt[4] = 0x06; /* h/w address length */ pkt[5] = 0x04; /* prot address length */ pkt[6] = function >> 8; /* AARP function */ ! pkt[7] = function&0xff; /* AARP function */ bcopy(eaddr, buf+6, 6); /* our eth addr as src */ bcopy(eaddr, pkt+8, 6); /* our eth addr as src */ --- 325,331 ---- pkt[4] = 0x06; /* h/w address length */ pkt[5] = 0x04; /* prot address length */ pkt[6] = function >> 8; /* AARP function */ ! pkt[7] = function & 0xff;/* AARP function */ bcopy(eaddr, buf+6, 6); /* our eth addr as src */ bcopy(eaddr, pkt+8, 6); /* our eth addr as src */ *************** *** 327,342 **** if (debug & AARPDEBUG) { fprintf(stderr, "AARP: writing %d bytes\n", len); ! if (debug & PKTDEBUG) { ! for (i = 0; i < len; i++) { ! fprintf(stderr, "%02x ", buf[i]); ! if ((i+1) % 16 == 0) ! fprintf(stderr, "\n"); ! } ! fprintf(stderr, "\n"); ! } } if (write_eth(aarpfd, buf, len) != len) perror("write_eth()"); } --- 337,348 ---- if (debug & AARPDEBUG) { fprintf(stderr, "AARP: writing %d bytes\n", len); ! if (debug & PKTDEBUG) ! dumppacket(buf, len); } if (write_eth(aarpfd, buf, len) != len) perror("write_eth()"); + + return; } *** arns.c.orig Tue Mar 9 14:10:52 1993 --- arns.c Sat May 1 23:50:49 1993 *************** *** 5,22 **** * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * ! * This software is supplied "as is" without express ! * or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.5 $ * */ --- 5,21 ---- * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * ! * This software is supplied "as is" without express or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.6 $ * */ *************** *** 52,70 **** struct nodeTab nodeTab[MAXNODES]; /* Primary data structure */ struct ipFilter ipFilter[MAXFILTERS]; /* Filter list: IPaddr/perm */ extern u_char eaddr[]; /* server hardware address */ extern u_char maddr[]; /* phase 2 multicast address */ extern u_char thisNode; /* server node number */ extern u_short thisNet; /* server network number */ extern u_char bridgeNode; /* adopted bridge node number */ - extern u_short bridgeNet; /* adopted bridge net number */ extern char *thisZone; /* server zone name */ - struct timeval tp; /* time to run protocol driver */ - struct timeval tn; /* time packet read from net */ - FILE *log, *fopen(); - main(argc, argv) int argc; char *argv[]; --- 51,69 ---- struct nodeTab nodeTab[MAXNODES]; /* Primary data structure */ struct ipFilter ipFilter[MAXFILTERS]; /* Filter list: IPaddr/perm */ + struct timeval tp; /* time to run protocol driver */ + struct timeval tn; /* time packet read from net */ + + FILE *log, *fopen(); + extern u_char eaddr[]; /* server hardware address */ extern u_char maddr[]; /* phase 2 multicast address */ extern u_char thisNode; /* server node number */ extern u_short thisNet; /* server network number */ extern u_char bridgeNode; /* adopted bridge node number */ extern char *thisZone; /* server zone name */ main(argc, argv) int argc; char *argv[]; *************** *** 77,83 **** extern char *optarg; extern int optind, opterr; struct servent *s, *getservbyname(); ! void readeth(), readaarp(), readdev(); #ifdef SYSTYPE_SYSV void readIPFilter(); #else /* SYSTYPE_SYSV */ --- 76,83 ---- extern char *optarg; extern int optind, opterr; struct servent *s, *getservbyname(); ! void buildIPFilterList(), process(), usage(); ! void readeth(), readaarp(), readdev(), readip(); #ifdef SYSTYPE_SYSV void readIPFilter(); #else /* SYSTYPE_SYSV */ *************** *** 200,228 **** } } ! /* get eth address */ eth_addr(etfd, eaddr); if (phase == 2) { thisNet = P2STARTUP; /* startup range 255.0 */ infoTimer = INFOTimer; /* GetNetInfo period */ - eth_addmulti(etfd, interface, maddr); /* add m/cast to iface */ nodeTab[254].connType = ARNS_ETALK; /* illegal node number */ nodeTab[254].aarpState = AARP_UNKNOWN;/* illegal node number */ } ! /* queue probe for br node ID */ for (i = 253; i >= 0; i--) if (initNode(i)) break; ! nfds = 16; ! FD_ZERO(&fdset); ! to.tv_sec = 0; ! to.tv_usec = 200000; /* 200 ms */ ! ! /* disassociate */ ! if (!debug) { if (fork()) exit(0); --- 200,234 ---- } } ! /* ! * get interface hardware address ! * ! */ eth_addr(etfd, eaddr); + /* + * Phase 2 setup + * + */ if (phase == 2) { thisNet = P2STARTUP; /* startup range 255.0 */ infoTimer = INFOTimer; /* GetNetInfo period */ nodeTab[254].connType = ARNS_ETALK; /* illegal node number */ nodeTab[254].aarpState = AARP_UNKNOWN;/* illegal node number */ } ! /* ! * queue probe for br node ID ! * ! */ for (i = 253; i >= 0; i--) if (initNode(i)) break; ! /* ! * disassociate ! * ! */ if (!debug) { if (fork()) exit(0); *************** *** 236,241 **** --- 242,263 ---- #endif /* TIOCNOTTY */ } + /* + * add Phase 2 multicast address (after fork()) + * + */ + if (phase == 2) + eth_addmulti(etfd, interface, maddr); + + /* + * initialization for select() + * + */ + nfds = 16; + FD_ZERO(&fdset); + to.tv_sec = 0; + to.tv_usec = 200000; /* 200 ms */ + for ( ; ; ) { FD_SET(ipfd, &fdset); FD_SET(etfd, &fdset); *************** *** 260,271 **** } } ! int usage() { fprintf(stderr, "usage: %s [-d flags] [-f filterlist]\n", progname); fprintf(stderr, "\t[-i interface] [-l logfile] [-1] [-2]\n"); fprintf(stderr, "\t[-n maxusers] [-p passwd] [-z zone]\n"); } /* --- 282,295 ---- } } ! void usage() { fprintf(stderr, "usage: %s [-d flags] [-f filterlist]\n", progname); fprintf(stderr, "\t[-i interface] [-l logfile] [-1] [-2]\n"); fprintf(stderr, "\t[-n maxusers] [-p passwd] [-z zone]\n"); + + return; } /* *************** *** 279,285 **** * data */ ! int readip(fd) int fd; { --- 303,309 ---- * data */ ! void readip(fd) int fd; { *************** *** 286,296 **** u_char *bufp; u_char *data; int trusted = 0; ! int i, cc, fromlen; int srcNode, dstNode; int request, reqType; struct sockaddr from; void aarpQueue(), routeDDP(); bufp = buf+28; /* ensure 32 bytes free before packet DATA */ --- 310,322 ---- u_char *bufp; u_char *data; int trusted = 0; ! int cc, fromlen; int srcNode, dstNode; int request, reqType; struct sockaddr from; void aarpQueue(), routeDDP(); + void reply(), replyNetInfo(); + void buildIPFilterList(), record(); bufp = buf+28; /* ensure 32 bytes free before packet DATA */ *************** *** 322,333 **** fprintf(stderr, " @%d.%d.%d.%d, socket %d\n", bufp[4], bufp[5], bufp[6], bufp[7], (bufp[2]<<8) | bufp[3]); bufp = buf+28; ! for (i = 0; i < cc; i++) { ! fprintf(stderr, "%02x ", bufp[i]); ! if ((i+1) % 16 == 0) ! fprintf(stderr, "\n"); ! } ! fprintf(stderr, "\n"); } switch (request) { --- 348,355 ---- fprintf(stderr, " @%d.%d.%d.%d, socket %d\n", bufp[4], bufp[5], bufp[6], bufp[7], (bufp[2]<<8) | bufp[3]); bufp = buf+28; ! if (debug & PKTDEBUG) ! dumppacket(bufp, cc); } switch (request) { *************** *** 337,370 **** case CONN_PROBE: if (needIPFilter) buildIPFilterList(); ! if (illegalIP(&from, fromlen, &trusted)) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_ILLEGAL, "Access Denied (IP Address Filter).")); ! if (users > maxusers) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_TOOBUSY, "Too Many Users Now, Try Later ...")); if (!trusted) { ! if (password[0] != '\0' && data[0] == '\0') ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_NEEDPASS, "The Server Requires a Password.")); if (password[0] != '\0' && passChk(password, data) != 0) { record(LOG_BADPASS, &from, srcNode, data); ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADPASS, "Server Password Incorrect.")); } } ! if (reqType == CONN_PROBE) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_WAITING, "The Server Is Ready.")); if (nodeTab[srcNode].connType == ARNS_PENDING /* repeat */ && bcmp(&from, &nodeTab[srcNode].remote, fromlen) == 0) return; /* ignore duplicate request from same node */ if (nodeTab[srcNode].connType == ARNS_IPLAP /* reconnect */ ! && bcmp(&from, &nodeTab[srcNode].remote, fromlen) == 0) ! return(replyNetInfo(&from, fromlen, srcNode)); ! if (nodeTab[srcNode].connType != ARNS_UNUSED) /* busy */ ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_NODEUSED, "That Node Number Is In Use.")); record(LOG_REQUEST, &from, srcNode, data); bcopy(&from, &nodeTab[srcNode].remote, sizeof(from)); nodeTab[srcNode].fromlen = fromlen; --- 359,405 ---- case CONN_PROBE: if (needIPFilter) buildIPFilterList(); ! if (illegalIP(&from, fromlen, &trusted)) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_ILLEGAL, "Access Denied (IP Address Filter)."); ! return; ! } ! if (users > maxusers) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_TOOBUSY, "Too Many Users Now, Try Later ..."); ! return; ! } if (!trusted) { ! if (password[0] != '\0' && data[0] == '\0') { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_NEEDPASS, "The Server Requires a Password."); ! return; ! } if (password[0] != '\0' && passChk(password, data) != 0) { record(LOG_BADPASS, &from, srcNode, data); ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADPASS, "Server Password Incorrect."); ! return; } } ! if (reqType == CONN_PROBE) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_WAITING, "The Server Is Ready."); ! return; ! } if (nodeTab[srcNode].connType == ARNS_PENDING /* repeat */ && bcmp(&from, &nodeTab[srcNode].remote, fromlen) == 0) return; /* ignore duplicate request from same node */ if (nodeTab[srcNode].connType == ARNS_IPLAP /* reconnect */ ! && bcmp(&from, &nodeTab[srcNode].remote, fromlen) == 0) { ! replyNetInfo(&from, fromlen, srcNode); ! return; ! } ! if (nodeTab[srcNode].connType != ARNS_UNUSED) { /* busy */ ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_NODEUSED, "That Node Number Is In Use."); ! return; ! } record(LOG_REQUEST, &from, srcNode, data); bcopy(&from, &nodeTab[srcNode].remote, sizeof(from)); nodeTab[srcNode].fromlen = fromlen; *************** *** 374,411 **** return; break; case CONN_DISCONN: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?")); if (users > 0) users--; record(LOG_DISCONN, &from, srcNode, ""); bzero(&nodeTab[srcNode], sizeof(struct nodeTab)); ! return(reply(&from, fromlen, srcNode, ARNS_CONNECT, ! CONN_GOODBYE, "Goodbye.")); break; case CONN_REDIRECT: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?")); if (validAddr(data)) { record(LOG_REDIRECT, &from, srcNode, ""); bcopy(data, &nodeTab[srcNode].remote, sizeof(from)); ! return(reply(&nodeTab[srcNode].remote, fromlen, srcNode, ! ARNS_CONNECT, CONN_REDIRECTED, "Link Redirected.")); } ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADADDR, "Redirect Address Bad Format.")); break; default: ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADRQST, "Unknown Request.")); break; } break; case ARNS_DDPDATA: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?")); nodeTab[srcNode].heardFrom = tn.tv_sec; nodeTab[srcNode].idleCount = 0; nodeTab[srcNode].idleTimer = 0; --- 409,456 ---- return; break; case CONN_DISCONN: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?"); ! return; ! } if (users > 0) users--; record(LOG_DISCONN, &from, srcNode, ""); bzero(&nodeTab[srcNode], sizeof(struct nodeTab)); ! reply(&from, fromlen, srcNode, ARNS_CONNECT, ! CONN_GOODBYE, "Goodbye."); ! return; break; case CONN_REDIRECT: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?"); ! return; ! } if (validAddr(data)) { record(LOG_REDIRECT, &from, srcNode, ""); bcopy(data, &nodeTab[srcNode].remote, sizeof(from)); ! reply(&nodeTab[srcNode].remote, fromlen, srcNode, ! ARNS_CONNECT, CONN_REDIRECTED, "Link Redirected."); ! return; } ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADADDR, "Redirect Address Bad Format."); ! return; break; default: ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADRQST, "Unknown Request."); ! return; break; } break; case ARNS_DDPDATA: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?"); ! return; ! } nodeTab[srcNode].heardFrom = tn.tv_sec; nodeTab[srcNode].idleCount = 0; nodeTab[srcNode].idleTimer = 0; *************** *** 417,425 **** switch (reqType) { case ECHO_REQUEST: case ECHO_REPLY: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?")); nodeTab[srcNode].heardFrom = tn.tv_sec; nodeTab[srcNode].idleCount = 0; nodeTab[srcNode].idleTimer = 0; --- 462,472 ---- switch (reqType) { case ECHO_REQUEST: case ECHO_REPLY: ! if (bcmp(&from, &nodeTab[srcNode].remote, fromlen) != 0) { ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_UNKNOWN, "Who Are You?"); ! return; ! } nodeTab[srcNode].heardFrom = tn.tv_sec; nodeTab[srcNode].idleCount = 0; nodeTab[srcNode].idleTimer = 0; *************** *** 432,441 **** } break; default: ! return(reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADRQST, "Unknown Request.")); break; } } /* --- 479,491 ---- } break; default: ! reply(&from, fromlen, srcNode, ARNS_ERROR, ! ERR_BADRQST, "Unknown Request."); ! return; break; } + + return; } /* *************** *** 467,473 **** case 0xf3: if (debug & AARPDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! aarp(buf); break; case 0x9b: if (thisNode == 0) --- 517,523 ---- case 0xf3: if (debug & AARPDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! aarp(buf, cc); break; case 0x9b: if (thisNode == 0) *************** *** 474,480 **** return; /* not init'd yet */ if (debug & ETHDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! ddp(buf); break; default: break; --- 524,530 ---- return; /* not init'd yet */ if (debug & ETHDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! ddp(buf, cc); break; default: break; *************** *** 490,506 **** return; /* not init'd yet */ if (debug & ETHDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! ddp(buf); } else { if ((buf[17]==0x00) && (buf[18]==0x00) && (buf[19]==0x00) && (buf[20]==0x80) && (buf[21]==0xF3)) { if (debug & AARPDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! aarp(buf); } } } } } /* --- 540,558 ---- return; /* not init'd yet */ if (debug & ETHDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! ddp(buf, cc); } else { if ((buf[17]==0x00) && (buf[18]==0x00) && (buf[19]==0x00) && (buf[20]==0x80) && (buf[21]==0xF3)) { if (debug & AARPDEBUG) fprintf(stderr, "DEV%d: read %d bytes\n", phase, cc); ! aarp(buf, cc); } } } } + + return; } /* *************** *** 529,535 **** if (debug & ETHDEBUG) fprintf(stderr, "ETH%d: read %d bytes\n", phase, cc); ! ddp(buf); } /* --- 581,589 ---- if (debug & ETHDEBUG) fprintf(stderr, "ETH%d: read %d bytes\n", phase, cc); ! ddp(buf, cc); ! ! return; } /* *************** *** 555,561 **** if (debug & AARPDEBUG) fprintf(stderr, "AARP: read %d bytes\n", cc); ! aarp(buf); } /* --- 609,617 ---- if (debug & AARPDEBUG) fprintf(stderr, "AARP: read %d bytes\n", cc); ! aarp(buf, cc); ! ! return; } /* *************** *** 564,576 **** * */ ! int replyNetInfo(from, fromlen, node) struct sockaddr *from; ! int fromlen; { int len; u_char buf[128]; if (thisNode == 0) /* not init'd yet */ return; --- 620,633 ---- * */ ! void replyNetInfo(from, fromlen, node) struct sockaddr *from; ! int fromlen, node; { int len; u_char buf[128]; + void registerUser(); if (thisNode == 0) /* not init'd yet */ return; *************** *** 581,587 **** buf[3] = CONN_NETINFO; /* type */ buf[4] = thisNet >> 8; ! buf[5] = thisNet&0xff; buf[6] = bridgeNode; buf[7] = node; --- 638,644 ---- buf[3] = CONN_NETINFO; /* type */ buf[4] = thisNet >> 8; ! buf[5] = thisNet & 0xff; buf[6] = bridgeNode; buf[7] = node; *************** *** 594,604 **** return; } - registerUser(from, node); - if (debug & IPDEBUG) fprintf(stderr, "ILAP: Reply %02x/%02x to node %02x, net %02x%02x\n", buf[0], buf[3], buf[1], buf[4], buf[5]); } /* --- 651,663 ---- return; } if (debug & IPDEBUG) fprintf(stderr, "ILAP: Reply %02x/%02x to node %02x, net %02x%02x\n", buf[0], buf[3], buf[1], buf[4], buf[5]); + + registerUser(from, node); + + return; } /* *************** *** 607,613 **** * */ ! int reply(from, fromlen, node, typ, err, msg) struct sockaddr *from; int fromlen, typ, err; --- 666,672 ---- * */ ! void reply(from, fromlen, node, typ, err, msg) struct sockaddr *from; int fromlen, typ, err; *************** *** 616,621 **** --- 675,681 ---- { int len; u_char buf[128]; + void record(); if (thisNode == 0) /* not init'd yet */ return; *************** *** 637,648 **** return; } - if (verbose) - record(LOG_MESSAGE, from, node, msg); - if (debug & IPDEBUG) fprintf(stderr, "ILAP: Reply %02x/%02x to node %02x, message: %s\n", buf[0], buf[3], buf[1], buf+4); } /* --- 697,710 ---- return; } if (debug & IPDEBUG) fprintf(stderr, "ILAP: Reply %02x/%02x to node %02x, message: %s\n", buf[0], buf[3], buf[1], buf+4); + + if (verbose) + record(LOG_MESSAGE, from, node, msg); + + return; } /* *************** *** 681,686 **** --- 743,749 ---- { char *user; struct passwd *pw; + void munge(); switch ((*data++)) { case PASS_NONE: *************** *** 705,718 **** return(1); break; } } ! int munge(q) char *q; { for ( ; *q != '\0' ; q++) *q = *q ^ 0x15; } /* --- 768,785 ---- return(1); break; } + + return(1); } ! void munge(q) char *q; { for ( ; *q != '\0' ; q++) *q = *q ^ 0x15; + + return; } /* *************** *** 728,734 **** "(Unkn)" }; ! int record(typ, from, node, msg) int typ; struct sockaddr_in *from; --- 795,801 ---- "(Unkn)" }; ! void record(typ, from, node, msg) int typ; struct sockaddr_in *from; *************** *** 774,779 **** --- 841,848 ---- } fflush(log); } + + return; } /* *************** *** 803,808 **** --- 872,878 ---- } strncpy(name, (char *)inet_ntoa(from->sin_addr), sizeof(name)); + return(name); } *************** *** 811,817 **** * */ ! int buildIPFilterList() { FILE *fd; --- 881,887 ---- * */ ! void buildIPFilterList() { FILE *fd; *************** *** 849,854 **** --- 919,926 ---- fclose(fd); } needIPFilter = 0; + + return; } /* *************** *** 971,983 **** if (debug & IPDEBUG) { fprintf(stderr, "ILAP: writing %d bytes to %02x\n", len, dstNode); ! for (i = 0; i < len; i++) { ! fprintf(stderr, "%02x ", pkt[i]); ! if ((i+1) % 16 == 0) ! fprintf(stderr, "\n"); ! } ! fprintf(stderr, "\n"); } } /* --- 1043,1053 ---- if (debug & IPDEBUG) { fprintf(stderr, "ILAP: writing %d bytes to %02x\n", len, dstNode); ! if (debug & PKTDEBUG) ! dumppacket(pkt, len); } + + return; } /* *************** *** 1006,1011 **** --- 1076,1083 ---- initNode(node) int node; { + void aarpQueue(); + if (node < 1 || node > 254) { if (debug) fprintf(stderr, "Node %02x unavailable\n", node); exit(1); *************** *** 1045,1055 **** * */ ! int process() { int i, j; void aarpLookUp(); static int rtmpTimer = 0; static int infoCount = 5; --- 1117,1131 ---- * */ ! void process() { int i, j; + void record(); void aarpLookUp(); + void sendGetNetInfo(); + void reply(), replyNetInfo(); + void nbpLkUp(), echoRequest(); static int rtmpTimer = 0; static int infoCount = 5; *************** *** 1202,1211 **** * Adopted bridge still alive ? * */ ! if (tn.tv_sec > brHeardFrom+30) { bridgeNode = 0; - bridgeNet = 0; - } /* * RTMP (every 10 seconds) --- 1278,1285 ---- * Adopted bridge still alive ? * */ ! if (tn.tv_sec > brHeardFrom+30) bridgeNode = 0; /* * RTMP (every 10 seconds) *************** *** 1229,1232 **** --- 1303,1339 ---- infoTimer = 1; } } + + return; + } + + /* + * display packet content in hex and ascii + * + */ + + int + dumppacket(pkt, len) + u_char *pkt; + int len; + { + int i, j; + u_char line[16]; + + for (i = 0, j = 0; i < len; i++) { + fprintf(stderr, "%02x ", (line[j++] = pkt[i])); + if ((i+1) % 16 == 0 || (i+1) == len) { + while (j < 16) { + fprintf(stderr, " "); + line[j++] = ' '; + } + fprintf(stderr, " "); + for (j = 0; j < 16; j++) + fprintf(stderr, "%c", (isprint(line[j])) ? line[j] : '.'); + fprintf(stderr, "\n"); + j = 0; + } + } + + return(1); } *** arns.h.orig Tue Mar 9 20:40:21 1993 --- arns.h Sat May 1 23:50:54 1993 *************** *** 5,22 **** * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * ! * This software is supplied "as is" without express ! * or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.7 $ * */ --- 5,21 ---- * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * ! * This software is supplied "as is" without express or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.8 $ * */ *************** *** 73,80 **** --- 72,81 ---- #define NBPIDENT 0x01 /* client NBP lookup ID */ + #define NBPBRREQ 0x01 /* NBP broadcast request */ #define NBPLKUPREQ 0x02 /* NBP lookup request packet */ #define NBPLKUPREPLY 0x03 /* NBP lookup reply packet */ + #define NBPFWDREQ 0x04 /* NBP forward request */ #define nbpEquals '=' #define nbpWild 0xc5 *************** *** 95,101 **** #define RTMP 0x01 #define NBP 0x02 #define ATP 0x03 ! #define AEP 0x04 #define RTMPR 0x05 #define ZIP 0x06 #define ADSP 0x07 --- 96,102 ---- #define RTMP 0x01 #define NBP 0x02 #define ATP 0x03 ! #define AEP 0x04 #define RTMPR 0x05 #define ZIP 0x06 #define ADSP 0x07 *** arnsrd.c.orig Wed Mar 10 22:26:09 1993 --- arnsrd.c Sat May 1 23:50:57 1993 *************** *** 10,27 **** * An arnsrd is started by inetd(8) for each incoming request. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * ! * This software is supplied "as is" without express ! * or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.2 $ * */ --- 10,26 ---- * An arnsrd is started by inetd(8) for each incoming request. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * ! * This software is supplied "as is" without express or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.3 $ * */ *************** *** 54,59 **** --- 53,59 ---- #define PORTBEGIN 10000 /* range for UDP port binding */ #define PORTEND 12000 /* range for UDP port binding */ + main(argc, argv, envp) int argc; char *argv[]; *************** *** 74,80 **** extern int optind, opterr; struct sockaddr_in from; struct hostent *h, *gethostbyaddr(); ! struct servent *s, *getservbyname(); tcpfd = 0; --- 74,82 ---- extern int optind, opterr; struct sockaddr_in from; struct hostent *h, *gethostbyaddr(); ! struct servent *s, *getservbyname(); ! void sendLinkOK(), buildIPFilterList(); ! void doUDPRead(), doTCPRead(), updateInfo(); tcpfd = 0; *************** *** 193,200 **** FD_SET(tcpfd, &readfds); FD_SET(udpfd, &readfds); ! if ((res = select(nfds, &readfds, (fd_set *) 0, (fd_set *) 0, ! (struct timeval *) &timeout)) >= 0) { if (FD_ISSET(tcpfd, &readfds)) doTCPRead(tcpfd); if (FD_ISSET(udpfd, &readfds)) --- 195,202 ---- FD_SET(tcpfd, &readfds); FD_SET(udpfd, &readfds); ! if ((res = select(nfds, &readfds, (fd_set *)0, (fd_set *)0, ! (struct timeval *)&timeout)) >= 0) { if (FD_ISSET(tcpfd, &readfds)) doTCPRead(tcpfd); if (FD_ISSET(udpfd, &readfds)) *************** *** 216,222 **** * */ ! int doTCPRead(fd) int fd; { --- 218,224 ---- * */ ! void doTCPRead(fd) int fd; { *************** *** 246,251 **** --- 248,255 ---- (struct sockaddr *)&sin, sizeof(sin)); pktsin++; } + + return; } /* *************** *** 254,260 **** * */ ! int doUDPRead(fd) int fd; { --- 258,264 ---- * */ ! void doUDPRead(fd) int fd; { *************** *** 264,270 **** return; obuf[0] = len >> 8; ! obuf[1] = len&0xff; len += 2; --- 268,274 ---- return; obuf[0] = len >> 8; ! obuf[1] = len & 0xff; len += 2; *************** *** 277,282 **** --- 281,288 ---- cleanup(); /* must have died */ pktsout++; + + return; } /* *************** *** 284,294 **** * */ ! int buildIPFilterList() { FILE *fd; ! char *q, line[160]; if (filter != NULL) { if ((fd = fopen(filter, "r")) == NULL) { --- 290,301 ---- * */ ! void buildIPFilterList() { FILE *fd; ! char line[160]; ! char *mask, *addr; if (filter != NULL) { if ((fd = fopen(filter, "r")) == NULL) { *************** *** 299,312 **** while (fgets(line, sizeof(line), fd) != NULL) { if (line[0] == '#') continue; ! if ((q = (char *) index(line, '\n')) != NULL) ! *q = '\0'; ! q = line+1; ! while (*q != '\0' && isspace(*q)) ! q++; ! if (line[0] == '+' || line[0] == '-') { ! ipFilter[filters].perm = (line[0] == '-'); ! ipFilter[filters].addr = inet_addr(q); if (++filters >= MAXFILTERS) break; } --- 306,325 ---- while (fgets(line, sizeof(line), fd) != NULL) { if (line[0] == '#') continue; ! if ((mask = (char *) index(line, '\n')) != NULL) ! *mask = '\0'; ! mask = line+1; ! while (*mask != '\0' && isspace(*mask)) ! mask++; /* skip spaces */ ! addr = mask; ! while (*addr != '\0' && !isspace(*addr)) ! addr++; /* skip mask */ ! while (*addr != '\0' && isspace(*addr)) ! addr++; /* skip spaces */ ! if (line[0] == '+' || line[0] == '*' || line[0] == '-') { ! ipFilter[filters].perm = line[0]; ! ipFilter[filters].addr = (*addr == '\0') ? 0L : inet_addr(addr); ! ipFilter[filters].mask = (*mask == '\0') ? 0L : inet_addr(mask); if (++filters >= MAXFILTERS) break; } *************** *** 313,318 **** --- 326,333 ---- } fclose(fd); } + + return; } /* *************** *** 326,339 **** int fromlen; { int i; if (filters == 0) return(0); ! for (i = 0 ; i < filters ; i++) ! if ((sin->sin_addr.s_addr & ipFilter[i].addr) == sin->sin_addr.s_addr) ! return(ipFilter[i].perm); return(0); } --- 341,363 ---- int fromlen; { int i; + unsigned long addr; if (filters == 0) return(0); ! addr = sin->sin_addr.s_addr; + for (i = 0 ; i < filters ; i++) { + if (ipFilter[i].addr != 0L) { + if ((addr & ipFilter[i].mask) == ipFilter[i].addr) + return(ipFilter[i].perm == '-'); + } else { + if ((addr & ipFilter[i].mask) == addr) + return(ipFilter[i].perm == '-'); + } + } + return(0); } *************** *** 342,348 **** * */ ! int sendLinkOK() { int fromLen; --- 366,372 ---- * */ ! void sendLinkOK() { int fromLen; *************** *** 363,368 **** --- 387,394 ---- /* get name binding & send sockaddr_in */ if (getsockname(udpfd, (struct sockaddr *)(buf+6), &fromLen) == 0) write(tcpfd, buf, fromLen+6); + + return; } /* *************** *** 370,382 **** * */ ! int disconnect() { u_char buf[32]; if (clntNode == 0) ! return(-1); buf[0] = ARNS_CONNECT; buf[1] = srvrNode; --- 396,408 ---- * */ ! void disconnect() { u_char buf[32]; if (clntNode == 0) ! return; buf[0] = ARNS_CONNECT; buf[1] = srvrNode; *************** *** 383,389 **** buf[2] = clntNode; buf[3] = CONN_DISCONN; ! return(sendto(udpfd, buf, 4, 0, (struct sockaddr *)&sin, sizeof(sin))); } /* --- 409,417 ---- buf[2] = clntNode; buf[3] = CONN_DISCONN; ! sendto(udpfd, buf, 4, 0, (struct sockaddr *)&sin, sizeof(sin)); ! ! return; } /* *************** *** 392,398 **** * */ ! int updateInfo() { char *p, *q; --- 420,426 ---- * */ ! void updateInfo() { char *p, *q; *************** *** 413,418 **** --- 441,448 ---- while (q < ep) *q++ = ' '; + + return; } /* *************** *** 435,440 **** --- 465,471 ---- return(str); } sprintf(str,"%dh%dm%ds",period/3600,(period%3600)/60,(period%3600)%60); + return(str); } *************** *** 453,458 **** --- 484,491 ---- cleanup() #endif /* SYSTYPE_SYSV */ { + void disconnect(); + disconnect(); close(udpfd); close(tcpfd); *** ddp.c.orig Tue Mar 9 19:29:21 1993 --- ddp.c Sat May 1 23:51:01 1993 *************** *** 5,22 **** * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * ! * This software is supplied "as is" without express ! * or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.6 $ * */ --- 5,21 ---- * EtherTalk network using IP as the transport layer. * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * ! * This software is supplied "as is" without express or implied warranty. * * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.7 $ * */ *************** *** 28,37 **** u_char maddr[] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff }; /* multicast */ u_char zaddr[] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff }; /* zone m/cast */ - u_char thisNode = 0; u_short thisNet = 0; u_char bridgeNode = 0; - u_short bridgeNet = 0; int zipinited = 1; char *thisZone = "*"; --- 27,35 ---- u_char maddr[] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff }; /* multicast */ u_char zaddr[] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff }; /* zone m/cast */ u_short thisNet = 0; + u_char thisNode = 0; u_char bridgeNode = 0; int zipinited = 1; char *thisZone = "*"; *************** *** 54,61 **** */ void ! ddp(buf) register u_char *buf; { register u_char *pkt, ddpType; u_char *addr, srcNode, dstNode, lapType, *ethType; --- 52,60 ---- */ void ! ddp(buf, pktLen) register u_char *buf; + int pktLen; { register u_char *pkt, ddpType; u_char *addr, srcNode, dstNode, lapType, *ethType; *************** *** 63,68 **** --- 62,70 ---- u_short srcNet, dstNet; int len; + if (debug & PKTDEBUG) + dumppacket(buf, pktLen); + addr = buf+6; /* ethernet source */ if (bcmp(eaddr, addr, 6) == 0) { *************** *** 157,164 **** * anything else goes via the default router). * */ ! ! if (srcNet == bridgeNet && srcNode == bridgeNode) { bcopy(addr, raddr, 6); /* update default router */ if (debug & AARPDEBUG) { fprintf(stderr,"aarp: node %02x %02x:%02x:%02x:%02x:%02x:%02x br\n", --- 159,165 ---- * anything else goes via the default router). * */ ! if (srcNet == thisNet && srcNode == bridgeNode) { bcopy(addr, raddr, 6); /* update default router */ if (debug & AARPDEBUG) { fprintf(stderr,"aarp: node %02x %02x:%02x:%02x:%02x:%02x:%02x br\n", *************** *** 171,177 **** * don't glean from RTMP, NBP, ZIP or broadcasts * */ - if (dstNode == BCAST) return; --- 172,177 ---- *************** *** 195,204 **** } } } } /* ! * select the "best" router based on the number of nets it can route to. * */ --- 195,207 ---- } } } + + return; } /* ! * select the "best" router on 'thisNet' based on the number ! * of nets it can route to. * */ *************** *** 219,224 **** --- 222,229 ---- static u_char lastNode = 0; static u_short lastNet = 0; static int router_goodness = -1; + void sendGetNetInfo(); + void routeIP(); if (dstNode != BCAST) { /* a directed packet */ routeIP(pkt, len, dstNode, srcNode, lapType); *************** *** 227,232 **** --- 232,238 ---- data = pkt+5; len = len-5; + if (lapType == LDDP) { data += 8; len -= 8; *************** *** 251,259 **** break; } - if (bridgeNet == 0) - bridgeNet = net; - if (phase == PHASE2) if (!(data[4] == 0x00 && data[5] == 0x00 && data[6] == 0x82)) tupleLen = 6; --- 257,262 ---- *************** *** 266,271 **** --- 269,277 ---- if (debug & RTMPDEBUG) fprintf(stderr,"RTMP: Router %02x/%04x: %d tuples\n",node,net,tuples); + if (net != thisNet) + return; + #define MARGIN(x) (x/20) /* 5% */ if ((tuples > (router_goodness+MARGIN(router_goodness))) *************** *** 272,278 **** || (now > brHeardFrom+15)) { router_goodness = tuples; bridgeNode = node; - bridgeNet = net; /* new bridge, may have to re-init */ if (phase == PHASE2 && !zipinited) --- 278,283 ---- *************** *** 282,288 **** fprintf(stderr,"RTMP: NEW default Router %02x/%04x\n",node,net); } ! if (net == bridgeNet && node == bridgeNode) brHeardFrom = now; lastNet = net; --- 287,293 ---- fprintf(stderr,"RTMP: NEW default Router %02x/%04x\n",node,net); } ! if (node == bridgeNode) brHeardFrom = now; lastNet = net; *************** *** 289,294 **** --- 294,301 ---- lastNode = node; lastTuples = tuples; lastTime = now; + + return; } /* *************** *** 311,316 **** --- 318,328 ---- u_short dstNet; u_short TID; int atp_ctrl; + void dummyRTMP(); + void DDPWrite(); + void gmzReply(); + void cacheNBP(); + void routeIP(); void nbp(); if (debug & ROUTEDEBUG) *************** *** 351,367 **** * (IE: avoid the flood of responses from lots of routers) * */ ! if (ddpType == RTMPR && dNode == BCAST) { dummyRTMP(srcNode); return; } /* ! * also send broadcast NBP packets to ARNS server process * */ ! if (ddpType == NBP && dNode == BCAST) ! nbp(pkt, len, dstNode, srcNode, lapType); #define TRELMIN TREL120 /* two minute timeout */ --- 363,383 ---- * (IE: avoid the flood of responses from lots of routers) * */ ! if (ddpType == RTMPR ! && dNode == BCAST) { dummyRTMP(srcNode); return; } /* ! * NBP activity, do cache lookup sooner * */ ! if (ddpType == NBP ! && ((pkt[atp_ctrl] >> 4) == NBPBRREQ ! || (pkt[atp_ctrl] >> 4) == NBPLKUPREQ)) ! if (nodeTab[srcNode].nbpTimer > 50) ! nodeTab[srcNode].nbpTimer = 50; #define TRELMIN TREL120 /* two minute timeout */ *************** *** 370,383 **** * */ if (ddpType == ATP ! && (pkt[atp_ctrl] & XO) == XO ! && (pkt[atp_ctrl] & FNMSK) == TREQ ! && (pkt[atp_ctrl] & TRELMSK) < TRELMIN) { ! pkt[atp_ctrl] = ((pkt[atp_ctrl] & ~TRELMSK) | TRELMIN); ! if (lapType == LDDP) { /* nuke checksum */ ! pkt[2] = 0x00; ! pkt[3] = 0x00; ! } } /* --- 386,399 ---- * */ if (ddpType == ATP ! && (pkt[atp_ctrl] & XO) == XO ! && (pkt[atp_ctrl] & FNMSK) == TREQ ! && (pkt[atp_ctrl] & TRELMSK) < TRELMIN) { ! pkt[atp_ctrl] = ((pkt[atp_ctrl] & ~TRELMSK) | TRELMIN); ! if (lapType == LDDP) { /* nuke checksum */ ! pkt[2] = 0x00; ! pkt[3] = 0x00; ! } } /* *************** *** 385,392 **** * I *really* wish I didn't have to do this ... * */ ! ! if (phase == PHASE1 && ddpType == ATP && dstSkt == ZIP && (pkt[atp_ctrl] & FNMSK) == TREQ && (pkt[atp_ctrl+1] == 0x01) && (pkt[atp_ctrl+4] == GETLOCALZONES)) { --- 401,408 ---- * I *really* wish I didn't have to do this ... * */ ! if (ddpType == ATP ! && phase == PHASE1 && dstSkt == ZIP && (pkt[atp_ctrl] & FNMSK) == TREQ && (pkt[atp_ctrl+1] == 0x01) && (pkt[atp_ctrl+4] == GETLOCALZONES)) { *************** *** 399,405 **** * handle some special case phase 2 packets internally * */ ! if (phase == PHASE2 && dstNet == bridgeNet && dNode == bridgeNode) if (handlePhase2(pkt, &len, dstNode, srcNode, lapType)) return; /* no more processing required */ --- 415,421 ---- * handle some special case phase 2 packets internally * */ ! if (phase == PHASE2 && dstNet == thisNet && dNode == bridgeNode) if (handlePhase2(pkt, &len, dstNode, srcNode, lapType)) return; /* no more processing required */ *************** *** 425,433 **** if (lapType == LDDP) { pkt[2] = 0x00; /* nuke checksum */ pkt[3] = 0x00; /* nuke checksum */ ! pkt[4] = bridgeNet >> 8; ! pkt[5] = bridgeNet&0xff; ! pkt[8] = bridgeNode; } DDPWrite(pkt, len, bridgeNode, srcNode, lapType, raddr); return; --- 441,449 ---- if (lapType == LDDP) { pkt[2] = 0x00; /* nuke checksum */ pkt[3] = 0x00; /* nuke checksum */ ! pkt[4] = thisNet >> 8; ! pkt[5] = thisNet & 0xff; ! pkt[8] = thisNode; } DDPWrite(pkt, len, bridgeNode, srcNode, lapType, raddr); return; *************** *** 469,475 **** */ if (dstNode == BCAST) { if (dstNet == thisNet) { ! if (ddpType != NBP) routeIP(pkt, len, dstNode, srcNode, lapType); DDPWrite(pkt, len, dstNode, srcNode, lapType, (phase == 1) ? baddr : ((ddpType == NBP) ? zaddr : maddr)); --- 485,493 ---- */ if (dstNode == BCAST) { if (dstNet == thisNet) { ! if (ddpType == NBP) ! nbp(pkt, len, dstNode, srcNode, lapType); ! else routeIP(pkt, len, dstNode, srcNode, lapType); DDPWrite(pkt, len, dstNode, srcNode, lapType, (phase == 1) ? baddr : ((ddpType == NBP) ? zaddr : maddr)); *************** *** 482,487 **** --- 500,507 ---- * */ DDPWrite(pkt, len, bridgeNode, srcNode, lapType, raddr); + + return; } /* *************** *** 489,495 **** * */ ! int DDPWrite(pkt, len, dstNode, srcNode, lapType, addr) register u_char *pkt, *addr; int len, dstNode, srcNode, lapType; --- 509,515 ---- * */ ! void DDPWrite(pkt, len, dstNode, srcNode, lapType, addr) register u_char *pkt, *addr; int len, dstNode, srcNode, lapType; *************** *** 532,538 **** len += 8; } buf[12] = len >> 8; ! buf[13] = len&0xff; buf[14] = 0xaa; /* 802.2 header */ buf[15] = 0xaa; /* 802.2 header */ buf[16] = 0x03; /* 802.2 header */ --- 552,558 ---- len += 8; } buf[12] = len >> 8; ! buf[13] = len & 0xff; buf[14] = 0xaa; /* 802.2 header */ buf[15] = 0xaa; /* 802.2 header */ buf[16] = 0x03; /* 802.2 header */ *************** *** 545,557 **** /* convert to long DDP */ lapType = LDDP; pkt[0] = (len-8) >> 8; ! pkt[1] = (len-8)&0xff; pkt[2] = 0x00; /* no chksum */ pkt[3] = 0x00; /* no chksum */ pkt[4] = thisNet >> 8; ! pkt[5] = thisNet&0xff; pkt[6] = thisNet >> 8; ! pkt[7] = thisNet&0xff; pkt[8] = dstNode; pkt[9] = srcNode; } --- 565,577 ---- /* convert to long DDP */ lapType = LDDP; pkt[0] = (len-8) >> 8; ! pkt[1] = (len-8) & 0xff; pkt[2] = 0x00; /* no chksum */ pkt[3] = 0x00; /* no chksum */ pkt[4] = thisNet >> 8; ! pkt[5] = thisNet & 0xff; pkt[6] = thisNet >> 8; ! pkt[7] = thisNet & 0xff; pkt[8] = dstNode; pkt[9] = srcNode; } *************** *** 579,594 **** } if (debug & ROUTEDEBUG) { ! fprintf(stderr, "DDP%d: writing\n", phase); ! if (debug & PKTDEBUG) { ! for (i = 0; i < len; i++) { ! fprintf(stderr, "%02x ", buf[i]); ! if ((i+1) % 16 == 0) ! fprintf(stderr, "\n"); ! } ! fprintf(stderr, "\n"); ! } } } /* --- 599,610 ---- } if (debug & ROUTEDEBUG) { ! fprintf(stderr, "DDP%d: writing %d bytes\n", phase, len); ! if (debug & PKTDEBUG) ! dumppacket(buf, len); } + + return; } /* *************** *** 596,611 **** * */ ! int dummyRTMP(dstNode) int dstNode; { static u_char len = 0; static u_char buf[32]; if (bridgeNode == 0) return; if (len == 0) { len = 12; --- 612,631 ---- * */ ! void dummyRTMP(dstNode) int dstNode; { static u_char len = 0; static u_char buf[32]; + void routeIP(); if (bridgeNode == 0) return; + if (thisNet == 0) + return; + if (len == 0) { len = 12; *************** *** 621,636 **** buf[11] = IDLEN; /* ID length */ buf[15] = 0x00; /* distance */ } ! buf[9] = bridgeNet >> 8; ! buf[10] = bridgeNet&0xff; buf[12] = bridgeNode; - buf[13] = bridgeNet >> 8; - buf[14] = bridgeNet&0xff; if (debug & RTMPDEBUG) fprintf(stderr, "RTMP: Dummy to %02x/%04x\n", dstNode, thisNet); routeIP(buf+4, len, dstNode, bridgeNode, SDDP); } /* --- 641,658 ---- buf[11] = IDLEN; /* ID length */ buf[15] = 0x00; /* distance */ } ! buf[9] = thisNet >> 8; ! buf[10] = thisNet & 0xff; ! buf[13] = thisNet >> 8; ! buf[14] = thisNet & 0xff; buf[12] = bridgeNode; if (debug & RTMPDEBUG) fprintf(stderr, "RTMP: Dummy to %02x/%04x\n", dstNode, thisNet); routeIP(buf+4, len, dstNode, bridgeNode, SDDP); + + return; } /* *************** *** 638,649 **** * */ ! int echoRequest(dstNode) int dstNode; { static u_char len = 0; static u_char buf[32]; if (len == 0) { len = strlen(ECHOMSG) + 1; --- 660,672 ---- * */ ! void echoRequest(dstNode) int dstNode; { static u_char len = 0; static u_char buf[32]; + void routeIP(); if (len == 0) { len = strlen(ECHOMSG) + 1; *************** *** 667,672 **** --- 690,697 ---- fprintf(stderr, "ECHO: EchoReq to %02x/%04x\n", dstNode, thisNet); routeIP(buf+4, len, dstNode, thisNode, SDDP); + + return; } /* *************** *** 674,685 **** * */ ! int nbpLkUp(dstNode) int dstNode; { static u_char len = 0; static u_char buf[32]; if (len == 0) { len = 18; --- 699,711 ---- * */ ! void nbpLkUp(dstNode) int dstNode; { static u_char len = 0; static u_char buf[32]; + void routeIP(); if (len == 0) { len = 18; *************** *** 707,713 **** buf[21] = '*'; /* zone */ } buf[11] = thisNet >> 8; ! buf[12] = thisNet&0xff; buf[13] = thisNode; if (debug & NBPDEBUG) --- 733,739 ---- buf[21] = '*'; /* zone */ } buf[11] = thisNet >> 8; ! buf[12] = thisNet & 0xff; buf[13] = thisNode; if (debug & NBPDEBUG) *************** *** 714,719 **** --- 740,747 ---- fprintf(stderr, " NBP: LookUp to %02x/%04x\n", dstNode, thisNet); routeIP(buf+4, len, dstNode, thisNode, SDDP); + + return; } /* *************** *** 721,727 **** * */ ! int gmzReply(dstNode, srcNode, dstSkt, TID, lastFlag) u_char dstNode, srcNode, dstSkt, lastFlag; u_short TID; --- 749,755 ---- * */ ! void gmzReply(dstNode, srcNode, dstSkt, TID, lastFlag) u_char dstNode, srcNode, dstSkt, lastFlag; u_short TID; *************** *** 728,733 **** --- 756,762 ---- { u_char len; u_char buf[128]; + void routeIP(); len = strlen(thisZone); *************** *** 742,750 **** buf[6] = 0x00; /* checksum */ buf[7] = 0x00; /* checksum */ buf[8] = thisNet >> 8; ! buf[9] = thisNet&0xff; ! buf[10] = bridgeNet >> 8; ! buf[11] = bridgeNet&0xff; buf[12] = dstNode; /* dst node */ buf[13] = srcNode; /* src node */ buf[14] = dstSkt; /* dst socket */ --- 771,779 ---- buf[6] = 0x00; /* checksum */ buf[7] = 0x00; /* checksum */ buf[8] = thisNet >> 8; ! buf[9] = thisNet & 0xff; ! buf[10] = thisNet >> 8; ! buf[11] = thisNet & 0xff; buf[12] = dstNode; /* dst node */ buf[13] = srcNode; /* src node */ buf[14] = dstSkt; /* dst socket */ *************** *** 756,763 **** buf[17] = 0x90; /* TResp */ buf[18] = 0x00; /* Sequence no. */ buf[19] = TID >> 8; /* TID */ ! buf[20] = TID&0xff; /* TID */ ! buf[21] = lastFlag; /* must be zero */ buf[22] = 0x00; /* must be zero */ buf[23] = 0x00; /* tuple count */ buf[24] = 0x01; /* tuple count */ --- 785,792 ---- buf[17] = 0x90; /* TResp */ buf[18] = 0x00; /* Sequence no. */ buf[19] = TID >> 8; /* TID */ ! buf[20] = TID & 0xff; /* TID */ ! buf[21] = lastFlag; /* 0 GMZ, 1 GLZ */ buf[22] = 0x00; /* must be zero */ buf[23] = 0x00; /* tuple count */ buf[24] = 0x01; /* tuple count */ *************** *** 766,771 **** --- 795,802 ---- fprintf(stderr, " ZIP: GetMyZone reply %s\n", thisZone); routeIP(buf+4, len, dstNode, srcNode, LDDP); + + return; } /* *************** *** 773,779 **** * */ ! int sendGetNetInfo(dstNode) int dstNode; { --- 804,810 ---- * */ ! void sendGetNetInfo(dstNode) int dstNode; { *************** *** 780,785 **** --- 811,817 ---- u_char len; u_char *pkt; u_char buf[128]; + void routeDDP(); pkt = buf+HDRSZ; /* leave room to prepend headers */ *************** *** 796,804 **** pkt[2] = 0x00; /* checksum */ pkt[3] = 0x00; /* checksum */ pkt[4] = thisNet >> 8; ! pkt[5] = thisNet&0xff; pkt[6] = thisNet >> 8; ! pkt[7] = thisNet&0xff; pkt[8] = dstNode; pkt[9] = thisNode; pkt[10] = 0x06; /* ZIP socket */ --- 828,836 ---- pkt[2] = 0x00; /* checksum */ pkt[3] = 0x00; /* checksum */ pkt[4] = thisNet >> 8; ! pkt[5] = thisNet & 0xff; pkt[6] = thisNet >> 8; ! pkt[7] = thisNet & 0xff; pkt[8] = dstNode; pkt[9] = thisNode; pkt[10] = 0x06; /* ZIP socket */ *************** *** 820,825 **** --- 852,859 ---- zipinited = 0; /* want reply */ routeDDP(pkt, len, dstNode, thisNode, LDDP); + + return; } /* *************** *** 842,847 **** --- 876,882 ---- u_short rangeStart; u_short rangeEnd; static char defZone[34]; + void routeIP(); if (dstNode != BCAST && dstNode != thisNode) { routeIP(pkt, len, dstNode, srcNode, lapType); *************** *** 924,929 **** --- 959,966 ---- fprintf(stderr, " ZIP: zaddr %02x:%02x:%02x:%02x:%02x:%02x\n", zaddr[0],zaddr[1],zaddr[2],zaddr[3],zaddr[4],zaddr[5]); } + + return; } /* *************** *** 944,949 **** --- 981,987 ---- u_char dNode; u_char *zone; u_short TID; + void gmzReply(); switch (lapType) { case SDDP: /* short DDP */ *************** *** 997,1002 **** --- 1035,1042 ---- default: return(0); } + + return(0); } /* *************** *** 1004,1009 **** --- 1044,1050 ---- * */ + void cacheNBP(pkt, len, dstNode, srcNode, lapType) register u_char *pkt; int len, dstNode, srcNode, lapType; *************** *** 1014,1019 **** --- 1055,1061 ---- short function; short tupleCnt; short nbpIdent; + void insertTuple(); if (nodeTab[srcNode].connType != ARNS_IPLAP) return; *************** *** 1058,1063 **** --- 1100,1107 ---- insertTuple(d, o, t, t-d, 0); /* insert into list */ tupleCnt--; } + + return; } /* *************** *** 1066,1071 **** --- 1110,1116 ---- * */ + void insertTuple(tuple, obj, typ, tupleLen, perm) register u_char *tuple, *obj, *typ; int tupleLen, perm; *************** *** 1235,1240 **** --- 1280,1287 ---- register u_char *obj, *typ, *zon; u_char object[34], type[34], zone[34]; u_char *reqTuple; + void nbpReply(); + void routeIP(); if (dstNode != BCAST) { /* a directed packet */ routeIP(pkt, len, dstNode, srcNode, lapType); *************** *** 1374,1379 **** --- 1421,1428 ---- } q = p; p = p->next; } + + return; } /* *************** *** 1382,1387 **** --- 1431,1437 ---- * */ + void nbpReply(nbpIdent, reqTuple, repTuple, type, dNode, lapType) u_char nbpIdent, *reqTuple, *repTuple, *type; int dNode, lapType; *************** *** 1392,1397 **** --- 1442,1448 ---- u_char *p, *data; u_char dstNode; u_short dstNet; + void routeDDP(); len = 0; *************** *** 1423,1429 **** pkt[4] = reqTuple[0]; /* dst network */ pkt[5] = reqTuple[1]; /* dst network */ pkt[6] = thisNet >> 8; ! pkt[7] = thisNet&0xff; pkt[8] = dstNode; /* dst node */ pkt[9] = srcNode; /* src node */ pkt[10] = reqTuple[3]; /* dst socket */ --- 1474,1480 ---- pkt[4] = reqTuple[0]; /* dst network */ pkt[5] = reqTuple[1]; /* dst network */ pkt[6] = thisNet >> 8; ! pkt[7] = thisNet & 0xff; pkt[8] = dstNode; /* dst node */ pkt[9] = srcNode; /* src node */ pkt[10] = reqTuple[3]; /* dst socket */ *************** *** 1466,1471 **** --- 1517,1524 ---- fprintf(stderr, " NBP: replying to LkUp from %02x\n", dstNode); routeDDP(pkt, len, dNode, srcNode, lapType); + + return; } /* *************** *** 1474,1479 **** --- 1527,1533 ---- * */ + void registerUser(from, node) struct sockaddr_in *from; u_char node; *************** *** 1481,1493 **** char *object; char tuple[96]; char *hostname, *remotehost(); ! struct hostent *h, *gethostbyaddr(); if (from->sin_family != AF_INET) return; tuple[0] = thisNet >> 8; ! tuple[1] = thisNet&0xff; tuple[2] = node; tuple[3] = 0x04; /* ECHO */ tuple[4] = 0x00; /* enum */ --- 1535,1547 ---- char *object; char tuple[96]; char *hostname, *remotehost(); ! void insertTuple(); if (from->sin_family != AF_INET) return; tuple[0] = thisNet >> 8; ! tuple[1] = thisNet & 0xff; tuple[2] = node; tuple[3] = 0x04; /* ECHO */ tuple[4] = 0x00; /* enum */ *************** *** 1507,1512 **** --- 1561,1568 ---- *object = strlen(object+1); insertTuple(tuple, object, NBPTYPE, (*object)+6, 1); + + return; } /* *************** *** 1556,1561 **** --- 1612,1618 ---- } if (strcmpci((char *)pat, (char *)thing) != 0) return (0); + return (1); } *************** *** 1568,1585 **** strcmpci(s,t) register char *s,*t; { ! register char c,d; if (debug & NBPDEBUG) fprintf(stderr, " NBP: comparing :%s: to :%s:\n", s, t); ! for (;;) { ! c = *s++; ! if (isascii(c) && isupper(c)) ! c = tolower(c); ! d = *t++; ! if (isascii(d) && isupper(d)) ! d = tolower(d); if (c != d) return(c-d); if (c == '\0') --- 1625,1638 ---- strcmpci(s,t) register char *s,*t; { ! register char c, d; if (debug & NBPDEBUG) fprintf(stderr, " NBP: comparing :%s: to :%s:\n", s, t); ! for ( ; ; ) { ! c = mactolower(*s++); ! d = mactolower(*t++); if (c != d) return(c-d); if (c == '\0') *************** *** 1603,1618 **** fprintf(stderr, " NBP: comparing (%d) :%s: to :%s:\n", n, s, t); for ( ; n > 0 ; n--) { ! c = *s++; ! if (isascii(c) && isupper(c)) ! c = tolower(c); ! d = *t++; ! if (isascii(d) && isupper(d)) ! d = tolower(d); if (c != d) return(c-d); if (c == '\0') return(0); } return(0); } --- 1656,1729 ---- fprintf(stderr, " NBP: comparing (%d) :%s: to :%s:\n", n, s, t); for ( ; n > 0 ; n--) { ! c = mactolower(*s++); ! d = mactolower(*t++); if (c != d) return(c-d); if (c == '\0') return(0); } + return(0); + } + + /* + * map Macintosh uppercase characters to lowercase + * (Inside AppleTalk, 2nd Edition, Appendix D) + * + */ + + int + mactolower(c) + int c; + { + if (!(c & 0x80)) { + if (isupper(c)) + return(tolower(c)); + else + return(c); + } + + switch (c) { + case 0xcb: + return(0x88); + break; + case 0x80: + return(0x8a); + break; + case 0xcc: + return(0x8b); + break; + case 0x81: + return(0x8c); + break; + case 0x82: + return(0x8d); + break; + case 0x83: + return(0x8e); + break; + case 0x84: + return(0x96); + break; + case 0x85: + return(0x9a); + break; + case 0xcd: + return(0x9b); + break; + case 0x86: + return(0x9f); + break; + case 0xae: + return(0xbe); + break; + case 0xaf: + return(0xbf); + break; + case 0xce: + return(0xcf); + break; + } + return(c); } *** clients/README.orig Fri Nov 13 00:05:15 1992 --- clients/README Wed Apr 21 02:01:46 1993 *************** *** 118,125 **** NOTICE ! Copyright (c) 1992, The University of Melbourne. All rights reserved. ! Permission to redistribute or use any part of this software for any purpose ! other than as part of the ARNS distribution must be obtained in writing from ! the copyright owner. This software is supplied "as is" without express or ! implied warranty. May not be resold. --- 118,128 ---- NOTICE ! Copyright (c) 1992, The University of Melbourne. ! All Rights Reserved. Permission to publicly redistribute this package ! or to use any part of this software for any purpose, other than that ! intended by the original distribution, *must* be obtained in writing ! from the copyright owner. ! ! This software is supplied "as is" without express or implied warranty. ! May not be resold. *** clients/async.c.orig Tue Mar 9 19:19:38 1993 --- clients/async.c Sat May 1 23:52:20 1993 *************** *** 2,12 **** * A Remote Network Server (ARNS) client for Async AppleTalk adev * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * * djh@munnari.OZ.AU * * Use UDP for a local net connection, otherwise attempt to open --- 2,14 ---- * A Remote Network Server (ARNS) client for Async AppleTalk adev * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * + * This software is supplied "as is" without express or implied warranty. + * * djh@munnari.OZ.AU * * Use UDP for a local net connection, otherwise attempt to open *************** *** 14,20 **** * started on the ARNS server host by inetd(8)) * * $Author: djh $ ! * $Revision: 1.5 $ * * */ --- 16,22 ---- * started on the ARNS server host by inetd(8)) * * $Author: djh $ ! * $Revision: 1.6 $ * * */ *************** *** 121,126 **** --- 123,133 ---- #endif /* SYSTYPE_SYSV */ struct hostent *ho; struct passwd *pw; + void doAALAPRead(); + void doShellRead(); + void connectReq(); + void doUDPRead(); + void doTCPRead(); sifd = 0; sofd = 1; *************** *** 139,146 **** resetTTY = linkUp = serOpen = linkTest = FALSE; tcpOpen = TCP_UNUSED; ! while(--argc > 0 && (*++argv)[0] == '-') ! for(s = argv[0]+1 ; *s != '\0' ; s++) switch (*s) { case 'd': debug = TRUE; --- 146,153 ---- resetTTY = linkUp = serOpen = linkTest = FALSE; tcpOpen = TCP_UNUSED; ! while (--argc > 0 && (*++argv)[0] == '-') ! for (s = argv[0]+1 ; *s != '\0' ; s++) switch (*s) { case 'd': debug = TRUE; *************** *** 162,168 **** exit(1); } if (ho->h_length == 4 && ho->h_addrtype == AF_INET) ! bridgeIP = * (long *) ho->h_addr_list[0]; } if ((pw = getpwuid(getuid())) != NULL) { bcopy(pw->pw_name, usernm, strlen(pw->pw_name)+1); --- 169,175 ---- exit(1); } if (ho->h_length == 4 && ho->h_addrtype == AF_INET) ! bridgeIP = *(long *)ho->h_addr_list[0]; } if ((pw = getpwuid(getuid())) != NULL) { bcopy(pw->pw_name, usernm, strlen(pw->pw_name)+1); *************** *** 179,189 **** timeout.tv_sec = 15; timeout.tv_usec = 0; ! (void) signal(SIGHUP, cleanup); ! (void) signal(SIGINT, cleanup); ! (void) signal(SIGQUIT, cleanup); ! (void) signal(SIGTERM, cleanup); ! (void) signal(SIGALRM, linkerr); if ((udpfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { fprintf(stderr, "Couldn't open UDP socket\n"); --- 186,196 ---- timeout.tv_sec = 15; timeout.tv_usec = 0; ! (void)signal(SIGHUP, cleanup); ! (void)signal(SIGINT, cleanup); ! (void)signal(SIGQUIT, cleanup); ! (void)signal(SIGTERM, cleanup); ! (void)signal(SIGALRM, linkerr); if ((udpfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { fprintf(stderr, "Couldn't open UDP socket\n"); *************** *** 200,206 **** nfds = 16; ! for( ; ; ) { if (debug) fflush(dbg); FD_ZERO(&readfds); FD_SET(sifd, &readfds); --- 207,213 ---- nfds = 16; ! for ( ; ; ) { if (debug) fflush(dbg); FD_ZERO(&readfds); FD_SET(sifd, &readfds); *************** *** 210,217 **** if (serOpen) FD_SET(pty, &readfds); ! if ((res = select(nfds, &readfds, (fd_set *) 0, (fd_set *) 0, ! (struct timeval *) &timeout)) >= 0) { if (FD_ISSET(sifd, &readfds)) doAALAPRead(sifd); if (FD_ISSET(udpfd, &readfds)) --- 217,224 ---- if (serOpen) FD_SET(pty, &readfds); ! if ((res = select(nfds, &readfds, (fd_set *)0, (fd_set *)0, ! (struct timeval *)&timeout)) >= 0) { if (FD_ISSET(sifd, &readfds)) doAALAPRead(sifd); if (FD_ISSET(udpfd, &readfds)) *************** *** 233,239 **** * */ ! int doAALAPRead(fd) int fd; { --- 240,246 ---- * */ ! void doAALAPRead(fd) int fd; { *************** *** 242,251 **** u_char buf[1500]; u_char LAPType; u_char *data; len = read(fd, buf, sizeof(buf)); ! for(i = 0 ; i < len ; i++ ) { if (buf[i] == lastChar && buf[i] == FrameChar) { --- 249,261 ---- u_char buf[1500]; u_char LAPType; u_char *data; + void doSrvrWrite(); + void processSerial(); + void recvIM(), recvUR(); len = read(fd, buf, sizeof(buf)); ! for (i = 0 ; i < len ; i++) { if (buf[i] == lastChar && buf[i] == FrameChar) { *************** *** 379,384 **** --- 389,396 ---- dataLen = 0; } } + + return; } /* *************** *** 387,398 **** * */ ! int doUDPRead(fd) int fd; { int len; u_char buf[1024]; if ((len = read(fd, buf+8, sizeof(buf)-8)) == 0) return; --- 399,411 ---- * */ ! void doUDPRead(fd) int fd; { int len; u_char buf[1024]; + void processPkt(); if ((len = read(fd, buf+8, sizeof(buf)-8)) == 0) return; *************** *** 400,405 **** --- 413,420 ---- if (debug) fprintf(dbg, "UDP "); processPkt(buf, len); + + return; } /* *************** *** 411,417 **** * */ ! int doTCPRead(fd) int fd; { --- 426,432 ---- * */ ! void doTCPRead(fd) int fd; { *************** *** 420,425 **** --- 435,441 ---- static u_char *dataPtr = tbuf+8; static short dataLen = 0; static short pktLen = 0; + void processPkt(); if (dataLen == 0) { if ((len = read(fd, &dataLen, sizeof(short))) == sizeof(short)) { *************** *** 450,455 **** --- 466,473 ---- if (debug) fprintf(dbg, "TCP "); processPkt(tbuf, pktLen); } + + return; } /* *************** *** 460,466 **** * */ ! int processPkt(buf, len) u_char *buf; int len; --- 478,484 ---- * */ ! void processPkt(buf, len) u_char *buf; int len; *************** *** 468,477 **** int delay; short pktlen; char *p, *getpass(), *fgets(); pktsIn++; ! if(debug) { fprintf(dbg,"doSrvrRead: "); dumppacket(buf+8, len); } --- 486,503 ---- int delay; short pktlen; char *p, *getpass(), *fgets(); + void connectReq(), echoReq(); + void requestREDIR(); + void doAALAPWrite(); + void doLinkTest(); + void setUPTCPLink(); + void setUPTerm(); + void sendIMUR(); + void sendLT(); pktsIn++; ! if (debug) { fprintf(dbg,"doSrvrRead: "); dumppacket(buf+8, len); } *************** *** 565,571 **** if (delay > 0 && delay < 120) sendLT(delay & 0xffff); if (delay > 1 || useTCP) ! setUpTCPLink(); } return; } --- 591,597 ---- if (delay > 0 && delay < 120) sendLT(delay & 0xffff); if (delay > 1 || useTCP) ! setUPTCPLink(); } return; } *************** *** 600,605 **** --- 626,633 ---- } doAALAPWrite(buf+12, len-4, buf[11]); + + return; } /* *************** *** 609,620 **** * */ ! int doSrvrWrite(pkt, len, lapType) u_char *pkt; u_short len; u_char lapType; { if (ourNode == 0) /* not inited */ return; --- 637,650 ---- * */ ! void doSrvrWrite(pkt, len, lapType) u_char *pkt; u_short len; u_char lapType; { + void deliver(); + if (ourNode == 0) /* not inited */ return; *************** *** 633,638 **** --- 663,670 ---- } deliver(pkt-2, len); + + return; } /* *************** *** 640,646 **** * */ ! int connectReq(typ, node) u_char typ, node; { --- 672,678 ---- * */ ! void connectReq(typ, node) u_char typ, node; { *************** *** 647,652 **** --- 679,685 ---- int i,len; u_char *q; u_char pkt[32]; + void munge(), deliver(); q = pkt+2; /* leave room for our TCP hdr length bytes */ *************** *** 684,697 **** } deliver(pkt, len); } ! int munge(q) char *q; { ! for( ; *q != '\0' ; q++) *q = *q ^ 0x15; } /* --- 717,734 ---- } deliver(pkt, len); + + return; } ! void munge(q) char *q; { ! for ( ; *q != '\0' ; q++) *q = *q ^ 0x15; + + return; } /* *************** *** 699,705 **** * */ ! int echoReq(typ) u_char typ; { --- 736,742 ---- * */ ! void echoReq(typ) u_char typ; { *************** *** 706,711 **** --- 743,749 ---- int len; u_char *q; u_char pkt[32]; + void deliver(); q = pkt+2; /* leave room for our TCP hdr length bytes */ *************** *** 727,732 **** --- 765,772 ---- gettimeofday(&echoout, NULL); deliver(pkt, len); + + return; } /* *************** *** 734,740 **** * */ ! int deliver(pkt, len) u_char *pkt; short len; --- 774,780 ---- * */ ! void deliver(pkt, len) u_char *pkt; short len; *************** *** 759,764 **** --- 799,806 ---- if (debug) fprintf(dbg, "Server UDP write failed\n"); return; /* drop it, do nothing */ } + + return; } /* *************** *** 767,773 **** * */ ! int requestREDIR(dstNode, srcNode, addr) u_char dstNode; u_char srcNode; --- 809,815 ---- * */ ! void requestREDIR(dstNode, srcNode, addr) u_char dstNode; u_char srcNode; *************** *** 796,801 **** --- 838,845 ---- if (debug) fprintf(dbg, "Server UDP write failed\n"); return; /* drop it, do nothing */ } + + return; } /* *************** *** 803,809 **** * */ ! int recvIM(pkt, len, typ) u_char *pkt; int len; --- 847,853 ---- * */ ! void recvIM(pkt, len, typ) u_char *pkt; int len; *************** *** 810,815 **** --- 854,861 ---- u_char typ; { u_char node; + void connectReq(); + void sendIMUR(); node = pkt[2]; if (ourNode == 0) *************** *** 816,821 **** --- 862,869 ---- connectReq(CONN_REQUEST, node); else sendIMUR(URType); + + return; } /* *************** *** 823,829 **** * */ ! int recvUR(pkt, len, typ) u_char *pkt; int len; --- 871,877 ---- * */ ! void recvUR(pkt, len, typ) u_char *pkt; int len; *************** *** 831,836 **** --- 879,885 ---- { u_char node; u_short net; + void sendIMUR(); net = (pkt[0] << 8) | pkt[1]; node = pkt[2]; *************** *** 839,844 **** --- 888,895 ---- linkUp = TRUE; else sendIMUR(IMType); + + return; } /* *************** *** 846,856 **** * */ ! int sendIMUR(typ) u_char typ; { u_char buf[10]; if (debug) fprintf(dbg, "%s ", (typ == IMType) ? "IMType" : "URType"); --- 897,908 ---- * */ ! void sendIMUR(typ) u_char typ; { u_char buf[10]; + void doAALAPWrite(); if (debug) fprintf(dbg, "%s ", (typ == IMType) ? "IMType" : "URType"); *************** *** 860,865 **** --- 912,919 ---- buf[4] = (typ == IMType) ? bridgeNode : ourNode; doAALAPWrite(buf+2, 3, typ); + + return; } /* *************** *** 868,878 **** * */ ! int sendLT(delay) short delay; { u_char buf[10]; if (debug) fprintf(dbg, "LTType "); --- 922,933 ---- * */ ! void sendLT(delay) short delay; { u_char buf[10]; + void doAALAPWrite(); if (debug) fprintf(dbg, "LTType "); *************** *** 881,886 **** --- 936,943 ---- buf[3] = delay&0xff; doAALAPWrite(buf+2, 2, LTType); + + return; } /* *************** *** 888,894 **** * */ ! int doAALAPWrite(pkt, len, lapType) u_char *pkt; int len; --- 945,951 ---- * */ ! void doAALAPWrite(pkt, len, lapType) u_char *pkt; int len; *************** *** 926,932 **** /* body including CRC */ ! for(i = 2 ; i < len ; i++, q++) { switch (*q) { case FrameChar: case DLEChar: --- 983,989 ---- /* body including CRC */ ! for (i = 2 ; i < len ; i++, q++) { switch (*q) { case FrameChar: case DLEChar: *************** *** 950,955 **** --- 1007,1014 ---- /* send it */ write(sofd, obuf, j); + + return; } /* *************** *** 957,970 **** * */ ! int doShellRead(fd) int fd; { short len; u_char buf[518]; ! if((len = read(fd, buf+5, 512)) <= 0) return; len += 3; --- 1016,1030 ---- * */ ! void doShellRead(fd) int fd; { short len; u_char buf[518]; + void doAALAPWrite(); ! if ((len = read(fd, buf+5, 512)) <= 0) return; len += 3; *************** *** 974,985 **** buf[3] = len&0xff; buf[4] = SB_DATA; ! if(debug) { ! fprintf(dbg,"ShellRead: "); dumppacket(buf+2, len); } doAALAPWrite(buf+2, len, SERIALType); } /* --- 1034,1047 ---- buf[3] = len&0xff; buf[4] = SB_DATA; ! if (debug) { ! fprintf(dbg,"doShellRead: "); dumppacket(buf+2, len); } doAALAPWrite(buf+2, len, SERIALType); + + return; } /* *************** *** 987,993 **** * */ ! int processSerial(pkt, len, LAPType) u_char *pkt; int len; --- 1049,1055 ---- * */ ! void processSerial(pkt, len, LAPType) u_char *pkt; int len; *************** *** 1003,1009 **** switch (*(pkt+2)) { case SB_OPEN: ! if(serOpen) { write(pty, "exit\n", 5); close(pty); } --- 1065,1071 ---- switch (*(pkt+2)) { case SB_OPEN: ! if (serOpen) { write(pty, "exit\n", 5); close(pty); } *************** *** 1028,1033 **** --- 1090,1097 ---- default: break; } + + return; } /* *************** *** 1048,1054 **** char *line; char c; ! if(debug) fprintf(dbg, "Opening a Shell ...\n"); /* --- 1112,1118 ---- char *line; char c; ! if (debug) fprintf(dbg, "Opening a Shell ...\n"); /* *************** *** 1057,1072 **** */ pty = -1; ! for(c = 'p' ; c < 's' ; c++) { struct stat statb; line = "/dev/ptyZZ"; line[strlen("/dev/pty")] = c; line[strlen("/dev/ptyZ")] = '0'; ! if(stat(line, &statb) < 0) break; ! for(i = 0 ; i < 16 ; i++) { line[strlen("/dev/ptyZ")] = "0123456789abcdef"[i]; if ((pty = open(line, 2)) >= 0) break; --- 1121,1136 ---- */ pty = -1; ! for (c = 'p' ; c < 's' ; c++) { struct stat statb; line = "/dev/ptyZZ"; line[strlen("/dev/pty")] = c; line[strlen("/dev/ptyZ")] = '0'; ! if (stat(line, &statb) < 0) break; ! for (i = 0 ; i < 16 ; i++) { line[strlen("/dev/ptyZ")] = "0123456789abcdef"[i]; if ((pty = open(line, 2)) >= 0) break; *************** *** 1075,1081 **** break; } ! if(pty < 0) { if (debug) fprintf(dbg, "Failed to open pty\n"); return(0); --- 1139,1145 ---- break; } ! if (pty < 0) { if (debug) fprintf(dbg, "Failed to open pty\n"); return(0); *************** *** 1105,1111 **** line[strlen("/dev/")] = 't'; if ((tty = open(line, 2)) < 0) { ! if(debug) fprintf(dbg, "Failed to open tty\n"); exit(1); } --- 1169,1175 ---- line[strlen("/dev/")] = 't'; if ((tty = open(line, 2)) < 0) { ! if (debug) fprintf(dbg, "Failed to open tty\n"); exit(1); } *************** *** 1147,1154 **** ioctl(pty, FIONBIO, &on); /* non blocking */ ! (void) signal(SIGTSTP, SIG_IGN); ! (void) signal(SIGCHLD, funeral); return(1); } --- 1211,1218 ---- ioctl(pty, FIONBIO, &on); /* non blocking */ ! (void)signal(SIGTSTP, SIG_IGN); ! (void)signal(SIGCHLD, funeral); return(1); } *************** *** 1171,1186 **** #ifdef PARTPACKET ! if(len > 21) /* just enough to cover ATP header */ len = 21; #endif /* PARTPACKET */ ! for(i = 0, k = 0 ; i < len ; i++, q++) { fprintf(dbg, "%02x ", (*q & 0xff)); if (((i+1) % 16) == 0) { fprintf(dbg, "\n "); ! for(j = 0 ; j < 16 ; j++, k++, p++) fprintf(dbg, "%c ", (isprint(*p)) ? *p : '.'); fprintf(dbg, "\n "); } --- 1235,1250 ---- #ifdef PARTPACKET ! if (len > 21) /* just enough to cover ATP header */ len = 21; #endif /* PARTPACKET */ ! for (i = 0, k = 0 ; i < len ; i++, q++) { fprintf(dbg, "%02x ", (*q & 0xff)); if (((i+1) % 16) == 0) { fprintf(dbg, "\n "); ! for (j = 0 ; j < 16 ; j++, k++, p++) fprintf(dbg, "%c ", (isprint(*p)) ? *p : '.'); fprintf(dbg, "\n "); } *************** *** 1187,1193 **** } if (k < len) { fprintf(dbg, "\n "); ! for( ; k < len ; k++, p++) fprintf(dbg, "%c ", (isprint(*p)) ? *p : '.'); fprintf(dbg, "\n"); } --- 1251,1257 ---- } if (k < len) { fprintf(dbg, "\n "); ! for ( ; k < len ; k++, p++) fprintf(dbg, "%c ", (isprint(*p)) ? *p : '.'); fprintf(dbg, "\n"); } *************** *** 1218,1224 **** crc = 0; q = pkt; ! while(len-- > 0) { c = *q++; index = c ^ crc; index &= 0x0f; --- 1282,1288 ---- crc = 0; q = pkt; ! while (len-- > 0) { c = *q++; index = c ^ crc; index &= 0x0f; *************** *** 1232,1240 **** } if (debug) fprintf(dbg,"[%04x] ",crc&0xffff); ! result = (unsigned short) (crc & 0xffff); ! if(result == htons(result)) /* on a network byte order machine */ result = ((crc & 0xff00) >> 8) | ((crc & 0xff) << 8); return(result & 0xffff); } --- 1296,1305 ---- } if (debug) fprintf(dbg,"[%04x] ",crc&0xffff); ! result = (unsigned short)(crc & 0xffff); ! if (result == htons(result)) /* on a network byte order machine */ result = ((crc & 0xff00) >> 8) | ((crc & 0xff) << 8); + return(result & 0xffff); } *************** *** 1243,1249 **** * */ ! int setUPTerm() { /* --- 1308,1314 ---- * */ ! void setUPTerm() { /* *************** *** 1289,1294 **** --- 1354,1361 ---- } resetTTY = TRUE; + + return; } /* *************** *** 1297,1306 **** * */ ! int doLinkTest() { u_char ch; alarm(5); setUPTerm(); --- 1364,1374 ---- * */ ! void doLinkTest() { u_char ch; + void setUPTerm(); alarm(5); setUPTerm(); *************** *** 1314,1324 **** continue; break; } ! ch = (u_char) linkChar; write(sofd, &ch, 1); /* send */ read(sifd, &ch, 1); /* & wait */ ! if (ch != (u_char) linkChar) linkerr(); /* never returns */ alarm(5); --- 1382,1392 ---- continue; break; } ! ch = (u_char)linkChar; write(sofd, &ch, 1); /* send */ read(sifd, &ch, 1); /* & wait */ ! if (ch != (u_char)linkChar) linkerr(); /* never returns */ alarm(5); *************** *** 1327,1332 **** --- 1395,1402 ---- ch = 0x20; write(sofd, &ch, 1); write(sofd, "Link OK.\r\n", 10); + + return; } /* *************** *** 1335,1342 **** * */ ! int ! setUpTCPLink() { if (tcpOpen) return; --- 1405,1412 ---- * */ ! void ! setUPTCPLink() { if (tcpOpen) return; *************** *** 1343,1360 **** tin.sin_family = AF_INET; tin.sin_addr.s_addr = bridgeIP; ! tin.sin_port = (u_short) htons(ARNS_PORT); if ((tcpfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { tcpfd = -1; return; } if (connect(tcpfd, (struct sockaddr *)&tin, sizeof(tin)) < 0) { close(tcpfd); tcpfd = -1; return; } ! if (debug) fprintf(dbg, "TCP connection opened\n"); } /* --- 1413,1435 ---- tin.sin_family = AF_INET; tin.sin_addr.s_addr = bridgeIP; ! tin.sin_port = (u_short)htons(ARNS_PORT); if ((tcpfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { tcpfd = -1; return; } + if (connect(tcpfd, (struct sockaddr *)&tin, sizeof(tin)) < 0) { close(tcpfd); tcpfd = -1; return; } ! ! if (debug) ! fprintf(dbg, "TCP connection opened\n"); ! ! return; } /* *************** *** 1372,1377 **** --- 1447,1454 ---- cleanup() #endif /* SYSTYPE_SYSV */ { + void connectReq(); + /* * disconnect from server * *************** *** 1428,1433 **** --- 1505,1512 ---- sprintf(msgbuf, " Link Test failed at character: 0x%02x\r\n",linkChar); write(sofd, msgbuf, strlen(msgbuf)); cleanup(); + + return; } #if defined(SYSTYPE_SYSV) && !defined(__STRICT_BSD__) *************** *** 1447,1453 **** #endif /* SYSTYPE_SYSV */ serOpen = 0; ! while(wait3(&junk, WNOHANG, 0) > 0) ; close(pty); } --- 1526,1534 ---- #endif /* SYSTYPE_SYSV */ serOpen = 0; ! while (wait3(&junk, WNOHANG, 0) > 0) ; close(pty); + + return; } *** clients/async.h.orig Tue Mar 9 18:50:31 1993 --- clients/async.h Sat May 1 23:52:24 1993 *************** *** 2,12 **** * A Remote Network Server client for Async AppleTalk adev * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to redistribute ! * or use any part of this software for any purpose ! * other than as part of the ARNS distribution must ! * be obtained in writing from the copyright owner. * * djh@munnari.OZ.AU * * Use UDP for a local net connection, otherwise attempt to open --- 2,14 ---- * A Remote Network Server client for Async AppleTalk adev * * Copyright (c) 1992, The University of Melbourne. ! * All Rights Reserved. Permission to publicly redistribute this package ! * or to use any part of this software for any purpose, other than that ! * intended by the original distribution, *must* be obtained in writing ! * from the copyright owner. * + * This software is supplied "as is" without express or implied warranty. + * * djh@munnari.OZ.AU * * Use UDP for a local net connection, otherwise attempt to open *************** *** 14,20 **** * on the ARNS server host by INETD) * * $Author: djh $ ! * $Revision: 1.1 $ * * */ --- 16,22 ---- * on the ARNS server host by INETD) * * $Author: djh $ ! * $Revision: 1.2 $ * * */