From: Guy Harris Date: Mon, 16 Aug 2010 22:02:12 +0000 (-0700) Subject: Print AppleTalk layer-3 network numbers as 16-bit unsigned decimal numbers. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/27cd2c64553667e59d9fef664ce4259189bf9838 Print AppleTalk layer-3 network numbers as 16-bit unsigned decimal numbers. Pick up from FreeBSD: revision 1.3 date: 1996/09/11 06:18:26; author: pst; state: Exp; lines: +9 -12 branches: 1.3.2; Print appletalk layer 3 addresses as 16 bit unsigned decimal numbers, not two 8 bit values. This conforms to industry standard. These changes have been sent back to LBL. Inside AppleTalk(R), Second Edition speaks of node numbers as 16-bit. --- diff --git a/print-atalk.c b/print-atalk.c index fe51cba0..995fcff5 100644 --- a/print-atalk.c +++ b/print-atalk.c @@ -543,26 +543,24 @@ ataddr_string(u_short atnet, u_char athost) if (first && (first = 0, !nflag) && (fp = fopen("/etc/atalk.names", "r"))) { char line[256]; - int i1, i2, i3; + int i1, i2; while (fgets(line, sizeof(line), fp)) { if (line[0] == '\n' || line[0] == 0 || line[0] == '#') continue; - if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3, - nambuf) == 4) + if (sscanf(line, "%d.%d %256s", &i1, &i2, nambuf) == 3) /* got a hostname. */ - i3 |= ((i1 << 8) | i2) << 8; - else if (sscanf(line, "%d.%d %256s", &i1, &i2, - nambuf) == 3) + i2 |= (i1 << 8); + else if (sscanf(line, "%d %256s", &i1, nambuf) == 2) /* got a net name */ - i3 = (((i1 << 8) | i2) << 8) | 255; + i2 = (i1 << 8) | 255; else continue; - for (tp = &hnametable[i3 & (HASHNAMESIZE-1)]; + for (tp = &hnametable[i2 & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) ; - tp->addr = i3; + tp->addr = i2; tp->nxt = newhnamemem(); tp->name = strdup(nambuf); } @@ -588,11 +586,9 @@ ataddr_string(u_short atnet, u_char athost) tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(); if (athost != 255) - (void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d", - atnet >> 8, atnet & 0xff, athost); + (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost); else - (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8, - atnet & 0xff); + (void)snprintf(nambuf, sizeof(nambuf), "%d", atnet); tp->name = strdup(nambuf); return (tp->name);