print-sunrpc.c (111729) | print-sunrpc.c (127675) |
---|---|
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 --- 4 unchanged lines hidden (view full) --- 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 * | 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 --- 4 unchanged lines hidden (view full) --- 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 * $FreeBSD: head/contrib/tcpdump/print-sunrpc.c 111729 2003-03-02 08:25:48Z fenner $ | 21 * $FreeBSD: head/contrib/tcpdump/print-sunrpc.c 127675 2004-03-31 14:57:24Z bms $ |
22 */ 23 24#ifndef lint | 22 */ 23 24#ifndef lint |
25static const char rcsid[] = 26 "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.39.6.1 2002/06/01 23:51:16 guy Exp $ (LBL)"; | 25static 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)"; |
27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 | 27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 |
33#include <sys/param.h> 34#include <sys/time.h> 35#include <sys/socket.h> | 33#include <tcpdump-stdinc.h> |
36 | 34 |
37#include <netinet/in.h> 38 | |
39#include <rpc/rpc.h> 40#ifdef HAVE_RPC_RPCENT_H 41#include <rpc/rpcent.h> 42#endif | 35#include <rpc/rpc.h> 36#ifdef HAVE_RPC_RPCENT_H 37#include <rpc/rpcent.h> 38#endif |
39#ifndef WIN32 |
|
43#include <rpc/pmap_prot.h> | 40#include <rpc/pmap_prot.h> |
41#endif /* WIN32 */ |
|
44 | 42 |
45#include <ctype.h> 46#include <netdb.h> | |
47#include <stdio.h> 48#include <string.h> 49 50#include "interface.h" 51#include "addrtoname.h" | 43#include <stdio.h> 44#include <string.h> 45 46#include "interface.h" 47#include "addrtoname.h" |
48#include "extract.h" |
|
52 53#include "ip.h" 54#ifdef INET6 55#include "ip6.h" 56#endif 57 58static struct tok proc2str[] = { 59 { PMAPPROC_NULL, "null" }, --- 19 unchanged lines hidden (view full) --- 79#endif 80 u_int32_t x; 81 char srcid[20], dstid[20]; /*fits 32bit*/ 82 83 rp = (struct rpc_msg *)bp; 84 85 if (!nflag) { 86 snprintf(srcid, sizeof(srcid), "0x%x", | 49 50#include "ip.h" 51#ifdef INET6 52#include "ip6.h" 53#endif 54 55static struct tok proc2str[] = { 56 { PMAPPROC_NULL, "null" }, --- 19 unchanged lines hidden (view full) --- 76#endif 77 u_int32_t x; 78 char srcid[20], dstid[20]; /*fits 32bit*/ 79 80 rp = (struct rpc_msg *)bp; 81 82 if (!nflag) { 83 snprintf(srcid, sizeof(srcid), "0x%x", |
87 (u_int32_t)ntohl(rp->rm_xid)); | 84 EXTRACT_32BITS(&rp->rm_xid)); |
88 strlcpy(dstid, "sunrpc", sizeof(dstid)); 89 } else { 90 snprintf(srcid, sizeof(srcid), "0x%x", | 85 strlcpy(dstid, "sunrpc", sizeof(dstid)); 86 } else { 87 snprintf(srcid, sizeof(srcid), "0x%x", |
91 (u_int32_t)ntohl(rp->rm_xid)); | 88 EXTRACT_32BITS(&rp->rm_xid)); |
92 snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT); 93 } 94 95 switch (IP_V((struct ip *)bp2)) { 96 case 4: 97 ip = (struct ip *)bp2; 98 printf("%s.%s > %s.%s: %d", 99 ipaddr_string(&ip->ip_src), srcid, --- 8 unchanged lines hidden (view full) --- 108 break; 109#endif 110 default: 111 printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length); 112 break; 113 } 114 115 printf(" %s", tok2str(proc2str, " proc #%u", | 89 snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT); 90 } 91 92 switch (IP_V((struct ip *)bp2)) { 93 case 4: 94 ip = (struct ip *)bp2; 95 printf("%s.%s > %s.%s: %d", 96 ipaddr_string(&ip->ip_src), srcid, --- 8 unchanged lines hidden (view full) --- 105 break; 106#endif 107 default: 108 printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length); 109 break; 110 } 111 112 printf(" %s", tok2str(proc2str, " proc #%u", |
116 (u_int32_t)ntohl(rp->rm_call.cb_proc))); 117 x = ntohl(rp->rm_call.cb_rpcvers); | 113 EXTRACT_32BITS(&rp->rm_call.cb_proc))); 114 x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers); |
118 if (x != 2) 119 printf(" [rpcver %u]", x); 120 | 115 if (x != 2) 116 printf(" [rpcver %u]", x); 117 |
121 switch (ntohl(rp->rm_call.cb_proc)) { | 118 switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) { |
122 123 case PMAPPROC_SET: 124 case PMAPPROC_UNSET: 125 case PMAPPROC_GETPORT: 126 case PMAPPROC_CALLIT: | 119 120 case PMAPPROC_SET: 121 case PMAPPROC_UNSET: 122 case PMAPPROC_GETPORT: 123 case PMAPPROC_CALLIT: |
127 x = ntohl(rp->rm_call.cb_prog); | 124 x = EXTRACT_32BITS(&rp->rm_call.cb_prog); |
128 if (!nflag) 129 printf(" %s", progstr(x)); 130 else 131 printf(" %u", x); | 125 if (!nflag) 126 printf(" %s", progstr(x)); 127 else 128 printf(" %u", x); |
132 printf(".%u", (u_int32_t)ntohl(rp->rm_call.cb_vers)); | 129 printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers)); |
133 break; 134 } 135} 136 137static char * 138progstr(prog) 139 u_int32_t prog; 140{ | 130 break; 131 } 132} 133 134static char * 135progstr(prog) 136 u_int32_t prog; 137{ |
138#ifndef WIN32 |
|
141 register struct rpcent *rp; | 139 register struct rpcent *rp; |
140#endif |
|
142 static char buf[32]; | 141 static char buf[32]; |
143 static int lastprog = 0; | 142 static u_int32_t lastprog = 0; |
144 145 if (lastprog != 0 && prog == lastprog) 146 return (buf); | 143 144 if (lastprog != 0 && prog == lastprog) 145 return (buf); |
146#ifndef WIN32 |
|
147 rp = getrpcbynumber(prog); 148 if (rp == NULL) | 147 rp = getrpcbynumber(prog); 148 if (rp == NULL) |
149#endif /* WIN32 */ |
|
149 (void) snprintf(buf, sizeof(buf), "#%u", prog); | 150 (void) snprintf(buf, sizeof(buf), "#%u", prog); |
151#ifndef WIN32 |
|
150 else 151 strlcpy(buf, rp->r_name, sizeof(buf)); | 152 else 153 strlcpy(buf, rp->r_name, sizeof(buf)); |
154#endif |
|
152 return (buf); 153} | 155 return (buf); 156} |