1/*
2 * WPA Supplicant - driver_wext exported functions
3 * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#ifndef DRIVER_WEXT_H
16#define DRIVER_WEXT_H
17
18#include <net/if.h>
19
20struct wpa_driver_wext_data {
21	void *ctx;
22	int event_sock;
23	int ioctl_sock;
24	int mlme_sock;
25	char ifname[IFNAMSIZ + 1];
26	int ifindex;
27	int ifindex2;
28	int if_removed;
29	u8 *assoc_req_ies;
30	size_t assoc_req_ies_len;
31	u8 *assoc_resp_ies;
32	size_t assoc_resp_ies_len;
33	struct wpa_driver_capa capa;
34	int has_capability;
35	int we_version_compiled;
36
37	/* for set_auth_alg fallback */
38	int use_crypt;
39	int auth_alg_fallback;
40
41	int operstate;
42
43	char mlmedev[IFNAMSIZ + 1];
44
45	int scan_complete_events;
46#ifdef ANDROID
47	int errors;
48	int driver_is_started;
49	int skip_disconnect;
50	int bgscan_enabled;
51#endif
52};
53
54int wpa_driver_wext_get_ifflags(struct wpa_driver_wext_data *drv, int *flags);
55int wpa_driver_wext_set_ifflags(struct wpa_driver_wext_data *drv, int flags);
56int wpa_driver_wext_get_bssid(void *priv, u8 *bssid);
57int wpa_driver_wext_set_bssid(void *priv, const u8 *bssid);
58int wpa_driver_wext_get_ssid(void *priv, u8 *ssid);
59int wpa_driver_wext_set_ssid(void *priv, const u8 *ssid, size_t ssid_len);
60int wpa_driver_wext_set_freq(void *priv, int freq);
61int wpa_driver_wext_set_mode(void *priv, int mode);
62int wpa_driver_wext_set_key(void *priv, wpa_alg alg,
63			    const u8 *addr, int key_idx,
64			    int set_tx, const u8 *seq, size_t seq_len,
65			    const u8 *key, size_t key_len);
66int wpa_driver_wext_scan(void *priv, const u8 *ssid, size_t ssid_len);
67int wpa_driver_wext_combo_scan(void *priv, struct wpa_ssid **ssid_ptr,
68			       struct wpa_ssid *ssid_conf);
69struct wpa_scan_results * wpa_driver_wext_get_scan_results(void *priv);
70
71void wpa_driver_wext_scan_timeout(void *eloop_ctx, void *timeout_ctx);
72
73int wpa_driver_wext_alternative_ifindex(struct wpa_driver_wext_data *drv,
74					const char *ifname);
75
76void * wpa_driver_wext_init(void *ctx, const char *ifname);
77void wpa_driver_wext_deinit(void *priv);
78
79int wpa_driver_wext_set_operstate(void *priv, int state);
80int wpa_driver_wext_get_version(struct wpa_driver_wext_data *drv);
81
82int wpa_driver_wext_associate(void *priv,
83			      struct wpa_driver_associate_params *params);
84int wpa_driver_wext_get_capa(void *priv, struct wpa_driver_capa *capa);
85int wpa_driver_wext_set_auth_param(struct wpa_driver_wext_data *drv,
86				   int idx, u32 value);
87int wpa_driver_wext_cipher2wext(int cipher);
88int wpa_driver_wext_keymgmt2wext(int keymgmt);
89
90#ifdef ANDROID
91#define WEXT_NUMBER_SCAN_CHANNELS_FCC	11
92#define WEXT_NUMBER_SCAN_CHANNELS_ETSI	13
93#define WEXT_NUMBER_SCAN_CHANNELS_MKK1	14
94
95#define WPA_DRIVER_WEXT_WAIT_US		400000
96#define MAX_DRV_CMD_SIZE		248
97#define WEXT_NUMBER_SEQUENTIAL_ERRORS	4
98#define WEXT_CSCAN_AMOUNT		9
99#define WEXT_CSCAN_BUF_LEN		360
100#define WEXT_CSCAN_HEADER		"CSCAN S\x01\x00\x00S\x00"
101#define WEXT_CSCAN_HEADER_SIZE		12
102#define WEXT_CSCAN_SSID_SECTION		'S'
103#define WEXT_CSCAN_CHANNEL_SECTION	'C'
104#define WEXT_CSCAN_NPROBE_SECTION	'N'
105#define WEXT_CSCAN_ACTV_DWELL_SECTION	'A'
106#define WEXT_CSCAN_PASV_DWELL_SECTION	'P'
107#define WEXT_CSCAN_HOME_DWELL_SECTION	'H'
108#define WEXT_CSCAN_TYPE_SECTION		'T'
109#define WEXT_CSCAN_TYPE_DEFAULT		0
110#define WEXT_CSCAN_TYPE_PASSIVE		1
111#define WEXT_CSCAN_PASV_DWELL_TIME	130
112#define WEXT_CSCAN_PASV_DWELL_TIME_DEF	250
113#define WEXT_CSCAN_PASV_DWELL_TIME_MAX	3000
114#define WEXT_CSCAN_HOME_DWELL_TIME	130
115
116#define WEXT_PNOSETUP_HEADER            "PNOSETUP "
117#define WEXT_PNOSETUP_HEADER_SIZE       9
118#define WEXT_PNO_TLV_VERSION            '1'
119#define WEXT_PNO_TLV_SUBVERSION         '2'
120#define WEXT_PNO_TLV_RESERVED           '0'
121#define WEXT_PNO_VERSION_SIZE           4
122#define WEXT_PNO_AMOUNT                 16
123#define WEXT_PNO_SSID_SECTION           'S'
124/* SSID header size is SSID section type above + SSID length */
125#define WEXT_PNO_SSID_HEADER_SIZE       2
126#define WEXT_PNO_SCAN_INTERVAL_SECTION  'T'
127#define WEXT_PNO_SCAN_INTERVAL_LENGTH   2
128#define WEXT_PNO_SCAN_INTERVAL          30
129/* Scan interval size is scan interval section type + scan interval length above*/
130#define WEXT_PNO_SCAN_INTERVAL_SIZE     (1 + WEXT_PNO_SCAN_INTERVAL_LENGTH)
131#define WEXT_PNO_REPEAT_SECTION         'R'
132#define WEXT_PNO_REPEAT_LENGTH          1
133#define WEXT_PNO_REPEAT                 4
134/* Repeat section size is Repeat section type + Repeat value length above*/
135#define WEXT_PNO_REPEAT_SIZE            (1 + WEXT_PNO_REPEAT_LENGTH)
136#define WEXT_PNO_MAX_REPEAT_SECTION     'M'
137#define WEXT_PNO_MAX_REPEAT_LENGTH      1
138#define WEXT_PNO_MAX_REPEAT             3
139/* Max Repeat section size is Max Repeat section type + Max Repeat value length above*/
140#define WEXT_PNO_MAX_REPEAT_SIZE        (1 + WEXT_PNO_MAX_REPEAT_LENGTH)
141/* This corresponds to the size of all sections expect SSIDs */
142#define WEXT_PNO_NONSSID_SECTIONS_SIZE  (WEXT_PNO_SCAN_INTERVAL_SIZE + WEXT_PNO_REPEAT_SIZE + WEXT_PNO_MAX_REPEAT_SIZE)
143/* PNO Max command size is total of header, version, ssid and other sections + Null termination */
144#define WEXT_PNO_MAX_COMMAND_SIZE       (WEXT_PNOSETUP_HEADER_SIZE + WEXT_PNO_VERSION_SIZE \
145					+ WEXT_PNO_AMOUNT * (WEXT_PNO_SSID_HEADER_SIZE + IW_ESSID_MAX_SIZE) \
146					+ WEXT_PNO_NONSSID_SECTIONS_SIZE + 1)
147#endif
148
149#endif /* DRIVER_WEXT_H */
150