]> The Tcpdump Group git mirrors - tcpdump/commitdiff
If -n is specified, don't look up IP protocol numbers.
authorGuy Harris <[email protected]>
Sun, 27 Aug 2017 03:06:34 +0000 (20:06 -0700)
committerDenis Ovsienko <[email protected]>
Fri, 1 Sep 2017 15:26:16 +0000 (16:26 +0100)
In ISAKMP, that means "add a test for the -n flag".

In CNFP, that means "if -n is specified, don't even bother doing the
lookup, don't do the lookup and then ignore the result" - the latter
just wastes resources doing the lookup.

print-cnfp.c
print-isakmp.c

index e3e9b6d07b8ba0af6ad9a5c81aad76baf0b6aa65..bd9b8a6586fd1c534c2becb76529c85085a6fdbe 100644 (file)
@@ -211,11 +211,10 @@ cnfp_v1_print(netdissect_options *ndo, const u_char *cp)
 
                ND_PRINT((ndo, ">> %s\n    ", intoa(nr->nhop_ina.s_addr)));
 
-               pent = getprotobynumber(nr->proto);
-               if (!pent || ndo->ndo_nflag)
-                       ND_PRINT((ndo, "%u ", nr->proto));
-               else
+               if (!ndo->ndo_nflag && (pent = getprotobynumber(nr->proto)) != NULL)
                        ND_PRINT((ndo, "%s ", pent->p_name));
+               else
+                       ND_PRINT((ndo, "%u ", nr->proto));
 
                /* tcp flags for tcp only */
                if (pent && pent->p_proto == IPPROTO_TCP) {
@@ -308,11 +307,10 @@ cnfp_v5_print(netdissect_options *ndo, const u_char *cp)
 
                ND_PRINT((ndo, ">> %s\n    ", intoa(nr->nhop_ina.s_addr)));
 
-               pent = getprotobynumber(nr->proto);
-               if (!pent || ndo->ndo_nflag)
-                       ND_PRINT((ndo, "%u ", nr->proto));
-               else
+               if (!ndo->ndo_nflag && (pent = getprotobynumber(nr->proto)) != NULL)
                        ND_PRINT((ndo, "%s ", pent->p_name));
+               else
+                       ND_PRINT((ndo, "%u ", nr->proto));
 
                /* tcp flags for tcp only */
                if (pent && pent->p_proto == IPPROTO_TCP) {
@@ -405,11 +403,10 @@ cnfp_v6_print(netdissect_options *ndo, const u_char *cp)
 
                ND_PRINT((ndo, ">> %s\n    ", intoa(nr->nhop_ina.s_addr)));
 
-               pent = getprotobynumber(nr->proto);
-               if (!pent || ndo->ndo_nflag)
-                       ND_PRINT((ndo, "%u ", nr->proto));
-               else
+               if (!ndo->ndo_nflag && (pent = getprotobynumber(nr->proto)) != NULL)
                        ND_PRINT((ndo, "%s ", pent->p_name));
+               else
+                       ND_PRINT((ndo, "%u ", nr->proto));
 
                /* tcp flags for tcp only */
                if (pent && pent->p_proto == IPPROTO_TCP) {
index 3dfa171f2bb5d192ba327749dbf5dbe82640b41f..02223c525bdf55155c423a169b3cb1d20f161578 100644 (file)
@@ -1353,8 +1353,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
                UNALIGNED_MEMCPY(&doi_id, ext, sizeof(doi_id));
                ND_PRINT((ndo," idtype=%s", STR_OR_ID(doi_id.type, ipsecidtypestr)));
                /* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */
-               pe = doi_id.proto_id ? getprotobynumber(doi_id.proto_id) : NULL;
-               if (pe)
+               if (!ndo->ndo_nflag && doi_id.proto_id && (pe = getprotobynumber(doi_id.proto_id)) != NULL)
                        ND_PRINT((ndo," protoid=%s", pe->p_name));
                else
                        ND_PRINT((ndo," protoid=%u", doi_id.proto_id));