blob: 7cd2715458f787c3543c0bcf03a4cefcca7b3d12 [file] [log] [blame]
Jouni Malinencd4e3c32015-10-29 12:39:56 +02001/*
2 * Sigma Control API DUT (station/AP)
3 * Copyright (c) 2010-2011, Atheros Communications, Inc.
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -07004 * Copyright (c) 2011-2017, Qualcomm Atheros, Inc.
Jouni Malinencd4e3c32015-10-29 12:39:56 +02005 * All Rights Reserved.
6 * Licensed under the Clear BSD license. See README for more details.
7 */
8
9#ifndef SIGMA_DUT_H
10#define SIGMA_DUT_H
11
Lior David9981b512017-01-20 13:16:40 +020012#ifdef __GNUC__
13#define _GNU_SOURCE 1
14#endif
15
Jouni Malinencd4e3c32015-10-29 12:39:56 +020016#include <stdlib.h>
17#include <stdio.h>
18#include <stdarg.h>
19#include <string.h>
20#include <errno.h>
21#include <unistd.h>
22#include <time.h>
23#include <sys/time.h>
Jouni Malinen3d972ba2017-03-15 20:52:20 +020024#include <sys/types.h>
Jouni Malinencd4e3c32015-10-29 12:39:56 +020025#include <sys/socket.h>
26#include <net/if.h>
27#ifdef __QNXNTO__
28#include <sys/select.h>
29#include <net/if_ether.h>
30#endif /* __QNXNTO__ */
31#include <netinet/in.h>
32#include <arpa/inet.h>
33#ifdef CONFIG_TRAFFIC_AGENT
34#include <pthread.h>
35#endif /* CONFIG_TRAFFIC_AGENT */
Peng Xu291d97d2018-01-31 16:34:03 -080036#ifdef NL80211_SUPPORT
37#include <netlink/genl/family.h>
38#include <netlink/genl/ctrl.h>
39#include <netlink/genl/genl.h>
40#include "qca-vendor_copy.h"
41#include "nl80211_copy.h"
42#endif /* NL80211_SUPPORT */
Jouni Malinencd4e3c32015-10-29 12:39:56 +020043
44
45#ifdef __GNUC__
46#define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
47#else
48#define PRINTF_FORMAT(a,b)
49#endif
50
51#ifndef SIGMA_TMPDIR
52#define SIGMA_TMPDIR "/tmp"
53#endif /* SIGMA_TMPDIR */
54
55#ifndef SIGMA_DUT_VER
56#define SIGMA_DUT_VER "(unknown)"
57#endif /* SIGMA_DUT_VER */
58
59#ifndef ETH_ALEN
60#define ETH_ALEN 6
61#endif
62
63#ifndef ETH_P_ARP
64#define ETH_P_ARP 0x0806
65#endif
66
67struct sigma_dut;
68
69#define MAX_PARAMS 100
Alejandro Vasquez363f5582018-07-17 11:25:05 -070070#define MAX_RADIO 3
Jouni Malinencd4e3c32015-10-29 12:39:56 +020071
72/* Set default operating channel width 80 MHz */
73#define VHT_DEFAULT_OPER_CHWIDTH AP_80_VHT_OPER_CHWIDTH
74
75typedef unsigned int u32;
Ankita Bajaj1bde7942018-01-09 19:15:01 +053076typedef uint16_t u16;
Jouni Malinencd4e3c32015-10-29 12:39:56 +020077typedef unsigned char u8;
78
79#define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
80 (((u32) (a)[2]) << 8) | ((u32) (a)[3]))
81#define WPA_PUT_BE32(a, val) \
82 do { \
83 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
84 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
85 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
86 (a)[3] = (u8) (((u32) (val)) & 0xff); \
87 } while (0)
88
89struct sigma_cmd {
90 char *params[MAX_PARAMS];
91 char *values[MAX_PARAMS];
92 int count;
93};
94
Alejandro Vasquez3410aa52018-07-17 11:26:17 -070095#define MAX_CMD_LEN 4096
Jouni Malinencd4e3c32015-10-29 12:39:56 +020096
97struct sigma_conn {
98 int s;
99 struct sockaddr_in addr;
100 socklen_t addrlen;
101 char buf[MAX_CMD_LEN + 5];
102 int pos;
103 int waiting_completion;
104};
105
106#define SIGMA_DUT_ERROR_CALLER_SEND_STATUS -2
107#define SIGMA_DUT_INVALID_CALLER_SEND_STATUS -1
108#define SIGMA_DUT_SUCCESS_STATUS_SENT 0
109#define SIGMA_DUT_SUCCESS_CALLER_SEND_STATUS 1
110
111struct sigma_cmd_handler {
112 struct sigma_cmd_handler *next;
113 char *cmd;
114 int (*validate)(struct sigma_cmd *cmd);
115 /* process return value:
116 * -2 = failed, caller will send status,ERROR
117 * -1 = failed, caller will send status,INVALID
118 * 0 = success, response already sent
119 * 1 = success, caller will send status,COMPLETE
120 */
121 int (*process)(struct sigma_dut *dut, struct sigma_conn *conn,
122 struct sigma_cmd *cmd);
123};
124
125#define P2P_GRP_ID_LEN 128
126#define IP_ADDR_STR_LEN 16
127
128struct wfa_cs_p2p_group {
129 struct wfa_cs_p2p_group *next;
130 char ifname[IFNAMSIZ];
131 int go;
132 char grpid[P2P_GRP_ID_LEN];
133 char ssid[33];
134};
135
136#ifdef CONFIG_TRAFFIC_AGENT
137
138#define MAX_SIGMA_STREAMS 16
139#define MAX_SIGMA_STATS 6000
140
141struct sigma_frame_stats {
142 unsigned int seqnum;
143 unsigned int local_sec;
144 unsigned int local_usec;
145 unsigned int remote_sec;
146 unsigned int remote_usec;
147};
148
149struct sigma_stream {
150 enum sigma_stream_profile {
151 SIGMA_PROFILE_FILE_TRANSFER,
152 SIGMA_PROFILE_MULTICAST,
153 SIGMA_PROFILE_IPTV,
154 SIGMA_PROFILE_TRANSACTION,
155 SIGMA_PROFILE_START_SYNC,
156 SIGMA_PROFILE_UAPSD
157 } profile;
158 int sender;
159 struct in_addr dst;
160 int dst_port;
161 struct in_addr src;
162 int src_port;
163 int frame_rate;
164 int duration;
Jouni Malinenc2493f82016-06-05 18:01:33 +0300165 unsigned int payload_size;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200166 int start_delay;
167 int max_cnt;
168 enum sigma_traffic_class {
169 SIGMA_TC_VOICE,
170 SIGMA_TC_VIDEO,
171 SIGMA_TC_BACKGROUND,
172 SIGMA_TC_BEST_EFFORT
173 } tc;
174 int user_priority;
175 int user_priority_set;
176 int started;
177 int no_timestamps;
178
179 int sock;
180 pthread_t thr;
181 int stop;
182 int ta_send_in_progress;
183 int trans_proto;
184
185 /* Statistics */
186 int tx_act_frames; /*
187 * Number of frames generated by the traffic
188 * generator application. The name is defined in the
189 * Sigma CAPI spec.
190 */
191 int tx_frames;
192 int rx_frames;
193 unsigned long long tx_payload_bytes;
194 unsigned long long rx_payload_bytes;
195 int out_of_seq_frames;
196 struct sigma_frame_stats *stats;
197 unsigned int num_stats;
198 unsigned int stream_id;
199
200 /* U-APSD */
201 unsigned int sta_id;
202 unsigned int rx_cookie;
203 unsigned int uapsd_sta_tc;
204 unsigned int uapsd_rx_state;
205 unsigned int uapsd_tx_state;
206 unsigned int tx_stop_cnt;
207 unsigned int tx_hello_cnt;
208 pthread_t uapsd_send_thr;
209 pthread_cond_t tx_thr_cond;
210 pthread_mutex_t tx_thr_mutex;
211 int reset_rx;
212 int num_retry;
213 char ifname[IFNAMSIZ]; /* ifname from the command */
214 struct sigma_dut *dut; /* for traffic agent thread to access context */
Pradeep Reddy POTTETI79594042015-11-23 12:59:12 +0530215 /* console */
216 char test_name[9]; /* test case name */
217 int can_quit;
218 int reset;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200219};
220
221#endif /* CONFIG_TRAFFIC_AGENT */
222
223
224#define NUM_AP_AC 4
225#define AP_AC_BE 0
226#define AP_AC_BK 1
227#define AP_AC_VI 2
228#define AP_AC_VO 3
229
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700230#define MAX_WLAN_TAGS 3
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700231#define MBO_MAX_PREF_BSSIDS 10
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700232#define MAX_FT_BSS_LIST 10
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700233
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200234enum value_not_set_enabled_disabled {
235 VALUE_NOT_SET,
236 VALUE_ENABLED,
237 VALUE_DISABLED
238};
239
Pradeep Reddy Potteti4b0cdee2017-03-15 12:37:33 +0530240enum sec_ch_offset {
241 SEC_CH_NO,
242 SEC_CH_40ABOVE,
243 SEC_CH_40BELOW
244};
245
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700246struct mbo_pref_ap {
247 int ap_ne_class;
248 int ap_ne_op_ch;
249 int ap_ne_pref;
250 unsigned char mac_addr[ETH_ALEN];
251};
252
Peng Xu291d97d2018-01-31 16:34:03 -0800253#ifdef NL80211_SUPPORT
254#define SOCK_BUF_SIZE (32 * 1024)
255struct nl80211_ctx {
256 struct nl_sock *sock;
257 int netlink_familyid;
258 int nlctrl_familyid;
259 size_t sock_buf_size;
260};
261#endif /* NL80211_SUPPORT */
262
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200263struct sigma_dut {
264 int s; /* server TCP socket */
265 int debug_level;
266 int stdout_debug;
267 struct sigma_cmd_handler *cmds;
268
269 /* Default timeout value (seconds) for commands */
270 unsigned int default_timeout;
271
272 int next_streamid;
273
274 const char *bridge; /* bridge interface to use in AP mode */
275
276 enum sigma_mode {
277 SIGMA_MODE_UNKNOWN,
278 SIGMA_MODE_STATION,
279 SIGMA_MODE_AP,
280 SIGMA_MODE_SNIFFER
281 } mode;
282
283 /*
284 * Local cached values to handle API that does not provide all the
285 * needed information with commands that actually trigger some
286 * operations.
287 */
288 int listen_chn;
289 int persistent;
290 int intra_bss;
291 int noa_duration;
292 int noa_interval;
293 int noa_count;
294 enum wfa_cs_wps_method {
295 WFA_CS_WPS_NOT_READY,
296 WFA_CS_WPS_PBC,
297 WFA_CS_WPS_PIN_DISPLAY,
298 WFA_CS_WPS_PIN_LABEL,
299 WFA_CS_WPS_PIN_KEYPAD
300 } wps_method;
301 char wps_pin[9];
302
303 struct wfa_cs_p2p_group *groups;
304
305 char infra_ssid[33];
306 int infra_network_id;
307
308 enum p2p_mode {
309 P2P_IDLE, P2P_DISCOVER, P2P_LISTEN, P2P_DISABLE
310 } p2p_mode;
311
312 int go;
313 int p2p_client;
Purushottam Kushwaha091e2532016-08-23 11:52:21 +0530314 char *p2p_ifname;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200315
316 int client_uapsd;
317
318 char arp_ipaddr[IP_ADDR_STR_LEN];
319 char arp_ifname[IFNAMSIZ + 1];
320
321 enum sta_pmf {
322 STA_PMF_DISABLED,
323 STA_PMF_OPTIONAL,
324 STA_PMF_REQUIRED
325 } sta_pmf;
326
327 int no_tpk_expiration;
328
329 int er_oper_performed;
330 char er_oper_bssid[20];
331 int amsdu_size;
332 int back_rcv_buf;
333
334 int testbed_flag_txsp;
335 int testbed_flag_rxsp;
336 int chwidth;
337
338 /* AP configuration */
339 char ap_ssid[33];
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700340 /*
341 * WLAN-TAG of 1 will use 'ap_' variables;
342 * tag higher than 1 will use 'ap_tag_' variables.
343 */
344 char ap_tag_ssid[MAX_WLAN_TAGS - 1][33];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200345 enum ap_mode {
346 AP_11a,
347 AP_11g,
348 AP_11b,
349 AP_11na,
350 AP_11ng,
351 AP_11ac,
352 AP_inval
353 } ap_mode;
354 int ap_channel;
355 int ap_rts;
356 int ap_frgmnt;
357 int ap_bcnint;
358 struct qos_params {
359 int ac;
360 int cwmin;
361 int cwmax;
362 int aifs;
363 int txop;
364 int acm;
365 } ap_qos[NUM_AP_AC], ap_sta_qos[NUM_AP_AC];
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200366 enum value_not_set_enabled_disabled ap_noack;
367 enum value_not_set_enabled_disabled ap_ampdu;
368 enum value_not_set_enabled_disabled ap_amsdu;
369 enum value_not_set_enabled_disabled ap_rx_amsdu;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200370 int ap_ampdu_exp;
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200371 enum value_not_set_enabled_disabled ap_addba_reject;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200372 int ap_fixed_rate;
373 int ap_mcs;
374 int ap_rx_streams;
375 int ap_tx_streams;
376 unsigned int ap_vhtmcs_map;
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200377 enum value_not_set_enabled_disabled ap_ldpc;
378 enum value_not_set_enabled_disabled ap_sig_rts;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200379 enum ap_chwidth {
380 AP_20,
381 AP_40,
382 AP_80,
383 AP_160,
priyadharshini gowthaman63ab8482017-12-28 15:32:55 -0800384 AP_80_80,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200385 AP_AUTO
386 } ap_chwidth;
Pradeep Reddy Pottetibf8af292017-02-15 15:28:39 +0530387 enum ap_chwidth default_11na_ap_chwidth;
388 enum ap_chwidth default_11ng_ap_chwidth;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200389 int ap_tx_stbc;
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200390 enum value_not_set_enabled_disabled ap_dyn_bw_sig;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200391 int ap_sgi80;
392 int ap_p2p_mgmt;
393 enum ap_key_mgmt {
394 AP_OPEN,
395 AP_WPA2_PSK,
396 AP_WPA_PSK,
397 AP_WPA2_EAP,
398 AP_WPA_EAP,
399 AP_WPA2_EAP_MIXED,
Jouni Malinen30824df2017-08-22 21:21:38 +0300400 AP_WPA2_PSK_MIXED,
401 AP_WPA2_SAE,
402 AP_WPA2_PSK_SAE,
Jouni Malinenad395a22017-09-01 21:13:46 +0300403 AP_SUITEB,
Jouni Malinen147b3c32017-10-09 16:51:54 +0300404 AP_WPA2_OWE,
Jouni Malinen4cf699f2018-06-19 00:46:27 +0300405 AP_WPA2_EAP_OSEN,
Jouni Malinen6be21c82018-08-01 18:47:24 +0300406 AP_WPA2_FT_EAP,
407 AP_WPA2_FT_PSK,
408 AP_WPA2_EAP_SHA256,
409 AP_WPA2_PSK_SHA256,
410 AP_WPA2_ENT_FT_EAP,
Jouni Malinenc2b91212018-09-12 02:26:39 +0300411 AP_OSEN,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200412 } ap_key_mgmt;
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700413 enum ap_tag_key_mgmt {
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200414 AP2_OPEN,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700415 AP2_OSEN,
Jouni Malinen353ba8b2018-01-10 17:04:12 +0200416 AP2_WPA2_PSK,
417 AP2_WPA2_OWE,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700418 } ap_tag_key_mgmt[MAX_WLAN_TAGS - 1];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200419 int ap_add_sha256;
priyadharshini gowthamande81f392017-12-28 15:28:49 -0800420 int ap_add_sha384;
Sarvepalli, Rajesh Babu24dc7e42016-03-18 21:27:26 +0530421 int ap_rsn_preauth;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200422 enum ap_pmf {
423 AP_PMF_DISABLED,
424 AP_PMF_OPTIONAL,
425 AP_PMF_REQUIRED
426 } ap_pmf;
427 enum ap_cipher {
Jouni Malinen2ba24492017-11-17 12:43:59 +0200428 AP_NO_GROUP_CIPHER_SET,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200429 AP_CCMP,
430 AP_TKIP,
431 AP_WEP,
432 AP_PLAIN,
Jouni Malinenad395a22017-09-01 21:13:46 +0300433 AP_CCMP_TKIP,
434 AP_GCMP_256,
Jouni Malinen3d633da2017-09-14 22:19:21 +0300435 AP_GCMP_128,
436 AP_CCMP_256,
Jouni Malinend538c782017-11-17 12:13:04 +0200437 AP_CCMP_128_GCMP_256,
Jouni Malinen2ba24492017-11-17 12:43:59 +0200438 } ap_cipher, ap_group_cipher;
Jouni Malinen3d633da2017-09-14 22:19:21 +0300439 enum ap_group_mgmt_cipher {
440 AP_NO_GROUP_MGMT_CIPHER_SET,
441 AP_BIP_GMAC_256,
442 AP_BIP_CMAC_256,
443 AP_BIP_GMAC_128,
444 AP_BIP_CMAC_128,
445 } ap_group_mgmt_cipher;
Jouni Malinened670f42017-08-31 01:39:28 +0300446 char *ap_sae_groups;
Jouni Malinen2f524ce2017-08-31 01:43:29 +0300447 int sae_anti_clogging_threshold;
Jouni Malinenb347db02017-09-02 01:36:03 +0300448 int sae_reflection;
Jouni Malinen2126f422017-10-11 23:24:33 +0300449 char ap_passphrase[101];
Jouni Malinen63370622017-11-18 17:47:13 +0200450 char ap_psk[65];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200451 char ap_wepkey[27];
452 char ap_radius_ipaddr[20];
453 int ap_radius_port;
454 char ap_radius_password[200];
455 char ap2_radius_ipaddr[20];
456 int ap2_radius_port;
457 char ap2_radius_password[200];
458 int ap_tdls_prohibit;
459 int ap_tdls_prohibit_chswitch;
460 int ap_hs2;
461 int ap_dgaf_disable;
462 int ap_p2p_cross_connect;
463 int ap_oper_name;
464 int ap_wan_metrics;
465 int ap_conn_capab;
466 int ap_oper_class;
467
468 int ap_interworking;
469 int ap_access_net_type;
470 int ap_internet;
471 int ap_venue_group;
472 int ap_venue_type;
473 char ap_hessid[20];
474 char ap_roaming_cons[100];
475 int ap_venue_name;
476 int ap_net_auth_type;
477 int ap_nai_realm_list;
478 char ap_domain_name_list[1000];
479 int ap_ip_addr_type_avail;
480 char ap_plmn_mcc[10][4];
481 char ap_plmn_mnc[10][4];
482 int ap_gas_cb_delay;
483 int ap_proxy_arp;
484 int ap2_proxy_arp;
485 int ap_l2tif;
486 int ap_anqpserver;
487 int ap_anqpserver_on;
488 int ap_osu_provider_list;
489 int ap_qos_map_set;
490 int ap_bss_load;
491 char ap_osu_server_uri[10][256];
492 char ap_osu_ssid[33];
493 int ap_osu_method[10];
494 int ap_osu_icon_tag;
Jouni Malinen54a89b02018-05-01 00:16:26 +0300495 int ap_venue_url;
Jouni Malinenf7ff42b2018-05-01 00:21:56 +0300496 int ap_advice_of_charge;
Jouni Malinenac104532018-05-01 00:27:37 +0300497 int ap_oper_icon_metadata;
Jouni Malinenac367142018-05-01 00:32:24 +0300498 int ap_tnc_file_name;
499 unsigned int ap_tnc_time_stamp;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200500
501 int ap_fake_pkhash;
502 int ap_disable_protection;
503 int ap_allow_vht_wep;
504 int ap_allow_vht_tkip;
505
506 enum ap_vht_chwidth {
507 AP_20_40_VHT_OPER_CHWIDTH,
508 AP_80_VHT_OPER_CHWIDTH,
509 AP_160_VHT_OPER_CHWIDTH
510 } ap_vht_chwidth;
511 int ap_txBF;
512 int ap_mu_txBF;
Pradeep Reddy POTTETIfba27db2015-11-20 16:42:22 +0530513 enum ap_regulatory_mode {
514 AP_80211D_MODE_DISABLED,
515 AP_80211D_MODE_ENABLED,
516 } ap_regulatory_mode;
517 enum ap_dfs_mode {
518 AP_DFS_MODE_DISABLED,
519 AP_DFS_MODE_ENABLED,
520 } ap_dfs_mode;
priyadharshini gowthaman264d5442016-02-25 15:52:22 -0800521 int ap_ndpa_frame;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200522
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700523 int ap_lci;
524 char ap_val_lci[33];
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700525 char ap_infoz[17];
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700526 int ap_lcr;
527 char ap_val_lcr[400];
528 int ap_rrm;
529 int ap_rtt;
530 int ap_neighap; /* number of configured neighbor APs */
531 unsigned char ap_val_neighap[3][6];
532 int ap_opchannel; /* number of oper channels */
533 int ap_val_opchannel[3];
534 int ap_scan;
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700535 int ap_fqdn_held;
536 int ap_fqdn_supl;
priyadharshini gowthamana27b5b62016-06-22 22:47:14 -0700537 int ap_msnt_type;
538
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700539 int ap_mbo;
540 int ap_ne_class;
541 int ap_ne_op_ch;
542 int ap_set_bssidpref;
543 int ap_btmreq_disassoc_imnt;
544 int ap_btmreq_term_bit;
Adil Saeed Musthafa7d9ae382017-04-10 23:13:33 -0700545 int ap_disassoc_timer;
546 int ap_btmreq_bss_term_dur;
Adil Saeed Musthafa604c8262017-04-10 23:13:31 -0700547 enum reg_domain {
548 REG_DOMAIN_NOT_SET,
549 REG_DOMAIN_LOCAL,
550 REG_DOMAIN_GLOBAL
551 } ap_reg_domain;
Adil Saeed Musthafacf752fa2017-04-10 23:13:32 -0700552 char ap_mobility_domain[10];
Adil Saeed Musthafa023108a2017-04-10 23:13:37 -0700553 unsigned char ap_cell_cap_pref;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700554 int ap_ft_oa;
555 int ap_name;
priyadharshini gowthaman09d613e2017-12-20 11:43:44 -0800556 int ap_interface_5g;
557 int ap_interface_2g;
priyadharshini gowthaman776562e2017-12-20 12:33:34 -0800558 int ap_assoc_delay;
priyadharshini gowthaman94062b52017-12-20 12:33:34 -0800559 int ap_btmreq_bss_term_tsf;
priyadharshini gowthaman00798a22017-12-28 15:15:00 -0800560 int ap_fils_dscv_int;
561 int ap_nairealm_int;
562 char ap_nairealm[33];
563 int ap_blechanutil;
564 int ap_ble_admit_cap;
565 int ap_datappdudura;
566 int ap_airtimefract;
567 char ap_dhcpserv_ipaddr[20];
568 int ap_dhcp_stop;
569 int ap_bawinsize;
570 int ap_blestacnt;
priyadharshini gowthamancb22e432017-12-28 15:23:31 -0800571 int ap_ul_availcap;
572 int ap_dl_availcap;
priyadharshini gowthamande81f392017-12-28 15:28:49 -0800573 int ap_akm;
574 int ap_pmksa;
575 int ap_pmksa_caching;
priyadharshini gowthaman63ab8482017-12-28 15:32:55 -0800576 int ap_80plus80;
priyadharshini gowthaman9149afc2018-01-15 13:40:18 -0800577 int ap_oper_chn;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700578
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700579 struct mbo_pref_ap mbo_pref_aps[MBO_MAX_PREF_BSSIDS];
580 struct mbo_pref_ap mbo_self_ap_tuple;
581 int mbo_pref_ap_cnt;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700582 unsigned char ft_bss_mac_list[MAX_FT_BSS_LIST][ETH_ALEN];
583 int ft_bss_mac_cnt;
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700584
priyadharshini gowthaman00798a22017-12-28 15:15:00 -0800585 enum value_not_set_enabled_disabled ap_oce;
586 enum value_not_set_enabled_disabled ap_filsdscv;
587 enum value_not_set_enabled_disabled ap_filshlp;
588 enum value_not_set_enabled_disabled ap_broadcast_ssid;
589 enum value_not_set_enabled_disabled ap_rnr;
590 enum value_not_set_enabled_disabled ap_esp;
591
priyadharshini gowthaman350f1912018-06-04 13:09:12 -0700592 enum ppdu {
593 PPDU_NOT_SET,
594 PPDU_MU,
595 PPDU_SU,
596 PPDU_ER,
597 PPDU_TB,
598 } ap_he_ppdu;
599
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200600 const char *hostapd_debug_log;
601
602#ifdef CONFIG_TRAFFIC_AGENT
603 /* Traffic Agent */
604 struct sigma_stream streams[MAX_SIGMA_STREAMS];
605 int stream_id;
606 int num_streams;
607 pthread_t thr;
608#endif /* CONFIG_TRAFFIC_AGENT */
609
Jouni Malinenc2493f82016-06-05 18:01:33 +0300610 unsigned int throughput_pktsize; /* If non-zero, override pktsize for
611 * throughput tests */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200612 int no_timestamps;
613
614 const char *sniffer_ifname;
615 const char *set_macaddr;
616 int tmp_mac_addr;
617 int ap_is_dual;
618 enum ap_mode ap_mode_1;
619 enum ap_chwidth ap_chwidth_1;
620 int ap_channel_1;
621 char ap_countrycode[3];
622
623 int ap_wpsnfc;
624
Pradeep Reddy POTTETI0d3db632016-03-11 15:21:11 +0530625 enum ap_wme {
626 AP_WME_OFF,
627 AP_WME_ON,
628 } ap_wme;
629
Mohammed Shafi Shajakhan02e3b822017-02-23 04:15:02 +0530630 enum ap_wmmps {
631 AP_WMMPS_OFF,
632 AP_WMMPS_ON,
633 } ap_wmmps;
634
Pradeep Reddy Potteti4b0cdee2017-03-15 12:37:33 +0530635 enum sec_ch_offset ap_chwidth_offset;
636
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200637#ifdef CONFIG_SNIFFER
638 pid_t sniffer_pid;
639 char sniffer_filename[200];
640#endif /* CONFIG_SNIFFER */
641
642 int last_set_ip_config_ipv6;
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -0700643#ifdef MIRACAST
644 pthread_t rtsp_thread_handle;
645 int wfd_device_type; /* 0 for source, 1 for sink */
646 char peer_mac_address[32];
647 void *miracast_lib;
648 const char *miracast_lib_path;
649 char mdns_instance_name[64];
650#endif /* MIRACAST */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200651
652 int tid_to_handle[8]; /* Mapping of TID to handle */
653 int dialog_token; /* Used for generating unique handle for an addTs */
654
655 enum sigma_program {
656 PROGRAM_UNKNOWN = 0,
657 PROGRAM_TDLS,
658 PROGRAM_HS2,
659 PROGRAM_HS2_R2,
660 PROGRAM_WFD,
Amarnath Hullur Subramanyam659a34c2017-03-17 00:04:41 -0700661 PROGRAM_DISPLAYR2,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200662 PROGRAM_PMF,
663 PROGRAM_WPS,
664 PROGRAM_60GHZ,
665 PROGRAM_HT,
666 PROGRAM_VHT,
667 PROGRAM_NAN,
priyadharshini gowthaman12dd4142016-06-22 22:47:14 -0700668 PROGRAM_LOC,
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700669 PROGRAM_MBO,
Jouni Malinen5c3813a2017-08-26 13:30:39 +0300670 PROGRAM_IOTLP,
671 PROGRAM_DPP,
Ankita Bajaja2cb5672017-10-25 16:08:28 +0530672 PROGRAM_OCE,
priyadharshini gowthaman0e209fc2018-01-26 15:15:37 -0800673 PROGRAM_WPA3,
Amarnath Hullur Subramanyam8f9c8682018-01-30 19:01:51 -0800674 PROGRAM_HE,
Jouni Malinenba630452018-06-22 11:49:59 +0300675 PROGRAM_HS2_R3,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200676 } program;
677
678 enum device_type {
679 device_type_unknown,
680 AP_unknown,
681 AP_testbed,
682 AP_dut,
683 STA_unknown,
684 STA_testbed,
685 STA_dut
686 } device_type;
687
688 enum {
689 DEVROLE_UNKNOWN = 0,
690 DEVROLE_STA,
691 DEVROLE_PCP,
Ankita Bajaj0d5825b2017-10-25 16:20:17 +0530692 DEVROLE_STA_CFON
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200693 } dev_role;
694
695 const char *version;
696 int no_ip_addr_set;
697 int sta_channel;
698
699 const char *summary_log;
700 const char *hostapd_entropy_log;
701
702 int iface_down_on_reset;
703 int write_stats; /* traffic stream e2e*.txt files */
Bala Krishna Bhamidipati73d7af02016-03-24 12:27:56 +0530704 int sim_no_username; /* do not set SIM username to use real SIM */
Jouni Malinen5db3b102016-08-04 12:27:18 +0300705
706 const char *vendor_name; /* device_get_info vendor override */
707 const char *model_name; /* device_get_info model override */
708 const char *version_name; /* device_get_info version override */
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700709
Rakesh Sunki14cfcd22017-03-30 14:47:55 -0700710 int ndp_enable; /* Flag which is set once the NDP is setup */
711
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700712 /* Length of nan_pmk in octets */
713 u8 nan_pmk_len;
714
715 /*
716 * PMK: Info is optional in Discovery phase. PMK info can
717 * be passed during the NDP session.
718 */
719 u8 nan_pmk[32];
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700720
721 enum value_not_set_enabled_disabled wnm_bss_max_feature;
722 int wnm_bss_max_idle_time;
723 enum value_not_set_enabled_disabled wnm_bss_max_protection;
Ashwini Patil00402582017-04-13 12:29:39 +0530724
725 char *non_pref_ch_list; /* MBO: non-preferred channel report */
Ashwini Patil5acd7382017-04-13 15:55:04 +0530726 char *btm_query_cand_list; /* Candidate list for BTM Query */
Jouni Malinen3c367e82017-06-23 17:01:47 +0300727
Jouni Malinen68143132017-09-02 02:34:08 +0300728 char *sae_commit_override;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300729 char *rsne_override;
Jouni Malinend6bf1b42017-06-23 17:51:01 +0300730 const char *hostapd_bin;
731 int use_hostapd_pid_file;
732 const char *hostapd_ifname;
Jouni Malinend86e5822017-08-29 03:55:32 +0300733 int hostapd_running;
734
Jouni Malinenb1dd21f2017-11-13 19:14:29 +0200735 char *dpp_peer_uri;
Jouni Malinend86e5822017-08-29 03:55:32 +0300736 int dpp_local_bootstrap;
737 int dpp_conf_id;
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530738
739 u8 fils_hlp;
740 pthread_t hlp_thread;
Peng Xu291d97d2018-01-31 16:34:03 -0800741
742#ifdef NL80211_SUPPORT
743 struct nl80211_ctx *nl_ctx;
Sunil Dutt076081f2018-02-05 19:45:50 +0530744 int config_rsnie;
Peng Xu291d97d2018-01-31 16:34:03 -0800745#endif /* NL80211_SUPPORT */
Arif Hussainac6c5112018-05-25 17:34:00 -0700746
747 int sta_nss;
Anurag Das2052daa2018-08-31 14:35:25 +0530748
749#ifdef ANDROID
750 int nanservicediscoveryinprogress;
751#endif /* ANDROID */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200752};
753
754
755enum sigma_dut_print_level {
756 DUT_MSG_DEBUG, DUT_MSG_INFO, DUT_MSG_ERROR
757};
758
759void sigma_dut_print(struct sigma_dut *dut, int level, const char *fmt, ...)
760PRINTF_FORMAT(3, 4);
761
762void sigma_dut_summary(struct sigma_dut *dut, const char *fmt, ...)
763PRINTF_FORMAT(2, 3);
764
765
766enum sigma_status {
767 SIGMA_RUNNING, SIGMA_INVALID, SIGMA_ERROR, SIGMA_COMPLETE
768};
769
770void send_resp(struct sigma_dut *dut, struct sigma_conn *conn,
Jouni Malinen76401f52017-03-18 01:04:55 +0200771 enum sigma_status status, const char *buf);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200772
773const char * get_param(struct sigma_cmd *cmd, const char *name);
774
775int sigma_dut_reg_cmd(const char *cmd,
776 int (*validate)(struct sigma_cmd *cmd),
777 int (*process)(struct sigma_dut *dut,
778 struct sigma_conn *conn,
779 struct sigma_cmd *cmd));
780
781void sigma_dut_register_cmds(void);
782
783int cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
784 struct sigma_cmd *cmd);
785int cmd_sta_set_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
786 struct sigma_cmd *cmd);
787int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
788 struct sigma_cmd *cmd);
789int cmd_wlantest_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
790 struct sigma_cmd *cmd);
Ankita Bajaj0d5825b2017-10-25 16:20:17 +0530791int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn,
792 struct sigma_cmd *cmd);
793int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn,
794 struct sigma_cmd *cmd);
795int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
796 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200797
798enum driver_type {
799 DRIVER_NOT_SET,
800 DRIVER_ATHEROS,
801 DRIVER_WCN,
802 DRIVER_MAC80211,
803 DRIVER_AR6003,
804 DRIVER_WIL6210,
805 DRIVER_QNXNTO,
Sreelakshmi Konamkib692f102016-04-26 19:47:00 +0530806 DRIVER_OPENWRT,
807 DRIVER_LINUX_WCN,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200808};
809
810enum openwrt_driver_type {
811 OPENWRT_DRIVER_NOT_SET,
812 OPENWRT_DRIVER_ATHEROS
813};
814
815#define DRIVER_NAME_60G "wil6210"
816
817int set_wifi_chip(const char *chip_type);
818enum driver_type get_driver_type(void);
819enum openwrt_driver_type get_openwrt_driver_type(void);
820int file_exists(const char *fname);
821
822struct wpa_ctrl;
823
824int wps_connection_event(struct sigma_dut *dut, struct sigma_conn *conn,
825 struct wpa_ctrl *ctrl, const char *intf, int p2p_resp);
826int ascii2hexstr(const char *str, char *hex);
827void disconnect_station(struct sigma_dut *dut);
828void nfc_status(struct sigma_dut *dut, const char *state, const char *oper);
829int get_ip_config(struct sigma_dut *dut, const char *ifname, char *buf,
830 size_t buf_len);
831int ath6kl_client_uapsd(struct sigma_dut *dut, const char *intf, int uapsd);
832int is_ip_addr(const char *str);
833int run_system(struct sigma_dut *dut, const char *cmd);
Adil Saeed Musthafa5f793f02017-04-10 23:13:30 -0700834int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200835int cmd_wlantest_set_channel(struct sigma_dut *dut, struct sigma_conn *conn,
836 struct sigma_cmd *cmd);
837void sniffer_close(struct sigma_dut *dut);
838
839/* ap.c */
840void ath_disable_txbf(struct sigma_dut *dut, const char *intf);
Priyadharshini Gowthaman818afef2015-11-09 13:28:15 -0800841void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname,
842 const char *val);
priyadharshini gowthamane5e25172015-12-08 14:53:48 -0800843void novap_reset(struct sigma_dut *dut, const char *ifname);
Jouni Malinen2e6ccc22017-09-04 13:43:16 +0300844int get_hwaddr(const char *ifname, unsigned char *hwaddr);
Jouni Malinena326d7b2017-09-04 13:46:02 +0300845int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn,
846 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200847
848/* sta.c */
849int set_ps(const char *intf, struct sigma_dut *dut, int enabled);
850void ath_set_zero_crc(struct sigma_dut *dut, const char *val);
851void ath_set_cts_width(struct sigma_dut *dut, const char *ifname,
852 const char *val);
853int ath_set_width(struct sigma_dut *dut, struct sigma_conn *conn,
854 const char *intf, const char *val);
Lior David0fe101e2017-03-09 16:09:50 +0200855int wil6210_send_frame_60g(struct sigma_dut *dut, struct sigma_conn *conn,
856 struct sigma_cmd *cmd);
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530857int hwaddr_aton(const char *txt, unsigned char *addr);
858int set_ipv4_addr(struct sigma_dut *dut, const char *ifname,
859 const char *ip, const char *mask);
860int set_ipv4_gw(struct sigma_dut *dut, const char *gw);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200861
862/* p2p.c */
863int p2p_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
864 struct sigma_cmd *cmd);
Purushottam Kushwaha091e2532016-08-23 11:52:21 +0530865void p2p_create_event_thread(struct sigma_dut *dut);
866void stop_event_thread(void);
Amarnath Hullur Subramanyam89b37cd2017-03-17 00:04:41 -0700867void start_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
868void stop_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
869int p2p_discover_peer(struct sigma_dut *dut, const char *ifname,
870 const char *peer, int full);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200871
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700872/* utils.c */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200873enum sigma_program sigma_program_to_enum(const char *prog);
Jouni Malinen08cf2312017-09-04 13:39:47 +0300874int parse_hexstr(const char *hex, unsigned char *buf, size_t buflen);
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700875int parse_mac_address(struct sigma_dut *dut, const char *arg,
876 unsigned char *addr);
Rakesh Sunki7192dc42017-03-30 14:47:55 -0700877unsigned int channel_to_freq(unsigned int channel);
878unsigned int freq_to_channel(unsigned int freq);
Peng Xu525965b2018-06-26 16:40:14 -0700879int is_ipv6_addr(const char *str);
Rakesh Sunki8f8e74b2017-05-16 15:42:12 -0700880void convert_mac_addr_to_ipv6_lladdr(u8 *mac_addr, char *ipv6_buf,
881 size_t buf_len);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200882
Peng Xu769731a2017-05-10 17:27:28 -0700883#ifndef ANDROID
884size_t strlcpy(char *dest, const char *src, size_t siz);
885size_t strlcat(char *dst, const char *str, size_t size);
886#endif /* ANDROID */
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530887void hex_dump(struct sigma_dut *dut, u8 *data, size_t len);
Peng Xu769731a2017-05-10 17:27:28 -0700888
889
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200890/* uapsd_stream.c */
891void receive_uapsd(struct sigma_stream *s);
Pradeep Reddy POTTETI79594042015-11-23 12:59:12 +0530892void send_uapsd_console(struct sigma_stream *s);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200893
894/* nan.c */
895int nan_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn,
896 struct sigma_cmd *cmd);
897int nan_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
898 struct sigma_cmd *cmd);
899int nan_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
900 struct sigma_cmd *cmd);
901int nan_cmd_sta_get_events(struct sigma_dut *dut, struct sigma_conn *conn,
902 struct sigma_cmd *cmd);
903int nan_cmd_sta_transmit_followup(struct sigma_dut *dut,
904 struct sigma_conn *conn,
905 struct sigma_cmd *cmd);
906void nan_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
907 struct sigma_cmd *cmd);
908int nan_cmd_sta_preset_testparameters(struct sigma_dut *dut,
909 struct sigma_conn *conn,
910 struct sigma_cmd *cmd);
911
priyadharshini gowthamand66913a2016-07-29 15:11:17 -0700912/* ftm.c */
913int loc_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
914 struct sigma_cmd *cmd);
915int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
916 struct sigma_cmd *cmd);
917int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
918 struct sigma_conn *conn,
919 struct sigma_cmd *cmd);
920
Jouni Malinend86e5822017-08-29 03:55:32 +0300921/* dpp.c */
922int dpp_dev_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
923 struct sigma_cmd *cmd);
924
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530925/* dhcp.c */
926void process_fils_hlp(struct sigma_dut *dut);
927void hlp_thread_cleanup(struct sigma_dut *dut);
Jouni Malinend86e5822017-08-29 03:55:32 +0300928
Peng Xu291d97d2018-01-31 16:34:03 -0800929#ifdef NL80211_SUPPORT
930struct nl80211_ctx * nl80211_init(struct sigma_dut *dut);
931void nl80211_deinit(struct sigma_dut *dut, struct nl80211_ctx *ctx);
932struct nl_msg * nl80211_drv_msg(struct sigma_dut *dut, struct nl80211_ctx *ctx,
933 int ifindex, int flags,
934 uint8_t cmd);
935int send_and_recv_msgs(struct sigma_dut *dut, struct nl80211_ctx *ctx,
936 struct nl_msg *nlmsg,
937 int (*valid_handler)(struct nl_msg *, void *),
938 void *valid_data);
939#endif /* NL80211_SUPPORT */
940
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200941#endif /* SIGMA_DUT_H */