]> The Tcpdump Group git mirrors - tcpdump/commitdiff
refactored ip_print() so that chained header parser (ESP/AH) can
authormcr <mcr>
Wed, 6 Apr 2005 21:32:38 +0000 (21:32 +0000)
committermcr <mcr>
Wed, 6 Apr 2005 21:32:38 +0000 (21:32 +0000)
more easily call the inner parts.

20 files changed:
print-arcnet.c
print-chdlc.c
print-cip.c
print-enc.c
print-ether.c
print-fr.c
print-gre.c
print-icmp.c
print-ip.c
print-ip6.c
print-isoclns.c
print-juniper.c
print-llc.c
print-mpls.c
print-msdp.c
print-null.c
print-pflog.c
print-pim.c
print-ppp.c
print-sl.c

index 1515d2d62666d24e9d6273420ab5a7313f71f47c..48a43030b4d22b5abb390056178c7f0089b8eab2 100644 (file)
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.19 2004-04-30 16:42:14 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -259,7 +259,7 @@ arcnet_encap_print(u_char arctype, const u_char *p,
 
        case ARCTYPE_IP_OLD:
        case ARCTYPE_IP:
-               ip_print(p, length);
+               ip_print(gndo, p, length);
                return (1);
 
 #ifdef INET6
index ec5855a2f6a0888a4351365b5b6c05d5999ded6d..41d94141be7b347165e84f77e933dc92e78b0d98 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.31 2004-03-24 00:45:39 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32 2005-04-06 21:32:38 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -76,7 +76,7 @@ chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
        ip = (const struct ip *)(p + CHDLC_HDRLEN);
        switch (proto) {
        case ETHERTYPE_IP:
-               ip_print((const u_char *)ip, length);
+               ip_print(gndo, (const u_char *)ip, length);
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:
@@ -182,3 +182,11 @@ chdlc_slarp_print(const u_char *cp, u_int length)
 trunc:
        printf("[|slarp]");
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index d7dd85af52ef4c4c5fed7bd6e23c95b4bf7c15c6..3a7d33a5c258508cfb1e2c45576c5469fe7733fb 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.24 2004-03-17 23:24:36 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.25 2005-04-06 21:32:39 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -101,8 +101,16 @@ cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
                /*
                 * LLC header is absent; treat it as just IP.
                 */
-               ip_print(p, length);
+               ip_print(gndo, p, length);
        }
 
        return (0);
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index e3c2ad738be71b5bd5b98105bdbfeaf7254d65b5..605ca33d255677a509f71f8e9b68fb53b16ace3a 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.3 2003-11-16 09:36:20 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.4 2005-04-06 21:32:39 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -71,8 +71,16 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 
        length -= ENC_HDRLEN;
        /* XXX - use the address family */
-       ip_print(p + ENC_HDRLEN, length);
+       ip_print(gndo, p + ENC_HDRLEN, length);
 
 out:
        return (ENC_HDRLEN);
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index 0df63fd5564ae6963bbb4b2155bd9c87eae0e6ca..a12e7b05342edddd77e811195053ef4f97c6dfdc 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.94 2005-01-25 16:22:56 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95 2005-04-06 21:32:39 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -202,7 +202,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
        switch (ether_type) {
 
        case ETHERTYPE_IP:
-               ip_print(p, length);
+               ip_print(gndo, p, length);
                return (1);
 
 #ifdef INET6
@@ -329,9 +329,11 @@ ether_encap_print(u_short ether_type, const u_char *p,
        }
 }
 
+
 /*
  * Local Variables:
- * c-style: bsd
+ * c-style: whitesmith
+ * c-basic-offset: 8
  * End:
  */
 
index b0ffab99bedab655602cd49183f3a3f595b95ba5..d182535490c9f399d112234bf6e9350198d4b88c 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.31 2005-04-06 20:09:08 hannes Exp $ (LBL)";
+       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32 2005-04-06 21:32:39 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -253,7 +253,7 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 
        switch (nlpid) {
        case NLPID_IP:
-               ip_print(p, length);
+               ip_print(gndo, p, length);
                break;
 
 #ifdef INET6
index ed4c957b661f1472e193fce8291e4202d05d1362..55f0e9d16b3380bd16269c2699eebe7f24a42ba7 100644 (file)
@@ -38,7 +38,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.27 2004-07-02 06:39:11 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -206,7 +206,7 @@ gre_print_0(const u_char *bp, u_int length)
 
        switch (prot) {
        case ETHERTYPE_IP:
-               ip_print(bp, len);
+               ip_print(gndo, bp, len);
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:
index 228824603ed13c826d43c785208433340ca21073..862b095a1fc15a3c1efc847a16bf6433ba02bbfa 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.80 2004-12-23 10:51:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81 2005-04-06 21:32:40 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -527,7 +527,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
                (void)printf("\n\t");
                ip = (struct ip *)bp;
                snaplen = snapend - bp;
-               ip_print(bp, EXTRACT_16BITS(&ip->ip_len));
+               ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
        }
 
         if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
index b05088d31da638dd4bfaab8068380c42492f83a0..8446532682bd4509e45ab39a7ce0542b61e689bd 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.147 2005-01-21 08:02:06 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.148 2005-04-06 21:33:02 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -356,31 +356,187 @@ static struct tok ip_frag_values[] = {
         { 0,            NULL }
 };
 
+struct ip_print_demux_state {
+       const struct ip *ip;
+       const u_char *cp;
+       u_int   hlen, len, off;
+       u_char  nh;
+       int     advance;
+};
+
+static void
+ip_print_demux(netdissect_options *ndo,
+              struct ip_print_demux_state *ipds)
+{
+       struct protoent *proto;
+
+again:
+       switch (ipds->nh) {
+
+       case IPPROTO_AH:
+               ipds->nh = *ipds->cp;
+               ipds->advance = ah_print(ipds->cp);
+               if (ipds->advance <= 0)
+                       break;
+               ipds->cp += ipds->advance;
+               ipds->len -= ipds->advance;
+               goto again;
+
+       case IPPROTO_ESP:
+       {
+               int enh, padlen;
+               ipds->advance = esp_print(ndo, ipds->cp, ipds->len,
+                                   (const u_char *)ipds->ip,
+                                   &enh, &padlen);
+               if (ipds->advance <= 0)
+                       break;
+               ipds->cp += ipds->advance;
+               ipds->len -= ipds->advance + padlen;
+               ipds->nh = enh & 0xff;
+               goto again;
+       }
+       
+       case IPPROTO_IPCOMP:
+       {
+               int enh;
+               ipds->advance = ipcomp_print(ipds->cp, &enh);
+               if (ipds->advance <= 0)
+                       break;
+               ipds->cp += ipds->advance;
+               ipds->len -= ipds->advance;
+               ipds->nh = enh & 0xff;
+               goto again;
+       }
+
+       case IPPROTO_SCTP:
+               sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+               break;
+               
+       case IPPROTO_TCP:
+               tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+                         (ipds->off &~ 0x6000));
+               break;
+               
+       case IPPROTO_UDP:
+               udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+                         (ipds->off &~ 0x6000));
+               break;
+               
+       case IPPROTO_ICMP:
+               /* pass on the MF bit plus the offset to detect fragments */
+               icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+                          (ipds->off & 0x3fff));
+               break;
+               
+       case IPPROTO_PIGP:
+               /*
+                * XXX - the current IANA protocol number assignments
+                * page lists 9 as "any private interior gateway
+                * (used by Cisco for their IGRP)" and 88 as
+                * "EIGRP" from Cisco.
+                *
+                * Recent BSD <netinet/in.h> headers define
+                * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
+                * We define IP_PROTO_PIGP as 9 and
+                * IP_PROTO_EIGRP as 88; those names better
+                * match was the current protocol number
+                * assignments say.
+                */
+               igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+               break;
+               
+       case IPPROTO_EIGRP:
+               eigrp_print(ipds->cp, ipds->len);
+               break;
+               
+       case IPPROTO_ND:
+               ND_PRINT((ndo, " nd %d", ipds->len));
+               break;
+
+       case IPPROTO_EGP:
+               egp_print(ipds->cp, ipds->len);
+               break;
+
+       case IPPROTO_OSPF:
+               ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+               break;
+
+       case IPPROTO_IGMP:
+               igmp_print(ipds->cp, ipds->len);
+               break;
+
+       case IPPROTO_IPV4:
+               /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
+               ip_print(gndo, ipds->cp, ipds->len);
+               if (! vflag) {
+                       ND_PRINT((ndo, " (ipip-proto-4)"));
+                       return;
+               }
+               break;
+               
+#ifdef INET6
+       case IPPROTO_IPV6:
+               /* ip6-in-ip encapsulation */
+               ip6_print(ipds->cp, ipds->len);
+               break;
+#endif /*INET6*/
+
+       case IPPROTO_RSVP:
+               rsvp_print(ipds->cp, ipds->len);
+               break;
+
+       case IPPROTO_GRE:
+               /* do it */
+               gre_print(ipds->cp, ipds->len);
+               break;
+
+       case IPPROTO_MOBILE:
+               mobile_print(ipds->cp, ipds->len);
+               break;
+
+       case IPPROTO_PIM:
+               pim_print(ipds->cp,  ipds->len);
+               break;
+
+       case IPPROTO_VRRP:
+               vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+               break;
+
+       default:
+               if ((proto = getprotobynumber(ipds->nh)) != NULL)
+                       ND_PRINT((ndo, " %s", proto->p_name));
+               else
+                       ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
+               ND_PRINT((ndo, " %d", ipds->len));
+               break;
+       }
+}
+              
+
 /*
  * print an IP datagram.
  */
 void
