4 * Jean II - HPLB 97->99 - HPL 99->09
6 * Private common header for the Wireless Extension library...
8 * This file is released under the GPL license.
9 * Copyright (c) 1997-2009 Jean Tourrilhes <jt@hpl.hp.com>
12 #ifndef IWLIB_PRIVATE_H
13 #define IWLIB_PRIVATE_H
15 /*#include "CHANGELOG.h"*/
17 /***************************** INCLUDES *****************************/
19 #include "iwlib.h" /* Public header */
21 /* Make gcc understand that when we say inline, we mean it.
22 * I really hate when the compiler is trying to be more clever than me,
23 * because in this case gcc is not able to figure out functions with a
24 * single call site, so not only I have to tag those functions inline
25 * by hand, but then it refuse to inline them properly.
26 * Total saving for iwevent : 150B = 0.7%.
27 * Fortunately, in gcc 3.4, they now automatically inline static functions
28 * with a single call site. Hurrah !
30 #undef IW_GCC_HAS_BROKEN_INLINE
32 #if __GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 4
33 #define IW_GCC_HAS_BROKEN_INLINE 1
34 #endif /* __GNUC_MINOR__ */
36 /* However, gcc 4.0 has introduce a new "feature", when compiling with
37 * '-Os', it does not want to inline iw_ether_cmp() and friends.
38 * So, we need to fix inline again !
41 #define IW_GCC_HAS_BROKEN_INLINE 1
43 /* Now, really fix the inline */
44 #ifdef IW_GCC_HAS_BROKEN_INLINE
48 #define inline inline __attribute__((always_inline))
49 #endif /* IW_GCC_HAS_BROKEN_INLINE */
55 /****************************** DEBUG ******************************/
59 /************************ CONSTANTS & MACROS ************************/
62 #define PROC_NET_WIRELESS "/proc/net/wireless"
63 #define PROC_NET_DEV "/proc/net/dev"
65 /* Some usefull constants */
69 /* For doing log10/exp10 without libm */
70 #define LOG10_MAGIC 1.25892541179
72 /* Backward compatibility for network headers */
73 #ifndef ARPHRD_IEEE80211
74 #define ARPHRD_IEEE80211 801 /* IEEE 802.11 */
75 #endif /* ARPHRD_IEEE80211 */
77 #ifndef IW_EV_LCP_PK_LEN
78 /* Size of the Event prefix when packed in stream */
79 #define IW_EV_LCP_PK_LEN (4)
80 /* Size of the various events when packed in stream */
81 #define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
82 #define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32))
83 #define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
84 #define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
85 #define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
86 #define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
87 #define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4)
88 #endif /* IW_EV_LCP_PK_LEN */
90 #ifndef IW_EV_LCP_PK2_LEN
93 __u16 len; /* Real lenght of this stuff */
94 __u16 cmd; /* Wireless IOCTL */
95 union iwreq_data u; /* IOCTL fixed payload */
96 } __attribute__ ((packed));
99 void __user *pointer; /* Pointer to the data (in user space) */
100 __u16 length; /* number of fields or size in bytes */
101 __u16 flags; /* Optional params */
102 } __attribute__ ((packed));
104 #define IW_EV_LCP_PK2_LEN (sizeof(struct iw_pk_event) - sizeof(union iwreq_data))
105 #define IW_EV_POINT_PK2_LEN (IW_EV_LCP_PK2_LEN + sizeof(struct iw_pk_point) - IW_EV_POINT_OFF)
106 #endif /* IW_EV_LCP_PK2_LEN */
108 /************************* INLINE FUNTIONS *************************/
110 * Functions that are so simple that it's more efficient inlining them
111 * Most inline are private because gcc is fussy about inline...
114 /*------------------------------------------------------------------*/
116 * Display an Ethernet Socket Address in readable format.
119 iw_saether_ntop(const struct sockaddr *sap, char* bufp)
121 iw_ether_ntop((const struct ether_addr *) sap->sa_data, bufp);
124 /*------------------------------------------------------------------*/
126 * Input an Ethernet Socket Address and convert to binary.
129 iw_saether_aton(const char *bufp, struct sockaddr *sap)
131 sap->sa_family = ARPHRD_ETHER;
132 return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data);
135 /*------------------------------------------------------------------*/
137 * Create an Ethernet broadcast address
140 iw_broad_ether(struct sockaddr *sap)
142 sap->sa_family = ARPHRD_ETHER;
143 memset((char *) sap->sa_data, 0xFF, ETH_ALEN);
146 /*------------------------------------------------------------------*/
148 * Create an Ethernet NULL address
151 iw_null_ether(struct sockaddr *sap)
153 sap->sa_family = ARPHRD_ETHER;
154 memset((char *) sap->sa_data, 0x00, ETH_ALEN);
157 /*------------------------------------------------------------------*/
159 * Compare two ethernet addresses
162 iw_ether_cmp(const struct ether_addr* eth1, const struct ether_addr* eth2)
164 return memcmp(eth1, eth2, sizeof(*eth1));
171 #endif /* IWLIB_PRIVATE_H */