9fans archive / 1996 / 08 / 10 /    prev next

From: scott@ang... scott@ang...
Subject: No subject
Date: Sun, 4 Aug 1996 17:00:35 EDT

I've noticed that APE has some byte order problems in the bsd compatability 
code. The bsd interface uses network order exclusively, while the ape code
sometimes assumed host order. There have already been some updates on 
this topic: enclosed are a few additional changes. 

One problem that isn't fixed is that gethostbyaddr calls gethostbyname
with the ascii dotted-quad form of the network address.  That's a good
idea, except that the connection server only asks dns to return ip 
addresses, even though it returns the whole record if it came from ndb.
gethostbyname could be modified to get the answer, but I think cs is
a more appropriate place for it.

diff inet_addr.c /n/cd/sys/src/ape/lib/bsd/inet_addr.c
50d49
< 	x = htonl(x);
diff inet_ntoa.c /n/cd/sys/src/ape/lib/bsd/inet_ntoa.c
19c19
< 	x = ntohl(in.s_addr);
---
> 	x = in.s_addr;
diff gethostbyaddr.c /n/cd/sys/src/ape/lib/bsd/gethostbyaddr.c
23c23,24
< 	memcpy(&x.s_addr, addr, sizeof(x.s_addr));
---
> 	x.s_addr = (addr[0]<<24)|(addr[1]<<16)|(addr[2]<<8)|addr[3];
> 
diff gethostbyname.c /n/cd/sys/src/ape/lib/bsd/gethostbyname.c
98d97
< 			x = ntohl(x);