#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.101 2001-10-08 21:25:24 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.104 2002-06-11 17:08:58 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#define DHCP6_CLI_PORT 547 /*XXX*/
#endif
+static void
+udpipaddr_print(const struct ip *ip, u_int16_t sport, u_int16_t dport)
+{
+#ifdef INET6
+ const struct ip6_hdr *ip6;
+
+ if (IP_V(ip) == 6)
+ ip6 = (const struct ip6_hdr *)ip;
+ else
+ ip6 = NULL;
+
+ if (ip6) {
+ if (ip6->ip6_nxt == IPPROTO_UDP) {
+ (void)printf("%s.%s > %s.%s: ",
+ ip6addr_string(&ip6->ip6_src),
+ udpport_string(sport),
+ ip6addr_string(&ip6->ip6_dst),
+ udpport_string(dport));
+ } else {
+ (void)printf("%s > %s: ",
+ udpport_string(sport), udpport_string(dport));
+ }
+ } else
+#endif /*INET6*/
+ {
+ if (ip->ip_p == IPPROTO_UDP) {
+ (void)printf("%s.%s > %s.%s: ",
+ ipaddr_string(&ip->ip_src),
+ udpport_string(sport),
+ ipaddr_string(&ip->ip_dst),
+ udpport_string(dport));
+ } else {
+ (void)printf("%s > %s: ",
+ udpport_string(sport), udpport_string(dport));
+ }
+ }
+}
+
void
udp_print(register const u_char *bp, u_int length,
register const u_char *bp2, int fragmented)
switch (packettype) {
case PT_VAT:
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ udpipaddr_print(ip, sport, dport);
vat_print((void *)(up + 1), length, up);
break;
case PT_WB:
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ udpipaddr_print(ip, sport, dport);
wb_print((void *)(up + 1), length);
break;
break;
case PT_RTP:
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ udpipaddr_print(ip, sport, dport);
rtp_print((void *)(up + 1), length, up);
break;
case PT_RTCP:
- (void)printf("%s.%s > %s.%s:",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ udpipaddr_print(ip, sport, dport);
while (cp < ep)
cp = rtcp_print(cp, ep);
break;
case PT_SNMP:
- (void)printf("%s.%s > %s.%s:",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ udpipaddr_print(ip, sport, dport);
snmp_print((const u_char *)(up + 1), length);
break;
case PT_CNFP:
- (void)printf("%s.%s > %s.%s:",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ udpipaddr_print(ip, sport, dport);
cnfp_print(cp, length, (const u_char *)ip);
break;
}
return;
}
}
-#ifdef INET6
- if (ip6) {
- if (ip6->ip6_nxt == IPPROTO_UDP) {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
- udpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- udpport_string(dport));
- } else {
- (void)printf("%s > %s: ",
- udpport_string(sport), udpport_string(dport));
- }
- } else
-#endif /*INET6*/
- {
- if (ip->ip_p == IPPROTO_UDP) {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
- } else {
- (void)printf("%s > %s: ",
- udpport_string(sport), udpport_string(dport));
- }
- }
+ udpipaddr_print(ip, sport, dport);
if (IP_V(ip) == 4 && vflag && !fragmented) {
int sum = up->uh_sum;
else if (ISPORT(L2TP_PORT))
l2tp_print((const u_char *)(up + 1), length);
#ifdef TCPDUMP_DO_SMB
- else if (ISPORT(NETBIOS_NS_PORT))
+ else if (ISPORT(NETBIOS_NS_PORT))
nbt_udp137_print((const u_char *)(up + 1), length);
- else if (ISPORT(NETBIOS_DGRAM_PORT))
- nbt_udp138_print((const u_char *)(up + 1), length);
+ else if (ISPORT(NETBIOS_DGRAM_PORT))
+ nbt_udp138_print((const u_char *)(up + 1), length);
#endif
else if (dport == 3456)
vat_print((const void *)(up + 1), length, up);
else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
zephyr_print((const void *)(up + 1), length);
- /*
- * Since there are 10 possible ports to check, I think
- * a <> test would be more efficient
- */
- else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
- (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
- rx_print((const void *)(up + 1), length, sport, dport,
- (u_char *) ip);
+ /*
+ * Since there are 10 possible ports to check, I think
+ * a <> test would be more efficient
+ */
+ else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
+ (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
+ rx_print((const void *)(up + 1), length, sport, dport,
+ (u_char *) ip);
#ifdef INET6
else if (ISPORT(RIPNG_PORT))
ripng_print((const u_char *)(up + 1), length);
cisco_autorp_print((const void *)(up + 1), length);
else if (ISPORT(RADIUS_PORT) ||
ISPORT(RADIUS_NEW_PORT) ||
- ISPORT(RADIUS_ACCOUNTING_PORT) ||
+ ISPORT(RADIUS_ACCOUNTING_PORT) ||
ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
radius_print((const u_char *)(up+1), length);
else if (dport == HSRP_PORT)
- hsrp_print((const u_char *)(up + 1), length);
+ hsrp_print((const u_char *)(up + 1), length);
else if (ISPORT(LWRES_PORT))
lwres_print((const u_char *)(up + 1), length);
else