Add manpage for stge(4)
[dragonfly.git] / contrib / hostapd-0.4.9 / hostapd.h
1 #ifndef HOSTAPD_H
2 #define HOSTAPD_H
3
4 #include "common.h"
5 #include "ap.h"
6
7 #ifndef ETH_ALEN
8 #define ETH_ALEN 6
9 #endif
10 #ifndef IFNAMSIZ
11 #define IFNAMSIZ 16
12 #endif
13 #ifndef ETH_P_ALL
14 #define ETH_P_ALL 0x0003
15 #endif
16 #ifndef ETH_P_PAE
17 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
18 #endif /* ETH_P_PAE */
19
20 #ifndef BIT
21 #define BIT(x) (1 << (x))
22 #endif
23
24 #ifndef MAC2STR
25 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
26 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
27 #endif
28
29 #include "config.h"
30
31 struct ieee8023_hdr {
32         u8 dest[6];
33         u8 src[6];
34         u16 ethertype;
35 } __attribute__ ((packed));
36
37
38 struct ieee80211_hdr {
39         u16 frame_control;
40         u16 duration_id;
41         u8 addr1[6];
42         u8 addr2[6];
43         u8 addr3[6];
44         u16 seq_ctrl;
45         /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
46          */
47 } __attribute__ ((packed));
48
49 #define IEEE80211_DA_FROMDS addr1
50 #define IEEE80211_BSSID_FROMDS addr2
51 #define IEEE80211_SA_FROMDS addr3
52
53 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
54
55 #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
56
57 /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
58  * frames that might be longer than normal default MTU and they are not
59  * fragmented */
60 #define HOSTAPD_MTU 2290
61
62 extern unsigned char rfc1042_header[6];
63
64 typedef struct hostapd_data hostapd;
65
66 struct hostap_sta_driver_data {
67         unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
68 };
69
70 struct driver_ops;
71 struct wpa_ctrl_dst;
72 struct radius_server_data;
73
74 struct hostapd_data {
75         struct hostapd_config *conf;
76         char *config_fname;
77
78         u8 own_addr[6];
79
80         int num_sta; /* number of entries in sta_list */
81         struct sta_info *sta_list; /* STA info list head */
82         struct sta_info *sta_hash[STA_HASH_SIZE];
83
84         /* pointers to STA info; based on allocated AID or NULL if AID free
85          * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
86          * and so on
87          */
88         struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
89
90         struct driver_ops *driver;
91
92         u8 *default_wep_key;
93         u8 default_wep_key_idx;
94
95         struct radius_client_data *radius;
96         u32 acct_session_id_hi, acct_session_id_lo;
97
98         struct iapp_data *iapp;
99
100         enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
101                ASSOCIATED } assoc_ap_state;
102         char assoc_ap_ssid[33];
103         int assoc_ap_ssid_len;
104         u16 assoc_ap_aid;
105
106         struct hostapd_cached_radius_acl *acl_cache;
107         struct hostapd_acl_query_data *acl_queries;
108
109         u8 *wpa_ie;
110         size_t wpa_ie_len;
111         struct wpa_authenticator *wpa_auth;
112
113 #define PMKID_HASH_SIZE 128
114 #define PMKID_HASH(pmkid) (unsigned int) ((pmkid)[0] & 0x7f)
115         struct rsn_pmksa_cache *pmkid[PMKID_HASH_SIZE];
116         struct rsn_pmksa_cache *pmksa;
117         int pmksa_count;
118
119         struct rsn_preauth_interface *preauth_iface;
120         time_t michael_mic_failure;
121         int michael_mic_failures;
122         int tkip_countermeasures;
123
124         int ctrl_sock;
125         struct wpa_ctrl_dst *ctrl_dst;
126
127         void *ssl_ctx;
128         void *eap_sim_db_priv;
129         struct radius_server_data *radius_srv;
130 };
131
132 void hostapd_new_assoc_sta(hostapd *hapd, struct sta_info *sta, int reassoc);
133 void hostapd_logger(struct hostapd_data *hapd, const u8 *addr,
134                     unsigned int module, int level, const char *fmt,
135                     ...) __attribute__ ((format (printf, 5, 6)));
136
137
138 #define HOSTAPD_DEBUG(level, args...) \
139 do { \
140         if (hapd->conf == NULL || hapd->conf->debug >= (level)) \
141                 printf(args); \
142 } while (0)
143
144 #define HOSTAPD_DEBUG_COND(level) (hapd->conf->debug >= (level))
145
146 const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
147                             size_t buflen);
148
149 #endif /* HOSTAPD_H */