tisdag den 21 september 2010 klockan 15:52 skrev Simon Josefsson detta: > Mats Erik Andersson <mats.anders...@gisladisker.se> writes: > > > tisdag den 21 september 2010 klockan 14:22 skrev Simon Josefsson detta: > >> As an initial response to this problem, I'm installing a self check of > >> the net/if.h interface. See below. Mats, if you could quote the > >> compiler errors you get when building the self-check below on OpenBSD, > >> that would be useful. The next step is to see how gnulib can provide a > >> replacement that works on various systems. Perhaps OpenBSD isn't the > >> only system not working here. > >> > >> /Simon > > > > Quickest reply without need to test compile: > > > > #include <sys/types.h> > > #include <sys/socket.h> > > #include <net/if.h> > > > > is the mandatory order for OpenBSD! Lest <config.h> knows that, > > the test must augmented. Will return later for more info. > > That's the first thing a gnulib net/if.h replacement header should > provide then, since I believe the net/if.h header needs to be > self-contained according to POSIX. > > It would be interesting to see if the self tests works even if you make > the above modification, though. Also try running it with a command line > parameter and check that it prints all the host interfaces on your > machine.
My protocol "report_for_test_net_if.txt" is attached. I am not able to compile the test into any working executable for OpenBSD 4.6. The mishaps are due to "if_freenameindex". In contrast, the original text works for Debian Squeeze, of course. Mats E A
Test protocol of "test-net_if.c" on OpenBSD 4.6 =============================================== Common compiling step $ gcc test-net_if.c Line numbering in printouts is consistent since all of my inclusion additions were inserted once and then deactivated using "//" as protector. ## ## Only <config.h> removed from the suggested module. ## In file included from test-net_if.c:22: /usr/include/net/if.h:240: error: `AF_MAX' undeclared here (not in a function) /usr/include/net/if.h:578: error: field `ifru_addr' has incomplete type /usr/include/net/if.h:579: error: field `ifru_dstaddr' has incomplete type /usr/include/net/if.h:580: error: field `ifru_broadaddr' has incomplete type /usr/include/net/if.h:598: error: field `ifra_addr' has incomplete type /usr/include/net/if.h:599: error: field `ifra_dstaddr' has incomplete type /usr/include/net/if.h:601: error: field `ifra_mask' has incomplete type /usr/include/net/if.h:639: error: field `addr' has incomplete type /usr/include/net/if.h:640: error: field `dstaddr' has incomplete type In file included from /usr/include/net/if.h:657, from test-net_if.c:22: /usr/include/net/if_arp.h:79: error: field `arp_pa' has incomplete type /usr/include/net/if_arp.h:80: error: field `arp_ha' has incomplete type test-net_if.c: In function `main': test-net_if.c:30: error: `if_freenameindex' undeclared (first use in this function) test-net_if.c:30: error: (Each undeclared identifier is reported only once test-net_if.c:30: error: for each function it appears in.) ## ## Addition: ## ## #include <sys/types.h> ## In file included from test-net_if.c:22: /usr/include/net/if.h:240: error: `AF_MAX' undeclared here (not in a function) /usr/include/net/if.h:578: error: field `ifru_addr' has incomplete type /usr/include/net/if.h:579: error: field `ifru_dstaddr' has incomplete type /usr/include/net/if.h:580: error: field `ifru_broadaddr' has incomplete type /usr/include/net/if.h:598: error: field `ifra_addr' has incomplete type /usr/include/net/if.h:599: error: field `ifra_dstaddr' has incomplete type /usr/include/net/if.h:601: error: field `ifra_mask' has incomplete type /usr/include/net/if.h:639: error: field `addr' has incomplete type /usr/include/net/if.h:640: error: field `dstaddr' has incomplete type In file included from /usr/include/net/if.h:657, from test-net_if.c:22: /usr/include/net/if_arp.h:79: error: field `arp_pa' has incomplete type /usr/include/net/if_arp.h:80: error: field `arp_ha' has incomplete type test-net_if.c: In function `main': test-net_if.c:30: error: `if_freenameindex' undeclared (first use in this function) test-net_if.c:30: error: (Each undeclared identifier is reported only once test-net_if.c:30: error: for each function it appears in.) ## ## Addition: ## ## #include <sys/socket.h> ## In file included from test-net_if.c:21: /usr/include/sys/socket.h:152: error: syntax error before "u_int8_t" /usr/include/sys/socket.h:170: error: syntax error before "u_int8_t" /usr/include/sys/socket.h:173: error: syntax error before "u_int64_t" /usr/include/sys/socket.h:239: error: syntax error before "uid_t" /usr/include/sys/socket.h:244: error: syntax error before "gid_t" /usr/include/sys/socket.h:372: error: syntax error before "socklen_t" /usr/include/sys/socket.h:376: error: syntax error before "socklen_t" /usr/include/sys/socket.h:398: error: syntax error before "socklen_t" /usr/include/sys/socket.h:454: error: syntax error before "caddr_t" /usr/include/sys/socket.h:458: error: syntax error before "caddr_t" In file included from test-net_if.c:21: /usr/include/sys/socket.h:469: error: syntax error before "socklen_t" /usr/include/sys/socket.h:470: error: syntax error before "socklen_t" /usr/include/sys/socket.h:471: error: syntax error before "socklen_t" /usr/include/sys/socket.h:472: error: syntax error before "uid_t" /usr/include/sys/socket.h:473: error: syntax error before "socklen_t" /usr/include/sys/socket.h:474: error: syntax error before "socklen_t" /usr/include/sys/socket.h:475: error: syntax error before "socklen_t" /usr/include/sys/socket.h:477: error: syntax error before "recv" /usr/include/sys/socket.h:477: error: syntax error before "size_t" /usr/include/sys/socket.h:478: error: syntax error before "recvfrom" /usr/include/sys/socket.h:478: error: syntax error before "size_t" /usr/include/sys/socket.h:479: error: syntax error before "recvmsg" /usr/include/sys/socket.h:480: error: syntax error before "send" /usr/include/sys/socket.h:480: error: syntax error before "size_t" /usr/include/sys/socket.h:481: error: syntax error before "sendto" /usr/include/sys/socket.h:482: error: syntax error before "size_t" /usr/include/sys/socket.h:483: error: syntax error before "sendmsg" /usr/include/sys/socket.h:484: error: syntax error before "socklen_t" test-net_if.c: In function `main': test-net_if.c:30: error: `if_freenameindex' undeclared (first use in this function) test-net_if.c:30: error: (Each undeclared identifier is reported only once test-net_if.c:30: error: for each function it appears in.) ## ## Additions: ## ## #include <sys/types.h> ## #include <sys/socket.h> ## test-net_if.c: In function `main': test-net_if.c:30: error: `if_freenameindex' undeclared (first use in this function) test-net_if.c:30: error: (Each undeclared identifier is reported only once test-net_if.c:30: error: for each function it appears in.) ## ## Additions: ## ## #include <sys/types.h> ## #include <sys/socket.h> ## ## #undefine if_freenameindex ## test-net_if.c: In function `main': test-net_if.c:32: error: `if_freenameindex' undeclared (first use in this function) test-net_if.c:32: error: (Each undeclared identifier is reported only once test-net_if.c:32: error: for each function it appears in.) test-net_if.c:84: error: `if_freenameindex' used prior to declaration ## ## Addendum: ## ## The relevant part from /usr/include/net/if.h is this #ifndef _KERNEL __BEGIN_DECLS unsigned int if_nametoindex(const char *); char *if_indextoname(unsigned int, char *); struct if_nameindex *if_nameindex(void); __END_DECLS #define if_freenameindex(x) free(x) #endif