X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/d2595809586aeb427dd536fff5246c89db79968d..cbd4cbb99cf9e68c67af16b5b20a050ef8819af6:/print-udp.c diff --git a/print-udp.c b/print-udp.c index 25d4d948..c9bb189b 100644 --- a/print-udp.c +++ b/print-udp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.87 2000-10-30 05:41:31 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.93 2001-03-17 04:41:51 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -325,7 +325,7 @@ static int udp_cksum(register const struct ip *ip, sum += *sp++; if (tlen & 1) { - sum += htons( (*(const char *)sp) << 8); + sum += htons( (*(const u_int8_t *)sp) << 8); } while (sum > 0xffff) @@ -373,7 +373,7 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, sum += *sp++; if (tlen & 1) - sum += htons((*(const char *)sp) << 8); + sum += htons((*(const u_int8_t *)sp) << 8); while (sum > 0xffff) sum = (sum & 0xffff) + (sum >> 16); @@ -396,8 +396,8 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, #define RIP_PORT 520 /*XXX*/ #define KERBEROS_SEC_PORT 750 /*XXX*/ #define L2TP_PORT 1701 /*XXX*/ -#define ISAKMP_PORT_USER1 7500 /*??? - nonstandard*/ -#define ISAKMP_PORT_USER2 8500 /*??? - nonstandard*/ +#define ISAKMP_PORT_USER1 7500 /*XXX - nonstandard*/ +#define ISAKMP_PORT_USER2 8500 /*XXX - nonstandard*/ #define RX_PORT_LOW 7000 /*XXX*/ #define RX_PORT_HIGH 7009 /*XXX*/ #define NETBIOS_NS_PORT 137 @@ -407,6 +407,7 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, #define RADIUS_NEW_PORT 1812 #define RADIUS_ACCOUNTING_PORT 1646 #define RADIUS_NEW_ACCOUNTING_PORT 1813 +#define LWRES_PORT 921 #ifdef INET6 #define RIPNG_PORT 521 /*XXX*/ @@ -415,7 +416,8 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, #endif void -udp_print(register const u_char *bp, u_int length, register const u_char *bp2) +udp_print(register const u_char *bp, u_int length, + register const u_char *bp2, int fragmented) { register const struct udphdr *up; register const struct ip *ip; @@ -564,7 +566,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) (atalk_port(sport) || atalk_port(dport))) { if (vflag) fputs("kip ", stdout); - iptalk_print(cp, length); + llap_print(cp, length); return; } } @@ -601,28 +603,28 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) } #endif - if (IP_V(ip) == 4 && vflag) { + if (IP_V(ip) == 4 && vflag && !fragmented) { int sum = up->uh_sum; if (sum == 0) { - (void)printf(" [no cksum]"); + (void)printf("[no cksum] "); } else if (TTEST2(cp[0], length)) { sum = udp_cksum(ip, up, length); if (sum != 0) - (void)printf(" [bad udp cksum %x!]", sum); + (void)printf("[bad udp cksum %x!] ", sum); else - (void)printf(" [udp sum ok]"); + (void)printf("[udp sum ok] "); } } #ifdef INET6 - if (IP_V(ip) == 6 && ip6->ip6_plen && vflag) { + if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) { int sum = up->uh_sum; /* for IPv6, UDP checksum is mandatory */ if (TTEST2(cp[0], length)) { sum = udp6_cksum(ip6, up, length); if (sum != 0) - (void)printf(" [bad udp cksum %x!]", sum); + (void)printf("[bad udp cksum %x!] ", sum); else - (void)printf(" [udp sum ok]"); + (void)printf("[udp sum ok] "); } } #endif @@ -686,10 +688,12 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) else if (ISPORT(CISCO_AUTORP_PORT)) cisco_autorp_print((const void *)(up + 1), length); else if (ISPORT(RADIUS_PORT) || - ISPORT(RADIUS_NEW_PORT) || - ISPORT(RADIUS_ACCOUNTING_PORT) || - ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ) - radius_print((const u_char *)(up+1), length); + ISPORT(RADIUS_NEW_PORT) || + ISPORT(RADIUS_ACCOUNTING_PORT) || + ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ) + radius_print((const u_char *)(up+1), length); + else if (ISPORT(LWRES_PORT)) + lwres_print((const u_char *)(up + 1), length); else (void)printf(" udp %u", (u_int32_t)(ulen - sizeof(*up)));