]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-atalk.c
NDOize AH, BEEP and DTP decoders
[tcpdump] / print-atalk.c
index 995fcff5a9dfb0e54f3db65da61883d2953b43cd..7546543bce9d456e505b2a5b129284c93be5fd72 100644 (file)
  * Format and print AppleTalk packets.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -43,7 +38,9 @@ static const char rcsid[] _U_ =
 #include "extract.h"                   /* must come after interface.h */
 #include "appletalk.h"
 
-static struct tok type2str[] = {
+static const char tstr[] = "[|atalk]";
+
+static const struct tok type2str[] = {
        { ddpRTMP,              "rtmp" },
        { ddpRTMPrequest,       "rtmpReq" },
        { ddpECHO,              "echo" },
@@ -63,8 +60,6 @@ struct aarp {
        u_int8_t        pdaddr[4];
 };
 
-static char tstr[] = "[|atalk]";
-
 static void atp_print(const struct atATP *, u_int);
 static void atp_bitmap_print(u_char);
 static void nbp_print(const struct atNBP *, u_int, u_short, u_char, u_char);
@@ -99,6 +94,10 @@ llap_print(register const u_char *bp, u_int length)
        u_short snet;
        u_int hdrlen;
 
+       if (length < sizeof(*lp)) {
+               (void)printf(" [|llap %u]", length);
+               return (length);
+       }
        lp = (const struct LAP *)bp;
        bp += sizeof(*lp);
        length -= sizeof(*lp);
@@ -107,7 +106,7 @@ llap_print(register const u_char *bp, u_int length)
 
        case lapShortDDP:
                if (length < ddpSSize) {
-                       (void)printf(" [|sddp %d]", length);
+                       (void)printf(" [|sddp %u]", length);
                        return (length);
                }
                sdp = (const struct atShortDDP *)bp;
@@ -123,7 +122,7 @@ llap_print(register const u_char *bp, u_int length)
 
        case lapDDP:
                if (length < ddpSize) {
-                       (void)printf(" [|ddp %d]", length);
+                       (void)printf(" [|ddp %u]", length);
                        return (length);
                }
                dp = (const struct atDDP *)bp;
@@ -146,7 +145,7 @@ llap_print(register const u_char *bp, u_int length)
 #endif
 
        default:
-               printf("%d > %d at-lap#%d %d",
+               printf("%d > %d at-lap#%d %u",
                    lp->src, lp->dst, lp->type, length);
                break;
        }
@@ -168,7 +167,7 @@ atalk_print(register const u_char *bp, u_int length)
             printf("AT ");
 
        if (length < ddpSize) {
-               (void)printf(" [|ddp %d]", length);
+               (void)printf(" [|ddp %u]", length);
                return;
        }
        dp = (const struct atDDP *)bp;
@@ -257,6 +256,10 @@ atp_print(register const struct atATP *ap, u_int length)
                fputs(tstr, stdout);
                return;
        }
+       if (length < sizeof(*ap)) {
+               (void)printf(" [|atp %u]", length);
+               return;
+       }
        length -= sizeof(*ap);
        switch (ap->control & 0xc0) {
 
@@ -268,7 +271,7 @@ atp_print(register const struct atATP *ap, u_int length)
                atp_bitmap_print(ap->bitmap);
 
                if (length != 0)
-                       (void)printf(" [len=%d]", length);
+                       (void)printf(" [len=%u]", length);
 
                switch (ap->control & (atpEOM|atpSTS)) {
                case atpEOM:
@@ -284,7 +287,7 @@ atp_print(register const struct atATP *ap, u_int length)
                break;
 
        case atpRspCode:
-               (void)printf(" atp-resp%s%d:%d (%d)",
+               (void)printf(" atp-resp%s%d:%d (%u)",
                             ap->control & atpEOM? "*" : " ",
                             EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
                switch (ap->control & (atpXO|atpSTS)) {
@@ -307,7 +310,7 @@ atp_print(register const struct atATP *ap, u_int length)
 
                /* length should be zero */
                if (length)
-                       (void)printf(" [len=%d]", length);
+                       (void)printf(" [len=%u]", length);
 
                /* there shouldn't be any control flags */
                if (ap->control & (atpXO|atpEOM|atpSTS)) {
@@ -329,7 +332,7 @@ atp_print(register const struct atATP *ap, u_int length)
                break;
 
        default:
-               (void)printf(" atp-0x%x  %d (%d)", ap->control,
+               (void)printf(" atp-0x%x  %d (%u)", ap->control,
                             EXTRACT_16BITS(&ap->transID), length);
                break;
        }
@@ -379,14 +382,14 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
        const u_char *ep;
 
        if (length < nbpHeaderSize) {
-               (void)printf(" truncated-nbp %d", length);
+               (void)printf(" truncated-nbp %u", length);
                return;
        }
 
        length -= nbpHeaderSize;
        if (length < 8) {
                /* must be room for at least one tuple */
-               (void)printf(" truncated-nbp %d", length + nbpHeaderSize);
+               (void)printf(" truncated-nbp %u", length + nbpHeaderSize);
                return;
        }
        /* ep points to end of available data */
@@ -431,7 +434,7 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
                break;
 
        default:
-               (void)printf(" nbp-0x%x  %d (%d)", np->control, np->id,
+               (void)printf(" nbp-0x%x  %d (%u)", np->control, np->id,
                                length);
                break;
        }
@@ -532,7 +535,7 @@ ataddr_string(u_short atnet, u_char athost)
 {
        register struct hnamemem *tp, *tp2;
        register int i = (atnet << 8) | athost;
-       char nambuf[MAXHOSTNAMELEN + 20];
+       char nambuf[256+1];
        static int first = 1;
        FILE *fp;
 
@@ -594,7 +597,7 @@ ataddr_string(u_short atnet, u_char athost)
        return (tp->name);
 }
 
-static struct tok skt2str[] = {
+static const struct tok skt2str[] = {
        { rtmpSkt,      "rtmp" },       /* routing table maintenance */
        { nbpSkt,       "nis" },        /* name info socket */
        { echoSkt,      "echo" },       /* AppleTalk echo protocol */