Subject: Re: getting rid of NTOHS() in ip_input()
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: None <itojun@iijlab.net>
List: tech-net
Date: 08/13/2002 14:28:54
byte-swapping constant is good. i've updated my tree.
> > @@ -764,3 +759,3 @@
> > */
> > - if (mff || ip->ip_off) {
> > + if (mff || ntohs(ip->ip_off)) {
>Don't need to byte-swap if you're testing != 0.
for completeness i'd like to have it.
> > Index: netinet/raw_ip.c
> > ===================================================================
> > RCS file: /cvsroot/syssrc/sys/netinet/raw_ip.c,v
> > retrieving revision 1.61
> > diff -u -1 -r1.61 raw_ip.c
> > --- netinet/raw_ip.c 2002/06/09 16:33:43 1.61
> > +++ netinet/raw_ip.c 2002/08/12 22:57:50
> > @@ -165,5 +165,7 @@
> > * XXX Compatibility: programs using raw IP expect ip_len
> > - * XXX to have the header length subtracted.
> > + * XXX to have the header length subtracted, and in host order.
> > + * XXX ip_off is also expected to be host order.
> > */
> > - ip->ip_len -= ip->ip_hl << 2;
> > + ip->ip_len = ntohs(ip->ip_len) - (ip->ip_hl << 2);
> > + NTOHS(ip->ip_off);
>You're converting from host-to-net, so use htons() and HTONS(), right?
no, this is in rip_input, so net-to-host.
itojun