From: Denis Ovsienko Date: Tue, 1 Dec 2020 19:13:24 +0000 (+0000) Subject: Sun RPC: Modernize packet parsing style. X-Git-Tag: tcpdump-4.99-bp~52 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/75fe4ba35dd633614eaa2b5ea2daeb672978647b Sun RPC: Modernize packet parsing style. Enable ND_LONGJMP_FROM_TCHECK. Lose a few unused constants and use another one. In progstr() swap if() branches to lose one #ifdef wrapper and set lastprog to make the static cache, which has been in place at least since 1999, actually work. --- diff --git a/print-sunrpc.c b/print-sunrpc.c index 651963ce..82bfd8a9 100644 --- a/print-sunrpc.c +++ b/print-sunrpc.c @@ -52,6 +52,7 @@ #include #include +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "addrtoname.h" #include "extract.h" @@ -133,10 +134,6 @@ */ #define SUNRPC_PMAPPORT ((uint16_t)111) -#define SUNRPC_PMAPPROG ((uint32_t)100000) -#define SUNRPC_PMAPVERS ((uint32_t)2) -#define SUNRPC_PMAPVERS_PROTO ((uint32_t)2) -#define SUNRPC_PMAPVERS_ORIG ((uint32_t)1) #define SUNRPC_PMAPPROC_NULL ((uint32_t)0) #define SUNRPC_PMAPPROC_SET ((uint32_t)1) #define SUNRPC_PMAPPROC_UNSET ((uint32_t)2) @@ -202,7 +199,7 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp, ND_PRINT(" %s", tok2str(proc2str, " proc #%u", GET_BE_U_4(rp->rm_call.cb_proc))); x = GET_BE_U_4(rp->rm_call.cb_rpcvers); - if (x != 2) + if (x != SUNRPC_MSG_VERSION) ND_PRINT(" [rpcver %u]", x); switch (GET_BE_U_4(rp->rm_call.cb_proc)) { @@ -219,10 +216,6 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp, ND_PRINT(".%u", GET_BE_U_4(rp->rm_call.cb_vers)); break; } - return; - -trunc: - nd_print_trunc(ndo); } static char * @@ -238,12 +231,11 @@ progstr(uint32_t prog) return (buf); #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H) rp = getrpcbynumber(prog); - if (rp == NULL) -#endif - (void) snprintf(buf, sizeof(buf), "#%u", prog); -#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H) - else + if (rp != NULL) strlcpy(buf, rp->r_name, sizeof(buf)); + else #endif + (void) snprintf(buf, sizeof(buf), "#%u", prog); + lastprog = prog; return (buf); } diff --git a/rpc_auth.h b/rpc_auth.h index 3385ab9d..b73e3be0 100644 --- a/rpc_auth.h +++ b/rpc_auth.h @@ -69,10 +69,3 @@ struct sunrpc_opaque_auth { nd_uint32_t oa_len; /* length of opaque body */ /* zero or more bytes of body */ }; - -#define SUNRPC_AUTH_NONE 0 /* no authentication */ -#define SUNRPC_AUTH_NULL 0 /* backward compatibility */ -#define SUNRPC_AUTH_UNIX 1 /* unix style (uid, gids) */ -#define SUNRPC_AUTH_SYS 1 /* forward compatibility */ -#define SUNRPC_AUTH_SHORT 2 /* short hand unix style */ -#define SUNRPC_AUTH_DES 3 /* des style (encrypted timestamps) */