diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-08-26 20:06:34 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-08-26 20:06:50 -0700 |
commit | 516d11ec82618d1bfaf19a693b1171eaac42397e (patch) | |
tree | d668f250bf8517df1fc1473c88cf5cf92813fca3 /print-cnfp.c | |
parent | 2db5b35a8d7944ef882ead93c7f83dda70476975 (diff) | |
download | tcpdump-516d11ec82618d1bfaf19a693b1171eaac42397e.tar.gz |
If -n is specified, don't look up IP protocol numbers.
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.
Diffstat (limited to 'print-cnfp.c')
-rw-r--r-- | print-cnfp.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/print-cnfp.c b/print-cnfp.c index e3e9b6d0..bd9b8a65 100644 --- a/print-cnfp.c +++ b/print-cnfp.c @@ -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) { |