]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
IPoIB: Add the output with -e for a capture test
[tcpdump] / print-ip.c
index a701fede62d5b0bfa844b27a31ed2551497372f0..a77bfce832057c7c5f222e90425a42f62730df50 100644 (file)
@@ -141,13 +141,13 @@ trunc:
 uint16_t
 nextproto4_cksum(netdissect_options *ndo,
                  const struct ip *ip, const uint8_t *data,
-                 u_int len, u_int covlen, u_int next_proto)
+                 u_int len, u_int covlen, uint8_t next_proto)
 {
        struct phdr {
                uint32_t src;
                uint32_t dst;
-               u_char mbz;
-               u_char proto;
+               uint8_t mbz;
+               uint8_t proto;
                uint16_t len;
        } ph;
        struct cksum_vec vec[2];
@@ -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;
 
@@ -483,7 +480,7 @@ ip_print(netdissect_options *ndo,
         * fragments.
         */
        if ((off & IP_OFFMASK) == 0) {
-               u_int nh = GET_U_1(ip->ip_p);
+               uint8_t nh = GET_U_1(ip->ip_p);
 
                if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
                    nh != IPPROTO_SCTP && nh != IPPROTO_DCCP) {
@@ -498,8 +495,10 @@ 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
@@ -513,10 +512,12 @@ ip_print(netdissect_options *ndo,
                else
                        ND_PRINT(" ip-proto-%u", ip_proto);
        }
+       nd_pop_packet_info(ndo);
        return;
 
 trunc:
        nd_print_trunc(ndo);
+       nd_pop_packet_info(ndo);
        return;
 }