summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2020-12-01 19:13:24 +0000
committerDenis Ovsienko <denis@ovsienko.info>2020-12-01 19:13:24 +0000
commit75fe4ba35dd633614eaa2b5ea2daeb672978647b (patch)
tree66267a6193dfe10f08fbf2944cac9348ab9bcb78
parent9fd5c63aaa6d118b8785da56c16fcc66a7f9b741 (diff)
downloadtcpdump-75fe4ba35dd633614eaa2b5ea2daeb672978647b.tar.gz
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.
-rw-r--r--print-sunrpc.c20
-rw-r--r--rpc_auth.h7
2 files changed, 6 insertions, 21 deletions
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 <stdio.h>
#include <string.h>
+#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) */