blob: 3e9d311f3dc8d1bffb1e264d50b9ebf74c8816bc [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
70#define MAX_RADIO 2
71
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
95#define MAX_CMD_LEN 2048
96
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 Malinencd4e3c32015-10-29 12:39:56 +0200405 } ap_key_mgmt;
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700406 enum ap_tag_key_mgmt {
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200407 AP2_OPEN,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700408 AP2_OSEN,
Jouni Malinen353ba8b2018-01-10 17:04:12 +0200409 AP2_WPA2_PSK,
410 AP2_WPA2_OWE,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700411 } ap_tag_key_mgmt[MAX_WLAN_TAGS - 1];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200412 int ap_add_sha256;
priyadharshini gowthamande81f392017-12-28 15:28:49 -0800413 int ap_add_sha384;
Sarvepalli, Rajesh Babu24dc7e42016-03-18 21:27:26 +0530414 int ap_rsn_preauth;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200415 enum ap_pmf {
416 AP_PMF_DISABLED,
417 AP_PMF_OPTIONAL,
418 AP_PMF_REQUIRED
419 } ap_pmf;
420 enum ap_cipher {
Jouni Malinen2ba24492017-11-17 12:43:59 +0200421 AP_NO_GROUP_CIPHER_SET,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200422 AP_CCMP,
423 AP_TKIP,
424 AP_WEP,
425 AP_PLAIN,
Jouni Malinenad395a22017-09-01 21:13:46 +0300426 AP_CCMP_TKIP,
427 AP_GCMP_256,
Jouni Malinen3d633da2017-09-14 22:19:21 +0300428 AP_GCMP_128,
429 AP_CCMP_256,
Jouni Malinend538c782017-11-17 12:13:04 +0200430 AP_CCMP_128_GCMP_256,
Jouni Malinen2ba24492017-11-17 12:43:59 +0200431 } ap_cipher, ap_group_cipher;
Jouni Malinen3d633da2017-09-14 22:19:21 +0300432 enum ap_group_mgmt_cipher {
433 AP_NO_GROUP_MGMT_CIPHER_SET,
434 AP_BIP_GMAC_256,
435 AP_BIP_CMAC_256,
436 AP_BIP_GMAC_128,
437 AP_BIP_CMAC_128,
438 } ap_group_mgmt_cipher;
Jouni Malinened670f42017-08-31 01:39:28 +0300439 char *ap_sae_groups;
Jouni Malinen2f524ce2017-08-31 01:43:29 +0300440 int sae_anti_clogging_threshold;
Jouni Malinenb347db02017-09-02 01:36:03 +0300441 int sae_reflection;
Jouni Malinen2126f422017-10-11 23:24:33 +0300442 char ap_passphrase[101];
Jouni Malinen63370622017-11-18 17:47:13 +0200443 char ap_psk[65];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200444 char ap_wepkey[27];
445 char ap_radius_ipaddr[20];
446 int ap_radius_port;
447 char ap_radius_password[200];
448 char ap2_radius_ipaddr[20];
449 int ap2_radius_port;
450 char ap2_radius_password[200];
451 int ap_tdls_prohibit;
452 int ap_tdls_prohibit_chswitch;
453 int ap_hs2;
454 int ap_dgaf_disable;
455 int ap_p2p_cross_connect;
456 int ap_oper_name;
457 int ap_wan_metrics;
458 int ap_conn_capab;
459 int ap_oper_class;
460
461 int ap_interworking;
462 int ap_access_net_type;
463 int ap_internet;
464 int ap_venue_group;
465 int ap_venue_type;
466 char ap_hessid[20];
467 char ap_roaming_cons[100];
468 int ap_venue_name;
469 int ap_net_auth_type;
470 int ap_nai_realm_list;
471 char ap_domain_name_list[1000];
472 int ap_ip_addr_type_avail;
473 char ap_plmn_mcc[10][4];
474 char ap_plmn_mnc[10][4];
475 int ap_gas_cb_delay;
476 int ap_proxy_arp;
477 int ap2_proxy_arp;
478 int ap_l2tif;
479 int ap_anqpserver;
480 int ap_anqpserver_on;
481 int ap_osu_provider_list;
482 int ap_qos_map_set;
483 int ap_bss_load;
484 char ap_osu_server_uri[10][256];
485 char ap_osu_ssid[33];
486 int ap_osu_method[10];
487 int ap_osu_icon_tag;
488
489 int ap_fake_pkhash;
490 int ap_disable_protection;
491 int ap_allow_vht_wep;
492 int ap_allow_vht_tkip;
493
494 enum ap_vht_chwidth {
495 AP_20_40_VHT_OPER_CHWIDTH,
496 AP_80_VHT_OPER_CHWIDTH,
497 AP_160_VHT_OPER_CHWIDTH
498 } ap_vht_chwidth;
499 int ap_txBF;
500 int ap_mu_txBF;
Pradeep Reddy POTTETIfba27db2015-11-20 16:42:22 +0530501 enum ap_regulatory_mode {
502 AP_80211D_MODE_DISABLED,
503 AP_80211D_MODE_ENABLED,
504 } ap_regulatory_mode;
505 enum ap_dfs_mode {
506 AP_DFS_MODE_DISABLED,
507 AP_DFS_MODE_ENABLED,
508 } ap_dfs_mode;
priyadharshini gowthaman264d5442016-02-25 15:52:22 -0800509 int ap_ndpa_frame;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200510
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700511 int ap_lci;
512 char ap_val_lci[33];
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700513 char ap_infoz[17];
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700514 int ap_lcr;
515 char ap_val_lcr[400];
516 int ap_rrm;
517 int ap_rtt;
518 int ap_neighap; /* number of configured neighbor APs */
519 unsigned char ap_val_neighap[3][6];
520 int ap_opchannel; /* number of oper channels */
521 int ap_val_opchannel[3];
522 int ap_scan;
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700523 int ap_fqdn_held;
524 int ap_fqdn_supl;
priyadharshini gowthamana27b5b62016-06-22 22:47:14 -0700525 int ap_msnt_type;
526
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700527 int ap_mbo;
528 int ap_ne_class;
529 int ap_ne_op_ch;
530 int ap_set_bssidpref;
531 int ap_btmreq_disassoc_imnt;
532 int ap_btmreq_term_bit;
Adil Saeed Musthafa7d9ae382017-04-10 23:13:33 -0700533 int ap_disassoc_timer;
534 int ap_btmreq_bss_term_dur;
Adil Saeed Musthafa604c8262017-04-10 23:13:31 -0700535 enum reg_domain {
536 REG_DOMAIN_NOT_SET,
537 REG_DOMAIN_LOCAL,
538 REG_DOMAIN_GLOBAL
539 } ap_reg_domain;
Adil Saeed Musthafacf752fa2017-04-10 23:13:32 -0700540 char ap_mobility_domain[10];
Adil Saeed Musthafa023108a2017-04-10 23:13:37 -0700541 unsigned char ap_cell_cap_pref;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700542 int ap_ft_oa;
543 int ap_name;
priyadharshini gowthaman09d613e2017-12-20 11:43:44 -0800544 int ap_interface_5g;
545 int ap_interface_2g;
priyadharshini gowthaman776562e2017-12-20 12:33:34 -0800546 int ap_assoc_delay;
priyadharshini gowthaman94062b52017-12-20 12:33:34 -0800547 int ap_btmreq_bss_term_tsf;
priyadharshini gowthaman00798a22017-12-28 15:15:00 -0800548 int ap_fils_dscv_int;
549 int ap_nairealm_int;
550 char ap_nairealm[33];
551 int ap_blechanutil;
552 int ap_ble_admit_cap;
553 int ap_datappdudura;
554 int ap_airtimefract;
555 char ap_dhcpserv_ipaddr[20];
556 int ap_dhcp_stop;
557 int ap_bawinsize;
558 int ap_blestacnt;
priyadharshini gowthamancb22e432017-12-28 15:23:31 -0800559 int ap_ul_availcap;
560 int ap_dl_availcap;
priyadharshini gowthamande81f392017-12-28 15:28:49 -0800561 int ap_akm;
562 int ap_pmksa;
563 int ap_pmksa_caching;
priyadharshini gowthaman63ab8482017-12-28 15:32:55 -0800564 int ap_80plus80;
priyadharshini gowthaman9149afc2018-01-15 13:40:18 -0800565 int ap_oper_chn;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700566
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700567 struct mbo_pref_ap mbo_pref_aps[MBO_MAX_PREF_BSSIDS];
568 struct mbo_pref_ap mbo_self_ap_tuple;
569 int mbo_pref_ap_cnt;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700570 unsigned char ft_bss_mac_list[MAX_FT_BSS_LIST][ETH_ALEN];
571 int ft_bss_mac_cnt;
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700572
priyadharshini gowthaman00798a22017-12-28 15:15:00 -0800573 enum value_not_set_enabled_disabled ap_oce;
574 enum value_not_set_enabled_disabled ap_filsdscv;
575 enum value_not_set_enabled_disabled ap_filshlp;
576 enum value_not_set_enabled_disabled ap_broadcast_ssid;
577 enum value_not_set_enabled_disabled ap_rnr;
578 enum value_not_set_enabled_disabled ap_esp;
579
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200580 const char *hostapd_debug_log;
581
582#ifdef CONFIG_TRAFFIC_AGENT
583 /* Traffic Agent */
584 struct sigma_stream streams[MAX_SIGMA_STREAMS];
585 int stream_id;
586 int num_streams;
587 pthread_t thr;
588#endif /* CONFIG_TRAFFIC_AGENT */
589
Jouni Malinenc2493f82016-06-05 18:01:33 +0300590 unsigned int throughput_pktsize; /* If non-zero, override pktsize for
591 * throughput tests */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200592 int no_timestamps;
593
594 const char *sniffer_ifname;
595 const char *set_macaddr;
596 int tmp_mac_addr;
597 int ap_is_dual;
598 enum ap_mode ap_mode_1;
599 enum ap_chwidth ap_chwidth_1;
600 int ap_channel_1;
601 char ap_countrycode[3];
602
603 int ap_wpsnfc;
604
Pradeep Reddy POTTETI0d3db632016-03-11 15:21:11 +0530605 enum ap_wme {
606 AP_WME_OFF,
607 AP_WME_ON,
608 } ap_wme;
609
Mohammed Shafi Shajakhan02e3b822017-02-23 04:15:02 +0530610 enum ap_wmmps {
611 AP_WMMPS_OFF,
612 AP_WMMPS_ON,
613 } ap_wmmps;
614
Pradeep Reddy Potteti4b0cdee2017-03-15 12:37:33 +0530615 enum sec_ch_offset ap_chwidth_offset;
616
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200617#ifdef CONFIG_SNIFFER
618 pid_t sniffer_pid;
619 char sniffer_filename[200];
620#endif /* CONFIG_SNIFFER */
621
622 int last_set_ip_config_ipv6;
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -0700623#ifdef MIRACAST
624 pthread_t rtsp_thread_handle;
625 int wfd_device_type; /* 0 for source, 1 for sink */
626 char peer_mac_address[32];
627 void *miracast_lib;
628 const char *miracast_lib_path;
629 char mdns_instance_name[64];
630#endif /* MIRACAST */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200631
632 int tid_to_handle[8]; /* Mapping of TID to handle */
633 int dialog_token; /* Used for generating unique handle for an addTs */
634
635 enum sigma_program {
636 PROGRAM_UNKNOWN = 0,
637 PROGRAM_TDLS,
638 PROGRAM_HS2,
639 PROGRAM_HS2_R2,
640 PROGRAM_WFD,
Amarnath Hullur Subramanyam659a34c2017-03-17 00:04:41 -0700641 PROGRAM_DISPLAYR2,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200642 PROGRAM_PMF,
643 PROGRAM_WPS,
644 PROGRAM_60GHZ,
645 PROGRAM_HT,
646 PROGRAM_VHT,
647 PROGRAM_NAN,
priyadharshini gowthaman12dd4142016-06-22 22:47:14 -0700648 PROGRAM_LOC,
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700649 PROGRAM_MBO,
Jouni Malinen5c3813a2017-08-26 13:30:39 +0300650 PROGRAM_IOTLP,
651 PROGRAM_DPP,
Ankita Bajaja2cb5672017-10-25 16:08:28 +0530652 PROGRAM_OCE,
priyadharshini gowthaman0e209fc2018-01-26 15:15:37 -0800653 PROGRAM_WPA3,
Amarnath Hullur Subramanyam8f9c8682018-01-30 19:01:51 -0800654 PROGRAM_HE,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200655 } program;
656
657 enum device_type {
658 device_type_unknown,
659 AP_unknown,
660 AP_testbed,
661 AP_dut,
662 STA_unknown,
663 STA_testbed,
664 STA_dut
665 } device_type;
666
667 enum {
668 DEVROLE_UNKNOWN = 0,
669 DEVROLE_STA,
670 DEVROLE_PCP,
Ankita Bajaj0d5825b2017-10-25 16:20:17 +0530671 DEVROLE_STA_CFON
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200672 } dev_role;
673
674 const char *version;
675 int no_ip_addr_set;
676 int sta_channel;
677
678 const char *summary_log;
679 const char *hostapd_entropy_log;
680
681 int iface_down_on_reset;
682 int write_stats; /* traffic stream e2e*.txt files */
Bala Krishna Bhamidipati73d7af02016-03-24 12:27:56 +0530683 int sim_no_username; /* do not set SIM username to use real SIM */
Jouni Malinen5db3b102016-08-04 12:27:18 +0300684
685 const char *vendor_name; /* device_get_info vendor override */
686 const char *model_name; /* device_get_info model override */
687 const char *version_name; /* device_get_info version override */
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700688
Rakesh Sunki14cfcd22017-03-30 14:47:55 -0700689 int ndp_enable; /* Flag which is set once the NDP is setup */
690
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700691 /* Length of nan_pmk in octets */
692 u8 nan_pmk_len;
693
694 /*
695 * PMK: Info is optional in Discovery phase. PMK info can
696 * be passed during the NDP session.
697 */
698 u8 nan_pmk[32];
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700699
700 enum value_not_set_enabled_disabled wnm_bss_max_feature;
701 int wnm_bss_max_idle_time;
702 enum value_not_set_enabled_disabled wnm_bss_max_protection;
Ashwini Patil00402582017-04-13 12:29:39 +0530703
704 char *non_pref_ch_list; /* MBO: non-preferred channel report */
Ashwini Patil5acd7382017-04-13 15:55:04 +0530705 char *btm_query_cand_list; /* Candidate list for BTM Query */
Jouni Malinen3c367e82017-06-23 17:01:47 +0300706
Jouni Malinen68143132017-09-02 02:34:08 +0300707 char *sae_commit_override;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300708 char *rsne_override;
Jouni Malinend6bf1b42017-06-23 17:51:01 +0300709 const char *hostapd_bin;
710 int use_hostapd_pid_file;
711 const char *hostapd_ifname;
Jouni Malinend86e5822017-08-29 03:55:32 +0300712 int hostapd_running;
713
Jouni Malinenb1dd21f2017-11-13 19:14:29 +0200714 char *dpp_peer_uri;
Jouni Malinend86e5822017-08-29 03:55:32 +0300715 int dpp_local_bootstrap;
716 int dpp_conf_id;
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530717
718 u8 fils_hlp;
719 pthread_t hlp_thread;
Peng Xu291d97d2018-01-31 16:34:03 -0800720
721#ifdef NL80211_SUPPORT
722 struct nl80211_ctx *nl_ctx;
Sunil Dutt076081f2018-02-05 19:45:50 +0530723 int config_rsnie;
Peng Xu291d97d2018-01-31 16:34:03 -0800724#endif /* NL80211_SUPPORT */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200725};
726
727
728enum sigma_dut_print_level {
729 DUT_MSG_DEBUG, DUT_MSG_INFO, DUT_MSG_ERROR
730};
731
732void sigma_dut_print(struct sigma_dut *dut, int level, const char *fmt, ...)
733PRINTF_FORMAT(3, 4);
734
735void sigma_dut_summary(struct sigma_dut *dut, const char *fmt, ...)
736PRINTF_FORMAT(2, 3);
737
738
739enum sigma_status {
740 SIGMA_RUNNING, SIGMA_INVALID, SIGMA_ERROR, SIGMA_COMPLETE
741};
742
743void send_resp(struct sigma_dut *dut, struct sigma_conn *conn,
Jouni Malinen76401f52017-03-18 01:04:55 +0200744 enum sigma_status status, const char *buf);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200745
746const char * get_param(struct sigma_cmd *cmd, const char *name);
747
748int sigma_dut_reg_cmd(const char *cmd,
749 int (*validate)(struct sigma_cmd *cmd),
750 int (*process)(struct sigma_dut *dut,
751 struct sigma_conn *conn,
752 struct sigma_cmd *cmd));
753
754void sigma_dut_register_cmds(void);
755
756int cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
757 struct sigma_cmd *cmd);
758int cmd_sta_set_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
759 struct sigma_cmd *cmd);
760int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
761 struct sigma_cmd *cmd);
762int cmd_wlantest_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
763 struct sigma_cmd *cmd);
Ankita Bajaj0d5825b2017-10-25 16:20:17 +0530764int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn,
765 struct sigma_cmd *cmd);
766int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn,
767 struct sigma_cmd *cmd);
768int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
769 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200770
771enum driver_type {
772 DRIVER_NOT_SET,
773 DRIVER_ATHEROS,
774 DRIVER_WCN,
775 DRIVER_MAC80211,
776 DRIVER_AR6003,
777 DRIVER_WIL6210,
778 DRIVER_QNXNTO,
Sreelakshmi Konamkib692f102016-04-26 19:47:00 +0530779 DRIVER_OPENWRT,
780 DRIVER_LINUX_WCN,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200781};
782
783enum openwrt_driver_type {
784 OPENWRT_DRIVER_NOT_SET,
785 OPENWRT_DRIVER_ATHEROS
786};
787
788#define DRIVER_NAME_60G "wil6210"
789
790int set_wifi_chip(const char *chip_type);
791enum driver_type get_driver_type(void);
792enum openwrt_driver_type get_openwrt_driver_type(void);
793int file_exists(const char *fname);
794
795struct wpa_ctrl;
796
797int wps_connection_event(struct sigma_dut *dut, struct sigma_conn *conn,
798 struct wpa_ctrl *ctrl, const char *intf, int p2p_resp);
799int ascii2hexstr(const char *str, char *hex);
800void disconnect_station(struct sigma_dut *dut);
801void nfc_status(struct sigma_dut *dut, const char *state, const char *oper);
802int get_ip_config(struct sigma_dut *dut, const char *ifname, char *buf,
803 size_t buf_len);
804int ath6kl_client_uapsd(struct sigma_dut *dut, const char *intf, int uapsd);
805int is_ip_addr(const char *str);
806int run_system(struct sigma_dut *dut, const char *cmd);
Adil Saeed Musthafa5f793f02017-04-10 23:13:30 -0700807int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200808int cmd_wlantest_set_channel(struct sigma_dut *dut, struct sigma_conn *conn,
809 struct sigma_cmd *cmd);
810void sniffer_close(struct sigma_dut *dut);
811
812/* ap.c */
813void ath_disable_txbf(struct sigma_dut *dut, const char *intf);
Priyadharshini Gowthaman818afef2015-11-09 13:28:15 -0800814void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname,
815 const char *val);
priyadharshini gowthamane5e25172015-12-08 14:53:48 -0800816void novap_reset(struct sigma_dut *dut, const char *ifname);
Jouni Malinen2e6ccc22017-09-04 13:43:16 +0300817int get_hwaddr(const char *ifname, unsigned char *hwaddr);
Jouni Malinena326d7b2017-09-04 13:46:02 +0300818int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn,
819 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200820
821/* sta.c */
822int set_ps(const char *intf, struct sigma_dut *dut, int enabled);
823void ath_set_zero_crc(struct sigma_dut *dut, const char *val);
824void ath_set_cts_width(struct sigma_dut *dut, const char *ifname,
825 const char *val);
826int ath_set_width(struct sigma_dut *dut, struct sigma_conn *conn,
827 const char *intf, const char *val);
Lior David0fe101e2017-03-09 16:09:50 +0200828int wil6210_send_frame_60g(struct sigma_dut *dut, struct sigma_conn *conn,
829 struct sigma_cmd *cmd);
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530830int hwaddr_aton(const char *txt, unsigned char *addr);
831int set_ipv4_addr(struct sigma_dut *dut, const char *ifname,
832 const char *ip, const char *mask);
833int set_ipv4_gw(struct sigma_dut *dut, const char *gw);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200834
835/* p2p.c */
836int p2p_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
837 struct sigma_cmd *cmd);
Purushottam Kushwaha091e2532016-08-23 11:52:21 +0530838void p2p_create_event_thread(struct sigma_dut *dut);
839void stop_event_thread(void);
Amarnath Hullur Subramanyam89b37cd2017-03-17 00:04:41 -0700840void start_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
841void stop_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
842int p2p_discover_peer(struct sigma_dut *dut, const char *ifname,
843 const char *peer, int full);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200844
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700845/* utils.c */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200846enum sigma_program sigma_program_to_enum(const char *prog);
Jouni Malinen08cf2312017-09-04 13:39:47 +0300847int parse_hexstr(const char *hex, unsigned char *buf, size_t buflen);
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700848int parse_mac_address(struct sigma_dut *dut, const char *arg,
849 unsigned char *addr);
Rakesh Sunki7192dc42017-03-30 14:47:55 -0700850unsigned int channel_to_freq(unsigned int channel);
851unsigned int freq_to_channel(unsigned int freq);
Rakesh Sunki8f8e74b2017-05-16 15:42:12 -0700852void convert_mac_addr_to_ipv6_lladdr(u8 *mac_addr, char *ipv6_buf,
853 size_t buf_len);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200854
Peng Xu769731a2017-05-10 17:27:28 -0700855#ifndef ANDROID
856size_t strlcpy(char *dest, const char *src, size_t siz);
857size_t strlcat(char *dst, const char *str, size_t size);
858#endif /* ANDROID */
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530859void hex_dump(struct sigma_dut *dut, u8 *data, size_t len);
Peng Xu769731a2017-05-10 17:27:28 -0700860
861
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200862/* uapsd_stream.c */
863void receive_uapsd(struct sigma_stream *s);
Pradeep Reddy POTTETI79594042015-11-23 12:59:12 +0530864void send_uapsd_console(struct sigma_stream *s);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200865
866/* nan.c */
867int nan_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn,
868 struct sigma_cmd *cmd);
869int nan_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
870 struct sigma_cmd *cmd);
871int nan_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
872 struct sigma_cmd *cmd);
873int nan_cmd_sta_get_events(struct sigma_dut *dut, struct sigma_conn *conn,
874 struct sigma_cmd *cmd);
875int nan_cmd_sta_transmit_followup(struct sigma_dut *dut,
876 struct sigma_conn *conn,
877 struct sigma_cmd *cmd);
878void nan_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
879 struct sigma_cmd *cmd);
880int nan_cmd_sta_preset_testparameters(struct sigma_dut *dut,
881 struct sigma_conn *conn,
882 struct sigma_cmd *cmd);
883
priyadharshini gowthamand66913a2016-07-29 15:11:17 -0700884/* ftm.c */
885int loc_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
886 struct sigma_cmd *cmd);
887int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
888 struct sigma_cmd *cmd);
889int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
890 struct sigma_conn *conn,
891 struct sigma_cmd *cmd);
892
Jouni Malinend86e5822017-08-29 03:55:32 +0300893/* dpp.c */
894int dpp_dev_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
895 struct sigma_cmd *cmd);
896
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530897/* dhcp.c */
898void process_fils_hlp(struct sigma_dut *dut);
899void hlp_thread_cleanup(struct sigma_dut *dut);
Jouni Malinend86e5822017-08-29 03:55:32 +0300900
Peng Xu291d97d2018-01-31 16:34:03 -0800901#ifdef NL80211_SUPPORT
902struct nl80211_ctx * nl80211_init(struct sigma_dut *dut);
903void nl80211_deinit(struct sigma_dut *dut, struct nl80211_ctx *ctx);
904struct nl_msg * nl80211_drv_msg(struct sigma_dut *dut, struct nl80211_ctx *ctx,
905 int ifindex, int flags,
906 uint8_t cmd);
907int send_and_recv_msgs(struct sigma_dut *dut, struct nl80211_ctx *ctx,
908 struct nl_msg *nlmsg,
909 int (*valid_handler)(struct nl_msg *, void *),
910 void *valid_data);
911#endif /* NL80211_SUPPORT */
912
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200913#endif /* SIGMA_DUT_H */