Build problem when using linux/wireless.h header
An error when building airpwn (airpwn.sf.net) was reported to me:
In file included from airpwn.c:36:/usr/include/linux/wireless.h:886: error: 'IFNAMSIZ' undeclared here (not in a function)airpwn.c: In function 'process_ip_packet':
airpwn.c:482: warning: ignoring return value of 'write', declared with attribute warn_unused_result
airpwn.c:483: warning: ignoring return value of 'write', declared with attribute warn_unused_result
airpwn.c:484: warning: ignoring return value of 'write', declared with attribute warn_unused_result
make[1]: *** [airpwn.o] Error 1
This is on a system with sanitized kernel headers installed. airpwn uses <linux/wireless.h>. The problem here is that wireless.h have:
#ifdef __KERNEL__
#include <linux/types.h> /* for "caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */
#endif /* __KERNEL__ */
This when exported to user space is removed, but they are needed later on, otherwise you get build problems when using this header. One can say that the program including wireless.h should include manually the required headers, but doesn't seem very nice. Also wireless-tools include a copy of wireless.h, seems an unecessary duplication. So what about doing this:
- Don't export wireless.h from kernel to user space, since wireless-tools already provide it.
- Patch wireless-tools to include missing headers like this patch:
wireless.21.h renamed from wireless.21.h.orig +4 -0
@@ -76,6 +76,10 @@#include <linux/types.h> /* for "caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */ +#else +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> #endif /* __KERNEL__ */ /***************************** VERSION *****************************/
wireless.22.h renamed from wireless.22.h.orig +4 -0
@@ -76,6 +76,10 @@#include <linux/types.h> /* for "caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */ +#else +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> #endif /* __KERNEL__ */ /***************************** VERSION *****************************/
--
[]'s
Herton
Em Monday 18 February 2008 14:49:01 Herton Ronaldo Krzesinski escreveu:
Quoted 51 lines
An error when building airpwn (airpwn.sf.net) was reported to me:
In file included from airpwn.c:36:
/usr/include/linux/wireless.h:886: error: 'IFNAMSIZ' undeclared here (not in a function)airpwn.c: In function 'process_ip_packet':
airpwn.c:482: warning: ignoring return value of 'write', declared with attributewarn_unused_result
airpwn.c:483: warning: ignoring return value of 'write', declared with attributewarn_unused_result
airpwn.c:484: warning: ignoring return value of 'write', declared with attributewarn_unused_result
make[1]: *** [airpwn.o] Error 1This is on a system with sanitized kernel headers installed. airpwn uses <
linux/wireless.h>. The problem here is thatwireless.hhave:#ifdef
__KERNEL__#include <linux/types.h> /* for "caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */#endif /*
__KERNEL__*/This when exported to user space is removed, but they are needed later on, otherwise you get build problems when using this header. One can say that the program including
wireless.hshould include manually the required headers, but doesn't seem very nice. Also wireless-tools include a copy ofwireless.h, seems an unecessary duplication. So what about doing this:- Don't export
wireless.hfrom kernel to user space, since wireless-tools already provide it.
- Patch wireless-tools to include missing headers like this patch:diff -p -up wireless_tools.29/wireless.21.h.orig
wireless_tools.29/wireless.21.hwireless.21.h renamed from wireless.21.h.orig +4
-0@@ -76,6 +76,10 @@#include <linux/types.h> /* for "caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */ +#else +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> #endif /* __KERNEL__ */ /***************************** VERSION *****************************/ diff -p -up wireless_tools.29/wireless.22.h.orig
wireless_tools.29/wireless.22.h
wireless.22.h line 85
Quoted 10 lines
wireless.22.h renamed from wireless.22.h.orig +4
-0@@ -76,6 +76,10 @@#include <linux/types.h> /* for "caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */ +#else +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> #endif /* __KERNEL__ */ /***************************** VERSION *****************************/
Ok, there will be still an error because of __user with the patch above (btw the patch is ugly), that can be solved adding:
#ifndef __user
#define __user
#endif
Or just using the linux headers like previously... but then there is the question:
- Why the includes above were protected by "ifdef __KERNEL__"? (yes I read the comment, but they make the header unusable)
--
[]'s
Herton