SIOCGIFCONF usage in unix_get_ifinfo (tcpTransportImpl.cc)
"Aleksander Wlodarczyk" <[email protected]> Wed, 28 Jan 2004 22:20:43 +0100
| Newsgroups | gmane.comp.corba.omniorb.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I tried to port omniORB-4.0.3 to OpenBSD 3.4 and I have found incorrect (in this one and similar cases) usage of SIOCGIFCONF ioctl in tcpTransportImpl module. It's incorrect because it assumes old 4.3 BSD behaviour, and "fixes" "special case" of AIX through OSIOCGIFCONF usage instead of SIOCGIFCONF (AIX is special only in regard to its endianess - it is big endian system, whereas most other are little endian.) In case of OpenBSD (and others also) it means inability to find all interfaces. To clear up the confusion I'd like to explaint that there are generally two types of systems: - supporting old 4.3 BSD behavior, in which case SIOCGIFCONF returns array of equally sized elements, each 16 bytes long (size of struct sockaddr) (but to make the confusion bigger, there are variations returning elements of type struct sockaddr_storage, which is much bigger - 128 or 256 bytes); in this case struct sockaddr looks like that: short sa_family; char sa_data[14]; - supporting new 4.4 BSD behavior, in which case SIOCGIFCONF returns packed array of elements of different size (for example for IP ver. 6 addresses), and OSIOCGIFCONF behaves like 4.3 BSD SIOCGIFCONF; in this case struct sockaddr looks like that: unsigned char sa_len; unsigned char sa_family; char sa_data[14]; First group includes Linux, Solaris and different System V derivatives. Second group includes current BSD derivatives: FreeBSD, NetBSD, OpenBSD, AIX, Tru64 (in this case there is special macrodefinition controlling behaviour of socket routines), etc. I will shortly prepare more general solution, which involves using getifaddrs if it's available, and SIOCGIFCONF ioctl if it isn't. Cheers, Aleksander Wlodarczyk