Deleted Added
full compact
print-sunrpc.c (26183) print-sunrpc.c (39300)
1/*
2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
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
16 * written permission.
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.
20 */
21
22#ifndef lint
23static const char rcsid[] =
1/*
2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
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
16 * written permission.
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.
20 */
21
22#ifndef lint
23static const char rcsid[] =
24 "@(#) $Header: print-sunrpc.c,v 1.25 96/09/26 23:36:49 leres Exp $ (LBL)";
24 "@(#) $Header: print-sunrpc.c,v 1.26 96/12/31 21:27:43 leres Exp $ (LBL)";
25#endif
26
27#include <sys/param.h>
28#include <sys/time.h>
29#include <sys/socket.h>
30
31#if __STDC__
32struct mbuf;
33struct rtentry;
34#endif
35#include <net/if.h>
36
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>
42
43#include <rpc/rpc.h>
44#ifdef HAVE_RPC_RPCENT_H
45#include <rpc/rpcent.h>
46#endif
47#include <rpc/pmap_prot.h>
48
49#include <ctype.h>
50#include <netdb.h>
51#include <stdio.h>
52#include <string.h>
53
54#include "interface.h"
55#include "addrtoname.h"
56
57static 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" },
64 { 0, NULL }
65};
66
67/* Forwards */
68static char *progstr(u_int32_t);
69
70void
71sunrpcrequest_print(register const u_char *bp, register u_int length,
72 register const u_char *bp2)
73{
74 register const struct rpc_msg *rp;
75 register const struct ip *ip;
76 u_int32_t x;
77
78 rp = (struct rpc_msg *)bp;
79 ip = (struct ip *)bp2;
80
81 if (!nflag)
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),
86 length);
87 else
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),
92 PMAPPORT,
93 length);
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);
97 if (x != 2)
98 printf(" [rpcver %u]", x);
99
100 switch (ntohl(rp->rm_call.cb_proc)) {
101
102 case PMAPPROC_SET:
103 case PMAPPROC_UNSET:
104 case PMAPPROC_GETPORT:
105 case PMAPPROC_CALLIT:
106 x = ntohl(rp->rm_call.cb_prog);
107 if (!nflag)
108 printf(" %s", progstr(x));
109 else
110 printf(" %u", x);
111 printf(".%u", (u_int32_t)ntohl(rp->rm_call.cb_vers));
112 break;
113 }
114}
115
116static char *
117progstr(prog)
118 u_int32_t prog;
119{
120 register struct rpcent *rp;
121 static char buf[32];
25#endif
26
27#include <sys/param.h>
28#include <sys/time.h>
29#include <sys/socket.h>
30
31#if __STDC__
32struct mbuf;
33struct rtentry;
34#endif
35#include <net/if.h>
36
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>
42
43#include <rpc/rpc.h>
44#ifdef HAVE_RPC_RPCENT_H
45#include <rpc/rpcent.h>
46#endif
47#include <rpc/pmap_prot.h>
48
49#include <ctype.h>
50#include <netdb.h>
51#include <stdio.h>
52#include <string.h>
53
54#include "interface.h"
55#include "addrtoname.h"
56
57static 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" },
64 { 0, NULL }
65};
66
67/* Forwards */
68static char *progstr(u_int32_t);
69
70void
71sunrpcrequest_print(register const u_char *bp, register u_int length,
72 register const u_char *bp2)
73{
74 register const struct rpc_msg *rp;
75 register const struct ip *ip;
76 u_int32_t x;
77
78 rp = (struct rpc_msg *)bp;
79 ip = (struct ip *)bp2;
80
81 if (!nflag)
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),
86 length);
87 else
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),
92 PMAPPORT,
93 length);
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);
97 if (x != 2)
98 printf(" [rpcver %u]", x);
99
100 switch (ntohl(rp->rm_call.cb_proc)) {
101
102 case PMAPPROC_SET:
103 case PMAPPROC_UNSET:
104 case PMAPPROC_GETPORT:
105 case PMAPPROC_CALLIT:
106 x = ntohl(rp->rm_call.cb_prog);
107 if (!nflag)
108 printf(" %s", progstr(x));
109 else
110 printf(" %u", x);
111 printf(".%u", (u_int32_t)ntohl(rp->rm_call.cb_vers));
112 break;
113 }
114}
115
116static char *
117progstr(prog)
118 u_int32_t prog;
119{
120 register struct rpcent *rp;
121 static char buf[32];
122 static lastprog = 0;
122 static int lastprog = 0;
123
124 if (lastprog != 0 && prog == lastprog)
125 return (buf);
126 rp = getrpcbynumber(prog);
127 if (rp == NULL)
128 (void) sprintf(buf, "#%u", prog);
129 else
130 strcpy(buf, rp->r_name);
131 return (buf);
132}
123
124 if (lastprog != 0 && prog == lastprog)
125 return (buf);
126 rp = getrpcbynumber(prog);
127 if (rp == NULL)
128 (void) sprintf(buf, "#%u", prog);
129 else
130 strcpy(buf, rp->r_name);
131 return (buf);
132}