4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 #include <sys/cdefs.h>
27 static const char rcsid
[] _U_
=
28 "@(#) Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.46.2.1 2005/04/27 21:44:06 guy Exp (LBL)";
30 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
38 #include <tcpdump-stdinc.h>
40 #ifdef HAVE_GETRPCBYNUMBER
42 #ifdef HAVE_RPC_RPCENT_H
43 #include <rpc/rpcent.h>
44 #endif /* HAVE_RPC_RPCENT_H */
45 #endif /* HAVE_GETRPCBYNUMBER */
50 #include "interface.h"
51 #include "addrtoname.h"
61 #include "pmap_prot.h"
63 static struct tok proc2str
[] = {
64 { SUNRPC_PMAPPROC_NULL
, "null" },
65 { SUNRPC_PMAPPROC_SET
, "set" },
66 { SUNRPC_PMAPPROC_UNSET
, "unset" },
67 { SUNRPC_PMAPPROC_GETPORT
, "getport" },
68 { SUNRPC_PMAPPROC_DUMP
, "dump" },
69 { SUNRPC_PMAPPROC_CALLIT
, "call" },
74 static char *progstr(u_int32_t
);
77 sunrpcrequest_print(register const u_char
*bp
, register u_int length
,
78 register const u_char
*bp2
)
80 register const struct sunrpc_msg
*rp
;
81 register const struct ip
*ip
;
83 register const struct ip6_hdr
*ip6
;
86 char srcid
[20], dstid
[20]; /*fits 32bit*/
88 rp
= (struct sunrpc_msg
*)bp
;
91 snprintf(srcid
, sizeof(srcid
), "0x%x",
92 EXTRACT_32BITS(&rp
->rm_xid
));
93 strlcpy(dstid
, "sunrpc", sizeof(dstid
));
95 snprintf(srcid
, sizeof(srcid
), "0x%x",
96 EXTRACT_32BITS(&rp
->rm_xid
));
97 snprintf(dstid
, sizeof(dstid
), "0x%x", SUNRPC_PMAPPORT
);
100 switch (IP_V((struct ip
*)bp2
)) {
102 ip
= (struct ip
*)bp2
;
103 printf("%s.%s > %s.%s: %d",
104 ipaddr_string(&ip
->ip_src
), srcid
,
105 ipaddr_string(&ip
->ip_dst
), dstid
, length
);
109 ip6
= (struct ip6_hdr
*)bp2
;
110 printf("%s.%s > %s.%s: %d",
111 ip6addr_string(&ip6
->ip6_src
), srcid
,
112 ip6addr_string(&ip6
->ip6_dst
), dstid
, length
);
116 printf("%s.%s > %s.%s: %d", "?", srcid
, "?", dstid
, length
);
120 printf(" %s", tok2str(proc2str
, " proc #%u",
121 EXTRACT_32BITS(&rp
->rm_call
.cb_proc
)));
122 x
= EXTRACT_32BITS(&rp
->rm_call
.cb_rpcvers
);
124 printf(" [rpcver %u]", x
);
126 switch (EXTRACT_32BITS(&rp
->rm_call
.cb_proc
)) {
128 case SUNRPC_PMAPPROC_SET
:
129 case SUNRPC_PMAPPROC_UNSET
:
130 case SUNRPC_PMAPPROC_GETPORT
:
131 case SUNRPC_PMAPPROC_CALLIT
:
132 x
= EXTRACT_32BITS(&rp
->rm_call
.cb_prog
);
134 printf(" %s", progstr(x
));
137 printf(".%u", EXTRACT_32BITS(&rp
->rm_call
.cb_vers
));
146 #ifdef HAVE_GETRPCBYNUMBER
147 register struct rpcent
*rp
;
150 static u_int32_t lastprog
= 0;
152 if (lastprog
!= 0 && prog
== lastprog
)
154 #ifdef HAVE_GETRPCBYNUMBER
155 rp
= getrpcbynumber(prog
);
158 (void) snprintf(buf
, sizeof(buf
), "#%u", prog
);
159 #ifdef HAVE_GETRPCBYNUMBER
161 strlcpy(buf
, rp
->r_name
, sizeof(buf
));