Patch #: 153 Type: operational change Priority: none Modification: make getzones more useful Submitted: David Hornsby Archived: munnari.OZ.AU mac/cap.patches/cap60.patch153 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch153' Summary: add -l flag for Phase 2 localzones, -m flag for myZone File: cap60/netat/appletalk.h File: cap60/lib/cap/abzip.c File: cap60/samples/getzones.c *** netat/appletalk.h.orig Wed Aug 4 02:18:50 1993 --- netat/appletalk.h Mon Aug 9 00:07:02 1993 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1993/08/03 16:18:45 $ ! * $Header: /mac/src/cap60/netat/RCS/appletalk.h,v 2.5 1993/08/03 16:18:45 djh Rel djh $ ! * $Revision: 2.5 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1993/08/08 14:06:45 $ ! * $Header: /mac/src/cap60/netat/RCS/appletalk.h,v 2.6 1993/08/08 14:06:45 djh Rel djh $ ! * $Revision: 2.6 $ */ /* *************** *** 238,249 **** /* * Zone Information Protocol protocol definitions * ! */ #define zipZIS 0x6 /* Zone information socket */ /* define atp zip commands */ #define zip_GetMyZone 7 /* get my zone command */ #define zip_GetZoneList 8 /* get zone list command */ /* atp user bytes for zip commands */ /* no reply struct since return is packed array of pascal strings */ --- 238,250 ---- /* * Zone Information Protocol protocol definitions * ! */ #define zipZIS 0x6 /* Zone information socket */ /* define atp zip commands */ #define zip_GetMyZone 7 /* get my zone command */ #define zip_GetZoneList 8 /* get zone list command */ + #define zip_GetLocZones 9 /* get local zone list */ /* atp user bytes for zip commands */ /* no reply struct since return is packed array of pascal strings */ *** lib/cap/abzip.c.orig Wed Aug 4 02:15:57 1993 --- lib/cap/abzip.c Mon Aug 9 00:07:58 1993 *************** *** 1,13 **** /* ! * $Author: djh $ $Date: 1993/08/03 16:15:37 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abzip.c,v 2.2 1993/08/03 16:15:37 djh Rel djh $ ! * $Revision: 2.2 $ ! */ /* * abzip.c - AppleTalk Zone Information Protocol * ! * Only support for GetZoneList. GetMyZone is faked. * * MUST BE RUNNING KIP 1/88 or later to work properly (KIP 9/87 was the first * revision with zones, but the code didn't return properly) --- 1,14 ---- /* ! * $Author: djh $ $Date: 1993/08/08 14:07:45 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abzip.c,v 2.3 1993/08/08 14:07:45 djh Rel djh $ ! * $Revision: 2.3 $ ! * ! */ /* * abzip.c - AppleTalk Zone Information Protocol * ! * Only support for GetZoneList & GetLocalZones. GetMyZone is faked. * * MUST BE RUNNING KIP 1/88 or later to work properly (KIP 9/87 was the first * revision with zones, but the code didn't return properly) *************** *** 21,27 **** * * March 1988, CCKim Create * ! */ #include #include --- 22,28 ---- * * March 1988, CCKim Create * ! */ #include #include *************** *** 33,38 **** --- 34,40 ---- /* define atp zip commands */ #define zip_GetMyZone 7 /* get my zone command */ #define zip_GetZoneList 8 /* get zone list command */ + #define zip_GetLocZones 9 /* get local zone list */ /* atp user bytes for zip commands */ /* no reply struct since return is packed array of pascal strings */ *************** *** 43,49 **** word zip_index; /* zip index (count on return) */ } zipUserBytes; ! #endif extern u_char this_zone[]; extern u_char async_zone[]; --- 45,51 ---- word zip_index; /* zip index (count on return) */ } zipUserBytes; ! #endif zip_GetMyZOne extern u_char this_zone[]; extern u_char async_zone[]; *************** *** 54,66 **** * start_index: zone start index (first is 1) * buffer to return zone list reply in - must be atpMaxData * zipuserbytes: on noErr return: set to user bytes returned by bridge * ! */ OSErr ! atpgetzonelist(start_index, buf, zipuserbytes) int start_index; char *buf; zipUserBytes *zipuserbytes; { AddrBlock addr; BDS bds[1]; /* 1 for zip */ --- 56,71 ---- * start_index: zone start index (first is 1) * buffer to return zone list reply in - must be atpMaxData * zipuserbytes: on noErr return: set to user bytes returned by bridge + * function: zip_GetZoneList or zip_GetLocZones * ! */ ! OSErr ! atpgetzonelist(start_index, buf, zipuserbytes, function) int start_index; char *buf; zipUserBytes *zipuserbytes; + byte function; { AddrBlock addr; BDS bds[1]; /* 1 for zip */ *************** *** 69,79 **** ABusRecord abr; OSErr err, GetBridgeAddress(); ap = &abr.proto.atp; ap->atpUserData = 0L; zub = (zipUserBytes *)&ap->atpUserData; ! zub->zip_cmd = zip_GetZoneList; zub->zip_zero = 0; zub->zip_index = htons(start_index); /* start at 1 */ --- 74,94 ---- ABusRecord abr; OSErr err, GetBridgeAddress(); + #ifndef PHASE2 + if (function == zip_GetLocZones) { + fprintf(stderr, "ZIP: local zones request undefined for Phase 1\n"); + exit(1); + } + #endif PHASE2 + + if (function != zip_GetZoneList && function != zip_GetLocZones) + return(-1); + ap = &abr.proto.atp; ap->atpUserData = 0L; zub = (zipUserBytes *)&ap->atpUserData; ! zub->zip_cmd = function; zub->zip_zero = 0; zub->zip_index = htons(start_index); /* start at 1 */ *************** *** 98,105 **** --- 113,122 ---- /* send off request */ err = ATPSndRequest(&abr, FALSE); + if (err == noErr) bcopy(&bds[0].userData, zipuserbytes, sizeof(bds[0].userData)); + return(err); } *************** *** 110,118 **** * return: the real count in realcnt * return: any errors * ! */ OSErr ! GetZoneList(zones, numzones, realcnt) byte *zones[]; int numzones; int *realcnt; --- 127,137 ---- * return: the real count in realcnt * return: any errors * ! */ ! OSErr ! GetZoneList(function, zones, numzones, realcnt) ! byte function; byte *zones[]; int numzones; int *realcnt; *************** *** 129,135 **** zc = 0; zi = 1; do { ! if ((err=atpgetzonelist(zi, buf, &zub)) != noErr) return(err); gotcnt = ntohs(zub.zip_index); /* get count */ if (gotcnt && numzones) { --- 148,154 ---- zc = 0; zi = 1; do { ! if ((err=atpgetzonelist(zi, buf, &zub, function)) != noErr) return(err); gotcnt = ntohs(zub.zip_index); /* get count */ if (gotcnt && numzones) { *************** *** 146,151 **** --- 165,171 ---- zi += gotcnt; /* new index */ } while (zub.zip_cmd == 0); *realcnt = zi - 1; + return(noErr); } *** samples/getzones.c.orig Wed Aug 4 02:22:47 1993 --- samples/getzones.c Mon Aug 9 00:08:36 1993 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1993/08/03 16:22:40 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/samples/RCS/getzones.c,v 2.5 1993/08/03 16:22:40 djh Rel djh $"; ! static char revision[] = "$Revision: 2.5 $"; /* * getzones - retrieves the zone list from our bridge --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1993/08/08 14:08:26 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/samples/RCS/getzones.c,v 2.6 1993/08/08 14:08:26 djh Rel djh $"; ! static char revision[] = "$Revision: 2.6 $"; /* * getzones - retrieves the zone list from our bridge *************** *** 39,59 **** { int i,cnt; OSErr err; char *zones[NUMZONES]; /* room for pointers to zone names */ u_char *GetMyZone(); u_char *myzone; int verbose = 0; extern int opterr; extern char *optarg; opterr = 0; ! while ((i = getopt(argc, argv, "d:D:v")) != EOF) { switch (i) { case 'd': case 'D': dbugarg(optarg); break; case 'v': verbose++; break; --- 39,68 ---- { int i,cnt; OSErr err; + byte function; char *zones[NUMZONES]; /* room for pointers to zone names */ u_char *GetMyZone(); u_char *myzone; int verbose = 0; + int mzone = 0; extern int opterr; extern char *optarg; opterr = 0; + function = zip_GetZoneList; ! while ((i = getopt(argc, argv, "d:D:lmv")) != EOF) { switch (i) { case 'd': case 'D': dbugarg(optarg); break; + case 'l': + function = zip_GetLocZones; + break; + case 'm': + mzone = 1; + break; case 'v': verbose++; break; *************** *** 62,79 **** abInit(verbose ? TRUE : FALSE); ! if ((err = GetZoneList(zones, NUMZONES, &cnt)) != noErr) { fprintf(stderr, "error %d getting zone list\n", err); exit(1); } if (cnt > NUMZONES) { printf("only asked for %d zones when there were actually %d\n", NUMZONES,cnt); cnt = NUMZONES; } if (verbose) printf("Count is %d\n", cnt); ! myzone = GetMyZone(); for (i = 0; i < cnt ; i++) { if (verbose) printf("ZONE %s", zones[i]); --- 71,97 ---- abInit(verbose ? TRUE : FALSE); ! myzone = GetMyZone(); ! ! if (mzone) { ! printf("%s\n", (char *)myzone); ! exit(0); ! } ! ! if ((err = GetZoneList(function, zones, NUMZONES, &cnt)) != noErr) { fprintf(stderr, "error %d getting zone list\n", err); exit(1); } + if (cnt > NUMZONES) { printf("only asked for %d zones when there were actually %d\n", NUMZONES,cnt); cnt = NUMZONES; } + if (verbose) printf("Count is %d\n", cnt); ! for (i = 0; i < cnt ; i++) { if (verbose) printf("ZONE %s", zones[i]); *************** *** 83,88 **** --- 101,107 ---- putchar('*'); putchar('\n'); } + FreeZoneList(zones, cnt); } *** man/getzones.1.orig Wed Apr 14 17:17:20 1993 --- man/getzones.1 Mon Aug 9 00:09:17 1993 *************** *** 6,11 **** --- 6,15 ---- [ .BI \-d " " ] [ + .BI \-l + ] [ + .BI \-m + ] [ .BI \-v ] .SH DESCRIPTION *************** *** 12,17 **** --- 16,23 ---- .I getzones queries the AppleTalk to Ethernet gateway listed in .I atalk.local + or + .I etalk.local for the list of acccessible AppleTalk zones and then displays that list on standard output. .PP *************** *** 24,34 **** .I CAP library. See CAP(3) for a description of the valid flags. .TP .BI \-v produces a more verbose output including a zone count and the zone name for this host marked with an asterisk. .SH SEE ALSO ! CAP(8), CAP(3), atalk.local(5) .SH AUTHOR Manual entry by Phil Farrell, Stanford University School of Earth Sciences. Updated by David Hornsby, The University of Melbourne. --- 30,46 ---- .I CAP library. See CAP(3) for a description of the valid flags. .TP + .BI \-l + lists the local zones for this network (Phase 2 networks only). + .TP + .BI \-m + print the zone name for this host (myZone). + .TP .BI \-v produces a more verbose output including a zone count and the zone name for this host marked with an asterisk. .SH SEE ALSO ! CAP(8), CAP(3), atalk.local(5), etalk.local(5) .SH AUTHOR Manual entry by Phil Farrell, Stanford University School of Earth Sciences. Updated by David Hornsby, The University of Melbourne. *** lib/cap/abversion.c.orig Fri Aug 6 01:55:31 1993 --- lib/cap/abversion.c Mon Aug 9 00:13:28 1993 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1993/08/05 15:55:26 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abversion.c,v 2.52 1993/08/05 15:55:26 djh Rel djh $ ! * $Revision: 2.52 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1993/08/08 14:13:20 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abversion.c,v 2.53 1993/08/08 14:13:20 djh Rel djh $ ! * $Revision: 2.53 $ */ /* *************** *** 31,37 **** myversion.cv_name = "CAP"; myversion.cv_version = 6; myversion.cv_subversion = 0; ! myversion.cv_patchlevel = 152; myversion.cv_rmonth = "August"; myversion.cv_ryear = "1993"; switch (lap_proto) { --- 31,37 ---- myversion.cv_name = "CAP"; myversion.cv_version = 6; myversion.cv_subversion = 0; ! myversion.cv_patchlevel = 153; myversion.cv_rmonth = "August"; myversion.cv_ryear = "1993"; switch (lap_proto) { *** README.orig Fri Aug 6 01:56:35 1993 --- README Mon Aug 9 00:14:48 1993 *************** *** 2,8 **** CAP - Columbia AppleTalk Package for UNIX o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 152, August 1993 Notice ------ --- 2,8 ---- CAP - Columbia AppleTalk Package for UNIX o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 153, August 1993 Notice ------