X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/7074f77080d5d15ba9c6ea5970c5d49372170a86..7d0510cec8de0f7157050e9daaf0246d7d6c7eeb:/print-udp.c diff --git a/print-udp.c b/print-udp.c index 32a7e8af..fb56be58 100644 --- a/print-udp.c +++ b/print-udp.c @@ -286,57 +286,16 @@ static int udp_cksum(register const struct ip *ip, register const struct udphdr *up, register u_int len) { - struct phdr { - u_int32_t src; - u_int32_t dst; - u_char mbz; - u_char proto; - u_int16_t len; - } ph; - struct cksum_vec vec[2]; - - /* pseudo-header.. */ - ph.len = htons((u_int16_t)len); - ph.mbz = 0; - ph.proto = IPPROTO_UDP; - memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); - if (IP_HL(ip) == 5) - memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); - else - ph.dst = ip_finddst(ip); - - vec[0].ptr = (const u_int8_t *)(void *)&ph; - vec[0].len = sizeof(ph); - vec[1].ptr = (const u_int8_t *)(void *)up; - vec[1].len = len; - return (in_cksum(vec, 2)); + return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len, + IPPROTO_UDP)); } #ifdef INET6 static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, u_int len) { - struct { - struct in6_addr ph_src; - struct in6_addr ph_dst; - u_int32_t ph_len; - u_int8_t ph_zero[3]; - u_int8_t ph_nxt; - } ph; - struct cksum_vec vec[2]; - - /* pseudo-header */ - memset(&ph, 0, sizeof(ph)); - ph.ph_src = ip6->ip6_src; - ph.ph_dst = ip6->ip6_dst; - ph.ph_len = htonl(len); - ph.ph_nxt = IPPROTO_UDP; - - vec[0].ptr = (const u_int8_t *)(void *)&ph; - vec[0].len = sizeof(ph); - vec[1].ptr = (const u_int8_t *)(void *)up; - vec[1].len = len; - return (in_cksum(vec, 2)); + return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len, + IPPROTO_UDP)); } #endif @@ -510,6 +469,22 @@ udp_print(register const u_char *bp, u_int length, 0); #endif break; + + case PT_RADIUS: + udpipaddr_print(ip, sport, dport); + radius_print(cp, length); + break; + + case PT_VXLAN: + udpipaddr_print(ip, sport, dport); + vxlan_print((const u_char *)(up + 1), length); + break; + + case PT_PGM: + case PT_PGM_ZMTP1: + udpipaddr_print(ip, sport, dport); + pgm_print(cp, length, bp2); + break; } return; } @@ -633,7 +608,7 @@ udp_print(register const u_char *bp, u_int length, else if (ISPORT(NETBIOS_DGRAM_PORT)) nbt_udp138_print((const u_char *)(up + 1), length); #endif - else if (dport == 3456) + else if (dport == VAT_PORT) vat_print((const void *)(up + 1), up); else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT)) zephyr_print((const void *)(up + 1), length); @@ -650,13 +625,13 @@ udp_print(register const u_char *bp, u_int length, ripng_print((const u_char *)(up + 1), length); else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT)) dhcp6_print((const u_char *)(up + 1), length); - else if (ISPORT(BABEL_PORT)) + else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD)) babel_print((const u_char *)(up + 1), length); #endif /*INET6*/ /* * Kludge in test for whiteboard packets. */ - else if (dport == 4567) + else if (dport == WB_PORT) wb_print((const void *)(up + 1), length); else if (ISPORT(CISCO_AUTORP_PORT)) cisco_autorp_print((const void *)(up + 1), length); @@ -699,6 +674,8 @@ udp_print(register const u_char *bp, u_int length, sip_print((const u_char *)(up + 1), length); else if (ISPORT(SYSLOG_PORT)) syslog_print((const u_char *)(up + 1), length); + else if (ISPORT(OTV_PORT)) + otv_print((const u_char *)(up + 1), length); else (void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));