]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-atalk.c
s/u_short/u_int16_t/ for KAME-origin source codes
[tcpdump] / print-atalk.c
index e6782c0107e16fd50ef7d8b7fff92cbbad87729c..274e0fb571d235e9f40cbe5d1e34b47703059517 100644 (file)
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.49 1999-10-17 21:37:11 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.54 2000-04-02 23:50:48 itojun Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
 #include <sys/param.h>
@@ -39,8 +43,10 @@ struct rtentry;
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
+#include <netinet/ip_var.h>
 #include <netinet/if_ether.h>
 #include <netinet/udp.h>
+#include <netinet/udp_var.h>
 #include <netinet/tcp.h>
 
 #include <stdio.h>
@@ -65,13 +71,13 @@ static struct tok type2str[] = {
 };
 
 struct aarp {
-       u_short htype, ptype;
-       u_char  halen, palen;
-       u_short op;
-       u_char  hsaddr[6];
-       u_char  psaddr[4];
-       u_char  hdaddr[6];
-       u_char  pdaddr[4];
+       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];
 };
 
 static char tstr[] = "[|atalk]";
@@ -160,9 +166,9 @@ aarp_print(register const u_char *bp, u_int length)
 
        printf("aarp ");
        ap = (const struct aarp *)bp;
-       if (ap->htype == 1 && ap->ptype == ETHERTYPE_ATALK &&
+       if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK &&
            ap->halen == 6 && ap->palen == 4 )
-               switch (ap->op) {
+               switch (ntohs(ap->op)) {
 
                case 1:                         /* request */
                        (void)printf("who-has %s tell %s",
@@ -179,8 +185,9 @@ aarp_print(register const u_char *bp, u_int length)
                            AT(pdaddr), AT(psaddr));
                        return;
                }
-       (void)printf("len %d op %d htype %d ptype %#x halen %d palen %d",
-           length, ap->op, ap->htype, ap->ptype, ap->halen, ap->palen );
+       (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
+           length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype),
+           ap->halen, ap->palen);
 }
 
 static void
@@ -501,11 +508,11 @@ ataddr_string(u_short atnet, u_char athost)
                while (fgets(line, sizeof(line), fp)) {
                        if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
                                continue;
-                       if (sscanf(line, "%d.%d.%d %s", &i1, &i2, &i3,
+                       if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3,
                                     nambuf) == 4)
                                /* got a hostname. */
                                i3 |= ((i1 << 8) | i2) << 8;
-                       else if (sscanf(line, "%d.%d %s", &i1, &i2,
+                       else if (sscanf(line, "%d.%d %256s", &i1, &i2,
                                        nambuf) == 3)
                                /* got a net name */
                                i3 = (((i1 << 8) | i2) << 8) | 255;
@@ -532,7 +539,8 @@ ataddr_string(u_short atnet, u_char athost)
                if (tp2->addr == i) {
                        tp->addr = (atnet << 8) | athost;
                        tp->nxt = newhnamemem();
-                       (void)sprintf(nambuf, "%s.%d", tp2->name, athost);
+                       (void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
+                           tp2->name, athost);
                        tp->name = savestr(nambuf);
                        return (tp->name);
                }
@@ -540,10 +548,11 @@ ataddr_string(u_short atnet, u_char athost)
        tp->addr = (atnet << 8) | athost;
        tp->nxt = newhnamemem();
        if (athost != 255)
-               (void)sprintf(nambuf, "%d.%d.%d",
+               (void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d",
                    atnet >> 8, atnet & 0xff, athost);
        else
-               (void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff);
+               (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
+                   atnet & 0xff);
        tp->name = savestr(nambuf);
 
        return (tp->name);
@@ -563,7 +572,7 @@ ddpskt_string(register int skt)
        static char buf[8];
 
        if (nflag) {
-               (void)sprintf(buf, "%d", skt);
+               (void)snprintf(buf, sizeof(buf), "%d", skt);
                return (buf);
        }
        return (tok2str(skt2str, "%d", skt));