blob: 73b6bc49c9013d87f91749cc1b1fbc46503f5ff5 [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 Malinen4cf699f2018-06-19 00:46:27 +0300405 AP_WPA2_EAP_OSEN,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200406 } ap_key_mgmt;
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700407 enum ap_tag_key_mgmt {
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200408 AP2_OPEN,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700409 AP2_OSEN,
Jouni Malinen353ba8b2018-01-10 17:04:12 +0200410 AP2_WPA2_PSK,
411 AP2_WPA2_OWE,
Adil Saeed Musthafab7b297f2017-04-10 23:13:31 -0700412 } ap_tag_key_mgmt[MAX_WLAN_TAGS - 1];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200413 int ap_add_sha256;
priyadharshini gowthamande81f392017-12-28 15:28:49 -0800414 int ap_add_sha384;
Sarvepalli, Rajesh Babu24dc7e42016-03-18 21:27:26 +0530415 int ap_rsn_preauth;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200416 enum ap_pmf {
417 AP_PMF_DISABLED,
418 AP_PMF_OPTIONAL,
419 AP_PMF_REQUIRED
420 } ap_pmf;
421 enum ap_cipher {
Jouni Malinen2ba24492017-11-17 12:43:59 +0200422 AP_NO_GROUP_CIPHER_SET,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200423 AP_CCMP,
424 AP_TKIP,
425 AP_WEP,
426 AP_PLAIN,
Jouni Malinenad395a22017-09-01 21:13:46 +0300427 AP_CCMP_TKIP,
428 AP_GCMP_256,
Jouni Malinen3d633da2017-09-14 22:19:21 +0300429 AP_GCMP_128,
430 AP_CCMP_256,
Jouni Malinend538c782017-11-17 12:13:04 +0200431 AP_CCMP_128_GCMP_256,
Jouni Malinen2ba24492017-11-17 12:43:59 +0200432 } ap_cipher, ap_group_cipher;
Jouni Malinen3d633da2017-09-14 22:19:21 +0300433 enum ap_group_mgmt_cipher {
434 AP_NO_GROUP_MGMT_CIPHER_SET,
435 AP_BIP_GMAC_256,
436 AP_BIP_CMAC_256,
437 AP_BIP_GMAC_128,
438 AP_BIP_CMAC_128,
439 } ap_group_mgmt_cipher;
Jouni Malinened670f42017-08-31 01:39:28 +0300440 char *ap_sae_groups;
Jouni Malinen2f524ce2017-08-31 01:43:29 +0300441 int sae_anti_clogging_threshold;
Jouni Malinenb347db02017-09-02 01:36:03 +0300442 int sae_reflection;
Jouni Malinen2126f422017-10-11 23:24:33 +0300443 char ap_passphrase[101];
Jouni Malinen63370622017-11-18 17:47:13 +0200444 char ap_psk[65];
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200445 char ap_wepkey[27];
446 char ap_radius_ipaddr[20];
447 int ap_radius_port;
448 char ap_radius_password[200];
449 char ap2_radius_ipaddr[20];
450 int ap2_radius_port;
451 char ap2_radius_password[200];
452 int ap_tdls_prohibit;
453 int ap_tdls_prohibit_chswitch;
454 int ap_hs2;
455 int ap_dgaf_disable;
456 int ap_p2p_cross_connect;
457 int ap_oper_name;
458 int ap_wan_metrics;
459 int ap_conn_capab;
460 int ap_oper_class;
461
462 int ap_interworking;
463 int ap_access_net_type;
464 int ap_internet;
465 int ap_venue_group;
466 int ap_venue_type;
467 char ap_hessid[20];
468 char ap_roaming_cons[100];
469 int ap_venue_name;
470 int ap_net_auth_type;
471 int ap_nai_realm_list;
472 char ap_domain_name_list[1000];
473 int ap_ip_addr_type_avail;
474 char ap_plmn_mcc[10][4];
475 char ap_plmn_mnc[10][4];
476 int ap_gas_cb_delay;
477 int ap_proxy_arp;
478 int ap2_proxy_arp;
479 int ap_l2tif;
480 int ap_anqpserver;
481 int ap_anqpserver_on;
482 int ap_osu_provider_list;
483 int ap_qos_map_set;
484 int ap_bss_load;
485 char ap_osu_server_uri[10][256];
486 char ap_osu_ssid[33];
487 int ap_osu_method[10];
488 int ap_osu_icon_tag;
Jouni Malinen54a89b02018-05-01 00:16:26 +0300489 int ap_venue_url;
Jouni Malinenf7ff42b2018-05-01 00:21:56 +0300490 int ap_advice_of_charge;
Jouni Malinenac104532018-05-01 00:27:37 +0300491 int ap_oper_icon_metadata;
Jouni Malinenac367142018-05-01 00:32:24 +0300492 int ap_tnc_file_name;
493 unsigned int ap_tnc_time_stamp;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200494
495 int ap_fake_pkhash;
496 int ap_disable_protection;
497 int ap_allow_vht_wep;
498 int ap_allow_vht_tkip;
499
500 enum ap_vht_chwidth {
501 AP_20_40_VHT_OPER_CHWIDTH,
502 AP_80_VHT_OPER_CHWIDTH,
503 AP_160_VHT_OPER_CHWIDTH
504 } ap_vht_chwidth;
505 int ap_txBF;
506 int ap_mu_txBF;
Pradeep Reddy POTTETIfba27db2015-11-20 16:42:22 +0530507 enum ap_regulatory_mode {
508 AP_80211D_MODE_DISABLED,
509 AP_80211D_MODE_ENABLED,
510 } ap_regulatory_mode;
511 enum ap_dfs_mode {
512 AP_DFS_MODE_DISABLED,
513 AP_DFS_MODE_ENABLED,
514 } ap_dfs_mode;
priyadharshini gowthaman264d5442016-02-25 15:52:22 -0800515 int ap_ndpa_frame;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200516
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700517 int ap_lci;
518 char ap_val_lci[33];
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700519 char ap_infoz[17];
priyadharshini gowthaman8e26ff42016-06-22 22:47:14 -0700520 int ap_lcr;
521 char ap_val_lcr[400];
522 int ap_rrm;
523 int ap_rtt;
524 int ap_neighap; /* number of configured neighbor APs */
525 unsigned char ap_val_neighap[3][6];
526 int ap_opchannel; /* number of oper channels */
527 int ap_val_opchannel[3];
528 int ap_scan;
priyadharshini gowthamanc2357bd2016-06-22 22:47:14 -0700529 int ap_fqdn_held;
530 int ap_fqdn_supl;
priyadharshini gowthamana27b5b62016-06-22 22:47:14 -0700531 int ap_msnt_type;
532
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700533 int ap_mbo;
534 int ap_ne_class;
535 int ap_ne_op_ch;
536 int ap_set_bssidpref;
537 int ap_btmreq_disassoc_imnt;
538 int ap_btmreq_term_bit;
Adil Saeed Musthafa7d9ae382017-04-10 23:13:33 -0700539 int ap_disassoc_timer;
540 int ap_btmreq_bss_term_dur;
Adil Saeed Musthafa604c8262017-04-10 23:13:31 -0700541 enum reg_domain {
542 REG_DOMAIN_NOT_SET,
543 REG_DOMAIN_LOCAL,
544 REG_DOMAIN_GLOBAL
545 } ap_reg_domain;
Adil Saeed Musthafacf752fa2017-04-10 23:13:32 -0700546 char ap_mobility_domain[10];
Adil Saeed Musthafa023108a2017-04-10 23:13:37 -0700547 unsigned char ap_cell_cap_pref;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700548 int ap_ft_oa;
549 int ap_name;
priyadharshini gowthaman09d613e2017-12-20 11:43:44 -0800550 int ap_interface_5g;
551 int ap_interface_2g;
priyadharshini gowthaman776562e2017-12-20 12:33:34 -0800552 int ap_assoc_delay;
priyadharshini gowthaman94062b52017-12-20 12:33:34 -0800553 int ap_btmreq_bss_term_tsf;
priyadharshini gowthaman00798a22017-12-28 15:15:00 -0800554 int ap_fils_dscv_int;
555 int ap_nairealm_int;
556 char ap_nairealm[33];
557 int ap_blechanutil;
558 int ap_ble_admit_cap;
559 int ap_datappdudura;
560 int ap_airtimefract;
561 char ap_dhcpserv_ipaddr[20];
562 int ap_dhcp_stop;
563 int ap_bawinsize;
564 int ap_blestacnt;
priyadharshini gowthamancb22e432017-12-28 15:23:31 -0800565 int ap_ul_availcap;
566 int ap_dl_availcap;
priyadharshini gowthamande81f392017-12-28 15:28:49 -0800567 int ap_akm;
568 int ap_pmksa;
569 int ap_pmksa_caching;
priyadharshini gowthaman63ab8482017-12-28 15:32:55 -0800570 int ap_80plus80;
priyadharshini gowthaman9149afc2018-01-15 13:40:18 -0800571 int ap_oper_chn;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700572
Adil Saeed Musthafa69063722017-04-10 23:13:40 -0700573 struct mbo_pref_ap mbo_pref_aps[MBO_MAX_PREF_BSSIDS];
574 struct mbo_pref_ap mbo_self_ap_tuple;
575 int mbo_pref_ap_cnt;
Adil Saeed Musthafa4ec61bd2017-04-10 23:13:41 -0700576 unsigned char ft_bss_mac_list[MAX_FT_BSS_LIST][ETH_ALEN];
577 int ft_bss_mac_cnt;
priyadharshini gowthamanb4e05fc2016-10-13 15:02:35 -0700578
priyadharshini gowthaman00798a22017-12-28 15:15:00 -0800579 enum value_not_set_enabled_disabled ap_oce;
580 enum value_not_set_enabled_disabled ap_filsdscv;
581 enum value_not_set_enabled_disabled ap_filshlp;
582 enum value_not_set_enabled_disabled ap_broadcast_ssid;
583 enum value_not_set_enabled_disabled ap_rnr;
584 enum value_not_set_enabled_disabled ap_esp;
585
priyadharshini gowthaman350f1912018-06-04 13:09:12 -0700586 enum ppdu {
587 PPDU_NOT_SET,
588 PPDU_MU,
589 PPDU_SU,
590 PPDU_ER,
591 PPDU_TB,
592 } ap_he_ppdu;
593
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200594 const char *hostapd_debug_log;
595
596#ifdef CONFIG_TRAFFIC_AGENT
597 /* Traffic Agent */
598 struct sigma_stream streams[MAX_SIGMA_STREAMS];
599 int stream_id;
600 int num_streams;
601 pthread_t thr;
602#endif /* CONFIG_TRAFFIC_AGENT */
603
Jouni Malinenc2493f82016-06-05 18:01:33 +0300604 unsigned int throughput_pktsize; /* If non-zero, override pktsize for
605 * throughput tests */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200606 int no_timestamps;
607
608 const char *sniffer_ifname;
609 const char *set_macaddr;
610 int tmp_mac_addr;
611 int ap_is_dual;
612 enum ap_mode ap_mode_1;
613 enum ap_chwidth ap_chwidth_1;
614 int ap_channel_1;
615 char ap_countrycode[3];
616
617 int ap_wpsnfc;
618
Pradeep Reddy POTTETI0d3db632016-03-11 15:21:11 +0530619 enum ap_wme {
620 AP_WME_OFF,
621 AP_WME_ON,
622 } ap_wme;
623
Mohammed Shafi Shajakhan02e3b822017-02-23 04:15:02 +0530624 enum ap_wmmps {
625 AP_WMMPS_OFF,
626 AP_WMMPS_ON,
627 } ap_wmmps;
628
Pradeep Reddy Potteti4b0cdee2017-03-15 12:37:33 +0530629 enum sec_ch_offset ap_chwidth_offset;
630
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200631#ifdef CONFIG_SNIFFER
632 pid_t sniffer_pid;
633 char sniffer_filename[200];
634#endif /* CONFIG_SNIFFER */
635
636 int last_set_ip_config_ipv6;
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -0700637#ifdef MIRACAST
638 pthread_t rtsp_thread_handle;
639 int wfd_device_type; /* 0 for source, 1 for sink */
640 char peer_mac_address[32];
641 void *miracast_lib;
642 const char *miracast_lib_path;
643 char mdns_instance_name[64];
644#endif /* MIRACAST */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200645
646 int tid_to_handle[8]; /* Mapping of TID to handle */
647 int dialog_token; /* Used for generating unique handle for an addTs */
648
649 enum sigma_program {
650 PROGRAM_UNKNOWN = 0,
651 PROGRAM_TDLS,
652 PROGRAM_HS2,
653 PROGRAM_HS2_R2,
654 PROGRAM_WFD,
Amarnath Hullur Subramanyam659a34c2017-03-17 00:04:41 -0700655 PROGRAM_DISPLAYR2,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200656 PROGRAM_PMF,
657 PROGRAM_WPS,
658 PROGRAM_60GHZ,
659 PROGRAM_HT,
660 PROGRAM_VHT,
661 PROGRAM_NAN,
priyadharshini gowthaman12dd4142016-06-22 22:47:14 -0700662 PROGRAM_LOC,
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700663 PROGRAM_MBO,
Jouni Malinen5c3813a2017-08-26 13:30:39 +0300664 PROGRAM_IOTLP,
665 PROGRAM_DPP,
Ankita Bajaja2cb5672017-10-25 16:08:28 +0530666 PROGRAM_OCE,
priyadharshini gowthaman0e209fc2018-01-26 15:15:37 -0800667 PROGRAM_WPA3,
Amarnath Hullur Subramanyam8f9c8682018-01-30 19:01:51 -0800668 PROGRAM_HE,
Jouni Malinenba630452018-06-22 11:49:59 +0300669 PROGRAM_HS2_R3,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200670 } program;
671
672 enum device_type {
673 device_type_unknown,
674 AP_unknown,
675 AP_testbed,
676 AP_dut,
677 STA_unknown,
678 STA_testbed,
679 STA_dut
680 } device_type;
681
682 enum {
683 DEVROLE_UNKNOWN = 0,
684 DEVROLE_STA,
685 DEVROLE_PCP,
Ankita Bajaj0d5825b2017-10-25 16:20:17 +0530686 DEVROLE_STA_CFON
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200687 } dev_role;
688
689 const char *version;
690 int no_ip_addr_set;
691 int sta_channel;
692
693 const char *summary_log;
694 const char *hostapd_entropy_log;
695
696 int iface_down_on_reset;
697 int write_stats; /* traffic stream e2e*.txt files */
Bala Krishna Bhamidipati73d7af02016-03-24 12:27:56 +0530698 int sim_no_username; /* do not set SIM username to use real SIM */
Jouni Malinen5db3b102016-08-04 12:27:18 +0300699
700 const char *vendor_name; /* device_get_info vendor override */
701 const char *model_name; /* device_get_info model override */
702 const char *version_name; /* device_get_info version override */
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700703
Rakesh Sunki14cfcd22017-03-30 14:47:55 -0700704 int ndp_enable; /* Flag which is set once the NDP is setup */
705
Rakesh Sunki7d37f412017-03-30 14:47:55 -0700706 /* Length of nan_pmk in octets */
707 u8 nan_pmk_len;
708
709 /*
710 * PMK: Info is optional in Discovery phase. PMK info can
711 * be passed during the NDP session.
712 */
713 u8 nan_pmk[32];
Adil Saeed Musthafa33ea2872017-04-10 23:13:24 -0700714
715 enum value_not_set_enabled_disabled wnm_bss_max_feature;
716 int wnm_bss_max_idle_time;
717 enum value_not_set_enabled_disabled wnm_bss_max_protection;
Ashwini Patil00402582017-04-13 12:29:39 +0530718
719 char *non_pref_ch_list; /* MBO: non-preferred channel report */
Ashwini Patil5acd7382017-04-13 15:55:04 +0530720 char *btm_query_cand_list; /* Candidate list for BTM Query */
Jouni Malinen3c367e82017-06-23 17:01:47 +0300721
Jouni Malinen68143132017-09-02 02:34:08 +0300722 char *sae_commit_override;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300723 char *rsne_override;
Jouni Malinend6bf1b42017-06-23 17:51:01 +0300724 const char *hostapd_bin;
725 int use_hostapd_pid_file;
726 const char *hostapd_ifname;
Jouni Malinend86e5822017-08-29 03:55:32 +0300727 int hostapd_running;
728
Jouni Malinenb1dd21f2017-11-13 19:14:29 +0200729 char *dpp_peer_uri;
Jouni Malinend86e5822017-08-29 03:55:32 +0300730 int dpp_local_bootstrap;
731 int dpp_conf_id;
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530732
733 u8 fils_hlp;
734 pthread_t hlp_thread;
Peng Xu291d97d2018-01-31 16:34:03 -0800735
736#ifdef NL80211_SUPPORT
737 struct nl80211_ctx *nl_ctx;
Sunil Dutt076081f2018-02-05 19:45:50 +0530738 int config_rsnie;
Peng Xu291d97d2018-01-31 16:34:03 -0800739#endif /* NL80211_SUPPORT */
Arif Hussainac6c5112018-05-25 17:34:00 -0700740
741 int sta_nss;
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200742};
743
744
745enum sigma_dut_print_level {
746 DUT_MSG_DEBUG, DUT_MSG_INFO, DUT_MSG_ERROR
747};
748
749void sigma_dut_print(struct sigma_dut *dut, int level, const char *fmt, ...)
750PRINTF_FORMAT(3, 4);
751
752void sigma_dut_summary(struct sigma_dut *dut, const char *fmt, ...)
753PRINTF_FORMAT(2, 3);
754
755
756enum sigma_status {
757 SIGMA_RUNNING, SIGMA_INVALID, SIGMA_ERROR, SIGMA_COMPLETE
758};
759
760void send_resp(struct sigma_dut *dut, struct sigma_conn *conn,
Jouni Malinen76401f52017-03-18 01:04:55 +0200761 enum sigma_status status, const char *buf);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200762
763const char * get_param(struct sigma_cmd *cmd, const char *name);
764
765int sigma_dut_reg_cmd(const char *cmd,
766 int (*validate)(struct sigma_cmd *cmd),
767 int (*process)(struct sigma_dut *dut,
768 struct sigma_conn *conn,
769 struct sigma_cmd *cmd));
770
771void sigma_dut_register_cmds(void);
772
773int cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
774 struct sigma_cmd *cmd);
775int cmd_sta_set_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
776 struct sigma_cmd *cmd);
777int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
778 struct sigma_cmd *cmd);
779int cmd_wlantest_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
780 struct sigma_cmd *cmd);
Ankita Bajaj0d5825b2017-10-25 16:20:17 +0530781int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn,
782 struct sigma_cmd *cmd);
783int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn,
784 struct sigma_cmd *cmd);
785int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
786 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200787
788enum driver_type {
789 DRIVER_NOT_SET,
790 DRIVER_ATHEROS,
791 DRIVER_WCN,
792 DRIVER_MAC80211,
793 DRIVER_AR6003,
794 DRIVER_WIL6210,
795 DRIVER_QNXNTO,
Sreelakshmi Konamkib692f102016-04-26 19:47:00 +0530796 DRIVER_OPENWRT,
797 DRIVER_LINUX_WCN,
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200798};
799
800enum openwrt_driver_type {
801 OPENWRT_DRIVER_NOT_SET,
802 OPENWRT_DRIVER_ATHEROS
803};
804
805#define DRIVER_NAME_60G "wil6210"
806
807int set_wifi_chip(const char *chip_type);
808enum driver_type get_driver_type(void);
809enum openwrt_driver_type get_openwrt_driver_type(void);
810int file_exists(const char *fname);
811
812struct wpa_ctrl;
813
814int wps_connection_event(struct sigma_dut *dut, struct sigma_conn *conn,
815 struct wpa_ctrl *ctrl, const char *intf, int p2p_resp);
816int ascii2hexstr(const char *str, char *hex);
817void disconnect_station(struct sigma_dut *dut);
818void nfc_status(struct sigma_dut *dut, const char *state, const char *oper);
819int get_ip_config(struct sigma_dut *dut, const char *ifname, char *buf,
820 size_t buf_len);
821int ath6kl_client_uapsd(struct sigma_dut *dut, const char *intf, int uapsd);
822int is_ip_addr(const char *str);
823int run_system(struct sigma_dut *dut, const char *cmd);
Adil Saeed Musthafa5f793f02017-04-10 23:13:30 -0700824int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200825int cmd_wlantest_set_channel(struct sigma_dut *dut, struct sigma_conn *conn,
826 struct sigma_cmd *cmd);
827void sniffer_close(struct sigma_dut *dut);
828
829/* ap.c */
830void ath_disable_txbf(struct sigma_dut *dut, const char *intf);
Priyadharshini Gowthaman818afef2015-11-09 13:28:15 -0800831void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname,
832 const char *val);
priyadharshini gowthamane5e25172015-12-08 14:53:48 -0800833void novap_reset(struct sigma_dut *dut, const char *ifname);
Jouni Malinen2e6ccc22017-09-04 13:43:16 +0300834int get_hwaddr(const char *ifname, unsigned char *hwaddr);
Jouni Malinena326d7b2017-09-04 13:46:02 +0300835int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn,
836 struct sigma_cmd *cmd);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200837
838/* sta.c */
839int set_ps(const char *intf, struct sigma_dut *dut, int enabled);
840void ath_set_zero_crc(struct sigma_dut *dut, const char *val);
841void ath_set_cts_width(struct sigma_dut *dut, const char *ifname,
842 const char *val);
843int ath_set_width(struct sigma_dut *dut, struct sigma_conn *conn,
844 const char *intf, const char *val);
Lior David0fe101e2017-03-09 16:09:50 +0200845int wil6210_send_frame_60g(struct sigma_dut *dut, struct sigma_conn *conn,
846 struct sigma_cmd *cmd);
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530847int hwaddr_aton(const char *txt, unsigned char *addr);
848int set_ipv4_addr(struct sigma_dut *dut, const char *ifname,
849 const char *ip, const char *mask);
850int set_ipv4_gw(struct sigma_dut *dut, const char *gw);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200851
852/* p2p.c */
853int p2p_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
854 struct sigma_cmd *cmd);
Purushottam Kushwaha091e2532016-08-23 11:52:21 +0530855void p2p_create_event_thread(struct sigma_dut *dut);
856void stop_event_thread(void);
Amarnath Hullur Subramanyam89b37cd2017-03-17 00:04:41 -0700857void start_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
858void stop_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
859int p2p_discover_peer(struct sigma_dut *dut, const char *ifname,
860 const char *peer, int full);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200861
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700862/* utils.c */
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200863enum sigma_program sigma_program_to_enum(const char *prog);
Jouni Malinen08cf2312017-09-04 13:39:47 +0300864int parse_hexstr(const char *hex, unsigned char *buf, size_t buflen);
priyadharshini gowthaman72462ef2016-06-22 22:47:14 -0700865int parse_mac_address(struct sigma_dut *dut, const char *arg,
866 unsigned char *addr);
Rakesh Sunki7192dc42017-03-30 14:47:55 -0700867unsigned int channel_to_freq(unsigned int channel);
868unsigned int freq_to_channel(unsigned int freq);
Rakesh Sunki8f8e74b2017-05-16 15:42:12 -0700869void convert_mac_addr_to_ipv6_lladdr(u8 *mac_addr, char *ipv6_buf,
870 size_t buf_len);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200871
Peng Xu769731a2017-05-10 17:27:28 -0700872#ifndef ANDROID
873size_t strlcpy(char *dest, const char *src, size_t siz);
874size_t strlcat(char *dst, const char *str, size_t size);
875#endif /* ANDROID */
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530876void hex_dump(struct sigma_dut *dut, u8 *data, size_t len);
Peng Xu769731a2017-05-10 17:27:28 -0700877
878
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200879/* uapsd_stream.c */
880void receive_uapsd(struct sigma_stream *s);
Pradeep Reddy POTTETI79594042015-11-23 12:59:12 +0530881void send_uapsd_console(struct sigma_stream *s);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200882
883/* nan.c */
884int nan_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn,
885 struct sigma_cmd *cmd);
886int nan_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn,
887 struct sigma_cmd *cmd);
888int nan_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
889 struct sigma_cmd *cmd);
890int nan_cmd_sta_get_events(struct sigma_dut *dut, struct sigma_conn *conn,
891 struct sigma_cmd *cmd);
892int nan_cmd_sta_transmit_followup(struct sigma_dut *dut,
893 struct sigma_conn *conn,
894 struct sigma_cmd *cmd);
895void nan_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
896 struct sigma_cmd *cmd);
897int nan_cmd_sta_preset_testparameters(struct sigma_dut *dut,
898 struct sigma_conn *conn,
899 struct sigma_cmd *cmd);
900
priyadharshini gowthamand66913a2016-07-29 15:11:17 -0700901/* ftm.c */
902int loc_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
903 struct sigma_cmd *cmd);
904int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
905 struct sigma_cmd *cmd);
906int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
907 struct sigma_conn *conn,
908 struct sigma_cmd *cmd);
909
Jouni Malinend86e5822017-08-29 03:55:32 +0300910/* dpp.c */
911int dpp_dev_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
912 struct sigma_cmd *cmd);
913
Ankita Bajaj1bde7942018-01-09 19:15:01 +0530914/* dhcp.c */
915void process_fils_hlp(struct sigma_dut *dut);
916void hlp_thread_cleanup(struct sigma_dut *dut);
Jouni Malinend86e5822017-08-29 03:55:32 +0300917
Peng Xu291d97d2018-01-31 16:34:03 -0800918#ifdef NL80211_SUPPORT
919struct nl80211_ctx * nl80211_init(struct sigma_dut *dut);
920void nl80211_deinit(struct sigma_dut *dut, struct nl80211_ctx *ctx);
921struct nl_msg * nl80211_drv_msg(struct sigma_dut *dut, struct nl80211_ctx *ctx,
922 int ifindex, int flags,
923 uint8_t cmd);
924int send_and_recv_msgs(struct sigma_dut *dut, struct nl80211_ctx *ctx,
925 struct nl_msg *nlmsg,
926 int (*valid_handler)(struct nl_msg *, void *),
927 void *valid_data);
928#endif /* NL80211_SUPPORT */
929
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200930#endif /* SIGMA_DUT_H */