-ip_print(register const u_char *bp, register u_int length)
+ip_print(netdissect_options *ndo,
+        const u_char *bp,
+        u_int length)
 {
-       register const struct ip *ip;
-       register u_int hlen, len, off;
+       struct ip_print_demux_state  ipd;
+       struct ip_print_demux_state *ipds=&ipd;
        const u_char *ipend;
-       register const u_char *cp;
-       u_char nh;
-       int advance;
-       struct protoent *proto;
        u_int16_t sum, ip_sum;
+       struct protoent *proto;
 
-       ip = (const struct ip *)bp;
-       if (IP_V(ip) != 4) { /* print version if != 4 */
-           printf("IP%u ", IP_V(ip));
-           if (IP_V(ip) == 6)
+       ipds->ip = (const struct ip *)bp;
+       if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
+           printf("IP%u ", IP_V(ipds->ip));
+           if (IP_V(ipds->ip) == 6)
                printf(", wrong link-layer encapsulation");
        }
         else if (!eflag)
            printf("IP ");
 
-       if ((u_char *)(ip + 1) > snapend) {
+       if ((u_char *)(ipds->ip + 1) > snapend) {
                printf("[|ip]");
                return;
        }
@@ -388,28 +544,28 @@ ip_print(register const u_char *bp, register u_int length)
                (void)printf("truncated-ip %u", length);
                return;
        }
-       hlen = IP_HL(ip) * 4;
-       if (hlen < sizeof (struct ip)) {
-               (void)printf("bad-hlen %u", hlen);
+       ipds->hlen = IP_HL(ipds->ip) * 4;
+       if (ipds->hlen < sizeof (struct ip)) {
+               (void)printf("bad-hlen %u", ipds->hlen);
                return;
        }
 
-       len = EXTRACT_16BITS(&ip->ip_len);
-       if (length < len)
+       ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
+       if (length < ipds->len)
                (void)printf("truncated-ip - %u bytes missing! ",
-                       len - length);
-       if (len < hlen) {
+                       ipds->len - length);
+       if (ipds->len < ipds->hlen) {
 #ifdef GUESS_TSO
-            if (len) {
-                (void)printf("bad-len %u", len);
+            if (ipds->len) {
+                (void)printf("bad-len %u", ipds->len);
                 return;
             }
             else {
                 /* we guess that it is a TSO send */
-                len = length;
+                ipds->len = length;
             }
 #else
-            (void)printf("bad-len %u", len);
+            (void)printf("bad-len %u", ipds->len);
             return;
 #endif /* GUESS_TSO */
        }
@@ -417,19 +573,19 @@ ip_print(register const u_char *bp, register u_int length)
        /*
         * Cut off the snapshot length to the end of the IP payload.
         */
-       ipend = bp + len;
+       ipend = bp + ipds->len;
        if (ipend < snapend)
                snapend = ipend;
 
-       len -= hlen;
+       ipds->len -= ipds->hlen;
 
-       off = EXTRACT_16BITS(&ip->ip_off);
+       ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
 
         if (vflag) {
-            (void)printf("(tos 0x%x", (int)ip->ip_tos);
+            (void)printf("(tos 0x%x", (int)ipds->ip->ip_tos);
             /* ECN bits */
-            if (ip->ip_tos & 0x03) {
-                switch (ip->ip_tos & 0x03) {
+            if (ipds->ip->ip_tos & 0x03) {
+                switch (ipds->ip->ip_tos & 0x03) {
                 case 1:
                     (void)printf(",ECT(1)");
                     break;
@@ -441,8 +597,8 @@ ip_print(register const u_char *bp, register u_int length)
                 }
             }
 
-            if (ip->ip_ttl >= 1)
-                (void)printf(", ttl %3u", ip->ip_ttl);    
+            if (ipds->ip->ip_ttl >= 1)
+                (void)printf(", ttl %3u", ipds->ip->ip_ttl);    
 
            /*
             * for the firewall guys, print id, offset.
@@ -451,24 +607,24 @@ ip_print(register const u_char *bp, register u_int length)
             */
 
            (void)printf(", id %u, offset %u, flags [%s], proto: %s (%u)",
-                         EXTRACT_16BITS(&ip->ip_id),
-                         (off & 0x1fff) * 8,
-                         bittok2str(ip_frag_values, "none", off & 0xe000 ),
-                         tok2str(ipproto_values,"unknown",ip->ip_p),
-                         ip->ip_p);
+                         EXTRACT_16BITS(&ipds->ip->ip_id),
+                         (ipds->off & 0x1fff) * 8,
+                         bittok2str(ip_frag_values, "none", ipds->off&0xe000 ),
+                         tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
+                         ipds->ip->ip_p);
 
-            (void)printf(", length: %u", EXTRACT_16BITS(&ip->ip_len));
+            (void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len));
 
-            if ((hlen - sizeof(struct ip)) > 0) {
+            if ((ipds->hlen - sizeof(struct ip)) > 0) {
                 printf(", options ( ");
-                ip_optprint((u_char *)(ip + 1), hlen - sizeof(struct ip));
+                ip_optprint((u_char *)(ipds->ip + 1), ipds->hlen - sizeof(struct ip));
                 printf(" )");
             }
 
-           if ((u_char *)ip + hlen <= snapend) {
-               sum = in_cksum((const u_short *)iphlen, 0);
+           if ((u_char *)ipds->ip + ipds->hlen <= snapend) {
+               sum = in_cksum((const u_short *)ipds->ip, ipds->hlen, 0);
                if (sum != 0) {
-                   ip_sum = EXTRACT_16BITS(&ip->ip_sum);
+                   ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
                    (void)printf(", bad cksum %x (->%x)!", ip_sum,
                             in_cksum_shouldbe(ip_sum, sum));
                }
@@ -481,150 +637,17 @@ ip_print(register const u_char *bp, register u_int length)
         * If this is fragment zero, hand it to the next higher
         * level protocol.
         */
-       if ((off & 0x1fff) == 0) {
-               cp = (const u_char *)ip + hlen;
-               nh = ip->ip_p;
-
-               if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
-                   nh != IPPROTO_SCTP) {
-                       (void)printf("%s > %s: ", ipaddr_string(&ip->ip_src),
-                               ipaddr_string(&ip->ip_dst));
-               }
-again:
-               switch (nh) {
-
-               case IPPROTO_AH:
-                       nh = *cp;
-                       advance = ah_print(cp);
-                       if (advance <= 0)
-                               break;
-                       cp += advance;
-                       len -= advance;
-                       goto again;
-
-               case IPPROTO_ESP:
-                   {
-                       int enh, padlen;
-                       advance = esp_print(gndo, cp, len, (const u_char *)ip, &enh, &padlen);
-                       if (advance <= 0)
-                               break;
-                       cp += advance;
-                       len -= advance + padlen;
-                       nh = enh & 0xff;
-                       goto again;
-                   }
-
-               case IPPROTO_IPCOMP:
-                   {
-                       int enh;
-                       advance = ipcomp_print(cp, &enh);
-                       if (advance <= 0)
-                               break;
-                       cp += advance;
-                       len -= advance;
-                       nh = enh & 0xff;
-                       goto again;
-                   }
-
-               case IPPROTO_SCTP:
-                       sctp_print(cp, (const u_char *)ip, len);
-                       break;
-
-               case IPPROTO_TCP:
-                       tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
-                       break;
-
-               case IPPROTO_UDP:
-                       udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
-                       break;
-
-               case IPPROTO_ICMP:
-                       /* pass on the MF bit plus the offset to detect fragments */
-                       icmp_print(cp, len, (const u_char *)ip, (off & 0x3fff));
-                       break;
-
-               case IPPROTO_PIGP:
-                       /*
-                        * XXX - the current IANA protocol number assignments
-                        * page lists 9 as "any private interior gateway
-                        * (used by Cisco for their IGRP)" and 88 as
-                        * "EIGRP" from Cisco.
-                        *
-                        * Recent BSD <netinet/in.h> headers define
-                        * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
-                        * We define IP_PROTO_PIGP as 9 and
-                        * IP_PROTO_EIGRP as 88; those names better
-                        * match was the current protocol number
-                        * assignments say.
-                        */
-                       igrp_print(cp, len, (const u_char *)ip);
-                       break;
-
-               case IPPROTO_EIGRP:
-                       eigrp_print(cp, len);
-                       break;
-
-               case IPPROTO_ND:
-                       (void)printf(" nd %d", len);
-                       break;
-
-               case IPPROTO_EGP:
-                       egp_print(cp, len);
-                       break;
-
-               case IPPROTO_OSPF:
-                       ospf_print(cp, len, (const u_char *)ip);
-                       break;
-
-               case IPPROTO_IGMP:
-                       igmp_print(cp, len);
-                       break;
-
-               case IPPROTO_IPV4:
-                       /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
-                       ip_print(cp, len);
-                       if (! vflag) {
-                               printf(" (ipip-proto-4)");
-                               return;
-                       }
-                       break;
-
-#ifdef INET6
-               case IPPROTO_IPV6:
-                       /* ip6-in-ip encapsulation */
-                       ip6_print(cp, len);
-                       break;
-#endif /*INET6*/
-
-               case IPPROTO_RSVP:
-                       rsvp_print(cp, len);
-                       break;
-
-               case IPPROTO_GRE:
-                       /* do it */
-                       gre_print(cp, len);
-                       break;
-
-               case IPPROTO_MOBILE:
-                       mobile_print(cp, len);
-                       break;
-
-               case IPPROTO_PIM:
-                       pim_print(cp, len);
-                       break;
-
-               case IPPROTO_VRRP:
-                       vrrp_print(cp, len, ip->ip_ttl);
-                       break;
-
-               default:
-                       if ((proto = getprotobynumber(nh)) != NULL)
-                               (void)printf(" %s", proto->p_name);
-                       else
-                               (void)printf(" ip-proto-%d", nh);
-                       printf(" %d", len);
-                       break;
+       if ((ipds->off & 0x1fff) == 0) {
+               ipds->cp = (const u_char *)ipds->ip + ipds->hlen;
+               ipds->nh = ipds->ip->ip_p;
+
+               if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
+                   ipds->nh != IPPROTO_SCTP) {
+                       (void)printf("%s > %s: ",
+                                    ipaddr_string(&ipds->ip->ip_src),
+                                    ipaddr_string(&ipds->ip->ip_dst));
                }
+               ip_print_demux(ndo, ipds);
        } else {
            /* Ultra quiet now means that all this stuff should be suppressed */
            if (qflag > 1) return;
@@ -634,13 +657,13 @@ again:
             * next level protocol header.  print the ip addr
             * and the protocol.
             */
-           if (off & 0x1fff) {
-               (void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
-                            ipaddr_string(&ip->ip_dst));
-               if ((proto = getprotobynumber(ip->ip_p)) != NULL)
+           if (ipds->off & 0x1fff) {
+               (void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
+                            ipaddr_string(&ipds->ip->ip_dst));
+               if ((proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
                    (void)printf(" %s", proto->p_name);
                else
-                   (void)printf(" ip-proto-%d", ip->ip_p);
+                   (void)printf(" ip-proto-%d", ipds->ip->ip_p);
            } 
        }
 }
@@ -658,7 +681,7 @@ ipN_print(register const u_char *bp, register u_int length)
        memcpy (&hdr, (char *)ip, 4);
        switch (IP_V(&hdr)) {
        case 4:
-               ip_print (bp, length);
+               ip_print (gndo, bp, length);
                return;
 #ifdef INET6
        case 6:
index f174888a0f6fe4f5cae1bc9b210b79c1570e5ab1..05db9d97da2d3d214bb9e874dd4f0f123345b2d0 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.46 2004-09-29 16:49:32 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47 2005-04-06 21:32:40 mcr Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -201,7 +201,7 @@ ip6_print(register const u_char *bp, register u_int length)
                        return;
 
                case IPPROTO_IPV4:
-                       ip_print(cp, len);
+                       ip_print(gndo, cp, len);
                        return;
 
                case IPPROTO_NONE:
index 5eba78c52edfc18bd25380b8d547d2d1b5f3d1ee..106e9d533a615fca09a7821efe2abed9b5173350 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.132 2005-04-02 18:32:41 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133 2005-04-06 21:32:40 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -594,7 +594,7 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
                 break;
 
         case NLPID_IP:
-                ip_print(p+1, length-1);
+               ip_print(gndo, p+1, length-1);
                 break;
 
 #ifdef INET6
@@ -2437,3 +2437,11 @@ osi_cksum(const u_int8_t *tptr, u_int len)
        }
        return (c0 | c1);
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index d90bce80823118dd232d9cb5b2c78ad246e0ff7b..80c9e88a3330dcdbe8f490e84b0cedd37d837a5a 100644 (file)
@@ -15,7 +15,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.7 2005-01-27 18:30:36 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8 2005-04-06 21:32:41 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -337,8 +337,8 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
     case 0x4d:
     case 0x4e:
     case 0x4f:
-        ip_print(p, length);
-        break;
+           ip_print(gndo, p, length);
+           break;
 #ifdef INET6
     case 0x60:
     case 0x61:
@@ -399,3 +399,11 @@ juniper_parse_header (const u_char *p, u_int8_t *direction, u_int length) {
     }
     return 1; /* everything went ok so far. continue parsing */
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index f1b8eb423c03c8e397b535e344228c2916e512fe..52250f2ffb537e082bfa3d8dea7c63c82ea2f07c 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.60 2005-04-06 20:09:08 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61 2005-04-06 21:32:41 mcr Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -131,7 +131,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
        }
 
        if (llc.ssap == LLCSAP_IP && llc.dsap == LLCSAP_IP) {
-               ip_print(p+4, length-4);
+               ip_print(gndo, p+4, length-4);
                return (1);
        }
 
@@ -438,3 +438,11 @@ snap_print(const u_char *p, u_int length, u_int caplen,
        }
        return (0);
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index a6de5cf12f5a56463bf425925cbb507faee487b2..a2043eaca114fbacd679d1ea20df8ceb26fefe10 100644 (file)
@@ -28,7 +28,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.12 2004-06-14 14:47:58 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.13 2005-04-06 21:32:41 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -86,7 +86,7 @@ mpls_print(const u_char *bp, u_int length)
        switch (MPLS_LABEL(v)) {
        case 0: /* IPv4 explicit NULL label */
         case 3:        /* IPv4 implicit NULL label */
-               ip_print(p, length - (p - bp));
+               ip_print(gndo, p, length - (p - bp));
                break;
 #ifdef INET6
        case 2: /* IPv6 explicit NULL label */
@@ -122,7 +122,7 @@ mpls_print(const u_char *bp, u_int length)
                     case 0x4f:
                        if (vflag>0) {
                             printf("\n\t");
-                            ip_print(p, length - (p - bp));
+                            ip_print(gndo, p, length - (p - bp));
                            }
                         else printf(", IP, length: %u",length);
                         break;
@@ -170,3 +170,11 @@ mpls_print(const u_char *bp, u_int length)
 trunc:
        printf("[|MPLS]");
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index 50d445e580a918fe64dd71431e996d37a3095a73..a228ab7cec53711bf8465db08fc68c6a2e171c4d 100644 (file)
@@ -17,7 +17,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.6 2003-11-16 09:36:29 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -70,7 +70,7 @@ msdp_print(const unsigned char *sp, u_int length)
                                (void)printf(" [w/data]");
                                if (vflag > 1) {
                                        (void)printf(" ");
-                                       ip_print(sp + *sp * 12 + 8 - 3,
+                                       ip_print(gndo, sp + *sp * 12 + 8 - 3,
                                                 len - (*sp * 12 + 8));
                                }
                        }
@@ -99,3 +99,10 @@ msdp_print(const unsigned char *sp, u_int length)
 trunc:
        (void)printf(" [|msdp]");
 }
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index cfb431e58e16d3d4ec80a7a4483b92b749932c45..bfdf3e41958e79608f737a22b37ae65eb32f5757 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.52 2004-03-17 23:24:38 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53 2005-04-06 21:32:41 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -163,7 +163,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
        switch (family) {
 
        case BSD_AF_INET:
-               ip_print(p, length);
+               ip_print(gndo, p, length);
                break;
 
 #ifdef INET6
@@ -197,3 +197,9 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
        return (NULL_HDRLEN);
 }
 
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index 463cd18bbd011f13de1cbed7903ff3370b4f2011..6cd004cc1c68cddf97da3a8c30525ff92f9575c0 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.12 2004-04-02 06:48:10 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.13 2005-04-06 21:32:41 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -136,7 +136,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 #if OPENBSD_AF_INET != AF_INET
                case OPENBSD_AF_INET:           /* XXX: read pcap files */
 #endif
-                       ip_print(p, length);
+                       ip_print(gndo, p, length);
                        break;
 
 #ifdef INET6
@@ -161,3 +161,10 @@ trunc:
        printf("[|pflog]");
        return (hdrlen);
 }
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index 82c19f2ab88704f2bedab75e24b4834c3829daa3..18c6da4df5307cc00573843d3afccaff72bfef1c 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.44 2004-09-29 16:49:31 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45 2005-04-06 21:32:42 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -743,7 +743,7 @@ pimv2_print(register const u_char *bp, register u_int len)
                switch (IP_V(ip)) {
                case 4: /* IPv4 */
                        printf(" ");
-                       ip_print(bp, len);
+                       ip_print(gndo, bp, len);
                        break;
 #ifdef INET6
                case 6: /* IPv6 */
@@ -1062,3 +1062,10 @@ pimv2_print(register const u_char *bp, register u_int len)
 trunc:
        (void)printf("[|pim]");
 }
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index 43fddfa2020d60a939c7182782c9e6b930a0c8af..84429012acc85fec7a04291e832ed2d07d7fd256 100644 (file)
@@ -31,7 +31,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.107 2005-01-25 16:27:56 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108 2005-04-06 21:32:42 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -1149,8 +1149,8 @@ ppp_hdlc(const u_char *p, int length)
         
         switch (proto) {
         case PPP_IP:
-            ip_print(b+1, t - b - 1);
-            goto cleanup;
+               ip_print(gndo, b+1, t - b - 1);
+               goto cleanup;
 #ifdef INET6
         case PPP_IPV6:
             ip6_print(b+1, t - b - 1);
@@ -1213,7 +1213,7 @@ handle_ppp(u_int proto, const u_char *p, int length)
        case ETHERTYPE_IP:      /*XXX*/
         case PPP_VJNC:
        case PPP_IP:
-               ip_print(p, length);
+               ip_print(gndo, p, length);
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:    /*XXX*/
@@ -1597,3 +1597,11 @@ printx:
 #endif /* __bsdi__ */
        return (hdrlength);
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
index dbe423da90e50c126cca30bea279e1ce8bde983a..f00d3943d320a6d4613f8ad9265210fa4238eb6a 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.64 2003-11-16 09:36:36 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005-04-06 21:32:42 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -69,7 +69,7 @@ sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
 
        switch (IP_V(ip)) {
        case 4:
-               ip_print((u_char *)ip, length);
+               ip_print(gndo, (u_char *)ip, length);
                break;
 #ifdef INET6
        case 6:
@@ -104,7 +104,7 @@ sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
                sliplink_print(p, ip, length);
 #endif
 
-       ip_print((u_char *)ip, length);
+       ip_print(gndo, (u_char *)ip, length);
 
        return (SLIP_HDRLEN);
 }