Subject: htons - POSIX vs BSD
To: None <tech-userlevel@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-userlevel
Date: 06/10/2004 17:45:41
$ uname -a
NetBSD IANZAG 2.0_BETA NetBSD 2.0_BETA (IANZAG) #0: Thu Jun  3 20:54:46 NOVST 
2004  ianzag@IANZAG:/usr/src/sys/arch/i386/compile/IANZAG i386

According to htons manual page host/network convertion functions declared as:

---cut---
SYNOPSIS
     #include <sys/types.h>

     in_addr_t
     htonl(in_addr_t host32);

     in_port_t
     htons(in_port_t host16);

     in_addr_t
     ntohl(in_addr_t net32);

     in_port_t
     ntohs(in_port_t net16);
---cut---

...which is not compatible with POSIX declaration:
http://www.opengroup.org/onlinepubs/009695399/functions/htonl.html

---cut---
SYNOPSIS
	#include <arpa/inet.h>
 
	 uint32_t htonl(uint32_t hostlong);
	 uint16_t htons(uint16_t hostshort);
	 uint32_t ntohl(uint32_t netlong);
	 uint16_t ntohs(uint16_t netshort);
---cut---

Different header files, different types, even different goals of convertion - 
POSIX deals with any integers of fixed length and NetBSD deals only with 
internet port/address numbers.

Maybe i'm missing something but this style looks a bit weird, don't you 
think ? :)

// wbr