* Copyright (c) 1988-1990 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) $Header: /a/cvs/386BSD/src/contrib/tcpdump/tcpdump/print-udp.c,v 1.1.1.1 1993/06/12 14:42:06 rgrimes Exp $ (LBL)";
#include <netinet/in_systm.h>
#include <netinet/ip_var.h>
#include <netinet/udp_var.h>
#include <arpa/nameser.h>
/* These must come after interface.h for BSD. */
/* XXX probably should use getservbyname() and cache answers */
#define TFTP_PORT 69 /*XXX*/
#define SUNRPC_PORT 111 /*XXX*/
#define SNMP_PORT 161 /*XXX*/
#define NTP_PORT 123 /*XXX*/
#define SNMPTRAP_PORT 162 /*XXX*/
#define RIP_PORT 520 /*XXX*/
udp_print(up
, length
, ip
)
register struct udphdr
*up
;
register u_char
*cp
= (u_char
*)(up
+ 1);
if (length
< sizeof(struct udphdr
)) {
(void)printf(" truncated-udp %d", length
);
length
-= sizeof(struct udphdr
);
register struct rpc_msg
*rp
;
rp
= (struct rpc_msg
*)(up
+ 1);
direction
= (enum msg_type
)ntohl(rp
->rm_direction
);
if (up
->uh_dport
== NFS_PORT
&& direction
== CALL
) {
nfsreq_print(rp
, length
, ip
);
else if (up
->uh_sport
== NFS_PORT
&& direction
== REPLY
) {
nfsreply_print(rp
, length
, ip
);
else if (up
->uh_dport
== SUNRPC_PORT
&& direction
== CALL
) {
sunrpcrequest_print(rp
, length
, ip
);
else if (cp
[2] == 2 && (atalk_port(up
->uh_sport
) ||
atalk_port(up
->uh_dport
))) {
ddp_print((struct atDDP
*)(&cp
[3]), length
- 3);
(void)printf("%s.%s > %s.%s:",
ipaddr_string(&ip
->ip_src
), udpport_string(up
->uh_sport
),
ipaddr_string(&ip
->ip_dst
), udpport_string(up
->uh_dport
));
#define ISPORT(p) (up->uh_dport == (p) || up->uh_sport == (p))
if (ISPORT(NAMESERVER_PORT
))
ns_print((HEADER
*)(up
+ 1), length
);
else if (ISPORT(TFTP_PORT
))
tftp_print((struct tftphdr
*)(up
+ 1), length
);
else if (ISPORT(IPPORT_BOOTPC
) || ISPORT(IPPORT_BOOTPS
))
bootp_print((struct bootp
*)(up
+ 1), length
,
up
->uh_sport
, up
->uh_dport
);
else if (up
->uh_dport
== RIP_PORT
)
rip_print((u_char
*)(up
+ 1), length
);
else if (ISPORT(SNMP_PORT
) || ISPORT(SNMPTRAP_PORT
))
snmp_print((u_char
*)(up
+ 1), length
);
else if (ISPORT(NTP_PORT
))
ntp_print((struct ntpdata
*)(up
+ 1), length
);
(void)printf(" udp %d", up
->uh_ulen
- sizeof(*up
));
(void)printf(" udp %d", up
->uh_ulen
- sizeof(*up
));