blob: 020b6702e641b1fe5441d07ee466ea614b060bd7 [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 */
36
37
38#ifdef __GNUC__
39#define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
40#else
41#define PRINTF_FORMAT(a,b)
42#endif
43
44#ifndef SIGMA_TMPDIR
45#define SIGMA_TMPDIR "/tmp"
46#endif /* SIGMA_TMPDIR */
47
48#ifndef SIGMA_DUT_VER
49#define SIGMA_DUT_VER "(unknown)"
50#endif /* SIGMA_DUT_VER */
51
52#ifndef ETH_ALEN
53#define ETH_ALEN 6
54#endif
55
56#ifndef ETH_P_ARP
57#define ETH_P_ARP 0x0806
58#endif
59
60struct sigma_dut;
61
62#define MAX_PARAMS 100
63#define MAX_RADIO 2
64
65/* Set default operating channel width 80 MHz */
66#define VHT_DEFAULT_OPER_CHWIDTH AP_80_VHT_OPER_CHWIDTH
67
68typedef unsigned int u32;
69typedef unsigned char u8;
70
71#define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
72 (((u32) (a)[2]) << 8) | ((u32) (a)[3]))
73#define WPA_PUT_BE32(a, val) \
74 do { \
75 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
76 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
77 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
78 (a)[3] = (u8) (((u32) (val)) & 0xff); \
79 } while (0)
80
81struct sigma_cmd {
82 char *params[MAX_PARAMS];
83 char *values[MAX_PARAMS];
84 int count;
85};
86
87#define MAX_CMD_LEN 2048
88
89struct sigma_conn {
90 int s;
91 struct sockaddr_in addr;
92 socklen_t addrlen;
93 char buf[MAX_CMD_LEN + 5];
94 int pos;
95 int waiting_completion;
96};
97
98#define SIGMA_DUT_ERROR_CALLER_SEND_STATUS -2
99#define SIGMA_DUT_INVALID_CALLER_SEND_STATUS -1
100#define SIGMA_DUT_SUCCESS_STATUS_SENT 0
101#define SIGMA_DUT_SUCCESS_CALLER_SEND_STATUS 1
102
103struct sigma_cmd_handler {
104 struct sigma_cmd_handler *next;
105 char *cmd;
106 int (*validate)(struct sigma_cmd *cmd);
107 /* process return value:
108 * -2 = failed, caller will send status,ERROR
109 * -1 = failed, caller will send status,INVALID
110 * 0 = success, response already sent
111 * 1 = success, caller will send status,COMPLETE
112 */
113 int (*process)(struct sigma_dut *dut, struct sigma_conn *conn,
114 struct sigma_cmd *cmd);
115};
116
117#define P2P_GRP_ID_LEN 128
118#define IP_ADDR_STR_LEN 16
119
120struct wfa_cs_p2p_group {
121 struct wfa_cs_p2p_group *next;
122 char ifname[IFNAMSIZ];
123 int go;
124 char grpid[P2P_GRP_ID_LEN];
125 char ssid[33];
126};
127
128#ifdef CONFIG_TRAFFIC_AGENT
129
130#define MAX_SIGMA_STREAMS 16
131#define MAX_SIGMA_STATS 6000
132
133struct sigma_frame_stats {
134 unsigned int seqnum;
135 unsigned int local_sec;
136 unsigned int local_usec;
137 unsigned int remote_sec;
138 unsigned int remote_usec;
139};
140
141struct sigma_stream {
142 enum sigma_stream_profile {
143 SIGMA_PROFILE_FILE_TRANSFER,
144 SIGMA_PROFILE_MULTICAST,
145 SIGMA_PROFILE_IPTV,
146 SIGMA_PROFILE_TRANSACTION,
147 SIGMA_PROFILE_START_SYNC,
148 SIGMA_PROFILE_UAPSD
149 } profile;
150 int sender;
151 struct in_addr dst;
152 int dst_port;
153 struct in_addr src;
154 int src_port;
155 int frame_rate;
156 int duration;
Jouni Malinenc2493f82016-06-05 18:01:33 +0300157 unsigned int payload_size;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200158 int start_delay;
159 int max_cnt;
160 enum sigma_traffic_class {
161 SIGMA_TC_VOICE,
162 SIGMA_TC_VIDEO,
163 SIGMA_TC_BACKGROUND,
164 SIGMA_TC_BEST_EFFORT
165 } tc;
166 int user_priority;
167 int user_priority_set;
168 int started;
169 int no_timestamps;
170
171 int sock;
172 pthread_t thr;
173 int stop;
174 int ta_send_in_progress;
175 int trans_proto;
176
177 /* Statistics */
178 int tx_act_frames; /*
179 * Number of frames generated by the traffic
180 * generator application. The name is defined in the
181 * Sigma CAPI spec.
182 */
183 int tx_frames;
184 int rx_frames;
185 unsigned long long tx_payload_bytes;
186 unsigned long long rx_payload_bytes;
187 int out_of_seq_frames;
188 struct sigma_frame_stats *stats;
189 unsigned int num_stats;
190 unsigned int stream_id;
191
192 /* U-APSD */
193 unsigned int sta_id;
194 unsigned int rx_cookie;
195 unsigned int uapsd_sta_tc;
196 unsigned int uapsd_rx_state;
197 unsigned int uapsd_tx_state;
198 unsigned int tx_stop_cnt;
199 unsigned int tx_hello_cnt;
200 pthread_t uapsd_send_thr;
201 pthread_cond_t tx_thr_cond;
202 pthread_mutex_t tx_thr_mutex;
203 int reset_rx;
204 int num_retry;
205 char ifname[IFNAMSIZ]; /* ifname from the command */
206 struct sigma_dut *dut; /* for traffic agent thread to access context */
Pradeep Reddy POTTETI79594042015-11-23 12:59:12 +0530207 /* console */
208 char test_name[9]; /* test case name */
209 int can_quit;
210 int reset;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200211};
212
213#endif /* CONFIG_TRAFFIC_AGENT */
214
215
216#define NUM_AP_AC 4
217#define AP_AC_BE 0
218#define AP_AC_BK 1
219#define AP_AC_VI 2
220#define AP_AC_VO 3
221
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700222#define MAX_WLAN_TAGS 3
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700223#define MBO_MAX_PREF_BSSIDS 10
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700224#define MAX_FT_BSS_LIST 10
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700225
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200226enum value_not_set_enabled_disabled {
227 VALUE_NOT_SET,
228 VALUE_ENABLED,
229 VALUE_DISABLED
230};
231
Pradeep Reddy Potteti4b0cdee2017-03-15 12:37:33 +0530232enum sec_ch_offset {
233 SEC_CH_NO,
234 SEC_CH_40ABOVE,
235 SEC_CH_40BELOW
236};
237
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700238struct mbo_pref_ap {
239 int ap_ne_class;
240 int ap_ne_op_ch;
241 int ap_ne_pref;
242 unsigned char mac_addr[ETH_ALEN];
243};
244
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200245struct sigma_dut {
246 int s; /* server TCP socket */
247 int debug_level;
248 int stdout_debug;
249 struct sigma_cmd_handler *cmds;
250
251 /* Default timeout value (seconds) for commands */
252 unsigned int default_timeout;
253
254 int next_streamid;
255
256 const char *bridge; /* bridge interface to use in AP mode */
257
258 enum sigma_mode {
259 SIGMA_MODE_UNKNOWN,
260 SIGMA_MODE_STATION,
261 SIGMA_MODE_AP,
262 SIGMA_MODE_SNIFFER
263 } mode;
264
265 /*
266 * Local cached values to handle API that does not provide all the
267 * needed information with commands that actually trigger some
268 * operations.
269 */
270 int listen_chn;
271 int persistent;
272 int intra_bss;
273 int noa_duration;
274 int noa_interval;
275 int noa_count;
276 enum wfa_cs_wps_method {
277 WFA_CS_WPS_NOT_READY,
278 WFA_CS_WPS_PBC,
279 WFA_CS_WPS_PIN_DISPLAY,
280 WFA_CS_WPS_PIN_LABEL,
281 WFA_CS_WPS_PIN_KEYPAD
282 } wps_method;
283 char wps_pin[9];
284
285 struct wfa_cs_p2p_group *groups;
286
287 char infra_ssid[33];
288 int infra_network_id;
289
290 enum p2p_mode {
291 P2P_IDLE, P2P_DISCOVER, P2P_LISTEN, P2P_DISABLE
292 } p2p_mode;
293
294 int go;
295 int p2p_client;
Purushottam Kushwaha091e2532016-08-23 11:52:21 +0530296 char *p2p_ifname;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200297
298 int client_uapsd;
299
300 char arp_ipaddr[IP_ADDR_STR_LEN];
301 char arp_ifname[IFNAMSIZ + 1];
302
303 enum sta_pmf {
304 STA_PMF_DISABLED,
305 STA_PMF_OPTIONAL,
306 STA_PMF_REQUIRED
307 } sta_pmf;
308
309 int no_tpk_expiration;
310
311 int er_oper_performed;
312 char er_oper_bssid[20];
313 int amsdu_size;
314 int back_rcv_buf;
315
316 int testbed_flag_txsp;
317 int testbed_flag_rxsp;
318 int chwidth;
319
320 /* AP configuration */
321 char ap_ssid[33];
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700322 /*
323 * WLAN-TAG of 1 will use 'ap_' variables;
324 * tag higher than 1 will use 'ap_tag_' variables.
325 */
326 char ap_tag_ssid[MAX_WLAN_TAGS - 1][33];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200327 enum ap_mode {
328 AP_11a,
329 AP_11g,
330 AP_11b,
331 AP_11na,
332 AP_11ng,
333 AP_11ac,
334 AP_inval
335 } ap_mode;
336 int ap_channel;
337 int ap_rts;
338 int ap_frgmnt;
339 int ap_bcnint;
340 struct qos_params {
341 int ac;
342 int cwmin;
343 int cwmax;
344 int aifs;
345 int txop;
346 int acm;
347 } ap_qos[NUM_AP_AC], ap_sta_qos[NUM_AP_AC];
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200348 enum value_not_set_enabled_disabled ap_noack;
349 enum value_not_set_enabled_disabled ap_ampdu;
350 enum value_not_set_enabled_disabled ap_amsdu;
351 enum value_not_set_enabled_disabled ap_rx_amsdu;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200352 int ap_ampdu_exp;
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200353 enum value_not_set_enabled_disabled ap_addba_reject;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200354 int ap_fixed_rate;
355 int ap_mcs;
356 int ap_rx_streams;
357 int ap_tx_streams;
358 unsigned int ap_vhtmcs_map;
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200359 enum value_not_set_enabled_disabled ap_ldpc;
360 enum value_not_set_enabled_disabled ap_sig_rts;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200361 enum ap_chwidth {
362 AP_20,
363 AP_40,
364 AP_80,
365 AP_160,
366 AP_AUTO
367 } ap_chwidth;
Pradeep Reddy Pottetibf8af292017-02-15 15:28:39 +0530368 enum ap_chwidth default_11na_ap_chwidth;
369 enum ap_chwidth default_11ng_ap_chwidth;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200370 int ap_tx_stbc;
Jouni Malinen57fa3d82016-11-30 12:51:43 +0200371 enum value_not_set_enabled_disabled ap_dyn_bw_sig;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200372 int ap_sgi80;
373 int ap_p2p_mgmt;
374 enum ap_key_mgmt {
375 AP_OPEN,
376 AP_WPA2_PSK,
377 AP_WPA_PSK,
378 AP_WPA2_EAP,
379 AP_WPA_EAP,
380 AP_WPA2_EAP_MIXED,
Jouni Malinen30824df2017-08-22 21:21:38 +0300381 AP_WPA2_PSK_MIXED,
382 AP_WPA2_SAE,
383 AP_WPA2_PSK_SAE,
Jouni Malinenad395a22017-09-01 21:13:46 +0300384 AP_SUITEB,
Jouni Malinen147b3c32017-10-09 16:51:54 +0300385 AP_WPA2_OWE,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200386 } ap_key_mgmt;
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700387 enum ap_tag_key_mgmt {
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200388 AP2_OPEN,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700389 AP2_OSEN,
390 AP2_WPA2_PSK
391 } ap_tag_key_mgmt[MAX_WLAN_TAGS - 1];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200392 int ap_add_sha256;
Sarvepalli, Rajesh Babu24dc7e42016-03-18 21:27:26 +0530393 int ap_rsn_preauth;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200394 enum ap_pmf {
395 AP_PMF_DISABLED,
396 AP_PMF_OPTIONAL,
397 AP_PMF_REQUIRED
398 } ap_pmf;
399 enum ap_cipher {
400 AP_CCMP,
401 AP_TKIP,
402 AP_WEP,
403 AP_PLAIN,
Jouni Malinenad395a22017-09-01 21:13:46 +0300404 AP_CCMP_TKIP,
405 AP_GCMP_256,
Jouni Malinen3d633da2017-09-14 22:19:21 +0300406 AP_GCMP_128,
407 AP_CCMP_256,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200408 } ap_cipher;
Jouni Malinen3d633da2017-09-14 22:19:21 +0300409 enum ap_group_mgmt_cipher {
410 AP_NO_GROUP_MGMT_CIPHER_SET,
411 AP_BIP_GMAC_256,
412 AP_BIP_CMAC_256,
413 AP_BIP_GMAC_128,
414 AP_BIP_CMAC_128,
415 } ap_group_mgmt_cipher;
Jouni Malinened670f42017-08-31 01:39:28 +0300416 char *ap_sae_groups;
Jouni Malinen2f524ce2017-08-31 01:43:29 +0300417 int sae_anti_clogging_threshold;
Jouni Malinenb347db02017-09-02 01:36:03 +0300418 int sae_reflection;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200419 char ap_passphrase[65];
420 char ap_wepkey[27];
421 char ap_radius_ipaddr[20];
422 int ap_radius_port;
423 char ap_radius_password[200];
424 char ap2_radius_ipaddr[20];
425 int ap2_radius_port;
426 char ap2_radius_password[200];
427 int ap_tdls_prohibit;
428 int ap_tdls_prohibit_chswitch;
429 int ap_hs2;
430 int ap_dgaf_disable;
431 int ap_p2p_cross_connect;
432 int ap_oper_name;
433 int ap_wan_metrics;
434 int ap_conn_capab;
435 int ap_oper_class;
436
437 int ap_interworking;
438 int ap_access_net_type;
439 int ap_internet;
440 int ap_venue_group;
441 int ap_venue_type;
442 char ap_hessid[20];
443 char ap_roaming_cons[100];
444 int ap_venue_name;
445 int ap_net_auth_type;
446 int ap_nai_realm_list;
447 char ap_domain_name_list[1000];
448 int ap_ip_addr_type_avail;
449 char ap_plmn_mcc[10][4];
450 char ap_plmn_mnc[10][4];
451 int ap_gas_cb_delay;
452 int ap_proxy_arp;
453 int ap2_proxy_arp;
454 int ap_l2tif;
455 int ap_anqpserver;
456 int ap_anqpserver_on;
457 int ap_osu_provider_list;
458 int ap_qos_map_set;
459 int ap_bss_load;
460 char ap_osu_server_uri[10][256];
461 char ap_osu_ssid[33];
462 int ap_osu_method[10];
463 int ap_osu_icon_tag;
464
465 int ap_fake_pkhash;
466 int ap_disable_protection;
467 int ap_allow_vht_wep;
468 int ap_allow_vht_tkip;
469
470 enum ap_vht_chwidth {
471 AP_20_40_VHT_OPER_CHWIDTH,
472 AP_80_VHT_OPER_CHWIDTH,
473 AP_160_VHT_OPER_CHWIDTH
474 } ap_vht_chwidth;
475 int ap_txBF;
476 int ap_mu_txBF;
Pradeep Reddy POTTETIfba27db2015-11-20 16:42:22 +0530477 enum ap_regulatory_mode {
478 AP_80211D_MODE_DISABLED,
479 AP_80211D_MODE_ENABLED,
480 } ap_regulatory_mode;
481 enum ap_dfs_mode {
482 AP_DFS_MODE_DISABLED,
483 AP_DFS_MODE_ENABLED,
484 } ap_dfs_mode;
priyadharshini gowthaman264d5442016-02-25 15:52:22 -0800485 int ap_ndpa_frame;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200486
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700487 int ap_lci;
488 char ap_val_lci[33];
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700489 char ap_infoz[17];
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700490 int ap_lcr;
491 char ap_val_lcr[400];
492 int ap_rrm;
493 int ap_rtt;
494 int ap_neighap; /* number of configured neighbor APs */
495 unsigned char ap_val_neighap[3][6];
496 int ap_opchannel; /* number of oper channels */
497 int ap_val_opchannel[3];
498 int ap_scan;
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700499 int ap_fqdn_held;
500 int ap_fqdn_supl;
priyadharshini gowthamana27b5b62016-06-22 22:47:14 -0700501 int ap_msnt_type;
502
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700503 int ap_mbo;
504 int ap_ne_class;
505 int ap_ne_op_ch;
506 int ap_set_bssidpref;
507 int ap_btmreq_disassoc_imnt;
508 int ap_btmreq_term_bit;
Adil Saeed Musthafa7d9ae382017-04-10 23:13:33 -0700509 int ap_disassoc_timer;
510 int ap_btmreq_bss_term_dur;
Adil Saeed Musthafa604c8262017-04-10 23:13:31 -0700511 enum reg_domain {
512 REG_DOMAIN_NOT_SET,
513 REG_DOMAIN_LOCAL,
514 REG_DOMAIN_GLOBAL
515 } ap_reg_domain;
Adil Saeed Musthafacf752fa2017-04-10 23:13:32 -0700516 char ap_mobility_domain[10];
Adil Saeed Musthafa023108a2017-04-10 23:13:37 -0700517 unsigned char ap_cell_cap_pref;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700518 int ap_ft_oa;
519 int ap_name;
520
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700521 struct mbo_pref_ap mbo_pref_aps[MBO_MAX_PREF_BSSIDS];
522 struct mbo_pref_ap mbo_self_ap_tuple;
523 int mbo_pref_ap_cnt;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700524 unsigned char ft_bss_mac_list[MAX_FT_BSS_LIST][ETH_ALEN];
525 int ft_bss_mac_cnt;
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700526
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200527 const char *hostapd_debug_log;
528
529#ifdef CONFIG_TRAFFIC_AGENT
530 /* Traffic Agent */
531 struct sigma_stream streams[MAX_SIGMA_STREAMS];
532 int stream_id;
533 int num_streams;
534 pthread_t thr;
535#endif /* CONFIG_TRAFFIC_AGENT */
536
Jouni Malinenc2493f82016-06-05 18:01:33 +0300537 unsigned int throughput_pktsize; /* If non-zero, override pktsize for
538 * throughput tests */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200539 int no_timestamps;
540
541 const char *sniffer_ifname;
542 const char *set_macaddr;
543 int tmp_mac_addr;
544 int ap_is_dual;
545 enum ap_mode ap_mode_1;
546 enum ap_chwidth ap_chwidth_1;
547 int ap_channel_1;
548 char ap_countrycode[3];
549
550 int ap_wpsnfc;
551
Pradeep Reddy POTTETI0d3db632016-03-11 15:21:11 +0530552 enum ap_wme {
553 AP_WME_OFF,
554 AP_WME_ON,
555 } ap_wme;
556
Mohammed Shafi Shajakhan02e3b822017-02-23 04:15:02 +0530557 enum ap_wmmps {
558 AP_WMMPS_OFF,
559 AP_WMMPS_ON,
560 } ap_wmmps;
561
Pradeep Reddy Potteti4b0cdee2017-03-15 12:37:33 +0530562 enum sec_ch_offset ap_chwidth_offset;
563
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200564#ifdef CONFIG_SNIFFER
565 pid_t sniffer_pid;
566 char sniffer_filename[200];
567#endif /* CONFIG_SNIFFER */
568
569 int last_set_ip_config_ipv6;
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -0700570#ifdef MIRACAST
571 pthread_t rtsp_thread_handle;
572 int wfd_device_type; /* 0 for source, 1 for sink */
573 char peer_mac_address[32];
574 void *miracast_lib;
575 const char *miracast_lib_path;
576 char mdns_instance_name[64];
577#endif /* MIRACAST */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200578
579 int tid_to_handle[8]; /* Mapping of TID to handle */
580 int dialog_token; /* Used for generating unique handle for an addTs */
581
582 enum sigma_program {
583 PROGRAM_UNKNOWN = 0,
584 PROGRAM_TDLS,
585 PROGRAM_HS2,
586 PROGRAM_HS2_R2,
587 PROGRAM_WFD,
Amarnath Hullur Subramanyam659a34c2017-03-17 00:04:41 -0700588 PROGRAM_DISPLAYR2,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200589 PROGRAM_PMF,
590 PROGRAM_WPS,
591 PROGRAM_60GHZ,
592 PROGRAM_HT,
593 PROGRAM_VHT,
594 PROGRAM_NAN,
priyadharshini gowthaman12dd4142016-06-22 22:47:14 -0700595 PROGRAM_LOC,
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700596 PROGRAM_MBO,
Jouni Malinen5c3813a2017-08-26 13:30:39 +0300597 PROGRAM_IOTLP,
598 PROGRAM_DPP,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200599 } program;
600
601 enum device_type {
602 device_type_unknown,
603 AP_unknown,
604 AP_testbed,
605 AP_dut,
606 STA_unknown,
607 STA_testbed,
608 STA_dut
609 } device_type;
610
611 enum {
612 DEVROLE_UNKNOWN = 0,
613 DEVROLE_STA,
614 DEVROLE_PCP,
615 } dev_role;
616
617 const char *version;
618 int no_ip_addr_set;
619 int sta_channel;
620
621 const char *summary_log;
622 const char *hostapd_entropy_log;
623
624 int iface_down_on_reset;
625 int write_stats; /* traffic stream e2e*.txt files */
Bala Krishna Bhamidipati73d7af02016-03-24 12:27:56 +0530626 int sim_no_username; /* do not set SIM username to use real SIM */
Jouni Malinen5db3b102016-08-04 12:27:18 +0300627
628 const char *vendor_name; /* device_get_info vendor override */
629 const char *model_name; /* device_get_info model override */
630 const char *version_name; /* device_get_info version override */
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700631
Rakesh Sunki14cfcd22017-03-30 14:47:55 -0700632 int ndp_enable; /* Flag which is set once the NDP is setup */
633
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700634 /* Length of nan_pmk in octets */
635 u8 nan_pmk_len;
636
637 /*
638 * PMK: Info is optional in Discovery phase. PMK info can
639 * be passed during the NDP session.
640 */
641 u8 nan_pmk[32];
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700642
643 enum value_not_set_enabled_disabled wnm_bss_max_feature;
644 int wnm_bss_max_idle_time;
645 enum value_not_set_enabled_disabled wnm_bss_max_protection;
Ashwini Patil00402582017-04-13 12:29:39 +0530646
647 char *non_pref_ch_list; /* MBO: non-preferred channel report */
Ashwini Patil5acd7382017-04-13 15:55:04 +0530648 char *btm_query_cand_list; /* Candidate list for BTM Query */
Jouni Malinen3c367e82017-06-23 17:01:47 +0300649
Jouni Malinen68143132017-09-02 02:34:08 +0300650 char *sae_commit_override;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300651 char *rsne_override;
Jouni Malinend6bf1b42017-06-23 17:51:01 +0300652 const char *hostapd_bin;
653 int use_hostapd_pid_file;
654 const char *hostapd_ifname;
Jouni Malinend86e5822017-08-29 03:55:32 +0300655 int hostapd_running;
656
657 int dpp_peer_bootstrap;
658 int dpp_local_bootstrap;
659 int dpp_conf_id;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200660};
661
662
663enum sigma_dut_print_level {
664 DUT_MSG_DEBUG, DUT_MSG_INFO, DUT_MSG_ERROR
665};
666
667void sigma_dut_print(struct sigma_dut *dut, int level, const char *fmt, ...)
668PRINTF_FORMAT(3, 4);
669
670void sigma_dut_summary(struct sigma_dut *dut, const char *fmt, ...)
671PRINTF_FORMAT(2, 3);
672
673
674enum sigma_status {
675 SIGMA_RUNNING, SIGMA_INVALID, SIGMA_ERROR, SIGMA_COMPLETE
676};
677
678void send_resp(struct sigma_dut *dut, struct sigma_conn *conn,
Jouni Malinen76401f52017-03-18 01:04:55 +0200679 enum sigma_status status, const char *buf);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200680
681const char * get_param(struct sigma_cmd *cmd, const char *name);
682
683int sigma_dut_reg_cmd(const char *cmd,
684 int (*validate)(struct sigma_cmd *cmd),
685 int (*process)(struct sigma_dut *dut,
686 struct sigma_conn *conn,
687 struct sigma_cmd *cmd));
688
689void sigma_dut_register_cmds(void);
690
691int cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
692 struct sigma_cmd *cmd);
693int cmd_sta_set_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
694 struct sigma_cmd *cmd);
695int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
696 struct sigma_cmd *cmd);
697int cmd_wlantest_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
698 struct sigma_cmd *cmd);
699
700enum driver_type {
701 DRIVER_NOT_SET,
702 DRIVER_ATHEROS,
703 DRIVER_WCN,
704 DRIVER_MAC80211,
705 DRIVER_AR6003,
706 DRIVER_WIL6210,
707 DRIVER_QNXNTO,
Sreelakshmi Konamkib692f102016-04-26 19:47:00 +0530708 DRIVER_OPENWRT,
709 DRIVER_LINUX_WCN,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200710};
711
712enum openwrt_driver_type {
713 OPENWRT_DRIVER_NOT_SET,
714 OPENWRT_DRIVER_ATHEROS
715};
716
717#define DRIVER_NAME_60G "wil6210"
718
719int set_wifi_chip(const char *chip_type);
720enum driver_type get_driver_type(void);
721enum openwrt_driver_type get_openwrt_driver_type(void);
722int file_exists(const char *fname);
723
724struct wpa_ctrl;
725
726int wps_connection_event(struct sigma_dut *dut, struct sigma_conn *conn,
727 struct wpa_ctrl *ctrl, const char *intf, int p2p_resp);
728int ascii2hexstr(const char *str, char *hex);
729void disconnect_station(struct sigma_dut *dut);
730void nfc_status(struct sigma_dut *dut, const char *state, const char *oper);
731int get_ip_config(struct sigma_dut *dut, const char *ifname, char *buf,
732 size_t buf_len);
733int ath6kl_client_uapsd(struct sigma_dut *dut, const char *intf, int uapsd);
734int is_ip_addr(const char *str);
735int run_system(struct sigma_dut *dut, const char *cmd);
Adil Saeed Musthafa5f793f02017-04-10 23:13:30 -0700736int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200737int cmd_wlantest_set_channel(struct sigma_dut *dut, struct sigma_conn *conn,
738 struct sigma_cmd *cmd);
739void sniffer_close(struct sigma_dut *dut);
740
741/* ap.c */
742void ath_disable_txbf(struct sigma_dut *dut, const char *intf);
Priyadharshini Gowthaman818afef2015-11-09 13:28:15 -0800743void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname,
744 const char *val);
priyadharshini gowthamane5e25172015-12-08 14:53:48 -0800745void novap_reset(struct sigma_dut *dut, const char *ifname);
Jouni Malinen2e6ccc22017-09-04 13:43:16 +0300746int get_hwaddr(const char *ifname, unsigned char *hwaddr);
Jouni Malinena326d7b2017-09-04 13:46:02 +0300747int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn,
748 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200749
750/* sta.c */
751int set_ps(const char *intf, struct sigma_dut *dut, int enabled);
752void ath_set_zero_crc(struct sigma_dut *dut, const char *val);
753void ath_set_cts_width(struct sigma_dut *dut, const char *ifname,
754 const char *val);
755int ath_set_width(struct sigma_dut *dut, struct sigma_conn *conn,
756 const char *intf, const char *val);
Lior David0fe101e2017-03-09 16:09:50 +0200757int wil6210_send_frame_60g(struct sigma_dut *dut, struct sigma_conn *conn,
758 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200759
760/* p2p.c */
761int p2p_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
762 struct sigma_cmd *cmd);
Purushottam Kushwaha091e2532016-08-23 11:52:21 +0530763void p2p_create_event_thread(struct sigma_dut *dut);
764void stop_event_thread(void);
Amarnath Hullur Subramanyam89b37cd2017-03-17 00:04:41 -0700765void start_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
766void stop_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
767int p2p_discover_peer(struct sigma_dut *dut, const char *ifname,
768 const char *peer, int full);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200769
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700770/* utils.c */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200771enum sigma_program sigma_program_to_enum(const char *prog);
Jouni Malinen08cf2312017-09-04 13:39:47 +0300772int parse_hexstr(const char *hex, unsigned char *buf, size_t buflen);
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700773int parse_mac_address(struct sigma_dut *dut, const char *arg,
774 unsigned char *addr);
Rakesh Sunki7192dc42017-03-30 14:47:55 -0700775unsigned int channel_to_freq(unsigned int channel);
776unsigned int freq_to_channel(unsigned int freq);
Rakesh Sunki8f8e74b2017-05-16 15:42:12 -0700777void convert_mac_addr_to_ipv6_lladdr(u8 *mac_addr, char *ipv6_buf,
778 size_t buf_len);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200779
Peng Xu769731a2017-05-10 17:27:28 -0700780#ifndef ANDROID
781size_t strlcpy(char *dest, const char *src, size_t siz);
782size_t strlcat(char *dst, const char *str, size_t size);
783#endif /* ANDROID */
784
785
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200786/* uapsd_stream.c */
787void receive_uapsd(struct sigma_stream *s);
Pradeep Reddy POTTETI79594042015-11-23 12:59:12 +0530788void send_uapsd_console(struct sigma_stream *s);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200789
790/* nan.c */
791int nan_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn,
792 struct sigma_cmd *cmd);
793int nan_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
794 struct sigma_cmd *cmd);
795int nan_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
796 struct sigma_cmd *cmd);
797int nan_cmd_sta_get_events(struct sigma_dut *dut, struct sigma_conn *conn,
798 struct sigma_cmd *cmd);
799int nan_cmd_sta_transmit_followup(struct sigma_dut *dut,
800 struct sigma_conn *conn,
801 struct sigma_cmd *cmd);
802void nan_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
803 struct sigma_cmd *cmd);
804int nan_cmd_sta_preset_testparameters(struct sigma_dut *dut,
805 struct sigma_conn *conn,
806 struct sigma_cmd *cmd);
807
priyadharshini gowthamand66913a2016-07-29 15:11:17 -0700808/* ftm.c */
809int loc_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
810 struct sigma_cmd *cmd);
811int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
812 struct sigma_cmd *cmd);
813int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
814 struct sigma_conn *conn,
815 struct sigma_cmd *cmd);
816
Jouni Malinend86e5822017-08-29 03:55:32 +0300817/* dpp.c */
818int dpp_dev_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
819 struct sigma_cmd *cmd);
820
821
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200822#endif /* SIGMA_DUT_H */