Patch #: 2 Type: update Priority: medium Modification: changes to handle CAP services in other than default zone Archived: munnari.OZ.AU mac/cap.patches/uar.1.0.patch02 Application: 'cd uar; patch -p < uar.1.0.patch02' *** README.orig Tue Oct 26 19:11:04 1993 --- README Tue Oct 26 19:11:41 1993 *************** *** 4,10 **** The University of Melbourne djh@munnari.OZ.AU October, 1993 ! version 1.0.1 --- 4,10 ---- The University of Melbourne djh@munnari.OZ.AU October, 1993 ! version 1.0.2 *************** *** 90,95 **** --- 90,96 ---- zonelist unimelb-CompSci zonelist unimelb-Maths zonelist unimelb-Stats + zonename unimelb-Maths phase 2 cap on interface le1 *************** *** 102,108 **** There should be a "zonelist" entry for each of the zones on a Phase 2 network (including the default zone). NB: this is not the same as the full zone list for the entire network. The "zone" entry should contain ! the default zone name for the cable (CAP services appear in this zone). The "node" entry is optional. If not supplied, node numbers are assigned starting from 253 (for Phase 2 networks and 254 on Phase 1 networks). On --- 103,111 ---- There should be a "zonelist" entry for each of the zones on a Phase 2 network (including the default zone). NB: this is not the same as the full zone list for the entire network. The "zone" entry should contain ! the default zone name for the cable. CAP services will appear in the ! default zone unless explicitly set to one of the local cable zones with ! a "zonename" entry. The "node" entry is optional. If not supplied, node numbers are assigned starting from 253 (for Phase 2 networks and 254 on Phase 1 networks). On *************** *** 111,117 **** from the interface node number downwards. For this reason it is suggested that the node hint be chosen from the high end of the valid range (1-253). ! The configuration information in uar.conf *must* be identical to that configured into other routers for the local network. If the network range or default zone information in the usr.conf file does not match that of other routers on the network, UAR will write a PANIC message to a log file --- 114,120 ---- from the interface node number downwards. For this reason it is suggested that the node hint be chosen from the high end of the valid range (1-253). ! The configuration information in uar.conf *MUST* be identical to that configured into other routers for the local network. If the network range or default zone information in the usr.conf file does not match that of other routers on the network, UAR will write a PANIC message to a log file *************** *** 212,218 **** Each UAR host participating in IP tunneling must contain identical network, zone, peer and phase entries and each must have a unique node ! number. The peer entries are used to map node numbers to IP addresses. For security reasons, remote UAR hosts are not permitted to participate in tunneling unless their IP address is explicitly listed as a peer in --- 215,223 ---- Each UAR host participating in IP tunneling must contain identical network, zone, peer and phase entries and each must have a unique node ! number. A UAR tunnel, since it is effectively a separate network/cable, ! must be assigned a unique network number. The peer entries are used to ! map node numbers to IP addresses. For security reasons, remote UAR hosts are not permitted to participate in tunneling unless their IP address is explicitly listed as a peer in *** rtmp.c.orig Sun Oct 24 19:08:17 1993 --- rtmp.c Tue Oct 26 18:26:25 1993 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.1 $ * */ *************** *** 98,107 **** zone_rtmp_add(zone, rtmp); ! if (iflist[ifn].phase == PHASE2) { iflist[ifn].defzone = zone; - iflist[ifn].ourzone = zone; - } return; } --- 98,105 ---- zone_rtmp_add(zone, rtmp); ! if (iflist[ifn].phase == PHASE2) iflist[ifn].defzone = zone; return; } *** uar.c.orig Sun Oct 24 20:31:55 1993 --- uar.c Tue Oct 26 18:25:53 1993 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.1 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.2 $ * */ *************** *** 37,43 **** char *logfile = LOGFILE; /* Default logfile */ char *interface = NULL; /* Network interface */ char *progname = NULL; /* Saved argv[0] */ ! char *thisZone = "*"; /* server zone name */ char *linep; /* line pointer for configure() */ u_char baddr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* broadcast */ --- 37,43 ---- char *logfile = LOGFILE; /* Default logfile */ char *interface = NULL; /* Network interface */ char *progname = NULL; /* Saved argv[0] */ ! char *thisZone = NULL; /* server zone name */ char *linep; /* line pointer for configure() */ u_char baddr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* broadcast */ *************** *** 216,222 **** if (eth_mopen(iflist[i].phase)) { /* interface handles multiple opens */ if ((aarpfd = (*(iflist[i].iopen))(interface, ! O_RDWR, 0x80f3, iflist[i].phase)) < 0) { fprintf(stderr, " UAR: failed to open %s\n", interface); exit(1); } --- 216,222 ---- if (eth_mopen(iflist[i].phase)) { /* interface handles multiple opens */ if ((aarpfd = (*(iflist[i].iopen))(interface, ! O_RDWR, 0x80f3, iflist[i].phase)) < 0) { fprintf(stderr, " UAR: failed to open %s\n", interface); exit(1); } *************** *** 315,323 **** if (iflist[i].reade != NULL) (*(iflist[i].reade))(i, iflist[i].etfd); if (iflist[i].aarpfd >= 0) ! if (FD_ISSET(iflist[i].aarpfd, &fdset)) ! if (iflist[i].reada != NULL) ! (*(iflist[i].reada))(i, iflist[i].aarpfd); } if (capfd >= 0) if (FD_ISSET(capfd, &fdset)) --- 315,323 ---- if (iflist[i].reade != NULL) (*(iflist[i].reade))(i, iflist[i].etfd); if (iflist[i].aarpfd >= 0) ! if (FD_ISSET(iflist[i].aarpfd, &fdset)) ! if (iflist[i].reada != NULL) ! (*(iflist[i].reada))(i, iflist[i].aarpfd); } if (capfd >= 0) if (FD_ISSET(capfd, &fdset)) *************** *** 332,338 **** void usage() { ! fprintf(stderr, "usage: %s [-d flags] [-f filterlist]\n", progname); fprintf(stderr, "\t[-l logfile] [-z zone] [-1] [-2] interfaces\n"); return; --- 332,338 ---- void usage() { ! fprintf(stderr, "usage: %s [-d flags] [-c] [-C]\n", progname); fprintf(stderr, "\t[-l logfile] [-z zone] [-1] [-2] interfaces\n"); return; *************** *** 556,562 **** int ifn, phase, zlen, zones; u_short net, net_lo, net_hi, atnetshort(); char interface[64], name[64], value[64], line[256], znam[34], *p; ! struct zone *zone, *zone_find(), *zone_new(), *zonelist[258]; void cap_initialize(); void do_config(); void getfield(); --- 556,562 ---- int ifn, phase, zlen, zones; u_short net, net_lo, net_hi, atnetshort(); char interface[64], name[64], value[64], line[256], znam[34], *p; ! struct zone *zone, *zonelist[258], *zone_make(); void cap_initialize(); void do_config(); void getfield(); *************** *** 598,604 **** for (ifn = 0; ifn < numintfc; ifn++) if (strcmp(value, iflist[ifn].if_name) == 0) ! break; if (ifn == numintfc) ifn = -1; --- 598,604 ---- for (ifn = 0; ifn < numintfc; ifn++) if (strcmp(value, iflist[ifn].if_name) == 0) ! break; if (ifn == numintfc) ifn = -1; *************** *** 621,630 **** continue; } if (strcmp(name, "zone") == 0) { if ((zlen = strlen(value)) > 32) { ! fprintf(stderr, " UAR: Zone name \"%s\" too long (%d)\n", ! value, zlen); exit(1); } bcopy((char *)value, (char *)znam, zlen); --- 621,634 ---- continue; } + /* + * default zone for network + * + */ if (strcmp(name, "zone") == 0) { if ((zlen = strlen(value)) > 32) { ! fprintf(stderr, " UAR: Zonename \"%s\" too long (%d)\n", ! value, zlen); exit(1); } bcopy((char *)value, (char *)znam, zlen); *************** *** 632,662 **** continue; } if (strcmp(name, "zonelist") == 0) { - if ((zlen = strlen(value)) > 32) { - fprintf(stderr, " UAR: Zonelist name \"%s\" too long (%d)\n", - value, zlen); - exit(1); - } if (ifn >= 0) { ! if ((zone = zone_find(value, zlen)) == ZONENULL) { ! if ((zone = zone_new()) != ZONENULL) { ! bcopy((char *)value, (char *)(zone->name+1), zlen); ! zone->name[zlen+1] = '\0'; ! zone->name[0] = zlen; ! zone->nets = NETNULL; ! zone->next = ZONENULL; ! zone_insert(zone); ! } ! } ! if (zone != ZONENULL) { if (zones < 256) { zonelist[zones++] = zone; zonelist[zones] = ZONENULL; } else { ! fprintf(stderr, " UAR: %-5s Too many zones in zonelist\n", ! iflist[ifn].if_name); ! exit(1); } } } --- 636,665 ---- continue; } + /* + * zone name for interface services, ie: CAP + * + */ + if (strcmp(name, "zonename") == 0) { + if (ifn >= 0) + iflist[ifn].ourzone = zone_make((u_char *)value); + continue; + } + + /* + * Phase 2 zone list + * + */ if (strcmp(name, "zonelist") == 0) { if (ifn >= 0) { ! if ((zone = zone_make((u_char *)value)) != ZONENULL) { if (zones < 256) { zonelist[zones++] = zone; zonelist[zones] = ZONENULL; } else { ! fprintf(stderr, " UAR: %-5s Too many zones in zonelist\n", ! iflist[ifn].if_name); ! exit(1); } } } *************** *** 667,673 **** if (strcmp(name, "node") == 0) { node = atoi(value) & 0xff; if (node > 0 && node < 0xff) ! iflist[ifn].node = node; continue; } --- 670,676 ---- if (strcmp(name, "node") == 0) { node = atoi(value) & 0xff; if (node > 0 && node < 0xff) ! iflist[ifn].node = node; continue; } *************** *** 680,687 **** if (strcmp(name, "cap") == 0) { if (strcmp(interface, "tnnl") == 0) { ! fprintf(stderr, " UAR: cannot attach CAP to tnnl interface\n"); ! exit(1); } if (strcmp(value, "on") == 0) cap_initialize(ifn); --- 683,690 ---- if (strcmp(name, "cap") == 0) { if (strcmp(interface, "tnnl") == 0) { ! fprintf(stderr, " UAR: cannot attach CAP to tnnl interface\n"); ! exit(1); } if (strcmp(value, "on") == 0) cap_initialize(ifn); *************** *** 690,722 **** if (strcmp(name, "peer") == 0) { if (strcmp(interface, "tnnl") == 0) { ! if ((p = (char *)index(value, '@')) == NULL) { ! fprintf(stderr, ! " UAR: bad format peer entry \"%s %s\" in %s\n", ! name, value, CONFIG_FILE); ! exit(1); ! } ! *p++ = '\0'; ! peer = atoi(value); ! if (peer < 0 || peer > 253) { ! fprintf(stderr, ! " UAR: tnnl peer nodes must be in the range 1-253\n"); ! exit(1); ! } ! /* skip white space */ ! while (isspace(*p) && *p != '\0') ! *p++ = '\0'; ! if (!isdigit(*p)) { ! fprintf(stderr, ! " UAR: tnnl peer addresses must be numeric IP numbers\n"); ! exit(1); ! } ! iflist[ifn].mnode[peer].client = MNODE_TNNL; ! iflist[ifn].mnode[peer].state = MNODE_VALID; ! iflist[ifn].mnode[peer].addr = inet_addr(p); continue; } --- 693,725 ---- if (strcmp(name, "peer") == 0) { if (strcmp(interface, "tnnl") == 0) { ! if ((p = (char *)index(value, '@')) == NULL) { ! fprintf(stderr, ! " UAR: bad format peer entry \"%s %s\" in %s\n", ! name, value, CONFIG_FILE); ! exit(1); ! } ! *p++ = '\0'; ! peer = atoi(value); ! if (peer < 0 || peer > 253) { ! fprintf(stderr, ! " UAR: tnnl peer nodes must be in the range 1-253\n"); ! exit(1); ! } ! /* skip white space */ ! while (isspace(*p) && *p != '\0') ! *p++ = '\0'; ! if (!isdigit(*p)) { ! fprintf(stderr, ! " UAR: tnnl peer addresses must be numeric IP numbers\n"); ! exit(1); ! } ! iflist[ifn].mnode[peer].client = MNODE_TNNL; ! iflist[ifn].mnode[peer].state = MNODE_VALID; ! iflist[ifn].mnode[peer].addr = inet_addr(p); continue; } *************** *** 773,779 **** iflist[ifn].net = net; else { fprintf(stderr, " UAR: %-5s Net number not within lo/hi range\n", ! iflist[ifn].if_name); exit(1); } } else net = net_lo; --- 776,782 ---- iflist[ifn].net = net; else { fprintf(stderr, " UAR: %-5s Net number not within lo/hi range\n", ! iflist[ifn].if_name); exit(1); } } else net = net_lo; *** zip.c.orig Sun Oct 24 20:31:59 1993 --- zip.c Tue Oct 26 18:25:48 1993 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.1 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.2 $ * */ *************** *** 1350,1355 **** --- 1350,1387 ---- zoneTab = zone; return; + } + + /* + * find or make a zone entry + * + */ + + struct zone * + zone_make(znam) + u_char *znam; + { + short zlen; + void zone_insert(), exit(); + struct zone *zone, *zone_find(), *zone_new(); + + if ((zlen = strlen((char *)znam)) > 32) { + fprintf(stderr, " UAR: Zonename \"%s\" too long (%d)\n", znam, zlen); + exit(1); + } + + if ((zone = zone_find(znam, zlen)) == ZONENULL) { + if ((zone = zone_new()) != ZONENULL) { + bcopy((char *)znam, (char *)(zone->name+1), zlen); + zone->name[zlen+1] = '\0'; + zone->name[0] = zlen; + zone->nets = NETNULL; + zone->next = ZONENULL; + zone_insert(zone); + } + } + + return(zone); } /* *** cap.c.orig Sun Oct 24 20:31:37 1993 --- cap.c Tue Oct 26 18:30:30 1993 *************** *** 15,21 **** * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.1.1.1 $ * */ --- 15,21 ---- * djh@munnari.OZ.AU * * $Author: djh $ ! * $Revision: 1.2 $ * */ *************** *** 28,33 **** --- 28,34 ---- extern u_long pkts_dropped; extern struct iflist iflist[]; extern char *stats_msg[]; + extern char *thisZone; extern u_char buf[]; static int portrange; *************** *** 45,51 **** --- 46,55 ---- int ifn; { int len; + unsigned long inet_addr(); + struct zone *zone, *zone_make(); struct servent *s, *getservbyname(); + void exit(); if (capfd != -1) { fprintf(stderr, *************** *** 61,67 **** lsin.sin_family = AF_INET; lsin.sin_port = htons(CAP_PORT); ! lsin.sin_addr.s_addr = inet_addr("127.0.0.1"); if (bind(capfd, (struct sockaddr *)&lsin, sizeof(lsin)) < 0) { perror("bind()"); exit(1); --- 65,71 ---- lsin.sin_family = AF_INET; lsin.sin_port = htons(CAP_PORT); ! lsin.sin_addr.s_addr = (unsigned long)inet_addr("127.0.0.1"); if (bind(capfd, (struct sockaddr *)&lsin, sizeof(lsin)) < 0) { perror("bind()"); exit(1); *************** *** 85,90 **** --- 89,98 ---- capNet = 0; capNode = 0; + if (thisZone != NULL) + if ((zone = zone_make((u_char *)thisZone)) != ZONENULL) + iflist[ifn].ourzone = zone; + iflist[ifn].clients |= MNODE_CAP; if (debug & CAPDEBUG) *************** *** 104,113 **** int ifn; u_char node; { - time_t now; char *ctime(); char *zone_name(); FILE *r, *fopen(); capNode = node; capNet = iflist[ifn].net; --- 112,121 ---- int ifn; u_char node; { char *ctime(); char *zone_name(); FILE *r, *fopen(); + time_t now, time(); capNode = node; capNet = iflist[ifn].net; *************** *** 117,123 **** * */ if ((r = fopen(ETH_DATABASE, "w")) != NULL) { ! time(&now); fprintf(r, "#\n# EtherTalk dynamic configuration data\n#\n"); fprintf(r, "# Last update:\t%s#\n", ctime(&now)); fprintf(r, "# Generated by UAR\n#\n"); --- 125,131 ---- * */ if ((r = fopen(ETH_DATABASE, "w")) != NULL) { ! (void)time(&now); fprintf(r, "#\n# EtherTalk dynamic configuration data\n#\n"); fprintf(r, "# Last update:\t%s#\n", ctime(&now)); fprintf(r, "# Generated by UAR\n#\n"); *************** *** 189,194 **** --- 197,203 ---- u_char *pkt, *hdr; u_short cap_udpport(); u_short cksum, chkSum(); + void dumppacket(); if (capfd < 0 || capNet == 0 || capNode == 0) return; *************** *** 275,283 **** struct pd pd; short pktlen; int ddp_for_gw(); u_short cksum, chkSum(); struct rtmp *rtmp, *rtmp_route(); ! void ddp_route(); if (capfd < 0 || capNet == 0 || capNode == 0) return; --- 284,293 ---- struct pd pd; short pktlen; int ddp_for_gw(); + int ddp_for_mn(); u_short cksum, chkSum(); struct rtmp *rtmp, *rtmp_route(); ! void ddp_gw(), ddp_mn(), ddp_route(), dumppacket(); if (capfd < 0 || capNet == 0 || capNode == 0) return; *************** *** 323,329 **** pd.data = pkt+13; if (checksum && cksum) if (cksum != chkSum(pkt+4, pktlen-4)) ! drop(ddpChecksumErrors); break; default: drop(uarBadLapType); --- 333,339 ---- pd.data = pkt+13; if (checksum && cksum) if (cksum != chkSum(pkt+4, pktlen-4)) ! drop(ddpChecksumErrors); break; default: drop(uarBadLapType); *************** *** 364,375 **** } /* ! * check if packet for RTMP ! * route entry interface * */ if (ddp_for_gw(rtmp->intfc, pd.dstNet, pd.dstNode)) { ddp_gw(rtmp->intfc, &pd); if (pd.dstNode != BCAST) return; } --- 374,394 ---- } /* ! * packet for gateway on rtmp->intfc ? * */ if (ddp_for_gw(rtmp->intfc, pd.dstNet, pd.dstNode)) { ddp_gw(rtmp->intfc, &pd); + if (pd.dstNode != BCAST) + return; + } + + /* + * packet for multinode client on rtmp->intfc ? + * + */ + if (ddp_for_mn(rtmp->intfc, pd.dstNet, pd.dstNode)) { + ddp_mn(rtmp->intfc, &pd); if (pd.dstNode != BCAST) return; }