X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b46194277a029332c9d1b0ba38110cabc179210f..d4876278a77ed6576073cc6fd81d2ec43eb85733:/print-atalk.c diff --git a/print-atalk.c b/print-atalk.c index 732e6112..72fd72ad 100644 --- a/print-atalk.c +++ b/print-atalk.c @@ -21,20 +21,19 @@ * Format and print AppleTalk packets. */ -#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include #include #include -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ethertype.h" -#include "extract.h" /* must come after interface.h */ +#include "extract.h" #include "appletalk.h" static const char tstr[] = "[|atalk]"; @@ -50,13 +49,13 @@ static const struct tok type2str[] = { }; struct aarp { - u_int16_t htype, ptype; - u_int8_t halen, palen; - u_int16_t op; - u_int8_t hsaddr[6]; - u_int8_t psaddr[4]; - u_int8_t hdaddr[6]; - u_int8_t pdaddr[4]; + uint16_t htype, ptype; + uint8_t halen, palen; + uint16_t op; + uint8_t hsaddr[6]; + uint8_t psaddr[4]; + uint8_t hdaddr[6]; + uint8_t pdaddr[4]; }; static void atp_print(netdissect_options *, const struct atATP *, u_int); @@ -204,7 +203,7 @@ aarp_print(netdissect_options *ndo, return; case 2: /* response */ - ND_PRINT((ndo, "reply %s is-at %s", AT(psaddr), etheraddr_string(ap->hsaddr))); + ND_PRINT((ndo, "reply %s is-at %s", AT(psaddr), etheraddr_string(ndo, ap->hsaddr))); return; case 3: /* probe (oy!) */ @@ -250,7 +249,7 @@ atp_print(netdissect_options *ndo, register const struct atATP *ap, u_int length) { char c; - u_int32_t data; + uint32_t data; if ((const u_char *)(ap + 1) > ndo->ndo_snapend) { /* Just bail if we don't have the whole chunk. */ @@ -380,7 +379,7 @@ nbp_print(netdissect_options *ndo, register u_char snode, register u_char skt) { register const struct atNBPtuple *tp = - (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize); + (const struct atNBPtuple *)((const u_char *)np + nbpHeaderSize); int i; const u_char *ep; @@ -567,8 +566,11 @@ ataddr_string(netdissect_options *ndo, tp->nxt; tp = tp->nxt) ; tp->addr = i2; - tp->nxt = newhnamemem(); + tp->nxt = newhnamemem(ndo); tp->name = strdup(nambuf); + if (tp->name == NULL) + (*ndo->ndo_error)(ndo, + "ataddr_string: strdup(nambuf)"); } fclose(fp); } @@ -582,20 +584,25 @@ ataddr_string(netdissect_options *ndo, for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt) if (tp2->addr == i) { tp->addr = (atnet << 8) | athost; - tp->nxt = newhnamemem(); + tp->nxt = newhnamemem(ndo); (void)snprintf(nambuf, sizeof(nambuf), "%s.%d", tp2->name, athost); tp->name = strdup(nambuf); + if (tp->name == NULL) + (*ndo->ndo_error)(ndo, + "ataddr_string: strdup(nambuf)"); return (tp->name); } tp->addr = (atnet << 8) | athost; - tp->nxt = newhnamemem(); + tp->nxt = newhnamemem(ndo); if (athost != 255) (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost); else (void)snprintf(nambuf, sizeof(nambuf), "%d", atnet); tp->name = strdup(nambuf); + if (tp->name == NULL) + (*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)"); return (tp->name); }