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.
23 static const char rcsid[] =
24 "@(#) $Header: print-sunrpc.c,v 1.26 96/12/31 21:27:43 leres Exp $ (LBL)";
27 #include <sys/param.h>
29 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <net/ethernet.h>
39 #include <netinet/in_systm.h>
40 #include <netinet/ip.h>
41 #include <netinet/ip_var.h>
44 #ifdef HAVE_RPC_RPCENT_H
45 #include <rpc/rpcent.h>
47 #include <rpc/pmap_prot.h>
54 #include "interface.h"
55 #include "addrtoname.h"
57 static struct tok proc2str[] = {
58 { PMAPPROC_NULL, "null" },
59 { PMAPPROC_SET, "set" },
60 { PMAPPROC_UNSET, "unset" },
61 { PMAPPROC_GETPORT, "getport" },
62 { PMAPPROC_DUMP, "dump" },
63 { PMAPPROC_CALLIT, "call" },
68 static char *progstr(u_int32_t);
71 sunrpcrequest_print(register const u_char *bp, register u_int length,
72 register const u_char *bp2)
74 register const struct rpc_msg *rp;
75 register const struct ip *ip;
78 rp = (struct rpc_msg *)bp;
79 ip = (struct ip *)bp2;
82 (void)printf("%s.%x > %s.sunrpc: %d",
83 ipaddr_string(&ip->ip_src),
84 (u_int32_t)ntohl(rp->rm_xid),
85 ipaddr_string(&ip->ip_dst),
88 (void)printf("%s.%x > %s.%x: %d",
89 ipaddr_string(&ip->ip_src),
90 (u_int32_t)ntohl(rp->rm_xid),
91 ipaddr_string(&ip->ip_dst),
94 printf(" %s", tok2str(proc2str, " proc #%u",
95 (u_int32_t)ntohl(rp->rm_call.cb_proc)));
96 x = ntohl(rp->rm_call.cb_rpcvers);
98 printf(" [rpcver %u]", x);
100 switch (ntohl(rp->rm_call.cb_proc)) {
104 case PMAPPROC_GETPORT:
105 case PMAPPROC_CALLIT:
106 x = ntohl(rp->rm_call.cb_prog);
108 printf(" %s", progstr(x));
111 printf(".%u", (u_int32_t)ntohl(rp->rm_call.cb_vers));
120 register struct rpcent *rp;
122 static int lastprog = 0;
124 if (lastprog != 0 && prog == lastprog)
126 rp = getrpcbynumber(prog);
128 (void) sprintf(buf, "#%u", prog);
130 strcpy(buf, rp->r_name);