]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Sun RPC: Modernize packet parsing style.
authorDenis Ovsienko <[email protected]>
Tue, 1 Dec 2020 19:13:24 +0000 (19:13 +0000)
committerDenis Ovsienko <[email protected]>
Tue, 1 Dec 2020 19:13:24 +0000 (19:13 +0000)
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.

print-sunrpc.c
rpc_auth.h

index 651963ce6767b08f2299188d661039c8cd23d2ef..82bfd8a9d92a4583767cade34485af8f54995820 100644 (file)
@@ -52,6 +52,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
  */
 
 #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);
 }
index 3385ab9d42ec29b65b1cce9bca11e5a4eb552459..b73e3be048d1ee992f9fecc5eb5603c571b2a50a 100644 (file)
@@ -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) */