]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-cnfp.c
Handle IPX socket 0x553, which is some kind of NetBIOS-over-IPX socket.
[tcpdump] / print-cnfp.c
index 34baf8a366a50ea8508151643f3b1d59fc8b46f7..cba4fc0443b1f6da1788e0238df2fd1bff791a8d 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.3 2000-04-27 13:45:11 itojun Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.6 2000-09-23 08:26:32 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -47,13 +47,16 @@ static const char rcsid[] =
 #include <netdb.h>
 
 #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <arpa/inet.h>
 
 #include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 
+#include "tcp.h"
+
 struct nfhdr {
        u_int32_t       ver_cnt;        /* version [15], and # of records */
        u_int32_t       msys_uptime;
@@ -88,7 +91,6 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
        struct protoent *pent;
        int nrecs, ver;
        time_t t;
-       char *p;
 
        ip = (struct ip *)bp;
        nh = (struct nfhdr *)cp;
@@ -102,11 +104,12 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
 /*     (p = ctime(&t))[24] = '\0'; */
 
        printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
-              ntohl(nh->msys_uptime)/1000, ntohl(nh->msys_uptime)%1000,
-              ntohl(nh->utc_sec), ntohl(nh->utc_nsec));
+              (unsigned)ntohl(nh->msys_uptime)/1000,
+              (unsigned)ntohl(nh->msys_uptime)%1000,
+              (unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec));
 
        if (ver == 5) {
-               printf("#%u, ", htonl(nh->sequence));
+               printf("#%u, ", (unsigned)htonl(nh->sequence));
                nr = (struct nfrec *)&nh[1];
                snaplen -= 24;
        } else {
@@ -117,33 +120,40 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
        printf("%2u recs", nrecs);
 
        for (; nrecs-- && (u_char *)(nr + 1) <= snapend; nr++) {
-               char buf[5];
-               char asbuf[7];
+               char buf[20];
+               char asbuf[20];
 
                printf("\n  started %u.%03u, last %u.%03u",
-                       ntohl(nr->start_time)/1000, ntohl(nr->start_time)%1000,
-                       ntohl(nr->last_time)/1000, ntohl(nr->last_time)%1000);
+                      (unsigned)ntohl(nr->start_time)/1000,
+                      (unsigned)ntohl(nr->start_time)%1000,
+                      (unsigned)ntohl(nr->last_time)/1000,
+                      (unsigned)ntohl(nr->last_time)%1000);
 
                asbuf[0] = buf[0] = '\0';
                if (ver == 5) {
-                       sprintf(buf, "/%d", (ntohl(nr->masks) >> 24) & 0xff);
-                       sprintf(asbuf, "%d:", (ntohl(nr->asses) >> 16) & 0xffff);
+                       snprintf(buf, sizeof(buf), "/%u",
+                                (unsigned)(ntohl(nr->masks) >> 24) & 0xff);
+                       snprintf(asbuf, sizeof(asbuf), "%u:",
+                                (unsigned)(ntohl(nr->asses) >> 16) & 0xffff);
                }
                printf("\n    %s%s%s:%u ", inet_ntoa(nr->src_ina), buf, asbuf,
-                       ntohl(nr->ports) >> 16);
+                       (unsigned)ntohl(nr->ports) >> 16);
 
                if (ver == 5) {
-                       sprintf(buf, "/%d", (ntohl(nr->masks) >> 16) & 0xff);
-                       sprintf(asbuf, "%d:", ntohl(nr->asses) & 0xffff);
+                       snprintf(buf, sizeof(buf), "/%d",
+                                (unsigned)(ntohl(nr->masks) >> 16) & 0xff);
+                       snprintf(asbuf, sizeof(asbuf), "%u:",
+                                (unsigned)ntohl(nr->asses) & 0xffff);
                }
                printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf,
-                       ntohl(nr->ports) & 0xffff);
+                       (unsigned)ntohl(nr->ports) & 0xffff);
 
                printf(">> %s\n    ", inet_ntoa(nr->nhop_ina));
 
                pent = getprotobynumber((ntohl(nr->proto_tos) >> 8) & 0xff);
                if (!pent || nflag)
-                       printf("%u ", (ntohl(nr->proto_tos) >> 8) & 0xff);
+                       printf("%u ",
+                              (unsigned)(ntohl(nr->proto_tos) >> 8) & 0xff);
                else
                        printf("%s ", pent->p_name);
 
@@ -163,11 +173,9 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
                        if (flags)
                                putchar(' ');
                }
-               printf("tos %u, %u (%u octets)", ntohl(nr->proto_tos) & 0xff,
-                       ntohl(nr->packets), ntohl(nr->octets));
-
-
+               printf("tos %u, %u (%u octets)",
+                      (unsigned)ntohl(nr->proto_tos) & 0xff,
+                      (unsigned)ntohl(nr->packets),
+                      (unsigned)ntohl(nr->octets));
        }
-
 }
-