1 /* 2 * Sigma Control API DUT (station/AP) 3 * Copyright (c) 2010-2011, Atheros Communications, Inc. 4 * Copyright (c) 2011-2017, Qualcomm Atheros, Inc. 5 * Copyright (c) 2018-2019, The Linux Foundation 6 * All Rights Reserved. 7 * Licensed under the Clear BSD license. See README for more details. 8 */ 9 10 #ifndef SIGMA_DUT_H 11 #define SIGMA_DUT_H 12 13 #ifdef __GNUC__ 14 #define _GNU_SOURCE 1 15 #endif 16 17 #include <stdlib.h> 18 #include <stdio.h> 19 #include <stdarg.h> 20 #include <string.h> 21 #include <errno.h> 22 #include <unistd.h> 23 #include <time.h> 24 #include <sys/time.h> 25 #include <sys/types.h> 26 #include <sys/socket.h> 27 #include <net/if.h> 28 #ifdef __QNXNTO__ 29 #include <sys/select.h> 30 #include <net/if_ether.h> 31 #endif /* __QNXNTO__ */ 32 #include <netinet/in.h> 33 #include <arpa/inet.h> 34 #ifdef CONFIG_TRAFFIC_AGENT 35 #include <pthread.h> 36 #endif /* CONFIG_TRAFFIC_AGENT */ 37 #ifdef NL80211_SUPPORT 38 #include <netlink/genl/family.h> 39 #include <netlink/genl/ctrl.h> 40 #include <netlink/genl/genl.h> 41 #include "qca-vendor_copy.h" 42 #include "nl80211_copy.h" 43 #endif /* NL80211_SUPPORT */ 44 #ifdef ANDROID_WIFI_HAL 45 /* avoid duplicate definitions from wifi_hal.h causing issues */ 46 #define u32 wifi_hal_u32 47 #define u16 wifi_hal_u16 48 #define u8 wifi_hal_u8 49 #include "wifi_hal.h" 50 #undef u32 51 #undef u16 52 #undef u8 53 #endif /*ANDROID_WIFI_HAL*/ 54 55 #ifdef NL80211_SUPPORT 56 #ifndef NL_CAPABILITY_VERSION_3_5_0 57 #define nla_nest_start(msg, attrtype) \ 58 nla_nest_start(msg, NLA_F_NESTED | (attrtype)) 59 #endif 60 #endif 61 62 #ifdef __GNUC__ 63 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b)))) 64 #else 65 #define PRINTF_FORMAT(a,b) 66 #endif 67 68 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 69 70 #ifndef SIGMA_TMPDIR 71 #define SIGMA_TMPDIR "/tmp" 72 #endif /* SIGMA_TMPDIR */ 73 74 #ifndef SIGMA_DUT_VER 75 #define SIGMA_DUT_VER "(unknown)" 76 #endif /* SIGMA_DUT_VER */ 77 78 #ifndef ETH_ALEN 79 #define ETH_ALEN 6 80 #endif 81 82 #ifndef BIT_ULL 83 #define BIT_ULL(nr) (1ULL << (nr)) 84 #endif 85 86 #ifndef ETH_P_ARP 87 #define ETH_P_ARP 0x0806 88 #endif 89 90 #ifndef ARRAY_SIZE 91 #define ARRAY_SIZE(x) (sizeof((x)) / (sizeof(((x)[0])))) 92 #endif 93 94 #define IPV6_ADDR_LEN 16 95 96 struct sigma_dut; 97 98 #define MAX_PARAMS 100 99 #define MAX_RADIO 3 100 101 #define NAN_AWARE_IFACE "wifi-aware0" 102 103 /* Set default operating channel width 80 MHz */ 104 #define VHT_DEFAULT_OPER_CHWIDTH AP_80_VHT_OPER_CHWIDTH 105 106 typedef unsigned int u32; 107 typedef uint16_t u16; 108 typedef unsigned char u8; 109 110 struct ieee80211_hdr_3addr { 111 uint16_t frame_control; 112 uint16_t duration_id; 113 uint8_t addr1[ETH_ALEN]; 114 uint8_t addr2[ETH_ALEN]; 115 uint8_t addr3[ETH_ALEN]; 116 uint16_t seq_ctrl; 117 } __attribute__((packed)); 118 119 struct wfa_p2p_attribute { 120 uint8_t id; 121 uint16_t len; 122 uint8_t variable[0]; 123 } __attribute__((packed)); 124 125 struct dut_hw_modes { 126 u16 ht_capab; 127 u8 mcs_set[16]; 128 u8 ampdu_params; 129 u32 vht_capab; 130 u8 vht_mcs_set[8]; 131 }; 132 133 #define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ 134 (((u32) (a)[2]) << 8) | ((u32) (a)[3])) 135 #define WPA_PUT_BE32(a, val) \ 136 do { \ 137 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ 138 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ 139 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ 140 (a)[3] = (u8) (((u32) (val)) & 0xff); \ 141 } while (0) 142 143 struct sigma_cmd { 144 char *params[MAX_PARAMS]; 145 char *values[MAX_PARAMS]; 146 int count; 147 }; 148 149 #define MAX_CMD_LEN 4096 150 151 struct sigma_conn { 152 int s; 153 struct sockaddr_in addr; 154 socklen_t addrlen; 155 char buf[MAX_CMD_LEN + 5]; 156 int pos; 157 int waiting_completion; 158 }; 159 160 enum sigma_cmd_result { 161 STATUS_SENT_ERROR = -3, 162 ERROR_SEND_STATUS = -2, 163 INVALID_SEND_STATUS = -1, 164 STATUS_SENT = 0, 165 SUCCESS_SEND_STATUS = 1 166 }; 167 168 struct sigma_cmd_handler { 169 struct sigma_cmd_handler *next; 170 char *cmd; 171 int (*validate)(struct sigma_cmd *cmd); 172 /* process return value: 173 * -2 = failed, caller will send status,ERROR 174 * -1 = failed, caller will send status,INVALID 175 * 0 = response already sent 176 * 1 = success, caller will send status,COMPLETE 177 */ 178 enum sigma_cmd_result (*process)(struct sigma_dut *dut, 179 struct sigma_conn *conn, 180 struct sigma_cmd *cmd); 181 }; 182 183 #define P2P_GRP_ID_LEN 128 184 #define IP_ADDR_STR_LEN 16 185 186 struct wfa_cs_p2p_group { 187 struct wfa_cs_p2p_group *next; 188 char ifname[IFNAMSIZ]; 189 int go; 190 char grpid[P2P_GRP_ID_LEN]; 191 char ssid[33]; 192 }; 193 194 #ifdef CONFIG_TRAFFIC_AGENT 195 196 #define MAX_SIGMA_STREAMS 16 197 #define MAX_SIGMA_STATS 6000 198 199 struct sigma_frame_stats { 200 unsigned int seqnum; 201 unsigned int local_sec; 202 unsigned int local_usec; 203 unsigned int remote_sec; 204 unsigned int remote_usec; 205 }; 206 207 struct sigma_stream { 208 enum sigma_stream_profile { 209 SIGMA_PROFILE_FILE_TRANSFER, 210 SIGMA_PROFILE_MULTICAST, 211 SIGMA_PROFILE_IPTV, 212 SIGMA_PROFILE_TRANSACTION, 213 SIGMA_PROFILE_START_SYNC, 214 SIGMA_PROFILE_UAPSD 215 } profile; 216 int sender; 217 struct in_addr dst; 218 int dst_port; 219 struct in_addr src; 220 int src_port; 221 int frame_rate; 222 int duration; 223 unsigned int payload_size; 224 int start_delay; 225 int max_cnt; 226 enum sigma_traffic_class { 227 SIGMA_TC_VOICE, 228 SIGMA_TC_VIDEO, 229 SIGMA_TC_BACKGROUND, 230 SIGMA_TC_BEST_EFFORT 231 } tc; 232 int user_priority; 233 int user_priority_set; 234 int started; 235 int no_timestamps; 236 237 int sock; 238 pthread_t thr; 239 int stop; 240 int ta_send_in_progress; 241 int trans_proto; 242 243 /* Statistics */ 244 int tx_act_frames; /* 245 * Number of frames generated by the traffic 246 * generator application. The name is defined in the 247 * Sigma CAPI spec. 248 */ 249 int tx_frames; 250 int rx_frames; 251 unsigned long long tx_payload_bytes; 252 unsigned long long rx_payload_bytes; 253 int out_of_seq_frames; 254 struct sigma_frame_stats *stats; 255 unsigned int num_stats; 256 unsigned int stream_id; 257 258 /* U-APSD */ 259 unsigned int sta_id; 260 unsigned int rx_cookie; 261 unsigned int uapsd_sta_tc; 262 unsigned int uapsd_rx_state; 263 unsigned int uapsd_tx_state; 264 unsigned int tx_stop_cnt; 265 unsigned int tx_hello_cnt; 266 pthread_t uapsd_send_thr; 267 pthread_cond_t tx_thr_cond; 268 pthread_mutex_t tx_thr_mutex; 269 int reset_rx; 270 int num_retry; 271 char ifname[IFNAMSIZ]; /* ifname from the command */ 272 struct sigma_dut *dut; /* for traffic agent thread to access context */ 273 /* console */ 274 char test_name[9]; /* test case name */ 275 int can_quit; 276 int reset; 277 }; 278 279 #endif /* CONFIG_TRAFFIC_AGENT */ 280 281 /* extended scheduling test */ 282 enum sigma_ese_type { 283 ESE_CBAP, 284 ESE_SP, 285 }; 286 287 struct sigma_ese_alloc { 288 unsigned int percent_bi; 289 enum sigma_ese_type type; 290 unsigned int src_aid, dst_aid; 291 }; 292 293 #define ESE_BCAST_AID 255 294 #define MAX_ESE_ALLOCS 4 295 296 #define NUM_AP_AC 4 297 #define AP_AC_BE 0 298 #define AP_AC_BK 1 299 #define AP_AC_VI 2 300 #define AP_AC_VO 3 301 302 #define MAX_WLAN_TAGS 3 303 #define MBO_MAX_PREF_BSSIDS 10 304 #define MAX_FT_BSS_LIST 10 305 306 #define TRANSPORT_PROTO_TYPE_TCP 0x06 307 #define TRANSPORT_PROTO_TYPE_UDP 0x11 308 #define NAN_TRANSPORT_PORT_DEFAULT 7000 309 #define NAN_TRANSPORT_PROTOCOL_DEFAULT TRANSPORT_PROTO_TYPE_TCP 310 311 enum value_not_set_enabled_disabled { 312 VALUE_NOT_SET, 313 VALUE_ENABLED, 314 VALUE_DISABLED 315 }; 316 317 enum sec_ch_offset { 318 SEC_CH_NO, 319 SEC_CH_40ABOVE, 320 SEC_CH_40BELOW 321 }; 322 323 struct mbo_pref_ap { 324 int ap_ne_class; 325 int ap_ne_op_ch; 326 int ap_ne_pref; 327 unsigned char mac_addr[ETH_ALEN]; 328 }; 329 330 #ifdef NL80211_SUPPORT 331 #define SOCK_BUF_SIZE (32 * 1024) 332 struct nl80211_ctx { 333 struct nl_sock *sock; 334 int netlink_familyid; 335 int nlctrl_familyid; 336 size_t sock_buf_size; 337 }; 338 #endif /* NL80211_SUPPORT */ 339 340 /* hardcoded long WSC IE values to force fragmentation */ 341 #define WPS_LONG_DEVICE_NAME "Qti1234511adtest1234567890123456" 342 #define WPS_LONG_MANUFACTURER "Qti1234511adQti1234511adQti1234511adQti1234511adQti1234511ad" 343 #define WPS_LONG_MODEL_NAME "Qti1234511adtest1234567890123456" 344 #define WPS_LONG_MODEL_NUMBER "11111111111111111111111111111111" 345 #define WPS_LONG_SERIAL_NUMBER "22222222222222222222222222222222" 346 347 enum akm_suite_values { 348 AKM_WPA_EAP = 1, 349 AKM_WPA_PSK = 2, 350 AKM_FT_EAP = 3, 351 AKM_FT_PSK = 4, 352 AKM_EAP_SHA256 = 5, 353 AKM_PSK_SHA256 = 6, 354 AKM_SAE = 8, 355 AKM_FT_SAE = 9, 356 AKM_SUITE_B = 12, 357 AKM_FT_SUITE_B = 13, 358 AKM_FILS_SHA256 = 14, 359 AKM_FILS_SHA384 = 15, 360 AKM_FT_FILS_SHA256 = 16, 361 AKM_FT_FILS_SHA384 = 17, 362 363 }; 364 365 struct sigma_dut { 366 const char *main_ifname; 367 char *main_ifname_2g; 368 char *main_ifname_5g; 369 const char *station_ifname; 370 char *station_ifname_2g; 371 char *station_ifname_5g; 372 char *p2p_ifname_buf; 373 int use_5g; 374 int sta_2g_started; 375 int sta_5g_started; 376 377 int s; /* server TCP socket */ 378 int debug_level; 379 int stdout_debug; 380 struct sigma_cmd_handler *cmds; 381 int response_sent; 382 383 const char *sigma_tmpdir; 384 385 /* Default timeout value (seconds) for commands */ 386 unsigned int default_timeout; 387 unsigned int user_config_timeout; 388 389 int next_streamid; 390 391 const char *bridge; /* bridge interface to use in AP mode */ 392 393 enum sigma_mode { 394 SIGMA_MODE_UNKNOWN, 395 SIGMA_MODE_STATION, 396 SIGMA_MODE_AP, 397 SIGMA_MODE_SNIFFER 398 } mode; 399 400 /* 401 * Local cached values to handle API that does not provide all the 402 * needed information with commands that actually trigger some 403 * operations. 404 */ 405 int listen_chn; 406 int persistent; 407 int intra_bss; 408 int noa_duration; 409 int noa_interval; 410 int noa_count; 411 enum wfa_cs_wps_method { 412 WFA_CS_WPS_NOT_READY, 413 WFA_CS_WPS_PBC, 414 WFA_CS_WPS_PIN_DISPLAY, 415 WFA_CS_WPS_PIN_LABEL, 416 WFA_CS_WPS_PIN_KEYPAD 417 } wps_method; 418 char wps_pin[9]; 419 420 struct wfa_cs_p2p_group *groups; 421 422 char infra_ssid[33]; 423 int infra_network_id; 424 425 enum p2p_mode { 426 P2P_IDLE, P2P_DISCOVER, P2P_LISTEN, P2P_DISABLE 427 } p2p_mode; 428 429 int go; 430 int p2p_client; 431 const char *p2p_ifname; 432 433 int client_uapsd; 434 435 char arp_ipaddr[IP_ADDR_STR_LEN]; 436 char arp_ifname[IFNAMSIZ + 1]; 437 438 enum sta_pmf { 439 STA_PMF_DISABLED, 440 STA_PMF_OPTIONAL, 441 STA_PMF_REQUIRED 442 } sta_pmf; 443 444 int sta_ft_ds; 445 446 int no_tpk_expiration; 447 448 int er_oper_performed; 449 char er_oper_bssid[20]; 450 int amsdu_size; 451 int back_rcv_buf; 452 453 int testbed_flag_txsp; 454 int testbed_flag_rxsp; 455 int chwidth; 456 457 unsigned int akm_values; 458 459 /* AP configuration */ 460 char ap_ssid[33]; 461 /* 462 * WLAN-TAG of 1 will use 'ap_' variables; 463 * tag higher than 1 will use 'ap_tag_' variables. 464 */ 465 char ap_tag_ssid[MAX_WLAN_TAGS - 1][33]; 466 enum ap_mode { 467 AP_11a, 468 AP_11g, 469 AP_11b, 470 AP_11na, 471 AP_11ng, 472 AP_11ac, 473 AP_11ad, 474 AP_11ax, 475 AP_inval 476 } ap_mode; 477 int ap_channel; 478 int ap_rts; 479 int ap_frgmnt; 480 int ap_bcnint; 481 int ap_start_disabled; 482 struct qos_params { 483 int ac; 484 int cwmin; 485 int cwmax; 486 int aifs; 487 int txop; 488 int acm; 489 } ap_qos[NUM_AP_AC], ap_sta_qos[NUM_AP_AC]; 490 enum value_not_set_enabled_disabled ap_noack; 491 enum value_not_set_enabled_disabled ap_ampdu; 492 enum value_not_set_enabled_disabled ap_amsdu; 493 enum value_not_set_enabled_disabled ap_rx_amsdu; 494 int ap_ampdu_exp; 495 int ap_max_mpdu_len; 496 enum value_not_set_enabled_disabled ap_addba_reject; 497 int ap_fixed_rate; 498 int ap_mcs; 499 int ap_rx_streams; 500 int ap_tx_streams; 501 unsigned int ap_vhtmcs_map; 502 enum value_not_set_enabled_disabled ap_ldpc; 503 enum value_not_set_enabled_disabled ap_sig_rts; 504 enum ap_chwidth { 505 AP_20, 506 AP_40, 507 AP_80, 508 AP_160, 509 AP_80_80, 510 AP_AUTO 511 } ap_chwidth; 512 enum ap_chwidth default_11na_ap_chwidth; 513 enum ap_chwidth default_11ng_ap_chwidth; 514 int ap_tx_stbc; 515 enum value_not_set_enabled_disabled ap_dyn_bw_sig; 516 int ap_sgi80; 517 int ap_p2p_mgmt; 518 enum ap_key_mgmt { 519 AP_OPEN, 520 AP_WPA2_PSK, 521 AP_WPA_PSK, 522 AP_WPA2_EAP, 523 AP_WPA_EAP, 524 AP_WPA2_EAP_MIXED, 525 AP_WPA2_PSK_MIXED, 526 AP_WPA2_SAE, 527 AP_WPA2_PSK_SAE, 528 AP_SUITEB, 529 AP_WPA2_OWE, 530 AP_WPA2_EAP_OSEN, 531 AP_WPA2_FT_EAP, 532 AP_WPA2_FT_PSK, 533 AP_WPA2_EAP_SHA256, 534 AP_WPA2_PSK_SHA256, 535 AP_WPA2_ENT_FT_EAP, 536 AP_OSEN, 537 } ap_key_mgmt; 538 enum ap_tag_key_mgmt { 539 AP2_OPEN, 540 AP2_OSEN, 541 AP2_WPA2_PSK, 542 AP2_WPA2_OWE, 543 } ap_tag_key_mgmt[MAX_WLAN_TAGS - 1]; 544 int ap_add_sha256; 545 int ap_add_sha384; 546 int ap_rsn_preauth; 547 enum ap_pmf { 548 AP_PMF_DISABLED, 549 AP_PMF_OPTIONAL, 550 AP_PMF_REQUIRED 551 } ap_pmf; 552 enum ap_cipher { 553 AP_NO_GROUP_CIPHER_SET, 554 AP_CCMP, 555 AP_TKIP, 556 AP_WEP, 557 AP_PLAIN, 558 AP_CCMP_TKIP, 559 AP_GCMP_256, 560 AP_GCMP_128, 561 AP_CCMP_256, 562 AP_CCMP_128_GCMP_256, 563 } ap_cipher, ap_group_cipher; 564 enum ap_group_mgmt_cipher { 565 AP_NO_GROUP_MGMT_CIPHER_SET, 566 AP_BIP_GMAC_256, 567 AP_BIP_CMAC_256, 568 AP_BIP_GMAC_128, 569 AP_BIP_CMAC_128, 570 } ap_group_mgmt_cipher; 571 char *ap_sae_groups; 572 int sae_anti_clogging_threshold; 573 int sae_reflection; 574 int ap_sae_commit_status; 575 int ap_sae_pk_omit; 576 int sae_confirm_immediate; 577 char ap_passphrase[101]; 578 char ap_psk[65]; 579 char *ap_sae_passwords; 580 char *ap_sae_pk_modifier; 581 char *ap_sae_pk_keypair; 582 char *ap_sae_pk_keypair_sig; 583 int ap_sae_pk; 584 char ap_wepkey[27]; 585 char ap_radius_ipaddr[20]; 586 int ap_radius_port; 587 char ap_radius_password[200]; 588 char ap2_radius_ipaddr[20]; 589 int ap2_radius_port; 590 char ap2_radius_password[200]; 591 int ap_tdls_prohibit; 592 int ap_tdls_prohibit_chswitch; 593 int ap_hs2; 594 int ap_dgaf_disable; 595 int ap_p2p_cross_connect; 596 int ap_oper_name; 597 int ap_wan_metrics; 598 int ap_conn_capab; 599 int ap_oper_class; 600 601 int ap_interworking; 602 int ap_access_net_type; 603 int ap_internet; 604 int ap_venue_group; 605 int ap_venue_type; 606 char ap_hessid[20]; 607 char ap_roaming_cons[100]; 608 int ap_venue_name; 609 int ap_net_auth_type; 610 int ap_nai_realm_list; 611 char ap_domain_name_list[1000]; 612 int ap_ip_addr_type_avail; 613 char ap_plmn_mcc[10][4]; 614 char ap_plmn_mnc[10][4]; 615 int ap_gas_cb_delay; 616 int ap_proxy_arp; 617 int ap2_proxy_arp; 618 int ap2_osu; 619 int ap_l2tif; 620 int ap_anqpserver; 621 int ap_anqpserver_on; 622 int ap_osu_provider_list; 623 int ap_osu_provider_nai_list; 624 int ap_qos_map_set; 625 int ap_bss_load; 626 char ap_osu_server_uri[10][256]; 627 char ap_osu_ssid[33]; 628 int ap_osu_method[10]; 629 int ap_osu_icon_tag; 630 int ap_venue_url; 631 int ap_advice_of_charge; 632 int ap_oper_icon_metadata; 633 int ap_tnc_file_name; 634 unsigned int ap_tnc_time_stamp; 635 636 int ap_fake_pkhash; 637 int ap_disable_protection; 638 int ap_allow_vht_wep; 639 int ap_allow_vht_tkip; 640 641 enum ap_vht_chwidth { 642 AP_20_40_VHT_OPER_CHWIDTH, 643 AP_80_VHT_OPER_CHWIDTH, 644 AP_160_VHT_OPER_CHWIDTH 645 } ap_vht_chwidth; 646 int ap_txBF; 647 int ap_mu_txBF; 648 enum ap_regulatory_mode { 649 AP_80211D_MODE_DISABLED, 650 AP_80211D_MODE_ENABLED, 651 } ap_regulatory_mode; 652 enum ap_dfs_mode { 653 AP_DFS_MODE_DISABLED, 654 AP_DFS_MODE_ENABLED, 655 } ap_dfs_mode; 656 int ap_ndpa_frame; 657 658 int ap_lci; 659 char ap_val_lci[33]; 660 char ap_infoz[17]; 661 int ap_lcr; 662 char ap_val_lcr[400]; 663 int ap_rrm; 664 int ap_rtt; 665 int ap_neighap; /* number of configured neighbor APs */ 666 unsigned char ap_val_neighap[3][6]; 667 int ap_opchannel; /* number of oper channels */ 668 int ap_val_opchannel[3]; 669 int ap_scan; 670 int ap_fqdn_held; 671 int ap_fqdn_supl; 672 int ap_msnt_type; 673 674 int ap_mbo; 675 int ap_ne_class; 676 int ap_ne_op_ch; 677 int ap_set_bssidpref; 678 int ap_btmreq_disassoc_imnt; 679 int ap_btmreq_term_bit; 680 int ap_disassoc_timer; 681 int ap_btmreq_bss_term_dur; 682 enum reg_domain { 683 REG_DOMAIN_NOT_SET, 684 REG_DOMAIN_LOCAL, 685 REG_DOMAIN_GLOBAL 686 } ap_reg_domain; 687 char ap_mobility_domain[10]; 688 unsigned char ap_cell_cap_pref; 689 int ap_ft_oa; 690 enum value_not_set_enabled_disabled ap_ft_ds; 691 int ap_name; 692 int ap_interface_5g; 693 int ap_interface_2g; 694 int ap_assoc_delay; 695 int ap_btmreq_bss_term_tsf; 696 int ap_fils_dscv_int; 697 int ap_nairealm_int; 698 char ap_nairealm[33]; 699 int ap_blechanutil; 700 int ap_ble_admit_cap; 701 int ap_datappdudura; 702 int ap_airtimefract; 703 char ap_dhcpserv_ipaddr[20]; 704 int ap_dhcp_stop; 705 int ap_bawinsize; 706 int ap_blestacnt; 707 int ap_ul_availcap; 708 int ap_dl_availcap; 709 int ap_akm; 710 unsigned int ap_akm_values; 711 int ap_pmksa; 712 int ap_pmksa_caching; 713 int ap_beacon_prot; 714 u8 ap_transition_disable; 715 int ap_80plus80; 716 int ap_oper_chn; 717 718 struct mbo_pref_ap mbo_pref_aps[MBO_MAX_PREF_BSSIDS]; 719 struct mbo_pref_ap mbo_self_ap_tuple; 720 int mbo_pref_ap_cnt; 721 unsigned char ft_bss_mac_list[MAX_FT_BSS_LIST][ETH_ALEN]; 722 int ft_bss_mac_cnt; 723 724 char *ar_ltf; 725 726 int ap_numsounddim; 727 unsigned int he_mcsnssmap; 728 int he_ul_mcs; 729 int he_mmss; 730 int he_srctrl_allow; 731 732 int ap_ocvc; 733 734 enum value_not_set_enabled_disabled ap_oce; 735 enum value_not_set_enabled_disabled ap_filsdscv; 736 enum value_not_set_enabled_disabled ap_filshlp; 737 enum value_not_set_enabled_disabled ap_broadcast_ssid; 738 enum value_not_set_enabled_disabled ap_rnr; 739 enum value_not_set_enabled_disabled ap_esp; 740 741 enum value_not_set_enabled_disabled ap_he_ulofdma; 742 enum value_not_set_enabled_disabled ap_he_dlofdma; 743 enum value_not_set_enabled_disabled ap_bcc; 744 enum value_not_set_enabled_disabled ap_he_frag; 745 enum value_not_set_enabled_disabled ap_mu_edca; 746 enum value_not_set_enabled_disabled ap_he_rtsthrshld; 747 enum value_not_set_enabled_disabled ap_mbssid; 748 enum value_not_set_enabled_disabled ap_twtresp; 749 enum value_not_set_enabled_disabled he_sounding; 750 enum value_not_set_enabled_disabled he_set_sta_1x1; 751 752 enum ppdu { 753 PPDU_NOT_SET, 754 PPDU_MU, 755 PPDU_SU, 756 PPDU_ER, 757 PPDU_TB, 758 PPDU_HESU, 759 } ap_he_ppdu; 760 761 enum bufsize { 762 BA_BUFSIZE_NOT_SET, 763 BA_BUFSIZE_64, 764 BA_BUFSIZE_256, 765 } ap_ba_bufsize; 766 767 enum mimo { 768 MIMO_NOT_SET, 769 MIMO_DL, 770 MIMO_UL, 771 } ap_he_mimo; 772 773 struct sigma_ese_alloc ap_ese_allocs[MAX_ESE_ALLOCS]; 774 int ap_num_ese_allocs; 775 776 const char *hostapd_debug_log; 777 const char *wpa_supplicant_debug_log; 778 779 #ifdef CONFIG_TRAFFIC_AGENT 780 /* Traffic Agent */ 781 struct sigma_stream streams[MAX_SIGMA_STREAMS]; 782 int stream_id; 783 int num_streams; 784 pthread_t thr; 785 #endif /* CONFIG_TRAFFIC_AGENT */ 786 787 unsigned int throughput_pktsize; /* If non-zero, override pktsize for 788 * throughput tests */ 789 int no_timestamps; 790 791 const char *sniffer_ifname; 792 const char *set_macaddr; 793 int tmp_mac_addr; 794 int ap_is_dual; 795 enum ap_mode ap_mode_1; 796 enum ap_chwidth ap_chwidth_1; 797 int ap_channel_1; 798 char ap_countrycode[3]; 799 800 int ap_wpsnfc; 801 802 enum ap_wme { 803 AP_WME_OFF, 804 AP_WME_ON, 805 } ap_wme; 806 807 enum ap_wmmps { 808 AP_WMMPS_OFF, 809 AP_WMMPS_ON, 810 } ap_wmmps; 811 812 enum sec_ch_offset ap_chwidth_offset; 813 814 char *ap_dpp_conf_addr; 815 char *ap_dpp_conf_pkhash; 816 817 #ifdef CONFIG_SNIFFER 818 pid_t sniffer_pid; 819 char sniffer_filename[200]; 820 #endif /* CONFIG_SNIFFER */ 821 822 int last_set_ip_config_ipv6; 823 #ifdef MIRACAST 824 pthread_t rtsp_thread_handle; 825 int wfd_device_type; /* 0 for source, 1 for sink */ 826 char peer_mac_address[32]; 827 char modified_peer_mac_address[32]; 828 void *miracast_lib; 829 const char *miracast_lib_path; 830 char mdns_instance_name[64]; 831 #endif /* MIRACAST */ 832 833 int tid_to_handle[8]; /* Mapping of TID to handle */ 834 int dialog_token; /* Used for generating unique handle for an addTs */ 835 836 enum sigma_program { 837 PROGRAM_UNKNOWN = 0, 838 PROGRAM_TDLS, 839 PROGRAM_HS2, 840 PROGRAM_HS2_R2, 841 PROGRAM_WFD, 842 PROGRAM_DISPLAYR2, 843 PROGRAM_PMF, 844 PROGRAM_WPS, 845 PROGRAM_60GHZ, 846 PROGRAM_HT, 847 PROGRAM_VHT, 848 PROGRAM_NAN, 849 PROGRAM_LOC, 850 PROGRAM_MBO, 851 PROGRAM_IOTLP, 852 PROGRAM_DPP, 853 PROGRAM_OCE, 854 PROGRAM_WPA3, 855 PROGRAM_HE, 856 PROGRAM_HS2_R3, 857 PROGRAM_QM, 858 } program; 859 860 enum device_type { 861 device_type_unknown, 862 AP_unknown, 863 AP_testbed, 864 AP_dut, 865 STA_unknown, 866 STA_testbed, 867 STA_dut 868 } device_type; 869 870 enum { 871 DEVROLE_UNKNOWN = 0, 872 DEVROLE_STA, 873 DEVROLE_PCP, 874 DEVROLE_STA_CFON, 875 DEVROLE_AP, 876 } dev_role; 877 878 enum wps_band { 879 WPS_BAND_NON_60G = 0, 880 WPS_BAND_60G, 881 } band; 882 883 int wps_disable; /* Used for 60G to disable PCP from sending WPS IE */ 884 int wsc_fragment; /* simulate WSC IE fragmentation */ 885 int eap_fragment; /* simulate EAP fragmentation */ 886 int wps_forced_version; /* Used to force reported WPS version */ 887 enum { 888 /* no change */ 889 FORCE_RSN_IE_NONE = 0, 890 /* if exists, remove and clear privacy bit */ 891 FORCE_RSN_IE_REMOVE, 892 /* if not exists, add and set privacy bit */ 893 FORCE_RSN_IE_ADD, 894 } force_rsn_ie; /* override RSN IE in association request */ 895 896 const char *version; 897 int no_ip_addr_set; 898 int sta_channel; 899 900 const char *summary_log; 901 const char *hostapd_entropy_log; 902 903 int iface_down_on_reset; 904 int write_stats; /* traffic stream e2e*.txt files */ 905 int sim_no_username; /* do not set SIM username to use real SIM */ 906 907 const char *vendor_name; /* device_get_info vendor override */ 908 const char *model_name; /* device_get_info model override */ 909 const char *version_name; /* device_get_info version override */ 910 const char *log_file_dir; /* Directory to generate log file */ 911 FILE *log_file_fd; /* Pointer to log file */ 912 913 int ndp_enable; /* Flag which is set once the NDP is setup */ 914 915 int ndpe; /* Flag indicating NDPE is supported */ 916 u16 trans_port; /* transport port number for TCP/UDP connection */ 917 u8 trans_proto; /* transport protocol, 0x06: TCP, 0x11: UDP */ 918 u8 nan_ipv6_addr[IPV6_ADDR_LEN]; /* NAN IPv6 address */ 919 u8 nan_ipv6_len; /* NAN IPv6 address length */ 920 921 /* Length of nan_pmk in octets */ 922 u8 nan_pmk_len; 923 924 /* 925 * PMK: Info is optional in Discovery phase. PMK info can 926 * be passed during the NDP session. 927 */ 928 u8 nan_pmk[32]; 929 930 enum value_not_set_enabled_disabled wnm_bss_max_feature; 931 int wnm_bss_max_idle_time; 932 enum value_not_set_enabled_disabled wnm_bss_max_protection; 933 934 char *non_pref_ch_list; /* MBO: non-preferred channel report */ 935 char *btm_query_cand_list; /* Candidate list for BTM Query */ 936 937 char *sae_commit_override; 938 char *rsne_override; 939 char *rsnxe_override_eapol; 940 int sta_associate_wait_connect; 941 char server_cert_hash[65]; 942 int server_cert_tod; 943 int sta_tod_policy; 944 const char *hostapd_bin; 945 int use_hostapd_pid_file; 946 const char *hostapd_ifname; 947 int hostapd_running; 948 949 char *dpp_peer_uri; 950 int dpp_local_bootstrap; 951 int dpp_conf_id; 952 int dpp_network_id; 953 954 u8 fils_hlp; 955 pthread_t hlp_thread; 956 957 #ifdef NL80211_SUPPORT 958 struct nl80211_ctx *nl_ctx; 959 int config_rsnie; 960 #endif /* NL80211_SUPPORT */ 961 962 int sta_nss; 963 964 #ifdef ANDROID 965 int nanservicediscoveryinprogress; 966 #endif /* ANDROID */ 967 968 const char *priv_cmd; /* iwpriv / cfg80211tool command name */ 969 970 unsigned int wpa_log_size; 971 char dev_start_test_runtime_id[100]; 972 #ifdef ANDROID_WIFI_HAL 973 wifi_interface_handle wifi_hal_iface_handle; 974 wifi_handle wifi_hal_handle; 975 bool wifi_hal_initialized; 976 #endif /*ANDROID_WIFI_HAL*/ 977 978 int sae_h2e_default; 979 enum { 980 SAE_PWE_DEFAULT, 981 SAE_PWE_LOOP, 982 SAE_PWE_H2E 983 } sae_pwe; 984 int owe_ptk_workaround; 985 struct dut_hw_modes hw_modes; 986 int ocvc; 987 int beacon_prot; 988 int client_privacy; 989 int client_privacy_default; 990 int saquery_oci_freq; 991 char device_driver[32]; 992 }; 993 994 995 enum sigma_dut_print_level { 996 DUT_MSG_DEBUG, DUT_MSG_INFO, DUT_MSG_ERROR 997 }; 998 999 void sigma_dut_print(struct sigma_dut *dut, int level, const char *fmt, ...) 1000 PRINTF_FORMAT(3, 4); 1001 1002 void sigma_dut_summary(struct sigma_dut *dut, const char *fmt, ...) 1003 PRINTF_FORMAT(2, 3); 1004 1005 1006 enum sigma_status { 1007 SIGMA_RUNNING, SIGMA_INVALID, SIGMA_ERROR, SIGMA_COMPLETE 1008 }; 1009 1010 void send_resp(struct sigma_dut *dut, struct sigma_conn *conn, 1011 enum sigma_status status, const char *buf); 1012 1013 const char * get_param(struct sigma_cmd *cmd, const char *name); 1014 const char * get_param_indexed(struct sigma_cmd *cmd, const char *name, 1015 int index); 1016 1017 int sigma_dut_reg_cmd(const char *cmd, 1018 int (*validate)(struct sigma_cmd *cmd), 1019 enum sigma_cmd_result (*process)(struct sigma_dut *dut, 1020 struct sigma_conn *conn, 1021 struct sigma_cmd *cmd)); 1022 1023 void sigma_dut_register_cmds(void); 1024 1025 enum sigma_cmd_result cmd_sta_send_frame(struct sigma_dut *dut, 1026 struct sigma_conn *conn, 1027 struct sigma_cmd *cmd); 1028 int cmd_sta_set_parameter(struct sigma_dut *dut, struct sigma_conn *conn, 1029 struct sigma_cmd *cmd); 1030 enum sigma_cmd_result cmd_ap_send_frame(struct sigma_dut *dut, 1031 struct sigma_conn *conn, 1032 struct sigma_cmd *cmd); 1033 enum sigma_cmd_result cmd_wlantest_send_frame(struct sigma_dut *dut, 1034 struct sigma_conn *conn, 1035 struct sigma_cmd *cmd); 1036 int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, 1037 struct sigma_cmd *cmd); 1038 int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, 1039 struct sigma_cmd *cmd); 1040 int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, 1041 struct sigma_cmd *cmd); 1042 1043 enum driver_type { 1044 DRIVER_NOT_SET, 1045 DRIVER_ATHEROS, 1046 DRIVER_WCN, 1047 DRIVER_MAC80211, 1048 DRIVER_AR6003, 1049 DRIVER_WIL6210, 1050 DRIVER_QNXNTO, 1051 DRIVER_OPENWRT, 1052 DRIVER_LINUX_WCN, 1053 }; 1054 1055 enum openwrt_driver_type { 1056 OPENWRT_DRIVER_NOT_SET, 1057 OPENWRT_DRIVER_ATHEROS 1058 }; 1059 1060 #define DRIVER_NAME_60G "wil6210" 1061 1062 int set_wifi_chip(const char *chip_type); 1063 enum driver_type get_driver_type(struct sigma_dut *dut); 1064 enum openwrt_driver_type get_openwrt_driver_type(void); 1065 void sigma_dut_get_device_driver_name(const char *ifname, char *name, 1066 size_t size); 1067 int file_exists(const char *fname); 1068 1069 struct wpa_ctrl; 1070 1071 int wps_connection_event(struct sigma_dut *dut, struct sigma_conn *conn, 1072 struct wpa_ctrl *ctrl, const char *intf, int p2p_resp); 1073 int ascii2hexstr(const char *str, char *hex); 1074 void disconnect_station(struct sigma_dut *dut); 1075 void nfc_status(struct sigma_dut *dut, const char *state, const char *oper); 1076 int get_ip_config(struct sigma_dut *dut, const char *ifname, char *buf, 1077 size_t buf_len); 1078 int ath6kl_client_uapsd(struct sigma_dut *dut, const char *intf, int uapsd); 1079 int is_ip_addr(const char *str); 1080 int run_system(struct sigma_dut *dut, const char *cmd); 1081 int run_system_wrapper(struct sigma_dut *dut, const char *cmd, ...); 1082 int run_iwpriv(struct sigma_dut *dut, const char *ifname, const char *cmd, ...); 1083 enum sigma_cmd_result cmd_wlantest_set_channel(struct sigma_dut *dut, 1084 struct sigma_conn *conn, 1085 struct sigma_cmd *cmd); 1086 void wlantest_register_cmds(void); 1087 void sniffer_close(struct sigma_dut *dut); 1088 1089 /* sigma_dut.c */ 1090 int wifi_hal_initialize(struct sigma_dut *dut); 1091 1092 /* ap.c */ 1093 void ap_register_cmds(void); 1094 void ath_disable_txbf(struct sigma_dut *dut, const char *intf); 1095 void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, 1096 const char *val); 1097 void novap_reset(struct sigma_dut *dut, const char *ifname, int reset); 1098 int get_hwaddr(const char *ifname, unsigned char *hwaddr); 1099 enum sigma_cmd_result cmd_ap_config_commit(struct sigma_dut *dut, 1100 struct sigma_conn *conn, 1101 struct sigma_cmd *cmd); 1102 int ap_wps_registration(struct sigma_dut *dut, struct sigma_conn *conn, 1103 struct sigma_cmd *cmd); 1104 const char * get_hostapd_ifname(struct sigma_dut *dut); 1105 1106 /* sta.c */ 1107 void sta_register_cmds(void); 1108 int set_ps(const char *intf, struct sigma_dut *dut, int enabled); 1109 void ath_set_zero_crc(struct sigma_dut *dut, const char *val); 1110 void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, 1111 const char *val); 1112 int ath_set_width(struct sigma_dut *dut, struct sigma_conn *conn, 1113 const char *intf, const char *val); 1114 int sta_set_60g_abft_len(struct sigma_dut *dut, struct sigma_conn *conn, 1115 int abft_len); 1116 int wil6210_send_frame_60g(struct sigma_dut *dut, struct sigma_conn *conn, 1117 struct sigma_cmd *cmd); 1118 int hwaddr_aton(const char *txt, unsigned char *addr); 1119 int set_ipv4_addr(struct sigma_dut *dut, const char *ifname, 1120 const char *ip, const char *mask); 1121 int set_ipv4_gw(struct sigma_dut *dut, const char *gw); 1122 int send_addba_60g(struct sigma_dut *dut, struct sigma_conn *conn, 1123 struct sigma_cmd *cmd, const char *param); 1124 int wil6210_set_ese(struct sigma_dut *dut, int count, 1125 struct sigma_ese_alloc *allocs); 1126 int sta_extract_60g_ese(struct sigma_dut *dut, struct sigma_cmd *cmd, 1127 struct sigma_ese_alloc *allocs, int *allocs_size); 1128 int wil6210_set_force_mcs(struct sigma_dut *dut, int force, int mcs); 1129 int sta_set_addba_buf_size(struct sigma_dut *dut, 1130 const char *intf, int bufsize); 1131 #ifdef NL80211_SUPPORT 1132 int wcn_set_he_ltf(struct sigma_dut *dut, const char *intf, 1133 enum qca_wlan_he_ltf_cfg ltf); 1134 #endif /* NL80211_SUPPORT */ 1135 1136 /* p2p.c */ 1137 void p2p_register_cmds(void); 1138 int p2p_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn, 1139 struct sigma_cmd *cmd); 1140 void p2p_create_event_thread(struct sigma_dut *dut); 1141 void stop_event_thread(void); 1142 void start_dhcp(struct sigma_dut *dut, const char *group_ifname, int go); 1143 void stop_dhcp(struct sigma_dut *dut, const char *group_ifname, int go); 1144 int p2p_discover_peer(struct sigma_dut *dut, const char *ifname, 1145 const char *peer, int full); 1146 enum sigma_cmd_result cmd_sta_p2p_reset(struct sigma_dut *dut, 1147 struct sigma_conn *conn, 1148 struct sigma_cmd *cmd); 1149 1150 /* basic.c */ 1151 void basic_register_cmds(void); 1152 void get_ver(const char *cmd, char *buf, size_t buflen); 1153 1154 /* utils.c */ 1155 enum sigma_program sigma_program_to_enum(const char *prog); 1156 int hex_byte(const char *str); 1157 int parse_hexstr(const char *hex, unsigned char *buf, size_t buflen); 1158 int parse_mac_address(struct sigma_dut *dut, const char *arg, 1159 unsigned char *addr); 1160 int is_60g_sigma_dut(struct sigma_dut *dut); 1161 unsigned int channel_to_freq(struct sigma_dut *dut, unsigned int channel); 1162 unsigned int freq_to_channel(unsigned int freq); 1163 int is_ipv6_addr(const char *str); 1164 void convert_mac_addr_to_ipv6_lladdr(u8 *mac_addr, char *ipv6_buf, 1165 size_t buf_len); 1166 size_t convert_mac_addr_to_ipv6_linklocal(const u8 *mac_addr, u8 *ipv6); 1167 1168 #ifndef ANDROID 1169 size_t strlcpy(char *dest, const char *src, size_t siz); 1170 size_t strlcat(char *dst, const char *str, size_t size); 1171 #endif /* ANDROID */ 1172 void hex_dump(struct sigma_dut *dut, u8 *data, size_t len); 1173 int get_wps_pin_from_mac(struct sigma_dut *dut, const char *macaddr, 1174 char *pin, size_t len); 1175 void str_remove_chars(char *str, char ch); 1176 1177 int get_wps_forced_version(struct sigma_dut *dut, const char *str); 1178 int base64_encode(const char *src, size_t len, char *out, size_t out_len); 1179 int random_get_bytes(char *buf, size_t len); 1180 int get_enable_disable(const char *val); 1181 int wcn_driver_cmd(const char *ifname, char *buf); 1182 1183 /* uapsd_stream.c */ 1184 void receive_uapsd(struct sigma_stream *s); 1185 void send_uapsd_console(struct sigma_stream *s); 1186 1187 /* nan.c */ 1188 int nan_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn, 1189 struct sigma_cmd *cmd); 1190 int nan_cmd_sta_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn, 1191 struct sigma_cmd *cmd); 1192 int nan_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn, 1193 struct sigma_cmd *cmd); 1194 int nan_cmd_sta_get_events(struct sigma_dut *dut, struct sigma_conn *conn, 1195 struct sigma_cmd *cmd); 1196 int nan_cmd_sta_transmit_followup(struct sigma_dut *dut, 1197 struct sigma_conn *conn, 1198 struct sigma_cmd *cmd); 1199 void nan_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, 1200 struct sigma_cmd *cmd); 1201 int nan_cmd_sta_preset_testparameters(struct sigma_dut *dut, 1202 struct sigma_conn *conn, 1203 struct sigma_cmd *cmd); 1204 1205 /* ftm.c */ 1206 int loc_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn, 1207 struct sigma_cmd *cmd); 1208 int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, 1209 struct sigma_cmd *cmd); 1210 int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut, 1211 struct sigma_conn *conn, 1212 struct sigma_cmd *cmd); 1213 int lowi_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, 1214 struct sigma_cmd *cmd); 1215 1216 /* dpp.c */ 1217 enum sigma_cmd_result dpp_dev_exec_action(struct sigma_dut *dut, 1218 struct sigma_conn *conn, 1219 struct sigma_cmd *cmd); 1220 1221 /* dhcp.c */ 1222 void process_fils_hlp(struct sigma_dut *dut); 1223 void hlp_thread_cleanup(struct sigma_dut *dut); 1224 1225 #ifdef NL80211_SUPPORT 1226 struct nl80211_ctx * nl80211_init(struct sigma_dut *dut); 1227 void nl80211_deinit(struct sigma_dut *dut, struct nl80211_ctx *ctx); 1228 struct nl_msg * nl80211_drv_msg(struct sigma_dut *dut, struct nl80211_ctx *ctx, 1229 int ifindex, int flags, 1230 uint8_t cmd); 1231 int send_and_recv_msgs(struct sigma_dut *dut, struct nl80211_ctx *ctx, 1232 struct nl_msg *nlmsg, 1233 int (*valid_handler)(struct nl_msg *, void *), 1234 void *valid_data); 1235 int wcn_wifi_test_config_set_flag(struct sigma_dut *dut, const char *intf, 1236 int attr_id); 1237 int wcn_wifi_test_config_set_u8(struct sigma_dut *dut, const char *intf, 1238 int attr_id, uint8_t val); 1239 int wcn_wifi_test_config_set_u16(struct sigma_dut *dut, const char *intf, 1240 int attr_id, uint16_t val); 1241 #endif /* NL80211_SUPPORT */ 1242 1243 void traffic_register_cmds(void); 1244 void traffic_agent_register_cmds(void); 1245 void powerswitch_register_cmds(void); 1246 void atheros_register_cmds(void); 1247 void dev_register_cmds(void); 1248 void sniffer_register_cmds(void); 1249 void server_register_cmds(void); 1250 void miracast_register_cmds(void); 1251 int set_ipv6_addr(struct sigma_dut *dut, const char *ip, const char *mask, 1252 const char *ifname); 1253 1254 #endif /* SIGMA_DUT_H */ 1255