From owner-svn-src-all@FreeBSD.ORG Sat Feb 14 23:40:44 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E57791065674 for ; Sat, 14 Feb 2009 23:40:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outP.internet-mail-service.net (outp.internet-mail-service.net [216.240.47.239]) by mx1.freebsd.org (Postfix) with ESMTP id C7A518FC13 for ; Sat, 14 Feb 2009 23:40:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 1B9B0243B; Sat, 14 Feb 2009 15:26:11 -0800 (PST) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (home.elischer.org [216.240.48.38]) by idiom.com (Postfix) with ESMTP id 4CF112D600D; Sat, 14 Feb 2009 15:26:10 -0800 (PST) Message-ID: <4997531E.3000900@elischer.org> Date: Sat, 14 Feb 2009 15:26:22 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209) MIME-Version: 1.0 To: Luigi Rizzo References: <200902131514.n1DFEhft091837@svn.freebsd.org> In-Reply-To: <200902131514.n1DFEhft091837@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r188578 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 23:40:45 -0000 Luigi Rizzo wrote: > Author: luigi > Date: Fri Feb 13 15:14:43 2009 > New Revision: 188578 > URL: http://svn.freebsd.org/changeset/base/188578 > > Log: > Use uint32_t instead of n_long and n_time, and uint16_t instead of n_short. > Add a note next to fields in network format. > > The n_* types are not enough for compiler checks on endianness, and their > use often requires an otherwise unnecessary #include > > The typedef in in_systm.h are still there. There is a project out there (intel was involved frommemory) to make a compiler that knows the endianness of stuff. I know it exists because it was reported that one well known piece of big endian embedded software was compiled successfully to actually run on little endian machines. You can of course see why intel was interested.. > > Modified: > head/sys/netinet/in_systm.h > head/sys/netinet/ip.h > head/sys/netinet/ip_icmp.c > head/sys/netinet/ip_icmp.h > head/sys/netinet/ip_options.c > head/sys/netinet/tcp_debug.h > head/sys/netinet/tcp_subr.c > > Modified: head/sys/netinet/in_systm.h > ============================================================================== > --- head/sys/netinet/in_systm.h Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/in_systm.h Fri Feb 13 15:14:43 2009 (r188578) > @@ -52,7 +52,7 @@ typedef u_int32_t n_long; /* long as re > typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ > > #ifdef _KERNEL > -n_time iptime(void); > +uint32_t iptime(void); > #endif > > #endif > > Modified: head/sys/netinet/ip.h > ============================================================================== > --- head/sys/netinet/ip.h Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/ip.h Fri Feb 13 15:14:43 2009 (r188578) > @@ -150,10 +150,10 @@ struct ip_timestamp { > ipt_flg:4; /* flags, see below */ > #endif > union ipt_timestamp { > - n_long ipt_time[1]; > + uint32_t ipt_time[1]; /* network format */ > struct ipt_ta { > struct in_addr ipt_addr; > - n_long ipt_time; > + uint32_t ipt_time; /* network format */ > } ipt_ta[1]; > } ipt_timestamp; > }; > > Modified: head/sys/netinet/ip_icmp.c > ============================================================================== > --- head/sys/netinet/ip_icmp.c Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/ip_icmp.c Fri Feb 13 15:14:43 2009 (r188578) > @@ -165,7 +165,7 @@ icmp_init(void) > * in response to bad packet ip. > */ > void > -icmp_error(struct mbuf *n, int type, int code, n_long dest, int mtu) > +icmp_error(struct mbuf *n, int type, int code, uint32_t dest, int mtu) > { > INIT_VNET_INET(curvnet); > register struct ip *oip = mtod(n, struct ip *), *nip; > @@ -852,7 +852,10 @@ icmp_send(struct mbuf *m, struct mbuf *o > (void) ip_output(m, opts, NULL, 0, NULL, NULL); > } > > -n_time > +/* > + * Return milliseconds since 00:00 GMT in network format. > + */ > +uint32_t > iptime(void) > { > struct timeval atv; > > Modified: head/sys/netinet/ip_icmp.h > ============================================================================== > --- head/sys/netinet/ip_icmp.h Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/ip_icmp.h Fri Feb 13 15:14:43 2009 (r188578) > @@ -68,15 +68,15 @@ struct icmp { > u_char ih_pptr; /* ICMP_PARAMPROB */ > struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ > struct ih_idseq { > - n_short icd_id; > - n_short icd_seq; > + uint16_t icd_id; /* network format */ > + uint16_t icd_seq; /* network format */ > } ih_idseq; > int ih_void; > > /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ > struct ih_pmtu { > - n_short ipm_void; > - n_short ipm_nextmtu; > + uint16_t ipm_void; /* network format */ > + uint16_t ipm_nextmtu; /* network format */ > } ih_pmtu; > > struct ih_rtradv { > @@ -97,9 +97,13 @@ struct icmp { > #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime > union { > struct id_ts { /* ICMP Timestamp */ > - n_time its_otime; /* Originate */ > - n_time its_rtime; /* Receive */ > - n_time its_ttime; /* Transmit */ > + /* > + * The next 3 fields are in network format, > + * milliseconds since 00:00 GMT > + */ > + uint32_t its_otime; /* Originate */ > + uint32_t its_rtime; /* Receive */ > + uint32_t its_ttime; /* Transmit */ > } id_ts; > struct id_ip { > struct ip idi_ip; > @@ -127,7 +131,7 @@ struct icmp { > * ip header length. > */ > #define ICMP_MINLEN 8 /* abs minimum */ > -#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ > +#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */ > #define ICMP_MASKLEN 12 /* address mask */ > #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ > #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) > @@ -202,7 +206,7 @@ struct icmp { > (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) > > #ifdef _KERNEL > -void icmp_error(struct mbuf *, int, int, n_long, int); > +void icmp_error(struct mbuf *, int, int, uint32_t, int); > void icmp_input(struct mbuf *, int); > void icmp_init(void); > int ip_next_mtu(int, int); > > Modified: head/sys/netinet/ip_options.c > ============================================================================== > --- head/sys/netinet/ip_options.c Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/ip_options.c Fri Feb 13 15:14:43 2009 (r188578) > @@ -105,7 +105,7 @@ ip_dooptions(struct mbuf *m, int pass) > struct in_ifaddr *ia; > int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; > struct in_addr *sin, dst; > - n_time ntime; > + uint32_t ntime; > struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; > > /* Ignore or reject packets with IP options. */ > @@ -320,7 +320,7 @@ dropit: > break; > > case IPOPT_TS_TSANDADDR: > - if (off + sizeof(n_time) + > + if (off + sizeof(uint32_t) + > sizeof(struct in_addr) > optlen) { > code = &cp[IPOPT_OFFSET] - (u_char *)ip; > goto bad; > @@ -337,7 +337,7 @@ dropit: > break; > > case IPOPT_TS_PRESPEC: > - if (off + sizeof(n_time) + > + if (off + sizeof(uint32_t) + > sizeof(struct in_addr) > optlen) { > code = &cp[IPOPT_OFFSET] - (u_char *)ip; > goto bad; > @@ -355,8 +355,8 @@ dropit: > goto bad; > } > ntime = iptime(); > - (void)memcpy(cp + off, &ntime, sizeof(n_time)); > - cp[IPOPT_OFFSET] += sizeof(n_time); > + (void)memcpy(cp + off, &ntime, sizeof(uint32_t)); > + cp[IPOPT_OFFSET] += sizeof(uint32_t); > } > } > if (forward && V_ipforwarding) { > > Modified: head/sys/netinet/tcp_debug.h > ============================================================================== > --- head/sys/netinet/tcp_debug.h Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/tcp_debug.h Fri Feb 13 15:14:43 2009 (r188578) > @@ -34,7 +34,7 @@ > #define _NETINET_TCP_DEBUG_H_ > > struct tcp_debug { > - n_time td_time; > + uint32_t td_time; /* network format */ > short td_act; > short td_ostate; > caddr_t td_tcb; > > Modified: head/sys/netinet/tcp_subr.c > ============================================================================== > --- head/sys/netinet/tcp_subr.c Fri Feb 13 14:43:46 2009 (r188577) > +++ head/sys/netinet/tcp_subr.c Fri Feb 13 15:14:43 2009 (r188578) > @@ -581,7 +581,7 @@ tcp_respond(struct tcpcb *tp, void *ipge > } else > #endif /* INET6 */ > { > - xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, n_long); > + xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); > nth = (struct tcphdr *)(ip + 1); > } > if (th != nth) { > @@ -593,7 +593,7 @@ tcp_respond(struct tcpcb *tp, void *ipge > nth->th_sport = th->th_sport; > nth->th_dport = th->th_dport; > } > - xchg(nth->th_dport, nth->th_sport, n_short); > + xchg(nth->th_dport, nth->th_sport, uint16_t); > #undef xchg > } > #ifdef INET6