2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 static const char rcsid[] _U_ =
26 "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.43.2.2 2003/11/16 08:51:47 guy Exp $ (LBL)";
33 #include <tcpdump-stdinc.h>
36 #ifdef HAVE_RPC_RPCENT_H
37 #include <rpc/rpcent.h>
40 #include <rpc/pmap_prot.h>
46 #include "interface.h"
47 #include "addrtoname.h"
55 static struct tok proc2str[] = {
56 { PMAPPROC_NULL, "null" },
57 { PMAPPROC_SET, "set" },
58 { PMAPPROC_UNSET, "unset" },
59 { PMAPPROC_GETPORT, "getport" },
60 { PMAPPROC_DUMP, "dump" },
61 { PMAPPROC_CALLIT, "call" },
66 static char *progstr(u_int32_t);
69 sunrpcrequest_print(register const u_char *bp, register u_int length,
70 register const u_char *bp2)
72 register const struct rpc_msg *rp;
73 register const struct ip *ip;
75 register const struct ip6_hdr *ip6;
78 char srcid[20], dstid[20]; /*fits 32bit*/
80 rp = (struct rpc_msg *)bp;
83 snprintf(srcid, sizeof(srcid), "0x%x",
84 EXTRACT_32BITS(&rp->rm_xid));
85 strlcpy(dstid, "sunrpc", sizeof(dstid));
87 snprintf(srcid, sizeof(srcid), "0x%x",
88 EXTRACT_32BITS(&rp->rm_xid));
89 snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT);
92 switch (IP_V((struct ip *)bp2)) {
94 ip = (struct ip *)bp2;
95 printf("%s.%s > %s.%s: %d",
96 ipaddr_string(&ip->ip_src), srcid,
97 ipaddr_string(&ip->ip_dst), dstid, length);
101 ip6 = (struct ip6_hdr *)bp2;
102 printf("%s.%s > %s.%s: %d",
103 ip6addr_string(&ip6->ip6_src), srcid,
104 ip6addr_string(&ip6->ip6_dst), dstid, length);
108 printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
112 printf(" %s", tok2str(proc2str, " proc #%u",
113 EXTRACT_32BITS(&rp->rm_call.cb_proc)));
114 x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers);
116 printf(" [rpcver %u]", x);
118 switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) {
122 case PMAPPROC_GETPORT:
123 case PMAPPROC_CALLIT:
124 x = EXTRACT_32BITS(&rp->rm_call.cb_prog);
126 printf(" %s", progstr(x));
129 printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers));
139 register struct rpcent *rp;
142 static u_int32_t lastprog = 0;
144 if (lastprog != 0 && prog == lastprog)
147 rp = getrpcbynumber(prog);
150 (void) snprintf(buf, sizeof(buf), "#%u", prog);
153 strlcpy(buf, rp->r_name, sizeof(buf));