X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ad7a38341c19e71e3595c17368ac18f08b71482d..refs/pull/440/head:/print-sunrpc.c diff --git a/print-sunrpc.c b/print-sunrpc.c index 4652e8f2..bc7138de 100644 --- a/print-sunrpc.c +++ b/print-sunrpc.c @@ -19,11 +19,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.47 2005-04-27 21:43:48 guy Exp $ (LBL)"; -#endif - +#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -137,23 +133,23 @@ static const char rcsid[] _U_ = * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. */ -#define SUNRPC_PMAPPORT ((u_int16_t)111) -#define SUNRPC_PMAPPROG ((u_int32_t)100000) -#define SUNRPC_PMAPVERS ((u_int32_t)2) -#define SUNRPC_PMAPVERS_PROTO ((u_int32_t)2) -#define SUNRPC_PMAPVERS_ORIG ((u_int32_t)1) -#define SUNRPC_PMAPPROC_NULL ((u_int32_t)0) -#define SUNRPC_PMAPPROC_SET ((u_int32_t)1) -#define SUNRPC_PMAPPROC_UNSET ((u_int32_t)2) -#define SUNRPC_PMAPPROC_GETPORT ((u_int32_t)3) -#define SUNRPC_PMAPPROC_DUMP ((u_int32_t)4) -#define SUNRPC_PMAPPROC_CALLIT ((u_int32_t)5) +#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) +#define SUNRPC_PMAPPROC_GETPORT ((uint32_t)3) +#define SUNRPC_PMAPPROC_DUMP ((uint32_t)4) +#define SUNRPC_PMAPPROC_CALLIT ((uint32_t)5) struct sunrpc_pmap { - u_int32_t pm_prog; - u_int32_t pm_vers; - u_int32_t pm_prot; - u_int32_t pm_port; + uint32_t pm_prog; + uint32_t pm_vers; + uint32_t pm_prot; + uint32_t pm_port; }; static const struct tok proc2str[] = { @@ -167,23 +163,23 @@ static const struct tok proc2str[] = { }; /* Forwards */ -static char *progstr(u_int32_t); +static char *progstr(uint32_t); void -sunrpcrequest_print(register const u_char *bp, register u_int length, - register const u_char *bp2) +sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp, + register u_int length, register const u_char *bp2) { register const struct sunrpc_msg *rp; register const struct ip *ip; #ifdef INET6 register const struct ip6_hdr *ip6; #endif - u_int32_t x; + uint32_t x; char srcid[20], dstid[20]; /*fits 32bit*/ rp = (struct sunrpc_msg *)bp; - if (!nflag) { + if (!ndo->ndo_nflag) { snprintf(srcid, sizeof(srcid), "0x%x", EXTRACT_32BITS(&rp->rm_xid)); strlcpy(dstid, "sunrpc", sizeof(dstid)); @@ -196,28 +192,28 @@ sunrpcrequest_print(register const u_char *bp, register u_int length, switch (IP_V((struct ip *)bp2)) { case 4: ip = (struct ip *)bp2; - printf("%s.%s > %s.%s: %d", - ipaddr_string(&ip->ip_src), srcid, - ipaddr_string(&ip->ip_dst), dstid, length); + ND_PRINT((ndo, "%s.%s > %s.%s: %d", + ipaddr_string(ndo, &ip->ip_src), srcid, + ipaddr_string(ndo, &ip->ip_dst), dstid, length)); break; #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp2; - printf("%s.%s > %s.%s: %d", - ip6addr_string(&ip6->ip6_src), srcid, - ip6addr_string(&ip6->ip6_dst), dstid, length); + ND_PRINT((ndo, "%s.%s > %s.%s: %d", + ip6addr_string(ndo, &ip6->ip6_src), srcid, + ip6addr_string(ndo, &ip6->ip6_dst), dstid, length)); break; #endif default: - printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length); + ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length)); break; } - printf(" %s", tok2str(proc2str, " proc #%u", - EXTRACT_32BITS(&rp->rm_call.cb_proc))); + ND_PRINT((ndo, " %s", tok2str(proc2str, " proc #%u", + EXTRACT_32BITS(&rp->rm_call.cb_proc)))); x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers); if (x != 2) - printf(" [rpcver %u]", x); + ND_PRINT((ndo, " [rpcver %u]", x)); switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) { @@ -226,24 +222,23 @@ sunrpcrequest_print(register const u_char *bp, register u_int length, case SUNRPC_PMAPPROC_GETPORT: case SUNRPC_PMAPPROC_CALLIT: x = EXTRACT_32BITS(&rp->rm_call.cb_prog); - if (!nflag) - printf(" %s", progstr(x)); + if (!ndo->ndo_nflag) + ND_PRINT((ndo, " %s", progstr(x))); else - printf(" %u", x); - printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers)); + ND_PRINT((ndo, " %u", x)); + ND_PRINT((ndo, ".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers))); break; } } static char * -progstr(prog) - u_int32_t prog; +progstr(uint32_t prog) { #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H) register struct rpcent *rp; #endif static char buf[32]; - static u_int32_t lastprog = 0; + static uint32_t lastprog = 0; if (lastprog != 0 && prog == lastprog) return (buf);