byte order in rep_inet_ntoa()
Andrew Bartlett
abartlet at samba.org
Fri Nov 15 20:07:00 GMT 2002
On Sat, 2002-11-16 at 02:38, Stefan (metze) Metzmacher wrote:
> Hi,
>
> I add #define REPLACE_INET_NTOA 1 to config.h
>
> and in the debug's I got '7.5.0.10' not not '10.0.5.7 as ip.
>
> WORDS_BIGENDIAN is undefined (SuSE 7.3 i386)
>
> is this really right???
> (lib/replace.c)
> ...
> #ifdef REPLACE_INET_NTOA
> char *rep_inet_ntoa(struct in_addr ip)
> {
> unsigned char *p = (unsigned char *)&ip.s_addr;
> static char buf[18];
> #if WORDS_BIGENDIAN
> slprintf(buf, 17, "%d.%d.%d.%d",
> (int)p[0], (int)p[1], (int)p[2], (int)p[3]);
> #else /* WORDS_BIGENDIAN */
> slprintf(buf, 17, "%d.%d.%d.%d",
> (int)p[3], (int)p[2], (int)p[1], (int)p[0]);
> #endif /* WORDS_BIGENDIAN */
> return buf;
> }
> #endif /* REPLACE_INET_NTOA */
The manpage indicates that (on linux) this is stored in network byte
order, so the 'little endien' case would indeed be wrong.
Can somebody else confirm this?
Andrew Bartlett
--
Andrew Bartlett abartlet at pcug.org.au
Manager, Authentication Subsystems, Samba Team abartlet at samba.org
Student Network Administrator, Hawker College abartlet at hawkerc.net
http://samba.org http://build.samba.org http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20021115/7eea047f/attachment.bin
More information about the samba-technical
mailing list