Deleted Added
full compact
21c21
< * $FreeBSD: head/contrib/tcpdump/print-udp.c 56896 2000-01-30 01:05:24Z fenner $
---
> * $FreeBSD: head/contrib/tcpdump/print-udp.c 75118 2001-04-03 07:50:46Z fenner $
26c26
< "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.70 1999/12/22 06:27:23 itojun Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.90 2000/12/23 20:55:22 guy Exp $ (LBL)";
35d34
< #include <sys/socket.h>
38,42d36
< #include <netinet/in_systm.h>
< #include <netinet/ip.h>
< #include <netinet/ip_var.h>
< #include <netinet/udp.h>
< #include <netinet/udp_var.h>
44,50d37
< #ifdef NOERROR
< #undef NOERROR /* Solaris sucks */
< #endif
< #ifdef T_UNSPEC
< #undef T_UNSPEC /* SINIX does too */
< #endif
< #include <arpa/nameser.h>
58a46
> #include <string.h>
60,63d47
< #ifdef INET6
< #include <netinet/ip6.h>
< #endif
<
67a52,65
> #include "udp.h"
>
> #include "ip.h"
> #ifdef INET6
> #include "ip6.h"
> #endif
>
> #ifdef NOERROR
> #undef NOERROR /* Solaris sucks */
> #endif
> #ifdef T_UNSPEC
> #undef T_UNSPEC /* SINIX does too */
> #endif
> #include "nameser.h"
72,74c70,72
< u_short rh_flags; /* T:2 P:1 CNT:5 PT:8 */
< u_short rh_len; /* length of message (in words) */
< u_int rh_ssrc; /* synchronization src id */
---
> u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
> u_int16_t rh_len; /* length of message (in words) */
> u_int32_t rh_ssrc; /* synchronization src id */
78,79c76,77
< u_int upper; /* more significant 32 bits */
< u_int lower; /* less significant 32 bits */
---
> u_int32_t upper; /* more significant 32 bits */
> u_int32_t lower; /* less significant 32 bits */
87,89c85,87
< u_int sr_ts; /* reference media timestamp */
< u_int sr_np; /* no. packets sent */
< u_int sr_nb; /* no. bytes sent */
---
> u_int32_t sr_ts; /* reference media timestamp */
> u_int32_t sr_np; /* no. packets sent */
> u_int32_t sr_nb; /* no. bytes sent */
97,102c95,100
< u_int rr_srcid; /* sender being reported */
< u_int rr_nl; /* no. packets lost */
< u_int rr_ls; /* extended last seq number received */
< u_int rr_dv; /* jitter (delay variance) */
< u_int rr_lsr; /* orig. ts from last rr from this src */
< u_int rr_dlsr; /* time from recpt of last rr to xmit time */
---
> u_int32_t rr_srcid; /* sender being reported */
> u_int32_t rr_nl; /* no. packets lost */
> u_int32_t rr_ls; /* extended last seq number received */
> u_int32_t rr_dv; /* jitter (delay variance) */
> u_int32_t rr_lsr; /* orig. ts from last rr from this src */
> u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */
124c122
< u_int ts = *(u_short *)hdr;
---
> u_int ts = *(u_int16_t *)hdr;
132,133c130,131
< u_int i0 = ntohl(((u_int *)hdr)[0]);
< u_int i1 = ntohl(((u_int *)hdr)[1]);
---
> u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
> u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
152,153c150,151
< u_int i0 = ntohl(((u_int *)hdr)[0]);
< u_int i1 = ntohl(((u_int *)hdr)[1]);
---
> u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
> u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
187c185
< printf(" %u", i1);
---
> printf(" %u", (u_int32_t)ntohl(((u_int *)hdr)[2]));
224c222
< u_short flags;
---
> u_int16_t flags;
241c239
< printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
---
> printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
259c257
< printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
---
> printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
264c262
< printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
---
> printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
270c268
< printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
---
> printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
296a295,388
> static int udp_cksum(register const struct ip *ip,
> register const struct udphdr *up,
> register int len)
> {
> int i, tlen;
> union phu {
> struct phdr {
> u_int32_t src;
> u_int32_t dst;
> u_char mbz;
> u_char proto;
> u_int16_t len;
> } ph;
> u_int16_t pa[6];
> } phu;
> register const u_int16_t *sp;
> u_int32_t sum;
> tlen = ntohs(ip->ip_len) - ((const char *)up-(const char*)ip);
>
> /* pseudo-header.. */
> phu.ph.len = htons(tlen);
> phu.ph.mbz = 0;
> phu.ph.proto = IPPROTO_UDP;
> memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
> memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
>
> sp = &phu.pa[0];
> sum = sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5];
>
> sp = (const u_int16_t *)up;
>
> for (i=0; i<(tlen&~1); i+= 2)
> sum += *sp++;
>
> if (tlen & 1) {
> sum += htons( (*(const u_int8_t *)sp) << 8);
> }
>
> while (sum > 0xffff)
> sum = (sum & 0xffff) + (sum >> 16);
> sum = ~sum & 0xffff;
>
> return (sum);
> }
>
> #ifdef INET6
> static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
> int len)
> {
> int i, tlen;
> register const u_int16_t *sp;
> u_int32_t sum;
> union {
> 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;
> u_int16_t pa[20];
> } phu;
>
> tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) -
> ((const char *)up - (const char*)ip6);
>
> /* pseudo-header */
> memset(&phu, 0, sizeof(phu));
> phu.ph.ph_src = ip6->ip6_src;
> phu.ph.ph_dst = ip6->ip6_dst;
> phu.ph.ph_len = htonl(tlen);
> phu.ph.ph_nxt = IPPROTO_UDP;
>
> sum = 0;
> for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
> sum += phu.pa[i];
>
> sp = (const u_int16_t *)up;
>
> for (i = 0; i < (tlen & ~1); i += 2)
> sum += *sp++;
>
> if (tlen & 1)
> sum += htons((*(const u_int8_t *)sp) << 8);
>
> while (sum > 0xffff)
> sum = (sum & 0xffff) + (sum >> 16);
> sum = ~sum & 0xffff;
>
> return (sum);
> }
> #endif
>
>
304a397
> #define TIMED_PORT 525 /*XXX*/
314a408,411
> #define RADIUS_PORT 1645
> #define RADIUS_NEW_PORT 1812
> #define RADIUS_ACCOUNTING_PORT 1646
> #define RADIUS_NEW_ACCOUNTING_PORT 1813
323c420,421
< 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)
329c427
< u_short sport, dport, ulen;
---
> u_int16_t sport, dport, ulen;
339c437
< if (ip->ip_v == 6)
---
> if (IP_V(ip) == 6)
360a459,465
> if (ulen < 8) {
> (void)printf("%s > %s: truncated-udplength %d",
> ipaddr_string(&ip->ip_src),
> ipaddr_string(&ip->ip_dst),
> ulen);
> return;
> }
422a528,536
>
> 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));
> cnfp_print(cp, length, (const u_char *)ip);
> break;
456c570
< atalk_print(cp, length);
---
> llap_print(cp, length);
492a607,632
> if (IP_V(ip) == 4 && vflag && !fragmented) {
> int sum = up->uh_sum;
> if (sum == 0) {
> (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);
> else
> (void)printf(" [udp sum ok]");
> }
> }
> #ifdef INET6
> 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);
> else
> (void)printf(" [udp sum ok]");
> }
> }
> #endif
>
496a637,638
> else if (ISPORT(TIMED_PORT))
> timed_print((const u_char *)(up + 1), length);
548a691,695
> 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);