]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
Merge pull request #827 from NanXiao/patch-1
[tcpdump] / print-ip.c
index 3478de172dfa4f7ab39c3abf61b43763f5d7bef9..8001f7746661e1630799b1503d9ea50d08984b81 100644 (file)
@@ -73,7 +73,7 @@ ip_printroute(netdissect_options *ndo,
 
        for (len = 3; len < length; len += 4) {
                ND_TCHECK_4(cp + len);
-               ND_PRINT(" %s", ipaddr_string(ndo, cp + len));
+               ND_PRINT(" %s", GET_IPADDR_STRING(cp + len));
                if (ptr > len)
                        ND_PRINT(",");
        }
@@ -223,7 +223,7 @@ ip_printts(netdissect_options *ndo,
                        type = " ^ ";
                ND_TCHECK_LEN(cp + len, hoplen);
                ND_PRINT("%s%u@%s", type, GET_BE_U_4(cp + len + hoplen - 4),
-                         hoplen!=8 ? "" : ipaddr_string(ndo, cp + len));
+                         hoplen!=8 ? "" : GET_IPADDR_STRING(cp + len));
                type = " ";
        }
 
@@ -340,7 +340,6 @@ ip_print(netdissect_options *ndo,
         u_int length)
 {
        const struct ip *ip;
-       const u_char *ipend;
        u_int off;
        u_int hlen;
        u_int len;
@@ -397,9 +396,7 @@ ip_print(netdissect_options *ndo,
        /*
         * Cut off the snapshot length to the end of the IP payload.
         */
-       ipend = bp + len;
-       if (ipend < ndo->ndo_snapend)
-               ndo->ndo_snapend = ipend;
+       nd_push_snapend(ndo, bp + len);
 
        len -= hlen;
 
@@ -471,9 +468,11 @@ ip_print(netdissect_options *ndo,
            ND_PRINT(")\n    ");
            if (truncated) {
                ND_PRINT("%s > %s: ",
-                        ipaddr_string(ndo, ip->ip_src),
-                        ipaddr_string(ndo, ip->ip_dst));
-               goto trunc;
+                        GET_IPADDR_STRING(ip->ip_src),
+                        GET_IPADDR_STRING(ip->ip_dst));
+               nd_print_trunc(ndo);
+               nd_pop_packet_info(ndo);
+               return;
            }
        }
 
@@ -488,8 +487,8 @@ ip_print(netdissect_options *ndo,
                if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
                    nh != IPPROTO_SCTP && nh != IPPROTO_DCCP) {
                        ND_PRINT("%s > %s: ",
-                                    ipaddr_string(ndo, ip->ip_src),
-                                    ipaddr_string(ndo, ip->ip_dst));
+                                    GET_IPADDR_STRING(ip->ip_src),
+                                    GET_IPADDR_STRING(ip->ip_dst));
                }
                ip_print_demux(ndo, (const u_char *)ip + hlen, len, 4,
                    off & IP_MF, GET_U_1(ip->ip_ttl), nh, bp);
@@ -498,21 +497,24 @@ ip_print(netdissect_options *ndo,
                 * Ultra quiet now means that all this stuff should be
                 * suppressed.
                 */
-               if (ndo->ndo_qflag > 1)
+               if (ndo->ndo_qflag > 1) {
+                       nd_pop_packet_info(ndo);
                        return;
+               }
 
                /*
                 * This isn't the first frag, so we're missing the
                 * next level protocol header.  print the ip addr
                 * and the protocol.
                 */
-               ND_PRINT("%s > %s:", ipaddr_string(ndo, ip->ip_src),
-                         ipaddr_string(ndo, ip->ip_dst));
+               ND_PRINT("%s > %s:", GET_IPADDR_STRING(ip->ip_src),
+                         GET_IPADDR_STRING(ip->ip_dst));
                if (!ndo->ndo_nflag && (p_name = netdb_protoname(ip_proto)) != NULL)
                        ND_PRINT(" %s", p_name);
                else
                        ND_PRINT(" ip-proto-%u", ip_proto);
        }
+       nd_pop_packet_info(ndo);
        return;
 
 trunc:
@@ -523,7 +525,7 @@ trunc:
 void
 ipN_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
-       ndo->ndo_protocol = "ipN";
+       ndo->ndo_protocol = "ipn";
        if (length < 1) {
                ND_PRINT("truncated-ip %u", length);
                return;