From 9b08cf4d6418bbde260581677e186464c720583d Mon Sep 17 00:00:00 2001 From: Sherry Sun Date: Wed, 2 Dec 2020 13:38:14 +0800 Subject: [PATCH] mxm_wifiex: mapp: update to mxm5x16215(p1/p2) release changes: 1. Removed unnecessary .conf files from config folder Signed-off-by: Sherry Sun --- mxm_wifiex/wlan_src/Makefile | 97 +- mxm_wifiex/wlan_src/README | 1125 -- mxm_wifiex/wlan_src/README_MLAN | 3544 +--- .../wlan_src/mapp/mlan2040coex/Makefile | 48 - .../wlan_src/mapp/mlan2040coex/mlan2040coex.c | 1385 -- .../wlan_src/mapp/mlan2040coex/mlan2040coex.h | 234 - .../wlan_src/mapp/mlan2040coex/mlan2040misc.c | 281 - .../wlan_src/mapp/mlan2040coex/mlan2040misc.h | 444 - .../config/ed_mac_ctrl_V3_8997.conf | 23 + .../config/txpwrlimit_cfg_8997.conf | 621 + mxm_wifiex/wlan_src/mapp/mlanevent/Makefile | 52 - .../wlan_src/mapp/mlanevent/mlanevent.c | 2565 --- .../wlan_src/mapp/mlanevent/mlanevent.h | 1264 -- mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c | 22 + mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h | 31 + mxm_wifiex/wlan_src/mapp/uaputl/Makefile | 54 - .../mapp/uaputl/config/80211d_domain.conf | 45 - .../mapp/uaputl/config/embedded_dhcp.conf | 9 - .../config/sample_cal_data_bg_8688.conf | 42 - .../wlan_src/mapp/uaputl/config/uapcoex.conf | 22 - .../wlan_src/mapp/uaputl/config/uaputl.conf | 151 - .../mapp/uaputl/config/uaputl_wifidirect.conf | 80 - mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.c | 7558 -------- mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.h | 81 - mxm_wifiex/wlan_src/mapp/uaputl/uaphostcmd.c | 338 - mxm_wifiex/wlan_src/mapp/uaputl/uaputl.c | 14528 ---------------- mxm_wifiex/wlan_src/mapp/uaputl/uaputl.h | 2666 --- .../wlan_src/mapp/wifidirectutl/Makefile | 57 - .../mapp/wifidirectutl/config/wifidirect.conf | 415 - .../mapp/wifidirectutl/wifidirectutl.c | 8331 --------- .../mapp/wifidirectutl/wifidirectutl.h | 1403 -- mxm_wifiex/wlan_src/script/usbconfig | Bin 9098 -> 0 bytes 32 files changed, 1040 insertions(+), 46476 deletions(-) delete mode 100644 mxm_wifiex/wlan_src/README delete mode 100644 mxm_wifiex/wlan_src/mapp/mlan2040coex/Makefile delete mode 100644 mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.h create mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf create mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanevent/Makefile delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.h delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/Makefile delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/config/80211d_domain.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/config/embedded_dhcp.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/config/sample_cal_data_bg_8688.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/config/uapcoex.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl_wifidirect.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.c delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.h delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/uaphostcmd.c delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/uaputl.c delete mode 100644 mxm_wifiex/wlan_src/mapp/uaputl/uaputl.h delete mode 100644 mxm_wifiex/wlan_src/mapp/wifidirectutl/Makefile delete mode 100644 mxm_wifiex/wlan_src/mapp/wifidirectutl/config/wifidirect.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.c delete mode 100644 mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.h delete mode 100644 mxm_wifiex/wlan_src/script/usbconfig diff --git a/mxm_wifiex/wlan_src/Makefile b/mxm_wifiex/wlan_src/Makefile index a95f603..a95b175 100644 --- a/mxm_wifiex/wlan_src/Makefile +++ b/mxm_wifiex/wlan_src/Makefile @@ -18,7 +18,7 @@ COMPATDIR=/lib/modules/$(KERNELVERSION_X86)/build/compat-wireless-3.2-rc1-1/include ifeq ($(CC),) -CC= $(CROSS_COMPILE)gcc -I$(COMPATDIR) +CC ?= $(CROSS_COMPILE)gcc -I$(COMPATDIR) endif ifeq ($(LD),) LD= $(CROSS_COMPILE)ld @@ -39,7 +39,7 @@ CONFIG_SD8978=n CONFIG_USB8978=n CONFIG_SD8997=n CONFIG_USB8997=n -CONFIG_PCIE8997=n +CONFIG_PCIE8997=y CONFIG_SD8987=y CONFIG_SD9097=n CONFIG_USB9097=n @@ -99,8 +99,9 @@ CONFIG_DFS_TESTING_SUPPORT=y -CONFIG_ANDROID_KERNEL=n +# Use static link for app build +CONFIG_ANDROID_KERNEL=n #32bit app over 64bit kernel support CONFIG_USERSPACE_32BIT_OVER_KERNEL_64BIT=n @@ -112,7 +113,7 @@ CONFIG_USERSPACE_32BIT_OVER_KERNEL_64BIT=n ccflags-y += -DLINUX -KERNELVERSION_X86 := $(shell uname -r) +KERNELVERSION_X86 := $(shell uname -r) KERNELDIR ?= /lib/modules/$(KERNELVERSION_X86)/build LD += -S @@ -281,14 +282,28 @@ ifeq ($(CONFIG_PCIE),y) ccflags-y += -DPCIE endif +ifeq ($(CONFIG_MAC80211_SUPPORT),y) + ccflags-y += -DMAC80211_SUPPORT +endif +ifeq ($(CONFIG_MAC80211_SUPPORT_UAP),y) + ccflags-y += -DMAC80211_SUPPORT_UAP +endif +ifeq ($(CONFIG_MAC80211_SUPPORT_MESH),y) + ccflags-y += -DMAC80211_SUPPORT_MESH +endif # add -Wno-packed-bitfield-compat when GCC version greater than 4.4 GCC_VERSION := $(shell echo `gcc -dumpversion | cut -f1-2 -d.` \>= 4.4 | sed -e 's/\./*100+/g' | bc ) ifeq ($(GCC_VERSION),1) ccflags-y += -Wno-packed-bitfield-compat endif - ccflags-y += -Wno-stringop-overflow - ccflags-y += -Wno-tautological-compare +WimpGCC_VERSION := $(shell echo `gcc -dumpversion | cut -f1 -d.`| bc ) +ifeq ($(shell test $(WimpGCC_VERSION) -ge 7; echo $$?),0) +ccflags-y += -Wimplicit-fallthrough=3 +endif +ccflags-y += -Wno-stringop-overflow +ccflags-y += -Wno-tautological-compare +ccflags-y += -Wno-stringop-truncation ############################################################################# # Make Targets @@ -411,37 +426,13 @@ endif export CC LD ccflags-y KERNELDIR -ifeq ($(CONFIG_STA_SUPPORT),y) -ifeq ($(CONFIG_UAP_SUPPORT),y) -.PHONY: mapp/mlanconfig mapp/mlan2040coex mapp/mlanevent mapp/uaputl mapp/mlanutl clean distclean -else -.PHONY: mapp/mlanconfig mapp/mlanevent mapp/mlan2040coex mapp/mlanutl clean distclean -endif -else -ifeq ($(CONFIG_UAP_SUPPORT),y) -.PHONY: mapp/mlanevent mapp/uaputl clean distclean -endif -endif +.PHONY: mapp/mlanconfig mapp/mlanutl clean distclean @echo "Finished Making NXP Wlan Linux Driver" -ifeq ($(CONFIG_STA_SUPPORT),y) mapp/mlanconfig: $(MAKE) -C $@ mapp/mlanutl: $(MAKE) -C $@ -mapp/mlan2040coex: - $(MAKE) -C $@ -endif -ifeq ($(CONFIG_UAP_SUPPORT),y) -mapp/uaputl: - $(MAKE) -C $@ -endif -ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) -mapp/wifidirectutl: - $(MAKE) -C $@ -endif -mapp/mlanevent: - $(MAKE) -C $@ echo: @@ -453,35 +444,11 @@ build: cp -rpf script/load $(BINDIR)/ cp -rpf script/unload $(BINDIR)/ -ifeq ($(CONFIG_MUSB),y) - cp -rpf script/usbconfig $(BINDIR)/ -endif -ifeq ($(CONFIG_STA_SUPPORT),y) - cp -f README $(BINDIR) cp -f README_MLAN $(BINDIR) - #cp -f README_RBC $(BINDIR) ifneq ($(APPDIR),) $(MAKE) -C mapp/mlanconfig $@ INSTALLDIR=$(BINDIR) $(MAKE) -C mapp/mlanutl $@ INSTALLDIR=$(BINDIR) - $(MAKE) -C mapp/mlan2040coex $@ INSTALLDIR=$(BINDIR) -endif -endif -ifeq ($(CONFIG_UAP_SUPPORT),y) - #cp -f README_UAP $(BINDIR) -ifneq ($(APPDIR),) - $(MAKE) -C mapp/uaputl $@ INSTALLDIR=$(BINDIR) -endif -endif -ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) - #cp -f README_WIFIDIRECT $(BINDIR) - cp -rpf script/wifidirect $(BINDIR) -ifneq ($(APPDIR),) - $(MAKE) -C mapp/wifidirectutl $@ INSTALLDIR=$(BINDIR) -endif -endif -ifneq ($(APPDIR),) - $(MAKE) -C mapp/mlanevent $@ INSTALLDIR=$(BINDIR) endif clean: @@ -497,18 +464,8 @@ clean: -find . -name "*dwo" -exec rm {} \; -rm -rf .tmp_versions ifneq ($(APPDIR),) -ifeq ($(CONFIG_STA_SUPPORT),y) $(MAKE) -C mapp/mlanconfig $@ $(MAKE) -C mapp/mlanutl $@ - $(MAKE) -C mapp/mlan2040coex $@ -endif -ifeq ($(CONFIG_UAP_SUPPORT),y) - $(MAKE) -C mapp/uaputl $@ -endif -ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) - $(MAKE) -C mapp/wifidirectutl $@ -endif - $(MAKE) -C mapp/mlanevent $@ endif #ifdef SDIO #endif // SDIO @@ -535,18 +492,8 @@ distclean: -find . -name "*dwo" -exec rm {} \; -rm -rf .tmp_versions ifneq ($(APPDIR),) -ifeq ($(CONFIG_STA_SUPPORT),y) $(MAKE) -C mapp/mlanconfig $@ $(MAKE) -C mapp/mlanutl $@ - $(MAKE) -C mapp/mlan2040coex $@ -endif -ifeq ($(CONFIG_UAP_SUPPORT),y) - $(MAKE) -C mapp/uaputl $@ -endif -ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) - $(MAKE) -C mapp/wifidirectutl $@ -endif - $(MAKE) -C mapp/mlanevent $@ endif # End of file diff --git a/mxm_wifiex/wlan_src/README b/mxm_wifiex/wlan_src/README deleted file mode 100644 index 34ec998..0000000 --- a/mxm_wifiex/wlan_src/README +++ /dev/null @@ -1,1125 +0,0 @@ -=============================================================================== - U S E R M A N U A L - - Copyright 2014-2020 NXP - - -1) FOR DRIVER BUILD - - Goto source code directory wlan_src/. - make [clean] build - The driver and utility binaries can be found in ../bin_xxxx directory. - The driver code supports Linux kernel from 2.6.32 to 5.5.2. - -2) FOR DRIVER INSTALL - - a) Copy firmware image to /lib/firmware/nxp/, copy wifi_mod_para.conf to /lib/firmware/nxp/. - b) Install WLAN driver - There are drv_mode, max_sta_bss, max_uap_bss etc. module parameters. - The bit settings of drv_mode are, - Bit 0 : STA - Bit 1 : uAP - Bit 2 : WIFIDIRECT - - max_sta_bss: Maximum number of STA BSS (default 1, max 1) - sta_name: Name of the STA interface (default: "mlan") - max_uap_bss: Maximum number of uAP BSS (default 1, max 1) - uap_name: Name of the uAP interface (default: "uap") - uap_max_sta: Maximum number of STA for UAP/GO (default 0, max 64) - max_wfd_bss: Maximum number of WIFIDIRECT BSS (default 1, max 1) - wfd_name: Name of the WIFIDIRECT interface (default: "wfd") - max_vir_bss: Number of Virtual interfaces (default 0) - uap_oper_ctrl: uAP operation control when in-STA disconnect with ext-AP - 0: default do nothing, 2: uAP stops and restarts automatically - For example, to install multi-chip driver, - insmod mlan.ko - insmod moal.ko mod_para=nxp/wifi_mod_para.conf [drvdbg=0x7] - wifi_mod_para.conf is used to support multi-chips which has different load module parameters. It contains - the module parameters for different chips. - c) Uninstall WLAN driver, - ifconfig mlanX down - ifconfig uapX down - rmmod moal - rmmod mlan - - To load driver with MFG firmware file, use mfg_mode=1 when insmod WLAN driver and - specify MFG firmware name if needed. - - There are some other parameters for debugging purpose etc. Use modinfo to check details. - drvdbg= - dev_cap_mask= - mac_addr=xx:xx:xx:xx:xx:xx - auto_ds=0|1|2 - ps_mode=0|1|2 - max_tx_buf=2048|4096|8192 - pm_keep_power=1|0 - shutdown_hs=1|0 - cfg_11d=0|1|2 - dts_enable=0|1 - fw_name = - e.g. copy pcieuart9098_combo_v1.bin to firmware directory, fw_name=nxp/pcieuart9098_combo_v1.bin - fw_region - hw_test=0|1 - fw_serial=0|1 - req_fw_nowait=0|1 - antcfg=0|1|2|0xffff - slew_rate: Slew Rate Control value = 0|1|2|3 (0 is the slowest slew rate and 03 has the highest slew rate (default)) - init_cfg= - e.g. copy init_cfg.conf to firmware directory, init_cfg=nxp/init_cfg.conf - cal_data_cfg= - e.g. copy cal_data.conf to firmware directory, cal_data_cfg=nxp/cal_data.conf - dpd_data_cfg= - e.g. copy dpd_data.conf to firmware directory, dpd_data_cfg=nxp/dpd_data.conf - txpwrlimit_cfg= - e.g. copy txpwrlimit_cfg_set.conf to firmware directory, txpwrlimit_cfg=nxp/txpwrlimit_cfg_set.conf - cntry_txpwr= - init_hostcmd_cfg= - e.g. copy init_hostcmd_cfg.conf to firmware directory, init_hostcmd_cfg=nxp/init_hostcmd_cfg.conf - sdio_rx_aggr=1|0 - cfg80211_wext= - Bit 0: STA WEXT - Bit 1: uAP WEXT - Bit 2: STA CFG80211 - Bit 3: uAP CFG80211 - reg_alpha2= - skip_fwdnld=0|1 - wq_sched_prio: Priority for work queue - wq_sched_policy: Scheduling policy for work queue - (0: SCHED_NORMAL, 1: SCHED_FIFO, 2: SCHED_RR, 3: SCHED_BATCH, 5: SCHED_IDLE) - Please note that, both wq_sched_prio and wq_sched_policy should be provided - as module parameters. If wq_sched_policy is (0, 3 or 5), then wq_sched_prio - must be 0. wq_sched_prio should be 1 to 99 otherwise. - rx_work=0|1|2 - pcie_int_mode=0|1|2 - pcie_int_mode=0|1 - wakelock_timeout= - defined(SD9098)||defined(USB9098) || defined(PCIE9098) || defined(SD9097) || defined(USB9097)|| defined(PCIE9097)||defined(SD8978) - pmic=0|1 - indication_gpio=0xXY - hs_wake_interval= - disconnect_on_suspend=0|1 - hs_mimo_switch=0|1 - usb_aggr=0|1|2 - low_power_mode_enable=0|1 - When low power mode is enabled, the output power will be clipped at ~+10dBm and the - expected PA current is expected to be in the 80-90 mA range for b/g/n modes - indrstcfg=<2-byte IR configuration> - gpio pin (high byte): GPIO pin no to be used as trigger for out band reset - (0xFF: default pin configuration) - ir_mode (low byte) : independent reset mode - (0: disable, 1: enable out band, 2: enable in band) - For example, to enable out band reset via gpio_pin 14 - indrstcfg=0x0e01 - To enable out band reset via default gpio_pin - indrstcfg=0xff01 - To enable in band reset and disable out band reset - indrstcfg=0x02 - fixed_beacon_buffer=0|1 - GoAgeoutTime=0|x - multi_dtim=0|x - inact_tmo=0|x - host_mlme=0|1 - country_ie_ignore=0|1 - beacon_hints=0|1 - - Note: On some platforms (e.g. PXA910/920) double quotation marks ("") need to used - for module parameters. - insmod sdxxx.ko " ..." - -3) FOR DRIVER PROC & DEBUG - - The following info are provided in /proc/net/mwlan/adapterX/mlanY/info, - on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY/info. - - driver_name = "wlan" - driver_version = - interface_name = "mlanX" - bss_mode = "Ad-hoc" | "Managed" | "Auto" | "Unknown" - media_state = "Disconnected" | "Connected" - mac_address = <6-byte adapter MAC address> - multicase_count = - essid = - bssid = - channel = - region_code = - multicast_address[n] = - num_tx_bytes = - num_rx_bytes = - num_tx_pkts = - num_rx_pkts = - num_tx_pkts_dropped = - num_rx_pkts_dropped = - num_tx_pkts_err = - num_rx_pkts_err = - carrier "on" | "off" - tx queue "stopped" | "started" - - The following debug info are provided in /proc/net/mwlan/adapterX/mlanY/debug, - on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY/debug. - - drvdbg = - wmm_ac_vo = - wmm_ac_vi = - wmm_ac_be = - wmm_ac_bk = - max_tx_buf_size = - tx_buf_size = - curr_tx_buf_size = - ps_mode = <0/1, CAM mode/PS mode> - ps_state = <0/1/2/3, awake state/pre-sleep state/sleep-confirm state/sleep state> - is_deep_sleep = <0/1, not deep sleep state/deep sleep state> - wakeup_dev_req = <0/1, wakeup device not required/required> - wakeup_tries = - hs_configured = <0/1, host sleep not configured/configured> - hs_activated = <0/1, extended host sleep not activated/activated> - tx_pkts_queued = - pps_uapsd_mode = <0/1, PPS/UAPSD mode disabled/enabled> - sleep_pd = - qos_cfg = - tx_lock_flag = <0/1, Tx lock flag> - port_open = <0/1, port open flag> - scan_processing = <0/1, scan processing flag> - num_tx_timeout = - num_cmd_timeout = - timeout_cmd_id = - timeout_cmd_act = - last_cmd_id = - last_cmd_act = - last_cmd_index = <0 based last command index> - last_cmd_resp_id = - last_cmd_resp_index = <0 based last command response index> - last_event = - last_event_index = <0 based last event index> - num_cmd_h2c_fail = - num_cmd_sleep_cfm_fail = - num_tx_h2c_fail = - num_cmdevt_c2h_fail = - num_rx_c2h_fail = - num_int_read_fail = - last_int_status = - num_evt_deauth = - num_evt_disassoc = - num_evt_link_lost = - num_cmd_deauth = - num_cmd_assoc_ok = - num_cmd_assoc_fail = - cmd_sent = <0/1, send command resources available/sending command to device> - data_sent = <0/1, send data resources available/sending data to device> - mp_rd_bitmap = - curr_rd_port = - mp_wr_bitmap = - curr_wr_port = - txbd_rdptr = - txbd_wrptr = - rxbd_rdptr = - rxbd_wrptr = - eventbd_rdptr = - eventbd_wrptr = - cmd_resp_received = <0/1, no cmd response to process/response received and yet to process> - event_received = <0/1, no event to process/event received and yet to process> - tx_cmd_urb_pending = - tx_data_urb_pending = - rx_cmd_urb_pending = - rx_data_urb_pending = - ioctl_pending = - tx_pending = - rx_pending = - lock_count = - malloc_count = - mbufalloc_count = - malloc_cons_count = - main_state = - sdiocmd53w = - sdiocmd53r = - hs_skip_count = - hs_force_count = - - Issue SDIO cmd52 read/write through proc. - Usage: - echo "sdcmd52rw= [data]" > /proc/mwlan/adapterX/config - where the parameters: - func: The function number to use (0-7) - reg: The address of the register - data: The value to write, read if the value is absent - For SDIO MMC driver, only function 0 and WLAN function access is allowed. - And there is a limitation for function 0 write, only vendor specific CCCR - registers (0xf0 -0xff) are permiited. - Examples: - echo "sdcmd52rw= 0 4" > /proc/mwlan/adapterX/config # read func 0 address 4 - cat /proc/mwlan/adapterX/config # display the register value - echo "sdcmd52rw= 1 3 0xf" > /proc/mwlan/adapterX/config # write 0xf to func 1 address 3 - - Use dmesg or cat /var/log/debug to check driver debug messages. - To log driver debug messages to file, - a) Edit /etc/syslog.conf, add one line "*.debug /var/log/debug" - on kernel 2.6.24 or later, edit /etc/rsyslog.conf instead - b) touch /var/log/debug (if the file doesn't exist) - c) service syslog restart - on kernel 2.6.24 or later, service rsyslog restart - - Update /proc/sys/kernel/printk to change message log levels. - For example, - echo 6 > /proc/sys/kernel/printk (messages with a higher priority than 6 - will be printed to the console) - echo 15 > /proc/sys/kernel/printk (all messages will be printed to console) - -4) FOR IWPRIV COMMAND - -NAME - This manual describes the usage of private commands used in NXP MLAN - Linux Driver. - - To use parameters as hex format, a '0x' must precede it for the parameters to - be parsed properly. - -SYNOPSIS - iwpriv [sub-command] ... - - iwpriv mlanX version - iwpriv mlanX verext - iwpriv mlanX getsignal [m] [n] - iwpriv mlanX antcfg [m] [n] - iwpriv mlanX regioncode [n] - iwpriv mlanX cfpcode [m] [n] - iwpriv mlanX wwscfg [m] - iwpriv mlanX esuppmode - iwpriv mlanX passphrase - iwpriv mlanX httxcfg [] [] - iwpriv mlanX htcapinfo [] [] - iwpriv mlanX addbapara

- iwpriv mlanX aggrpriotbl - iwpriv mlanX addbareject - iwpriv mlanX txbufcfg - iwpriv mlanX amsduaggrctrl - iwpriv mlanX httxbfcap [cap] - iwpriv mlanX httxbfcfg "[;GlobalData/tsData/interval/txPeerData/snrData]" - iwpriv mlanX mpactrl [tx_ena] [rx_ena] [tx_size] [rx_size] [tx_ports] [rx_ports] - iwpriv mlanX deepsleep [n] [m] - iwpriv mlanX usbsuspend - iwpriv mlanX usbresume - iwpriv mlanX hscfg [condition [[GPIO# [gap]]]] - iwpriv mlanX hssetpara condition [GPIO# [gap]] - iwpriv mlanX deauth [n] - iwpriv mlanX radioctrl - iwpriv mlanX reassoctrl [n] - iwpriv mlanX bandcfg [l] [m] [n] - iwpriv mlanX getlog - iwpriv mlanX 11dcfg - iwpriv mlanX 11dclrtbl - iwpriv mlanX wmmcfg [n] - iwpriv mlanX hotspotcfg [n] - iwpriv mlanX txpowercfg [ [ [ ]]] - iwpriv mlanX qoscfg - iwpriv mlanX getdatarate - iwpriv mlanX txratecfg [n] - iwpriv mlanX bcninterval [n] - iwpriv mlanX sysclock [clk1] [clk2] [clk3] [clk4] - iwpriv mlanX drvdbg [n] - iwpriv mlanX mgmtframectrl - iwpriv mlanX warmreset - iwpriv mlanX regrdwr [value] - iwpriv mlanX rdeeprom - iwpriv mlanX memrdwr

[value] - iwpriv mlanX inactivityto [k] - iwpriv mlanX sdioclock - iwpriv mlanX sdcmd52rw
[data] - iwpriv mlanX scancfg [t] [m] [p] [s] [a] [b] [ext] - iwpriv mlanX sleeppd [n] - iwpriv mlanX pscfg [k] [d] [l] ... - iwpriv mlanX getkey - iwpriv mlanX associate " " - iwpriv mlanX sleepparams [ ] - iwpriv mlanX authtype [n] - iwpriv mlanX powercons [n] - iwpriv mlanX htstreamcfg [n] - iwpriv mlanX ipaddr [";"] - iwpriv mlanX macctrl [n] - iwpriv mlanX dfstesting [ ] - iwpriv mlanX thermal - iwpriv mlanX indrstcfg [gpio_pin] - -DESCRIPTION - Those commands are used to send additional commands to the NXP MLAN - card via the Linux device driver. - - The mlanX parameter specifies the network device that is to be used to - perform this command on. It could be mlan0, mlan1 etc. - -version - This is used to get the current version of the driver and the firmware. - -verext - Retrieve and display an extended version string from the firmware - - Usage: - iwpriv mlanX verext [#] - - where [#] is an optional argument to retrieve a specific version string, - omission of the argument retrieves the 0 indexed string. - -getsignal - This command gets the last and average value of RSSI, SNR and NF of - Beacon and Data. - Note: This command is available only when STA is connected. - - where value of m is: - 1 -- RSSI (Receive Signal Strength Indication) - 2 -- SNR (Signal to Noise Ratio) - 3 -- NF (Noise Floor) - where value of n is: - 1 -- Beacon last - 2 -- Beacon average - 3 -- Data last - 4 -- Data average - - Examples: - iwpriv mlan0 getsignal 1 : Get the RSSI info (beacon last, beacon - average, data last and data average) - iwpriv mlan0 getsignal 3 4 : Get the NF of data average - iwpriv mlan0 getsignal 2 1 : Get the SNR of beacon last - iwpriv mlan0 getsignal : Get all of the signal info - mlan0 getsignal:-32 -33 -35 -36 67 59 63 56 -99 -92 -98 -92 - RSSI info: beacon last -32, beacon average -33, data last -35, data average -36 - SNR info: beacon last 67, beacon average 59, data last 63, data average 56 - NF info: beacon last -99, beacon average -92, data last -98, data average -92 - -antcfg - This command is used to set/get the mode of Tx/Rx path. - - where value of m is: - Bit 0 -- Tx Path A - Bit 1 -- Tx Path B - Bit 0-1 -- Tx Path A+B - For 9097/9098, LOW BYTE for 2G setting - Bit 8 -- Tx Path A - Bit 9 -- Tx Path B - Bit 8-9 -- Tx Path A+B - For 9097/9098, HIGH BYTE for 5G setting - - where value of n is: - Bit 0 -- Rx Path A - Bit 1 -- Rx Path B - Bit 0-1 -- Rx Path A+B - For 9097/9098, LOW BYTE for 2G setting - Bit 8 -- Rx Path A - Bit 9 -- Rx Path B - Bit 8-9 -- Rx Path A+B - For 9097/9098, HIGH BYTE for 5G setting - The Tx path setting (m) is used if Rx path (n) is not provided. - - Examples: - iwpriv mlan0 antcfg : Get Tx and Rx path - iwpriv mlan0 antcfg 3 : Set Tx and Rx path to A+B - iwpriv mlan0 antcfg 1 3 : Set Tx path to A and Rx path to A+B - mlanutl mlan0 antcfg 0x103 : Set Tx and Rx path to A+B on 2G and Tx and Rx path to A on 5G - mlanutl mlan0 antcfg 0x103 0x103 : Set Tx path to A+B and Rx path to A+B on 2G, and Tx and Rx path to A on 5G - -regioncode - This command is used to set/get the region code in the station. - Note: This command should be issued at beginning before band/channel selection - and association. - - where value is 'region code' for various regions like - USA FCC, Canada IC, Europe ETSI, Japan ... - The special code (0xff) is used for Japan to support channel 1-14 in B/G/N mode. - - Examples: - iwpriv mlan0 regioncode : Get region code - iwpriv mlan0 regioncode 0x10 : Set region code to USA (0x10) - - Note : in some case regioncode will be 0 after updated countycode or 80211d - i.e. mlanutl mlanX countrycode (CA, JP, CN, DE, ES AT, BR, RU) - or uaputl.exe sys_cfg_80211d state 1 country (CA, JP, CN, DE, ES AT, BR, RU) - Please use cfp instead of it. - -cfpcode - This command is used to set/get the Channel-Frequency-Power table codes. - The region table can be selected through region code. - The current configuration is returned if no parameter provided. - - where the parameters are, - [m]: code of the CFP table for 2.4GHz (0: unchanged) - [n]: code of the CFP table for 5GHz (0 or not provided: unchanged) - - Examples: - iwpriv mlan0 cfpcode : Get current configuration - iwpriv mlan0 cfpcode 0x30 : Set 2.4GHz CFP table code 0x30 (EU), - keep 5GHz table unchanged - iwpriv mlan0 cfpcode 0x10 5 : Set 2.4GHz CFP table code 0x10 (USA) - and 5GHz table code 5 - -wwscfg - This command is used to set/get the WWS (World Wide Safe) mode. - - where value of m is: - 0 -- Disable WWS mode (default) - 1 -- Enable WWS mode - - Examples: - iwpriv mlan0 wwscfg : Get WWS mode - iwpriv mlan0 wwscfg 1 : Enable WWS mode - iwpriv mlan0 wwscfg 0 : Disable WWS mode - -esuppmode - This command is used to get the current RSN mode and active pairwise/group - cipher for WPA/WPA2 mode. - Note: This command is available only when STA is connected. - - These are bits settings used to indicate each RSN mode. - Bit 0 : No RSN - Bit 1-2 : RFU - Bit 3 : WPA - Bit 4 : WPA-NONE - Bit 5 : WPA2 - Bit 6 : AES - Bit 7-15 : RFU - - These are bits settings used to indicate each pairwise and group cipher. - Bit 0 : RFU - Bit 1 : RFU - Bit 2 : TKIP - Bit 3 : AES - Bit 2-7 : RFU - - Example: - iwpriv mlan0 esuppmode : Get RSN mode and pairwise/group cipher - 8 4 4 - (The current RSN mode is WPA, active pairwise cipher is TKIP and - active group cipher is TKIP.) - -passphrase - This command is used to set/get passphrase for WPA-PSK/WPA2-PSK mode. - - Where - ASCII string for ssid/passphrase/psk. - - This passphrase is used as password if WPA3 SAE protocol is configured, so please - use extremely difficult to guess password to protect from attacks. - - Also setting psk for WPA3 SAE protocol is not possible, as new psk gets generated - everytime in protocol flow. - - 1) "0;" - This will get the passphrase, AKMP - for specified ssid, if none specified then it will get all. - - Example: - iwpriv mlan0 passphrase "0;ssid=nxp" - - 2) "1;; - " - Passphrase and psk cannot be provided for the same SSID. - This command takes only one SSID at a time, If ssid= is present it should contain - a passphrase or psk. If no arguments are provided then AKMP=802.1x, and passphrase - should be provided after association. - End of each parameter should be followed by a ';'(except for the last parameter) - as the delimiter. If ';' or '/' has to be used in an SSID then a '/' should be preceded - to ';' or '/' as a escape. - - Examples: - iwpriv mlan0 passphrase "1;ssid=nxpAP;passphrase=abcdefgd" - iwpriv mlan0 passphrase "1;ssid=nxp AP;psk=<64 bytes hexpsk>" - - If user wants to input the ssid as "nxp; AP" then command has to be - iwpriv mlan0 passphrase "1;ssid=nxp/; AP;passphrase=abcdefgh" - - If user wants to input the ssid as "//;" then command has to be - iwpriv mlan0 passphrase "1;ssid=/////;;passphrase=abcdefgh" - - 3) "2;" - This will clear the passphrase - for specified ssid, if none specified then it will clear all. - - Examples: - iwpriv mlan0 passphrase "2;ssid=nxp" - iwpriv mlan0 passphrase "2" : Clear all profiles and disable embedded supplicant - -httxcfg - This command is used to configure various 11n specific configuration - for transmit (such as Short GI, Channel BW and Green field support) - - where is - This is a bitmap and should be used as following - Bit 15-8: Reserved set to 0 - Bit 7: STBC enable/disable - Bit 6: Short GI in 40 Mhz enable/disable - Bit 5: Short GI in 20 Mhz enable/disable - Bit 4: Green field enable/disable - Bit 3-2: Reserved set to 1 - Bit 1: 20/40 Mhz enable disable. - Bit 0: LDPC enable/disable - - When Bit 1 is set then firmware could transmit in 20Mhz or 40Mhz based - on rate adaptation. When this bit is reset then firmware will only - transmit in 20Mhz. - - where is - - This is the band info for settings. - 0: Settings for both 2.4G and 5G bands - 1: Settings for 2.4G band - 2: Settings for 5G band - - Examples: - iwpriv mlanX httxcfg - This will display HT Tx configuration. - If the configurations for 2.4G and 5G are different, - the first value is for 2.4G and the second value is for 5G. - Otherwise, it will display a single value for both bands. - - iwpriv mlanX httxcfg 0x62 - This will enable 20/40 and Short GI but will disable Green field for 2.4G and 5G band. - - iwpriv mlanX httxcfg 0x30 1 - This will enable Short GI 20 Mhz and Green field for 2.4G band. - - The default value is 0x20 for 2.4G and 0x62 for 5G. - - Note:- If 20/40 MHz support is disabled in htcapinfo, device will not transmit - in 40 MHz even 20/40 MHz is enabled in httxcfg. - -htcapinfo - This command is used to configure some of parameters in HTCapInfo IE - (such as Short GI, Channel BW, and Green field support) - - where is - - This is a bitmap and should be used as following - Bit 29: Green field enable/disable - Bit 26: Rx STBC Support enable/disable. (As we support - single spatial stream only 1 bit is used for Rx STBC) - Bit 24: Short GI in 40 Mhz enable/disable - Bit 23: Short GI in 20 Mhz enable/disable - Bit 17: 20/40 Mhz enable disable. - Bit 8: Enable/disable 40Mhz Intolarent bit in ht capinfo. - 0 will reset this bit and 1 will set this bit in - htcapinfo attached in assoc request. - All others are reserved and should be set to 0. - - Setting of any other bits will return error. - - where is - - This is the band info for settings. - 0: Settings for both 2.4G and 5G bands - 1: Settings for 2.4G band - 2: Settings for 5G band - - Examples: - iwpriv mlanX htcapinfo - This will display HT capabilties information. - If the information for 2.4G and 5G is different, - the first value is for 2.4G and the second value is for 5G. - Otherwise, it will display a single value for both bands. - - iwpriv mlanX htcapinfo 0x1820000 - This will enable Short GI, Channel BW to 20/40 and disable Green field support for 2.4G and 5G band. - - iwpriv mlanX htcapinfo 0x800000 2 - This will enable Short GI, Channel BW to 20 only, No Rx STBC support and disable Green field support for 5G band. - - The default value is 0x4800000 for 2.4G and 0x5820000 for 5G. - - Note:- This command can be issued any time but it will only come to effect from - next association. (as HTCapInfo is sent only during Association). - -addbapara - This command can be used to update the default ADDBA parameters. - - where is - - This is the block ack timeout for ADDBA request. - 0 : Disable (recommended for throughput test) - 1 - 65535 : Block Ack Timeout in TU - - where is - - Window size for ADDBA request. (16 is recommended and default value) - - where is - - Window size for ADDBA response. (48 is recommended and 32 is default value) - (16 is recommended for IWNCOMM AP in WAPI throughput test) - - Current window size limit for Tx as well as Rx is 1023. - - where

is - - amsdu support for ADDBA request. (1 is default value) - 0: disable amsdu in ADDBA request - 1: enable amsdu in ADDBA request - - where is - - amsdu support for ADDBA response. (1 is default value) - 0: disable amsdu in ADDBA response - 1: enable amsdu in ADDBA response - - eg: - iwpriv mlanX addbapara - This command will get the current addba params - iwpriv mlanX addbapara 1000 64 8 0 0 - This will change the ADDBA timeout to (1000 * 1024) us, - txwinsize to 64 and rxwinsize to 8 and disable amdsu in ADDBA request/response. - - The default setting is 65535 16 32 1 1. - - In case the ADDBA timeout value is updated then a ADDBA is sent for all streams - to update the timeout value. - - In case txwinsize and/or rxwinsize is updated, the effect could only be seen on - next ADDBA request/response. The current streams will not be affected with this - change. - - In case of txamsdu/rxamsdu is updated, the effect could only be seen on - next ADDBA request/response. The current streams will not be affected with this - change. AMSDU in AMPDU stream will be enabled when AP support this feature - and AMSDU is enabled in aggrpriotbl. - -aggrpriotbl - This command is used set/get the priority table for AMPDU/AMSDU traffic per tid. - This command can also be used to disable AMPDU/AMSDU for a given tid. - In case of AMPDU this priority table will be used to setup block ack (to make - sure the highest priority tid always uses AMPDU as we have limited AMPDU streams) - - where ... - - - This is priority for Tid0 for AMPDU packet. A priority could be any - values between 0 - 7, 0xff to disable aggregation. - - This is priority for Tid0 for AMSDU packet. A priority could be any - values between 0 - 7, 0xff to disable aggregation. - - eg: - iwpriv mlanX aggrpriotbl - This command will get the current Priority table for AMPDU and AMSDU. - <2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255>. This is read as - <"Prio for AMPDU for Tid0" "Prio for AMSDU for Tid0" - "Prio for AMPDU for Tid1" "Prio for AMSDU for Tid1" and so on - iwpriv mlanX aggrpriotbl 2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255 - - This will set the priority table for AMPDU and AMSDU - Priority for Tid0/AMPDU = 2, Tid0/AMSDU = 2, Tid1/AMPDU = 0, Tid1/AMSDU = 0 - and so on. Aggregation for Tid6 and Tid7 are disabled. - Here higher the priority number, higher the priority (i.e. 7 - has higher priority than 6). Similarly for AMSDU. - iwpriv mlanX aggrpriotbl 0xff 2 0xff 0 0xff 1 0xff 3 0xff 4 0xff 5 0xff 0xff 0xff 0xff - This will disable - AMPDU for all the TIDs but will still keep AMSDU enabled to Tid0 to Tid5 - - The default setting is 2 255 0 255 1 255 3 255 4 255 5 255 255 255 255 255. - - A delBA should be seen in case a disable happens on a TID for which AMPDU stream - is currently setup. - - Note:- This command should only be issue in disconnected state. - -addbareject - This command is used set/get the addbareject table for all the TIDs. - This command can also be used to enable rejection of ADDBA requests for a given tid. - - where ... - - - This can be 0/1 for TidX. 1 enables rejection of ADDBA request for TidX and - 0 would accept any ADDBAs for TidX. - - eg: - iwpriv mlanX addbareject - This command will get the current table. - [0 0 0 0 0 0 0 0]. ADDBA would be accepted for all TIDs. This is the default state. - - iwpriv mlanX addbareject 0 0 1 1 0 0 0 0 - This command will accept ADDBA requests for - Tid [0,1,4,5,6,7] and reject ADDBA requests for Tid [2,3] - - iwpriv mlanX addbareject 1 1 1 1 1 1 1 1 - This will enable rejection of ADDBA requests for - all Tids. - - Note:- This command should only be issue in disconnected state. - -txbufcfg - This command can be used to get current buffer size. - - eg: - iwpriv mlanX txbufcfg - This will display the current buffer size. - - Note:- The actual tx buf size will depends on AP's capability and max transmit buffer size. - -amsduaggrctrl - This command could be used to enable/disable a feature where firmware gives feedback to driver - regarding the optimal AMSDU buffer size to use with the current rate. Firmware will use the - current rate to decide the buffer size we could transmit. The max buffer size will still be - limited by buffer size provided in txbufcfg. (i.e. if the txbufcfg is 4K, then we could only transmit - 4K/2K AMSDU packets, if the txbufcfg is 8K then we could transmit 8k/4k/2k based on current rate) - - If enabled AMSDU buffer size at various rates will be as follows - - 1. Legacy B/G rate. - No AMSDU aggregation. - - 2. BW20 HT Rate: - When TX rate goes down, - MCS 7, 6, 5, 4: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 3, 2: - a 4K aggregation size (if TX buffer size is 8K/4K) - b 2K aggregation size (if TX buffer size is 2K) - - MCS 1, 0: - a No aggregation - - When TX rate goes up, - MCS 7, 6, 5: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 4, 3: - a 4K aggregation size (if TX buffer size is 8K/4K) - b 2K aggregation size (if TX buffer size is 2K) - - MCS 2, 1, 0: - a No aggregation - - 3. BW40 HT Rate: - When TX rate goes down, - MCS 7, 6, 5, 4, 3, 2, 1: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 0: - a No aggregation - - When TX rate goes up, - MCS 7, 6, 5, 4, 3: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 2, 1, 0: - a No aggregation - - where is 0/1 (for disable/enable) - - eg: - iwpriv mlanx amsduaggrctrl 1 - Enable this feature - iwpriv mlanx amsduaggrctrl 0 - Disable this feature - iwpriv mlanx amsduaggrctrl - This will get the enable/disable flag - and the current AMSDU buffer size). The AMSDU buffer size returned is only - valid after association as before association there is no rate info. - - Note:- This command to enable/disable could be given anytime (before/after - association). This feature is enabled by default by the driver during - initialization. - -httxbfcap - This command is used to set/get the TX beamforming capabilities. - - Usage: - iwpriv mlanX httxbfcap [cap] - - where the parameters are, - cap: TX beamforming capabilities - Bit 0 : Implicit TX BF receiving capable - Bit 1 : RX staggered sounding capable - Bit 2 : TX staggered sounding capable - Bit 3 : RX NDP capable - Bit 4 : TX NDP capable - Bit 5 : Implicit TX BF capable - Bit 6-7 : Calibration - 0: - not supported - 1: - STA can respond to a calibration request using - the CSI Report, but cannot initiate calibration - 2: - reserved - 3: - STA can both initiate and respond to a calibration request - Bit 8 : Explicit CSI TX BF capable - Bit 9 : Explicit non-compressed steering capable - Bit 10 : Explicit compressed steering capable - Bit 11-12: Explicit TX BF CSI feedback - 0: - not supported - 1: - delayed feedback - 2: - immediate feedback - 3: - delayed and immediate feedback - Bit 13-14: Explicit non-compressed BF feedback capable - 0: - not supported - 1: - delayed feedback - 2: - immediate feedback - 3: - delayed and immediate feedback - Bit 15-16: Explicit compressed BF feedback capable - 0: - not supported - 1: - delayed feedback - 2: - immediate feedback - 3: - delayed and immediate feedback - Bit 17-18: Minimal grouping - 0: - no grouping (STA supports groups of 1) - 1: - groups of 1, 2 - 2: - groups of 1, 4 - 3: - groups of 1, 2, 4 - Bit 19-20: CSI number of beamformer antennas supported - 0: - single TX antenna sounding - 1: - 2 TX antenna sounding - 2: - 3 TX antenna sounding - 3: - 4 TX antenna sounding - Bit 21-22: Non-compressed steering number of beamformer antennas supported - 0: - single TX antenna sounding - 1: - 2 TX antenna sounding - 2: - 3 TX antenna sounding - 3: - 4 TX antenna sounding - Bit 23-24: Compressed steering number of beamformer antennas supported - 0: - single TX antenna sounding - 1: - 2 TX antenna sounding - 2: - 3 TX antenna sounding - 3: - 4 TX antenna sounding - Bit 25-26: CSI max number of rows beamformer supported - 0: - single row of CSI - 1: - 2 rows of CSI - 2: - 3 rows of CSI - 3: - 4 rows of CSI - Bit 27-28: Channel estimation capability - 0: - 1 space time stream - 1: - 2 space time streams - 2: - 3 space time streams - 3: - 4 space time streams - Bit 29-31: Reserved - - Examples: - iwpriv mlan0 httxbfcap : Get the current TX BF capabilities - iwpriv mlan0 httxbfcap 0x0000001F : Set the TX BF capabilities of the - Implicit TX BF receiving capable, - RX staggered sounding capable, - TX staggered sounding capable, - RX NDP capable and TX NDP capable - -httxbfcfg - This command is used to configure the TX beamforming options. - Note: Any new subcommand should be inserted in the second - argument and each argument of the sub command should be - separated by semicolon. For global configuration, the - arguments should be separated by space. - - Usage: - iwpriv mlanX httxbfcfg "[;GlobalData/tsData/interval/txPeerData/snrData]" - - where the parameters are, - action: TX beamforming action - 0: Control global parameters for beamforming - 1: Performs NDP Sounding for PEER - 2: TX BF interval in milliseconds - 3: Enable/Disable beamforming/sounding for a particular peer - 4: TX BF SNR Threshold for peer - .. - GlobalData: Global parameter arguments. - It contains beamforming enable, sounding enable, FB type, snr_threshold - sounding interval, Beamformig mode values seperated by space. - Syntax: - iwpriv mlanX httxbfcfg ; - - tsData: Trigger sounding for PEER specific arguments, - it contains PEER MAC and status - interval: TX BF interval in milliseconds - txPeerData: Enable/Disable beamforming/sounding for the indicated peer, - it contains PEER MAC, sounding, beamfoming options and FB type; - snrData: TX BF SNR Threshold for peer, it contains PEER MAC and SNR - - Examples: - iwpriv mlan0 httxbfcfg "0" : Get current global configuration parameter - iwpriv mlan0 httxbfcfg "2;00:50:43:20:BF:64" : Get the TX BF periodicity for a given peer - iwpriv mlan0 httxbfcfg "3" : Get the list of MAC addresses that have - beamforming and/or sounding enabled - iwpriv mlan0 httxbfcfg "4" : Get the list of PEER MAC, SNR tuples - programmed into the firmware. - iwpriv mlan0 httxbfcfg "0;0 0 3 10 500 5" : Disable beamforming, sounding, set FB type - to 3, snr threshold to 10, sounding interval - to 500 ms and beamforming mode to 5 - iwpriv mlan0 httxbfcfg "1;00:50:43:20:BF:64" : Perform NDP Trigger sounding to peer - 00:50:43:20:BF:64 - iwpriv mlan0 httxbfcfg "2;00:50:43:20:BF:64;500" : Set TX BF periodicity for peer 00:50:43:20:BF:64 - to 500 milliseconds - iwpriv mlan0 httxbfcfg "3;00:50:43:20:BF:43;1;0;3" : Enable beamforming, disable sounding and set - FB type to 3 for peer 00:50:43:20:BF:43 - iwpriv mlan0 httxbfcfg "4;00:50:43:20:BF:24;43" : Set TX BF SNR threshold to peer - 00:50:43:20:BF:24 with SNR 43 - -mgmtframectrl - This command is used to get/set mask for the management frames which needs to be forwarded to application layer. - - Usage: - iwpriv mlanX mgmtframectrl [m] - - where the parameter [m] is the bit mask of management frame reception. - Following are the bit definitions. - Bit 0 : Association Request - Bit 1 : Association Response - Bit 2 : Re-Association Request - Bit 3 : Re-Association Response - Bit 4 : Probe Request - Bit 5 : Probe Response - Bit 8 : Beacon Frames - - Examples: - iwpriv mlan0 mgmtframectrl : Get the current Mgmt Frame forwarding mask - iwpriv mlan0 mgmtframectrl 0x0020 : Bit 5 is set, Forward probe response - frames to application layer - -mpactrl - This command is used to set/get the Tx, Rx SDIO aggregation parameters. - Note: The parameters can be set only in disconnected state. - - Usage: - iwpriv mlanX mpactrl [tx_ena] [rx_ena] [tx_size] [rx_size] [tx_ports] [rx_ports] - - where the parameter are: - [tx_ena]: Enable/disable (1/0) Tx MP-A - [rx_ena]: Enable/disable (1/0) Rx MP-A - [tx_size]: Size of Tx MP-A buffer - [rx_size]: Size of Rx MP-A buffer - [tx_ports]: Max ports (1-16) for Tx MP-A - [rx_ports]: Max ports (1-16) for Rx MP-A - default values are 1 1 16384 32768 16 16 - The MP-A may be disabled by default at build time if the MMC driver byte mode patch - is not available in kernel. - - Examples: - iwpriv mlan0 mpactrl : Get MP aggregation parameters - iwpriv mlan0 mpactrl 0 0 - : Disable MP aggregation for Tx, Rx respectively - iwpriv mlan0 mpactrl 1 1 8192 8192 8 8 - : Enable MP aggregation for Tx, Rx - : Set Tx, Rx buffer size to 8192 bytes - : Set maximum Tx, Rx ports to 8 - -deepsleep - This command is used to set/get auto deep sleep mode. - - Usage: - iwpriv mlanX deepsleep [n] [m] - - where the parameters are: - [n]: Enable/disable auto deep sleep mode (1/0) - [m]: Idle time in milliseconds after which firmware will put the device - in deep sleep mode. Default value is 100 ms. - - Examples: - iwpriv mlan0 deepsleep : Display auto deep sleep mode - iwpriv mlan0 deepsleep 1 : Enable auto deep sleep mode, idle time unchanged - iwpriv mlan0 deepsleep 0 : Disable auto deep sleep mode - iwpriv mlan0 deepsleep 1 500 : Enable auto deep sleep mode with idle time 500 ms - Note: - Deepsleep must be disabled before changing idle time. - -usbsuspend - This command is used to put device to suspend mode. - Note: It's only valid on kernel 2.6.24 or later. - -usbresume - This command is used to resume the device from suspend mode. - Note: It's only valid on kernel 2.6.24 or later. - -hscfg - This command is used to configure the host sleep parameters. - - Usage: - iwpriv mlanX hscfg [condition [[GPIO# [gap]]]] - - This command takes one (condition), two (condition and GPIO#) or three - (condition, GPIO# and gap) parameters for set. If no parameter provided, - get is performed. - - where Condition is: - bit 0 = 1 -- broadcast data - bit 1 = 1 -- unicast data - bit 2 = 1 -- mac event - bit 3 = 1 -- multicast data - bit 6 = 1 -- Wakeup when mgmt frame received. - bit 7 = 1 -- Reserved - bit 8 = 1 -- Disable non maskable data wakeup. - - The host sleep mode will be canceled if condition is set to -1. The default is 0x7. - - where GPIO is the pin number of GPIO used to wakeup the host. It could be any valid - GPIO pin# (e.g. 0-7) or 0xff (interface, e.g. SDIO will be used instead). - The default is 0xff. - - where Gap is the gap in milliseconds between wakeup signal and wakeup event or 0xff - for special setting (host acknowledge required) when GPIO is used to wakeup host. - The default is 200. - - The host sleep set except for cancellation will be blocked if host sleep is - already activated. - - Please note hssetpara and usbsuspend/usbresume commands should be used for USB - host sleep related tests. - - Examples: - iwpriv mlan0 hscfg : Get current host sleep mode - iwpriv mlan0 hscfg -1 : Cancel host sleep mode - iwpriv mlan0 hscfg 3 : Broadcast and unicast data - Use GPIO and gap set previously - iwpriv mlan0 hscfg 2 3 : Unicast data - Use GPIO 3 and gap set previously - iwpriv mlan0 hscfg 2 1 0xa0 : Unicast data - Use GPIO 1 and gap 160 ms - iwpriv mlan0 hscfg 2 0xff : Unicast data - Use interface (e.g. SDIO) - Use gap set previously - iwpriv mlan0 hscfg 4 3 0xff : MAC event - Use GPIO 3 - Special host sleep mode - iwpriv mlan0 hscfg 1 0xff 0xff : Broadcast data - Use interface (e.g. SDIO) - Use gap 255ms - -hssetpara - This command is used to set host sleep parameters. - - Usage: - iwpriv mlanX hssetpara Condition [GPIO# [gap]] - - Note: - 1) The usages of parameters are the same as "hscfg" command. - 2) The parameters will be saved in the driver and be used when host suspends. - -deauth - This command is used to send a de-authentication to an arbitrary AP. - If [n] is omitted, the driver will deauth the associated AP. - If in ad-hoc mode this command is used to stop beacon transmission - from the station and go into idle state. - - When is supplied as a MAC address, the driver will deauth the - specified AP. If the AP address matches the driver's associated AP, - the driver will disconnect. Otherwise, the driver remains connected. - -radioctrl - This command is used to turn on/off the radio. - Note: The radio can be disabled only in disconnected state. - - where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - iwpriv mlan0 radioctrl 1 : Turn the radio on - iwpriv mlan0 radioctrl : Get radio status - -reassoctrl - This command is used to turn on/off re-association in driver. - - Usage: - iwpriv mlanX reassoctrl [n] - - Where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - iwpriv mlan0 reassoctrl : Get re-association status - iwpriv mlan0 reassoctrl 1 : Turn re-association on - -bandcfg - This command is used to set/get infra/ad-hoc band. - Note: This command is only available in disconnected state. - - Usage: - iwpriv mlanX bandcfg [l] [m] [n] - - where the parameters: - [l]: Infrastructure band - bit 0: B - bit 1: G - bit 2: A - bit 3: GN - bit 4: AN - - bit 5: AC 2.4G - bit 6: AC 5G - [m]: Ad-hoc start band - bit 0: B - bit 1: G - bit 2: A diff --git a/mxm_wifiex/wlan_src/README_MLAN b/mxm_wifiex/wlan_src/README_MLAN index 1fe737c..38612dc 100644 --- a/mxm_wifiex/wlan_src/README_MLAN +++ b/mxm_wifiex/wlan_src/README_MLAN @@ -9,7 +9,7 @@ Goto source code directory wlan_src/. make [clean] build The driver and utility binaries can be found in ../bin_xxxx directory. - The driver code supports Linux kernel from 2.6.32 to 5.5.2. + The driver code supports Linux kernel from 2.6.32 to 5.8.0. 2) FOR DRIVER INSTALL @@ -57,10 +57,10 @@ dts_enable=0|1 fw_name = e.g. copy pcieuart9098_combo_v1.bin to firmware directory, fw_name=nxp/pcieuart9098_combo_v1.bin - fw_region hw_test=0|1 fw_serial=0|1 req_fw_nowait=0|1 + dfs53cfg=0|1|2 SD8887: antcfg=0|1|2|0xffff SD8897/SD8997: antcfg=0x11|0x13|0x33 slew_rate: Slew Rate Control value = 0|1|2|3 (0 is the slowest slew rate and 03 has the highest slew rate (default)) @@ -276,12 +276,6 @@ echo "debug_dump" > /proc/mwlan/adapterX/config # dump driver internal debug status. Use dmesg or cat /var/log/debug to check driver debug messages. - To log driver debug messages to file, - a) Edit /etc/syslog.conf, add one line "*.debug /var/log/debug" - on kernel 2.6.24 or later, edit /etc/rsyslog.conf instead - b) touch /var/log/debug (if the file doesn't exist) - c) service syslog restart - on kernel 2.6.24 or later, service rsyslog restart Update /proc/sys/kernel/printk to change message log levels. For example, @@ -305,229 +299,134 @@ (Note: This feature will be supported on Robin3 and KF2. For CAC-A2, it only work with the board which supports parallel fw download) +5) FOR RF test mode commands: + + Following commands are used to perform RF testing of the wifi chipset. + Please not that these test mode commands can only be issued while the + device is in disconnected state and the uAP BSS is inactive. + Normal wifi operations cannot be used on entering RF Test Mode. + + Enter RF Test Mode: + echo "rf_test_mode=1" > /proc/mwlan/adapterX/config + + Exit RF Test Mode: + echo "rf_test_mode=0" > /proc/mwlan/adapterX/config + Please note that after exiting the RF Test Mode, the FW needs to be + reset in order to use normal wifi connectivity. + + To get the set of available RF Test Mode commands, currently set + parameters values for each command and the output, + cat /proc/mwlan/adapterX/config + + Set Tx Antenna + For 1x1 chipsets, 1:Main, 2:Aux when antenna diversity is supported + For 2x2 chipsets, 1:Path A, 2: Path B, 3: Path A+B + Both Tx and Rx must be set to same antenna path + echo "tx_antenna=1" > /proc/mwlan/adapterX/config + + Set Rx Antenna + For 1x1 chipsets, 1:Main, 2:Aux when antenna diversity is supported + For 2x2 chipsets, 1:Path A, 2:Path B, 3:Path A+B + Both Tx and Rx must be set to same antenna path + echo "rx_antenna=1" > /proc/mwlan/adapterX/config + + Set RF band (0:2G, 1:5G) + For 2G, channel will be reset to 6, while for 5G, to channel 36 + echo "band=0" > /proc/mwlan/adapterX/config + + Set RF bandwidth (0:20MHz, 1:40MHz, 4:80MHz) + echo "bw=0" > /proc/mwlan/adapterX/config + + Set RF channel + echo "channel=6" > /proc/mwlan/adapterX/config + + Get and reset packet error rate + echo "get_and_reset_per" > /proc/mwlan/adapterX/config + + Set Tx Power + This command will set power only if caldata is already loaded in the FW. + Power (0 to 24 dBm) + Modulation (0: CCK, 1:OFDM, 2:MCS) + Path ID (0: PathA, 1:PathB, 2:PathA+B) + echo "tx_power=16 2 0" > /proc/mwlan/adapterX/config + + Set Tx Continuous Mode + Start (0:disable, 1:enable) + Continuous Wave Mode (0:disable, 1:enable) + Payload Pattern (0 to 0xFFFFFFFF) + CS Mode (Applicable only when continuous wave is disabled) + (0:disable, 1:enable) + Active SubChannel (0:low, 1:upper, 3:both) + Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates) + + Example: To start continuous wave (tone) mode, first stop any ongoing + Tx and then start wave mode: + step1: echo "tx_continuous=0" > /proc/mwlan/adapterX/config + step2: echo "tx_continuous=1 1 0xAAA 0 3 7" > /proc/mwlan/adapterX/config + + Example: To start continuous packet mode, first stop any ongoing Tx and + then start pkt mode: + step1: echo "tx_continuous=0" > /proc/mwlan/adapterX/config + step2: echo "tx_continuous=1 0 0xAAA 0 3 7" > /proc/mwlan/adapterX/config + + stop: + echo "tx_continuous=0" > /proc/mwlan/adapterX/config + + Set Tx Frame + Start (0:disable, 1:enable) + Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates) + Payload Pattern (0 to 0xFFFFFFFF) + Payload Length (1 to 0x400) + Adjust Burst SIFS Gap (0:disable, 1:enable) + Burst SIFS in us (0 to 255us) + Short Preamble (0:disable, 1:enable) + Active SubChannel (0:low, 1:upper, 3:both) + Short GI (0:disable, 1:enable) + Adv Coding (0:disable, 1:enable) + Beamforming (0:disable, 1:enable) + GreenField Mode (0:disable, 1:enable) + STBC (0:disable, 1:enable) + BSSID (xx:xx:xx:xx:xx:xx) + + Example: To start Tx frame with duty cycle, first stop any ongoing Tx + and then start Tx frame: + echo "tx_frame=0" > /proc/mwlan/adapterX/config + echo "tx_frame=1 7 0xAAA 0x100 1 20 0 0 0 0 0 0 0 05:43:3f:c4:51" > /proc/mwlan/adapterX/config =============================================================================== U S E R M A N U A L F O R MLANUTL NAME - mlanutl - configure the additional parameters available for NXP mdriver. + mlanutl - configure the additional parameters available for NXP mdriver. SYNOPSIS - mlanutl -v - mlanutl [parameters] ... + mlanutl -v + mlanutl [parameters] ... - mlanutl mlanX 11dcfg - mlanutl mlanX 11dclrtbl - mlanutl mlanX addbapara [

] - mlanutl uapX addbapara [

] - mlanutl mlanX addbareject [ ... ] - mlanutl uapX addbareject [ ... ] - mlanutl mlanX addts - mlanutl mlanX aggrpriotbl [ ... ] - mlanutl uapX aggrpriotbl [ ... ] - mlanutl mlanX amsduaggrctrl - - mlanutl mlanX min_ba_threshold - mlanutl mlanX antcfg [m] [n] - mlanutl mlanX/uapX mimoswitch [tx_antmode] [rx_antmode] - mlanutl mlanX assocessid <"[essid]"> - mlanutl mlanX assocessid_bssid <"[bssid] [essid]"> - mlanutl mlanX associate " " - mlanutl mlanX get_chnrgpwr [save_region_channel_power_data_file] - mlanutl mlanX comparergpwr [target_file] - mlanutl mlanX get_txpwrlimit [raw_data_file] - mlanutl mlanX comparetrpc [display] - mlanutl mlanX getcfgchanlist - mlanutl mlanX authtype [n] - mlanutl uapX dfs_offload [n] - mlanutl mlanX cloud_keep_alive - mlanutl mlanX bandcfg [l] [m] [n] - mlanutl mlanX bcninterval [n] - mlanutl wfdX bssrole [l] - mlanutl mlanX cfgdata [] - mlanutl mlanX cfpcode [m] [n] - mlanutl mlanX changraph [ ] - mlanutl mlanX coex_rx_winsize [m] - mlanutl mlanX countrycode [l] - - mlanutl mlanX cfpinfo - mlanutl uapX cfpinfo - - mlanutl mlanX customie [[[] ] ] - mlanutl mlanX deauth [l] - mlanutl uapX deauth [l] - mlanutl mlanX deepsleep [l] [m] - mlanutl mlanX delba [ ] - mlanutl uapX delba [ ] - mlanutl mlanX delts - mlanutl mlanX dfstesting [ ] - mlanutl mlanX dfs_repeater [n] - mlanutl mlanX drvdbg [n] - mlanutl mlanX esuppmode [l] [m] [n] - mlanutl mlanX extcapcfg [] - mlanutl mlanX fwmacaddr [mac_addr] + mlanutl mlanX verext + mlanutl mlanX version + mlanutl mlanX hostcmd generate_raw mlanutl mlanX getdatarate mlanutl uapX getdatarate - mlanutl mlanX getkey + mlanutl mlanX drvdbg [n] mlanutl mlanX getlog - mlanutl mlanX getscantable [ARGS] mlanutl mlanX getsignal [m] [n] mlanutl mlanX signalextcfg [m] mlanutl mlanX getsignalextv2 [m] mlanutl mlanX getsignalext [m] - mlanutl mlanX dyn_bw [n] - mlanutl uapX getstalist - mlanutl uapX channel_switch - mlanutl mlanX hostcmd <11n_2040coex.conf> 2040coex - mlanutl mlanX hostcmd auto_tx_get - mlanutl mlanX hostcmd auto_tx_unreg - mlanutl mlanX hostcmd bgscfg - - mlanutl mlanX hostcmd coalesce_cfg - mlanutl mlanX hostcmd ed_mac_ctrl - mlanutl mlanX hostcmd crypto_test - mlanutl mlanX hostcmd nat_keep_alive - mlanutl mlanX hostcmd pad_cfg_get - mlanutl mlanX hostcmd pad_cfg_set - mlanutl mlanX hostcmd requesttpc - mlanutl mlanX hostcmd mode_get - mlanutl mlanX hostcmd mode_timeshare - mlanutl mlanX hostcmd mode_spatial - mlanutl mlanX hostcmd mode_none - mlanutl mlanX hostcmd gpio_cfg - mlanutl mlanX hostcmd generictime - mlanutl mlanX hostcmd a2dptime - mlanutl mlanX hostcmd inquirytim - mlanutl mlanX hostcmd ap_generictime - mlanutl mlanX hostcmd ap_a2dptime - mlanutl mlanX hostcmd ap_inquirytime - mlanutl mlanX hostcmd sdio_pulldown_disable - mlanutl mlanX hostcmd sdio_pulldown_get - mlanutl mlanX hostcmd sdio_pulldown_set - mlanutl mlanX hostcmd subevent_get - mlanutl mlanX hostcmd subevent_set - mlanutl mlanX hostcmd txpwrlimit_2g_cfg_set - mlanutl mlanX hostcmd txpwrlimit_5g_cfg_set - mlanutl mlanX hostcmd txpwrlimit_cfg_get - mlanutl mlanX hostcmd txrate_cfg_get - mlanutl mlanX hostcmd txrate_cfg_set_bg - mlanutl mlanX hostcmd txrate_cfg_set_bgn - mlanutl mlanX hostcmd generate_raw - mlanutl mlanX hostcmd fwdump - - mlanutl mlanX hostcmd stop_su - mlanutl mlanX hostcmd start_su - - mlanutl mlanX hotspotcfg [] - mlanutl mlanX hscfg [condition [[GPIO# [gap]]]] [ind_GPIO# [level]] - mlanutl mlanX hssetpara condition [GPIO# [gap]] [ind_GPIO# [level]] - mlanutl mlanX mgmtfilter - mlanutl mlanX auto_arp [n] - mlanutl mlanX htcapinfo [] [] - mlanutl mlanX htstreamcfg [n] - mlanutl mlanX httxbfcap [cap] - mlanutl mlanX httxbfcfg "[;GlobalData/tsData/interval/txPeerData/snrData]" - mlanutl mlanX httxcfg [] [] - mlanutl mlanX inactivityto [k] - mlanutl mlanX ipaddr [";"] - mlanutl mlanX linkstats - mlanutl mlanX listeninterval [l] - mlanutl mlanX macctrl [n] - mlanutl uapX macctrl [n] - mlanutl mlanX mefcfg - mlanutl mlanX memrdwr

[value] - mlanutl mlanX miracastcfg [l] [m] [n] - mlanutl mlanX mgmtframectrl [] - mlanutl uapX mgmtframectrl [] - mlanutl mlanX mgmtframetx - mlanutl mlanX mpactrl [tx_ena] [rx_ena] [tx_size] [rx_size] [tx_ports] [rx_ports] - mlanutl mlanX offchannel [ ] - mlanutl mlanX otpuserdata - mlanutl mlanX passphrase [l] - mlanutl mlanX pb_bypass [data_1, data_2, ... data_n] - mlanutl mlanX pcieregrw [value] - mlanutl mlanX pciebar0regrw [value] - mlanutl mlanX pmfcfg - mlanutl mlanX port_ctrl [n] - mlanutl mlanX powercons [n] - mlanutl mlanX pscfg [k] [d] [l] ... - mlanutl mlanX bcntimeoutcfg [l] [m] [o] [p] - mlanutl mlanX psmode [l] - - mlanutl robustcoex [Enable/Disable] [gpionum] [gpiopolarity] - mlanutl mlanX qconfig def [Queue Id: 0-3] - mlanutl mlanX qconfig get [Queue Id: 0-3] - mlanutl mlanX qconfig set msdu [Queue Id: 0-3] - mlanutl mlanX qoscfg - mlanutl mlanX qstatus - mlanutl mlanX radioctrl [n] - mlanutl mlanX rdeeprom - mlanutl mlanX reassoctrl [n] - mlanutl mlanX regioncode [n] - mlanutl mlanX regrdwr [value] - mlanutl mlanX rejectaddbareq [conditions] - mlanutl uapX rejectaddbareq [conditions] - mlanutl mlanX scancfg [t] [m] [p] [s] [a] [b] [c] [ext] [gap] - mlanutl mlanX sdcmd52rw
[data] - mlanutl mlanX sdcmd53rw
[data1] ... [dataN] - mlanutl mlanX sdioclock - mlanutl mlanX setuserscan [ARGS] - mlanutl mlanX cancelscan - mlanutl mlanX sleepparams [ ] - mlanutl mlanX sleeppd [n] - mlanutl mlanX sysclock [clk1] [clk2] [clk3] [clk4] - mlanutl mlanX tcpackenh [l] - mlanutl mlanX thermal - mlanutl mlanX ts_status - mlanutl mlanX tsf - mlanutl mlanX txbufcfg - mlanutl mlanX txratecfg [l] [m] [n] [o] - mlanutl uapX txratecfg [l] [m] [n] [o] - mlanutl mlanX aggrctrl [l] - mlanutl mlanX usbaggrctrl [l] [m] [n] [o] [p] [q] [r] [s] - mlanutl mlanX usbresume - mlanutl mlanX usbsuspend - mlanutl mlanX verext - mlanutl mlanX version + mlanutl mlanX get_txpwrlimit [raw_data_file] + mlanutl mlanX aggrpriotbl [ ... ] + mlanutl uapX aggrpriotbl [ ... ] + mlanutl mlanX addbapara [

] + mlanutl uapX addbapara [

] + mlanutl mlanX addbareject [ ... ] + mlanutl uapX addbareject [ ... ] + mlanutl mlanX dyn_bw [n] mlanutl mlanX vhtcfg [l] [m] [n] [o] mlanutl uapX vhtcfg [l] [m] [n] [o] - mlanutl per_pkt_cfg [tx_rx_control] [type_num] [ether_type1 ether_type2 ...] [tx_rx_control] [type_num] [ether_type1 ether_type2 ...] - mlanutl dot11_txrx - mlanutl mlanX txrxhistogram [action] [tx_rx_statics] - mlanutl uapX txrxhistogram [action] [tx_rx_statics] - mlanutl mlanX wakeupreason - mlanutl uapX wakeupreason - mlanutl mlanX warmreset - mlanutl mlanX wpssession [n] - mlanutl mlanX wmmcfg [n] - mlanutl mlanX wmmparamcfg [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] - [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] - [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] - [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP] - mlanutl mlanX wwscfg [m] - mlanutl p2pX cfg_noa [h] [i] [j] [k] [l] - mlanutl p2pX cfg_opp_ps [m] [n] - mlanutl mlanX get_sensor_temp - mlanutl indrstcfg [gpio_pin] - - - mlanutl uapX ctrldeauth - - mlanutl mlanX/uapX bootsleep <1/0> - - mlanutl mlanX ssu [mode] [ssu file] - - mlanutl mlanX dmcs [value] - - mlanutl mlanX 11axcfg [config/11axcfg.conf] - mlanutl mlanX 11axcmd - mlanutl rx_abort_cfg [enable] [rssi_threshold] - mlanutl rx_abort_cfg_ext [enable] [margin ceil_thresh] - mlanutl tx_ampdu_prot_mode [mode] - mlanutl rate_adapt_cfg [low_thresh high_thresh timer_interval] - mlanutl cck_desense_cfg [mode] [margin ceil_thresh] [num_on_intervals num_off_intervals] - mlanutl mlanX/uapX lpm [mode] + mlanutl mlanX httxcfg [] [] + mlanutl mlanX htcapinfo [] [] DESCRIPTION Those commands are used to send additional commands to the NXP MLAN @@ -536,734 +435,17 @@ DESCRIPTION The mlanX parameter specifies the network device that is to be used to perform this command on. It could be mlan0, mlan1 etc. -11dcfg - This command is used to control 11D. No argument is used to get. - - where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - mlanutl mlan0 11dcfg 1 : Enable 11D - mlanutl mlan0 11dcfg : Get 11D status - -11dclrtbl - This command is used to clear the 11D channel table. +verext + Retrieve and display an extended version string from the firmware Usage: - mlanutl mlanX 11dclrtbl + mlanutl mlanX verext [#] -addbapara - This command can be used to update the default ADDBA parameters. + where [#] is an optional argument to retrieve a specific version string, + omission of the argument retrieves the 0 indexed string. - where is - - This is the block ack timeout for ADDBA request. - 0 : Disable (recommended for throughput test) - 1 - 65535 : Block Ack Timeout in TU - - where is - - Window size for ADDBA request. (16 is recommended and default value) - - where is - - Window size for ADDBA response. (48 is recommended and 32 is default value) - (16 is recommended for IWNCOMM AP in WAPI throughput test) - - Current window size limit for Tx as well as Rx is 1023. - - where

is - - amsdu support for ADDBA request. (1 is default value) - 0: disable amsdu in ADDBA request - 1: enable amsdu in ADDBA request - - where is - - amsdu support for ADDBA response. (1 is default value) - 0: disable amsdu in ADDBA response - 1: enable amsdu in ADDBA response - - eg: - mlanutl mlanX addbapara - This command will get the current addba params - mlanutl mlanX addbapara 1000 64 8 0 0 - This will change the ADDBA timeout to (1000 * 1024) us, - txwinsize to 64 and rxwinsize to 8 and disable amdsu in ADDBA request/response. - - The default setting is 65535 16 32 1 1. - - In case the ADDBA timeout value is updated then a ADDBA is sent for all streams - to update the timeout value. - - In case txwinsize and/or rxwinsize is updated, the effect could only be seen on - next ADDBA request/response. The current streams will not be affected with this - change. - - In case of txamsdu/rxamsdu is updated, the effect could only be seen on - next ADDBA request/response. The current streams will not be affected with this - change. AMSDU in AMPDU stream will be enabled when AP support this feature - and AMSDU is enabled in aggrpriotbl. - -addbareject - This command is used set/get the addbareject table for all the TIDs. - This command can also be used to enable rejection of ADDBA requests for a given tid. - - where ... - - - This can be 0/1 for TidX. 1 enables rejection of ADDBA request for TidX and - 0 would accept any ADDBAs for TidX. - - eg: - mlanutl mlanX addbareject - This command will get the current table. - [0 0 0 0 0 0 0 0]. ADDBA would be accepted for all TIDs. This is the default state. - - mlanutl mlanX addbareject 0 0 1 1 0 0 0 0 - This command will accept ADDBA requests for - Tid [0,1,4,5,6,7] and reject ADDBA requests for Tid [2,3] - - mlanutl mlanX addbareject 1 1 1 1 1 1 1 1 - This will enable rejection of ADDBA requests for - all Tids. - - Note:- This command should only be issue in disconnected state. - -addts - Send an ADDTS command to the associated AP. - - Process a given conf file for a specific TSPEC data block. Send the - TSPEC along with any other IEs to the driver/firmware for transmission - in an ADDTS request to the associated AP. - - Return the execution status of the command as well as the ADDTS response - from the AP if any. - - Usage: - mlanutl mlanX addts - -aggrpriotbl - This command is used set/get the priority table for AMPDU/AMSDU traffic per tid. - This command can also be used to disable AMPDU/AMSDU for a given tid. - In case of AMPDU this priority table will be used to setup block ack (to make - sure the highest priority tid always uses AMPDU as we have limited AMPDU streams) - - where ... - - - This is priority for Tid0 for AMPDU packet. A priority could be any - values between 0 - 7, 0xff to disable aggregation. - - This is priority for Tid0 for AMSDU packet. A priority could be any - values between 0 - 7, 0xff to disable aggregation. - - eg: - mlanutl mlanX aggrpriotbl - This command will get the current Priority table for AMPDU and AMSDU. - <2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255>. This is read as - <"Prio for AMPDU for Tid0" "Prio for AMSDU for Tid0" - "Prio for AMPDU for Tid1" "Prio for AMSDU for Tid1" and so on - mlanutl mlanX aggrpriotbl 2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255 - - This will set the priority table for AMPDU and AMSDU - Priority for Tid0/AMPDU = 2, Tid0/AMSDU = 2, Tid1/AMPDU = 0, Tid1/AMSDU = 0 - and so on. Aggregation for Tid6 and Tid7 are disabled. - Here higher the priority number, higher the priority (i.e. 7 - has higher priority than 6). Similarly for AMSDU. - mlanutl mlanX aggrpriotbl 0xff 2 0xff 0 0xff 1 0xff 3 0xff 4 0xff 5 0xff 0xff 0xff 0xff - This will disable - AMPDU for all the TIDs but will still keep AMSDU enabled to Tid0 to Tid5 - - The default setting is 2 255 0 255 1 255 3 255 4 255 5 255 255 255 255 255. - - A delBA should be seen in case a disable happens on a TID for which AMPDU stream - is currently setup. - - Note:- This command should only be issue in disconnected state. - -amsduaggrctrl - This command could be used to enable/disable a feature where firmware gives feedback to driver - regarding the optimal AMSDU buffer size to use with the current rate. Firmware will use the - current rate to decide the buffer size we could transmit. The max buffer size will still be - limited by buffer size provided in txbufcfg. (i.e. if the txbufcfg is 4K, then we could only transmit - 4K/2K AMSDU packets, if the txbufcfg is 8K then we could transmit 8k/4k/2k based on current rate) - - If enabled AMSDU buffer size at various rates will be as follows - - 1. Legacy B/G rate. - No AMSDU aggregation. - - 2. BW20 HT Rate: - When TX rate goes down, - MCS 7, 6, 5, 4: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 3, 2: - a 4K aggregation size (if TX buffer size is 8K/4K) - b 2K aggregation size (if TX buffer size is 2K) - - MCS 1, 0: - a No aggregation - - When TX rate goes up, - MCS 7, 6, 5: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 4, 3: - a 4K aggregation size (if TX buffer size is 8K/4K) - b 2K aggregation size (if TX buffer size is 2K) - - MCS 2, 1, 0: - a No aggregation - - 3. BW40 HT Rate: - When TX rate goes down, - MCS 7, 6, 5, 4, 3, 2, 1: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 0: - a No aggregation - - When TX rate goes up, - MCS 7, 6, 5, 4, 3: - a 8K aggregation size (if TX buffer size is 8K) - b 4K aggregation size (if TX buffer size is 4K) - c 2K aggregation size (if TX buffer size is 2K) - - MCS 2, 1, 0: - a No aggregation - - where is 0/1 (for disable/enable) - - eg: - mlanutl mlan0 amsduaggrctrl 1 - Enable this feature - mlanutl mlan0 amsduaggrctrl 0 - Disable this feature - mlanutl mlan0 amsduaggrctrl - This will get the enable/disable flag - and the current AMSDU buffer size). The AMSDU buffer size returned is only - valid after association as before association there is no rate info. - - Note:- This command to enable/disable could be given anytime (before/after - association). This feature is enabled by default by the driver during - initialization. - -min_ba_threshold - This command is to set minimum Tx BA setup threshold - - Usage: - mlanutl mlanX min_ba_threshold - - where the parameters are: - : minimum BA Threshold :0-16 (default is 16) - Example: - mlanutl mlan0 min_ba_threshold : get min_ba_threshold value - mlanutl mlan0 min_ba_threshold 10 : set minimum BA threshold to 10 - -antcfg - This command is used to set/get the mode of Tx/Rx path. - - For chip which support STREAM_2X2 - where value of m is: - Bit 0 -- Tx Path A or Tx/Rx Path A if [n] is not provided - Bit 1 -- Tx Path B or Tx/Rx Path B if [n] is not provided - Bit 0-1 -- Tx Path A+B or Tx/Rx Path A+B if [n] is not provided - For 9097/9098, LOW BYTE for 2G setting - Bit 8 -- Tx Path A or Tx/Rx Path A if [n] is not provided - Bit 9 -- Tx Path B or Tx/Rx Path B if [n] is not provided - Bit 8-9 -- Tx Path A+B or Tx/Rx Path A+B if [n] is not provided - For 9097/9098, HIGH BYTE for 5G setting - where value of n is: - Bit 0 -- Rx Path A - Bit 1 -- Rx Path B - Bit 0-1 -- Rx Path A+B - For 9097/9098, LOW BYTE for 2G setting - Bit 8 -- Rx Path A - Bit 8 -- Rx Path B - Bit 8-9 -- Rx Path A+B - For 9097/9098, HIGH BYTE for 5G setting - The Tx path setting (m) is used for both Tx and Rx if Rx path (n) is not provided. - - Examples: - mlanutl mlan0 antcfg : Get Tx and Rx path - mlanutl mlan0 antcfg 3 : Set Tx and Rx path to A+B - mlanutl mlan0 antcfg 1 3 : Set Tx path to A and Rx path to A+B - mlanutl mlan0 antcfg 0x103 : Set Tx and Rx path to A+B on 2G and Tx and Rx path to A on 5G - mlanutl mlan0 antcfg 0x103 0x103 : Set Tx path to A+B and Rx path to A+B on 2G, and Tx and Rx path to A on 5G - - For chip which support SAD - where value of m is: - Bit 0 -- Tx/Rx antenna 1 - Bit 1 -- Tx/Rx antenna 2 - ... - 0xFFFF -- Tx/Rx antenna diversity - - where value of n is: - SAD evaluate time interval, only be provided when m = 0xFFFF, default value is 6s(0x1770) - - Examples: - mlanutl mlan0 antcfg : Get Tx/Rx antenna mode - mlanutl mlan0 antcfg 1 : Set Tx/Rx antenna 1 - mlanutl mlan0 antcfg 0xFFFF : Set Tx/Rx antenna diversity - mlanutl mlan0 antcfg 0xFFFF 0x1770 : Set antenna evaluate time interval to 6s -mimoswitch - This command is used to do MIMO switch for 11n and 11ac mode and is available for all interfaces. - mlanutl mlanX/uapX mimoswitch [tx_antmode] [rx_antmode] - - This command takes 2 conditions. - The supported options are: - tx_antmode: 1 - ANTENNA A - 2 - ANTENNA B - 3 - ANTENNA AB - rx_antmode: 1 - ANTENNA A - 2 - ANTENNA B - 3 - ANTENNA AB - Examples: - mlanutl mlan0/uap0 mimoswitch 1 1 : set Tx and Rx path to ANTENNA A - mlanutl mlna0/uap0 mimoswitch 2 2 : set Tx and Rx path to ANTENNA B - mlanutl mlan0/uap0 mimoswitch 3 3 : set Tx and Rx path to ANTENNA A+B - mlnautl mlan0/uap0 mimoswitch 1 3 : set Tx path to ANTENNA A and Rx path to ANTENNA A+B - -assocessid - This command is used to assoc essid with asynced mode, - and driver will auto retry if driver auto assoc enabled. - - Usage: - mlanutl mlanX assocessid <"[essid]"> - - Where - <"[essid]"> is the essid which need to be associated with asynced mode. - - Examples: - mlanutl mlan0 assocessid "NXP Micro AP" : Associate to the ESSID "NXP Micro AP" - -assocessid_bssid - This command is used to assoc AP by ssid/bssid pair with asynced mode, - and driver will auto retry if driver auto assoc enabled. - - Usage: - mlanutl mlanX assocessid_bssid <"[bssid] [essid]"> - - Where - <"[bssid]"> is the bssid which need to be associated with asynced mode. - <"[essid]"> is the essid which need to be associated with asynced mode. - - Examples: - mlanutl mlan0 assocessid_bssid "xx:xx:xx:xx:xx:xx NXP Micro AP" : Associate to the AP which ssid = "NXP Micro AP", bssid = "xx:xx:xx:xx:xx:xx" - -associate - Request an association to a given SSID/BSSID pair. This the only accurate - way to pick a specific AP and ESS for an association. The entry must - already exist in the scan table for the association to be attempted. - - mlanutl mlanX associate "xx:xx:xx:xx:xx:xx SSID" - -get_chnrgpwr - This command is used to get the txpwrlimit table in FW -Usage: - mlanutl mlanX get_chnrgpwr [save_region_channel_power_data_file] - driver will save fw raw data to this file. - - Examples: - mlanutl mlan0 get_chnrgpwr fw_region_pwr.bin : Get region channel power table and save to file fw_region_pwr.bin - -comparergpwr - This command is used to compare two regionpower tables and output differences. - - Usage : - mlanutl mlanX comparergpwr [target_file] - where: - : raw data file save from get_chnrgpwr command. - : uncompressed raw data file generated by powerutil from the excel input region power file - - Example : - mlanutl mlan0 comparergpwr uncompressed.bin fw_region_pwr.bin : Show power table comparison in text format - mlanutl mlan0 comparergpwr uncompressed.bin : Show power table of uncompressed file in text format -get_txpwrlimit - This command is used to get the txpwrlimit table in FW -Usage: - mlanutl mlanX get_txpwrlimit [raw_data_file] - where - 0: Get 2.4G txpwrlimit table - 0x10: Get 5G sub0 txpwrlimit table - 0x11: Get 5G sub1 txpwrlimit table - 0x12 Get 5G sub2 txpwrlimit table - 0x1f Get all 5G txpwrlimit table - 0xff Get both 2G and 5G txpwrlimit table - driver will save fw raw data to this file. - - Examples: - mlanutl mlan0 get_txpwrlimit 0 : Get 2G txpwrlimit table. - mlanutl mlan0 get_txpwrlimit 0x10 : Get 5G sub band0 txpwrlimit table - mlanutl mlan0 get_txpwrlimit 0xff txpwrlimit.bin : Get both 2G/5G txpwrlimit table and save to txpwrlimit.bin -comparetrpc - This command is used to compare two txpower tables and output differences. - - Usage : - mlanutl mlanX comparetrpc [display] - where: - : raw data file save from get_txpwrlimit command. - : raw data file used by driver load parameter "txpwrlimit_cfg" which will be download to FW during driver init. - : display comparison output - : 1 - text format - : 2 - table format - - Example : - mlanutl mlan0 comparetrpc txpwrlimit.bin txpwrlimit_init.bin 1 : Show power table comparison in text format - mlanutl mlan0 comparetrpc txpwrlimit.bin txpwrlimit_init.bin 2 : Show power table comparison in table format -getcfgchanlist - This command is used to get the channel list used by cfg80211 stack - - Example: - mlanutl mlan0 getcfgchanlist - - -authtype - This command is used to set/get authentication type. - - Usage: - mlanutl mlanX authtype [n] - - where - 0: 802.11 open system authentication - 1: 802.11 shared key authentication - 3: 802.11 WPA3 SAE authentication - 255: allow open system or shared key authentication (default) - - Examples: - mlanutl mlan0 authtype 0 : use open system authentication - mlanutl mlan0 authtype 1 : use shared key authentication - mlanutl mlan0 authtype 255 : allow open system or shared key authentication - mlanutl mlan0 authtype : get current setting - -dyn_bw - This command is used to set/get dynamic bandwidth. - - Usage: - mlanutl mlanX dyn_bw [n] - - where - [BIT0] - 0 = TxInfo Indicated BW Disable - 1 = TxInfo Indicated BW Enable - [BIT1] - 0 = TxInfo Dynamatic BW Disable - 1 = TxInfo Dynamatic BW Enable - [BIT2] - 0 = TxInfo Force send RTS Disable - 1 = TxInfo Force send RTS Enable - [BIT3] - 0 = Mac Dynamic BW Operation Mode Disable (Static BW Operation Mode) - 1 = Mac Dynamic BW Operation Mode Enable - other bits reserved. - - If no parameter provided, get is performed. - - Examples: - mlanutl mlan0 dyn_bw 0x1 : Enable TxInfo Indicated BW - mlanutl mlan0 dyn_bw : get current setting - -dfs_offload - This command is used to enable/disable DFS offload. The valid value is 0/1. - Note: The parameters can be set only in disconnected state. - - Usage: - mlanutl uapX dfs_offload [n] - - where - Enable/disable - - Examples: - mlanutl uap0 dfs_offload 1 : enable DFS offload - mlanutl uap0 dfs_offload 0 : disable DFS offload - -cloud_keep_alive - This command is used to start/stop send keep alive packet which set from host.And reset TCP connection. - - Usage: - mlanutl mlanX cloud_keep_alive - - where - start means set cloud keep alive packet and paramters to firmware. stop means stop firmware from sending keep alive packet.reset will stop and reset TCP connection when host resume. - - Examples: - mlanutl mlan0 cloud_keep_alive keep_alive.conf start - mlanutl mlan0 cloud_keep_alive keep_alive.conf stop - mlanutl mlan0 cloud_keep_alive keep_alive.conf reset - -bandcfg - This command is used to set/get infra/ad-hoc band. - Note: This command is only available in disconnected state. - - Usage: - mlanutl mlanX bandcfg [l] [m] [n] - - where the parameters: - [l]: Infrastructure band - bit 0: B - bit 1: G - bit 2: A - bit 3: GN - bit 4: AN - - bit 5: AC 2.4G - bit 6: AC 5G - bit 8: AX 2.4G - bit 9: AX 5G - [m]: Ad-hoc start band - bit 0: B - bit 1: G - bit 2: A - [n]: Ad-hoc start channel - Examples: - mlanutl mlan0 bandcfg : Get infra/ad-hoc band and ad-hoc - start channel configurations - mlanutl mlan0 bandcfg 1 : Set infra band to B only - mlanutl mlan0 bandcfg 3 2 6 : Set infra band to B/G, ad-hoc start band - to G and ad-hoc start channel to 6 - -bcninterval - This command is used to set/get the beacon interval in ad-hoc mode. - The valid beacon interval is between 20 - 1000, default beacon - interval is 100. - - Where - Beacon interval in TU (Time Unit: 1024 us). - - Examples: - mlanutl mlan0 bcninterval 200 : Set ad-hoc beacon interval to 200 - mlanutl mlan0 bcninterval : Get ad-hoc beacon interval - -bssrole - This command is used to set/get the BSS role. - - Where - [l] is - - This parameter specifies the BSS role to set. - 0 : STA - 1 : uAP - - Examples: - mlanutl wfd0 bssrole : Get the current BSS role - mlanutl wfd0 bssrole 1 : Set the current BSS role to uAP - -cfgdata - This command is used to set/get the configuration data to/from firmware. - - Usage: - mlanutl mlanX cfgdata [<.conf file name>] - - Where the parameters are: - type : - 2 -- CAL data download and <.conf file name> is cal_data.conf - .conf file name : The configuration file used to set/get the configuration data. - - Examples: - mlanutl mlan0 cfgdata 2 - : This command is used to get and display the CAL data from firmware. - -cfpcode - This command is used to set/get the Channel-Frequency-Power table codes. - The region table can be selected through region code. - The current configuration is returned if no parameter provided. - - where the parameters are, - [m]: code of the CFP table for 2.4GHz (0: unchanged) - [n]: code of the CFP table for 5GHz (0 or not provided: unchanged) - - Examples: - mlanutl mlan0 cfpcode : Get current configuration - mlanutl mlan0 cfpcode 0x30 : Set 2.4GHz CFP table code 0x30 (EU), - keep 5GHz table unchanged - mlanutl mlan0 cfpcode 0x10 5 : Set 2.4GHz CFP table code 0x10 (USA) - and 5GHz table code 5 - -changraph - Displays 2-dimensional graph, plotting channel number along x-axis and - anpi or channel-load along y-axis, depending on whether it is an anpi graph - or a channel load graph. - - Usage: - mlanutl mlanX changraph [ ] - where: - load: Only channel vs channel-load graph is displayed - anpi: Only channel vs Average Noise Power Indicator(ANPI) - graph is displayed - anpiload: Both the graphs for anpi and for the load are displayed - loops: This is used to calculate the number of times - the graph [load or anpi or both] will be printed - -coex_rx_winsize - This command is used to set/get control to coex RX window size - - where value of m is: - 0 -- Disable COEX RX winsize (default) - 1 -- Enable COEX RX winsize - - Examples: - mlanutl mlan0 coex_rx_winsize : Get COEX RX winsize - mlanutl mlan0 coex_rx_winsize 1 : Enable COEX RX winsize - -countrycode - This command is used to set and get the country code. - - Where - [l] is Country code - - Examples: - mlanutl mlan0 countrycode : Get current countrycode - mlanutl mlan0 countrycode CN : Set countrycode as China (CN) - -cfpinfo - This command is used to get region, country, environment codes, - channel and power table information from the FW. - - Examples: - mlanutl mlan0 cfpinfo : Display cfp tables - mlanutl uap0 cfpinfo - -customie - This command is used to set or get custom IEs for management frames. - - Usage: - mlanutl mlanX customie [[[] ] ] - - Where the parameter is: - empty - Get all IE settings - : 0 - Get/Set IE index 0 setting - 1 - Get/Set IE index 1 setting - 2 - Get/Set IE index 2 setting - MAX IE Index depends on device memory. - -1 - Append/Delete IE automatically - Delete will delete the IE from the matching IE buffer - Append will append the IE to the buffer with the same mask - : Management subtype mask value as per bit definitions - : Bit 0 - Association request - : Bit 1 - Association response - : Bit 2 - Reassociation request - : Bit 3 - Reassociation response - : Bit 4 - Probe request - : Bit 5 - Probe response - : Bit 8 - Beacon - : mask = 0 to clear the mask and the IE buffer - : IE Buffer in hex (max 256 bytes) - The Buffer should not be space separated. - - Examples: - mlanutl mlan0 customie - : Get IE buffer, subtype mask settings for all indices. - - mlanutl mlan0 customie 1 - : Get IE buffer and subtype mask for the Index = 1. - - mlanutl mlan0 customie 2 0 - : Clear IE buffer and mask value for Index = 2. - - mlanutl mlan0 customie 3 0x101 0xdd051234567890 - : Set IE buffer and mask value for Index = 3. - - mlanutl mlan0 customie -1 0x101 0xdd051234567890 - : Append the specified IEBuffer at index with mask value of 0x101. - - mlanutl mlan0 customie -1 0 0xdd051234567890 - : Delete the specified IEBuffer from all the IEs. - - mlanutl mlan0 customie 2 0 0xdd051234567890 - : Delete the specified IEBuffer from the IEs at index 2. - -deauth - This command is used to send a de-authentication to an arbitrary AP. - If [l] is omitted, the driver will deauth the associated AP. - If in ad-hoc mode this command is used to stop beacon transmission - from the station and go into idle state. - - When is supplied as a MAC address, the driver will deauth the - specified AP. If the AP address matches the driver's associated AP, - the driver will disconnect. Otherwise, the driver remains connected. - - When this command is executed on AP interface, it is used to send - a de-authentication to associated station. - -deepsleep - This command is used to set/get auto deep sleep mode. - - Usage: - mlanutl mlanX deepsleep [l] [m] - - where the parameters are: - [l]: Enable/disable auto deep sleep mode (1/0) - [m]: Idle time in milliseconds after which firmware will put the device - in deep sleep mode. Default value is 100 ms. - - Examples: - mlanutl mlan0 deepsleep : Display auto deep sleep mode - mlanutl mlan0 deepsleep 1 : Enable auto deep sleep mode, idle time unchanged - mlanutl mlan0 deepsleep 0 : Disable auto deep sleep mode - mlanutl mlan0 deepsleep 1 500 : Enable auto deep sleep mode with idle time 500 ms - Note: - Deepsleep must be disabled before changing idle time. - -delba - This command is used to delete either all Tx BA or all Rx BA or a specific BA stream - based on direction, TID and peer address. - - where [ ] - - This is the direction of BA stream, Tx (bit 0), Rx (bit 1). - - This is the TID (0-7, 0xff for all) of BA stream. - - This is the peer MAC addres of BA stream. - - eg: - mlanutl mlanX delba 2 - This command will delete all the Rx BA streams. - mlanutl mlanX delba 3 - This command will delete all the Tx and Rx BA streams. - mlanutl mlanX delba 1 0 - This command will delete all the Tx streams with TID 0. - mlanutl mlanX delba 2 0xff "00:11:22:33:44:55" - This command will delete all the Rx BA streams - with specified peer MAC address - mlanutl mlanX delba 1 3 "00:11:22:33:44:55" - This command will delete the Tx BA stream with - TID 3 and specified peer MAC address. - -delts - Send a DELTS command to the associated AP. - - Process a given conf file for a specific TSPEC data block. Send the - TSPEC along with any other IEs to the driver/firmware for transmission - in a DELTS request to the associated AP. - - Return the execution status of the command. There is no response to a - DELTS from the AP. - - Usage: - mlanutl mlanX delts - -dfstesting - This command is used to set/get settings for DFS testing. - - Usage: - mlanutl mlanX dfstesting [ ] - - where is user-configured Channel Availability Check in msec - 0 = disable, use default period (60000) - 1-65535 = enable with that period - where is user-configured Non-Occupancy Period in sec - 0 = disable, use default period (1800) - 1-65535 = enable with that period - where is enable/disable no channel change on radar - 0 = disable, 1 = enable (overrides below) - where is user-configured channel to change to on radar - 0 = disable, 1-255 = enable with that channel - (channel validity for region, etc. is not checked) - (only takes effect if no_chan_change = 0) - - Examples: - mlanutl mlan0 dfstesting : Get current dfstesting settings - mlanutl mlan0 dfstesting 2000 0 0 0 : user_cac=2sec, others disabled/default - mlanutl mlan0 dfstesting 0 0 1 0 : only no_chan_change enabled - mlanutl mlan0 dfstesting 0 120 0 64 : user_nop=2min, force chan 64 on radar - -dfs_repeater - This command is used to get/set DFS Repeater mode. - - Usage: - mlanutl mlan0 dfs_repeater - - where the parameter is : - null: to get current setting - 1: to enable dfs_repeater mode - 0: to disable dfs_repeater mode - - eg., - mlanutl mlan0 dfs_repeater :get current setting - mlanutl mlan0 dfs_repeater 1 :enable dfs repeater mode - mlanutl mlan0 dfs_repeater 0 :disable dfs repeater mode +version + This is used to get the current version of the driver and the firmware. drvdbg This command is used to set/get the bit masks of driver debug message control. @@ -1312,75 +494,17 @@ drvdbg MCMND, MEVENT and MCMD_D messages mlanutl mlan0 drvdbg -1 : Enable all the debug messages -esuppmode - This command is used to set/get the e-supplicant mode configurations/status. - - Note: The configurations can be set only before association. - For get, the configurations will be returned before association - and the current status will be returned after association. - - Where - [l] is - - This parameter specifies the RSN mode configuration - Bit 0 : No RSN - Bit 1-2 : RFU - Bit 3 : WPA - Bit 4 : WPA-NONE - Bit 5 : WPA2 - Bit 6-15 : RFU - [m] is - - This parameter specifies the pairwise cipher - Bit 0 : RFU - Bit 1 : RFU - Bit 2 : TKIP - Bit 3 : AES - Bit 4-7 : RFU - [n] is - - This parameter specifies the group cipher - Bit 0 : RFU - Bit 1 : RFU - Bit 2 : TKIP - Bit 3 : AES - Bit 4-7 : RFU - Note that: the RFU bits cannot be SET. - - Examples: - mlanutl mlan0 esuppmode : Get RSN mode and pairwise/group cipher - mlanutl mlan0 esuppmode 8 4 4 : Set RSN mode yo WPA, active pairwise and - group ciphers to TKIP - -extcapcfg - This command is used to set/get extended capabilities. +hostcmd generate_raw + This command is used to generate the raw data(hostcommand block) for + hostcommand in and write that to file Usage: - mlanutl mlanX extcapcfg [] - - where : Extended capabilities in hex (max 9 bytes) - The Buffer should not be space separated. - - Examples: - mlanutl mlan0 extcapcfg 0x0000008020 : Set TDLS support and Interworking bits. - -fwmacaddr - This command is used to set/get FW side MAC address but host side address will remain as earlier. - - Usage: - mlanutl mlanX fwmacaddr [mac_addr] - - where is desired MAC address - - Examples: - mlanutl mlan0 fwmacaddr : Get current FW MAC address - mlanutl mlan0 fwmacaddr 00:50:43:20:bc:44 : Set FW side MAC address + mlanutl mlanX hostcmd generate_raw getdatarate This command is used to get the data rate being used in last Tx packet and last Rx packet. -getkey - This command is used to get PTK/GTK - mlanutl mlanX getkey - getlog This command is used to get the statistics available in the station. Following stats are displayed:- @@ -1498,95 +622,6 @@ getlog dot11AMPDUDelimiterCRCErrorCount Increments when an MPDU delimiter has a CRC error when this is the first CRC error in the received A-MPDU or when the previous delimiter has been decoded correctly -per_pkt_cfg --------------- - mlanutl per_pkt_cfg [tx_rx_control] [type_num] [ether_type1 ether_type2...] [tx_rx_control] [type_num] [ether_type1 ether_type2 ...] - This command is used to set tx/rx per packet Txctl and Rxinfo configuration. - - The supported options are: - tx_rx_control : - 0 - disable Tx and Rx per packet control - 1 - enable Tx per packet control - 2 - enable Rx Per packet control - 3 - enable Tx and Rx Per packet control - - type_num : Number of ether_types which support per packet control, the Max is 8. - ether_type : Array of ether_types for which need to do per-packet Tx control or get per-packet Rx info. - - Examples: - mlanutl mlan0/uap0 per_pkt_cfg : get the configuration of per-packet control - mlanutl mlan0/uap0 per_pkt_cfg 0 : disable per-packet control - mlanutl mlan0/uap0 per_pkt_cfg 3 1 0x88dc : set the Tx and Rx per-packet control configuration - -dot11_txrx - This command is used to send or receive packets. - - Usage: - mlanutl dot11_txrx - interface : mlanX or uapX - options send : - conf_file : config file name - options recv : [ verbose_mode ] - protocol : packet protocol type - verbose_mode : v -- enter verbose mode - - Example: - mlanutl mlan0 dot11_txrx send config/tx_ctrl.conf : To send packets - mlanutl mlan0 dot11_txrx recv 0x88dc : To receive packets of type 0x88dc - mlanutl mlan0 dot11_txrx recv 0x88dc v : To receive packets of type 0x88dc and - enter verbose mode - -txrxhistogram --------------- - mlanutl mlanX/uapX txrxhistogram [action] [tx_rx_statics] - This command is used to get tx/rx statics from firmware. - - This command takes 2 conditions. - The supported options are: - action : 0 - disable Tx/Rx statics - 1 - enable Tx/Rx statics - 2 - get Tx/Rx statics - tx_rx_statics: 1 - enable/disable/get Tx statics - 2 - enable/disable/get Rx statics - 3 - enable/disable/get Tx and Rx statics - Examples: - mlanutl mlan0/uap0 txrxhistogram 1 3 : enable Tx and Rx statics - mlanutl mlna0/uap0 txrxhistogram 0 3 : disable Tx and Rx statics - mlanutl mlan0/uap0 txrxhistogram 2 2 : Get only Rx statics - mlnautl mlan0/uap0 txrxhistogram 2 1 : Get only Tx statics - mlnautl mlan0/uap0 txrxhistogram 2 3 : Get both Tx/Rx statics - -getscantable - Display the current contents of the driver scan table - - Usage: - mlanutl mlanX getscantable - mlanutl mlanX getscantable [#] - mlanutl mlanX getscantable tsf - mlanutl mlanX getscantable ch - mlanutl mlanX getscantable help - - 1) Without argument, the entire scantable is displayed in terms of channel (ch), signal strength (ss), BSS id (bssid), capability (cap), and SSID, - where each column in the capability is described as follows: - column 1 indicates the IBSS capability: A (Adhoc), I (Infra) - column 2 indicates the encryption capability: P (WEP), W (WPA), 2 (WPA2) - column 3 indicates the 11D capability: D (11D) - column 4 indicates the WMM capability: W (WMM), C (CAC) - column 5 indicates the 11K capability: K (11K) - column 6 indicates the 11R capability: R (11R) - column 7 indicates the WPS capability: S (WPS) - column 8 indicates the 11N/11AC capability: N (11N), A (11AC) - - 2) Specifying a # will display detailed information about a specific scan - table entry. '0' displays driver cached information regarding the - current association (if any). - 3) The tsf argument will display the entire scan table with the recorded - TSF timestamp for the entry. - 4) The ch argument will display the entire scan table sorted by channel - number in the ascending order. If this argument is not specified, - scan table is sorted by signal strength in the descending order. - 6) The help argument will display the legend for the capability field. - getsignal This command gets the last and average value of RSSI, SNR and NF of Beacon and Data. @@ -1670,1642 +705,124 @@ getsignalextv2 SNR info: beacon last 65, beacon average 45, data last 39, data average 42 NF info: beacon last -111, beacon average -91, data last -88, data average -91 -getstalist - This command is used to get list of associated stations to the AP. - - Example: - mlanutl uap0 getstalist - -channel_switch - This command is used to do channel switch according to spec. - - Where the paramters are: - switch mode : 0 -- no need to block traffic, 1 -- need block traffic - oper class : operating class according to IEEE std802.11 spec, when 0 is used, only CSA IE will be used - new channel : the channel will switch to - switch count: channel switch time to send ECSA ie - bandwidth : channel width switch to(optional),only for 5G channels. - Support value 1 -- 40M above, 3 -- 40M below, 4 -- 80M, 5 -- 160M - - Example: - mlanutl uap0 channel_switch 1 115 36 10 :switch to channel 36, oper class 115 - mlanutl uap0 channel_switch 1 81 6 10 :switch to channel 6, oper class 81 - mlanutl uap0 channel_switch 1 0 6 10 :switch to channel 6 - mlanutl uap0 channel_switch 1 0 36 10 1 :switch to channel 36, bandwidth 40MHz above - -hostcmd 2040coex - This command is used to send the 11n 20/40 Coex command to firmware. - Firmware will send 11n 20/40 Coex management action frame to AP. - - Usage: - mlanutl mlanX hostcmd config/11n_2040coex.conf 2040coex - -hostcmd auto_tx_get -hostcmd auto_tx_unreg - This command is used to configures the Frame Auto Transmission parameters. - auto_tx_get: get auto_tx parameters - auto_tx_unreg: unregister to firmware auto_tx - - Usage: - mlanutl mlanX hostcmd config/auto_tx.conf auto_tx_get - mlanutl mlanX hostcmd config/auto_tx.conf auto_tx_unreg - -hostcmd bgscfg - This command is used to configure the various parameters for PPS/UAPSD - or normal background scan. - - Usage: - mlanutl mlanX hostcmd config/bg_scan.conf bgscfg - -hostcmd coalesce_cfg - This command is used to set/clear rules to filter and buffer - broadcast/multicast packet which reduce unwanted patcket or interrupt to - host. - - Usage: - mlanutl mlanX hostcmd coalesce_cfg - -hostcmd ed_mac_ctrl - This command is used to control ED MAC. - - Usage: - mlanutl mlanX hostcmd ed_mac_ctrl - -hostcmd crypto_test - This command is used to test the encryption/decryption API of the firmware. - - Usage: - mlanutl mlanX hostcmd config/crypto_test.conf crypto_test - -hostcmd nat_keep_alive - This command is used to configures the Frame Auto Transmission parameters. - nat_keep_alive: register to firmware for sending NAT Keep Alive packet - - Usage: - mlanutl mlanX hostcmd config/auto_tx.conf nat_keep_alive - -hostcmd pad_cfg_get -hostcmd pad_cfg_set - This command is used to set/get the configuration data for PAD OR. - - Usage: - mlanutl mlanX hostcmd config/pad_cfg.conf pad_cfg_get - mlanutl mlanX hostcmd config/pad_cfg.conf pad_cfg_set - -hostcmd requesttpc - This command is used to request 802.11H TPC info. - - Usage: - mlanutl mlanX hostcmd config/requesttpc.conf requesttpc - -hostcmd mode_get -hostcmd mode_timeshare -hostcmd mode_spatial -hostcmd mode_none - This command is used to get/set Robust BT Coex. - mode_get: get the current mode - mode_timeshare: set Robust BT Coex to timeshare mode (default on 1x1 chips) - mode_spatial: set Robust BT Coex to spatial mode (only for, and default on 2x2 chips) - mode_none: set Robust BT Coex to mode none (only for, and default on 2x2_3Antenna chips) - - Usage: - mlanutl mlanX hostcmd config/robust_btc.conf mode_get - mlanutl mlanX hostcmd config/robust_btc.conf mode_timeshare - mlanutl mlanX hostcmd config/robust_btc.conf mode_spatial - mlanutl mlanX hostcmd config/robust_btc.conf mode_none - -hostcmd gpio_cfg - This command is used to enable/disable GPIO cfg. - gpio_cfg: enable/disable GPIO cfg for external bt request (default is enable with High Polarity) - - Usage: - mlanutl mlanX hostcmd config/robust_btc.conf gpio_cfg -hostcmd generictime -hostcmd a2dptime -hostcmd inquirytime -hostcmd ap_generictime -hostcmd ap_a2dptime -hostcmd ap_inquirytime - This command is used to configure the time slice of COEX (only works in timeshare mode) - generictime: configure the Bttime and Wlantime in Station Generic case - a2dptime: configure the Bttime and Wlantime in Station A2DP case - inquirytime: configure the Bttime and Wlantime in Station Inquiry case - ap_generictime: configure the Bttime and Wlantime in Ap Generic case - ap_a2dptime: configure the Bttime and Wlantime in Ap A2DP case - ap_inquirytime: configure the Bttime and Wlantime in Ap Inquiry case - - Usage: - mlanutl mlanX hostcmd config/robust_btc.conf generictime - mlanutl mlanX hostcmd config/robust_btc.conf a2dptime - mlanutl mlanX hostcmd config/robust_btc.conf inquirytim - mlanutl mlanX hostcmd config/robust_btc.conf ap_generictime - mlanutl mlanX hostcmd config/robust_btc.conf ap_a2dptime - mlanutl mlanX hostcmd config/robust_btc.conf ap_inquirytime - -hostcmd sdio_pulldown_get -hostcmd sdio_pulldown_set -hostcmd sdio_pulldown_disable - This command is used to set/get the settings of pulling up and - pulling down of SDIO lines. - - Usage: - mlanutl mlanX hostcmd config/sdio_pulldown.conf sdio_pulldown_get - mlanutl mlanX hostcmd config/sdio_pulldown.conf sdio_pulldown_set - mlanutl mlanX hostcmd config/sdio_pulldown.conf sdio_pulldown_disable - -hostcmd subevent_get -hostcmd subevent_set - This command is used to get/set the configurations for event descriptor - interface command. - subsvent_get: get subscribed event parameters - subsvent_set: set subscribed event parameters - - Usage: - mlanutl mlanX hostcmd config/subevent.conf subevent_get - mlanutl mlanX hostcmd config/subevent.conf subevent_set - -hostcmd txpwrlimit_2g_cfg_set -hostcmd txpwrlimit_5g_cfg_set -hostcmd txpwrlimit_cfg_get - This command is used to set/get the configuration data of Tx power limitation. - Note: The configuration set should be issued when STA is disconnected. - - Usage: - mlanutl mlanX hostcmd config/txpwrlimit_cfg.conf txpwrlimit_cfg_get - mlanutl mlanX hostcmd config/txpwrlimit_cfg.conf txpwrlimit_2g_cfg_set - mlanutl mlanX hostcmd config/txpwrlimit_cfg.conf txpwrlimit_5g_cfg_set - -hostcmd txrate_cfg_get -hostcmd txrate_cfg_set_bg -hostcmd txrate_cfg_set_bgn - This command is used to set/get the transmit data rate. - - Usage: - mlanutl mlanX hostcmd config/txrate_cfg.conf txrate_cfg_get - mlanutl mlanX hostcmd config/txrate_cfg.conf txrate_cfg_set_bg - mlanutl mlanX hostcmd config/txrate_cfg.conf txrate_cfg_set_bgn - -hostcmd generate_raw - This command is used to generate the raw data(hostcommand block) for - hostcommand in and write that to file - - Usage: - mlanutl mlanX hostcmd generate_raw - -hostcmd fwdump - This command is used to trigger firmware dump - - Usage: - mlanutl mlanX hostcmd fwdump - -hostcmd stop_su -hostcmd start_su - This command is used to set/get 11ax related setting - stop_su: stop su - start_su: resume su - stop_forceRTS: stop force Tx RTS - start_forceRTS: start force Tx RTS - Usage: - mlanutl mlanX hostcmd config/debug.conf stop_su - mlanutl mlanX hostcmd config/debug.conf start_su - mlanutl mlanX hostcmd config/debug.conf stop_forceRTS - mlanutl mlanX hostcmd config/debug.conf start_forceRTS - -hotspotcfg - This command is used to get/set the HotSpot configuration. - - Usage: - mlanutl mlanX hotspotcfg [] - - Where the parameter is: - : configuration bitset - : Bit 31-10 - Reserved set to 0 - : Bit 9 - TDLS support indication enable/disable - : Bit 8 - Interworking indication enable/disable - : Bit 7-1 - Reserved set to 0 - : Bit 0 - HotSpot feature enable/disable - - Examples: - mlanutl mlan0 hotspotcfg : Get present remote address mode - mlanutl mlan0 hotspotcfg 0x301 : Turn on HotSpot2.0 and enable TDLS support and interworking indication - mlanutl mlan0 hotspotcfg 0 : Turn off HotSpot2.0 and disable TDLS support and interworking indication - -hscfg - This command is used to configure the host sleep parameters. - Please note hssetpara and usbsuspend/usbresume commands should be used for USB - host sleep related tests. - - Usage: - mlanutl mlanX hscfg [condition [[GPIO# [gap]]]] (optional)[type ind_GPIO# [level]] (optional)[type event_force_ignore event_use_ext_gap ext_gap [gpio_wave]] - - This command takes one (condition), two (condition and GPIO#) or three - (condition, GPIO# and gap). If more than three parameters, it can set different or multiple features indicating by type(this is optional): - - If type=1, it will set indication gpio and its level. And the parameter format will be (condition, GPIO#,gap and type,ind_GPIO#) or - (condition, GPIO#, gap, type, ind_GPIO# and level). - - If type=2, it will set extend hscfg wakup method. And the parameter format will be (condition, GPIO#, gap, type, force_ignore, - use_ext_gap, ext_gap [gpio_wave]). gpio_wave parameter is optional and default value is 0(falling edge). Each bit of - event_force_ignore and event_use_ext_gap will be defined to one same event, and set one same event(same bit) in those two - parameters is not allowed. Set bit(s) in event_force_ignore means the event(s) will be forced ignore in firmware silently. - Set bit(s) in event_use_ext_gap mean the event(s) will use extend gap to inform host. Not set means not handle. - - If type=3, it will set hs_wakeup_interval. - - If no parameter provided, get is performed. - - The usages of parameters for "hscfg" are the same as that for "hssetpara" command. - -hssetpara - This command is used to set host sleep parameters. - - Usage: - mlanutl mlanX hssetpara condition [GPIO# [gap]] (optional)[type ind_GPIO# [level]] (optional)[type event_force_ignore event_use_ext_gap ext_gap [gpio_wave]] (optional)[type hs_wakeup_interval] - - This command takes one (condition), two (condition and GPIO#) or three - (condition, GPIO# and gap).If more than three parameters, it can set different or multiple features indicating by type and - the detailed usage is the same as hscfg above. - - where Condition is: - bit 0 = 1 -- broadcast data - bit 1 = 1 -- unicast data - bit 2 = 1 -- mac event - bit 3 = 1 -- multicast data - bit 6 = 1 -- Wakeup when mgmt frame received. - Bit 31 = 1 -- Don't wakeup when IPV6 packet received. - - The host sleep mode will be canceled if condition is set to -1. The default is 0x7. - - where GPIO is the pin number of GPIO used to wakeup the host. It could be any valid - GPIO pin# (e.g. 0-7) or 0xff (interface, e.g. SDIO will be used instead). - The default is 0xff. - - where Gap is the gap in milliseconds between wakeup signal and wakeup event or 0xff - for special setting (host acknowledge required) when GPIO is used to wakeup host. - The default is 200. - - The host sleep set except for cancellation will be blocked if host sleep is - already activated. - - where ind_GPIO# is the pin number of GPIO used to indicate wakeup source. The level on - this GPIO will indicate normal wakeup source or abnormal wakeup source. - - where level is used to set level(0/1) on ind_GPIO# pin for indication normal wakeup source. - The opposite level will indicate abnormal wakeup source. The default value is 0. - - where event_force_ignore is a bitmap,each bit represent one wakeup reason event. Set the bit means this - wakeup reason should be force ignored in firmware. Reset the bit means do not handle this reason. - - where event_use_ext_gap is a bitmap, each bit represent one wakeup reason event. Set the bit means this - wakeup reason should use ext_gap to indicate host. Reset the bit means do not handle this reason. - - where event_force_ignore and event_use_ext_gap have the same wakeup reason event definition of each bit: - bit 0 = 1 --Disconnect - bit 1 = 1 --GTK/iGTK rekey failure - bit 2 = 1 --Eapol - other bits --Reserved - They should not set both for one same wakeup reason. - - where ext_gap is the extend gap based on third parameter Gap. Only valid when use_ext_gap is used. - The total gap is (Gap + (x+1)*ext_gap). x means the bit number(start from 0) of this reason in use_ext_gap. - - where gpio_wave is used to set GPIO wave level for hscfg extend. 0 means falling edge, 1 means rising edge. - This parameter is optional and default value is 0. - - where hs_wakeup_interval is used to set host sleep wakeup interval and the type must set to 3 to indicate - this feature. And the value will round to the nearest multiple dtim*beacon_interval in fw. The unit is milliseconds. - - Examples: - mlanutl mlan0 hssetpara -1 : Cancel host sleep mode - mlanutl mlan0 hssetpara 3 : Broadcast and unicast data - Use GPIO and gap set previously - mlanutl mlan0 hssetpara 2 3 : Unicast data - Use GPIO 3 and gap set previously - mlanutl mlan0 hssetpara 2 1 0xa0 : Unicast data - Use GPIO 1 and gap 160 ms - mlanutl mlan0 hssetpara 2 0xff : Unicast data - Use interface (e.g. SDIO) - Use gap set previously - mlanutl mlan0 hssetpara 4 3 0xff : MAC event - Use GPIO 3 - Special host sleep mode - mlanutl mlan0 hssetpara 1 0xff 0xff : Broadcast data - - mlanutl mlan0 hssetpara 2 1 0xa0 1 5 1 : Unicast data - Use GPIO 1 - Gap 160 ms - type=1 to set indication GPIO feature - Use GPIO 5 to indicate wakeup source - High level on GPIO 5 means this is a normal wakeup - mlanutl mlan0 hssetpara 2 1 0xa0 1 5 : Unicast data - Use GPIO 1 - Gap 160 ms - type=1 to set indication GPIO feature - Use GPIO 5 to indicate wakeup source - Use level set previously. - - mlanutl mlan0 hssetpara 2 1 0xa0 2 0 0x1 10 1: Unicast data - Use GPIO 1 - Gap 160 ms - type=2 to set extend hscfg feature - Force_ignore not used - Disconnect will use extend gap to indicate host - Use gap 170. - Rising edge - mlanutl mlan0 hssetpara 2 1 0xa0 2 0x1 0 0 0: Unicast data - Use GPIO 1 - Gap 160 ms - type=2 to set extend hscfg feature - Falling edge - Force ignore Disconnect - Extend gap not used - Not used. - Falling edge - mlanutl mlan0 hssetpara 2 1 0xa0 3 400: Unicast data - Use GPIO 1 - Gap 160 ms - type=3 to set hs_wakeup_interval feature - hs_wakeup_interval set to 400ms - - Note: The parameters will be saved in the driver and be used when host suspends. - The ind_GPIO# and level parameters only work with specific board and firmware. - -mgmtfilter - This command is used to set management frame to wake up host when host suspend. - - Usage: - mlanutl mlanX mgmtfilter - - where - This conf file will set management frame catagory, action and frame mask. - - Examples: - mlanutl mlan0 mgmtfilter mgmtfilter.conf - -auto_arp - This command is used to enable/disable auto arp response in host sleep mode. - No argument is used to get. - - where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - mlanutl mlan0 auto_arp 0 : Disable auto arp response from FW - mlanutl mlan0 auto_arp : Get auto arp configuration status - -htcapinfo - This command is used to configure some of parameters in HTCapInfo IE - (such as Short GI, Channel BW, and Green field support) - - where is - - This is a bitmap and should be used as following - Bit 29: Green field enable/disable - Bit 26: Rx STBC Support enable/disable. (As we support - single spatial stream only 1 bit is used for Rx STBC) - Bit 25: Tx STBC support enable/disable. - Bit 24: Short GI in 40 Mhz enable/disable - Bit 23: Short GI in 20 Mhz enable/disable - Bit 22: Rx LDPC enable/disable - Bit 17: 20/40 Mhz enable disable. - Bit 8: Enable/disable 40Mhz Intolarent bit in ht capinfo. - 0 will reset this bit and 1 will set this bit in - htcapinfo attached in assoc request. - All others are reserved and should be set to 0. - - Setting of any other bits will return error. - - where is - - This is the band info for settings. - 0: Settings for both 2.4G and 5G bands - 1: Settings for 2.4G band - 2: Settings for 5G band - - Example: - mlanutl mlanX htcapinfo - This will display HT capabilties information. - If the information for 2.4G and 5G is different, - the first value is for 2.4G and the second value is for 5G. - Otherwise, it will display a single value for both bands. - - mlanutl mlanX htcapinfo 0x1820000 - This will enable Short GI, Channel BW to 20/40 and disable Green field support for 2.4G and 5G band. - - mlanutl mlanX htcapinfo 0x800000 2 - This will enable Short GI, Channel BW to 20 only, No Rx STBC support and disable Green field support for 5G band. - - The default value is 0x4800000 for 2.4G and 0x5820000 for 5G. - - Note:- This command can be issued any time but it will only come to effect from - next association. (as HTCapInfo is sent only during Association). - -htstreamcfg - This command is used to set/get HT stream configuration. - The setting only takes effect in next association. - - Usage: - mlanutl mlanX htstreamcfg [n] - +get_txpwrlimit + This command is used to get the txpwrlimit table in FW +Usage: + mlanutl mlanX get_txpwrlimit [raw_data_file] where - 0x11: HT stream 1x1 mode - 0x22: HT stream 2x2 mode - - Examples: - mlanutl mlan0 htstreamcfg : Get current setting - mlanutl mlan0 htstreamcfg 0x11 : Set HT stream 1x1 mode - mlanutl mlan0 htstreamcfg 0x22 : Set HT stream 2x2 mode - -httxbfcap - This command is used to set/get the TX beamforming capabilities. - - Usage: - mlanutl mlanX httxbfcap [cap] - - where the parameters are, - cap: TX beamforming capabilities - Bit 0 : Implicit TX BF receiving capable - Bit 1 : RX staggered sounding capable - Bit 2 : TX staggered sounding capable - Bit 3 : RX NDP capable - Bit 4 : TX NDP capable - Bit 5 : Implicit TX BF capable - Bit 6-7 : Calibration - 0: - not supported - 1: - STA can respond to a calibration request using - the CSI Report, but cannot initiate calibration - 2: - reserved - 3: - STA can both initiate and respond to a calibration request - Bit 8 : Explicit CSI TX BF capable - Bit 9 : Explicit non-compressed steering capable - Bit 10 : Explicit compressed steering capable - Bit 11-12: Explicit TX BF CSI feedback - 0: - not supported - 1: - delayed feedback - 2: - immediate feedback - 3: - delayed and immediate feedback - Bit 13-14: Explicit non-compressed BF feedback capable - 0: - not supported - 1: - delayed feedback - 2: - immediate feedback - 3: - delayed and immediate feedback - Bit 15-16: Explicit compressed BF feedback capable - 0: - not supported - 1: - delayed feedback - 2: - immediate feedback - 3: - delayed and immediate feedback - Bit 17-18: Minimal grouping - 0: - no grouping (STA supports groups of 1) - 1: - groups of 1, 2 - 2: - groups of 1, 4 - 3: - groups of 1, 2, 4 - Bit 19-20: CSI number of beamformer antennas supported - 0: - single TX antenna sounding - 1: - 2 TX antenna sounding - 2: - 3 TX antenna sounding - 3: - 4 TX antenna sounding - Bit 21-22: Non-compressed steering number of beamformer antennas supported - 0: - single TX antenna sounding - 1: - 2 TX antenna sounding - 2: - 3 TX antenna sounding - 3: - 4 TX antenna sounding - Bit 23-24: Compressed steering number of beamformer antennas supported - 0: - single TX antenna sounding - 1: - 2 TX antenna sounding - 2: - 3 TX antenna sounding - 3: - 4 TX antenna sounding - Bit 25-26: CSI max number of rows beamformer supported - 0: - single row of CSI - 1: - 2 rows of CSI - 2: - 3 rows of CSI - 3: - 4 rows of CSI - Bit 27-28: Channel estimation capability - 0: - 1 space time stream - 1: - 2 space time streams - 2: - 3 space time streams - 3: - 4 space time streams - Bit 29-31: Reserved - - Examples: - mlanutl mlan0 httxbfcap : Get the current TX BF capabilities - mlanutl mlan0 httxbfcap 0x0000001F : Set the TX BF capabilities of the - Implicit TX BF receiving capable, - RX staggered sounding capable, - TX staggered sounding capable, - RX NDP capable and TX NDP capable - -httxbfcfg - This command is used to configure the TX beamforming options. - Note: Any new subcommand should be inserted in the second - argument and each argument of the sub command should be - separated by semicolon. For global configuration, the - arguments should be separated by space. - - Usage: - mlanutl mlanX httxbfcfg "[;GlobalData/tsData/interval/txPeerData/snrData/txSounding]" - - where the parameters are, - action: TX beamforming action - 0: Control global parameters for beamforming - 1: Performs NDP Sounding for PEER - 2: TX BF interval in milliseconds - 3: Enable/Disable beamforming/sounding for a particular peer - 4: TX BF SNR Threshold for peer - .. - GlobalData: Global parameter arguments. - It contains beamforming enable, sounding enable, FB type, snr_threshold - sounding interval, Beamformig mode values seperated by space. - Syntax: - mlanutl mlanX httxbfcfg ; - - tsData: Trigger sounding for PEER specific arguments, - it contains PEER MAC and status - interval: TX BF interval in milliseconds - txPeerData: Enable/Disable beamforming/sounding for the indicated peer, - it contains PEER MAC, sounding, beamfoming options and FB type; - snrData: TX BF SNR Threshold for peer, it contains PEER MAC and SNR - - Examples: - mlanutl mlan0 httxbfcfg "0" : Get current global configuration parameter - mlanutl mlan0 httxbfcfg "2;00:50:43:20:BF:64" : Get the TX BF periodicity for a given peer - mlanutl mlan0 httxbfcfg "3" : Get the list of MAC addresses that have - beamforming and/or sounding enabled - mlanutl mlan0 httxbfcfg "4" : Get the list of PEER MAC, SNR tuples - programmed into the firmware. - mlanutl mlan0 httxbfcfg "0;0 0 3 10 500 5" : Disable beamforming, sounding, set FB type - to 3, snr threshold to 10, sounding interval - to 500 ms and beamforming mode to 5 - mlanutl mlan0 httxbfcfg "1;00:50:43:20:BF:64" : Perform NDP Trigger sounding to peer - 00:50:43:20:BF:64 - mlanutl mlan0 httxbfcfg "2;00:50:43:20:BF:64;500" : Set TX BF periodicity for peer 00:50:43:20:BF:64 - to 500 milliseconds - mlanutl mlan0 httxbfcfg "3;00:50:43:20:BF:43;1;0;3" : Enable beamforming, disable sounding and set - FB type to 3 for peer 00:50:43:20:BF:43 - mlanutl mlan0 httxbfcfg "4;00:50:43:20:BF:24;43" : Set TX BF SNR threshold to peer - 00:50:43:20:BF:24 with SNR 43 - -httxcfg - This command is used to configure various 11n specific configuration - for transmit (such as Short GI, Channel BW and Green field support) - - where is - This is a bitmap and should be used as following - Bit 15-8: Reserved set to 0 - Bit 7: STBC enable/disable - Bit 6: Short GI in 40 Mhz enable/disable - Bit 5: Short GI in 20 Mhz enable/disable - Bit 4: Green field enable/disable - Bit 3-2: Reserved set to 1 - Bit 1: 20/40 Mhz enable disable. - Bit 0: LDPC enable/disable - - When Bit 1 is set then firmware could transmit in 20Mhz or 40Mhz based - on rate adaptation. When this bit is reset then firmware will only - transmit in 20Mhz. - - where is - - This is the band info for settings. - 0: Settings for both 2.4G and 5G bands - 1: Settings for 2.4G band - 2: Settings for 5G band - - Example: - mlanutl mlanX httxcfg - This will display HT Tx configuration for 2.4G and 5G band. - - mlanutl mlanX httxcfg 0x62 - This will enable 20/40 and Short GI but will disable Green field for 2.4G and 5G band. - - mlanutl mlanX httxcfg 0x30 1 - This will enable Short GI 20 Mhz and Green field for 2.4G band. - - The default value is 0x20 for 2.4G and 0x62 for 5G. - - Note:- If 20/40 MHz support is disabled in htcapinfo, device will not transmit - in 40 MHz even 20/40 MHz is enabled in httxcfg. - -inactivityto - This command is used to set/get the inactivity timeout value, which specifies - when WLAN device is put to sleep. - - Usage: - mlanutl mlanX inactivityto [k] - - where the parameter are: - : timeout unit in microseconds. - : Inactivity timeout for unicast data. - : Inactivity timeout for multicast data. - [k]: Inactivity timeout for new Rx traffic after PS notification to AP. - - Examples: - mlanutl mlan0 inactivityto : Get the timeout value - mlanutl mlan0 inactivityto 1000 2 3 : Set timeout unit to 1000 us (1 ms), - inactivity timeout for unicast data is 2 ms, - inactivity timeout for multicast data is 3 ms - -ipaddr - This command is used to set/get IP address. - - Usage: - mlanutl mlanX ipaddr [";"] - - where - 0: Remove the IP address - bit 1: Set IP address for auto broadcast ARP response - - Examples: - mlanutl mlan0 ipaddr : Get current settings - mlanutl mlan0 ipaddr "0" : Remove IP address - -linkstats - This command is used to get the link statistics from the firmware. - - Usage: - mlanutl mlanX linkstats - -listeninterval - This command is used to set/get listen interval in assoc request. - - Usage: - mlanutl mlanX listeninterval [l] - - where the parameter: - [l]: Value of listen interval [Default 10] - - Examples: - mlanutl mlan0 listeninterval : Display Listen interval - mlanutl mlan0 listeninterval 1 : Set Listen interval to 1. - -macctrl - This command is used to set/get MAC control. - It's recommended to read the current setting first to avoid override issue. - - Usage: - mlanutl mlanX macctrl [n] - - where - bit 0: Rx enabled - bit 1: Directed Filter enabled - bit 2: LoopBack enabled - bit 3: WEP enabled - bit 4: EthernetII enabled - bit 5: MultiCast enabled - bit 6: BroadCast enabled - bit 7: Promiscuous enabled - bit 8: All MultiCast enabled - bit 9: RTS/CTS enabled (0: CTS to self) - bit 10: Enforce Protection enabled - bit 11: Force 11N Protection enabled - bit 12: Rx 802.11 Packets enabled - bit 13: Ad-hoc g Protection enabled - bit 14: Reserved - bit 15: WEP Type - bit 16: BandWidth Indication in RTS enabled - bit 17: Dynamic BandWidth Indication Mode in RTS enabled - bit 18-31: Reserved - - Examples: - mlanutl mlan0 macctrl : Get current MAC control - mlanutl mlan0 macctrl 0x13 : Set Rx enabled and Directed Filter enabled and EthernetII enabled - mlanutl mlan0 macctrl 0x813 : Set Rx enabled and Directed Filter enabled and EthernetII enabled - Force 11N Protection enabled - -mefcfg - This command is used to set MEF settings. - - Usage: - mlanutl mlanX mefcfg - - Where the parameter is: - mef.conf : The configuration file specifying the MEF settings. - - Example: - mlanutl mlan0 mefcfg config/mef.conf - -memrdwr - This command is used to read/write the adapter memory. - - Usage: - mlanutl mlanX memrdwr

[value] - - where the parameters are, -
: memory address - [value]: value to be written - - Examples: - mlanutl mlan0 memrdwr 0x4cf70 : Read memory address 0x4cf70 - mlanutl mlan0 memrdwr 0x80000000 0xffffffff - : Write 0xffffffff to memory address 0x80000000 - -miracastcfg - This command is used to set/get the miracast configuration. - - Usage: - mlanutl mlanX miracastcfg [l] [m] [n] - - where the parameters are, - [l]: miracast mode - 0: Disable - 1: Source - 2: Sink - [m]: scan time per channel, in ms - [n]: gap during two scans, in ms - - Examples: - mlanutl mlan0 miracastcfg : Get miracast configuration - mlanutl mlan0 miracastcfg 0 : Disable miracast configuration - mlanutl mlan0 miracastcfg 1 20 40 : Set miracast mode as source, with scan time - 20ms per channel and gap during two scans 40ms - -mgmtframectrl - This command is used to set/get registered frame type to passthrough. - - Usage: - mlanutl mlanX mgmtframectrl [] - mlanutl uapX mgmtframectrl [] - - Where the parameter is: - : the bit mask of management frame reception. - : Bit 0 - Association Request - : Bit 1 - Association Response - : Bit 2 - Re-Association Request - : Bit 3 - Re-Association Response - : Bit 4 - Probe Request - : Bit 5 - Probe Response - : Bit 8 - Beacon Frames - : Bit 13 - Action Frames - - Examples: - mlanutl mlan0 mgmtframectrl : Get present mask - mlanutl mlan0 mgmtframectrl 0x0020 : Bit 5 is set, Forward probe response frames to application layer - -mgmtframetx - This command is used to send management frame. - - Usage: - mlanutl mlanX mgmtframetx - - Where the parameter is: - mgmt_frame.conf : The configuration file contains the management frame. - - Examples: - mlanutl mlan0 mgmtframetx config/mgmt_frame.conf - -mpactrl - This command is used to set/get the Tx, Rx SDIO aggregation parameters. - Note: The parameters can be set only in disconnected state. - - Usage: - mlanutl mlanX mpactrl [tx_ena] [rx_ena] [tx_size] [rx_size] [tx_ports] [rx_ports] - - where the parameter are: - [tx_ena]: Enable/disable (1/0) Tx MP-A - [rx_ena]: Enable/disable (1/0) Rx MP-A - [tx_size]: Size of Tx MP-A buffer - [rx_size]: Size of Rx MP-A buffer - [tx_ports]: Max ports (1-16) for Tx MP-A - [rx_ports]: Max ports (1-16) for Rx MP-A - default values are 1 1 16384 32768 16 16 - The MP-A may be disabled by default at build time if the MMC driver byte mode patch - is not available in kernel. - - Examples: - mlanutl mlan0 mpactrl : Get MP aggregation parameters - mlanutl mlan0 mpactrl 0 0 - : Disable MP aggregation for Tx, Rx respectively - mlanutl mlan0 mpactrl 1 1 8192 8192 8 8 - : Enable MP aggregation for Tx, Rx - : Set Tx, Rx buffer size to 8192 bytes - : Set maximum Tx, Rx ports to 8 - -offchannel - This command is used to set/cancel the offchannel configuration. - Note: This command only can be used when cfg80211 is enabled during load time. - - Usage: - mlanutl mlanX offchannel [ ] - - where - - 0 : Cancel the offchannel configuration - 1 : Set the offchannel configuration - - The channel to configure - - The duration for which to configure - : channel bandwidth - 0 - Bandwidth 20Mhz - 1 - HT Bandwidth 40Mhz sec channel above - 3 - HT Bandwidth 40Mhz sec channel below - 4 - VHT Bandwidth 80Mhz - - Examples: - mlanutl mlan0 offchannel : Get current offchannel status. - mlanutl mlan0 offchannel 0 : Cancel the offchannel configuration. - mlanutl mlan0 offchannel 1 3 5 : Configure channel 3 for 5 milliseconds. - mlanutl mlan0 offchannel 1 36 5000 : Configure channel 36 for 5000 milliseconds. - mlanutl mlan0 offchannel 1 64 500 4 : Configure channel 64 in 80MHz for 500 milliseconds. - -otpuserdata - This command is used to get the OTP user data. - - Where - is - - This parameter specifies the length of OTP user data to be read - - Examples: - mlanutl mlan0 otpuserdata 10 : Get the 10-byte OTP user data - -passphrase - This command is used to set/get passphrase for WPA-PSK/WPA2-PSK/WPA3-SAE mode. - - Where - ASCII string for ssid/passphrase/psk/sae_password. - - Setting psk for WPA3 SAE protocol is not possible, as new psk gets generated - everytime in protocol flow. - - 1) "0;" - This will get the passphrase, AKMP - for specified ssid, if none specified then it will get all. - - Example: - mlanutl mlan0 passphrase "0;ssid=nxp" - - 2) "1;; - " - Passphrase and psk cannot be provided for the same SSID. - This command takes only one SSID at a time, If ssid= is present it should contain - a passphrase or psk. If no arguments are provided then AKMP=802.1x, and passphrase - should be provided after association. - End of each parameter should be followed by a ';'(except for the last parameter) - as the delimiter. If ';' or '/' has to be used in an SSID then a '/' should be preceded - to ';' or '/' as a escape. - - Examples: - mlanutl mlan0 passphrase "1;ssid=nxpAP;passphrase=abcdefgd" - mlanutl mlan0 passphrase "1;ssid=nxp AP;psk=<64 bytes hexpsk>" - - If user wants to input the ssid as "nxp; AP" then command has to be - mlanutl mlan0 passphrase "1;ssid=nxp/; AP;passphrase=abcdefgh" - - If user wants to input the ssid as "//;" then command has to be - mlanutl mlan0 passphrase "1;ssid=/////;;passphrase=abcdefgh" - - 3) "2;" - This will clear the passphrase - for specified ssid, if none specified then it will clear all. - - Examples: - mlanutl mlan0 passphrase "2;ssid=nxp" - mlanutl mlan0 passphrase "2" : Clear all profiles and disable embedded supplicant - - 4)"1;ssid=;sae_password=" This will set WPA3 SAE ssid & password. sae_password should be within the range of 8 to 255 char. - Examples: - mlanutl mlan0 passphrase "1;ssid=nxp;sae_password=1234567890" - -pb_bypass - This command is used to get the By-passed TX packet from upper layer. - - Usage: - - mlanutl mlanX pb_bypass [data_1, data_2, ... data_n] - - where value of data_1, data_2, ... data_n isBypass TX Data - -pcieregrw - This command is used to read/write PCIE register. - - Usage: - mlanutl mlanX pcieregrw [value] - - where the parameters are, - : The offset of PCIE register - [value]: The value to write - - Examples: - mlanutl mlan0 pcieregrw 0x48 : Read PCIE register 0x48 - mlanutl mlan0 pcieregrw 0x44 8 : Write 8 to PCIE register 0x44 - -pciebar0regrw - This command is used to read/write PCIE register/memory from BAR0. - - Usage: - mlanutl mlanX pciebar0regrw [value] - - where the parameters are, - : The offset of PCIE register - [value]: The value to write - - Examples: - mlanutl mlan0 pciebar0regrw 0x48 : Read PCIE register 0x48 - mlanutl mlan0 pciebar0regrw 0x44 8 : Write 8 to PCIE register 0x44 - -pmfcfg - This command is used to set/get management frame protection parameters. - - Usage: - mlanutl mlanX pmfcfg - - where - : Management Frame Protection Capable (MFPC) - 1: Management Frame Protection Capable - 0: Management Frame Protection not Capable - : Management Frame Protection Required (MFPR) - 1: Management Frame Protection Required - 0: Management Frame Protection Optional - Default setting is PMF not capable. - m = 0, n = 1 is an invalid combination - - Examples: - mlanutl mlan0 pmfcfg : Get PMF parameters - mlanutl mlan0 pmfcfg 1 0 : Set MFPC and make MFPR optional - -port_ctrl - This command is used to Set/Get Port Control mode. No argument is used to get. - - where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - mlanutl mlan0 port_ctrl 1 : Enable Port Control mode - mlanutl mlan0 port_ctrl : Get Port Control mode status - -powercons - This command is used to set the local transmit power constraint. - Value is in dbm unit. This command is only used for ad-hoc start. - - Usage: - mlanutl mlanX powercons [n] - - Examples: - mlanutl mlanX powercons : get the current setting - mlanutl mlanX powercons 12 : set local power constraint to 12 dbm - -pscfg - This command is used to set/get PS configuration parameters. - - Usage: - mlanutl mlanX pscfg [k] [d] [l] ... - - Where the parameters: - [k]: Keep alive null packet interval (0: Unchanged, -1: Disable, n: Interval in seconds) - [d]: DTIM interval ( 0: Unchanged, - 1-5: Value, - 65534: DTIM will be ignored, listen interval will be used, - 65533: Closest DTIM to the listen interval period will be used ) - [l]: Local listen interval ( 0: Unchanged, - -1: Disable, - 1-49: Value in beacon intervals, - >= 50: Value in TUs ) - [b]: Beacon miss timeout (0: Unchanged, 1-50: Value in milliseconds, 65535: Disable) - [p]: Delay to PS (0-65535: Value in milliseconds, default 1000ms) - [m]: PS mode (0: Unchanged, 1: Auto mode, 2: PS-Poll mode, 3: PS Null mode) - No change if parameters are not provided. - - Examples: - mlanutl mlan0 pscfg : Get all the current PS configuration settings - mlanutl mlan0 pscfg 3 4 : Set PS keep alive null packet interval to 3 seconds - and DTIM interval to 4, all the other configurations - are unchanged - mlanutl mlan0 pscfg 0 0 0 0 50 2 : Set delay to PS to 50 ms and PS mode to PS-Poll mode, - keep the others unchanged - -bcntimeoutcfg - This command is used to set Beacon timeout parameters. - - Usage: - mlanutl mlanX bcntimeoutcfg [l] [m] [o] [p] - - Where the parameters: - [l]: Beacon miss timeout period Rx window (in ms) - [m]: Beacon miss timeout period (unit in beacon interval) - [o]: Beacon reacquire timeout period Rx window (unit in beacon interval) - [p]: Beacon reacquire timeout period (unit in beacon interval) - Please note that it would be better [m]+[p] not exceed 64. - Examples: - mlanutl mlan0 bcntimeoutcfg 10 30 2 30 : Set beacon timeout configure to - Beacon miss timeout period Rx window : 10 (ms) - Beacon miss timeout period : 30 (Beacon Interval) - Beacon reacquire timeout period Rx window : 2 (Beacon Interval) - Beacon reacquire timeout period : 30 (Beacon Interval) - -psmode - This command is used to set/get the IEEE PS mode configuration. - - Usage: - mlanutl mlanX psmode [l] - - where the parameter: - [l] - 0 : Disable IEEE PS mode - 1 : Enable IEEE PS mode - : Get IEEE PS mode - - Examples: - mlanutl mlan0 psmode : Get IEEE PS mode. - mlanutl mlan0 psmode 1 : Enable IEEE PS mode. - -qconfig - Send a WMM AC Queue configuration command to get/set/default params - - Configure or get the parameters of a WMM AC queue. The command takes - an optional Queue Id as a last parameter. Without the queue id, all - queues will be acted upon. - - Usage: - mlanutl mlanX qconfig def [Queue Id: 0-3] - mlanutl mlanX qconfig get [Queue Id: 0-3] - mlanutl mlanX qconfig set msdu [Queue Id: 0-3] - -qoscfg - This command sets WMM IE QOS info when an argument is given, and gets current WMM - IE QOS info when no argument is given. - - Examples: - mlanutl mlanX qoscfg 0x0f : Set WMM IE QOS info to 0x0f - mlanutl mlanX qoscfg : Get WMM IE QOS info - -qstatus - This command retrieves the current status of the WMM queues. If WMM - is enabled then it displays the information for each AC in a table. - - Usage: - mlanutl mlanX qstatus - -radioctrl - This command is used to turn on/off the radio. - Note: The radio can be disabled only in disconnected state. - - where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - mlanutl mlan0 radioctrl 1 : Turn the radio on - mlanutl mlan0 radioctrl : Get radio status - -rdeeprom - This command is used to read the EEPROM contents of the card. - - Usage: - mlanutl mlanX rdeeprom - - where the parameters are, - : multiples of 4 - : 4-20, multiples of 4 - - Example: - mlanutl mlan0 rdeeprom 0 20 : Read 20 bytes of EEPROM data from offset 0 - -reassoctrl - This command is used to turn on/off re-association in driver. - - Usage: - mlanutl mlanX reassoctrl [n] - - Where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - mlanutl mlan0 reassoctrl : Get re-association status - mlanutl mlan0 reassoctrl 1 : Turn re-association on - -regioncode - This command is used to set/get the region code in the station. - Note: This command should be issued at beginning before band/channel selection - and association. - - where value is 'region code' for various regions like - USA FCC, Canada IC, Europe ETSI, Japan ... - The special code (0xff) is used for Japan to support channel 1-14 in B/G/N mode. - - Examples: - mlanutl mlan0 regioncode : Get region code - mlanutl mlan0 regioncode 0x10 : Set region code to USA (0x10) - Note : in some case regioncode will be 0 after updated countycode or 80211d - i.e. mlanutl mlanX countrycode (CA, JP, CN, DE, ES AT, BR, RU) - or uaputl.exe sys_cfg_80211d state 1 country (CA, JP, CN, DE, ES AT, BR, RU) - Please use cfp instead of it. - -regrdwr - This command is used to read/write the adapter register. - - Usage: - mlanutl mlanX regrdwr [value] - - where the parameters are, - : 1:MAC/SOC, 2:BBP, 3:RF, 5:CAU, 6:PSU, 0x81:MAC2, 0x82:BBP2, 0x83: RF2 - : 1:MAC/SOC, 2:BBP, 3:RF, 5:CAU, 6:PSU - : offset of register - [value]: value to be written - Note: - BBP reg (type 2) 0xXZZZ: - X: 0=BBUD, 8=BBUA. - ZZZ: offset (0-0xFFF). - RF reg (type 3) 0xXYZZ: - - For 8887/8897/8777 - 1. If Y == 0, access RFU BASE Register. - X = Path ID (0=Path_A, 1=Path_B), ZZ = offset (0-0xFF). - 2. If Y != 0, access RFU XCVR Register on Path Y (1=Path_A, 2=Path_B). - X = Page # (0=Page_1, 1=Page_2, 2=Page_3 if chip support), ZZ: offset (0-0xFF). - For 8977/8997/8987 - X = Path ID (0-1) - Y = Page Number (0-6) in selected Path - ZZ = Register offset in selected path/page - - Examples: - mlanutl mlan0 regrdwr 1 0xa060 : Read the MAC register - mlanutl mlan0 regrdwr 1 0xa794 0x80000000 : Write 0x80000000 to MAC register - mlanutl mlan0 regrdwr 0x81 0xa060 :Read MAC2 register - -rejectaddbareq - This command is used to set/get the conditions of rejecting addba request. - - Usage: - mlanutl mlanX rejectaddbareq [conditions] - mlanutl uapX rejectaddbareq [conditions] - - Where conditions are: - bit 0 = 1 -- reject the addba request when host sleep activated - others -- reserved - - Examples: - mlanutl mlan0 rejectaddbareq : Get the reject addba request conditions - mlanutl mlan0 rejectaddbareq 0x1 : Reject the addba request - when host sleep activated - mlanutl uap0 rejectaddbareq 0x1 : Reject the addba request - when host sleep activated - -scancfg - This command is used to set/get scan configuration parameters. - - Usage: - mlanutl mlanX scancfg [t] [m] [p] [s] [a] [b] [c] [ext] [gap] - - where the parameters: - [t]: Scan Type (0: Unchanged, 1: Active, 2: Passive, default Active) - [m]: Scan Mode (0: Unchanged, 1: BSS, 2: IBSS, 3: Any, default Any) - [p]: Scan Probes (0: Unchanged, 1-5: Number of probes per channel, default 4) - [s]: Specific Scan Time (0: Unchanged, n: Value in ms, default 110 ms, max 500 ms) - [a]: Active Scan Time (0: Unchanged, n: Value in ms, default 200 ms, max 500 ms) - [b]: Passive Scan Time (0: Unchanged, n: Value in ms, default 200 ms, max 2000 ms) - [c]: Passive to Active Scan (0: Unchanged, 1: Enable, 2: Disable, default Enable) - [ext]: Extended scan (0: Unchanged, 1: Legacy scan, 2: Extended scan, 3: Extended scan enhance) - [gap]: Time gap between two scans in milliseconds (max value 500ms) - No change if the parameter is 0 or the parameter is not provided. - - Examples: - mlanutl mlan0 scancfg : Get all the current scan configuration settings - mlanutl mlan0 scancfg 1 3 : Set scan type to active and scan mode to any, - all the other scan configurations are unchanged - mlanutl mlan0 scancfg 0 1 2 200 : Set scan mode to BSS, number of probes to 2 and - specific scan time to 200 ms, all the other scan - configurations are unchanged - mlanutl mlan0 scancfg 0 0 0 0 0 0 1 : Set Passive to Active Scan to enable, all the - other scan configurations are unchanged - mlanutl mlan0 scancfg 2 0 0 0 0 0 2 : Set scan type to passive, Passive to Active - Scan to disable, all the other scan configurations - are unchanged - -sdcmd52rw - This command is used to read/write a controller register in - Secure Digital I/O Interfaces. - - Usage: - mlanutl mlanX sdcmd52rw [value] - - For SDIO MMC driver, only function 0 and 1 access is allowed. And there - is a limitation for function 0 write, only vendor specific CCCR registers - (0xf0 -0xff) are permiited. - - Examples: - mlanutl mlan0 sdcmd52rw 1 3 : Read SDIO function 1 register 3 - mlanutl mlan0 sdcmd52rw 1 1 0x3f : Write 0x3f to SDIO function 1 register 1 - -sdcmd53rw - This command is used to issue a CMD53 read/write data in - Secure Digital I/O Interfaces. - - Usage: - mlanutl mlanX sdcmd53rw
[data1] ... [dataN] - - where the parameters are, - : function number (0/1/2/..) -
: data address - : byte mode/block mode (0/1) - : block size (32/64/../512, NA for byte mode) - : block number or byte number - ... : data for write - - Note: The total data length is block size * block number for block mode - or byte number for byte mode. The max data length is 2000-byte. - For write the data pattern will be duplicated to data buffer. - - Examples: - mlanutl mlan0 sdcmd53rw 0 0x8000 1 0x40 2 - mlanutl mlan0 sdcmd53rw 1 0x10000 0 1 5 0x0a 0x0b 0x0c 0x0d 0x0e - -sdioclock - Turn On(1) or Off(0) the SDIO clock. - - Usage: - mlanutl mlanX sdioclock 1 (on) - mlanutl mlanX sdioclock 0 (off) - mlanutl mlanX sdioclock (get the current clock state) - - -setuserscan - Initiate a customized scan and retrieve the results - - Usage: - mlanutl mlanX setuserscan [ARGS] - - Where [ARGS]: - ssid="[SSID]" specify a SSID filter for the scan - group= specify the channel group(s) to scan - chan=[chan#][band][mode] where band is [a,b,g,n] and mode is - blank for unchange, or 'c' for active or 'p' for passive - bssid=xx:xx:xx:xx:xx:xx specify a BSSID filter for the scan - wc="[WILDCARD SSID]" specify a UNIX pattern matching filter (using * - and ?) for SSIDs found in a broadcast probe - keep=[0 or 1] keep the previous scan results (1), discard (0) - dur=[scan time] time to scan for each channel in milliseconds - gap=[gap time] Time gap between two scans in milliseconds - probes=[#] number of probe requests to send on each chan - for each broadcast probe required and each SSID - specific probe required (1-5) - bss_type=[1,2,3] BSS type: 1 (Infra), 2(Adhoc), 3(Any) - sort_by_ch Sort by channel number in ascending order. - Default mode: Sort by Signal Strength in descending order. - scan_type=[0,1] ext scan type (0-1) 0: legacy, 1: enhance scan - - Any combination of the above arguments can be supplied on the command line. - If the chan token is absent, a full channel scan will be completed by driver. - If the dur or probes tokens are absent, the driver default setting will be - used. The bssid and ssid fields, if blank, will produce an unfiltered scan. - It's allowed to input multiple ssid/wc entries, the max entry number is 10. - The type field will default to 3 (Any) and the keep field will default to 0 - (Discard). - - Examples: - 1) Perform an active scan on channels 1, 6, and 11 in the 'g' band: - setuserscan chan=1g,6g,11g - - 2) Perform a passive scan on channel 11 for 20 ms: - setuserscan chan=11gp dur=20 - - 3) Perform an active scan on channels 1, 6, and 11; and a passive scan on - channel 36 in the 'a' band: - setuserscan chan=1g,6g,11g,36ap - - 4) Perform an active scan on channel 6 and 36 for specific SSID: - setuserscan chan=6g,36a ssid=TestAP1 ssid=TestAP2 - - 5) Scan all available channels (B/G/N, A bands) for a specific BSSID, keep - the current scan table intact, update existing or append new scan data: - setuserscan bssid=00:50:43:20:12:82 keep=1 - - 6) Scan channel 6, for all infrastructure networks, sending two probe - requests. Keep the previous scan table intact. Update any duplicate - BSSID/SSID matches with the new scan data: - setuserscan chan=6g bss_type=1 probes=2 keep=1 - - 7) Scan channel 1 and 6, for all networks matching the NXP*AP - or AP*NXP? patterns and for NXPTst SSID. Generate 3 broadcast - probes for the patterns and 3 SSID specific probes for NXPTst on - both channel 1 and channel 6. - setuserscan chan=1g,6g probes=3 wc="NXP*AP" wc="AP*NXP?" ssid="NXPTst" - - 8) Scan all the channels for specified band. - setuserscan chan=0g - 9) Perform active scan for a list of specific BSSIDs - setuserscan bssid=00:50:43:20:12:82 bssid=48:e2:44:3f:ec:76 - - 9) Scan channel 1 and 6, send 3 probe requests, scan each channel for 40 ms - with time gap of 50ms between 2 scans - setuserscan chan=1g,6g probes=3 dur=40 gap=50 - - 10) Perform an enhance scan - setuserscan scan_type=1 - - All entries in the scan table (not just the new scan data when keep=1) - will be displayed upon completion by use of the getscantable ioctl. -cancelscan - This command is used to cancel scan - Usage: - mlanutl mlanX cancelscan -sleepparams - This command is used to set the sleepclock configurations - - Usage: - mlanutl mlanX sleepparams [ ] - - where: - p1 is Sleep clock error in ppm (0-65535) - p2 is Wakeup offset in usec (0-65535) - p3 is Clock stabilization time in usec (0-65535) - p4 is Control periodic calibration (0-2) - p5 is Control the use of external sleep clock (0-2) - p6 is reserved for debug (0-65535) - - Examples: - mlanutl mlan0 sleepparams : Get current sleepclock configuration - mlanutl mlan0 sleepparams 10 1000 2000 1 0 128 : Set sleepclock configuration - -sleeppd - This command is used to configure the sleep period of the WLAN device. - - Usage: - mlanutl mlanX sleeppd [] - - Where the parameter is: - period: sleep period in milliseconds. Range 10~60. 0 for disable. - - Examples: - mlanutl mlan0 sleeppd : Get sleep period configuration - mlanutl mlan0 sleeppd 10 : Set sleep period to 10 ms - -sysclock - This command is used to set/get system clocks in MHz. - The current system clock, configurable system clocks and all of the - supported system clocks will be returned if no parameter provided. - - Examples: - mlanutl mlan0 sysclock : Get system clocks - 80 80 128 128 128 5 11 16 20 22 32 40 44 64 80 106 128 160 ... - (The current system clock is 80 MHz. - The configurable system clocks of non-security, security, non-security - A-MPDU and security A-MPDU are 80 MHz, 128 MHz, 128 MHz and 128 MHz. - The supported system clocks are 5 MHz, 11 MHz, ..., 160 MHz, 182 MHz, - 213 MHz, 256 MHz, 320 Mhz, 366 MHz , ... . the Max system clocks is different - for different chips, you could use this command to get the supported system clock) - - mlanutl mlanX sysclock 80 : Set system clock in non-security mode - to 80 MHz, no change for others - mlanutl mlanX sysclock 0 0 128 : Set system clock in non-security A-MPDU - mode to 128 MHz, no changes for others - -thermal - This command is used to get the current thermal reading. - - Examples: - mlanutl mlan0 thermal : Get thermal reading - -ts_status - This command queries the FW for the status of TSIDs 0 through 7 - configured via call admission control and displays the results in a - table. - - Usage: - mlanutl mlanX ts_status - -tsf - Get the TSF timer value for the station. Station maintains a TSF timer with - modulus 2^64 counting in increments of microseconds. - - Usage: - mlanutl mlanX tsf - -txbufcfg - This command can be used to get current buffer size. + 0: Get 2.4G txpwrlimit table + 0x10: Get 5G sub0 txpwrlimit table + 0x11: Get 5G sub1 txpwrlimit table + 0x12 Get 5G sub2 txpwrlimit table + 0x1f Get all 5G txpwrlimit table + 0xff Get both 2G and 5G txpwrlimit table + driver will save fw raw data to this file. + + Examples: + mlanutl mlan0 get_txpwrlimit 0 : Get 2G txpwrlimit table. + mlanutl mlan0 get_txpwrlimit 0x10 : Get 5G sub band0 txpwrlimit table + mlanutl mlan0 get_txpwrlimit 0xff txpwrlimit.bin : Get both 2G/5G txpwrlimit table and save to txpwrlimit.bin + +aggrpriotbl + This command is used set/get the priority table for AMPDU/AMSDU traffic per tid. + This command can also be used to disable AMPDU/AMSDU for a given tid. + In case of AMPDU this priority table will be used to setup block ack (to make + sure the highest priority tid always uses AMPDU as we have limited AMPDU streams) + + where ... + + - This is priority for Tid0 for AMPDU packet. A priority could be any + values between 0 - 7, 0xff to disable aggregation. + - This is priority for Tid0 for AMSDU packet. A priority could be any + values between 0 - 7, 0xff to disable aggregation. eg: - mlanutl mlanX txbufcfg - This will display the current buffer size. + mlanutl mlanX aggrpriotbl - This command will get the current Priority table for AMPDU and AMSDU. + <2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255>. This is read as + <"Prio for AMPDU for Tid0" "Prio for AMSDU for Tid0" + "Prio for AMPDU for Tid1" "Prio for AMSDU for Tid1" and so on + mlanutl mlanX aggrpriotbl 2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255 - + This will set the priority table for AMPDU and AMSDU + Priority for Tid0/AMPDU = 2, Tid0/AMSDU = 2, Tid1/AMPDU = 0, Tid1/AMSDU = 0 + and so on. Aggregation for Tid6 and Tid7 are disabled. + Here higher the priority number, higher the priority (i.e. 7 + has higher priority than 6). Similarly for AMSDU. + mlanutl mlanX aggrpriotbl 0xff 2 0xff 0 0xff 1 0xff 3 0xff 4 0xff 5 0xff 0xff 0xff 0xff - This will disable + AMPDU for all the TIDs but will still keep AMSDU enabled to Tid0 to Tid5 - Note:- The actual tx buf size will depends on AP's capability and max transmit buffer size. + The default setting is 2 255 0 255 1 255 3 255 4 255 5 255 255 255 255 255. -txratecfg - This command is used to set/get the transmit data rate. + A delBA should be seen in case a disable happens on a TID for which AMPDU stream + is currently setup. - Note: - 1) The data rate can be set only after association. + Note:- This command should only be issue in disconnected state. - 2) If the reassoc is OFF driver reset the data rate to auto if the connection state is disconnected. - Please note that user has to re-issue the set data rate command if the driver is disconnected. +addbapara + This command can be used to update the default ADDBA parameters. - 3) If the reassoc is ON driver remembers the data rate set by the user, if the driver is - disconnected user does not have to re-issue the set data rate again. - 4) Parameter [o] is optional. If [o] is not given, it will be set as 0xffff. + where is + - This is the block ack timeout for ADDBA request. + 0 : Disable (recommended for throughput test) + 1 - 65535 : Block Ack Timeout in TU - Where - [l] is - - This parameter specifies the data rate format used in this command - 0: LG - 1: HT - 2: VHT - 3: HE - 0xff: Auto + where is + - Window size for ADDBA request. (16 is recommended and default value) - [m] is - - This parameter specifies the rate or MCS index - If is 0 (LG), - 0 1 Mbps - 1 2 Mbps - 2 5.5 Mbps - 3 11 Mbps - 4 6 Mbps - 5 9 Mbps - 6 12 Mbps - 7 18 Mbps - 8 24 Mbps - 9 36 Mbps - 10 48 Mbps - 11 54 Mbps - If is 1 (HT), - 0 MCS0 - 1 MCS1 - 2 MCS2 - 3 MCS3 - 4 MCS4 - 5 MCS5 - 6 MCS6 - 7 MCS7 - 8 MCS8 - 9 MCS9 - 10 MCS10 - 11 MCS11 - 12 MCS12 - 13 MCS13 - 14 MCS14 - 15 MCS15 - If is 2 (VHT), - 0 MCS0 - 1 MCS1 - 2 MCS2 - 3 MCS3 - 4 MCS4 - 5 MCS5 - 6 MCS6 - 7 MCS7 - 8 MCS8 - 9 MCS9 - If is 3 (HE), - 0 MCS0 - 1 MCS1 - 2 MCS2 - 3 MCS3 - 4 MCS4 - 5 MCS5 - 6 MCS6 - 7 MCS7 - 8 MCS8 - 9 MCS9 - 10 MCS10 - 11 MCS11 - [n] is - - This parameter specifies the NSS. It is valid for VHT - If is 2 (VHT), - 1 NSS1 - 2 NSS2 - [n] is - - This parameter specifies the NSS. It is valid for HE - If is 3 (HE), - 1 NSS1 - 2 NSS2 - [o] is - Bit0 - 1: indicate preambleType - For legacy 11b: preemble type - 00 = long - 01 = short - 10/11 = reserved - For legacy 11g: reserved - For 11n: Green field PPDU indicator - 00 = HT-mix - 01 = HT-GF - 10/11 = reserved. - For 11ac: reserved. - For 11ax: - 00 = HE-SU - 01 = HE-EXT-SU - others are reserved + where is + - Window size for ADDBA response. (48 is recommended and 32 is default value) + (16 is recommended for IWNCOMM AP in WAPI throughput test) - Bit 2 - 4 : indicate BW: - For HE ER: - 0 = 242-tone RU - 1 = upper frequency 106-tone RU within the primary 20 MHz - Otherwise: - 0 = 20 MHz - 1 = 40 MHz - 2 = 80 MHz - 3 = 160 MHz + Current window size limit for Tx as well as Rx is 1023. - Bit 5 -6: indicate LTF + GI size - For HT: - 0 = normal - 1 = Short GI - For VHT: - 01 = Short GI - 11 = Short GI and Nsym mod 10=9 - 00 = otherwise - For HE: - 0 = 1xHELTF + GI0.8us - 1 = 2xHELTF + GI0.8us - 2 = 2xHELTF + GI1.6us - 3 = 4xHELTF + GI0.8us if DCM = 1 and STBC = 1 - 4xHELTF + GI3.2us, otherwise. + where

is + - amsdu support for ADDBA request. (1 is default value) + 0: disable amsdu in ADDBA request + 1: enable amsdu in ADDBA request - Bit 7: Indicate STBC: - 0 = no STBC - 1 = STBC + where is + - amsdu support for ADDBA response. (1 is default value) + 0: disable amsdu in ADDBA response + 1: enable amsdu in ADDBA response - Bit 8: indicate DCM: - 0 = no DCM - 1 = DCM + eg: + mlanutl mlanX addbapara - This command will get the current addba params + mlanutl mlanX addbapara 1000 64 8 0 0 - This will change the ADDBA timeout to (1000 * 1024) us, + txwinsize to 64 and rxwinsize to 8 and disable amdsu in ADDBA request/response. - Bit 9: indicate coding: - 0 = BCC - 1 = LDPC + The default setting is 65535 16 32 1 1. - Bit 10 - 11: reserved. + In case the ADDBA timeout value is updated then a ADDBA is sent for all streams + to update the timeout value. - Bit 12 - 13: Indicate maxPE - Max packet extension - 0 - 0 usec - 1 - 8 usec - 2 - 16 usec. + In case txwinsize and/or rxwinsize is updated, the effect could only be seen on + next ADDBA request/response. The current streams will not be affected with this + change. - Bit 14 - 15: reserved. + In case of txamsdu/rxamsdu is updated, the effect could only be seen on + next ADDBA request/response. The current streams will not be affected with this + change. AMSDU in AMPDU stream will be enabled when AP support this feature + and AMSDU is enabled in aggrpriotbl. - 0xffff: Auto +addbareject + This command is used set/get the addbareject table for all the TIDs. + This command can also be used to enable rejection of ADDBA requests for a given tid. - Examples: - mlanutl mlan0 txratecfg : Read the current data rate setting - mlanutl mlan0 txratecfg 0 3 : Set fixed Tx rate to 11 Mbps - mlanutl mlan0 txratecfg 0 11 : Set fixed Tx rate to 54 Mbps - mlanutl mlan0 txratecfg 1 3 : Set fixed Tx rate to MCS3 - mlanutl mlan0 txratecfg 2 3 2 : Set fixed Tx rate to MCS3 for NSS2 - mlanutl mlan0 txratecfg 3 3 2 : Set 11AX fixed Tx rate to MCS3 for NSS2 - mlanutl mlan0 txratecfg 3 5 2 0x2282 : Set 11AX fixed Tx rate to MCS5 for NSS2, and Preamble type is 2, BW is 0, LTF + GI size 0 - STBC is 1, DMC is 0, Coding is 1, maxPE is 2. - mlanutl mlan0 txratecfg 0xff : Disable fixed rate and uses auto rate + where ... -aggrctrl - This command is used to set/get aggregation parameters. + - This can be 0/1 for TidX. 1 enables rejection of ADDBA request for TidX and + 0 would accept any ADDBAs for TidX. - Usage: - mlanutl mlanX aggrctrl [l] + eg: + mlanutl mlanX addbareject - This command will get the current table. + [0 0 0 0 0 0 0 0]. ADDBA would be accepted for all TIDs. This is the default state. - where the parameter: - [l]: Enable (1) or disable (0) Tx aggregation + mlanutl mlanX addbareject 0 0 1 1 0 0 0 0 - This command will accept ADDBA requests for + Tid [0,1,4,5,6,7] and reject ADDBA requests for Tid [2,3] - Examples: - mlanutl mlan0 aggrctrl : Display aggregation configurations - mlanutl mlan0 aggrctrl 0 : Disable Tx aggregation - mlanutl mlan0 aggrctrl 1 : Enable Tx aggregation + mlanutl mlanX addbareject 1 1 1 1 1 1 1 1 - This will enable rejection of ADDBA requests for + all Tids. -usbaggrctrl - This command is used to set/get USB aggregation parameters. - - Usage: - mlanutl mlanX usbaggrctrl [l] [m] [n] [o] [p] [q] [r] [s] - - where the parameter: - [l]: Enable (1) or disable (0) Tx aggregation - [m]: Enable (1) or disable (0) Rx aggregation - [n]: Tx aggregation max size/number - For number based aggregation, the values supported are - - 2, 4, 8, 16 - For size based aggregation, the number supported are - - 4096, 8192, 16384, 32768 - [o]: Rx aggregation max size/number - For number based deaggregation, the values supported are - - 2, 4, 8, 16 - For size based deaggregation, the number supported are - - 4096, 8192, 16384, 32768 - [p]: Tx aggregation alignment - The value must be 2048, 4096, 8192 etc. - [q]: Rx aggregation alignment - The value must be 512, 1024, 2048, 4096, 8192 etc. - [r]: Tx aggregation timeout - Timeout value in us, 0 for disabled, 0xFFFF for dynamic timeout - and 1-10000 are valid timeout value - [s]: Rx aggregation timeout - Timeout value in us, 0 for disabled - - Examples: - mlanutl mlan0 usbaggrctrl : Display USB aggregation configurations - mlanutl mlan0 usbaggrctrl 0 0 : Disable both Tx and Rx aggregation - mlanutl mlan0 usbaggrctrl 1 1 4 8 2048 512 1000 200 : Enable both Tx and Rx aggregation - -usbresume - This command is used to resume the device from suspend mode. - Note: It's only valid on kernel 2.6.24 or later. - -usbsuspend - This command is used to put device to suspend mode. - Note: It's only valid on kernel 2.6.24 or later. - -verext - Retrieve and display an extended version string from the firmware - - Usage: - mlanutl mlanX verext [#] - - where [#] is an optional argument to retrieve a specific version string, - omission of the argument retrieves the 0 indexed string. - -version - This is used to get the current version of the driver and the firmware. + Note:- This command should only be issue in disconnected state. vhtcfg This command is used to set and get various 11ac specific configuration @@ -3439,534 +956,115 @@ vhtcfg mlanutl uap0 vhtcfg 2 3 0 0x000001b0 : Set the VHT capability information in 5GHz for the uAP, and keep the Tx/Rx MCS Map same as before. -opermodecfg - This command is used to set and get 11ac Operating Mode Notification configuration. - - where is - - This is the channel width setting for the opermodecfg - 1: 20MHz - 2: 40MHz - 3: 80MHz - 4: 160MHz or 80+80MHz - - where is - - This parameter specifies the nss that the STA can receive. - 1: NSS1 - 2: NSS2 - 3: NSS3 - 4: NSS4 - 5: NSS5 - 6: NSS6 - 7: NSS7 - 8: NSS8 - -wakeupreason - This command is used to get the host sleep wakeup reason. +dyn_bw + This command is used to set/get dynamic bandwidth. Usage: - mlanutl mlanX wakeupreason - mlanutl uapX wakeupreason - Examples: - mlanutl mlan0 wakeupreason : Get the host sleep wakeup reason - mlanutl uap0 wakeupreason : Get the host sleep wakeup reason - 0: unknown - 1: Broadcast data matched - 2: Multicast data matched - 3: Unicast data matched - 4: Maskable event matched - 5. Non-maskable event matched - 6: Non-maskable condition matched (EAPoL rekey) - 7: Magic pattern matched - 8: Control frame matched - 9: Management frame matched - Others: reserved. (0) + mlanutl mlanX dyn_bw [n] -warmreset - This command is used for warm reset of the interface. + where + [BIT0] + 0 = TxInfo Indicated BW Disable + 1 = TxInfo Indicated BW Enable + [BIT1] + 0 = TxInfo Dynamatic BW Disable + 1 = TxInfo Dynamatic BW Enable + [BIT2] + 0 = TxInfo Force send RTS Disable + 1 = TxInfo Force send RTS Enable + [BIT3] + 0 = Mac Dynamic BW Operation Mode Disable (Static BW Operation Mode) + 1 = Mac Dynamic BW Operation Mode Enable + other bits reserved. - Usage: - mlanutl mlanX warmreset - -wpssession - This command is used to control wps session. No argument is used to get. - - where value of n is: - 0 -- Disable - 1 -- Enable + If no parameter provided, get is performed. Examples: - mlanutl mlan0 wpssession 1 : Enable wpssession - mlanutl mlan0 wpssession : Get wpssession status - -wmmcfg - This command is used to control WMM. No argument is used to get. - - where value of n is: - 0 -- Disable - 1 -- Enable - - Examples: - mlanutl mlan0 wmmcfg 1 : Enable WMM - mlanutl mlan0 wmmcfg : Get WMM status - -wmmparamcfg - This command is used to configure WMM paramameters. - - Usage: - mlanutl mlanX wmmparamcfg [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] - [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] - [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] - [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP] - - The supported option are: - AC_BE: 0 - AC_BK: 1 - AC_VI: 2 - AC_V0: 3 - AIFSN: AIFSN value - ECW_MAX: ECW max - ECW_MIN: ECW min - TX_OP: TXOP Limit - empty - Get current WMM parameters - - Example: - mlanutl mlanX wmmparamcfg 0 3 10 4 0 - Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 - - mlanutl mlanX wmmparamcfg 1 7 10 4 0 - Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 - - mlanutl mlanX wmmparamcfg 2 2 4 3 94 - Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 - - mlanutl mlanX wmmparamcfg 3 2 3 2 47 - Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 - - mlanutl mlanX wmmparamcfg - Get current WMM parameters - - mlanutl mlanX wmmparamcfg 0 3 10 4 0 1 7 10 4 0 2 2 4 3 94 3 2 3 2 47 - Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 - Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 - Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 - Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 - -wwscfg - This command is used to set/get the WWS (World Wide Safe) mode. - - where value of m is: - 0 -- Disable WWS mode (default) - 1 -- Enable WWS mode - - Examples: - mlanutl mlan0 wwscfg : Get WWS mode - mlanutl mlan0 wwscfg 1 : Enable WWS mode - mlanutl mlan0 wwscfg 0 : Disable WWS mode - -cfg_noa - This is used to get/set P2P NoA (Notice of Absence) parameters only for P2P GO. - - Usage: - mlanutl p2pX cfg_noa [h] [i] [j] [k] [l] - - where: - [h] : noa_enable : 1/0 Set to 1 to enable NoA, 0 to disable NoA. - [i] : index : 0 - 255 Identifies an instance of NoA timing. - [j] : count : 1 - 255 Indicates the number of absence intervals. - 255 means a continuous schedule. - [k] : duration : Indicates the maximum duration in units of microseconds - that P2P GO can remain absent following the start of - a NoA interval. - [l] : interval : Indicates the length of the NoA interval in units of - microseconds. - - Examples: - mlanutl p2pX cfg_noa : Get noa configuration. - mlanutl p2pX cfg_noa 1 1 255 50 100 : Set noa configuration. - -cfg_opp_ps - This is used to get/set P2P OPP-PS parameters only for P2P GO. - - Usage: - mlanutl p2pX cfg_opp_ps [m] [n] - - where: - [m] : ps_enable : 1/0 Set to 1 to indicate P2P GO is using opportunistic - power save. Set to 0 if opportunistic power save is disabled. - [n] : ct_window : A period of time in TU after a TBTT during which P2P GO - is present. 0 indicates that there shall be no - CTWindow (Client Traffic Window). - - Examples: - mlanutl p2pX cfg_opp_ps : Get noa configuration. - mlanutl p2pX cfg_opp_ps 1 7 : Set noa configuration. - -rxpktcoal_cfg - This is used to get/set RX packet coalescing paramters - Usage: - mlanutl mlanX rxpktcoal_cfg [m] [n] - - where: - [m]: pkt_threshold: count after which packets would be sent to host. Valid values 1-7 - [n]: delay: timeout in ms after which packets would be sent to host. Valid values 1-4 - Coalescing is disabled if both or either of packet_thershold and delay is zero - - RX packet coalescing parameters can be changed only when device is in - idle state i.e. all interfaces are disconnected. - -get_sensor_temp - This command is used to get SOC temperature - Usage: - mlanutl mlanX get_sensor_temp - -indrstcfg - This command is used to set/ get independent reset mode configuration - - Usage : - mlanutl indrstcfg [gpio_pin] - - interface : mlanX, uapX - ir_mode : 0 -- Disable - 1 -- Enable out band reset, disable in band - 2 -- Enable in band, disable out band - gpio_pin : 255 -- Default pin for reset - any other number for changing the gpio for reset. - - Example : - mlanutl mlan0 indrstcfg 1 255 : Set default pin on interface mlan0 as reset pin - mlanutl mlan0 indrstcfg 0 : Disable the gpio 17 as reset pin on interface mlan0 - mlanutl mlan0 indrstcfg : Get the status and the pin used for reset pin - mlanutl mlan0 indrstcfg 2 : Enable in band reset mode - -ctrldeauth - This command is used to set/get firmware ctrldeauth setting - Usage : - mlanutl uapX ctrldeauth - - Where value of n is : - 0 -- Firmware will use default behavior - 1 -- Firmware will not send deauth packet when uap move to another channel. - - Example : - mlanutl uap0 ctrldeauth : Get current setting - mlanutl uap0 ctrldeauth : Firmware will not send deauth packet when uap move to different channel. - -robustcoex - This command is used to set robust coex. - - Usage : - mlanutl robustcoex [Enable/Disable] [gpionum] [gpiopolarity] - Enable/Disable : 0 -- Disable ; 1 -- Enable - gpionum : Number of gpio - gpiopolarity : polarity of gpio - - Example : - mlanutl mlan0 robustcoex gpiocfg 1 4 1 : Enable robustcoex gpio, set gpionum to 4 and gpiopolarity to 1 - mlanutl mlan0 robustcoex gpiocfg 0 : Disable robustcoex gpio - -cwmode - This command is used to set Cont. Tx/Wave mode. - - Usage: - mlanutl cwmode config/cwmode.conf - interface: mlanX - cwmode.conf: This config file specifies whether to enable/disable Cont Tx/Wave mode. - User can specify parameters like Channel, datarate, BW, Channel Offset, Band. - Detailed information about parameters is mentioned in the conf file. - Example: - mlanutl mlan0 cwmode config/cwmode.conf : Enable/Disable Cont Tx/Wave mode. - mlanutl mlan0 cwmode : Get current Tx mode - -bootsleep - This command is used to set and get boot sleep configure. - - Usage : - mlanutl mlanX/uapX bootsleep - : enable boot sleep - : 0 - disable boot sleep - : 1 - enable boot sleep - - Example : - mlanutl mlan0/uap0 bootsleep 1 : Enable boot sleep - mlanutl mlan0/uap0 bootsleep : Get boot sleep configure - -ssu - Collect spectral analysis data and save them into /data/ssudump.txt - - Usage : - mlanutl mlanX ssu [mode] [ssu file] - - mode : 2 -- Enable ssu and use FW default ssu parameter - ssu file : file to config ssu parameter - - Example : - mlanutl mlan0 ssu :Enable SSU and use driver default ssu parameter - mlanutl mlan0 ssu config/ssu.conf :Enable SSU and use ssu parameter from ssu.conf - mlanutl mlan0 ssu 2 :Enable SSU and use FW default ssu parameter - -dmcs - This command is used to config DMCS or get DMCS status. - - Usage: - mlanutl mlanX dmcs [value] - - : config mapping policy - disable dynamic mapping when [value = 0] - enable dynamic mapping when [value = 1] - : get DMCS status - - Example : - mlanutl mlan0 dmcs 0 1 : Enable dynamic mapping - mlanutl mlan0 dmcs 0 0 : Disable dynamic mapping - mlanutl mlan0 dmcs 1 : Get DMCS status - -11axcfg - This command is used to config 11ax HE capability using conf file. - - Usage: - mlanutl mlanX 11axcfg [conf file] - - Example: - mlanutl mlan0 11axcfg config/11axcfg.conf - mlanutl uap0 11axcfg config/11axcfg.conf - -11axcmd - This command is used to config 11ax HE capability using command. - - Usage: - mlanutl mlanX 11axcmd [value_1] [value_2] - - : spatial reuse configuration - set obss_pd offset, [value_1] = NON_SRG_OffSET, [value_2] = SRG_OFFSET - - : spatial reuse configuration - control SR, [value_1]= 1 is enable SR, [value_1] = 0 is disable SR - - : enable/disable beam change - enable beam_change when [value_1 = 0] - disable beam_change when [value_1 = 1] - - : enable/disable HTC transmission - enable transmission of HTC when [value_1 = 1] - disable transmission of HTC when [value_1 = 0] - Example : - mlanutl mlan0 11axcmd obss_pd_offset 2 3 : set obss_pd offset of spatial reuse, NON_SRG_OffSET = 2, SRG_OFFSET = 3 - mlanutl mlan0 11axcmd obss_pd_offset : get obss_pd offset of spatial reuse - mlanutl mlan0 11axcmd enable_sr 1 : enable spatial reuse - mlanutl mlan0 11axcmd beam_change 0 : enable beam change - mlanutl mlan0 11axcmd enable_htc 1 : enable transmission of HTC - -rx_abort_cfg - This command is used to set/get static rx abort config for pkt having - weaker RSSI than threshold. This threshold will be overwritten on starting - dynamic rx abort cfg ext. - - Usage: - mlanutl rx_abort_cfg [enable] [rssi_threshold] - - Where the parameters are: - : mlanX, - uapX - [enable] : 0 - Disable Rx abort - 1 - Enable Rx abort of pkt having weak RSSI - [rssi_threshold] : weak RSSI pkt threshold in dBm (absolute value) - (default = 70) - - Examples: - mlanutl mlan0 rx_abort_cfg - - Display current rx abort configuration - mlanutl uap0 rx_abort_cfg 1 60 - - Enable rx abort and set weak RSSI Threshold to -60 dBm - mlanutl mlan0 rx_abort_cfg 1 40 - - Enable rx abort and set weak RSSI Threshold to -40 dBm - mlanutl mlan0 rx_abort_cfg 0 - - Disable rx abort - -rx_abort_cfg_ext - This command is used to set/get dynamic rx abort config. This will set - threshold based on minimum of ceiling rssi threshold and the weakest - RSSI among all connected peers. Margin can be specified as an offset to - this threshold. Default margin is set to -10 dBm. Ceiling rssi threshold - can be changed by specifying. Default ceil is set to -70 dBm. - This will be disabled on enabling fixed rx abort (rx_abort_cfg) - - Note: This dynamic rx abort mode is enabled by default. - - Usage: - mlanutl rx_abort_cfg_ext [enable] [margin ceil_thresh] - - Where the parameters are: - : mlanX, - uapX - [enable] : 0 - Disable Rx abort - 1 - Enable Rx abort of pkt having weak RSSI - [margin] : rssi margin in dBm (absolute val) - (default = 10) - [ceil_thresh] : ceiling weak RSSI pkt threshold in dBm - (absolute value) (default = 70) - - Examples: - mlanutl mlan0 rx_abort_cfg_ext - - Display current rx abort configuration - mlanutl uap0 rx_abort_cfg_ext 1 10 60 - - Enable dynamic rx abort, set margin to -10 dBm and set ceil - RSSI Threshold to -60 dBm - mlanutl mlan0 rx_abort_cfg_ext 1 5 50 - - Enable dynamic rx abort, set margin to -5 dBm and set ceil - RSSI Threshold to -50 dBm - mlanutl mlan0 rx_abort_cfg_ext 0 - - Disable dynamic rx abort - -tx_ampdu_prot_mode - This command is used to set either RTS/CTS or CTS2SELF protection mechanism - in MAC, for aggregated Tx QoS data frames. RTS/CTS is enabled by default. - - Usage: - mlanutl tx_ampdu_prot_mode [mode] - - Where the parameters are: - : mlanX, - uapX - [mode] : 0 - Set RTS/CTS mode - 1 - Set CTS2SELF mode - 2 - Disable Protection mode - 3 - Set Dynamic RTS/CTS mode - - Examples: - mlanutl mlan0 tx_ampdu_prot_mode - - Get currently set protection mode for Tx AMPDU - mlanutl mlan0 tx_ampdu_prot_mode 1 - - Set protection mode for Tx AMPDU to CTS2SELF - -rate_adapt_cfg - This command is used to switch between SR rateadapt and Legacy rateadapt. - FW default Algorithm is Legacy rateadapt - when SR rateadapt is enabled then it is used to set static threshold based - or dynamic noise based rate adaptation and set the timer interval to evaluate - sw rate adaptation.For static mode, low and high thresholds for Tx aggregated - pkt success rate should be configured. The Tx rate will decrease if success rate - goes lower than LOW_THRESH, will increase if it goes beyond HIGH_THRESH, and will - remain the same when success rate is between these thresholds.To set dynamic mode, - specify 0xff for both low and high thresh. - - Note: config can be set only before associating with an external AP - when in STA mode, or before starting bss when in uAP mode - - Usage: - mlanutl rate_adapt_cfg - [sr_rateadapt low_thresh high_thresh timer_interval] - - Where the parameters are: - : mlanX, - uapX - [sr_rateadapt] : SR Rateadapt or Legacy Rateadapt - [low_thresh] : lower tx success rate threshold - [high_thresh] : higher tx success rate threshold - [timer_interval] : interval to evaluate tx rate in sw in multiples - of 10 (ms) - - Examples: - mlanutl mlan0 rate_adapt_cfg - - Display SR rateadapt or Legacy rateadapt enabled - - Display current rate adapt configuration if SR rateadapt is enabled. - mlanutl uap0 rate_adapt_cfg 1 60 80 10 - - set lower Tx success rate threshold to 60%, higher to 80% - and evaluate tx rate every 100 ms (i.e 10 * 10 = 100 ms) - when SR Rateadapt is enabled. - mlanutl mlan0 rateadapt_cfg 0 - - switch to Legacy rateadapt. - mlanutl mlan0 rateadapt_cfg 1 - - switch to SR rateadapt. - Fw default is dynamic Success threshold enabled - with 100 ms linkadapt timer. - mlanutl mlan0 rate_adapt_cfg 1 50 70 50 - - set lower Tx success rate threshold to 50%, higher to 70% - and evaluate tx rate every 500 ms (i.e 50 * 10 = 500 ms) - when SR Rateadapt is enabled. - mlanutl mlan0 rate_adapt_cfg 1 0xff 0xff 10 - - set dynamic environment noise based mode and evaluate tx rate - every 100 ms (i.e 10 * 10 = 100 ms) - when SR Rateadapt is enabled. - -cck_desense_cfg - This command is used to configure CCK (802.11b) Desensitization RSSI - threshold. All CCK traffic beyond this threshold will be ignored, resulting - in higher Tx throughput. Threshold value is in absolute value of rssi in - dBm. In dynamic and enhanced modes, cck desense will be turned on only in - presence of an active connection and the effective CCK desense RSSI - threshold will be updated every rateadapt interval, based on: - min{ceil_thresh, [min RSSI among all connected peers] - margin} - - Further, for dynamic enhanced mode, CCK desense will be turned on/off based - on environment noise condition and ongoing Tx traffic rate. In this mode, - CCK desense will also be turned off periodically in order to allow 802.11b - Rx frames from Ext-AP, if rx rssi becomes weaker than the current threshold - or when in uAP mode, frames from clients which attempt to connect with the - uAP, but have weaker RSSI than the set threshold. - Turn on and off intervals are specified in terms of rateadapt intervals. - Please note that in this mode, if dynamic Rx Abort is enabled, then it - will turn on/off in sync with cck desense. - - Usage: - mlanutl cck_desense_cfg [mode] [margin ceil_thresh] - [num_on_intervals num_off_intervals] - - Where the parameters are: - : mlanX, - uapX - [mode] : 0 - Disable cck desense - 1 - Enable dynamic cck desense mode - 2 - Enable dynamic enhanced cck desense mode - [margin] : rssi margin in dBm (absolute val) - (default = 10) - [ceil_thresh] : ceiling weak RSSI pkt threshold in dBm - (absolute value) (default = 70) - [num_on_intervals] : number of rateadapt intervals to keep cck - desense "on" [for mode 2 only] (default = 20) - [num_off_intervals]: number of rateadapt intervals to keep cck - desense "off" [for mode 2 only] (default = 3) - - Examples: - mlanutl mlan0 cck_desense_cfg - - Display current cck desense configuration - mlanutl uap0 cck_desense_cfg 1 10 70 - - Set dynamic mode, margin to -10 dBm and ceil RSSI Threshold to - -70 dBm - mlanutl uap0 cck_desense_cfg 2 10 60 30 5 - - Set dynamic enhanced mode, margin to -10 dBm, ceil RSSI Threshold - to -60 dBm, num on intervals to 30 and num off intervals to 5. - mlanutl mlan0 cck_desense_cfg 1 10 50 - - Set dynamic mode, margin to -10 dBm and ceil RSSI Threshold to - -50 dBm - mlanutl mlan0 cck_desense_cfg 2 5 60 - - Set dynamic enhanced mode, set margin to -5 dBm, set ceil RSSI - Threshold to -60 dBm, and retain previous num on/off intervals - setting. - mlanutl mlan0 cck_desense_cfg 0 - - Disable cck desense - -lpm - This command is used to configure low power mode. - - Usage: - mlanutl mlanX/uapX lpm [mode] - - Where the paramter is: - [mode] : low power mode 0, 1, 2, 3 - - Examples: - mlanutl mlan0 lpm Get low power mode - mlanutl mlan0 lpm 1 Set low power mode to 1 - -=============================================================================== -=============================================================================== - U S E R M A N U A L F O R Enable Scan GAP - -Following commands can be used to enable gap between scans. - -mlanutl mlanX scancfg [t] [m] [p] [s] [a] [b] [c] [ext] [gap] -mlanutl mlanX setuserscan [ARGS] - -For detail information, please refer the command description. -=============================================================================== + mlanutl mlan0 dyn_bw 0x1 : Enable TxInfo Indicated BW + mlanutl mlan0 dyn_bw : get current setting + +httxcfg + This command is used to configure various 11n specific configuration + for transmit (such as Short GI, Channel BW and Green field support) + + where is + This is a bitmap and should be used as following + Bit 15-8: Reserved set to 0 + Bit 7: STBC enable/disable + Bit 6: Short GI in 40 Mhz enable/disable + Bit 5: Short GI in 20 Mhz enable/disable + Bit 4: Green field enable/disable + Bit 3-2: Reserved set to 1 + Bit 1: 20/40 Mhz enable disable. + Bit 0: LDPC enable/disable + + When Bit 1 is set then firmware could transmit in 20Mhz or 40Mhz based + on rate adaptation. When this bit is reset then firmware will only + transmit in 20Mhz. + + where is + - This is the band info for settings. + 0: Settings for both 2.4G and 5G bands + 1: Settings for 2.4G band + 2: Settings for 5G band + + Example: + mlanutl mlanX httxcfg + This will display HT Tx configuration for 2.4G and 5G band. + + mlanutl mlanX httxcfg 0x62 + This will enable 20/40 and Short GI but will disable Green field for 2.4G and 5G band. + + mlanutl mlanX httxcfg 0x30 1 + This will enable Short GI 20 Mhz and Green field for 2.4G band. + + The default value is 0x20 for 2.4G and 0x62 for 5G. + + Note:- If 20/40 MHz support is disabled in htcapinfo, device will not transmit + in 40 MHz even 20/40 MHz is enabled in httxcfg. + +htcapinfo + This command is used to configure some of parameters in HTCapInfo IE + (such as Short GI, Channel BW, and Green field support) + + where is + - This is a bitmap and should be used as following + Bit 29: Green field enable/disable + Bit 26: Rx STBC Support enable/disable. (As we support + single spatial stream only 1 bit is used for Rx STBC) + Bit 25: Tx STBC support enable/disable. + Bit 24: Short GI in 40 Mhz enable/disable + Bit 23: Short GI in 20 Mhz enable/disable + Bit 22: Rx LDPC enable/disable + Bit 17: 20/40 Mhz enable disable. + Bit 8: Enable/disable 40Mhz Intolarent bit in ht capinfo. + 0 will reset this bit and 1 will set this bit in + htcapinfo attached in assoc request. + All others are reserved and should be set to 0. + + Setting of any other bits will return error. + + where is + - This is the band info for settings. + 0: Settings for both 2.4G and 5G bands + 1: Settings for 2.4G band + 2: Settings for 5G band + + Example: + mlanutl mlanX htcapinfo + This will display HT capabilties information. + If the information for 2.4G and 5G is different, + the first value is for 2.4G and the second value is for 5G. + Otherwise, it will display a single value for both bands. + + mlanutl mlanX htcapinfo 0x1820000 + This will enable Short GI, Channel BW to 20/40 and disable Green field support for 2.4G and 5G band. + + mlanutl mlanX htcapinfo 0x800000 2 + This will enable Short GI, Channel BW to 20 only, No Rx STBC support and disable Green field support for 5G band. + + The default value is 0x4800000 for 2.4G and 0x5820000 for 5G. + + Note:- This command can be issued any time but it will only come to effect from + next association. (as HTCapInfo is sent only during Association). diff --git a/mxm_wifiex/wlan_src/mapp/mlan2040coex/Makefile b/mxm_wifiex/wlan_src/mapp/mlan2040coex/Makefile deleted file mode 100644 index 9725f90..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlan2040coex/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# File : mlan2040coex/Makefile -# -# Copyright 2014-2020 NXP - -# Path to the top directory of the mlandriver distribution -PATH_TO_TOP = ../.. - -# Determine how we should copy things to the install directory -ABSPATH := $(filter /%, $(INSTALLDIR)) -RELPATH := $(filter-out /%, $(INSTALLDIR)) -INSTALLPATH := $(ABSPATH) -ifeq ($(strip $(INSTALLPATH)),) -INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) -endif - -# Override CFLAGS for application sources, remove __ kernel namespace defines -CFLAGS := $(filter-out -D__%, $(ccflags-y)) -# remove KERNEL include dir -CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) - -# -# List of application executables to create -# -libobjs:= mlan2040coex.o mlan2040misc.o -exectarget=mlan2040coex -TARGETS := $(exectarget) - -# -# Make target rules -# - -# All rule compiles list of TARGETS using builtin program target from src rule -all : -$(exectarget): $(libobjs) - $(CC) $(CFLAGS) $(libobjs) -o $(exectarget) - -# Update any needed TARGETS and then copy to the install path -build install: $(TARGETS) - @cp -f $(exectarget) $(INSTALLPATH) - -clean: - @rm -f $(exectarget) - @rm -f *.o - -distclean: clean - @rm -f *~ core - @rm -f tags diff --git a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.c b/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.c deleted file mode 100644 index 3d0f9ba..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.c +++ /dev/null @@ -1,1385 +0,0 @@ -/** @file mlan2040coex.c - * - * @brief 11n 20/40 MHz Coex application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 06/24/2009: initial version -************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mlan2040coex.h" -#include "mlan2040misc.h" - -/** coex application's version number */ -#define COEX_VER "M2.0" - -/** Initial number of total private ioctl calls */ -#define IW_INIT_PRIV_NUM 128 -/** Maximum number of total private ioctl calls supported */ -#define IW_MAX_PRIV_NUM 1024 - -/** Legacy APs channel list */ -chan_intol_t leg_ap_chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; -/** Total number of channel present in Legacy APs channel list */ -t_u8 num_leg_ap_chan; - -/******************************************************** - Local Variables -********************************************************/ - -static char *usage[] = { - "Usage: ", - " mlan2040coex [-i ] [-hvB] ", - " -h = help", - " -v = version", - " -B = run the process in background.", - " (if intfname not present then mlan0 assumed)" -}; - -t_s32 sockfd = 0; /**< socket descriptor */ -char dev_name[IFNAMSIZ + 1]; /**< device name */ - -/** Flag: is 2040coex command required */ -int coex_cmd_req_flag = FALSE; -/** Flag: is associated */ -int assoc_flag = FALSE; -/** Flag: is HT AP */ -int is_ht_ap = FALSE; -/** terminate flag */ -int terminate_flag = FALSE; - -/******************************************************** - Global Variables -********************************************************/ -/** OBSS scan parameter of associated AP */ -OBSSScanParam_t cur_obss_scan_param; - -/******************************************************** - Local Functions -********************************************************/ - -/** - * @brief Prepare command buffer - * @param buffer Command buffer to be filled - * @param cmd Command id - * @param num Number of arguments - * @param args Arguments list - * @return MLAN_STATUS_SUCCESS - */ -static int -prepare_buffer(t_u8 *buffer, char *cmd, t_u32 num, char *args[]) -{ - t_u8 *pos = NULL; - unsigned int i = 0; - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - /* Flag it for our use */ - pos = buffer; - strncpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); - pos += (strlen(CMD_NXP)); - - /* Insert command */ - strncpy((char *)pos, (char *)cmd, strlen(cmd)); - pos += (strlen(cmd)); - - /* Insert arguments */ - for (i = 0; i < num; i++) { - strncpy((char *)pos, args[i], strlen(args[i])); - pos += strlen(args[i]); - if (i < (num - 1)) { - strncpy((char *)pos, " ", strlen(" ")); - pos += 1; - } - } - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process OBSS scan table - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_scantable(void) -{ - char ssid[MRVDRV_MAX_SSID_LENGTH + 1] = { 0 }; - unsigned int scan_start; - int idx, i = 0, j, already_listed, ssid_len = 0, ssid_idx; - - t_u8 *pcurrent; - t_u8 *pnext; - IEEEtypes_ElementId_e *pelement_id; - t_u8 *pelement_len, ht_cap_present, intol_bit_is_set; - int ret = MLAN_STATUS_SUCCESS; - t_s32 bss_info_len = 0; - t_u32 fixed_field_length = 0; - - IEEEtypes_CapInfo_t cap_info; - t_u8 tsf[8]; - t_u16 beacon_interval; - IEEEtypes_HTCap_t *pht_cap; - - wlan_ioctl_get_scan_table_info *prsp_info; - wlan_get_scan_table_fixed fixed_fields; - - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Start preparing the buffer */ - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - memset(&cap_info, 0x00, sizeof(cap_info)); - memset(leg_ap_chan_list, 0, sizeof(leg_ap_chan_list)); - num_leg_ap_chan = 0; - - scan_start = 1; - - do { - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "getscantable", 0, NULL); - prsp_info = - (wlan_ioctl_get_scan_table_info *)(buffer + - strlen(CMD_NXP) + - strlen - ("getscantable")); - - prsp_info->scan_number = scan_start; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - if (errno == EAGAIN) { - ret = -EAGAIN; - } else { - perror("mlan2040coex"); - fprintf(stderr, - "mlan2040coex: getscantable fail\n"); - ret = MLAN_STATUS_FAILURE; - } - goto done; - } - - prsp_info = (wlan_ioctl_get_scan_table_info *)buffer; - pcurrent = 0; - pnext = prsp_info->scan_table_entry_buf; - - if (scan_start == 1) { - printf("----------------------------------------------\n"); - } - - for (idx = 0; (unsigned int)idx < prsp_info->scan_number; idx++) { - - /* - * Set pcurrent to pnext in case pad bytes are at the end - * of the last IE we processed. - */ - pcurrent = pnext; - - memcpy((t_u8 *)&fixed_field_length, - (t_u8 *)pcurrent, sizeof(fixed_field_length)); - pcurrent += sizeof(fixed_field_length); - - memcpy((t_u8 *)&bss_info_len, - (t_u8 *)pcurrent, sizeof(bss_info_len)); - pcurrent += sizeof(bss_info_len); - - memcpy((t_u8 *)&fixed_fields, - (t_u8 *)pcurrent, sizeof(fixed_fields)); - pcurrent += fixed_field_length; - - pnext = pcurrent + bss_info_len; - - if (bss_info_len >= (sizeof(tsf) - + sizeof(beacon_interval) + - sizeof(cap_info))) { - pcurrent += - (sizeof(tsf) + sizeof(beacon_interval) + - sizeof(cap_info)); - bss_info_len -= - (sizeof(tsf) + sizeof(beacon_interval) + - sizeof(cap_info)); - } - ht_cap_present = FALSE; - intol_bit_is_set = FALSE; - memset(ssid, 0, MRVDRV_MAX_SSID_LENGTH + 1); - ssid_len = 0; - while (bss_info_len >= 2) { - pelement_id = (IEEEtypes_ElementId_e *)pcurrent; - pelement_len = pcurrent + 1; - pcurrent += 2; - - switch (*pelement_id) { - case SSID: - if (*pelement_len && - *pelement_len <= - MRVDRV_MAX_SSID_LENGTH) { - memcpy(ssid, pcurrent, - *pelement_len); - ssid_len = *pelement_len; - } - break; - - case HT_CAPABILITY: - pht_cap = - (IEEEtypes_HTCap_t *) - pelement_id; - ht_cap_present = TRUE; - if (IS_INTOL_BIT_SET - (le16_to_cpu - (pht_cap->ht_cap.ht_cap_info))) { - intol_bit_is_set = TRUE; - } - break; - default: - break; - } - pcurrent += *pelement_len; - bss_info_len -= (2 + *pelement_len); - } - if (!ht_cap_present || intol_bit_is_set) { - printf("%s AP found on channel number: %-3d ", - intol_bit_is_set ? "40 MHZ intolerant" : - "Legacy", fixed_fields.channel); - if (ssid_len) { - printf("SSID: "); - /* Print out the ssid or the hex values if non-printable */ - for (ssid_idx = 0; ssid_idx < ssid_len; - ssid_idx++) { - if (isprint(ssid[ssid_idx])) { - printf("%c", - ssid[ssid_idx]); - } else { - printf("\\%02x", - ssid[ssid_idx]); - } - } - } - printf("\n"); - - /* Verify that the channel is already listed or not */ - already_listed = FALSE; - for (j = 0; j < i; j++) { - if (leg_ap_chan_list[j].chan_num == - fixed_fields.channel) { - already_listed = TRUE; - if (intol_bit_is_set) - leg_ap_chan_list[j]. - is_intol_set = - intol_bit_is_set; - break; - } - } - if (!already_listed) { - /* add the channel in list */ - leg_ap_chan_list[i].chan_num = - fixed_fields.channel; - leg_ap_chan_list[i].is_intol_set = - intol_bit_is_set; - i++; - coex_cmd_req_flag = TRUE; - num_leg_ap_chan++; - } - } - } - scan_start += prsp_info->scan_number; - - } while (prsp_info->scan_number); - -done: - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; -} - -/** BSS Mode any (both infra and adhoc) */ -#define BSS_MODE_ANY 3 - -/** current scan config parameters */ -#define SCAN_CFG_PARAMS 7 - -/** Active : 1 , Passive : 2 */ -#define SCAN_TYPE_ACTIVE 1 - -/** - * @brief Issue get scan type command - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -get_scan_cfg(int *scan_param) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int ret = MLAN_STATUS_SUCCESS; - - /* Start preparing the buffer */ - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "scancfg", 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: get_scan_cfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - scan_param = (int *)(buffer); -done: - if (cmd) - free(cmd); - if (buffer) - free(buffer); - - return ret; -} - -/** - * @brief Issue OBSS scan command - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_setuserscan(void) -{ - wlan_ioctl_user_scan_cfg scan_req; - int scan_cfg[SCAN_CFG_PARAMS]; - t_u8 *buffer = NULL, *pos = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int status = 0; - - memset(&scan_req, 0x00, sizeof(scan_req)); - memset(scan_cfg, 0x00, SCAN_CFG_PARAMS); - coex_cmd_req_flag = FALSE; - - if (get_scan_cfg(scan_cfg) != MLAN_STATUS_SUCCESS) { - printf("mlan2040coex: scancfg ioctl failure"); - return -EFAULT; - } - - if (scan_cfg[0] == SCAN_TYPE_ACTIVE) - scan_req.chan_list[0].scan_time = - (t_u32)le16_to_cpu(cur_obss_scan_param. - obss_scan_active_dwell); - else - scan_req.chan_list[0].scan_time = - (t_u32)le16_to_cpu(cur_obss_scan_param. - obss_scan_passive_total); - scan_req.bss_mode = (scan_cfg[1]) ? scan_cfg[1] : BSS_MODE_ANY; - - /* Start preparing the buffer */ - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "setuserscan", 0, NULL); - pos = buffer + strlen(CMD_NXP) + strlen("setuserscan"); - - /* buffer = buffer + 'scan_req' */ - memcpy(pos, &scan_req, sizeof(wlan_ioctl_user_scan_cfg)); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: setuserscan fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /** process scan results */ - do { - status = process_scantable(); - } while (status == -EAGAIN); - - if (cmd) - free(cmd); - if (buffer) - free(buffer); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Display usage - * - * @return NA - */ -static t_void -display_usage(t_void) -{ - t_u32 i; - for (i = 0; i < NELEMENTS(usage); i++) - fprintf(stderr, "%s\n", usage[i]); -} - -/** - * @brief get connection status - * - * @param data Pointer to the output buffer holding connection status - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - */ -int -get_connstatus(int *data) -{ - struct ether_addr apaddr; - struct ether_addr etherzero = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "getwap", 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: getwap fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - memset(&apaddr, 0, sizeof(struct ether_addr)); - memcpy(&apaddr, (struct ether_addr *)(buffer), - sizeof(struct ether_addr)); - - if (!memcmp(&apaddr, ðerzero, sizeof(struct ether_addr))) { - /* not associated */ - *data = FALSE; - } else { - /* associated */ - *data = TRUE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Print connect and disconnect event related information - * - * @param buffer Pointer to received event buffer - * @param size Length of the received event - * - * @return N/A - */ -void -print_event_drv_connected(t_u8 *buffer, t_u16 size) -{ - struct ether_addr *wap; - struct ether_addr etherzero = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; - char buf[32]; - - wap = (struct ether_addr *)(buffer + strlen(CUS_EVT_AP_CONNECTED)); - - if (!memcmp(wap, ðerzero, sizeof(struct ether_addr))) { - printf("---< Disconnected from AP >---\n"); - memset(&cur_obss_scan_param, 0, sizeof(cur_obss_scan_param)); - assoc_flag = FALSE; - is_ht_ap = FALSE; - } else { - memset(buf, 0, sizeof(buf)); - snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X", - wap->ether_addr_octet[0], - wap->ether_addr_octet[1], - wap->ether_addr_octet[2], - wap->ether_addr_octet[3], - wap->ether_addr_octet[4], wap->ether_addr_octet[5]); - printf("---< Connected to AP: %s >---\n", buf); - /** set TRUE, if connected */ - assoc_flag = TRUE; - } -} - -/** - * @brief Parse and print received event information - * - * @param event Pointer to received event - * @param size Length of the received event - * @param evt_conn A pointer to a output buffer. It sets TRUE when it gets - * the event CUS_EVT_OBSS_SCAN_PARAM, otherwise FALSE - * @param if_name The interface name - * - * @return N/A - */ -void -print_event(event_header *event, t_u16 size, int *evt_conn, char *if_name) -{ - if (!strncmp - (CUS_EVT_AP_CONNECTED, (char *)event, - strlen(CUS_EVT_AP_CONNECTED))) { - if (strlen(if_name)) - printf("EVENT for interface %s\n", if_name); - print_event_drv_connected((t_u8 *)event, size); - return; - } - if (!strncmp - (CUS_EVT_OBSS_SCAN_PARAM, (char *)event, - strlen(CUS_EVT_OBSS_SCAN_PARAM))) { - if (strlen(if_name)) - printf("EVENT for interface %s\n", if_name); - printf("---< %s >---\n", CUS_EVT_OBSS_SCAN_PARAM); - memset(&cur_obss_scan_param, 0, sizeof(cur_obss_scan_param)); - memcpy(&cur_obss_scan_param, - ((t_u8 *)event + strlen(CUS_EVT_OBSS_SCAN_PARAM) + 1), - sizeof(cur_obss_scan_param)); - /** set TRUE, since it is an HT AP */ - is_ht_ap = TRUE; - *evt_conn = TRUE; - return; - } - if (!strncmp - (CUS_EVT_BW_CHANGED, (char *)event, strlen(CUS_EVT_BW_CHANGED))) { - if (strlen(if_name)) - printf("EVENT for interface %s\n", if_name); - printf("---< %s >---\n", CUS_EVT_BW_CHANGED); - return; - } -} - -/** - * @brief This function parses for NETLINK events - * - * @param nlh Pointer to Netlink message header - * @param bytes_read Number of bytes to be read - * @param evt_conn A pointer to a output buffer. It sets TRUE when it gets - * the event CUS_EVT_OBSS_SCAN_PARAM, otherwise FALSE - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - */ -static int -drv_nlevt_handler(struct nlmsghdr *nlh, int bytes_read, int *evt_conn) -{ - int len, plen; - t_u8 *buffer = NULL; - t_u32 event_id = 0; - event_header *event = NULL; - char if_name[IFNAMSIZ + 1]; - - /* Initialize receive buffer */ - buffer = (t_u8 *)malloc(NL_MAX_PAYLOAD); - if (!buffer) { - printf("ERR: Could not alloc buffer\n"); - return MLAN_STATUS_FAILURE; - } - memset(buffer, 0, NL_MAX_PAYLOAD); - - *evt_conn = FALSE; - while ((unsigned int)bytes_read >= NLMSG_HDRLEN) { - len = nlh->nlmsg_len; /* Length of message including header */ - plen = len - NLMSG_HDRLEN; - if (len > bytes_read || plen < 0) { - free(buffer); - /* malformed netlink message */ - return MLAN_STATUS_FAILURE; - } - if ((unsigned int)len > NLMSG_SPACE(NL_MAX_PAYLOAD)) { - printf("ERR:Buffer overflow!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - memset(buffer, 0, NL_MAX_PAYLOAD); - memcpy(buffer, NLMSG_DATA(nlh), plen); - - if (NLMSG_OK(nlh, len)) { - memcpy(&event_id, buffer, sizeof(event_id)); - - if (((event_id & 0xFF000000) == 0x80000000) || - ((event_id & 0xFF000000) == 0)) { - event = (event_header *)buffer; - } else { - memset(if_name, 0, IFNAMSIZ + 1); - memcpy(if_name, buffer, IFNAMSIZ); - event = (event_header *)(buffer + IFNAMSIZ); - } - } - - print_event(event, bytes_read, evt_conn, if_name); - len = NLMSG_ALIGN(len); - bytes_read -= len; - nlh = (struct nlmsghdr *)((char *)nlh + len); - } - free(buffer); - return MLAN_STATUS_SUCCESS; -} - -/** Maximum event message length */ -#define MAX_MSG_LENGTH 1024 - -/** - * @brief Configure and read event data from netlink socket - * - * @param nl_sk Netlink socket handler - * @param msg Pointer to message header - * @param ptv Pointer to struct timeval - * - * @return Number of bytes read or MLAN_STATUS_FAILURE - */ -int -read_event(int nl_sk, struct msghdr *msg, struct timeval *ptv) -{ - int count = -1; - int ret = MLAN_STATUS_FAILURE; - fd_set rfds; - - /* Setup read fds and initialize event buffers */ - FD_ZERO(&rfds); - FD_SET(nl_sk, &rfds); - - /* Wait for reply */ - ret = select(nl_sk + 1, &rfds, NULL, NULL, ptv); - - if (ret == MLAN_STATUS_FAILURE) { - /* Error */ - terminate_flag++; - ptv->tv_sec = DEFAULT_SCAN_INTERVAL; - ptv->tv_usec = 0; - goto done; - } else if (!ret) { - if (assoc_flag && is_ht_ap) { - /** Issue OBSS scan */ - process_setuserscan(); - /** Invoke 2040coex command, if any legacy AP found or - * any AP has 40MHz intolarent bit set */ - if (coex_cmd_req_flag) - invoke_coex_command(); - } - if (assoc_flag && is_ht_ap) { - /* Timeout. Try again after BSS channel width triger scan - interval when the STA is connected with a HT AP */ - ptv->tv_sec = - (t_u32)le16_to_cpu(cur_obss_scan_param. - bss_chan_width_trigger_scan_int); - } else { - /* Timeout. Try again after default duration when the STA is - not connected with a HT AP */ - ptv->tv_sec = DEFAULT_SCAN_INTERVAL; - } - ptv->tv_usec = 0; - goto done; - } - - if (!FD_ISSET(nl_sk, &rfds)) { - /* Unexpected error. Try again */ - ptv->tv_sec = DEFAULT_SCAN_INTERVAL; - ptv->tv_usec = 0; - goto done; - } - /* Success */ - count = recvmsg(nl_sk, msg, 0); - -done: - return count; -} - -/** Maximum event message length */ -#define MAX_MSG_LENGTH 1024 -/** - * @brief Run the application - * - * @param nl_sk Netlink socket - * - * @return N/A - */ -void -run_app(int nl_sk) -{ - struct timeval tv; - int bytes_read, evt_conn; - struct msghdr msg; - struct sockaddr_nl dest_addr; - struct nlmsghdr *nlh; - struct iovec iov; - - /** Get connection status */ - if (get_connstatus(&assoc_flag) == MLAN_STATUS_FAILURE) - return; - - /* Initialize timeout value */ - tv.tv_sec = DEFAULT_SCAN_INTERVAL; - tv.tv_usec = 0; - - /* Initialize netlink header */ - nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); - if (!nlh) { - printf("ERR: Could not allocate space for netlink header\n"); - goto done; - } - memset(nlh, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); - /* Fill the netlink message header */ - nlh->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); - nlh->nlmsg_pid = getpid(); /* self pid */ - nlh->nlmsg_flags = 0; - - /* Initialize I/O vector */ - memset(&iov, 0, sizeof(struct iovec)); - iov.iov_base = (void *)nlh; - iov.iov_len = nlh->nlmsg_len; - - /* Set destination address */ - memset(&dest_addr, 0, sizeof(struct sockaddr_nl)); - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = 0; /* Kernel */ - dest_addr.nl_groups = NL_MULTICAST_GROUP; - - /* Initialize message header */ - memset(&msg, 0, sizeof(struct msghdr)); - msg.msg_name = (void *)&dest_addr; - msg.msg_namelen = sizeof(dest_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - while (!terminate_flag) { - /* event buffer is received for all the interfaces */ - bytes_read = read_event(nl_sk, &msg, &tv); - /* handle only NETLINK events here */ - drv_nlevt_handler((struct nlmsghdr *)nlh, bytes_read, - &evt_conn); - if (assoc_flag && is_ht_ap) { - /** If the event is connected with an HT AP then issue OBSS scan immediately */ - if (evt_conn) { - /** Issue OBSS scan */ - process_setuserscan(); - /** Invoke 2040coex command, if any legacy AP found or - * any AP has 40MHz intolarent bit set */ - if (coex_cmd_req_flag) - invoke_coex_command(); - } - tv.tv_sec = - (t_u32)le16_to_cpu(cur_obss_scan_param. - bss_chan_width_trigger_scan_int); - } else { - tv.tv_sec = DEFAULT_SCAN_INTERVAL; - } - tv.tv_usec = 0; - } - -done: - if (nl_sk > 0) - close(nl_sk); - if (nlh) - free(nlh); - return; -} - -/** - * @brief Determine the netlink number - * - * @return Netlink number to use - */ -static int -get_netlink_num(char *dev_name, int dev_index) -{ - FILE *fp = NULL; - int netlink_num = -1; - char str[64]; - char *srch = "netlink_num"; - char filename[64]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* if dev_index is specified by user */ - if (dev_index >= 0) { - /* Try to open old driver proc: /proc/mwlan/configX first */ - if (dev_index == 0) - strcpy(filename, "/proc/mwlan/config"); - else if (dev_index > 0) - sprintf(filename, "/proc/mwlan/config%d", dev_index); - fp = fopen(filename, "r"); - if (!fp) { - /* Try to open multi-adapter driver proc: /proc/mwlan/adapterX/config if old proc access fail */ - snprintf(filename, sizeof(filename), - "/proc/mwlan/adapter%d/config", dev_index); - fp = fopen(filename, "r"); - } - - if (fp) { - while (fgets(str, sizeof(str), fp)) { - if (strncmp(str, srch, strlen(srch)) == 0) { - netlink_num = - atoi(str + strlen(srch) + 1); - break; - } - } - fclose(fp); - } else { - return -1; - } - } else { - /* Start preparing the buffer */ - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return -1; - } - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "getnlnum", 0, NULL); - - cmd = (struct eth_priv_cmd *) - malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: getnlnum fail\n"); - goto done; - } - netlink_num = *(int *)(buffer); - } - -done: - if (cmd) - free(cmd); - if (buffer) - free(buffer); - printf("Netlink number = %d\n", netlink_num); - return netlink_num; -} - -/** - * @brief opens netlink socket to receive NETLINK events - * @return socket id --success, otherwise--MLAN_STATUS_FAILURE - */ -int -open_netlink(char *dev_name, int dev_index) -{ - int sk = -1; - struct sockaddr_nl src_addr; - int netlink_num = 0; - - netlink_num = get_netlink_num(dev_name, dev_index); - if (netlink_num < 0) { - printf("ERR:Could not get netlink socket. Invalid device number.\n"); - return sk; - } - - /* Open netlink socket */ - sk = socket(PF_NETLINK, SOCK_RAW, netlink_num); - if (sk < 0) { - printf("ERR:Could not open netlink socket.\n"); - return sk; - } - - /* Set source address */ - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = getpid(); - src_addr.nl_groups = NL_MULTICAST_GROUP; - - /* Bind socket with source address */ - if (bind(sk, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) { - printf("ERR:Could not bind socket!\n"); - close(sk); - return -1; - } - return sk; -} - -/** - * @brief Terminate signal handler - * @param signal Signal to handle - * @return NA - */ -static t_void -terminate_handler(int signal) -{ - printf("Stopping application.\n"); -#if DEBUG - printf("Process ID of process killed = %d\n", getpid()); -#endif - terminate_flag = TRUE; -} - -/******************************************************** - Global Functions -********************************************************/ -/** - * @brief Process host command - * @param hostcmd_idx Host command index - * @param chan_list A pointer to a channel list - * @param chan_num Number of channels in the channel list - * @param reg_class Regulatory class of the channels - * @param is_intol_ap_present Flag:is there any 40 MHz intolerant AP is present or not - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_host_cmd(int hostcmd_idx, t_u8 *chan_list, t_u8 chan_num, - t_u8 reg_class, t_u8 is_intol_ap_present) -{ - int ret = MLAN_STATUS_SUCCESS; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, "hostcmd", 0, NULL); - switch (hostcmd_idx) { - case CMD_2040COEX: - prepare_coex_cmd_buff(buffer + strlen(CMD_NXP) + - strlen("hostcmd"), chan_list, chan_num, - reg_class, is_intol_ap_present); - break; - default: - break; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: hostcmd fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - ret = process_host_cmd_resp("hostcmd", buffer); - -done: - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Check the STA is 40 MHz intolerant or not - * @param intol Flag: TRUE when the STA is 40 MHz intolerant, otherwise FALSE - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -is_intolerant_sta(int *intol) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int htcap_info, ret = MLAN_STATUS_SUCCESS; - - *intol = FALSE; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "htcapinfo", 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: htcapinfo fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - htcap_info = *((int *)(buffer)); - - if (htcap_info & MBIT(8)) - *intol = TRUE; - -done: - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief get region code - * @param reg_code Pointer to region code - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -get_region_code(int *reg_code) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int ret = MLAN_STATUS_SUCCESS; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* buffer = CMD_NXP + */ - prepare_buffer(buffer, "regioncode", 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlan2040coex"); - fprintf(stderr, "mlan2040coex: regioncode fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memcpy(reg_code, buffer, sizeof(int)); -done: - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; -} - -/** No option */ -#define NO_OPTION -1 - -/** - * @brief Entry function for coex - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -main(int argc, char *argv[]) -{ - char ifname[IFNAMSIZ + 1] = "mlan0"; - int c, daemonize = FALSE; - t_s32 nl_sk = 0; - /**< netlink socket descriptor to receive an event */ - int dev_index = -1; /** initialise with -1 to open multiple NETLINK Sockets */ - - char temp[2]; - int arg_count = 0; - int ifname_given = FALSE; - - memset(dev_name, 0, sizeof(dev_name)); - - for (;;) { - c = getopt(argc, argv, "Bhi:vd:"); - /* check if all command-line options have been parsed */ - if (c == NO_OPTION) - break; - - switch (c) { - case 'B': - daemonize = TRUE; - break; - case 'h': - display_usage(); - return MLAN_STATUS_SUCCESS; - case 'v': - fprintf(stdout, - "NXP 20/40coex application version %s\n", - COEX_VER); - return MLAN_STATUS_SUCCESS; - case 'i': - ifname_given = TRUE; - if (strlen(optarg) < IFNAMSIZ) - strncpy(ifname, optarg, IFNAMSIZ - 1); - else { - fprintf(stdout, "Interface name too long\n"); - display_usage(); - return MLAN_STATUS_SUCCESS; - } - arg_count += 1; - break; - case 'd': - strncpy(temp, optarg, strlen(optarg)); - if (isdigit(temp[0])) - dev_index = atoi(temp); - arg_count += 1; - break; - default: - fprintf(stdout, "Invalid argument\n"); - display_usage(); - return MLAN_STATUS_SUCCESS; - } - } - - if (!ifname_given) { - sprintf(ifname, "mlan%d", dev_index); - } - - if (optind < argc) { - fputs("Too many arguments.\n", stderr); - display_usage(); - goto done; - } - - strncpy(dev_name, ifname, IFNAMSIZ - 1); - - /* create a socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - fprintf(stderr, "mlan2040coex: Cannot open socket.\n"); - goto done; - } - - /* create netlink sockets and bind them with app side addr */ - nl_sk = open_netlink(dev_name, dev_index); - - if (nl_sk < 0) { - fprintf(stderr, "mlan2040coex: Cannot open netlink socket.\n"); - goto done; - } - - signal(SIGHUP, terminate_handler); /* catch hangup signal */ - signal(SIGTERM, terminate_handler); /* catch kill signal */ - signal(SIGINT, terminate_handler); /* catch kill signal */ - signal(SIGALRM, terminate_handler); /* catch kill signal */ - - /** Make the process background-process */ - if (daemonize) { - if (daemon(0, 0)) - fprintf(stderr, "mlan2040coex: Cannot start daemon\n"); - } - - /** run the application */ - run_app(nl_sk); - -done: - if (sockfd > 0) - close(sockfd); - if (nl_sk > 0) - close(nl_sk); - - return MLAN_STATUS_SUCCESS; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.h b/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.h deleted file mode 100644 index 6a344fc..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040coex.h +++ /dev/null @@ -1,234 +0,0 @@ -/** @file mlan2040coex.h - * - * @brief This file contains definitions for application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 06/24/2009: initial version -************************************************************************/ -#ifndef _COEX_H_ -#define _COEX_H_ - -/** NXP private command identifier */ -#define CMD_NXP "MRVL_CMD" - -/** IOCTL number */ -#define MLAN_ETH_PRIV (SIOCDEVPRIVATE + 14) - -#if (BYTE_ORDER == LITTLE_ENDIAN) -#undef BIG_ENDIAN_SUPPORT -#endif - -/** 16 bits byte swap */ -#define swap_byte_16(x) \ -((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \ - (((t_u16)(x) & 0xff00U) >> 8))) - -/** 32 bits byte swap */ -#define swap_byte_32(x) \ -((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \ - (((t_u32)(x) & 0x0000ff00UL) << 8) | \ - (((t_u32)(x) & 0x00ff0000UL) >> 8) | \ - (((t_u32)(x) & 0xff000000UL) >> 24))) - -/** 64 bits byte swap */ -#define swap_byte_64(x) \ - ((t_u64)((t_u64)(((t_u64)(x) & 0x00000000000000ffULL) << 56) | \ - (t_u64)(((t_u64)(x) & 0x000000000000ff00ULL) << 40) | \ - (t_u64)(((t_u64)(x) & 0x0000000000ff0000ULL) << 24) | \ - (t_u64)(((t_u64)(x) & 0x00000000ff000000ULL) << 8) | \ - (t_u64)(((t_u64)(x) & 0x000000ff00000000ULL) >> 8) | \ - (t_u64)(((t_u64)(x) & 0x0000ff0000000000ULL) >> 24) | \ - (t_u64)(((t_u64)(x) & 0x00ff000000000000ULL) >> 40) | \ - (t_u64)(((t_u64)(x) & 0xff00000000000000ULL) >> 56) )) - -/** Convert to correct endian format */ -#ifdef BIG_ENDIAN_SUPPORT -/** CPU to little-endian convert for 16-bit */ -#define cpu_to_le16(x) swap_byte_16(x) -/** CPU to little-endian convert for 32-bit */ -#define cpu_to_le32(x) swap_byte_32(x) -/** CPU to little-endian convert for 64-bit */ -#define cpu_to_le64(x) swap_byte_64(x) -/** Little-endian to CPU convert for 16-bit */ -#define le16_to_cpu(x) swap_byte_16(x) -/** Little-endian to CPU convert for 32-bit */ -#define le32_to_cpu(x) swap_byte_32(x) -/** Little-endian to CPU convert for 64-bit */ -#define le64_to_cpu(x) swap_byte_64(x) -#else -/** Do nothing */ -#define cpu_to_le16(x) (x) -/** Do nothing */ -#define cpu_to_le32(x) (x) -/** Do nothing */ -#define cpu_to_le64(x) (x) -/** Do nothing */ -#define le16_to_cpu(x) (x) -/** Do nothing */ -#define le32_to_cpu(x) (x) -/** Do nothing */ -#define le64_to_cpu(x) (x) -#endif - -#ifdef __GNUC__ -/** Structure packing begins */ -#define PACK_START -/** Structure packeing end */ -#define PACK_END __attribute__ ((packed)) -#else -/** Structure packing begins */ -#define PACK_START __packed -/** Structure packeing end */ -#define PACK_END -#endif - -/** Character, 1 byte */ -typedef signed char t_s8; -/** Unsigned character, 1 byte */ -typedef unsigned char t_u8; - -/** Short integer */ -typedef signed short t_s16; -/** Unsigned short integer */ -typedef unsigned short t_u16; - -/** Integer */ -typedef signed int t_s32; -/** Unsigned integer */ -typedef unsigned int t_u32; - -/** Long long integer */ -typedef signed long long t_s64; -/** Unsigned long long integer */ -typedef unsigned long long t_u64; - -/** Void pointer (4-bytes) */ -typedef void t_void; - -#ifdef FALSE -#undef FALSE -#endif - -#ifdef TRUE -#undef TRUE -#endif - -#ifndef MIN -/** Find minimum value */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -/** Type definition: boolean */ -typedef enum { FALSE, TRUE } boolean; - -/** Find number of elements */ -#define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) -/** Success */ -#define MLAN_STATUS_SUCCESS (0) -/** Failure */ -#define MLAN_STATUS_FAILURE (-1) - -/** Enumeration for host-command index */ -enum COMMANDS { - CMD_2040COEX = 1, -}; -/** Maximum number of channels that can be sent in a setuserscan ioctl */ -#define WLAN_IOCTL_USER_SCAN_CHAN_MAX 50 - -#ifndef ETH_ALEN -/** MAC address length */ -#define ETH_ALEN 6 -#endif - -/** Netlink protocol number */ -#define NETLINK_NXP (MAX_LINKS - 1) -/** Netlink maximum payload size */ -#define NL_MAX_PAYLOAD 1024 -/** Netlink multicast group number */ -#define NL_MULTICAST_GROUP RTMGRP_LINK -/** Default wait time in seconds for events */ -#define UAP_RECV_WAIT_DEFAULT 10 -#ifndef NLMSG_HDRLEN -/** NL message header length */ -#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) -#endif - -/** Event header */ -typedef PACK_START struct _event_header { - /** Event ID */ - t_u32 event_id; - /** Event data */ - t_u8 event_data[]; -} PACK_END event_header; - -/** Event ID length */ -#define EVENT_ID_LEN 4 - -/** Custom events definitions */ -/** AP connected event */ -#define CUS_EVT_AP_CONNECTED "EVENT=AP_CONNECTED" - -/** Custom event : BW changed */ -#define CUS_EVT_BW_CHANGED "EVENT=BW_CHANGED" -/** Custom event : OBSS scan parameter */ -#define CUS_EVT_OBSS_SCAN_PARAM "EVENT=OBSS_SCAN_PARAM" - -/** Custom events definitions end */ - -/** Structure defination of chan_intol_t*/ -typedef struct _chan_intol_t { - /** Channel numer */ - t_u8 chan_num; - /** Flag: Is any 40MHz intolerant AP found in this channel */ - t_u8 is_intol_set; -} chan_intol_t; - -/** Private command structure */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT -struct eth_priv_cmd { - /** Command buffer pointer */ - t_u64 buf; - /** buffer updated by driver */ - int used_len; - /** buffer sent by application */ - int total_len; -} __ATTRIB_PACK__; -#else -struct eth_priv_cmd { - /** Command buffer */ - t_u8 *buf; - /** Used length */ - int used_len; - /** Total length */ - int total_len; -}; -#endif - -/** Legacy APs channel list */ -extern chan_intol_t leg_ap_chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; -/** Total number of channel present in Legacy APs channel list */ -extern t_u8 num_leg_ap_chan; -int get_region_code(int *reg_code); -int process_host_cmd(int cmd, t_u8 *chan_list, t_u8 chan_num, t_u8 reg_class, - t_u8 is_intol_ap_present); -int is_intolerant_sta(int *intol); - -#endif /* _COEX_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.c b/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.c deleted file mode 100644 index e57947a..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.c +++ /dev/null @@ -1,281 +0,0 @@ -/** @file mlan2040misc.c - * - * @brief This file contains helper functions for coex application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 06/24/2009: initial version -************************************************************************/ -#include -#include -#include -#include -#include "mlan2040coex.h" -#include "mlan2040misc.h" - -/******************************************************** - Local Variables -********************************************************/ -/** Regulatory class and Channel mapping for various regions */ -static class_chan_t us_class_chan_t[] = { - {32, {1, 2, 3, 4, 5, 6, 7}, 7}, - {33, {5, 6, 7, 8, 9, 10, 11}, 7} -}; - -static class_chan_t europe_class_chan_t[] = { - {11, {1, 2, 3, 4, 5, 6, 7, 8, 9}, 9}, - {12, {5, 6, 7, 8, 9, 10, 11, 12, 13}, 9} -}; - -static class_chan_t japan_class_chan_t[] = { - {56, {1, 2, 3, 4, 5, 6, 7, 8, 9}, 9}, - {57, {5, 6, 7, 8, 9, 10, 11, 12, 13}, 9}, - {58, {14}, 1} -}; - -/** Region-code(Regulatory domain) and Class-channel table mapping */ -static region_class_chan_t region_class_chan_table[] = { - {0x10, us_class_chan_t, sizeof(us_class_chan_t) / sizeof(class_chan_t)} /* US */ - , - {0x20, us_class_chan_t, sizeof(us_class_chan_t) / sizeof(class_chan_t)} /* CANADA */ - , - {0x30, europe_class_chan_t, sizeof(europe_class_chan_t) / sizeof(class_chan_t)} /* EUROPE */ - , - {0x32, europe_class_chan_t, sizeof(europe_class_chan_t) / sizeof(class_chan_t)} /* FRANCE */ - , - {0x40, japan_class_chan_t, sizeof(japan_class_chan_t) / sizeof(class_chan_t)} /* JAPAN */ - , - {0x41, japan_class_chan_t, sizeof(japan_class_chan_t) / sizeof(class_chan_t)} /* JAPAN */ - , - {0x50, europe_class_chan_t, sizeof(europe_class_chan_t) / sizeof(class_chan_t)} /* CHINA */ -}; - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ -/** - * @brief This function prepares the channel list for a particular - * regulatory class from channel number for legacy AP - * @param cur_class_chan_table A pointer to the class_chan_t - * @param num_entry Number of entry in cur_class_chan_table table - * @param chan_list A pointer to the output channel list - * @param chan_num total number of channel in output channel list - * @param reg_domain regulatory domain - * @param reg_class regulatory class - * @param is_intol_ap_present It sets TRUE when 40MHz intolerant AP is found - * otherwise FALSE - * @return None - */ -static void -get_channels_for_specified_reg_class(class_chan_t *cur_class_chan_table, - int num_entry, t_u8 *chan_list, - t_u8 *chan_num, t_u8 reg_domain, - t_u8 reg_class, t_u8 *is_intol_ap_present) -{ - int i, j, k, idx = 0; - - *is_intol_ap_present = FALSE; - - /* For each regulatory class */ - for (i = 0; i < num_entry; i++) { - if (cur_class_chan_table[i].reg_class == reg_class) { - /* For each channel of the regulatory class */ - for (j = 0; j < cur_class_chan_table[i].total_chan; j++) { - for (k = 0; k < num_leg_ap_chan; k++) { - - if (cur_class_chan_table[i]. - channels[j] == - leg_ap_chan_list[k].chan_num) { - *(chan_list + idx) = - leg_ap_chan_list[k]. - chan_num; - idx++; - if (leg_ap_chan_list[k]. - is_intol_set) - *is_intol_ap_present = - TRUE; - } - } - } - break; - } - } - /* update the total number of channel */ - *chan_num = idx--; - return; -} - -/******************************************************** - Global Functions -********************************************************/ -/** - * @brief Prepare 2040 coex command buffer - * @param buf A pointer to the command buffer - * @param chan_list Channel list - * @param num_of_chan Number of channel present in channel list - * @param reg_class Regulatory class - * @param is_intol_ap_present Flag: is any 40 MHz intolerant AP - * is present in these chaanel set - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -void -prepare_coex_cmd_buff(t_u8 *buf, t_u8 *chan_list, t_u8 num_of_chan, - t_u8 reg_class, t_u8 is_intol_ap_present) -{ - HostCmd_DS_GEN *hostcmd; - MrvlIETypes_2040COEX_t *coex_ie = NULL; - MrvlIETypes_2040BssIntolerantChannelReport_t *bss_intol_ie = NULL; - t_u8 *pos = NULL; - int intol; - - hostcmd = (HostCmd_DS_GEN *)(buf + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_11N_2040COEX); - hostcmd->size = S_DS_GEN; - pos = buf + sizeof(t_u32) + S_DS_GEN; - { - coex_ie = (MrvlIETypes_2040COEX_t *)pos; - coex_ie->header.element_id = TLV_ID_2040COEX; - coex_ie->header.len = sizeof(coex_ie->coex_elem); - /* Check STA is 40 MHz intolerant or not */ - is_intolerant_sta(&intol); - if (intol) - coex_ie->coex_elem |= MBIT(1); - - if (is_intol_ap_present) - coex_ie->coex_elem |= MBIT(2); - pos += sizeof(MrvlIETypes_2040COEX_t); - hostcmd->size += sizeof(MrvlIETypes_2040COEX_t); - } - { - bss_intol_ie = - (MrvlIETypes_2040BssIntolerantChannelReport_t *)pos; - bss_intol_ie->header.element_id = - TLV_ID_2040BSS_INTOL_CHAN_REPORT; - hostcmd->size += - sizeof(MrvlIETypes_2040BssIntolerantChannelReport_t) - - sizeof(bss_intol_ie->chan_num); - bss_intol_ie->reg_class = reg_class; - memcpy(bss_intol_ie->chan_num, chan_list, num_of_chan); - bss_intol_ie->header.len = - sizeof(bss_intol_ie->reg_class) + num_of_chan; - hostcmd->size += num_of_chan; - } - hostcmd->size = cpu_to_le16(hostcmd->size); - return; -} - -/** - * @brief Invoke multiple 2040Coex commands for multiple regulatory classes - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -invoke_coex_command(void) -{ - int cur_reg_domain; - t_u8 chan_list[MAX_CHAN], is_intol_ap_present; - t_u8 num_of_chan; - int i, num_entry, ret = MLAN_STATUS_SUCCESS; - class_chan_t *cur_class_chan_table = NULL; - - /** get region code */ - ret = get_region_code(&cur_reg_domain); - if (ret != MLAN_STATUS_SUCCESS) - return ret; - /** Find region_class_chan_table for this region */ - for (i = 0; - (unsigned int)i < - (sizeof(region_class_chan_table) / sizeof(region_class_chan_t)); - i++) { - if (region_class_chan_table[i].reg_domain == cur_reg_domain) { - cur_class_chan_table = - region_class_chan_table[i].class_chan_list; - num_entry = - region_class_chan_table[i].num_class_chan_entry; - break; - } - } - if (cur_class_chan_table == NULL) { - printf("No region_class_chan table found for this region\n"); - return MLAN_STATUS_FAILURE; - } - - for (i = 0; i < num_entry; i++) { - /** Get channels for the specified regulatory class */ - get_channels_for_specified_reg_class(cur_class_chan_table, - num_entry, chan_list, - &num_of_chan, - cur_reg_domain, - cur_class_chan_table[i]. - reg_class, - &is_intol_ap_present); - - /** If any channel found for this regulatory class, then invoke the 2040coex command */ - if (num_of_chan > 0) { - ret = process_host_cmd(CMD_2040COEX, chan_list, - num_of_chan, - cur_class_chan_table[i]. - reg_class, is_intol_ap_present); - if (ret) - break; - } - } - return ret; -} - -/** - * @brief Process host_cmd response - * - * @param cmd_name The command string - * @param buf A pointer to the response buffer - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_host_cmd_resp(char *cmd_name, t_u8 *buf) -{ - t_u32 hostcmd_size = 0; - HostCmd_DS_GEN *hostcmd = NULL; - int ret = MLAN_STATUS_SUCCESS; - - buf += strlen(CMD_NXP) + strlen(cmd_name); - memcpy((t_u8 *)&hostcmd_size, buf, sizeof(t_u32)); - buf += sizeof(t_u32); - - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = le16_to_cpu(hostcmd->command); - hostcmd->size = le16_to_cpu(hostcmd->size); - - hostcmd->command &= ~HostCmd_RET_BIT; - if (!le16_to_cpu(hostcmd->result)) { - switch (hostcmd->command) { - } - } else { - printf("HOSTCMD failed: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - ret = MLAN_STATUS_FAILURE; - } - return ret; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.h b/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.h deleted file mode 100644 index 09f3594..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlan2040coex/mlan2040misc.h +++ /dev/null @@ -1,444 +0,0 @@ -/** @file mlan2040misc.h - * - * @brief This file contains command definitions for application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 06/24/2009: initial version -************************************************************************/ -#ifndef _COEX_MISC_H_ -#define _COEX_MISC_H_ - -/** MLAN MAC Address Length */ -#define MLAN_MAC_ADDR_LENGTH (6) -/** Size of command buffer */ -#define MRVDRV_SIZE_OF_CMD_BUFFER (3 * 1024) - -/** Command RET code, MSB is set to 1 */ -#define HostCmd_RET_BIT 0x8000 -/** General purpose action : Get */ -#define HostCmd_ACT_GEN_GET 0x0000 -/** General purpose action : Set */ -#define HostCmd_ACT_GEN_SET 0x0001 -/** TLV Id for 2040Coex IE */ -#define TLV_ID_2040COEX 0x48 -/** TLV Id for 2040BSS intolarent channel report IE */ -#define TLV_ID_2040BSS_INTOL_CHAN_REPORT 0x49 -/** Host-command for 2040coex command */ -#define HostCmd_CMD_11N_2040COEX 0x00e9 -/** Maximum scan response buffer size */ -#define SCAN_RESP_BUF_SIZE 2000 - -/** Maximum length of SSID */ -#define MRVDRV_MAX_SSID_LENGTH 32 - -/** Length of ethernet address */ -#ifndef ETH_ALEN -#define ETH_ALEN 6 -#endif -/** Maximum length of SSID list */ -#define MRVDRV_MAX_SSID_LIST_LENGTH 10 -/** Default scan interval in second*/ -#define DEFAULT_SCAN_INTERVAL 300 - -/** BIT value */ -#define MBIT(x) (((t_u32)1) << (x)) - -/** Check intolerent bit set */ -#define IS_INTOL_BIT_SET(cap_info) (cap_info & MBIT(14)) - -/** Check OBSS non-HT STAs present bit set */ -#define IS_NON_HT_STA_PRESENT(ht_info) (ht_info.field3 & MBIT(4)) - -/** IEEE Type definitions */ -typedef enum _IEEEtypes_ElementId_e { - SSID = 0, - SUPPORTED_RATES = 1, - FH_PARAM_SET = 2, - DS_PARAM_SET = 3, - CF_PARAM_SET = 4, - IBSS_PARAM_SET = 6, - HT_CAPABILITY = 45, - HT_OPERATION = 61, - BSSCO_2040 = 72, - OVERLAPBSSSCANPARAM = 74, - EXT_CAPABILITY = 127, - ERP_INFO = 42, - EXTENDED_SUPPORTED_RATES = 50, - VENDOR_SPECIFIC_221 = 221, - WMM_IE = VENDOR_SPECIFIC_221, - RSN_IE = 48, -} __attribute__ ((packed)) - IEEEtypes_ElementId_e; - -/** HT Capabilities Data */ - typedef struct _HTCap_t { - /** HT Capabilities Info field */ - t_u16 ht_cap_info; - /** A-MPDU Parameters field */ - t_u8 ampdu_param; - /** Supported MCS Set field */ - t_u8 supported_mcs_set[16]; - /** HT Extended Capabilities field */ - t_u16 ht_ext_cap; - /** Transmit Beamforming Capabilities field */ - t_u32 tx_bf_cap; - /** Antenna Selection Capability field */ - t_u8 asel; - /** Reserved set to 0 */ - t_u16 reserved; - } __attribute__ ((packed)) - HTCap_t, *pHTCap_t; - -/** HT Information Data */ - typedef struct _HTInfo_t { - /** Primary channel */ - t_u8 pri_chan; - /** Field 2 */ - t_u8 field2; - /** Field 3 */ - t_u16 field3; - /** Field 4 */ - t_u16 field4; - /** Bitmap indicating MCSs supported by all HT STAs in the BSS */ - t_u8 basic_mcs_set[16]; - /** Reserved set to 0 */ - t_u16 reserved; - } __attribute__ ((packed)) - HTInfo_t, *pHTInfo_t; - -/** 20/40 BSS Coexistence Data */ - typedef struct _BSSCo2040_t { - /** 20/40 BSS Coexistence value */ - t_u8 bss_co_2040_value; - /** Reserve field */ - t_u8 reserved[3]; - } __attribute__ ((packed)) - BSSCo2040_t, *pBSSCo2040_t; - -/** Extended Capabilities Data */ - typedef struct _ExtCap_t { - /** Extended Capabilities value */ - t_u8 ext_cap_value; - /** Reserved field */ - t_u8 reserved[3]; - } __attribute__ ((packed)) - ExtCap_t, *pExtCap_t; - -/** Overlapping BSS Scan Parameters Data */ - typedef struct _OverlapBSSScanParam_t { - /** OBSS Scan Passive Dwell */ - t_u16 obss_scan_passive_dwell; - /** OBSS Scan Active Dwell */ - t_u16 obss_scan_active_dwell; - /** BSS Channel Width Trigger Scan Interval */ - t_u16 bss_chan_width_trigger_scan_int; - /** OBSS Scan Passive Total Per Channel */ - t_u16 obss_scan_passive_total; - /** OBSS Scan Active Total Per Channel */ - t_u16 obss_scan_active_total; - /** BSS Width Channel Transition Delay Factor */ - t_u16 bss_width_chan_trans_delay; - /** OBSS Scan Activity Threshold */ - t_u16 obss_scan_active_threshold; - } __attribute__ ((packed)) - OBSSScanParam_t, *pOBSSScanParam_t; - -/** IEEEtypes_CapInfo_t structure*/ - typedef struct _IEEEtypes_CapInfo_t { - /** Capability Bit Map : ESS */ - t_u8 ess:1; - /** Capability Bit Map : IBSS */ - t_u8 ibss:1; - /** Capability Bit Map : CF pollable */ - t_u8 cf_pollable:1; - /** Capability Bit Map : CF poll request */ - t_u8 cf_poll_rqst:1; - /** Capability Bit Map : privacy */ - t_u8 privacy:1; - /** Capability Bit Map : Short preamble */ - t_u8 short_preamble:1; - /** Capability Bit Map : PBCC */ - t_u8 pbcc:1; - /** Capability Bit Map : Channel agility */ - t_u8 chan_agility:1; - /** Capability Bit Map : Spectrum management */ - t_u8 spectrum_mgmt:1; - /** Capability Bit Map : Reserved */ - t_u8 rsrvd3:1; - /** Capability Bit Map : Short slot time */ - t_u8 short_slot_time:1; - /** Capability Bit Map : APSD */ - t_u8 apsd:1; - /** Capability Bit Map : Reserved */ - t_u8 rsvrd2:1; - /** Capability Bit Map : DSS OFDM */ - t_u8 dsss_ofdm:1; - /** Capability Bit Map : Reserved */ - t_u8 rsrvd1:2; - } __attribute__ ((packed)) - IEEEtypes_CapInfo_t, *pIEEEtypes_CapInfo_t; - - typedef struct { - t_u8 chan_number; - /**< Channel Number to scan */ - t_u8 radio_type; - /**< Radio type: 'B/G' Band = 0, 'A' Band = 1 */ - t_u8 scan_type; - /**< Scan type: Active = 1, Passive = 2 */ - t_u8 reserved; - /**< Reserved */ - t_u32 scan_time; - /**< Scan duration in milliseconds; if 0 default used */ - } __attribute__ ((packed)) - wlan_ioctl_user_scan_chan; - - typedef struct { - char ssid[MRVDRV_MAX_SSID_LENGTH + 1]; - /**< SSID */ - t_u8 max_len; /**< Maximum length of SSID */ - } __attribute__ ((packed)) - wlan_ioctl_user_scan_ssid; - - typedef struct { - - /** Flag set to keep the previous scan table intact */ - t_u8 keep_previous_scan; /* Do not erase the existing scan results */ - - /** BSS mode to be sent in the firmware command */ - t_u8 bss_mode; - - /** Configure the number of probe requests for active chan scans */ - t_u8 num_probes; - - /** Reserved */ - t_u8 reserved; - - /** BSSID filter sent in the firmware command to limit the results */ - t_u8 specific_bssid[ETH_ALEN]; - /** SSID filter list used in the to limit the scan results */ - wlan_ioctl_user_scan_ssid ssid_list[MRVDRV_MAX_SSID_LIST_LENGTH]; - - /** Variable number (fixed maximum) of channels to scan up */ - wlan_ioctl_user_scan_chan chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; - - } __attribute__ ((packed)) - wlan_ioctl_user_scan_cfg; - -/** IEEE IE header */ - typedef struct _IEEEtypes_Header_t { - /** Element ID */ - t_u8 element_id; - /** Length */ - t_u8 len; - } __attribute__ ((packed)) - IEEEtypes_Header_t, *pIEEEtypes_Header_t; - -/** HT Capabilities IE */ - typedef struct _IEEEtypes_HTCap_t { - /** Generic IE header */ - IEEEtypes_Header_t ieee_hdr; - /** HTCap struct */ - HTCap_t ht_cap; - } __attribute__ ((packed)) - IEEEtypes_HTCap_t, *pIEEEtypes_HTCap_t; - -/** HT Information IE */ - typedef struct _IEEEtypes_HTInfo_t { - /** Generic IE header */ - IEEEtypes_Header_t ieee_hdr; - /** HTInfo struct */ - HTInfo_t ht_info; - } __attribute__ ((packed)) - IEEEtypes_HTInfo_t, *pIEEEtypes_HTInfo_t; - -/** 20/40 BSS Coexistence IE */ - typedef struct _IEEEtypes_2040BSSCo_t { - /** Generic IE header */ - IEEEtypes_Header_t ieee_hdr; - /** BSSCo2040_t struct */ - BSSCo2040_t bss_co_2040; - } __attribute__ ((packed)) - IEEEtypes_2040BSSCo_t, *pIEEEtypes_2040BSSCo_t; - -/** Extended Capabilities IE */ - typedef struct _IEEEtypes_ExtCap_t { - /** Generic IE header */ - IEEEtypes_Header_t ieee_hdr; - /** ExtCap_t struct */ - ExtCap_t ext_cap; - } __attribute__ ((packed)) - IEEEtypes_ExtCap_t, *pIEEEtypes_ExtCap_t; - -/** Overlapping BSS Scan Parameters IE */ - typedef struct _IEEEtypes_OverlapBSSScanParam_t { - /** Generic IE header */ - IEEEtypes_Header_t ieee_hdr; - /** OBSSScanParam_t struct */ - OBSSScanParam_t obss_scan_param; - } __attribute__ ((packed)) - IEEEtypes_OverlapBSSScanParam_t, *pIEEEtypes_OverlapBSSScanParam_t; - - typedef struct _wlan_get_scan_table_fixed { - /** BSSID of this network */ - t_u8 bssid[MLAN_MAC_ADDR_LENGTH]; - /** Channel this beacon/probe response was detected */ - t_u8 channel; - /** RSSI for the received packet */ - t_u8 rssi; - /** TSF value from the firmware at packet reception */ - t_u64 network_tsf; - } wlan_get_scan_table_fixed; - -/** - * Structure passed in the wlan_ioctl_get_scan_table_info for each - * BSS returned in the WLAN_GET_SCAN_RESP IOCTL - */ - typedef struct _wlan_ioctl_get_scan_table_entry { - /** - * Fixed field length included in the response. - * - * Length value is included so future fixed fields can be added to the - * response without breaking backwards compatibility. Use the length - * to find the offset for the bssInfoLength field, not a sizeof() calc. - */ - t_u32 fixed_field_length; - - /** - * Length of the BSS Information (probe resp or beacon) that - * follows starting at bssInfoBuffer - */ - t_u32 bss_info_length; - - /** - * Always present, fixed length data fields for the BSS - */ - wlan_get_scan_table_fixed fixed_fields; - - /* - * Probe response or beacon scanned for the BSS. - * - * Field layout: - * - TSF 8 octets - * - Beacon Interval 2 octets - * - Capability Info 2 octets - * - * - IEEE Infomation Elements; variable number & length per 802.11 spec - */ - /* t_u8 bss_info_buffer[1]; */ - } wlan_ioctl_get_scan_table_entry; - -/** - * Sructure to retrieve the scan table - */ - typedef struct { - /** - * - Zero based scan entry to start retrieval in command request - * - Number of scans entries returned in command response - */ - t_u32 scan_number; - /** - * Buffer marker for multiple wlan_ioctl_get_scan_table_entry structures. - * Each struct is padded to the nearest 32 bit boundary. - */ - t_u8 scan_table_entry_buf[1]; - } wlan_ioctl_get_scan_table_info; - -/* Define general hostcmd data structure */ -/** HostCmd_DS_GEN */ - typedef struct _HostCmd_DS_GEN { - /** Command */ - t_u16 command; - /** Size */ - t_u16 size; - /** Sequence number */ - t_u16 seq_num; - /** Result */ - t_u16 result; - } __attribute__ ((packed)) - HostCmd_DS_GEN; - -/** Size of HostCmd_DS_GEN */ -#define S_DS_GEN sizeof(HostCmd_DS_GEN) - -/** TLV related data structures*/ -/** MrvlIEtypesHeader_t */ - typedef struct _MrvlIEtypesHeader { - /** Header type */ - t_u16 type; - /** Header length */ - t_u16 len; - } __attribute__ ((packed)) - MrvlIEtypesHeader_t; - -/** _MrvlIETypes_2040BssIntolerantChannelReport_t */ - typedef struct _MrvlIETypes_2040BssIntolerantChannelReport_t { - /** Header */ - IEEEtypes_Header_t header; - /** regulatory class */ - t_u8 reg_class; - /** channel numbers for legacy AP */ - t_u8 chan_num[1]; - } __attribute__ ((packed)) - MrvlIETypes_2040BssIntolerantChannelReport_t; - -/** MrvlIETypes_2040COEX_t */ - typedef struct _MrvlIETypes_2040COEX_t { - /** Header */ - IEEEtypes_Header_t header; - /** 2040 coex element */ - t_u8 coex_elem; - } __attribute__ ((packed)) - MrvlIETypes_2040COEX_t; - - typedef struct _HostCmd_DS_CMD_11N_2040COEX { - /** 2040 coex element */ - MrvlIETypes_2040COEX_t coex; - /** 2040 BSS intolerant channel report*/ - MrvlIETypes_2040BssIntolerantChannelReport_t chan_intol_report; - } __attribute__ ((packed)) - HostCmd_DS_CMD_11N_2040COEX; - -/** Maximum number of channel per regulatory class */ -#define MAX_CHAN 20 - typedef struct _class_chan_t { - /** Regulatory class */ - t_u8 reg_class; - /** Channel numbers */ - t_u8 channels[MAX_CHAN]; - /** Total number of channels */ - t_u8 total_chan; - } class_chan_t; - - typedef struct _region_class_chan_t { - /** Regulatory domain */ - int reg_domain; - /** Channel numbers */ - class_chan_t *class_chan_list; - /** Number of class channel table entry */ - int num_class_chan_entry; - } region_class_chan_t; - - int process_host_cmd_resp(char *cmd_name, t_u8 *buf); - void prepare_coex_cmd_buff(t_u8 *buf, t_u8 *chan_list, t_u8 num_of_chan, - t_u8 reg_class, t_u8 is_intol_ap_present); - int invoke_coex_command(void); - -#endif /* _COEX_MISC_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf new file mode 100644 index 0000000..6c86bd7 --- /dev/null +++ b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf @@ -0,0 +1,23 @@ +# File : ed_mac_ctrl_V3_8997.conf +# +# ed_mac_ctrl_v3 is used for 88W8997, 88W8987, 88W8977 +# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V3_8997.conf ed_mac_ctrl_v3 +# +## Set Energy Detect Threshold for EU Adaptivity test + +ed_mac_ctrl_v3={ + CmdCode=0x0130 #Command code, DO NOT change this line + ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band + # 1 - enable EU adaptivity for 2.4GHz band + + ed_ctrl_2g.offset:2=0x0 # 0 - Default Energy Detect threshold + #offset value range: 0x80 to 0x7F + + ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band + # 1 - enable EU adaptivity for 5GHz band + + ed_ctrl_5g.offset:2=0x4 # 0 - Default Energy Detect threshold + #offset value range: 0x80 to 0x7F + + ed_ctrl_txq_lock:4=0xFF #DO NOT Change this line +} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf new file mode 100644 index 0000000..0f3b71a --- /dev/null +++ b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf @@ -0,0 +1,621 @@ +# File : txpwrlimit_cfg.conf +## Get CFG data for Tx power limitation +txpwrlimit_2g_cfg_get={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x00 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub0={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x10 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub1={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x11 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub2={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x12 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub3={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x13 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + +## Set CFG data for Tx power limitation +## +## TLVStartFreq: Starting Frequency of the band for this channel +## 2407, 2414 or 2400 for 2.4 GHz +## 5000 +## 4000 +## TLVChanWidth: Channel Width +## 20 +## TLVChanNum : Channel Number +## TLVPwr[] : ModulationGroup +## 0: CCK (1,2,5.5,11 Mbps) +## 1: OFDM (6,9,12,18 Mbps) +## 2: OFDM (24,36 Mbps) +## 3: OFDM (48,54 Mbps) +## 4: HT20 (MCS0,1,2) +## 5: HT20 (MCS3,4) +## 6: HT20 (MCS5,6,7) +## 7: HT40 (MCS0,1,2) +## 8: HT40 (MCS3,4) +## 9: HT40 (MCS5,6,7) +## 10: HT2_20 (MCS8,9,10) +## 11: HT2_20 (MCS11,12) +## 12: HT2_20 (MCS13,14,15) +## 13: HT2_40 (MCS8,9,10) +## 14: HT2_40 (MCS11,12) +## 15: HT2_40 (MCS13,14,15) +## 16: VHT_QAM256 (MCS8) +## 17: VHT_40_QAM256 (MCS8,9) +## 18: VHT_80_PSK (MCS0,1,2) +## 19: VHT_80_QAM16 (MCS3,4) +## 20: VHT_80_QAM64 (MCS5,6,7) +## 21: VHT_80_QAM256 (MCS8,9) +## 22: VHT2_20_QAM256 (MCS8,9) +## 23: VHT2_40_QAM256 (MCS8,9) +## 24: VHT2_80_PSK (MCS0, 1, 2) +## 25: VHT2_80_QAM16 (MCS3,4) +## 26: VHT2_80_QAM64 (MCS5,6,7) +## 27: VHT2_80_QAM256 (MCS8,9) +## Power Limit in dBm + +## For 40MHz modulation groups, specify same Tx power value for a set of +## two consecutive channel frequencies +## Valid channel sets: +## (36, 40), (44, 48), (52, 56), (60, 64) +## (100, 104), (108, 112), (116, 120), (124, 128), (132, 136), (140, 144) +## (149, 153), (157, 161) +## +## For 80MHz modulation groups, specify same Tx power value for a set of +## four consecutive channel frequencies +## Valid channel sets: +## (36, 40, 44, 48), (52, 56, 60, 64) +## (100, 104, 108, 112), (116, 120, 124, 128), (132, 136, 140, 144) +## (149, 153, 157, 161) + + +## 2G subband0 Tx power limit CFG +txpwrlimit_2g_cfg_set={ + CmdCode=0x00fb # do NOT change this line + Action:2=1 # 1 - SET + SubBand:2=0 # do NOT use this member in set cmd + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=1 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=2 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=3 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=4 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=5 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=6 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=7 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=8 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=9 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=10 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=11 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=12 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=13 + TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=14 + TLVPwr:32='0,12,1,12,2,12,3,12,4,12,5,12,6,12,7,12,8,12,9,12,10,12,11,12,12,12,13,12,14,12,15,12' + } +} + +## 5G subband1 Tx power limit CFG +txpwrlimit_5g_cfg_set_sub0={ + CmdCode=0x00fb # do NOT change this line + Action:2=1 # 1 - SET + SubBand:2=0 # do NOT use this member in set cmd + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=36 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=40 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=44 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=48 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=52 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=56 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=60 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=64 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } +} + +## 5G subband2 Tx power limit CFG +txpwrlimit_5g_cfg_set_sub1={ + CmdCode=0x00fb # do NOT change this line + Action:2=1 # 1 - SET + SubBand:2=0 # do NOT use this member in set cmd + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=100 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=104 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=108 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=112 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=116 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=120 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=124 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=128 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=132 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=136 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=140 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=144 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + +} + + +## 5G subband3 Tx power limit CFG +txpwrlimit_5g_cfg_set_sub2={ + CmdCode=0x00fb # do NOT change this line + Action:2=1 # 1 - SET + SubBand:2=0 # do NOT use this member in set cmd + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=149 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=153 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=157 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=161 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=165 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } +} + + +## 5G subband4 Tx power limit CFG +txpwrlimit_5g_cfg_set_sub3={ + CmdCode=0x00fb # do NOT change this line + Action:2=1 # 1 - SET + SubBand:2=0 # do NOT use this in set cmd + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=183 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=184 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=185 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=187 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=188 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=189 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=192 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=196 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=7 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=8 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=11 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=12 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=16 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=34 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } +} diff --git a/mxm_wifiex/wlan_src/mapp/mlanevent/Makefile b/mxm_wifiex/wlan_src/mapp/mlanevent/Makefile deleted file mode 100644 index 0254778..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanevent/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# File : mlanevent/Makefile -# -# Copyright 2014-2020 NXP - -# Path to the top directory of the wlan distribution -PATH_TO_TOP = ../.. - -# Determine how we should copy things to the install directory -ABSPATH := $(filter /%, $(INSTALLDIR)) -RELPATH := $(filter-out /%, $(INSTALLDIR)) -INSTALLPATH := $(ABSPATH) -ifeq ($(strip $(INSTALLPATH)),) -INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) -endif - -# Override CFLAGS for application sources, remove __ kernel namespace defines -CFLAGS := $(filter-out -D__%, $(ccflags-y)) -# remove KERNEL include dir -CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) - - -#CFLAGS += -DAP22 -fshort-enums -CFLAGS += -Wall -#ECHO = @ -LIBS = -lrt - - -.PHONY: default tags all - -OBJECTS = mlanevent.o -HEADERS = mlanevent.h - -TARGET = mlanevent.exe - -build default: $(TARGET) - @cp -f $(TARGET) $(INSTALLPATH) - -all : tags default - -$(TARGET): $(OBJECTS) $(HEADERS) - $(ECHO)$(CC) $(LIBS) -o $@ $(OBJECTS) - -%.o: %.c $(HEADERS) - $(ECHO)$(CC) $(CFLAGS) -c -o $@ $< - -tags: - ctags -R -f tags.txt - -distclean clean: - $(ECHO)$(RM) $(OBJECTS) $(TARGET) - $(ECHO)$(RM) tags.txt - diff --git a/mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.c b/mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.c deleted file mode 100644 index 70f52a1..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.c +++ /dev/null @@ -1,2565 +0,0 @@ -/** @file mlanevent.c - * - * @brief Program to receive events from the driver/firmware of the uAP - * driver. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/**************************************************************************** -Change log: - 03/18/08: Initial creation -****************************************************************************/ - -/**************************************************************************** - Header files -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "mlanevent.h" -#ifdef WIFI_DIRECT_SUPPORT -#include -#endif - -/**************************************************************************** - Definitions -****************************************************************************/ -/** Enable or disable debug outputs */ -#define DEBUG 0 - -/**************************************************************************** - Global variables -****************************************************************************/ -/** Termination flag */ -int terminate_flag = 0; - -/**************************************************************************** - Local functions -****************************************************************************/ -/** - * @brief Signal handler - * - * @param sig Received signal number - * @return N/A - */ -void -sig_handler(int sig) -{ - printf("Stopping application.\n"); -#if DEBUG - printf("Process ID of process killed = %d\n", getpid()); -#endif - terminate_flag = 1; -} - -/** - * @brief Dump hex data - * - * @param p A pointer to data buffer - * @param len The len of data buffer - * @param delim Deliminator character - * @return Hex integer - */ -static void -hexdump(void *p, t_s32 len, char delim) -{ - t_s32 i; - t_u8 *s = p; - for (i = 0; i < len; i++) { - if (i != len - 1) - printf("%02x%c", *s++, delim); - else - printf("%02x\n", *s); - if ((i + 1) % 16 == 0) - printf("\n"); - } -} - -/** - * @brief Hex to number - * - * @param c Hex value - * @return Integer value or -1 - */ -int -hex2num(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - - return -1; -} - -/** - * @brief Check hex string - * - * @param hex A pointer to hex string - * @return 0 or MLAN_EVENT_FAILURE - */ -int -ishexstring(void *hex) -{ - int i, a; - char *p = hex; - int len = strlen(p); - if (!strncasecmp("0x", p, 2)) { - p += 2; - len -= 2; - } - for (i = 0; i < len; i++) { - a = hex2num(*p); - if (a < 0) - return MLAN_EVENT_FAILURE; - p++; - } - return 0; -} - -/** - * @brief Convert char to hex integer - * - * @param chr Char - * @return Hex integer - */ -unsigned char -hexc2bin(char chr) -{ - if (chr >= '0' && chr <= '9') - chr -= '0'; - else if (chr >= 'A' && chr <= 'F') - chr -= ('A' - 10); - else if (chr >= 'a' && chr <= 'f') - chr -= ('a' - 10); - - return chr; -} - -/** - * @brief Convert string to hex integer - * - * @param s A pointer string buffer - * @return Hex integer - */ -unsigned int -a2hex(char *s) -{ - unsigned int val = 0; - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - while (*s && isxdigit(*s)) { - val = (val << 4) + hexc2bin(*s++); - } - return val; -} - -/** - * @brief Prints a MAC address in colon separated form from raw data - * - * @param raw A pointer to the hex data buffer - * @return N/A - */ -void -print_mac(t_u8 *raw) -{ - printf("%02x:%02x:%02x:%02x:%02x:%02x", (unsigned int)raw[0], - (unsigned int)raw[1], (unsigned int)raw[2], (unsigned int)raw[3], - (unsigned int)raw[4], (unsigned int)raw[5]); - return; -} - -/** - * @brief Print usage information - * - * @return N/A - */ -void -print_usage(void) -{ - printf("\n"); - printf("Usage : mlanevent.exe [-v] [-h]\n"); - printf(" -v : Print version information\n"); - printf(" -h : Print help information\n"); - printf(" -i : Specify device number from 0 to %d\n", - MAX_NO_OF_DEVICES - 1); - printf(" 0xff for all devices\n"); - printf("\n"); -} - -/** - * @brief Parse and print STA deauthentication event data - * - * @param buffer Pointer to received event buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_sta_deauth(t_u8 *buffer, t_u16 size) -{ - eventbuf_sta_deauth *event_body = NULL; - - if (size < sizeof(eventbuf_sta_deauth)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_sta_deauth *)buffer; - event_body->reason_code = uap_le16_to_cpu(event_body->reason_code); - printf("EVENT: STA_DEAUTH\n"); - printf("Deauthenticated STA MAC: "); - print_mac(event_body->sta_mac_address); - printf("\nReason: "); - switch (event_body->reason_code) { - case 1: - printf("Client station leaving the network\n"); - break; - case 2: - printf("Client station aged out\n"); - break; - case 3: - printf("Client station deauthenticated by user's request\n"); - break; - case 4: - printf("Client station authentication failure\n"); - break; - case 5: - printf("Client station association failure\n"); - break; - case 6: - printf("Client mac address is blocked by ACL filter\n"); - break; - case 7: - printf("Client station table is full\n"); - break; - case 8: - printf("Client 4-way handshake timeout\n"); - break; - case 9: - printf("Client group key handshake timeout\n"); - break; - default: - printf("Unspecified\n"); - break; - } - return; -} - -/** - * @brief Parse and print WEP ICV error event data - * - * @param buffer Pointer to received event buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_wep_icv_error(t_u8 *buffer, t_u16 size) -{ - int i = 0; - eventbuf_wep_icv_error *event_body = NULL; - - if (size < sizeof(eventbuf_wep_icv_error)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_wep_icv_error *)buffer; - event_body->reason_code = uap_le16_to_cpu(event_body->reason_code); - printf("EVENT: WEP_ICV_ERROR\n"); - printf("Deauthenticated STA MAC: "); - print_mac(event_body->sta_mac_address); - printf("WEP key index = %d\n", event_body->wep_key_index); - printf("WEP key length = %d\n", event_body->wep_key_length); - printf("WEP key : \n"); - for (i = 0; i < event_body->wep_key_length; i++) { - printf("%02x ", event_body->wep_key[i]); - } - printf("\n"); - return; -} - -/** - * @brief Prints mgmt frame - * - * @param mgmt_tlv A pointer to mgmt_tlv - * @param tlv_len Length of tlv payload - * @return N/A - */ -void -print_mgmt_frame(MrvlIETypes_MgmtFrameSet_t *mgmt_tlv, int tlv_len) -{ - IEEEtypes_AssocRqst_t *assoc_req = NULL; - IEEEtypes_ReAssocRqst_t *reassoc_req = NULL; - IEEEtypes_AssocRsp_t *assoc_resp = NULL; - t_u16 frm_ctl = 0; - printf("\nMgmt Frame:\n"); - memcpy(&frm_ctl, &mgmt_tlv->frame_control, sizeof(t_u16)); - printf("FrameControl: 0x%x\n", frm_ctl); - if (mgmt_tlv->frame_control.type != 0) { - printf("Frame type=%d subtype=%d:\n", - mgmt_tlv->frame_control.type, - mgmt_tlv->frame_control.sub_type); - hexdump(mgmt_tlv->frame_contents, tlv_len - sizeof(t_u16), ' '); - return; - } - switch (mgmt_tlv->frame_control.sub_type) { - case SUBTYPE_ASSOC_REQUEST: - printf("Assoc Request:\n"); - assoc_req = (IEEEtypes_AssocRqst_t *)mgmt_tlv->frame_contents; - printf("CapInfo: 0x%x ListenInterval: 0x%x \n", - uap_le16_to_cpu(assoc_req->cap_info), - uap_le16_to_cpu(assoc_req->listen_interval)); - printf("AssocReqIE:\n"); - hexdump(assoc_req->ie_buffer, - tlv_len - sizeof(IEEEtypes_AssocRqst_t) - - sizeof(IEEEtypes_FrameCtl_t), ' '); - break; - case SUBTYPE_REASSOC_REQUEST: - printf("ReAssoc Request:\n"); - reassoc_req = - (IEEEtypes_ReAssocRqst_t *)mgmt_tlv->frame_contents; - printf("CapInfo: 0x%x ListenInterval: 0x%x \n", - uap_le16_to_cpu(reassoc_req->cap_info), - uap_le16_to_cpu(reassoc_req->listen_interval)); - printf("Current AP address: "); - print_mac(reassoc_req->current_ap_addr); - printf("\nReAssocReqIE:\n"); - hexdump(reassoc_req->ie_buffer, - tlv_len - sizeof(IEEEtypes_ReAssocRqst_t) - - sizeof(IEEEtypes_FrameCtl_t), ' '); - break; - case SUBTYPE_ASSOC_RESPONSE: - case SUBTYPE_REASSOC_RESPONSE: - if (mgmt_tlv->frame_control.sub_type == SUBTYPE_ASSOC_RESPONSE) - printf("Assoc Response:\n"); - else - printf("ReAssoc Response:\n"); - assoc_resp = (IEEEtypes_AssocRsp_t *)mgmt_tlv->frame_contents; - printf("CapInfo: 0x%x StatusCode: %d AID: 0x%x \n", - uap_le16_to_cpu(assoc_resp->cap_info), - (int)(uap_le16_to_cpu(assoc_resp->status_code)), - uap_le16_to_cpu(assoc_resp->aid) & 0x3fff); - break; - default: - printf("Frame subtype = %d:\n", - mgmt_tlv->frame_control.sub_type); - hexdump(mgmt_tlv->frame_contents, tlv_len - sizeof(t_u16), ' '); - break; - } - return; -} - -/** - * @brief Parse and print RSN connect event data - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_rsn_connect(t_u8 *buffer, t_u16 size) -{ - int tlv_buf_left = size; - t_u16 tlv_type, tlv_len; - tlvbuf_header *tlv = NULL; - eventbuf_rsn_connect *event_body = NULL; - if (size < sizeof(eventbuf_rsn_connect)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_rsn_connect *)buffer; - printf("EVENT: RSN_CONNECT\n"); - printf("Station MAC: "); - print_mac(event_body->sta_mac_address); - printf("\n"); - tlv_buf_left = size - sizeof(eventbuf_rsn_connect); - if (tlv_buf_left < (int)sizeof(tlvbuf_header)) - return; - tlv = (tlvbuf_header *)(buffer + sizeof(eventbuf_rsn_connect)); - - while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { - tlv_type = uap_le16_to_cpu(tlv->type); - tlv_len = uap_le16_to_cpu(tlv->len); - if ((sizeof(tlvbuf_header) + tlv_len) > - (unsigned int)tlv_buf_left) { - printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, - tlv_buf_left); - break; - } - switch (tlv_type) { - case IEEE_WPA_IE: - printf("WPA IE:\n"); - hexdump((t_u8 *)tlv + sizeof(tlvbuf_header), tlv_len, - ' '); - break; - case IEEE_RSN_IE: - printf("RSN IE:\n"); - hexdump((t_u8 *)tlv + sizeof(tlvbuf_header), tlv_len, - ' '); - break; - default: - printf("unknown tlv: %d\n", tlv_type); - break; - } - tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); - tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + - sizeof(tlvbuf_header)); - } - return; -} - -/** - * @brief Parse and print STA associate event data - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_sta_assoc(t_u8 *buffer, t_u16 size) -{ - int tlv_buf_left = size; - t_u16 tlv_type, tlv_len; - tlvbuf_header *tlv = NULL; - MrvlIEtypes_WapiInfoSet_t *wapi_tlv = NULL; - MrvlIETypes_MgmtFrameSet_t *mgmt_tlv = NULL; - eventbuf_sta_assoc *event_body = NULL; - if (size < sizeof(eventbuf_sta_assoc)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_sta_assoc *)buffer; - printf("EVENT: STA_ASSOCIATE\n"); - printf("Associated STA MAC: "); - print_mac(event_body->sta_mac_address); - printf("\n"); - tlv_buf_left = size - sizeof(eventbuf_sta_assoc); - if (tlv_buf_left < (int)sizeof(tlvbuf_header)) - return; - tlv = (tlvbuf_header *)(buffer + sizeof(eventbuf_sta_assoc)); - - while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { - tlv_type = uap_le16_to_cpu(tlv->type); - tlv_len = uap_le16_to_cpu(tlv->len); - if ((sizeof(tlvbuf_header) + tlv_len) > - (unsigned int)tlv_buf_left) { - printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, - tlv_buf_left); - break; - } - switch (tlv_type) { - case MRVL_WAPI_INFO_TLV_ID: - wapi_tlv = (MrvlIEtypes_WapiInfoSet_t *)tlv; - printf("WAPI Multicast PN:\n"); - hexdump(wapi_tlv->multicast_PN, tlv_len, ' '); - break; - case MRVL_MGMT_FRAME_TLV_ID: - mgmt_tlv = (MrvlIETypes_MgmtFrameSet_t *)tlv; - print_mgmt_frame(mgmt_tlv, tlv_len); - break; - default: - printf("unknown tlv: %d\n", tlv_type); - break; - } - tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); - tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + - sizeof(tlvbuf_header)); - } - return; -} - -/** - * @brief Parse and print BSS start event data - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_bss_start(t_u8 *buffer, t_u16 size) -{ - eventbuf_bss_start *event_body = NULL; - int tlv_buf_left = size; - t_u16 tlv_type, tlv_len; - tlvbuf_header *tlv = NULL; - tlvbuf_channel_config *channel_tlv = NULL; - - if (size < sizeof(eventbuf_bss_start)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_bss_start *)buffer; - printf("EVENT: BSS_START "); - printf("BSS MAC: "); - print_mac(event_body->ap_mac_address); - printf("\n"); - tlv_buf_left = size - sizeof(eventbuf_bss_start); - if (tlv_buf_left < (int)sizeof(tlvbuf_header)) - return; - tlv = (tlvbuf_header *)(buffer + sizeof(eventbuf_bss_start)); - - while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { - tlv_type = uap_le16_to_cpu(tlv->type); - tlv_len = uap_le16_to_cpu(tlv->len); - if ((sizeof(tlvbuf_header) + tlv_len) > - (unsigned int)tlv_buf_left) { - printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, - tlv_buf_left); - break; - } - switch (tlv_type) { - case MRVL_CHANNELCONFIG_TLV_ID: - channel_tlv = (tlvbuf_channel_config *)tlv; - printf("Channel = %d\n", channel_tlv->chan_number); - printf("Band = %s\n", - (channel_tlv->bandcfg.chanBand == - BAND_5GHZ) ? "5GHz" : "2.4GHz"); - printf("Channel Select Mode = %s\n", - (channel_tlv->bandcfg.scanMode == - SCAN_MODE_ACS) ? "ACS" : "Manual"); - if (channel_tlv->bandcfg.chan2Offset == SEC_CHAN_NONE) - printf("no secondary channel\n"); - else if (channel_tlv->bandcfg.chan2Offset == - SEC_CHAN_ABOVE) - printf("secondary channel is above primary channel\n"); - else if (channel_tlv->bandcfg.chan2Offset == - SEC_CHAN_BELOW) - printf("secondary channel is below primary channel\n"); - break; - default: -#if DEBUG - printf("unknown tlv: %d\n", tlv_type); -#endif - break; - } - tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); - tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + - sizeof(tlvbuf_header)); - } - - return; -} - -/** - * @brief Parse and print MIC Countermeasures state - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_mic_countermeasures(t_u8 *buffer, t_u16 size) -{ - eventbuf_mic_countermeasures *event_body = NULL; - - if (size < sizeof(eventbuf_mic_countermeasures)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_mic_countermeasures *)buffer; - if (event_body->status) - printf("EVENT: Countermeasures active.\n"); - else - printf("EVENT: Countermeasures inactive\n"); - return; -} - -#ifdef WIFI_DIRECT_SUPPORT -/** - * @brief Print WIFI_WPS IE elements from event payload - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_wifi_wps_ie_elements(t_u8 *buffer, t_u16 size) -{ - t_u8 *ptr = buffer; - t_u8 *array_ptr; - int i; - t_u16 wps_len = 0, wps_type = 0; - t_u16 ie_len_wps = size; - - while (ie_len_wps > sizeof(tlvbuf_wps_ie)) { - memcpy(&wps_type, ptr, sizeof(t_u16)); - memcpy(&wps_len, ptr + 2, sizeof(t_u16)); - endian_convert_tlv_wps_header_in(wps_type, wps_len); - switch (wps_type) { - case SC_Version: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - printf("\t WPS Version = 0x%2x\n", - *(wps_tlv->data)); - } - break; - case SC_Simple_Config_State: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - printf("\t WPS setupstate = 0x%x\n", - *(wps_tlv->data)); - } - break; - case SC_Request_Type: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - printf("\t WPS RequestType = 0x%x\n", - *(wps_tlv->data)); - } - break; - case SC_Response_Type: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - printf("\t WPS ResponseType = 0x%x\n", - *(wps_tlv->data)); - } - break; - case SC_Config_Methods: - { - t_u16 wps_config_methods = 0; - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - memcpy(&wps_config_methods, wps_tlv->data, - sizeof(t_u16)); - wps_config_methods = ntohs(wps_config_methods); - printf("\t WPS SpecConfigMethods = 0x%x\n", - wps_config_methods); - } - break; - case SC_UUID_E: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS UUID = "); - for (i = 0; i < wps_len; i++) - printf("0x%02X ", *array_ptr++); - printf("\n"); - } - break; - case SC_Primary_Device_Type: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS Primary Device Type = "); - for (i = 0; i < wps_len; i++) - printf("0x%02X ", *array_ptr++); - printf("\n"); - } - break; - case SC_RF_Band: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - printf("\t WPS RF Band = 0x%x\n", - *(wps_tlv->data)); - } - break; - case SC_Association_State: - { - t_u16 wps_association_state = 0; - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - memcpy(&wps_association_state, wps_tlv->data, - sizeof(t_u16)); - wps_association_state = - ntohs(wps_association_state); - printf("\t WPS Association State = 0x%x\n", - wps_association_state); - } - break; - case SC_Configuration_Error: - { - t_u16 wps_configuration_error = 0; - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - memcpy(&wps_configuration_error, wps_tlv->data, - sizeof(t_u16)); - wps_configuration_error = - ntohs(wps_configuration_error); - printf("\t WPS Configuration Error = 0x%x\n", - wps_configuration_error); - } - break; - case SC_Device_Password_ID: - { - t_u16 wps_device_password_id = 0; - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - memcpy(&wps_device_password_id, wps_tlv->data, - sizeof(t_u16)); - wps_device_password_id = - ntohs(wps_device_password_id); - printf("\t WPS Device Password ID = 0x%x\n", - wps_device_password_id); - } - break; - case SC_Device_Name: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS Device Name = "); - for (i = 0; i < wps_len; i++) - printf("%c", *array_ptr++); - printf("\n"); - } - break; - case SC_Manufacturer: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS Manufacturer = "); - for (i = 0; i < wps_len; i++) - printf("%c", *array_ptr++); - printf("\n"); - } - break; - case SC_Model_Name: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS Model Name = "); - for (i = 0; i < wps_len; i++) - printf("%c", *array_ptr++); - printf("\n"); - } - break; - case SC_Model_Number: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS Model Number = "); - for (i = 0; i < wps_len; i++) - printf("%c", *array_ptr++); - printf("\n"); - } - break; - case SC_Serial_Number: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS Serial Number = "); - for (i = 0; i < wps_len; i++) - printf("%c", *array_ptr++); - printf("\n"); - } - break; - case SC_Vendor_Extension: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - array_ptr = wps_tlv->data; - printf("\t WPS 2.0 Vendor Extension = "); - for (i = 0; i < wps_len; i++) - printf("%x", *array_ptr++); - printf("\n"); - } - break; - case SC_Selected_Registrar: - { - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - printf("\t Selected Registrar = %d\n", - *(wps_tlv->data)); - } - break; - case SC_SelectedRegistrarConfigMethods: - { - t_u16 sr_config_methods = 0; - tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; - memcpy(&sr_config_methods, wps_tlv->data, - sizeof(t_u16)); - sr_config_methods = ntohs(sr_config_methods); - printf("\t Selected Registrar Configuration Methods = 0x%x\n", sr_config_methods); - } - break; - default: - printf("unknown ie=0x%x, len=%d\n", wps_type, wps_len); - break; - } - ptr += wps_len + sizeof(tlvbuf_wps_ie); - /* Take care of error condition */ - if (wps_len + sizeof(tlvbuf_wps_ie) <= ie_len_wps) - ie_len_wps -= wps_len + sizeof(tlvbuf_wps_ie); - else - ie_len_wps = 0; - } -} - -/** - * @brief Print WIFIDIRECT IE elements from event payload - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_wifidirect_ie_elements(t_u8 *buffer, t_u16 size) -{ - t_u8 *ptr = buffer; - t_u8 *array_ptr, *orig_ptr = NULL; - int i; - static t_u16 len = 0; - static t_u16 saved_len = 0; - static t_u16 pending_len = 0; - static t_u8 type = 0; - static t_u8 next_byte = WIFIDIRECT_OVERLAP_TYPE; - static t_u8 saved_data[WIFI_IE_MAX_PAYLOAD] = { 0 }; - t_u16 temp; - t_u16 left_len = size; - - while (left_len > 0) { - if (next_byte == WIFIDIRECT_OVERLAP_TYPE) { - type = *ptr; - next_byte = WIFIDIRECT_OVERLAP_LEN; - left_len--; - ptr++; - } - if (left_len >= sizeof(len) && - next_byte == WIFIDIRECT_OVERLAP_LEN) { - memcpy(&len, ptr, sizeof(t_u16)); - len = uap_le16_to_cpu(len); - next_byte = WIFIDIRECT_OVERLAP_DATA; - left_len -= sizeof(t_u16); - ptr += sizeof(t_u16); - - /* case when Type, Len in one frame and data in next */ - if (left_len == 0) { - memcpy(saved_data, - ptr - WIFIDIRECT_IE_HEADER_LEN, - WIFIDIRECT_IE_HEADER_LEN); - saved_len = WIFIDIRECT_IE_HEADER_LEN; - pending_len = len; - } - } - if (left_len > 0 && next_byte == WIFIDIRECT_OVERLAP_DATA) { - /* copy next data */ - if (pending_len > 0 && - (left_len <= (WIFI_IE_MAX_PAYLOAD - saved_len))) { - memcpy(saved_data + saved_len, ptr, - pending_len); - orig_ptr = ptr; - ptr = saved_data; - } else { - ptr -= WIFIDIRECT_IE_HEADER_LEN; - } - - if (!pending_len && !orig_ptr && left_len < len) { - /* save along with type and len */ - memcpy(saved_data, - ptr - WIFIDIRECT_IE_HEADER_LEN, - left_len + WIFIDIRECT_IE_HEADER_LEN); - saved_len = left_len + WIFIDIRECT_IE_HEADER_LEN; - pending_len = len - left_len; - break; - } - switch (type) { - case TLV_TYPE_WIFIDIRECT_DEVICE_ID: - { - tlvbuf_wifidirect_device_id - *wifidirect_tlv = - (tlvbuf_wifidirect_device_id *) - ptr; - printf("\t Device ID - "); - print_mac(wifidirect_tlv-> - dev_mac_address); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_CAPABILITY: - { - tlvbuf_wifidirect_capability - *wifidirect_tlv = - (tlvbuf_wifidirect_capability *) - ptr; - printf("\t Device capability = %d\n", - (int)wifidirect_tlv-> - dev_capability); - printf("\t Group capability = %d\n", - (int)wifidirect_tlv-> - group_capability); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT: - { - tlvbuf_wifidirect_group_owner_intent - *wifidirect_tlv = - (tlvbuf_wifidirect_group_owner_intent - *)ptr; - printf("\t Group owner intent = %d\n", - (int)wifidirect_tlv->dev_intent); - } - break; - case TLV_TYPE_WIFIDIRECT_MANAGEABILITY: - { - tlvbuf_wifidirect_manageability - *wifidirect_tlv = - (tlvbuf_wifidirect_manageability - *)ptr; - printf("\t Manageability = %d\n", - (int)wifidirect_tlv-> - manageability); - } - break; - case TLV_TYPE_WIFIDIRECT_INVITATION_FLAG: - { - tlvbuf_wifidirect_invitation_flag - *wifidirect_tlv = - (tlvbuf_wifidirect_invitation_flag - *)ptr; - printf("\t Invitation Flag = %d\n", - (int)wifidirect_tlv-> - invitation_flag & - INVITATION_FLAG_MASK); - } - break; - case TLV_TYPE_WIFIDIRECT_CHANNEL_LIST: - { - tlvbuf_wifidirect_channel_list - *wifidirect_tlv = - (tlvbuf_wifidirect_channel_list - *)ptr; - chan_entry *temp_ptr; - printf("\t Country String %c%c", - wifidirect_tlv-> - country_string[0], - wifidirect_tlv-> - country_string[1]); - if (isalpha - (wifidirect_tlv->country_string[2])) - printf("%c", - wifidirect_tlv-> - country_string[2]); - printf("\n"); - temp_ptr = - (chan_entry *)wifidirect_tlv-> - wifidirect_chan_entry_list; - temp = uap_le16_to_cpu(wifidirect_tlv-> - length) - - (sizeof - (tlvbuf_wifidirect_channel_list) - - WIFIDIRECT_IE_HEADER_LEN); - while (temp) { - printf("\t Regulatory_class = %d\n", (int)(temp_ptr->regulatory_class)); - printf("\t No of channels = %d\n", (int)temp_ptr->num_of_channels); - printf("\t Channel list = "); - for (i = 0; - i < - temp_ptr->num_of_channels; - i++) { - printf("%d ", - *(temp_ptr-> - chan_list + - i)); - } - printf("\n"); - temp -= sizeof(chan_entry) + - temp_ptr-> - num_of_channels; - temp_ptr = - (chan_entry *)((t_u8 *) - temp_ptr - + - sizeof - (chan_entry) - + - temp_ptr-> - num_of_channels); - } - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE: - { - tlvbuf_wifidirect_notice_of_absence - *wifidirect_tlv = - (tlvbuf_wifidirect_notice_of_absence - *)ptr; - noa_descriptor *temp_ptr; - printf("\t Instance of Notice of absence timing %d\n", (int)wifidirect_tlv->noa_index); - printf("\t CTWindow and Opportunistic power save parameters %d\n", (int)wifidirect_tlv->ctwindow_opp_ps); - temp_ptr = - (noa_descriptor *) - wifidirect_tlv-> - wifidirect_noa_descriptor_list; - temp = uap_le16_to_cpu(wifidirect_tlv-> - length) - - (sizeof - (tlvbuf_wifidirect_notice_of_absence) - - WIFIDIRECT_IE_HEADER_LEN); - while (temp) { - printf("\t Count or Type = %d\n", (int)temp_ptr->count_type); - printf("\t Duration = %dms\n", - uap_le32_to_cpu - (temp_ptr->duration)); - printf("\t Interval = %dms\n", - uap_le32_to_cpu - (temp_ptr->interval)); - printf("\t Start Time = %d\n", - uap_le32_to_cpu - (temp_ptr->start_time)); - printf("\n"); - temp_ptr += - sizeof(noa_descriptor); - temp -= sizeof(noa_descriptor); - } - } - break; - case TLV_TYPE_WIFIDIRECT_DEVICE_INFO: - { - tlvbuf_wifidirect_device_info - *wifidirect_tlv = - (tlvbuf_wifidirect_device_info - *)ptr; - printf("\t Device address - "); - print_mac(wifidirect_tlv->dev_address); - printf("\n"); - printf("\t Config methods - 0x%02X\n", - ntohs(wifidirect_tlv-> - config_methods)); - printf("\t Primay device type = %02d-%02X%02X%02X%02X-%02d\n", (int)ntohs(wifidirect_tlv->primary_category), (int)wifidirect_tlv->primary_oui[0], (int)wifidirect_tlv->primary_oui[1], (int)wifidirect_tlv->primary_oui[2], (int)wifidirect_tlv->primary_oui[3], (int)ntohs(wifidirect_tlv->primary_subcategory)); - printf("\t Secondary Device Count = %d\n", (int)wifidirect_tlv->secondary_dev_count); - array_ptr = - wifidirect_tlv-> - secondary_dev_info; - for (i = 0; - i < - wifidirect_tlv-> - secondary_dev_count; i++) { - memcpy(&temp, array_ptr, - sizeof(t_u16)); - printf("\t Secondary device type = %02d-", ntohs(temp)); - array_ptr += sizeof(temp); - printf("%02X%02X%02X%02X", - array_ptr[0], - array_ptr[1], - array_ptr[2], - array_ptr[3]); - array_ptr += 4; - memcpy(&temp, array_ptr, - sizeof(t_u16)); - printf("-%02d\n", ntohs(temp)); - array_ptr += sizeof(temp); - } - /* display device name */ - array_ptr = - wifidirect_tlv->device_name + - wifidirect_tlv-> - secondary_dev_count * - WPS_DEVICE_TYPE_LEN; - if (*(t_u16 *) - (((t_u8 *)(&wifidirect_tlv-> - device_name_len)) + - wifidirect_tlv-> - secondary_dev_count * - WPS_DEVICE_TYPE_LEN)) - printf("\t Device Name = "); - memcpy(&temp, - (((t_u8 *)(&wifidirect_tlv-> - device_name_len)) + - wifidirect_tlv-> - secondary_dev_count * - WPS_DEVICE_TYPE_LEN), - sizeof(t_u16)); - temp = ntohs(temp); - for (i = 0; i < temp; i++) - printf("%c", *array_ptr++); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUP_INFO: - { - tlvbuf_wifidirect_group_info - *wifidirect_tlv = - (tlvbuf_wifidirect_group_info *) - ptr; - t_u8 wifidirect_client_dev_length; - wifidirect_client_dev_info *temp_ptr; - temp_ptr = - (wifidirect_client_dev_info *) - wifidirect_tlv-> - wifidirect_client_dev_list; - if (temp_ptr == NULL) - break; - wifidirect_client_dev_length = - temp_ptr->dev_length; - temp = uap_le16_to_cpu(wifidirect_tlv-> - length) - - wifidirect_client_dev_length; - while (temp_ptr) { - - printf("\t Group WifiDirect Client Device address - "); - print_mac(temp_ptr-> - wifidirect_dev_address); - printf("\n"); - printf("\t Group WifiDirect Client Interface address - "); - print_mac(temp_ptr-> - wifidirect_intf_address); - printf("\n"); - printf("\t Group WifiDirect Client Device capability = %d\n", (int)temp_ptr->wifidirect_dev_capability); - printf("\t Group WifiDirect Client Config methods - 0x%02X\n", ntohs(temp_ptr->config_methods)); - printf("\t Group WifiDirect Client Primay device type = %02d-%02X%02X%02X%02X-%02d\n", (int)ntohs(temp_ptr->primary_category), (int)temp_ptr->primary_oui[0], (int)temp_ptr->primary_oui[1], (int)temp_ptr->primary_oui[2], (int)temp_ptr->primary_oui[3], (int)ntohs(temp_ptr->primary_subcategory)); - printf("\t Group WifiDirect Client Secondary Device Count = %d\n", (int)temp_ptr->wifidirect_secondary_dev_count); - array_ptr = - temp_ptr-> - wifidirect_secondary_dev_info; - for (i = 0; - i < - temp_ptr-> - wifidirect_secondary_dev_count; - i++) { - memcpy(&temp, array_ptr, - sizeof(t_u16)); - printf("\t Group WifiDirect Client Secondary device type = %02d-", ntohs(temp)); - array_ptr += - sizeof(temp); - printf("%02X%02X%02X%02X", array_ptr[0], array_ptr[1], array_ptr[2], array_ptr[3]); - array_ptr += 4; - memcpy(&temp, array_ptr, - sizeof(t_u16)); - printf("-%02d\n", - ntohs(temp)); - array_ptr += - sizeof(temp); - } - /* display device name */ - array_ptr = - temp_ptr-> - wifidirect_device_name + - temp_ptr-> - wifidirect_secondary_dev_count - * WPS_DEVICE_TYPE_LEN; - printf("\t Group WifiDirect Device Name = "); - memcpy(&temp, - (((t_u8 *)(&temp_ptr-> - wifidirect_device_name_len)) - + - temp_ptr-> - wifidirect_secondary_dev_count - * WPS_DEVICE_TYPE_LEN), - sizeof(t_u16)); - temp = ntohs(temp); - for (i = 0; i < temp; i++) - printf("%c", - *array_ptr++); - printf("\n"); - temp_ptr += - wifidirect_client_dev_length; - temp -= wifidirect_client_dev_length; - if (temp_ptr) - wifidirect_client_dev_length - = - temp_ptr-> - dev_length; - } - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUP_ID: - { - tlvbuf_wifidirect_group_id - *wifidirect_tlv = - (tlvbuf_wifidirect_group_id *) - ptr; - printf("\t Group address - "); - print_mac(wifidirect_tlv-> - group_address); - printf("\n"); - printf("\t Group ssid = "); - for (i = 0; - (unsigned int)i < - uap_le16_to_cpu(wifidirect_tlv-> - length) - - - (sizeof(tlvbuf_wifidirect_group_id) - - WIFIDIRECT_IE_HEADER_LEN); i++) - printf("%c", - wifidirect_tlv-> - group_ssid[i]); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID: - { - tlvbuf_wifidirect_group_bss_id - *wifidirect_tlv = - (tlvbuf_wifidirect_group_bss_id - *)ptr; - printf("\t Group BSS Id - "); - print_mac(wifidirect_tlv->group_bssid); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_INTERFACE: - { - tlvbuf_wifidirect_interface - *wifidirect_tlv = - (tlvbuf_wifidirect_interface *) - ptr; - printf("\t Interface Id - "); - print_mac(wifidirect_tlv->interface_id); - printf("\t Interface count = %d", - (int)wifidirect_tlv-> - interface_count); - for (i = 0; - i < - wifidirect_tlv->interface_count; - i++) { - printf("\n\t Interface address [%d]", i + 1); - print_mac(&wifidirect_tlv-> - interface_idlist[i * - ETH_ALEN]); - } - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_CHANNEL: - { - tlvbuf_wifidirect_channel - *wifidirect_tlv = - (tlvbuf_wifidirect_channel *) - ptr; - printf("\t Listen Channel Country String %c%c", wifidirect_tlv->country_string[0], wifidirect_tlv->country_string[1]); - if (isalpha - (wifidirect_tlv->country_string[2])) - printf("%c", - wifidirect_tlv-> - country_string[2]); - printf("\n"); - printf("\t Listen Channel regulatory class = %d\n", (int)wifidirect_tlv->regulatory_class); - printf("\t Listen Channel number = %d\n", (int)wifidirect_tlv->channel_number); - } - break; - - case TLV_TYPE_WIFIDIRECT_OPCHANNEL: - { - tlvbuf_wifidirect_channel - *wifidirect_tlv = - (tlvbuf_wifidirect_channel *) - ptr; - printf("\t Operating Channel Country String %c%c", wifidirect_tlv->country_string[0], wifidirect_tlv->country_string[1]); - if (isalpha - (wifidirect_tlv->country_string[2])) - printf("%c", - wifidirect_tlv-> - country_string[2]); - printf("\n"); - printf("\t Operating Channel regulatory class = %d\n", (int)wifidirect_tlv->regulatory_class); - printf("\t Operating Channel number = %d\n", (int)wifidirect_tlv->channel_number); - } - break; - - case TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT: - { - tlvbuf_wifidirect_config_timeout - *wifidirect_tlv = - (tlvbuf_wifidirect_config_timeout - *)ptr; - printf("\t GO configuration timeout = %d msec\n", (int)wifidirect_tlv->group_config_timeout * 10); - printf("\t Client configuration timeout = %d msec\n", (int)wifidirect_tlv->device_config_timeout * 10); - } - break; - case TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME: - { - tlvbuf_wifidirect_ext_listen_time - *wifidirect_tlv = - (tlvbuf_wifidirect_ext_listen_time - *)ptr; - printf("\t Availability Period = %d msec\n", (int)wifidirect_tlv->availability_period); - printf("\t Availability Interval = %d msec\n", (int)wifidirect_tlv->availability_interval); - } - break; - case TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS: - { - tlvbuf_wifidirect_intended_addr - *wifidirect_tlv = - (tlvbuf_wifidirect_intended_addr - *)ptr; - printf("\t Intended Interface Address - "); - print_mac(wifidirect_tlv-> - group_address); - printf("\n"); - } - break; - - case TLV_TYPE_WIFIDIRECT_STATUS: - { - tlvbuf_wifidirect_status *wifidirect_tlv - = - (tlvbuf_wifidirect_status *)ptr; - printf("\t Status = %d\n", - wifidirect_tlv->status_code); - } - break; - - default: - printf("unknown ie=0x%x, len=%d\n", type, len); - break; - } - next_byte = WIFIDIRECT_OVERLAP_TYPE; - if (orig_ptr) - ptr = orig_ptr + pending_len; - } - ptr += len + WIFIDIRECT_IE_HEADER_LEN; - left_len -= len; - } - printf("\n"); - return; -} - -/** - * @brief Parse and print WIFIDIRECT generic event data - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_wifidirect_generic(t_u8 *buffer, t_u16 size) -{ - const t_u8 wifi_oui[3] = { 0x50, 0x6F, 0x9A }; - const t_u8 wps_oui[3] = { 0x00, 0x50, 0xF2 }; - apeventbuf_wifidirect_generic *wifidirect_event; - wifidirect_ie_header *wifidirect_wps_header; - t_u16 wifidirect_wps_len = 0, type, sub_type; - printf("EVENT: WIFIDIRECT \n"); - wifidirect_event = (apeventbuf_wifidirect_generic *)(buffer); - printf("Event length = %d\n", - uap_le16_to_cpu(wifidirect_event->event_length)); - printf("Event Type = "); - type = uap_le16_to_cpu(wifidirect_event->event_type); - switch (type) { - case 0: - printf("Negotiation Request\n"); - break; - case 1: - printf("Negotiation Response\n"); - break; - case 2: - printf("Negotiation Result\n"); - break; - case 3: - printf("Invitation Request\n"); - break; - case 4: - printf("Invitation Response\n"); - break; - case 5: - printf("Discoverability Request\n"); - break; - case 6: - printf("Discoverability Response\n"); - break; - case 7: - printf("Provision Discovery Request\n"); - break; - case 8: - printf("Provision Discovery Response\n"); - break; - case 9: - printf("GO Negotiation response Tx Event\n"); - break; - case 10: - printf("GO Negotiation confirm Tx Event\n"); - break; - case 14: - printf("Peer Detected event\n"); - break; - case 15: - printf("Client associated event\n"); - break; - case 16: - printf("FW debug event: %s\n", - wifidirect_event->entire_ie_list); - return; - default: - printf("Unknown\n"); - break; - } - sub_type = uap_le16_to_cpu(wifidirect_event->event_sub_type); - if (type == 2) { - switch (sub_type) { - case 0: - printf("Event SubType = No Role\n"); - break; - case 1: - printf("Event SubType = Group Owner Role\n"); - break; - case 2: - printf("Event SubType = Client Role\n"); - break; - default: - printf("Event SubType = %d\n", sub_type); - break; - } - } else if (type == 3 || type == 4) { - switch (sub_type & 0x03) { /* lower 2 bits */ - case 0: - printf("Event SubType = No Role\n"); - break; - case 1: - printf("Event SubType = Group Owner Role\n"); - break; - case 2: - printf("Event SubType = Client Role\n"); - break; - } - switch ((sub_type & 0x1C) >> 2) { /* next 3 bits */ - case 0: - printf("Packet processing state = None\n"); - break; - case 1: - printf("Packet processing state = Processing\n"); - break; - case 2: - printf("Packet processing state = Insufficient information, Dropped\n"); - break; - case 3: - printf("Packet processing state = Success\n"); - break; - case 4: - printf("Packet processing state = Fail\n"); - break; - default: - printf("Event SubType = %d\n", sub_type); - break; - } - } else if (type == 7 || type == 8) { - switch (sub_type) { - case 0: - printf("Event SubType = No Config Method\n"); - break; - case 8: - printf("Event SubType = Config Method Display\n"); - break; - case 0x80: - printf("Event SubType = Config Method Push Button\n"); - break; - case 0x100: - printf("Event SubType = Config Method Keypad\n"); - break; - default: - printf("Event SubType = %d\n", sub_type); - break; - } - } - printf("Peer Mac Address - "); - print_mac(wifidirect_event->peer_mac_addr); - printf("\n"); - /* Print rest of IE elements */ - wifidirect_wps_header = - (wifidirect_ie_header *)(wifidirect_event->entire_ie_list); - wifidirect_wps_len = uap_le16_to_cpu(wifidirect_event->event_length) - - sizeof(apeventbuf_wifidirect_generic); - - while (wifidirect_wps_len >= sizeof(wifidirect_ie_header)) { - if (!memcmp - (wifidirect_wps_header->oui, wifi_oui, sizeof(wifi_oui)) || - !(memcmp - (wifidirect_wps_header->oui, wps_oui, sizeof(wps_oui)))) { - switch (wifidirect_wps_header->oui_type) { - case WIFIDIRECT_OUI_TYPE: - print_wifidirect_ie_elements - (wifidirect_wps_header->ie_list, - wifidirect_wps_header->ie_length - - sizeof(wifidirect_wps_header->oui) - - - sizeof(wifidirect_wps_header-> - oui_type)); - printf("\n"); - break; - case WIFI_WPS_OUI_TYPE: - print_wifi_wps_ie_elements - (wifidirect_wps_header->ie_list, - wifidirect_wps_header->ie_length - - sizeof(wifidirect_wps_header->oui) - - - sizeof(wifidirect_wps_header-> - oui_type)); - printf("\n"); - break; - } - } - wifidirect_wps_len -= - wifidirect_wps_header->ie_length + IE_HEADER_LEN; - wifidirect_wps_header = - (wifidirect_ie_header *)(((t_u8 *)wifidirect_wps_header) - + - wifidirect_wps_header-> - ie_length + IE_HEADER_LEN); - } -} - -/** - * @brief Parse and print WIFIDIRECT service discovery event data - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_wifidirect_service_discovery(t_u8 *buffer, t_u16 size) -{ - unsigned int i; - t_u16 event_len = 0; - t_u16 dns_len = 0, dns_type; - t_u8 action = 0; /* req = 0, resp = 1 */ - apeventbuf_wifidirect_discovery_request *wifidirect_disc_req; - apeventbuf_wifidirect_discovery_response *wifidirect_disc_resp; - printf("EVENT: WIFIDIRECT SERVICE DISCOVERY\n"); - memcpy(&event_len, buffer, sizeof(t_u16)); - event_len = uap_le16_to_cpu(event_len); - printf("Event length = %d\n", event_len); - printf("Service Discovery packet:\n"); - /* check request /response Byte at offset 2+6+2 */ - action = *(buffer + sizeof(t_u16) + ETH_ALEN + sizeof(t_u8)); - if (action == WIFIDIRECT_DISCOVERY_REQUEST_ACTION) { - wifidirect_disc_req = - (apeventbuf_wifidirect_discovery_request *)(buffer + - sizeof - (t_u16)); - printf("\t Peer Mac Address - "); - print_mac(wifidirect_disc_req->peer_mac_addr); - printf("\n\t Category = %d\n", wifidirect_disc_req->category); - printf("\t Action = %d\n", wifidirect_disc_req->action); - printf("\t Dialog taken = %d\n", - wifidirect_disc_req->dialog_taken); - printf("\t Advertize protocol IE - 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", wifidirect_disc_req->advertize_protocol_ie[0], wifidirect_disc_req->advertize_protocol_ie[1], wifidirect_disc_req->advertize_protocol_ie[2], wifidirect_disc_req->advertize_protocol_ie[3]); - printf("\t Request query length = %d\n", - uap_le16_to_cpu(wifidirect_disc_req->query_len)); - printf("\t Information Id - 0x%02x, 0x%02x\n", - wifidirect_disc_req->info_id[0], - wifidirect_disc_req->info_id[1]); - printf("\t Request length = %d\n", - uap_le16_to_cpu(wifidirect_disc_req->request_len)); - printf("\t OUI - 0x%02x, 0x%02x, 0x%02x\n", - wifidirect_disc_req->oui[0], wifidirect_disc_req->oui[1], - wifidirect_disc_req->oui[2]); - printf("\t OUI sub type = %d\n", - wifidirect_disc_req->oui_sub_type); - printf("\t Service update Indicator = %d\n", - uap_le16_to_cpu(wifidirect_disc_req-> - service_update_indicator)); - printf("\t Vendor length = %d\n", - uap_le16_to_cpu(wifidirect_disc_req->vendor_len)); - printf("\t Service protocol = %d\n", - wifidirect_disc_req->service_protocol); - printf("\t Service transaction Id = %d\n", - wifidirect_disc_req->service_transaction_id); - printf("\t Query Data = "); - if (wifidirect_disc_req->service_protocol == 1) { - printf(" * Bonjour * \n"); - printf("\t\t DNS = "); - dns_len = - uap_le16_to_cpu(wifidirect_disc_req-> - vendor_len) - - WIFIDIRECT_DISCOVERY_BONJOUR_FIXED_LEN; - for (i = 0; i < dns_len; i++) - printf("%02x ", - (int)*(wifidirect_disc_req->disc_query.u. - bonjour.dns + i)); - memcpy(&dns_type, - (&wifidirect_disc_req->disc_query.u.bonjour. - dns_type + dns_len), sizeof(dns_type)); - dns_type = uap_le16_to_cpu(dns_type); - printf("\n\t\t DNS Type = %d\n", dns_type); - printf("\t\t Version = %d\n", - *(&wifidirect_disc_req->disc_query.u.bonjour. - version + dns_len)); - } else if (wifidirect_disc_req->service_protocol == 2) { - printf(" * uPnP * \n"); - printf("\t\t Version = %d\n", - wifidirect_disc_req->disc_query.u.upnp.version); - dns_len = - uap_le16_to_cpu(wifidirect_disc_req-> - vendor_len) - - WIFIDIRECT_DISCOVERY_UPNP_FIXED_LEN; - printf("\t\t Value = "); - for (i = 0; i < dns_len; i++) - printf("%02x ", - (int)*(wifidirect_disc_req->disc_query.u. - upnp.value + i)); - } - printf("\n"); - } else if (action == WIFIDIRECT_DISCOVERY_RESPONSE_ACTION) { - wifidirect_disc_resp = - (apeventbuf_wifidirect_discovery_response *)(buffer + - sizeof - (t_u16)); - printf("\t Peer Mac Address - "); - print_mac(wifidirect_disc_resp->peer_mac_addr); - printf("\n\t Category = %d\n", wifidirect_disc_resp->category); - printf("\t Action = %d\n", wifidirect_disc_resp->action); - printf("\t Dialog taken = %d\n", - wifidirect_disc_resp->dialog_taken); - printf("\t Status code = %d\n", - wifidirect_disc_resp->status_code); - printf("\t GAS reply - 0x%02x\n", - uap_le16_to_cpu(wifidirect_disc_resp->gas_reply)); - printf("\t Advertize protocol IE - 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", wifidirect_disc_resp->advertize_protocol_ie[0], wifidirect_disc_resp->advertize_protocol_ie[1], wifidirect_disc_resp->advertize_protocol_ie[2], wifidirect_disc_resp->advertize_protocol_ie[3]); - printf("\t Response query length = %d\n", - uap_le16_to_cpu(wifidirect_disc_resp->query_len)); - printf("\t Information Id - 0x%02x, 0x%02x\n", - wifidirect_disc_resp->info_id[0], - wifidirect_disc_resp->info_id[1]); - printf("\t Response length = %d\n", - uap_le16_to_cpu(wifidirect_disc_resp->response_len)); - printf("\t OUI - 0x%02x, 0x%02x, 0x%02x\n", - wifidirect_disc_resp->oui[0], - wifidirect_disc_resp->oui[1], - wifidirect_disc_resp->oui[2]); - printf("\t OUI sub type = %d\n", - wifidirect_disc_resp->oui_sub_type); - printf("\t Service update Indicator = %d\n", - uap_le16_to_cpu(wifidirect_disc_resp-> - service_update_indicator)); - printf("\t Vendor length = %d\n", - uap_le16_to_cpu(wifidirect_disc_resp->vendor_len)); - printf("\t Service protocol = %d\n", - wifidirect_disc_resp->service_protocol); - printf("\t Service transaction Id = %d\n", - wifidirect_disc_resp->service_transaction_id); - printf("\t Status Code = %d\n", - wifidirect_disc_resp->disc_status_code); - printf("\t Response Data = "); - if (wifidirect_disc_resp->service_protocol == 1) { - printf(" * Bonjour * \n"); - /* - printf("\t\t DNS = "); - dns_len = uap_le16_to_cpu(wifidirect_disc_resp->vendor_len) - - (WIFIDIRECT_DISCOVERY_BONJOUR_FIXED_LEN + 1); - for( i=0; i < dns_len; i++) - printf("%c",*(wifidirect_disc_resp->disc_resp.u.bonjour.dns + i)); - memcpy(&dns_type, (&wifidirect_disc_req->disc_query.u.bonjour.dns_type - + dns_len), sizeof(dns_type)); - dns_type = uap_le16_to_cpu(dns_type); - printf("\n\t\t DNS Type = %d\n", dns_type); - printf("\t\t Version = %d\n", *(&wifidirect_disc_resp->disc_resp.u.bonjour.version - + dns_len)); - */ - } else if (wifidirect_disc_resp->service_protocol == 2) { - printf(" * uPnP * \n"); - printf("\t\t Version = %d\n", - wifidirect_disc_resp->disc_resp.u.upnp.version); - dns_len = - uap_le16_to_cpu(wifidirect_disc_resp-> - vendor_len) - - WIFIDIRECT_DISCOVERY_UPNP_FIXED_LEN; - printf("\t\t Value = "); - for (i = 0; i < dns_len; i++) - printf("%02x ", - (int)*(wifidirect_disc_resp->disc_resp.u. - upnp.value + i)); - } - printf("\n"); - } -} -#endif - -/** - * @brief Prints station reject state - * - * @param state Fail state - * @return N/A - */ -void -print_reject_state(t_u8 state) -{ - switch (state) { - case REJECT_STATE_FAIL_EAPOL_2: - printf("Reject state: FAIL_EAPOL_2\n"); - break; - case REJECT_STATE_FAIL_EAPOL_4: - printf("Reject state: FAIL_EAPOL_4:\n"); - break; - case REJECT_STATE_FAIL_EAPOL_GROUP_2: - printf("Reject state: FAIL_EAPOL_GROUP_2\n"); - break; - default: - printf("ERR: unknown reject state %d\n", state); - break; - } - return; -} - -/** - * @brief Prints station reject reason - * - * @param reason Reason code - * @return N/A - */ -void -print_reject_reason(t_u16 reason) -{ - switch (reason) { - case IEEEtypes_REASON_INVALID_IE: - printf("Reject reason: Invalid IE\n"); - break; - case IEEEtypes_REASON_MIC_FAILURE: - printf("Reject reason: Mic Failure\n"); - break; - default: - printf("Reject reason: %d\n", reason); - break; - } - return; -} - -/** - * @brief Prints EAPOL state - * - * @param state Eapol state - * @return N/A - */ -void -print_eapol_state(t_u8 state) -{ - switch (state) { - case EAPOL_START: - printf("Eapol state: EAPOL_START\n"); - break; - case EAPOL_WAIT_PWK2: - printf("Eapol state: EAPOL_WAIT_PWK2\n"); - break; - case EAPOL_WAIT_PWK4: - printf("Eapol state: EAPOL_WAIT_PWK4\n"); - break; - case EAPOL_WAIT_GTK2: - printf("Eapol state: EAPOL_WAIT_GTK2\n"); - break; - case EAPOL_END: - printf("Eapol state: EAPOL_END\n"); - break; - default: - printf("ERR: unknow eapol state%d\n", state); - break; - } - return; -} - -/** - * @brief Parse and print debug event data - * - * @param buffer Pointer to received buffer - * @param size Length of the received event data - * @return N/A - */ -void -print_event_debug(t_u8 *buffer, t_u16 size) -{ - eventbuf_debug *event_body = NULL; - if (size < sizeof(eventbuf_debug)) { - printf("ERR:Event buffer too small!\n"); - return; - } - event_body = (eventbuf_debug *)buffer; - printf("Debug Event Type: %s\n", - (event_body->debug_type == 0) ? "EVENT" : "INFO"); - printf("%s log:\n", - (uap_le32_to_cpu(event_body->debug_id_major) == - DEBUG_ID_MAJ_AUTHENTICATOR) ? "Authenticator" : "Assoc_agent"); - if (uap_le32_to_cpu(event_body->debug_id_major) == - DEBUG_ID_MAJ_AUTHENTICATOR) { - switch (uap_le32_to_cpu(event_body->debug_id_minor)) { - case DEBUG_MAJ_AUTH_MIN_PWK1: - printf("EAPOL Key message 1 (PWK):\n"); - hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, - sizeof(eapol_keymsg_debug_t), ' '); - break; - case DEBUG_MAJ_AUTH_MIN_PWK2: - printf("EAPOL Key message 2 (PWK):\n"); - hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, - sizeof(eapol_keymsg_debug_t), ' '); - break; - case DEBUG_MAJ_AUTH_MIN_PWK3: - printf("EAPOL Key message 3 (PWK):\n"); - hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, - sizeof(eapol_keymsg_debug_t), ' '); - break; - case DEBUG_MAJ_AUTH_MIN_PWK4: - printf("EAPOL Key message 4: (PWK)\n"); - hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, - sizeof(eapol_keymsg_debug_t), ' '); - break; - case DEBUG_MAJ_AUTH_MIN_GWK1: - printf("EAPOL Key message 1: (GWK)\n"); - hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, - sizeof(eapol_keymsg_debug_t), ' '); - break; - case DEBUG_MAJ_AUTH_MIN_GWK2: - printf("EAPOL Key message 2: (GWK)\n"); - hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, - sizeof(eapol_keymsg_debug_t), ' '); - break; - case DEBUG_MAJ_AUTH_MIN_STA_REJ: - printf("Reject STA MAC: "); - print_mac(event_body->info.sta_reject.sta_mac_addr); - printf("\n"); - print_reject_state(event_body->info.sta_reject. - reject_state); - print_reject_reason(uap_le16_to_cpu - (event_body->info.sta_reject. - reject_reason)); - break; - case DEBUG_MAJ_AUTH_MIN_EAPOL_TR: - printf("STA MAC: "); - print_mac(event_body->info.eapol_state.sta_mac_addr); - printf("\n"); - print_eapol_state(event_body->info.eapol_state. - eapol_state); - break; - default: - printf("ERR: unknow debug_id_minor: %d\n", - (int)uap_le32_to_cpu(event_body-> - debug_id_minor)); - hexdump(buffer, size, ' '); - return; - } - } else if (uap_le32_to_cpu(event_body->debug_id_major) == - DEBUG_ID_MAJ_ASSOC_AGENT) { - switch (uap_le32_to_cpu(event_body->debug_id_minor)) { - case DEBUG_ID_MAJ_ASSOC_MIN_WPA_IE: - printf("STA MAC: "); - print_mac(event_body->info.wpaie.sta_mac_addr); - printf("\n"); - printf("wpa ie:\n"); - hexdump(event_body->info.wpaie.wpa_ie, MAX_WPA_IE_LEN, - ' '); - break; - case DEBUG_ID_MAJ_ASSOC_MIN_STA_REJ: - printf("Reject STA MAC: "); - print_mac(event_body->info.sta_reject.sta_mac_addr); - printf("\n"); - print_reject_state(event_body->info.sta_reject. - reject_state); - print_reject_reason(uap_le16_to_cpu - (event_body->info.sta_reject. - reject_reason)); - break; - default: - printf("ERR: unknow debug_id_minor: %d\n", - (int)uap_le32_to_cpu(event_body-> - debug_id_minor)); - hexdump(buffer, size, ' '); - return; - } - } - return; -} - -/** - * @brief Parse and print received event information - * - * @param event Pointer to received event - * @param size Length of the received event - * @return N/A - */ -void -print_event(event_header *event, t_u16 size, char *if_name) -{ - t_u32 event_id = event->event_id; - switch (event_id) { - case MICRO_AP_EV_ID_STA_DEAUTH: - print_event_sta_deauth(event->event_data, size - EVENT_ID_LEN); - break; - case MICRO_AP_EV_ID_STA_ASSOC: - print_event_sta_assoc(event->event_data, size - EVENT_ID_LEN); - break; - case MICRO_AP_EV_ID_BSS_START: - print_event_bss_start(event->event_data, size - EVENT_ID_LEN); - break; - case MICRO_AP_EV_ID_DEBUG: - print_event_debug(event->event_data, size - EVENT_ID_LEN); - break; - case MICRO_AP_EV_BSS_IDLE: - printf("EVENT: BSS_IDLE\n"); - break; - case MICRO_AP_EV_BSS_ACTIVE: - printf("EVENT: BSS_ACTIVE\n"); - break; - case MICRO_AP_EV_RSN_CONNECT: - print_event_rsn_connect(event->event_data, size - EVENT_ID_LEN); - break; - case MICRO_AP_EV_ID_MIC_COUNTERMEASURES: - print_event_mic_countermeasures(event->event_data, - size - EVENT_ID_LEN); - break; -#ifdef WIFI_DIRECT_SUPPORT - case EVENT_WIFIDIRECT_GENERIC: - print_event_wifidirect_generic(event->event_data, - size - EVENT_ID_LEN); - break; - case EVENT_WIFIDIRECT_SERVICE_DISCOVERY: - print_event_wifidirect_service_discovery(event->event_data, - size - EVENT_ID_LEN); - break; -#endif - - case UAP_EVENT_ID_DRV_HS_ACTIVATED: - printf("EVENT: uAP HS_ACTIVATED\n"); - break; - case UAP_EVENT_ID_DRV_HS_DEACTIVATED: - printf("EVENT: uAP HS_DEACTIVATED\n"); - break; - case UAP_EVENT_ID_HS_WAKEUP: - printf("EVENT: uAP HS_WAKEUP\n"); - break; - case UAP_EVENT_HOST_SLEEP_AWAKE: - break; - case UAP_EVENT_ID_DRV_MGMT_FRAME: - printf("EVENT: Mgmt frame from FW\n"); - hexdump((void *)event, size, ' '); - break; - case MICRO_AP_EV_WMM_STATUS_CHANGE: - printf("EVENT: WMM_STATUS_CHANGE\n"); - break; - case EVENT_RADAR_DETECTED: - printf("EVENT: RADAR_DETECTED\n"); - break; - case EVENT_CHANNEL_REPORT_RDY: - printf("EVENT: CHANNEL_REPORT_READY\n"); - hexdump((void *)event, size, ' '); - break; - case EVENT_WEP_ICV_ERROR: - print_event_wep_icv_error(event->event_data, - size - EVENT_ID_LEN); - break; - case EVENT_ID_DRV_SCAN_REPORT: - printf("Scan request completed.\n"); - break; - - default: - /* Handle string based events */ -#define CUS_EVT_PORT_RELEASE "EVENT=PORT_RELEASE" - if (!strncmp - ((char *)event, CUS_EVT_PORT_RELEASE, - strlen(CUS_EVT_PORT_RELEASE))) { - printf("EVENT: PORT_RELEASE.\n"); - break; - } -#define CUS_EVT_TDLS_CONNECTED "EVENT=TDLS_CONNECTED" - if (!strncmp - ((char *)event, CUS_EVT_TDLS_CONNECTED, - strlen(CUS_EVT_TDLS_CONNECTED))) { - printf("EVENT: TDLS_CONNECTED\n"); - print_mac((t_u8 *)event + - strlen(CUS_EVT_TDLS_CONNECTED)); - printf("\n"); - break; - } -#define CUS_EVT_TDLS_TEARDOWN "EVENT=TDLS_TEARDOWN" - if (!strncmp - ((char *)event, CUS_EVT_TDLS_TEARDOWN, - strlen(CUS_EVT_TDLS_TEARDOWN))) { - printf("EVENT: TDLS_TEARDOWN\n"); - print_mac((t_u8 *)event + - strlen(CUS_EVT_TDLS_TEARDOWN)); - printf("\n"); - break; - } -#define CUS_EVT_STA_CONNECTED "EVENT=STA_CONNECTED" - if (!strncmp - ((char *)event, CUS_EVT_STA_CONNECTED, - strlen(CUS_EVT_STA_CONNECTED))) { - printf("EVENT: STA_CONNECTED\n"); - print_mac((t_u8 *)event + - strlen(CUS_EVT_STA_CONNECTED) + 1); - printf("\n"); - break; - } -#define CUS_EVT_STA_DISCONNECTED "EVENT=STA_DISCONNECTED" - if (!strncmp - ((char *)event, CUS_EVT_STA_DISCONNECTED, - strlen(CUS_EVT_STA_DISCONNECTED))) { - printf("EVENT: STA_DISCONNECTED\n"); - break; - } -#define CUS_EVT_AP_CONNECTED "EVENT=AP_CONNECTED" - if (!strncmp - ((char *)event, CUS_EVT_AP_CONNECTED, - strlen(CUS_EVT_AP_CONNECTED))) { - printf("EVENT: AP_CONNECTED\n"); - print_mac((t_u8 *)event + strlen(CUS_EVT_AP_CONNECTED)); - printf("\n"); - break; - } -#define CUS_EVT_ADHOC_LINK_SENSED "EVENT=ADHOC_LINK_SENSED" - if (!strncmp - ((char *)event, CUS_EVT_ADHOC_LINK_SENSED, - strlen(CUS_EVT_ADHOC_LINK_SENSED))) { - printf("EVENT: ADHOC_LINK_SENSED\n"); - break; - } -#define CUS_EVT_ADHOC_LINK_LOST "EVENT=ADHOC_LINK_LOST" - if (!strncmp - ((char *)event, CUS_EVT_ADHOC_LINK_LOST, - strlen(CUS_EVT_ADHOC_LINK_LOST))) { - printf("EVENT: ADHOC_LINK_LOST\n"); - break; - } -#define CUS_EVT_OBSS_SCAN_PARAM "EVENT=OBSS_SCAN_PARAM" - if (!strncmp - ((char *)event, CUS_EVT_OBSS_SCAN_PARAM, - strlen(CUS_EVT_OBSS_SCAN_PARAM))) { - printf("EVENT: OBSS_SCAN_PARAM\n"); - break; - } -#define CUS_EVT_BW_CHANGED "EVENT=BW_CHANGED" - if (!strncmp - ((char *)event, CUS_EVT_BW_CHANGED, - strlen(CUS_EVT_BW_CHANGED))) { - printf("EVENT: BW_CHANGED\n"); - break; - } -#define CUS_EVT_MLME_MIC_ERR_UNI "MLME-MICHAELMICFAILURE.indication unicast" - if (!strncmp - ((char *)event, CUS_EVT_MLME_MIC_ERR_UNI, - strlen(CUS_EVT_MLME_MIC_ERR_UNI))) { - printf("EVENT: MLME-MICHAELMICFAILURE.indication unicast\n"); - break; - } -#define CUS_EVT_MLME_MIC_ERR_MUL "MLME-MICHAELMICFAILURE.indication multicast" - if (!strncmp - ((char *)event, CUS_EVT_MLME_MIC_ERR_MUL, - strlen(CUS_EVT_MLME_MIC_ERR_MUL))) { - printf("EVENT: MLME-MICHAELMICFAILURE.indication multicast\n"); - break; - } -#define CUS_EVT_BEACON_RSSI_LOW "EVENT=BEACON_RSSI_LOW" - if (!strncmp - ((char *)event, CUS_EVT_BEACON_RSSI_LOW, - strlen(CUS_EVT_BEACON_RSSI_LOW))) { - printf("EVENT: BEACON_RSSI_LOW\n"); - break; - } -#define CUS_EVT_BEACON_RSSI_HIGH "EVENT=BEACON_RSSI_HIGH" - if (!strncmp - ((char *)event, CUS_EVT_BEACON_RSSI_HIGH, - strlen(CUS_EVT_BEACON_RSSI_HIGH))) { - printf("EVENT: BEACON_RSSI_HIGH\n"); - break; - } -#define CUS_EVT_BEACON_SNR_LOW "EVENT=BEACON_SNR_LOW" - if (!strncmp - ((char *)event, CUS_EVT_BEACON_SNR_LOW, - strlen(CUS_EVT_BEACON_SNR_LOW))) { - printf("EVENT: BEACON_SNR_LOW\n"); - break; - } -#define CUS_EVT_BEACON_SNR_HIGH "EVENT=BEACON_SNR_HIGH" - if (!strncmp - ((char *)event, CUS_EVT_BEACON_SNR_HIGH, - strlen(CUS_EVT_BEACON_SNR_HIGH))) { - printf("EVENT: BEACON_SNR_HIGH\n"); - break; - } -#define CUS_EVT_MAX_FAIL "EVENT=MAX_FAIL" - if (!strncmp - ((char *)event, CUS_EVT_MAX_FAIL, - strlen(CUS_EVT_MAX_FAIL))) { - printf("EVENT: MAX_FAIL\n"); - break; - } -#define CUS_EVT_DATA_RSSI_LOW "EVENT=DATA_RSSI_LOW" - if (!strncmp - ((char *)event, CUS_EVT_DATA_RSSI_LOW, - strlen(CUS_EVT_DATA_RSSI_LOW))) { - printf("EVENT: DATA_RSSI_LOW\n"); - break; - } -#define CUS_EVT_DATA_SNR_LOW "EVENT=DATA_SNR_LOW" - if (!strncmp - ((char *)event, CUS_EVT_DATA_SNR_LOW, - strlen(CUS_EVT_DATA_SNR_LOW))) { - printf("EVENT: DATA_SNR_LOW\n"); - break; - } -#define CUS_EVT_DATA_RSSI_HIGH "EVENT=DATA_RSSI_HIGH" - if (!strncmp - ((char *)event, CUS_EVT_DATA_RSSI_HIGH, - strlen(CUS_EVT_DATA_RSSI_HIGH))) { - printf("EVENT: DATA_RSSI_HIGH\n"); - break; - } -#define CUS_EVT_DATA_SNR_HIGH "EVENT=DATA_SNR_HIGH" - if (!strncmp - ((char *)event, CUS_EVT_DATA_SNR_HIGH, - strlen(CUS_EVT_DATA_SNR_HIGH))) { - printf("EVENT: DATA_SNR_HIGH\n"); - break; - } -#define CUS_EVT_LINK_QUALITY "EVENT=LINK_QUALITY" - if (!strncmp - ((char *)event, CUS_EVT_LINK_QUALITY, - strlen(CUS_EVT_LINK_QUALITY))) { - printf("EVENT: LINK_QUALITY\n"); - break; - } -#define CUS_EVT_WEP_ICV_ERR "EVENT=WEP_ICV_ERR" - if (!strncmp - ((char *)event, CUS_EVT_WEP_ICV_ERR, - strlen(CUS_EVT_WEP_ICV_ERR))) { - printf("EVENT: WEP_ICV_ERR\n"); - break; - } -#define CUS_EVT_CHANNEL_SWITCH_ANN "EVENT=CHANNEL_SWITCH_ANN" - if (!strncmp - ((char *)event, CUS_EVT_CHANNEL_SWITCH_ANN, - strlen(CUS_EVT_CHANNEL_SWITCH_ANN))) { - printf("EVENT: CHANNEL_SWITCH_ANN\n"); - break; - } -#define CUS_EVT_HS_WAKEUP "HS_WAKEUP" - if (!strncmp - ((char *)event, CUS_EVT_HS_WAKEUP, - strlen(CUS_EVT_HS_WAKEUP))) { - printf("EVENT: HS_WAKEUP\n"); - break; - } -#define CUS_EVT_HS_ACTIVATED "HS_ACTIVATED" - if (!strncmp - ((char *)event, CUS_EVT_HS_ACTIVATED, - strlen(CUS_EVT_HS_ACTIVATED))) { - printf("EVENT: HS_ACTIVATED\n"); - break; - } -#define CUS_EVT_HS_DEACTIVATED "HS_DEACTIVATED" - if (!strncmp - ((char *)event, CUS_EVT_HS_DEACTIVATED, - strlen(CUS_EVT_HS_DEACTIVATED))) { - printf("EVENT: HS_DEACTIVATED\n"); - break; - } -/** Custom indication message sent to the application layer for WMM changes */ -#define WMM_CONFIG_CHANGE_INDICATION "WMM_CONFIG_CHANGE.indication" - if (!strncmp - ((char *)event, WMM_CONFIG_CHANGE_INDICATION, - strlen(WMM_CONFIG_CHANGE_INDICATION))) { - printf("EVENT: STA_DISCONNECTED\n"); - break; - } -#define CUS_EVT_DRIVER_HANG "EVENT=DRIVER_HANG" - if (!strncmp - ((char *)event, CUS_EVT_DRIVER_HANG, - strlen(CUS_EVT_DRIVER_HANG))) { - printf("EVENT: DRIVER_HANG\n"); - break; - } -#define FW_DEBUG_INFO "EVENT=FW_DEBUG_INFO" - if (!strncmp - ((char *)event, FW_DEBUG_INFO, strlen(FW_DEBUG_INFO))) { - printf("EVENT: FW_DEBUG_INFO\n"); - printf("%s\n", - (t_u8 *)event + strlen(CUS_EVT_STA_CONNECTED) + - 1); - printf("\n"); - break; - } - printf("ERR:Undefined event type (0x%X). Dumping event buffer:\n", (unsigned int)event_id); - hexdump((void *)event, size, ' '); - break; - } - return; -} - -/** - * @brief Read event data from netlink socket - * - * @param sk_fd Netlink socket handler - * @param buffer Pointer to the data buffer - * @param nlh Pointer to netlink message header - * @param msg Pointer to message header - * @return Number of bytes read or MLAN_EVENT_FAILURE - */ -int -read_event_netlink_socket(int sk_fd, unsigned char *buffer, - struct nlmsghdr *nlh, struct msghdr *msg) -{ - int count = -1; - count = recvmsg(sk_fd, msg, 0); -#if DEBUG - printf("DBG:Waiting for message from NETLINK.\n"); -#endif - if (count < 0) { - printf("ERR:NETLINK read failed!\n"); - return MLAN_EVENT_FAILURE; - } -#if DEBUG - printf("DBG:Received message payload (%d)\n", count); -#endif - if (count > NLMSG_SPACE(NL_MAX_PAYLOAD)) { - printf("ERR:Buffer overflow!\n"); - return MLAN_EVENT_FAILURE; - } - memset(buffer, 0, NL_MAX_PAYLOAD); - memcpy(buffer, NLMSG_DATA(nlh), count - NLMSG_HDRLEN); -#if DEBUG - hexdump(buffer, count - NLMSG_HDRLEN, ' '); -#endif - return count - NLMSG_HDRLEN; -} - -/** - * @brief Configure and read event data from netlink socket - * - * @param sk_fd Array of netlink sockets - * @param no_of_sk Number of netlink sockets opened - * @param recv_buf Pointer to the array of evt_buf structures - * @param timeout Socket listen timeout value - * @param nlh Pointer to netlink message header - * @param msg Pointer to message header - * @return Number of bytes read or MLAN_EVENT_FAILURE - */ -int -read_event(int *sk_fd, int no_of_sk, evt_buf *recv_buf, int timeout, - struct nlmsghdr *nlh, struct msghdr *msg) -{ - struct timeval tv; - fd_set rfds; - int i = 0, max_sk_fd = sk_fd[0]; - int ret = MLAN_EVENT_FAILURE; - - /* Setup read fds */ - FD_ZERO(&rfds); - for (i = 0; i < no_of_sk; i++) { - if (sk_fd[i] > max_sk_fd) - max_sk_fd = sk_fd[i]; - - if (sk_fd[i] > 0) - FD_SET(sk_fd[i], &rfds); - } - - /* Initialize timeout value */ - if (timeout != 0) - tv.tv_sec = timeout; - else - tv.tv_sec = UAP_RECV_WAIT_DEFAULT; - tv.tv_usec = 0; - - /* Wait for reply */ - ret = select(max_sk_fd + 1, &rfds, NULL, NULL, &tv); - if (ret == -1) { - /* Error */ - terminate_flag++; - return MLAN_EVENT_FAILURE; - } else if (!ret) { - /* Timeout. Try again */ - return MLAN_EVENT_FAILURE; - } - for (i = 0; i < no_of_sk; i++) { - if (sk_fd[i] > 0) { - if (FD_ISSET(sk_fd[i], &rfds)) { - /* Success */ - recv_buf[i].flag = 1; - recv_buf[i].length = - read_event_netlink_socket(sk_fd[i], - recv_buf[i]. - buffer, nlh, - msg); - ret += recv_buf[i].length; - } - } - } - return ret; -} - -/* Command line options */ -static const struct option long_opts[] = { - {"help", no_argument, NULL, 'h'}, - {"version", no_argument, NULL, 'v'}, - {NULL, 0, NULL, 0} -}; - -/** - * @brief Determine the netlink number - * - * @param i socket number - * - * @return Netlink number to use - */ -static int -get_netlink_num(int i) -{ - FILE *fp; - int netlink_num = NETLINK_NXP; - char str[64]; - char *srch = "netlink_num"; - char filename[64]; - - /* Try to open old driver proc: /proc/mwlan/configX first */ - if (i == 0) - strcpy(filename, "/proc/mwlan/config"); - else if (i > 0) - sprintf(filename, "/proc/mwlan/config%d", i); - fp = fopen(filename, "r"); - if (!fp) { - /* Try to open multi-adapter driver proc: /proc/mwlan/adapterX/config if old proc access fail */ - snprintf(filename, sizeof(filename), - "/proc/mwlan/adapter%d/config", i); - fp = fopen(filename, "r"); - } - - if (fp) { - while (fgets(str, sizeof(str), fp)) { - if (strncmp(str, srch, strlen(srch)) == 0) { - netlink_num = atoi(str + strlen(srch) + 1); - break; - } - } - fclose(fp); - } else { - return -1; - } - printf("Netlink number = %d\n", netlink_num); - return netlink_num; -} - -/**************************************************************************** - Global functions -****************************************************************************/ -/** - * @brief The main function - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return 0 or 1 - */ -int -main(int argc, char *argv[]) -{ - int opt; - int nl_sk[MAX_NO_OF_DEVICES]; - struct nlmsghdr *nlh = NULL; - struct sockaddr_nl src_addr, dest_addr; - struct msghdr msg; - struct iovec iov; - evt_buf evt_recv_buf[MAX_NO_OF_DEVICES]; - struct timeval current_time; - struct tm *timeinfo; - int num_events = 0; - event_header *event = NULL; - int ret = MLAN_EVENT_FAILURE; - int netlink_num[MAX_NO_OF_DEVICES]; - char if_name[IFNAMSIZ + 1]; - t_u32 event_id = 0; - int i = 0, no_of_sk = 0, dev_index = -1; - - /* Check command line options */ - while ((opt = getopt_long(argc, argv, "hvti:", long_opts, NULL)) > 0) { - switch (opt) { - case 'h': - print_usage(); - return 0; - case 'v': - printf("mlanevent version : %s\n", MLAN_EVENT_VERSION); - return 0; - break; - case 'i': - if ((IS_HEX_OR_DIGIT(argv[2]) == MLAN_EVENT_FAILURE) - || ((A2HEXDECIMAL(argv[2]) >= MAX_NO_OF_DEVICES) && - (A2HEXDECIMAL(argv[2]) != 0xff))) { - print_usage(); - return 1; - } else { - dev_index = A2HEXDECIMAL(argv[2]); - argc -= optind; - argv += optind; - } - break; - default: - print_usage(); - return 1; - } - } - - if (optind < argc) { - fputs("Too many arguments.\n", stderr); - print_usage(); - return 1; - } - if ((dev_index >= 0) && (dev_index < MAX_NO_OF_DEVICES)) { - no_of_sk = 1; - } else { - /* Currently, we support maximum 4 devices */ - /* TODO: determine no_of_sk at run time */ - no_of_sk = MAX_NO_OF_DEVICES; - } - - for (i = 0; i < no_of_sk; i++) { - /* Initialise */ - nl_sk[i] = -1; - if (no_of_sk == 1) { - netlink_num[i] = get_netlink_num(dev_index); - if (netlink_num[i] < 0) { - printf("ERR:Could not get netlink socket. Invalid device number.\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - } else { - netlink_num[i] = get_netlink_num(i); - } - if (netlink_num[i] >= 0) { - /* Open netlink socket */ - nl_sk[i] = socket(PF_NETLINK, SOCK_RAW, netlink_num[i]); - if (nl_sk[i] < 0) { - printf("ERR:Could not open netlink socket.\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - - /* Set source address */ - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = getpid(); /* Our PID */ - src_addr.nl_groups = NL_MULTICAST_GROUP; - - /* Bind socket with source address */ - if (bind - (nl_sk[i], (struct sockaddr *)&src_addr, - sizeof(src_addr)) < 0) { - printf("ERR:Could not bind socket!\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - - /* Set destination address */ - memset(&dest_addr, 0, sizeof(dest_addr)); - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = 0; /* Kernel */ - dest_addr.nl_groups = NL_MULTICAST_GROUP; - - /* Initialize netlink header */ - nlh = (struct nlmsghdr *) - malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); - if (!nlh) { - printf("ERR: Could not alloc buffer\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - memset(nlh, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); - - /* Initialize I/O vector */ - iov.iov_base = (void *)nlh; - iov.iov_len = NLMSG_SPACE(NL_MAX_PAYLOAD); - - /* Initialize message header */ - memset(&msg, 0, sizeof(struct msghdr)); - msg.msg_name = (void *)&dest_addr; - msg.msg_namelen = sizeof(dest_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - memset(&evt_recv_buf[i], 0, sizeof(evt_buf)); - } - } - gettimeofday(¤t_time, NULL); - - printf("\n"); - printf("**********************************************\n"); - if ((timeinfo = localtime(&(current_time.tv_sec)))) - printf("mlanevent start time : %s", asctime(timeinfo)); - printf(" %u usecs\n", - (unsigned int)current_time.tv_usec); - printf("**********************************************\n"); - - signal(SIGTERM, sig_handler); - signal(SIGINT, sig_handler); - signal(SIGALRM, sig_handler); - while (1) { - if (terminate_flag) { - printf("Stopping!\n"); - break; - } - ret = read_event(nl_sk, no_of_sk, evt_recv_buf, 0, nlh, &msg); - - /* No result. Loop again */ - if (ret == MLAN_EVENT_FAILURE) { - continue; - } - if (ret == 0) { - /* Zero bytes received */ - printf("ERR:Received zero bytes!\n"); - continue; - } - for (i = 0; i < no_of_sk; i++) { - if (evt_recv_buf[i].flag == 1) { - num_events++; - gettimeofday(¤t_time, NULL); - printf("\n"); - printf("============================================\n"); - printf("Received event"); - if ((timeinfo = - localtime(&(current_time.tv_sec)))) - printf(": %s", asctime(timeinfo)); - printf(" %u usecs\n", - (unsigned int)current_time.tv_usec); - printf("============================================\n"); - - memcpy(&event_id, evt_recv_buf[i].buffer, - sizeof(event_id)); - if (((event_id & 0xFF000000) == 0x80000000) || - ((event_id & 0xFF000000) == 0)) { - event = (event_header - *)(evt_recv_buf[i].buffer); - } else { - memset(if_name, 0, IFNAMSIZ + 1); - memcpy(if_name, evt_recv_buf[i].buffer, - IFNAMSIZ); - printf("EVENT for interface %s\n", - if_name); - event = (event_header - *)((t_u8 *)(evt_recv_buf[i]. - buffer) + - IFNAMSIZ); - ret -= IFNAMSIZ; - evt_recv_buf[i].length -= IFNAMSIZ; - } -#if DEBUG - printf("DBG:Received buffer =\n"); - hexdump(evt_recv_buf[i].buffer, - evt_recv_buf[i].length + IFNAMSIZ, ' '); -#endif - print_event(event, evt_recv_buf[i].length, - if_name); - /* Reset event flag after reading */ - evt_recv_buf[i].flag = 0; - } - } - fflush(stdout); - } - gettimeofday(¤t_time, NULL); - printf("\n"); - printf("*********************************************\n"); - if ((timeinfo = localtime(&(current_time.tv_sec)))) - printf("mlanevent end time : %s", asctime(timeinfo)); - printf(" %u usecs\n", - (unsigned int)current_time.tv_usec); - printf("Total events : %u\n", num_events); - printf("*********************************************\n"); -done: - for (i = 0; i < no_of_sk; i++) { - if (nl_sk[i] > 0) - close(nl_sk[i]); - } - if (nlh) - free(nlh); - return 0; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.h b/mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.h deleted file mode 100644 index c1fcba0..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanevent/mlanevent.h +++ /dev/null @@ -1,1264 +0,0 @@ -/** @file mlanevent.h - * - * @brief Header file for mlanevent application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 03/18/08: Initial creation -************************************************************************/ - -#ifndef _MLAN_EVENT_H -#define _MLAN_EVENT_H - -/** Character, 1 byte */ -typedef signed char t_s8; -/** Unsigned character, 1 byte */ -typedef unsigned char t_u8; - -/** Short integer */ -typedef signed short t_s16; -/** Unsigned short integer */ -typedef unsigned short t_u16; - -/** Integer */ -typedef signed int t_s32; -/** Unsigned integer */ -typedef unsigned int t_u32; - -/** Long long integer */ -typedef long long t_s64; -/** Unsigned long long integer */ -typedef unsigned long long t_u64; - -#if (BYTE_ORDER == LITTLE_ENDIAN) -#undef BIG_ENDIAN_SUPPORT -#endif - -/** 16 bits byte swap */ -#define swap_byte_16(x) \ - ((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \ - (((t_u16)(x) & 0xff00U) >> 8))) - -/** 32 bits byte swap */ -#define swap_byte_32(x) \ - ((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \ - (((t_u32)(x) & 0x0000ff00UL) << 8) | \ - (((t_u32)(x) & 0x00ff0000UL) >> 8) | \ - (((t_u32)(x) & 0xff000000UL) >> 24))) - -/** 64 bits byte swap */ -#define swap_byte_64(x) \ - ((t_u64)((t_u64)(((t_u64)(x) & 0x00000000000000ffULL) << 56) | \ - (t_u64)(((t_u64)(x) & 0x000000000000ff00ULL) << 40) | \ - (t_u64)(((t_u64)(x) & 0x0000000000ff0000ULL) << 24) | \ - (t_u64)(((t_u64)(x) & 0x00000000ff000000ULL) << 8) | \ - (t_u64)(((t_u64)(x) & 0x000000ff00000000ULL) >> 8) | \ - (t_u64)(((t_u64)(x) & 0x0000ff0000000000ULL) >> 24) | \ - (t_u64)(((t_u64)(x) & 0x00ff000000000000ULL) >> 40) | \ - (t_u64)(((t_u64)(x) & 0xff00000000000000ULL) >> 56) )) - -#ifdef BIG_ENDIAN_SUPPORT -/** Convert from 16 bit little endian format to CPU format */ -#define uap_le16_to_cpu(x) swap_byte_16(x) -/** Convert from 32 bit little endian format to CPU format */ -#define uap_le32_to_cpu(x) swap_byte_32(x) -/** Convert from 64 bit little endian format to CPU format */ -#define uap_le64_to_cpu(x) swap_byte_64(x) -/** Convert to 16 bit little endian format from CPU format */ -#define uap_cpu_to_le16(x) swap_byte_16(x) -/** Convert to 32 bit little endian format from CPU format */ -#define uap_cpu_to_le32(x) swap_byte_32(x) -/** Convert to 64 bit little endian format from CPU format */ -#define uap_cpu_to_le64(x) swap_byte_64(x) -#else /* BIG_ENDIAN_SUPPORT */ -/** Do nothing */ -#define uap_le16_to_cpu(x) x -/** Do nothing */ -#define uap_le32_to_cpu(x) x -/** Do nothing */ -#define uap_le64_to_cpu(x) x -/** Do nothing */ -#define uap_cpu_to_le16(x) x -/** Do nothing */ -#define uap_cpu_to_le32(x) x -/** Do nothing */ -#define uap_cpu_to_le64(x) x -#endif /* BIG_ENDIAN_SUPPORT */ - -/** Convert WPS TLV header from network to host order */ -#define endian_convert_tlv_wps_header_in(t,l) \ - { \ - (t) = ntohs(t); \ - (l) = ntohs(l); \ - } - -/** - * Hex or Decimal to Integer - * @param num string to convert into decimal or hex - */ -#define A2HEXDECIMAL(num) \ - (strncasecmp("0x", (num), 2)?(unsigned int) strtoll((num),NULL,0):a2hex((num)))\ - -/** - * Check of decimal or hex string - * @param num string - */ -#define IS_HEX_OR_DIGIT(num) \ - (strncasecmp("0x", (num), 2)?ISDIGIT((num)):ishexstring((num)))\ - -/** MLan Event application version string */ -#define MLAN_EVENT_VERSION "MlanEvent 2.0" - -/** Failure */ -#define MLAN_EVENT_FAILURE -1 - -#ifdef __GNUC__ -/** Structure packing begins */ -#define PACK_START -/** Structure packeing end */ -#define PACK_END __attribute__ ((packed)) -#else -/** Structure packing begins */ -#define PACK_START __packed -/** Structure packeing end */ -#define PACK_END -#endif - -#ifndef ETH_ALEN -/** MAC address length */ -#define ETH_ALEN 6 -#endif - -/** Netlink protocol number */ -#define NETLINK_NXP (MAX_LINKS - 1) -/** Netlink maximum payload size */ -#define NL_MAX_PAYLOAD (3 * 1024) -/** Netlink multicast group number */ -#define NL_MULTICAST_GROUP 1 -/** Default wait time in seconds for events */ -#define UAP_RECV_WAIT_DEFAULT 10 -/** Maximum number of devices */ -#define MAX_NO_OF_DEVICES 6 - -#ifndef NLMSG_HDRLEN -/** NL message header length */ -#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) -#endif - -/** Event ID mask */ -#define EVENT_ID_MASK 0xffff - -/** BSS number mask */ -#define BSS_NUM_MASK 0xf - -/** Get BSS number from event cause (bit 23:16) */ -#define EVENT_GET_BSS_NUM(event_cause) \ - (((event_cause) >> 16) & BSS_NUM_MASK) - -/** Invitation Flag mask */ -#define INVITATION_FLAG_MASK 0x01 - -/* Event buffer */ -typedef PACK_START struct _evt_buf { - /** Flag to check if event data is present in the buffer or not */ - int flag; - /** Event length */ - int length; - /** Event data */ - t_u8 buffer[NL_MAX_PAYLOAD]; -} PACK_END evt_buf; - -/** Event header */ -typedef PACK_START struct _event_header { - /** Event ID */ - t_u32 event_id; - /** Event data */ - t_u8 event_data[]; -} PACK_END event_header; - -/** Event ID length */ -#define EVENT_ID_LEN 4 - -/** Event ID : WMM status change */ -#define MICRO_AP_EV_WMM_STATUS_CHANGE 0x00000017 - -/** Event ID: STA deauth */ -#define MICRO_AP_EV_ID_STA_DEAUTH 0x0000002c - -/** Event ID: STA associated */ -#define MICRO_AP_EV_ID_STA_ASSOC 0x0000002d - -/** Event ID: BSS started */ -#define MICRO_AP_EV_ID_BSS_START 0x0000002e - -/** Event ID: Debug event */ -#define MICRO_AP_EV_ID_DEBUG 0x00000036 - -/** Event ID: BSS idle event */ -#define MICRO_AP_EV_BSS_IDLE 0x00000043 - -/** Event ID: BSS active event */ -#define MICRO_AP_EV_BSS_ACTIVE 0x00000044 - -/** Event ID: WEP ICV error */ -#define EVENT_WEP_ICV_ERROR 0x00000046 - -#ifdef WIFI_DIRECT_SUPPORT -/** Event ID: UAP,STA wifidirect generic event */ -#define EVENT_WIFIDIRECT_GENERIC 0x00000049 - -/** Event ID: UAP,STA wifidirect service discovery event */ -#define EVENT_WIFIDIRECT_SERVICE_DISCOVERY 0x0000004a -#endif - -/** Event ID: MIC Countermeasures event */ -#define MICRO_AP_EV_ID_MIC_COUNTERMEASURES 0x0000004c - -/** Event ID: RSN Connect event */ -#define MICRO_AP_EV_RSN_CONNECT 0x00000051 - -/** Event ID: Radar Detected */ -#define EVENT_RADAR_DETECTED 0x00000053 -/** Event ID: Channel Report Ready */ -#define EVENT_CHANNEL_REPORT_RDY 0x00000054 - -/** HS WAKE UP event id */ -#define UAP_EVENT_ID_HS_WAKEUP 0x80000001 -/** HS_ACTIVATED event id */ -#define UAP_EVENT_ID_DRV_HS_ACTIVATED 0x80000002 -/** HS DEACTIVATED event id */ -#define UAP_EVENT_ID_DRV_HS_DEACTIVATED 0x80000003 -/** HOST SLEEP AWAKE event id in legacy PS*/ -#define UAP_EVENT_HOST_SLEEP_AWAKE 0x00000012 - -/** HS WAKE UP event id */ -#define UAP_EVENT_ID_DRV_MGMT_FRAME 0x80000005 - -/** SCAN REPORT Event id */ -#define EVENT_ID_DRV_SCAN_REPORT 0x80000009 - -/** WPA IE Tag */ -#define IEEE_WPA_IE 221 -/** RSN IE Tag */ -#define IEEE_RSN_IE 48 - -/** TLV ID : WAPI Information */ -#define MRVL_WAPI_INFO_TLV_ID 0x0167 - -/** TLV ID : Management Frame */ -#define MRVL_MGMT_FRAME_TLV_ID 0x0168 - -/** TLV Id : Channel Config */ -#define MRVL_CHANNELCONFIG_TLV_ID 0x012a - -/** Assoc Request */ -#define SUBTYPE_ASSOC_REQUEST 0 -/** Assoc Response */ -#define SUBTYPE_ASSOC_RESPONSE 1 -/** ReAssoc Request */ -#define SUBTYPE_REASSOC_REQUEST 2 -/** ReAssoc Response */ -#define SUBTYPE_REASSOC_RESPONSE 3 -/** WEP key user input length */ -#define WEP_KEY_USER_INPUT 13 - -/** TLV buffer header*/ -typedef PACK_START struct _tlvbuf_header { - /** Header type */ - t_u16 type; - /** Header length */ - t_u16 len; -} PACK_END tlvbuf_header; - -/** Event body : STA deauth */ -typedef PACK_START struct _eventbuf_sta_deauth { - /** Deauthentication reason */ - t_u16 reason_code; - /** MAC address of deauthenticated STA */ - t_u8 sta_mac_address[ETH_ALEN]; -} PACK_END eventbuf_sta_deauth; - -/** Event body : WEP ICV error */ -typedef PACK_START struct _eventbuf_wep_icv_error { - /** Deauthentication reason */ - t_u16 reason_code; - /** MAC address of deauthenticated STA */ - t_u8 sta_mac_address[ETH_ALEN]; - /** WEP key index */ - t_u8 wep_key_index; - /** WEP key length */ - t_u8 wep_key_length; - /** WEP key */ - t_u8 wep_key[WEP_KEY_USER_INPUT]; -} PACK_END eventbuf_wep_icv_error; - -/** Event body : STA associated */ -typedef PACK_START struct _eventbuf_sta_assoc { - /** Reserved */ - t_u8 reserved[2]; - /** MAC address of associated STA */ - t_u8 sta_mac_address[ETH_ALEN]; - /** Assoc request/response buffer */ - t_u8 assoc_payload[]; -} PACK_END eventbuf_sta_assoc; - -/** Event body : RSN Connect */ -typedef PACK_START struct _eventbuf_rsn_connect { - /** Reserved */ - t_u8 reserved[2]; - /** MAC address of Station */ - t_u8 sta_mac_address[ETH_ALEN]; - /** WPA/WPA2 TLV IEs */ - t_u8 tlv_list[]; -} PACK_END eventbuf_rsn_connect; - -/** Event body : BSS started */ -typedef PACK_START struct _eventbuf_bss_start { - /** Reserved */ - t_u8 reserved[2]; - /** MAC address of BSS */ - t_u8 ap_mac_address[ETH_ALEN]; -} PACK_END eventbuf_bss_start; - -/** Event body : MIC Countermeasures */ -typedef PACK_START struct _eventbuf_mic_countermeasures { - /** Status */ - t_u16 status; -} PACK_END eventbuf_mic_countermeasures; - -/** - * IEEE 802.11 MAC Message Data Structures - * - * Each IEEE 802.11 MAC message includes a MAC header, a frame body (which - * can be empty), and a frame check sequence field. This section gives the - * structures that used for the MAC message headers and frame bodies that - * can exist in the three types of MAC messages - 1) Control messages, - * 2) Data messages, and 3) Management messages. - */ -typedef PACK_START struct _IEEEtypes_FrameCtl_t { - /** Protocol Version */ - t_u8 protocol_version:2; - /** Type */ - t_u8 type:2; - /** Sub Type */ - t_u8 sub_type:4; - /** To DS */ - t_u8 to_ds:1; - /** From DS */ - t_u8 from_ds:1; - /** More Frag */ - t_u8 more_frag:1; - /** Retry */ - t_u8 retry:1; - /** Power Mgmt */ - t_u8 pwr_mgmt:1; - /** More Data */ - t_u8 more_data:1; - /** Wep */ - t_u8 wep:1; - /** Order */ - t_u8 order:1; -} PACK_END IEEEtypes_FrameCtl_t; - -/** IEEEtypes_AssocRqst_t */ -typedef PACK_START struct _IEEEtypes_AssocRqst_t { - /** Capability Info */ - t_u16 cap_info; - /** Listen Interval */ - t_u16 listen_interval; - /** IE Buffer */ - t_u8 ie_buffer[]; -} PACK_END IEEEtypes_AssocRqst_t; - -/** IEEEtypes_AssocRsp_t */ -typedef PACK_START struct _IEEEtypes_AssocRsp_t { - /** Capability Info */ - t_u16 cap_info; - /** Status Code */ - t_u16 status_code; - /** AID */ - t_u16 aid; -} PACK_END IEEEtypes_AssocRsp_t; - -/** IEEEtypes_ReAssocRqst_t */ -typedef PACK_START struct _IEEEtypes_ReAssocRqst_t { - /** Capability Info */ - t_u16 cap_info; - /** Listen Interval */ - t_u16 listen_interval; - /** Current AP Address */ - t_u8 current_ap_addr[ETH_ALEN]; - /** IE Buffer */ - t_u8 ie_buffer[]; -} PACK_END IEEEtypes_ReAssocRqst_t; - -/** channel band */ -enum { - BAND_2GHZ = 0, - BAND_5GHZ = 1, - BAND_4GHZ = 2, -}; - -/** channel offset */ -enum { - SEC_CHAN_NONE = 0, - SEC_CHAN_ABOVE = 1, - SEC_CHAN_5MHZ = 2, - SEC_CHAN_BELOW = 3 -}; - -/** channel bandwidth */ -enum { - CHAN_BW_20MHZ = 0, - CHAN_BW_10MHZ, - CHAN_BW_40MHZ, - CHAN_BW_80MHZ, - -}; - -/** scan mode */ -enum { - SCAN_MODE_MANUAL = 0, - SCAN_MODE_ACS, - SCAN_MODE_USER, -}; - -/** Band_Config_t */ -typedef PACK_START struct _Band_Config_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=user*/ - t_u8 scanMode:2; - /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ - t_u8 chan2Offset:2; - /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ - t_u8 chanWidth:2; - /** Band Info - (00)=2.4GHz, (01)=5GHz */ - t_u8 chanBand:2; -#else - /** Band Info - (00)=2.4GHz, (01)=5GHz */ - t_u8 chanBand:2; - /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ - t_u8 chanWidth:2; - /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ - t_u8 chan2Offset:2; - /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=Adoption mode*/ - t_u8 scanMode:2; -#endif -} PACK_END Band_Config_t; - -/** TLV buffer : Channel Config */ -typedef PACK_START struct _tlvbuf_channel_config { - /** Type */ - t_u16 type; - /** Length */ - t_u16 len; - /** Band Configuration */ - Band_Config_t bandcfg; - /** Channel number */ - t_u8 chan_number; -} PACK_END tlvbuf_channel_config; - -/** MrvlIEtypes_WapiInfoSet_t */ -typedef PACK_START struct _MrvlIEtypes_WapiInfoSet_t { - /** Type */ - t_u16 type; - /** Length */ - t_u16 len; - /** Multicast PN */ - t_u8 multicast_PN[16]; -} PACK_END MrvlIEtypes_WapiInfoSet_t; - -/** MrvlIETypes_MgmtFrameSet_t */ -typedef PACK_START struct _MrvlIETypes_MgmtFrameSet_t { - /** Type */ - t_u16 type; - /** Length */ - t_u16 len; - /** Frame Control */ - IEEEtypes_FrameCtl_t frame_control; - /** Frame Contents */ - t_u8 frame_contents[]; -} PACK_END MrvlIETypes_MgmtFrameSet_t; - -/** Debug Type : Event */ -#define DEBUG_TYPE_EVENT 0 -/** Debug Type : Info */ -#define DEBUG_TYPE_INFO 1 - -/** Major debug id: Authenticator */ -#define DEBUG_ID_MAJ_AUTHENTICATOR 1 -/** Minor debug id: PWK1 */ -#define DEBUG_MAJ_AUTH_MIN_PWK1 0 -/** Minor debug id: PWK2 */ -#define DEBUG_MAJ_AUTH_MIN_PWK2 1 -/** Minor debug id: PWK3 */ -#define DEBUG_MAJ_AUTH_MIN_PWK3 2 -/** Minor debug id: PWK4 */ -#define DEBUG_MAJ_AUTH_MIN_PWK4 3 -/** Minor debug id: GWK1 */ -#define DEBUG_MAJ_AUTH_MIN_GWK1 4 -/** Minor debug id: GWK2 */ -#define DEBUG_MAJ_AUTH_MIN_GWK2 5 -/** Minor debug id: station reject */ -#define DEBUG_MAJ_AUTH_MIN_STA_REJ 6 -/** Minor debug id: EAPOL_TR */ -#define DEBUG_MAJ_AUTH_MIN_EAPOL_TR 7 - -/** Major debug id: Assoicate agent */ -#define DEBUG_ID_MAJ_ASSOC_AGENT 2 -/** Minor debug id: WPA IE*/ -#define DEBUG_ID_MAJ_ASSOC_MIN_WPA_IE 0 -/** Minor debug id: station reject */ -#define DEBUG_ID_MAJ_ASSOC_MIN_STA_REJ 1 - -/** ether_hdr */ -typedef PACK_START struct { - /** Dest address */ - t_u8 da[ETH_ALEN]; - /** Src address */ - t_u8 sa[ETH_ALEN]; - /** Header type */ - t_u16 type; -} PACK_END ether_hdr_t; - -/** 8021x header */ -typedef PACK_START struct { - /** Protocol version*/ - t_u8 protocol_ver; - /** Packet type*/ - t_u8 pckt_type; - /** Packet len */ - t_u8 pckt_body_len; -} PACK_END hdr_8021x_t; - -/** Nonce size */ -#define NONCE_SIZE 32 -/** Max WPA IE len */ -#define MAX_WPA_IE_LEN 64 -/** EAPOL mic size */ -#define EAPOL_MIC_SIZE 16 - -/** EAPOL key message */ -typedef PACK_START struct { - /** Ether header */ - ether_hdr_t ether_hdr; - /** 8021x header */ - hdr_8021x_t hdr_8021x; - /** desc_type */ - t_u8 desc_type; - /** Key info */ - t_u16 k; - /** Key length */ - t_u16 key_length; - /** Replay count */ - t_u32 replay_cnt[2]; - /** Key nonce */ - t_u8 key_nonce[NONCE_SIZE]; - /** Key IV */ - t_u8 eapol_key_iv[16]; - /** Key RSC */ - t_u8 key_rsc[8]; - /** Key ID */ - t_u8 key_id[8]; - /** Key MIC */ - t_u8 key_mic[EAPOL_MIC_SIZE]; - /** Key len */ - t_u16 key_material_len; - /** Key data */ - t_u8 key_data[MAX_WPA_IE_LEN]; -} PACK_END eapol_keymsg_debug_t; - -/** Failure after receive EAPOL MSG2 PMK */ -#define REJECT_STATE_FAIL_EAPOL_2 1 -/** Failure after receive EAPOL MSG4 PMK*/ -#define REJECT_STATE_FAIL_EAPOL_4 2 -/** Failure after receive EAPOL Group MSG2 GWK */ -#define REJECT_STATE_FAIL_EAPOL_GROUP_2 3 - -/** Fail reason: Invalid ie */ -#define IEEEtypes_REASON_INVALID_IE 13 -/** Fail reason: Mic failure */ -#define IEEEtypes_REASON_MIC_FAILURE 14 - -/** Station reject */ -typedef PACK_START struct { - /** Reject state */ - t_u8 reject_state; - /** Reject reason */ - t_u16 reject_reason; - /** Station mac address */ - t_u8 sta_mac_addr[ETH_ALEN]; -} PACK_END sta_reject_t; - -/** wpa_ie */ -typedef PACK_START struct { - /** Station mac address */ - t_u8 sta_mac_addr[ETH_ALEN]; - /** WPA IE */ - t_u8 wpa_ie[MAX_WPA_IE_LEN]; -} PACK_END wpaie_t; - -/** Initial state of the state machine */ -#define EAPOL_START 1 -/** Sent eapol msg1, wait for msg2 from the client */ -#define EAPOL_WAIT_PWK2 2 -/** Sent eapol msg3, wait for msg4 from the client */ -#define EAPOL_WAIT_PWK4 3 -/** Sent eapol group key msg1, wait for group msg2 from the client */ -#define EAPOL_WAIT_GTK2 4 -/** Eapol handshake complete */ -#define EAPOL_END 5 - -#ifdef WIFI_DIRECT_SUPPORT -/** TLV : WifiDirect status */ -#define TLV_TYPE_WIFIDIRECT_STATUS 0x0000 -/** TLV : WifiDirect param capability */ -#define TLV_TYPE_WIFIDIRECT_CAPABILITY 0x0002 -/** TLV : WifiDirect param device Id */ -#define TLV_TYPE_WIFIDIRECT_DEVICE_ID 0x0003 -/** TLV : WifiDirect param group owner intent */ -#define TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT 0x0004 -/** TLV : WifiDirect param config timeout */ -#define TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT 0x0005 -/** TLV : WifiDirect param channel */ -#define TLV_TYPE_WIFIDIRECT_CHANNEL 0x0006 -/** TLV : WifiDirect param group bssId */ -#define TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID 0x0007 -/** TLV : WifiDirect param extended listen time */ -#define TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME 0x0008 -/** TLV : WifiDirect param intended address */ -#define TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS 0x0009 -/** TLV : WifiDirect param manageability */ -#define TLV_TYPE_WIFIDIRECT_MANAGEABILITY 0x000a -/** TLV : WifiDirect param channel list */ -#define TLV_TYPE_WIFIDIRECT_CHANNEL_LIST 0x000b -/** TLV : WifiDirect Notice of Absence */ -#define TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE 0x000c -/** TLV : WifiDirect param device Info */ -#define TLV_TYPE_WIFIDIRECT_DEVICE_INFO 0x000d -/** TLV : WifiDirect param Group Info */ -#define TLV_TYPE_WIFIDIRECT_GROUP_INFO 0x000e -/** TLV : WifiDirect param group Id */ -#define TLV_TYPE_WIFIDIRECT_GROUP_ID 0x000f -/** TLV : WifiDirect param interface */ -#define TLV_TYPE_WIFIDIRECT_INTERFACE 0x0010 -/** TLV : WifiDirect param operating channel */ -#define TLV_TYPE_WIFIDIRECT_OPCHANNEL 0x0011 -/** TLV : WifiDirect param invitation flag */ -#define TLV_TYPE_WIFIDIRECT_INVITATION_FLAG 0x0012 - -/** WPS Device Info OUI+Type+SubType Length */ -#define WPS_DEVICE_TYPE_LEN 8 - -/** IE header len */ -#define IE_HEADER_LEN 2 - -/** WIFIDIRECT IE header len */ -#define WIFIDIRECT_IE_HEADER_LEN 3 - -/** OUI Type WIFIDIRECT */ -#define WIFIDIRECT_OUI_TYPE 9 -/** OUI Type WPS */ -#define WIFI_WPS_OUI_TYPE 4 - -/* - * To handle overlapping WIFIDIRECT IEs - */ -/** IE next byte type */ -#define WIFIDIRECT_OVERLAP_TYPE 1 -/** IE next byte length */ -#define WIFIDIRECT_OVERLAP_LEN 2 -/** IE next byte data */ -#define WIFIDIRECT_OVERLAP_DATA 3 - -/** Max payload for IE buffer */ -#define WIFI_IE_MAX_PAYLOAD 256 - -/** Fixed length fields in bonjour payload query data */ -#define WIFIDIRECT_DISCOVERY_BONJOUR_FIXED_LEN 5 - -/** Fixed length fields in uPnP payload query data */ -#define WIFIDIRECT_DISCOVERY_UPNP_FIXED_LEN 3 - -/** Action field for discovery request */ -#define WIFIDIRECT_DISCOVERY_REQUEST_ACTION 10 - -/** Action field for discovery response */ -#define WIFIDIRECT_DISCOVERY_RESPONSE_ACTION 11 - -/** TLV buffer : WifiDirect Status */ -typedef PACK_START struct _tlvbuf_wifidirect_status { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT status code */ - t_u8 status_code; -} PACK_END tlvbuf_wifidirect_status; - -/** TLV buffer : wifidirect IE device Id */ -typedef PACK_START struct _tlvbuf_wifidirect_device_id { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device MAC address */ - t_u8 dev_mac_address[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_device_id; - -/** TLV buffer : wifidirect IE capability */ -typedef PACK_START struct _tlvbuf_wifidirect_capability { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device capability */ - t_u8 dev_capability; - /** WIFIDIRECT group capability */ - t_u8 group_capability; -} PACK_END tlvbuf_wifidirect_capability; - -/** TLV buffer : wifidirect IE Group owner intent */ -typedef PACK_START struct _tlvbuf_wifidirect_group_owner_intent { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device group owner intent */ - t_u8 dev_intent; -} PACK_END tlvbuf_wifidirect_group_owner_intent; - -/** TLV buffer : WifiDirect IE Manageability */ -typedef PACK_START struct _tlvbuf_wifidirect_manageability { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT Manageability */ - t_u8 manageability; -} PACK_END tlvbuf_wifidirect_manageability; - -/** TLV buffer : WifiDirect IE Invitation Flag */ -typedef PACK_START struct _tlvbuf_wifidirect_invitation_flag { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT Manageability */ - t_u8 invitation_flag; -} PACK_END tlvbuf_wifidirect_invitation_flag; - -/** TLV buffer : wifidirect IE capability */ -typedef PACK_START struct _tlvbuf_wifidirect_channel { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT country string */ - t_u8 country_string[3]; - /** WIFIDIRECT regulatory class */ - t_u8 regulatory_class; - /** WIFIDIRECT channel number */ - t_u8 channel_number; -} PACK_END tlvbuf_wifidirect_channel; - -/** Channel Entry */ -typedef PACK_START struct _chan_entry { - /** WIFIDIRECT regulatory class */ - t_u8 regulatory_class; - /** WIFIDIRECT no of channels */ - t_u8 num_of_channels; - /** WIFIDIRECT channel number */ - t_u8 chan_list[]; -} PACK_END chan_entry; - -/** TLV buffer : wifidirect IE channel list */ -typedef PACK_START struct _tlvbuf_wifidirect_channel_list { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT country string */ - t_u8 country_string[3]; - /** WIFIDIRECT channel entries */ - chan_entry wifidirect_chan_entry_list[]; -} PACK_END tlvbuf_wifidirect_channel_list; - -/** NoA Descriptor */ -typedef PACK_START struct _noa_descriptor { - /** WIFIDIRECT count OR type */ - t_u8 count_type; - /** WIFIDIRECT duration */ - t_u32 duration; - /** WIFIDIRECT interval */ - t_u32 interval; - /** WIFIDIRECT start time */ - t_u32 start_time; -} PACK_END noa_descriptor; - -/** TLV buffer : WifiDirect IE Notice of Absence */ -typedef PACK_START struct _tlvbuf_wifidirect_notice_of_absence { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT NoA Index */ - t_u8 noa_index; - /** WIFIDIRECT CTWindow and OppPS parameters */ - t_u8 ctwindow_opp_ps; - /** WIFIDIRECT NoA Descriptor list */ - noa_descriptor wifidirect_noa_descriptor_list[]; -} PACK_END tlvbuf_wifidirect_notice_of_absence; - -/** TLV buffer : wifidirect IE device Info */ -typedef PACK_START struct _tlvbuf_wifidirect_device_info { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device address */ - t_u8 dev_address[ETH_ALEN]; - /** WPS config methods */ - t_u16 config_methods; - /** Primary device type : category */ - t_u16 primary_category; - /** Primary device type : OUI */ - t_u8 primary_oui[4]; - /** Primary device type : sub-category */ - t_u16 primary_subcategory; - /** Secondary Device Count */ - t_u8 secondary_dev_count; - /** Secondary Device Info */ - t_u8 secondary_dev_info[0]; - /** WPS Device Name Tag */ - t_u16 device_name_type; - /** WPS Device Name Length */ - t_u16 device_name_len; - /** Device name */ - t_u8 device_name[]; -} PACK_END tlvbuf_wifidirect_device_info; - -typedef PACK_START struct _wifidirect_client_dev_info { - /** Length of each device */ - t_u8 dev_length; - /** WIFIDIRECT device address */ - t_u8 wifidirect_dev_address[ETH_ALEN]; - /** WIFIDIRECT Interface address */ - t_u8 wifidirect_intf_address[ETH_ALEN]; - /** WIFIDIRECT Device capability*/ - t_u8 wifidirect_dev_capability; - /** WPS config methods */ - t_u16 config_methods; - /** Primary device type : category */ - t_u16 primary_category; - /** Primary device type : OUI */ - t_u8 primary_oui[4]; - /** Primary device type : sub-category */ - t_u16 primary_subcategory; - /** Secondary Device Count */ - t_u8 wifidirect_secondary_dev_count; - /** Secondary Device Info */ - t_u8 wifidirect_secondary_dev_info[0]; - /** WPS WIFIDIRECT Device Name Tag */ - t_u16 wifidirect_device_name_type; - /** WPS WIFIDIRECT Device Name Length */ - t_u16 wifidirect_device_name_len; - /** WIFIDIRECT Device name */ - t_u8 wifidirect_device_name[]; -} PACK_END wifidirect_client_dev_info; - -typedef PACK_START struct _tlvbuf_wifidirect_group_info { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** Secondary Device Info */ - t_u8 wifidirect_client_dev_list[]; -} PACK_END tlvbuf_wifidirect_group_info; - -/** TLV buffer : wifidirect IE group Id */ -typedef PACK_START struct _tlvbuf_wifidirect_group_id { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT group MAC address */ - t_u8 group_address[ETH_ALEN]; - /** WIFIDIRECT group SSID */ - t_u8 group_ssid[]; -} PACK_END tlvbuf_wifidirect_group_id; - -/** TLV buffer : wifidirect IE group BSS Id */ -typedef PACK_START struct _tlvbuf_wifidirect_group_bss_id { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT group Bss Id */ - t_u8 group_bssid[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_group_bss_id; - -/** TLV buffer : wifidirect IE Interface */ -typedef PACK_START struct _tlvbuf_wifidirect_interface { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT interface Id */ - t_u8 interface_id[ETH_ALEN]; - /** WIFIDIRECT interface count */ - t_u8 interface_count; - /** WIFIDIRECT interface addresslist */ - t_u8 interface_idlist[]; -} PACK_END tlvbuf_wifidirect_interface; - -/** TLV buffer : WifiDirect configuration timeout */ -typedef PACK_START struct _tlvbuf_wifidirect_config_timeout { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** Group configuration timeout */ - t_u8 group_config_timeout; - /** Device configuration timeout */ - t_u8 device_config_timeout; -} PACK_END tlvbuf_wifidirect_config_timeout; - -/** TLV buffer : WifiDirect extended listen time */ -typedef PACK_START struct _tlvbuf_wifidirect_ext_listen_time { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** Availability period */ - t_u16 availability_period; - /** Availability interval */ - t_u16 availability_interval; -} PACK_END tlvbuf_wifidirect_ext_listen_time; - -/** TLV buffer : WifiDirect Intended Interface Address */ -typedef PACK_START struct _tlvbuf_wifidirect_intended_addr { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT Group interface address */ - t_u8 group_address[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_intended_addr; - -/** TLV buffer : Wifi WPS IE */ -typedef PACK_START struct _tlvbuf_wifi_wps_ie { - /** TLV Header tag */ - t_u16 tag; - /** TLV Header length */ - t_u16 length; - /** WIFI WPS IE data */ - t_u8 data[]; -} PACK_END tlvbuf_wps_ie; - -/** WifiDirect IE Header */ -typedef PACK_START struct _wifidirect_ie_header { - /** Element ID */ - t_u8 element_id; - /** IE Length */ - t_u8 ie_length; - /** OUI */ - t_u8 oui[3]; - /** OUI type */ - t_u8 oui_type; - /** IE List of TLV */ - t_u8 ie_list[]; -} PACK_END wifidirect_ie_header; - -/** Event : WifiDirect Generic event */ -typedef PACK_START struct _apeventbuf_wifidirect_generic { - /** Event Length */ - t_u16 event_length; - /** Event Type */ - t_u16 event_type; - /** Event SubType */ - t_u16 event_sub_type; - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** IE List of TLV */ - t_u8 entire_ie_list[]; -} PACK_END apeventbuf_wifidirect_generic; - -/** Internal WIFIDIRECT structure for Query Data */ -typedef PACK_START struct wifidirect_query_data { - union { - PACK_START struct upnp_specific_query { - /** version field */ - t_u8 version; - /** value */ - t_u8 value[]; - } PACK_END upnp; - - PACK_START struct bonjour_specific_query { - /** DNS name */ - t_u8 dns[0]; - /** DNS type */ - t_u8 dns_type; - /** version field */ - t_u8 version; - } PACK_END bonjour; - } u; -} PACK_END wifidirect_query_data; - -/** Internal WIFIDIRECT structure for Response Data */ -typedef PACK_START struct wifidirect_Response_data { - union { - PACK_START struct upnp_specific_response { - /** version field */ - t_u8 version; - /** value */ - t_u8 value[]; - } PACK_END upnp; - - PACK_START struct bonjour_specific_response { - /** DNS name */ - t_u8 dns[0]; - /** DNS type */ - t_u8 dns_type; - /** version field */ - t_u8 version; - /** DNS name */ - t_u8 record[]; - } PACK_END bonjour; - } u; -} PACK_END wifidirect_response_data; - -/** Event : Service Discovery request */ -typedef PACK_START struct _apeventbuf_wifidirect_discovery_request { - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** Dialog taken */ - t_u8 dialog_taken; - /** Advertize protocol IE */ - t_u8 advertize_protocol_ie[4]; - /** Query request Length */ - t_u16 query_len; - /** Information identifier */ - t_u8 info_id[2]; - /** Request Length */ - t_u16 request_len; - /** OUI */ - t_u8 oui[3]; - /** OUI sub type */ - t_u8 oui_sub_type; - /** Service update indicator */ - t_u16 service_update_indicator; - /** Vendor Length */ - t_u16 vendor_len; - /** Service protocol */ - t_u8 service_protocol; - /** Service transaction Id */ - t_u8 service_transaction_id; - /** Query Data */ - wifidirect_query_data disc_query; -} PACK_END apeventbuf_wifidirect_discovery_request; - -/** HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY response */ -typedef PACK_START struct _apeventbuf_wifidirect_discovery_response { - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** Dialog taken */ - t_u8 dialog_taken; - /** Status code */ - t_u8 status_code; - /** GAS comback reply */ - t_u16 gas_reply; - /** Advertize protocol IE */ - t_u8 advertize_protocol_ie[4]; - /** Query response Length */ - t_u16 query_len; - /** Information identifier */ - t_u8 info_id[2]; - /** Response Length */ - t_u16 response_len; - /** OUI */ - t_u8 oui[3]; - /** OUI sub type */ - t_u8 oui_sub_type; - /** Service update indicator */ - t_u16 service_update_indicator; - /** Vendor Length */ - t_u16 vendor_len; - /** Service protocol */ - t_u8 service_protocol; - /** Service transaction Id */ - t_u8 service_transaction_id; - /** Discovery status code */ - t_u8 disc_status_code; - /** Response Data */ - wifidirect_response_data disc_resp; -} PACK_END apeventbuf_wifidirect_discovery_response; - -/** enum : WPS attribute type */ -typedef enum { - SC_AP_Channel = 0x1001, - SC_Association_State = 0x1002, - SC_Authentication_Type = 0x1003, - SC_Authentication_Type_Flags = 0x1004, - SC_Authenticator = 0x1005, - SC_Config_Methods = 0x1008, - SC_Configuration_Error = 0x1009, - SC_Confirmation_URL4 = 0x100A, - SC_Confirmation_URL6 = 0x100B, - SC_Connection_Type = 0x100C, - SC_Connection_Type_Flags = 0x100D, - SC_Credential = 0x100E, - SC_Device_Name = 0x1011, - SC_Device_Password_ID = 0x1012, - SC_E_Hash1 = 0x1014, - SC_E_Hash2 = 0x1015, - SC_E_SNonce1 = 0x1016, - SC_E_SNonce2 = 0x1017, - SC_Encrypted_Settings = 0x1018, - SC_Encryption_Type = 0X100F, - SC_Encryption_Type_Flags = 0x1010, - SC_Enrollee_Nonce = 0x101A, - SC_Feature_ID = 0x101B, - SC_Identity = 0X101C, - SC_Identity_Proof = 0X101D, - SC_Key_Wrap_Authenticator = 0X101E, - SC_Key_Identifier = 0X101F, - SC_MAC_Address = 0x1020, - SC_Manufacturer = 0x1021, - SC_Message_Type = 0x1022, - SC_Model_Name = 0x1023, - SC_Model_Number = 0x1024, - SC_Network_Index = 0x1026, - SC_Network_Key = 0x1027, - SC_Network_Key_Index = 0x1028, - SC_New_Device_Name = 0x1029, - SC_New_Password = 0x102A, - SC_OOB_Device_Password = 0X102C, - SC_OS_Version = 0X102D, - SC_Power_Level = 0X102F, - SC_PSK_Current = 0x1030, - SC_PSK_Max = 0x1031, - SC_Public_Key = 0x1032, - SC_Radio_Enabled = 0x1033, - SC_Reboot = 0x1034, - SC_Registrar_Current = 0x1035, - SC_Registrar_Established = 0x1036, - SC_Registrar_List = 0x1037, - SC_Registrar_Max = 0x1038, - SC_Registrar_Nonce = 0x1039, - SC_Request_Type = 0x103A, - SC_Response_Type = 0x103B, - SC_RF_Band = 0X103C, - SC_R_Hash1 = 0X103D, - SC_R_Hash2 = 0X103E, - SC_R_SNonce1 = 0X103F, - SC_R_SNonce2 = 0x1040, - SC_Selected_Registrar = 0x1041, - SC_Serial_Number = 0x1042, - SC_Simple_Config_State = 0x1044, - SC_SSID = 0x1045, - SC_Total_Networks = 0x1046, - SC_UUID_E = 0x1047, - SC_UUID_R = 0x1048, - SC_Vendor_Extension = 0x1049, - SC_Version = 0x104A, - SC_X_509_Certificate_Request = 0x104B, - SC_X_509_Certificate = 0x104C, - SC_EAP_Identity = 0x104D, - SC_Message_Counter = 0x104E, - SC_Public_Key_Hash = 0x104F, - SC_Rekey_Key = 0x1050, - SC_Key_Lifetime = 0x1051, - SC_Permitted_Config_Methods = 0x1052, - SC_SelectedRegistrarConfigMethods = 0x1053, - SC_Primary_Device_Type = 0x1054, - SC_Secondary_Device_Type_List = 0x1055, - SC_Portable_Device = 0x1056, - SC_AP_Setup_Locked = 0x1057, - SC_Application_List = 0x1058, - SC_EAP_Type = 0x1059, - SC_Initialization_Vector = 0x1060, - SC_Key_Provided_Auto = 0x1061, - SC_8021x_Enabled = 0x1062, - SC_App_Session_key = 0x1063, - SC_WEP_Transmit_Key = 0x1064, -} wps_simple_config_attribute; -#endif - -/** Eapol state */ -typedef PACK_START struct { - /** Eapol state*/ - t_u8 eapol_state; - /** Station address*/ - t_u8 sta_mac_addr[ETH_ALEN]; -} PACK_END eapol_state_t; - -/** Debug Info */ -typedef PACK_START union { - /** Eapol key message */ - eapol_keymsg_debug_t eapol_pwkmsg; - /** Station reject*/ - sta_reject_t sta_reject; - /** WPA IE */ - wpaie_t wpaie; - /** Eapol state */ - eapol_state_t eapol_state; -} PACK_END d_info; - -/** Event body : Debug */ -typedef PACK_START struct _eventbuf_debug { - /** Debug type */ - t_u8 debug_type; - /** Major debug id */ - t_u32 debug_id_major; - /** Minor debug id */ - t_u32 debug_id_minor; - /** Debug Info */ - d_info info; -} PACK_END eventbuf_debug; - -int ishexstring(void *hex); -unsigned int a2hex(char *s); -/** - * @brief isdigit for String. - * - * @param x Char string - * @return MLAN_EVENT_FAILURE for non-digit. - * 0 for digit - */ -static inline int -ISDIGIT(char *x) -{ - unsigned int i; - for (i = 0; i < strlen(x); i++) - if (isdigit(x[i]) == 0) - return MLAN_EVENT_FAILURE; - return 0; -} - -#endif /* _MLAN_EVENT_H */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c index 3ec83dc..6fd6e0a 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c +++ b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c @@ -1499,6 +1499,28 @@ static int process_getlog(int argc, char *argv[]) stats->wep_icv_error[0], stats->wep_icv_error[1], stats->wep_icv_error[2], stats->wep_icv_error[3], stats->bcn_rcv_cnt, stats->bcn_miss_cnt); + + printf("rxStuckIssueCount-1 %u\n" + "rxStuckIssueCount-2 %u\n" + "rxStuckRecoveryCount %u\n" + "rxStuckTsf-1 %llu\n" + "rxStuckTsf-2 %llu\n" + "txWatchdogRecoveryCount %u\n" + "txWatchdogTsf-1 %llu\n" + "txWatchdogTsf-2 %llu\n" + "channelSwitchAnnouncementSent %u\n" + "channelSwitchState %u\n" + "registerClass %u\n" + "channelNumber %u\n" + "channelSwitchMode %u\n", + stats->rx_stuck_issue_cnt[0], stats->rx_stuck_issue_cnt[1], + stats->rx_stuck_recovery_cnt, stats->rx_stuck_tsf[0], + stats->rx_stuck_tsf[1], stats->tx_watchdog_recovery_cnt, + stats->tx_watchdog_tsf[0], stats->tx_watchdog_tsf[1], + stats->channel_switch_ann_sent, stats->channel_switch_state, + stats->reg_class, stats->channel_number, + stats->channel_switch_mode); + if (cmd->used_len == sizeof(struct eth_priv_get_log)) { printf("dot11TransmittedFragmentCount %u\n", stats->tx_frag_cnt); diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h index c3ed113..06bd45e 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h +++ b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h @@ -254,6 +254,14 @@ struct eth_priv_get_log { t_u32 bcn_rcv_cnt; /** beacon miss count */ t_u32 bcn_miss_cnt; + /** received amsdu count*/ + t_u32 amsdu_rx_cnt; + /** received msdu count in amsdu*/ + t_u32 msdu_in_rx_amsdu_cnt; + /** tx amsdu count*/ + t_u32 amsdu_tx_cnt; + /** tx msdu count in amsdu*/ + t_u32 msdu_in_tx_amsdu_cnt; /** Tx frag count */ t_u32 tx_frag_cnt; /** Qos Tx frag count */ @@ -326,6 +334,29 @@ struct eth_priv_get_log { t_u64 rx_octets_in_ampdu_cnt; /** ampdu delimiter CRC error count */ t_u32 ampdu_delimiter_crc_error_cnt; + /** Rx Stuck Related Info*/ + /** Rx Stuck Issue count */ + t_u32 rx_stuck_issue_cnt[2]; + /** Rx Stuck Recovery count */ + t_u32 rx_stuck_recovery_cnt; + /** Rx Stuck TSF */ + t_u64 rx_stuck_tsf[2]; + /** Tx Watchdog Recovery Related Info */ + /** Tx Watchdog Recovery count */ + t_u32 tx_watchdog_recovery_cnt; + /** Tx Watchdog TSF */ + t_u64 tx_watchdog_tsf[2]; + /** Channel Switch Related Info */ + /** Channel Switch Announcement Sent */ + t_u32 channel_switch_ann_sent; + /** Channel Switch State */ + t_u32 channel_switch_state; + /** Register Class */ + t_u32 reg_class; + /** Channel Number */ + t_u32 channel_number; + /** Channel Switch Mode */ + t_u32 channel_switch_mode; }; /** MLAN MAC Address Length */ diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/Makefile b/mxm_wifiex/wlan_src/mapp/uaputl/Makefile deleted file mode 100644 index 0f04379..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# File : uaputl/Makefile -# -# Copyright 2014-2020 NXP - -# Path to the top directory of the wlan distribution -PATH_TO_TOP = ../.. - -# Determine how we should copy things to the install directory -ABSPATH := $(filter /%, $(INSTALLDIR)) -RELPATH := $(filter-out /%, $(INSTALLDIR)) -INSTALLPATH := $(ABSPATH) -ifeq ($(strip $(INSTALLPATH)),) -INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) -endif - -# Override CFLAGS for application sources, remove __ kernel namespace defines -CFLAGS := $(filter-out -D__%, $(ccflags-y)) -# remove KERNEL include dir -CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) - - -#CFLAGS += -DAP22 -fshort-enums -CFLAGS += -Wall -#ECHO = @ -LIBS = -lrt - - -.PHONY: default tags all - -OBJECTS = uaputl.o uapcmd.o uaphostcmd.o -HEADERS = uaputl.h uapcmd.h - -TARGET = uaputl.exe - -build default: $(TARGET) - @cp -f $(TARGET) $(INSTALLPATH) - @cp -rf config $(INSTALLPATH) - - -all : tags default - -$(TARGET): $(OBJECTS) $(HEADERS) - $(ECHO)$(CC) $(LIBS) -o $@ $(OBJECTS) - -%.o: %.c $(HEADERS) - $(ECHO)$(CC) $(CFLAGS) -c -o $@ $< - -tags: - ctags -R -f tags.txt - -distclean clean: - $(ECHO)$(RM) $(OBJECTS) $(TARGET) - $(ECHO)$(RM) tags.txt - diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/config/80211d_domain.conf b/mxm_wifiex/wlan_src/mapp/uaputl/config/80211d_domain.conf deleted file mode 100644 index bb14e86..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/config/80211d_domain.conf +++ /dev/null @@ -1,45 +0,0 @@ -/* Domain and country mapping are in this section */ -/* Domain name followed by supported countries */ - -COUNTRY: DOMAIN_CODE_FCC AE AM AN AR AZ BH BL BN BR CL CN CR CS DZ EC EG GE HN HK ID IL IR JM JO KP KW KZ LB LK MA MO NP OM PE PG PH PK PT QA SA SG SV SY TH TT TN UY YE ZA ZW VN -COUNTRY: DOMAIN_CODE_FCC1 US UZ CA CO DO GT MX PA PR TW NZ BO BZ VE -COUNTRY: DOMAIN_CODE_MKK JP -COUNTRY: DOMAIN_CODE_ETSI AL AD AT AU BY BE BA BG HR CY CZ DK EE FI FR MK DE GB GR HU IS IE IT KR LV LI LT LU MT MD MC ME NL NO PL RO RU SM RS SI SK ES SE CH TR UA UK -COUNTRY: DOMAIN_CODE_IN IN -COUNTRY: DOMAIN_CODE_MY MY - - -/* Domain specific sub-band information */ -/* Domain name followed by set of triplets separated by comma */ -/* 1st number in triplet is First channel, */ -/* 2nd number in triplet is Number of channels followed from the First channel */ -/* 3rd number in triplet is Max-TX-power in dbm */ - -DOMAIN: DOMAIN_CODE_FCC 1 13 20 -DOMAIN: DOMAIN_CODE_FCC1 1 11 30 -DOMAIN: DOMAIN_CODE_ETSI 1 13 20 -DOMAIN: DOMAIN_CODE_MKK 1 14 23 -DOMAIN: DOMAIN_CODE_IN 1 11 30 -DOMAIN: DOMAIN_CODE_MY 1 13 20 -DOMAIN: DOMAIN_CODE_TEST 1 1 20, 2 1 16, 3 6 30, 11 1 10 -DOMAIN: DOMAIN_CODE_TEST1 1 11 30, 36 1 17, 40 1 17, 44 1 17, 48 1 17, 52 1 24, 56 1 24, 60 1 24, 64 1 24, 149 1 23, 153 1 23, 157 1 23, 161 1 23, 165 1 23, -DOMAIN: DOMAIN_CODE_END - -/* - * Information for channels in A Band. - */ - -*** 5GHz *** - -DOMAIN: DOMAIN_CODE_FCC 36 1 20, 40 1 20, 44 1 20, 48 1 20, 52 1 20, 56 1 20, 60 1 20, 64 1 20, 100 1 20, 104 1 20, 108 1 20, 112 1 20, 116 1 20, 120 1 20, 124 1 20, 128 1 20, 132 1 20, 136 1 20, 140 1 20, 144 1 20, 149 1 20, 153 1 20, 157 1 20, 161 1 20, 165 1 20, -DOMAIN: DOMAIN_CODE_FCC1 36 1 30, 40 1 30, 44 1 30, 48 1 30, 52 1 30, 56 1 30, 60 1 30, 64 1 30, 100 1 30, 104 1 30, 108 1 30, 112 1 30, 116 1 30, 120 1 30, 124 1 30, 128 1 30, 132 1 30, 136 1 30, 140 1 30, 144 1 30, 149 1 30, 153 1 30, 157 1 30, 161 1 30, 165 1 30, - -DOMAIN: DOMAIN_CODE_MKK 8 1 24, 12 1 24, 16 1 24, 36 1 23, 40 1 23, 44 1 23, 48 1 23, 52 1 23, 56 1 23, 60 1 23, 64 1 23, 100 1 23, 104 1 23, 108 1 23, 112 1 23, 116 1 23, 120 1 23, 124 1 23, 128 1 23, 132 1 23, 136 1 23, 140 1 23, - -DOMAIN: DOMAIN_CODE_ETSI 36 1 20, 40 1 20, 44 1 20, 48 1 20, 52 1 20, 56 1 20, 60 1 20, 64 1 20, 100 1 20, 104 1 20, 108 1 20, 112 1 20, 116 1 20, 120 1 20, 124 1 20, 128 1 20, 132 1 20, 136 1 20, 140 1 20, 149 1 20, 153 1 20, 157 1 20, 161 1 20, 165 1 20, - -DOMAIN: DOMAIN_CODE_IN 36 1 30, 40 1 30, 44 1 30, 48 1 30, 52 1 30, 56 1 30, 60 1 30, 64 1 30, 149 1 30, 153 1 30, 157 1 30, 161 1 30, 165 1 30, - -DOMAIN: DOMAIN_CODE_MY 36 1 20, 40 1 20, 44 1 20, 48 1 20, 52 1 20, 56 1 20, 60 1 20, 64 1 20, 149 1 20, 153 1 20, 157 1 20, 161 1 20, 165 1 20, - -DOMAIN: DOMAIN_CODE_5G_END diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/config/embedded_dhcp.conf b/mxm_wifiex/wlan_src/mapp/uaputl/config/embedded_dhcp.conf deleted file mode 100644 index 4417c5b..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/config/embedded_dhcp.conf +++ /dev/null @@ -1,9 +0,0 @@ -# File : embedded_dhcp.conf - -dhcp_config={ - HostIPAddr=192.168.10.1 - StartIPAddr=192.168.10.10 - SubMask=255.255.255.0 - LeaseTime=10000 - LimitCount=5 -} diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/config/sample_cal_data_bg_8688.conf b/mxm_wifiex/wlan_src/mapp/uaputl/config/sample_cal_data_bg_8688.conf deleted file mode 100644 index e37f674..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/config/sample_cal_data_bg_8688.conf +++ /dev/null @@ -1,42 +0,0 @@ -01 00 0c 00 58 02 -00 40 68 0c 00 00 00 40 00 00 00 00 00 11 00 00 -00 11 00 10 00 00 00 00 00 00 00 00 00 00 00 00 -10 12 00 10 10 86 40 89 01 03 02 00 01 02 05 00 -01 03 05 00 17 17 00 05 00 00 00 00 00 00 00 00 -00 30 1f 11 00 00 00 70 00 00 00 00 13 00 1e 01 -00 1e 5e 15 29 5e 15 13 5c 1d 0d 0b 1d 0d 0b 29 -0d 0b 29 5c 0b 29 5c 1d 00 5c 1d 0d 00 00 00 00 -00 5c c0 0e 00 00 00 cc 00 5f 00 00 07 01 04 00 -00 00 0e 0d 00 00 00 00 00 00 00 00 00 00 00 ff -00 00 00 01 00 00 00 00 00 00 00 ff 00 00 00 01 -00 00 00 00 00 00 00 ff 00 00 00 01 00 00 00 00 -00 00 00 ff 00 00 00 01 00 00 00 00 06 3c 06 3d -00 00 00 00 00 00 00 00 00 00 00 00 -00 5c dc 25 00 00 01 28 00 6f 00 00 07 01 04 00 -00 00 0e 0d 00 00 00 00 00 00 00 00 00 08 00 07 -00 00 00 09 00 00 00 00 00 08 00 07 00 00 00 09 -00 00 00 00 00 08 00 07 00 00 00 09 00 00 00 00 -00 08 00 07 00 00 00 09 00 00 00 00 06 3c 06 3d -00 00 00 00 00 00 00 00 00 00 00 00 -00 14 9f 1f 00 00 01 3c 03 00 00 00 00 f1 0a f1 -00 fb 0d fb -00 20 dd 28 00 00 01 5c 08 86 00 88 ff 06 b1 05 -24 24 3c 42 00 00 24 18 a4 24 bc bc 3d 00 a0 8f -00 14 00 2a 00 00 01 70 00 00 30 00 01 05 1b 00 -00 00 00 01 -00 74 2c 10 00 00 01 e4 00 00 00 00 09 6a 09 b0 -0b 12 00 6c 04 0a 00 6c 03 03 00 6c 03 03 00 6c -3f ff ff 00 3f ff ff 01 3f ff ff 02 3f ff ff 03 -15 00 00 04 17 00 00 05 19 00 00 06 1b 00 00 07 -1d 00 00 08 1f 00 00 09 21 00 00 0a 23 00 00 0b -25 00 00 0c 28 00 00 0d 2a 00 00 0e 2d 00 00 0f -2f 00 00 10 32 00 00 11 34 00 00 12 3f ff ff 13 -3f ff ff 14 -00 74 84 10 ff ff ff ff 01 00 00 00 09 b0 09 ba -0a 0f 00 6c 04 09 00 6c 03 03 00 6c 03 03 00 6c -3f ff ff 00 3f ff ff 01 3f ff ff 02 3f ff ff 03 -15 00 00 04 17 00 00 05 1a 00 00 06 1c 00 00 07 -1f 00 00 08 21 00 00 09 23 00 00 0a 26 00 00 0b -2a 00 00 0c 2d 00 00 0d 31 00 00 0e 34 00 00 0f -3f ff ff 10 3f ff ff 11 3f ff ff 12 3f ff ff 13 -3f ff ff 14 diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/config/uapcoex.conf b/mxm_wifiex/wlan_src/mapp/uaputl/config/uapcoex.conf deleted file mode 100644 index 40912f7..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/config/uapcoex.conf +++ /dev/null @@ -1,22 +0,0 @@ -# File : uapcoex.conf - -coex_config={ - common_config={ - bitmap=0x0 # bit 0: override CTS2RTS protection - APBTCoex=0 # enabled or not - } - sco_config={ - protectionFromQTime0=1000 - protectionFromQTime1=600 - protectionFromQTime2=0 - protectionFromQTime3=0 - scoProtectionFromRate=9 - aclFrequency=20 - } - acl_config={ - enabled=1 - btTime=40 - wlanTime=60 - aclProtectionFromRate=1 - } -} diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl.conf b/mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl.conf deleted file mode 100644 index 8c807a5..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl.conf +++ /dev/null @@ -1,151 +0,0 @@ -# File : uaputl.conf - - -ap_config={ - SSID="NXP Micro AP" # SSID of Micro AP, use '\' as an escape character before '"' character in SSID - BeaconPeriod=100 # Beacon period in TU - Channel=6 # Radio Channel 6 -# Channel=0,1 # auto channel select (MCS mode) -# Channel=6,2 # primary channel 6, secondary channel above. -# Channel=6,4 # primary channel 6, secondary channel below - ChanList=1,6,11 # Scan channel list -# AP_MAC=00:34:22:77:46:41 # MAC address of AP - Band=0 # 0 for 2.4GHz band - # 1 for 5GHz band - Rate=0x82,0x84,0x8b,0x96,0x0C,0x12,0x18,0x24,0x30,0x48,0x60,0x6c - # Set of data rate that a station - # in the BSS may use - # (in unit of 500 kilobit/s) - TxPowerLevel=13 # Transmit power level in dBm - BroadcastSSID=1 # Broadcast SSID feature - # 1: Enable 0:Disable - RTSThreshold=2347 # RTS threshold value - FragThreshold=2346 # Fragmentation threshold value - DTIMPeriod=1 # DTIM period in beacon periods - MCBCdataRate=0 # MCBC rate to use for packet transmission - # 0:auto - # >0 fix rate (in unit of 500 kilobit/s) -# TxBeaconRate=0 # Beacon rate to use for Beacon transmission - # 0:auto - # >0 fix rate (in unit of 500 kilobit/s) - PktFwdCtl=1 # Packet forwarding control - # 0: forward all packets to the host - # 1: firmware handles intr-BSS packets - StaAgeoutTimer=1800 # Inactive client station age out timer value - # in units of 100ms - PSStaAgeoutTimer=400 # Inactive client PS station age out timer value - # in units of 100ms - MaxStaNum=10 # Max number of stations allowed to connect - Retrylimit=7 # Retry limit to use for packet transmissions - AuthMode=0 # 0:Open authentication - # 1:shared key authentication - # 3: WPA3 SAE - Protocol=1 # protocol to use - # 1: No security 2: Static WEP - # 8: WPA 32: WPA2 40:WPA2 Mixed Mode - # 64: WPA3 SAE - RSNReplayProtection=0 # RSN replay protection 0: disabled, 1: enabled - PairwiseUpdateTimeout=100 #Pairwise Handshake update timeout: 100ms - PairwiseHandshakeRetries=3 #Pairwise Handshake retries: 3 - GroupwiseUpdateTimeout=100 #Groupwise Handshake update timeout: 100ms - GroupwiseHandshakeRetries=3 #Groupwise Handshake retries: 3 - -# **** WEP security setting****** -# KeyIndex=0 # Index of WEP key to use (0 to 3) -# Sample Key configurations are -# Key_0="55555" -# Key_1=1234567890 -# Key_2="1234567890123" -# Key_3=12345678901234567890123456 - -# **** Pairwise Cipher setting****** -# Configure both of the following for Protocol=40 -# PwkCipherWPA=4 # Pairwise cipher type - # 4: TKIP 8: AES CCMP - # 12: AES CCMP + TKIP -# PwkCipherWPA2=8 # Pairwise cipher type - # 4: TKIP 8: AES CCMP - # 12: AES CCMP + TKIP - -# **** Group Cipher setting****** - -# GwkCipher=4 # group cipher type - # 4: TKIP 8: AES CCMP - -# PSK="1234567890" # WPA/WPA2 passphrase - GroupRekeyTime= 86400 # Group key re-key interval, in second. - # 0 mean never re-key - - Enable11n=1 # 1 to enable, 0 to disable - HTCapInfo=0x111c # HTCapInfo - # Bit 15-13: Reserved set to 0 - # Bit 12: DSS/CCK mode in 40MHz enable/disable - # Bit 11-10: Reserved set to 0 - # Bit 9-8: Reserved set to 0x01 - # Bit 7: Reserved set to 0 - # Bit 6: Short GI in 40 Mhz enable/disable - # Bit 5: Short GI in 20 Mhz enable/disable - # Bit 4: Green field enable/disble - # Bit 3-2: Reserved set to 1 - # Bit 1: 20/40 Mhz enable disable. - # Bit 0: Reserved set to 0 - AMPDU=0x03 # AMPDU - # Bit 7-5: Reserved set to 0 - # Bit 4-2: Minimum MPDU Start spacing - # Set to 0 for no restriction - # Set to 1 for 1/4 us - # Set to 2 for 1/2 us - # Set to 3 for 1 us - # Set to 4 for 2 us - # Set to 5 for 4 us - # Set to 6 for 8 us - # Set to 7 for 16 us - # Bit 1-0: Max A-MPDU length - HT_MCS_MAP=0x0000ffff # Bit 7-0: MCS_SET_0 - # Bit 15-8:MCS_SET_1 -# Enable2040Coex=1 #Enable 20/40 coex feature - - #802.11D specific configuration - 11d_enable=0 # 0-disable 1-enable -# country=US # country information -# PreambleType=2 #0 to set auto, 1 to set short, 2 to set long preamble -} - - - -ap_mac_filter={ - FilterMode=0 # Mode of filter table - # 0: filter table is disabled - # 1: allow MAC address in the filter table to associate - # 2: block MAC address in the filter table - Count=0 # Number of entries in filter table,up to 16 -#Sample mac settings are -# mac_1=00:50:23:45:76:22 # mac address -# mac_2=00:34:22:77:46:34 # mac address -} - -# Wmm param setting -Wmm_parameters={ - Qos_info=0x80 - AC_BE - Aifsn=1 - Ecw_max=1 - Ecw_min=1 - Tx_op=1 - AC_BK - Aifsn=2 - Ecw_max=2 - Ecw_min=2 - Tx_op=2 - AC_VI - Aifsn=3 - Ecw_max=3 - Ecw_min=3 - Tx_op=3 - AC_VO - Aifsn=4 - Ecw_max=4 - Ecw_min=4 - Tx_op=4 -} - diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl_wifidirect.conf b/mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl_wifidirect.conf deleted file mode 100644 index fa1017c..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/config/uaputl_wifidirect.conf +++ /dev/null @@ -1,80 +0,0 @@ -# File : uaputl_wifidirect.conf - - -ap_config={ - SSID="DIRECT-" # SSID for WifiDirect - BeaconPeriod=100 # Beacon period in TU - Channel=6 # Radio Channel 6 -# Channel=0,1 # auto channel select (MCS mode) -# Channel=6,2 # primary channel 6, secondary channel above. -# Channel=6,4 # primary channel 6, secondary channel below - ChanList=1,6,11 # Scan channel list -# AP_MAC=00:34:22:77:46:41 # MAC address of AP - Rate=0x8C,0x12,0x18,0x24,0x30,0x48,0x60,0x6c - # Set of data rate that a station - # in the BSS may use - # (in unit of 500 kilobit/s) - TxPowerLevel=13 # Transmit power level in dBm - BroadcastSSID=1 # Broadcast SSID feature - # 1: Enable 0:Disable - RTSThreshold=2347 # RTS threshold value - FragThreshold=2346 # Fragmentation threshold value - DTIMPeriod=1 # DTIM period in beacon periods - MCBCdataRate=0 # MCBC rate to use for packet transmission - # 0:auto - # >0 fix rate (in unit of 500 kilobit/s) - PktFwdCtl=1 # Packet forwarding control - # 0: forward all packets to the host - # 1: firmware handles intr-BSS packets - StaAgeoutTimer=1800 # Inactive client station age out timer value - # in units of 100ms - PSStaAgeoutTimer=400 # Inactive client PS station age out timer value - # in units of 100ms - MaxStaNum=7 # Max number of stations allowed to connect - Retrylimit=7 # Retry limit to use for packet transmissions - AuthMode=0 # 0:Open authentication - # 1:shared key authentication - Protocol=32 # protocol to use - # 1: No security 2: Static WEP - # 8: WPA 32: WPA2 40:WPA2 Mixed Mode - RSNReplayProtection=0 # RSN replay protection 0: disabled, 1: enabled - PairwiseUpdateTimeout=2000 #Pairwise Handshake update timeout: 2000ms - PairwiseHandshakeRetries=3 #Pairwise Handshake retries: 3 - GroupwiseUpdateTimeout=2000 #Groupwise Handshake update timeout: 2000ms - GroupwiseHandshakeRetries=3 #Groupwise Handshake retries: 3 - - PwkCipherWPA2=8 # Pairwise cipher type - GwkCipher=8 # group cipher type - PSK="1234567890" # WPA/WPA2 passphrase - - GroupRekeyTime= 86400 # Group key re-key interval, in second. - # 0 mean never re-key - - Enable11n=1 # 1 to enable, 0 to disable - HTCapInfo=0x111c # HTCapInfo - # Bit 15-13: Reserved set to 0 - # Bit 12: DSS/CCK mode in 40MHz enable/disable - # Bit 11-10: Reserved set to 0 - # Bit 9-8: Reserved set to 0x01 - # Bit 7: Reserved set to 0 - # Bit 6: Short GI in 40 Mhz enable/disable - # Bit 5: Short GI in 20 Mhz enable/disable - # Bit 4: Green field enable/disble - # Bit 3-2: Reserved set to 1 - # Bit 1: 20/40 Mhz enable disable. - # Bit 0: Reserved set to 0 - AMPDU=0x03 # AMPDU - # Bit 7-5: Reserved set to 0 - # Bit 4-2: Minimum MPDU Start spacing - # Set to 0 for no restriction - # Set to 1 for 1/4 us - # Set to 2 for 1/2 us - # Set to 3 for 1 us - # Set to 4 for 2 us - # Set to 5 for 4 us - # Set to 6 for 8 us - # Set to 7 for 16 us - # Bit 1-0: Max A-MPDU length - #802.11D specific configuration - 11d_enable=0 # 0-disable 1-enable -} diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.c b/mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.c deleted file mode 100644 index fd1023b..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.c +++ /dev/null @@ -1,7558 +0,0 @@ -/** @file uapcmd.c - * - * @brief This file contains the handling of command. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/**************************************************************************** -Change log: - 03/01/08: Initial creation -****************************************************************************/ - -/**************************************************************************** - Header files -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "uaputl.h" -#include "uapcmd.h" - -extern struct option cmd_options[]; -/**************************************************************************** - Local functions -****************************************************************************/ -/** - * @brief Show usage information for the sys_cfg_ap_mac_address - * command - * - * $return N/A - */ -void -print_sys_cfg_ap_mac_address_usage(void) -{ - printf("\nUsage : sys_cfg_ap_mac_address [AP_MAC_ADDRESS]\n"); - printf("\nIf AP_MAC_ADDRESS is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_ssid command - * - * $return N/A - */ -void -print_sys_cfg_ssid_usage(void) -{ - printf("\nUsage : sys_cfg_ssid [SSID]\n"); - printf("\nIf SSID is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_beacon_period - * command - * - * $return N/A - */ -void -print_sys_cfg_beacon_period_usage(void) -{ - printf("\nUsage : sys_cfg_beacon_period [BEACON_PERIOD]\n"); - printf("\nIf BEACON_PERIOD is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_dtim_period - * command - * - * $return N/A - */ -void -print_sys_cfg_dtim_period_usage(void) -{ - printf("\nUsage : sys_cfg_dtim_period [DTIM_PERIOD]\n"); - printf("\nIf DTIM_PERIOD is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the bss_status - * command - * - * $return N/A - */ -void -print_sys_cfg_bss_status_usage(void) -{ - printf("\nUsage : sys_cfg_bss_status\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_channel - * command - * - * $return N/A - */ -void -print_sys_cfg_channel_usage(void) -{ - printf("\nUsage : sys_cfg_channel [CHANNEL] [MODE]\n"); - printf("\nIf CHANNEL is provided, a 'set' is performed, else a 'get' is performed."); - printf("\n MODE: band config mode "); - printf("\n Bit 0: ACS mode enable/disable"); - printf("\n Bit 1: secondary channel is above primary channel"); - printf("\n Bit 2: secondary channel is below primary channel"); - printf("\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_channel - * command - * - * $return N/A - */ -void -print_sys_cfg_channel_ext_usage(void) -{ - printf("\nUsage : sys_cfg_channel_ext [CHANNEL] [BAND] [MODE]\n"); - printf("\nIf CHANNEL is provided, a 'set' is performed, else a 'get' is performed."); - printf("\n BAND:"); - printf("\n 0 : 2.4GHz operation"); - printf("\n 1 : 5GHz operation"); - printf("\n MODE: band config mode "); - printf("\n Bit 0: ACS mode enable/disable"); - printf("\n Bit 1: secondary channel is above primary channel"); - printf("\n Bit 2: secondary channel is below primary channel"); - printf("\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_scan_channels - * command - * - * $return N/A - */ -void -print_sys_cfg_scan_channels_usage(void) -{ - printf("\nUsage : sys_cfg_scan_channels [CHANNEL[.BAND]]\n"); - printf("\nIf CHANNELS and BANDS are provided, a 'set' is performed, else a 'get' is performed.\n"); - printf("\n BAND : band of operation"); - printf("\n 0 : 2.4GHZ"); - printf("\n 1 : 5GHZ\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_rates_ext command - * - * $return N/A - */ -void -print_sys_cfg_rates_ext_usage(void) -{ - printf("\nUsage : sys_cfg_rates_ext [rates RATES] [mbrate RATE]\n"); - printf("\nIf 'Rate' provided, a 'set' is performed else a 'get' is performed"); - printf("\nRATES is provided as a set of data rates, in unit of 500 kilobits"); - printf("\nA rate with MSB bit is basic rate, i.e 0x82 is basic rate.\n"); - printf("\nFollowing is the list of supported rates in units of 500 Kbps:"); - printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)"); - printf("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)"); - printf("\nBasic rates: (0x82, 0x84, 0x8b, 0x96, 0x8C, 0x92, 0x98, 0xA4, 0xB0, 0xC8, 0xE0, 0xEc)\n"); - printf("\nRates 2, 4, 11 and 22 (in units of 500 Kbps) must be present in either of basic or"); - printf("\nnon-basic rates. If OFDM rates are enabled then 12, 24 and 48 (in units of 500 Kbps)"); - printf("\nmust be present in either basic or non-basic rates"); - printf("\nEach rate must be separated by a space."); - printf("\nrates followed by RATES for setting operational rates."); - printf("\nmbrate followed by RATE for setting multicast and broadcast rate."); - return; -} - -/** - * @brief Show usage information for the sys_cfg_rates command - * - * $return N/A - */ -void -print_sys_cfg_rates_usage(void) -{ - printf("\nUsage : sys_cfg_rates [RATES]\n"); - printf("\n[RATES] is set of data rates in unit of 500 kbps and each rate can be"); - printf("\nentered in hexadecimal or decimal format. Rates must be separated by"); - printf("\nspace. Duplicate Rate fields are not allowed"); - printf("\nA rate with MSB bit is basic rate, i.e 0x82 is basic rate."); - printf("\nFollowing is the list of supported rates in units of 500 Kbps:"); - printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)"); - printf("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)"); - printf("\nBasic rates: (0x82, 0x84, 0x8b, 0x96, 0x8C, 0x92, 0x98, 0xA4, 0xB0, 0xC8, 0xE0, 0xEc)\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_tx_power - * command - * - * $return N/A - */ -void -print_sys_cfg_tx_power_usage(void) -{ - printf("\nUsage : sys_cfg_tx_power [TX_POWER]\n"); - printf("\nIf TX_POWER is provided, a 'set' is performed, else a 'get' is performed."); - printf("\nTX_POWER is represented in dBm.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_bcast_ssid_ctl - * command - * - * $return N/A - */ -void -print_sys_cfg_bcast_ssid_ctl_usage(void) -{ - printf("\nUsage : sys_cfg_bcast_ssid_ctl [0|1]\n"); - printf("\nOptions: 0 - Disable SSID broadcast,send empty SSID (length=0) in beacon"); - printf("\n 1 - Enable SSID broadcast"); - printf("\n 2 - Disable SSID broadcast, clear SSID (ACSII 0) in beacon, but keep the original length"); - printf("\n empty - Get current SSID broadcast setting\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_rsn_replay_prot - * command - * - * $return N/A - */ -void -print_sys_cfg_rsn_replay_prot_usage(void) -{ - printf("\nUsage : sys_cfg_rsn_replay_prot [0|1]\n"); - printf("\nOptions: 0 - Disable RSN replay protection"); - printf("\n 1 - Enable RSN replay protection"); - printf("\n empty - Get current RSN replay protection setting\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_preamble_ctl - * command - * - * $return N/A - */ -void -print_sys_cfg_preamble_ctl_usage(void) -{ - printf("\nUsage : sys_cfg_preamble_ctl\n"); - printf("\nOptions: 0 - Auto/Default"); - printf("\n 1 - Short Preamble"); - printf("\n 2 - Long Preamble\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_antenna_ctl - * command - * - * $return N/A - */ -void -print_sys_cfg_antenna_ctl_usage(void) -{ - printf("\nUsage : sys_cfg_antenna_ctl [MODE]\n"); - printf("\nOptions: ANTENNA : 0 - Rx antenna"); - printf("\n 1 - Tx antenna"); - printf("\n MODE : 0 - Antenna A"); - printf("\n 1 - Antenna B"); - printf("\n empty - Get current antenna settings\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_rts_threshold - * command - * - * $return N/A - */ -void -print_sys_cfg_rts_threshold_usage(void) -{ - printf("\nUsage : sys_cfg_rts_threshold [RTS_THRESHOLD]\n"); - printf("\nIf RTS_THRESHOLD is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_frag_threshold - * command - * - * $return N/A - */ -void -print_sys_cfg_frag_threshold_usage(void) -{ - printf("\nUsage : sys_cfg_frag_threshold [FRAG_THRESHOLD]\n"); - printf("\nIf FRAG_THRESHOLD is provided, a 'set' is performed, else a 'get' is performed."); - printf("\nFragment threshold should between 256 and 2346.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_tx_beacon_rate - * command - * - * $return N/A - */ -void -print_sys_cfg_tx_beacon_rates_usage(void) -{ - printf("\nUsage : sys_cfg_tx_beacon_rate [TX_DATA_RATE]\n"); - printf("\nOptions: 0 - Auto rate"); - printf("\n >0 - Set specified beacon rate"); - printf("\n empty - Get current beacon rate"); - printf("\nFollowing is the list of supported rates in units of 500 Kbps"); - printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)"); - printf("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)"); - printf("\nOnly zero or rates currently configured are allowed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_mcbc_data_rate - * command - * - * $return N/A - */ -void -print_sys_cfg_mcbc_data_rates_usage(void) -{ - printf("\nUsage : sys_cfg_mcbc_data_rate [MCBC_DATA_RATE]\n"); - printf("\nOptions: 0 - Auto rate"); - printf("\n >0 - Set specified MCBC data rate"); - printf("\n empty - Get current MCBC data rate"); - printf("\nFollowing is the list of supported rates in units of 500 Kbps"); - printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)"); - printf("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)"); - printf("\nOnly zero or one of the basic rates currently configured are allowed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_auth command - * - * $return N/A - */ -void -print_sys_cfg_auth_usage(void) -{ - printf("\nUsage : sys_cfg_auth [AUTHMODE]\n"); - printf("\nOptions: AUTHMODE : 0 - Open authentication"); - printf("\n 1 - Shared key authentication"); - printf("\n 255 - Auto (Open and Shared key) authentication"); - printf("\n empty - Get current authenticaton mode\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_pkt_fwd_ctl command - * - * $return N/A - */ -void -print_sys_cfg_pkt_fwd_ctl_usage(void) -{ - printf("\nUsage : sys_cfg_pkt_fwd_ctl [PKT_FWD_CTRL]\n"); - printf("\nPKT_FWD_CTRL: bit 0 -- Packet forwarding handled by Host (0) or Firmware (1)"); - printf("\n bit 1 -- Intra-BSS broadcast packets are allowed (0) or denied (1)"); - printf("\n bit 2 -- Intra-BSS unicast packets are allowed (0) or denied (1)"); - printf("\n bit 3 -- Inter-BSS unicast packets are allowed (0) or denied (1)"); - printf("\n empty - Get current packet forwarding setting\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_sta_ageout_timer - * command - * - * $return N/A - */ -void -print_sys_cfg_sta_ageout_timer_usage(void) -{ - printf("\nUsage : sys_cfg_sta_ageout_timer [STA_AGEOUT_TIMER]\n"); - printf("\nIf STA_AGEOUT_TIMER is provided, a 'set' is performed, else a 'get' is performed."); - printf("\nSTA_AGEOUT_TIMER is represented in units of 100 ms."); - printf("\nValue of 0 will mean that stations will never be aged out."); - printf("\nThe value should be between 100 and 864000.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_ps_sta_ageout_timer - * command - * - * $return N/A - */ -void -print_sys_cfg_ps_sta_ageout_timer_usage(void) -{ - printf("\nUsage : sys_cfg_ps_sta_ageout_timer [PS_STA_AGEOUT_TIMER]\n"); - printf("\nIf PS_STA_AGEOUT_TIMER is provided, a 'set' is performed, else a 'get' is performed."); - printf("\nPS_STA_AGEOUT_TIMER is represented in units of 100 ms."); - printf("\nValue of 0 will mean that stations will never be aged out."); - printf("\nThe value should be between 100 and 864000.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_protocol command - * - * $return N/A - */ -void -print_sys_cfg_protocol_usage(void) -{ - printf("\nUsage : sys_cfg_protocol [PROTOCOL] [AKM_SUITE]\n"); - printf("\nOptions: PROTOCOL: 1 - No RSN"); - printf("\n 2 - WEP Static"); - printf("\n 8 - WPA"); - printf("\n 32 - WPA2"); - printf("\n 40 - WPA2 Mixed"); - printf("\n 256 - WPA3 SAE"); - printf("\n empty - Get current protocol"); - printf("\n AKM_SUITE: bit 0 - KEY_MGMT_EAP"); - printf("\n bit 1 - KEY_MGMT_PSK"); - printf("\n bit 2 - KEY_MGMT_NONE"); - printf("\n bit 8 - KEY_MGMT_PSK_SHA256"); - printf("\n bit 10 - KEY_MGMT_WPA3_SAE"); - printf("\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_wep_key - * command - * - * $return N/A - */ -void -print_sys_cfg_wep_key_usage(void) -{ - printf("\nUsage : sys_cfg_wep_key "); - printf("[INDEX_0 IS_DEFAULT KEY_0] [INDEX_1 IS_DEFAULT KEY_1] [INDEX_2 IS_DEFAULT KEY_2] [INDEX_3 IS_DEFAULT KEY_3]\n"); - printf("[Index_0] [Index_1] [Index_2] [Index_3]\n"); - printf("\nOptions: INDEX_* : 0 - KeyIndex is 0"); - printf("\n 1 - KeyIndex is 1"); - printf("\n 2 - KeyIndex is 2"); - printf("\n 3 - KeyIndex is 3"); - printf("\n IS_DEFAULT : 0 - KeyIndex is not the default"); - printf("\n 1 - KeyIndex is the default transmit key"); - printf("\n KEY_* : Key value"); - printf("\n Index_*: 0 - Get key 0 setting"); - printf("\n 1 - Get key 1 setting"); - printf("\n 2 - Get key 2 setting"); - printf("\n 3 - Get key 3 setting"); - printf("\n empty - Get current WEP key settings\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_cipher - * command - * - * $return N/A - */ -void -print_sys_cfg_cipher_usage(void) -{ - printf("\nUsage : sys_cfg_cipher [PAIRWISE_CIPHER GROUP_CIPHER]\n"); - printf("\nOptions: PAIRWISE_CIPHER: 0 - NONE"); - printf("\n 4 - TKIP"); - printf("\n 8 - AES CCMP"); - printf("\n 12 - AES CCMP + TKIP"); - printf("\n GROUP_CIPHER : 0 - NONE"); - printf("\n 4 - TKIP"); - printf("\n 8 - AES CCMP"); - printf("\n empty - Get current cipher settings\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_pwk_cipher - * command - * - * $return N/A - */ -void -print_sys_cfg_pwk_cipher_usage(void) -{ - printf("\nUsage : sys_cfg_pwk_cipher [] [PAIRWISE_CIPHER]\n"); - printf("\nOptions: PROTOCOL :"); - printf("\n 8 - WPA"); - printf("\n 32 - WPA2"); - printf("\n PAIRWISE_CIPHER : "); - printf("\n 4 - TKIP"); - printf("\n 8 - AES CCMP"); - printf("\n 12 - AES CCMP + TKIP"); - printf("\n WPA/TKIP cannot be used when uAP operates in 802.11n mode.\n"); - printf("\n If only PROTOCOL is given, pairwise cipher for that protocol is displayed\n"); - printf("\n empty - Get current protocol and pairwise cipher settings\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_gwk_cipher - * command - * - * $return N/A - */ -void -print_sys_cfg_gwk_cipher_usage(void) -{ - printf("\nUsage : sys_cfg_gwk_cipher [GROUP_CIPHER]\n"); - printf("\n GROUP_CIPHER :"); - printf("\n 4 - TKIP"); - printf("\n 8 - AES CCMP"); - printf("\n empty - Get current group cipher settings\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_group_rekey_timer command - * - * $return N/A - */ -void -print_sys_cfg_group_rekey_timer_usage(void) -{ - printf("\nUsage : sys_cfg_group_rekey_timer [GROUP_REKEY_TIMER]\n"); - printf("\nOptions: GROUP_REKEY_TIME is represented in seconds"); - printf("\n empty - Get current group re-key time\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_wpa_passphrase - * command - * - * $return N/A - */ -void -print_sys_cfg_wpa_passphrase_usage(void) -{ - printf("\nUsage : sys_cfg_wpa_passphrase [PASSPHRASE]\n"); - printf("\nIf PASSPHRASE is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_wpa3_sae_password - * command - * - * $return N/A - */ -void -print_sys_cfg_wpa3_sae_password_usage(void) -{ - printf("\nUsage : sys_cfg_wpa3_sae_password [PASSWORD]\n"); - printf("\nIf PASSWORD is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sta_filter_table command - * - * $return N/A - */ -void -print_sta_filter_table_usage(void) -{ - printf("\nUsage : sta_filter_table \n"); - printf("\nOptions: FILTERMODE : 0 - Disable filter table"); - printf("\n 1 - allow MAC addresses specified in the allowed list"); - printf("\n 2 - block MAC addresses specified in the banned list"); - printf("\n MACADDRESS_LIST is the list of MAC addresses to be acted upon. Each"); - printf("\n MAC address must be separated with a space. Maximum of"); - printf("\n 16 MAC addresses are supported."); - printf("\n empty - Get current mac filter settings\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_max_sta_num command - * - * $return N/A - */ -void -print_sys_cfg_max_sta_num_usage(void) -{ - printf("\nUsage : sys_cfg_max_sta_num [STA_NUM]\n"); - printf("\nIf STA_NUM is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_retry_limit command - * - * $return N/A - */ -void -print_sys_cfg_retry_limit_usage(void) -{ - printf("\nUsage : sys_cfg_retry_limit [RETRY_LIMIT]\n"); - printf("\nIf RETRY_LIMIT is provided, a 'set' is performed, else a 'get' is performed."); - printf("\nRETRY_LIMIT should be greater than or equal to zero and less than or equal to 14\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_sticky_tim_config command - * - * $return N/A - */ -void -print_sys_cfg_sticky_tim_config_usage(void) -{ - printf("\nUsage : sys_cfg_sticky_tim_config [ENABLE] [ ]\n"); - printf("\nOptions: ENABLE 0 - disable"); - printf("\n 1 - enable"); - printf("\n 2 - enable with previous values of DURATION and STICKY_BITMASK"); - printf("\n DURATION: duration for sticky TIM"); - printf("\n STICKY_BITMASK: Bitmask for sticky TIM configuartion"); - printf("\n empty - Get current sticky TIM configuration\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_sticky_tim_mac_addr command - * - * $return N/A - */ -void -print_sys_cfg_sticky_tim_sta_mac_addr_usage(void) -{ - printf("\nUsage : sys_cfg_sticky_tim_sta_mac_addr [CONTROL] [STA_MAC_ADDRESS]\n"); - printf("\nOptions: CONTROL: sticky TIM config for given station"); - printf("\n STA_MAC_ADDRESS: station MAC address"); - printf("\n if only STA_MAC_ADDRESS is given - Get sticky TIM configuration for that station\n"); - printf("\n empty - Get current sticky TIM configuration for all associated stations\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_2040_coex command - * - * $return N/A - */ -void -print_sys_cfg_2040_coex_usage(void) -{ - printf("\nUsage : sys_cfg_2040_coex [ENABLE]\n"); - printf("\nOptions: ENABLE 0 - disable"); - printf("\n 1 - enable"); - printf("\n empty - Get current 20/40 BSS coexistence configuration\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_eapol_pwk_hsk command - * - * $return N/A - */ -void -print_sys_cfg_eapol_pwk_hsk_usage(void) -{ - printf("\nUsage : sys_cfg_eapol_pwk_hsk [ ]\n"); - printf("\nIf TIMEOUT and number of RETRIES are both provided, a 'set' is performed."); - printf("\nIf no parameter is provided,a 'get' is performed."); - printf("\nTIMEOUT and number of RETRIES should be greater than or equal to zero\n"); - return; -} - -/** - * @brief Show usage information for the sys_cfg_eapol_gwk_hsk command - * - * $return N/A - */ -void -print_sys_cfg_eapol_gwk_hsk_usage(void) -{ - printf("\nUsage : sys_cfg_eapol_gwk_hsk [ ]\n"); - printf("\nIf TIMEOUT and number of RETRIES are both provided, a 'set' is performed."); - printf("\nIf no parameter is provided,a 'get' is performed."); - printf("\nTIMEOUT and number of RETRIES should be greater than or equal to zero\n"); - return; -} - -/** - * @brief Show usage information for the cfg_data command - * - * $return N/A - */ -void -print_cfg_data_usage(void) -{ - printf("\nUsage : cfg_data [*.conf]\n"); - printf("\n type : 2 -- cal data"); - printf("\n *.conf : file contain configuration data"); - printf("\n empty - get current configuration data\n"); - return; -} - -/** - * @brief Get configured operational rates. - * - * @param rates Operational rates allowed are - * stored at this pointer - * @return Number of basic rates allowed. - * -1 if a failure - */ -int -get_sys_cfg_rates(t_u8 *rates) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_rates *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len; - int ret = UAP_FAILURE; - int i = 0; - int rate_cnt = 0; - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_rates) + - MAX_DATA_RATES; - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return -1; - } - memset(buffer, 0, cmd_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rates *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_RATES_TLV_ID; - cmd_buf->action = ACTION_GET; - tlv->length = MAX_DATA_RATES; - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, cmd_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_RATES_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return -1; - } - - /* Copy response */ - if (cmd_buf->result == CMD_SUCCESS) { - for (i = 0; i < tlv->length; i++) { - if (tlv->operational_rates[i] != 0) { - rates[rate_cnt++] = - tlv->operational_rates[i]; - } - } - } else { - printf("ERR:Could not get operational rates!\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return rate_cnt; -} - -/** - * @brief Check rate is valid or not. - * - * @param rate Rate for check - * - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_tx_rate_valid(t_u8 rate) -{ - int rate_cnt = 0; - int i; - t_u8 rates[MAX_DATA_RATES]; - - rate_cnt = get_sys_cfg_rates((t_u8 *)&rates); - if (rate_cnt > 0) { - for (i = 0; i < rate_cnt; i++) { - if (rate == (rates[i] & ~BASIC_RATE_SET_BIT)) { - return UAP_SUCCESS; - } - } - } - return UAP_FAILURE; -} - -/** - * @brief Check mcbc rate is valid or not. - * - * @param rate Rate for check - * - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_mcbc_rate_valid(t_u8 rate) -{ - int rate_cnt = 0; - int i; - t_u8 rates[MAX_DATA_RATES]; - - rate_cnt = get_sys_cfg_rates((t_u8 *)&rates); - if (rate_cnt > 0) { - for (i = 0; i < rate_cnt; i++) { - if (rates[i] & BASIC_RATE_SET_BIT) { - if (rate == (rates[i] & ~BASIC_RATE_SET_BIT)) { - return UAP_SUCCESS; - } - } - } - } - return UAP_FAILURE; -} - -/**************************************************************************** - Global functions -****************************************************************************/ -/** - * @brief Creates a sys_cfg request for AP MAC address - * and sends to the driver - * - * Usage: "sys_cfg_ap_mac_address [AP_MAC_ADDRESS]" - * if AP_MAC_ADDRESS is provided, a 'set' is performed, - * else a 'get' is performed. - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_ap_mac_address(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_ap_mac_address *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_ap_mac_address_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_ap_mac_address_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_ap_mac_address); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_ap_mac_address *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_AP_MAC_ADDRESS_TLV_ID; - tlv->length = ETH_ALEN; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - if ((ret = mac2raw(argv[0], tlv->ap_mac_addr)) != UAP_SUCCESS) { - printf("ERR: %s Address \n", - ret == UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - free(buffer); - return UAP_FAILURE; - } - } - endian_convert_tlv_header_out(tlv); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_AP_MAC_ADDRESS_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("AP MAC address = "); - print_mac(tlv->ap_mac_addr); - printf("\n"); - } else { - printf("AP MAC address setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get AP MAC address!\n"); - } else { - printf("ERR:Could not set AP MAC address!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for SSID - * and sends to the driver - * - * Usage: "sys_cfg_ssid [SSID]" - * if SSID is provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_ssid(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_ssid *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - t_u8 ssid[33]; - - argc--; - argv++; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_ssid_usage(); - return UAP_FAILURE; - } - - if (argc == 0) { - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_ssid) + - MAX_SSID_LENGTH; - } else { - if (strlen(argv[0]) > MAX_SSID_LENGTH) { - printf("ERR:SSID too long.\n"); - return UAP_FAILURE; - } - /* Initialize the command length */ - if (argv[0][1] == '"') { - argv[0]++; - } - if (argv[0][strlen(argv[0])] == '"') { - argv[0][strlen(argv[0])] = '\0'; - } - if (!strlen(argv[0])) { - printf("ERR:NULL SSID not allowed.\n"); - return UAP_FAILURE; - } - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_ssid) + - strlen(argv[0]); - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_ssid *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_SSID_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->length = MAX_SSID_LENGTH; - } else { - cmd_buf->action = ACTION_SET; - tlv->length = strlen(argv[0]); - memcpy(tlv->ssid, argv[0], tlv->length); - } - - endian_convert_tlv_header_out(tlv); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_SSID_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - memset(ssid, 0, sizeof(ssid)); - strncpy((char *)ssid, (char *)tlv->ssid, - sizeof(ssid) - 1); - - printf("SSID = %s\n", ssid); - } else { - printf("SSID setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get SSID!\n"); - } else { - printf("ERR:Could not set SSID!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for beacon period - * and sends to the driver - * - * Usage: "sys_cfg_beacon_period [BEACON_PERIOD]" - * if BEACON_PERIOD is provided, a 'set' is performed - * else a 'get' is performed. - * - * BEACON_PERIOD is represented in ms - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_beacon_period(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_beacon_period *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_beacon_period_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && is_input_valid(BEACONPERIOD, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_beacon_period_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_beacon_period); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_beacon_period *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_BEACON_PERIOD_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->beacon_period_ms = (t_u16)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->beacon_period_ms = uap_cpu_to_le16(tlv->beacon_period_ms); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->beacon_period_ms = uap_le16_to_cpu(tlv->beacon_period_ms); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_BEACON_PERIOD_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Beacon period = %d\n", - tlv->beacon_period_ms); - } else { - printf("Beacon period setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get beacon period!\n"); - } else { - printf("ERR:Could not set beacon period!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for DTIM period - * and sends to the driver - * - * Usage: "sys_cfg_dtim_period [DTIM_PERIOD]" - * if DTIM_PERIOD is provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_dtim_period(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_dtim_period *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_dtim_period_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(DTIMPERIOD, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_dtim_period_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_dtim_period); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_dtim_period *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_DTIM_PERIOD_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->dtim_period = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_DTIM_PERIOD_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("DTIM period = %d\n", tlv->dtim_period); - } else { - printf("DTIM period setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get DTIM period!\n"); - } else { - printf("ERR:Could not set DTIM period!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for bss_status - * and sends to the driver - * - * Usage: "sys_cfg_bss_status" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_bss_status(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_bss_status *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_bss_status_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 0) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_bss_status_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_bss_status); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_bss_status *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_BSS_STATUS_TLV_ID; - tlv->length = 2; - cmd_buf->action = ACTION_GET; - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->bss_status = uap_le16_to_cpu(tlv->bss_status); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_BSS_STATUS_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("BSS status = %s\n", - (tlv->bss_status == 0) ? "stopped" : "started"); - } else { - printf("ERR:Could not get BSS status!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** DFS Radar starting channel FCC */ -#define DFS_FCC_RADAR_CHANNEL_START 52 -/** DFS Radar ending channel FCC */ -#define DFS_FCC_RADAR_CHANNEL_END 144 - -/** DFS Radar starting channel ETSI */ -#define DFS_ETSI_RADAR_CHANNEL_START 52 -/** DFS Radar ending channel ETSI */ -#define DFS_ETSI_RADAR_CHANNEL_END 140 - -/** DFS Radar starting channel JAPAN */ -#define DFS_JAPAN_RADAR_CHANNEL_START 52 -/** DFS Radar ending channel JAPAN */ -#define DFS_JAPAN_RADAR_CHANNEL_END 140 - -/** list of RegDomain values */ -typedef enum { - RegDomain_Null = 0x00, - RegDomain_FCC = 0x01, - RegDomain_ETSI = 0x02, - RegDomain_MIC = 0x03, - RegDomain_Other = 0xFF, -} regdomain_e; - -/** mapping of region and domain code */ -typedef struct { - /** region */ - t_u8 region[COUNTRY_CODE_LEN]; - /** domain code */ - regdomain_e code; -} region_code_mapping_t; - -static region_code_mapping_t region_code_mapping[] = { - {"US ", RegDomain_FCC}, /* US FCC 0x10 */ - {"SG ", RegDomain_FCC}, /* Singapore 0x10 */ - {"EU ", RegDomain_ETSI}, /* ETSI 0x30 */ - {"AU ", RegDomain_ETSI}, /* Australia 0x30 */ - {"KR ", RegDomain_ETSI}, /* Republic Of Korea 0x30 */ - {"JP ", RegDomain_MIC}, /* Japan 0x40 */ - {"J1 ", RegDomain_MIC}, /* Japan1 0x41 */ -}; - -/** - * @brief This function converts region string to region code - * - * @param region_string Region string - * - * @return Region code - */ -regdomain_e -region_string_2_region_code(char *region_string) -{ - t_u8 i; - t_u8 size = sizeof(region_code_mapping) / sizeof(region_code_mapping_t); - - for (i = 0; i < COUNTRY_CODE_LEN && region_string[i]; i++) { - region_string[i] = toupper(region_string[i]); - } - - for (i = 0; i < size; i++) { - if (!memcmp(region_string, - region_code_mapping[i].region, COUNTRY_CODE_LEN)) { - return (region_code_mapping[i].code); - } - } - - /* default is US */ - return (region_code_mapping[0].code); -} - -/** - * @brief Checks if channel is dfs channel and allow only if 11h is enabled. - * - * @param channel Channel - * @param country Country - * @return UAP_FAILURE/UAP_SUCCESS - */ -int -is_dfs_channel(int channel, char *country) -{ - regdomain_e region; - t_u8 DFS_RadarDetectChannelStart = DFS_FCC_RADAR_CHANNEL_START; - t_u8 DFS_RadarDetectChannelEnd = DFS_FCC_RADAR_CHANNEL_END; - - region = region_string_2_region_code(country); - /* set radar start channel and end channel */ - switch (region) { - default: /* use FCC as default setting */ - case RegDomain_FCC: - DFS_RadarDetectChannelStart = DFS_FCC_RADAR_CHANNEL_START; - DFS_RadarDetectChannelEnd = DFS_FCC_RADAR_CHANNEL_END; - break; - case RegDomain_ETSI: - DFS_RadarDetectChannelStart = DFS_ETSI_RADAR_CHANNEL_START; - DFS_RadarDetectChannelEnd = DFS_ETSI_RADAR_CHANNEL_END; - break; - case RegDomain_MIC: - DFS_RadarDetectChannelStart = DFS_JAPAN_RADAR_CHANNEL_START; - DFS_RadarDetectChannelEnd = DFS_JAPAN_RADAR_CHANNEL_END; - break; - } - if (channel < DFS_RadarDetectChannelStart - || channel > DFS_RadarDetectChannelEnd) { - return UAP_FAILURE; - } - - return UAP_SUCCESS; -} - -/** - * @brief Checks if channel is valid for given 11d domain. - * - * @param channel Channel - * @param band Band - * @param set_domain Flag to indicate update domain info with this channel - * @return UAP_FAILURE/UAP_SUCCESS - */ -int -check_channel_validity_11d(int channel, int band, int set_domain) -{ - apcmdbuf_cfg_80211d *cmd_buf = NULL; - ieeetypes_subband_set_t sub_bands[MAX_SUB_BANDS]; - t_u8 *buf = NULL; - t_u16 cmd_len; - t_u16 buf_len = 0; - int ret = UAP_FAILURE; - int i, j, found = 0; - t_u8 no_of_sub_band = 0; - char country[4] = { ' ', ' ', 0, 0 }; - - buf_len = sizeof(apcmdbuf_cfg_80211d); - buf_len += MAX_SUB_BANDS * sizeof(ieeetypes_subband_set_t); - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_cfg_80211d *)buf; - cmd_len = (sizeof(apcmdbuf_cfg_80211d) - sizeof(domain_param_t)); - - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = ACTION_GET; - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - /* Check channel against US if country code is not set */ - if (! - (cmd_buf->domain.country_code[0] || - cmd_buf->domain.country_code[1] || - cmd_buf->domain.country_code[2])) { - country[0] = 'U'; - country[1] = 'S'; - country[2] = '\0'; - /* Do not send this country code to FW though */ - set_domain = 0; - } else { - country[0] = cmd_buf->domain.country_code[0]; - country[1] = cmd_buf->domain.country_code[1]; - } - if (cmd_buf->domain.country_code[2] == 'I') { - if ((channel != 36) && (channel != 40) && - (channel != 44) && (channel != 48)) { - printf("ERR: Channel not valid for indoor operation!\n"); - ret = UAP_FAILURE; - goto done; - } - } - if (is_dfs_channel(channel, country) == UAP_SUCCESS) { - printf("DFS channel selected.\n"); - } - no_of_sub_band = - parse_domain_file(country, band, sub_bands, - NULL); - /* copy third character of country code here as domain file cannot handle it */ - country[2] = cmd_buf->domain.country_code[2]; - if (no_of_sub_band == UAP_FAILURE) { - printf("Parsing of domain configuration file failed\n"); - ret = UAP_FAILURE; - goto done; - } - - for (i = 0; i < no_of_sub_band; i++) { - for (j = 0; j < sub_bands[i].no_of_chan; j++) { - if (channel == - (sub_bands[i].first_chan + j)) { - found = 1; - break; - } - } - if (found) - break; - } - - if (!found) { - printf("ERR:Invalid channel %d for given domain!\n", channel); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command Response incorrect!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command sending failed!\n"); - goto done; - } - if (found && set_domain) { - /* If channel is valid then set domain_info with new band */ - memset(buf, 0, buf_len); - buf_len = - sizeof(apcmdbuf_cfg_80211d) + - no_of_sub_band * sizeof(ieeetypes_subband_set_t); - cmd_buf = (apcmdbuf_cfg_80211d *)buf; - cmd_len = buf_len; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = ACTION_SET; - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - - cmd_buf->domain.tag = uap_cpu_to_le16(TLV_TYPE_DOMAIN); - cmd_buf->domain.length = uap_cpu_to_le16(sizeof(domain_param_t) - - BUF_HEADER_SIZE + - (no_of_sub_band * - sizeof - (ieeetypes_subband_set_t))); - - memset(cmd_buf->domain.country_code, ' ', - sizeof(cmd_buf->domain.country_code)); - memcpy(cmd_buf->domain.country_code, country, strlen(country)); - memcpy(cmd_buf->domain.subband, sub_bands, - no_of_sub_band * sizeof(ieeetypes_subband_set_t)); - - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - ret = UAP_SUCCESS; - } else { - printf("ERR:Command Response incorrect!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command sending failed!\n"); - ret = UAP_FAILURE; - goto done; - } - } -done: - if (buf) - free(buf); - return ret; -} - -/** - * @brief Creates a sys_cfg request for channel - * and sends to the driver - * - * Usage: "sys_cfg_channel [CHANNEL] [MODE]" - * if CHANNEL is provided, a 'set' is performed - * else a 'get' is performed - * if MODE is provided, a 'set' is performed with - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_channel(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_channel_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - int mode = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_channel_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && is_input_valid(CHANNEL, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_channel_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_channel_config); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_channel_config *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CHANNELCONFIG_TLV_ID; - tlv->length = sizeof(tlvbuf_channel_config) - TLVHEADER_LEN; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - if (argc == 1) { - tlv->chan_number = (t_u8)atoi(argv[0]); - memset(&(tlv->bandcfg), 0, sizeof(tlv->bandcfg)); - } else { - mode = atoi(argv[1]); - memset(&(tlv->bandcfg), 0, sizeof(tlv->bandcfg)); - if (mode & BITMAP_ACS_MODE) { - int mode; - if (uap_ioctl_dfs_repeater_mode(&mode) == - UAP_SUCCESS) { - if (mode) { - printf("ERR: ACS in DFS Repeater mode" " is not allowed\n"); - ret = UAP_FAILURE; - goto done; - } - } - tlv->bandcfg.scanMode = SCAN_MODE_ACS; - } - if (mode & BITMAP_CHANNEL_ABOVE) - tlv->bandcfg.chan2Offset = SEC_CHAN_ABOVE; - if (mode & BITMAP_CHANNEL_BELOW) - tlv->bandcfg.chan2Offset = SEC_CHAN_BELOW; - tlv->chan_number = (t_u8)atoi(argv[0]); - } - if (atoi(argv[0]) > MAX_CHANNELS_BG) { - tlv->bandcfg.chanBand = BAND_5GHZ; - } - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CHANNELCONFIG_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Mode = %s\n", - (tlv->bandcfg.scanMode == - SCAN_MODE_ACS) ? "ACS" : "Manual"); - printf("Channel = %d\n", tlv->chan_number); - if (tlv->bandcfg.chan2Offset == SEC_CHAN_NONE) - printf("no secondary channel\n"); - else if (tlv->bandcfg.chan2Offset == - SEC_CHAN_ABOVE) - printf("secondary channel is above primary channel\n"); - else if (tlv->bandcfg.chan2Offset == - SEC_CHAN_BELOW) - printf("secondary channel is below primary channel\n"); - } else { - printf("Channel setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get channel!\n"); - } else { - printf("ERR:Could not set channel!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for channel - * and sends to the driver - * - * Usage: "sys_cfg_channel_ext [CHANNEL] [BAND] [MODE]" - * if CHANNEL is provided, a 'set' is performed - * else a 'get' is performed - * if BAND is provided, a 'set' is performed with band info(2.4GHz/5GHz) - * if MODE is provided, a 'set' is performed with mode (ACS/secondary channel) - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_channel_ext(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_channel_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - int mode = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_channel_ext_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && is_input_valid(CHANNEL_EXT, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_channel_ext_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_channel_config); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_channel_config *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CHANNELCONFIG_TLV_ID; - tlv->length = sizeof(tlvbuf_channel_config) - TLVHEADER_LEN; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->chan_number = (t_u8)atoi(argv[0]); - if (argc == 1) { - if (atoi(argv[0]) > MAX_CHANNELS_BG) - tlv->bandcfg.chanBand = BAND_5GHZ; - } else { - if (atoi(argv[1]) == 0) { - tlv->bandcfg.chanBand = BAND_2GHZ; - } else { - tlv->bandcfg.chanBand = BAND_5GHZ; - } - if (argc == 3) { - mode = atoi(argv[2]); - if (mode & BITMAP_ACS_MODE) { - int mode; - if (uap_ioctl_dfs_repeater_mode(&mode) - == UAP_SUCCESS) { - if (mode) { - printf("ERR: ACS in DFS Repeater mode" " is not allowed\n"); - ret = UAP_FAILURE; - goto done; - } - } - tlv->bandcfg.scanMode = SCAN_MODE_ACS; - } - if (mode & BITMAP_CHANNEL_ABOVE) - tlv->bandcfg.chan2Offset = - SEC_CHAN_ABOVE; - if (mode & BITMAP_CHANNEL_BELOW) - tlv->bandcfg.chan2Offset = - SEC_CHAN_BELOW; - } - } - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CHANNELCONFIG_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Mode = %s\n", - (tlv->bandcfg.scanMode == - SCAN_MODE_ACS) ? "ACS" : "Manual"); - printf("Channel = %d\n", tlv->chan_number); - printf("Band = %s\n", - (tlv->bandcfg.chanBand == - BAND_5GHZ) ? "5GHz" : "2.4GHz"); - if (tlv->bandcfg.chan2Offset == SEC_CHAN_NONE) - printf("no secondary channel\n"); - else if (tlv->bandcfg.chan2Offset == - SEC_CHAN_ABOVE) - printf("secondary channel is above primary channel\n"); - else if (tlv->bandcfg.chan2Offset == - SEC_CHAN_BELOW) - printf("secondary channel is below primary channel\n"); - } else { - printf("Channel setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get channel!\n"); - } else { - printf("ERR:Could not set channel!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for channel list - * and sends to the driver - * - * Usage: "sys_cfg_scan_channels [CHANNEL[.BAND]]" - * if CHANNEL and BAND are provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_scan_channels(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_channel_list *tlv = NULL; - channel_list *pchan_list = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_FAILURE; - int opt; - int i; - int scan_channels_band; - int chan_number = 0; - int band_flag = -1; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_scan_channels_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && is_input_valid(SCANCHANNELS, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_scan_channels_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - if (argc == 0) - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_channel_list) + - sizeof(channel_list) * MAX_CHANNELS; - else - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_channel_list) + - sizeof(channel_list) * argc; - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* LOCATE HEADERS */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_channel_list *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CHANNELLIST_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->length = sizeof(channel_list) * MAX_CHANNELS; - } else { - cmd_buf->action = ACTION_SET; - tlv->length = sizeof(channel_list) * argc; - pchan_list = tlv->chan_list; - for (i = 0; i < argc; i++) { - band_flag = -1; - sscanf(argv[i], "%d.%d", &chan_number, &band_flag); - pchan_list->chan_number = chan_number; - pchan_list->bandcfg.chanBand = BAND_2GHZ; - if (((band_flag != -1) && (band_flag)) || - (chan_number > MAX_CHANNELS_BG)) { - pchan_list->bandcfg.chanBand = BAND_5GHZ; - } - scan_channels_band = BAND_B | BAND_G; - if ((scan_channels_band != BAND_A) && - (pchan_list->bandcfg.chanBand == BAND_5GHZ)) { - scan_channels_band = BAND_A; - } - if (check_channel_validity_11d - (pchan_list->chan_number, scan_channels_band, - 0) == UAP_FAILURE) { - free(buffer); - return UAP_FAILURE; - } - pchan_list++; - } - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CHANNELLIST_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Channels List = "); - if (tlv->length % sizeof(channel_list)) { - printf("Error: Length mismatch\n"); - free(buffer); - return UAP_FAILURE; - } - pchan_list = tlv->chan_list; - for (i = 0; - (unsigned int)i < - (tlv->length / sizeof(channel_list)); - i++) { - printf("\n%d\t%sGHz", - pchan_list->chan_number, - (pchan_list->bandcfg.chanBand == - BAND_5GHZ) ? "5" : "2.4"); - pchan_list++; - } - printf("\n"); - } else { - printf("Scan Channel List setting successful\n"); - } - } else { - printf("ERR:Could not %s scan channel list!\n", - argc ? "SET" : "GET"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Parser for sys_cfg_rates_ext input - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @param output Stores indexes for "rates, mbrate and urate" - * arguments - * - * e.g., - * - * "rates 0x82 4 16 22 0x30 mbrate 2 urate 16" - * - * will have output array as - * - * start_index end_index - * rates 0 5 - * mbrate 6 7 - * urate 8 9 - * - * @return NA - * - */ -void -parse_input(int argc, char **argv, int output[3][2]) -{ - int i, j, k = 0; - char *keywords[3] = { "rates", "mbrate", "urate" }; - - for (i = 0; i < 3; i++) - output[i][0] = -1; - - for (i = 0; i < argc; i++) { - for (j = 0; j < 3; j++) { - if (strcmp(argv[i], keywords[j]) == 0) { - output[j][1] = output[j][0] = i; - k = j; - break; - } - } - output[k][1] += 1; - } -} - -/** - * @brief Creates a sys_cfg request for setting data_rates, MCBC and - * TX data rates. - * - * Usage: "sys_cfg_rates_ext [RATES]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_rates_ext(int argc, char *argv[]) -{ - int i, j = 0, found = 0; - int opt; - int rflag = 0, mflag = 0; - char *argv_rate[14]; - int argc_rate = 0; - char *argv_mrate[1]; - int mrate_found = UAP_FAILURE; - t_u8 *tlv_buf = NULL; - tlvbuf_mcbc_data_rate *tlv_mrate = NULL; - tlvbuf_rates *tlv_rate = NULL; - t_u8 *buffer = NULL; - apcmdbuf_sys_configure *cmd_buf = NULL; - int ret = UAP_SUCCESS; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int output[3][2]; - char *keywords[3] = { "rates", "mbrate" }; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_rates_ext_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - if (argc) { - /* - * SET - */ - parse_input(argc, argv, output); - - for (i = 0; i < 3; i++) { - if (output[i][0] == -1) { - for (j = 0; j < 3; j++) { - if (output[j][0] == 0) - found = 1; - } - if (!found) { - printf("%s keyword not specified!\n", - keywords[i]); - ret = UAP_FAILURE; - goto done; - } - } - } - /* - * Rate - */ - if ((output[0][0] != -1) && (output[0][1] > output[0][0])) { - rflag = 1; - i = 0; - for (j = (output[0][0] + 1); j < output[0][1]; j++) { - argv_rate[i] = - (char *)malloc(sizeof(char) * - (strlen(argv[j]) + 1)); - memset(argv_rate[i], 0, - sizeof(char) * (strlen(argv[j]) + 1)); - strncpy(argv_rate[i], argv[j], strlen(argv[j])); - argc_rate = ++i; - } - } - - /* - * mrate - */ - - if ((output[1][0] != -1) && (output[1][1] > output[1][0])) { - if ((output[1][1] - output[1][0]) != 2) { - printf("\nERR: Invalid mrate input"); - print_sys_cfg_rates_ext_usage(); - ret = UAP_FAILURE; - goto done; - } - mflag = 1; - argv_mrate[0] = - (char *)malloc(sizeof(char) * - (strlen(argv[j]) + 1)); - memset(argv_mrate[0], 0, - sizeof(char) * (strlen(argv[j]) + 1)); - strncpy(argv_mrate[0], argv[output[1][0] + 1], - strlen(argv[j])); - } - if (!rflag && !mflag) { - printf("ERR: Invalid input\n"); - print_sys_cfg_rates_ext_usage(); - ret = UAP_FAILURE; - goto done; - } - - if (rflag && - is_input_valid(RATE, argc_rate, argv_rate) != UAP_SUCCESS) { - printf("ERR: Invalid RATE\n"); - print_sys_cfg_rates_ext_usage(); - ret = UAP_FAILURE; - goto done; - } - - if (mflag && - is_input_valid(MCBCDATARATE, 1, - argv_mrate) != UAP_SUCCESS) { - printf("ERR: Invalid MCBC RATE\n"); - print_sys_cfg_rates_ext_usage(); - ret = UAP_FAILURE; - goto done; - } - - if (!rflag && mflag) { - /* - * Check mrate wrt old Rates - */ - if (mflag && A2HEXDECIMAL(argv_mrate[0]) && - is_mcbc_rate_valid(A2HEXDECIMAL(argv_mrate[0])) != - UAP_SUCCESS) { - printf("ERR: invalid MCBC data rate."); - print_sys_cfg_rates_ext_usage(); - ret = UAP_FAILURE; - goto done; - } - } else if (rflag && mflag) { - /* - * Check mrate wrt new Rates - */ - for (i = 0; i < argc_rate; i++) { - /* - * MCBC rate must be from Basic rates - */ - if (mflag && !mrate_found && - A2HEXDECIMAL(argv_rate[i]) & - BASIC_RATE_SET_BIT) { - if (A2HEXDECIMAL(argv_mrate[0]) == - (A2HEXDECIMAL(argv_rate[i]) & - ~BASIC_RATE_SET_BIT)) { - mrate_found = UAP_SUCCESS; - } - } - } - - if (mflag && A2HEXDECIMAL(argv_mrate[0]) && - !(mrate_found == UAP_SUCCESS)) { - printf("ERR: mrate not valid\n"); - ret = UAP_FAILURE; - goto done; - } - } - /* Post-parsing */ - cmd_len = sizeof(apcmdbuf_sys_configure); - if (rflag) - cmd_len += sizeof(tlvbuf_rates) + argc_rate; - if (mflag) - cmd_len += sizeof(tlvbuf_mcbc_data_rate); - } else { - /* GET */ - cmd_len = sizeof(apcmdbuf_sys_configure) - + sizeof(tlvbuf_rates) + MAX_RATES + - sizeof(tlvbuf_mcbc_data_rate); - } - - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Fill the command buffer */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = argc ? ACTION_SET : ACTION_GET; - tlv_buf = buffer + sizeof(apcmdbuf_sys_configure); - /* Locate headers */ - if (rflag || (!argc)) { - tlv_rate = - (tlvbuf_rates *)(buffer + - sizeof(apcmdbuf_sys_configure)); - tlv_rate->tag = MRVL_RATES_TLV_ID; - tlv_rate->length = argc ? argc_rate : MAX_RATES; - for (i = 0; i < argc_rate; i++) { - tlv_rate->operational_rates[i] = - (t_u8)A2HEXDECIMAL(argv_rate[i]); - } - tlv_buf += tlv_rate->length + sizeof(tlvbuf_rates); - endian_convert_tlv_header_out(tlv_rate); - } - if (mflag || (!argc)) { - tlv_mrate = (tlvbuf_mcbc_data_rate *)tlv_buf; - tlv_mrate->tag = MRVL_MCBC_DATA_RATE_TLV_ID; - tlv_mrate->length = 2; - tlv_mrate->mcbc_datarate = 0; - if (mflag) { - tlv_mrate->mcbc_datarate = - (t_u16)A2HEXDECIMAL(argv_mrate[0]) - & ~BASIC_RATE_SET_BIT; - tlv_mrate->mcbc_datarate = - uap_cpu_to_le16(tlv_mrate->mcbc_datarate); - } - tlv_buf += sizeof(tlvbuf_mcbc_data_rate); - endian_convert_tlv_header_out(tlv_mrate); - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - tlv_buf = buffer + sizeof(apcmdbuf_sys_configure); - - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x\n", - cmd_buf->cmd_code); - ret = UAP_FAILURE; - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc) { - printf("Rates setting successful\n"); - } else { - print_tlv((t_u8 *)tlv_buf, - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - } - } else { - printf("ERR:Could not %s operational rates!\n", - argc ? "set" : "get"); - if (argc) - printf("operational rates only allow to set before bss start.\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (rflag) { - for (i = 0; i < argc_rate; i++) { - free(argv_rate[i]); - } - } - if (mflag) - free(argv_mrate[0]); - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for data rates - * and sends to the driver - * - * Usage: "sys_cfg_rates [RATES]" - * - * RATES is provided as a set of data rates, in - * unit of 500 kilobits/s. - * Maximum 12 rates can be provided. - * - * if no RATE is provided, then it gets configured rates - * - * Each rate must be separated by a space - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_rates(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_rates *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int i = 0; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_rates_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && is_input_valid(RATE, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_rates_usage(); - return UAP_FAILURE; - } - if (argc == 0) { - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_rates) + - MAX_RATES; - } else { - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_rates) + - argc; - } - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rates *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_RATES_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->length = MAX_RATES; - } else { - cmd_buf->action = ACTION_SET; - tlv->length = argc; - for (i = 0; i < tlv->length; i++) { - tlv->operational_rates[i] = (t_u8)A2HEXDECIMAL(argv[i]); - } - } - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (uap_le16_to_cpu(tlv->tag) != MRVL_RATES_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, uap_le16_to_cpu(tlv->tag)); - free(buffer); - return UAP_FAILURE; - } - - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - print_rate(tlv); - } else { - printf("Rates setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get operational rates!\n"); - } else { - printf("ERR:Could not set operational rates!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Checks if tx power is valid for given 11d domain. - * - * @param tx_pwr tx power - * @return UAP_FAILURE/UAP_SUCCESS - */ -int -check_tx_pwr_validity_11d(t_u8 tx_pwr) -{ - apcmdbuf_sys_configure *cmd_buf1 = NULL; - apcmdbuf_cfg_80211d *cmd_buf2 = NULL; - tlvbuf_channel_config *tlv = NULL; - ieeetypes_subband_set_t sub_bands[MAX_SUB_BANDS]; - t_u8 *buf = NULL; - t_u16 cmd_len; - t_u16 buf_len = 0; - int ret = UAP_FAILURE; - int i, found = 0, band = BAND_B | BAND_G; - t_u8 no_of_sub_band = 0, channel = 0; - char country[4] = { ' ', ' ', 0, 0 }; - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_channel_config); - - /* Initialize the command buffer */ - buf = (t_u8 *)malloc(cmd_len); - - if (!buf) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, cmd_len); - - /* Locate headers */ - cmd_buf1 = (apcmdbuf_sys_configure *)buf; - tlv = (tlvbuf_channel_config *)(buf + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf1->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf1->size = cmd_len; - cmd_buf1->seq_num = 0; - cmd_buf1->result = 0; - tlv->tag = MRVL_CHANNELCONFIG_TLV_ID; - tlv->length = sizeof(tlvbuf_channel_config) - TLVHEADER_LEN; - cmd_buf1->action = ACTION_GET; - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf1, &cmd_len, cmd_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf1->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CHANNELCONFIG_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf1->cmd_code, tlv->tag); - free(buf); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf1->result == CMD_SUCCESS) { - channel = tlv->chan_number; - printf("channel=%d\n", channel); - } else { - printf("ERR:Could not get channel!\n"); - free(buf); - return UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - /* free current buffer */ - free(buf); - if (channel > MAX_CHANNELS_BG) - band = BAND_A; - /* initialize second command length and buffer */ - buf_len = sizeof(apcmdbuf_cfg_80211d); - buf_len += MAX_SUB_BANDS * sizeof(ieeetypes_subband_set_t); - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - /* Locate headers */ - cmd_buf2 = (apcmdbuf_cfg_80211d *)buf; - cmd_len = (sizeof(apcmdbuf_cfg_80211d) - sizeof(domain_param_t)); - - cmd_buf2->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf2->result = 0; - cmd_buf2->seq_num = 0; - cmd_buf2->action = ACTION_GET; - cmd_buf2->action = uap_cpu_to_le16(cmd_buf2->action); - cmd_buf2->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - - ret = uap_ioctl((t_u8 *)cmd_buf2, &cmd_len, buf_len); - - if (ret == UAP_SUCCESS) { - if (cmd_buf2->result == CMD_SUCCESS) { - if (cmd_buf2->domain.country_code[0] || - cmd_buf2->domain.country_code[1] || - cmd_buf2->domain.country_code[2]) { - country[0] = cmd_buf2->domain.country_code[0]; - country[1] = cmd_buf2->domain.country_code[1]; - if (cmd_buf2->domain.country_code[2] == 'I') { - if (tx_pwr > MAX_TX_PWR_INDOOR) { - printf("Transmit power invalid for indoor operation!\n"); - ret = UAP_FAILURE; - goto done; - } - } - no_of_sub_band = - parse_domain_file(country, band, - sub_bands, NULL); - if (no_of_sub_band == UAP_FAILURE) { - printf("Parsing of domain configuration file failed\n"); - ret = UAP_FAILURE; - goto done; - } - - for (i = 0; i < no_of_sub_band; i++) { - if (tx_pwr <= (sub_bands[i].max_tx_pwr)) { - found = 1; - break; - } - } - - if (!found) { - printf("ERR:Invalid transmit power for given domain!\n"); - ret = UAP_FAILURE; - goto done; - } - } - } else { - printf("ERR:Command Response incorrect!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buf) - free(buf); - return ret; -} - -/** - * @brief Creates a sys_cfg request for Tx power - * and sends to the driver - * - * Usage: "sys_cfg_tx_power [TX_POWER]" - * if TX_POWER is provided, a 'set' is performed - * else a 'get' is performed. - * - * TX_POWER is represented in dBm - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_tx_power(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_tx_power *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - t_u8 state = 0; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_tx_power_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && is_input_valid(TXPOWER, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_tx_power_usage(); - return UAP_FAILURE; - } - /* Check if tx power is valid for given domain. */ - if (argc) { - ret = sg_snmp_mib(ACTION_GET, OID_80211D_ENABLE, sizeof(state), - &state); - if (state) { - ret = check_tx_pwr_validity_11d(atoi(argv[0])); - if (ret == UAP_FAILURE) { - print_sys_cfg_tx_power_usage(); - return UAP_FAILURE; - } - } - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_tx_power); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_tx_power *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_TX_POWER_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - printf("Please check power calibration for board to see if this power\n" "setting is within calibrated range. Firmware may over-ride\n " "this setting if it is not within calibrated range, which can\n" "vary from board to board.\n"); - cmd_buf->action = ACTION_SET; - tlv->tx_power_dbm = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_TX_POWER_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Tx power = %d dBm\n", - tlv->tx_power_dbm); - } else { - printf("Tx power setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get tx power!\n"); - } else { - printf("ERR:Could not set tx power!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for SSID broadcast - * and sends to the driver - * - * Usage: "sys_cfg_bcast_ssid_ctl [0|1]" - * - * Options: 0 - Disable SSID broadcast - * 1 - Enable SSID broadcast - * empty - Get current SSID broadcast setting - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_bcast_ssid_ctl(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_bcast_ssid_ctl *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_bcast_ssid_ctl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && is_input_valid(BROADCASTSSID, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_bcast_ssid_ctl_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_bcast_ssid_ctl); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_bcast_ssid_ctl *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_BCAST_SSID_CTL_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->bcast_ssid_ctl = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_BCAST_SSID_CTL_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("SSID broadcast is %s\n", - (tlv->bcast_ssid_ctl == - 1) ? "enabled" : "disabled"); - } else { - printf("SSID broadcast setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get SSID broadcast!\n"); - } else { - printf("ERR:Could not set SSID broadcast!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for preamble settings - * and sends to the driver - * - * Usage: "sys_cfg_preamble_ctl" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_preamble_ctl(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_preamble_ctl *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_preamble_ctl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && (is_input_valid(PREAMBLETYPE, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_preamble_ctl_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_preamble_ctl); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_preamble_ctl *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_PREAMBLE_CTL_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->preamble_type = (t_u16)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_PREAMBLE_CTL_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Preamble type is %s\n", - (tlv->preamble_type == - 0) ? "auto" : ((tlv->preamble_type == - 1) ? "short" : "long")); - } else { - printf("Preamble type setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get preamble type!\n"); - } else { - printf("ERR:Could not set preamble type!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for RTS threshold - * and sends to the driver - * - * Usage: "sys_cfg_rts_threshold [RTS_THRESHOLD]" - * if RTS_THRESHOLD is provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_rts_threshold(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_rts_threshold *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_rts_threshold_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(RTSTHRESH, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_rts_threshold_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_rts_threshold); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rts_threshold *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_RTS_THRESHOLD_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->rts_threshold = (t_u16)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->rts_threshold = uap_cpu_to_le16(tlv->rts_threshold); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->rts_threshold = uap_le16_to_cpu(tlv->rts_threshold); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_RTS_THRESHOLD_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("RTS threshold = %d\n", - tlv->rts_threshold); - } else { - printf("RTS threshold setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get RTS threshold!\n"); - } else { - printf("ERR:Could not set RTS threshold!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for Fragmentation threshold - * and sends to the driver - * - * Usage: "sys_cfg_frag_threshold [FRAG_THRESHOLD]" - * if FRAG_THRESHOLD is provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_frag_threshold(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_frag_threshold *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_frag_threshold_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(FRAGTHRESH, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_frag_threshold_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_frag_threshold); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_frag_threshold *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_FRAG_THRESHOLD_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->frag_threshold = (t_u16)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->frag_threshold = uap_cpu_to_le16(tlv->frag_threshold); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->frag_threshold = uap_le16_to_cpu(tlv->frag_threshold); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_FRAG_THRESHOLD_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Fragmentation threshold = %d\n", - tlv->frag_threshold); - } else { - printf("Fragmentation threshold setting successful\n"); - } - } else { - if (argc == 1) { - printf("ERR:Could not set Fragmentation threshold!\n"); - } else { - printf("ERR:Could not get Fragmentation threshold!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for RSN replay protection - * and sends to the driver - * - * Usage: "sys_cfg_rsn_replay_prot [0|1]" - * - * Options: 0 - Disable RSN replay protection - * 1 - Enable RSN replay protection - * empty - Get current RSN replay protection setting - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_rsn_replay_prot(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_rsn_replay_prot *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_rsn_replay_prot_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && is_input_valid(RSNREPLAYPROT, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_rsn_replay_prot_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_rsn_replay_prot); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rsn_replay_prot *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_RSN_REPLAY_PROT_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->rsn_replay_prot = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_RSN_REPLAY_PROT_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->Tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("RSN replay protection is %s\n", - (tlv->rsn_replay_prot == - 1) ? "enabled" : "disabled"); - } else { - printf("RSN replay protection setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get RSN replay protection !\n"); - } else { - printf("ERR:Could not set RSN replay protection !\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for MCBC data rates - * and sends to the driver - * - * Usage: "sys_cfg_mcbc_data_rate [MCBC_DATA_RATE]" - * - * Options: 0 - Auto rate - * >0 - Set specified MCBC data rate - * empty - Get current MCBC data rate - * - * MCBC_DATA_RATE is represented in units of 500 kbps - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_mcbc_data_rate(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_mcbc_data_rate *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_mcbc_data_rates_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc) { - if (is_input_valid(MCBCDATARATE, argc, argv) != UAP_SUCCESS) { - printf("ERR: Invalid input\n"); - print_sys_cfg_mcbc_data_rates_usage(); - return UAP_FAILURE; - } - if ((A2HEXDECIMAL(argv[0]) != 0) && - (is_mcbc_rate_valid(A2HEXDECIMAL(argv[0])) != - UAP_SUCCESS)) { - printf("ERR: invalid MCBC data rate."); - print_sys_cfg_mcbc_data_rates_usage(); - return UAP_FAILURE; - } - } - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_mcbc_data_rate); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_mcbc_data_rate *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_MCBC_DATA_RATE_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->mcbc_datarate = (t_u16)A2HEXDECIMAL(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->mcbc_datarate = uap_cpu_to_le16(tlv->mcbc_datarate); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->mcbc_datarate = uap_le16_to_cpu(tlv->mcbc_datarate); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_MCBC_DATA_RATE_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - if (tlv->mcbc_datarate == 0) { - printf("MCBC data rate is auto\n"); - } else { - printf("MCBC data rate = 0x%x\n", - tlv->mcbc_datarate); - } - } else { - printf("MCBC data rate setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get MCBC data rate!\n"); - } else { - printf("ERR:Could not set MCBC data rate!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for Tx beacon rates - * and sends to the driver - * - * Usage: "sys_cfg_tx_beacon_rate [TX_BEACON_RATE]" - * - * Options: 0 - Auto rate - * >0 - Set specified data rate - * empty - Get current data rate - * - * TX_BEACON_RATE is represented in units of 500 kbps - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_tx_beacon_rate(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_tx_data_rate *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_tx_beacon_rates_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc) { - if (is_input_valid(TXBEACONRATE, argc, argv) != UAP_SUCCESS) { - printf("ERR: Invalid input\n"); - return UAP_FAILURE; - } else if ((A2HEXDECIMAL(argv[0]) != 0) && - (is_tx_rate_valid(A2HEXDECIMAL(argv[0])) != - UAP_SUCCESS)) { - printf("ERR: invalid tx beacon rate."); - return UAP_FAILURE; - } - } - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_tx_data_rate); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_tx_data_rate *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_TX_BEACON_RATE_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->tx_data_rate = (t_u16)A2HEXDECIMAL(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->tx_data_rate = uap_cpu_to_le16(tlv->tx_data_rate); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->tx_data_rate = uap_le16_to_cpu(tlv->tx_data_rate); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_TX_BEACON_RATE_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - if (tlv->tx_data_rate == 0) { - printf("Tx beacon rate is auto\n"); - } else { - printf("Tx beacon rate = 0x%x\n", - tlv->tx_data_rate); - } - } else { - printf("Tx beacon rate setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get tx beacon rate!\n"); - } else { - printf("ERR:Could not set tx beacon rate!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for packet forwarding - * and sends to the driver - * - * Usage: "sys_cfg_pkt_fwd_ctl [PKT_FWD_CTRL]" - * - * PKT_FWD_CTRL: bit 0 -- Packet forwarding handled by Host (0) or Firmware (1) - * bit 1 -- Intra-BSS broadcast packets are allowed (0) or denied (1) - * bit 2 -- Intra-BSS unicast packets are allowed (0) or denied (1) - * bit 3 -- Inter-BSS unicast packets are allowed (0) or denied (1) - * empty - Get current packet forwarding setting - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_pkt_fwd_ctl(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_pkt_fwd_ctl *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_pkt_fwd_ctl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(PKTFWD, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_pkt_fwd_ctl_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_pkt_fwd_ctl); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_pkt_fwd_ctl *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_PKT_FWD_CTL_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->pkt_fwd_ctl = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_PKT_FWD_CTL_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("%s handles packet forwarding -\n", - ((tlv->pkt_fwd_ctl & PKT_FWD_FW_BIT) == - 0) ? "Host" : "Firmware"); - printf("\tIntra-BSS broadcast packets are %s\n", - ((tlv-> - pkt_fwd_ctl & PKT_FWD_INTRA_BCAST) == - 0) ? "allowed" : "denied"); - printf("\tIntra-BSS unicast packets are %s\n", - ((tlv-> - pkt_fwd_ctl & PKT_FWD_INTRA_UCAST) == - 0) ? "allowed" : "denied"); - printf("\tInter-BSS unicast packets are %s\n", - ((tlv-> - pkt_fwd_ctl & PKT_FWD_INTER_UCAST) == - 0) ? "allowed" : "denied"); - } else { - printf("Packet control logic setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get packet control logic!\n"); - } else { - printf("ERR:Could not set packet control logic!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for STA ageout timer - * and sends to the driver - * - * Usage: "sys_cfg_sta_ageout_timer [STA_AGEOUT_TIMER]" - * if STA_AGEOUT_TIMER is provided, a 'set' is performed - * else a 'get' is performed. - * The value should between 100 and 864000 - * - * STA_AGEOUT_TIMER is represented in units of 100 ms - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_sta_ageout_timer(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_sta_ageout_timer *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_sta_ageout_timer_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(STAAGEOUTTIMER, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_sta_ageout_timer_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sta_ageout_timer); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_sta_ageout_timer *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_STA_AGEOUT_TIMER_TLV_ID; - tlv->length = 4; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->sta_ageout_timer_ms = (t_u32)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->sta_ageout_timer_ms = uap_cpu_to_le32(tlv->sta_ageout_timer_ms); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->sta_ageout_timer_ms = uap_le32_to_cpu(tlv->sta_ageout_timer_ms); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_STA_AGEOUT_TIMER_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("STA ageout timer value = %d\n", - (int)tlv->sta_ageout_timer_ms); - } else { - printf("STA ageout timer setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get STA ageout timer!\n"); - } else { - printf("ERR:Could not set STA ageout timer!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for PS STA ageout timer - * and sends to the driver - * - * Usage: "sys_cfg_ps_sta_ageout_timer [PS_STA_AGEOUT_TIMER]" - * if PS_STA_AGEOUT_TIMER is provided, a 'set' is performed - * else a 'get' is performed. - * The value should between 100 and 864000 - * - * PS_STA_AGEOUT_TIMER is represented in units of 100 ms - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_ps_sta_ageout_timer(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_ps_sta_ageout_timer *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_ps_sta_ageout_timer_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && - (is_input_valid(PSSTAAGEOUTTIMER, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_ps_sta_ageout_timer_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_ps_sta_ageout_timer); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_ps_sta_ageout_timer *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_PS_STA_AGEOUT_TIMER_TLV_ID; - tlv->length = 4; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->ps_sta_ageout_timer_ms = (t_u32)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->ps_sta_ageout_timer_ms = - uap_cpu_to_le32(tlv->ps_sta_ageout_timer_ms); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->ps_sta_ageout_timer_ms = - uap_le32_to_cpu(tlv->ps_sta_ageout_timer_ms); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_PS_STA_AGEOUT_TIMER_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("PS STA ageout timer value = %d\n", - (int)tlv->ps_sta_ageout_timer_ms); - } else { - printf("PS STA ageout timer setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get PS STA ageout timer!\n"); - } else { - printf("ERR:Could not set PS STA ageout timer!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for authentication mode - * and sends to the driver - * - * Usage: "Usage : sys_cfg_auth [AUTHMODE]" - * - * Options: AUTHMODE : 0 - Open authentication - * 1 - Shared key authentication - * empty - Get current authentication mode - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_auth(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_auth_mode *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_auth_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(AUTHMODE, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_auth_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_auth_mode); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_auth_mode *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_AUTH_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->auth_mode = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_AUTH_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - print_auth(tlv); - } else { - printf("authentication mode setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get authentication mode!\n"); - } else { - printf("ERR:Could not set authentication mode!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for encryption protocol - * and sends to the driver - * - * Usage: "Usage : sys_cfg_protocol [PROTOCOL]" - * - * Options: PROTOCOL Bit 0 - No RSN - * Bit 1 - WEP Static - * Bit 3 - WPA - * Bit 3 - WPA2 - * empty - Get current protocol - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_protocol(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_protocol *tlv = NULL; - tlvbuf_akmp *akmp_tlv = NULL; - t_u8 *buffer = NULL; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - t_u16 cmd_len = 0; - int ret = UAP_SUCCESS; - int opt; - int get_akm_val = 0; - int resend = 0; - t_u16 tlv_val_16 = 0; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_protocol_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && (is_input_valid(PROTOCOL, argc, argv) != UAP_SUCCESS || - is_input_valid(AKM_SUITE, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_protocol_usage(); - return UAP_FAILURE; - } - - if ((argc == 1) && - ((atoi(argv[0]) == PROTOCOL_WPA) || - (atoi(argv[0]) == PROTOCOL_WPA2) || - (atoi(argv[0]) == PROTOCOL_WPA2_MIXED) - || (atoi(argv[0]) == PROTOCOL_WPA3_SAE) - )) { - get_akm_val = 1; - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - - /* case such as ./uaputl.exe sys_cfg_protocol 8/32/40 */ - /* Don't assume PSK in such cases, query FW and then set */ - do { - memset(buffer, 0, buf_len); - - /* Initialize the command length */ - if ((argc == 1) && - ((atoi(argv[0]) == PROTOCOL_NO_SECURITY) || - (atoi(argv[0]) == PROTOCOL_STATIC_WEP))) { - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_protocol); - } else { - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_protocol) + sizeof(tlvbuf_akmp); - } - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_protocol *)(buffer + - sizeof(apcmdbuf_sys_configure)); - akmp_tlv = - (tlvbuf_akmp *)(buffer + - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_protocol)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_PROTOCOL_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - akmp_tlv->tag = MRVL_AKMP_TLV_ID; - akmp_tlv->length = 4; /* sizeof(tlvbuf_akmp) - TLVHEADER_LEN */ - } else { - cmd_buf->action = ACTION_SET; - tlv->protocol = (t_u16)atoi(argv[0]); - printf("protocol: 0x%x\n", tlv->protocol); - if (tlv->protocol & (PROTOCOL_WPA | PROTOCOL_WPA2 - | PROTOCOL_WPA3_SAE)) { - akmp_tlv->tag = MRVL_AKMP_TLV_ID; - akmp_tlv->length = 4; /* sizeof(tlvbuf_akmp) - TLVHEADER_LEN */ - if (argc == 2) { - akmp_tlv->key_mgmt = - (t_u16)A2HEXDECIMAL(argv[1]); - } else { - akmp_tlv->key_mgmt = tlv_val_16; // AKM SUITE from FW in 2nd iteration - if (get_akm_val) { - /* Get AKM SUITE val from FW */ - cmd_buf->action = ACTION_GET; - resend = 1; - } else - resend = 0; - } - printf("KeyMgmt: 0x%x\n", akmp_tlv->key_mgmt); - akmp_tlv->key_mgmt = - uap_cpu_to_le16(akmp_tlv->key_mgmt); - } - } - endian_convert_tlv_header_out(tlv); - if (cmd_len == - (sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_protocol) + - sizeof(tlvbuf_akmp))) { - endian_convert_tlv_header_out(akmp_tlv); - } - tlv->protocol = uap_cpu_to_le16(tlv->protocol); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, uap_le16_to_cpu(tlv->tag)); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - print_tlv((t_u8 *)tlv, - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) - + BUF_HEADER_SIZE); - } else { - if (get_akm_val) { - get_akm_val = 0; - /* AKM Suite value from FW */ - tlv_val_16 = - *(t_u8 *)&akmp_tlv-> - key_mgmt; - tlv_val_16 |= - (* - ((t_u8 *)&akmp_tlv-> - key_mgmt + 1) << 8); - } else - printf("protocol setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get protocol!\n"); - } else { - printf("ERR:Could not set protocol!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - } while (resend && (ret == UAP_SUCCESS)); - - if (buffer) - free(buffer); - - return ret; -} - -/** - * @brief Creates a sys_cfg request for WEP keys settings - * and sends to the driver - * - * Usage: "sys_cfg_wep_key [INDEX_0 IS_DEFAULT KEY_0] [INDEX_1 IS_DEFAULT KEY_1] [INDEX_2 IS_DEFAULT KEY_2] [INDEX_3 IS_DEFAULT KEY_3]" - * - * Options: INDEX_* : 0 - KeyIndex is 0 - * 1 - KeyIndex is 1 - * 2 - KeyIndex is 2 - * 3 - KeyIndex is 3 - * IS_DEFAUL : 0 - KeyIndex is not the default - * 1 - KeyIndex is the default transmit key - * KEY_* : Key value - * empty - Get current WEP key settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_wep_key(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_wep_key *tlv = NULL; - t_u8 *buffer = NULL; - t_u8 *tmp_buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int key_len = -1; - int length = 0; - int number_of_keys = 0; - int i = 0; - int keyindex = -1; - int is_default = -1; - char *key = NULL; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_wep_key_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 12) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } else if ((argc > 1) && ((argc % 3) != 0)) { - printf("ERR:Illegal number of parameters.\n"); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } else if (argc > 1) { - - /* Find number of keys provided */ - number_of_keys = argc / 3; - for (i = 0; i < number_of_keys; i++) { - if ((ISDIGIT(argv[(3 * i)]) == 0) || - (atoi(argv[(3 * i)]) < 0) || - (atoi(argv[(3 * i)]) > 3)) { - printf("ERR:Illegal INDEX %s. Must be either '0', '1', '2', or '3'.\n", argv[(3 * i)]); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } - if ((ISDIGIT(argv[(3 * i) + 1]) == 0) || - (atoi(argv[(3 * i) + 1]) < 0) || - (atoi(argv[(3 * i) + 1]) > 1)) { - printf("ERR:Illegal IS_DEFAULT %s. Must be either '0', or '1'.\n", argv[(3 * i) + 1]); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } - if ((strlen(argv[(3 * i) + 2]) != 5) && - (strlen(argv[(3 * i) + 2]) != 10) - && (strlen(argv[(3 * i) + 2]) != 13) && - (strlen(argv[(3 * i) + 2]) != 26)) { - printf("ERR:Incorrect KEY_%d length %d\n", - atoi(argv[(3 * i)]), - (t_u32)strlen(argv[(3 * i) + 2])); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } - if ((strlen(argv[(3 * i) + 2]) == 10) || - (strlen(argv[(3 * i) + 2]) == 26)) { - if (UAP_FAILURE == - ishexstring(argv[(3 * i) + 2])) { - printf("ERR:Only hex digits are allowed when key length is 10 or 26\n"); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } - } - } - } else if (argc == 1) { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 3)) { - printf("ERR:Illegal INDEX %s. Must be either '0', '1', '2', or '3'.\n", argv[0]); - print_sys_cfg_wep_key_usage(); - return UAP_FAILURE; - } - } - - /* Initialize the command length */ - if (argc == 0 || argc == 1) { - if (argc == 0) - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_header); - else - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_wep_key) - 1; - } else { - cmd_len = sizeof(apcmdbuf_sys_configure); - } - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - if (argc == 0 || argc == 1) { - cmd_buf->action = ACTION_GET; - tlv = (tlvbuf_wep_key *)(buffer + - sizeof(apcmdbuf_sys_configure)); - tlv->tag = MRVL_WEP_KEY_TLV_ID; - if (argc == 0) - tlv->length = 0; - else { - tlv->length = 1; - tlv->key_index = atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - } else { - cmd_buf->action = ACTION_SET; - } - /* Add key TLVs */ - for (i = 0; i < number_of_keys; i++) { - keyindex = atoi(argv[(3 * i)]); - is_default = atoi(argv[(3 * i) + 1]); - key = argv[(3 * i) + 2]; - length = strlen(key); - switch (length) { - case 5: - case 10: - key_len = 5; - break; - case 13: - case 26: - key_len = 13; - break; - default: - key_len = 0; - break; - } - /* Adjust command buffer */ - tmp_buffer = - realloc(buffer, - (cmd_len + sizeof(tlvbuf_wep_key) + key_len)); - if (!tmp_buffer) { - printf("ERR:Cannot append WEP key configurations TLV!\n"); - free(buffer); - return UAP_FAILURE; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wep_key *)(buffer + cmd_len); - /* Adjust command length */ - cmd_len += (sizeof(tlvbuf_wep_key) + key_len); - /* Set TLV fields */ - tlv->tag = MRVL_WEP_KEY_TLV_ID; - tlv->length = 2 + key_len; - tlv->key_index = (t_u8)keyindex; - tlv->is_default = (t_u8)is_default; - /* Check if string or raw */ - switch (length) { - case 5: - case 13: - memcpy(tlv->key, key, length); - break; - case 10: - case 26: - string2raw(key, tlv->key); - break; - default: - break; - } - endian_convert_tlv_header_out(tlv); - } - - /* Update command length */ - cmd_buf->size = cmd_len; - if ((argc != 0) && (argc != 1)) - buf_len = cmd_len; - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if ((argc != 0) && (argc != 1)) { - printf("WEP key setting successful\n"); - } else { - printf("query WEP key setting successful\n"); - tlv = (tlvbuf_wep_key *)(buffer + - sizeof - (apcmdbuf_sys_configure)); - print_tlv((t_u8 *)tlv, - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - } - } else { - if ((argc != 0) && (argc != 1)) - printf("ERR:Could not set WEP keys!\n"); - else - printf("ERR:Could not get WEP keys!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for cipher configurations - * and sends to the driver - * - * Usage: "sys_cfg_cipher [PAIRWISE_CIPHER GROUP_CIPHER]" - * - * Options: PAIRWISE_CIPHER : Bit 2 - TKIP - * Bit 3 - AES CCMP - * GROUP_CIPHER : Bit 2 - TKIP - * Bit 3 - AES CCMP - * empty - Get current cipher settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_cipher(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_cipher *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_cipher_usage(); - return UAP_FAILURE; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc != 0) && (argc != 2)) { - printf("ERR:wrong arguments.\n"); - print_sys_cfg_cipher_usage(); - return UAP_FAILURE; - } - if (argc == 2) { - if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0)) { - print_sys_cfg_cipher_usage(); - return UAP_FAILURE; - } - if (atoi(argv[0]) & ~CIPHER_BITMAP) { - printf("ERR:Illegal PAIRWISE_CIPHER parameter %s.\n", - argv[0]); - print_sys_cfg_cipher_usage(); - return UAP_FAILURE; - } - if (atoi(argv[1]) & ~CIPHER_BITMAP) { - printf("ERR:Illegal GROUP_CIPHER parameter %s.\n", - argv[1]); - print_sys_cfg_cipher_usage(); - return UAP_FAILURE; - } - if (is_cipher_valid(atoi(argv[0]), atoi(argv[1])) != - UAP_SUCCESS) { - printf("ERR:Wrong group and pairwise cipher combination!\n"); - print_sys_cfg_cipher_usage(); - return UAP_FAILURE; - } - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_cipher); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_cipher *)(buffer + sizeof(apcmdbuf_sys_configure)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CIPHER_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->pairwise_cipher = (t_u8)atoi(argv[0]); - tlv->group_cipher = (t_u8)atoi(argv[1]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CIPHER_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - print_cipher(tlv); - } else { - printf("cipher setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get cipher parameters!\n"); - } else { - printf("ERR:Could not set cipher parameters!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for pairwise cipher configurations - * and sends to the driver - * - * Usage: "sys_cfg_pwk_cipher [] [PAIRWISE_CIPHER]" - * - * Options: PROTOCOL : Bit 3 - WPA - * Bit 5 - WPA2 - * PAIRWISE_CIPHER : Bit 2 - TKIP - * Bit 3 - AES CCMP - * empty - Get current pairwise cipher settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_pwk_cipher(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_pwk_cipher *tlv = NULL; - HTCap_t htcap; - t_u16 proto = 0; - t_u8 *buffer = NULL; - t_u16 tlv_get_len = 0, protocol = 0, cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_pwk_cipher_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc) { - if (is_input_valid(PWK_CIPHER, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_pwk_cipher_usage(); - return UAP_FAILURE; - } - if ((argc == 2) && (atoi(argv[1]) == CIPHER_TKIP)) { - if (UAP_SUCCESS == get_sys_cfg_protocol(&proto)) { - /* Ok to have TKIP in mixed mode */ - if (proto != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == - get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0]) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - print_sys_cfg_pwk_cipher_usage - (); - return UAP_FAILURE; - } - } - } - } - } - } - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_pwk_cipher); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_pwk_cipher *)(buffer + sizeof(apcmdbuf_sys_configure)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CIPHER_PWK_TLV_ID; - if (argc < 2) { - cmd_buf->action = ACTION_GET; - tlv->length = 0; - /* Adjust cmd_len for 0 payload */ - cmd_len = cmd_len - (sizeof(tlvbuf_pwk_cipher) - TLVHEADER_LEN); - if (argc == 1) - protocol = atoi(argv[0]); - } else { - cmd_buf->action = ACTION_SET; - tlv->length = sizeof(tlvbuf_pwk_cipher) - TLVHEADER_LEN; - tlv->protocol = (t_u16)atoi(argv[0]); - tlv->pairwise_cipher = (t_u8)atoi(argv[1]); - } - endian_convert_tlv_header_out(tlv); - tlv->protocol = uap_cpu_to_le16(tlv->protocol); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CIPHER_PWK_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc < 2) { - tlv_get_len = - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE; - if ((!tlv_get_len) || - (tlv_get_len % sizeof(tlvbuf_pwk_cipher)) || - (tlv_get_len > - (3 * sizeof(tlvbuf_pwk_cipher)))) { - printf("ERR:Corrupted response!\n"); - free(buffer); - return UAP_FAILURE; - } - if (!proto) - get_sys_cfg_protocol(&proto); - if (proto & PROTOCOL_WPA || - proto & PROTOCOL_WPA2) - printf("Active Protocol = %s\n", - (proto == PROTOCOL_WPA) - ? "WPA" : (proto == - PROTOCOL_WPA2) ? - "WPA2" : "WPA | WPA2"); - while (tlv_get_len > 0) { - endian_convert_tlv_header_in(tlv); - tlv->protocol = - uap_le16_to_cpu(tlv->protocol); - if ((argc == 1) && - (protocol != tlv->protocol)) { - tlv_get_len -= - sizeof - (tlvbuf_pwk_cipher); - tlv++; - continue; - } - print_pwk_cipher(tlv); - tlv_get_len -= - sizeof(tlvbuf_pwk_cipher); - tlv++; - } - } else { - printf("protocol and pairwise cipher setting successful\n"); - } - } else { - if (argc < 2) { - printf("ERR:Could not get pairwise cipher parameters!\n"); - } else { - printf("ERR:Could not set pairwise cipher parameters!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for group cipher configurations - * and sends to the driver - * - * Usage: "sys_cfg_gwk_cipher [GROUP_CIPHER]" - * - * Options: GROUP_CIPHER : Bit 2 - TKIP - * Bit 3 - AES CCMP - * empty - Get current group cipher settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_gwk_cipher(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_gwk_cipher *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_gwk_cipher_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc) { - if (is_input_valid(GWK_CIPHER, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_gwk_cipher_usage(); - return UAP_FAILURE; - } - } - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_gwk_cipher); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_gwk_cipher *)(buffer + sizeof(apcmdbuf_sys_configure)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CIPHER_GWK_TLV_ID; - tlv->length = 2; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->group_cipher = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CIPHER_GWK_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - print_gwk_cipher(tlv); - } else { - printf("group cipher setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get group cipher parameters!\n"); - } else { - printf("ERR:Could not set group cipher parameters!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for group re-key timer - * and sends to the driver - * - * Usage: "Usage : sys_cfg_group_rekey_timer [GROUP_REKEY_TIMER]" - * - * Options: GROUP_REKEY_TIME is represented in seconds - * Get current group re-key timer - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_group_rekey_timer(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_group_rekey_timer *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_group_rekey_timer_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc && - (is_input_valid(GROUPREKEYTIMER, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_group_rekey_timer_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_group_rekey_timer); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_group_rekey_timer *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_GRP_REKEY_TIME_TLV_ID; - tlv->length = 4; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->group_rekey_time_sec = (t_u32)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->group_rekey_time_sec = uap_cpu_to_le32(tlv->group_rekey_time_sec); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->group_rekey_time_sec = uap_le32_to_cpu(tlv->group_rekey_time_sec); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_GRP_REKEY_TIME_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - if (tlv->group_rekey_time_sec > 0) - printf("Group rekey time is %d s\n", - tlv->group_rekey_time_sec); - else - printf("Group rekey time is disabled\n"); - } else { - printf("group re-key time setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get group re-key time!\n"); - } else { - printf("ERR:Could not set group re-key time!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for WPA passphrase - * and sends to the driver - * - * Usage: "sys_cfg_wpa_passphrase [PASSPHRASE]" - * if PASSPHRASE is provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_wpa_passphrase(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_wpa_passphrase *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - - argc--; - argv++; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_wpa_passphrase_usage(); - return UAP_FAILURE; - } - if ((argc == 1) && (strlen(argv[0]) > MAX_WPA_PASSPHRASE_LENGTH)) { - printf("ERR:PASSPHRASE too long.\n"); - return UAP_FAILURE; - } - if ((argc == 1) && (strlen(argv[0]) < MIN_WPA_PASSPHRASE_LENGTH)) { - printf("ERR:PASSPHRASE too short.\n"); - return UAP_FAILURE; - } - if ((argc == 1) && (strlen(argv[0]) == MAX_WPA_PASSPHRASE_LENGTH)) { - if (UAP_FAILURE == ishexstring(argv[0])) { - printf("ERR:Only hex digits are allowed when passphrase's length is 64\n"); - return UAP_FAILURE; - } - } - /* Initialize the command length */ - if (argc == 0) - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_wpa_passphrase) + - MAX_WPA_PASSPHRASE_LENGTH; - else - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_wpa_passphrase) + strlen(argv[0]); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wpa_passphrase *)(buffer + - sizeof(apcmdbuf_sys_configure)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_WPA_PASSPHRASE_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->length = MAX_WPA_PASSPHRASE_LENGTH; - } else { - cmd_buf->action = ACTION_SET; - tlv->length = strlen(argv[0]); - memcpy(tlv->passphrase, argv[0], tlv->length); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_WPA_PASSPHRASE_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - if (tlv->length > 0) - printf("WPA passphrase = %s\n", - tlv->passphrase); - else - printf("WPA passphrase: None\n"); - } else { - printf("WPA passphrase setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get WPA passphrase!\n"); - } else { - printf("ERR:Could not set WPA passphrase!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for WPA3 SAE password - * and sends to the driver - * - * Usage: "sys_cfg_wpa3_sae_password [PASSWORD]" - * if PASSWORD is provided, a 'set' is performed - * else a 'get' is performed - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_wpa3_sae_password(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_wpa3_sae_password *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - - argc--; - argv++; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_wpa3_sae_password_usage(); - return UAP_FAILURE; - } - if ((argc == 1) && (strlen(argv[0]) > MAX_WPA3_SAE_PASSWORD_LENGTH)) { - printf("ERR:PASSWORD too long.\n"); - return UAP_FAILURE; - } - if ((argc == 1) && (strlen(argv[0]) < MIN_WPA3_SAE_PASSWORD_LENGTH)) { - printf("ERR:PASSWORD too short.\n"); - return UAP_FAILURE; - } - /* Initialize the command length */ - if (argc == 0) - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_wpa3_sae_password) + - MAX_WPA3_SAE_PASSWORD_LENGTH; - else - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_wpa3_sae_password) + strlen(argv[0]); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wpa3_sae_password *) (buffer + - sizeof(apcmdbuf_sys_configure)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_WPA3_SAE_PASSWORD_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->length = MAX_WPA3_SAE_PASSWORD_LENGTH; - } else { - cmd_buf->action = ACTION_SET; - tlv->length = strlen(argv[0]); - memcpy(tlv->password, argv[0], tlv->length); - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_WPA3_SAE_PASSWORD_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - if (tlv->length > 0) - printf("WPA3 SAE password = %s\n", - tlv->password); - else - printf("WPA3 SAE password: None\n"); - } else { - printf("WPA3 SAE password setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get WPA3 SAE password!\n"); - } else { - printf("ERR:Could not set WPA3 SAE password!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a STA filter request and sends to the driver - * - * Usage: "sta_filter_table " - * - * Options: FILTERMODE : 0 - Disable filter table - * 1 - Allow mac address specified in the allwed list - * 2 - Block MAC addresses specified in the banned list - * MACADDRESS_LIST is the list of MAC addresses to be acted upon. Each - * MAC address must be separated with a space. Maximum of - * 16 MAC addresses are supported. - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sta_filter_table(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_sta_mac_addr_filter *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int i = 0; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sta_filter_table_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc > (MAX_MAC_ONESHOT_FILTER + 1)) { - printf("ERR:Too many arguments.\n"); - print_sta_filter_table_usage(); - return UAP_FAILURE; - } - if (argc > 0) { - if ((ISDIGIT(argv[0]) == 0) || - ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 2))) { - printf("ERR:Illegal FILTERMODE parameter %s. Must be either '0', '1', or '2'.\n", argv[1]); - print_sta_filter_table_usage(); - return UAP_FAILURE; - } - } - /* Initialize the command length */ - if (argc == 0) { - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sta_mac_addr_filter) + - (MAX_MAC_ONESHOT_FILTER * ETH_ALEN); - } else { - if (argc == 1) { - cmd_len = sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sta_mac_addr_filter) + - (MAX_MAC_ONESHOT_FILTER * ETH_ALEN); - } else { - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sta_mac_addr_filter) + (argc - - 1) * - ETH_ALEN; - } - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_sta_mac_addr_filter *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_STA_MAC_ADDR_FILTER_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->count = MAX_MAC_ONESHOT_FILTER; - } else { - cmd_buf->action = ACTION_SET; - tlv->filter_mode = atoi(argv[0]); - tlv->count = argc - 1; - if (tlv->count) { - for (i = 0; i < tlv->count; i++) { - if ((ret = - mac2raw(argv[i + 1], - &tlv->mac_address[i * - ETH_ALEN])) != - UAP_SUCCESS) { - printf("ERR: %s Address\n", - ret == - UAP_FAILURE ? "Invalid MAC" : ret - == - UAP_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - print_sta_filter_table_usage(); - free(buffer); - return UAP_FAILURE; - } - } - } else { - memset(tlv->mac_address, 0, - MAX_MAC_ONESHOT_FILTER * ETH_ALEN); - } - } - if (tlv->count) { - tlv->length = tlv->count * ETH_ALEN + 2; - } else { - tlv->length = MAX_MAC_ONESHOT_FILTER * ETH_ALEN + 2; - } - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_STA_MAC_ADDR_FILTER_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - print_mac_filter(tlv); - } else { - printf("MAC address filter table setting successful!\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get MAC address filter table settings!\n"); - } else { - printf("ERR:Could not set MAC address filter table settings!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for max station number - * and sends to the driver - * - * Usage: "sys_cfg_max_sta_num [STA_NUM]" - * if STA_NUM is provided, a 'set' is performed - * else a 'get' is performed. - * - * STA_NUM should not bigger than 8 - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_max_sta_num(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_max_sta_num *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - t_u16 max_sta_num_supported = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_max_sta_num_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && (is_input_valid(MAXSTANUM, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_max_sta_num_usage(); - return UAP_FAILURE; - } - if (argc) { - if (get_max_sta_num_supported(&max_sta_num_supported) == - UAP_FAILURE) { - return UAP_FAILURE; - } - if (atoi(argv[0]) > max_sta_num_supported) { - printf("ERR: MAX_STA_NUM must be less than %d\n", - max_sta_num_supported); - print_sys_cfg_max_sta_num_usage(); - return UAP_FAILURE; - } - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_max_sta_num); - if (argc) { - cmd_len -= sizeof(tlv->max_sta_num_supported); - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_max_sta_num *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_MAX_STA_CNT_TLV_ID; - if (argc == 0) { - tlv->length = 4; - cmd_buf->action = ACTION_GET; - } else { - tlv->length = 2; - cmd_buf->action = ACTION_SET; - tlv->max_sta_num_configured = (t_u16)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - tlv->max_sta_num_configured = - uap_cpu_to_le16(tlv->max_sta_num_configured); - tlv->max_sta_num_supported = - uap_cpu_to_le16(tlv->max_sta_num_supported); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->max_sta_num_configured = - uap_le16_to_cpu(tlv->max_sta_num_configured); - tlv->max_sta_num_supported = - uap_le16_to_cpu(tlv->max_sta_num_supported); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_MAX_STA_CNT_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("configured max station count = %d\n", - tlv->max_sta_num_configured); - if (tlv->length == 4) { - printf("max number of stations supported = %d\n", tlv->max_sta_num_supported); - } - } else { - printf("max station number setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get configured max station count and supported max station count!\n"); - } else { - printf("ERR:Could not set max station number!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for retry limit - * and sends to the driver - * - * Usage: "sys_cfg_retry_limit [RETRY_LIMIT]" - * if RETRY_LIMIT is provided, a 'set' is performed - * else a 'get' is performed. - * - * RETRY_LIMIT should not bigger than 14 - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_retry_limit(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_retry_limit *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_retry_limit_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && (is_input_valid(RETRYLIMIT, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_retry_limit_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_retry_limit); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_retry_limit *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_RETRY_LIMIT_TLV_ID; - tlv->length = 1; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->retry_limit = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_RETRY_LIMIT_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("retry limit = %d\n", tlv->retry_limit); - } else { - printf("retry limit setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get retry limit!\n"); - } else { - printf("ERR:Could not set retry limit!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for sticky TIM configuration - * and sends to the driver - * - * Usage: "sys_cfg_sticky_tim_config [ENABLE] [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_sticky_tim_config(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_sticky_tim_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_sticky_tim_config_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && - (is_input_valid(STICKYTIMCONFIG, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_sticky_tim_config_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sticky_tim_config); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_sticky_tim_config *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_STICKY_TIM_CONFIG_TLV_ID; - tlv->length = sizeof(tlvbuf_sticky_tim_config) - TLVHEADER_LEN; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->enable = (t_u16)atoi(argv[0]); - if (argc > 1) { - tlv->duration = (t_u16)atoi(argv[1]); - tlv->sticky_bitmask = (t_u16)atoi(argv[2]); - } - } - endian_convert_tlv_header_out(tlv); - tlv->enable = uap_cpu_to_le16(tlv->enable); - if (argc > 1) { - tlv->duration = uap_cpu_to_le16(tlv->duration); - tlv->sticky_bitmask = uap_cpu_to_le16(tlv->sticky_bitmask); - } - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->enable = uap_le16_to_cpu(tlv->enable); - if (argc > 1) { - tlv->duration = uap_le16_to_cpu(tlv->duration); - tlv->sticky_bitmask = uap_le16_to_cpu(tlv->sticky_bitmask); - } - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_STICKY_TIM_CONFIG_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("Sticky TIM is %s\n", - (tlv->enable == - 0) ? "disabled" : "enabled"); - printf("Duration = %d beacons\n", - tlv->duration); - printf("Sticky Bitmask = %x\n", - tlv->sticky_bitmask); - } else { - printf("sticky TIM configuration successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get sticky TIM configuration!\n"); - } else { - printf("ERR:Could not set sticky TIM configuration!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for sticky TIM station MAC address - * and sends to the driver - * - * Usage: "sys_cfg_sticky_tim_sta_mac_addr [CONTROL] [STA_MAC_ADDRESS]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_sticky_tim_sta_mac_addr(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_sticky_tim_sta_mac_addr *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int tlv_get_len = 0; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_sticky_tim_sta_mac_addr_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && - (is_input_valid(STICKYTIMSTAMACADDR, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_sticky_tim_sta_mac_addr_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sticky_tim_sta_mac_addr); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_sticky_tim_sta_mac_addr *)(buffer + - sizeof - (apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_STICKY_TIM_STA_MAC_ADDR_TLV_ID; - tlv->length = sizeof(tlvbuf_sticky_tim_sta_mac_addr) - TLVHEADER_LEN; - if (argc < 2) { - cmd_buf->action = ACTION_GET; - if (argc == 0) { - tlv->length = 0; - cmd_len -= - sizeof(tlvbuf_sticky_tim_sta_mac_addr) - - TLVHEADER_LEN; - } - if ((argc == 1) && - mac2raw(argv[0], tlv->sta_mac_address) != UAP_SUCCESS) { - printf("ERR: Invalid MAC address %s \n", argv[0]); - free(buffer); - return UAP_FAILURE; - } - } else { - cmd_buf->action = ACTION_SET; - tlv->control = (t_u16)atoi(argv[0]); - if (mac2raw(argv[1], tlv->sta_mac_address) != UAP_SUCCESS) { - printf("ERR: Invalid MAC address %s \n", argv[1]); - free(buffer); - return UAP_FAILURE; - } - } - endian_convert_tlv_header_out(tlv); - tlv->control = uap_cpu_to_le16(tlv->control); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->control = uap_le16_to_cpu(tlv->control); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_STICKY_TIM_STA_MAC_ADDR_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc < 2) { - tlv_get_len = - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE; - while (tlv_get_len > 0) { - printf("station MAC address = "); - print_mac(tlv->sta_mac_address); - printf("\ncontrol = %x\n", - tlv->control); - tlv++; - tlv_get_len -= - sizeof - (tlvbuf_sticky_tim_sta_mac_addr); - } - } else { - printf("sticky TIM configuration for given station is successful\n"); - } - } else { - if (argc < 2) { - printf("ERR:Could not get sticky TIM configuration for station(s)!\n"); - } else { - printf("ERR:Could not set sticky TIM configuration for given station!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for 20/40 coex configuration - * and sends to the driver - * - * Usage: "sys_cfg_2040_coex [ENABLE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_2040_coex(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_2040_coex *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_2040_coex_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && (is_input_valid(COEX2040CONFIG, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_2040_coex_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_2040_coex); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_2040_coex *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_2040_BSS_COEX_CONTROL_TLV_ID; - tlv->length = sizeof(tlvbuf_2040_coex) - TLVHEADER_LEN; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = ACTION_SET; - tlv->enable = (t_u8)atoi(argv[0]); - } - endian_convert_tlv_header_out(tlv); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_2040_BSS_COEX_CONTROL_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - printf("20/40 BSS Co-existence is %s\n", - (tlv->enable == - 0) ? "disabled" : "enabled"); - } else { - printf("20/40 coex configuration successful\n"); - } - } else { - printf("ERR:Could not %s 2040 coex configuration!\n", - argc ? "set" : "get"); - if (argc) - printf("20/40 coex configuration is allowed to set only before bss start.\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for setting pairwise key handshake timeout - * and number of retries and sends to the driver - * - * Usage: "sys_cfg_eapol_pwk_hsk [ ]" - * If both TIMEOUT value and number of RETRIES are provided, - * a 'set' is performed else a 'get' is performed. - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_eapol_pwk_hsk(int argc, char *argv[]) -{ - int opt; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - t_u8 *tlv_buf = NULL; - t_u8 *buffer = NULL; - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_eapol_pwk_hsk_timeout *timeout_tlv = NULL; - tlvbuf_eapol_pwk_hsk_retries *retries_tlv = NULL; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_eapol_pwk_hsk_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check Arguments */ - if (argc && (is_input_valid(EAPOL_PWK_HSK, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_eapol_pwk_hsk_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_eapol_pwk_hsk_timeout) - + sizeof(tlvbuf_eapol_pwk_hsk_retries); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Fill the command buffer */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = argc ? ACTION_SET : ACTION_GET; - tlv_buf = buffer + sizeof(apcmdbuf_sys_configure); - - /* Fill Timeout tlv */ - timeout_tlv = - (tlvbuf_eapol_pwk_hsk_timeout *)(buffer + - sizeof - (apcmdbuf_sys_configure)); - timeout_tlv->tag = MRVL_EAPOL_PWK_HSK_TIMEOUT_TLV_ID; - timeout_tlv->length = 4; - if (argv[0]) - timeout_tlv->pairwise_update_timeout = (t_u32)atoi(argv[0]); - tlv_buf += sizeof(tlvbuf_eapol_pwk_hsk_timeout); - endian_convert_tlv_header_out(timeout_tlv); - timeout_tlv->pairwise_update_timeout = - uap_cpu_to_le32(timeout_tlv->pairwise_update_timeout); - - /* Fill retries tlv */ - retries_tlv = (tlvbuf_eapol_pwk_hsk_retries *)(tlv_buf); - retries_tlv->tag = MRVL_EAPOL_PWK_HSK_RETRIES_TLV_ID; - retries_tlv->length = 4; - if (argv[1]) - retries_tlv->pwk_retries = (t_u32)atoi(argv[1]); - endian_convert_tlv_header_out(retries_tlv); - retries_tlv->pwk_retries = uap_cpu_to_le32(retries_tlv->pwk_retries); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - tlv_buf = buffer + sizeof(apcmdbuf_sys_configure); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x\n", - cmd_buf->cmd_code); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc) { - printf("PWK update timeout and retries setting successful\n"); - } else { - print_tlv((t_u8 *)tlv_buf, - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - } - } else { - printf("ERR:Could not %s pwk timeout and retries value!\n", argc ? "set" : "get"); - if (argc) - printf("PWK timeout and retries are allowed to set only before bss start.\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for setting groupwise key handshake timeout - * and number of retries and sends to the driver - * - * Usage: "sys_cfg_eapol_gwk_hsk [ ]" - * If both TIMEOUT value and number of RETRIES are provided, - * a 'set' is performed else a 'get' is performed. - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_eapol_gwk_hsk(int argc, char *argv[]) -{ - int opt; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - t_u8 *tlv_buf = NULL; - t_u8 *buffer = NULL; - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_eapol_gwk_hsk_timeout *timeout_tlv = NULL; - tlvbuf_eapol_gwk_hsk_retries *retries_tlv = NULL; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_eapol_gwk_hsk_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check Arguments */ - if (argc && (is_input_valid(EAPOL_GWK_HSK, argc, argv) != UAP_SUCCESS)) { - print_sys_cfg_eapol_gwk_hsk_usage(); - return UAP_FAILURE; - } - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_eapol_gwk_hsk_timeout) + - sizeof(tlvbuf_eapol_gwk_hsk_retries); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Fill the command buffer */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = argc ? ACTION_SET : ACTION_GET; - tlv_buf = buffer + sizeof(apcmdbuf_sys_configure); - - /* Fill Timeout tlv */ - timeout_tlv = - (tlvbuf_eapol_gwk_hsk_timeout *)(buffer + - sizeof - (apcmdbuf_sys_configure)); - timeout_tlv->tag = MRVL_EAPOL_GWK_HSK_TIMEOUT_TLV_ID; - timeout_tlv->length = 4; - if (argv[0]) - timeout_tlv->groupwise_update_timeout = (t_u32)atoi(argv[0]); - tlv_buf += sizeof(tlvbuf_eapol_gwk_hsk_timeout); - endian_convert_tlv_header_out(timeout_tlv); - timeout_tlv->groupwise_update_timeout = - uap_cpu_to_le32(timeout_tlv->groupwise_update_timeout); - - /* Fill retries tlv */ - retries_tlv = (tlvbuf_eapol_gwk_hsk_retries *)(tlv_buf); - retries_tlv->tag = MRVL_EAPOL_GWK_HSK_RETRIES_TLV_ID; - retries_tlv->length = 4; - if (argv[1]) - retries_tlv->gwk_retries = (t_u32)atoi(argv[1]); - endian_convert_tlv_header_out(retries_tlv); - retries_tlv->gwk_retries = uap_cpu_to_le32(retries_tlv->gwk_retries); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - tlv_buf = buffer + sizeof(apcmdbuf_sys_configure); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x\n", - cmd_buf->cmd_code); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc) { - printf("GWK update timeout and retries setting successful\n"); - } else { - print_tlv((t_u8 *)tlv_buf, - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - } - } else { - printf("ERR:Could not %s gwk timeout and retries value!\n", argc ? "set" : "get"); - if (argc) - printf("GWK timeout and retries are allowed to set only before bss start.\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Convert string to integer - * - * @param ptr A pointer to data buffer - * @param chr A pointer to return integer - * @return A pointer to next data field - */ -char * -convert2hex(char *ptr, t_u8 *chr) -{ - t_u8 val; - - for (val = 0; *ptr && isxdigit(*ptr); ptr++) { - val = (val * 16) + hexc2bin(*ptr); - } - - *chr = val; - - return ptr; -} - -/** - * @brief Parse hex data - * @param fp A pointer to FILE stream - * @param dst A pointer to receive hex data - * @return length of hex data - */ -int -fparse_for_hex(FILE * fp, t_u8 *dst) -{ - char *ptr; - t_u8 *dptr; - char buf[256]; - - dptr = dst; - while (fgets(buf, sizeof(buf), fp)) { - ptr = buf; - - while (*ptr) { - /* Skip leading spaces */ - while (*ptr && (isspace(*ptr) || *ptr == '\t')) - ptr++; - - /* Skip blank lines and lines beginning with '#' */ - if (*ptr == '\0' || *ptr == '#') - break; - - if (isxdigit(*ptr)) { - ptr = convert2hex(ptr, dptr++); - } else { - /* Invalid character on data line */ - ptr++; - } - } - } - - return (dptr - dst); -} - -/** - * @brief Creates a cfg_data request - * and sends to the driver - * - * Usage: "cfg_data " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_cfg_data(int argc, char *argv[]) -{ - apcmdbuf_cfg_data *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - FILE *fp = NULL; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_cfg_data_usage(); - return UAP_FAILURE; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc == 0) || (argc > 2)) { - printf("ERR:wrong arguments.\n"); - print_cfg_data_usage(); - return UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) != 2)) { - printf("ERR:Illegal type parameter %s. Must be '2'.\n", - argv[0]); - print_cfg_data_usage(); - return UAP_FAILURE; - } - } - buf = (t_u8 *)malloc(buf_len); - if (buf == NULL) { - printf("Error: allocate memory for hostcmd failed\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - cmd_buf = (apcmdbuf_cfg_data *)buf; - if (argc == 2) { - /* Check if file exists */ - fp = fopen(argv[1], "r"); - if (fp == NULL) { - printf("\nERR:Config file can not open %s.\n", argv[1]); - free(buf); - return UAP_FAILURE; - } - cmd_buf->action = ACTION_SET; - cmd_buf->data_len = fparse_for_hex(fp, cmd_buf->data); - fclose(fp); - if (cmd_buf->data_len > MAX_CFG_DATA_SIZE) { - printf("ERR: Config file is too big %d\n", - cmd_buf->data_len); - free(buf); - return UAP_FAILURE; - } - } else { - cmd_buf->action = ACTION_GET; - cmd_buf->data_len = 0; - } - - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->type = atoi(argv[0]); - cmd_buf->type = uap_cpu_to_le16(cmd_buf->type); - cmd_buf->data_len = uap_cpu_to_le16(cmd_buf->data_len); - - /* Fill the command buffer */ - cmd_len = - uap_le16_to_cpu(cmd_buf->data_len) + sizeof(apcmdbuf_cfg_data); - cmd_buf->cmd_code = HostCmd_CMD_CFG_DATA; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - /* Process response */ - if (ret == UAP_SUCCESS) { - cmd_buf->action = uap_le16_to_cpu(cmd_buf->action); - cmd_buf->data_len = uap_le16_to_cpu(cmd_buf->data_len); - if (cmd_buf->action == ACTION_GET) { - hexdump_data("cfg_data", cmd_buf->data, - cmd_buf->data_len, ' '); - } else - printf("download cfg data successful\n"); - } - if (buf) - free(buf); - return ret; -} - -/** - * @brief Show usage information for the sys_cfg_11n - * command - * - * $return N/A - */ -void -print_sys_cfg_11n_usage(void) -{ - printf("\nUsage : sys_cfg_11n [ENABLE] [HTCAP] [AMPDU] [TXBFCAP] [HT_MCS_MAP]\n"); - printf("\nOptions: ENABLE 0 - disable"); - printf("\n 1 - enable"); - printf("\n HTCAP: HT Capabilities info"); - printf("\n AMPDU: A-MPDU Parameter"); - printf("\n TXBFCAP: TX Beamforming capabilities info"); - printf("\n HT_MCS_MAP: Bitmap for supported MCS rates\n"); - printf("\n empty - Get current 802.11n parameters\n"); - return; -} - -/** - * @brief Get Ht capability Info from firmware - * - * @param pHtCap A pointer to HTCap_t structure - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -get_sys_cfg_11n(HTCap_t *pHtCap) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_htcap_t *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len; - int ret = UAP_FAILURE; - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_htcap_t); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return -1; - } - memset(buffer, 0, cmd_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_htcap_t *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = HT_CAPABILITY_TLV_ID; - cmd_buf->action = ACTION_GET; - tlv->length = sizeof(HTCap_t); - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, cmd_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != HT_CAPABILITY_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - - /* Copy response */ - if (cmd_buf->result == CMD_SUCCESS) { - memcpy(pHtCap, &tlv->ht_cap, sizeof(HTCap_t)); - pHtCap->ht_cap_info = - uap_le16_to_cpu(pHtCap->ht_cap_info); - pHtCap->tx_bf_cap = uap_le32_to_cpu(pHtCap->tx_bf_cap); - ret = UAP_SUCCESS; - } else { - ret = UAP_FAILURE; - printf("ERR:Could not get HT capability!\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - ret = UAP_FAILURE; - } - if (buffer) - free(buffer); - return ret; -} - -#ifdef RX_PACKET_COALESCE -void -print_rx_packet_coalesc_help() -{ - printf("\nUSAGE: rxpktcoal_cfg [PKT-THRESHOLD] [TIMEOUT]\n\n"); - printf("OPTIONS:"); - printf("PKT-THRESHOLD: count after which packets would be sent to host. Valid values 1-7\n"); - printf("\tTIMEOUT: Time after which packets would be sent to host Valid values 1-4\n"); - printf("\tCoalescing is disabled if both or either of PKT-THRESHOLD or TIMEOUT is zero\n\n"); - printf("\tEmpty - Get current packet coalescing settings\n"); -} - -int -apcmd_rx_pkt_coalesce(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_rx_pkt_coal_t *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_rx_packet_coalesc_help(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc) { - if (argc != 2) { - printf("ERR: Invalid no. of arguments.\n"); - print_rx_packet_coalesc_help(); - return UAP_FAILURE; - } - if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0)) { - printf("ERR: Invalid arguments %s/%s. Both params must be digits.\n", argv[0], argv[1]); - print_rx_packet_coalesc_help(); - return UAP_FAILURE; - } - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rx_pkt_coal_t *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Initialize the command length */ - if (argc) { - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_rx_pkt_coal_t); - cmd_buf->action = ACTION_SET; - } else { - cmd_len = sizeof(apcmdbuf_sys_configure) + TLVHEADER_LEN; - cmd_buf->action = ACTION_GET; - } - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - if (!argc) { - tlv->tag = MRVL_RX_PKT_COAL_TLV_ID; - tlv->length = 0; - //endian_convert_tlv_header_out(tlv); - } else { - tlv->length = sizeof(tlvbuf_rx_pkt_coal_t) - TLVHEADER_LEN; - tlv->tag = MRVL_RX_PKT_COAL_TLV_ID; - tlv->rx_pkt_count = uap_cpu_to_le32(atoi(argv[0])); - tlv->delay = uap_cpu_to_le16(atoi(argv[1])); - } - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x\n", - cmd_buf->cmd_code); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc) { - printf("Configure RX packet coalesce parameters successful\n"); - } else { - - print_tlv((t_u8 *)tlv, cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - } - - } else { - if (argc) - printf("ERR:Could not set RX packet coalesce parameters!\n"); - else - printf("ERR: Could not get RX packet coalesce parameters!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; - -} -#endif - -/** - * @brief Creates a sys_cfg request for 11n parameters - * and sends to the driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_11n(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_htcap_t *tlv = NULL; - tlvbuf_htinfo_t *ht_info_tlv = NULL; - HTCap_t htcap; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - t_u32 supported_mcs_set = 0; - fw_info fw; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_11n_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc) { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR: Illegal ENABLE parameter %s. Must be either '0' or '1'.\n", argv[0]); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - if (argc > 5) { - printf("ERR:wrong arguments.\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - if (argc > 1) { - if (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - if ((((t_u16)A2HEXDECIMAL(argv[1])) & - (~HT_CAP_CONFIG_MASK)) != HT_CAP_CHECK_MASK) { - printf("ERR: Invalid HTCAP value!\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - } - if (argc > 2) { - if (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - if ((A2HEXDECIMAL(argv[2])) > AMPDU_CONFIG_MASK) { - printf("ERR: Invalid AMPDU value!\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - } - if (argc > 3) { - if (IS_HEX_OR_DIGIT(argv[3]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - } - if (argc > 4) { - if (IS_HEX_OR_DIGIT(argv[4]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_sys_cfg_11n_usage(); - return UAP_FAILURE; - } - if (0 == get_fw_info(&fw)) { - /* Check upper nibble of MCS support value - * and block MCS_SET_1 when 2X2 is not supported - * by the underlying hardware */ - if (((fw.hw_dev_mcs_support & 0xf0) < - STREAM_2X2_MASK) && - (A2HEXDECIMAL(argv[4]) & MCS_SET_1_MASK)) { - printf("ERR: Invalid HT_MCS_MAP\n"); - return UAP_FAILURE; - } - } - } - memset(&htcap, 0, sizeof(htcap)); - if (UAP_FAILURE == get_sys_cfg_11n(&htcap)) { - printf("Fail to get 11n parameters from firmware\n"); - return UAP_FAILURE; - } - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_htcap_t *)(buffer + sizeof(apcmdbuf_sys_configure)); - tlv->tag = HT_CAPABILITY_TLV_ID; - - /* Initialize the command length */ - if (argc) { - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_htcap_t); - cmd_buf->action = ACTION_SET; - } else { - cmd_len = sizeof(apcmdbuf_sys_configure) + 2 * TLVHEADER_LEN; - cmd_buf->action = ACTION_GET; - } - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - if (!argc) { - tlv->length = 0; - /* Append HT_INFO TLV only for GET */ - ht_info_tlv = - (tlvbuf_htinfo_t *)(buffer + - sizeof(apcmdbuf_sys_configure) + - TLVHEADER_LEN); - ht_info_tlv->tag = HT_INFO_TLV_ID; - ht_info_tlv->length = 0; - endian_convert_tlv_header_out(ht_info_tlv); - } else { - tlv->length = sizeof(HTCap_t); - /* disable 802.11n */ - if (atoi(argv[0]) == 0) { - if (argc > 1) { - printf("ERR:wrong arguments.\n"); - print_sys_cfg_11n_usage(); - free(buffer); - return UAP_FAILURE; - } - memcpy(&tlv->ht_cap, &htcap, sizeof(HTCap_t)); - /* disable mcs rate */ - tlv->ht_cap.supported_mcs_set[0] = 0; - tlv->ht_cap.supported_mcs_set[4] = 0; - tlv->ht_cap.supported_mcs_set[1] = 0; - } else { - t_u8 is_40MHz_supported = 0; - /* enable 802.11n */ - memcpy(&tlv->ht_cap, &htcap, sizeof(HTCap_t)); - if (0 == get_fw_info(&fw)) { - if ((fw.hw_dev_mcs_support & 0x0f) >= 2) - tlv->ht_cap.supported_mcs_set[1] = - DEFAULT_MCS_SET_1; - } - if (argc >= 2) { - tlv->ht_cap.ht_cap_info = - DEFAULT_HT_CAP_VALUE & - ~HT_CAP_CONFIG_MASK; - tlv->ht_cap.ht_cap_info |= - (t_u16)A2HEXDECIMAL(argv[1]) & - HT_CAP_CONFIG_MASK; - tlv->ht_cap.ht_cap_info = - uap_cpu_to_le16(tlv->ht_cap. - ht_cap_info); - is_40MHz_supported = - tlv->ht_cap.ht_cap_info & MBIT(1); - } - /* enable mcs rate */ - tlv->ht_cap.supported_mcs_set[0] = DEFAULT_MCS_SET_0; - /* enable MCS32 only in case of both 20/40 MHz support */ - if (is_40MHz_supported) - tlv->ht_cap.supported_mcs_set[4] = - DEFAULT_MCS_SET_4; - else - tlv->ht_cap.supported_mcs_set[4] = 0; - - if (argc >= 3) - tlv->ht_cap.ampdu_param = - (t_u8)A2HEXDECIMAL(argv[2]) & - AMPDU_CONFIG_MASK; - if (argc >= 4) { - tlv->ht_cap.tx_bf_cap = - (t_u32)A2HEXDECIMAL(argv[3]); - tlv->ht_cap.tx_bf_cap = - uap_cpu_to_le32(tlv->ht_cap.tx_bf_cap); - } - if (argc == 5) { - supported_mcs_set = - (t_u32)A2HEXDECIMAL(argv[4]); - supported_mcs_set = - uap_cpu_to_le32(supported_mcs_set); - memcpy(tlv->ht_cap.supported_mcs_set, - &supported_mcs_set, sizeof(t_u32)); - } - } - } - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x\n", - cmd_buf->cmd_code); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc) { - printf("Configure 802.11n parameters successful\n"); - } else { - print_tlv((t_u8 *)tlv, cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - } - - } else { - if (argc) - printf("ERR:Could not set 802.11n parameters!\n"); - else - printf("ERR: Could not get 802.11n parameters!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Show usage information for the sys_cfg_wmm - * command - * - * $return N/A - */ -void -print_sys_cfg_wmm_usage(void) -{ - printf("\nUsage : sys_cfg_wmm [qosinfo=] [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\n [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\n [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\n [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\nOptions: qosinfo - 0x80 or 0x00"); - printf("\n AC_BE - 0, AC_BK - 1"); - printf("\n AC_VI - 2, AC_VO - 3"); - printf("\n AIFSN - AIFSN value"); - printf("\n ECW_MAX: ECW max"); - printf("\n ECW_MIN: ECW min"); - printf("\n TX_OP: TXOP Limit"); - printf("\n empty - Get current wmm parameters\n"); - return; -} - - /** -@brief Show usage information for the sys_cfg_ap_wmm -* command -* -* $return N/A -*/ -void -print_sys_cfg_ap_wmm_usage(void) -{ - printf("\nUsage : sys_cfg_wmm [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\n [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\n [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\n [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\nOptions: AC_BE - 0, AC_BK - 1"); - printf("\n AC_VI - 2, AC_VO - 3"); - printf("\n AIFSN - AIFSN value"); - printf("\n ECW_MAX: ECW max"); - printf("\n ECW_MIN: ECW min"); - printf("\n TX_OP: TXOP Limit"); - printf("\n empty - Get current wmm parameters\n"); - return; -} - -/** - * @brief Get WMM parameters from firmware - * - * @param pWmm A pointer to WmmParameter_t structure - * @param tlv_tag TLV ID - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -get_wmm_parameters(WmmParameter_t *pWmm, t_u16 tlv_tag) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_wmm_para_t *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len; - t_u8 oui_type[4] = { 0x00, 0x50, 0xF2, 0x02 }; - - int ret = UAP_FAILURE; - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_wmm_para_t); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return -1; - } - memset(buffer, 0, cmd_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wmm_para_t *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = tlv_tag; - cmd_buf->action = ACTION_GET; - tlv->length = sizeof(WmmParameter_t); - memcpy(tlv->wmm_para.ouitype, oui_type, sizeof(oui_type)); - tlv->wmm_para.ouisubtype = 1; - tlv->wmm_para.version = 1; - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, cmd_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != tlv_tag) || - (tlv->length != sizeof(WmmParameter_t))) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - - /* Copy response */ - if (cmd_buf->result == CMD_SUCCESS) { - memcpy(pWmm, &tlv->wmm_para, sizeof(WmmParameter_t)); - ret = UAP_SUCCESS; - } else { - ret = UAP_FAILURE; - printf("ERR:Could not get wmm parameters!\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - ret = UAP_FAILURE; - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Creates a sys_cfg request for wmm parameters - * and sends to the driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_wmm(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_wmm_para_t *tlv = NULL; - WmmParameter_t wmm_para; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int i; - int ret = UAP_SUCCESS; - int opt; - t_u8 ac = 0; - t_u8 wmm_disable = 1; - t_u8 qos_info = 0; - t_u8 flag = 0; - char str[13]; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_wmm_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - memset(&wmm_para, 0, sizeof(wmm_para)); - memset(str, 0, sizeof(str)); - if (UAP_FAILURE == - get_wmm_parameters(&wmm_para, VENDOR_SPECIFIC_IE_TLV_ID)) { - printf("Fail to get wmm parameters from firmware\n"); - return UAP_FAILURE; - } - - if (!argc) { - printf("wmm parameters:\n"); - printf("\tqos_info = 0x%x\n", wmm_para.qos_info); - printf("\tBE: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_BE].aci_aifsn.aifsn, - wmm_para.ac_params[AC_BE].ecw.ecw_max, - wmm_para.ac_params[AC_BE].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_BE].tx_op_limit)); - printf("\tBK: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_BK].aci_aifsn.aifsn, - wmm_para.ac_params[AC_BK].ecw.ecw_max, - wmm_para.ac_params[AC_BK].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_BK].tx_op_limit)); - printf("\tVI: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_VI].aci_aifsn.aifsn, - wmm_para.ac_params[AC_VI].ecw.ecw_max, - wmm_para.ac_params[AC_VI].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_VI].tx_op_limit)); - printf("\tVO: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_VO].aci_aifsn.aifsn, - wmm_para.ac_params[AC_VO].ecw.ecw_max, - wmm_para.ac_params[AC_VO].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_VO].tx_op_limit)); - return UAP_SUCCESS; - } - - if (strlen(argv[0]) > 8) { - if (strncmp(argv[0], "qosinfo=", 8) == 0) { - strncpy(str, argv[0], sizeof(str) - 1); - strncpy(str, strchr(str, '=') + 1, 4); - qos_info = A2HEXDECIMAL(str); - if ((qos_info != ENABLE_WMM_PS) && - (qos_info != DISABLE_WMM_PS)) { - printf("ERR:qos_info must be either 0x80 or 0x00\n"); - print_sys_cfg_wmm_usage(); - return UAP_FAILURE; - } - argc -= 1; - argv += 1; - flag = 1; - } else { - printf("ERR:Invalid argument!\n"); - print_sys_cfg_wmm_usage(); - return UAP_FAILURE; - } - } - /* Check arguments */ - if ((argc != 1) && ((argc > 20) || ((argc > 0) && ((argc % 5) != 0)))) { - printf("ERR:Illegal number of parameters.\n"); - print_sys_cfg_wmm_usage(); - return UAP_FAILURE; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_sys_cfg_wmm_usage(); - return UAP_FAILURE; - } - if (A2HEXDECIMAL(argv[i])) - wmm_disable = 0; - } - if ((argc == 1) && A2HEXDECIMAL(argv[0])) { - printf("ERR: Only 0 is allowed to disable WMM using single parameter.\n"); - print_sys_cfg_wmm_usage(); - return UAP_FAILURE; - } - if (argc != 20 && argc != 1) - wmm_disable = 0; - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_wmm_para_t); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wmm_para_t *)(buffer + sizeof(apcmdbuf_sys_configure)); - tlv->tag = VENDOR_SPECIFIC_IE_TLV_ID; - tlv->length = sizeof(WmmParameter_t); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = ACTION_SET; - endian_convert_tlv_header_out(tlv); - - memcpy(&tlv->wmm_para, &wmm_para, sizeof(WmmParameter_t)); - if (wmm_disable) { - /* clear AC parameters to disalbe wmm */ - memset((t_u8 *)tlv->wmm_para.ac_params, 0, - sizeof(IEEEtypes_WmmAcParameters_t) * MAX_AC_QUEUES); - } else { - if (flag) { - if (qos_info) - tlv->wmm_para.qos_info = - wmm_para.qos_info | qos_info; - else - tlv->wmm_para.qos_info = - wmm_para.qos_info & WMM_PS_MASK; - } - for (i = 0; i < (argc / 5); i++) { - ac = (t_u8)A2HEXDECIMAL(argv[i * 5]); - if (ac > AC_VO) { - printf("ERR: Invalid AC queue index, Only support AC_BE, AC_BK, AC_VI, AC_VO\n"); - print_sys_cfg_wmm_usage(); - free(buffer); - return UAP_FAILURE; - } - tlv->wmm_para.ac_params[ac].aci_aifsn.aifsn = - (t_u8)A2HEXDECIMAL(argv[i * 5 + 1]); - tlv->wmm_para.ac_params[ac].aci_aifsn.aci = (t_u8)ac; - tlv->wmm_para.ac_params[ac].ecw.ecw_max = - (t_u8)A2HEXDECIMAL(argv[i * 5 + 2]); - tlv->wmm_para.ac_params[ac].ecw.ecw_min = - (t_u8)A2HEXDECIMAL(argv[i * 5 + 3]); - tlv->wmm_para.ac_params[ac].tx_op_limit = - uap_cpu_to_le16((t_u16) - A2HEXDECIMAL(argv[i * 5 + 4])); - } - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != VENDOR_SPECIFIC_IE_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("Configure wmm parameters successful\n"); - - } else { - printf("ERR:Could not set wmm parameters!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** -* @param argc Number of arguments -* @param argv Pointer to the arguments -* @return UAP_SUCCESS/UAP_FAILURE -*/ -int -apcmd_sys_cfg_ap_wmm(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_wmm_para_t *tlv = NULL; - WmmParameter_t wmm_para; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int i; - int opt; - t_u8 ac = 0; - t_u8 wmm_reset = 1; - int ret = UAP_SUCCESS; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_ap_wmm_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - memset(&wmm_para, 0, sizeof(wmm_para)); - if (UAP_FAILURE == - get_wmm_parameters(&wmm_para, MRVL_AP_WMM_PARAM_TLV_ID)) { - printf("Fail to get ap wmm parameters from firmware\n"); - return UAP_FAILURE; - } - - if (!argc) { - printf("ap wmm parameters:\n"); - printf("\tBE: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_BE].aci_aifsn.aifsn, - wmm_para.ac_params[AC_BE].ecw.ecw_max, - wmm_para.ac_params[AC_BE].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_BE].tx_op_limit)); - printf("\tBK: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_BK].aci_aifsn.aifsn, - wmm_para.ac_params[AC_BK].ecw.ecw_max, - wmm_para.ac_params[AC_BK].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_BK].tx_op_limit)); - printf("\tVI: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_VI].aci_aifsn.aifsn, - wmm_para.ac_params[AC_VI].ecw.ecw_max, - wmm_para.ac_params[AC_VI].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_VI].tx_op_limit)); - printf("\tVO: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para.ac_params[AC_VO].aci_aifsn.aifsn, - wmm_para.ac_params[AC_VO].ecw.ecw_max, - wmm_para.ac_params[AC_VO].ecw.ecw_min, - uap_le16_to_cpu(wmm_para.ac_params[AC_VO].tx_op_limit)); - return UAP_SUCCESS; - } - - /* Check arguments */ - if ((argc != 1) && ((argc > 20) || ((argc > 0) && ((argc % 5) != 0)))) { - printf("ERR:Illegal number of parameters.\n"); - print_sys_cfg_ap_wmm_usage(); - return UAP_FAILURE; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_sys_cfg_ap_wmm_usage(); - return UAP_FAILURE; - } - if (A2HEXDECIMAL(argv[i])) - wmm_reset = 0; - } - if ((argc == 1) && A2HEXDECIMAL(argv[0])) { - printf("ERR: Only 0 is allowed to reset AP WMM using single parameter.\n"); - print_sys_cfg_ap_wmm_usage(); - return UAP_FAILURE; - } - if (argc != 20 && argc != 1) - wmm_reset = 0; - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_wmm_para_t); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wmm_para_t *)(buffer + sizeof(apcmdbuf_sys_configure)); - tlv->tag = MRVL_AP_WMM_PARAM_TLV_ID; - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = ACTION_SET; - endian_convert_tlv_header_out(tlv); - - memcpy(&tlv->wmm_para, &wmm_para, sizeof(WmmParameter_t)); - if (wmm_reset) { - /* clear AC parameters to reset ap wmm */ - memset((t_u8 *)tlv->wmm_para.ac_params, 0, - sizeof(IEEEtypes_WmmAcParameters_t) * MAX_AC_QUEUES); - } else { - for (i = 0; i < (argc / 5); i++) { - ac = (t_u8)A2HEXDECIMAL(argv[i * 5]); - if (ac > AC_VO) { - printf("ERR: Invalid AC queue index, Only support AC_BE, AC_BK, AC_VI, AC_VO\n"); - print_sys_cfg_ap_wmm_usage(); - free(buffer); - return UAP_FAILURE; - } - tlv->wmm_para.ac_params[ac].aci_aifsn.aifsn = - (t_u8)A2HEXDECIMAL(argv[i * 5 + 1]); - tlv->wmm_para.ac_params[ac].aci_aifsn.aci = (t_u8)ac; - tlv->wmm_para.ac_params[ac].ecw.ecw_max = - (t_u8)A2HEXDECIMAL(argv[i * 5 + 2]); - tlv->wmm_para.ac_params[ac].ecw.ecw_min = - (t_u8)A2HEXDECIMAL(argv[i * 5 + 3]); - tlv->wmm_para.ac_params[ac].tx_op_limit = - uap_cpu_to_le16((t_u16) - A2HEXDECIMAL(argv[i * 5 + 4])); - } - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_AP_WMM_PARAM_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("Configure ap wmm parameters successful\n"); - } else { - printf("ERR:Could not set ap wmm parameters!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Show usage information for the sys_cfg_restrict_client_mode - * command - * - * $return N/A - */ -void -print_sys_cfg_restrict_client_mode_usage(void) -{ - printf("\nUsage : sys_cfg_restrict_client_mode [ [MODE_CONFIG]]\n"); - printf("\nOptions:"); - printf("\n Bit 0: 1 enable restricted client mode"); - printf("\n 0 disable restricted client mode"); - printf("\n Bits [1-7] : set to 0"); - printf("\n Bits [8:12]:"); - printf("\n Bit 8: B only Mode"); - printf("\n Bit 9: A only Mode"); - printf("\n Bit 10: G only Mode"); - printf("\n Bit 11: N only Mode"); - printf("\n Bit 12: AC only Mode"); - printf("\n Bits [13:15]: set to 0"); - printf("\n"); - printf("\n Empty - Get current restricted client mode setting.\n"); - return; -} - -/** - * @brief Creates a sys_cfg request to Set/Get restricted client mode - * and sends to the driver - * - * Usage: "sys_cfg_restrict_client_mode [ [MODE_CONFIG]]" - * If arguments are provided, a 'set' is performed - * else a 'get' is performed. - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_restrict_client_mode(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_restrict_client_mode *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_restrict_client_mode_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc && - is_input_valid(RESTRICT_CLIENT_MODE, argc, argv) != UAP_SUCCESS) { - print_sys_cfg_restrict_client_mode_usage(); - return UAP_FAILURE; - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_restrict_client_mode *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_RESTRICT_CLIENT_MODE_TLV_ID; - if (argc == 0) { - cmd_buf->action = ACTION_GET; - tlv->length = 0; - } else { - cmd_buf->action = ACTION_SET; - tlv->length = sizeof(t_u16); - tlv->mode_config = - (t_u16)((tlv-> - mode_config | RESTRICT_CLIENT_MODE_ENABLE_MASK) - & atoi(argv[0])); - if (argc == 2) { - tlv->mode_config |= (t_u16)(A2HEXDECIMAL(argv[1]) << 8); - } - tlv->mode_config = uap_cpu_to_le16(tlv->mode_config); - } - cmd_buf->size = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_restrict_client_mode); - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_restrict_client_mode); - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_RESTRICT_CLIENT_MODE_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 0) { - tlv->mode_config = - uap_le16_to_cpu(tlv->mode_config); - printf("Restricted Client Mode: %s\n", - (tlv-> - mode_config & - RESTRICT_CLIENT_MODE_ENABLE_MASK) ? - "Enabled" : "Disabled"); - if (tlv-> - mode_config & - RESTRICT_CLIENT_MODE_ENABLE_MASK) { - printf("Current client mode : "); - if (tlv->mode_config & B_ONLY_MASK) - printf("B Only\n"); - else if (tlv->mode_config & A_ONLY_MASK) - printf("A Only\n"); - else if (tlv->mode_config & G_ONLY_MASK) - printf("G Only\n"); - else if (tlv->mode_config & N_ONLY_MASK) - printf("N Only\n"); - else if (tlv-> - mode_config & AC_ONLY_MASK) - printf("AC Only\n"); - } - } else { - printf("Restricted client mode setting successful\n"); - } - } else { - if (argc == 0) { - printf("ERR:Could not get restrict client mode setting!\n"); - } else { - printf("ERR:Could not set restrict client mode setting!\n"); - } - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.h b/mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.h deleted file mode 100644 index 59dfcee..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/uapcmd.h +++ /dev/null @@ -1,81 +0,0 @@ -/** @file uapcmd.h - * - * @brief This file contains declaration referring to - * functions defined in uapcmd.c - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 03/01/08: Initial creation -************************************************************************/ - -#ifndef _UAPCMD_H -#define _UAPCMD_H - -/** Function Prototype Declaration */ -int apcmd_sys_cfg_ap_mac_address(int argc, char *argv[]); -int apcmd_sys_cfg_ssid(int argc, char *argv[]); -int apcmd_sys_cfg_beacon_period(int argc, char *argv[]); -int apcmd_sys_cfg_dtim_period(int argc, char *argv[]); -int apcmd_sys_cfg_bss_status(int argc, char *argv[]); -int apcmd_sys_cfg_channel(int argc, char *argv[]); -int apcmd_sys_cfg_channel_ext(int argc, char *argv[]); -int apcmd_sys_cfg_scan_channels(int argc, char *argv[]); -int apcmd_sys_cfg_rates(int argc, char *argv[]); -int apcmd_sys_cfg_rates_ext(int argc, char *argv[]); -int apcmd_sys_cfg_tx_power(int argc, char *argv[]); -int apcmd_sys_cfg_bcast_ssid_ctl(int argc, char *argv[]); -int apcmd_sys_cfg_preamble_ctl(int argc, char *argv[]); -int apcmd_sys_cfg_rts_threshold(int argc, char *argv[]); -int apcmd_sys_cfg_frag_threshold(int argc, char *argv[]); -int apcmd_sys_cfg_radio_ctl(int argc, char *argv[]); -int apcmd_sys_cfg_rsn_replay_prot(int argc, char *argv[]); -int apcmd_sys_cfg_tx_beacon_rate(int argc, char *argv[]); -int apcmd_sys_cfg_mcbc_data_rate(int argc, char *argv[]); -int apcmd_sys_cfg_pkt_fwd_ctl(int argc, char *argv[]); -int apcmd_sys_cfg_sta_ageout_timer(int argc, char *argv[]); -int apcmd_sys_cfg_ps_sta_ageout_timer(int argc, char *argv[]); -int apcmd_sys_cfg_auth(int argc, char *argv[]); -int apcmd_sys_cfg_protocol(int argc, char *argv[]); -int apcmd_sys_cfg_wep_key(int argc, char *argv[]); -int apcmd_sys_cfg_cipher(int argc, char *argv[]); -int apcmd_sys_cfg_pwk_cipher(int argc, char *argv[]); -int apcmd_sys_cfg_gwk_cipher(int argc, char *argv[]); -int apcmd_sys_cfg_wpa_passphrase(int argc, char *argv[]); -int apcmd_sys_cfg_wpa3_sae_password(int argc, char *argv[]); -int apcmd_sys_cfg_group_rekey_timer(int argc, char *argv[]); -int apcmd_sta_filter_table(int argc, char *argv[]); -int apcmd_sys_cfg_max_sta_num(int argc, char *argv[]); -int apcmd_sys_cfg_retry_limit(int argc, char *argv[]); -int apcmd_sys_cfg_sticky_tim_config(int argc, char *argv[]); -int apcmd_sys_cfg_sticky_tim_sta_mac_addr(int argc, char *argv[]); -int apcmd_sys_cfg_eapol_pwk_hsk(int argc, char *argv[]); -int apcmd_sys_cfg_eapol_gwk_hsk(int argc, char *argv[]); -int apcmd_cfg_data(int argc, char *argv[]); -int apcmd_sys_cfg_custom_ie(int argc, char *argv[]); -int apcmd_sys_cfg_wmm(int argc, char *argv[]); -int apcmd_sys_cfg_ap_wmm(int argc, char *argv[]); -int apcmd_sys_cfg_11n(int argc, char *argv[]); -#ifdef RX_PACKET_COALESCE -int apcmd_rx_pkt_coalesce(int argc, char *argv[]); -void print_rx_packet_coalesc_help(void); -#endif -int apcmd_sys_cfg_2040_coex(int argc, char *argv[]); -int apcmd_sys_cfg_restrict_client_mode(int argc, char *argv[]); -#endif /* _UAP_H */ diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/uaphostcmd.c b/mxm_wifiex/wlan_src/mapp/uaputl/uaphostcmd.c deleted file mode 100644 index 8f3b51e..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/uaphostcmd.c +++ /dev/null @@ -1,338 +0,0 @@ -/** @file uaphostcmd.c - * - * @brief This file contains uAP hostcmd functions - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version -************************************************************************/ - -#include -#include -#include -#include -#include "uaputl.h" - -#ifndef MIN -/** Find minimum value */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ -/* - * @brief convert String to integer - * - * @param value A pointer to string - * @return integer - */ -static t_u32 -a2hex_or_atoi(char *value) -{ - if (value[0] == '0' && (value[1] == 'X' || value[1] == 'x')) { - return a2hex(value + 2); - } else if (isdigit(*value)) { - return atoi(value); - } else { - return *value; - } -} - -/** - * @brief Get one line from the File - * - * @param fp File handler - * @param str Storage location for data. - * @param size Maximum number of characters to read. - * @param lineno A pointer to return current line number - * @return returns string or NULL - */ -char * -mlan_config_get_line(FILE * fp, char *str, t_s32 size, int *lineno) -{ - char *start, *end; - int out, next_line; - - if (!fp || !str) - return NULL; - - do { -read_line: - if (!fgets(str, size, fp)) - break; - start = str; - start[size - 1] = '\0'; - end = start + strlen(str); - (*lineno)++; - - out = 1; - while (out && (start < end)) { - next_line = 0; - /* Remove empty lines and lines starting with # */ - switch (start[0]) { - case ' ': /* White space */ - case '\t': /* Tab */ - start++; - break; - case '#': - case '\n': - case '\0': - next_line = 1; - break; - case '\r': - if (start[1] == '\n') - next_line = 1; - else - start++; - break; - default: - out = 0; - break; - } - if (next_line) - goto read_line; - } - - /* Remove # comments unless they are within a double quoted - * string. Remove trailing white space. */ - if ((end = strstr(start, "\""))) { - if (!(end = strstr(end + 1, "\""))) - end = start; - } else - end = start; - - if ((end = strstr(end + 1, "#"))) - *end-- = '\0'; - else - end = start + strlen(start) - 1; - - out = 1; - while (out && (start < end)) { - switch (*end) { - case ' ': /* White space */ - case '\t': /* Tab */ - case '\n': - case '\r': - *end = '\0'; - end--; - break; - default: - out = 0; - break; - } - } - - if (*start == '\0') - continue; - - return start; - } while (1); - - return NULL; -} - -/** - * @brief get hostcmd data - * - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return UAP_SUCCESS - */ -static int -mlan_get_hostcmd_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - t_s32 errors = 0, i; - char line[512], *pos, *pos1, *pos2, *pos3; - t_u16 len; - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - (*ln)++; - if (strcmp(pos, "}") == 0) { - break; - } - - pos1 = strchr(pos, ':'); - if (pos1 == NULL) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - - pos2 = strchr(pos1, '='); - if (pos2 == NULL) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos2++ = '\0'; - - len = a2hex_or_atoi(pos1); - if (len < 1 || len > MRVDRV_SIZE_OF_CMD_BUFFER) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - - *size += len; - - if (*pos2 == '"') { - pos2++; - if ((pos3 = strchr(pos2, '"')) == NULL) { - printf("Line %d: invalid quotation '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos3 = '\0'; - memset(buf, 0, len); - memmove(buf, pos2, MIN(strlen(pos2), len)); - buf += len; - } else if (*pos2 == '\'') { - pos2++; - if ((pos3 = strchr(pos2, '\'')) == NULL) { - printf("Line %d: invalid quotation '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos3 = ','; - for (i = 0; i < len; i++) { - if ((pos3 = strchr(pos2, ',')) != NULL) { - *pos3 = '\0'; - *buf++ = (t_u8)a2hex_or_atoi(pos2); - pos2 = pos3 + 1; - } else - *buf++ = 0; - } - } else if (*pos2 == '{') { - t_u16 tlvlen = 0, tmp_tlvlen; - mlan_get_hostcmd_data(fp, ln, buf + len, &tlvlen); - tmp_tlvlen = tlvlen; - while (len--) { - *buf++ = (t_u8)(tmp_tlvlen & 0xff); - tmp_tlvlen >>= 8; - } - *size += tlvlen; - buf += tlvlen; - } else { - t_u32 value = a2hex_or_atoi(pos2); - while (len--) { - *buf++ = (t_u8)(value & 0xff); - value >>= 8; - } - } - } - return UAP_SUCCESS; -} - -/******************************************************** - Global Functions -********************************************************/ - -/** - * @brief Prepare host-command buffer - * @param fname path to the config file - * @param cmd_name Command name - * @param buf A pointer to comand buffer - * @return UAP_SUCCESS--success, otherwise--fail - */ -int -prepare_host_cmd_buffer(char *fname, char *cmd_name, t_u8 *buf) -{ - char line[256], cmdname[256], *pos, cmdcode[10]; - apcmdbuf *hostcmd; - int ln = 0; - int cmdname_found = 0, cmdcode_found = 0; - FILE *config_fp; - int ret = UAP_SUCCESS; - - config_fp = fopen(fname, "r"); - - if (!config_fp) { - printf("Unable to find %s. Exiting...\n", fname); - return UAP_FAILURE; - } - - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - hostcmd = (apcmdbuf *)buf; - hostcmd->cmd_code = 0xffff; - - snprintf(cmdname, sizeof(cmdname), "%s={", cmd_name); - cmdname_found = 0; - while ((pos = mlan_config_get_line(config_fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - cmdname_found = 1; - snprintf(cmdcode, sizeof(cmdcode), "CmdCode="); - cmdcode_found = 0; - while ((pos = - mlan_config_get_line(config_fp, line, - sizeof(line), &ln))) { - if (strncmp(pos, cmdcode, strlen(cmdcode)) == 0) { - t_u16 len = 0; - cmdcode_found = 1; - hostcmd->cmd_code = - a2hex_or_atoi(pos + - strlen(cmdcode)); - hostcmd->size = - sizeof(apcmdbuf) - - BUF_HEADER_SIZE; - mlan_get_hostcmd_data(config_fp, &ln, - buf + - sizeof(apcmdbuf), - &len); - hostcmd->size += len; - break; - } - } - if (!cmdcode_found) { - fprintf(stderr, - "uaputl: CmdCode not found in conf file\n"); - ret = UAP_FAILURE; - goto done; - } - break; - } - } - - if (!cmdname_found) { - fprintf(stderr, - "uaputl: cmdname '%s' is not found in conf file\n", - cmd_name); - ret = UAP_FAILURE; - goto done; - } -done: - fclose(config_fp); - return ret; -} diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/uaputl.c b/mxm_wifiex/wlan_src/mapp/uaputl/uaputl.c deleted file mode 100644 index 56c8ee2..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/uaputl.c +++ /dev/null @@ -1,14528 +0,0 @@ -/** @file uaputl.c - * - * @brief Program to send AP commands to the driver/firmware of the uAP - * driver. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/**************************************************************************** -Change log: - 03/01/08: Initial creation -****************************************************************************/ - -/**************************************************************************** - Header files -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "uaputl.h" -#include "uapcmd.h" - -/**************************************************************************** - Definitions -****************************************************************************/ -/** Default debug level */ -int debug_level = MSG_NONE; - -/** Enable or disable debug outputs */ -#define DEBUG 1 - -/** Convert character to integer */ -#define CHAR2INT(x) (((x) >= 'A') ? ((x) - 'A' + 10) : ((x) - '0')) - -/** Supported stream modes */ -#define HT_STREAM_MODE_1X1 0x11 -#define HT_STREAM_MODE_2X2 0x22 - -static int get_bss_config(t_u8 *buf); - -/**************************************************************************** - Global variables -****************************************************************************/ -/** Device name */ -static char dev_name[IFNAMSIZ + 1]; -/** Option for cmd */ -struct option cmd_options[] = { - {"help", 0, 0, 'h'}, - {0, 0, 0, 0} -}; - -/** Flag to check if custom IE is present in sys_config response from FW */ -int custom_ie_present = 0; - -/** Flag to check if max mgmt IE is printed in sys_config response from FW */ -int max_mgmt_ie_print = 0; - -/** Flag to bypass re-route path */ -int uap_ioctl_no_reroute = 0; - -/**************************************************************************** - Local functions -****************************************************************************/ -/** - * @brief Convert char to hex integer - * - * @param chr Char - * @return Hex integer - */ -unsigned char -hexc2bin(char chr) -{ - if (chr >= '0' && chr <= '9') - chr -= '0'; - else if (chr >= 'A' && chr <= 'F') - chr -= ('A' - 10); - else if (chr >= 'a' && chr <= 'f') - chr -= ('a' - 10); - - return chr; -} - -/** - * @brief Check protocol is valid or not - * - * @param protocol Protocol - * - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_protocol_valid(int protocol) -{ - int ret = UAP_FAILURE; - switch (protocol) { - case PROTOCOL_NO_SECURITY: - case PROTOCOL_STATIC_WEP: - case PROTOCOL_WPA: - case PROTOCOL_WPA2: - case PROTOCOL_WPA2_MIXED: - case PROTOCOL_WPA3_SAE: - ret = UAP_SUCCESS; - break; - default: - printf("ERR: Invalid Protocol: %d\n", protocol); - break; - } - return ret; -} - -/** - * @brief Function to check valid rate - * - * - * @param rate Rate to verify - * - * return UAP_SUCCESS or UAP_FAILURE - **/ -int -is_rate_valid(int rate) -{ - int ret = UAP_SUCCESS; - switch (rate) { - case 2: - case 4: - case 11: - case 13: - case 22: - case 12: - case 18: - case 24: - case 48: - case 72: - case 96: - case 108: - case 36: - break; - default: - ret = UAP_FAILURE; - break; - } - return ret; -} - -/** - * @brief Check for mandatory rates - * - * - * 2, 4, 11, 22 must be present - * - * 6 12 and 24 must be present for ofdm - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_FAILURE or UAP_SUCCESS - * - */ -static int -check_mandatory_rates(int argc, char **argv) -{ - int i; - int tmp; - t_u32 rate_bitmap = 0; - int cck_enable = 0; - int ofdm_enable = 0; -#define BITMAP_RATE_1M 0x01 -#define BITMAP_RATE_2M 0x02 -#define BITMAP_RATE_5_5M 0x04 -#define BITMAP_RATE_11M 0x8 -#define B_RATE_MANDATORY 0x0f -#define BITMAP_RATE_6M 0x10 -#define BITMAP_RATE_12M 0x20 -#define BITMAP_RATE_24M 0x40 -#define G_RATE_MANDATORY 0x70 - for (i = 0; i < argc; i++) { - tmp = (A2HEXDECIMAL(argv[i]) & ~BASIC_RATE_SET_BIT); - switch (tmp) { - case 2: - cck_enable = 1; - rate_bitmap |= BITMAP_RATE_1M; - break; - case 4: - cck_enable = 1; - rate_bitmap |= BITMAP_RATE_2M; - break; - case 11: - cck_enable = 1; - rate_bitmap |= BITMAP_RATE_5_5M; - break; - case 22: - cck_enable = 1; - rate_bitmap |= BITMAP_RATE_11M; - break; - case 12: - ofdm_enable = 1; - rate_bitmap |= BITMAP_RATE_6M; - break; - case 24: - ofdm_enable = 1; - rate_bitmap |= BITMAP_RATE_12M; - break; - case 48: - ofdm_enable = 1; - rate_bitmap |= BITMAP_RATE_24M; - break; - case 18: - case 36: - case 72: - case 96: - case 108: - ofdm_enable = 1; - break; - } - } -#ifdef WIFI_DIRECT_SUPPORT - if (strncmp(dev_name, "wfd", 3)) -#endif - if ((rate_bitmap & B_RATE_MANDATORY) != B_RATE_MANDATORY) { - if (cck_enable) { - printf("Basic Rates 2, 4, 11 and 22 (500K units) \n" "must be present in basic or non-basic rates\n"); - return UAP_FAILURE; - } - } - if (ofdm_enable && - ((rate_bitmap & G_RATE_MANDATORY) != G_RATE_MANDATORY)) { - printf("OFDM Rates 12, 24 and 48 ( 500Kb units)\n" - "must be present in basic or non-basic rates\n"); - return UAP_FAILURE; - } - return UAP_SUCCESS; -} - -/** - * @brief Convert string to hex integer - * - * @param s A pointer string buffer - * @return Hex integer - */ -unsigned int -a2hex(char *s) -{ - unsigned int val = 0; - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - while (*s && isxdigit(*s)) { - val = (val << 4) + hexc2bin(*s++); - } - return val; -} - -/** - * @brief Dump hex data - * - * @param prompt A pointer prompt buffer - * @param p A pointer to data buffer - * @param len The len of data buffer - * @param delim Delim char - * @return None - */ -void -hexdump_data(char *prompt, void *p, int len, char delim) -{ - int i; - unsigned char *s = p; - - if (prompt) { - printf("%s: len=%d\n", prompt, (int)len); - } - for (i = 0; i < len; i++) { - if (i != len - 1) - printf("%02x%c", *s++, delim); - else - printf("%02x\n", *s); - if ((i + 1) % 16 == 0) - printf("\n"); - } - printf("\n"); -} - -#if DEBUG -/** - * @brief Conditional printf - * - * @param level Severity level of the message - * @param fmt Printf format string, followed by optional arguments - */ -void -uap_printf(int level, char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (level <= debug_level) { - vprintf(fmt, ap); - } - va_end(ap); -} - -/** - * @brief Dump hex data - * - * @param prompt A pointer prompt buffer - * @param p A pointer to data buffer - * @param len The len of data buffer - * @param delim Delim char - * @return None - */ -void -hexdump(char *prompt, void *p, int len, char delim) -{ - if (debug_level < MSG_ALL) - return; - hexdump_data(prompt, p, len, delim); -} -#endif - -/** - * @brief Hex to number - * - * @param c Hex value - * @return Integer value or -1 - */ -int -hex2num(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - - return -1; -} - -/** - * @brief Show usage information for the sys_info command - * - * $return N/A - */ -void -print_sys_info_usage(void) -{ - printf("\nUsage : sys_info\n"); - return; -} - -/** - * @brief Get Max sta num from firmware - * - * @return max number of stations - */ -int -get_max_sta_num_supported(t_u16 *max_sta_num_supported) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_max_sta_num *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_max_sta_num); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_max_sta_num *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_MAX_STA_CNT_TLV_ID; - tlv->length = 4; - cmd_buf->action = ACTION_GET; - - endian_convert_tlv_header_out(tlv); - tlv->max_sta_num_configured = - uap_cpu_to_le16(tlv->max_sta_num_configured); - tlv->max_sta_num_supported = - uap_cpu_to_le16(tlv->max_sta_num_supported); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->max_sta_num_configured = - uap_le16_to_cpu(tlv->max_sta_num_configured); - tlv->max_sta_num_supported = - uap_le16_to_cpu(tlv->max_sta_num_supported); - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_MAX_STA_CNT_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result != CMD_SUCCESS) { - printf("ERR:Could not get max station number!\n"); - ret = UAP_FAILURE; - } else { - if (tlv->length == 4) { - *max_sta_num_supported = - tlv->max_sta_num_supported; - } else { - *max_sta_num_supported = MAX_STA_COUNT; - } - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Parse domain name for domain_code - * - * @param dom_name Domain name - * @return domain_code / UAP_FAILURE - */ -static t_u8 -parse_domain_name(char *domain_name) -{ - t_u8 domain_code = UAP_FAILURE; - - if (strstr(domain_name, "DOMAIN_CODE_")) { - domain_name += sizeof("DOMAIN_CODE_") - 1; - - if (!(strncmp(domain_name, "FCC", sizeof("FCC") - 1))) - domain_code = DOMAIN_CODE_FCC; - else if (!(strcmp(domain_name, "ETSI"))) - domain_code = DOMAIN_CODE_ETSI; - else if (!(strcmp(domain_name, "MKK"))) - domain_code = DOMAIN_CODE_MKK; - else if (!(strcmp(domain_name, "IN"))) - domain_code = DOMAIN_CODE_IN; - else if (!(strcmp(domain_name, "MY"))) - domain_code = DOMAIN_CODE_MY; - } - return domain_code; -} - -/** - * @brief Parse domain file for country information - * - * @param country Country name - * @param band Band Info. 0x01 : B band, 0x02 : G band, 0x04 : A band. - * @param sub_bands Band information - * @param pdomain_code Pointer to receive domain_code - * @return number of band/ UAP_FAILURE - */ -t_u8 -parse_domain_file(char *country, int band, ieeetypes_subband_set_t *sub_bands, - t_u8 *pdomain_code) -{ - FILE *fp; - char str[64]; - char domain_name[64]; - int cflag = 0; - int dflag = 0; - int found = 0; - int skip = 0; - int j = -1, reset_j = 0; - t_u8 no_of_sub_band = 0; - char *strp = NULL; - int ret = 0; - - fp = fopen("config/80211d_domain.conf", "r"); - if (fp == NULL) { - printf("File opening Error\n"); - return UAP_FAILURE; - } - - /** - * Search specific domain name - */ - memset(domain_name, 0, sizeof(domain_name)); - memset(str, 0, 64); - while (!feof(fp)) { - ret = fscanf(fp, "%63s", str); - if (ret <= 0) - break; - if (cflag) { - strncpy(domain_name, str, sizeof(domain_name) - 1); - cflag = 0; - } - if (!strcmp(str, "COUNTRY:")) { - /** Store next string to domain_name */ - cflag = 1; - } - - if (!strcmp(str, country)) { - /** Country is matched ;)*/ - found = 1; - break; - } - } - - if (!found) { - printf("No match found for Country = %s in the 80211d_domain.conf \n", country); - fclose(fp); - found = 0; - return UAP_FAILURE; - } - - /** - * Search domain specific information - */ - while (!feof(fp)) { - ret = fscanf(fp, "%63s", str); - if (ret <= 0) - break; - - if (feof(fp) - ) { - break; - } - - if (dflag && !strcmp(str, "DOMAIN:")) { - - if ((band & BAND_A) == 0) - break; - - /* parse next domain */ - cflag = 0; - dflag = 0; - j = -1; - reset_j = 0; - } - if (dflag) { - j++; - if (strchr(str, ',')) - reset_j = 1; - - strp = strtok(str, ", "); - - if (strp == NULL) { - if (reset_j) { - j = -1; - reset_j = 0; - } - continue; - } else { - strncpy(str, strp, (sizeof(str) - 1)); - } - - if (IS_HEX_OR_DIGIT(str) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - fclose(fp); - return UAP_FAILURE; - } - - switch (j) { - case 0: - sub_bands[no_of_sub_band].first_chan = - (t_u8)A2HEXDECIMAL(str); - break; - case 1: - sub_bands[no_of_sub_band].no_of_chan = - (t_u8)A2HEXDECIMAL(str); - break; - case 2: - sub_bands[no_of_sub_band++].max_tx_pwr = - (t_u8)A2HEXDECIMAL(str); - break; - default: - printf("ERR: Incorrect 80211d_domain.conf file\n"); - fclose(fp); - return UAP_FAILURE; - } - - if (reset_j) { - j = -1; - reset_j = 0; - } - } - - if (cflag && !strcmp(str, domain_name)) { - /* Followed will be the band details */ - cflag = 0; - if (band & (BAND_B | BAND_G) || skip) - dflag = 1; - else - skip = 1; - } - if (!dflag && !strcmp(str, "DOMAIN:")) { - cflag = 1; - } - } - fclose(fp); - - if (pdomain_code && no_of_sub_band && (band & BAND_A)) { - *pdomain_code = parse_domain_name(domain_name); - } - return (no_of_sub_band); -} - -/** - * - * @brief Set/Get SNMP MIB - * - * @param action 0-GET 1-SET - * @param oid Oid - * @param size Size of oid value - * @param oid_buf Oid value - * @return UAP_FAILURE or UAP_SUCCESS - * - */ -int -sg_snmp_mib(t_u16 action, t_u16 oid, t_u16 size, t_u8 *oid_buf) -{ - apcmdbuf_snmp_mib *cmd_buf = NULL; - tlvbuf_header *tlv = NULL; - int ret = UAP_FAILURE; - t_u8 *buf = NULL; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - t_u16 cmd_len; - int i; - - cmd_len = sizeof(apcmdbuf_snmp_mib) + sizeof(tlvbuf_header) + size; - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return ret; - } - memset(buf, 0, buf_len); - - /* Locate Headers */ - cmd_buf = (apcmdbuf_snmp_mib *)buf; - tlv = (tlvbuf_header *)(buf + sizeof(apcmdbuf_snmp_mib)); - cmd_buf->size = buf_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->cmd_code = HostCmd_SNMP_MIB; - - tlv->type = uap_cpu_to_le16(oid); - tlv->len = uap_cpu_to_le16(size); - for (i = 0; action && (i < size); i++) { - tlv->data[i] = oid_buf[i]; - } - - cmd_buf->action = uap_cpu_to_le16(action); - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - if (!action) { - /** Relocate the headers */ - tlv = (tlvbuf_header *)((t_u8 *)cmd_buf + - sizeof - (apcmdbuf_snmp_mib)); - for (i = 0; - i < MIN(uap_le16_to_cpu(tlv->len), size); - i++) { - oid_buf[i] = tlv->data[i]; - } - } - ret = UAP_SUCCESS; - } else { - printf("ERR:Command Response incorrect!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - free(buf); - return ret; -} - -/** - * @brief Creates a sys_info request and sends to the driver - * - * Usage: "sys_info" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_info(int argc, char *argv[]) -{ - apcmdbuf_sys_info_request *cmd_buf = NULL; - apcmdbuf_sys_info_response *response_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_info_usage(); - return UAP_FAILURE; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 0) { - printf("ERR:Too many arguments.\n"); - print_sys_info_usage(); - return UAP_FAILURE; - } - - /* Alloc buf for command */ - buf = (t_u8 *)malloc(buf_len); - - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - - /* Locate headers */ - cmd_len = sizeof(apcmdbuf_sys_info_request); - cmd_buf = (apcmdbuf_sys_info_request *)buf; - response_buf = (apcmdbuf_sys_info_response *)buf; - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_INFO; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (response_buf->cmd_code != - (APCMD_SYS_INFO | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - free(buf); - return UAP_FAILURE; - } - /* Print response */ - if (response_buf->result == CMD_SUCCESS) { - printf("System information = %s\n", - response_buf->sys_info); - } else { - printf("ERR:Could not retrieve system information!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - free(buf); - return ret; -} - -/** - * @brief Show usage information for deepsleep command - * - * $return N/A - */ -void -print_deepsleep_usage(void) -{ - printf("\nUsage : deepsleep [MODE][IDLE_TIME]"); - printf("\nOptions: MODE : 0 - Disable auto deep sleep mode"); - printf("\n 1 - Enable auto deep sleep mode"); - printf("\n IDLE_TIME: Idle time in milliseconds, default value is 100 ms"); - printf("\n empty - get auto deep sleep mode\n"); - return; -} - -/** - * @brief Creates deepsleep request and send to driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_deepsleep(int argc, char *argv[]) -{ - int opt; - deep_sleep_para param; - struct ifreq ifr; - t_s32 sockfd; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_deepsleep_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if (argc > 2) { - printf("ERR:wrong arguments. Only support 2 arguments\n"); - print_deepsleep_usage(); - return UAP_FAILURE; - } - param.subcmd = UAP_DEEP_SLEEP; - if (argc) { - if (argc >= 1) { - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) || - ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 1))) { - printf("ERR: Only Number values are allowed\n"); - print_deepsleep_usage(); - return UAP_FAILURE; - } - } - param.action = 1; - param.deep_sleep = (t_u16)A2HEXDECIMAL(argv[0]); - param.idle_time = 0; - if (argc == 2) { - if (IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_deepsleep_usage(); - return UAP_FAILURE; - } - param.idle_time = (t_u16)A2HEXDECIMAL(argv[1]); - } - } else { - param.action = 0; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - if (argc) - printf("ERR: deep sleep must be disabled before changing idle time\n"); - else { - perror(""); - printf("ERR:deep sleep failed\n"); - } - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - if (param.deep_sleep == 1) { - printf("deep sleep mode: enabled\n"); - printf("idle time = %dms\n", param.idle_time); - } else { - printf("deep sleep mode: disabled\n"); - } - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Configure Band Steering - * - * Usage: band_steering_cfg state block_2g_prb_req max_btm_req_allowed - * - * State 0 or 1 - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ - -int -apcmd_band_steering(int argc, char *argv[]) -{ - int opt; - band_steer_para param; - struct ifreq ifr; - t_s32 sockfd; - t_u8 state = 0; - t_u8 block2gPrbReq = 0; - t_u8 maxBtmReqAllowed = 0; - - t_u8 i; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - printf("\nUsage: band_steering_cfg \n"); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if (!(argc == 0 || argc == 2 || argc == 4 || argc == 6)) { - printf("ERR:wrong arguments.\n"); - return UAP_FAILURE; - } - param.subcmd = UAP_BAND_STEER; - - if (argc) { - if (strcmp(argv[0], "state") && - strcmp(argv[0], "block_2g_prb_req") && - strcmp(argv[0], "max_btm_req_allowed")) { - printf("ERR: Incorrect input. Either state, block_2g_prb_req or max_btm_req_allowed is needed.\n"); - return UAP_FAILURE; - } - /** SET */ - for (i = 0; i < argc; i = i + 2) { - if (strcmp(argv[i], "state") == 0) { - param.action += ACT_SET_STATE; - if (strcmp(argv[i + 1], "0") == 0) { - state = 0; - } else if (strcmp(argv[i + 1], "1") == 0) { - state = 1; - } else { - printf("ERR: Invalid State value."); - return UAP_FAILURE; - } - } else if (strcmp(argv[i], "block_2g_prb_req") == 0) { - param.action += ACT_SET_BLOCK_2G_PRB_REQ; - block2gPrbReq = atoi(argv[i + 1]); - if (block2gPrbReq < 0 || block2gPrbReq > 15) { - printf("ERR: Invalid block_2g_prb_req value. Enter value between 0 and 15"); - return UAP_FAILURE; - } - } else if (strcmp(argv[i], "max_btm_req_allowed") == 0) { - param.action += ACT_SET_MAX_BTM_REQ_ALLOWED; - maxBtmReqAllowed = atoi(argv[i + 1]); - if (maxBtmReqAllowed <= 0 || - maxBtmReqAllowed > 255) { - printf("ERR: Invalid max_btm_req_allowed value."); - return UAP_FAILURE; - } - } else { - printf("ERR: Incorrect input. state, block_2g_prb_req and/or max_btm_req_allowed is needed in decimal format."); - return UAP_FAILURE; - } - } - } - param.state = state; - param.block_2g_prb_req = block2gPrbReq; - param.max_btm_req_allowed = maxBtmReqAllowed; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - ioctl(sockfd, UAP_IOCTL_CMD, &ifr); - - if (argc) { - printf("Set Successfull\n"); - printf("state = %d \n", param.state); - printf("block_2g_prb_req = %d\n", param.block_2g_prb_req); - printf("max_btm_req_allowed = %d\n", param.max_btm_req_allowed); - } else { - printf("Get Successfull\n"); - if (param.state == 1) { - printf("band steering mode: enabled\n"); - printf("block_2g_prb_req = %d\n", - param.block_2g_prb_req); - printf("max_btm_req_allowed = %d\n", - param.max_btm_req_allowed); - } else { - printf("band steering: disabled\n"); - } - - close(sockfd); - return UAP_FAILURE; - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for tx_data_pause command - * - * $return N/A - */ -void -print_txdatapause_usage(void) -{ - printf("\nUsage : tx_data_pause [ENABLE][TX_BUF_CNT]"); - printf("\nOptions: ENABLE : 0 - Disable Tx data pause events"); - printf("\n 1 - Enable Tx data pause events"); - printf("\n TX_BUF_CNT: Max number of TX buffer for PS clients"); - printf("\n empty - get Tx data pause settings\n"); - return; -} - -/** - * @brief Set/get txpause setting - * - * @param txpause A pointer to the Tx data pause parameters structure - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -send_txpause_ioctl(tx_data_pause_para *txpause) -{ - struct ifreq ifr; - t_s32 sockfd; - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)txpause; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR:txpause is not supported by %s\n", dev_name); - close(sockfd); - return UAP_FAILURE; - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Creates tx_data_pause request and sends to driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_txdatapause(int argc, char *argv[]) -{ - int opt; - tx_data_pause_para param; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_txdatapause_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if (argc > 2) { - printf("ERR: Wrong number of arguments\n"); - print_txdatapause_usage(); - return UAP_FAILURE; - } - param.subcmd = UAP_TX_DATA_PAUSE; - if (argc) { - if (argc >= 1) { - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) || - ((atoi(argv[0]) < TX_DATA_PAUSE_DISABLE) || - (atoi(argv[0]) > TX_DATA_PAUSE_ENABLE))) { - printf("ERR: First argument can either be 0 or 1\n"); - print_txdatapause_usage(); - return UAP_FAILURE; - } - } - if (argc == 1) { - param.action = ACTION_GET; - if (UAP_FAILURE == send_txpause_ioctl(¶m)) { - return UAP_FAILURE; - } - } - param.action = ACTION_SET; - param.txpause = (t_u16)A2HEXDECIMAL(argv[0]); - if (argc == 2) { - if (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) { - printf("ERR: Max buffer length must be numeric\n"); - print_txdatapause_usage(); - return UAP_FAILURE; - } - param.txbufcnt = (t_u16)A2HEXDECIMAL(argv[1]); - } - } else { - param.action = ACTION_GET; - } - if (UAP_FAILURE == send_txpause_ioctl(¶m)) - return UAP_FAILURE; - if ((argc == 2) && ((t_u16)A2HEXDECIMAL(argv[1]) != param.txbufcnt)) { - printf("Max number of TX buffer allowed for all PS client: %d\n", param.txbufcnt); - return UAP_FAILURE; - } - if (!argc) { - printf("Tx data pause: %s\n", - (param.txpause == 1) ? "enabled" : "disabled"); - printf("Max number of TX buffer allowed for all PS client: %d\n", param.txbufcnt); - } - return UAP_SUCCESS; -} - -/** - * @brief Process host_cmd - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return N/A - */ -int -apcmd_hostcmd(int argc, char *argv[]) -{ - apcmdbuf *hdr; - t_u8 *buffer = NULL; - int ret = UAP_SUCCESS; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - char cmdname[256]; - - if (argc <= 2) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./uaputl hostcmd \n"); - return UAP_FAILURE; - } - - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - - memset(buffer, 0, buf_len); - sprintf(cmdname, "%s", argv[2]); - ret = prepare_host_cmd_buffer(argv[1], cmdname, buffer); - if (ret == UAP_FAILURE) - goto _exit_; - - /* Locate headers */ - hdr = (apcmdbuf *)buffer; - cmd_len = hdr->size + BUF_HEADER_SIZE; - - /* Send the command */ - ret = uap_ioctl((t_u8 *)buffer, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - hdr->cmd_code &= HostCmd_CMD_ID_MASK; - if (!hdr->result) { - printf("UAPHOSTCMD: CmdCode=%#04x, Size=%#04x, SeqNum=%#04x, Result=%#04x\n", hdr->cmd_code, hdr->size, hdr->seq_num, hdr->result); - hexdump_data("payload", - (void *)(buffer + APCMDHEADERLEN), - hdr->size - (APCMDHEADERLEN - - BUF_HEADER_SIZE), ' '); - } else - printf("UAPHOSTCMD failed: CmdCode=%#04x, Size=%#04x, SeqNum=%#04x, Result=%#04x\n", hdr->cmd_code, hdr->size, hdr->seq_num, hdr->result); - } else - printf("ERR:Command sending failed!\n"); - -_exit_: - if (buffer) - free(buffer); - return ret; -} - -#ifdef SDIO -/** - * @brief Show usage information for cmd52rw command - * - * $return N/A - */ -void -print_cmd52rw_usage(void) -{ - printf("\nUsage : sdcmd52rw

[data]"); - printf("\nOptions: FN no : SDIO function number."); - printf("\n address: SDIO address"); - printf("\n data: data for SDIO write operation."); - printf("\n Read is performed if data is not provided."); - return; -} - -/** - * @brief Process cmd52 read/write handler - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return N/A - */ -int -apcmd_cmd52_readwrite(int argc, char *argv[]) -{ - int opt; - sdcmd52_para param; - struct ifreq ifr; - t_s32 sockfd; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_cmd52rw_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(sdcmd52_para)); - /* Check arguments */ - if (argc < 2 || argc > 3) { - printf("ERR:wrong arguments.\n"); - print_cmd52rw_usage(); - return UAP_FAILURE; - } - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) || - (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE)) { - printf("ERR: Only Number values are allowed\n"); - print_cmd52rw_usage(); - return UAP_FAILURE; - } - param.cmd52_params[0] = (t_u8)A2HEXDECIMAL(argv[0]); - if (param.cmd52_params[0] > 7) { - printf("ERR: Invalid function number!\n"); - return UAP_FAILURE; - } - param.cmd52_params[1] = (t_u8)A2HEXDECIMAL(argv[1]); - param.action = 0; - if (argc == 3) { - if (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - print_cmd52rw_usage(); - return UAP_FAILURE; - } - param.cmd52_params[2] = (t_u8)A2HEXDECIMAL(argv[2]); - param.action = 1; - } - param.subcmd = UAP_SDCMD52_RW; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR:cmd52rw failed\n"); - close(sockfd); - return UAP_FAILURE; - } - if (argc == 2) - printf("Cmd52 read done. "); - else - printf("Cmd52 write done. "); - printf("func=%d, reg=%d, data=0x%02X\n", - param.cmd52_params[0], param.cmd52_params[1], - param.cmd52_params[2]); - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} -#endif - -/** - * @brief Show usage information for addbapara command - * - * $return N/A - */ -void -print_addbapara_usage(void) -{ - printf("\nUsage : addbapara [timeout txwinsize rxwinsize]"); - printf("\nOptions: timeout : 0 - Disable"); - printf("\n 1 - 65535 : Block Ack Timeout in TU"); - printf("\n txwinsize: Buffer size for ADDBA request"); - printf("\n rxwinsize: Buffer size for ADDBA response"); - printf("\n txamsdu: amsdu for ADDBA request"); - printf("\n rxamsdu: amsdu for ADDBA response"); - printf("\n empty - get ADDBA parameters\n"); - return; -} - -/** - * @brief Creates addbaparam request and send to driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_addbapara(int argc, char *argv[]) -{ - int opt; - addba_param param; - struct ifreq ifr; - t_s32 sockfd; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_addbapara_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if ((argc != 0) && (argc != 5)) { - printf("ERR:wrong arguments. Only support 0 or 5 arguments\n"); - print_addbapara_usage(); - return UAP_FAILURE; - } - param.subcmd = UAP_ADDBA_PARA; - if (argc) { - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) - || (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) - || (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE) - || (IS_HEX_OR_DIGIT(argv[3]) == UAP_FAILURE) - || (IS_HEX_OR_DIGIT(argv[4]) == UAP_FAILURE) - ) { - printf("ERR: Only Number values are allowed\n"); - print_addbapara_usage(); - return UAP_FAILURE; - } - param.action = 1; - param.timeout = (t_u32)A2HEXDECIMAL(argv[0]); - if (param.timeout > DEFAULT_BLOCK_ACK_TIMEOUT) { - printf("ERR: Block Ack timeout should be in range [1-65535]\n"); - print_addbapara_usage(); - return UAP_FAILURE; - } - param.txwinsize = (t_u32)A2HEXDECIMAL(argv[1]); - param.rxwinsize = (t_u32)A2HEXDECIMAL(argv[2]); - if (param.txwinsize > MAX_TXRX_WINDOW_SIZE || - param.rxwinsize > MAX_TXRX_WINDOW_SIZE) { - printf("ERR: Tx/Rx window size should not be greater than 1023\n"); - print_addbapara_usage(); - return UAP_FAILURE; - } - param.txamsdu = (t_u8)A2HEXDECIMAL(argv[3]); - param.rxamsdu = (t_u8)A2HEXDECIMAL(argv[4]); - if (param.txamsdu > 1 || param.rxamsdu > 1) { - printf("ERR: Tx/Rx amsdu should not be 0 or 1\n"); - print_addbapara_usage(); - return UAP_FAILURE; - } - } else { - param.action = 0; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR:ADDBA PARA failed\n"); - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - printf("ADDBA parameters:\n"); - printf("\ttimeout=%d\n", (int)param.timeout); - printf("\ttxwinsize=%d\n", (int)param.txwinsize); - printf("\trxwinsize=%d\n", (int)param.rxwinsize); - printf("\ttxamsdu=%d\n", (int)param.txamsdu); - printf("\trxamsdu=%d\n", (int)param.rxamsdu); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for aggrpriotbl command - * - * $return N/A - */ -void -print_aggrpriotbl_usage(void) -{ - printf("\nUsage : aggrpriotbl ... "); - printf("\nOptions: : 0 - 7, 0xff to disable AMPDU aggregation."); - printf("\n : 0 - 7, 0xff to disable AMSDU aggregation."); - printf("\n empty - get the priority table\n"); - return; -} - -/** - * @brief Creates aggrpriotbl request and send to driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_aggrpriotbl(int argc, char *argv[]) -{ - int opt; - aggr_prio_tbl prio_tbl; - struct ifreq ifr; - t_s32 sockfd; - t_u8 value; - int i; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_aggrpriotbl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(&prio_tbl, 0, sizeof(prio_tbl)); - /* Check arguments */ - if ((argc != 0) && (argc != 16)) { - printf("ERR:wrong arguments. Only support 0 or 16 arguments\n"); - print_aggrpriotbl_usage(); - return UAP_FAILURE; - } - prio_tbl.subcmd = UAP_AGGR_PRIOTBL; - if (argc) { - for (i = 0; i < argc; i++) { - if ((IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE)) { - printf("ERR: Only Number values are allowed\n"); - print_aggrpriotbl_usage(); - return UAP_FAILURE; - } - value = (t_u8)A2HEXDECIMAL(argv[i]); - if ((value > 7) && (value != 0xff)) { - printf("ERR: Invalid priority, Valid value 0-7, 0xff to disable aggregation.\n"); - print_aggrpriotbl_usage(); - return UAP_FAILURE; - } - } - prio_tbl.action = 1; - for (i = 0; i < MAX_NUM_TID; i++) { - prio_tbl.ampdu[i] = (t_u8)A2HEXDECIMAL(argv[i * 2]); - prio_tbl.amsdu[i] = (t_u8)A2HEXDECIMAL(argv[i * 2 + 1]); - } - } else { - prio_tbl.action = 0; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&prio_tbl; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: priority table failed\n"); - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - printf("AMPDU/AMSDU priority table:"); - for (i = 0; i < MAX_NUM_TID; i++) { - printf(" %d %d", prio_tbl.ampdu[i], prio_tbl.amsdu[i]); - } - printf("\n"); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for addbareject command - * - * $return N/A - */ -void -print_addba_reject_usage(void) -{ - printf("\nUsage : addbareject ... "); - printf("\nOptions: : 1 enables rejection of ADDBA request for TidX."); - printf("\n 0 would accept any ADDBAs for TidX."); - printf("\n empty - get the addbareject table\n"); - return; -} - -/** - * @brief Creates addbareject request and send to driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_addbareject(int argc, char *argv[]) -{ - int opt; - addba_reject_para param; - struct ifreq ifr; - t_s32 sockfd; - int i; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_addba_reject_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if ((argc != 0) && (argc != 8)) { - printf("ERR:wrong arguments. Only support 0 or 8 arguments\n"); - print_addba_reject_usage(); - return UAP_FAILURE; - } - param.subcmd = UAP_ADDBA_REJECT; - if (argc) { - for (i = 0; i < argc; i++) { - if ((ISDIGIT(argv[i]) == UAP_FAILURE) || - (atoi(argv[i]) < 0) || (atoi(argv[i]) > 1)) { - printf("ERR: Only allow 0 or 1\n"); - print_addba_reject_usage(); - return UAP_FAILURE; - } - } - param.action = 1; - for (i = 0; i < MAX_NUM_TID; i++) { - param.addba_reject[i] = (t_u8)atoi(argv[i]); - } - } else { - param.action = 0; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: addba reject table failed\n"); - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - printf("addba reject table: "); - for (i = 0; i < MAX_NUM_TID; i++) { - printf("%d ", param.addba_reject[i]); - } - printf("\n"); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Creates get_fw_info request and send to driver - * - * - * @param pfw_info Pointer to FW information structure - * @return 0--success, otherwise fail - */ -int -get_fw_info(fw_info *pfw_info) -{ - struct ifreq ifr; - t_s32 sockfd; - - memset(pfw_info, 0, sizeof(fw_info)); - pfw_info->subcmd = UAP_FW_INFO; - pfw_info->action = 0; - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return -1; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)pfw_info; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: get fw info failed\n"); - close(sockfd); - return -1; - } - /* Close socket */ - close(sockfd); - return 0; -} - -/** - * @brief Show usage information for HT Tx command - * - * $return N/A - */ -void -print_ht_tx_usage(void) -{ - printf("\nUsage : httxcfg []"); - printf("\nOptions: txcfg : This is a bitmap and should be used as following"); - printf("\n Bit 15-7: Reserved set to 0"); - printf("\n Bit 6: Short GI in 40 Mhz enable/disable"); - printf("\n Bit 5: Short GI in 20 Mhz enable/disable"); - printf("\n Bit 4: Green field enable/disable"); - printf("\n Bit 3-2: Reserved set to 0"); - printf("\n Bit 1: 20/40 Mhz enable disable."); - printf("\n Bit 0: Reserved set to 0"); - return; -} - -/** - * @brief Process HT Tx configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -apcmd_sys_cfg_ht_tx(int argc, char *argv[]) -{ - int opt; - ht_tx_cfg_para param; - struct ifreq ifr; - t_s32 sockfd; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_ht_tx_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if (argc == 0) { - param.action = ACTION_GET; - } else if (argc == 1) { - param.action = ACTION_SET; - param.tx_cfg.httxcap = (t_u16)A2HEXDECIMAL(argv[0]); - } else { - print_ht_tx_usage(); - return UAP_FAILURE; - } - param.subcmd = UAP_HT_TX_CFG; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: HT Tx configuration failed\n"); - close(sockfd); - return UAP_FAILURE; - } - - /* Handle response */ - if (param.action == ACTION_GET) { - printf("HT Tx cfg: 0x%08x\n", param.tx_cfg.httxcap); - } - - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for vhtcfg command - * - * $return N/A - */ -void -print_vht_usage(void) -{ - printf("\nUsage : vhtcfg " - ""); - printf("\nOption: band : This is the band info for vhtcfg settings."); - printf("\n 0: Settings for both 2.4G and 5G bands"); - printf("\n 1: Settings for 2.4G band"); - printf("\n 2: Settings for 5G band"); - printf("\n txrx : This parameter specifies the configuration of VHT" "operation for TX or/and VHT capabilities."); - printf("\n 1: configuration of VHT capabilities tx"); - printf("\n 2: configuration of VHT capabilities rx"); - printf("\n bwcfg : This parameter specifies the bandwidth (BW)" - "configuration applied to the vhtcfg."); - printf("\n If is 1/3 (Tx operations)"); - printf("\n 0: Tx BW follows the BW (20/40 MHz) from" "11N CFG"); - printf("\n 1: Tx BW follows the BW (80/160/80+80 MHz)" "from VHT Capabilities."); - printf("\n vhtcap : This parameter specifies the VHT capabilities info."); - printf("\n tx_mcs_map : This parameter specifies the TX MCS map."); - printf("\n rx_mcs_map : This parameter specifies the RX MCS map.\n"); - return; -} - -/** - * @brief Handle response of the vhtcfg command - * - * @param vhtcfg Pointer to structure eth_priv_vhtcfg - * - * $return N/A - */ -void -print_vht_response(struct eth_priv_vhtcfg *vhtcfg) -{ - /* GET operation */ - /* Band */ - if (vhtcfg->band == BAND_SELECT_BG) - printf("Band: 2.4G\n"); - else - printf("Band: 5G\n"); - /* BW confi9 */ - if (vhtcfg->txrx & 0x3) { - if (vhtcfg->bwcfg == 0) - printf(" BW config: the 11N config\n"); - else - printf(" BW config: the VHT Capabilities\n"); - } - /* Tx/Rx */ - if (vhtcfg->txrx & 0x1) - printf(" VHT operation for Tx: 0x%08x\n", - vhtcfg->vht_cap_info); - if (vhtcfg->txrx & 0x2) - /* VHT capabilities */ - printf(" VHT Capabilities Info: 0x%08x\n", - vhtcfg->vht_cap_info); - /* MCS */ - printf(" Tx MCS set: 0x%04x\n", vhtcfg->vht_tx_mcs); - printf(" Rx MCS set: 0x%04x\n", vhtcfg->vht_rx_mcs); -} - -/** - * @brief Set/Get 11AC configurations - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -apcmd_sys_cfg_vht(int argc, char *argv[]) -{ - int opt, i = 0; - vht_cfg_para param; - struct eth_priv_vhtcfg vhtcfg; - struct ifreq ifr; - t_s32 sockfd; - t_u8 *respbuf = NULL, num = 0; - fw_info fw; - if (0 == get_fw_info(&fw)) { - /*check whether support 802.11AC through BAND_AAC bit */ - if (!(fw.fw_bands & BAND_AAC)) { - printf("ERR: No support 802 11AC.\n"); - return UAP_FAILURE; - } - } else { - printf("ERR: get_fw_info fail\n"); - return UAP_FAILURE; - } - - memset(¶m, 0, sizeof(param)); - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_vht_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - respbuf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!respbuf) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(respbuf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - /* Check arguments */ - if ((argc > 6) || (argc < 2)) { - printf("ERR: Invalid number of arguments.\n"); - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } - if ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 2)) { - printf("ERR: Invalid band selection.\n"); - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } else { - param.vht_cfg.band = (t_u32)A2HEXDECIMAL(argv[0]); - } - if ((atoi(argv[1]) <= 0) || (atoi(argv[1]) > 3)) { - printf("ERR: Invalid Tx/Rx selection.\n"); - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } else { - param.vht_cfg.txrx = (t_u32)A2HEXDECIMAL(argv[1]); - } - if (argc == 2) { - param.action = ACTION_GET; - } else if (argc > 2) { - param.vht_cfg.band = (t_u32)A2HEXDECIMAL(argv[0]); - param.vht_cfg.txrx = (t_u32)A2HEXDECIMAL(argv[1]); - if (argc == 3) { - printf("ERR: Invalid number of arguments.\n"); - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } - if (argc >= 4) { - if ((atoi(argv[2]) < 0) || (atoi(argv[2]) > 1) || - ((atoi(argv[2]) == 1) && - (atoi(argv[0]) & BAND_SELECT_BG))) { - printf("ERR: Invalid BW cfg selection.\n"); - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } else { - param.vht_cfg.bwcfg = - (t_u32)A2HEXDECIMAL(argv[2]); - } - param.vht_cfg.vht_cap_info = - (t_u32)A2HEXDECIMAL(argv[3]); - if (argc == 4) { - param.vht_cfg.vht_tx_mcs = 0xffffffff; - param.vht_cfg.vht_rx_mcs = 0xffffffff; - } else { - if (argc == 5) { - printf("ERR: Invalid number of arguments.\n"); - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } - param.vht_cfg.vht_tx_mcs = - (t_u32)A2HEXDECIMAL(argv[4]); - param.vht_cfg.vht_rx_mcs = - (t_u32)A2HEXDECIMAL(argv[5]); - } - } - param.action = ACTION_SET; - } else { - print_vht_usage(); - free(respbuf); - return UAP_FAILURE; - } - param.subcmd = UAP_VHT_CFG; - memcpy(respbuf, ¶m, sizeof(vht_cfg_para)); - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - free(respbuf); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)respbuf; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: 11ac VHT configuration failed\n"); - close(sockfd); - free(respbuf); - return UAP_FAILURE; - } - - /* Handle response */ - if (param.action == ACTION_GET) { - /* Process result */ - /* the first attribute is the number of vhtcfg entries */ - num = *respbuf; - printf("11AC VHT Configuration: \n"); - for (i = 0; i < num; i++) { - memcpy(&vhtcfg, respbuf + 1 + i * sizeof(vhtcfg), - sizeof(vhtcfg)); - print_vht_response(&vhtcfg); - } - } else - printf("11AC VHT Configuration success!\n"); - - /* Close socket */ - close(sockfd); - if (respbuf) - free(respbuf); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for TX BF command - * - * $return N/A - */ -void -print_tx_bf_usage(void) -{ - printf("\nUsage : httxbfcfg [ACT_DATA]"); - printf("\nOptions: ACTION : 1 - Performs NDP Sounding for PEER"); - printf("\n 2 - TX BF interval in milliseconds"); - printf("\n 3 - Not to perform any sounding"); - printf("\n 4 - TX BF SNR Threshold for peer"); - printf("\n ACT_DATA : Specific data for the above actions"); - printf("\n For 1: PEER MAC and status"); - printf("\n For 2: TX BF interval"); - printf("\n For 3: PEER MAC"); - printf("\n For 4: PEER MAC and SNR"); - printf("\n empty - get action specific settings\n"); - return; -} - -/** - * @brief Handle response of the TX BF command - * - * @param param Pointer to structure tx_bf_cfg_para - * - * $return N/A - */ -void -print_tx_bf_response(tx_bf_cfg_para *param) -{ - int i; - trigger_sound_args *bf_sound = param->body.bf_sound; - tx_bf_peer_args *tx_bf_peer = param->body.tx_bf_peer; - snr_thr_args *bf_snr = param->body.bf_snr; - bf_periodicity_args *bf_periodicity = param->body.bf_periodicity; - bf_global_cfg_args *bf_global = ¶m->body.bf_global_cfg; - - switch (param->bf_action) { - case BF_GLOBAL_CONFIGURATION: - printf("Global BF Status :%s\n", - bf_global->bf_enbl ? "ENABLED" : "DISABLED"); - printf("Global Sounding Status :%s\n", - bf_global->sounding_enbl ? "ENABLED" : "DISABLED"); - printf("Default FB Type :%d\n", bf_global->fb_type); - printf("Default SNR Threshold :%d\n", bf_global->snr_threshold); - printf("Default Sounding Interval :%d\n", - bf_global->sounding_interval); - printf("Beamforming Mode :%d\n", bf_global->bf_mode); - break; - case TRIGGER_SOUNDING_FOR_PEER: - printf("PEER MAC = %02X:%02X:%02X:%02X:%02X:%02X, STATUS = %s\n", bf_sound->peer_mac[0], bf_sound->peer_mac[1], bf_sound->peer_mac[2], bf_sound->peer_mac[3], bf_sound->peer_mac[4], bf_sound->peer_mac[5], bf_sound->status ? "Failure" : "Success"); - break; - case SET_GET_BF_PERIODICITY: - printf("PEER MAC = %02x:%02x:%02x:%02x:%02x:%02x, Interval (ms) = %d\n", bf_periodicity->peer_mac[0], bf_periodicity->peer_mac[1], bf_periodicity->peer_mac[2], bf_periodicity->peer_mac[3], bf_periodicity->peer_mac[4], bf_periodicity->peer_mac[5], bf_periodicity->interval); - break; - case TX_BF_FOR_PEER_ENBL: - for (i = 0; i < param->no_of_peers; i++) { - printf("PEER MAC = %02x:%02x:%02x:%02x:%02x:%02x\n", - tx_bf_peer->peer_mac[0], tx_bf_peer->peer_mac[1], - tx_bf_peer->peer_mac[2], tx_bf_peer->peer_mac[3], - tx_bf_peer->peer_mac[4], - tx_bf_peer->peer_mac[5]); - printf("BF Status : %s\n", - tx_bf_peer->bf_enbl ? "ENABLED" : "DISABLED"); - printf("Sounding Status : %s\n", - tx_bf_peer-> - sounding_enbl ? "ENABLED" : "DISABLED"); - printf("FB Type : %d\n", tx_bf_peer->fb_type); - tx_bf_peer++; - } - break; - case SET_SNR_THR_PEER: - for (i = 0; i < param->no_of_peers; i++) { - printf("PEER MAC = %02x:%02x:%02x:%02x:%02x:%02x, SNR = %d\n", bf_snr->peer_mac[0], bf_snr->peer_mac[1], bf_snr->peer_mac[2], bf_snr->peer_mac[3], bf_snr->peer_mac[4], bf_snr->peer_mac[5], bf_snr->snr); - bf_snr++; - } - break; - } -} - -/** Tx BF Global conf argument index */ -#define BF_ENABLE_PARAM 1 -#define SOUND_ENABLE_PARAM 2 -#define FB_TYPE_PARAM 3 -#define SNR_THRESHOLD_PARAM 4 -#define SOUND_INTVL_PARAM 5 -#define BF_MODE_PARAM 6 -#define BF_CFG_ACT_GET 0 -#define BF_CFG_ACT_SET 1 - -/** - * @brief Creates TX BF request and send to driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_tx_bf(int argc, char *argv[]) -{ - int opt, ret = UAP_FAILURE; - tx_bf_cfg_para param; - struct ifreq ifr; - t_s32 sockfd; - t_u32 bf_action = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_tx_bf_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if (argc < 1) { - printf("ERR: wrong arguments.\n"); - print_tx_bf_usage(); - return UAP_FAILURE; - } - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) || - ((atoi(argv[0]) < BF_GLOBAL_CONFIGURATION) || - (atoi(argv[0]) > SET_SNR_THR_PEER))) { - printf("ERR: Only Number values are allowed\n"); - print_tx_bf_usage(); - return UAP_FAILURE; - } - bf_action = (t_u32)A2HEXDECIMAL(argv[0]); - param.subcmd = UAP_TX_BF_CFG; - param.bf_action = bf_action; - switch (bf_action) { - case BF_GLOBAL_CONFIGURATION: - if (argc != 1 && argc != 7) { - printf("Invalid argument for Global BF Configuration\n"); - return UAP_FAILURE; - } - if (argc == 1) { - param.bf_cmd_action = BF_CFG_ACT_GET; - param.action = ACTION_GET; - } else { - param.bf_cmd_action = BF_CFG_ACT_SET; - param.action = ACTION_SET; - param.body.bf_global_cfg.bf_enbl = - atoi(argv[BF_ENABLE_PARAM]); - param.body.bf_global_cfg.sounding_enbl = - atoi(argv[SOUND_ENABLE_PARAM]); - param.body.bf_global_cfg.fb_type = - atoi(argv[FB_TYPE_PARAM]); - param.body.bf_global_cfg.snr_threshold = - atoi(argv[SNR_THRESHOLD_PARAM]); - param.body.bf_global_cfg.sounding_interval = - atoi(argv[SOUND_INTVL_PARAM]); - param.body.bf_global_cfg.bf_mode = - atoi(argv[BF_MODE_PARAM]); - } - break; - case TRIGGER_SOUNDING_FOR_PEER: - if (argc != 2) { - printf("ERR: wrong arguments.\n"); - print_tx_bf_usage(); - return UAP_FAILURE; - } - if ((ret = - mac2raw(argv[1], - param.body.bf_sound[0].peer_mac)) != UAP_SUCCESS) { - printf("ERR: %s Address\n", - ret == UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - return UAP_FAILURE; - } - param.bf_cmd_action = BF_CFG_ACT_SET; - param.action = ACTION_SET; - break; - case SET_GET_BF_PERIODICITY: - if (argc != 2 && argc != 3) { - printf("ERR: wrong arguments.\n"); - print_tx_bf_usage(); - return UAP_FAILURE; - } - if ((ret = - mac2raw(argv[1], - param.body.bf_periodicity[0].peer_mac)) != - UAP_SUCCESS) { - printf("ERR: %s Address\n", - ret == UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - return UAP_FAILURE; - } - - if (argc == 3) { - if (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE) - return UAP_FAILURE; - param.body.bf_periodicity[0].interval = - (t_u32)A2HEXDECIMAL(argv[2]); - param.bf_cmd_action = BF_CFG_ACT_SET; - param.action = ACTION_SET; - } else { - param.bf_cmd_action = BF_CFG_ACT_GET; - param.action = ACTION_GET; - } - break; - case TX_BF_FOR_PEER_ENBL: - if (argc != 1 && argc != 5) { - printf("ERR: wrong arguments.\n"); - print_tx_bf_usage(); - return UAP_FAILURE; - } - if (argc == 1) { - param.bf_cmd_action = BF_CFG_ACT_GET; - param.action = ACTION_GET; - } else { - if ((ret = - mac2raw(argv[1], - param.body.tx_bf_peer[0].peer_mac)) != - UAP_SUCCESS) { - printf("ERR: %s Address\n", - ret == - UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - return UAP_FAILURE; - } - param.body.tx_bf_peer->bf_enbl = atoi(argv[2]); - param.body.tx_bf_peer->sounding_enbl = atoi(argv[3]); - param.body.tx_bf_peer->fb_type = atoi(argv[4]); - param.bf_cmd_action = BF_CFG_ACT_SET; - param.action = ACTION_SET; - } - break; - case SET_SNR_THR_PEER: - if (argc != 1 && argc != 3) { - printf("ERR: wrong arguments.\n"); - print_tx_bf_usage(); - return UAP_FAILURE; - } - if (argc == 1) { - param.bf_cmd_action = BF_CFG_ACT_GET; - param.action = ACTION_GET; - } else { - if ((ret = - mac2raw(argv[1], - param.body.bf_snr[0].peer_mac)) != - UAP_SUCCESS) { - printf("ERR: %s Address\n", - ret == - UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - return UAP_FAILURE; - } - if (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE) - return UAP_FAILURE; - param.body.bf_snr[0].snr = (t_u8)A2HEXDECIMAL(argv[2]); - param.bf_cmd_action = BF_CFG_ACT_SET; - param.action = ACTION_SET; - } - break; - default: - return UAP_FAILURE; - } - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: TX BF configuration failed\n"); - close(sockfd); - return UAP_FAILURE; - } - - printf("TX BF configuration successful\n"); - /* Handle response */ - if (param.action == ACTION_GET) - print_tx_bf_response(¶m); - - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for hscfg command - * - * $return N/A - */ -void -print_hscfg_usage(void) -{ - printf("\nUsage : hscfg [condition [[GPIO# [gap]]]]"); - printf("\nOptions: condition : bit 0 = 1 -- broadcast data"); - printf("\n bit 1 = 1 -- unicast data"); - printf("\n bit 2 = 1 -- mac event"); - printf("\n bit 3 = 1 -- multicast packet"); - printf("\n bit 6 = 1 -- mgmt frame received"); - printf("\n GPIO: the pin number (e.g. 0-7) of GPIO used to wakeup the host"); - printf("\n or 0xff interface (e.g. SDIO) used to wakeup the host"); - printf("\n gap: time between wakeup signal and wakeup event (in milliseconds)"); - printf("\n or 0xff for special setting when GPIO is used to wakeup host"); - printf("\n empty - get current host sleep parameters\n"); - return; -} - -/** - * @brief Creates host sleep parameter request and send to driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_hscfg(int argc, char *argv[]) -{ - int opt; - int i = 0; - ds_hs_cfg hscfg; - struct ifreq ifr; - t_s32 sockfd; - - if ((argc == 2) && strstr(argv[1], "-1")) - strcpy(argv[1], "0xffff"); - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_hscfg_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(&hscfg, 0, sizeof(hscfg)); - hscfg.subcmd = UAP_HS_CFG; - /* Check arguments */ - if (argc > 3) { - printf("ERR:wrong arguments.\n"); - print_hscfg_usage(); - return UAP_FAILURE; - } - if (argc) { - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) { - printf("ERR: Invalid argument %s\n", argv[i]); - print_hscfg_usage(); - return UAP_FAILURE; - } - } - } - - if (argc) { - hscfg.flags |= HS_CFG_FLAG_SET | HS_CFG_FLAG_CONDITION; - hscfg.conditions = (t_u32)A2HEXDECIMAL(argv[0]); - if (hscfg.conditions >= 0xffff) - hscfg.conditions = HS_CFG_CANCEL; - if ((hscfg.conditions != HS_CFG_CANCEL) && - (hscfg.conditions & ~HS_CFG_CONDITION_MASK)) { - printf("ERR:Illegal conditions 0x%x\n", - hscfg.conditions); - print_hscfg_usage(); - return UAP_FAILURE; - } - if (argc > 1) { - hscfg.flags |= HS_CFG_FLAG_GPIO; - hscfg.gpio = (t_u32)A2HEXDECIMAL(argv[1]); - if (hscfg.gpio > 255) { - printf("ERR:Illegal gpio 0x%x\n", hscfg.gpio); - print_hscfg_usage(); - return UAP_FAILURE; - } - } - if (argc > 2) { - hscfg.flags |= HS_CFG_FLAG_GAP; - hscfg.gap = (t_u32)A2HEXDECIMAL(argv[2]); - } - } else { - hscfg.flags = HS_CFG_FLAG_GET; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&hscfg; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR:UAP_HS_CFG failed\n"); - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - printf("Host sleep parameters:\n"); - printf("\tconditions=%d\n", (int)hscfg.conditions); - printf("\tGPIO=%d\n", (int)hscfg.gpio); - printf("\tgap=%d\n", (int)hscfg.gap); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for hssetpara command - * - * $return N/A - */ -void -print_hssetpara_usage(void) -{ - printf("\nUsage : hssetpara condition [[GPIO# [gap]]]"); - printf("\nOptions: condition : bit 0 = 1 -- broadcast data"); - printf("\n bit 1 = 1 -- unicast data"); - printf("\n bit 2 = 1 -- mac event"); - printf("\n bit 3 = 1 -- multicast packet"); - printf("\n bit 6 = 1 -- mgmt frame received"); - printf("\n GPIO: the pin number (e.g. 0-7) of GPIO used to wakeup the host"); - printf("\n or 0xff interface (e.g. SDIO) used to wakeup the host"); - printf("\n gap: time between wakeup signal and wakeup event (in milliseconds)"); - printf("\n or 0xff for special setting when GPIO is used to wakeup host\n"); - return; -} - -/** - * @brief Creates host sleep parameter request and send to driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_hssetpara(int argc, char *argv[]) -{ - int opt; - int i = 0; - ds_hs_cfg hscfg; - struct ifreq ifr; - t_s32 sockfd; - - if ((argc == 2) && strstr(argv[1], "-1")) - strcpy(argv[1], "0xffff"); - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_hssetpara_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(&hscfg, 0, sizeof(hscfg)); - hscfg.subcmd = UAP_HS_SET_PARA; - /* Check arguments */ - if ((argc < 1) || (argc > 3)) { - printf("ERR:wrong arguments.\n"); - print_hssetpara_usage(); - return UAP_FAILURE; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) { - printf("ERR: Invalid argument %s\n", argv[i]); - print_hssetpara_usage(); - return UAP_FAILURE; - } - } - - hscfg.flags |= HS_CFG_FLAG_SET | HS_CFG_FLAG_CONDITION; - hscfg.conditions = (t_u32)A2HEXDECIMAL(argv[0]); - if (hscfg.conditions >= 0xffff) - hscfg.conditions = HS_CFG_CANCEL; - if ((hscfg.conditions != HS_CFG_CANCEL) && - (hscfg.conditions & ~HS_CFG_CONDITION_MASK)) { - printf("ERR:Illegal conditions 0x%x\n", hscfg.conditions); - print_hssetpara_usage(); - return UAP_FAILURE; - } - if (argc > 1) { - hscfg.flags |= HS_CFG_FLAG_GPIO; - hscfg.gpio = (t_u32)A2HEXDECIMAL(argv[1]); - if (hscfg.gpio > 255) { - printf("ERR:Illegal gpio 0x%x\n", hscfg.gpio); - print_hssetpara_usage(); - return UAP_FAILURE; - } - } - if (argc > 2) { - hscfg.flags |= HS_CFG_FLAG_GAP; - hscfg.gap = (t_u32)A2HEXDECIMAL(argv[2]); - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)&hscfg; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR:UAP_HS_SET_PARA failed\n"); - close(sockfd); - return UAP_FAILURE; - } - printf("Host sleep parameters setting successful!\n"); - printf("\tconditions=%d\n", (int)hscfg.conditions); - printf("\tGPIO=%d\n", (int)hscfg.gpio); - printf("\tgap=%d\n", (int)hscfg.gap); - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief get dfs repeater mode - * - * @param mode status of DFS repeater mode is returned here - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -uap_ioctl_dfs_repeater_mode(int *mode) -{ - struct ifreq ifr; - dfs_repeater_mode param; - t_s32 sockfd; - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - param.action = ACTION_GET; - param.subcmd = UAP_DFS_REPEATER_MODE; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - printf("ERR:UAP_DFS_REPEATER_MODE is not" - "supported by %s\n", dev_name); - close(sockfd); - return UAP_FAILURE; - } - *mode = (int)param.mode; - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Get CAC timer status - * - * @param mode status of CAC timer is returned here - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -uap_ioctl_cac_timer_status(unsigned int *mode) -{ - struct ifreq ifr; - cac_timer_status param; - t_s32 sockfd; - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - param.action = ACTION_GET; - param.subcmd = UAP_CAC_TIMER_STATUS; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - printf("ERR:UAP_CAC_TIMER_STATUS is not" - "supported by %s\n", dev_name); - close(sockfd); - return UAP_FAILURE; - } - *mode = (int)param.mode; - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Set/get power mode - * - * @param pm A pointer to ps_mgmt structure - * @param flag flag for query - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -send_power_mode_ioctl(ps_mgmt * pm, int flag) -{ - struct ifreq ifr; - t_s32 sockfd; - t_u32 result = 0; - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)pm; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_POWER_MODE, &ifr)) { - memcpy((void *)&result, (void *)pm, sizeof(result)); - if (result == 1) { - printf("ERR:Power mode needs to be disabled before modifying it\n"); - } else { - perror(""); - printf("ERR:UAP_POWER_MODE is not supported by %s\n", - dev_name); - } - close(sockfd); - return UAP_FAILURE; - } - if (flag) { - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; - } - switch (pm->ps_mode) { - case 0: - printf("power mode = Disabled\n"); - break; - case 1: - printf("power mode = Periodic DTIM PS\n"); - break; - case 2: - printf("power mode = Inactivity based PS \n"); - break; - } - if (pm->flags & PS_FLAG_SLEEP_PARAM) { - printf("Sleep param:\n"); - printf("\tctrl_bitmap=%d\n", (int)pm->sleep_param.ctrl_bitmap); - printf("\tmin_sleep=%d us\n", (int)pm->sleep_param.min_sleep); - printf("\tmax_sleep=%d us\n", (int)pm->sleep_param.max_sleep); - } - if (pm->flags & PS_FLAG_INACT_SLEEP_PARAM) { - printf("Inactivity sleep param:\n"); - printf("\tinactivity_to=%d us\n", - (int)pm->inact_param.inactivity_to); - printf("\tmin_awake=%d us\n", (int)pm->inact_param.min_awake); - printf("\tmax_awake=%d us\n", (int)pm->inact_param.max_awake); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the pscfg command - * - * $return N/A - */ -void -print_pscfg_usage(void) -{ - printf("\nUsage : pscfg [MODE] [CTRL INACTTO MIN_SLEEP MAX_SLEEP MIN_AWAKE MAX_AWAKE]"); - printf("\nOptions: MODE : 0 - disable power mode"); - printf("\n 1 - periodic DTIM power save mode"); - printf("\n 2 - inactivity based power save mode"); - printf("\n PS PARAMS:"); - printf("\n CTRL: 0 - disable protection frame Tx before PS"); - printf("\n 1 - enable protection frame Tx before PS"); - printf("\n INACTTO: Inactivity timeout in miroseconds"); - printf("\n MIN_SLEEP: Minimum sleep duration in microseconds"); - printf("\n MAX_SLEEP: Maximum sleep duration in miroseconds"); - printf("\n MIN_AWAKE: Minimum awake duration in microseconds"); - printf("\n MAX_AWAKE: Maximum awake duration in microseconds"); - printf("\n MIN_AWAKE,MAX_AWAKE only valid for inactivity based power save mode"); - printf("\n empty - get current power mode\n"); - return; -} - -/** - * @brief Creates power mode request and send to driver - * and sends to the driver - * - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_pscfg(int argc, char *argv[]) -{ - int opt; - ps_mgmt pm; - int ret = UAP_SUCCESS; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_pscfg_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(&pm, 0, sizeof(ps_mgmt)); - /* Check arguments */ - if ((argc > 7) || - ((argc != 0) && (argc != 1) && (argc != 5) && (argc != 7))) { - printf("ERR:wrong arguments.\n"); - print_pscfg_usage(); - return UAP_FAILURE; - } - - if (argc) { - if (send_power_mode_ioctl(&pm, 1) == UAP_FAILURE) - return UAP_FAILURE; - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 2)) { - printf("ERR:Illegal power mode %s. Must be either '0' '1' or '2'.\n", argv[0]); - print_pscfg_usage(); - return UAP_FAILURE; - } - pm.flags = PS_FLAG_PS_MODE; - pm.ps_mode = atoi(argv[0]); - if ((pm.ps_mode == PS_MODE_DISABLE) && (argc > 1)) { - printf("ERR: Illegal parameter for disable power mode\n"); - print_pscfg_usage(); - return UAP_FAILURE; - } - if ((pm.ps_mode != PS_MODE_INACTIVITY) && (argc > 5)) { - printf("ERR:Min awake period and Max awake period are valid only for inactivity based power save mode\n"); - print_pscfg_usage(); - return UAP_FAILURE; - } - if (argc >= 5) { - if ((ISDIGIT(argv[1]) == 0) || (atoi(argv[1]) < 0) || - (atoi(argv[1]) > 1)) { - printf("ERR:Illegal ctrl bitmap = %s. Must be either '0' or '1'.\n", argv[1]); - print_pscfg_usage(); - return UAP_FAILURE; - } - pm.flags |= - PS_FLAG_SLEEP_PARAM | PS_FLAG_INACT_SLEEP_PARAM; - pm.sleep_param.ctrl_bitmap = atoi(argv[1]); - if ((ISDIGIT(argv[2]) == 0) || (ISDIGIT(argv[3]) == 0) - || (ISDIGIT(argv[4]) == 0)) { - printf("ERR:Illegal parameter\n"); - print_pscfg_usage(); - return UAP_FAILURE; - } - pm.inact_param.inactivity_to = atoi(argv[2]); - pm.sleep_param.min_sleep = atoi(argv[3]); - pm.sleep_param.max_sleep = atoi(argv[4]); - if (pm.sleep_param.min_sleep > pm.sleep_param.max_sleep) { - printf("ERR: MIN_SLEEP value should be less than or equal to MAX_SLEEP\n"); - return UAP_FAILURE; - } - if (pm.sleep_param.min_sleep < PS_SLEEP_PARAM_MIN || - ((pm.sleep_param.max_sleep > PS_SLEEP_PARAM_MAX) && - pm.sleep_param.ctrl_bitmap)) { - printf("ERR: Incorrect value of sleep period. Please check README\n"); - return UAP_FAILURE; - } - if (argc == 7) { - if ((ISDIGIT(argv[5]) == 0) || - (ISDIGIT(argv[6]) == 0)) { - printf("ERR:Illegal parameter\n"); - print_pscfg_usage(); - return UAP_FAILURE; - } - pm.inact_param.min_awake = atoi(argv[5]); - pm.inact_param.max_awake = atoi(argv[6]); - if (pm.inact_param.min_awake > - pm.inact_param.max_awake) { - printf("ERR: MIN_AWAKE value should be less than or equal to MAX_AWAKE\n"); - return UAP_FAILURE; - } - if (pm.inact_param.min_awake < - PS_AWAKE_PERIOD_MIN) { - printf("ERR: Incorrect value of MIN_AWAKE period.\n"); - return UAP_FAILURE; - } - } - } - } - ret = send_power_mode_ioctl(&pm, 0); - return ret; -} - -/** - * @brief Get bss status started/stopped - * - * @param current bss status - * @return UAP_SUCCESS/UAP_FAILURE - */ -static int -get_bss_status(int *status) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_bss_status *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_FAILURE; - - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_bss_status); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_bss_status *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_BSS_STATUS_TLV_ID; - tlv->length = 2; - cmd_buf->action = ACTION_GET; - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - tlv->bss_status = uap_le16_to_cpu(tlv->bss_status); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_BSS_STATUS_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (tlv->bss_status == 0) - *status = UAP_BSS_STOP; - else - *status = UAP_BSS_START; - } else { - printf("ERR:Could not get BSS status!\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief start/stop/reset bss - * - * @param mode bss control mode - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -send_bss_ctl_ioctl(int mode) -{ - struct ifreq ifr; - t_s32 sockfd; - t_u32 data = (t_u32)mode; - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&data; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_BSS_CTRL, &ifr)) { - printf("ERR:UAP_BSS_CTRL fail, result=%d\n", (int)data); - switch (mode) { - case UAP_BSS_START: - if (data == BSS_FAILURE_START_INVAL) - printf("ERR:Could not start BSS! Invalid BSS parameters.\n"); - else - printf("ERR:Could not start BSS!\n"); - break; - case UAP_BSS_STOP: - printf("ERR:Could not stop BSS!\n"); - break; - case UAP_BSS_RESET: - printf("ERR:Could not reset system!\n"); - break; - } - close(sockfd); - return UAP_FAILURE; - } - - switch (mode) { - case UAP_BSS_START: - printf("BSS start successful!\n"); - break; - case UAP_BSS_STOP: - printf("BSS stop successful!\n"); - break; - case UAP_BSS_RESET: - printf("System reset successful!\n"); - break; - } - - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sys_reset command - * - * $return N/A - */ -void -print_sys_reset_usage(void) -{ - printf("\nUsage : sys_reset\n"); - return; -} - -/** - * @brief Creates a sys_reset request and sends to the driver - * - * Usage: "sys_reset" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_reset(int argc, char *argv[]) -{ - int opt; - int ret = UAP_SUCCESS; - ps_mgmt pm; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_reset_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 0) { - printf("ERR:Too many arguments.\n"); - print_sys_reset_usage(); - return UAP_FAILURE; - } - memset(&pm, 0, sizeof(ps_mgmt)); - pm.flags = PS_FLAG_PS_MODE; - pm.ps_mode = PS_MODE_DISABLE; - if (send_power_mode_ioctl(&pm, 0) == UAP_FAILURE) - return UAP_FAILURE; - ret = send_bss_ctl_ioctl(UAP_BSS_RESET); - return ret; -} - -/** - * @brief Show usage information for the bss_start command - * - * $return N/A - */ -void -print_bss_start_usage(void) -{ - printf("\nUsage : bss_start\n"); - return; -} - -/** - * @brief Creates a BSS start request and sends to the driver - * - * Usage: "bss_start" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_bss_start(int argc, char *argv[]) -{ - int opt; - t_u8 *buf = NULL; - t_u16 buf_len = 0; - int status = 0; - int ret = UAP_SUCCESS; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_bss_start_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 0) { - printf("ERR:Too many arguments.\n"); - print_bss_start_usage(); - return UAP_FAILURE; - } - - if (get_bss_status(&status) != UAP_SUCCESS) { - printf("ERR:Cannot get current bss status!\n"); - return UAP_FAILURE; - } - - if (status == UAP_BSS_START) { - printf("ERR: Could not start BSS! BSS already started!\n"); - return UAP_FAILURE; - } - - /* Query BSS settings */ - - /* Alloc buf for command */ - buf_len = sizeof(apcmdbuf_bss_configure) + sizeof(bss_config_t); - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset((char *)buf, 0, buf_len); - - /* Get all parametes first */ - if (get_bss_config(buf) == UAP_FAILURE) { - printf("ERR:Reading current bss configuration\n"); - free(buf); - return UAP_FAILURE; - } - - ret = check_bss_config(buf + sizeof(apcmdbuf_bss_configure)); - - if (ret == UAP_FAILURE) { - printf("ERR: Wrong bss configuration!\n"); - goto done; - } - - ret = send_bss_ctl_ioctl(UAP_BSS_START); - -done: - if (buf) - free(buf); - return ret; -} - -/** - * @brief Show usage information for the bss_stop command - * - * $return N/A - */ -void -print_bss_stop_usage(void) -{ - printf("\nUsage : bss_stop\n"); - return; -} - -/** - * @brief Creates a BSS stop request and sends to the driver - * - * Usage: "bss_stop" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_bss_stop(int argc, char *argv[]) -{ - int opt; - int status = 0; - int ret = UAP_SUCCESS; - unsigned int cac_timer = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_bss_stop_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; /* Check arguments */ - - if (argc != 0) { - printf("ERR:Too many arguments.\n"); - print_bss_stop_usage(); - return UAP_FAILURE; - } - if (get_bss_status(&status) != UAP_SUCCESS) { - printf("ERR:Cannot get current bss status!\n"); - return UAP_FAILURE; - } - - if ((status != UAP_BSS_STOP) - || ((uap_ioctl_cac_timer_status(&cac_timer) == UAP_SUCCESS) - && (cac_timer)) - ) - ret = send_bss_ctl_ioctl(UAP_BSS_STOP); - else { - printf("ERR: Could not stop BSS! BSS already stopped!\n"); - ret = UAP_FAILURE; - } - return ret; -} - -void -print_skip_cac_usage(void) -{ - printf("\nUsage : skip_cac [MODE]"); - printf("\nOptions: MODE : 0 - Disable skip CAC mode"); - printf("\n 1 - Enable skip CAC mode"); - printf("\n empty - get skip CAC mode\n"); - return; -} - -/** - * @brief Skip CAC for next immediate BSS_START - * - * Usage: "skip_cac [1/0]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_skip_cac(int argc, char *argv[]) -{ - int opt; - skip_cac_para param; - struct ifreq ifr; - t_s32 sockfd; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_skip_cac_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(¶m, 0, sizeof(param)); - /* Check arguments */ - if (argc > 1) { - printf("ERR:wrong arguments. Only support 1 argument\n"); - print_skip_cac_usage(); - return UAP_FAILURE; - } - param.subcmd = UAP_SKIP_CAC; - if (argc) { - if (argc == 1) { - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) || - ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 1))) { - printf("ERR: Only Number values are allowed\n"); - print_skip_cac_usage(); - return UAP_FAILURE; - } - } - param.action = 1; - param.skip_cac = (t_u16)A2HEXDECIMAL(argv[0]); - } else { - param.action = 0; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - if (argc) - printf("ERR:skip_cac set failed\n"); - else { - perror(""); - printf("ERR:skip_cac get failed\n"); - } - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - if (param.skip_cac == 1) { - printf("skip CAC mode: enabled\n"); - } else { - printf("skip CAC mode: disabled\n"); - } - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sta_list command - * - * $return N/A - */ -void -print_sta_list_usage(void) -{ - printf("\nUsage : sta_list\n"); - return; -} - -/** - * @brief Creates a STA list request and sends to the driver - * - * Usage: "sta_list" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sta_list(int argc, char *argv[]) -{ - struct ifreq ifr; - t_s32 sockfd; - sta_list list; - int i = 0; - int opt; - int rssi = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sta_list_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 0) { - printf("ERR:Too many arguments.\n"); - print_sta_list_usage(); - return UAP_FAILURE; - } - memset(&list, 0, sizeof(sta_list)); - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&list; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_GET_STA_LIST, &ifr)) { - perror(""); - printf("ERR:UAP_GET_STA_LIST is not supported by %s\n", - dev_name); - close(sockfd); - return UAP_FAILURE; - } - printf("Number of STA = %d\n\n", list.sta_count); - - for (i = 0; i < list.sta_count; i++) { - printf("STA %d information:\n", i + 1); - printf("=====================\n"); - printf("MAC Address: "); - print_mac(list.info[i].mac_address); - printf("\nPower mgmt status: %s\n", - (list.info[i].power_mgmt_status == - 0) ? "active" : "power save"); - printf("Mode: %s\n", - (list.info[i].bandmode == - BAND_B) ? "11b," : (list.info[i].bandmode == - BAND_G) ? "11g," : (list.info[i]. - bandmode == - BAND_A) ? "11a," - : (list.info[i].bandmode == - BAND_GN) ? "2.4G_11n," : (list.info[i].bandmode == - BAND_AN) ? "5G_11n," - : (list.info[i].bandmode == - BAND_GAC) ? "2.4G_11ac," : (list.info[i].bandmode == - BAND_AAC) ? "5G_11ac," - : (list.info[i].bandmode == - BAND_GAX) ? "2.4G_11ax," : (list.info[i].bandmode == - BAND_AAX) ? "5G_11ax," : - "unknown"); - /** On some platform, s8 is same as unsigned char*/ - rssi = (int)list.info[i].rssi; - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("Rssi : %d dBm\n\n", rssi); - if (list.info[i].ie_len) - hexdump_data("IE", (void *)list.info[i].ie_buf, - list.info[i].ie_len, ' '); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sta_deauth command - * - * $return N/A - */ -void -print_sta_deauth_usage(void) -{ - printf("\nUsage : sta_deauth \n"); - return; -} - -/** - * @brief Creates a STA deauth request and sends to the driver - * - * Usage: "sta_deauth " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sta_deauth(int argc, char *argv[]) -{ - APCMDBUF_STA_DEAUTH *cmd_buf = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_FAILURE; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sta_deauth_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 1) { - printf("ERR:wrong arguments! Must provide STA_MAC_ADDRESS.\n"); - print_sta_deauth_usage(); - return UAP_FAILURE; - } - - /* Initialize the command length */ - cmd_len = sizeof(APCMDBUF_STA_DEAUTH); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (APCMDBUF_STA_DEAUTH *)buffer; - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_STA_DEAUTH; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - if ((ret = mac2raw(argv[0], cmd_buf->sta_mac_address)) != UAP_SUCCESS) { - printf("ERR: %s Address\n", ret == UAP_FAILURE ? "Invalid MAC" : - ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast"); - free(buffer); - return UAP_FAILURE; - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != (APCMD_STA_DEAUTH | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - free(buffer); - return UAP_FAILURE; - } - - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("Deauthentication successful!\n"); - } else { - printf("ERR:Deauthentication unsuccessful!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Show usage information for the sta_deauth_ext command - * - * $return N/A - */ -void -print_sta_deauth_ext_usage(void) -{ - printf("\nUsage : sta_deauth \n"); - return; -} - -/** - * @brief Creates a STA deauth request and sends to the driver - * - * Usage: "sta_deauth " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sta_deauth_ext(int argc, char *argv[]) -{ - int ret = UAP_SUCCESS; - int opt; - deauth_param param; - struct ifreq ifr; - t_s32 sockfd; - t_u32 result = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sta_deauth_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 2) { - printf("ERR:wrong arguments! Must provide STA_MAC_ADDRESS, REASON_CODE.\n"); - print_sta_deauth_ext_usage(); - return UAP_FAILURE; - } - memset(¶m, 0, sizeof(deauth_param)); - - if ((ret = mac2raw(argv[0], param.mac_addr)) != UAP_SUCCESS) { - printf("ERR: %s Address\n", ret == UAP_FAILURE ? "Invalid MAC" : - ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast"); - return UAP_FAILURE; - } - - if ((IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) || - (atoi(argv[1]) > MAX_DEAUTH_REASON_CODE)) { - printf("ERR: Invalid input for reason code\n"); - return UAP_FAILURE; - } - param.reason_code = (t_u16)A2HEXDECIMAL(argv[1]); - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_STA_DEAUTH, &ifr)) { - memcpy((void *)&result, (void *)¶m, sizeof(result)); - if (result == 1) - printf("ERR:UAP_STA_DEAUTH fail\n"); - else - perror(""); - close(sockfd); - return UAP_FAILURE; - } - printf("Station deauth successful\n"); - /* Close socket */ - close(sockfd); - return ret; -} - -/** - * @brief Show usage information for the radioctrl command - * - * $return N/A - */ -void -print_radio_ctl_usage(void) -{ - printf("\nUsage : radioctrl [ 0 | 1 ]\n"); - return; -} - -/** - * @brief Creates a Radio control request and sends to the driver - * - * Usage: "radioctrl [0 | 1]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_radio_ctl(int argc, char *argv[]) -{ - int opt; - int param[2] = { 0, 0 }; /* action (Set/Get), Control (ON/OFF) */ - struct ifreq ifr; - t_s32 sockfd; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_radio_ctl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:wrong arguments! Only 1 or 0 arguments are supported.\n"); - print_radio_ctl_usage(); - return UAP_FAILURE; - } - if (argc && (is_input_valid(RADIOCONTROL, argc, argv) != UAP_SUCCESS)) { - print_radio_ctl_usage(); - return UAP_FAILURE; - } - if (argc) { - param[0] = ACTION_SET; - param[1] = atoi(argv[0]); - } - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)param; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_RADIO_CTL, &ifr)) { - printf("ERR:UAP_RADIO_CTL fail\n"); - close(sockfd); - return UAP_FAILURE; - } - if (argc) - printf("Radio setting successful\n"); - else - printf("Radio is %s.\n", (param[1]) ? "on" : "off"); - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the txratecfg command - * - * $return N/A - */ -void -print_txratecfg_usage(void) -{ - printf("\nUsage : txratecfg Index should be one of the following.\n"); - printf("\n [l] is "); - printf("\n - This parameter specifies the data rate format used in this command"); - printf("\n 0: LG"); - printf("\n 1: HT"); - printf("\n 2: VHT"); - printf("\n 3: HE"); - printf("\n 0xff: Auto"); - printf("\n"); - printf("\n [m] is "); - printf("\n - This parameter specifies the rate or MCS index"); - printf("\n If is 0 (LG),"); - printf("\n 0 1 Mbps"); - printf("\n 1 2 Mbps"); - printf("\n 2 5.5 Mbps"); - printf("\n 3 11 Mbps"); - printf("\n 4 6 Mbps"); - printf("\n 5 9 Mbps"); - printf("\n 6 12 Mbps"); - printf("\n 7 18 Mbps"); - printf("\n 8 24 Mbps"); - printf("\n 9 36 Mbps"); - printf("\n 10 48 Mbps"); - printf("\n 11 54 Mbps"); - printf("\n If is 1 (HT), "); - printf("\n 0 MCS0"); - printf("\n 1 MCS1"); - printf("\n 2 MCS2"); - printf("\n 3 MCS3"); - printf("\n 4 MCS4"); - printf("\n 5 MCS5"); - printf("\n 6 MCS6"); - printf("\n 7 MCS7"); - printf("\n 8 MCS8"); - printf("\n 9 MCS9"); - printf("\n 10 MCS10"); - printf("\n 11 MCS11"); - printf("\n 12 MCS12"); - printf("\n 13 MCS13"); - printf("\n 14 MCS14"); - printf("\n 15 MCS15"); - printf("\n 32 MCS32"); - printf("\n If is 2 (VHT), "); - printf("\n 0 MCS0"); - printf("\n 1 MCS1"); - printf("\n 2 MCS2"); - printf("\n 3 MCS3"); - printf("\n 4 MCS4"); - printf("\n 5 MCS5"); - printf("\n 6 MCS6"); - printf("\n 7 MCS7"); - printf("\n 8 MCS8"); - printf("\n 9 MCS9"); - printf("\n [n] is "); - printf("\n - This parameter specifies the NSS. It is valid only for VHT"); - printf("\n If is 2 (VHT), "); - printf("\n 1 NSS1"); - printf("\n 2 NSS2"); - printf("\n If is 3 (HE), "); - printf("\n 0 MCS0"); - printf("\n 1 MCS1"); - printf("\n 2 MCS2"); - printf("\n 3 MCS3"); - printf("\n 4 MCS4"); - printf("\n 5 MCS5"); - printf("\n 6 MCS6"); - printf("\n 7 MCS7"); - printf("\n 8 MCS8"); - printf("\n 9 MCS9"); - printf("\n 10 MCS10"); - printf("\n 11 MCS11"); - printf("\n [n] is "); - printf("\n - This parameter specifies the NSS. It is valid only for HE"); - printf("\n If is 3 (HE), "); - printf("\n 1 NSS1"); - printf("\n 2 NSS2"); - printf("\n"); - return; -} - -/** - * @brief Creates a Tx Rate Config get request and sends to the driver - * @param rate_config Tx rate config struct - * @return UAP_SUCCESS/UAP_FAILURE - */ -static int -get_tx_rate_cfg(tx_rate_cfg_t *rate_config) -{ - struct ifreq ifr; - t_s32 sockfd; - int ret = UAP_SUCCESS; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(rate_config, 0, sizeof(tx_rate_cfg_t)); - rate_config->subcmd = UAP_TX_RATE_CFG; - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)rate_config; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - printf("ERR:UAP_IOCTL_CMD fail\n"); - close(sockfd); - return UAP_FAILURE; - } - /* Close socket */ - close(sockfd); - return ret; -} - -static char *rate_format[4] = { "LG", "HT", "VHT", "HE" }; - -static char *lg_rate[] = { "1 Mbps", "2 Mbps", "5.5 Mbps", "11 Mbps", - "6 Mbps", "9 Mbps", "12 Mbps", "18 Mbps", - "24 Mbps", "36 Mbps", "48 Mbps", "54 Mbps" -}; - -/** - * @brief Creates a Tx Rate Config request and sends to the driver - * - * Usage: "txratecfg " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_tx_rate_cfg(int argc, char *argv[]) -{ - int opt; - int status = 0; - tx_rate_cfg_t tx_rate_config; - struct ifreq ifr; - t_s32 sockfd; - HTCap_t htcap; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_txratecfg_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 3) { - printf("ERR:wrong arguments! Only 0~3 arguments are supported.\n"); - print_txratecfg_usage(); - return UAP_FAILURE; - } - if (argc && (is_input_valid(TXRATECFG, argc, argv) != UAP_SUCCESS)) { - print_txratecfg_usage(); - return UAP_FAILURE; - } - memset(&tx_rate_config, 0, sizeof(tx_rate_cfg_t)); - tx_rate_config.subcmd = UAP_TX_RATE_CFG; - if (argc) { - tx_rate_config.action = ACTION_SET; - tx_rate_config.rate_format = A2HEXDECIMAL(argv[0]); - if (argc >= 2) - tx_rate_config.rate = A2HEXDECIMAL(argv[1]); - if (argc >= 3) - tx_rate_config.nss = A2HEXDECIMAL(argv[2]); - if (argc == 4) - tx_rate_config.rate_setting = A2HEXDECIMAL(argv[3]); - tx_rate_config.user_data_cnt = argc; - /* If bss is already started and uAP is in (short GI in 20 MHz + GF) mode, block MCS0-MCS7 rates */ - if (get_bss_status(&status) != UAP_SUCCESS) { - printf("ERR:Cannot get current bss status!\n"); - return UAP_FAILURE; - } - if (UAP_SUCCESS == get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0] && - (status == UAP_BSS_START)) { - if (((tx_rate_config.rate >= 0) && - (tx_rate_config.rate <= 7)) - && - (IS_11N_20MHZ_SHORTGI_ENABLED - (htcap.ht_cap_info) && - IS_11N_GF_ENABLED(htcap.ht_cap_info))) { - printf("ERR: Invalid rate for bss in (20MHz Short GI + Green Field) mode\n"); - return UAP_FAILURE; - } - if ((tx_rate_config.rate == 32) && - (!(IS_11N_40MHZ_ENABLED - (htcap.ht_cap_info)))) { - printf("ERR:uAP must be configured to operate in 40MHz if tx_rate is MCS32\n"); - return UAP_FAILURE; - } - } - } - } - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)&tx_rate_config; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - printf("ERR:UAP_IOCTL_CMD fail\n"); - close(sockfd); - return UAP_FAILURE; - } - if (argc) { - printf("Transmit Rate setting successful\n"); - } else { - /* GET operation */ - printf("Tx Rate Configuration: \n"); - /* format */ - if (tx_rate_config.rate_format == 0xFF) { - printf(" Type: 0xFF (Auto)\n"); - } else if (tx_rate_config.rate_format <= 3) { - printf(" Type: %d (%s)\n", - tx_rate_config.rate_format, - rate_format[tx_rate_config.rate_format]); - if (tx_rate_config.rate_format == 0) - printf(" Rate Index: %d (%s)\n", - tx_rate_config.rate, - lg_rate[tx_rate_config.rate]); - else if (tx_rate_config.rate_format >= 1) - printf(" MCS Index: %d\n", - (int)tx_rate_config.rate); - if (tx_rate_config.rate_format == 2 || - tx_rate_config.rate_format == 3) - printf(" NSS: %d\n", - (int)tx_rate_config.nss); - if (tx_rate_config.rate_setting == 0xffff) - printf("Rate setting :Preamble type/BW/GI/STBC/.. : auto \n"); - else { - printf("Preamble type: %x\n", - (tx_rate_config.rate_setting & 0x0003)); - printf("BW: %x\n", - (tx_rate_config. - rate_setting & 0x001C) >> 2); - printf("LTF + GI size %x\n", - (tx_rate_config. - rate_setting & 0x0060) >> 5); - printf("STBC %x\n", - (tx_rate_config. - rate_setting & 0x0080) >> 7); - printf("DCM %x\n", - (tx_rate_config. - rate_setting & 0x0100) >> 8); - printf("Coding %x\n", - (tx_rate_config. - rate_setting & 0x0200) >> 9); - printf("maxPE %x\n", - (tx_rate_config. - rate_setting & 0x3000) >> 12); - } - } else { - printf(" Unknown rate format.\n"); - } - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the antcfg - * command - * - * $return N/A - */ -void -print_antcfg_usage(void) -{ - printf("\nUsage : antcfg [ ]\n"); - printf("\n MODE : 1 - Antenna A"); - printf("\n 2 - Antenna B"); - printf("\n 3 - Antenna A+B"); - printf("\n empty - Get current antenna settings\n"); - return; -} - -/** - * @brief Creates a RF Antenna Mode Config request and sends to the driver - * - * Usage: "antcfg [MODE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_antcfg(int argc, char *argv[]) -{ - int opt; - int tx_val = 0; - int rx_val = 0; - ant_cfg_t antenna_config; - struct ifreq ifr; - t_s32 sockfd; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_antcfg_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 2) { - printf("ERR:wrong arguments!\n"); - print_antcfg_usage(); - return UAP_FAILURE; - } - if (argc) { - sscanf(argv[0], "%x", (unsigned int *)&tx_val); - if (tx_val < 1 || tx_val > 0x303) { - printf("ERR:Illegal ANTENNA parameter %s. Must be either '1', '2' or '3'.\n", argv[0]); - print_antcfg_usage(); - return UAP_FAILURE; - } - if (argc == 2) { - sscanf(argv[1], "%x", (unsigned int *)&rx_val); - if (rx_val < 1 || rx_val > 0x303) { - printf("ERR:Illegal RX ANTENNA parameter %s. Must be either '1', '2' or '3'.\n", argv[1]); - print_antcfg_usage(); - return UAP_FAILURE; - } - } - } - memset(&antenna_config, 0, sizeof(ant_cfg_t)); - antenna_config.subcmd = UAP_ANTENNA_CFG; - if (argc) { - antenna_config.action = ACTION_SET; - if (argc == 1) { - antenna_config.tx_mode = tx_val; - antenna_config.rx_mode = tx_val; - } else { - antenna_config.tx_mode = tx_val; - antenna_config.rx_mode = rx_val; - } - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)&antenna_config; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - printf("ERR:UAP_IOCTL_CMD fail\n"); - close(sockfd); - return UAP_FAILURE; - } - if (argc) { - printf("Antenna mode setting successful\n"); - } else { - printf("TX Antenna mode is 0x%x.\n", antenna_config.tx_mode); - printf("RX Antenna mode is 0x%x.\n", antenna_config.rx_mode); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the htstreamcfg - * command - * - * $return N/A - */ -void -print_htstreamcfg_usage(void) -{ - printf("\nUsage : htstreamcfg []\n"); - printf("\n Where "); - printf("\n 0x11: HT stream 1x1 mode"); - printf("\n 0x22: HT stream 2x2 mode\n"); - return; -} - -/** - * @brief Set/get HT stream configurations - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_htstreamcfg(int argc, char *argv[]) -{ - int opt; - htstream_cfg_t htstream_cfg; - struct ifreq ifr; - t_s32 sockfd; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_htstreamcfg_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - - memset(&htstream_cfg, 0, sizeof(htstream_cfg)); - if (argc == 0) { - htstream_cfg.action = ACTION_GET; - } else if (argc == 1) { - if ((t_u32)A2HEXDECIMAL(argv[0]) != HT_STREAM_MODE_1X1 - && (t_u32)A2HEXDECIMAL(argv[0]) != HT_STREAM_MODE_2X2) { - printf("ERR:Invalid argument\n"); - return UAP_FAILURE; - } - htstream_cfg.action = ACTION_SET; - htstream_cfg.stream_cfg = (t_u32)A2HEXDECIMAL(argv[0]); - } else { - print_htstreamcfg_usage(); - return UAP_FAILURE; - } - htstream_cfg.subcmd = UAP_HT_STREAM_CFG; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&htstream_cfg; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: HT STREAM configuration failed\n"); - close(sockfd); - return UAP_FAILURE; - } - - /* Handle response */ - if (htstream_cfg.action == ACTION_GET) { - if (htstream_cfg.stream_cfg == HT_STREAM_MODE_1X1) - printf("HT stream is in 1x1 mode\n"); - else if (htstream_cfg.stream_cfg == HT_STREAM_MODE_2X2) - printf("HT stream is in 2x2 mode\n"); - else - printf("HT stream is unknown mode\n"); - } - - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -static int -get_802_11ac_cfg(struct eth_priv_vhtcfg *vhtcfg) -{ - t_u8 *buf = NULL; - t_u8 *pos = NULL; - mrvl_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_s32 sockfd; - - buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buf) { - printf("ERR: cannot allocate buffer for command payload \n"); - return UAP_FAILURE; - } - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd = (mrvl_priv_cmd *)malloc(sizeof(mrvl_priv_cmd)); - if (!cmd) { - printf("ERR: cannot allocate buffer for cmd \n"); - free(buf); - return UAP_FAILURE; - } - - /*prepare command: mlanutl uap0 vhtcfg 2 3 , GET operation */ - pos = buf; - strncpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); - pos += strlen(CMD_NXP); - strncpy((char *)pos, "vhtcfg2 3", strlen("vhtcfg2 3")); - - /* fill up buffer */ - cmd->buf = buf; - cmd->used_len = 0; - cmd->total_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - if (cmd) - free(cmd); - if (buf) - free(buf); - return UAP_FAILURE; - } - - if (ioctl(sockfd, MRVLPRIVCMD, &ifr)) { - if (cmd) - free(cmd); - if (buf) - free(buf); - close(sockfd); - return UAP_FAILURE; - } - - /* Process result */ - memcpy(vhtcfg, buf + 1, sizeof(struct eth_priv_vhtcfg)); - - close(sockfd); - free(cmd); - free(buf); - - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sys_config command - * - * $return N/A - */ -void -print_sys_config_usage(void) -{ - printf("\nUsage : sys_config [CONFIG_FILE]\n"); - printf("\nIf CONFIG_FILE is provided, a 'set' is performed, else a 'get' is performed.\n"); - printf("CONFIG_FILE is file contain all the Micro AP settings.\n"); - return; -} - -/** - * @brief Show usage information for the rdeeprom command - * - * $return N/A - */ -void -print_apcmd_read_eeprom_usage(void) -{ - printf("\nUsage: rdeeprom \n"); - printf(" offset : 0,4,8,..., multiple of 4\n"); - printf(" bytecount : 4-20, multiple of 4\n"); - return; -} - -/** - * @brief Show protocol tlv - * - * @param protocol Protocol number - * - * $return N/A - */ -void -print_protocol(t_u16 protocol) -{ - switch (protocol) { - case 0: - case PROTOCOL_NO_SECURITY: - printf("PROTOCOL = No security\n"); - break; - case PROTOCOL_STATIC_WEP: - printf("PROTOCOL = Static WEP\n"); - break; - case PROTOCOL_WPA: - printf("PROTOCOL = WPA \n"); - break; - case PROTOCOL_WPA2: - printf("PROTOCOL = WPA2 \n"); - break; - case PROTOCOL_WPA | PROTOCOL_WPA2: - printf("PROTOCOL = WPA/WPA2 \n"); - break; - case PROTOCOL_WPA3_SAE: - printf("PROTOCOL = WPA3 SAE \n"); - break; - default: - printf("Unknown PROTOCOL: 0x%x \n", protocol); - break; - } -} - -/** - * @brief Show wep tlv - * - * @param tlv Pointer to wep tlv - * - * $return N/A - */ -void -print_wep_key(tlvbuf_wep_key *tlv) -{ - int i; - t_u16 tlv_len; - - tlv_len = *(t_u8 *)&tlv->length; - tlv_len |= (*((t_u8 *)&tlv->length + 1) << 8); - - if (tlv_len <= 2) { - printf("wrong wep_key tlv: length=%d\n", tlv_len); - return; - } - printf("WEP KEY_%d = ", tlv->key_index); - for (i = 0; i < tlv_len - 2; i++) - printf("%02x ", tlv->key[i]); - if (tlv->is_default) - printf("\nDefault WEP Key = %d\n", tlv->key_index); - else - printf("\n"); -} - -/** - * @brief Parses a command line - * - * @param line The line to parse - * @param args Pointer to the argument buffer to be filled in - * @return Number of arguments in the line or EOF - */ -static int -parse_line(char *line, char *args[]) -{ - int arg_num = 0; - int is_start = 0; - int is_quote = 0; - int is_escape = 0; - int length = 0; - int i = 0; - int j = 0; - - arg_num = 0; - length = strlen(line); - /* Process line */ - - /* Find number of arguments */ - is_start = 0; - is_quote = 0; - for (i = 0; i < length; i++) { - /* Ignore leading spaces */ - if (is_start == 0) { - if (line[i] == ' ') { - continue; - } else if (line[i] == '\t') { - continue; - } else if (line[i] == '\n') { - break; - } else { - is_start = 1; - args[arg_num] = &line[i]; - arg_num++; - } - } - if (is_start == 1) { - if ((line[i] == '\\') && (i < (length - 1))) { - if (line[i + 1] == '"') { - is_escape = 1; - for (j = i; j < length - 1; j++) { - line[j] = line[j + 1]; - } - line[length - 1] = '\0'; - continue; - } - } - /* Ignore comments */ - if (line[i] == '#') { - if (is_quote == 0) { - line[i] = '\0'; - arg_num--; - } - break; - } - /* Separate by '=' */ - if (line[i] == '=') { - if (is_quote == 0) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - /* Separate by ',' */ - if (line[i] == ',') { - if (is_quote == 0) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - /* Change ',' to ' ', but not inside quotes */ - if ((line[i] == ',') && (is_quote == 0)) { - line[i] = ' '; - continue; - } - } - /* Remove newlines */ - if (line[i] == '\n') { - line[i] = '\0'; - } - /* Check for quotes */ - if (line[i] == '"') { - if (is_escape) { - is_escape = 0; - /* no change in is_quote */ - } else { - is_quote = (is_quote == 1) ? 0 : 1; - } - continue; - } - if (((line[i] == ' ') || (line[i] == '\t')) && (is_quote == 0)) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - return arg_num; -} - -/** - * @brief Parse function for a configuration line - * - * @param s Storage buffer for data - * @param size Maximum size of data - * @param stream File stream pointer - * @param line Pointer to current line within the file - * @param _pos Output string or NULL - * @return String or NULL - */ -static char * -config_get_line(char *s, int size, FILE * stream, int *line, char **_pos) -{ - *_pos = mlan_config_get_line(stream, s, size, line); - return *_pos; -} - -/** - * @brief Read the profile and sends to the driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -apcmd_sys_config_profile(int argc, char *argv[]) -{ - FILE *config_file = NULL; - char *line = NULL; - int li = 0; - char *pos = NULL; - int arg_num = 0; - char *args[30]; - int i; - int is_ap_config = 0; - int is_ap_mac_filter = 0; - apcmdbuf_sys_configure *cmd_buf = NULL; - HTCap_t htcap; - int enable_11n = -1; - t_u16 tlv_offset_11n = 0; - t_u32 supported_mcs_set = 0; - t_u8 *buffer = NULL; - t_u8 *tmp_buffer = NULL; - t_u16 cmd_len = 0; - t_u16 tlv_len = 0; - int keyindex = -1; - int protocol = -1; - int pwkcipher_wpa = -1; - int pwkcipher_wpa2 = -1; - int gwkcipher = -1; - tlvbuf_sta_mac_addr_filter *filter_tlv = NULL; - tlvbuf_channel_config *channel_band_tlv = NULL; - int filter_mac_count = -1; - int tx_data_rate = -1; - int tx_beacon_rate = -1; - int mcbc_data_rate = -1; - t_u8 rate[MAX_RATES]; - int found = 0; - char country_80211d[4]; - t_u8 state_80211d = 0; - int chan_mode = 0; - int band = 0; - int band_flag = 0; - int chan_number = 0; - t_u16 max_sta_num_supported = 0; - fw_info fw; - struct eth_priv_vhtcfg vhtcfg = { 0 }; - int ret = UAP_SUCCESS; - memset(rate, 0, MAX_RATES); - /* Check if file exists */ - config_file = fopen(argv[0], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - return UAP_FAILURE; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - ret = UAP_FAILURE; - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { -#if DEBUG - uap_printf(MSG_DEBUG, "DBG:Received config line (%d) = %s\n", - li, line); -#endif - arg_num = parse_line(line, args); -#if DEBUG - uap_printf(MSG_DEBUG, "DBG:Number of arguments = %d\n", - arg_num); - for (i = 0; i < arg_num; i++) { - uap_printf(MSG_DEBUG, "\tDBG:Argument %d. %s\n", i + 1, - args[i]); - } -#endif - /* Check for end of AP configurations */ - if (is_ap_config == 1) { - if (strcmp(args[0], "}") == 0) { - is_ap_config = 0; - if (tx_data_rate != -1) { - if ((!rate[0]) && (tx_data_rate) && - (is_tx_rate_valid - ((t_u8)tx_data_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid Tx Data Rate \n"); - ret = UAP_FAILURE; - goto done; - } - if (rate[0] && tx_data_rate) { - for (i = 0; rate[i] != 0; i++) { - if ((rate[i] & - ~BASIC_RATE_SET_BIT) - == tx_data_rate) { - found = 1; - break; - } - } - if (!found) { - printf("ERR: Invalid Tx Data Rate \n"); - ret = UAP_FAILURE; - goto done; - } - } - } - if (tx_beacon_rate != -1) { - if ((!rate[0]) && (tx_beacon_rate) && - (is_tx_rate_valid - ((t_u8)tx_beacon_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid Tx Beacon Rate \n"); - ret = UAP_FAILURE; - goto done; - } - if (rate[0] && tx_beacon_rate) { - for (i = 0; rate[i] != 0; i++) { - if ((rate[i] & - ~BASIC_RATE_SET_BIT) - == tx_beacon_rate) { - found = 1; - break; - } - } - if (!found) { - printf("ERR: Invalid Tx Beacon Rate \n"); - ret = UAP_FAILURE; - goto done; - } - } - /* Append a new TLV */ - tlvbuf_tx_data_rate *tlv = NULL; - tlv_len = sizeof(tlvbuf_tx_data_rate); - tmp_buffer = - realloc(buffer, - cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append tx beacon rate TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure *) - buffer; - tlv = (tlvbuf_tx_data_rate *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_TX_BEACON_RATE_TLV_ID; - tlv->length = 2; - tlv->tx_data_rate = tx_beacon_rate; - endian_convert_tlv_header_out(tlv); - tlv->tx_data_rate = - uap_cpu_to_le16(tlv-> - tx_data_rate); - } - if (mcbc_data_rate != -1) { - if ((!rate[0]) && (mcbc_data_rate) && - (is_mcbc_rate_valid - ((t_u8)mcbc_data_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid Tx Data Rate \n"); - ret = UAP_FAILURE; - goto done; - } - if (rate[0] && mcbc_data_rate) { - for (i = 0; rate[i] != 0; i++) { - if (rate[i] & - BASIC_RATE_SET_BIT) - { - if ((rate[i] & - ~BASIC_RATE_SET_BIT) - == - mcbc_data_rate) - { - found = 1; - break; - } - } - } - if (!found) { - printf("ERR: Invalid MCBC Data Rate \n"); - ret = UAP_FAILURE; - goto done; - } - } - - /* Append a new TLV */ - tlvbuf_mcbc_data_rate *tlv = NULL; - tlv_len = sizeof(tlvbuf_mcbc_data_rate); - tmp_buffer = - realloc(buffer, - cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append tx data rate TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure *) - buffer; - tlv = (tlvbuf_mcbc_data_rate *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_MCBC_DATA_RATE_TLV_ID; - tlv->length = 2; - tlv->mcbc_datarate = mcbc_data_rate; - endian_convert_tlv_header_out(tlv); - tlv->mcbc_datarate = - uap_cpu_to_le16(tlv-> - mcbc_datarate); - } - if ((protocol == PROTOCOL_STATIC_WEP) && - (enable_11n == 1)) { - printf("ERR:WEP cannot be used when AP operates in 802.11n mode.\n"); - ret = UAP_FAILURE; - goto done; - } - if ((protocol == PROTOCOL_WPA2_MIXED) && - ((pwkcipher_wpa < 0) || - (pwkcipher_wpa2 < 0))) { - printf("ERR:Both PwkCipherWPA and PwkCipherWPA2 should be defined for Mixed mode.\n"); - ret = UAP_FAILURE; - goto done; - } - - if (((pwkcipher_wpa >= 0) || - (pwkcipher_wpa2 >= 0)) && - (gwkcipher >= 0)) { - if ((protocol == PROTOCOL_WPA) || - (protocol == PROTOCOL_WPA2_MIXED)) { - if (enable_11n != -1) { - if (is_cipher_valid_with_11n(pwkcipher_wpa, gwkcipher, protocol, enable_11n) != UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA pairwise cipher combination!\n"); - ret = UAP_FAILURE; - goto done; - } - } else if - (is_cipher_valid_with_proto - (pwkcipher_wpa, - gwkcipher, - protocol) != - UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA pairwise cipher combination!\n"); - ret = UAP_FAILURE; - goto done; - } - } - if ((protocol == PROTOCOL_WPA2) || - (protocol == PROTOCOL_WPA2_MIXED) - || (protocol == PROTOCOL_WPA3_SAE) - ) { - if (enable_11n != -1) { - if (is_cipher_valid_with_11n(pwkcipher_wpa2, gwkcipher, protocol, enable_11n) != UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA2 pairwise cipher combination!\n"); - ret = UAP_FAILURE; - goto done; - } - } else if - (is_cipher_valid_with_proto - (pwkcipher_wpa2, - gwkcipher, - protocol) != - UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA2 pairwise cipher combination!\n"); - ret = UAP_FAILURE; - goto done; - } - } - } - - if (0 == get_fw_info(&fw)) { - /*check whether support 802.11AC through BAND_AAC bit */ - if (fw.fw_bands & BAND_AAC) { - ret = get_802_11ac_cfg(&vhtcfg); - if (ret != UAP_SUCCESS) - goto done; - if (enable_11n != -1) { - /* Note: When 11AC is disabled, FW sets vht_rx_mcs to 0xffff */ - if ((vhtcfg. - vht_rx_mcs != - 0xffff) && - (!enable_11n)) { - printf("ERR: 11n must be enabled when AP operates in 11ac mode. \n"); - ret = UAP_FAILURE; - goto done; - } - } - } else - printf("No support 802 11AC.\n"); - } else { - printf("ERR: get_fw_info fail\n"); - ret = UAP_FAILURE; - goto done; - } - - if (protocol != -1) { - tlvbuf_protocol *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_protocol); - tmp_buffer = - realloc(buffer, - cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append protocol TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure *) - buffer; - tlv = (tlvbuf_protocol *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_PROTOCOL_TLV_ID; - tlv->length = 2; - tlv->protocol = protocol; - endian_convert_tlv_header_out(tlv); - tlv->protocol = - uap_cpu_to_le16(tlv->protocol); - if (protocol & - (PROTOCOL_WPA | PROTOCOL_WPA2 | - PROTOCOL_WPA3_SAE)) { - tlvbuf_akmp *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_akmp); - tmp_buffer = - realloc(buffer, - cmd_len + - tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append AKMP TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure - *)buffer; - tlv = (tlvbuf_akmp *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_AKMP_TLV_ID; - tlv->length = 4; /* sizeof(tlvbuf_akmp) - TLVHEADER */ - if (protocol & - PROTOCOL_WPA3_SAE) { - tlv->key_mgmt = - KEY_MGMT_SAE; - } else { - tlv->key_mgmt = - KEY_MGMT_PSK; - } - endian_convert_tlv_header_out - (tlv); - tlv->key_mgmt = - uap_cpu_to_le16(tlv-> - key_mgmt); - tlv->key_mgmt_operation = 0; - } - } - if (pwkcipher_wpa >= 0) { - tlvbuf_pwk_cipher *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_pwk_cipher); - tmp_buffer = - realloc(buffer, - cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append cipher TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure *) - buffer; - tlv = (tlvbuf_pwk_cipher *)(buffer + - cmd_len); - memset(tlv, 0, tlv_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_CIPHER_PWK_TLV_ID; - tlv->length = - sizeof(tlvbuf_pwk_cipher) - - TLVHEADER_LEN; - tlv->pairwise_cipher = pwkcipher_wpa; - tlv->protocol = PROTOCOL_WPA; - endian_convert_tlv_header_out(tlv); - tlv->protocol = - uap_cpu_to_le16(tlv->protocol); - } - - if (pwkcipher_wpa2 >= 0) { - tlvbuf_pwk_cipher *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_pwk_cipher); - tmp_buffer = - realloc(buffer, - cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append cipher TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure *) - buffer; - tlv = (tlvbuf_pwk_cipher *)(buffer + - cmd_len); - memset(tlv, 0, tlv_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_CIPHER_PWK_TLV_ID; - tlv->length = - sizeof(tlvbuf_pwk_cipher) - - TLVHEADER_LEN; - tlv->pairwise_cipher = pwkcipher_wpa2; - tlv->protocol = PROTOCOL_WPA2; - endian_convert_tlv_header_out(tlv); - tlv->protocol = - uap_cpu_to_le16(tlv->protocol); - } - - if (gwkcipher >= 0) { - tlvbuf_gwk_cipher *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_gwk_cipher); - tmp_buffer = - realloc(buffer, - cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append cipher TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = - (apcmdbuf_sys_configure *) - buffer; - tlv = (tlvbuf_gwk_cipher *)(buffer + - cmd_len); - memset(tlv, 0, tlv_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_CIPHER_GWK_TLV_ID; - tlv->length = - sizeof(tlvbuf_gwk_cipher) - - TLVHEADER_LEN; - tlv->group_cipher = gwkcipher; - endian_convert_tlv_header_out(tlv); - } - - cmd_buf->size = cmd_len; - /* Send collective command */ - if (uap_ioctl - ((t_u8 *)cmd_buf, &cmd_len, - cmd_len) == UAP_SUCCESS) { - if (cmd_buf->result != CMD_SUCCESS) { - printf("ERR: Failed to set the configuration!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR: Command sending failed!\n"); - ret = UAP_FAILURE; - goto done; - } - cmd_len = 0; - if (buffer) { - free(buffer); - buffer = NULL; - } - continue; - } - } - - /* Check for beginning of AP configurations */ - if (strcmp(args[0], "ap_config") == 0) { - is_ap_config = 1; - cmd_len = sizeof(apcmdbuf_sys_configure); - if (buffer) { - free(buffer); - buffer = NULL; - } - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - ret = UAP_FAILURE; - goto done; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = ACTION_SET; - continue; - } - - /* Check for end of AP MAC address filter configurations */ - if (is_ap_mac_filter == 1) { - if (strcmp(args[0], "}") == 0) { - is_ap_mac_filter = 0; - if (filter_tlv->count != filter_mac_count) { - printf("ERR:Number of MAC address provided does not match 'Count'\n"); - ret = UAP_FAILURE; - goto done; - } - if (filter_tlv->count) { - filter_tlv->length = - (filter_tlv->count * ETH_ALEN) + - 2; - cmd_len -= - (MAX_MAC_ONESHOT_FILTER - - filter_mac_count) * ETH_ALEN; - } else { - filter_tlv->length = - (MAX_MAC_ONESHOT_FILTER * - ETH_ALEN) + 2; - memset(filter_tlv->mac_address, 0, - MAX_MAC_ONESHOT_FILTER * - ETH_ALEN); - } - cmd_buf->size = cmd_len; - endian_convert_tlv_header_out(filter_tlv); - if (uap_ioctl - ((t_u8 *)cmd_buf, &cmd_len, - cmd_len) == UAP_SUCCESS) { - if (cmd_buf->result != CMD_SUCCESS) { - printf("ERR: Failed to set the configuration!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR: Command sending failed!\n"); - ret = UAP_FAILURE; - goto done; - } - - cmd_len = 0; - if (buffer) { - free(buffer); - buffer = NULL; - } - continue; - } - } - - if (strcmp(args[0], "11d_enable") == 0) { - if (IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE) { - printf("ERR: valid input for state are 0 or 1\n"); - ret = UAP_FAILURE; - goto done; - } - state_80211d = (t_u8)A2HEXDECIMAL(args[1]); - - if ((state_80211d != 0) && (state_80211d != 1)) { - printf("ERR: valid input for state are 0 or 1 \n"); - ret = UAP_FAILURE; - goto done; - } - if (sg_snmp_mib - (ACTION_SET, OID_80211D_ENABLE, - sizeof(state_80211d), &state_80211d) - == UAP_FAILURE) { - ret = UAP_FAILURE; - goto done; - } - } - - if (strcmp(args[0], "country") == 0) { - apcmdbuf_cfg_80211d *cmd_buf = NULL; - ieeetypes_subband_set_t sub_bands[MAX_SUB_BANDS]; - t_u8 no_of_sub_band = 0; - t_u16 buf_len; - t_u16 cmdlen; - t_u8 *buf = NULL; - - if ((strlen(args[1]) > 3) || (strlen(args[1]) == 0)) { - printf("In-correct country input\n"); - ret = UAP_FAILURE; - goto done; - } - strncpy(country_80211d, args[1], - sizeof(country_80211d) - 1); - for (i = 0; (unsigned int)i < strlen(country_80211d); - i++) { - if ((country_80211d[i] < 'A') || - (country_80211d[i] > 'z')) { - printf("Invalid Country Code\n"); - ret = UAP_FAILURE; - goto done; - } - if (country_80211d[i] > 'Z') - country_80211d[i] = - country_80211d[i] - 'a' + 'A'; - } - no_of_sub_band = - parse_domain_file(country_80211d, band, - sub_bands, NULL); - if (no_of_sub_band == UAP_FAILURE) { - printf("Parsing Failed\n"); - ret = UAP_FAILURE; - goto done; - } - buf_len = sizeof(apcmdbuf_cfg_80211d); - buf_len += - no_of_sub_band * - sizeof(ieeetypes_subband_set_t); - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - ret = UAP_FAILURE; - goto done; - } - memset(buf, 0, buf_len); - cmd_buf = (apcmdbuf_cfg_80211d *)buf; - cmdlen = buf_len; - cmd_buf->size = cmdlen - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = uap_cpu_to_le16(ACTION_SET); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - cmd_buf->domain.tag = uap_cpu_to_le16(TLV_TYPE_DOMAIN); - cmd_buf->domain.length = - uap_cpu_to_le16(sizeof(domain_param_t) - - BUF_HEADER_SIZE + - (no_of_sub_band * - sizeof - (ieeetypes_subband_set_t))); - - memset(cmd_buf->domain.country_code, ' ', - sizeof(cmd_buf->domain.country_code)); - memcpy(cmd_buf->domain.country_code, country_80211d, - strlen(country_80211d)); - memcpy(cmd_buf->domain.subband, sub_bands, - no_of_sub_band * - sizeof(ieeetypes_subband_set_t)); - - /* Send the command */ - if (uap_ioctl((t_u8 *)cmd_buf, &cmdlen, cmdlen) == - UAP_SUCCESS) { - if (cmd_buf->result != CMD_SUCCESS) { - printf("ERR: Failed to set the configuration!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR: Command sending failed!\n"); - ret = UAP_FAILURE; - goto done; - } - - if (buf) - free(buf); - } - - /* Check for beginning of AP MAC address filter configurations */ - if (strcmp(args[0], "ap_mac_filter") == 0) { - is_ap_mac_filter = 1; - cmd_len = - sizeof(apcmdbuf_sys_configure) + - sizeof(tlvbuf_sta_mac_addr_filter) + - (MAX_MAC_ONESHOT_FILTER * ETH_ALEN); - if (buffer) { - free(buffer); - buffer = NULL; - } - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - ret = UAP_FAILURE; - goto done; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = ACTION_SET; - filter_tlv = - (tlvbuf_sta_mac_addr_filter *)(buffer + - sizeof - (apcmdbuf_sys_configure)); - filter_tlv->tag = MRVL_STA_MAC_ADDR_FILTER_TLV_ID; - filter_tlv->length = 2; - filter_tlv->count = 0; - filter_mac_count = 0; - continue; - } - if ((strcmp(args[0], "FilterMode") == 0) && is_ap_mac_filter) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0) || - (atoi(args[1]) > 2)) { - printf("ERR:Illegal FilterMode paramter %d. Must be either '0', '1', or '2'.\n", atoi(args[1])); - ret = UAP_FAILURE; - goto done; - } - filter_tlv->filter_mode = atoi(args[1]); - continue; - } - if ((strcmp(args[0], "Count") == 0) && is_ap_mac_filter) { - filter_tlv->count = atoi(args[1]); - if ((ISDIGIT(args[1]) == 0) || - (filter_tlv->count > MAX_MAC_ONESHOT_FILTER)) { - printf("ERR: Illegal Count parameter.\n"); - ret = UAP_FAILURE; - goto done; - } - } - if ((strncmp(args[0], "mac_", 4) == 0) && is_ap_mac_filter) { - if (filter_mac_count < MAX_MAC_ONESHOT_FILTER) { - if (mac2raw - (args[1], - &filter_tlv->mac_address[filter_mac_count * - ETH_ALEN]) != - UAP_SUCCESS) { - printf("ERR: Invalid MAC address %s \n", - args[1]); - ret = UAP_FAILURE; - goto done; - } - filter_mac_count++; - } else { - printf("ERR: Filter table can not have more than %d MAC addresses\n", MAX_MAC_ONESHOT_FILTER); - ret = UAP_FAILURE; - goto done; - } - } - - if (strcmp(args[0], "SSID") == 0) { - if (arg_num == 1) { - printf("ERR:SSID field is blank!\n"); - ret = UAP_FAILURE; - goto done; - } else { - tlvbuf_ssid *tlv = NULL; - if (args[1][0] == '"') { - args[1]++; - } - if (args[1][strlen(args[1]) - 1] == '"') { - args[1][strlen(args[1]) - 1] = '\0'; - } - if ((strlen(args[1]) > MAX_SSID_LENGTH) || - (strlen(args[1]) == 0)) { - printf("ERR:SSID length out of range (%d to %d).\n", MIN_SSID_LENGTH, MAX_SSID_LENGTH); - ret = UAP_FAILURE; - goto done; - } - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_ssid) + strlen(args[1]); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot realloc SSID TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_ssid *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_SSID_TLV_ID; - tlv->length = strlen(args[1]); - memcpy(tlv->ssid, args[1], tlv->length); - endian_convert_tlv_header_out(tlv); - } - } - if (strcmp(args[0], "BeaconPeriod") == 0) { - if (is_input_valid(BEACONPERIOD, arg_num - 1, args + 1) - != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_beacon_period *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_beacon_period); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot realloc beacon period TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_beacon_period *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_BEACON_PERIOD_TLV_ID; - tlv->length = 2; - tlv->beacon_period_ms = (t_u16)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->beacon_period_ms = - uap_cpu_to_le16(tlv->beacon_period_ms); - } - if (strcmp(args[0], "ChanList") == 0) { - if (is_input_valid(SCANCHANNELS, arg_num - 1, args + 1) - != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - - tlvbuf_channel_list *tlv = NULL; - channel_list *pchan_list = NULL; - /* Append a new TLV */ - tlv_len = - sizeof(tlvbuf_channel_list) + - ((arg_num - 1) * sizeof(channel_list)); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append channel list TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_channel_list *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_CHANNELLIST_TLV_ID; - tlv->length = sizeof(channel_list) * (arg_num - 1); - pchan_list = (channel_list *) tlv->chan_list; - for (i = 0; i < (arg_num - 1); i++) { - band_flag = -1; - sscanf(args[i + 1], "%d.%d", &chan_number, - &band_flag); - pchan_list->chan_number = chan_number; - pchan_list->bandcfg.chanBand = BAND_2GHZ; - if (((band_flag != -1) && (band_flag)) || - (chan_number > MAX_CHANNELS_BG)) { - pchan_list->bandcfg.chanBand = - BAND_5GHZ; - } - pchan_list++; - } - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "Channel") == 0) { - if (is_input_valid(CHANNEL, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_channel_config *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_channel_config); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append channel TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_channel_config *)(buffer + cmd_len); - channel_band_tlv = tlv; - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_CHANNELCONFIG_TLV_ID; - tlv->length = - sizeof(tlvbuf_channel_config) - TLVHEADER_LEN; - tlv->chan_number = (t_u8)atoi(args[1]); - if (tlv->chan_number > MAX_CHANNELS_BG) - band = BAND_A; - else - band = BAND_B | BAND_G; - if ((arg_num - 1) == 2) { - chan_mode = atoi(args[2]); - memset(&(tlv->bandcfg), 0, - sizeof(tlv->bandcfg)); - if (chan_mode & BITMAP_ACS_MODE) { - int mode; - if (uap_ioctl_dfs_repeater_mode(&mode) - == UAP_SUCCESS) { - if (mode) { - printf("ERR: ACS in DFS Repeater mode" " is not allowed\n"); - ret = UAP_FAILURE; - goto done; - } - } - tlv->bandcfg.scanMode = SCAN_MODE_ACS; - } - if (chan_mode & BITMAP_CHANNEL_ABOVE) - tlv->bandcfg.chan2Offset = - SEC_CHAN_ABOVE; - if (chan_mode & BITMAP_CHANNEL_BELOW) - tlv->bandcfg.chan2Offset = - SEC_CHAN_BELOW; - } else - memset(&(tlv->bandcfg), 0, - sizeof(tlv->bandcfg)); - if (tlv->chan_number > MAX_CHANNELS_BG) { - tlv->bandcfg.chanBand = BAND_5GHZ; - } - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "Band") == 0) { - if (is_input_valid(BAND, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - if (channel_band_tlv == NULL) { - printf("ERR: Channel parameter should be specified before Band\n"); - ret = UAP_FAILURE; - goto done; - } - /* If band is provided, clear previous value of band */ - channel_band_tlv->bandcfg.chanBand = BAND_2GHZ; - if (atoi(args[1]) == 0) { - band = BAND_B | BAND_G; - } else { - channel_band_tlv->bandcfg.chanBand = BAND_5GHZ; - band = BAND_A; - } - } - if (strcmp(args[0], "AP_MAC") == 0) { - tlvbuf_ap_mac_address *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_ap_mac_address); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append ap_mac TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_ap_mac_address *)(buffer + cmd_len); - cmd_len += tlv_len; - cmd_buf->action = ACTION_SET; - tlv->tag = MRVL_AP_MAC_ADDRESS_TLV_ID; - tlv->length = ETH_ALEN; - if ((ret = - mac2raw(args[1], - tlv->ap_mac_addr)) != UAP_SUCCESS) { - printf("ERR: %s Address \n", - ret == - UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - ret = UAP_FAILURE; - goto done; - } - endian_convert_tlv_header_out(tlv); - } - - if (strcmp(args[0], "Rate") == 0) { - if (is_input_valid(RATE, arg_num - 1, args + 1) != - UAP_SUCCESS) { - printf("ERR: Invalid Rate input\n"); - ret = UAP_FAILURE; - goto done; - } - tlvbuf_rates *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_rates) + arg_num - 1; - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append rates TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rates *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_RATES_TLV_ID; - tlv->length = arg_num - 1; - for (i = 0; i < tlv->length; i++) { - rate[i] = tlv->operational_rates[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "TxPowerLevel") == 0) { - if (is_input_valid(TXPOWER, arg_num - 1, args + 1) != - UAP_SUCCESS) { - printf("ERR:Invalid TxPowerLevel \n"); - ret = UAP_FAILURE; - goto done; - } else { - tlvbuf_tx_power *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_tx_power); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append tx power level TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_tx_power *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_TX_POWER_TLV_ID; - tlv->length = 1; - tlv->tx_power_dbm = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - } - if (strcmp(args[0], "BroadcastSSID") == 0) { - if (is_input_valid(BROADCASTSSID, arg_num - 1, args + 1) - != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_bcast_ssid_ctl *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_bcast_ssid_ctl); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append SSID broadcast control TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_bcast_ssid_ctl *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_BCAST_SSID_CTL_TLV_ID; - tlv->length = 1; - tlv->bcast_ssid_ctl = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "RTSThreshold") == 0) { - if (is_input_valid(RTSTHRESH, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_rts_threshold *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_rts_threshold); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append RTS threshold TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rts_threshold *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_RTS_THRESHOLD_TLV_ID; - tlv->length = 2; - tlv->rts_threshold = (t_u16)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->rts_threshold = - uap_cpu_to_le16(tlv->rts_threshold); - } - if (strcmp(args[0], "FragThreshold") == 0) { - if (is_input_valid(FRAGTHRESH, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_frag_threshold *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_frag_threshold); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append Fragmentation threshold TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_frag_threshold *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_FRAG_THRESHOLD_TLV_ID; - tlv->length = 2; - tlv->frag_threshold = (t_u16)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->frag_threshold = - uap_cpu_to_le16(tlv->frag_threshold); - } - if (strcmp(args[0], "DTIMPeriod") == 0) { - if (is_input_valid(DTIMPERIOD, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_dtim_period *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_dtim_period); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append DTIM period TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_dtim_period *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_DTIM_PERIOD_TLV_ID; - tlv->length = 1; - tlv->dtim_period = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "RSNReplayProtection") == 0) { - if (is_input_valid(RSNREPLAYPROT, arg_num - 1, args + 1) - != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_rsn_replay_prot *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_rsn_replay_prot); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append RSN replay protection TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_rsn_replay_prot *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_RSN_REPLAY_PROT_TLV_ID; - tlv->length = 1; - tlv->rsn_replay_prot = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "TxBeaconRate") == 0) { - if (is_input_valid(TXBEACONRATE, arg_num - 1, args + 1) - != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tx_beacon_rate = (t_u16)A2HEXDECIMAL(args[1]); - } - if (strcmp(args[0], "MCBCdataRate") == 0) { - if (is_input_valid(MCBCDATARATE, arg_num - 1, args + 1) - != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - mcbc_data_rate = (t_u16)A2HEXDECIMAL(args[1]); - } - if (strcmp(args[0], "PktFwdCtl") == 0) { - if (is_input_valid(PKTFWD, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_pkt_fwd_ctl *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_pkt_fwd_ctl); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append packet forwarding control TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_pkt_fwd_ctl *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_PKT_FWD_CTL_TLV_ID; - tlv->length = 1; - tlv->pkt_fwd_ctl = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "StaAgeoutTimer") == 0) { - if (is_input_valid - (STAAGEOUTTIMER, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_sta_ageout_timer *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_sta_ageout_timer); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append STA ageout timer TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_sta_ageout_timer *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_STA_AGEOUT_TIMER_TLV_ID; - tlv->length = 4; - tlv->sta_ageout_timer_ms = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->sta_ageout_timer_ms = - uap_cpu_to_le32(tlv->sta_ageout_timer_ms); - } - if (strcmp(args[0], "PSStaAgeoutTimer") == 0) { - if (is_input_valid - (PSSTAAGEOUTTIMER, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_ps_sta_ageout_timer *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_ps_sta_ageout_timer); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append PS STA ageout timer TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_ps_sta_ageout_timer *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_PS_STA_AGEOUT_TIMER_TLV_ID; - tlv->length = 4; - tlv->ps_sta_ageout_timer_ms = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->ps_sta_ageout_timer_ms = - uap_cpu_to_le32(tlv->ps_sta_ageout_timer_ms); - } - if (strcmp(args[0], "AuthMode") == 0) { - if (is_input_valid(AUTHMODE, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_auth_mode *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_auth_mode); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append auth mode TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_auth_mode *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_AUTH_TLV_ID; - tlv->length = 1; - tlv->auth_mode = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "KeyIndex") == 0) { - if (arg_num == 1) { - printf("KeyIndex is blank!\n"); - ret = UAP_FAILURE; - goto done; - } else { - if (ISDIGIT(args[1]) == 0) { - printf("ERR:Illegal KeyIndex parameter. Must be either '0', '1', '2', or '3'.\n"); - ret = UAP_FAILURE; - goto done; - } - keyindex = atoi(args[1]); - if ((keyindex < 0) || (keyindex > 3)) { - printf("ERR:Illegal KeyIndex parameter. Must be either '0', '1', '2', or '3'.\n"); - ret = UAP_FAILURE; - goto done; - } - } - } - if (strncmp(args[0], "Key_", 4) == 0) { - if (arg_num == 1) { - printf("ERR:%s is blank!\n", args[0]); - ret = UAP_FAILURE; - goto done; - } else { - tlvbuf_wep_key *tlv = NULL; - int key_len = 0; - if (args[1][0] == '"') { - if ((strlen(args[1]) != 2) && - (strlen(args[1]) != 7) && - (strlen(args[1]) != 15)) { - printf("ERR:Wrong key length!\n"); - ret = UAP_FAILURE; - goto done; - } - key_len = strlen(args[1]) - 2; - } else { - if ((strlen(args[1]) != 0) && - (strlen(args[1]) != 10) && - (strlen(args[1]) != 26)) { - printf("ERR:Wrong key length!\n"); - ret = UAP_FAILURE; - goto done; - } - if (UAP_FAILURE == ishexstring(args[1])) { - printf("ERR:Only hex digits are allowed when key length is 10 or 26\n"); - ret = UAP_FAILURE; - goto done; - } - key_len = strlen(args[1]) / 2; - } - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_wep_key) + key_len; - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append WEP key configurations TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wep_key *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_WEP_KEY_TLV_ID; - tlv->length = key_len + 2; - if (strcmp(args[0], "Key_0") == 0) { - tlv->key_index = 0; - } else if (strcmp(args[0], "Key_1") == 0) { - tlv->key_index = 1; - } else if (strcmp(args[0], "Key_2") == 0) { - tlv->key_index = 2; - } else if (strcmp(args[0], "Key_3") == 0) { - tlv->key_index = 3; - } - if (keyindex == tlv->key_index) { - tlv->is_default = 1; - } else { - tlv->is_default = 0; - } - if (args[1][0] == '"') { - memcpy(tlv->key, &args[1][1], - strlen(args[1]) - 2); - } else { - string2raw(args[1], tlv->key); - } - endian_convert_tlv_header_out(tlv); - } - } - if (strcmp(args[0], "PSK") == 0) { - if (arg_num == 1) { - printf("ERR:PSK is blank!\n"); - ret = UAP_FAILURE; - goto done; - } else { - tlvbuf_wpa_passphrase *tlv = NULL; - if (args[1][0] == '"') { - args[1]++; - } - if (args[1][strlen(args[1]) - 1] == '"') { - args[1][strlen(args[1]) - 1] = '\0'; - } - tlv_len = - sizeof(tlvbuf_wpa_passphrase) + - strlen(args[1]); - if (strlen(args[1]) > MAX_WPA_PASSPHRASE_LENGTH) { - printf("ERR:PSK too long.\n"); - ret = UAP_FAILURE; - goto done; - } - if (strlen(args[1]) < MIN_WPA_PASSPHRASE_LENGTH) { - printf("ERR:PSK too short.\n"); - ret = UAP_FAILURE; - goto done; - } - if (strlen(args[1]) == - MAX_WPA_PASSPHRASE_LENGTH) { - if (UAP_FAILURE == ishexstring(args[1])) { - printf("ERR:Only hex digits are allowed when passphrase's length is 64\n"); - ret = UAP_FAILURE; - goto done; - } - } - /* Append a new TLV */ - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append WPA passphrase TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_wpa_passphrase *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_WPA_PASSPHRASE_TLV_ID; - tlv->length = strlen(args[1]); - memcpy(tlv->passphrase, args[1], tlv->length); - endian_convert_tlv_header_out(tlv); - } - } - if (strcmp(args[0], "Protocol") == 0) { - if (is_input_valid(PROTOCOL, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - protocol = (t_u16)atoi(args[1]); - } - if ((strcmp(args[0], "PairwiseCipher") == 0) || - (strcmp(args[0], "GroupCipher") == 0)) { - printf("ERR:PairwiseCipher and GroupCipher are not supported.\n" " Please configure pairwise cipher using parameters PwkCipherWPA or PwkCipherWPA2\n" " and group cipher using GwkCipher in the config file.\n"); - ret = UAP_FAILURE; - goto done; - } - - if ((protocol == PROTOCOL_NO_SECURITY) || - (protocol == PROTOCOL_STATIC_WEP)) { - if ((strcmp(args[0], "PwkCipherWPA") == 0) || - (strcmp(args[0], "PwkCipherWPA2") == 0) - || (strcmp(args[0], "GwkCipher") == 0)) { - printf("ERR:Pairwise cipher and group cipher should not be defined for Open and WEP mode.\n"); - ret = UAP_FAILURE; - goto done; - } - } - - if (strcmp(args[0], "PwkCipherWPA") == 0) { - if (arg_num == 1) { - printf("ERR:PwkCipherWPA is blank!\n"); - ret = UAP_FAILURE; - goto done; - } else { - if (ISDIGIT(args[1]) == 0) { - printf("ERR:Illegal PwkCipherWPA parameter. Must be either bit '2' or '3'.\n"); - ret = UAP_FAILURE; - goto done; - } - if (atoi(args[1]) & ~CIPHER_BITMAP) { - printf("ERR:Illegal PwkCipherWPA parameter. Must be either bit '2' or '3'.\n"); - ret = UAP_FAILURE; - goto done; - } - pwkcipher_wpa = atoi(args[1]); - if (enable_11n && - protocol != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == - get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0] - && (atoi(args[1]) == - CIPHER_TKIP)) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - ret = UAP_FAILURE; - goto done; - } - } - } - } - } - - if (strcmp(args[0], "PwkCipherWPA2") == 0) { - if (arg_num == 1) { - printf("ERR:PwkCipherWPA2 is blank!\n"); - ret = UAP_FAILURE; - goto done; - } else { - if (ISDIGIT(args[1]) == 0) { - printf("ERR:Illegal PwkCipherWPA2 parameter. Must be either bit '2' or '3'.\n"); - ret = UAP_FAILURE; - goto done; - } - if (atoi(args[1]) & ~CIPHER_BITMAP) { - printf("ERR:Illegal PwkCipherWPA2 parameter. Must be either bit '2' or '3'.\n"); - ret = UAP_FAILURE; - goto done; - } - pwkcipher_wpa2 = atoi(args[1]); - if (enable_11n && - protocol != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == - get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0] - && (atoi(args[1]) == - CIPHER_TKIP)) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - ret = UAP_FAILURE; - goto done; - } - } - } - } - } - if (strcmp(args[0], "GwkCipher") == 0) { - if (is_input_valid(GWK_CIPHER, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - gwkcipher = atoi(args[1]); - } - if (strcmp(args[0], "GroupRekeyTime") == 0) { - if (is_input_valid - (GROUPREKEYTIMER, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_group_rekey_timer *tlv = NULL; - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_group_rekey_timer); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append group rekey timer TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_group_rekey_timer *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_GRP_REKEY_TIME_TLV_ID; - tlv->length = 4; - tlv->group_rekey_time_sec = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->group_rekey_time_sec = - uap_cpu_to_le32(tlv->group_rekey_time_sec); - } - if (strcmp(args[0], "MaxStaNum") == 0) { - if (is_input_valid(MAXSTANUM, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - if (get_max_sta_num_supported(&max_sta_num_supported) == - UAP_FAILURE) { - ret = UAP_FAILURE; - goto done; - } - if (atoi(args[1]) > max_sta_num_supported) { - printf("ERR: MAX_STA_NUM must be less than %d\n", max_sta_num_supported); - ret = UAP_FAILURE; - goto done; - } - tlvbuf_max_sta_num *tlv = NULL; - - /* Append a new TLV */ - tlv_len = - sizeof(tlvbuf_max_sta_num) - - sizeof(tlv->max_sta_num_supported); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot realloc max station number TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_max_sta_num *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_MAX_STA_CNT_TLV_ID; - tlv->length = 2; - tlv->max_sta_num_configured = (t_u16)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->max_sta_num_configured = - uap_cpu_to_le16(tlv->max_sta_num_configured); - } - if (strcmp(args[0], "Retrylimit") == 0) { - if (is_input_valid(RETRYLIMIT, arg_num - 1, args + 1) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_retry_limit *tlv = NULL; - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_retry_limit); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot realloc retry limit TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_retry_limit *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_RETRY_LIMIT_TLV_ID; - tlv->length = 1; - tlv->retry_limit = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "PairwiseUpdateTimeout") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_eapol_pwk_hsk_timeout *tlv = NULL; - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_eapol_pwk_hsk_timeout); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append pairwise update timeout TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_eapol_pwk_hsk_timeout *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_EAPOL_PWK_HSK_TIMEOUT_TLV_ID; - tlv->length = 4; - tlv->pairwise_update_timeout = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->pairwise_update_timeout = - uap_cpu_to_le32(tlv->pairwise_update_timeout); - } - if (strcmp(args[0], "PairwiseHandshakeRetries") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_eapol_pwk_hsk_retries *tlv = NULL; - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_eapol_pwk_hsk_retries); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append pairwise handshake retries TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_eapol_pwk_hsk_retries *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_EAPOL_PWK_HSK_RETRIES_TLV_ID; - tlv->length = 4; - tlv->pwk_retries = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->pwk_retries = uap_cpu_to_le32(tlv->pwk_retries); - } - if (strcmp(args[0], "GroupwiseUpdateTimeout") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_eapol_gwk_hsk_timeout *tlv = NULL; - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_eapol_gwk_hsk_timeout); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append groupwise update timeout TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_eapol_gwk_hsk_timeout *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_EAPOL_GWK_HSK_TIMEOUT_TLV_ID; - tlv->length = 4; - tlv->groupwise_update_timeout = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->groupwise_update_timeout = - uap_cpu_to_le32(tlv->groupwise_update_timeout); - } - if (strcmp(args[0], "GroupwiseHandshakeRetries") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - ret = UAP_FAILURE; - goto done; - } - tlvbuf_eapol_gwk_hsk_retries *tlv = NULL; - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_eapol_gwk_hsk_retries); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append groupwise handshake retries TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_eapol_gwk_hsk_retries *)(buffer + - cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_EAPOL_GWK_HSK_RETRIES_TLV_ID; - tlv->length = 4; - tlv->gwk_retries = (t_u32)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - tlv->gwk_retries = uap_cpu_to_le32(tlv->gwk_retries); - } - - if (strcmp(args[0], "Enable11n") == 0) { - if ((ISDIGIT(args[1]) != UAP_SUCCESS) || - (atoi(args[1]) < 0) || (atoi(args[1]) > 1)) { - printf("ERR: Invalid Enable11n value\n"); - ret = UAP_FAILURE; - goto done; - } - tlvbuf_htcap_t *tlv = NULL; - enable_11n = atoi(args[1]); - - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS != get_sys_cfg_11n(&htcap)) { - printf("ERR: Reading current 11n configuration.\n"); - ret = UAP_FAILURE; - goto done; - } - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_htcap_t); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append HT Cap TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_htcap_t *)(buffer + cmd_len); - tlv_offset_11n = cmd_len; - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = HT_CAPABILITY_TLV_ID; - tlv->length = sizeof(HTCap_t); - memcpy(&tlv->ht_cap, &htcap, sizeof(HTCap_t)); - if (enable_11n == 1) { - /* enable mcs rate */ - tlv->ht_cap.supported_mcs_set[0] = - DEFAULT_MCS_SET_0; - tlv->ht_cap.supported_mcs_set[4] = - DEFAULT_MCS_SET_4; - if (0 == get_fw_info(&fw)) { - if ((fw.hw_dev_mcs_support & 0x0f) >= 2) - tlv->ht_cap. - supported_mcs_set[1] = - DEFAULT_MCS_SET_1; - } - } else { - /* disable mcs rate */ - tlv->ht_cap.supported_mcs_set[0] = 0; - tlv->ht_cap.supported_mcs_set[4] = 0; - tlv->ht_cap.supported_mcs_set[1] = 0; - } - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "HTCapInfo") == 0) { - if (enable_11n <= 0) { - printf("ERR: Enable11n parameter should be set before HTCapInfo.\n"); - ret = UAP_FAILURE; - goto done; - } - if ((IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE) || - ((((t_u16)A2HEXDECIMAL(args[1])) & - (~HT_CAP_CONFIG_MASK)) != HT_CAP_CHECK_MASK)) { - printf("ERR: Invalid HTCapInfo value\n"); - ret = UAP_FAILURE; - goto done; - } - - /* Find HT tlv pointer in buffer and set HTCapInfo */ - tlvbuf_htcap_t *tlv = NULL; - tlv = (tlvbuf_htcap_t *)(buffer + tlv_offset_11n); - tlv->ht_cap.ht_cap_info = - DEFAULT_HT_CAP_VALUE & ~HT_CAP_CONFIG_MASK; - tlv->ht_cap.ht_cap_info |= - (t_u16)A2HEXDECIMAL(args[1]) & - HT_CAP_CONFIG_MASK; - tlv->ht_cap.ht_cap_info = - uap_cpu_to_le16(tlv->ht_cap.ht_cap_info); - } - if (strcmp(args[0], "AMPDU") == 0) { - if (enable_11n <= 0) { - printf("ERR: Enable11n parameter should be set before AMPDU.\n"); - ret = UAP_FAILURE; - goto done; - } - if ((IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE) || - ((A2HEXDECIMAL(args[1])) > AMPDU_CONFIG_MASK)) { - printf("ERR: Invalid AMPDU value\n"); - ret = UAP_FAILURE; - goto done; - } - - /* Find HT tlv pointer in buffer and set AMPDU */ - tlvbuf_htcap_t *tlv = NULL; - tlv = (tlvbuf_htcap_t *)(buffer + tlv_offset_11n); - tlv->ht_cap.ampdu_param = - (t_u8)A2HEXDECIMAL(args[1]) & AMPDU_CONFIG_MASK; - } - if (strcmp(args[0], "HT_MCS_MAP") == 0) { - if (enable_11n <= 0) { - printf("ERR: Enable11n parameter should be set before HT_MCS_MAP.\n"); - ret = UAP_FAILURE; - goto done; - } - if (0 == get_fw_info(&fw)) { - /* Check upper nibble of MCS support value - * and block MCS_SET_1 when 2X2 is not supported - * by the underlying hardware */ - if (((fw.hw_dev_mcs_support & 0xf0) < - STREAM_2X2_MASK) && - (A2HEXDECIMAL(args[1]) & MCS_SET_1_MASK)) { - printf("ERR: Invalid HT_MCS_MAP\n"); - goto done; - } - } - - /* Find HT tlv pointer in buffer and set supported MCS set */ - tlvbuf_htcap_t *tlv = NULL; - tlv = (tlvbuf_htcap_t *)(buffer + tlv_offset_11n); - supported_mcs_set = (t_u32)A2HEXDECIMAL(args[1]); - supported_mcs_set = uap_cpu_to_le32(supported_mcs_set); - memcpy(tlv->ht_cap.supported_mcs_set, - &supported_mcs_set, sizeof(t_u32)); - } - if (strcmp(args[0], "Enable2040Coex") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0) || - (atoi(args[1]) > 1)) { - printf("ERR: Invalid Enable2040Coex value\n"); - ret = UAP_FAILURE; - goto done; - } - tlvbuf_2040_coex *tlv = NULL; - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_2040_coex); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append 2040 coex TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_2040_coex *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_2040_BSS_COEX_CONTROL_TLV_ID; - tlv->length = 1; - tlv->enable = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } - if (strcmp(args[0], "PreambleType") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0) || - (atoi(args[1]) > 2)) { - printf("ERR: Invalid PreambleType value\n"); - ret = UAP_FAILURE; - goto done; - } - - /* Append a new TLV */ - tlvbuf_preamble_ctl *tlv = NULL; - tlv_len = sizeof(tlvbuf_preamble_ctl); - tmp_buffer = realloc(buffer, cmd_len + tlv_len); - if (!tmp_buffer) { - printf("ERR:Cannot append preamble type TLV!\n"); - ret = UAP_FAILURE; - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_preamble_ctl *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - tlv->tag = MRVL_PREAMBLE_CTL_TLV_ID; - tlv->length = 1; - tlv->preamble_type = (t_u8)atoi(args[1]); - endian_convert_tlv_header_out(tlv); - } -#if DEBUG - if (cmd_len != 0) { - hexdump("Command Buffer", (void *)cmd_buf, cmd_len, - ' '); - } -#endif - } -done: - fclose(config_file); - if (buffer) - free(buffer); - if (line) - free(line); - return ret; -} - -/** - * @brief Get band from current channel - * @param band - * @return UAP_SUCCESS/UAP_FAILURE - */ -static int -get_band(int *band) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_channel_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len; - int ret = UAP_SUCCESS; - - /* Initialize the command length */ - cmd_len = - sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_channel_config); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(cmd_len); - - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = UAP_FAILURE; - goto done; - } - memset(buffer, 0, cmd_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_channel_config *)(buffer + - sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_CHANNELCONFIG_TLV_ID; - tlv->length = sizeof(tlvbuf_channel_config) - TLVHEADER_LEN; - cmd_buf->action = ACTION_GET; - - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, cmd_len); - endian_convert_tlv_header_in(tlv); - - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_CHANNELCONFIG_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - ret = UAP_FAILURE; - goto done; - } - if (cmd_buf->result == CMD_SUCCESS) { - if (tlv->chan_number > MAX_CHANNELS_BG) - *band = BAND_A; - else - *band = BAND_B | BAND_G; - } else { - printf("ERR:Could not get band!\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command sending failed!\n"); - ret = UAP_FAILURE; - goto done; - } -done: - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Show usage information for the cfg_80211d command - * - * $return N/A - */ -void -print_apcmd_cfg_80211d_usage(void) -{ - printf("\nUsage: cfg_80211d \n"); - return; -} - -/** - * @brief Show usage information for the uap_stats command - * - * $return N/A - */ -void -print_apcmd_uap_stats(void) -{ - printf("Usage: uap_stats \n"); - return; -} - -/** - * SNMP MIB OIDs Table - */ -static oids_table snmp_oids[] = { - {0x0b, 4, "dot11LocalTKIPMICFailures"}, - {0x0c, 4, "dot11CCMPDecryptErrors"}, - {0x0d, 4, "dot11WEPUndecryptableCount"}, - {0x0e, 4, "dot11WEPICVErrorCount"}, - {0x0f, 4, "dot11DecryptFailureCount"}, - {0x12, 4, "dot11FailedCount"}, - {0x13, 4, "dot11RetryCount"}, - {0x14, 4, "dot11MultipleRetryCount"}, - {0x15, 4, "dot11FrameDuplicateCount"}, - {0x16, 4, "dot11RTSSuccessCount"}, - {0x17, 4, "dot11RTSFailureCount"}, - {0x18, 4, "dot11ACKFailureCount"}, - {0x19, 4, "dot11ReceivedFragmentCount"}, - {0x1a, 4, "dot11MulticastReceivedFrameCount"}, - {0x1b, 4, "dot11FCSErrorCount"}, - {0x1c, 4, "dot11TransmittedFrameCount"}, - {0x1d, 4, "dot11RSNATKIPCounterMeasuresInvoked"}, - {0x1e, 4, "dot11RSNA4WayHandshakeFailures"}, - {0x1f, 4, "dot11MulticastTransmittedFrameCount"} -}; - -/** - * @brief Get uAP stats - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_uap_stats(int argc, char *argv[]) -{ - t_u8 no_of_oids = sizeof(snmp_oids) / sizeof(snmp_oids[0]); - t_u16 i, j; - int size; - apcmdbuf_snmp_mib *cmd_buf = NULL; - t_u8 *buf = NULL; - tlvbuf_header *tlv = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int opt; - t_u16 oid_size, byte2 = 0; - t_u32 byte4 = 0; - int ret = UAP_SUCCESS; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_apcmd_uap_stats(); - return UAP_SUCCESS; - } - } - - argc -= optind; - argv += optind; - if (argc) { - printf("Error: Invalid Input\n"); - print_apcmd_uap_stats(); - return UAP_FAILURE; - } - - /** Command Header */ - cmd_len += sizeof(apcmdbuf_snmp_mib); - - for (i = 0; i < no_of_oids; i++) { - /** - * Size of Oid + Oid_value + Oid_size - */ - cmd_len += snmp_oids[i].len + sizeof(tlvbuf_header); - } - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - - /* Locate Headers */ - cmd_buf = (apcmdbuf_snmp_mib *)buf; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->cmd_code = HostCmd_SNMP_MIB; - cmd_buf->action = uap_cpu_to_le16(ACTION_GET); - - tlv = (tlvbuf_header *)((t_u8 *)cmd_buf + sizeof(apcmdbuf_snmp_mib)); - /* Add oid, oid_size and oid_value for each OID */ - for (i = 0; i < no_of_oids; i++) { - /** Copy Index as Oid */ - tlv->type = uap_cpu_to_le16(snmp_oids[i].type); - /** Copy its size */ - tlv->len = uap_cpu_to_le16(snmp_oids[i].len); - /** Next TLV */ - tlv = (tlvbuf_header *)&(tlv->data[snmp_oids[i].len]); - } - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - tlv = (tlvbuf_header *)((t_u8 *)cmd_buf + - sizeof(apcmdbuf_snmp_mib)); - - size = cmd_buf->size - (sizeof(apcmdbuf_snmp_mib) - - BUF_HEADER_SIZE); - - while ((unsigned int)size >= sizeof(tlvbuf_header)) { - tlv->type = uap_le16_to_cpu(tlv->type); - for (i = 0; i < no_of_oids; i++) { - if (snmp_oids[i].type == tlv->type) { - printf("%s: ", - snmp_oids[i].name); - break; - } - } - oid_size = uap_le16_to_cpu(tlv->len); - switch (oid_size) { - case 1: - printf("%d", - (unsigned int)tlv->data[0]); - break; - case 2: - memcpy(&byte2, &tlv->data[0], - sizeof(oid_size)); - printf("%d", - (unsigned int) - uap_le16_to_cpu(byte2)); - break; - case 4: - memcpy(&byte4, &tlv->data[0], - sizeof(oid_size)); - printf("%d", - (unsigned int) - uap_le32_to_cpu(byte4)); - break; - default: - for (j = 0; j < oid_size; j++) { - printf("%d ", - (t_u8)tlv->data[j]); - } - break; - } - /** Next TLV */ - tlv = (tlvbuf_header *)&(tlv->data[oid_size]); - size -= (sizeof(tlvbuf_header) + oid_size); - size = (size > 0) ? size : 0; - printf("\n"); - } - - } else { - printf("ERR:Command Response incorrect!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - free(buf); - return ret; -} - -/** - * @brief parser for sys_cfg_80211d input - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @param output Stores indexes for "state, country" - * arguments - * - * @return NA - * - */ -static void -parse_input_80211d(int argc, char **argv, int output[2][2]) -{ - int i, j, k = 0; - char *keywords[2] = { "state", "country" }; - - for (i = 0; i < 2; i++) - output[i][0] = -1; - - for (i = 0; i < argc; i++) { - for (j = 0; j < 2; j++) { - if (strcmp(argv[i], keywords[j]) == 0) { - output[j][1] = output[j][0] = i; - k = j; - break; - } - } - output[k][1] += 1; - } -} - -/** - * @brief Set/Get 802.11D country information - * - * Usage: cfg_80211d state country_code - * - * State 0 or 1 - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_cfg_80211d(int argc, char *argv[]) -{ - apcmdbuf_cfg_80211d *cmd_buf = NULL; - ieeetypes_subband_set_t *subband = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int output[2][2]; - int ret = UAP_SUCCESS; - int opt; - int status = 0; - int i, j; - t_u8 state = 0; - char country[4] = { ' ', ' ', 0, 0 }; - t_u8 sflag = 0, cflag = 0; - ieeetypes_subband_set_t sub_bands[MAX_SUB_BANDS]; - t_u8 no_of_sub_band = 0; - int band; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_apcmd_cfg_80211d_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - if (argc) { - if (strcmp(argv[0], "state") && strcmp(argv[0], "country")) { - printf("ERR: Incorrect input. Either state or country is needed."); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - /** SET */ - parse_input_80211d(argc, argv, output); - - /** State */ - if ((output[0][0] != -1) && (output[0][1] > output[0][0])) { - if ((output[0][1] - output[0][0]) != 2) { - printf("ERR: Invalid state inputs\n"); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - - if (IS_HEX_OR_DIGIT(argv[output[0][0] + 1]) == - UAP_FAILURE) { - printf("ERR: valid input for state are 0 or 1\n"); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - state = (t_u8)A2HEXDECIMAL(argv[output[0][0] + 1]); - - if ((state != 0) && (state != 1)) { - printf("ERR: valid input for state are 0 or 1 \n"); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - sflag = 1; - } - - /** Country */ - if ((output[1][0] != -1) && (output[1][1] > output[1][0])) { - if ((output[1][1] - output[1][0]) != 2) { - printf("ERR: Invalid country inputs\n"); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - if ((strlen(argv[output[1][0] + 1]) > 3) || - (strlen(argv[output[1][0] + 1]) == 0)) { - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - /* Only 2 characters of country code are copied here as indoor/outdoor - * conditions are not handled in domain file */ - strncpy(country, argv[output[1][0] + 1], 2); - - for (i = 0; (unsigned int)i < strlen(country); i++) { - if ((country[i] < 'A') || (country[i] > 'z')) { - printf("Invalid Country Code\n"); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - if (country[i] > 'Z') - country[i] = country[i] - 'a' + 'A'; - } - - cflag = 1; - if (!get_band(&band)) { - printf("ERR:couldn't get band from channel!\n"); - return UAP_FAILURE; - } - /** Get domain information from the file */ - no_of_sub_band = - parse_domain_file(country, band, sub_bands, - NULL); - if (no_of_sub_band == UAP_FAILURE) { - printf("Parsing Failed\n"); - return UAP_FAILURE; - } - } - if (get_bss_status(&status) != UAP_SUCCESS) { - printf("ERR:Cannot get current bss status!\n"); - return UAP_FAILURE; - } - if (status == UAP_BSS_START) { - printf("ERR: 11d status can not be changed after BSS start!\n"); - return UAP_FAILURE; - } - } - - if (argc && !cflag && !sflag) { - printf("ERR: Invalid input\n"); - print_apcmd_cfg_80211d_usage(); - return UAP_FAILURE; - } - - if (sflag && !cflag) { - /** - * Update MIB only and return - */ - if (sg_snmp_mib - (ACTION_SET, OID_80211D_ENABLE, sizeof(state), - &state) == UAP_SUCCESS) { - printf("802.11d %sd \n", state ? "enable" : "disable"); - return UAP_SUCCESS; - } else { - return UAP_FAILURE; - } - } - - cmd_len = sizeof(apcmdbuf_cfg_80211d); - - if (cflag) { - cmd_len += no_of_sub_band * sizeof(ieeetypes_subband_set_t); - } else { - /** Get */ - cmd_len += MAX_SUB_BANDS * sizeof(ieeetypes_subband_set_t); - } - - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_cfg_80211d *)buf; - cmd_len = argc ? cmd_len : - /** Set */ - (sizeof(apcmdbuf_cfg_80211d) - sizeof(domain_param_t)); - /** Get */ - - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = argc ? ACTION_SET : ACTION_GET; - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - - if (cflag) { - /* third character of country code is copied here as indoor/outdoor - * condition is not supported in domain file*/ - strncpy(country, argv[output[1][0] + 1], sizeof(country) - 1); - for (i = 0; (unsigned int)i < strlen(country); i++) { - if ((country[i] < 'A') || (country[i] > 'z')) { - printf("Invalid Country Code\n"); - print_apcmd_cfg_80211d_usage(); - free(buf); - return UAP_FAILURE; - } - if (country[i] > 'Z') - country[i] = country[i] - 'a' + 'A'; - } - cmd_buf->domain.tag = uap_cpu_to_le16(TLV_TYPE_DOMAIN); - cmd_buf->domain.length = uap_cpu_to_le16(sizeof(domain_param_t) - - BUF_HEADER_SIZE - + - (no_of_sub_band * - sizeof - (ieeetypes_subband_set_t))); - - memset(cmd_buf->domain.country_code, ' ', - sizeof(cmd_buf->domain.country_code)); - memcpy(cmd_buf->domain.country_code, country, strlen(country)); - memcpy(cmd_buf->domain.subband, sub_bands, - no_of_sub_band * sizeof(ieeetypes_subband_set_t)); - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - if (argc) { - printf("Set executed successfully\n"); - if (sflag) { - if (sg_snmp_mib - (ACTION_SET, OID_80211D_ENABLE, - sizeof(state), - &state) == UAP_SUCCESS) { - printf("802.11d %sd \n", - state ? "enable" : - "disable"); - } - } - } else { - j = uap_le16_to_cpu(cmd_buf->domain.length); - if (sg_snmp_mib - (ACTION_GET, OID_80211D_ENABLE, - sizeof(state), &state) - == UAP_SUCCESS) { - printf("State = %sd\n", - state ? "enable" : "disable"); - } - - if (cmd_buf->domain.country_code[0] || - cmd_buf->domain.country_code[1] || - cmd_buf->domain.country_code[2]) { - printf("Country string = %c%c%c", - cmd_buf->domain.country_code[0], - cmd_buf->domain.country_code[1], - cmd_buf->domain.country_code[2]); - j -= sizeof(cmd_buf->domain. - country_code); - subband = - (ieeetypes_subband_set_t *) - cmd_buf->domain.subband; - printf("\nSub-band info="); - printf("\t(1st, #chan, MAX-power) \n"); - for (i = 0; i < (j / 3); i++) { - printf("\t\t(%d, \t%d, \t%d dbm)\n", subband->first_chan, subband->no_of_chan, subband->max_tx_pwr); - subband++; - } - } - } - } else { - printf("ERR:Command Response incorrect!\n"); - if (argc) - printf("11d info is allowed to set only before bss start.\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - free(buf); - return ret; -} - -/** - * @brief Creates a sys_config request and sends to the driver - * - * Usage: "Usage : sys_config [CONFIG_FILE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_config(int argc, char *argv[]) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len; - t_u16 buf_len; - int ret = UAP_SUCCESS; - int opt; - char **argv_dummy = NULL; - ps_mgmt pm; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_config_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_sys_config_usage(); - return UAP_FAILURE; - } - if (argc == 1) { - /* Read profile and send command to firmware */ - ret = apcmd_sys_config_profile(argc, argv); - return ret; - } - - /** Query AP's setting */ - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - - /* Alloc buf for command */ - buf = (t_u8 *)malloc(buf_len); - - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - - /* Reset custom_ie_present flag */ - custom_ie_present = 0; - - /* Reset max_mgmt_ie_print flag */ - max_mgmt_ie_print = 0; - - /* Locate headers */ - cmd_len = sizeof(apcmdbuf_sys_configure); - cmd_buf = (apcmdbuf_sys_configure *)buf; - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - free(buf); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("AP settings:\n"); - print_tlv(buf + sizeof(apcmdbuf_sys_configure), - cmd_buf->size - - sizeof(apcmdbuf_sys_configure) + - BUF_HEADER_SIZE); - if (apcmd_addbapara(1, argv_dummy) == UAP_FAILURE) { - printf("Couldn't get ADDBA parameters\n"); - free(buf); - return UAP_FAILURE; - } - if (apcmd_aggrpriotbl(1, argv_dummy) == UAP_FAILURE) { - printf("Couldn't get AMSDU/AMPDU priority table\n"); - free(buf); - return UAP_FAILURE; - } - if (apcmd_addbareject(1, argv_dummy) == UAP_FAILURE) { - printf("Couldn't get ADDBA reject table\n"); - free(buf); - return UAP_FAILURE; - } - printf("\n802.11D setting:\n"); - if (apcmd_cfg_80211d(1, argv_dummy) == UAP_FAILURE) { - free(buf); - return UAP_FAILURE; - } - if (!custom_ie_present) { - printf("\nCustom IE settings:\n"); - if (apcmd_sys_cfg_custom_ie(1, argv_dummy) == - UAP_FAILURE) { - free(buf); - return UAP_FAILURE; - } - } - } else { - printf("ERR:Could not retrieve system configure\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - free(buf); - memset(&pm, 0, sizeof(ps_mgmt)); - ret = send_power_mode_ioctl(&pm, 0); - return ret; -} - -/** Update domain info with given country and band - * - * @param country_80211d country to be set - * @param band band of operation - * @return UAP_SUCCESS/UAP_FAILURE - */ -static int -update_domain_info(char *country_80211d, int band) -{ - apcmdbuf_cfg_80211d *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - ieeetypes_subband_set_t sub_bands[MAX_SUB_BANDS]; - t_u8 no_of_sub_band = 0; - char country[4] = { ' ', ' ', 0, 0 }; - int ret = UAP_SUCCESS; - t_u8 domain_code = 0; - rgn_dom_code_t *prgn_dom_code = NULL; - - /* Get currently set country code from FW */ - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_cfg_80211d *)buf; - cmd_len = (sizeof(apcmdbuf_cfg_80211d) - sizeof(domain_param_t)); - - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = ACTION_GET; - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if ((ret == UAP_SUCCESS) && (cmd_buf->result == CMD_SUCCESS) && - (cmd_buf->domain.country_code[0] || - cmd_buf->domain.country_code[1] || - cmd_buf->domain.country_code[2])) { - country[0] = cmd_buf->domain.country_code[0]; - country[1] = cmd_buf->domain.country_code[1]; - } else { - /* country_80211d will only be used if country code is not already set */ - country[0] = country_80211d[0]; - country[1] = country_80211d[1]; - } - - if (band == BAND_A) - printf("Enabling 11d for 11h operation and setting country code to %s\n", country); - cmd_len = sizeof(apcmdbuf_cfg_80211d); - /** Get domain information from the file */ - no_of_sub_band = - parse_domain_file(country, band, sub_bands, &domain_code); - if (no_of_sub_band == UAP_FAILURE) { - printf("Parsing Failed\n"); - ret = UAP_FAILURE; - goto done; - } - /* Copy third character of country code here */ - if (cmd_buf->domain.country_code[2]) { - country[2] = cmd_buf->domain.country_code[2]; - } else { - country[2] = country_80211d[2]; - } - - /* Set domain for this country code */ - memset(buf, 0, buf_len); - cmd_len += no_of_sub_band * sizeof(ieeetypes_subband_set_t); - /* Locate headers */ - cmd_buf = (apcmdbuf_cfg_80211d *)buf; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = ACTION_SET; - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - - cmd_buf->domain.tag = uap_cpu_to_le16(TLV_TYPE_DOMAIN); - cmd_buf->domain.length = uap_cpu_to_le16(sizeof(domain_param_t) - - BUF_HEADER_SIZE - + - (no_of_sub_band * - sizeof - (ieeetypes_subband_set_t))); - - memset(cmd_buf->domain.country_code, ' ', - sizeof(cmd_buf->domain.country_code)); - memcpy(cmd_buf->domain.country_code, country, strlen(country)); - memcpy(cmd_buf->domain.subband, sub_bands, - no_of_sub_band * sizeof(ieeetypes_subband_set_t)); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if (ret == UAP_SUCCESS) { - if (cmd_buf->result != CMD_SUCCESS) { - printf("ERR:Command Response incorrect!\n"); - printf("11d info is allowed to set only before bss start.\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - if ((band == BAND_A) && domain_code) { - /* Send 11D_CMD a second time, with reg_dom_code TLV appended. - * Use hostcmd instead of re-route. */ - cmd_len = cmd_buf->size + BUF_HEADER_SIZE; - prgn_dom_code = (rgn_dom_code_t *)((t_u8 *)cmd_buf + cmd_len); - cmd_len += sizeof(rgn_dom_code_t); - cmd_buf->size += sizeof(rgn_dom_code_t); -#if DEBUG - uap_printf(MSG_DEBUG, - "Adding Region Domain Code TLV. Domain_code=%d\n", - domain_code); -#endif - prgn_dom_code->tag = - uap_cpu_to_le16(MRVL_REGION_DOMAIN_CODE_TLV_ID); - prgn_dom_code->length = uap_cpu_to_le16(sizeof(rgn_dom_code_t) - - BUF_HEADER_SIZE); - prgn_dom_code->domain_code = domain_code; - - /* Send the command */ - uap_ioctl_no_reroute = 1; - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - uap_ioctl_no_reroute = 0; - - if (ret == UAP_SUCCESS) { - if (cmd_buf->result != CMD_SUCCESS) { - printf("ERR:Command Response incorrect!\n"); - printf("11d info is allowed to set only before bss start.\n"); - ret = UAP_FAILURE; - goto done; - } - } else { - printf("ERR:Command sending failed!\n"); - } - } - -done: - if (buf) - free(buf); - return ret; -} - -/** - * @brief Covert MCS Rate Bitmap to MCS Rate index - * - * @param rate_bitmap Pointer to rate bitmap - * @param size Size of the bitmap array - * - * @return Rate index - */ -int -get_rate_index_from_bitmap(t_u16 *rate_bitmap, int size) -{ - int i; - - for (i = 0; i < size * 8; i++) { - if (rate_bitmap[i / 16] & (1 << (i % 16))) { - return i; - } - } - return 0; -} - -/** - * @brief Checks current system configuration - * - * @param buf pointer to TLV buffer - * @param len TLV buffer length - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -check_sys_config(t_u8 *buf, t_u16 len) -{ - tlvbuf_header *pcurrent_tlv = (tlvbuf_header *)buf; - int tlv_buf_left = len; - t_u16 tlv_type; - t_u16 tlv_len; - tlvbuf_channel_config *channel_tlv = NULL; - tlvbuf_channel_list *chnlist_tlv = NULL; - tlvbuf_pwk_cipher *pwk_cipher_tlv = NULL; - tlvbuf_gwk_cipher *gwk_cipher_tlv = NULL; - tlvbuf_auth_mode *auth_tlv = NULL; - tlvbuf_protocol *protocol_tlv = NULL; - tlvbuf_wep_key *wep_key_tlv = NULL; - tlvbuf_wpa_passphrase *passphrase_tlv = NULL; - tlvbuf_rates *rates_tlv = NULL; - tlvbuf_mcbc_data_rate *mcbc_data_rate_tlv = NULL; - t_u16 protocol = 0; - t_u16 mcbc_data_rate = 0; - t_u16 op_rates_len = 0; - t_u8 acs_mode_enabled = 0; - t_u8 *cbuf = NULL; - apcmdbuf_cfg_80211d *cmd_buf = NULL; - t_u16 buf_len, cmd_len; - char country_80211d[4] = { 'U', 'S', ' ', 0 }; - t_u8 state_80211h = 0; - int channel_tlv_band = BAND_B | BAND_G; - t_u8 secondary_ch_set = 0; - int scan_channels_band = BAND_B | BAND_G; - t_u8 state_80211d = 0; - t_u8 rate = 0; - t_u32 rate_bitmap = 0; - tlvbuf_htcap_t *ht_cap_tlv = NULL; - t_u16 enable_40Mhz = 0; - t_u16 enable_20Mhz_sgi = 0; - t_u16 enable_gf = 0; - t_u8 enable_11n = 0; - int flag = 0; - fw_info fw; - channel_list *pchan_list; - tlvbuf_tx_power *txpower_tlv = NULL; - int i = 0, ret = UAP_SUCCESS; - int pairwise_cipher_wpa = -1; - int pairwise_cipher_wpa2 = -1; - int group_cipher = -1; - int chan_list_len = 0; - int key_set = 0; - t_u8 channel = 0; - tx_rate_cfg_t tx_rate_config; - t_u32 mcs_rate_index = 0; - struct eth_priv_vhtcfg vhtcfg = { 0 }; - -#define BITMAP_RATE_1M 0x01 -#define BITMAP_RATE_2M 0x02 -#define BITMAP_RATE_5_5M 0x04 -#define BITMAP_RATE_11M 0x8 -#define B_RATE_MANDATORY 0x0f - - if (pcurrent_tlv == NULL) { - printf("ERR: No TLV buffer available!\n"); - return UAP_FAILURE; - } - - ret = sg_snmp_mib(ACTION_GET, OID_80211D_ENABLE, sizeof(state_80211d), - &state_80211d); - - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - cbuf = (t_u8 *)malloc(buf_len); - if (!cbuf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(cbuf, 0, buf_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_cfg_80211d *)cbuf; - cmd_len = (sizeof(apcmdbuf_cfg_80211d) - sizeof(domain_param_t)); - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->action = uap_cpu_to_le16(ACTION_GET); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if (ret == UAP_SUCCESS && cmd_buf->result == CMD_SUCCESS) { - if (cmd_buf->domain.country_code[0] || - cmd_buf->domain.country_code[1] || - cmd_buf->domain.country_code[2]) { - strncpy(country_80211d, - (char *)cmd_buf->domain.country_code, - COUNTRY_CODE_LEN); - } - } - free(cbuf); - - /* get region code to handle special cases */ - memset(&fw, 0, sizeof(fw)); - if (get_fw_info(&fw)) { - printf("Could not get fw info!\n"); - return UAP_FAILURE; - } - - if (get_tx_rate_cfg(&tx_rate_config) == UAP_FAILURE) { - printf("Could not get tx_rate_cfg!\n"); - return UAP_FAILURE; - } - while (tlv_buf_left >= (int)sizeof(tlvbuf_header) && - (ret != UAP_FAILURE)) { - tlv_type = *(t_u8 *)&pcurrent_tlv->type; - tlv_type |= (*((t_u8 *)&pcurrent_tlv->type + 1) << 8); - tlv_len = *(t_u8 *)&pcurrent_tlv->len; - tlv_len |= (*((t_u8 *)&pcurrent_tlv->len + 1) << 8); - if ((sizeof(tlvbuf_header) + tlv_len) > - (unsigned int)tlv_buf_left) { - printf("wrong tlv: tlv_len=%d, tlv_buf_left=%d\n", - tlv_len, tlv_buf_left); - break; - } - switch (tlv_type) { - case MRVL_CHANNELCONFIG_TLV_ID: - channel_tlv = (tlvbuf_channel_config *)pcurrent_tlv; - channel = channel_tlv->chan_number; - - if ((!state_80211d) && - (channel_tlv->chan_number == MAX_CHANNELS_BG) - && - (strncmp(country_80211d, "JP", COUNTRY_CODE_LEN - 1) - == 0) - ) { - printf("ERR: Invalid channel 14, 802.11d disabled, country code JP!\n"); - return UAP_FAILURE; - } - if (channel_tlv->bandcfg.chanBand == BAND_5GHZ) - channel_tlv_band = BAND_A; - secondary_ch_set = channel_tlv->bandcfg.chan2Offset; - if (channel_tlv_band != BAND_A) { - /* When country code is not Japan, allow channels 5-11 for US and 5-13 for non-US - * only for secondary channel below */ - if (secondary_ch_set == SEC_CHAN_BELOW) { - if (!strncmp - (country_80211d, "US", - COUNTRY_CODE_LEN - 1)) { - if (channel_tlv->chan_number > - DEFAULT_MAX_CHANNEL_BELOW) { - printf("ERR: Only channels 5-11 are allowed with secondary channel below for the US\n"); - return UAP_FAILURE; - } - } else if (strncmp - (country_80211d, "JP", - COUNTRY_CODE_LEN - 1)) { - if (channel_tlv->chan_number > - DEFAULT_MAX_CHANNEL_BELOW_NON_US) - { - printf("ERR: Only channels 5-13 are allowed with secondary channel below for" "non-Japan countries!\n"); - return UAP_FAILURE; - } - } - } - - /* When country code is not Japan, allow channels 1-7 for US and 1-9 for non-US - * only for secondary channel above */ - if (secondary_ch_set == SEC_CHAN_ABOVE) { - if (!strncmp - (country_80211d, "US", - COUNTRY_CODE_LEN - 1)) { - if (channel_tlv->chan_number > - DEFAULT_MAX_CHANNEL_ABOVE) { - printf("ERR: Only channels 1-7 are allowed with secondary channel above for the US\n"); - return UAP_FAILURE; - } - } else if (strncmp - (country_80211d, "JP", - COUNTRY_CODE_LEN - 1)) { - if (channel_tlv->chan_number > - DEFAULT_MAX_CHANNEL_ABOVE_NON_US) - { - printf("ERR: Only channels 1-9 are allowed with secondary channel above for" "non-Japan countries!\n"); - return UAP_FAILURE; - } - } - } - } - if (!(channel_tlv->bandcfg.scanMode == SCAN_MODE_ACS)) { - if (check_channel_validity_11d - (channel_tlv->chan_number, channel_tlv_band, - 1) == UAP_FAILURE) - return UAP_FAILURE; - if (state_80211d) { - /* Set country code to JP if channel is 8 or 12 and band is 5GHZ */ - if ((channel_tlv->chan_number < - MAX_CHANNELS_BG) && - (channel_tlv_band == BAND_A)) - strncpy(country_80211d, "JP ", - sizeof(country_80211d) - - 1); - } else { - if ((channel_tlv_band == BAND_A) && - ((channel_tlv->chan_number == 8) || - (channel_tlv->chan_number == - 12))) { - printf("ERR:Invalid band for given channel\n"); - return UAP_FAILURE; - } - } - } else { - acs_mode_enabled = 1; - } -#define JP_REGION_0xFE 0xFE - if (fw.region_code == JP_REGION_0xFE && - ((channel_tlv->chan_number == 12) || - (channel_tlv->chan_number == 13))) { - printf("ERR:Channel 12 or 13 is not allowed for region code 0xFE\n"); - return UAP_FAILURE; - } - break; - case MRVL_CHANNELLIST_TLV_ID: - chnlist_tlv = (tlvbuf_channel_list *)pcurrent_tlv; - pchan_list = - (channel_list *) & (chnlist_tlv->chan_list); - if (tlv_len % sizeof(channel_list)) { - printf("ERR:Invalid Scan channel list TLV!\n"); - return UAP_FAILURE; - } - chan_list_len = tlv_len / sizeof(channel_list); - - for (i = 0; i < chan_list_len; i++) { - scan_channels_band = BAND_B | BAND_G; - if ((scan_channels_band != BAND_A) && - (pchan_list->bandcfg.chanBand == - BAND_5GHZ)) { - scan_channels_band = BAND_A; - } - if (check_channel_validity_11d - (pchan_list->chan_number, - scan_channels_band, 0) == UAP_FAILURE) - return UAP_FAILURE; - pchan_list++; - } - break; - case MRVL_TX_POWER_TLV_ID: - txpower_tlv = (tlvbuf_tx_power *)pcurrent_tlv; - if (state_80211d) { - if (check_tx_pwr_validity_11d - (txpower_tlv->tx_power_dbm) == UAP_FAILURE) - return UAP_FAILURE; - } - break; - case MRVL_CIPHER_PWK_TLV_ID: - pwk_cipher_tlv = (tlvbuf_pwk_cipher *)pcurrent_tlv; - pwk_cipher_tlv->protocol = - uap_le16_to_cpu(pwk_cipher_tlv->protocol); - if (pwk_cipher_tlv->protocol == PROTOCOL_WPA) - pairwise_cipher_wpa = - pwk_cipher_tlv->pairwise_cipher; - else if (pwk_cipher_tlv->protocol == PROTOCOL_WPA2) - pairwise_cipher_wpa2 = - pwk_cipher_tlv->pairwise_cipher; - break; - case MRVL_CIPHER_GWK_TLV_ID: - gwk_cipher_tlv = (tlvbuf_gwk_cipher *)pcurrent_tlv; - group_cipher = gwk_cipher_tlv->group_cipher; - break; - case MRVL_AUTH_TLV_ID: - auth_tlv = (tlvbuf_auth_mode *)pcurrent_tlv; - break; - case MRVL_PROTOCOL_TLV_ID: - protocol_tlv = (tlvbuf_protocol *)pcurrent_tlv; - protocol = uap_le16_to_cpu(protocol_tlv->protocol); - break; - case MRVL_WPA_PASSPHRASE_TLV_ID: - passphrase_tlv = (tlvbuf_wpa_passphrase *)pcurrent_tlv; - break; - case MRVL_WEP_KEY_TLV_ID: - wep_key_tlv = (tlvbuf_wep_key *)pcurrent_tlv; - if (wep_key_tlv->is_default) { - key_set = 1; - } - break; - case HT_CAPABILITY_TLV_ID: - ht_cap_tlv = (tlvbuf_htcap_t *)pcurrent_tlv; - ht_cap_tlv->ht_cap.ht_cap_info = - uap_le16_to_cpu(ht_cap_tlv->ht_cap.ht_cap_info); - if (ht_cap_tlv->ht_cap.supported_mcs_set[0]) { - enable_11n = 1; - enable_40Mhz = - IS_11N_40MHZ_ENABLED(ht_cap_tlv->ht_cap. - ht_cap_info); - enable_20Mhz_sgi = - IS_11N_20MHZ_SHORTGI_ENABLED - (ht_cap_tlv->ht_cap.ht_cap_info); - enable_gf = - IS_11N_GF_ENABLED(ht_cap_tlv->ht_cap. - ht_cap_info); - } - break; - case MRVL_RATES_TLV_ID: - rates_tlv = (tlvbuf_rates *)pcurrent_tlv; - op_rates_len = tlv_len; - break; - case MRVL_MCBC_DATA_RATE_TLV_ID: - mcbc_data_rate_tlv = - (tlvbuf_mcbc_data_rate *)pcurrent_tlv; - mcbc_data_rate = - uap_le16_to_cpu(mcbc_data_rate_tlv-> - mcbc_datarate); - if (mcbc_data_rate && - (is_mcbc_rate_valid((t_u8)mcbc_data_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid MCBC Data Rate \n"); - return UAP_FAILURE; - } - break; - } - tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); - pcurrent_tlv = (tlvbuf_header *)(pcurrent_tlv->data + tlv_len); - } - - if ((protocol == PROTOCOL_STATIC_WEP) && !key_set) { - printf("ERR:WEP keys not set!\n"); - return UAP_FAILURE; - } - if (auth_tlv == NULL) { - printf("ERR: No authentication found\n"); - return UAP_FAILURE; - } - if ((auth_tlv->auth_mode == 1) && (protocol != PROTOCOL_STATIC_WEP)) { - printf("ERR:Shared key authentication is not allowed for Open/WPA/WPA2/Mixed mode\n"); - return UAP_FAILURE; - } - - if (passphrase_tlv == NULL) { - printf("ERR: No passphrase found\n"); - return UAP_FAILURE; - } - if (((protocol == PROTOCOL_WPA) || (protocol == PROTOCOL_WPA2) - || (protocol == PROTOCOL_WPA3_SAE) - || (protocol == PROTOCOL_WPA2_MIXED)) - && !(passphrase_tlv->length)) { - printf("ERR:Passphrase must be set for WPA/WPA2/Mixed/WPA3 SAE mode\n"); - return UAP_FAILURE; - } - if ((protocol == PROTOCOL_WPA) || (protocol == PROTOCOL_WPA2_MIXED)) { - if (is_cipher_valid(pairwise_cipher_wpa, group_cipher) != - UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA pairwise cipher combination!\n"); - return UAP_FAILURE; - } - } - if ((protocol == PROTOCOL_WPA2) || (protocol == PROTOCOL_WPA2_MIXED) - || (protocol == PROTOCOL_WPA3_SAE) - ) { - if (is_cipher_valid(pairwise_cipher_wpa2, group_cipher) != - UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA2 pairwise cipher combination!\n"); - return UAP_FAILURE; - } - } - - if (chnlist_tlv == NULL) { - printf("ERR: No channel list found\n"); - return UAP_FAILURE; - } - if (acs_mode_enabled) { - pchan_list = (channel_list *) & (chnlist_tlv->chan_list); - for (i = 0; i < chan_list_len; i++) { - if ((!state_80211d) && - (pchan_list->chan_number == MAX_CHANNELS_BG) - && - (strncmp(country_80211d, "JP", COUNTRY_CODE_LEN - 1) - == 0) - ) { - printf("ERR: Invalid scan channel 14, 802.11d disabled, country code JP!\n"); - return UAP_FAILURE; - } - - if (fw.region_code == JP_REGION_0xFE && - ((pchan_list->chan_number == 12) || - (pchan_list->chan_number == 13))) { - printf("ERR:Scan Channel 12 or 13 is not allowed for region code 0xFE\n"); - return UAP_FAILURE; - } - pchan_list++; - } - - if (!state_80211d) { - /* Block scan channels 8 and 12 in 5GHz band if 11d is not enabled and country code not set to JP */ - pchan_list = - (channel_list *) & (chnlist_tlv->chan_list); - for (i = 0; i < chan_list_len; i++) { - if ((pchan_list->bandcfg.chanBand == BAND_5GHZ) - && ((pchan_list->chan_number == 8) || - (pchan_list->chan_number == 12))) { - printf("ERR: Invalid band for scan channel %d\n", pchan_list->chan_number); - return UAP_FAILURE; - } - pchan_list++; - } - } - if (state_80211d) { - /* Set default country code to US */ - strncpy(country_80211d, "US ", - sizeof(country_80211d) - 1); - pchan_list = - (channel_list *) & (chnlist_tlv->chan_list); - for (i = 0; i < chan_list_len; i++) { - /* Set country code to JP if channel is 8 or 12 and band is 5GHZ */ - if ((pchan_list->chan_number < MAX_CHANNELS_BG) - && (scan_channels_band == BAND_A)) { - strncpy(country_80211d, "JP ", - sizeof(country_80211d) - 1); - } - if (check_channel_validity_11d - (pchan_list->chan_number, - scan_channels_band, 0) == UAP_FAILURE) - return UAP_FAILURE; - pchan_list++; - } - if (update_domain_info - (country_80211d, - scan_channels_band) == UAP_FAILURE) { - return UAP_FAILURE; - } - } - } -#ifdef WIFI_DIRECT_SUPPORT - if (strncmp(dev_name, "wfd", 3)) -#endif - if ((!acs_mode_enabled && - (channel_tlv_band == (BAND_B | BAND_G))) - || (acs_mode_enabled && - (scan_channels_band == (BAND_B | BAND_G)))) { - if (rates_tlv == NULL) { - printf("ERR: No rates found\n"); - return UAP_FAILURE; - } - for (i = 0; i < op_rates_len; i++) { - rate = rates_tlv-> - operational_rates[i] & - ~BASIC_RATE_SET_BIT; - switch (rate) { - case 2: - rate_bitmap |= BITMAP_RATE_1M; - break; - case 4: - rate_bitmap |= BITMAP_RATE_2M; - break; - case 11: - rate_bitmap |= BITMAP_RATE_5_5M; - break; - case 22: - rate_bitmap |= BITMAP_RATE_11M; - break; - } - } - if ((rate_bitmap & B_RATE_MANDATORY) != - B_RATE_MANDATORY) { - if (acs_mode_enabled) - printf("ERR: Rates/Scan channels do not match!\n"); - else - printf("ERR: Rates/Channel do not match!\n"); - return UAP_FAILURE; - } - } - if ((!acs_mode_enabled && (channel_tlv_band == BAND_A)) - || (acs_mode_enabled && (scan_channels_band == BAND_A))) { - if (rates_tlv == NULL) { - printf("ERR: No rates found\n"); - return UAP_FAILURE; - } - for (i = 0; i < op_rates_len; i++) { - rate = rates_tlv-> - operational_rates[i] & ~BASIC_RATE_SET_BIT; - switch (rate) { - case 2: - case 4: - case 11: - case 22: - if (acs_mode_enabled) - printf("ERR: Rates/Scan channels do not match!\n"); - else - printf("ERR: Rates/Channel do not match!\n"); - return UAP_FAILURE; - } - } - state_80211h = 1; - if (sg_snmp_mib - (ACTION_SET, OID_80211H_ENABLE, sizeof(state_80211h), - &state_80211h) - == UAP_FAILURE) { - return UAP_FAILURE; - } - if (update_domain_info(country_80211d, BAND_A) == UAP_FAILURE) { - return UAP_FAILURE; - } - } -#define ISSUPP_CHANWIDTH40(Dot11nDevCap) (Dot11nDevCap & MBIT(17)) -#define ISSUPP_SHORTGI40(Dot11nDevCap) (Dot11nDevCap & MBIT(24)) - - if (enable_40Mhz) { - if (!ISSUPP_CHANWIDTH40(fw.hw_dot_11n_dev_cap)) { - printf("ERR: It's not support HT40 from Hardware Cap\n"); - return UAP_FAILURE; - } - } - - if (enable_11n) { - /*For protocol = Mixed, 11n enabled, only allow TKIP cipher for WPA protocol, not for WPA2 */ - if ((protocol == PROTOCOL_WPA2_MIXED) && - (pairwise_cipher_wpa2 == CIPHER_TKIP)) { - printf("ERR: WPA2 pairwise cipher cannot be TKIP when AP operates in 802.11n Mixed mode.\n"); - return UAP_FAILURE; - } else if (protocol == PROTOCOL_STATIC_WEP) { - printf("ERR: WEP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - if ((tx_rate_config.rate == UAP_RATE_INDEX_MCS32) && !enable_40Mhz) { - printf("ERR:uAP must be configured to operate in 40MHz if tx_rate is MCS32\n"); - return UAP_FAILURE; - } - if (enable_20Mhz_sgi && enable_gf) { - if ((tx_rate_config.rate >= UAP_RATE_INDEX_MCS0) && - (tx_rate_config.rate <= UAP_RATE_INDEX_MCS7)) { - printf("ERR: Invalid tx_rate for uAP in (20MHz Short GI + Green Field) mode\n"); - return UAP_FAILURE; - } - } - mcs_rate_index = - get_rate_index_from_bitmap(tx_rate_config.bitmap_rates, - sizeof(tx_rate_config.bitmap_rates)); - if ((mcs_rate_index >= UAP_RATE_BITMAP_MCS0) && - (mcs_rate_index <= UAP_RATE_BITMAP_MCS127)) { - mcs_rate_index -= (UAP_RATE_BITMAP_MCS0 - UAP_RATE_INDEX_MCS0); - if ((mcs_rate_index == UAP_RATE_INDEX_MCS32) & !enable_40Mhz) { - printf("ERR:uAP must be configured to operate in 40MHz if rate_bitmap contains MCS32\n"); - return UAP_FAILURE; - } - if (enable_20Mhz_sgi && enable_gf) { - if ((mcs_rate_index >= UAP_RATE_INDEX_MCS0) && - (mcs_rate_index <= UAP_RATE_INDEX_MCS7)) { - printf("ERR: Invalid tx_rate for uAP in (20MHz Short GI + Green Field) mode\n"); - return UAP_FAILURE; - } - } - } - - /* if 11d enabled, Channel 14, country code "JP", only B rates are allowed */ - if ((channel == 14) && state_80211d && - (strncmp(country_80211d, "JP", COUNTRY_CODE_LEN - 1) == 0)) { - if (rates_tlv == NULL) { - printf("ERR:No rates found\n"); - return UAP_FAILURE; - } - if (enable_11n) { - printf("ERR:11n must be disabled and the only B rates are allowed if 11d enabled and country code is JP with channel 14.\n"); - return UAP_FAILURE; - } - for (i = 0; i < op_rates_len; i++) { - rate = rates_tlv-> - operational_rates[i] & ~BASIC_RATE_SET_BIT; - switch (rate) { - case 2: - case 4: - case 11: - case 22: - break; - default: - printf("ERR:If 11d enabled, channel 14 and country code is JP, the only B rates are allowed.\n"); - return UAP_FAILURE; - } - } - } - - /* Channels 14, 165 are not allowed to operate in 40MHz mode */ - if (!acs_mode_enabled && enable_40Mhz) { - if ((channel == 14) - || (channel == 165) - ) { - printf("ERR:Invalid channel %d for 40MHz operation\n", - channel); - return UAP_FAILURE; - } else if (!secondary_ch_set) { - printf("ERR:Secondary channel should be set when 40Mhz is enabled!\n"); - return UAP_FAILURE; - } - } - /* Channels 14, 140, 165 are not allowed to operate in 40MHz mode */ - if (acs_mode_enabled && enable_40Mhz) { - if (chnlist_tlv == NULL) { - printf("ERR: No channel list found\n"); - return UAP_FAILURE; - } - pchan_list = (channel_list *) & (chnlist_tlv->chan_list); - for (i = 0; i < chan_list_len; i++) { - if ((pchan_list->chan_number != 14) - && (pchan_list->chan_number != 140) && - (pchan_list->chan_number != 165) - ) { - flag = 1; - break; - } - pchan_list++; - } - if (!flag) { - printf("ERR:Invalid channels in scan channel list for 40MHz operation\n"); - return UAP_FAILURE; - } - } - - if (0 == get_fw_info(&fw)) { - /*check whether support 802.11AC through BAND_AAC bit */ - if (fw.fw_bands & BAND_AAC) { - ret = get_802_11ac_cfg(&vhtcfg); - if (UAP_SUCCESS == ret) { - /* Note: When 11AC is disabled, FW sets vht_rx_mcs to 0xffff */ - if ((vhtcfg.vht_rx_mcs != 0xffff) && - (!enable_11n)) { - printf("ERR: 11ac enable while 11n disable, it is forbidden! \n"); - return UAP_FAILURE; - } - } else { - printf("Don't support 802.11AC \n"); - return UAP_SUCCESS; - } - } else - printf("No support 802 11AC.\n"); - } else { - printf("ERR: get_fw_info fail\n"); - return UAP_FAILURE; - } - - return ret; -} - -/** - * @brief Checks current bss configuration - * - * @param buf pointer to bss_config_t - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -check_bss_config(t_u8 *buf) -{ - bss_config_t *bss_config = NULL;; - t_u8 acs_mode_enabled = 0; - t_u8 *cbuf = NULL; - apcmdbuf_cfg_80211d *cmd_buf = NULL; - t_u16 buf_len, cmd_len; - char country_80211d[4] = { 'U', 'S', ' ', 0 }; - t_u8 state_80211h = 0; - int channel_tlv_band = BAND_B | BAND_G; - t_u8 secondary_ch_set = 0; - int scan_channels_band = BAND_B | BAND_G; - t_u8 state_80211d = 0; - t_u8 rate = 0; - t_u32 rate_bitmap = 0; - t_u16 enable_40Mhz = 0; - t_u16 enable_20Mhz_sgi = 0; - t_u16 enable_gf = 0; - t_u8 enable_11n = 0; - int flag = 0; - fw_info fw; - int i = 0, ret = UAP_SUCCESS; - tx_rate_cfg_t tx_rate_config; - t_u32 mcs_rate_index = 0; - struct eth_priv_vhtcfg vhtcfg = { 0 }; - -#define BITMAP_RATE_1M 0x01 -#define BITMAP_RATE_2M 0x02 -#define BITMAP_RATE_5_5M 0x04 -#define BITMAP_RATE_11M 0x8 -#define B_RATE_MANDATORY 0x0f - - if (NULL == buf) { - printf("ERR: No buffer for bss_configure!\n"); - return UAP_FAILURE; - } - - bss_config = (bss_config_t *)buf; - - ret = sg_snmp_mib(ACTION_GET, OID_80211D_ENABLE, sizeof(state_80211d), - &state_80211d); - - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - cbuf = (t_u8 *)malloc(buf_len); - if (!cbuf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(cbuf, 0, buf_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_cfg_80211d *)cbuf; - cmd_len = (sizeof(apcmdbuf_cfg_80211d) - sizeof(domain_param_t)); - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->action = uap_cpu_to_le16(ACTION_GET); - cmd_buf->cmd_code = HostCmd_CMD_802_11D_DOMAIN_INFO; - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - if (ret == UAP_SUCCESS && cmd_buf->result == CMD_SUCCESS) { - if (cmd_buf->domain.country_code[0] || - cmd_buf->domain.country_code[1] || - cmd_buf->domain.country_code[2]) { - strncpy(country_80211d, - (char *)cmd_buf->domain.country_code, - COUNTRY_CODE_LEN); - } - } - free(cbuf); - - /* get region code to handle special cases */ - memset(&fw, 0, sizeof(fw)); - if (get_fw_info(&fw)) { - printf("Could not get fw info!\n"); - return UAP_FAILURE; - } - - if (get_tx_rate_cfg(&tx_rate_config) == UAP_FAILURE) { - printf("Could not get tx_rate_cfg!\n"); - return UAP_FAILURE; - } - - if ((!state_80211d) && (bss_config->channel == MAX_CHANNELS_BG) - && (strncmp(country_80211d, "JP", COUNTRY_CODE_LEN - 1) == 0) - ) { - printf("ERR: Invalid channel 14, 802.11d disabled, country code JP!\n"); - return UAP_FAILURE; - } - - if ((fw.fw_bands & (BAND_B | BAND_G | BAND_GN | BAND_GAC)) - && !(fw.fw_bands & (BAND_A | BAND_AAC)) - ) { - if (bss_config->channel > MAX_CHANNELS_BG) { - printf("ERR: Invalid channel in 2.4GHz band!\n"); - return UAP_FAILURE; - } - } - - if (!(fw.fw_bands & (BAND_B | BAND_G | BAND_GN - | BAND_GAC)) && (fw.fw_bands & (BAND_A - | BAND_AAC))) { - if (bss_config->channel < 36 || - bss_config->channel > MAX_CHANNELS) { - printf("ERR: Invalid channel in 5GHz band!\n"); - return UAP_FAILURE; - } - } - if (bss_config->bandcfg.chanBand == BAND_5GHZ) - channel_tlv_band = BAND_A; - secondary_ch_set = bss_config->bandcfg.chan2Offset; - if (channel_tlv_band != BAND_A) { - /* When country code is not Japan, allow channels 5-11 for US and 5-13 for non-US - * only for secondary channel below */ - if (secondary_ch_set == SEC_CHAN_BELOW) { - if (!strncmp - (country_80211d, "US", COUNTRY_CODE_LEN - 1)) { - if (bss_config->channel > - DEFAULT_MAX_CHANNEL_BELOW) { - printf("ERR: Only channels 5-11 are allowed with secondary channel below for the US\n"); - return UAP_FAILURE; - } - } else if (strncmp - (country_80211d, "JP", - COUNTRY_CODE_LEN - 1)) { - if (bss_config->channel > - DEFAULT_MAX_CHANNEL_BELOW_NON_US) { - printf("ERR: Only channels 5-13 are allowed with secondary channel below for" "non-Japan countries!\n"); - return UAP_FAILURE; - } - } - } - - /* When country code is not Japan, allow channels 1-7 for US and 1-9 for non-US - * only for secondary channel above */ - if (secondary_ch_set == SEC_CHAN_ABOVE) { - if (!strncmp - (country_80211d, "US", COUNTRY_CODE_LEN - 1)) { - if (bss_config->channel > - DEFAULT_MAX_CHANNEL_ABOVE) { - printf("ERR: Only channels 1-7 are allowed with secondary channel above for the US\n"); - return UAP_FAILURE; - } - } else if (strncmp - (country_80211d, "JP", - COUNTRY_CODE_LEN - 1)) { - if (bss_config->channel > - DEFAULT_MAX_CHANNEL_ABOVE_NON_US) { - printf("ERR: Only channels 1-9 are allowed with secondary channel above for" "non-Japan countries!\n"); - return UAP_FAILURE; - } - } - } - } - - if (!(bss_config->bandcfg.scanMode == SCAN_MODE_ACS)) { - if (check_channel_validity_11d - (bss_config->channel, channel_tlv_band, 1) == UAP_FAILURE) - return UAP_FAILURE; - if (state_80211d) { - /* Set country code to JP if channel is 8 or 12 and band is 5GHZ */ - if ((bss_config->channel < MAX_CHANNELS_BG) && - (channel_tlv_band == BAND_A)) - strncpy(country_80211d, "JP ", - sizeof(country_80211d) - 1); - } else { - if ((channel_tlv_band == BAND_A) && - ((bss_config->channel == 8) || - (bss_config->channel == 12))) { - printf("ERR:Invalid band for given channel\n"); - return UAP_FAILURE; - } - } - } else { - acs_mode_enabled = 1; - } - -#define JP_REGION_0xFE 0xFE - if (fw.region_code == JP_REGION_0xFE && - ((bss_config->channel == 12) || (bss_config->channel == 13))) { - printf("ERR:Channel 12 or 13 is not allowed for region code 0xFE\n"); - return UAP_FAILURE; - } - - for (i = 0; i < bss_config->num_of_chan; i++) { - scan_channels_band = BAND_B | BAND_G; - if ((scan_channels_band != BAND_A) && - (bss_config->chan_list[i].bandcfg.chanBand == BAND_5GHZ)) { - scan_channels_band = BAND_A; - } - if (check_channel_validity_11d - (bss_config->chan_list[i].chan_number, scan_channels_band, - 0) == UAP_FAILURE) - return UAP_FAILURE; - } - - if (state_80211d) { - if (check_tx_pwr_validity_11d(bss_config->tx_power_level) == - UAP_FAILURE) - return UAP_FAILURE; - } - - if (bss_config->supported_mcs_set[0]) { - enable_11n = 1; - enable_40Mhz = IS_11N_40MHZ_ENABLED(bss_config->ht_cap_info); - enable_20Mhz_sgi = - IS_11N_20MHZ_SHORTGI_ENABLED(bss_config->ht_cap_info); - enable_gf = IS_11N_GF_ENABLED(bss_config->ht_cap_info); - } - - if (bss_config->mcbc_data_rate && - (is_mcbc_rate_valid(bss_config->mcbc_data_rate) != UAP_SUCCESS)) { - printf("ERR: Invalid MCBC Data Rate \n"); - return UAP_FAILURE; - } - - if ((bss_config->protocol == PROTOCOL_STATIC_WEP) - && (0 == bss_config->wep_cfg.key0.is_default) - && (0 == bss_config->wep_cfg.key1.is_default) - && (0 == bss_config->wep_cfg.key2.is_default) - && (0 == bss_config->wep_cfg.key3.is_default)) { - printf("ERR:WEP keys not set!\n"); - return UAP_FAILURE; - } - - if ((bss_config->auth_mode == 1) && - (bss_config->protocol != PROTOCOL_STATIC_WEP)) { - printf("ERR:Shared key authentication is not allowed for Open/WPA/WPA2/Mixed mode\n"); - return UAP_FAILURE; - } - - if (((bss_config->protocol == PROTOCOL_WPA) || - (bss_config->protocol == PROTOCOL_WPA2) - || (bss_config->protocol == PROTOCOL_WPA3_SAE) - || (bss_config->protocol == PROTOCOL_WPA2_MIXED)) && - !(bss_config->wpa_cfg.length)) { - printf("ERR:Passphrase must be set for WPA/WPA2/Mixed/WPA3 SAE mode\n"); - return UAP_FAILURE; - } - - if ((bss_config->protocol == PROTOCOL_WPA) || - (bss_config->protocol == PROTOCOL_WPA2_MIXED)) { - if (is_cipher_valid - (bss_config->wpa_cfg.pairwise_cipher_wpa, - bss_config->wpa_cfg.group_cipher) != UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA pairwise cipher combination!\n"); - return UAP_FAILURE; - } - } - if ((bss_config->protocol == PROTOCOL_WPA2) || - (bss_config->protocol == PROTOCOL_WPA2_MIXED) - || (bss_config->protocol == PROTOCOL_WPA3_SAE) - ) { - if (is_cipher_valid - (bss_config->wpa_cfg.pairwise_cipher_wpa2, - bss_config->wpa_cfg.group_cipher) != UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA2 pairwise cipher combination!\n"); - return UAP_FAILURE; - } - } - - if (0 == bss_config->num_of_chan) { - printf("ERR: No channel list found\n"); - return UAP_FAILURE; - } - - if (acs_mode_enabled) { - for (i = 0; i < bss_config->num_of_chan; i++) { - if ((!state_80211d) && - (bss_config->chan_list[i].chan_number == - MAX_CHANNELS_BG) - && - (strncmp(country_80211d, "JP", COUNTRY_CODE_LEN - 1) - == 0) - ) { - printf("ERR: Invalid scan channel 14, 802.11d disabled, country code JP!\n"); - return UAP_FAILURE; - } - - if (fw.region_code == JP_REGION_0xFE && - ((bss_config->chan_list[i].chan_number == 12) || - (bss_config->chan_list[i].chan_number == 13))) { - printf("ERR:Scan Channel 12 or 13 is not allowed for region code 0xFE\n"); - return UAP_FAILURE; - } - } - - if (!state_80211d) { - /* Block scan channels 8 and 12 in 5GHz band if 11d is not enabled and country code not set to JP */ - for (i = 0; i < bss_config->num_of_chan; i++) { - if ((bss_config->chan_list[i].bandcfg. - chanBand == BAND_5GHZ) - && - ((bss_config->chan_list[i].chan_number == 8) - || (bss_config->chan_list[i].chan_number == - 12))) { - printf("ERR: Invalid band for scan channel %d\n", bss_config->chan_list[i].chan_number); - return UAP_FAILURE; - } - } - } - - if (state_80211d) { - /* Set default country code to US */ - strncpy(country_80211d, "US ", - sizeof(country_80211d) - 1); - for (i = 0; i < bss_config->num_of_chan; i++) { - /* Set country code to JP if channel is 8 or 12 and band is 5GHZ */ - if ((bss_config->chan_list[i].chan_number < - MAX_CHANNELS_BG) && - (scan_channels_band == BAND_A)) { - strncpy(country_80211d, "JP ", - sizeof(country_80211d) - 1); - } - if (check_channel_validity_11d - (bss_config->chan_list[i].chan_number, - scan_channels_band, 0) == UAP_FAILURE) - return UAP_FAILURE; - } - if (update_domain_info - (country_80211d, - scan_channels_band) == UAP_FAILURE) { - return UAP_FAILURE; - } - } - } -#ifdef WIFI_DIRECT_SUPPORT - if (strncmp(dev_name, "wfd", 3)) -#endif - if ((!acs_mode_enabled && - (channel_tlv_band == (BAND_B | BAND_G))) - || (acs_mode_enabled && - (scan_channels_band == (BAND_B | BAND_G)))) { - if (0 == bss_config->rates[0]) { - printf("ERR: No rates found\n"); - return UAP_FAILURE; - } - for (i = 0; i < MAX_DATA_RATES && bss_config->rates[i]; - i++) { - rate = bss_config-> - rates[i] & ~BASIC_RATE_SET_BIT; - switch (rate) { - case 2: - rate_bitmap |= BITMAP_RATE_1M; - break; - case 4: - rate_bitmap |= BITMAP_RATE_2M; - break; - case 11: - rate_bitmap |= BITMAP_RATE_5_5M; - break; - case 22: - rate_bitmap |= BITMAP_RATE_11M; - break; - } - } - if ((rate_bitmap & B_RATE_MANDATORY) != - B_RATE_MANDATORY) { - if (acs_mode_enabled) - printf("ERR: Rates/Scan channels do not match!\n"); - else - printf("ERR: Rates/Channel do not match!\n"); - return UAP_FAILURE; - } - } - if ((!acs_mode_enabled && (channel_tlv_band == BAND_A)) - || (acs_mode_enabled && (scan_channels_band == BAND_A))) { - if (0 == bss_config->rates[0]) { - printf("ERR: No rates found\n"); - return UAP_FAILURE; - } - for (i = 0; i < MAX_DATA_RATES && bss_config->rates[i]; i++) { - rate = bss_config->rates[i] & ~BASIC_RATE_SET_BIT; - switch (rate) { - case 2: - case 4: - case 11: - case 22: - if (acs_mode_enabled) - printf("ERR: Rates/Scan channels do not match!\n"); - else - printf("ERR: Rates/Channel do not match!\n"); - return UAP_FAILURE; - } - } - state_80211h = 1; - if (sg_snmp_mib - (ACTION_SET, OID_80211H_ENABLE, sizeof(state_80211h), - &state_80211h) - == UAP_FAILURE) { - return UAP_FAILURE; - } - if (update_domain_info(country_80211d, BAND_A) == UAP_FAILURE) { - return UAP_FAILURE; - } - } -#define ISSUPP_CHANWIDTH40(Dot11nDevCap) (Dot11nDevCap & MBIT(17)) -#define ISSUPP_SHORTGI40(Dot11nDevCap) (Dot11nDevCap & MBIT(24)) - - if (enable_40Mhz) { - if (!ISSUPP_CHANWIDTH40(fw.hw_dot_11n_dev_cap)) { - printf("ERR: It's not support HT40 from Hardware Cap\n"); - return UAP_FAILURE; - } - } - - if (enable_11n) { - /*For protocol = Mixed, 11n enabled, only allow TKIP cipher for WPA protocol, not for WPA2 */ - if ((bss_config->protocol == PROTOCOL_WPA2_MIXED) && - (bss_config->wpa_cfg.pairwise_cipher_wpa2 == CIPHER_TKIP)) { - printf("ERR: WPA2 pairwise cipher cannot be TKIP when AP operates in 802.11n Mixed mode.\n"); - return UAP_FAILURE; - } else if (bss_config->protocol == PROTOCOL_STATIC_WEP) { - printf("ERR: WEP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - if ((tx_rate_config.rate == UAP_RATE_INDEX_MCS32) && !enable_40Mhz) { - printf("ERR:uAP must be configured to operate in 40MHz if tx_rate is MCS32\n"); - return UAP_FAILURE; - } - if (enable_20Mhz_sgi && enable_gf) { - if ((tx_rate_config.rate >= UAP_RATE_INDEX_MCS0) && - (tx_rate_config.rate <= UAP_RATE_INDEX_MCS7)) { - printf("ERR: Invalid tx_rate for uAP in (20MHz Short GI + Green Field) mode\n"); - return UAP_FAILURE; - } - } - mcs_rate_index = - get_rate_index_from_bitmap(tx_rate_config.bitmap_rates, - sizeof(tx_rate_config.bitmap_rates)); - if ((mcs_rate_index >= UAP_RATE_BITMAP_MCS0) && - (mcs_rate_index <= UAP_RATE_BITMAP_MCS127)) { - mcs_rate_index -= (UAP_RATE_BITMAP_MCS0 - UAP_RATE_INDEX_MCS0); - if ((mcs_rate_index == UAP_RATE_INDEX_MCS32) & !enable_40Mhz) { - printf("ERR:uAP must be configured to operate in 40MHz if rate_bitmap contains MCS32\n"); - return UAP_FAILURE; - } - if (enable_20Mhz_sgi && enable_gf) { - if ((mcs_rate_index >= UAP_RATE_INDEX_MCS0) && - (mcs_rate_index <= UAP_RATE_INDEX_MCS7)) { - printf("ERR: Invalid tx_rate for uAP in (20MHz Short GI + Green Field) mode\n"); - return UAP_FAILURE; - } - } - } - -/* if 11d enabled, Channel 14, country code "JP", only B rates are allowed*/ - if ((bss_config->channel == 14) && state_80211d && - (strncmp(country_80211d, "JP", COUNTRY_CODE_LEN - 1) == 0)) { - if (0 == bss_config->rates[0]) { - printf("ERR:No rates found\n"); - return UAP_FAILURE; - } - if (enable_11n) { - printf("ERR:11n must be disabled and the only B rates are allowed if 11d enabled and country code is JP with channel 14.\n"); - return UAP_FAILURE; - } - for (i = 0; i < MAX_DATA_RATES && bss_config->rates[i]; i++) { - rate = bss_config->rates[i] & ~BASIC_RATE_SET_BIT; - switch (rate) { - case 2: - case 4: - case 11: - case 22: - break; - default: - printf("ERR:If 11d enabled, channel 14 and country code is JP, the only B rates are allowed.\n"); - return UAP_FAILURE; - } - } - } - - /* Channels 14, 165 are not allowed to operate in 40MHz mode */ - if (!acs_mode_enabled && enable_40Mhz) { - if ((bss_config->channel == 14) - || (bss_config->channel == 165) - ) { - printf("ERR:Invalid channel %d for 40MHz operation\n", - bss_config->channel); - return UAP_FAILURE; - } else if (!secondary_ch_set) { - printf("ERR:Secondary channel should be set when 40Mhz is enabled!\n"); - return UAP_FAILURE; - } - } -/* Channels 14, 140, 165 are not allowed to operate in 40MHz mode */ - if (acs_mode_enabled && enable_40Mhz) { - if (bss_config->num_of_chan == 0) { - printf("ERR: No channel list found\n"); - return UAP_FAILURE; - } - for (i = 0; i < bss_config->num_of_chan; i++) { - if ((bss_config->chan_list[i].chan_number != 14) - && (bss_config->chan_list[i].chan_number != 140) && - (bss_config->chan_list[i].chan_number != 165) - ) { - flag = 1; - break; - } - } - if (!flag) { - printf("ERR:Invalid channels in scan channel list for 40MHz operation\n"); - return UAP_FAILURE; - } - } - - if (0 == get_fw_info(&fw)) { - /*check whether support 802.11AC through BAND_AAC bit */ - if (fw.fw_bands & BAND_AAC) { - ret = get_802_11ac_cfg(&vhtcfg); - if (UAP_SUCCESS == ret) { - /* Note: When 11AC is disabled, FW sets vht_rx_mcs to 0xffff */ - if ((vhtcfg.vht_rx_mcs != 0xffff) && - (!enable_11n)) { - printf("ERR: 11ac enable while 11n disable, it is forbidden! \n"); - return UAP_FAILURE; - } - } else { - printf("Don't support 802.11AC \n"); - return UAP_SUCCESS; - } - } else - printf("No support 802 11AC.\n"); - } else { - printf("ERR: get_fw_info fail\n"); - return UAP_FAILURE; - } - - return ret; -} - -/** - * @brief Send read/write command along with register details to the driver - * @param reg Reg type - * @param offset Pointer to register offset string - * @param strvalue Pointer to value string - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -apcmd_regrdwr_process(int reg, char *offset, char *strvalue) -{ - apcmdbuf_reg_rdwr *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - char *whichreg; - - /* Alloc buf for command */ - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - - /* Locate headers */ - cmd_len = sizeof(apcmdbuf_reg_rdwr); - cmd_buf = (apcmdbuf_reg_rdwr *)buf; - - /* Fill the command buffer */ - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - switch (reg) { - case CMD_MAC: - whichreg = "MAC"; - cmd_buf->cmd_code = HostCmd_CMD_MAC_REG_ACCESS; - break; - case CMD_BBP: - whichreg = "BBP"; - cmd_buf->cmd_code = HostCmd_CMD_BBP_REG_ACCESS; - break; - case CMD_RF: - cmd_buf->cmd_code = HostCmd_CMD_RF_REG_ACCESS; - whichreg = "RF"; - break; - default: - printf("Invalid register set specified.\n"); - free(buf); - return UAP_FAILURE; - } - if (strvalue) { - cmd_buf->action = 1; // WRITE - } else { - cmd_buf->action = 0; // READ - } - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->offset = A2HEXDECIMAL(offset); - cmd_buf->offset = uap_cpu_to_le16(cmd_buf->offset); - if (strvalue) { - cmd_buf->value = A2HEXDECIMAL(strvalue); - cmd_buf->value = uap_cpu_to_le32(cmd_buf->value); - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - printf("Successfully executed the command\n"); - printf("%s[0x%04hx] = 0x%08x\n", - whichreg, uap_le16_to_cpu(cmd_buf->offset), - uap_le32_to_cpu(cmd_buf->value)); - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - - free(buf); - return UAP_SUCCESS; -} - -/** - * @brief Send read command for EEPROM - * - * Usage: "Usage : rdeeprom " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_read_eeprom(int argc, char *argv[]) -{ - apcmdbuf_eeprom_access *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - t_u16 byte_count, offset; - int ret = UAP_SUCCESS; - int opt; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_apcmd_read_eeprom_usage(); - return UAP_FAILURE; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (!argc || - (argc && is_input_valid(RDEEPROM, argc, argv) != UAP_SUCCESS)) { - print_apcmd_read_eeprom_usage(); - return UAP_FAILURE; - } - offset = A2HEXDECIMAL(argv[0]); - byte_count = A2HEXDECIMAL(argv[1]); - - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_eeprom_access *)buf; - cmd_len = sizeof(apcmdbuf_eeprom_access); - - cmd_buf->size = sizeof(apcmdbuf_eeprom_access) - BUF_HEADER_SIZE; - cmd_buf->result = 0; - cmd_buf->seq_num = 0; - cmd_buf->action = 0; - - cmd_buf->cmd_code = HostCmd_EEPROM_ACCESS; - cmd_buf->offset = uap_cpu_to_le16(offset); - cmd_buf->byte_count = uap_cpu_to_le16(byte_count); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - printf("Successfully executed the command\n"); - byte_count = uap_le16_to_cpu(cmd_buf->byte_count); - offset = uap_le16_to_cpu(cmd_buf->offset); - hexdump_data("EEPROM", (void *)cmd_buf->value, - byte_count, ' '); - } else { - printf("ERR:Command Response incorrect!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - - free(buf); - return ret; -} - -/** - * @brief Show usage information for the regrdwr command - * command - * - * $return N/A - */ -void -print_regrdwr_usage(void) -{ - printf("\nUsage : uaputl.exe regrdwr [value]\n"); - printf("\nTYPE Options: 1 - read/write MAC register"); - printf("\n 2 - read/write BBP register"); - printf("\n 3 - read/write RF register"); - printf("\n"); - return; - -} - -/** - * @brief Provides interface to perform read/write operations on regsiters - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_regrdwr(int argc, char *argv[]) -{ - int opt; - t_s32 reg; - int ret = UAP_SUCCESS; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_regrdwr_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc < 2) || (argc > 3)) { - printf("ERR:wrong arguments.\n"); - print_regrdwr_usage(); - return UAP_FAILURE; - } - if ((atoi(argv[0]) != 1) && (atoi(argv[0]) != 2) && - (atoi(argv[0]) != 3)) { - printf("ERR:Illegal register type %s. Must be either '1','2' or '3'.\n", argv[0]); - print_regrdwr_usage(); - return UAP_FAILURE; - } - reg = atoi(argv[0]); - ret = apcmd_regrdwr_process(reg, argv[1], argc > 2 ? argv[2] : NULL); - return ret; -} - -/** - * @brief Show usage information for the memaccess command - * command - * - * $return N/A - */ -void -print_memaccess_usage(void) -{ - printf("\nUsage : uaputl.exe memaccess
[value]\n"); - printf("\nRead/Write memory location"); - printf("\nADDRESS: Address of the memory location to be read/written"); - printf("\nValue : Value to be written at that address\n"); - return; -} - -/** - * @brief Provides interface to perform read/write memory location - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_memaccess(int argc, char *argv[]) -{ - int opt; - apcmdbuf_mem_access *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - char *address = NULL; - char *value = NULL; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_memaccess_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc < 1) || (argc > 2)) { - printf("ERR:wrong arguments.\n"); - print_memaccess_usage(); - return UAP_FAILURE; - } - - address = argv[0]; - if (argc == 2) - value = argv[1]; - - /* Alloc buf for command */ - buf = (t_u8 *)malloc(buf_len); - - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - /* Locate headers */ - cmd_len = sizeof(apcmdbuf_mem_access); - cmd_buf = (apcmdbuf_mem_access *)buf; - - /* Fill the command buffer */ - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->cmd_code = HostCmd_CMD_MEM_ACCESS; - - if (value) - cmd_buf->action = 1; // WRITE - else - cmd_buf->action = 0; // READ - - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->address = A2HEXDECIMAL(address); - cmd_buf->address = uap_cpu_to_le32(cmd_buf->address); - - if (value) { - cmd_buf->value = A2HEXDECIMAL(value); - cmd_buf->value = uap_cpu_to_le32(cmd_buf->value); - } - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - printf("Successfully executed the command\n"); - printf("[0x%04x] = 0x%08x\n", - uap_le32_to_cpu(cmd_buf->address), - uap_le32_to_cpu(cmd_buf->value)); - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - free(buf); - return UAP_SUCCESS; -} - -/** - * @brief Creates a sys_debug request to send data packet directly to driver - * @param pkt_type packet type 0 or 5. - * @param control management packet tx control field. - * @param file packet data file. - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_debug_data_packet_inject(int pkt_type, int control, char *file) -{ - struct ifreq ifr; - t_s32 sockfd; - t_u8 *buf = NULL; - t_u32 data_len; - FILE *fp = NULL; - pkt_header *header = NULL; - - /* Check if file exists */ - fp = fopen(file, "r"); - if (fp == NULL) { - printf("\nERR:Data file can not be opened %s.\n", file); - return UAP_FAILURE; - } - buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_PKT_BUFFER); - if (buf == NULL) { - printf("Error: allocate memory for packet buffer failed\n"); - fclose(fp); - return UAP_FAILURE; - } - memset(buf, 0, MRVDRV_SIZE_OF_PKT_BUFFER); - header = (pkt_header *)buf; - data_len = fparse_for_hex(fp, buf + sizeof(pkt_header)); - fclose(fp); - if (data_len > (MRVDRV_SIZE_OF_PKT_BUFFER - sizeof(pkt_header))) { - printf("ERR: Config file is too big %d\n", data_len); - free(buf); - return UAP_FAILURE; - } - header->tx_pkt_type = pkt_type; - header->tx_control = control; - header->pkt_len = data_len; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - free(buf); - return UAP_FAILURE; - } - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)buf; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAPHOSTPKTINJECT, &ifr)) { - perror(""); - printf("ERR:ioctl is not supported by %s\n", dev_name); - close(sockfd); - free(buf); - return UAP_FAILURE; - } - /* Close socket */ - close(sockfd); - - if (buf) - free(buf); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the bss_config command - * - * $return N/A - */ -void -print_bss_config_usage(void) -{ - printf("\nUsage : bss_config [CONFIG_FILE]\n"); - printf("\nIf CONFIG_FILE is provided, a 'set' is performed, else a 'get' is performed.\n"); - printf("CONFIG_FILE is file containing all the BSS settings.\n"); - return; -} - -/** - * @brief Read the BSS profile and populate structure - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @param bss Pointer to BSS configuration buffer - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -parse_bss_config(int argc, char *argv[], bss_config_t *bss) -{ - FILE *config_file = NULL; - char *line = NULL; - int li = 0; - char *pos = NULL; - int arg_num = 0; - char *args[30]; - int i; - int is_ap_config = 0; - int is_ap_mac_filter = 0; - int keyindex = -1; - int pwkcipher_wpa = -1; - int pwkcipher_wpa2 = -1; - int gwkcipher = -1; - int protocol = -1; - int tx_beacon_rate = -1; - int tx_data_rate = -1; - int mcbc_data_rate = -1; - int num_rates = 0; - int found = 0; - int filter_mac_count = -1; - int retval = UAP_SUCCESS; - int chan_mode = 0; - int band_flag = 0; - int chan_number = 0; - t_u16 max_sta_num_supported = 0; - fw_info fw; - HTCap_t htcap; - int enable_11n = -1; - t_u32 supported_mcs_set = 0; - int ac = 0; - int is_wmm_parameters = 0; - char oui_type[4] = { 0x00, 0x50, 0xf2, 0x02 }; - struct eth_priv_vhtcfg vhtcfg = { 0 }; - - /* Check if file exists */ - config_file = fopen(argv[0], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - return UAP_FAILURE; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - retval = UAP_FAILURE; - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { -#if DEBUG - uap_printf(MSG_DEBUG, "DBG:Received config line (%d) = %s\n", - li, line); -#endif - arg_num = parse_line(line, args); -#if DEBUG - uap_printf(MSG_DEBUG, "DBG:Number of arguments = %d\n", - arg_num); - for (i = 0; i < arg_num; i++) { - uap_printf(MSG_DEBUG, "\tDBG:Argument %d. %s\n", i + 1, - args[i]); - } -#endif - /* Check for end of AP configurations */ - if (is_ap_config == 1) { - if (strcmp(args[0], "}") == 0) { - is_ap_config = 0; - if (tx_data_rate != -1) { - if ((!bss->rates[0]) && (tx_data_rate) - && - (is_tx_rate_valid - ((t_u8)tx_data_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid Tx Data Rate \n"); - retval = UAP_FAILURE; - goto done; - } - if (bss->rates[0] && tx_data_rate) { - for (i = 0; bss->rates[i] != 0; - i++) { - if ((bss-> - rates[i] & - ~BASIC_RATE_SET_BIT) - == tx_data_rate) { - found = 1; - break; - } - } - if (!found) { - printf("ERR: Invalid Tx Data Rate \n"); - retval = UAP_FAILURE; - goto done; - } - } - - /* Set Tx data rate field */ - bss->tx_data_rate = tx_data_rate; - } - if (tx_beacon_rate != -1) { - if ((!bss->rates[0]) && (tx_beacon_rate) - && - (is_tx_rate_valid - ((t_u8)tx_beacon_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid Tx Beacon Rate \n"); - retval = UAP_FAILURE; - goto done; - } - if (bss->rates[0] && tx_beacon_rate) { - for (i = 0; bss->rates[i] != 0; - i++) { - if ((bss-> - rates[i] & - ~BASIC_RATE_SET_BIT) - == tx_beacon_rate) { - found = 1; - break; - } - } - if (!found) { - printf("ERR: Invalid Tx Beacon Rate \n"); - retval = UAP_FAILURE; - goto done; - } - } - - /* Set Tx beacon rate field */ - bss->tx_beacon_rate = tx_beacon_rate; - } - if (mcbc_data_rate != -1) { - if ((!bss->rates[0]) && (mcbc_data_rate) - && - (is_mcbc_rate_valid - ((t_u8)mcbc_data_rate) != - UAP_SUCCESS)) { - printf("ERR: Invalid Tx Data Rate \n"); - retval = UAP_FAILURE; - goto done; - } - if (bss->rates[0] && mcbc_data_rate) { - for (i = 0; bss->rates[i] != 0; - i++) { - if (bss-> - rates[i] & - BASIC_RATE_SET_BIT) - { - if ((bss-> - rates[i] & - ~BASIC_RATE_SET_BIT) - == - mcbc_data_rate) - { - found = 1; - break; - } - } - } - if (!found) { - printf("ERR: Invalid MCBC Data Rate \n"); - retval = UAP_FAILURE; - goto done; - } - } - - /* Set MCBC data rate field */ - bss->mcbc_data_rate = mcbc_data_rate; - } - if ((protocol == PROTOCOL_STATIC_WEP) && - (enable_11n == 1)) { - printf("ERR:WEP cannot be used when AP operates in 802.11n mode.\n"); - goto done; - } - if (0 == get_fw_info(&fw)) { - /*check whether support 802.11AC through BAND_AAC bit */ - if (fw.fw_bands & BAND_AAC) { - retval = get_802_11ac_cfg - (&vhtcfg); - if (retval != UAP_SUCCESS) - goto done; - if ((enable_11n == 1) && - (vhtcfg.vht_rx_mcs != - 0xffff)) { - printf("ERR: 11n must be enabled when AP operates in 11ac mode.\n"); - retval = UAP_FAILURE; - goto done; - } - } else - printf("No support 802 11AC.\n"); - } else { - printf("ERR: get_fw_info fail\n"); - retval = UAP_FAILURE; - goto done; - } - if ((protocol == PROTOCOL_WPA2_MIXED) && - ((pwkcipher_wpa < 0) || - (pwkcipher_wpa2 < 0))) { - printf("ERR:Both PwkCipherWPA and PwkCipherWPA2 should be defined for Mixed mode.\n"); - retval = UAP_FAILURE; - goto done; - } - if (protocol != -1) { - bss->protocol = protocol; - if (protocol & - (PROTOCOL_WPA | PROTOCOL_WPA2)) { - /* Set key management field */ - bss->key_mgmt = KEY_MGMT_PSK; - bss->key_mgmt_operation = 0; - } - } - if (((pwkcipher_wpa >= 0) || - (pwkcipher_wpa2 >= 0)) && - (gwkcipher >= 0)) { - if ((protocol == PROTOCOL_WPA) || - (protocol == PROTOCOL_WPA2_MIXED)) { - if (enable_11n != -1) { - if (is_cipher_valid_with_11n(pwkcipher_wpa, gwkcipher, protocol, enable_11n) != UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA pairwise cipher combination!\n"); - retval = UAP_FAILURE; - goto done; - } - } else if - (is_cipher_valid_with_proto - (pwkcipher_wpa, - gwkcipher, - protocol) != - UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA pairwise cipher combination!\n"); - retval = UAP_FAILURE; - goto done; - } - } - if ((protocol == PROTOCOL_WPA2) || - (protocol == PROTOCOL_WPA2_MIXED) - || (protocol == PROTOCOL_WPA3_SAE) - ) { - if (enable_11n != -1) { - if (is_cipher_valid_with_11n(pwkcipher_wpa2, gwkcipher, protocol, enable_11n) != UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA2 pairwise cipher combination!\n"); - retval = UAP_FAILURE; - goto done; - } - } else if - (is_cipher_valid_with_proto - (pwkcipher_wpa2, - gwkcipher, - protocol) != - UAP_SUCCESS) { - printf("ERR:Wrong group cipher and WPA2 pairwise cipher combination!\n"); - retval = UAP_FAILURE; - goto done; - } - } - /* Set pairwise and group cipher fields */ - bss->wpa_cfg.pairwise_cipher_wpa = - pwkcipher_wpa; - bss->wpa_cfg.pairwise_cipher_wpa2 = - pwkcipher_wpa2; - bss->wpa_cfg.group_cipher = gwkcipher; - } - continue; - } - } - - /* Check for beginning of AP configurations */ - if (strcmp(args[0], "ap_config") == 0) { - is_ap_config = 1; - continue; - } - - /* Check for end of AP MAC address filter configurations */ - if (is_ap_mac_filter == 1) { - if (strcmp(args[0], "}") == 0) { - is_ap_mac_filter = 0; - if (bss->filter.mac_count != filter_mac_count) { - printf("ERR:Number of MAC address provided does not match 'Count'\n"); - retval = UAP_FAILURE; - goto done; - } - if (bss->filter.filter_mode && - (bss->filter.mac_count == 0)) { - printf("ERR:Filter list can not be empty for %s Filter mode\n", (bss->filter.filter_mode == 1) ? "'Allow'" : "'Block'"); - retval = UAP_FAILURE; - goto done; - } - continue; - } - } - - /* Check for beginning of AP MAC address filter configurations */ - if (strcmp(args[0], "ap_mac_filter") == 0) { - is_ap_mac_filter = 1; - bss->filter.mac_count = 0; - filter_mac_count = 0; - continue; - } - if ((strcmp(args[0], "FilterMode") == 0) && is_ap_mac_filter) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0) || - (atoi(args[1]) > 2)) { - printf("ERR:Illegal FilterMode paramter %d. Must be either '0', '1', or '2'.\n", atoi(args[1])); - retval = UAP_FAILURE; - goto done; - } - bss->filter.filter_mode = atoi(args[1]); - continue; - } - if ((strcmp(args[0], "Count") == 0) && is_ap_mac_filter) { - bss->filter.mac_count = atoi(args[1]); - if ((ISDIGIT(args[1]) == 0) || - (bss->filter.mac_count > MAX_MAC_ONESHOT_FILTER)) { - printf("ERR: Illegal Count parameter.\n"); - retval = UAP_FAILURE; - goto done; - } - } - if ((strncmp(args[0], "mac_", 4) == 0) && is_ap_mac_filter) { - if (filter_mac_count < MAX_MAC_ONESHOT_FILTER) { - if (mac2raw - (args[1], - bss->filter.mac_list[filter_mac_count]) != - UAP_SUCCESS) { - printf("ERR: Invalid MAC address %s \n", - args[1]); - retval = UAP_FAILURE; - goto done; - } - filter_mac_count++; - } else { - printf("ERR: Filter table can not have more than %d MAC addresses\n", MAX_MAC_ONESHOT_FILTER); - retval = UAP_FAILURE; - goto done; - } - } - - /* Check for end of Wmm Parameters configurations */ - if (is_wmm_parameters == 1) { - if (strcmp(args[0], "}") == 0) { - is_wmm_parameters = 0; - continue; - } - } - /* Check for beginning of Sticky Tim Sta MAC address Configurations */ - if (strcmp(args[0], "Wmm_parameters") == 0) { - is_wmm_parameters = 1; - memset(&(bss->wmm_para), 0, sizeof(bss->wmm_para)); - memcpy(bss->wmm_para.ouitype, oui_type, - sizeof(oui_type)); - bss->wmm_para.ouisubtype = 1; - bss->wmm_para.version = 1; - continue; - } - if ((strcmp(args[0], "Qos_info") == 0) && is_wmm_parameters) { - bss->wmm_para.qos_info = A2HEXDECIMAL(args[1]); - printf("wmm_para.qos_info = %2x\n", - bss->wmm_para.qos_info); - if ((bss->wmm_para.qos_info != ENABLE_WMM_PS) && - (bss->wmm_para.qos_info != DISABLE_WMM_PS)) { - printf("ERR:qos_info must be either 0x80 or 0x00.\n"); - retval = UAP_FAILURE; - goto done; - } - } - if ((strcmp(args[0], "AC_BE") == 0) && is_wmm_parameters) { - ac = 0; - } - if ((strcmp(args[0], "AC_BK") == 0) && is_wmm_parameters) { - ac = 1; - } - if ((strcmp(args[0], "AC_VI") == 0) && is_wmm_parameters) { - ac = 2; - } - if ((strcmp(args[0], "AC_VO") == 0) && is_wmm_parameters) { - ac = 3; - } - if ((strcmp(args[0], "Aifsn") == 0) && is_wmm_parameters) { - bss->wmm_para.ac_params[ac].aci_aifsn.aifsn = - (t_u8)A2HEXDECIMAL(args[1]); - printf("wmm_para.ac_params[%d].aci_aifsn.aifsn = %x\n", - ac, bss->wmm_para.ac_params[ac].aci_aifsn.aifsn); - bss->wmm_para.ac_params[ac].aci_aifsn.aci = (t_u8)ac; - printf("wmm_para.ac_params[%d].aci_aifsn.aci = %x\n", - ac, bss->wmm_para.ac_params[ac].aci_aifsn.aci); - } - if ((strcmp(args[0], "Ecw_max") == 0) && is_wmm_parameters) { - bss->wmm_para.ac_params[ac].ecw.ecw_max = - (t_u8)A2HEXDECIMAL(args[1]); - printf("wmm_para.ac_params[%d].ecw.ecw_max = %x\n", ac, - bss->wmm_para.ac_params[ac].ecw.ecw_max); - } - if ((strcmp(args[0], "Ecw_min") == 0) && is_wmm_parameters) { - bss->wmm_para.ac_params[ac].ecw.ecw_min = - (t_u8)A2HEXDECIMAL(args[1]); - printf("wmm_para.ac_params[%d].ecw.ecw_min = %x\n", ac, - bss->wmm_para.ac_params[ac].ecw.ecw_min); - } - if ((strcmp(args[0], "Tx_op") == 0) && is_wmm_parameters) { - bss->wmm_para.ac_params[ac].tx_op_limit = - (t_u8)A2HEXDECIMAL(args[1]); - printf("wmm_para.ac_params[%d].tx_op_limit = %x\n", ac, - bss->wmm_para.ac_params[ac].tx_op_limit); - } - - if (strcmp(args[0], "SSID") == 0) { - if (arg_num == 1) { - printf("ERR:SSID field is blank!\n"); - retval = UAP_FAILURE; - goto done; - } else { - if (args[1][0] == '"') { - args[1]++; - } - if (args[1][strlen(args[1]) - 1] == '"') { - args[1][strlen(args[1]) - 1] = '\0'; - } - if ((strlen(args[1]) > MAX_SSID_LENGTH) || - (strlen(args[1]) == 0)) { - printf("ERR:SSID length out of range (%d to %d).\n", MIN_SSID_LENGTH, MAX_SSID_LENGTH); - retval = UAP_FAILURE; - goto done; - } - /* Set SSID field */ - bss->ssid.ssid_len = strlen(args[1]); - memcpy(bss->ssid.ssid, args[1], - bss->ssid.ssid_len); - } - } - if (strcmp(args[0], "BeaconPeriod") == 0) { - if (is_input_valid(BEACONPERIOD, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set beacon period field */ - bss->beacon_period = (t_u16)atoi(args[1]); - } - if (strcmp(args[0], "ChanList") == 0) { - if (is_input_valid(SCANCHANNELS, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - - /* Set channel list field */ - if ((arg_num - 1) < MAX_CHANNELS) { - bss->num_of_chan = arg_num - 1; - } else { - bss->num_of_chan = MAX_CHANNELS; - } - for (i = 0; (unsigned int)i < bss->num_of_chan; i++) { - sscanf(args[i + 1], "%d.%d", &chan_number, - &band_flag); - bss->chan_list[i].chan_number = chan_number; - bss->chan_list[i].bandcfg.chanBand = BAND_2GHZ; - if (((band_flag != -1) && (band_flag)) || - (chan_number > MAX_CHANNELS_BG)) { - bss->chan_list[i].bandcfg.chanBand = - BAND_5GHZ; - } - } - } - if (strcmp(args[0], "Channel") == 0) { - if (is_input_valid(CHANNEL, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set channel field */ - bss->channel = (t_u8)atoi(args[1]); - if ((arg_num - 1) == 2) { - chan_mode = atoi(args[2]); - memset(&(bss->bandcfg), 0, - sizeof(bss->bandcfg)); - if (chan_mode & BITMAP_ACS_MODE) { - int mode; - - if (uap_ioctl_dfs_repeater_mode(&mode) - == UAP_SUCCESS) { - if (mode) { - printf("ERR: ACS in DFS Repeater mode" " is not allowed\n"); - retval = UAP_FAILURE; - goto done; - } - } - - bss->bandcfg.scanMode = SCAN_MODE_ACS; - } - if (chan_mode & BITMAP_CHANNEL_ABOVE) - bss->bandcfg.chan2Offset = - SEC_CHAN_ABOVE; - if (chan_mode & BITMAP_CHANNEL_BELOW) - bss->bandcfg.chan2Offset = - SEC_CHAN_BELOW; - } else - memset(&(bss->bandcfg), 0, - sizeof(bss->bandcfg)); - if (bss->channel > MAX_CHANNELS_BG) - bss->bandcfg.chanBand = BAND_5GHZ; - } - if (strcmp(args[0], "Band") == 0) { - if (is_input_valid(BAND, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Clear previously set band */ - bss->bandcfg.chanBand = BAND_2GHZ; - if (atoi(args[1]) == 1) - bss->bandcfg.chanBand = BAND_5GHZ; - } - if (strcmp(args[0], "AP_MAC") == 0) { - int ret; - if ((ret = - mac2raw(args[1], bss->mac_addr)) != UAP_SUCCESS) { - printf("ERR: %s Address \n", - ret == - UAP_FAILURE ? "Invalid MAC" : ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - retval = UAP_FAILURE; - goto done; - } - } - - if (strcmp(args[0], "Rate") == 0) { - if (is_input_valid(RATE, arg_num - 1, args + 1) != - UAP_SUCCESS) { - printf("ERR: Invalid Rate input\n"); - retval = UAP_FAILURE; - goto done; - } - /* Set rates field */ - if ((arg_num - 1) < MAX_DATA_RATES) { - num_rates = arg_num - 1; - } else { - num_rates = MAX_DATA_RATES; - } - for (i = 0; i < num_rates; i++) { - bss->rates[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); - } - } - if (strcmp(args[0], "TxPowerLevel") == 0) { - if (is_input_valid(TXPOWER, arg_num - 1, args + 1) != - UAP_SUCCESS) { - printf("ERR:Invalid TxPowerLevel \n"); - retval = UAP_FAILURE; - goto done; - } - /* Set Tx power level field */ - bss->tx_power_level = (t_u8)atoi(args[1]); - } - if (strcmp(args[0], "BroadcastSSID") == 0) { - if (is_input_valid(BROADCASTSSID, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set broadcast SSID control field */ - bss->bcast_ssid_ctl = (t_u8)atoi(args[1]); - } - if (strcmp(args[0], "RTSThreshold") == 0) { - if (is_input_valid(RTSTHRESH, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set RTS threshold field */ - bss->rts_threshold = (t_u16)atoi(args[1]); - } - if (strcmp(args[0], "FragThreshold") == 0) { - if (is_input_valid(FRAGTHRESH, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set Frag threshold field */ - bss->frag_threshold = (t_u16)atoi(args[1]); - } - if (strcmp(args[0], "DTIMPeriod") == 0) { - if (is_input_valid(DTIMPERIOD, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set DTIM period field */ - bss->dtim_period = (t_u8)atoi(args[1]); - } - if (strcmp(args[0], "RSNReplayProtection") == 0) { - if (is_input_valid(RSNREPLAYPROT, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set RSN replay protection field */ - bss->wpa_cfg.rsn_protection = (t_u8)atoi(args[1]); - } - if (strcmp(args[0], "PairwiseUpdateTimeout") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - retval = UAP_FAILURE; - goto done; - } - /* Set Pairwise Update Timeout field */ - bss->pairwise_update_timeout = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "PairwiseHandshakeRetries") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - retval = UAP_FAILURE; - goto done; - } - /* Set Pairwise Hanshake Retries */ - bss->pwk_retries = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "GroupwiseUpdateTimeout") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - retval = UAP_FAILURE; - goto done; - } - /* Set Groupwise Update Timeout field */ - bss->groupwise_update_timeout = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "GroupwiseHandshakeRetries") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0)) { - retval = UAP_FAILURE; - goto done; - } - /* Set Groupwise Hanshake Retries */ - bss->gwk_retries = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "TxBeaconRate") == 0) { - if (is_input_valid(TXBEACONRATE, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - tx_beacon_rate = (t_u16)A2HEXDECIMAL(args[1]); - } - if (strcmp(args[0], "MCBCdataRate") == 0) { - if (is_input_valid(MCBCDATARATE, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - mcbc_data_rate = (t_u16)A2HEXDECIMAL(args[1]); - } - if (strcmp(args[0], "PktFwdCtl") == 0) { - if (is_input_valid(PKTFWD, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set packet forward control field */ - bss->pkt_forward_ctl = (t_u8)atoi(args[1]); - } - if (strcmp(args[0], "StaAgeoutTimer") == 0) { - if (is_input_valid - (STAAGEOUTTIMER, arg_num - 1, - args + 1) != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set STA ageout timer field */ - bss->sta_ageout_timer = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "PSStaAgeoutTimer") == 0) { - if (is_input_valid - (PSSTAAGEOUTTIMER, arg_num - 1, - args + 1) != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set PS STA ageout timer field */ - bss->ps_sta_ageout_timer = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "AuthMode") == 0) { - if (is_input_valid(AUTHMODE, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set auth mode field */ - bss->auth_mode = (t_u16)atoi(args[1]); - } - if (strcmp(args[0], "KeyIndex") == 0) { - if (arg_num == 1) { - printf("KeyIndex is blank!\n"); - retval = UAP_FAILURE; - goto done; - } else { - if (ISDIGIT(args[1]) == 0) { - printf("ERR:Illegal KeyIndex parameter. Must be either '0', '1', '2', or '3'.\n"); - retval = UAP_FAILURE; - goto done; - } - keyindex = atoi(args[1]); - if ((keyindex < 0) || (keyindex > 3)) { - printf("ERR:Illegal KeyIndex parameter. Must be either '0', '1', '2', or '3'.\n"); - retval = UAP_FAILURE; - goto done; - } - switch (keyindex) { - case 0: - bss->wep_cfg.key0.is_default = 1; - break; - case 1: - bss->wep_cfg.key1.is_default = 1; - break; - case 2: - bss->wep_cfg.key2.is_default = 1; - break; - case 3: - bss->wep_cfg.key3.is_default = 1; - break; - } - } - } - if (strncmp(args[0], "Key_", 4) == 0) { - if (arg_num == 1) { - printf("ERR:%s is blank!\n", args[0]); - retval = UAP_FAILURE; - goto done; - } else { - int key_len = 0; - if (args[1][0] == '"') { - if ((strlen(args[1]) != 2) && - (strlen(args[1]) != 7) && - (strlen(args[1]) != 15)) { - printf("ERR:Wrong key length!\n"); - retval = UAP_FAILURE; - goto done; - } - key_len = strlen(args[1]) - 2; - } else { - if ((strlen(args[1]) != 0) && - (strlen(args[1]) != 10) && - (strlen(args[1]) != 26)) { - printf("ERR:Wrong key length!\n"); - retval = UAP_FAILURE; - goto done; - } - if (UAP_FAILURE == ishexstring(args[1])) { - printf("ERR:Only hex digits are allowed when key length is 10 or 26\n"); - retval = UAP_FAILURE; - goto done; - } - key_len = strlen(args[1]) / 2; - } - /* Set WEP key fields */ - if (strcmp(args[0], "Key_0") == 0) { - bss->wep_cfg.key0.key_index = 0; - bss->wep_cfg.key0.length = key_len; - if (args[1][0] == '"') { - memcpy(bss->wep_cfg.key0.key, - &args[1][1], - strlen(args[1]) - 2); - } else { - string2raw(args[1], - bss->wep_cfg.key0. - key); - } - } else if (strcmp(args[0], "Key_1") == 0) { - bss->wep_cfg.key1.key_index = 1; - bss->wep_cfg.key1.length = key_len; - if (args[1][0] == '"') { - memcpy(bss->wep_cfg.key1.key, - &args[1][1], - strlen(args[1]) - 2); - } else { - string2raw(args[1], - bss->wep_cfg.key1. - key); - } - } else if (strcmp(args[0], "Key_2") == 0) { - bss->wep_cfg.key2.key_index = 2; - bss->wep_cfg.key2.length = key_len; - if (args[1][0] == '"') { - memcpy(bss->wep_cfg.key2.key, - &args[1][1], - strlen(args[1]) - 2); - } else { - string2raw(args[1], - bss->wep_cfg.key2. - key); - } - } else if (strcmp(args[0], "Key_3") == 0) { - bss->wep_cfg.key3.key_index = 3; - bss->wep_cfg.key3.length = key_len; - if (args[1][0] == '"') { - memcpy(bss->wep_cfg.key3.key, - &args[1][1], - strlen(args[1]) - 2); - } else { - string2raw(args[1], - bss->wep_cfg.key3. - key); - } - } - } - } - if (strcmp(args[0], "PSK") == 0) { - if (arg_num == 1) { - printf("ERR:PSK is blank!\n"); - retval = UAP_FAILURE; - goto done; - } else { - if (args[1][0] == '"') { - args[1]++; - } - if (args[1][strlen(args[1]) - 1] == '"') { - args[1][strlen(args[1]) - 1] = '\0'; - } - if (strlen(args[1]) > MAX_WPA_PASSPHRASE_LENGTH) { - printf("ERR:PSK too long.\n"); - retval = UAP_FAILURE; - goto done; - } - if (strlen(args[1]) < MIN_WPA_PASSPHRASE_LENGTH) { - printf("ERR:PSK too short.\n"); - retval = UAP_FAILURE; - goto done; - } - if (strlen(args[1]) == - MAX_WPA_PASSPHRASE_LENGTH) { - if (UAP_FAILURE == ishexstring(args[1])) { - printf("ERR:Only hex digits are allowed when passphrase's length is 64\n"); - retval = UAP_FAILURE; - goto done; - } - } - /* Set WPA passphrase field */ - bss->wpa_cfg.length = strlen(args[1]); - memcpy(bss->wpa_cfg.passphrase, args[1], - bss->wpa_cfg.length); - } - } - if (strcmp(args[0], "Protocol") == 0) { - if (is_input_valid(PROTOCOL, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - /* Set protocol field */ - protocol = (t_u16)atoi(args[1]); - } - if ((strcmp(args[0], "PairwiseCipher") == 0) || - (strcmp(args[0], "GroupCipher") == 0)) { - printf("ERR:PairwiseCipher and GroupCipher are not supported.\n" " Please configure pairwise cipher using parameters PwkCipherWPA or PwkCipherWPA2\n" " and group cipher using GwkCipher in the config file.\n"); - goto done; - } - - if ((protocol == PROTOCOL_NO_SECURITY) || - (protocol == PROTOCOL_STATIC_WEP)) { - if ((strcmp(args[0], "PwkCipherWPA") == 0) || - (strcmp(args[0], "PwkCipherWPA2") == 0) - || (strcmp(args[0], "GwkCipher") == 0)) { - printf("ERR:Pairwise cipher and group cipher should not be defined for Open and WEP mode.\n"); - goto done; - } - } - - if (strcmp(args[0], "PwkCipherWPA") == 0) { - if (arg_num == 1) { - printf("ERR:PwkCipherWPA is blank!\n"); - goto done; - } else { - if (ISDIGIT(args[1]) == 0) { - printf("ERR:Illegal PwkCipherWPA parameter. Must be either bit '2' or '3'.\n"); - goto done; - } - if (atoi(args[1]) & ~CIPHER_BITMAP) { - printf("ERR:Illegal PwkCipherWPA parameter. Must be either bit '2' or '3'.\n"); - goto done; - } - pwkcipher_wpa = atoi(args[1]); - if (enable_11n && - protocol != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == - get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0] - && (atoi(args[1]) == - CIPHER_TKIP)) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - } - } - } - if (strcmp(args[0], "PwkCipherWPA2") == 0) { - if (arg_num == 1) { - printf("ERR:PwkCipherWPA2 is blank!\n"); - goto done; - } else { - if (ISDIGIT(args[1]) == 0) { - printf("ERR:Illegal PwkCipherWPA2 parameter. Must be either bit '2' or '3'.\n"); - goto done; - } - if (atoi(args[1]) & ~CIPHER_BITMAP) { - printf("ERR:Illegal PwkCipherWPA2 parameter. Must be either bit '2' or '3'.\n"); - goto done; - } - pwkcipher_wpa2 = atoi(args[1]); - if (enable_11n && - protocol != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == - get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0] - && (atoi(args[1]) == - CIPHER_TKIP)) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - } - } - } - if (strcmp(args[0], "GwkCipher") == 0) { - if (is_input_valid(GWK_CIPHER, arg_num - 1, args + 1) != - UAP_SUCCESS) { - goto done; - } - gwkcipher = atoi(args[1]); - } - if (strcmp(args[0], "GroupRekeyTime") == 0) { - if (is_input_valid - (GROUPREKEYTIMER, arg_num - 1, - args + 1) != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - - /* Set group rekey time field */ - bss->wpa_cfg.gk_rekey_time = (t_u32)atoi(args[1]); - } - if (strcmp(args[0], "MaxStaNum") == 0) { - if (is_input_valid(MAXSTANUM, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - if (get_max_sta_num_supported(&max_sta_num_supported) == - UAP_FAILURE) { - retval = UAP_FAILURE; - goto done; - } - if (atoi(args[1]) > max_sta_num_supported) { - printf("ERR: MAX_STA_NUM must be less than %d\n", max_sta_num_supported); - retval = UAP_FAILURE; - goto done; - } - /* Set max STA number field */ - bss->max_sta_count = (t_u16)atoi(args[1]); - } - if (strcmp(args[0], "Retrylimit") == 0) { - if (is_input_valid(RETRYLIMIT, arg_num - 1, args + 1) != - UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - - /* Set retry limit field */ - bss->retry_limit = (t_u16)atoi(args[1]); - } - if (strcmp(args[0], "PreambleType") == 0) { - if (is_input_valid(PREAMBLETYPE, arg_num - 1, args + 1) - != UAP_SUCCESS) { - retval = UAP_FAILURE; - goto done; - } - - /* Set preamble type field */ - bss->preamble_type = (t_u8)atoi(args[1]); - } - if (strcmp(args[0], "Enable11n") == 0) { - if ((ISDIGIT(args[1]) != UAP_SUCCESS) || - (atoi(args[1]) < 0) || (atoi(args[1]) > 1)) { - printf("ERR: Invalid Enable11n value\n"); - goto done; - } - enable_11n = atoi(args[1]); - - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS != get_sys_cfg_11n(&htcap)) { - printf("ERR: Reading current 11n configuration.\n"); - goto done; - } - bss->ht_cap_info = htcap.ht_cap_info; - bss->ampdu_param = htcap.ampdu_param; - memcpy(bss->supported_mcs_set, htcap.supported_mcs_set, - 16); - bss->ht_ext_cap = htcap.ht_ext_cap; - bss->tx_bf_cap = htcap.tx_bf_cap; - bss->asel = htcap.asel; - if (enable_11n == 1) { - /* enable mcs rate */ - bss->supported_mcs_set[0] = DEFAULT_MCS_SET_0; - bss->supported_mcs_set[4] = DEFAULT_MCS_SET_4; - if (0 == get_fw_info(&fw)) { - if ((fw.hw_dev_mcs_support & 0x0f) >= 2) - bss->supported_mcs_set[1] = - DEFAULT_MCS_SET_1; - } - } else { - /* disable mcs rate */ - bss->supported_mcs_set[0] = 0; - bss->supported_mcs_set[4] = 0; - bss->supported_mcs_set[1] = 0; - } - } - if (strcmp(args[0], "HTCapInfo") == 0) { - if (enable_11n <= 0) { - printf("ERR: Enable11n parameter should be set before HTCapInfo.\n"); - goto done; - } - if ((IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE) || - ((((t_u16)A2HEXDECIMAL(args[1])) & - (~HT_CAP_CONFIG_MASK)) != HT_CAP_CHECK_MASK)) { - printf("ERR: Invalid HTCapInfo value\n"); - goto done; - } - bss->ht_cap_info = - DEFAULT_HT_CAP_VALUE & ~HT_CAP_CONFIG_MASK; - bss->ht_cap_info |= - (t_u16)A2HEXDECIMAL(args[1]) & - HT_CAP_CONFIG_MASK; - bss->ht_cap_info = uap_cpu_to_le16(bss->ht_cap_info); - } - if (strcmp(args[0], "AMPDU") == 0) { - if (enable_11n <= 0) { - printf("ERR: Enable11n parameter should be set before AMPDU.\n"); - goto done; - } - if ((IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE) || - ((A2HEXDECIMAL(args[1])) > AMPDU_CONFIG_MASK)) { - printf("ERR: Invalid AMPDU value\n"); - goto done; - } - /* Find HT tlv pointer in buffer and set AMPDU */ - bss->ampdu_param = - (t_u8)A2HEXDECIMAL(args[1]) & AMPDU_CONFIG_MASK; - } - if (strcmp(args[0], "HT_MCS_MAP") == 0) { - if (enable_11n <= 0) { - printf("ERR: Enable11n parameter should be set before HT_MCS_MAP.\n"); - goto done; - } - if ((IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE)) { - printf("ERR: Invalid HT_MCS_MAP value\n"); - goto done; - } - if (0 == get_fw_info(&fw)) { - /* Check upper nibble of MCS support value - * and block MCS_SET_1 when 2X2 is not supported - * by the underlying hardware */ - if (((fw.hw_dev_mcs_support & 0xf0) < - STREAM_2X2_MASK) && - (A2HEXDECIMAL(args[1]) & MCS_SET_1_MASK)) { - printf("ERR: Invalid HT_MCS_MAP\n"); - goto done; - } - } - supported_mcs_set = (t_u32)A2HEXDECIMAL(args[1]); - supported_mcs_set = uap_cpu_to_le32(supported_mcs_set); - memcpy(bss->supported_mcs_set, &supported_mcs_set, - sizeof(t_u32)); - } - if (strcmp(args[0], "Enable2040Coex") == 0) { - if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0) || - (atoi(args[1]) > 1)) { - printf("ERR:Invalid Enable2040Coex value.\n"); - goto done; - } - bss->enable_2040coex = (t_u8)atoi(args[1]); - } - } -done: - fclose(config_file); - if (line) - free(line); - return retval; -} - -/** - * @brief Show all the BSS configuration in the buffer - * - * @param buf Pointer to BSS configuration buffer - * - * $return N/A - */ -void -print_bss_config(bss_config_t *buf) -{ - int i = 0; - int flag = 0; - - if (!buf) { - printf("ERR:Empty BSS config!\n"); - return; - } - - /* Print AP MAC address */ - printf("AP MAC address = "); - print_mac(buf->mac_addr); - printf("\n"); - - /* Print SSID */ - if (buf->ssid.ssid_len) { - printf("SSID = %s\n", buf->ssid.ssid); - } - - /* Print broadcast SSID control */ - printf("SSID broadcast = %s\n", - (buf->bcast_ssid_ctl == 1) ? "enabled" : "disabled"); - - /* Print DTIM period */ - printf("DTIM period = %d\n", buf->dtim_period); - - /* Print beacon period */ - printf("Beacon period = %d\n", buf->beacon_period); - - /* Print rates */ - printf("Basic Rates ="); - for (i = 0; i < MAX_DATA_RATES; i++) { - if (!buf->rates[i]) - break; - if (buf->rates[i] > (BASIC_RATE_SET_BIT - 1)) { - flag = flag ? : 1; - printf(" 0x%x", buf->rates[i]); - } - } - printf("%s\nNon-Basic Rates =", flag ? "" : " ( none ) "); - for (flag = 0, i = 0; i < MAX_DATA_RATES; i++) { - if (!buf->rates[i]) - break; - if (buf->rates[i] < BASIC_RATE_SET_BIT) { - flag = flag ? : 1; - printf(" 0x%x", buf->rates[i]); - } - } - printf("%s\n", flag ? "" : " ( none ) "); - - /* Print Tx data rate */ - printf("Tx data rate = "); - if (buf->tx_data_rate == 0) - printf("auto\n"); - else - printf("0x%x\n", buf->tx_data_rate); - - /* Print MCBC data rate */ - printf("MCBC data rate = "); - if (buf->mcbc_data_rate == 0) - printf("auto\n"); - else - printf("0x%x\n", buf->mcbc_data_rate); - - /* Print Tx power level */ - printf("Tx power = %d dBm\n", buf->tx_power_level); - - /* Print Tx antenna */ - printf("Tx antenna = %s\n", (buf->tx_antenna) ? "B" : "A"); - - /* Print Rx antenna */ - printf("Rx antenna = %s\n", (buf->rx_antenna) ? "B" : "A"); - - /* Print packet forward control */ - printf("%s handles packet forwarding -\n", - ((buf->pkt_forward_ctl & PKT_FWD_FW_BIT) == - 0) ? "Host" : "Firmware"); - printf("\tIntra-BSS broadcast packets are %s\n", - ((buf->pkt_forward_ctl & PKT_FWD_INTRA_BCAST) == - 0) ? "allowed" : "denied"); - printf("\tIntra-BSS unicast packets are %s\n", - ((buf->pkt_forward_ctl & PKT_FWD_INTRA_UCAST) == - 0) ? "allowed" : "denied"); - printf("\tInter-BSS unicast packets are %s\n", - ((buf->pkt_forward_ctl & PKT_FWD_INTER_UCAST) == - 0) ? "allowed" : "denied"); - - /* Print maximum STA count */ - printf("Max Station Number configured = %d\n", buf->max_sta_count); - - /* Print mgmt frame FWD control */ - printf("MGMT frame Fwd Control = 0x%x\n", buf->mgmt_ie_passthru_mask); - - /* Print MAC filter */ - if (buf->filter.filter_mode == 0) { - printf("Filter Mode = Filter table is disabled\n"); - } else { - if (buf->filter.filter_mode == 1) { - printf("Filter Mode = Allow MAC addresses specified in the allowed list\n"); - } else if (buf->filter.filter_mode == 2) { - printf("Filter Mode = Block MAC addresses specified in the banned list\n"); - } else { - printf("Filter Mode = Unknown\n"); - } - for (i = 0; i < buf->filter.mac_count; i++) { - printf("MAC_%d = ", i); - print_mac(buf->filter.mac_list[i]); - printf("\n"); - } - } - - /* Print STA ageout timer */ - printf("STA ageout timer = %d\n", buf->sta_ageout_timer); - - /* Print PS STA ageout timer */ - printf("PS STA ageout timer = %d\n", buf->ps_sta_ageout_timer); - - /* Print RTS threshold */ - printf("RTS threshold = %d\n", buf->rts_threshold); - - /* Print Fragmentation threshold */ - printf("Fragmentation threshold = %d\n", buf->frag_threshold); - - /* Print retry limit */ - printf("Retry Limit = %d\n", buf->retry_limit); - - /* Print preamble type */ - printf("Preamble type = %s\n", (buf->preamble_type == 0) ? - "auto" : ((buf->preamble_type == 1) ? "short" : "long")); - - /* Print channel */ - printf("Channel = %d\n", buf->channel); - printf("Band = %s\n", - (buf->bandcfg.chanBand == BAND_5GHZ) ? "5GHz" : "2.4GHz"); - printf("Channel Select Mode = %s\n", - (buf->bandcfg.scanMode == SCAN_MODE_ACS) ? "ACS" : "Manual"); - if (buf->bandcfg.chan2Offset == SEC_CHAN_NONE) - printf("no secondary channel\n"); - else if (buf->bandcfg.chan2Offset == SEC_CHAN_ABOVE) - printf("secondary channel is above primary channel\n"); - else if (buf->bandcfg.chan2Offset == SEC_CHAN_BELOW) - printf("secondary channel is below primary channel\n"); - - /* Print channel list */ - printf("Channels List = "); - for (i = 0; (unsigned int)i < buf->num_of_chan; i++) { - printf("\n%d\t%sGHz", buf->chan_list[i].chan_number, - (buf->chan_list[i].bandcfg.chanBand == - BAND_5GHZ) ? "5" : "2.4"); - } - printf("\n"); - - /* Print auth mode */ - switch (buf->auth_mode) { - case 0: - printf("AUTHMODE = Open authentication\n"); - break; - case 1: - printf("AUTHMODE = Shared key authentication\n"); - break; - case 3: - printf("AUTHMODE = WPA3 SAE\n"); - break; - case 255: - printf("AUTHMODE = Auto (open and shared key)\n"); - break; - default: - printf("ERR: Invalid authmode=%d\n", buf->auth_mode); - break; - } - - /* Print protocol */ - switch (buf->protocol) { - case 0: - case PROTOCOL_NO_SECURITY: - printf("PROTOCOL = No security\n"); - break; - case PROTOCOL_STATIC_WEP: - printf("PROTOCOL = Static WEP\n"); - break; - case PROTOCOL_WPA: - printf("PROTOCOL = WPA \n"); - break; - case PROTOCOL_WPA2: - printf("PROTOCOL = WPA2 \n"); - break; - case PROTOCOL_WPA | PROTOCOL_WPA2: - printf("PROTOCOL = WPA/WPA2 \n"); - break; - case PROTOCOL_WPA3_SAE: - printf("PROTOCOL = WPA3 SAE \n"); - break; - default: - printf("Unknown PROTOCOL: 0x%x \n", buf->protocol); - break; - } - - /* Print key management */ - if (buf->key_mgmt == KEY_MGMT_PSK) - printf("KeyMgmt = PSK\n"); - else - printf("KeyMgmt = NONE\n"); - - /* Print WEP configurations */ - if (buf->wep_cfg.key0.length) { - printf("WEP KEY_0 = "); - for (i = 0; i < buf->wep_cfg.key0.length; i++) { - printf("%02x ", buf->wep_cfg.key0.key[i]); - } - (buf->wep_cfg.key0. - is_default) ? (printf("\n")) : (printf("\n")); - } else { - printf("WEP KEY_0 = NONE\n"); - } - if (buf->wep_cfg.key1.length) { - printf("WEP KEY_1 = "); - for (i = 0; i < buf->wep_cfg.key1.length; i++) { - printf("%02x ", buf->wep_cfg.key1.key[i]); - } - (buf->wep_cfg.key1. - is_default) ? (printf("\n")) : (printf("\n")); - } else { - printf("WEP KEY_1 = NONE\n"); - } - if (buf->wep_cfg.key2.length) { - printf("WEP KEY_2 = "); - for (i = 0; i < buf->wep_cfg.key2.length; i++) { - printf("%02x ", buf->wep_cfg.key2.key[i]); - } - (buf->wep_cfg.key2. - is_default) ? (printf("\n")) : (printf("\n")); - } else { - printf("WEP KEY_2 = NONE\n"); - } - if (buf->wep_cfg.key3.length) { - printf("WEP KEY_3 = "); - for (i = 0; i < buf->wep_cfg.key3.length; i++) { - printf("%02x ", buf->wep_cfg.key3.key[i]); - } - (buf->wep_cfg.key3. - is_default) ? (printf("\n")) : (printf("\n")); - } else { - printf("WEP KEY_3 = NONE\n"); - } - - /* Print WPA configurations */ - if (buf->protocol & PROTOCOL_WPA) { - switch (buf->wpa_cfg.pairwise_cipher_wpa) { - case CIPHER_TKIP: - printf("PwkCipherWPA = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("PwkCipherWPA = AES CCMP\n"); - break; - case CIPHER_TKIP | CIPHER_AES_CCMP: - printf("PwkCipherWPA = TKIP + AES CCMP\n"); - break; - case CIPHER_NONE: - printf("PwkCipherWPA = None\n"); - break; - default: - printf("Unknown PwkCipherWPA 0x%x\n", - buf->wpa_cfg.pairwise_cipher_wpa); - break; - } - } - if (buf->protocol & (PROTOCOL_WPA2 | PROTOCOL_WPA3_SAE)) { - switch (buf->wpa_cfg.pairwise_cipher_wpa2) { - case CIPHER_TKIP: - printf("PwkCipherWPA2 = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("PwkCipherWPA2 = AES CCMP\n"); - break; - case CIPHER_TKIP | CIPHER_AES_CCMP: - printf("PwkCipherWPA2 = TKIP + AES CCMP\n"); - break; - case CIPHER_NONE: - printf("PwkCipherWPA2 = None\n"); - break; - default: - printf("Unknown PwkCipherWPA2 0x%x\n", - buf->wpa_cfg.pairwise_cipher_wpa2); - break; - } - } - switch (buf->wpa_cfg.group_cipher) { - case CIPHER_TKIP: - printf("GroupCipher = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("GroupCipher = AES CCMP\n"); - break; - case CIPHER_NONE: - printf("GroupCipher = None\n"); - break; - default: - printf("Unknown Group cipher 0x%x\n", - buf->wpa_cfg.group_cipher); - break; - } - printf("RSN replay protection = %s\n", - (buf->wpa_cfg.rsn_protection) ? "enabled" : "disabled"); - printf("Pairwise Handshake timeout = %d\n", - buf->pairwise_update_timeout); - printf("Pairwise Handshake Retries = %d\n", buf->pwk_retries); - printf("Groupwise Handshake timeout = %d\n", - buf->groupwise_update_timeout); - printf("Groupwise Handshake Retries = %d\n", buf->gwk_retries); - if (buf->wpa_cfg.length > 0) { - printf("WPA passphrase = "); - for (i = 0; (unsigned int)i < buf->wpa_cfg.length; i++) - printf("%c", buf->wpa_cfg.passphrase[i]); - printf("\n"); - } else { - printf("WPA passphrase = None\n"); - } - if (buf->wpa_cfg.gk_rekey_time == 0) - printf("Group re-key time = disabled\n"); - else - printf("Group re-key time = %d second\n", - buf->wpa_cfg.gk_rekey_time); - printf("20/40 coex = %s\n", - (buf->enable_2040coex) ? "enabled" : "disabled"); - printf("wmm parameters:\n"); - printf("\tqos_info = 0x%x\n", buf->wmm_para.qos_info); - printf("\tBE: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - buf->wmm_para.ac_params[AC_BE].aci_aifsn.aifsn, - buf->wmm_para.ac_params[AC_BE].ecw.ecw_max, - buf->wmm_para.ac_params[AC_BE].ecw.ecw_min, - buf->wmm_para.ac_params[AC_BE].tx_op_limit); - printf("\tBK: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - buf->wmm_para.ac_params[AC_BK].aci_aifsn.aifsn, - buf->wmm_para.ac_params[AC_BK].ecw.ecw_max, - buf->wmm_para.ac_params[AC_BK].ecw.ecw_min, - buf->wmm_para.ac_params[AC_BK].tx_op_limit); - printf("\tVI: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - buf->wmm_para.ac_params[AC_VI].aci_aifsn.aifsn, - buf->wmm_para.ac_params[AC_VI].ecw.ecw_max, - buf->wmm_para.ac_params[AC_VI].ecw.ecw_min, - buf->wmm_para.ac_params[AC_VI].tx_op_limit); - printf("\tVO: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - buf->wmm_para.ac_params[AC_VO].aci_aifsn.aifsn, - buf->wmm_para.ac_params[AC_VO].ecw.ecw_max, - buf->wmm_para.ac_params[AC_VO].ecw.ecw_min, - buf->wmm_para.ac_params[AC_VO].tx_op_limit); - - return; -} - -/** - * @brief Send command to Read the BSS profile - * - * @param buf Pointer to bss command buffer for get - * @return UAP_SUCCESS or UAP_FAILURE - */ -static int -get_bss_config(t_u8 *buf) -{ - apcmdbuf_bss_configure *cmd_buf = NULL; - t_s32 sockfd; - struct ifreq ifr; - - cmd_buf = (apcmdbuf_bss_configure *)buf; - cmd_buf->action = ACTION_GET; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } -#if DEBUG - /* Dump request buffer */ - hexdump("Get Request buffer", (void *)buf, - sizeof(apcmdbuf_bss_configure) - + sizeof(bss_config_t), ' '); -#endif - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)cmd_buf; - if (ioctl(sockfd, UAP_BSS_CONFIG, &ifr)) { - printf("ERR:UAP_BSS_CONFIG is not supported by %s\n", dev_name); - close(sockfd); - return UAP_FAILURE; - } -#if DEBUG - /* Dump request buffer */ - hexdump("Get Response buffer", (void *)buf, - sizeof(apcmdbuf_bss_configure) - + sizeof(bss_config_t), ' '); -#endif - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Creates a bss_config request and sends to the driver - * - * Usage: "Usage : bss_config [CONFIG_FILE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_bss_config(int argc, char *argv[]) -{ - apcmdbuf_bss_configure *cmd_buf = NULL; - bss_config_t *bss = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len; - t_u16 buf_len; - int ret = UAP_SUCCESS; - int opt; - t_s32 sockfd; - struct ifreq ifr; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_bss_config_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_bss_config_usage(); - return UAP_FAILURE; - } - - /* Query BSS settings */ - - /* Alloc buf for command */ - buf_len = sizeof(apcmdbuf_bss_configure) + sizeof(bss_config_t); - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset((char *)buf, 0, buf_len); - - /* Locate headers */ - cmd_len = sizeof(apcmdbuf_bss_configure); - cmd_buf = (apcmdbuf_bss_configure *)buf; - bss = (bss_config_t *)(buf + cmd_len); - - /* Get all parametes first */ - if (get_bss_config(buf) == UAP_FAILURE) { - printf("ERR:Reading current parameters\n"); - free(buf); - return UAP_FAILURE; - } - - if (argc == 1) { - /* Parse config file and populate structure */ - ret = parse_bss_config(argc, argv, bss); - if (ret == UAP_FAILURE) { - free(buf); - return ret; - } - cmd_len += sizeof(bss_config_t); - cmd_buf->action = ACTION_SET; - - /* Send the command */ - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - free(buf); - return UAP_FAILURE; - } - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)cmd_buf; -#if DEBUG - /* Dump request buffer */ - hexdump("Request buffer", (void *)buf, buf_len, ' '); -#endif - if (ioctl(sockfd, UAP_BSS_CONFIG, &ifr)) { - perror(""); - printf("ERR:UAP_BSS_CONFIG is not supported by %s\n", - dev_name); - close(sockfd); - free(buf); - return UAP_FAILURE; - } -#if DEBUG - /* Dump respond buffer */ - hexdump("Respond buffer", (void *)buf, buf_len, ' '); -#endif - close(sockfd); - } else { - /* Print response */ - printf("BSS settings:\n"); - print_bss_config(bss); - } - - free(buf); - return ret; -} - -/** - * @brief Read the profile and sends to the driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -apcmd_coex_config_profile(int argc, char *argv[]) -{ - FILE *config_file = NULL; - char *line = NULL; - int i, index, li = 0; - int ret = UAP_SUCCESS; - char *pos = NULL; - int arg_num = 0; - char *args[30]; - int is_coex_config = 0; - int is_coex_common_config = 0; - int is_coex_sco_config = 0; - int is_coex_acl_config = 0; - t_u8 *buf = NULL; - apcmdbuf_coex_config *cmd_buf = NULL; - tlvbuf_coex_common_cfg *coex_common_tlv; - tlvbuf_coex_sco_cfg *coex_sco_tlv; - tlvbuf_coex_acl_cfg *coex_acl_tlv; - t_u16 acl_enabled = 0; - t_u32 conf_bitmap = 0; - t_u32 ap_coex_enable = 0; - t_u16 cmd_len = 0, tlv_len = 0; - t_u16 sco_prot_qtime[4] = { 0, 0, 0, 0 }, sco_prot_rate = - 0, sco_acl_freq = 0; - t_u16 acl_bt_time = 0, acl_wlan_time = 0, acl_prot_rate = 0; - - /* Check if file exists */ - config_file = fopen(argv[0], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - return UAP_FAILURE; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - ret = UAP_FAILURE; - goto done; - } - bzero(line, MAX_CONFIG_LINE); - - /* fixed command length */ - cmd_len = sizeof(apcmdbuf_coex_config) + sizeof(tlvbuf_coex_common_cfg) - + sizeof(tlvbuf_coex_sco_cfg) + sizeof(tlvbuf_coex_acl_cfg); - /* alloc buf for command */ - buf = (t_u8 *)malloc(cmd_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - ret = UAP_FAILURE; - goto done; - } - bzero((char *)buf, cmd_len); - - cmd_buf = (apcmdbuf_coex_config *)buf; - - /* Fill the command buffer */ - cmd_buf->cmd_code = HostCmd_ROBUST_COEX; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = uap_cpu_to_le16(ACTION_SET); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { -#if DEBUG - uap_printf(MSG_DEBUG, "DBG:Received config line (%d) = %s\n", - li, line); -#endif - arg_num = parse_line(line, args); -#if DEBUG - uap_printf(MSG_DEBUG, "DBG:Number of arguments = %d\n", - arg_num); - for (i = 0; i < arg_num; i++) { - uap_printf(MSG_DEBUG, "\tDBG:Argument %d. %s\n", i + 1, - args[i]); - } -#endif - /* Check for end of Coex configurations */ - if (is_coex_acl_config == 1) { - if (strcmp(args[0], "}") == 0) { - coex_acl_tlv = - (tlvbuf_coex_acl_cfg *)(cmd_buf-> - tlv_buffer + - tlv_len); - coex_acl_tlv->tag = MRVL_BT_COEX_ACL_CFG_TLV_ID; - coex_acl_tlv->length = - sizeof(tlvbuf_coex_acl_cfg) - - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_acl_tlv); - coex_acl_tlv->enabled = - uap_cpu_to_le16(acl_enabled); - coex_acl_tlv->bt_time = - uap_cpu_to_le16(acl_bt_time); - coex_acl_tlv->wlan_time = - uap_cpu_to_le16(acl_wlan_time); - coex_acl_tlv->protection_rate = - uap_cpu_to_le16(acl_prot_rate); - tlv_len += sizeof(tlvbuf_coex_acl_cfg); - is_coex_acl_config = 0; - } - } else if (is_coex_sco_config == 1) { - if (strcmp(args[0], "}") == 0) { - coex_sco_tlv = - (tlvbuf_coex_sco_cfg *)(cmd_buf-> - tlv_buffer + - tlv_len); - coex_sco_tlv->tag = MRVL_BT_COEX_SCO_CFG_TLV_ID; - coex_sco_tlv->length = - sizeof(tlvbuf_coex_sco_cfg) - - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_sco_tlv); - for (i = 0; i < 4; i++) - coex_sco_tlv->protection_qtime[i] = - uap_cpu_to_le16(sco_prot_qtime - [i]); - coex_sco_tlv->protection_rate = - uap_cpu_to_le16(sco_prot_rate); - coex_sco_tlv->acl_frequency = - uap_cpu_to_le16(sco_acl_freq); - tlv_len += sizeof(tlvbuf_coex_sco_cfg); - is_coex_sco_config = 0; - } - } else if (is_coex_common_config == 1) { - if (strcmp(args[0], "}") == 0) { - coex_common_tlv = - (tlvbuf_coex_common_cfg *)(cmd_buf-> - tlv_buffer + - tlv_len); - coex_common_tlv->tag = - MRVL_BT_COEX_COMMON_CFG_TLV_ID; - coex_common_tlv->length = - sizeof(tlvbuf_coex_common_cfg) - - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_common_tlv); - coex_common_tlv->config_bitmap = - uap_cpu_to_le32(conf_bitmap); - coex_common_tlv->ap_bt_coex = - uap_cpu_to_le32(ap_coex_enable); - tlv_len += sizeof(tlvbuf_coex_common_cfg); - is_coex_common_config = 0; - } - } else if (is_coex_config == 1) { - if (strcmp(args[0], "}") == 0) - is_coex_config = 0; - } - if (strcmp(args[0], "coex_config") == 0) { - is_coex_config = 1; - } else if (strcmp(args[0], "common_config") == 0) { - is_coex_common_config = 1; - } else if (strcmp(args[0], "sco_config") == 0) { - is_coex_sco_config = 1; - } else if (strcmp(args[0], "acl_config") == 0) { - is_coex_acl_config = 1; - } - if ((strcmp(args[0], "bitmap") == 0) && is_coex_common_config) { - if (is_input_valid - (COEX_COMM_BITMAP, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - conf_bitmap = (t_u32)A2HEXDECIMAL(args[1]); - } else if ((strcmp(args[0], "APBTCoex") == 0) && - is_coex_common_config) { - if (is_input_valid - (COEX_COMM_AP_COEX, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - ap_coex_enable = (t_u32)A2HEXDECIMAL(args[1]); - } else if ((strncmp(args[0], "protectionFromQTime", 19) == 0) && - is_coex_sco_config) { - index = atoi(args[0] + strlen("protectionFromQTime")); - if (index < 0 || index > 3) { - printf("ERR:Incorrect index %d.\n", index); - ret = UAP_FAILURE; - goto done; - } - if (is_input_valid(COEX_PROTECTION, arg_num, args) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - sco_prot_qtime[index] = (t_u16)atoi(args[1]); - } else if ((strcmp(args[0], "scoProtectionFromRate") == 0) && - is_coex_sco_config) { - if (is_input_valid(COEX_PROTECTION, arg_num, args) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - sco_prot_rate = (t_u16)atoi(args[1]); - } else if ((strcmp(args[0], "aclFrequency") == 0) && - is_coex_sco_config) { - if (is_input_valid - (COEX_SCO_ACL_FREQ, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - sco_acl_freq = (t_u16)atoi(args[1]); - } else if ((strcmp(args[0], "enabled") == 0) && - is_coex_acl_config) { - if (is_input_valid - (COEX_ACL_ENABLED, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - acl_enabled = (t_u16)atoi(args[1]); - } else if ((strcmp(args[0], "btTime") == 0) && - is_coex_acl_config) { - if (is_input_valid - (COEX_ACL_BT_TIME, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - acl_bt_time = (t_u16)atoi(args[1]); - } else if ((strcmp(args[0], "wlanTime") == 0) && - is_coex_acl_config) { - if (is_input_valid - (COEX_ACL_WLAN_TIME, arg_num - 1, - args + 1) != UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - acl_wlan_time = (t_u16)atoi(args[1]); - } else if ((strcmp(args[0], "aclProtectionFromRate") == 0) && - is_coex_acl_config) { - if (is_input_valid(COEX_PROTECTION, arg_num, args) != - UAP_SUCCESS) { - ret = UAP_FAILURE; - goto done; - } - acl_prot_rate = (t_u16)atoi(args[1]); - } - } - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, cmd_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_ROBUST_COEX | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - ret = UAP_FAILURE; - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("BT Coex settings sucessfully set.\n"); - } else { - printf("ERR:Could not set coex configuration.\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - fclose(config_file); - if (buf) - free(buf); - if (line) - free(line); - return ret; -} - -/** - * @brief Show usage information for the coex_config command - * - * $return N/A - */ -void -print_coex_config_usage(void) -{ - printf("\nUsage : coex_config [CONFIG_FILE]\n"); - printf("\nIf CONFIG_FILE is provided, a 'set' is performed, else a 'get' is performed.\n"); - return; -} - -/** - * @brief Creates a coex_config request and sends to the driver - * - * Usage: "Usage : coex_config [CONFIG_FILE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -apcmd_coex_config(int argc, char *argv[]) -{ - apcmdbuf_coex_config *cmd_buf = NULL; - tlvbuf_coex_common_cfg *coex_common_tlv; - tlvbuf_coex_sco_cfg *coex_sco_tlv; - tlvbuf_coex_acl_cfg *coex_acl_tlv; - tlvbuf_coex_stats *coex_stats_tlv; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_coex_config_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:Too many arguments.\n"); - print_coex_config_usage(); - return UAP_FAILURE; - } - if (argc == 1) { - /* Read profile and send command to firmware */ - ret = apcmd_coex_config_profile(argc, argv); - return ret; - } - - /* fixed command length */ - cmd_len = sizeof(apcmdbuf_coex_config) + sizeof(tlvbuf_coex_common_cfg) - + sizeof(tlvbuf_coex_sco_cfg) + sizeof(tlvbuf_coex_acl_cfg) - + sizeof(tlvbuf_coex_stats); - /* alloc buf for command */ - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - bzero((char *)buf, buf_len); - - cmd_buf = (apcmdbuf_coex_config *)buf; - - coex_common_tlv = (tlvbuf_coex_common_cfg *)cmd_buf->tlv_buffer; - coex_common_tlv->tag = MRVL_BT_COEX_COMMON_CFG_TLV_ID; - coex_common_tlv->length = - sizeof(tlvbuf_coex_common_cfg) - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_common_tlv); - - coex_sco_tlv = (tlvbuf_coex_sco_cfg *)(cmd_buf->tlv_buffer + - sizeof(tlvbuf_coex_common_cfg)); - coex_sco_tlv->tag = MRVL_BT_COEX_SCO_CFG_TLV_ID; - coex_sco_tlv->length = - sizeof(tlvbuf_coex_sco_cfg) - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_sco_tlv); - - coex_acl_tlv = (tlvbuf_coex_acl_cfg *)(cmd_buf->tlv_buffer + - sizeof(tlvbuf_coex_common_cfg) + - sizeof(tlvbuf_coex_sco_cfg)); - coex_acl_tlv->tag = MRVL_BT_COEX_ACL_CFG_TLV_ID; - coex_acl_tlv->length = - sizeof(tlvbuf_coex_acl_cfg) - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_acl_tlv); - - coex_stats_tlv = (tlvbuf_coex_stats *)(cmd_buf->tlv_buffer + - sizeof(tlvbuf_coex_common_cfg) + - sizeof(tlvbuf_coex_sco_cfg) - + sizeof(tlvbuf_coex_acl_cfg)); - coex_stats_tlv->tag = MRVL_BT_COEX_STATS_TLV_ID; - coex_stats_tlv->length = - sizeof(tlvbuf_coex_stats) - sizeof(tlvbuf_header); - endian_convert_tlv_header_out(coex_stats_tlv); - - /* Fill the command buffer */ - cmd_buf->cmd_code = HostCmd_ROBUST_COEX; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = uap_cpu_to_le16(ACTION_GET); - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_ROBUST_COEX | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - free(buf); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - printf("BT Coex settings:\n"); - print_tlv(buf + sizeof(apcmdbuf_coex_config), - cmd_buf->size - sizeof(apcmdbuf_coex_config) + - BUF_HEADER_SIZE); - } else { - printf("ERR:Could not retrieve coex configuration.\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - free(buf); - return ret; -} - -/** - * @brief Show usage information for the mic_err command - * - * $return N/A - */ -void -print_mic_err_usage(void) -{ - printf("\nUsage : mic_err \n"); - return; -} - -/** - * @brief report station mic error to the driver - * - * Usage: "mic_err " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_mic_err(int argc, char *argv[]) -{ - int ret = UAP_SUCCESS; - int opt; - struct ifreq ifr; - t_s32 sockfd; - t_u8 mac_addr[ETH_ALEN]; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_mic_err_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 1) { - printf("ERR:wrong arguments! Must provide STA_MAC_ADDRESS.\n"); - print_mic_err_usage(); - return UAP_FAILURE; - } - memset(mac_addr, 0, ETH_ALEN); - - if ((ret = mac2raw(argv[0], mac_addr)) != UAP_SUCCESS) { - printf("ERR: %s Address\n", ret == UAP_FAILURE ? "Invalid MAC" : - ret == - UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast"); - return UAP_FAILURE; - } -#if DEBUG - /* Dump mac address */ - hexdump("report mic error", (void *)mac_addr, ETH_ALEN, ' '); -#endif - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)mac_addr; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_REPORT_MIC_ERR, &ifr)) { - perror(""); - printf("ERR:UAP_REPORT_MIC_ERR is not supported by %s\n", - dev_name); - close(sockfd); - return UAP_FAILURE; - } - printf("MIC error reporting successful!\n"); - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sta_deauth_ext command - * - * $return N/A - */ -void -print_set_key_usage(void) -{ - printf("\nUsage : key_material [KEY_ID]\n"); - printf("\n MAC_ADDRESS: station mac address or ff:ff:ff:ff:ff:ff"); - printf("\n KEY: hex string, valid length 32 or 64\n"); - return; -} - -/** - * @brief Creates a set key request and sends to the driver - * - * Usage: "set_key [KEY_ID]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_set_key(int argc, char *argv[]) -{ - int ret = UAP_SUCCESS; - int opt; - struct ifreq ifr; - t_s32 sockfd; - encrypt_key key; - int key_id = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_set_key_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2 || argc > 3) { - print_set_key_usage(); - return UAP_FAILURE; - } - memset(&key, 0, sizeof(encrypt_key)); - - ret = mac2raw(argv[0], key.mac_addr); - - if ((ret != UAP_SUCCESS) && (ret != UAP_RET_MAC_BROADCAST)) { - printf("ERR: %s Address\n", - ret == UAP_FAILURE ? "Invalid MAC" : "Multicast"); - return UAP_FAILURE; - } - if ((strlen(argv[1]) != 32) && (strlen(argv[1]) != 64)) { - printf("ERR: key must be hex string with length 32 or 64"); - print_set_key_usage(); - return UAP_FAILURE; - } - if (UAP_FAILURE == ishexstring(argv[1])) { - printf("ERR:Only hex digits are allowed\n"); - print_set_key_usage(); - return UAP_FAILURE; - } - if (argc == 3) { - if ((ISDIGIT(argv[2]) == 0) || (atoi(argv[2]) < 0) || - (atoi(argv[2]) > 3)) { - printf("ERR:Illegal key id %s. Must be either '0', '1', '2', or '3'.\n", argv[2]); - print_set_key_usage(); - return UAP_FAILURE; - } - key_id = atoi(argv[2]); - } - - key.key_len = strlen(argv[1]) / 2; - string2raw(argv[1], key.key_material); - key.key_index = key_id; - -#if DEBUG - /* dump key buffer */ - hexdump("set key", (void *)&key, sizeof(encrypt_key), ' '); -#endif - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&key; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_SET_KEY, &ifr)) { - perror(""); - printf("ERR:UAP_SET_KEY is not supported by %s\n", dev_name); - close(sockfd); - return UAP_FAILURE; - } - printf("Key setting successful.\n"); - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sys_cfg_custom_ie - * command - * - * $return N/A - */ -void -print_sys_cfg_custom_ie_usage(void) -{ - printf("\nUsage : sys_cfg_custom_ie [INDEX] [MASK] [IEBuffer]"); - printf("\n empty - Get all IE settings\n"); - printf("\n INDEX: 0 - Get/Set IE index 0 setting"); - printf("\n 1 - Get/Set IE index 1 setting"); - printf("\n 2 - Get/Set IE index 2 setting"); - printf("\n 3 - Get/Set IE index 3 setting"); - printf("\n . "); - printf("\n . "); - printf("\n . "); - printf("\n -1 - Append/Delete IE automatically"); - printf("\n Delete will delete the IE from the matching IE buffer"); - printf("\n Append will append the IE to the buffer with the same mask"); - printf("\n MASK : Management subtype mask value as per bit defintions"); - printf("\n : Bit 0 - Association request."); - printf("\n : Bit 1 - Association response."); - printf("\n : Bit 2 - Reassociation request."); - printf("\n : Bit 3 - Reassociation response."); - printf("\n : Bit 4 - Probe request."); - printf("\n : Bit 5 - Probe response."); - printf("\n : Bit 8 - Beacon."); - printf("\n MASK : MASK = 0 to clear the mask and the IE buffer"); - printf("\n IEBuffer : IE Buffer in hex (max 256 bytes)\n\n"); - return; -} - -/** custom IE, auto mask value */ -#define UAP_CUSTOM_IE_AUTO_MASK 0xffff - -/** - * @brief Get max management IE index - * @param max_mgmt_ie - * @param print flag - * @return UAP_SUCCESS/UAP_FAILURE - */ -static int -get_max_mgmt_ie(int *max_mgmt_ie, int flag) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_max_mgmt_ie *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0, i = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - - *max_mgmt_ie = 0; - /* Initialize the command length */ - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_max_mgmt_ie); - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_max_mgmt_ie *)(buffer + sizeof(apcmdbuf_sys_configure)); - - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv->tag = MRVL_MAX_MGMT_IE_TLV_ID; - tlv->length = 0; - cmd_buf->action = ACTION_GET; - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if ((cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) || - (tlv->tag != MRVL_MAX_MGMT_IE_TLV_ID)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - tlv->count = uap_le16_to_cpu(tlv->count); - for (i = 0; i < tlv->count; i++) { - tlv->info[i].buf_size = - uap_le16_to_cpu(tlv->info[i].buf_size); - tlv->info[i].buf_count = - uap_le16_to_cpu(tlv->info[i].buf_count); - *max_mgmt_ie += tlv->info[i].buf_count; - if (flag) { - printf("buf%d_size = %d\n", i, - tlv->info[i].buf_size); - printf("number of buffers = %d\n", - tlv->info[i].buf_count); - printf("\n"); - } - } - } else { - printf("ERR:Could not get max_mgmt_ie_index!\n"); - ret = UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - } - if (buffer) - free(buffer); - return UAP_SUCCESS; -} - -/** - * @brief Creates a sys_cfg request for custom IE settings - * and sends to the driver - * - * Usage: "sys_cfg_custom_ie [INDEX] [MASK] [IEBuffer]" - * - * Options: INDEX : 0 - Get/Set IE index 0 setting - * 1 - Get/Set IE index 1 setting - * 2 - Get/Set IE index 2 setting - * 3 - Get/Set IE index 3 setting - * . - * . - * . - * MASK : Management subtype mask value - * IEBuffer: IE Buffer in hex - * empty - Get all IE settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_sys_cfg_custom_ie(int argc, char *argv[]) -{ - tlvbuf_custom_ie *tlv = NULL; - tlvbuf_max_mgmt_ie *max_mgmt_ie_tlv = NULL; - custom_ie *ie_ptr = NULL; - t_u8 *buffer = NULL; - t_u16 buf_len = 0; - t_u16 mgmt_subtype_mask = 0; - int ie_buf_len = 0, ie_len = 0, i = 0, max_mgmt_ie = 0, print_flag = 0; - struct ifreq ifr; - t_s32 sockfd; - - if (argc == 1 && max_mgmt_ie_print == 0) { - /* Print buffer sizes only if (argc == 1) i.e. get all indices one by one - * && (max_mgmt_ie_print == 0) i.e. max mgmt IE is not printed via sys_config cmd */ - print_flag = 1; - } - - /* Reset the max_mgmt_ie_print for successive cmds */ - max_mgmt_ie_print = 0; - - if (!get_max_mgmt_ie(&max_mgmt_ie, print_flag)) { - printf("ERR:couldn't get max_mgmt_ie!\n"); - return UAP_FAILURE; - } - if (max_mgmt_ie == 0) { - max_mgmt_ie = MAX_MGMT_IE_INDEX; -#if DEBUG - uap_printf(MSG_DEBUG, - "WARN: max_mgmt_ie=0, defaulting to MAX_MGMT_IE_INDEX\n"); -#endif - } - - /* Check arguments */ - if (argc > 4) { - printf("ERR:Too many arguments.\n"); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - - /* Error checks and initialize the command length */ - if (argc >= 2) { - if (((IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) && - (atoi(argv[1]) != -1)) || (atoi(argv[1]) < -1)) { - printf("ERR:Illegal index %s\n", argv[1]); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - } - switch (argc) { - case 1: - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - break; - case 2: - if ((atoi(argv[1]) < 0) || (atoi(argv[1]) >= max_mgmt_ie)) { - printf("ERR:Illegal index %s. Must be either greater than or equal to 0 and less than %d for Get Operation \n", argv[1], max_mgmt_ie); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - break; - case 3: - if (UAP_FAILURE == ishexstring(argv[2]) || - A2HEXDECIMAL(argv[2]) != 0) { - printf("ERR: Mask value should be 0 to clear IEBuffers.\n"); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - if (atoi(argv[1]) == -1) { - printf("ERR: Buffer should be provided for automatic deletion.\n"); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - buf_len = sizeof(tlvbuf_custom_ie) + sizeof(custom_ie); - break; - case 4: - /* This is to check negative numbers and special symbols */ - if (UAP_FAILURE == IS_HEX_OR_DIGIT(argv[2])) { - printf("ERR:Mask value must be 0 or hex digits\n"); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - /* If above check is passed and mask is not hex, then it must be 0 */ - if ((ISDIGIT(argv[2]) == UAP_SUCCESS) && atoi(argv[2])) { - printf("ERR:Mask value must be 0 or hex digits\n "); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - if (UAP_FAILURE == ishexstring(argv[3])) { - printf("ERR:Only hex digits are allowed\n"); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - ie_buf_len = strlen(argv[3]); - if (!strncasecmp("0x", argv[3], 2)) { - ie_len = (ie_buf_len - 2 + 1) / 2; - argv[3] += 2; - } else - ie_len = (ie_buf_len + 1) / 2; - if (ie_len > MAX_IE_BUFFER_LEN) { - printf("ERR:Incorrect IE length %d\n", ie_buf_len); - print_sys_cfg_custom_ie_usage(); - return UAP_FAILURE; - } - mgmt_subtype_mask = (t_u16)A2HEXDECIMAL(argv[2]); - buf_len = sizeof(tlvbuf_custom_ie) + sizeof(custom_ie) + ie_len; - break; - } - - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(buffer, 0, buf_len); - tlv = (tlvbuf_custom_ie *)buffer; - tlv->tag = MRVL_MGMT_IE_LIST_TLV_ID; - if (argc == 1 || argc == 2) { - if (argc == 1) - tlv->length = 0; - else { - tlv->length = sizeof(t_u16); - ie_ptr = (custom_ie *)(tlv->ie_data); - ie_ptr->ie_index = (t_u16)(atoi(argv[1])); - } - } else { - /* Locate headers */ - ie_ptr = (custom_ie *)(tlv->ie_data); - /* Set TLV fields */ - tlv->length = sizeof(custom_ie) + ie_len; - ie_ptr->ie_index = atoi(argv[1]); - ie_ptr->mgmt_subtype_mask = mgmt_subtype_mask; - ie_ptr->ie_length = ie_len; - if (argc == 4) - string2raw(argv[3], ie_ptr->ie_buffer); - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - if (buffer) - free(buffer); - return UAP_FAILURE; - } - if (argc != 1) { - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)buffer; - /* Perform ioctl */ - if (ioctl(sockfd, UAP_CUSTOM_IE, &ifr)) { - if (errno < 0) { - perror("ioctl[UAP_CUSTOM_IE]"); - printf("ERR:Command sending failed!\n"); - } else { - printf("custom IE configuration failed!\n"); - } - close(sockfd); - if (buffer) - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - if (argc > 2) { - printf("custom IE setting successful\n"); - } else { - printf("Querying custom IE successful\n"); - tlv = (tlvbuf_custom_ie *)buffer; - ie_len = tlv->length; - ie_ptr = (custom_ie *)(tlv->ie_data); - if (tlv->tag == MRVL_MGMT_IE_LIST_TLV_ID) { - while ((unsigned int)ie_len >= - sizeof(custom_ie)) { - printf("Index [%d]\n", - ie_ptr->ie_index); - if (ie_ptr->ie_length) - printf("Management Subtype Mask = 0x%02x\n", ie_ptr->mgmt_subtype_mask == 0 ? UAP_CUSTOM_IE_AUTO_MASK : ie_ptr->mgmt_subtype_mask); - else - printf("Management Subtype Mask = 0x%02x\n", ie_ptr->mgmt_subtype_mask); - hexdump_data("IE Buffer", - (void *)ie_ptr->ie_buffer, - (ie_ptr->ie_length), ' '); - ie_len -= - sizeof(custom_ie) + - ie_ptr->ie_length; - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) - + - ie_ptr-> - ie_length); - } - } - max_mgmt_ie_tlv = - (tlvbuf_max_mgmt_ie *)(buffer + - sizeof(tlvbuf_custom_ie) - + tlv->length); - if (max_mgmt_ie_tlv) { - if (max_mgmt_ie_tlv->tag == - MRVL_MAX_MGMT_IE_TLV_ID) { - for (i = 0; i < max_mgmt_ie_tlv->count; - i++) { - printf("buf%d_size = %d\n", i, - max_mgmt_ie_tlv->info[i]. - buf_size); - printf("number of buffers = %d\n", max_mgmt_ie_tlv->info[i].buf_count); - printf("\n"); - } - } - } - } - } - - /* Special handling for all indices: Get all IEs one-by-one */ - if (argc == 1) { - for (i = 0; i < max_mgmt_ie; i++) { - - tlv->length = sizeof(t_u16); - ie_ptr = (custom_ie *)(tlv->ie_data); - ie_ptr->ie_index = (t_u16)(i); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)buffer; - /* Perform ioctl */ - if (ioctl(sockfd, UAP_CUSTOM_IE, &ifr)) { - if (errno < 0) { - perror("ioctl[UAP_CUSTOM_IE]"); - printf("ERR:Command sending failed!\n"); - } else { - printf("custom IE configuration failed!\n"); - } - close(sockfd); - if (buffer) - free(buffer); - return UAP_FAILURE; - } - /* Print response */ - tlv = (tlvbuf_custom_ie *)buffer; - ie_len = tlv->length; - ie_ptr = (custom_ie *)(tlv->ie_data); - if (tlv->tag == MRVL_MGMT_IE_LIST_TLV_ID) { - while ((unsigned int)ie_len >= - sizeof(custom_ie)) { - printf("Index [%d]\n", - ie_ptr->ie_index); - if (ie_ptr->ie_length) - printf("Management Subtype Mask = 0x%02x\n", ie_ptr->mgmt_subtype_mask == 0 ? UAP_CUSTOM_IE_AUTO_MASK : ie_ptr->mgmt_subtype_mask); - else - printf("Management Subtype Mask = 0x%02x\n", ie_ptr->mgmt_subtype_mask); - hexdump_data("IE Buffer", - (void *)ie_ptr->ie_buffer, - (ie_ptr->ie_length), ' '); - ie_len -= - sizeof(custom_ie) + - ie_ptr->ie_length; - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) - + - ie_ptr-> - ie_length); - } - } - } - printf("Querying custom IE successful\n"); - } - - if (buffer) - free(buffer); - - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the dfstesting command - * - * $return N/A - */ -void -print_dfstesting_usage(void) -{ - printf("\nUsage : dfstesting [USER_CAC_PD USER_NOP_PD NO_CHAN_CHANGE FIXED_CHAN_NUM]\n"); - printf("\n empty - Get all dfstesting settings\n"); - printf("\n USER_CAC_PD: user configured Channel Availability Check period"); - printf("\n 0 - disable, use default (60000)"); - printf("\n 1-65535 - CAC period in msec"); - printf("\n USER_NOP_PD: user configured Non-Occupancy Period"); - printf("\n 0 - disable, use default (1800)"); - printf("\n 1-65535 - NOP period in sec"); - printf("\n NO_CHAN_CHANGE: user setting, don't change channel on radar"); - printf("\n 0 - disable, default behavior"); - printf("\n non-zero - enable, overrides below setting"); - printf("\n FIXED_CHAN_NUM: user fixed channel to change to on radar"); - printf("\n 0 - disable, use random channel [default]"); - printf("\n 1-255 - set fixed channel (not checked for validity)\n"); - return; -} - -/** - * @brief user configuration of dfs testing settings - * - * Usage: "dfstesting [USER_CAC_PD USER_NOP_PD NO_CHAN_CHANGE FIXED_CHAN_NUM]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_dfstesting(int argc, char *argv[]) -{ - int opt; - struct ifreq ifr; - t_s32 sockfd; - t_u32 val; - dfs_testing_para dfs_test; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_dfstesting_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - memset(&dfs_test, 0x00, sizeof(dfs_test)); - - /* Check arguments */ - if (argc == 0) { - dfs_test.action = ACTION_GET; - } else if (argc == 4) { - if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) || - (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) || - (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE) || - (IS_HEX_OR_DIGIT(argv[3]) == UAP_FAILURE)) { - printf("ERR: Only Number values are allowed\n"); - print_dfstesting_usage(); - return UAP_FAILURE; - } - - val = A2HEXDECIMAL(argv[0]); - if (val > 0xfffff) { - printf("ERR: invalid user_cac_pd value!\n"); - return UAP_FAILURE; - } - dfs_test.usr_cac_period = (t_u32)val; - - val = A2HEXDECIMAL(argv[1]); - if (val > 0xffff) { - printf("ERR: invalid user_nop_pd value!\n"); - return UAP_FAILURE; - } - dfs_test.usr_nop_period = (t_u16)val; - - val = A2HEXDECIMAL(argv[2]); - dfs_test.no_chan_change = (t_u8)(val ? 1 : 0); - - val = A2HEXDECIMAL(argv[3]); - if (val > 0xff) { - printf("ERR: invalid fixed_chan_num value!\n"); - return UAP_FAILURE; - } - dfs_test.fixed_new_chan = (t_u8)val; - dfs_test.action = ACTION_SET; - } else { - printf("ERR: invalid number of arguments! Must be 0 or 4.\n"); - print_dfstesting_usage(); - return UAP_FAILURE; - } - dfs_test.subcmd = UAP_DFS_TESTING; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&dfs_test; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: UAP_DFS_TESTING is not supported by %s\n", - dev_name); - close(sockfd); - return UAP_FAILURE; - } - - if (argc) - printf("DFS testing setting successful!\n"); - else - printf("DFS testing settings:\n" - " user_cac_period = %d msec\n" - " user_nop_period = %d sec\n" - " no_channel_change = %d\n" - " fixed_channel_num = %d\n", - dfs_test.usr_cac_period, dfs_test.usr_nop_period, - dfs_test.no_chan_change, dfs_test.fixed_new_chan); - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the cscount_cfg - * command - * - * $return N/A - */ -void -print_cscount_cfg_usage(void) -{ - printf("\nUsage : cscount []"); - printf("\n Where "); - printf("\n 5-20: No of beacons with Channel Switch Count IE\n"); - return; -} - -/** - * @brief Set/get cs_count configuration - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_cscount_cfg(int argc, char *argv[]) -{ - int opt; - cscount_cfg_t cscount_cfg; - struct ifreq ifr; - t_s32 sockfd; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_cscount_cfg_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - - memset(&cscount_cfg, 0, sizeof(cscount_cfg)); - if (argc == 0) { - cscount_cfg.action = ACTION_GET; - } else if (argc == 1) { - if ((t_u32)A2HEXDECIMAL(argv[0]) < 5 - && (t_u32)A2HEXDECIMAL(argv[0]) > 20) { - printf("ERR:Invalid Channel switch count value\n"); - return UAP_FAILURE; - } - cscount_cfg.action = ACTION_SET; - cscount_cfg.cs_count = (t_u32)A2HEXDECIMAL(argv[0]); - } else { - print_cscount_cfg_usage(); - return UAP_FAILURE; - } - cscount_cfg.subcmd = UAP_CHAN_SWITCH_COUNT_CFG; - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)&cscount_cfg; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: Channel switch count configuration failed\n"); - close(sockfd); - return UAP_FAILURE; - } - - /* Handle response */ - if (cscount_cfg.action == ACTION_GET) { - printf("Channel Switch count = %d\n", cscount_cfg.cs_count); - } - - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the mgmtframectrl command - * - * $return N/A - */ -void -print_mgmtframectrl_usage(void) -{ - printf("\nUsage : mgmtframectrl [MASK]\n"); - printf(" empty - Get management frame control mask\n"); - printf(" MASK - Set management frame control mask\n"); -} - -/** - * @brief Creates management frame control request and send to driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -apcmd_mgmt_frame_control(int argc, char *argv[]) -{ - int opt; - mgmt_frame_ctrl param; /* Action =0, Mask =0 */ - struct ifreq ifr; - t_s32 sockfd; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_mgmtframectrl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc > 1) { - printf("ERR:wrong arguments.\n"); - print_mgmtframectrl_usage(); - return UAP_FAILURE; - } - - if ((argc) && (IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE)) { - printf("ERR: Invalid argument %s\n", argv[0]); - print_mgmtframectrl_usage(); - return UAP_FAILURE; - } - - memset(¶m, 0, sizeof(mgmt_frame_ctrl)); - param.subcmd = UAP_MGMT_FRAME_CONTROL; - if (argc) { - param.action = ACTION_SET; - param.mask = (t_u16)A2HEXDECIMAL(argv[0]); - } else { - param.action = ACTION_GET; - } - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)¶m; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR:UAP_IOCTL_CMD failed\n"); - close(sockfd); - return UAP_FAILURE; - } - if (!argc) { - printf("Management Frame control mask = 0x%02x\n", - (int)param.mask); - } - /* Close socket */ - close(sockfd); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for the sys_cfg_pmf command - * command - * - * $return N/A - */ -void -print_sys_cfg_pmf(void) -{ - printf("\nUsage : uaputl.exe sys_cfg_pmf [MFPC] [MFPR]\n"); - printf("\nSet/Get PMF capabilities"); - printf("\n empty - Get PMF capabilites\n"); - printf("\n MFPC: Management frames protection capable"); - printf("\n 0 - Not capable"); - printf("\n 1 - capable"); - printf("\n MFPR: Management frames protection required"); - printf("\n don't care if MFPC is set to 0"); - printf("\n 0 - Not required"); - printf("\n 1 - required\n"); - return; -} - -int -apcmd_sys_cfg_pmf(int argc, char *argv[]) -{ - int opt; - apcmdbuf_pmf_params *cmd_buf = NULL; - t_u8 *buf = NULL; - t_u16 cmd_len = 0; - t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - int ret = UAP_SUCCESS; - t_u8 mfpc = 0; - t_u8 mfpr = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_sys_cfg_pmf(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc > 2)) { - printf("ERR:wrong arguments.\n"); - print_sys_cfg_pmf(); - return UAP_FAILURE; - } - - if (argc > 0) - mfpc = atoi(argv[0]); - - if (mfpc && (argc == 1)) { - printf("ERR:wrong arguments.\n"); - print_sys_cfg_pmf(); - return UAP_FAILURE; - } - - if (mfpc && (argc == 2)) - mfpr = atoi(argv[1]); - - /* Alloc buf for command */ - buf = (t_u8 *)malloc(buf_len); - - if (!buf) { - printf("ERR:Cannot allocate buffer from command!\n"); - return UAP_FAILURE; - } - memset(buf, 0, buf_len); - - /* Locate headers */ - cmd_len = sizeof(apcmdbuf_pmf_params); - cmd_buf = (apcmdbuf_pmf_params *) buf; - - /* Fill the command buffer */ - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->cmd_code = HostCmd_CMD_PMF_PARAMS; - if (argc == 0) - cmd_buf->action = ACTION_GET; - else - cmd_buf->action = ACTION_SET; - cmd_buf->action = uap_cpu_to_le16(cmd_buf->action); - cmd_buf->params.mfpc = mfpc; - cmd_buf->params.mfpr = mfpr; - - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len); - - /* Process response */ - if (ret == UAP_SUCCESS) { - if (cmd_buf->result == CMD_SUCCESS) { - printf("Successfully executed the command\n"); - printf("mfpc: %d, mfpr: %d\n", - cmd_buf->params.mfpc, cmd_buf->params.mfpr); - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - } else { - printf("ERR:Command sending failed!\n"); - free(buf); - return UAP_FAILURE; - } - free(buf); - return UAP_SUCCESS; -} - -/** - * @brief Show usage information for uap operation control command - * - * $return N/A - */ -void -print_uap_oper_ctrl_usage(void) -{ - printf("\nUsage : uap_oper_ctrl "); - printf("\n set/get uap operation when in-STA disconnected from ext-AP if multi channel is disabled"); - printf("\n control: 0: default, do nothing"); - printf("\n 2: uap stops and restart automatically"); - printf("\n chanopt : specify which channel should be used when uap restarts automatically"); - printf("\n 1: uap restarts on default 2.4G/channel 6"); - printf("\n 2: uap restart on band/channel configured by driver previously"); - printf("\n 3: uap restart on band/channel configured by parameter bandcfg/channel"); - printf("\n bandcfg : This parameter specifies the bandwidth (BW)"); - printf("\n 0: 20Mhz"); - printf("\n 2: 40Mhz"); - printf("\n 3: 80Mhz"); - printf("\n channel : This parameter specifies the channel will be used when chanopt is 3."); - return; -} - -/** - * @brief Set/Get uap operation when in-STA disconnected from ext-AP - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -apcmd_uap_oper_ctrl(int argc, char *argv[]) -{ - int opt; - uap_operation_ctrl param; - struct eth_priv_uap_oper_ctrl *uap_oper = NULL; - struct ifreq ifr; - t_s32 sockfd; - t_u8 *respbuf = NULL; - - memset(¶m, 0, sizeof(param)); - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_uap_oper_ctrl_usage(); - return UAP_SUCCESS; - } - } - argc -= optind; - argv += optind; - - respbuf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!respbuf) { - printf("ERR:Cannot allocate buffer for command!\n"); - return UAP_FAILURE; - } - memset(respbuf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - /* Check arguments */ - if (argc > 4) { - printf("ERR: Invalid number of arguments.\n"); - print_uap_oper_ctrl_usage(); - free(respbuf); - return UAP_FAILURE; - } - - if (argc > 0) { - param.uap_oper.ctrl = (t_u16)A2HEXDECIMAL(argv[0]); - if (param.uap_oper.ctrl == 2) - param.uap_oper.chan_opt = (t_u16)A2HEXDECIMAL(argv[1]); - - if (argc == 4 && param.uap_oper.chan_opt == 3) { - param.uap_oper.bandcfg = (t_u8)A2HEXDECIMAL(argv[2]); - param.uap_oper.channel = (t_u8)A2HEXDECIMAL(argv[3]); - } - param.action = ACTION_SET; - } else { - param.action = ACTION_GET; - } - param.subcmd = UAP_OPERATION_CTRL; - - memcpy(respbuf, ¶m, sizeof(uap_operation_ctrl)); - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - free(respbuf); - return UAP_FAILURE; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)respbuf; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - perror(""); - printf("ERR: uap operation control set/get failed\n"); - close(sockfd); - free(respbuf); - return UAP_FAILURE; - } - - /* Handle response */ - if (param.action == ACTION_GET) { - /* Process result */ - uap_oper = - (struct eth_priv_uap_oper_ctrl *)(respbuf + - 2 * sizeof(t_u32)); - printf(" uap operation control %x\n", uap_oper->ctrl); - printf(" uap channel operation %x\n", uap_oper->chan_opt); - if (uap_oper->chan_opt == 3) { - printf(" uap bandwidth %s\n", - uap_oper-> - bandcfg ? ((uap_oper->bandcfg == 2) ? "40Mhz" : - "80Mhz") : "20Mhz"); - printf(" uap channel %d\n", uap_oper->channel); - } - } else - printf("uap operation control set success!\n"); - /* Close socket */ - close(sockfd); - if (respbuf) - free(respbuf); - return UAP_SUCCESS; -} - -/** Structure of command table*/ -typedef struct { - /** Command name */ - char *cmd; - /** Command function pointer */ - int (*func) (int argc, char *argv[]); - /** Command usuage */ - char *help; -} command_table; - -/** AP command table */ -static command_table ap_command[] = { - {"sys_config", apcmd_sys_config, "\tSet/get uAP's profile"}, - {"sys_info", apcmd_sys_info, "\tDisplay system info"}, - {"sys_reset", apcmd_sys_reset, "\tReset uAP"}, - {"bss_start", apcmd_bss_start, "\tStart the BSS"}, - {"bss_stop", apcmd_bss_stop, "\tStop the BSS"}, - {"skip_cac", apcmd_skip_cac, "\tSkip the CAC"}, - {"sta_deauth", apcmd_sta_deauth, "\tDeauth client"}, - {"sta_list", apcmd_sta_list, "\tDisplay list of clients"}, - {"sys_cfg_ap_mac_address", apcmd_sys_cfg_ap_mac_address, - "Set/get uAP mac address"}, - {"sys_cfg_ssid", apcmd_sys_cfg_ssid, "\tSet/get uAP ssid"}, - {"sys_cfg_beacon_period", apcmd_sys_cfg_beacon_period, - "Set/get uAP beacon period"}, - {"sys_cfg_dtim_period", apcmd_sys_cfg_dtim_period, - "Set/get uAP dtim period"}, - {"sys_cfg_bss_status", apcmd_sys_cfg_bss_status, "Get BSS status"}, - {"sys_cfg_channel", apcmd_sys_cfg_channel, - "\tSet/get uAP radio channel"}, - {"sys_cfg_channel_ext", apcmd_sys_cfg_channel_ext, - "\tSet/get uAP radio channel, band and mode"}, - {"sys_cfg_scan_channels", apcmd_sys_cfg_scan_channels, - "Set/get uAP radio channel list"}, - {"sys_cfg_rates", apcmd_sys_cfg_rates, "\tSet/get uAP rates"}, - {"sys_cfg_rates_ext", apcmd_sys_cfg_rates_ext, "\tSet/get uAP rates"}, - {"sys_cfg_tx_power", apcmd_sys_cfg_tx_power, "Set/get uAP tx power"}, - {"sys_cfg_bcast_ssid_ctl", apcmd_sys_cfg_bcast_ssid_ctl, - "Set/get uAP broadcast ssid"}, - {"sys_cfg_preamble_ctl", apcmd_sys_cfg_preamble_ctl, - "Get uAP preamble"}, - {"antcfg", apcmd_antcfg, "Set/get uAP tx/rx antenna"}, - {"htstreamcfg", apcmd_htstreamcfg, - "Set/get uAP HT stream configurations"}, - {"sys_cfg_rts_threshold", apcmd_sys_cfg_rts_threshold, - "Set/get uAP rts threshold"}, - {"sys_cfg_frag_threshold", apcmd_sys_cfg_frag_threshold, - "Set/get uAP frag threshold"}, - {"radioctrl", apcmd_radio_ctl, "Set/get uAP radio on/off"}, - {"sys_cfg_tx_beacon_rate", apcmd_sys_cfg_tx_beacon_rate, - "Set/get uAP tx beacon rate"}, - {"txratecfg", apcmd_tx_rate_cfg, "Set/get trasnmit data rate"}, - {"sys_cfg_mcbc_data_rate", apcmd_sys_cfg_mcbc_data_rate, - "Set/get uAP MCBC rate"}, - {"sys_cfg_rsn_replay_prot", apcmd_sys_cfg_rsn_replay_prot, - "Set/get RSN replay protection"}, - {"sys_cfg_pkt_fwd_ctl", apcmd_sys_cfg_pkt_fwd_ctl, - "Set/get uAP packet forwarding"}, - {"sys_cfg_sta_ageout_timer", apcmd_sys_cfg_sta_ageout_timer, - "Set/get station ageout timer"}, - {"sys_cfg_ps_sta_ageout_timer", apcmd_sys_cfg_ps_sta_ageout_timer, - "Set/get PS station ageout timer"}, - {"sys_cfg_auth", apcmd_sys_cfg_auth, - "\tSet/get uAP authentication mode"}, - {"sys_cfg_protocol", apcmd_sys_cfg_protocol, - "Set/get uAP security protocol"}, - {"sys_cfg_wep_key", apcmd_sys_cfg_wep_key, "\tSet/get uAP wep key"}, - {"sys_cfg_cipher", apcmd_sys_cfg_cipher, - "\tSet/get uAP WPA/WPA2 cipher"}, - {"sys_cfg_pwk_cipher", apcmd_sys_cfg_pwk_cipher, - "\tSet/get uAP WPA/WPA2 pairwise cipher"}, - {"sys_cfg_gwk_cipher", apcmd_sys_cfg_gwk_cipher, - "\tSet/get uAP WPA/WPA2 group cipher"}, - {"sys_cfg_wpa_passphrase", apcmd_sys_cfg_wpa_passphrase, - "Set/get uAP WPA or WPA2 passphrase"}, - {"sys_cfg_wpa3_sae_password", apcmd_sys_cfg_wpa3_sae_password, - "Set/get uAP WPA3 SAE password"}, - {"sys_cfg_group_rekey_timer", apcmd_sys_cfg_group_rekey_timer, - "Set/get uAP group re-key time"}, - {"sys_cfg_max_sta_num", apcmd_sys_cfg_max_sta_num, - "Set/get uAP max station number"}, - {"sys_cfg_retry_limit", apcmd_sys_cfg_retry_limit, - "Set/get uAP retry limit number"}, - {"sys_cfg_sticky_tim_config", apcmd_sys_cfg_sticky_tim_config, - "Set/get uAP sticky TIM configuration"}, - {"sys_cfg_sticky_tim_sta_mac_addr", - apcmd_sys_cfg_sticky_tim_sta_mac_addr, - "Set/get uAP sticky TIM sta MAC address"}, - {"sys_cfg_eapol_pwk_hsk", apcmd_sys_cfg_eapol_pwk_hsk, - "Set/getuAP pairwise Handshake timeout value and retries"}, - {"sys_cfg_eapol_gwk_hsk", apcmd_sys_cfg_eapol_gwk_hsk, - "Set/getuAP groupwise Handshake timeout value and retries"}, - {"sys_cfg_custom_ie", apcmd_sys_cfg_custom_ie, - "\tSet/get custom IE configuration"}, - {"sta_filter_table", apcmd_sta_filter_table, "Set/get uAP mac filter"}, - {"regrdwr", apcmd_regrdwr, "\t\tRead/Write register command"}, - {"memaccess", apcmd_memaccess, - "\tRead/Write to a memory address command"}, - {"rdeeprom", apcmd_read_eeprom, "\tRead EEPROM "}, - {"cfg_data", apcmd_cfg_data, - "\tGet/Set configuration file from/to firmware"}, - {"sys_cfg_80211d", apcmd_cfg_80211d, "\tSet/Get 802.11D info"}, - {"uap_stats", apcmd_uap_stats, "\tGet uAP stats"}, - {"pscfg", apcmd_pscfg, "\t\tSet/get uAP power mode"}, - {"bss_config", apcmd_bss_config, "\tSet/get BSS configuration"}, - {"sta_deauth_ext", apcmd_sta_deauth_ext, "\tDeauth client"}, - {"mic_err", apcmd_mic_err, "\t\tReport station mic error"}, - {"key_material", apcmd_set_key, "\tSet key"}, - {"coex_config", apcmd_coex_config, - "\tSet/get uAP BT coex configuration"}, - {"hscfg", apcmd_hscfg, "\t\tSet/get uAP host sleep parameters."}, - {"hssetpara", apcmd_hssetpara, - "\t\tSet/get uAP host sleep parameters."}, - {"addbapara", apcmd_addbapara, "\tSet/get uAP ADDBA parameters."}, - {"aggrpriotbl", apcmd_aggrpriotbl, - "\tSet/get uAP priority table for AMPDU/AMSDU."}, - {"addbareject", apcmd_addbareject, "\tSet/get uAP addbareject table."}, - {"sys_cfg_11n", apcmd_sys_cfg_11n, "\tSet/get uAP 802.11n parameters."}, -#ifdef RX_PACKET_COALESCE - {"rxpktcoal_cfg", apcmd_rx_pkt_coalesce, - "\tSet/get RX Packet coalesing paramterts."}, -#endif - {"httxbfcfg", apcmd_sys_cfg_tx_bf, "\tSet/get uAP TX BF parameters."}, - {"httxcfg", apcmd_sys_cfg_ht_tx, "\t\tSet/get uAP HT Tx parameters."}, - {"vhtcfg", apcmd_sys_cfg_vht, "\t\tSet/get uAP VHT parameters."}, - {"sys_cfg_wmm", apcmd_sys_cfg_wmm, - "\tSet/get uAP beacon wmm parameters."}, - {"sys_cfg_ap_wmm", apcmd_sys_cfg_ap_wmm, - "\tSet/get uAP hardware wmm parameters."}, - {"deepsleep", apcmd_deepsleep, "\tSet/get deepsleep mode."}, - {"hostcmd", apcmd_hostcmd, "\t\tSet/get hostcmd"}, - {"tx_data_pause", apcmd_txdatapause, - "\tSet/get Tx data pause settings."}, -#ifdef SDIO - {"sdcmd52rw", apcmd_cmd52_readwrite, - "\tRead or write using sdio command 52."}, -#endif - {"sys_cfg_2040_coex", apcmd_sys_cfg_2040_coex, - "\tSet/get 20/40 coex settings."}, - {"dfstesting", apcmd_dfstesting, "\tConfigure DFS Testing settings."}, - {"cscount", apcmd_cscount_cfg, "\tConfigure DFS Channel Switch Count."}, - {"mgmtframectrl", apcmd_mgmt_frame_control, - "\tSpecifies mask indicating management frames to be sent from host."}, - {"sys_cfg_restrict_client_mode", apcmd_sys_cfg_restrict_client_mode, - "\tSet/get the mode in which client stations can connect to the uAP."}, - {"sys_cfg_pmf", apcmd_sys_cfg_pmf, "\tSet/get PMF capabilities."}, - {"uap_oper_ctrl", apcmd_uap_oper_ctrl, - "\tSet/get uap operation control value."}, - {"band_steering_cfg", apcmd_band_steering, - "\tConfigure Band Steering."}, - {NULL, NULL, 0} -}; - -/** - * @brief Prints usage information of uaputl - * - * @return N/A - */ -static void -print_tool_usage(void) -{ - int i; - printf("uaputl.exe - uAP utility ver %s\n", UAP_VERSION); - printf("Usage:\n" - "\tuaputl.exe [options] [command parameters]\n"); - printf("Options:\n" - "\t--help\tDisplay help\n" - "\t-v\tDisplay version\n" - "\t-i \n" "\t-d \n"); - printf("Commands:\n"); - for (i = 0; ap_command[i].cmd; i++) - printf("\t%-4s\t\t%s\n", ap_command[i].cmd, ap_command[i].help); - printf("\n" - "For more information on the usage of each command use:\n" - "\tuaputl.exe --help\n"); -} - -/**************************************************************************** - Global functions -****************************************************************************/ -/** Option parameter*/ -static struct option ap_options[] = { - {"help", 0, NULL, 'h'}, - {"interface", 1, NULL, 'i'}, - {"debug", 1, NULL, 'd'}, - {"version", 0, NULL, 'v'}, - {NULL, 0, NULL, '\0'} -}; - -/** - * @brief Checks if given channel in 'a' band is valid or not. - * - * @param channel Channel number - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_valid_a_band_channel(int channel) -{ - int ret = UAP_SUCCESS; - switch (channel) { - case 16: - case 34: - case 36: - case 38: - case 40: - case 42: - case 44: - case 46: - case 48: - case 52: - case 56: - case 60: - case 64: - case 100: - case 104: - case 108: - case 112: - case 116: - case 120: - case 124: - case 128: - case 132: - case 136: - case 140: - case 144: - case 149: - case 153: - case 157: - case 161: - case 165: - break; - default: - ret = UAP_FAILURE; - break; - } - return ret; -} - -/** - * @brief Checks if secondary channel can be set above given primary channel in 'a' band or not. - * - * @param channel Channel number - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_valid_a_band_channel_above(int channel) -{ - int ret = UAP_SUCCESS; - switch (channel) { - case 36: - case 44: - case 52: - case 60: - case 100: - case 108: - case 116: - case 124: - case 132: - case 140: - case 149: - case 157: - break; - default: - ret = UAP_FAILURE; - break; - } - return ret; -} - -/** - * @brief Checks if secondary channel can be set below given primary channel in 'a' band or not. - * - * @param channel Channel number - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_valid_a_band_channel_below(int channel) -{ - int ret = UAP_SUCCESS; - switch (channel) { - case 40: - case 48: - case 56: - case 64: - case 104: - case 112: - case 120: - case 128: - case 136: - case 153: - case 161: - break; - default: - ret = UAP_FAILURE; - break; - } - return ret; -} - -/** - * @brief Checkes a particular input for validatation. - * - * @param cmd Type of input - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_input_valid(valid_inputs cmd, int argc, char *argv[]) -{ - int i; - int chan_number = 0; - int band = 0; - int ch; - int ret = UAP_SUCCESS; - if (argc == 0) - return UAP_FAILURE; - switch (cmd) { - case RDEEPROM: - if (argc != 2) { - printf(" ERR: Argument count mismatch\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0) - || (A2HEXDECIMAL(argv[0]) & 0x03) || - ((int)(A2HEXDECIMAL(argv[0])) < 0) || - (A2HEXDECIMAL(argv[1]) & 0x03) || - (A2HEXDECIMAL(argv[1]) < 4) || - (A2HEXDECIMAL(argv[1]) > 20)) { - printf(" ERR: Invalid inputs for Read EEPROM\n"); - ret = UAP_FAILURE; - } - } - break; - case SCANCHANNELS: - if (argc > MAX_CHANNELS) { - printf("ERR: Invalid List of Channels\n"); - ret = UAP_FAILURE; - } else { - for (i = 0; i < argc; i++) { - chan_number = -1; - band = -1; - sscanf(argv[i], "%d.%d", &chan_number, &band); - if ((chan_number == -1) || (chan_number < 1) || - (chan_number > MAX_CHANNELS)) { - printf("ERR: Channel must be in the range of 1 to %d\n", MAX_CHANNELS); - ret = UAP_FAILURE; - break; - } - if ((chan_number > MAX_CHANNELS_BG) && - !(is_valid_a_band_channel(chan_number))) { - printf("ERR: Invalid Channel in 'a' band!\n"); - ret = UAP_FAILURE; - break; - } - if ((band < -1) || (band > 1)) { - printf("ERR:Band must be either 0 or 1\n"); - ret = UAP_FAILURE; - break; - } else { - if (((chan_number < MAX_CHANNELS_BG) && - (chan_number != 8) && - (chan_number != 12) && (band == 1)) - || ((chan_number > MAX_CHANNELS_BG) - && (band == 0))) { - printf("ERR:Invalid band for given channel\n"); - ret = UAP_FAILURE; - break; - } - } - } - if ((ret != UAP_FAILURE) && - (has_dup_channel(argc, argv) != UAP_SUCCESS)) { - printf("ERR: Duplicate channel values entered\n"); - ret = UAP_FAILURE; - } - if ((ret != UAP_FAILURE) && - (has_diff_band(argc, argv) != UAP_SUCCESS)) { - printf("ERR: Scan channel list should contain channels from only one band\n"); - ret = UAP_FAILURE; - } - } - break; - case TXPOWER: - if ((argc > 1) || (ISDIGIT(argv[0]) == 0)) { - printf("ERR:Invalid Transmit power\n"); - ret = UAP_FAILURE; - } else { - if ((atoi(argv[0]) < MIN_TX_POWER) || - (atoi(argv[0]) > MAX_TX_POWER)) { - printf("ERR: TX Powar must be in the rage of %d to %d. \n", MIN_TX_POWER, MAX_TX_POWER); - ret = UAP_FAILURE; - } - } - break; - case PROTOCOL: - if ((argc > 2) || (ISDIGIT(argv[0]) == 0)) { - printf("ERR:Invalid Protocol\n"); - ret = UAP_FAILURE; - } else - ret = is_protocol_valid(atoi(argv[0])); - break; - case AKM_SUITE: - if (argc == 2) { - if (A2HEXDECIMAL(argv[1]) & - ~(KEY_MGMT_PSK | KEY_MGMT_PSK_SHA256 | KEY_MGMT_EAP - | KEY_MGMT_NONE | KEY_MGMT_SAE)) { - printf("ERR: Invalid AKM suite\n"); - ret = UAP_FAILURE; - } - } - break; - case CHANNEL: - if ((argc != 1) && (argc != 2)) { - printf("ERR: Incorrect arguments for channel.\n"); - ret = UAP_FAILURE; - } else { - if (argc == 2) { - if ((ISDIGIT(argv[1]) == 0) || - (atoi(argv[1]) & ~CHANNEL_MODE_MASK)) { - printf("ERR: Invalid Mode\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[1]) & BITMAP_ACS_MODE) && - (atoi(argv[0]) != 0)) { - printf("ERR: Channel must be 0 for ACS; MODE = 1.\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[1]) & BITMAP_CHANNEL_ABOVE) && - (atoi(argv[1]) & BITMAP_CHANNEL_BELOW)) { - printf("ERR: secondary channel above and below both are enabled\n"); - ret = UAP_FAILURE; - } - } - if ((argc == 1) || (!(atoi(argv[1]) & BITMAP_ACS_MODE))) { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) < 1) || - (atoi(argv[0]) > MAX_CHANNELS)) { - printf("ERR: Channel must be in the range of 1 to %d\n", MAX_CHANNELS); - ret = UAP_FAILURE; - } - if ((atoi(argv[0]) > MAX_CHANNELS_BG) && - !(is_valid_a_band_channel(atoi(argv[0])))) { - printf("ERR: Invalid Channel in 'a' band!\n"); - ret = UAP_FAILURE; - } - ch = atoi(argv[0]); - if (ch <= MAX_CHANNELS_BG) { - if ((argc == 2) && - (atoi(argv[1]) & - BITMAP_CHANNEL_ABOVE) && - (atoi(argv[0]) > - MAX_CHANNEL_ABOVE)) { - printf("ERR: only allow channel 1-9 for secondary channel above\n"); - ret = UAP_FAILURE; - } - if ((argc == 2) && - (atoi(argv[1]) & - BITMAP_CHANNEL_BELOW) && - ((atoi(argv[0]) < MIN_CHANNEL_BELOW) - || (atoi(argv[0]) == 14))) { - printf("ERR: only allow channel 5-13 for secondary channel below\n"); - ret = UAP_FAILURE; - } - } else { - if (argc == 2) { - if ((atoi(argv[1]) & - BITMAP_CHANNEL_BELOW) && - !is_valid_a_band_channel_below - (atoi(argv[0]))) { - printf("ERR: For given primary channel secondary channel can not be set below\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[1]) & - BITMAP_CHANNEL_ABOVE) && - !is_valid_a_band_channel_above - (atoi(argv[0]))) { - printf("ERR: For given primary channel secondary channel can not be set above\n"); - ret = UAP_FAILURE; - } - } - } - } - } - break; - case CHANNEL_EXT: - if (argc > 3) { - printf("ERR: Incorrect arguments for channel_ext.\n"); - ret = UAP_FAILURE; - } else { - if (argc == 3) { - if ((ISDIGIT(argv[2]) == 0) || - (atoi(argv[2]) & ~CHANNEL_MODE_MASK)) { - printf("ERR: Invalid Mode\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[2]) & BITMAP_ACS_MODE) && - (atoi(argv[0]) != 0)) { - printf("ERR: Channel must be 0 for ACS; MODE = 1.\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[2]) & BITMAP_CHANNEL_ABOVE) && - (atoi(argv[2]) & BITMAP_CHANNEL_BELOW)) { - printf("ERR: secondary channel above and below both are enabled\n"); - ret = UAP_FAILURE; - } - } - if ((argc == 2) && - ((ISDIGIT(argv[1]) == 0) || (atoi(argv[1]) < 0) || - atoi(argv[1]) > 1)) { - printf("ERR:Invalid band\n"); - ret = UAP_FAILURE; - } - if ((argc == 1) || - ((argc == 3) && - !(atoi(argv[2]) & BITMAP_ACS_MODE))) { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) < 1) || - (atoi(argv[0]) > MAX_CHANNELS)) { - printf("ERR: Channel must be in the range of 1 to %d\n", MAX_CHANNELS); - ret = UAP_FAILURE; - } - if ((atoi(argv[0]) > MAX_CHANNELS_BG) && - !(is_valid_a_band_channel(atoi(argv[0])))) { - printf("ERR: Invalid Channel in 'a' band!\n"); - ret = UAP_FAILURE; - } - ch = atoi(argv[0]); - if (ch <= MAX_CHANNELS_BG) { - if ((argc == 3) && - (atoi(argv[2]) & - BITMAP_CHANNEL_ABOVE) && - (atoi(argv[0]) > - MAX_CHANNEL_ABOVE)) { - printf("ERR: only allow channel 1-9 for secondary channel above\n"); - ret = UAP_FAILURE; - } - if ((argc == 3) && - (atoi(argv[2]) & - BITMAP_CHANNEL_BELOW) && - ((atoi(argv[0]) < MIN_CHANNEL_BELOW) - || (atoi(argv[0]) == 14))) { - printf("ERR: only allow channel 5-13 for secondary channel below\n"); - ret = UAP_FAILURE; - } - } else { - if (argc == 3) { - if ((atoi(argv[2]) & - BITMAP_CHANNEL_BELOW) && - !is_valid_a_band_channel_below - (atoi(argv[0]))) { - printf("ERR: For given primary channel secondary channel can not be set below\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[2]) & - BITMAP_CHANNEL_ABOVE) && - !is_valid_a_band_channel_above - (atoi(argv[0]))) { - printf("ERR: For given primary channel secondary channel can not be set above\n"); - ret = UAP_FAILURE; - } - } - } - } - } - break; - case BAND: - if (argc > 1) { - printf("ERR: Incorrect number of BAND arguments.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR: Invalid band.\n"); - ret = UAP_FAILURE; - } - } - break; - case RATE: - if (argc > MAX_RATES) { - printf("ERR: Incorrect number of RATES arguments.\n"); - ret = UAP_FAILURE; - } else { - for (i = 0; i < argc; i++) { - if ((IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) || - (is_rate_valid - (A2HEXDECIMAL(argv[i]) & - ~BASIC_RATE_SET_BIT) - != UAP_SUCCESS)) { - printf("ERR:Unsupported rate.\n"); - ret = UAP_FAILURE; - break; - } - } - if ((ret != UAP_FAILURE) && - (has_dup_rate(argc, argv) != UAP_SUCCESS)) { - printf("ERR: Duplicate rate values entered\n"); - ret = UAP_FAILURE; - } - if (check_mandatory_rates(argc, argv) != UAP_SUCCESS) { - ret = UAP_FAILURE; - } - } - break; - case BROADCASTSSID: - if (argc != 1) { - printf("ERR:wrong BROADCASTSSID arguments.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - ((atoi(argv[0]) != 0) && (atoi(argv[0]) != 1) && - (atoi(argv[0]) != 2))) { - printf("ERR:Illegal parameter %s for BROADCASTSSID. Must be either '0', '1' or '2'.\n", argv[0]); - ret = UAP_FAILURE; - } - } - break; - case RTSTHRESH: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for RTSTHRESHOLD\n"); - ret = UAP_FAILURE; - } else if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > MAX_RTS_THRESHOLD)) { - printf("ERR:Illegal RTSTHRESHOLD %s. The value must between 0 and %d\n", argv[0], MAX_RTS_THRESHOLD); - ret = UAP_FAILURE; - } - break; - case FRAGTHRESH: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for FRAGTHRESH\n"); - ret = UAP_FAILURE; - } else if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) < MIN_FRAG_THRESHOLD) || - (atoi(argv[0]) > MAX_FRAG_THRESHOLD)) { - printf("ERR:Illegal FRAGTHRESH %s. The value must between %d and %d\n", argv[0], MIN_FRAG_THRESHOLD, MAX_FRAG_THRESHOLD); - ret = UAP_FAILURE; - } - break; - case DTIMPERIOD: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DTIMPERIOD\n"); - ret = UAP_FAILURE; - } else if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 1) || - (atoi(argv[0]) > MAX_DTIM_PERIOD)) { - printf("ERR: DTIMPERIOD Value must be in range of 1 to %d\n", MAX_DTIM_PERIOD); - ret = UAP_FAILURE; - } - break; - case RSNREPLAYPROT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for RSNREPLAYPROT\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR:Illegal RSNREPLAYPROT parameter %s. Must be either '0' or '1'.\n", argv[0]); - ret = UAP_FAILURE; - } - } - break; - case RADIOCONTROL: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for RADIOCONTROL\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR:Illegal RADIOCONTROL parameter %s. Must be either '0' or '1'.\n", argv[0]); - ret = UAP_FAILURE; - } - } - break; - case TXRATECFG: - if (argc > 3) { - printf("ERR:Incorrect number of arguments for DATARATE\n"); - ret = UAP_FAILURE; - } else { - if (((argc >= 1) && - (IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE)) || - ((argc >= 2) && - (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE)) - || ((argc >= 3) && - (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE)) - ) { - printf("ERR: invalid Tx data rate\n"); - ret = UAP_FAILURE; - } else if (argc >= 1) { - if (A2HEXDECIMAL(argv[0]) == 0xFF) { - if (argc != 1) { - printf("ERR: invalid auto rate input\n"); - ret = UAP_FAILURE; - } - } else { - if ((A2HEXDECIMAL(argv[0]) > 3) - ) { - printf("ERR: invalid format\n"); - ret = UAP_FAILURE; - } - if (argc >= 2) { - if (((A2HEXDECIMAL(argv[0]) == - 0) && - (A2HEXDECIMAL(argv[1]) > - 11)) || - ((A2HEXDECIMAL(argv[0]) == - 1) && - (A2HEXDECIMAL(argv[1]) != - 32) && - (A2HEXDECIMAL(argv[1]) > - 15) - )) { - printf("ERR:Incorrect TxRate %s.\n", argv[1]); - ret = UAP_FAILURE; - } - } - if (argc == 3) { - if (((A2HEXDECIMAL(argv[0]) != - 2) && - (A2HEXDECIMAL(argv[0]) != - 3)) || - ((A2HEXDECIMAL(argv[2]) < 1) - || (A2HEXDECIMAL(argv[2]) > - 2))) { - printf("ERR:Incorrect nss.\n"); - ret = UAP_FAILURE; - } - } - } - } - } - break; - case MCBCDATARATE: - case TXBEACONRATE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DATARATE\n"); - ret = UAP_FAILURE; - } else { - if (IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) { - printf("ERR: invalid data rate\n"); - ret = UAP_FAILURE; - } else if ((A2HEXDECIMAL(argv[0]) != 0) && - (is_rate_valid - (A2HEXDECIMAL(argv[0]) & - ~BASIC_RATE_SET_BIT) != UAP_SUCCESS)) { - printf("ERR: invalid data rate\n"); - ret = UAP_FAILURE; - } - } - break; - case PKTFWD: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for PKTFWD.\n"); - ret = UAP_FAILURE; - } else if ((ISDIGIT(argv[0]) == 0) || - ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 15))) { - printf("ERR:Illegal PKTFWD parameter %s. Must be within '0' and '15'.\n", argv[0]); - ret = UAP_FAILURE; - } - break; - case STAAGEOUTTIMER: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for STAAGEOUTTIMER.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 0) && - ((atoi(argv[0]) < - MIN_STAGE_OUT_TIME) || - (atoi(argv[0]) > - MAX_STAGE_OUT_TIME)))) - { - printf("ERR:Illegal STAAGEOUTTIMER %s. Must be between %d and %d.\n", argv[0], MIN_STAGE_OUT_TIME, MAX_STAGE_OUT_TIME); - ret = UAP_FAILURE; - } - } - break; - case PSSTAAGEOUTTIMER: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for PSSTAAGEOUTTIMER.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 0) && - ((atoi(argv[0]) < - MIN_STAGE_OUT_TIME) || - (atoi(argv[0]) > - MAX_STAGE_OUT_TIME)))) - { - printf("ERR:Illegal PSSTAAGEOUTTIMER %s. Must be between %d and %d.\n", argv[0], MIN_STAGE_OUT_TIME, MAX_STAGE_OUT_TIME); - ret = UAP_FAILURE; - } - } - break; - case AUTHMODE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for AUTHMODE\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 0) && - (atoi(argv[0]) != 1) - && (atoi(argv[0]) != 3) - && (atoi(argv[0]) != - 255))) { - printf("ERR:Illegal AUTHMODE parameter %s. Must be either '0','1','3' or 255''.\n", argv[0]); - ret = UAP_FAILURE; - } - } - break; - case GROUPREKEYTIMER: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for GROUPREKEYTIMER.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > MAX_GRP_TIMER)) { - printf("ERR: GROUPREKEYTIMER range is [0:%d] (0 for disable)\n", MAX_GRP_TIMER); - ret = UAP_FAILURE; - } - } - break; - case MAXSTANUM: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for MAXSTANUM\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) <= 0)) { - printf("ERR:Invalid STA_NUM argument %s.\n", - argv[0]); - ret = UAP_FAILURE; - } - } - break; - case BEACONPERIOD: - if (argc != 1) { - printf("ERR:Incorrect number of argument for BEACONPERIOD.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) < MIN_BEACON_PERIOD) - || (atoi(argv[0]) > MAX_BEACON_PERIOD)) { - printf("ERR: BEACONPERIOD must be in range of %d to %d.\n", MIN_BEACON_PERIOD, MAX_BEACON_PERIOD); - ret = UAP_FAILURE; - } - } - break; - case RETRYLIMIT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for RETRY LIMIT\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_RETRY_LIMIT) || - (atoi(argv[0]) < 0)) { - printf("ERR:RETRY_LIMIT must be in the range of [0:%d]. The input was %s.\n", MAX_RETRY_LIMIT, argv[0]); - ret = UAP_FAILURE; - } - } - break; - case STICKYTIMCONFIG: - if ((argc != 1) && (argc != 3)) { - printf("ERR:Incorrect number of arguments for STICKY_TIM_CONFIG\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 2)) { - printf("ERR:Enable parameter must be 0, 1 or 2\n"); - ret = UAP_FAILURE; - break; - } - if (((atoi(argv[0]) != 1) && (argc > 1))) { - printf("ERR: Invalid arguments\n"); - ret = UAP_FAILURE; - break; - } - if ((atoi(argv[0]) == 1) && (argc != 3)) { - printf("ERR: Both duration and sticky bit mask must be provided for ENABLE = 1\n"); - ret = UAP_FAILURE; - break; - } - if (argc > 1) { - if ((ISDIGIT(argv[1]) == 0)) { - printf("ERR: Invalid duration\n"); - ret = UAP_FAILURE; - break; - } - if ((ISDIGIT(argv[2]) == 0) || - (atoi(argv[2]) < 1) || - (atoi(argv[2]) > 3)) { - printf("ERR:Invalid sticky bit mask\n"); - ret = UAP_FAILURE; - break; - } - } - } - break; - case STICKYTIMSTAMACADDR: - if ((argc != 1) && (argc != 2)) { - printf("ERR:Incorrect number of STICKY_TIM_STA_MAC_ADDR arguments\n"); - ret = UAP_FAILURE; - } else { - if ((argc == 2) && - ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1))) { - printf("ERR:Invalid control parameter\n"); - ret = UAP_FAILURE; - break; - } - } - break; - case COEX2040CONFIG: - if (argc != 1) { - printf("ERR: Incorrect number of 2040 COEX CONFIG arguments\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR:Invalid enable parameter\n"); - ret = UAP_FAILURE; - break; - } - } - break; - case EAPOL_PWK_HSK: - if (argc != 2) { - printf("ERR:Incorrect number of EAPOL_PWK_HSK arguments.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0) - || (atoi(argv[0]) < 0) || (atoi(argv[1]) < 0)) { - printf("ERR:Illegal parameters for EAPOL_PWK_HSK. Must be digits greater than equal to zero.\n"); - } - } - break; - case EAPOL_GWK_HSK: - if (argc != 2) { - printf("ERR:Incorrect number of EAPOL_GWK_HSK arguments.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0) - || (atoi(argv[0]) < 0) || (atoi(argv[1]) < 0)) { - printf("ERR:Illegal parameters for EAPOL_GWK_HSK. Must be digits greater than equal to zero.\n"); - } - } - break; - case PREAMBLETYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for PREAMBLE TYPE\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_PREAMBLE_TYPE) || - (atoi(argv[0]) < 0)) { - printf("ERR:PREAMBLE TYPE must be in the range of [0:%d]. The input was %s.\n", MAX_PREAMBLE_TYPE, argv[0]); - ret = UAP_FAILURE; - } - } - break; - - case COEX_COMM_BITMAP: - if (argc != 1) { - printf("ERR:Incorrect number of argument for Bitmap.\n"); - ret = UAP_FAILURE; - } else { - /* Only bit 0 is supported now, hence check for 1 or 0 */ - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - (atoi(argv[0]) < 0) || (atoi(argv[0]) > 1)) { - printf("ERR: Bitmap must have value of 1 or 0.\n"); - ret = UAP_FAILURE; - } - } - break; - case COEX_COMM_AP_COEX: - if (argc != 1) { - printf("ERR:Incorrect number of argument for APBTCoex.\n"); - ret = UAP_FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - (atoi(argv[0]) < 0) || (atoi(argv[0]) > 1)) { - printf("ERR: APBTCoex must have value of 1 or 0.\n"); - ret = UAP_FAILURE; - } - } - break; - case COEX_SCO_ACL_FREQ: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for aclFrequency.\n"); - ret = UAP_FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR: Incorrect value for aclFrequency.\n"); - ret = UAP_FAILURE; - } - } - break; - case COEX_ACL_ENABLED: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for (acl) enabled.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR: (acl) enabled must have value of 1 or 0.\n"); - ret = UAP_FAILURE; - } - } - break; - case COEX_ACL_BT_TIME: - case COEX_ACL_WLAN_TIME: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for bt/wlan time.\n"); - ret = UAP_FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR: Incorrect value for bt/wlan time.\n"); - ret = UAP_FAILURE; - } - } - break; - case COEX_PROTECTION: - if (argc != 2) { - printf("ERR:Incorrect number of arguments for %s.\n", - argv[0]); - ret = UAP_FAILURE; - } else { - if (ISDIGIT(argv[1]) == 0) { - printf("ERR: Incorrect value for %s.\n", - argv[0]); - ret = UAP_FAILURE; - } - } - break; - case PWK_CIPHER: - if ((argc != 1) && (argc != 2)) { - printf("ERR:Incorrect number of arguments for pwk_cipher.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) & ~PROTOCOL_BITMAP)) { - printf("Invalid Protocol paramter.\n"); - ret = UAP_FAILURE; - } - if (argc == 2) { - if ((ISDIGIT(argv[1]) == 0) || - (atoi(argv[1]) & ~CIPHER_BITMAP)) { - printf("Invalid pairwise cipher.\n"); - ret = UAP_FAILURE; - } - } - } - break; - case GWK_CIPHER: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for gwk_cipher.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) & ~CIPHER_BITMAP) || - (atoi(argv[0]) == AES_CCMP_TKIP)) { - printf("Invalid group cipher.\n"); - ret = UAP_FAILURE; - } - } - break; - case RESTRICT_CLIENT_MODE: - if ((argc != 1) && (argc != 2)) { - printf("ERR: Incorrect number of arguments.\n"); - ret = UAP_FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((argc == 2) && - ((IS_HEX_OR_DIGIT - (argv[1]) == 0) || - ((atoi(argv[0]) < 0) || - (atoi(argv[0]) > - 1))))) { - printf("ERR: Invalid arguments\n"); - ret = UAP_FAILURE; - } - if ((atoi(argv[0]) == 1) && (argc == 1)) { - printf("ERR: Mode_config parameter must be provided to enable this feature.\n"); - ret = UAP_FAILURE; - } - if ((argc == 2) && - (((A2HEXDECIMAL(argv[1]) << 8) != B_ONLY_MASK) && - ((A2HEXDECIMAL(argv[1]) << 8) != G_ONLY_MASK) && - ((A2HEXDECIMAL(argv[1]) << 8) != A_ONLY_MASK) && - ((A2HEXDECIMAL(argv[1]) << 8) != N_ONLY_MASK) && - ((A2HEXDECIMAL(argv[1]) << 8) != AC_ONLY_MASK))) { - printf("ERR: Exactly one mode can be enabled at a time.\n"); - ret = UAP_FAILURE; - } - } - break; - default: - ret = UAP_FAILURE; - break; - } - return ret; -} - -/** - * @brief Converts colon separated MAC address to hex value - * - * @param mac A pointer to the colon separated MAC string - * @param raw A pointer to the hex data buffer - * @return UAP_SUCCESS or UAP_FAILURE - * UAP_RET_MAC_BROADCAST - if broadcast mac - * UAP_RET_MAC_MULTICAST - if multicast mac - */ -int -mac2raw(char *mac, t_u8 *raw) -{ - unsigned int temp_raw[ETH_ALEN]; - int num_tokens = 0; - int i; - if (strlen(mac) != ((2 * ETH_ALEN) + (ETH_ALEN - 1))) { - return UAP_FAILURE; - } - num_tokens = sscanf(mac, "%2x:%2x:%2x:%2x:%2x:%2x", - temp_raw + 0, temp_raw + 1, temp_raw + 2, - temp_raw + 3, temp_raw + 4, temp_raw + 5); - if (num_tokens != ETH_ALEN) { - return UAP_FAILURE; - } - for (i = 0; i < num_tokens; i++) - raw[i] = (t_u8)temp_raw[i]; - - if (memcmp(raw, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0) { - return UAP_RET_MAC_BROADCAST; - } else if (raw[0] & 0x01) { - return UAP_RET_MAC_MULTICAST; - } - return UAP_SUCCESS; -} - -/** - * @brief Converts a string to hex value - * - * @param str A pointer to the string - * @param raw A pointer to the raw data buffer - * @return Number of bytes read - */ -int -string2raw(char *str, unsigned char *raw) -{ - int len = (strlen(str) + 1) / 2; - - do { - if (!isxdigit(*str)) { - return -1; - } - *str = toupper(*str); - *raw = CHAR2INT(*str) << 4; - ++str; - *str = toupper(*str); - if (*str == '\0') - break; - *raw |= CHAR2INT(*str); - ++raw; - } while (*++str != '\0'); - return len; -} - -/** - * @brief Prints a MAC address in colon separated form from hex data - * - * @param raw A pointer to the hex data buffer - * @return N/A - */ -void -print_mac(t_u8 *raw) -{ - printf("%02x:%02x:%02x:%02x:%02x:%02x", (unsigned int)raw[0], - (unsigned int)raw[1], (unsigned int)raw[2], (unsigned int)raw[3], - (unsigned int)raw[4], (unsigned int)raw[5]); - return; -} - -/** - * @brief Check hex string - * - * @param hex A pointer to hex string - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -ishexstring(void *hex) -{ - int i, a; - char *p = hex; - int len = strlen(p); - if (!strncasecmp("0x", p, 2)) { - p += 2; - len -= 2; - } - for (i = 0; i < len; i++) { - a = hex2num(*p); - if (a < 0) - return UAP_FAILURE; - p++; - } - return UAP_SUCCESS; -} - -/** - * @brief Show auth tlv - * - * @param tlv Pointer to auth tlv - * - * $return N/A - */ -void -print_auth(tlvbuf_auth_mode *tlv) -{ - switch (tlv->auth_mode) { - case 0: - printf("AUTHMODE = Open authentication\n"); - break; - case 1: - printf("AUTHMODE = Shared key authentication\n"); - break; - case 3: - printf("AUTHMODE = WPA3 SAE\n"); - break; - case 255: - printf("AUTHMODE = Auto (open and shared key)\n"); - break; - default: - printf("ERR: Invalid authmode=%d\n", tlv->auth_mode); - break; - } -} - -/** - * - * @brief Show cipher tlv - * - * @param tlv Pointer to cipher tlv - * - * $return N/A - */ -void -print_cipher(tlvbuf_cipher *tlv) -{ - switch (tlv->pairwise_cipher) { - case CIPHER_TKIP: - printf("PairwiseCipher = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("PairwiseCipher = AES CCMP\n"); - break; - case CIPHER_TKIP | CIPHER_AES_CCMP: - printf("PairwiseCipher = TKIP + AES CCMP\n"); - break; - case CIPHER_NONE: - printf("PairwiseCipher = None\n"); - break; - default: - printf("Unknown Pairwise cipher 0x%x\n", tlv->pairwise_cipher); - break; - } - switch (tlv->group_cipher) { - case CIPHER_TKIP: - printf("GroupCipher = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("GroupCipher = AES CCMP\n"); - break; - case CIPHER_NONE: - printf("GroupCipher = None\n"); - break; - default: - printf("Unknown Group cipher 0x%x\n", tlv->group_cipher); - break; - } -} - -/** - * @brief Show pairwise cipher tlv - * - * @param tlv Pointer to pairwise cipher tlv - * - * $return N/A - */ -void -print_pwk_cipher(tlvbuf_pwk_cipher *tlv) -{ - switch (tlv->protocol) { - case PROTOCOL_WPA: - printf("Protocol WPA : "); - break; - case PROTOCOL_WPA2: - printf("Protocol WPA2 : "); - break; - case PROTOCOL_WPA3_SAE: - printf("Protocol WPA3_SAE : "); - break; - default: - printf("Unknown Protocol 0x%x\n", tlv->protocol); - break; - } - - switch (tlv->pairwise_cipher) { - case CIPHER_TKIP: - printf("PairwiseCipher = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("PairwiseCipher = AES CCMP\n"); - break; - case CIPHER_TKIP | CIPHER_AES_CCMP: - printf("PairwiseCipher = TKIP + AES CCMP\n"); - break; - case CIPHER_NONE: - printf("PairwiseCipher = None\n"); - break; - default: - printf("Unknown Pairwise cipher 0x%x\n", tlv->pairwise_cipher); - break; - } -} - -/** - * @brief Show group cipher tlv - * - * @param tlv Pointer to group cipher tlv - * - * $return N/A - */ -void -print_gwk_cipher(tlvbuf_gwk_cipher *tlv) -{ - switch (tlv->group_cipher) { - case CIPHER_TKIP: - printf("GroupCipher = TKIP\n"); - break; - case CIPHER_AES_CCMP: - printf("GroupCipher = AES CCMP\n"); - break; - case CIPHER_NONE: - printf("GroupCipher = None\n"); - break; - default: - printf("Unknown Group cipher 0x%x\n", tlv->group_cipher); - break; - } -} - -/** - * @brief Show mac filter tlv - * - * @param tlv Pointer to filter tlv - * - * $return N/A - */ -void -print_mac_filter(tlvbuf_sta_mac_addr_filter *tlv) -{ - int i; - switch (tlv->filter_mode) { - case 0: - printf("Filter Mode = Filter table is disabled\n"); - return; - case 1: - if (!tlv->count) { - printf("No mac address is allowed to connect\n"); - } else { - printf("Filter Mode = Allow mac address specified in the allowed list\n"); - } - break; - case 2: - if (!tlv->count) { - printf("No mac address is blocked\n"); - } else { - printf("Filter Mode = Block MAC addresses specified in the banned list\n"); - } - break; - } - for (i = 0; i < tlv->count; i++) { - printf("MAC_%d = ", i); - print_mac(&tlv->mac_address[i * ETH_ALEN]); - printf("\n"); - } -} - -/** - * @brief Show rate tlv - * - * @param tlv Pointer to rate tlv - * - * $return N/A - */ -void -print_rate(tlvbuf_rates *tlv) -{ - int flag = 0; - int i; - t_u16 tlv_len; - - tlv_len = *(t_u8 *)&tlv->length; - tlv_len |= (*((t_u8 *)&tlv->length + 1) << 8); - - printf("Basic Rates ="); - for (i = 0; i < tlv_len; i++) { - if (tlv->operational_rates[i] > (BASIC_RATE_SET_BIT - 1)) { - flag = flag ? : 1; - printf(" 0x%x", tlv->operational_rates[i]); - } - } - printf("%s\nNon-Basic Rates =", flag ? "" : " ( none ) "); - for (flag = 0, i = 0; i < tlv_len; i++) { - if (tlv->operational_rates[i] < BASIC_RATE_SET_BIT) { - flag = flag ? : 1; - printf(" 0x%x", tlv->operational_rates[i]); - } - } - printf("%s\n", flag ? "" : " ( none ) "); -} - -/** - * @brief Show all the tlv in the buf - * - * @param buf Pointer to tlv buffer - * @param len Tlv buffer len - * - * $return N/A - */ -void -print_tlv(t_u8 *buf, t_u16 len) -{ - tlvbuf_header *pcurrent_tlv = (tlvbuf_header *)buf; - int tlv_buf_left = len; - t_u16 tlv_type; - t_u16 tlv_len; - t_u16 tlv_val_16; - t_u32 tlv_val_32; - t_u8 ssid[33]; - int i = 0; - tlvbuf_ap_mac_address *mac_tlv; - tlvbuf_ssid *ssid_tlv; - tlvbuf_beacon_period *beacon_tlv; - tlvbuf_dtim_period *dtim_tlv; - tlvbuf_rates *rates_tlv; - tlvbuf_tx_power *txpower_tlv; - tlvbuf_bcast_ssid_ctl *bcast_tlv; - tlvbuf_preamble_ctl *preamble_tlv; - tlvbuf_bss_status *bss_status_tlv; - tlvbuf_rts_threshold *rts_tlv; - tlvbuf_mcbc_data_rate *mcbcrate_tlv; - tlvbuf_pkt_fwd_ctl *pkt_fwd_tlv; - tlvbuf_sta_ageout_timer *ageout_tlv; - tlvbuf_ps_sta_ageout_timer *ps_ageout_tlv; - tlvbuf_auth_mode *auth_tlv; - tlvbuf_protocol *proto_tlv; - tlvbuf_akmp *akmp_tlv; - tlvbuf_cipher *cipher_tlv; - tlvbuf_pwk_cipher *pwk_cipher_tlv; - tlvbuf_gwk_cipher *gwk_cipher_tlv; - tlvbuf_group_rekey_timer *rekey_tlv; - tlvbuf_wpa_passphrase *psk_tlv; - tlvbuf_coex_common_cfg *coex_common_tlv; - tlvbuf_coex_sco_cfg *coex_sco_tlv; - tlvbuf_coex_acl_cfg *coex_acl_tlv; - tlvbuf_coex_stats *coex_stats_tlv; - tlvbuf_wep_key *wep_tlv; - tlvbuf_frag_threshold *frag_tlv; - tlvbuf_sta_mac_addr_filter *filter_tlv; - tlvbuf_max_sta_num *max_sta_tlv; - tlvbuf_retry_limit *retry_limit_tlv; - tlvbuf_eapol_pwk_hsk_timeout *pwk_timeout_tlv; - tlvbuf_eapol_pwk_hsk_retries *pwk_retries_tlv; - tlvbuf_eapol_gwk_hsk_timeout *gwk_timeout_tlv; - tlvbuf_eapol_gwk_hsk_retries *gwk_retries_tlv; - tlvbuf_channel_config *channel_tlv; - tlvbuf_channel_list *chnlist_tlv; - channel_list *pchan_list; - t_u16 custom_ie_len; - tlvbuf_rsn_replay_prot *replay_prot_tlv; - tlvbuf_custom_ie *custom_ie_tlv; - custom_ie *custom_ie_ptr; - tlvbuf_max_mgmt_ie *max_mgmt_ie_tlv; - tlvbuf_wmm_para_t *wmm_para_tlv; - int flag = 0; - tlvbuf_htcap_t *ht_cap_tlv; - tlvbuf_htinfo_t *ht_info_tlv; - tlvbuf_2040_coex *coex_2040_tlv; - -#ifdef RX_PACKET_COALESCE - tlvbuf_rx_pkt_coal_t *rx_pkt_coal_tlv; -#endif - -#if DEBUG - uap_printf(MSG_DEBUG, "tlv total len=%d\n", len); -#endif - while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { - tlv_type = *(t_u8 *)&pcurrent_tlv->type; - tlv_type |= (*((t_u8 *)&pcurrent_tlv->type + 1) << 8); - tlv_len = *(t_u8 *)&pcurrent_tlv->len; - tlv_len |= (*((t_u8 *)&pcurrent_tlv->len + 1) << 8); - if ((sizeof(tlvbuf_header) + tlv_len) > - (unsigned int)tlv_buf_left) { - printf("wrong tlv: tlv_len=%d, tlv_buf_left=%d\n", - tlv_len, tlv_buf_left); - break; - } - switch (tlv_type) { - case MRVL_AP_MAC_ADDRESS_TLV_ID: - mac_tlv = (tlvbuf_ap_mac_address *)pcurrent_tlv; - printf("AP MAC address = "); - print_mac(mac_tlv->ap_mac_addr); - printf("\n"); - break; - case MRVL_SSID_TLV_ID: - memset(ssid, 0, sizeof(ssid)); - ssid_tlv = (tlvbuf_ssid *)pcurrent_tlv; - - strncpy((char *)ssid, (char *)ssid_tlv->ssid, - sizeof(ssid) - 1); - - printf("SSID = %s\n", ssid); - break; - case MRVL_BEACON_PERIOD_TLV_ID: - beacon_tlv = (tlvbuf_beacon_period *)pcurrent_tlv; - tlv_val_16 = *(t_u8 *)&beacon_tlv->beacon_period_ms; - tlv_val_16 |= - (*((t_u8 *)&beacon_tlv->beacon_period_ms + 1) << - 8); - printf("Beacon period = %d\n", tlv_val_16); - break; - case MRVL_DTIM_PERIOD_TLV_ID: - dtim_tlv = (tlvbuf_dtim_period *)pcurrent_tlv; - printf("DTIM period = %d\n", dtim_tlv->dtim_period); - break; - case MRVL_CHANNELCONFIG_TLV_ID: - channel_tlv = (tlvbuf_channel_config *)pcurrent_tlv; - printf("Channel = %d\n", channel_tlv->chan_number); - printf("Band = %s\n", - (channel_tlv->bandcfg.chanBand == - BAND_5GHZ) ? "5GHz" : "2.4GHz"); - printf("Channel Select Mode = %s\n", - (channel_tlv->bandcfg.scanMode == - SCAN_MODE_ACS) ? "ACS" : "Manual"); - if (channel_tlv->bandcfg.chan2Offset == SEC_CHAN_NONE) - printf("no secondary channel\n"); - else if (channel_tlv->bandcfg.chan2Offset == - SEC_CHAN_ABOVE) - printf("secondary channel is above primary channel\n"); - else if (channel_tlv->bandcfg.chan2Offset == - SEC_CHAN_BELOW) - printf("secondary channel is below primary channel\n"); - break; - case MRVL_CHANNELLIST_TLV_ID: - chnlist_tlv = (tlvbuf_channel_list *)pcurrent_tlv; - printf("Channels List = "); - pchan_list = - (channel_list *) & (chnlist_tlv->chan_list); - if (tlv_len % sizeof(channel_list)) { - break; - } - for (i = 0; - (unsigned int)i < (tlv_len / sizeof(channel_list)); - i++) { - printf("\n%d\t%sGHz", pchan_list->chan_number, - (pchan_list->bandcfg.chanBand == - BAND_5GHZ) ? "5" : "2.4"); - pchan_list++; - } - printf("\n"); - break; - case MRVL_RSN_REPLAY_PROT_TLV_ID: - replay_prot_tlv = - (tlvbuf_rsn_replay_prot *)pcurrent_tlv; - printf("RSN replay protection = %s\n", - replay_prot_tlv-> - rsn_replay_prot ? "enabled" : "disabled"); - break; - case MRVL_RATES_TLV_ID: - rates_tlv = (tlvbuf_rates *)pcurrent_tlv; - print_rate(rates_tlv); - break; - case MRVL_TX_POWER_TLV_ID: - txpower_tlv = (tlvbuf_tx_power *)pcurrent_tlv; - printf("Tx power = %d dBm\n", - txpower_tlv->tx_power_dbm); - break; - case MRVL_BCAST_SSID_CTL_TLV_ID: - bcast_tlv = (tlvbuf_bcast_ssid_ctl *)pcurrent_tlv; - printf("SSID broadcast = %s\n", - (bcast_tlv->bcast_ssid_ctl == - 1) ? "enabled" : "disabled"); - break; - case MRVL_PREAMBLE_CTL_TLV_ID: - preamble_tlv = (tlvbuf_preamble_ctl *)pcurrent_tlv; - printf("Preamble type = %s\n", - (preamble_tlv->preamble_type == - 0) ? "auto" : ((preamble_tlv->preamble_type == - 1) ? "short" : "long")); - break; - case MRVL_BSS_STATUS_TLV_ID: - bss_status_tlv = (tlvbuf_bss_status *)pcurrent_tlv; - printf("BSS status = %s\n", - (bss_status_tlv->bss_status == - 0) ? "stopped" : "started"); - break; - case MRVL_RTS_THRESHOLD_TLV_ID: - rts_tlv = (tlvbuf_rts_threshold *)pcurrent_tlv; - tlv_val_16 = *(t_u8 *)&rts_tlv->rts_threshold; - tlv_val_16 |= - (*((t_u8 *)&rts_tlv->rts_threshold + 1) << 8); - printf("RTS threshold = %d\n", tlv_val_16); - break; - case MRVL_FRAG_THRESHOLD_TLV_ID: - frag_tlv = (tlvbuf_frag_threshold *)pcurrent_tlv; - tlv_val_16 = *(t_u8 *)&frag_tlv->frag_threshold; - tlv_val_16 |= - (*((t_u8 *)&frag_tlv->frag_threshold + 1) << 8); - printf("Fragmentation threshold = %d\n", tlv_val_16); - break; - case MRVL_MCBC_DATA_RATE_TLV_ID: - mcbcrate_tlv = (tlvbuf_mcbc_data_rate *)pcurrent_tlv; - tlv_val_16 = *(t_u8 *)&mcbcrate_tlv->mcbc_datarate; - tlv_val_16 |= - (*((t_u8 *)&mcbcrate_tlv->mcbc_datarate + 1) << - 8); - if (mcbcrate_tlv->mcbc_datarate == 0) - printf("MCBC data rate = auto\n"); - else - printf("MCBC data rate = 0x%x\n", tlv_val_16); - break; - case MRVL_PKT_FWD_CTL_TLV_ID: - pkt_fwd_tlv = (tlvbuf_pkt_fwd_ctl *)pcurrent_tlv; - printf("%s handles packet forwarding -\n", - ((pkt_fwd_tlv->pkt_fwd_ctl & PKT_FWD_FW_BIT) == - 0) ? "Host" : "Firmware"); - printf("\tIntra-BSS broadcast packets are %s\n", - ((pkt_fwd_tlv-> - pkt_fwd_ctl & PKT_FWD_INTRA_BCAST) == - 0) ? "allowed" : "denied"); - printf("\tIntra-BSS unicast packets are %s\n", - ((pkt_fwd_tlv-> - pkt_fwd_ctl & PKT_FWD_INTRA_UCAST) == - 0) ? "allowed" : "denied"); - printf("\tInter-BSS unicast packets are %s\n", - ((pkt_fwd_tlv-> - pkt_fwd_ctl & PKT_FWD_INTER_UCAST) == - 0) ? "allowed" : "denied"); - break; - case MRVL_STA_AGEOUT_TIMER_TLV_ID: - ageout_tlv = (tlvbuf_sta_ageout_timer *)pcurrent_tlv; - tlv_val_32 = *(t_u8 *)&ageout_tlv->sta_ageout_timer_ms; - tlv_val_32 |= - (*((t_u8 *)&ageout_tlv->sta_ageout_timer_ms + 1) - << 8); - tlv_val_32 |= - (*((t_u8 *)&ageout_tlv->sta_ageout_timer_ms + 2) - << 16); - tlv_val_32 |= - (*((t_u8 *)&ageout_tlv->sta_ageout_timer_ms + 3) - << 24); - printf("STA ageout timer = %d\n", (int)tlv_val_32); - break; - case MRVL_PS_STA_AGEOUT_TIMER_TLV_ID: - ps_ageout_tlv = - (tlvbuf_ps_sta_ageout_timer *)pcurrent_tlv; - tlv_val_32 = - *(t_u8 *)&ps_ageout_tlv->ps_sta_ageout_timer_ms; - tlv_val_32 |= - (* - ((t_u8 *)&ps_ageout_tlv-> - ps_sta_ageout_timer_ms + 1) << 8); - tlv_val_32 |= - (* - ((t_u8 *)&ps_ageout_tlv-> - ps_sta_ageout_timer_ms + 2) << 16); - tlv_val_32 |= - (* - ((t_u8 *)&ps_ageout_tlv-> - ps_sta_ageout_timer_ms + 3) << 24); - printf("PS STA ageout timer = %d\n", (int)tlv_val_32); - break; - case MRVL_AUTH_TLV_ID: - auth_tlv = (tlvbuf_auth_mode *)pcurrent_tlv; - print_auth(auth_tlv); - break; - case MRVL_PROTOCOL_TLV_ID: - proto_tlv = (tlvbuf_protocol *)pcurrent_tlv; - tlv_val_16 = *(t_u8 *)&proto_tlv->protocol; - tlv_val_16 |= - (*((t_u8 *)&proto_tlv->protocol + 1) << 8); - print_protocol(tlv_val_16); - break; - case MRVL_AKMP_TLV_ID: - akmp_tlv = (tlvbuf_akmp *)pcurrent_tlv; - tlv_val_16 = *(t_u8 *)&akmp_tlv->key_mgmt; - tlv_val_16 |= (*((t_u8 *)&akmp_tlv->key_mgmt + 1) << 8); - if (tlv_val_16 & (KEY_MGMT_PSK | KEY_MGMT_PSK_SHA256)) { - if (tlv_val_16 & KEY_MGMT_PSK) - printf("KeyMgmt = PSK\n"); - if (tlv_val_16 & KEY_MGMT_PSK_SHA256) - printf("KeyMgmt = PSK_SHA256\n"); - tlv_val_16 = - *(t_u8 *)&akmp_tlv->key_mgmt_operation; - if (tlv_len > sizeof(t_u16)) { - tlv_val_16 |= - (* - ((t_u8 *)&akmp_tlv-> - key_mgmt_operation + 1) << 8); - printf("Key Exchange on : %s.\n", - (tlv_val_16 & 0x01) ? "Host" : - "Device"); - printf("1x Authentication on : %s.\n", - (tlv_val_16 & 0x10) ? "Host" : - "Device"); - } - } - if (tlv_val_16 & KEY_MGMT_EAP) - printf("KeyMgmt = EAP"); - if (tlv_val_16 & KEY_MGMT_NONE) - printf("KeyMgmt = NONE"); - break; - case MRVL_CIPHER_TLV_ID: - cipher_tlv = (tlvbuf_cipher *)pcurrent_tlv; - print_cipher(cipher_tlv); - break; - case MRVL_CIPHER_PWK_TLV_ID: - pwk_cipher_tlv = (tlvbuf_pwk_cipher *)pcurrent_tlv; - pwk_cipher_tlv->protocol = - uap_le16_to_cpu(pwk_cipher_tlv->protocol); - print_pwk_cipher(pwk_cipher_tlv); - break; - case MRVL_CIPHER_GWK_TLV_ID: - gwk_cipher_tlv = (tlvbuf_gwk_cipher *)pcurrent_tlv; - print_gwk_cipher(gwk_cipher_tlv); - break; - case MRVL_GRP_REKEY_TIME_TLV_ID: - rekey_tlv = (tlvbuf_group_rekey_timer *)pcurrent_tlv; - tlv_val_32 = *(t_u8 *)&rekey_tlv->group_rekey_time_sec; - tlv_val_32 |= - (*((t_u8 *)&rekey_tlv->group_rekey_time_sec + 1) - << 8); - tlv_val_32 |= - (*((t_u8 *)&rekey_tlv->group_rekey_time_sec + 2) - << 16); - tlv_val_32 |= - (*((t_u8 *)&rekey_tlv->group_rekey_time_sec + 3) - << 24); - if (tlv_val_32 == 0) - printf("Group re-key time = disabled\n"); - else - printf("Group re-key time = %d second\n", - tlv_val_32); - break; - case MRVL_WPA_PASSPHRASE_TLV_ID: - psk_tlv = (tlvbuf_wpa_passphrase *)pcurrent_tlv; - if (tlv_len > 0) { - printf("WPA passphrase = "); - for (i = 0; i < tlv_len; i++) - printf("%c", psk_tlv->passphrase[i]); - printf("\n"); - } else - printf("WPA passphrase = None\n"); - break; - case MRVL_WEP_KEY_TLV_ID: - wep_tlv = (tlvbuf_wep_key *)pcurrent_tlv; - print_wep_key(wep_tlv); - break; - case MRVL_STA_MAC_ADDR_FILTER_TLV_ID: - filter_tlv = (tlvbuf_sta_mac_addr_filter *)pcurrent_tlv; - print_mac_filter(filter_tlv); - break; - case MRVL_MAX_STA_CNT_TLV_ID: - max_sta_tlv = (tlvbuf_max_sta_num *)pcurrent_tlv; - tlv_val_16 = - *(t_u8 *)&max_sta_tlv->max_sta_num_configured; - tlv_val_16 |= - (* - ((t_u8 *)&max_sta_tlv->max_sta_num_configured + - 1) << 8); - printf("Max Station Number configured = %d\n", - tlv_val_16); - if (max_sta_tlv->length == 4) { - tlv_val_16 = - *(t_u8 *)&max_sta_tlv-> - max_sta_num_supported; - tlv_val_16 |= - (* - ((t_u8 *)&max_sta_tlv-> - max_sta_num_supported + 1) << 8); - printf("Max Station Number supported = %d\n", - tlv_val_16); - } - break; - case MRVL_RETRY_LIMIT_TLV_ID: - retry_limit_tlv = (tlvbuf_retry_limit *)pcurrent_tlv; - printf("Retry Limit = %d\n", - retry_limit_tlv->retry_limit); - break; - case MRVL_EAPOL_PWK_HSK_TIMEOUT_TLV_ID: - pwk_timeout_tlv = - (tlvbuf_eapol_pwk_hsk_timeout *)pcurrent_tlv; - pwk_timeout_tlv->pairwise_update_timeout = - uap_le32_to_cpu(pwk_timeout_tlv-> - pairwise_update_timeout); - printf("Pairwise handshake timeout = %d\n", - pwk_timeout_tlv->pairwise_update_timeout); - break; - case MRVL_EAPOL_PWK_HSK_RETRIES_TLV_ID: - pwk_retries_tlv = - (tlvbuf_eapol_pwk_hsk_retries *)pcurrent_tlv; - pwk_retries_tlv->pwk_retries = - uap_le32_to_cpu(pwk_retries_tlv->pwk_retries); - printf("Pairwise handshake retries = %d\n", - pwk_retries_tlv->pwk_retries); - break; - case MRVL_EAPOL_GWK_HSK_TIMEOUT_TLV_ID: - gwk_timeout_tlv = - (tlvbuf_eapol_gwk_hsk_timeout *)pcurrent_tlv; - gwk_timeout_tlv->groupwise_update_timeout = - uap_le32_to_cpu(gwk_timeout_tlv-> - groupwise_update_timeout); - printf("Groupwise handshake timeout = %d\n", - gwk_timeout_tlv->groupwise_update_timeout); - break; - case MRVL_EAPOL_GWK_HSK_RETRIES_TLV_ID: - gwk_retries_tlv = - (tlvbuf_eapol_gwk_hsk_retries *)pcurrent_tlv; - gwk_retries_tlv->gwk_retries = - uap_le32_to_cpu(gwk_retries_tlv->gwk_retries); - printf("Groupwise handshake retries = %d\n", - gwk_retries_tlv->gwk_retries); - break; - case MRVL_MGMT_IE_LIST_TLV_ID: - custom_ie_tlv = (tlvbuf_custom_ie *)pcurrent_tlv; - custom_ie_len = tlv_len; - custom_ie_ptr = (custom_ie *)(custom_ie_tlv->ie_data); - while (custom_ie_len >= sizeof(custom_ie)) { - custom_ie_ptr->ie_index = - uap_le16_to_cpu(custom_ie_ptr-> - ie_index); - custom_ie_ptr->ie_length = - uap_le16_to_cpu(custom_ie_ptr-> - ie_length); - custom_ie_ptr->mgmt_subtype_mask = - uap_le16_to_cpu(custom_ie_ptr-> - mgmt_subtype_mask); - printf("Index [%d]\n", custom_ie_ptr->ie_index); - if (custom_ie_ptr->ie_length) - printf("Management Subtype Mask = 0x%02x\n", custom_ie_ptr->mgmt_subtype_mask == 0 ? UAP_CUSTOM_IE_AUTO_MASK : custom_ie_ptr->mgmt_subtype_mask); - else - printf("Management Subtype Mask = 0x%02x\n", custom_ie_ptr->mgmt_subtype_mask); - hexdump_data("IE Buffer", - (void *)custom_ie_ptr->ie_buffer, - (custom_ie_ptr->ie_length), ' '); - custom_ie_len -= - sizeof(custom_ie) + - custom_ie_ptr->ie_length; - custom_ie_ptr = - (custom_ie *)((t_u8 *)custom_ie_ptr + - sizeof(custom_ie) + - custom_ie_ptr->ie_length); - } - custom_ie_present = 1; - break; - case MRVL_MAX_MGMT_IE_TLV_ID: - max_mgmt_ie_tlv = (tlvbuf_max_mgmt_ie *)pcurrent_tlv; - max_mgmt_ie_tlv->count = - uap_le16_to_cpu(max_mgmt_ie_tlv->count); - for (i = 0; i < max_mgmt_ie_tlv->count; i++) { - max_mgmt_ie_tlv->info[i].buf_size = - uap_le16_to_cpu(max_mgmt_ie_tlv-> - info[i].buf_size); - max_mgmt_ie_tlv->info[i].buf_count = - uap_le16_to_cpu(max_mgmt_ie_tlv-> - info[i].buf_count); - printf("buf%d_size = %d\n", i, - max_mgmt_ie_tlv->info[i].buf_size); - printf("number of buffers = %d\n", - max_mgmt_ie_tlv->info[i].buf_count); - printf("\n"); - } - max_mgmt_ie_print = 1; - break; - case MRVL_BT_COEX_COMMON_CFG_TLV_ID: - printf("Coex common configuration:\n"); - coex_common_tlv = - (tlvbuf_coex_common_cfg *)pcurrent_tlv; - printf("\tConfig Bitmap = 0x%02x\n", - uap_le32_to_cpu(coex_common_tlv->config_bitmap)); - printf("\tAP Coex Enabled = %d\n", - uap_le32_to_cpu(coex_common_tlv->ap_bt_coex)); - break; - - case MRVL_BT_COEX_SCO_CFG_TLV_ID: - printf("Coex sco configuration:\n"); - coex_sco_tlv = (tlvbuf_coex_sco_cfg *)pcurrent_tlv; - for (i = 0; i < 4; i++) - printf("\tQtime protection [%d] = %d usecs\n", - i, - uap_le16_to_cpu(coex_sco_tlv-> - protection_qtime[i])); - printf("\tProtection frame rate = %d\n", - uap_le16_to_cpu(coex_sco_tlv->protection_rate)); - printf("\tACL frequency = %d\n", - uap_le16_to_cpu(coex_sco_tlv->acl_frequency)); - break; - - case MRVL_BT_COEX_ACL_CFG_TLV_ID: - printf("Coex acl configuration: "); - coex_acl_tlv = (tlvbuf_coex_acl_cfg *)pcurrent_tlv; - coex_acl_tlv->enabled = - uap_le16_to_cpu(coex_acl_tlv->enabled); - printf("%s\n", - (coex_acl_tlv-> - enabled) ? "enabled" : "disabled"); - if (coex_acl_tlv->enabled) { - printf("\tBT time = %d usecs\n", - uap_le16_to_cpu(coex_acl_tlv->bt_time)); - printf("\tWLan time = %d usecs\n", - uap_le16_to_cpu(coex_acl_tlv-> - wlan_time)); - printf("\tProtection frame rate = %d\n", - uap_le16_to_cpu(coex_acl_tlv-> - protection_rate)); - } - break; - - case MRVL_BT_COEX_STATS_TLV_ID: - printf("Coex statistics: \n"); - coex_stats_tlv = (tlvbuf_coex_stats *)pcurrent_tlv; - printf("\tNull not sent = %d\n", - uap_le32_to_cpu(coex_stats_tlv->null_not_sent)); - printf("\tNull queued = %d\n", - uap_le32_to_cpu(coex_stats_tlv->null_queued)); - printf("\tNull not queued = %d\n", - uap_le32_to_cpu(coex_stats_tlv-> - null_not_queued)); - printf("\tCF End queued = %d\n", - uap_le32_to_cpu(coex_stats_tlv->cf_end_queued)); - printf("\tCF End not queued = %d\n", - uap_le32_to_cpu(coex_stats_tlv-> - cf_end_not_queued)); - printf("\tNull allocation failures = %d\n", - uap_le32_to_cpu(coex_stats_tlv-> - null_alloc_fail)); - printf("\tCF End allocation failures = %d\n", - uap_le32_to_cpu(coex_stats_tlv-> - cf_end_alloc_fail)); - break; - case HT_CAPABILITY_TLV_ID: - printf("\nHT Capability Info: \n"); - ht_cap_tlv = (tlvbuf_htcap_t *)pcurrent_tlv; - if (!ht_cap_tlv->ht_cap.supported_mcs_set[0]) { - printf("802.11n is disabled\n"); - } else { - printf("802.11n is enabled\n"); - printf("ht_cap_info=0x%x, ampdu_param=0x%x tx_bf_cap=%#x\n", uap_le16_to_cpu(ht_cap_tlv->ht_cap.ht_cap_info), ht_cap_tlv->ht_cap.ampdu_param, uap_le32_to_cpu(ht_cap_tlv->ht_cap.tx_bf_cap)); - printf("supported MCS set:\n"); - for (i = 0; i < MCS_SET_LEN; i++) { - printf("0x%x ", - ht_cap_tlv->ht_cap. - supported_mcs_set[i]); - } - printf("\n"); - } - break; - case HT_INFO_TLV_ID: - ht_info_tlv = (tlvbuf_htinfo_t *)pcurrent_tlv; - if (ht_info_tlv->length) { - printf("\nHT Information Element: \n"); - printf("Primary channel = %d\n", - ht_info_tlv->ht_info.pri_chan); - printf("Secondary channel offset = %d\n", - (int)GET_SECONDARY_CHAN(ht_info_tlv-> - ht_info.field2)); - printf("STA channel width = %dMHz\n", - IS_CHANNEL_WIDTH_40(ht_info_tlv->ht_info. - field2) ? 40 : 20); - printf("RIFS %s\n", - IS_RIFS_ALLOWED(ht_info_tlv->ht_info. - field2) ? "Allowed" : - "Prohibited"); - ht_info_tlv->ht_info.field3 = - uap_le16_to_cpu(ht_info_tlv->ht_info. - field3); - ht_info_tlv->ht_info.field4 = - uap_le16_to_cpu(ht_info_tlv->ht_info. - field4); - printf("HT Protection = %d\n", - (int)GET_HT_PROTECTION(ht_info_tlv-> - ht_info.field3)); - printf("Non-Greenfield HT STAs present: %s\n", - NONGF_STA_PRESENT(ht_info_tlv->ht_info. - field3) ? "Yes" : - "No"); - printf("OBSS Non-HT STAs present: %s\n", - OBSS_NONHT_STA_PRESENT(ht_info_tlv-> - ht_info. - field3) ? "Yes" : - "No"); - for (i = 0; i < MCS_SET_LEN; i++) { - if (ht_info_tlv->ht_info. - basic_mcs_set[i]) { - printf("Basic_mcs_set: \n"); - flag = 1; - break; - } - } - if (flag) { - for (i = 0; i < MCS_SET_LEN; i++) - printf("%x ", - ht_info_tlv->ht_info. - basic_mcs_set[i]); - printf("\n"); - } - } - break; - case MRVL_2040_BSS_COEX_CONTROL_TLV_ID: - coex_2040_tlv = (tlvbuf_2040_coex *)pcurrent_tlv; - printf("20/40 coex = %s\n", - (coex_2040_tlv-> - enable) ? "enabled" : "disabled"); - break; - case VENDOR_SPECIFIC_IE_TLV_ID: - wmm_para_tlv = (tlvbuf_wmm_para_t *)pcurrent_tlv; - printf("wmm parameters:\n"); - printf("\tqos_info = 0x%x\n", - wmm_para_tlv->wmm_para.qos_info); - printf("\tBE: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para_tlv->wmm_para.ac_params[AC_BE]. - aci_aifsn.aifsn, - wmm_para_tlv->wmm_para.ac_params[AC_BE].ecw. - ecw_max, - wmm_para_tlv->wmm_para.ac_params[AC_BE].ecw. - ecw_min, - uap_le16_to_cpu(wmm_para_tlv->wmm_para. - ac_params[AC_BE].tx_op_limit)); - printf("\tBK: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para_tlv->wmm_para.ac_params[AC_BK]. - aci_aifsn.aifsn, - wmm_para_tlv->wmm_para.ac_params[AC_BK].ecw. - ecw_max, - wmm_para_tlv->wmm_para.ac_params[AC_BK].ecw. - ecw_min, - uap_le16_to_cpu(wmm_para_tlv->wmm_para. - ac_params[AC_BK].tx_op_limit)); - printf("\tVI: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para_tlv->wmm_para.ac_params[AC_VI]. - aci_aifsn.aifsn, - wmm_para_tlv->wmm_para.ac_params[AC_VI].ecw. - ecw_max, - wmm_para_tlv->wmm_para.ac_params[AC_VI].ecw. - ecw_min, - uap_le16_to_cpu(wmm_para_tlv->wmm_para. - ac_params[AC_VI].tx_op_limit)); - printf("\tVO: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", - wmm_para_tlv->wmm_para.ac_params[AC_VO]. - aci_aifsn.aifsn, - wmm_para_tlv->wmm_para.ac_params[AC_VO].ecw. - ecw_max, - wmm_para_tlv->wmm_para.ac_params[AC_VO].ecw. - ecw_min, - uap_le16_to_cpu(wmm_para_tlv->wmm_para. - ac_params[AC_VO].tx_op_limit)); - break; -#ifdef RX_PACKET_COALESCE - case MRVL_RX_PKT_COAL_TLV_ID: - rx_pkt_coal_tlv = (tlvbuf_rx_pkt_coal_t *)pcurrent_tlv; - printf("RX packet coalesce threshold=%d\n", - uap_le32_to_cpu(rx_pkt_coal_tlv->rx_pkt_count)); - printf("RX packet coalesce timeout in msec=%d\n", - uap_le16_to_cpu(rx_pkt_coal_tlv->delay)); - break; -#endif - default: - break; - } - tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); - pcurrent_tlv = (tlvbuf_header *)(pcurrent_tlv->data + tlv_len); - } - return; -} - -/** - * @brief Checks if command requires driver handling, and if so, - * repackage and send as regular command, instead of hostcmd. - * - * @param cmd Pointer to the command buffer - * @param size Pointer to the command size. This value is - * overwritten by the function with the size of the - * received response. - * @param buf_size Size of the allocated command buffer - * @param reroute_ret Pointer to return value of rerouted command - * @return UAP_SUCCESS (handled here, further processing not needed) - * or UAP_FAILURE (not handled here, proceed as usual) - */ -static int -uap_ioctl_reroute(t_u8 *cmd, t_u16 *size, t_u16 buf_size, int *reroute_ret) -{ - t_u8 reroute = 0; - t_u16 cmd_code = 0; - t_u16 cmd_action = 0; - apcmdbuf_cfg_80211d *hcmd_domain = NULL; - apcmdbuf_snmp_mib *hcmd_snmp = NULL; - tlvbuf_header *tlv = NULL; - struct ifreq ifr; - t_s32 sockfd; - t_u8 *buf = NULL; - t_u16 buf_len = 0; - snmp_mib_param *snmp_param = NULL; - domain_info_param *domain_param = NULL; - - /* assume input is a hostcmd */ - cmd_code = ((apcmdbuf *)(cmd))->cmd_code; - - /* just check if we need to re-route right now */ - switch (cmd_code) { - case HostCmd_SNMP_MIB: - hcmd_snmp = (apcmdbuf_snmp_mib *)cmd; - tlv = (tlvbuf_header *)(cmd + sizeof(apcmdbuf_snmp_mib)); - cmd_action = uap_le16_to_cpu(hcmd_snmp->action); - /* reroute CMD_SNMP_MIB: SET */ - if (cmd_action == ACTION_SET) { - reroute = 1; - buf_len = - sizeof(snmp_mib_param) + - uap_le16_to_cpu(tlv->len); - } - break; - case HostCmd_CMD_802_11D_DOMAIN_INFO: - hcmd_domain = (apcmdbuf_cfg_80211d *)cmd; - cmd_action = uap_le16_to_cpu(hcmd_domain->action); - /* reroute CMD_DOMAIN_INFO: SET */ - if (cmd_action == ACTION_SET) { - reroute = 1; - buf_len = sizeof(domain_info_param) + (*size - - - sizeof - (apcmdbuf_cfg_80211d) - + - sizeof - (domain_param_t)); - } - break; - } - - /* Exit early if not re-routing */ - if (!reroute || uap_ioctl_no_reroute) - return UAP_FAILURE; - - /* Prepare buffer */ -#if DEBUG - uap_printf(MSG_DEBUG, "DBG: rerouting CMD 0x%04x\n", cmd_code); -#endif - buf = (t_u8 *)malloc(buf_len); - if (!buf) { - printf("ERR:Cannot allocate buffer for command!\n"); - goto done_no_socket; - } - memset(buf, 0, buf_len); - - /* Prepare param */ - switch (cmd_code) { - case HostCmd_SNMP_MIB: - snmp_param = (snmp_mib_param *)buf; - snmp_param->subcmd = UAP_SNMP_MIB; - snmp_param->action = cmd_action; - snmp_param->oid = uap_le16_to_cpu(tlv->type); - snmp_param->oid_val_len = uap_le16_to_cpu(tlv->len); - memcpy(snmp_param->oid_value, tlv->data, - MIN(sizeof(t_u32), snmp_param->oid_val_len)); - break; - case HostCmd_CMD_802_11D_DOMAIN_INFO: - domain_param = (domain_info_param *)buf; - domain_param->subcmd = UAP_DOMAIN_INFO; - domain_param->action = cmd_action; - memcpy(domain_param->tlv, &hcmd_domain->domain, - buf_len - sizeof(domain_info_param)); - tlv = (tlvbuf_header *)domain_param->tlv; - tlv->type = uap_le16_to_cpu(tlv->type); - tlv->len = uap_le16_to_cpu(tlv->len); - - break; - } -#if DEBUG - /* Dump request buffer */ - hexdump("Reroute Request buffer", buf, buf_len, ' '); -#endif - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - goto done_no_socket; - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)buf; - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) { - *reroute_ret = UAP_FAILURE; - perror(""); -#if DEBUG - uap_printf(MSG_DEBUG, "ERR: reroute of CMD 0x%04x failed\n", - cmd_code); -#endif - goto done; - } - *reroute_ret = UAP_SUCCESS; - -done: - /* Close socket */ - close(sockfd); -done_no_socket: - if (buf) - free(buf); - - return UAP_SUCCESS; -} - -/** - * @brief Performs the ioctl operation to send the command to - * the driver. - * - * @param cmd Pointer to the command buffer - * @param size Pointer to the command size. This value is - * overwritten by the function with the size of the - * received response. - * @param buf_size Size of the allocated command buffer - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -uap_ioctl(t_u8 *cmd, t_u16 *size, t_u16 buf_size) -{ - struct ifreq ifr; - apcmdbuf *header = NULL; - t_s32 sockfd; - int reroute_ret = 0; - mrvl_priv_cmd *mrvl_cmd = NULL; - t_u8 *buf = NULL, *temp = NULL; - t_u16 mrvl_header_len = 0; - int ret = UAP_SUCCESS; - -#ifdef WIFI_DIRECT_SUPPORT - if (strncmp(dev_name, "wfd", 3)) -#endif - if (uap_ioctl_reroute(cmd, size, buf_size, &reroute_ret) == - UAP_SUCCESS) { - return reroute_ret; - } - - if (buf_size < *size) { - printf("buf_size should not less than cmd buffer size\n"); - return UAP_FAILURE; - } - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return UAP_FAILURE; - } - *(t_u32 *)cmd = buf_size - BUF_HEADER_SIZE; - - mrvl_header_len = strlen(CMD_NXP) + strlen(PRIV_CMD_HOSTCMD); - buf = (unsigned char *)malloc(buf_size + sizeof(mrvl_priv_cmd) + - mrvl_header_len); - if (buf == NULL) { - close(sockfd); - return UAP_FAILURE; - } - - memset(buf, 0, buf_size + sizeof(mrvl_priv_cmd) + mrvl_header_len); - /* Fill up buffer */ - mrvl_cmd = (mrvl_priv_cmd *)buf; - mrvl_cmd->buf = buf + sizeof(mrvl_priv_cmd); - mrvl_cmd->used_len = 0; - mrvl_cmd->total_len = buf_size + mrvl_header_len; - /* Copy NXP command string */ - temp = mrvl_cmd->buf; - strncpy((char *)temp, CMD_NXP, strlen(CMD_NXP)); - temp += (strlen(CMD_NXP)); - /* Insert command string */ - strncpy((char *)temp, PRIV_CMD_HOSTCMD, strlen(PRIV_CMD_HOSTCMD)); - temp += (strlen(PRIV_CMD_HOSTCMD)); - - memcpy(temp, (t_u8 *)cmd, *size); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)mrvl_cmd; - header = (apcmdbuf *)(buf + sizeof(mrvl_priv_cmd) + mrvl_header_len); - header->size = *size - BUF_HEADER_SIZE; - if (header->cmd_code == APCMD_SYS_CONFIGURE) { - apcmdbuf_sys_configure *sys_cfg; - sys_cfg = (apcmdbuf_sys_configure *)header; - sys_cfg->action = uap_cpu_to_le16(sys_cfg->action); - } - endian_convert_request_header(header); -#if DEBUG - /* Dump request buffer */ - hexdump("Request buffer", mrvl_cmd, - *size + sizeof(mrvl_priv_cmd) + mrvl_header_len, ' '); -#endif - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, MRVLPRIVCMD, &ifr)) { - perror(""); - printf("ERR:MRVLPRIVCMD is not supported by %s\n", dev_name); - ret = UAP_FAILURE; - goto done; - } - endian_convert_response_header(header); - header->cmd_code &= HostCmd_CMD_ID_MASK; - header->cmd_code |= APCMD_RESP_CHECK; - *size = header->size; - - /* Validate response size */ - if (*size > (buf_size - BUF_HEADER_SIZE)) { - printf("ERR:Response size (%d) greater than buffer size (%d)! Aborting!\n", *size, buf_size); - ret = UAP_FAILURE; - goto done; - } - memcpy(cmd, (t_u8 *)header, *size + BUF_HEADER_SIZE); -#if DEBUG - /* Dump respond buffer */ - hexdump("Respond buffer", mrvl_cmd, - *size + BUF_HEADER_SIZE + sizeof(mrvl_priv_cmd) + - mrvl_header_len, ' '); -#endif - -done: - /* Close socket */ - close(sockfd); - if (buf) - free(buf); - return ret; -} - -/** - * @brief Get protocol from the firmware - * - * @param proto A pointer to protocol var - * @return UAP_SUCCESS/UAP_FAILURE - */ -int -get_sys_cfg_protocol(t_u16 *proto) -{ - apcmdbuf_sys_configure *cmd_buf = NULL; - tlvbuf_protocol *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len; - int ret = UAP_FAILURE; - - cmd_len = sizeof(apcmdbuf_sys_configure) + sizeof(tlvbuf_protocol); - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return ret; - } - memset(buffer, 0, cmd_len); - /* Locate headers */ - cmd_buf = (apcmdbuf_sys_configure *)buffer; - tlv = (tlvbuf_protocol *)(buffer + sizeof(apcmdbuf_sys_configure)); - /* Fill the command buffer */ - cmd_buf->cmd_code = APCMD_SYS_CONFIGURE; - cmd_buf->size = cmd_len; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = ACTION_GET; - tlv->tag = MRVL_PROTOCOL_TLV_ID; - tlv->length = 2; - endian_convert_tlv_header_out(tlv); - /* Send the command */ - ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, cmd_len); - endian_convert_tlv_header_in(tlv); - - /* Process response */ - if (ret == UAP_SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) { - printf("ERR:Corrupted response! cmd_code=%x, Tlv->tag=%x\n", cmd_buf->cmd_code, tlv->tag); - free(buffer); - return UAP_FAILURE; - } - - if (cmd_buf->result == CMD_SUCCESS) { - tlv->protocol = uap_le16_to_cpu(tlv->protocol); - memcpy(proto, &tlv->protocol, sizeof(tlv->protocol)); - } else { - ret = UAP_FAILURE; - } - } - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Check cipher is valid or not - * - * @param pairwisecipher Pairwise cipher - * @param groupcipher Group cipher - * @param protocol Protocol - * @param enable_11n 11n enabled or not. - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_cipher_valid_with_11n(int pairwisecipher, int groupcipher, - int protocol, int enable_11n) -{ - if ((pairwisecipher == CIPHER_NONE) && (groupcipher == CIPHER_NONE)) - return UAP_SUCCESS; - if (pairwisecipher == CIPHER_TKIP) { - /* Ok to have TKIP in mixed mode */ - if (enable_11n && protocol != PROTOCOL_WPA2_MIXED) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - if ((pairwisecipher == CIPHER_TKIP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_AES_CCMP) && - (groupcipher == CIPHER_AES_CCMP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_AES_CCMP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_BITMAP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - return UAP_FAILURE; -} - -/** - * @brief Check cipher is valid or not based on proto - * - * @param pairwisecipher Pairwise cipher - * @param groupcipher Group cipher - * @param protocol Protocol - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_cipher_valid_with_proto(int pairwisecipher, int groupcipher, int protocol) -{ - HTCap_t htcap; - - if ((pairwisecipher == CIPHER_NONE) && (groupcipher == CIPHER_NONE)) - return UAP_SUCCESS; - if (pairwisecipher == CIPHER_TKIP) { - /* Ok to have TKIP in mixed mode */ - if (protocol != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0]) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - } - } - if ((pairwisecipher == CIPHER_TKIP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_AES_CCMP) && - (groupcipher == CIPHER_AES_CCMP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_AES_CCMP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_BITMAP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - return UAP_FAILURE; -} - -/** - * @brief Check cipher is valid or not - * - * @param pairwisecipher Pairwise cipher - * @param groupcipher Group cipher - * @return UAP_SUCCESS or UAP_FAILURE - */ -int -is_cipher_valid(int pairwisecipher, int groupcipher) -{ - HTCap_t htcap; - t_u16 proto = 0; - - if ((pairwisecipher == CIPHER_NONE) && (groupcipher == CIPHER_NONE)) - return UAP_SUCCESS; - if (pairwisecipher == CIPHER_TKIP) { - if (UAP_SUCCESS == get_sys_cfg_protocol(&proto)) { - /* Ok to have TKIP in mixed mode */ - if (proto != PROTOCOL_WPA2_MIXED) { - memset(&htcap, 0, sizeof(htcap)); - if (UAP_SUCCESS == get_sys_cfg_11n(&htcap)) { - if (htcap.supported_mcs_set[0]) { - printf("ERR: WPA/TKIP cannot be used when AP operates in 802.11n mode.\n"); - return UAP_FAILURE; - } - } - } - } - } - if ((pairwisecipher == CIPHER_TKIP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_AES_CCMP) && - (groupcipher == CIPHER_AES_CCMP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_AES_CCMP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - if ((pairwisecipher == CIPHER_BITMAP) && (groupcipher == CIPHER_TKIP)) - return UAP_SUCCESS; - return UAP_FAILURE; -} - -/** - * @brief The main function - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return 0 or 1 - */ -int -main(int argc, char *argv[]) -{ - int opt, i; - int ret = 0; - memset(dev_name, 0, sizeof(dev_name)); - strcpy(dev_name, DEFAULT_DEV_NAME); - - /* Parse arguments */ - while ((opt = - getopt_long(argc, argv, "+hi:d:v", ap_options, NULL)) != -1) { - switch (opt) { - case 'i': - if (strlen(optarg) < IFNAMSIZ) { - memset(dev_name, 0, sizeof(dev_name)); - strncpy(dev_name, optarg, strlen(optarg)); - } - printf("dev_name:%s\n", dev_name); - break; - case 'v': - printf("uaputl.exe - uAP utility ver %s\n", - UAP_VERSION); - exit(0); - case 'd': - debug_level = strtoul(optarg, NULL, 10); -#if DEBUG - uap_printf(MSG_DEBUG, "debug_level=%x\n", debug_level); -#endif - break; - case 'h': - default: - print_tool_usage(); - exit(0); - } - } - - argc -= optind; - argv += optind; - optind = 0; - - if (argc < 1) { - print_tool_usage(); - exit(1); - } - - /* Process command */ - for (i = 0; ap_command[i].cmd; i++) { - if (strncmp - (ap_command[i].cmd, argv[0], strlen(ap_command[i].cmd))) - continue; - if (strlen(ap_command[i].cmd) != strlen(argv[0])) - continue; - ret = ap_command[i].func(argc, argv); - break; - } - if (!ap_command[i].cmd) { - printf("ERR: %s is not supported\n", argv[0]); - exit(1); - } - if (ret == UAP_FAILURE) - return -1; - else - return 0; -} diff --git a/mxm_wifiex/wlan_src/mapp/uaputl/uaputl.h b/mxm_wifiex/wlan_src/mapp/uaputl/uaputl.h deleted file mode 100644 index 59fc729..0000000 --- a/mxm_wifiex/wlan_src/mapp/uaputl/uaputl.h +++ /dev/null @@ -1,2666 +0,0 @@ -/** @file uaputl.h - * - * @brief Header file for uaputl application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 03/01/08: Initial creation -************************************************************************/ - -#ifndef _UAP_H -#define _UAP_H - -/** uAP application version string */ -#define UAP_VERSION "4.10" - -/** Character, 1 byte */ -typedef signed char t_s8; -/** Unsigned character, 1 byte */ -typedef unsigned char t_u8; - -/** Short integer */ -typedef signed short t_s16; -/** Unsigned short integer */ -typedef unsigned short t_u16; - -/** Integer */ -typedef signed int t_s32; -/** Unsigned integer */ -typedef unsigned int t_u32; - -/** Long long integer */ -typedef signed long long t_s64; -/** Unsigned long integer */ -typedef unsigned long long t_u64; - -#if (BYTE_ORDER == LITTLE_ENDIAN) -#undef BIG_ENDIAN_SUPPORT -#endif - -/** 16 bits byte swap */ -#define swap_byte_16(x) \ - ((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \ - (((t_u16)(x) & 0xff00U) >> 8))) - -/** 32 bits byte swap */ -#define swap_byte_32(x) \ - ((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \ - (((t_u32)(x) & 0x0000ff00UL) << 8) | \ - (((t_u32)(x) & 0x00ff0000UL) >> 8) | \ - (((t_u32)(x) & 0xff000000UL) >> 24))) - -/** 64 bits byte swap */ -#define swap_byte_64(x) \ - ((t_u64)((t_u64)(((t_u64)(x) & 0x00000000000000ffULL) << 56) | \ - (t_u64)(((t_u64)(x) & 0x000000000000ff00ULL) << 40) | \ - (t_u64)(((t_u64)(x) & 0x0000000000ff0000ULL) << 24) | \ - (t_u64)(((t_u64)(x) & 0x00000000ff000000ULL) << 8) | \ - (t_u64)(((t_u64)(x) & 0x000000ff00000000ULL) >> 8) | \ - (t_u64)(((t_u64)(x) & 0x0000ff0000000000ULL) >> 24) | \ - (t_u64)(((t_u64)(x) & 0x00ff000000000000ULL) >> 40) | \ - (t_u64)(((t_u64)(x) & 0xff00000000000000ULL) >> 56) )) - -#ifdef BIG_ENDIAN_SUPPORT -/** Convert from 16 bit little endian format to CPU format */ -#define uap_le16_to_cpu(x) swap_byte_16(x) -/** Convert from 32 bit little endian format to CPU format */ -#define uap_le32_to_cpu(x) swap_byte_32(x) -/** Convert from 64 bit little endian format to CPU format */ -#define uap_le64_to_cpu(x) swap_byte_64(x) -/** Convert to 16 bit little endian format from CPU format */ -#define uap_cpu_to_le16(x) swap_byte_16(x) -/** Convert to 32 bit little endian format from CPU format */ -#define uap_cpu_to_le32(x) swap_byte_32(x) -/** Convert to 64 bit little endian format from CPU format */ -#define uap_cpu_to_le64(x) swap_byte_64(x) - -/** Convert APCMD header to little endian format from CPU format */ -#define endian_convert_request_header(x) \ - { \ - (x)->cmd_code = uap_cpu_to_le16((x)->cmd_code); \ - (x)->size = uap_cpu_to_le16((x)->size); \ - (x)->seq_num = uap_cpu_to_le16((x)->seq_num); \ - (x)->result = uap_cpu_to_le16((x)->result); \ - } - -/** Convert APCMD header from little endian format to CPU format */ -#define endian_convert_response_header(x) \ - { \ - (x)->cmd_code = uap_le16_to_cpu((x)->cmd_code); \ - (x)->size = uap_le16_to_cpu((x)->size); \ - (x)->seq_num = uap_le16_to_cpu((x)->seq_num); \ - (x)->result = uap_le16_to_cpu((x)->result); \ - } - -/** Convert TLV header to little endian format from CPU format */ -#define endian_convert_tlv_header_out(x) \ - { \ - (x)->tag = uap_cpu_to_le16((x)->tag); \ - (x)->length = uap_cpu_to_le16((x)->length); \ - } - -/** Convert TLV header from little endian format to CPU format */ -#define endian_convert_tlv_header_in(x) \ - { \ - (x)->tag = uap_le16_to_cpu((x)->tag); \ - (x)->length = uap_le16_to_cpu((x)->length); \ - } - -#else /* BIG_ENDIAN_SUPPORT */ -/** Do nothing */ -#define uap_le16_to_cpu(x) x -/** Do nothing */ -#define uap_le32_to_cpu(x) x -/** Do nothing */ -#define uap_le64_to_cpu(x) x -/** Do nothing */ -#define uap_cpu_to_le16(x) x -/** Do nothing */ -#define uap_cpu_to_le32(x) x -/** Do nothing */ -#define uap_cpu_to_le64(x) x - -/** Do nothing */ -#define endian_convert_request_header(x) -/** Do nothing */ -#define endian_convert_response_header(x) -/** Do nothing */ -#define endian_convert_tlv_header_out(x) -/** Do nothing */ -#define endian_convert_tlv_header_in(x) -#endif /* BIG_ENDIAN_SUPPORT */ - -/** MRVL private command ioctl number */ -#define MRVLPRIVCMD (SIOCDEVPRIVATE + 14) -/** Private command ID to send ioctl */ -#define UAP_IOCTL_CMD (SIOCDEVPRIVATE + 2) -/** Updating ADDBA variables */ -#define UAP_ADDBA_PARA 0 -/** Updating priority table for AMPDU/AMSDU */ -#define UAP_AGGR_PRIOTBL 1 -/** Updating addbareject table */ -#define UAP_ADDBA_REJECT 2 -/** Get FW INFO */ -#define UAP_FW_INFO 4 -/** deep sleep subcommand */ -#define UAP_DEEP_SLEEP 3 -/** Tx data pause subcommand */ -#define UAP_TX_DATA_PAUSE 5 -#ifdef SDIO -/** sdcmd52 read write subcommand */ -#define UAP_SDCMD52_RW 6 -#endif -/** snmp mib subcommand */ -#define UAP_SNMP_MIB 7 -/** domain info subcommand */ -#define UAP_DOMAIN_INFO 8 -/** dfs testing subcommand */ -#define UAP_DFS_TESTING 10 -/** TX beamforming configuration */ -#define UAP_TX_BF_CFG 9 -/** sub command ID to set/get Host Sleep configuration */ -#define UAP_HS_CFG 11 -/** sub command ID to set/get Host Sleep Parameters */ -#define UAP_HS_SET_PARA 12 - -/** Management Frame Control Mask */ -#define UAP_MGMT_FRAME_CONTROL 13 -/** Tx rate configuration */ -#define UAP_TX_RATE_CFG 14 -/** Antenna configuration */ -#define UAP_ANTENNA_CFG 15 - -#define UAP_DFS_REPEATER_MODE 16 - -#define UAP_CAC_TIMER_STATUS 17 - -/** Skip CAC */ -#define UAP_SKIP_CAC 18 - -#define UAP_HT_TX_CFG 19 - -#define UAP_VHT_CFG 20 - -#define UAP_HT_STREAM_CFG 21 - -#define UAP_OPERATION_CTRL 22 - -/** Config DFS channel switch count subcommand */ -#define UAP_CHAN_SWITCH_COUNT_CFG 23 -#define UAP_BAND_STEER 24 - -/** Private command ID to Power Mode */ -#define UAP_POWER_MODE (SIOCDEVPRIVATE + 3) - -/** Private command id to start/stop/reset bss */ -#define UAP_BSS_CTRL (SIOCDEVPRIVATE + 4) -/** BSS START */ -#define UAP_BSS_START 0 -/** BSS STOP */ -#define UAP_BSS_STOP 1 -/** BSS RESET */ -#define UAP_BSS_RESET 2 - -/** deauth station */ -#define UAP_RADIO_CTL (SIOCDEVPRIVATE + 5) - -/** Private command ID to BSS config */ -#define UAP_BSS_CONFIG (SIOCDEVPRIVATE + 6) - -/** deauth station */ -#define UAP_STA_DEAUTH (SIOCDEVPRIVATE + 7) - -/** enable UAP report mic error */ -#define UAP_REPORT_MIC_ERR (SIOCDEVPRIVATE + 8) -/** uap set key */ -#define UAP_SET_KEY (SIOCDEVPRIVATE + 9) -/** Packet inject command ioctl number */ -#define UAPHOSTPKTINJECT (SIOCDEVPRIVATE + 12) - -/** uap get station list */ -#define UAP_GET_STA_LIST (SIOCDEVPRIVATE + 11) - -/** Private command ID to set/get custom IE buffer */ -#define UAP_CUSTOM_IE (SIOCDEVPRIVATE + 13) - -/** Max IE index per BSS */ -#define MAX_MGMT_IE_INDEX 12 - -/** HS_CFG: Get flag */ -#define HS_CFG_FLAG_GET 0 -/** HS_CFG: Set flag */ -#define HS_CFG_FLAG_SET 1 -/** HS_CFG: condition flag */ -#define HS_CFG_FLAG_CONDITION 2 -/** HS_CFG: gpio flag */ -#define HS_CFG_FLAG_GPIO 4 -/** HS_CFG: gap flag */ -#define HS_CFG_FLAG_GAP 8 -/** HS_CFG: all flags */ -#define HS_CFG_FLAG_ALL 0x0f -/** HS_CFG: condition mask */ -#define HS_CFG_CONDITION_MASK 0x4f - -/** Host sleep config conditions : Cancel */ -#define HS_CFG_CANCEL 0xffffffff - -/** ds_hs_cfg */ -typedef struct _ds_hs_cfg { - /** subcmd */ - t_u32 subcmd; - /** Bit0: 0 - Get, 1 Set - * Bit1: 1 - conditions is valid - * Bit2: 2 - gpio is valid - * Bit3: 3 - gap is valid - */ - t_u32 flags; - /** Host sleep config condition */ - /** Bit0: non-unicast data - * Bit1: unicast data - * Bit2: mac events - * Bit3: magic packet - */ - t_u32 conditions; - /** GPIO */ - t_u32 gpio; - /** Gap in milliseconds */ - t_u32 gap; -} ds_hs_cfg; - -/** sleep_param */ -typedef struct _ps_sleep_param { - /** control bitmap */ - t_u32 ctrl_bitmap; - /** minimum sleep period (micro second) */ - t_u32 min_sleep; - /** maximum sleep period (micro second) */ - t_u32 max_sleep; -} ps_sleep_param; - -/** inactivity sleep_param */ -typedef struct _inact_sleep_param { - /** inactivity timeout (micro second) */ - t_u32 inactivity_to; - /** miniumu awake period (micro second) */ - t_u32 min_awake; - /** maximum awake period (micro second) */ - t_u32 max_awake; -} inact_sleep_param; - -/** flag for ps mode */ -#define PS_FLAG_PS_MODE 1 -/** flag for sleep param */ -#define PS_FLAG_SLEEP_PARAM 2 -/** flag for inactivity sleep param */ -#define PS_FLAG_INACT_SLEEP_PARAM 4 - -/** Disable power mode */ -#define PS_MODE_DISABLE 0 -/** Enable periodic dtim ps */ -#define PS_MODE_PERIODIC_DTIM 1 -/** Enable inactivity ps */ -#define PS_MODE_INACTIVITY 2 - -/** sleep parameter */ -#define SLEEP_PARAMETER 1 -/** inactivity sleep parameter */ -#define INACTIVITY_SLEEP_PARAMETER 2 - -/** sleep parameter : lower limit in micro-sec */ -#define PS_SLEEP_PARAM_MIN 5000 -/** sleep parameter : upper limit in micro-sec */ -#define PS_SLEEP_PARAM_MAX 32000 -/** power save awake period minimum value in micro-sec */ -#define PS_AWAKE_PERIOD_MIN 2000 - -/** ps_mgmt */ -typedef struct _ps_mgmt { - /** flags for valid field */ - t_u16 flags; - /** power mode */ - t_u16 ps_mode; - /** sleep param */ - ps_sleep_param sleep_param; - /** inactivity sleep param */ - inact_sleep_param inact_param; -} ps_mgmt; - -/** addba_param */ -typedef struct _addba_param { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** block ack timeout for ADDBA request */ - t_u32 timeout; - /** Buffer size for ADDBA request */ - t_u32 txwinsize; - /** Buffer size for ADDBA response */ - t_u32 rxwinsize; - /** amsdu for ADDBA request */ - t_u8 txamsdu; - /** amsdu for ADDBA response */ - t_u8 rxamsdu; -} addba_param; - -/** Default block ACK timeout */ -#define DEFAULT_BLOCK_ACK_TIMEOUT 0xFFFF - -/** Default block ACK timeout */ -#define MAX_TXRX_WINDOW_SIZE 0x3FF - -/** MAXIMUM number of TID */ -#define MAX_NUM_TID 8 - -/** aggr_prio_tbl */ -typedef struct _aggr_prio_tbl { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** ampdu priority table */ - t_u8 ampdu[MAX_NUM_TID]; - /** amsdu priority table */ - t_u8 amsdu[MAX_NUM_TID]; -} aggr_prio_tbl; - -/** addba_reject parameters */ -typedef struct _addba_reject_para { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** BA Reject paramters */ - t_u8 addba_reject[MAX_NUM_TID]; -} addba_reject_para; - -/** fw_info */ -typedef struct _fw_info { - /** subcmd */ - t_u32 subcmd; - /** Get */ - t_u32 action; - /** Firmware release number */ - t_u32 fw_release_number; - /** Device support for MIMO abstraction of MCSs */ - t_u8 hw_dev_mcs_support; - /** fw_bands*/ - t_u8 fw_bands; - /** Region Code */ - t_u16 region_code; - /** 802.11n device capabilities */ - t_u32 hw_dot_11n_dev_cap; -} fw_info; - -#ifndef ETH_ALEN -/** MAC address length */ -#define ETH_ALEN 6 -#endif - -/** BF Global Configuration */ -#define BF_GLOBAL_CONFIGURATION 0x00 -/** Performs NDP sounding for PEER specified */ -#define TRIGGER_SOUNDING_FOR_PEER 0x01 -/** TX BF interval for channel sounding */ -#define SET_GET_BF_PERIODICITY 0x02 -/** Tell FW not to perform any sounding for peer */ -#define TX_BF_FOR_PEER_ENBL 0x03 -/** TX BF SNR threshold for peer */ -#define SET_SNR_THR_PEER 0x04 - -/* Maximum number of peer MAC and status/SNR tuples */ -#define MAX_PEER_MAC_TUPLES 10 - -/** Any new subcommand structure should be declare here */ - -/** bf global cfg args */ -typedef struct _bf_global_cfg_args { - /** Global enable/disable bf */ - t_u8 bf_enbl; - /** Global enable/disable sounding */ - t_u8 sounding_enbl; - /** FB Type */ - t_u8 fb_type; - /** SNR Threshold */ - t_u8 snr_threshold; - /** Sounding interval */ - t_u16 sounding_interval; - /** BF mode */ - t_u8 bf_mode; - /** Reserved */ - t_u8 reserved; -} bf_global_cfg_args; - -/** trigger sounding args */ -typedef struct _trigger_sound_args { - /** Peer MAC address */ - t_u8 peer_mac[ETH_ALEN]; - /** Status */ - t_u8 status; -} trigger_sound_args; - -/** bf periodicity args */ -typedef struct _bf_periodicity_args { - /** Peer MAC address */ - t_u8 peer_mac[ETH_ALEN]; - /** Current Tx BF Interval */ - t_u16 interval; - /** Status */ - t_u8 status; -} bf_periodicity_args; - -/** tx bf peer args */ -typedef struct _tx_bf_peer_args { - /** Peer MAC address */ - t_u8 peer_mac[ETH_ALEN]; - /** Reserved */ - t_u16 reserved; - /** Enable/Disable Beamforming */ - t_u8 bf_enbl; - /** Enable/Disable sounding */ - t_u8 sounding_enbl; - /** FB Type */ - t_u8 fb_type; -} tx_bf_peer_args; - -typedef struct _snr_thr_args { - /** Peer MAC address */ - t_u8 peer_mac[ETH_ALEN]; - /** SNR for peer */ - t_u8 snr; -} snr_thr_args; - -/** Type definition of tx_bf_cfg */ -typedef struct _tx_bf_cfg_para { - /** Sub command */ - t_u32 subcmd; - /** Action: Set/Get - * Will be eliminatied on moal */ - t_u32 action; - /** BF command id */ - t_u16 bf_action; - /** Action Set/Get - - * this will be pssed to DNLD_CMD*/ - t_u16 bf_cmd_action; - /** Number of peers */ - t_u32 no_of_peers; - union { - bf_global_cfg_args bf_global_cfg; - trigger_sound_args bf_sound[MAX_PEER_MAC_TUPLES]; - bf_periodicity_args bf_periodicity[MAX_PEER_MAC_TUPLES]; - tx_bf_peer_args tx_bf_peer[MAX_PEER_MAC_TUPLES]; - snr_thr_args bf_snr[MAX_PEER_MAC_TUPLES]; - } body; -} tx_bf_cfg_para; - -/** skip_cac parameters */ -typedef struct _skip_cac_para { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** enable/disable deepsleep*/ - t_u16 skip_cac; -} skip_cac_para; - -/** deep_sleep parameters */ -typedef struct _deep_sleep_para { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** enable/disable deepsleep*/ - t_u16 deep_sleep; - /** idle_time */ - t_u16 idle_time; -} deep_sleep_para; -/** Default idle time for auto deep sleep */ -#define DEEP_SLEEP_IDLE_TIME 100 - -/** band_steering parameters */ -typedef struct _band_steer_para { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u8 action; - /** enable/disable band steering*/ - t_u8 state; - /** Probe Response will be blocked to 2G channel for first block_2g_prb_req probe requests*/ - t_u8 block_2g_prb_req; - /** When band steering is enabled, limit the btm request sent to STA at */ - t_u8 max_btm_req_allowed; -} band_steer_para; - -/** tx_data_pause parameters */ -typedef struct _tx_data_pause_para { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** enable/disable Tx data pause*/ - t_u16 txpause; - /** Max number of TX buffer allowed for all PS client*/ - t_u16 txbufcnt; -} tx_data_pause_para; - -/** Tx data pause disable */ -#define TX_DATA_PAUSE_DISABLE 0 -/** Tx data pause enable */ -#define TX_DATA_PAUSE_ENABLE 1 -/** Default maximum Tx buffer for all PS clients */ -#define MAX_TX_BUF_CNT 2 - -/** snmp_mib parameters */ -typedef struct _snmp_mib_param { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** oid to set/get */ - t_u16 oid; - /** length of oid value */ - t_u16 oid_val_len; - /** oid value to set/get */ - t_u8 oid_value[]; -} snmp_mib_param; - -/** domain_info parameters */ -typedef struct _domain_info_param { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** domain_param TLV (incl. header) */ - t_u8 tlv[]; -} domain_info_param; - -/** dfs_testing parameters */ -typedef struct _dfs_testing_param { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** user CAC period (msec) */ - t_u32 usr_cac_period; - /** user NOP period (sec) */ - t_u16 usr_nop_period; - /** don't change channel on radar */ - t_u8 no_chan_change; - /** fixed channel to change to on radar */ - t_u8 fixed_new_chan; -} dfs_testing_para; - -/** Channel switch count config */ -typedef struct _cscount_cfg_t { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** user channel switch count */ - t_u8 cs_count; -} cscount_cfg_t; - -/** mgmt_frame_ctrl */ -typedef struct _mgmt_frame_ctrl { - /** subcmd */ - t_u32 subcmd; - /** Set/Get */ - t_u32 action; - /** mask */ - t_u32 mask; -} mgmt_frame_ctrl; - -/* dfs repeater mode */ -typedef struct _dfs_repeater_mode { - /** subcmd */ - t_u32 subcmd; - /** set/get */ - t_u32 action; - /** mode */ - t_u32 mode; -} dfs_repeater_mode; - -/* */ -typedef struct _cac_timer_status { - /** subcmd */ - t_u32 subcmd; - /** set/get */ - t_u32 action; - /** mode */ - t_u32 mode; -} cac_timer_status; - -/** Type definition of ht_tx_cfg */ -typedef struct _ht_tx_cfg { - /** HTTxCap */ - t_u16 httxcap; - /** HTTxInfo */ - t_u16 httxinfo; -} ht_tx_cfg; - -/** Type definition of ht_tx_cfg_para */ -typedef struct _ht_tx_cfg_para { - /** Sub command */ - t_u32 subcmd; - /** Action: Set/Get - * Will be eliminatied on moal */ - t_u32 action; - /* HT Tx configuration */ - ht_tx_cfg tx_cfg; -} ht_tx_cfg_para; - -/** Default device name */ -#define DEFAULT_DEV_NAME "uap0" - -/** Success */ -#define UAP_SUCCESS 1 -/** Failure */ -#define UAP_FAILURE 0 -/** MAC BROADCAST */ -#define UAP_RET_MAC_BROADCAST 0x1FF -/** MAC MULTICAST */ -#define UAP_RET_MAC_MULTICAST 0x1FE - -/** Command is successful */ -#define CMD_SUCCESS 0 -/** Command fails */ -#define CMD_FAILURE -1 - -/** BSS start error : Invalid parameters */ -#define BSS_FAILURE_START_INVAL 2 - -/** Maximum line length for config file */ -#define MAX_LINE_LENGTH 240 -/** Maximum command length */ -#define MAX_CMD_LENGTH 100 -/** Size of command buffer */ -#define MRVDRV_SIZE_OF_CMD_BUFFER (3 * 1024) -/** Size of packet inject buffer */ -#define MRVDRV_SIZE_OF_PKT_BUFFER (1500) - -/** Maximum number of clients supported by AP */ -#define MAX_NUM_CLIENTS MAX_STA_COUNT -/** Maximum number of MAC addresses for one-shot filter modifications */ -#define MAX_MAC_ONESHOT_FILTER 64 -/** Maximum SSID length */ -#define MAX_SSID_LENGTH 32 -/** Maximum SSID length */ -#define MIN_SSID_LENGTH 1 -/** Maximum WPA passphrase length */ -#define MAX_WPA_PASSPHRASE_LENGTH 64 -/** Minimum WPA passphrase length */ -#define MIN_WPA_PASSPHRASE_LENGTH 8 -/** Maximum WPA3 SAE password length */ -#define MAX_WPA3_SAE_PASSWORD_LENGTH 255 -/** Minimum WPA3 SAE password length */ -#define MIN_WPA3_SAE_PASSWORD_LENGTH 8 -/** Maximum data rates */ -#define MAX_DATA_RATES 14 -/** Maximum length of lines in configuration file */ -#define MAX_CONFIG_LINE 240 -/** MSB bit is set if its a basic rate */ -#define BASIC_RATE_SET_BIT 0x80 -/** Maximum group key timer */ -#define MAX_GRP_TIMER 86400 -/** Maximum Retry Limit */ -#define MAX_RETRY_LIMIT 14 -/** Maximum preamble type value */ -#define MAX_PREAMBLE_TYPE 2 - -/** Maximum TX Power Limit */ -#define MAX_TX_POWER 30 -/** Minimum TX Power Limit */ -#define MIN_TX_POWER 0 - -/** Maximum channel number in bg mode */ -#define MAX_CHANNELS_BG 14 -/** Maximum channels */ -#define MAX_CHANNELS 165 -#define DEFAULT_MAX_VALID_CHANNEL_BG 11 - -/** MAX station count */ -#define MAX_STA_COUNT 64 - -/** Maximum RTS threshold */ -#define MAX_RTS_THRESHOLD 2347 - -/** Maximum fragmentation threshold */ -#define MAX_FRAG_THRESHOLD 2346 -/** Minimum fragmentation threshold */ -#define MIN_FRAG_THRESHOLD 256 - -/** Maximum stage out time */ -#define MAX_STAGE_OUT_TIME 864000 -/** Minimum stage out time */ -#define MIN_STAGE_OUT_TIME 50 - -/** Maximum DTIM period */ -#define MAX_DTIM_PERIOD 100 - -/** Maximum BEACON period */ -#define MAX_BEACON_PERIOD 4000 - -/** Minimum BEACON period */ -#define MIN_BEACON_PERIOD 50 - -/** Maximum IE buffer length */ -#define MAX_IE_BUFFER_LEN 256 - -/** Maximum custom IE count */ -#define MAX_CUSTOM_IE_COUNT 4 - -/** Maximum number of rates allowed at a time */ -#define MAX_RATES 12 - -/** Default wait period in seconds */ -#define DEFAULT_WAIT_TIME 3 - -/** Maximum valid value of Deauth reason code */ -#define MAX_DEAUTH_REASON_CODE 0xFFFF - -#ifdef __GNUC__ -/** Structure packing begins */ -#define PACK_START -/** Structure packeing end */ -#define PACK_END __attribute__ ((packed)) -#else -/** Structure packing begins */ -#define PACK_START __packed -/** Structure packeing end */ -#define PACK_END -#endif - -/** Action field value : get */ -#define ACTION_GET 0 -/** Action field value : set */ -#define ACTION_SET 1 -/** - * Hex or Decimal to Integer - * @param num string to convert into decimal or hex - */ -#define A2HEXDECIMAL(num) \ - (strncasecmp("0x", (num), 2)?(unsigned int) strtoll((num),NULL,0):a2hex((num)))\ - -/** - * Check of decimal or hex string - * @param num string - */ -#define IS_HEX_OR_DIGIT(num) \ - (strncasecmp("0x", (num), 2)?ISDIGIT((num)):ishexstring((num)))\ - -/** Find minimum value */ -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -/** Valid Input Commands */ -typedef enum { - RDEEPROM, - SCANCHANNELS, - TXPOWER, - PROTOCOL, - CHANNEL, - CHANNEL_EXT, - BAND, - RATE, - BROADCASTSSID, - RTSTHRESH, - FRAGTHRESH, - DTIMPERIOD, - RADIOCONTROL, - TXBEACONRATE, - MCBCDATARATE, - PKTFWD, - STAAGEOUTTIMER, - PSSTAAGEOUTTIMER, - AUTHMODE, - GROUPREKEYTIMER, - MAXSTANUM, - BEACONPERIOD, - RETRYLIMIT, - STICKYTIMCONFIG, - STICKYTIMSTAMACADDR, - COEX2040CONFIG, - TXRATECFG, - RSNREPLAYPROT, - PREAMBLETYPE, - EAPOL_PWK_HSK, - EAPOL_GWK_HSK, - COEX_COMM_BITMAP, - COEX_COMM_AP_COEX, - COEX_PROTECTION, - COEX_SCO_ACL_FREQ, - COEX_ACL_ENABLED, - COEX_ACL_BT_TIME, - COEX_ACL_WLAN_TIME, - PWK_CIPHER, - GWK_CIPHER, - RESTRICT_CLIENT_MODE, - AKM_SUITE, -} valid_inputs; - -/** Message verbosity level */ -enum { MSG_NONE, MSG_DEBUG, MSG_ALL }; - -/** oids_table */ -typedef struct { - /** oid type */ - t_u16 type; - /** oid len */ - t_u16 len; - /** oid name */ - char *name; -} oids_table; - -/** NXP private command identifier */ -#define CMD_NXP "MRVL_CMD" -/** NXP private command for hostcmd */ -#define PRIV_CMD_HOSTCMD "hostcmd" - -/** 4 byte header to store buf len*/ -#define BUF_HEADER_SIZE 4 - -/** TLV header length */ -#define TLVHEADER_LEN 4 - -/** AP CMD header */ -#define APCMDHEADER /** Buf Size */ \ - t_u32 buf_size; \ - /** Command Code */ \ - t_u16 cmd_code; \ - /** Size */ \ - t_u16 size; \ - /** Sequence Number */ \ - t_u16 seq_num; \ - /** Result */ \ - t_s16 result - -/** TLV header */ -#define TLVHEADER /** Tag */ \ - t_u16 tag; \ - /** Length */ \ - t_u16 length - -/* TLV Definitions */ - -/** TLV buffer header*/ -typedef PACK_START struct _tlvbuf_header { - /** Header type */ - t_u16 type; - /** Header length */ - t_u16 len; - /** Data */ - t_u8 data[]; -} PACK_END tlvbuf_header; - -/** BITMAP for ACS mode */ -#define BITMAP_ACS_MODE 0x01 - -/* Both 2.4G and 5G band selected */ -#define BAND_SELECT_BOTH 0 -/* Band 2.4G selected */ -#define BAND_SELECT_BG 1 -/* Band 5G selected */ -#define BAND_SELECT_A 2 - -/** BITMAP for secondary channel above */ -#define BITMAP_CHANNEL_ABOVE 0x02 -/** BITMAP for secondary channel below */ -#define BITMAP_CHANNEL_BELOW 0x04 -/** Channle mode mask */ -#define CHANNEL_MODE_MASK 0x07 -/** max primary channel support secondary channel above */ -#define MAX_CHANNEL_ABOVE 9 -/** Default max primary channel supporting secondary channel above when country code is not Japan */ -#define DEFAULT_MAX_CHANNEL_ABOVE 7 -/** min primary channel support secondary channel below */ -#define MIN_CHANNEL_BELOW 5 -/** Default max primary channel supporting secondary channel above when country code is not Japan and not US */ -#define DEFAULT_MAX_CHANNEL_ABOVE_NON_US 9 -/** Default max primary channel supporting secondary channel below when country code is not Japan */ -#define DEFAULT_MAX_CHANNEL_BELOW 11 -/** Default max primary channel supporting secondary channel below when country code is not Japan and not US */ -#define DEFAULT_MAX_CHANNEL_BELOW_NON_US 13 - -/** channel band */ -enum { - BAND_2GHZ = 0, - BAND_5GHZ = 1, - BAND_4GHZ = 2, -}; - -/** channel offset */ -enum { - SEC_CHAN_NONE = 0, - SEC_CHAN_ABOVE = 1, - SEC_CHAN_5MHZ = 2, - SEC_CHAN_BELOW = 3 -}; - -/** channel bandwidth */ -enum { - CHAN_BW_20MHZ = 0, - CHAN_BW_10MHZ, - CHAN_BW_40MHZ, - CHAN_BW_80MHZ, -}; - -/** scan mode */ -enum { - SCAN_MODE_MANUAL = 0, - SCAN_MODE_ACS, - SCAN_MODE_USER, -}; - -/** Band_Config_t */ -typedef PACK_START struct _Band_Config_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=user*/ - t_u8 scanMode:2; - /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ - t_u8 chan2Offset:2; - /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ - t_u8 chanWidth:2; - /** Band Info - (00)=2.4GHz, (01)=5GHz */ - t_u8 chanBand:2; -#else - /** Band Info - (00)=2.4GHz, (01)=5GHz */ - t_u8 chanBand:2; - /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ - t_u8 chanWidth:2; - /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ - t_u8 chan2Offset:2; - /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=Adoption mode*/ - t_u8 scanMode:2; -#endif -} PACK_END Band_Config_t; - -/** TLV buffer : Channel Config */ -typedef PACK_START struct _tlvbuf_channel_config { - /** Header */ - TLVHEADER; - /** Band Configuration */ - Band_Config_t bandcfg; - /** Channel number */ - t_u8 chan_number; -} PACK_END tlvbuf_channel_config; - -/** Channel List Entry */ -typedef PACK_START struct _channel_list { - /** Band Config */ - Band_Config_t bandcfg; - /** Channel Number */ - t_u8 chan_number; - /** Reserved */ - t_u8 reserved1; - /** Reserved */ - t_u16 reserved2; - /** Reserved */ - t_u16 reserved3; -} PACK_END channel_list; - -/** TLV buffer : Channel List */ -typedef PACK_START struct _tlvbuf_channel_list { - /** Header */ - TLVHEADER; - /** Channel List */ - channel_list chan_list[]; -} PACK_END tlvbuf_channel_list; - -/** TLV buffer : AP MAC address */ -typedef PACK_START struct _tlvbuf_ap_mac_address { - /** Header */ - TLVHEADER; - /** AP MAC address */ - t_u8 ap_mac_addr[ETH_ALEN]; -} PACK_END tlvbuf_ap_mac_address; - -/** TLV buffer : SSID */ -typedef PACK_START struct _tlvbuf_ssid { - /** Header */ - TLVHEADER; - /** SSID */ - t_u8 ssid[]; -} PACK_END tlvbuf_ssid; - -/** TLV buffer : Beacon period */ -typedef PACK_START struct _tlvbuf_beacon_period { - /** Header */ - TLVHEADER; - /** Beacon period */ - t_u16 beacon_period_ms; -} PACK_END tlvbuf_beacon_period; - -/** TLV buffer : DTIM period */ -typedef PACK_START struct _tlvbuf_dtim_period { - /** Header */ - TLVHEADER; - /** DTIM period */ - t_u8 dtim_period; -} PACK_END tlvbuf_dtim_period; - -/** TLV buffer : BSS status */ -typedef PACK_START struct _tlvbuf_bss_status { - /** Header */ - TLVHEADER; - /** BSS status */ - t_u16 bss_status; -} PACK_END tlvbuf_bss_status; - -/** TLV buffer : Channel */ -typedef PACK_START struct _tlvbuf_phyparamdsset { - /** Header */ - TLVHEADER; - /** Channel */ - t_u8 channel; -} PACK_END tlvbuf_phyparamdsset; - -/** TLV buffer : Operational rates */ -typedef PACK_START struct _tlvbuf_rates { - /** Header */ - TLVHEADER; - /** Operational rates */ - t_u8 operational_rates[]; -} PACK_END tlvbuf_rates; - -/** TLV buffer : Tx power */ -typedef PACK_START struct _tlvbuf_tx_power { - /** Header */ - TLVHEADER; - /** Tx power in dBm */ - t_u8 tx_power_dbm; -} PACK_END tlvbuf_tx_power; - -/** TLV buffer : SSID broadcast control */ -typedef PACK_START struct _tlvbuf_bcast_ssid_ctl { - /** Header */ - TLVHEADER; - /** SSID broadcast control flag */ - t_u8 bcast_ssid_ctl; -} PACK_END tlvbuf_bcast_ssid_ctl; - -/** TLV buffer : RSN replay protection */ -typedef PACK_START struct _tlvbuf_rsn_replay_prot { - /** Header */ - TLVHEADER; - /** RSN replay protection control flag */ - t_u8 rsn_replay_prot; -} PACK_END tlvbuf_rsn_replay_prot; - -/** TLV buffer : Preamble control */ -typedef PACK_START struct _tlvbuf_preamble_ctl { - /** Header */ - TLVHEADER; - /** Preamble type */ - t_u8 preamble_type; -} PACK_END tlvbuf_preamble_ctl; - -/** ant_cfg structure */ -typedef PACK_START struct _ant_cfg_t { - /** Subcommand */ - int subcmd; - /** Action */ - int action; - /** TX mode configured */ - int tx_mode; - /** RX mode configured */ - int rx_mode; -} PACK_END ant_cfg_t; - -/** htstream_cfg structure */ -typedef struct _htstream_cfg_t { - /** Subcommand */ - int subcmd; - /** Action */ - int action; - /** HT stream configuration */ - t_u32 stream_cfg; -} htstream_cfg_t; - -/** TLV buffer : RTS threshold */ -typedef PACK_START struct _tlvbuf_rts_threshold { - /** Header */ - TLVHEADER; - /** RTS threshold */ - t_u16 rts_threshold; -} PACK_END tlvbuf_rts_threshold; - -/** TLV buffer : Tx data rate */ -typedef PACK_START struct _tlvbuf_tx_data_rate { - /** Header */ - TLVHEADER; - /** Tx data rate */ - t_u16 tx_data_rate; -} PACK_END tlvbuf_tx_data_rate; - -/** TLV buffer : MCBC Data Rate */ -typedef PACK_START struct _tlvbuf_mcbc_data_rate { - /** Header */ - TLVHEADER; - /** MCBC data rate */ - t_u16 mcbc_datarate; -} PACK_END tlvbuf_mcbc_data_rate; - -/** Packet forwarding to be done by FW or host */ -#define PKT_FWD_FW_BIT 0x01 -/** Intra-BSS broadcast packet forwarding allow bit */ -#define PKT_FWD_INTRA_BCAST 0x02 -/** Intra-BSS unicast packet forwarding allow bit */ -#define PKT_FWD_INTRA_UCAST 0x04 -/** Inter-BSS unicast packet forwarding allow bit */ -#define PKT_FWD_INTER_UCAST 0x08 -/** TLV buffer : Packet forward control */ -typedef PACK_START struct _tlvbuf_pkt_fwd_ctl { - /** Header */ - TLVHEADER; - /** Packet forwarding control flag */ - t_u8 pkt_fwd_ctl; -} PACK_END tlvbuf_pkt_fwd_ctl; - -#ifdef SDIO -/** sdcmd52rw parameters */ -typedef struct _sdcmd52_para { - /** subcmd */ - t_u32 subcmd; - /** Write /Read */ - t_u32 action; - /** Command 52 paramters */ - t_u8 cmd52_params[3]; -} sdcmd52_para; -#endif - -/** TLV buffer : STA MAC address filtering control */ -typedef PACK_START struct _tlvbuf_sta_mac_addr_filter { - /** Header */ - TLVHEADER; - /** Filter mode */ - t_u8 filter_mode; - /** Number of STA MACs */ - t_u8 count; - /** STA MAC addresses buffer */ - t_u8 mac_address[]; -} PACK_END tlvbuf_sta_mac_addr_filter; - -/** TLV buffer : STA ageout timer */ -typedef PACK_START struct _tlvbuf_sta_ageout_timer { - /** Header */ - TLVHEADER; - /** STA ageout timer in ms */ - t_u32 sta_ageout_timer_ms; -} PACK_END tlvbuf_sta_ageout_timer; - -/** TLV buffer : PS STA ageout timer */ -typedef PACK_START struct _tlvbuf_ps_sta_ageout_timer { - /** Header */ - TLVHEADER; - /** PS STA ageout timer in ms */ - t_u32 ps_sta_ageout_timer_ms; -} PACK_END tlvbuf_ps_sta_ageout_timer; - -/** TLV buffer : max station number */ -typedef PACK_START struct _tlvbuf_max_sta_num { - /** Header */ - TLVHEADER; - /** max station number configured*/ - t_u16 max_sta_num_configured; - /** max station number supported*/ - t_u16 max_sta_num_supported; -} PACK_END tlvbuf_max_sta_num; - -/** TLV buffer : retry limit */ -typedef PACK_START struct _tlvbuf_retry_limit { - /** Header */ - TLVHEADER; - /** Retry limit */ - t_u8 retry_limit; -} PACK_END tlvbuf_retry_limit; - -/** TLV buffer : sticky tim config */ -typedef PACK_START struct _tlvbuf_sticky_tim_config { - /** Header */ - TLVHEADER; - /** Enable */ - t_u16 enable; - /** Duration */ - t_u16 duration; - /** Sticky Bitmask */ - t_u16 sticky_bitmask; -} PACK_END tlvbuf_sticky_tim_config; - -/** TLV buffer : sticky tim sta mac address */ -typedef PACK_START struct _tlvbuf_sticky_tim_sta_mac_addr { - /** Header */ - TLVHEADER; - /** Control */ - t_u16 control; - /** Station MAC address */ - t_u8 sta_mac_address[ETH_ALEN]; -} PACK_END tlvbuf_sticky_tim_sta_mac_addr; - -/** TLV buffer : 2040 coex config */ -typedef PACK_START struct _tlvbuf_2040_coex { - /** Header */ - TLVHEADER; - /** Enable */ - t_u8 enable; -} PACK_END tlvbuf_2040_coex; - -/** TLV buffer : pairwise key handshake timeout */ -typedef PACK_START struct _tlvbuf_eapol_pwk_hsk_timeout { - /** Header */ - TLVHEADER; - /** pairwise update timeout in milliseconds */ - t_u32 pairwise_update_timeout; -} PACK_END tlvbuf_eapol_pwk_hsk_timeout; - -/** TLV buffer : pairwise key handshake number of retries */ -typedef PACK_START struct _tlvbuf_eapol_pwk_hsk_retries { - /** Header */ - TLVHEADER; - /** pairwise key retries */ - t_u32 pwk_retries; -} PACK_END tlvbuf_eapol_pwk_hsk_retries; - -/** TLV buffer : groupwise key handshake timeout */ -typedef PACK_START struct _tlvbuf_eapol_gwk_hsk_timeout { - /** Header */ - TLVHEADER; - /** groupwise update timeout in milliseconds */ - t_u32 groupwise_update_timeout; -} PACK_END tlvbuf_eapol_gwk_hsk_timeout; - -/** TLV buffer : groupwise key handshake number of retries */ -typedef PACK_START struct _tlvbuf_eapol_gwk_hsk_retries { - /** Header */ - TLVHEADER; - /** groupwise key retries */ - t_u32 gwk_retries; -} PACK_END tlvbuf_eapol_gwk_hsk_retries; - -/** custom IE */ -typedef PACK_START struct _custom_ie { - /** IE Index */ - t_u16 ie_index; - /** Mgmt Subtype Mask */ - t_u16 mgmt_subtype_mask; - /** IE Length */ - t_u16 ie_length; - /** IE buffer */ - t_u8 ie_buffer[]; -} PACK_END custom_ie; - -/** TLV buffer : custom IE */ -typedef PACK_START struct _tlvbuf_custom_ie { - /** Header */ - TLVHEADER; - /** custom IE data */ - custom_ie ie_data[]; -} PACK_END tlvbuf_custom_ie; - -/** custom IE info */ -typedef PACK_START struct _custom_ie_info { - /** size of buffer */ - t_u16 buf_size; - /** no of buffers of buf_size */ - t_u16 buf_count; -} PACK_END custom_ie_info; - -/** TLV buffer : custom IE */ -typedef PACK_START struct _tlvbuf_max_mgmt_ie { - /** Header */ - TLVHEADER; - /** No of tuples */ - t_u16 count; - /** custom IE info tuples */ - custom_ie_info info[]; -} PACK_END tlvbuf_max_mgmt_ie; - -/* Bitmap for protocol to use */ -/** No security */ -#define PROTOCOL_NO_SECURITY 1 -/** Static WEP */ -#define PROTOCOL_STATIC_WEP 2 -/** WPA */ -#define PROTOCOL_WPA 8 -/** WPA2 */ -#define PROTOCOL_WPA2 32 -/** WP2 Mixed */ -#define PROTOCOL_WPA2_MIXED 40 -/** WPA3 SAE */ -#define PROTOCOL_WPA3_SAE 0x100 -/* Bitmap for unicast/bcast cipher type */ -/** None */ -#define CIPHER_NONE 0 -/** WEP 40 */ -#define CIPHER_WEP_40 1 -/** WEP 104 */ -#define CIPHER_WEP_104 2 -/** TKIP */ -#define CIPHER_TKIP 4 -/** AES CCMP */ -#define CIPHER_AES_CCMP 8 -/** Valid cipher bitmap */ -#define CIPHER_BITMAP 0x0c -/** Valid protocol bitmap */ -#define PROTOCOL_BITMAP 0x3E8 -/** AES CCMP + TKIP cipher */ -#define AES_CCMP_TKIP 12 - -/** TLV buffer : Authentication Mode */ -typedef PACK_START struct _tlvbuf_auth_mode { - /** Header */ - TLVHEADER; - /** Authentication Mode */ - t_u8 auth_mode; -} PACK_END tlvbuf_auth_mode; - -/** TLV buffer : Security Protocol */ -typedef PACK_START struct _tlvbuf_protocol { - /** Header */ - TLVHEADER; - /** Security protocol */ - t_u16 protocol; -} PACK_END tlvbuf_protocol; - -/** TLV buffer : cipher */ -typedef PACK_START struct _tlvbuf_cipher { - /** Header */ - TLVHEADER; - /** Pairwise cipher */ - t_u8 pairwise_cipher; - /** Group cipher */ - t_u8 group_cipher; -} PACK_END tlvbuf_cipher; - -/** TLV buffer : Pairwise cipher */ -typedef PACK_START struct _tlvbuf_pwk_cipher { - /** Header */ - TLVHEADER; - /** Protocol */ - t_u16 protocol; - /** Pairwise cipher */ - t_u8 pairwise_cipher; - /** Reserved */ - t_u8 reserved; -} PACK_END tlvbuf_pwk_cipher; - -/** TLV buffer : Group cipher */ -typedef PACK_START struct _tlvbuf_gwk_cipher { - /** Header */ - TLVHEADER; - /** Group cipher */ - t_u8 group_cipher; - /** Reserved*/ - t_u8 reserved; -} PACK_END tlvbuf_gwk_cipher; - -/** TLV buffer : Group re-key time */ -typedef PACK_START struct _tlvbuf_group_rekey_timer { - /** Header */ - TLVHEADER; - /** Group rekey time in seconds */ - t_u32 group_rekey_time_sec; -} PACK_END tlvbuf_group_rekey_timer; - -/** Key_mgmt_none */ -#define KEY_MGMT_NONE 0x04 -/** Key_mgmt_psk */ -#define KEY_MGMT_PSK 0x02 -/** Key_mgmt_sae */ -#define KEY_MGMT_SAE 0x400 -/** Key_mgmt_eap */ -#define KEY_MGMT_EAP 0x01 -/** Key_mgmt_psk_sha256 */ -#define KEY_MGMT_PSK_SHA256 0X100 - -/** Wmm Max AC queues */ -#define MAX_AC_QUEUES 4 - -/** TLV buffer : KeyMgmt */ -typedef PACK_START struct _tlvbuf_akmp { - /** Header */ - TLVHEADER; - /** KeyMgmt */ - t_u16 key_mgmt; - /** key management operation */ - t_u16 key_mgmt_operation; -} PACK_END tlvbuf_akmp; - -/** TLV buffer : Single WEP key */ -typedef PACK_START struct _tlvbuf_wep_key { - /** Header */ - TLVHEADER; - /** Key index */ - t_u8 key_index; - /** Default key flag */ - t_u8 is_default; - /** Key */ - t_u8 key[]; -} PACK_END tlvbuf_wep_key; - -/** TLV buffer : WPA passphrase */ -typedef PACK_START struct _tlvbuf_wpa_passphrase { - /** Header */ - TLVHEADER; - /** WPA passphrase */ - t_u8 passphrase[]; -} PACK_END tlvbuf_wpa_passphrase; - -/** TLV buffer : WPA3 SAE password */ -typedef PACK_START struct _tlvbuf_wpa3_sae_password { - /** Header */ - TLVHEADER; - /** WPA3 SAE password */ - t_u8 password[]; -} PACK_END tlvbuf_wpa3_sae_password; - -/** TLV buffer : Fragmentation threshold */ -typedef PACK_START struct _tlvbuf_frag_threshold { - /** Header */ - TLVHEADER; - /** Fragmentation threshold */ - t_u16 frag_threshold; -} PACK_END tlvbuf_frag_threshold; - -/** MRVL private CMD structure */ -typedef PACK_START struct _mrvl_priv_cmd { - /** Command buffer */ - t_u8 *buf; - /** Used length */ - t_u32 used_len; - /** Total length */ - t_u32 total_len; -} PACK_END mrvl_priv_cmd; - -/* APCMD definitions */ -/** APCMD buffer */ -typedef PACK_START struct _apcmdbuf { - /** Header */ - APCMDHEADER; -} PACK_END apcmdbuf; - -/** APCMD header length */ -#define APCMDHEADERLEN (sizeof(apcmdbuf)) - -/** APCMD buffer : sys_info request */ -typedef PACK_START struct _apcmdbuf_sys_info_request { - /** Header */ - APCMDHEADER; -} PACK_END apcmdbuf_sys_info_request; - -/** APCMD buffer : sys_info response */ -typedef PACK_START struct _apcmdbuf_sys_info_response { - /** Header */ - APCMDHEADER; - /** System information buffer */ - t_u8 sys_info[64]; -} PACK_END apcmdbuf_sys_info_response; - -/** APCMD buffer : sys_reset */ -typedef PACK_START struct _apcmdbuf_sys_reset { - /** Header */ - APCMDHEADER; -} PACK_END apcmdbuf_sys_reset; - -/** APCMD buffer : sys_configure */ -typedef PACK_START struct _apcmdbuf_sys_configure { - /** Header */ - APCMDHEADER; - /** Action : GET or SET */ - t_u16 action; -} PACK_END apcmdbuf_sys_configure; - -/* Max transmit power for indoor operation */ -#define MAX_TX_PWR_INDOOR 17 - -/** APCMD buffer : SNMP MIB */ -typedef PACK_START struct _apcmdbuf_snmp_mib { - /** Header */ - APCMDHEADER; - /** Action : GET or SET */ - t_u16 action; -} PACK_END apcmdbuf_snmp_mib; -/** APCMD buffer : bss_start */ -typedef PACK_START struct _apcmdbuf_bss_start { - /** Header */ - APCMDHEADER; -} PACK_END apcmdbuf_bss_start; - -/** APCMD buffer : bss_stop */ -typedef PACK_START struct _apcmdbuf_bss_stop { - /** Header */ - APCMDHEADER; -} PACK_END apcmdbuf_bss_stop; - -/** APCMD buffer : sta_deauth */ -typedef PACK_START struct _APCMDBUF_STA_DEAUTH { - /** Header */ - APCMDHEADER; - /** STA MAC address to deauthenticate */ - t_u8 sta_mac_address[ETH_ALEN]; -} PACK_END APCMDBUF_STA_DEAUTH; - -/** Reg TYPE*/ -enum reg_commands { - CMD_MAC = 1, - CMD_BBP, - CMD_RF -}; - -/** APCMD buffer: Regrdwr */ -typedef PACK_START struct _apcmdbuf_reg_rdwr { - /** Header */ - APCMDHEADER; - /** Read or Write */ - t_u16 action; - /** Register offset */ - t_u16 offset; - /** Value */ - t_u32 value; -} PACK_END apcmdbuf_reg_rdwr; - -/** DOMAIN_CODEs for DFS regions */ -enum { - DOMAIN_CODE_FCC = 0x01, - DOMAIN_CODE_ETSI, - DOMAIN_CODE_MKK, - DOMAIN_CODE_IN, - DOMAIN_CODE_MY, -}; - -/** Region Domain Code */ -typedef PACK_START struct _rgn_dom_code { - /** Header */ - TLVHEADER; - /** Domain Code */ - t_u8 domain_code; - /** Reserved field */ - t_u8 reserved; -} PACK_END rgn_dom_code_t; - -/** sub-band type */ -typedef PACK_START struct _ieeetypes_subband_set { - t_u8 first_chan; /**< First channel */ - t_u8 no_of_chan; /**< Number of channels */ - t_u8 max_tx_pwr; /**< Maximum Tx power */ -} PACK_END ieeetypes_subband_set_t; - -/** country code length used for 802.11D */ -#define COUNTRY_CODE_LEN 3 - -/** MAX domain SUB-BAND*/ -#define MAX_SUB_BANDS 40 - -/** Max Multi Domain Entries for G */ -#define MAX_MULTI_DOMAIN_CAPABILITY_ENTRY_G 1 - -/** Max Multi Domain Entries for A */ -#define MAX_MULTI_DOMAIN_CAPABILITY_ENTRY_A 31 - -/** Country code and Sub-band */ -typedef PACK_START struct domain_param { - /** Header */ - TLVHEADER; - t_u8 country_code[COUNTRY_CODE_LEN]; /**< Country code */ - ieeetypes_subband_set_t subband[]; /**< Set of subbands */ -} PACK_END domain_param_t; - -/** HostCmd_CFG_80211D */ -typedef PACK_START struct _apcmdbuf_cfg_80211d { - /** Header */ - APCMDHEADER; - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - /** Domain parameters */ - domain_param_t domain; -} PACK_END apcmdbuf_cfg_80211d; - -/** HostCmd_MEM_ACCESS */ -typedef PACK_START struct _apcmdbuf_mem_access { - /** Header */ - APCMDHEADER; - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - /** Reserved field */ - t_u16 reserved; - /** Address */ - t_u32 address; - /** Value */ - t_u32 value; -} PACK_END apcmdbuf_mem_access; - -/** HostCmd_EEPROM_ACCESS */ -typedef PACK_START struct _apcmdbuf_eeprom_access { - /** Header */ - APCMDHEADER; - /** Action */ - t_u16 action; /* 0 = ACT_GET; */ - /** Offset field */ - t_u16 offset; /* Multiples of 4 */ - /** Byte count */ - t_u16 byte_count; /* Multiples of 4 */ - /** Value */ - t_u8 value[1]; -} PACK_END apcmdbuf_eeprom_access; - -/** TLV : BT Coex common configuration */ -typedef PACK_START struct _tlvbuf_coex_common_cfg { - /** Header */ - TLVHEADER; - /** Configuration bitmap */ - t_u32 config_bitmap; - /** AP Bt Coex Enabled or not */ - t_u32 ap_bt_coex; - /** Reserved */ - t_u32 reserved[3]; -} PACK_END tlvbuf_coex_common_cfg; - -/** TLV : BT Coex SCO configuration */ -typedef PACK_START struct _tlvbuf_coex_sco_cfg { - /** Header */ - TLVHEADER; - /** Qtime protection */ - t_u16 protection_qtime[4]; - /** Rate protection */ - t_u16 protection_rate; - /** ACL frequency */ - t_u16 acl_frequency; - /** Reserved */ - t_u32 reserved[4]; -} PACK_END tlvbuf_coex_sco_cfg; - -/** TLV : BT Coex ACL configuration */ -typedef PACK_START struct _tlvbuf_coex_acl_cfg { - /** Header */ - TLVHEADER; - /** Enabled or not */ - t_u16 enabled; - /** BT time */ - t_u16 bt_time; - /** Wlan time */ - t_u16 wlan_time; - /** Rate protection */ - t_u16 protection_rate; - /** Reserved */ - t_u32 reserved[4]; -} PACK_END tlvbuf_coex_acl_cfg; - -/** TLV : BT Coex statistics */ -typedef PACK_START struct _tlvbuf_coex_stats { - /** Header */ - TLVHEADER; - /** Null not sent */ - t_u32 null_not_sent; - /** Null queued */ - t_u32 null_queued; - /** Null not queued */ - t_u32 null_not_queued; - /** CF end queued */ - t_u32 cf_end_queued; - /** CF end not queued */ - t_u32 cf_end_not_queued; - /** Null allocation failures */ - t_u32 null_alloc_fail; - /** CF end allocation failures */ - t_u32 cf_end_alloc_fail; - /** Reserved */ - t_u32 reserved[8]; -} PACK_END tlvbuf_coex_stats; - -/** APCMD buffer : BT Coex API extension */ -typedef PACK_START struct _apcmdbuf_coex_config { - /** Header */ - APCMDHEADER; - /** Action : GET or SET */ - t_u16 action; - /** Reserved for alignment */ - t_u16 coex_reserved; - /** TLV buffer */ - t_u8 tlv_buffer[]; -} PACK_END apcmdbuf_coex_config; - -/** BIT value */ -#define MBIT(x) (((t_u32)1) << (x)) -/** RadioType : Support for 40Mhz channel BW */ -#define IS_CHANNEL_WIDTH_40(Field2) (Field2 & MBIT(2)) -/** RadioType : Get secondary channel */ -#define GET_SECONDARY_CHAN(Field2) (Field2 & (MBIT(0) | MBIT(1))) -/** RadioType : Is RIFS allowed */ -#define IS_RIFS_ALLOWED(Field2) (Field2 & MBIT(3)) -/** RadioType : Get HT Protection */ -#define GET_HT_PROTECTION(Field3) (Field3 & (MBIT(0) | MBIT(1))) -/** RadioType : Are Non-GreenField STAs present */ -#define NONGF_STA_PRESENT(Field3) (Field3 & MBIT(2)) -/** RadioType : Are OBSS Non-HT STAs present */ -#define OBSS_NONHT_STA_PRESENT(Field3) (Field3 & MBIT(4)) - -/** HT Capabilities Data */ -typedef struct PACK_START _HTCap_t { - /** HT Capabilities Info field */ - t_u16 ht_cap_info; - /** A-MPDU Parameters field */ - t_u8 ampdu_param; - /** Supported MCS Set field */ - t_u8 supported_mcs_set[16]; - /** HT Extended Capabilities field */ - t_u16 ht_ext_cap; - /** Transmit Beamforming Capabilities field */ - t_u32 tx_bf_cap; - /** Antenna Selection Capability field */ - t_u8 asel; -} PACK_END HTCap_t, *pHTCap_t; - -/** HT Information Data */ -typedef struct PACK_START _HTInfo_t { - /** Primary channel */ - t_u8 pri_chan; - /** Field 2 */ - t_u8 field2; - /** Field 3 */ - t_u16 field3; - /** Field 4 */ - t_u16 field4; - /** Bitmap indicating MCSs supported by all HT STAs in the BSS */ - t_u8 basic_mcs_set[16]; -} PACK_END HTInfo_t, *pHTInfo_t; - -/** MLAN 802.11 MAC Address */ -typedef t_u8 mlan_802_11_mac_addr[ETH_ALEN]; - -/** mlan_802_11_ssid data structure */ -typedef struct _mlan_802_11_ssid { - /** SSID Length */ - t_u32 ssid_len; - /** SSID information field */ - t_u8 ssid[MAX_SSID_LENGTH]; -} mlan_802_11_ssid; - -/** scan_chan_list data structure */ -typedef struct _scan_chan_list { - /** Channel number*/ - t_u8 chan_number; - /** Band config type */ - Band_Config_t bandcfg; -} scan_chan_list; - -/** mac_filter data structure */ -typedef struct _mac_filter { - /** Mac filter mode */ - t_u16 filter_mode; - /** Mac adress count */ - t_u16 mac_count; - /** Mac address list */ - mlan_802_11_mac_addr mac_list[MAX_MAC_ONESHOT_FILTER]; -} mac_filter; - -/** Data structure of WMM Aci/Aifsn */ -typedef PACK_START struct _IEEEtypes_WmmAciAifsn_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Reserved */ - t_u8 reserved:1; - /** Aci */ - t_u8 aci:2; - /** Acm */ - t_u8 acm:1; - /** Aifsn */ - t_u8 aifsn:4; -#else - /** Aifsn */ - t_u8 aifsn:4; - /** Acm */ - t_u8 acm:1; - /** Aci */ - t_u8 aci:2; - /** Reserved */ - t_u8 reserved:1; -#endif /* BIG_ENDIAN_SUPPORT */ -} PACK_END IEEEtypes_WmmAciAifsn_t, *pIEEEtypes_WmmAciAifsn_t; - -/** Data structure of WMM ECW */ -typedef PACK_START struct _IEEEtypes_WmmEcw_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Maximum Ecw */ - t_u8 ecw_max:4; - /** Minimum Ecw */ - t_u8 ecw_min:4; -#else - /** Minimum Ecw */ - t_u8 ecw_min:4; - /** Maximum Ecw */ - t_u8 ecw_max:4; -#endif /* BIG_ENDIAN_SUPPORT */ -} PACK_END IEEEtypes_WmmEcw_t, *pIEEEtypes_WmmEcw_t; - -/** Data structure of WMM AC parameters */ -typedef PACK_START struct _IEEEtypes_WmmAcParameters_t { - IEEEtypes_WmmAciAifsn_t aci_aifsn; /**< AciAifSn */ - IEEEtypes_WmmEcw_t ecw; /**< Ecw */ - t_u16 tx_op_limit; /**< Tx op limit */ -} PACK_END IEEEtypes_WmmAcParameters_t, *pIEEEtypes_WmmAcParameters_t; - -/** Data structure of WMM parameter IE */ -typedef PACK_START struct _WmmParameter_t { - /** OuiType: 00:50:f2:02 */ - t_u8 ouitype[4]; - /** Oui subtype: 01 */ - t_u8 ouisubtype; - /** version: 01 */ - t_u8 version; - /** QoS information */ - t_u8 qos_info; - /** Reserved */ - t_u8 reserved; - /** AC Parameters Record WMM_AC_BE, WMM_AC_BK, WMM_AC_VI, WMM_AC_VO */ - IEEEtypes_WmmAcParameters_t ac_params[MAX_AC_QUEUES]; -} PACK_END WmmParameter_t, *pWmmParameter_t; - -/** wpa parameter */ -typedef struct _wpa_param { - /** Pairwise cipher WPA */ - t_u8 pairwise_cipher_wpa; - /** Pairwise cipher WPA2 */ - t_u8 pairwise_cipher_wpa2; - /** Group cipher */ - t_u8 group_cipher; - /** RSN replay protection */ - t_u8 rsn_protection; - /** Passphrase length */ - t_u32 length; - /** Passphrase */ - t_u8 passphrase[64]; - /** Group key rekey time */ - t_u32 gk_rekey_time; -} wpa_param; - -/** wep key */ -typedef struct _wep_key { - /** Key index 0-3 */ - t_u8 key_index; - /** Is default */ - t_u8 is_default; - /** Length */ - t_u16 length; - /** Key data */ - t_u8 key[26]; -} wep_key; - -/** wep param */ -typedef struct _wep_param { - /** Key 0 */ - wep_key key0; - /** Key 1 */ - wep_key key1; - /** Key 2 */ - wep_key key2; - /** Key 3 */ - wep_key key3; -} wep_param; - -/** BSS config structure */ -typedef struct _bss_config_t { - /** AP mac addr */ - mlan_802_11_mac_addr mac_addr; - /** SSID */ - mlan_802_11_ssid ssid; - /** Broadcast ssid control */ - t_u8 bcast_ssid_ctl; - /** Radio control: on/off */ - t_u8 radio_ctl; - /** dtim period */ - t_u8 dtim_period; - /** beacon period */ - t_u16 beacon_period; - /** rates */ - t_u8 rates[MAX_DATA_RATES]; - /** Tx data rate */ - t_u16 tx_data_rate; - /** Tx beacon rate */ - t_u16 tx_beacon_rate; - /** multicast/broadcast data rate */ - t_u16 mcbc_data_rate; - /** Tx power level */ - t_u8 tx_power_level; - /** Tx antenna */ - t_u8 tx_antenna; - /** Rx anteena */ - t_u8 rx_antenna; - /** packet forward control */ - t_u8 pkt_forward_ctl; - /** max station count */ - t_u16 max_sta_count; - /** mac filter */ - mac_filter filter; - /** station ageout timer in the unit of 100ms */ - t_u32 sta_ageout_timer; - /** PS station ageout timer in the unit of 100ms */ - t_u32 ps_sta_ageout_timer; - /** RTS threshold */ - t_u16 rts_threshold; - /** fragmentation threshold */ - t_u16 frag_threshold; - /** retry_limit */ - t_u16 retry_limit; - /** pairwise update timeout in milliseconds */ - t_u32 pairwise_update_timeout; - /** pairwise handshake retries */ - t_u32 pwk_retries; - /** groupwise update timeout in milliseconds */ - t_u32 groupwise_update_timeout; - /** groupwise handshake retries */ - t_u32 gwk_retries; - /** preamble type */ - t_u8 preamble_type; - /** band cfg */ - Band_Config_t bandcfg; - /** channel */ - t_u8 channel; - /** auth mode */ - t_u16 auth_mode; - /** encryption protocol */ - t_u16 protocol; - /** key managment type */ - t_u16 key_mgmt; - /** wep param */ - wep_param wep_cfg; - /** wpa param */ - wpa_param wpa_cfg; - /** Mgmt IE passthru mask */ - t_u32 mgmt_ie_passthru_mask; - /* - * 11n HT Cap - */ - /** HT Capabilities Info field */ - t_u16 ht_cap_info; - /** A-MPDU Parameters field */ - t_u8 ampdu_param; - /** Supported MCS Set field */ - t_u8 supported_mcs_set[16]; - /** HT Extended Capabilities field */ - t_u16 ht_ext_cap; - /** Transmit Beamforming Capabilities field */ - t_u32 tx_bf_cap; - /** Antenna Selection Capability field */ - t_u8 asel; - /** Enable 20/40 coex */ - t_u8 enable_2040coex; - /** key managment operation */ - t_u16 key_mgmt_operation; - /** BSS status */ - t_u16 bss_status; -#ifdef WIFI_DIRECT_SUPPORT - /* pre shared key */ - t_u8 psk[32]; -#endif /* WIFI_DIRECT_SUPPORT */ - /** Number of channels in scan_channel_list */ - t_u32 num_of_chan; - /** scan channel list in ACS mode */ - scan_chan_list chan_list[MAX_CHANNELS]; - /** Wmm parameters */ - WmmParameter_t wmm_para; -} bss_config_t; - -/** Enumeration for band */ -enum _mlan_band_def { - BAND_B = 1, - BAND_G = 2, - BAND_A = 4, - BAND_GN = 8, - BAND_AN = 16, - BAND_GAC = 32, - BAND_AAC = 64, - BAND_GAX = 256, - BAND_AAX = 512, -}; - -/** station stats */ -typedef struct _sta_stats { - t_u64 last_rx_in_msec; -} sta_stats; - -/** station info */ -typedef struct _sta_info { - /** STA MAC address */ - t_u8 mac_address[ETH_ALEN]; - /** Power mgmt status */ - t_u8 power_mgmt_status; - /** RSSI */ - t_s8 rssi; - /** station bandmode */ - t_u16 bandmode; - /** station stats */ - sta_stats stats; - /** ie length */ - t_u16 ie_len; - /** ie buffer */ - t_u8 ie_buf[]; -} sta_info; - -/** sta_list structure */ -typedef struct _sta_list { - /** station count */ - t_u16 sta_count; - /** station list */ - sta_info info[MAX_NUM_CLIENTS]; -} sta_list; - -/** mlan_deauth_param */ -typedef struct _deauth_param { - /** STA mac addr */ - t_u8 mac_addr[ETH_ALEN]; - /** deauth reason */ - t_u16 reason_code; -} deauth_param; - -#define MAX_KEY_LENGTH 32 -/** encrypt key */ -typedef struct _encrypt_key { - /** Key index */ - t_u32 key_index; - /** Key length */ - t_u32 key_len; - /** Key */ - t_u8 key_material[MAX_KEY_LENGTH]; - /** mac address */ - t_u8 mac_addr[ETH_ALEN]; -} encrypt_key; - -/** injected pkt_header */ -typedef struct _pkt_header { - /** pkt_len */ - t_u32 pkt_len; - /** pkt_type */ - t_u32 tx_pkt_type; - /** tx control */ - t_u32 tx_control; -} pkt_header; - -/** APCMD buffer : bss_configure */ -typedef PACK_START struct _apcmdbuf_bss_configure { - /** Action : GET or SET */ - t_u32 action; -} PACK_END apcmdbuf_bss_configure; - -/** Max EEPROM length */ -#define MAX_EEPROM_LEN 20 - -/** Channel scan entry for each channel */ -typedef PACK_START struct _channel_scan_entry_t { - /** Channel Number */ - t_u8 chan_num; - /** Number of APs */ - t_u8 num_of_aps; - /** CCA count */ - t_u32 cca_count; - /** Duration */ - t_u32 duration; - /** Channel weight */ - t_u32 channel_weight; -} PACK_END channel_scan_entry_t; - -/** Channel scan entry */ -typedef PACK_START struct _channel_scan_entry { - /** Number of channels */ - t_u8 num_channels; - /** Channel scan entry */ - channel_scan_entry_t cst[]; -} PACK_END channel_scan_entry; - -/** HostCmd_CFG_DATA */ -typedef PACK_START struct _apcmdbuf_cfg_data { - /** Header */ - APCMDHEADER; - /** Action */ - t_u16 action; - /** Type */ - t_u16 type; - /** Data length */ - t_u16 data_len; - /** Data */ - t_u8 data[]; -} PACK_END apcmdbuf_cfg_data; - -/** Maximum size of set/get configurations */ -#define MAX_CFG_DATA_SIZE 3000 /* less than MRVDRV_SIZE_OF_CMD_BUFFER */ - -/** HostCmd_CMD_PMF_PARAMS */ -typedef PACK_START struct _apcmdbuf_pmf_params { - /** Header */ - APCMDHEADER; - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - /** Params */ - PACK_START struct { - t_u8 mfpc:1; /* capable bit */ - t_u8 mfpr:1; /* required bit */ - t_u8 rsvd:6; - } PACK_END params; -} PACK_END apcmdbuf_pmf_params; - -/** Host Command ID bit mask (bit 11:0) */ -#define HostCmd_CMD_ID_MASK 0x0fff -/** APCMD response check */ -#define APCMD_RESP_CHECK 0x8000 - -/* AP CMD IDs */ -/** APCMD : sys_info */ -#define APCMD_SYS_INFO 0x00ae -/** APCMD : sys_reset */ -#define APCMD_SYS_RESET 0x00af -/** APCMD : sys_configure */ -#define APCMD_SYS_CONFIGURE 0x00b0 -/** APCMD : bss_start */ -#define APCMD_BSS_START 0x00b1 -/** APCMD : bss_stop */ -#define APCMD_BSS_STOP 0x00b2 -/** APCMD : sta_list */ -#define APCMD_STA_LIST 0x00b3 -/** APCMD : sta_deauth */ -#define APCMD_STA_DEAUTH 0x00b5 -/** SNMP MIB SET/GET */ -#define HostCmd_SNMP_MIB 0x0016 -/** Read/Write Mac register */ -#define HostCmd_CMD_MAC_REG_ACCESS 0x0019 -/** Read/Write BBP register */ -#define HostCmd_CMD_BBP_REG_ACCESS 0x001a -/** Read/Write RF register */ -#define HostCmd_CMD_RF_REG_ACCESS 0x001b -/** Host Command ID : EEPROM access */ -#define HostCmd_EEPROM_ACCESS 0x0059 -/** Host Command ID : Memory access */ -#define HostCmd_CMD_MEM_ACCESS 0x0086 -/** Host Command ID : 802.11D configuration */ -#define HostCmd_CMD_802_11D_DOMAIN_INFO 0x005b -/** Host Command ID : Configuration data */ -#define HostCmd_CMD_CFG_DATA 0x008f - -/** Oid for 802.11D enable/disable */ -#define OID_80211D_ENABLE 0x0009 -/** Oid for 802.11H enable/disable */ -#define OID_80211H_ENABLE 0x000a - -/** Host Command ID: ROBUST_COEX */ -#define HostCmd_ROBUST_COEX 0x00e0 - -/** Host Command ID: PMF_PARAMS */ -#define HostCmd_CMD_PMF_PARAMS 0x0131 - -/* TLV IDs */ -/** TLV : Base */ -#define PROPRIETARY_TLV_BASE_ID 0x0100 - -/** TLV : SSID */ -#define MRVL_SSID_TLV_ID 0x0000 -/** TLV : Operational rates */ -#define MRVL_RATES_TLV_ID 0x0001 -/** TLV : Channel */ -#define MRVL_PHYPARAMDSSET_TLV_ID 0x0003 -/**TLV: Domain type */ -#define TLV_TYPE_DOMAIN 0x0007 - -/** TLV type : Scan Channels list */ -#define MRVL_CHANNELLIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x01) //0x0101 -/** TLV type : Authentication type */ -#define MRVL_AUTH_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x1f) //0x011f -/** TLV Id : Channel Config */ -#define MRVL_CHANNELCONFIG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2a) //0x012a -/** TLV : AP MAC address */ -#define MRVL_AP_MAC_ADDRESS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2b) //0x012b -/** TLV : Beacon period */ -#define MRVL_BEACON_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2c) //0x012c -/** TLV : DTIM period */ -#define MRVL_DTIM_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2d) //0x012d -/** TLV : Tx power */ -#define MRVL_TX_POWER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x2f) //0x012f -/** TLV : SSID broadcast control */ -#define MRVL_BCAST_SSID_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x30) //0x0130 -/** TLV : Preamble control */ -#define MRVL_PREAMBLE_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x31) //0x0131 -/** TLV : RTS threshold */ -#define MRVL_RTS_THRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x33) //0x0133 -/** TLV : Packet forwarding control */ -#define MRVL_PKT_FWD_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x36) //0x0136 -/** TLV : STA information */ -#define MRVL_STA_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x37) //0x0137 -/** TLV : STA MAC address filter */ -#define MRVL_STA_MAC_ADDR_FILTER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x38) //0x0138 -/** TLV : STA ageout timer */ -#define MRVL_STA_AGEOUT_TIMER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x39) //0x0139 -/** TLV : WEP keys */ -#define MRVL_WEP_KEY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3b) //0x013b -/** TLV : WPA passphrase */ -#define MRVL_WPA_PASSPHRASE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x3c) //0x013c -/** TLV : WPA3 SAE password */ -#define MRVL_WPA3_SAE_PASSWORD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x141) //0x0241 -/** TLV type : protocol TLV */ -#define MRVL_PROTOCOL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x40) //0x0140 -/** TLV type : AKMP TLV */ -#define MRVL_AKMP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x41) //0x0141 -/** TLV type : Cipher TLV */ -#define MRVL_CIPHER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x42) //0x0142 -/** TLV : Fragment threshold */ -#define MRVL_FRAG_THRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x46) //0x0146 -/** TLV : Group rekey timer */ -#define MRVL_GRP_REKEY_TIME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x47) //0x0147 -/**TLV: Max Station number */ -#define MRVL_MAX_STA_CNT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x55) //0x0155 -/**TLV: Retry limit */ -#define MRVL_RETRY_LIMIT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x5d) //0x015d -/**TLV: MCBC data rate */ -#define MRVL_MCBC_DATA_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x62) //0x0162 -/**TLV: RSN replay protection */ -#define MRVL_RSN_REPLAY_PROT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x64) //0x0164 -/** TLV: Management IE list */ -#define MRVL_MGMT_IE_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x69) //0x0169 -/** TLV : Coex common configuration */ -#define MRVL_BT_COEX_COMMON_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6c) //0x016c -/** TLV : Coex SCO configuration */ -#define MRVL_BT_COEX_SCO_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6d) //0x016d -/** TLV : Coex ACL configuration */ -#define MRVL_BT_COEX_ACL_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6e) //0x016e -/** TLV : Coex stats configuration */ -#define MRVL_BT_COEX_STATS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x6f) //0x016f -/** TLV :Pairwise Handshake Timeout */ -#define MRVL_EAPOL_PWK_HSK_TIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x75) //0x0175 -/** TLV :Pairwise Handshake Retries */ -#define MRVL_EAPOL_PWK_HSK_RETRIES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x76) //0x0176 -/** TLV :Groupwise Handshake Timeout */ -#define MRVL_EAPOL_GWK_HSK_TIMEOUT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x77) //0x0177 -/** TLV :Groupwise Handshake Retries */ -#define MRVL_EAPOL_GWK_HSK_RETRIES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x78) //0x0178 -/** TLV : PS STA ageout timer */ -#define MRVL_PS_STA_AGEOUT_TIMER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7b) //0x017b -/** TLV : Pairwise Cipher */ -#define MRVL_CIPHER_PWK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x91) //0x0191 -/** TLV : Group Cipher */ -#define MRVL_CIPHER_GWK_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x92) //0x0192 -/** TLV : BSS Status */ -#define MRVL_BSS_STATUS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x93) //0x0193 -/** TLV : Restricted Client Mode */ -#define MRVL_RESTRICT_CLIENT_MODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xC1) //0x01C1 -/** TLV : Sticky TIM config */ -#define MRVL_STICKY_TIM_CONFIG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x96) //0x0196 -/** TLV : Sticky TIM MAC address */ -#define MRVL_STICKY_TIM_STA_MAC_ADDR_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x97) //0x0197 -/** TLV : 20/40 coex config */ -#define MRVL_2040_BSS_COEX_CONTROL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x98) //0x0198 -/** TLV : Max Management IE */ -#define MRVL_MAX_MGMT_IE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xAA) //0x01aa - -/** TLV : Region Domain Code */ -#define MRVL_REGION_DOMAIN_CODE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xAB) //0x01ab - -#ifdef RX_PACKET_COALESCE -#define MRVL_RX_PKT_COAL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xC9) -#endif - -/** TLV : Tx beacon rate */ -#define MRVL_TX_BEACON_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 288) //0x0220 - -#ifdef RX_PACKET_COALESCE -/** RX packet coalesce tlv */ -typedef PACK_START struct _tlvbuf_rx_pkt_coal_t { - /** Header */ - TLVHEADER; - /** threshold for rx packets */ - t_u32 rx_pkt_count; - /** timeout for rx coalescing timer */ - t_u16 delay; -} PACK_END tlvbuf_rx_pkt_coal_t; -#endif -#define MRVL_AP_WMM_PARAM_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xD0) - -/** TLV: HT_CAPABILITY */ -#define HT_CAPABILITY_TLV_ID 0x2d -/** TLV: HT_INFO */ -#define HT_INFO_TLV_ID 0x3d -/** config mask for HT_CAP */ -#define HT_CAP_CONFIG_MASK 0x10f3 -/** default htcap value */ -#define DEFAULT_HT_CAP_VALUE 0x117e -/** HT_CAP validity check */ -#define HT_CAP_CHECK_MASK 0x10c -/** config mask for ampdu parameter */ -#define AMPDU_CONFIG_MASK 0x1f - -/** Macro to check if 11n 40 Mhz is enabled */ -#define IS_11N_40MHZ_ENABLED(cap) ((cap) & 0x002) >> 1 -/** Macro to check if 11n 20MHz with short GI is enabled */ -#define IS_11N_20MHZ_SHORTGI_ENABLED(cap) ((cap) & 0x0020) >> 5 -/** Macro to check if 11n Green Field is enabled */ -#define IS_11N_GF_ENABLED(cap) ((cap) & 0x0010) >> 4 -/** MCS set length */ -#define MCS_SET_LEN 16 - -/** HT Capabilities tlv */ -typedef PACK_START struct _tlvbuf_htcap_t { - /** Header */ - TLVHEADER; - /** HTCap struct */ - HTCap_t ht_cap; -} PACK_END tlvbuf_htcap_t; - -/** HT Information tlv */ -typedef PACK_START struct _tlvbuf_htinfo_t { - /** Header */ - TLVHEADER; - /** HTCap struct */ - HTInfo_t ht_info; -} PACK_END tlvbuf_htinfo_t; - -/** Max bitmap rates size */ -#define MAX_BITMAP_RATES_SIZE 26 - -/** tx_rate_cfg structure */ -typedef PACK_START struct _tx_rate_cfg_t { - /** Action */ - int subcmd; - /** Action */ - int action; - /** Rate format */ - int rate_format; - /** Rate configured */ - int rate; - /** nss */ - int nss; - /** user_data_cnt */ - int user_data_cnt; - /** Rate bitmap */ - t_u16 bitmap_rates[MAX_BITMAP_RATES_SIZE]; - /** Rate Setting */ - t_u16 rate_setting; -} PACK_END tx_rate_cfg_t; - -/** Mask for 2X2 support*/ -#define STREAM_2X2_MASK 0x20 -/** MCS_SET_1 Mask */ -#define MCS_SET_1_MASK 0x0000ff00 -/** MCS0-7 supported */ -#define DEFAULT_MCS_SET_0 0xff -/** MCS8-15 support */ -#define DEFAULT_MCS_SET_1 0xff -/** MCS32 supported */ -#define DEFAULT_MCS_SET_4 0x01 -/** Rate bitmap for MCS 0 */ -#define UAP_RATE_BITMAP_MCS0 32 -/** Rate bitmap for MCS 127 */ -#define UAP_RATE_BITMAP_MCS127 159 -/** Rate index for MCS 0 */ -#define UAP_RATE_INDEX_MCS0 12 -/** Rate index for MCS 7 */ -#define UAP_RATE_INDEX_MCS7 19 -/** Rate index for MCS 32 */ -#define UAP_RATE_INDEX_MCS32 44 - -/* Mask to enable/disable restricted client mode */ -#define RESTRICT_CLIENT_MODE_ENABLE_MASK 0x01 -/* Mask for B Only mode */ -#define B_ONLY_MASK 0x0100 -/* Mask for A Only mode */ -#define A_ONLY_MASK 0x0200 -/* Mask for G Only mode */ -#define G_ONLY_MASK 0x0400 -/* Mask for N Only mode */ -#define N_ONLY_MASK 0x0800 -/* Mask for AC Only mode */ -#define AC_ONLY_MASK 0x1000 - -/** Type enumeration of WMM AC_QUEUES */ -typedef enum _wmm_ac { - AC_BE, - AC_BK, - AC_VI, - AC_VO, -} wmm_ac; - -/** Enumeration for band steering actions */ -typedef enum _bandSteerAct { - ACT_GET = 0, - ACT_SET_STATE = 1, - ACT_SET_BLOCK_2G_PRB_REQ = 2, - ACT_SET_MAX_BTM_REQ_ALLOWED = 4, -} bandSteerAct; - -/** Restricted Client Mode tlv */ -typedef PACK_START struct _tlvbuf_restrict_client_mode { - /** Header */ - TLVHEADER; - /** Mode Config - * Bit 0: 1 enable restricted client mode - * 0 disable restricted client mode - * Bits [1-7] : set to 0 - * Bits [8:12] - * Bit 8: B only Mode - * Bit 9: A only Mode - * Bit 10: G only Mode - * Bit 11: N only Mode - * Bit 12: AC only Mode - * Currently only one of the bits from [8-12] should be set - * Bits [13:15]: set to 0 - */ - t_u16 mode_config; -} PACK_END tlvbuf_restrict_client_mode; - -/** ID for VENDOR_SPECIFIC_IE */ -#define VENDOR_SPECIFIC_IE_TLV_ID 0xdd - -/** WMM_PS Mask */ -#define WMM_PS_MASK 0x7f -/** Enable WMM PS */ -#define ENABLE_WMM_PS 128 -/** Disable WMM PS */ -#define DISABLE_WMM_PS 0 -/** Maximum number of AC QOS queues available in the driver/firmware */ -#define MAX_AC_QUEUES 4 - -/** wmm parameter tlv */ -typedef PACK_START struct _tlvbuf_wmm_para_t { - /** Header */ - TLVHEADER; - /** Wmm parameter */ - WmmParameter_t wmm_para; -} PACK_END tlvbuf_wmm_para_t; - -/** data_structure for cmd vhtcfg */ -struct eth_priv_vhtcfg { - /** Band (1: 2.4G, 2: 5 G, 3: both 2.4G and 5G) */ - t_u32 band; - /** TxRx (1: Tx, 2: Rx, 3: both Tx and Rx) */ - t_u32 txrx; - /** BW CFG (0: 11N CFG, 1: vhtcap) */ - t_u32 bwcfg; - /** VHT capabilities. */ - t_u32 vht_cap_info; - /** VHT Tx mcs */ - t_u32 vht_tx_mcs; - /** VHT Rx mcs */ - t_u32 vht_rx_mcs; - /** VHT rx max rate */ - t_u16 vht_rx_max_rate; - /** VHT max tx rate */ - t_u16 vht_tx_max_rate; -}; - -typedef struct _vht_cfg_para { - /** Sub command */ - t_u32 subcmd; - /** Action: Set/Get - * Will be eliminatied on moal */ - t_u32 action; - /* VHT configuration */ - struct eth_priv_vhtcfg vht_cfg; -} vht_cfg_para; - -/** data_structure for cmd uap operation control */ -struct eth_priv_uap_oper_ctrl { - /**operation control*/ - t_u16 ctrl; - /**channel operation*/ - t_u16 chan_opt; - /**band configuration*/ - t_u8 bandcfg; - /**channel */ - t_u8 channel; -}; - -typedef struct _uap_operation_ctrl { - /** Sub command */ - t_u32 subcmd; - /** Action: Set/Get */ - t_u32 action; - /**uap operation control */ - struct eth_priv_uap_oper_ctrl uap_oper; -} uap_operation_ctrl; - -/** Function Prototype Declaration */ -int mac2raw(char *mac, t_u8 *raw); -void print_mac(t_u8 *raw); -int uap_ioctl(t_u8 *cmd, t_u16 *size, t_u16 buf_size); -void print_auth(tlvbuf_auth_mode *tlv); -void print_tlv(t_u8 *buf, t_u16 len); -void print_cipher(tlvbuf_cipher *tlv); -void print_pwk_cipher(tlvbuf_pwk_cipher *tlv); -void print_gwk_cipher(tlvbuf_gwk_cipher *tlv); -void print_rate(tlvbuf_rates *tlv); -int string2raw(char *str, unsigned char *raw); -void print_mac_filter(tlvbuf_sta_mac_addr_filter *tlv); -int ishexstring(void *hex); -unsigned int a2hex(char *s); -int fparse_for_hex(FILE * fp, t_u8 *dst); -int is_input_valid(valid_inputs cmd, int argc, char *argv[]); -int is_cipher_valid(int pairwisecipher, int groupcipher); -int is_cipher_valid_with_proto(int pairwisecipher, int groupcipher, - int protocol); -int get_sys_cfg_rates(t_u8 *rates); -int is_tx_rate_valid(t_u8 rate); -int is_mcbc_rate_valid(t_u8 rate); -void hexdump_data(char *prompt, void *p, int len, char delim); -unsigned char hexc2bin(char chr); -int check_sys_config(t_u8 *buf, t_u16 len); -int check_bss_config(t_u8 *buf); -int get_max_sta_num_supported(t_u16 *max_sta_num_supported); -int get_sys_cfg_protocol(t_u16 *proto); -int is_cipher_valid_with_11n(int pairwisecipher, int groupcipher, - int protocol, int enable_11n); -int get_sys_cfg_11n(HTCap_t *pHtCap); -int get_fw_info(fw_info *pfw_info); -t_u8 parse_domain_file(char *country, int band, - ieeetypes_subband_set_t *sub_bands, t_u8 *pdomain_code); -int sg_snmp_mib(t_u16 action, t_u16 oid, t_u16 size, t_u8 *oid_buf); -int check_channel_validity_11d(int channel, int band, int set_domain); -int check_tx_pwr_validity_11d(t_u8 tx_pwr); -int prepare_host_cmd_buffer(char *fname, char *cmd_name, t_u8 *buf); -char *mlan_config_get_line(FILE * fp, char *s, t_s32 size, int *line); -int uap_ioctl_dfs_repeater_mode(int *mode); -/** - * @brief isdigit for String. - * - * @param x Char string - * @return UAP_FAILURE for non-digit. - * UAP_SUCCESS for digit - */ -static inline int -ISDIGIT(char *x) -{ - unsigned int i; - for (i = 0; i < strlen(x); i++) - if (isdigit(x[i]) == 0) - return UAP_FAILURE; - return UAP_SUCCESS; -} - -/** - * @brief Detects if band is different across the list of scan channels - * - * @param argc Number of elements - * @param argv Array of strings - * @return UAP_FAILURE or UAP_SUCCESS - */ -static inline int -has_diff_band(int argc, char *argv[]) -{ - int i = 0; - int channel = 0; - int band[MAX_CHANNELS]; - /* Check for different bands */ - for (i = 0; i < argc; i++) { - band[i] = -1; - sscanf(argv[i], "%d.%d", &channel, &band[i]); - if (band[i] == -1) { - if (channel > MAX_CHANNELS_BG) { - band[i] = 1; - } else { - band[i] = 0; - } - } - } - for (i = 0; i <= (argc - 2); i++) { - if (band[i] != band[i + 1]) { - return UAP_FAILURE; - } - } - return UAP_SUCCESS; -} - -/** - * @brief Detects duplicates channel in array of strings - * - * @param argc Number of elements - * @param argv Array of strings - * @return UAP_FAILURE or UAP_SUCCESS - */ -static inline int -has_dup_channel(int argc, char *argv[]) -{ - int i, j; - /* Check for duplicate */ - for (i = 0; i < (argc - 1); i++) { - for (j = i + 1; j < argc; j++) { - if (atoi(argv[i]) == atoi(argv[j])) { - return UAP_FAILURE; - } - } - } - return UAP_SUCCESS; -} - -/** - * @brief Detects duplicates rate in array of strings - * Note that 0x82 and 0x2 are same for rate - * - * @param argc Number of elements - * @param argv Array of strings - * @return UAP_FAILURE or UAP_SUCCESS - */ -static inline int -has_dup_rate(int argc, char *argv[]) -{ - int i, j; - /* Check for duplicate */ - for (i = 0; i < (argc - 1); i++) { - for (j = i + 1; j < argc; j++) { - if ((A2HEXDECIMAL(argv[i]) & ~BASIC_RATE_SET_BIT) == - (A2HEXDECIMAL(argv[j]) & ~BASIC_RATE_SET_BIT)) { - return UAP_FAILURE; - } - } - } - return UAP_SUCCESS; -} -#endif /* _UAP_H */ diff --git a/mxm_wifiex/wlan_src/mapp/wifidirectutl/Makefile b/mxm_wifiex/wlan_src/mapp/wifidirectutl/Makefile deleted file mode 100644 index e959672..0000000 --- a/mxm_wifiex/wlan_src/mapp/wifidirectutl/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# File : wifidirectutl/Makefile -# -# Copyright 2014-2020 NXP - -# Path to the top directory of the wlan distribution -PATH_TO_TOP = ../.. - -# Determine how we should copy things to the install directory -ABSPATH := $(filter /%, $(INSTALLDIR)) -RELPATH := $(filter-out /%, $(INSTALLDIR)) -INSTALLPATH := $(ABSPATH) -ifeq ($(strip $(INSTALLPATH)),) -INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) -endif - -# Override CFLAGS for application sources, remove __ kernel namespace defines -CFLAGS := $(filter-out -D__%, $(ccflags-y)) -# remove KERNEL include dir -CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) - - -CFLAGS += -Wall -LIBS = -lrt - - -.PHONY: default tags all - -OBJECTS = wifidirectutl.o -HEADERS = wifidirectutl.h - -ifneq (,$(findstring DWIFI_DISPLAY_SUPPORT, $(CFLAGS))) -OBJECTS += wifi_display.o -HEADERS += wifi_display.h -endif - -TARGET = wifidirectutl - -build default: $(TARGET) - @cp -f $(TARGET) $(INSTALLPATH) - @cp -rf config $(INSTALLPATH) - - -all : tags default - -$(TARGET): $(OBJECTS) $(HEADERS) - $(ECHO)$(CC) $(LIBS) -o $@ $(OBJECTS) - -%.o: %.c $(HEADERS) - $(ECHO)$(CC) $(CFLAGS) -c -o $@ $< - -tags: - ctags -R -f tags.txt - -distclean clean: - $(ECHO)$(RM) $(OBJECTS) $(TARGET) - $(ECHO)$(RM) tags.txt - diff --git a/mxm_wifiex/wlan_src/mapp/wifidirectutl/config/wifidirect.conf b/mxm_wifiex/wlan_src/mapp/wifidirectutl/config/wifidirect.conf deleted file mode 100644 index 00adc6b..0000000 --- a/mxm_wifiex/wlan_src/mapp/wifidirectutl/config/wifidirect.conf +++ /dev/null @@ -1,415 +0,0 @@ -# File : wifidirect.conf - -######################### WIFIDIRECT Configuration command ################## - -wifidirect_config={ - # Arrange in order of subelement Ids - # - # WIFIDIRECT IE parameters. - # - - Capability={ - DeviceCapability=33 - GroupCapability=8 - } - GroupOwnerIntent={ - Intent=5 # 0-15. 15-> highest GO desire - } - Channel={ # Listen channel attribute. - CountryString="US" - RegulatoryClass=81 - ChannelNumber=6 - } - InfrastructureManageabilityInfo={ - Manageability=0 - } - ChannelList={ - CountryString="US" - # multiple attributes channel entry list - Regulatory_Class_1=81 # Regulatory class - NumofChannels_1=11 # No of channels - ChanList_1=1,2,3,4,5,6,7,8,9,10,11 # Scan channel list - Regulatory_Class_2=115 # Regulatory class - NumofChannels_2=4 # No of channels - ChanList_2=36,40,44,48 # Scan channel list - #Regulatory_Class_3=118 # Regulatory class - #NumofChannels_3=4 # No of channels - #ChanList_3=52,56,60,64 # Scan channel list - #Regulatory_Class_4=121 # Regulatory class - #NumofChannels_4=11 # No of channels - #ChanList_4=100,104,108,112,116,120,124,128,132,136,140 # Scan channel list - # Enable only one of the country blocks at a time - #CountryString="JP" - # multiple attributes channel entry list - #Regulatory_Class_1=81 # Regulatory class - #NumofChannels_1=13 # No of channels - #ChanList_1=1,2,3,4,5,6,7,8,9,10,11,12,13 # Scan channel list - #Regulatory_Class_2=115 # Regulatory class - #NumofChannels_2=4 # No of channels - #ChanList_2=36,40,44,48 # Scan channel list - #Regulatory_Class_3=118 # Regulatory class - #NumofChannels_3=4 # No of channels - #ChanList_3=52,56,60,64 # Scan channel list - #Regulatory_Class_4=121 # Regulatory class - #NumofChannels_4=11 # No of channels - #ChanList_4=100,104,108,112,116,120,124,128,132,136,140 # Scan channel list - } - NoticeOfAbsence={ - NoA_Index=0 # Instance of NoA timing - OppPS=1 # Opportunistic Power save - CTWindow=10 # Client Traffic Window - NoA_descriptor={ - CountType_1=255 # Count for GO mode OR Type for client mode - Duration_1=51200 # Max absence duration for GO mode OR - # min acceptable presence period for client mode - Interval_1=102400 - StartTime_1=0 - #CountType_2=1 # Count for GO mode OR Type for client mode - #Duration_2=0 # Max absence duration for GO mode OR - # min acceptable presence period for client mode - #Interval_2=0 - #StartTime_2=0 - } - } - DeviceInfo={ - DeviceAddress=00:50:43:00:00:00 - # categ: 2 bytes, OUI: 4 bytes, subcateg: 2 bytes - PrimaryDeviceTypeCategory=1 - PrimaryDeviceTypeOUI=0x00,0x50,0xF2,0x04 - PrimaryDeviceTypeSubCategory=1 - SecondaryDeviceCount=2 - SecondaryDeviceType={ - SecondaryDeviceTypeCategory_1=6 - SecondaryDeviceTypeOUI_1=0x00,0x50,0xF2,0x04 - SecondaryDeviceTypeSubCategory_1=1 - SecondaryDeviceTypeCategory_2=4 - SecondaryDeviceTypeOUI_2=0x00,0x50,0xF2,0x04 - SecondaryDeviceTypeSubCategory_2=1 - } - DeviceName="MRVL_DEFAULT_NAME" - # ConfigMethods USB= 0x01 - # ConfigMethods Ethernet= 0x02 - # ConfigMethods Label= 0x04 - # ConfigMethods Display= 0x08 - # ConfigMethods Ext_NFC_Token= 0x10 - # ConfigMethods Int_NFC_Token= 0x20 - # ConfigMethods NFC_Interface= 0x40 - # ConfigMethods PushButton= 0x80 - # ConfigMethods KeyPad= 0x100 - WPSConfigMethods=0x188 - } - GroupId={ - GroupAddr=00:50:43:00:00:00 - GroupSsId="DIRECT-" - } - GroupBSSId={ - # using LAA for interface address by default - GroupBssId=02:50:43:00:00:00 - } - DeviceId={ - WIFIDIRECT_MAC=00:50:43:00:00:00 # MAC address of wifidirect device in Hex - } - Interface={ - # using LAA for interface addresses by default - InterfaceAddress=02:50:43:00:00:00 - InterfaceAddressCount=2 - InterfaceAddressList=02:50:43:00:00:00,02:52:43:00:00:00 - } - ConfigurationTimeout={ - # units of 10 milliseconds - GroupConfigurationTimeout=250 - ClientConfigurationTimeout=100 - } - ExtendedListenTime={ - # units of milliseconds - AvailabilityPeriod=1000 - AvailabilityInterval=1500 - } - IntendedIntfAddress={ - # using LAA for interface address by default - GroupInterfaceAddress=02:50:43:00:00:00 - } - OperatingChannel={ # Operating channel attribute. - CountryString="US" - OpRegulatoryClass=81 - OpChannelNumber=6 - } - InvitationFlagBitmap={ - InvitationFlag=0 # bit0: Invitation type: - } # 0: request to reinvoke a persistent group - # 1: request to join an active WIFIDIRECT group - - - #Extra={ - #Buffer=0x00,0x50,0x43,0x07,0x20,0xa1 - #} - - # - # WPS IE parameters. - # - WPSIE={ - WPSVersion=0x10 - WPSSetupState=0x1 - WPSRequestType=0x0 - WPSResponseType=0x0 - WPSSpecConfigMethods=0x0188 - WPSUUID=0x12,0x34,0x56,0x78,0x12,0x34,0x56,0x78,0x12,0x34,0x56,0x78,0x12,0x34,0x56,0x78 - WPSPrimaryDeviceType=0x00,0x01,0x00,0x50,0xF2,0x04,0x00,0x01 - WPSRFBand=0x01 - WPSAssociationState=0x00 - WPSConfigurationError=0x00 - WPSDevicePassword=0x00 - WPSDeviceName="MRVL_DEFAULT_NAME" - WPSManufacturer=NXP - WPSModelName=SD-8787 - WPSModelNumber=0x00,0x00,0x00,0x01 - WPSSerialNumber=0x00,0x00,0x00,0x01 - WPSVendorExtension=0x00,0x37,0x2A,0x00,0x01,0x20 - } -} - - -######################### WIFIDIRECT Parameters configuration command ####### - -wifidirect_param_config={ - MinDiscoveryInterval=1 - MaxDiscoveryInterval=7 - EnableScan=1 - #ScanPeerDeviceId=00:50:43:77:43:47 - #ScanRequestDeviceType=0x01,0x00,0x50,0xF2,0x04,0x01,0x3C,0x10 - DeviceState=4 -} - -######################### WIFIDIRECT Action Frame command ################## - -wifidirect_action_frame={ - PeerAddr=00:50:43:00:00:00 - Category=4 # 4 : Public action frame, 0x7F : Vendor specific - Action=0 # 0xDD : Vendor specific, Others : Reserved. - OUI=0x50,0x6F,0x9A - OUIType=9 # WFA wifidirect. - # 15 : WPSE. - - # OUI SubType 0 : GO Negotiation Request - # OUI SubType 1 : GO Negotiation Response - # OUI SubType 2 : GO Negotiation Confirmation - # OUI SubType 3 : WIFIDIRECT Invitation Request - # OUI SubType 4 : WIFIDIRECT Invitation Response - # OUI SubType 5 : Device Discoverability Request - # OUI SubType 6 : Device Discoverability Response - # OUI SubType 7 : Provision Discovery Request - # OUI SubType 8 : Provision Discovery Response - - # - # UPDATE LINE BELOW for APPROPRIATE SUB TYPE - # - OUISubType=0 - - DialogToken=1 - - # Arrange in order of subelement Ids - # Other parameters which can be configured from WIFIDIRECT config command. - - #DeviceId={ - # WIFIDIRECT_MAC=00:50:43:77:46:41 # MAC address of wifidirect device in Hex - #} - #Interface={ - # InterfaceAddress=00:50:43:77:46:41 - # InterfaceAddressCount=2 - # InterfaceAddressList=00:50:43:77:46:41,00:50:43:78:47:42 - #} -} - -######################### WIFIDIRECT service discovery command ################## - -wifidirect_discovery_request={ - PeerAddr=00:50:43:00:00:00 - Category=4 - Action=10 - DialogToken=1 - AdvertizementProtocolIE=0x6c,0x02,0x00,0x00 - # octet 1: Element Id = 108 ( 0x6c) - # octer 2: Length of following fields - # octer 3: Bit7: PAME-BI ( Message Exchange BSSID independant) - # Bits0-6: Query response length limit. - # octer 4: Advertizement Protocol ID - QueryRequestLen={ - InfoId=0xDD,0xDD - RequestLen={ - OUI=0x50,0x6F,0x9A - OUISubType=9 - ServiceUpdateIndicator=0 - VendorLen={ - ServiceProtocol=0 # 0: All service protocol types - # 1: Bonjour, 2: uPnP, 3: WS-Discovery - # 255: Vendor specific - ServiceTransactionId=1 - QueryData={ - ## Use Data below, if ServiceProtocol=1 (Bonjour). - # - ## DNSName can be string or hexadecimal sequence of bytes. - #DNSName="_afpovertcp._tcp.local." - # DNSName=0x07,0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x0B,0x5F,0x61,0x66,0x70,0x6F,0x76,0x65,0x72,0x74,0x63,0x70,0xC0,0x0C - #DNSType=12 - #BonjourVersion=1 - - ## Use Data below, if ServiceProtocol=2 (uPnP). - # - #uPnPVersion=0x10 - #uPnPQueryValue="ssdp:all" # Searches for all UPnP devices and services - # - # OR any one of following values in WIFIDIRECT spec. - #uPnPQueryValue="upnp:rootdevice" # Searches for all UPnP root devices - #uPnPQueryValue="uuid:device-uuid" # Searches for a particular device - #uPnPQueryValue="urn:schemas-upnp-org:device:deviceType:ver" - # Searches for devices of the given type - #uPnPQueryValue="urn:domain-name:device:deviceType:ver" - # Searches for devices with a vendor-specific type - #uPnPQueryValue="urn:schemas-upnp-org:service:serviceType:ver" - # Searches for devices containing a service of the given type - #uPnPQueryValue="urn:domain-name:service:serviceType:ver" - # Searches for devices containing a vendor-specific service - } - } - } - } -} - -wifidirect_discovery_response={ - PeerAddr=00:50:43:00:00:00 - Category=4 - Action=11 - DialogToken=1 - StatusCode=0 - GasComebackDelay=0x0000 - AdvertizementProtocolIE=0x6c,0x02,0x7F,0x00 - # octet 1: Element Id = 108 ( 0x6c) - # octer 2: Length of following fields - # octer 3: Bit7: PAME-BI ( Message Exchange BSSID independant) - # Bits0-6: Query response length limit. - # octer 4: Advertizement Protocol ID - QueryResponseLen={ - InfoId=0xDD,0xDD - ResponseLen={ - OUI=0x50,0x6F,0x9A - OUISubType=9 - ServiceUpdateIndicator=0 - VendorLen={ - ServiceProtocol=0 # 0: All service protocol types - # 1: Bonjour, 2: uPnP, 3: WS-Discovery - # 255: Vendor specific - ServiceTransactionId=1 - ServiceStatus=0 # 0: Success - # 1: Service protocol type not available - # 2: Query data not available - # 3: Bad request. - ResponseData={ - ## Use Data below, if ServiceProtocol=1 (Bonjour). - # - ## DNSName can be string or hexadecimal sequence of bytes. - - DNSName="_afpovertcp._tcp.local." - # DNSName=0x07,0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x0B,0x5F,0x61,0x66,0x70,0x6F,0x76,0x65,0x72,0x74,0x63,0x70,0xC0,0x0C - DNSType=12 - BonjourVersion=1 - ## RecordData can be string or hexadecimal sequence of bytes. - # RecordData="" - RecordData=0x00 - - ## Use Data below, if ServiceProtocol=2 (uPnP). - # - #uPnPVersion=0x10 - #uPnPResponseValue="ssdp:all" # Searches for all UPnP devices and services - # - # OR any one of following values in WIFIDIRECT spec. - #uPnPResponseValue="upnp:rootdevice" # Searches for all UPnP root devices - #uPnPResponseValue="uuid:device-uuid" # Searches for a particular device - #uPnPResponseValue="urn:schemas-upnp-org:device:deviceType:ver" - # Searches for devices of the given type - #uPnPResponseValue="urn:domain-name:device:deviceType:ver" - # Searches for devices with a vendor-specific type - #uPnPResponseValue="urn:schemas-upnp-org:service:serviceType:ver" - # Searches for devices containing a service of the given type - #uPnPResponseValue="urn:domain-name:service:serviceType:ver" - # Searches for devices containing a vendor-specific service - } - } - } - } -} - -### GAS Comback request and response Frame ### - -wifidirect_gas_comeback_request={ - PeerAddr=00:50:43:00:00:00 - Category=4 - Action=12 - DialogToken=1 -} - -wifidirect_gas_comeback_response={ - PeerAddr=00:50:43:00:00:00 - Category=4 - Action=13 - DialogToken=1 - StatusCode=0 - GasResponseFragID=0x01 - # Bit 7: More GAS fragments bit - # Bits 0-6: GAS query response fragment ID. - # 0 for initial frame and increments subsequently. - GasComebackDelay=0x0000 - AdvertizementProtocolIE=0x6c,0x02,0x7F,0x00 - # octet 1: Element Id = 108 ( 0x6c) - # octer 2: Length of following fields - # octer 3: Bit7: PAME-BI ( Message Exchange BSSID independant) - # Bits0-6: Query response length limit. - # octer 4: Advertizement Protocol ID - QueryResponseLen={ - InfoId=0xDD,0xDD - ResponseLen={ - OUI=0x00,0x50,0xF2 - OUISubType=9 - ServiceUpdateIndicator=0 - VendorLen={ - ServiceProtocol=1 # 0: All service protocol types - # 1: Bonjour, 2: uPnP, 3: WS-Discovery - # 255: Vendor specific - ServiceTransactionId=1 - ServiceStatus=0 # 0: Success - # 1: Service protocol type not available - # 2: Query data not available - # 3: Bad request. - ResponseData={ - ## Use Data below, if ServiceProtocol=1 (Bonjour). - # - ## DNSName can be string or hexadecimal sequence of bytes. - - # DNSName="_afpovertcp._tcp.local." - DNSName=0x07,0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x0B,0x5F,0x61,0x66,0x70,0x6F,0x76,0x65,0x72,0x74,0x63,0x70,0xC0,0x0C - DNSType=12 - BonjourVersion=1 - ## RecordData can be string or hexadecimal sequence of bytes. - # RecordData="" - RecordData=0x00 - - ## Use Data below, if ServiceProtocol=2 (uPnP). - # - #uPnPVersion=0x10 - #uPnPResponseValue="ssdp:all" # Searches for all UPnP devices and services - # - # OR any one of following values in WIFIDIRECT spec. - #uPnPResponseValue="upnp:rootdevice" # Searches for all UPnP root devices - #uPnPResponseValue="uuid:device-uuid" # Searches for a particular device - #uPnPResponseValue="urn:schemas-upnp-org:device:deviceType:ver" - # Searches for devices of the given type - #uPnPResponseValue="urn:domain-name:device:deviceType:ver" - # Searches for devices with a vendor-specific type - #uPnPResponseValue="urn:schemas-upnp-org:service:serviceType:ver" - # Searches for devices containing a service of the given type - #uPnPResponseValue="urn:domain-name:service:serviceType:ver" - # Searches for devices containing a vendor-specific service - } - } - } - } -} diff --git a/mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.c b/mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.c deleted file mode 100644 index 97f6714..0000000 --- a/mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.c +++ /dev/null @@ -1,8331 +0,0 @@ -/** @file wifidirectutl.c - * - * @brief Program to configure WifiDirect parameters. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/**************************************************************************** - Change log: - 07/10/09: Initial creation - ****************************************************************************/ - -/**************************************************************************** - Header files - ****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "wifidirectutl.h" -/**************************************************************************** - Definitions - ****************************************************************************/ - -/** Convert character to integer */ -#define CHAR2INT(x) (((x) >= 'A') ? ((x) - 'A' + 10) : ((x) - '0')) - -/** Uncomment this to enable DEBUG */ -/* #define DEBUG */ - -/**************************************************************************** - Global variables - ****************************************************************************/ -/** Device name */ -static -char dev_name[IFNAMSIZ + 1]; -/** Option for cmd */ -static -struct option cmd_options[] = { - {"help", 0, 0, 'h'}, - {0, 0, 0, 0} -}; - -/**************************************************************************** - Local functions - ***************************************************************************/ -/** - * @brief Dump hex data - * - * @param p A pointer to data buffer - * @param len The len of data buffer - * @param delim Deliminator character - * @return Hex integer - */ -#ifdef DEBUG -static void -hexdump(void *p, t_s32 len, char delim) -{ - t_s32 i; - t_u8 *s = p; - printf("HexDump: len=%d\n", (int)len); - for (i = 0; i < len; i++) { - if (i != len - 1) - printf("%02x%c", *s++, delim); - else - printf("%02x\n", *s); - if ((i + 1) % 16 == 0) - printf("\n"); - } -} -#endif - -static int -wifidir_use_fixed_ie_indices(void) -{ -#define WIFIDIR_USE_FIXED_IE_INDICES "WIFIDIR_USE_FIXED_IE_INDICES" - char *ret = getenv(WIFIDIR_USE_FIXED_IE_INDICES); - - if (ret != NULL && *ret == '1') { - printf("Using fixed ie indices 0 and 1 for P2P and WPS IEs"); - return 1; - } else { - return 0; - } -} - -/** - * @brief Converts a string to hex value - * - * @param str A pointer to the string - * @param raw A pointer to the raw data buffer - * @return Number of bytes read - */ -static int -string2raw(char *str, unsigned char *raw) -{ - int len = (strlen(str) + 1) / 2; - - do { - if (!isxdigit(*str)) { - return -1; - } - *str = toupper(*str); - *raw = CHAR2INT(*str) << 4; - ++str; - *str = toupper(*str); - if (*str == '\0') - break; - *raw |= CHAR2INT(*str); - ++raw; - } while (*++str != '\0'); - return len; -} - -/** - * @brief Convert string to hex integer - * - * @param s A pointer string buffer - * @return Hex integer - */ -static - unsigned int -a2hex(char *s) -{ - unsigned int val = 0; - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - while (*s && isxdigit(*s)) { - val = (val << 4) + hexc2bin(*s++); - } - return val; -} - -/** - * @brief Hex to number - * - * @param c Hex value - * @return Integer value or -1 - */ -static int -hex2num(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - - return -1; -} - -/** - * @brief Convert char to hex integer - * - * @param chr Char - * @return Hex integer - */ -unsigned char -hexc2bin(char chr) -{ - if (chr >= '0' && chr <= '9') - chr -= '0'; - else if (chr >= 'A' && chr <= 'F') - chr -= ('A' - 10); - else if (chr >= 'a' && chr <= 'f') - chr -= ('a' - 10); - - return chr; -} - -/** - * @brief Check hex string - * - * @param hex A pointer to hex string - * @return SUCCESS or FAILURE - */ -static int -ishexstring(void *hex) -{ - int i, a; - char *p = hex; - int len = strlen(p); - if (!strncasecmp("0x", p, 2)) { - p += 2; - len -= 2; - } - for (i = 0; i < len; i++) { - a = hex2num(*p); - if (a < 0) - return FAILURE; - p++; - } - return SUCCESS; -} - -/** - * @brief Prints a MAC address in colon separated form from hex data - * - * @param raw A pointer to the hex data buffer - * @return N/A - */ -static void -print_mac(t_u8 *raw) -{ - printf("%02x:%02x:%02x:%02x:%02x:%02x", (unsigned int)raw[0], - (unsigned int)raw[1], (unsigned int)raw[2], (unsigned int)raw[3], - (unsigned int)raw[4], (unsigned int)raw[5]); - return; -} - -/** - * @brief Converts colon separated MAC address to hex value - * - * @param mac A pointer to the colon separated MAC string - * @param raw A pointer to the hex data buffer - * @return SUCCESS or FAILURE - * WIFIDIRECT_RET_MAC_BROADCAST - if broadcast mac - * WIFIDIRECT_RET_MAC_MULTICAST - if multicast mac - */ -static - int -mac2raw(char *mac, t_u8 *raw) -{ - unsigned int temp_raw[ETH_ALEN]; - int num_tokens = 0; - int i; - if (strlen(mac) != ((2 * ETH_ALEN) + (ETH_ALEN - 1))) { - return FAILURE; - } - num_tokens = sscanf(mac, "%2x:%2x:%2x:%2x:%2x:%2x", - temp_raw + 0, temp_raw + 1, temp_raw + 2, - temp_raw + 3, temp_raw + 4, temp_raw + 5); - if (num_tokens != ETH_ALEN) { - return FAILURE; - } - for (i = 0; i < num_tokens; i++) - raw[i] = (t_u8)temp_raw[i]; - - if (memcmp(raw, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0) { - return WIFIDIRECT_RET_MAC_BROADCAST; - } else if (raw[0] & 0x01) { - return WIFIDIRECT_RET_MAC_MULTICAST; - } - return SUCCESS; -} - -/** - * @brief Prints usage information of wifidirectutl - * - * @return N/A - */ -static void -print_tool_usage(void) -{ - - printf("Usage:\n"); - printf("./wifidirectutl wifidirect_mode [mode]\n" - "./wifidirectutl wifidirect_config [*.conf]\n" - "./wifidirectutl wifidirect_params_config [*.conf]\n" - "./wifidirectutl wifidirect_action_frame <*.conf>|" - " \n" - "./wifidirectutl wifidirect_discovery_request <*.conf>\n" - "./wifidirectutl wifidirect_discovery_response <*.conf>\n" - "./wifidirectutl wifidirect_gas_comeback_request <*.conf>\n" - "./wifidirectutl wifidirect_gas_comeback_response <*.conf>\n"); - printf("\nPlease see example configuration file config/wifidirect.conf\n\n"); - printf("Configuration API:\n"); - printf("./wifidirectutl wifidirect_cfg_discovery_period [ ]\n" "./wifidirectutl wifidirect_cfg_intent [IntentValue]\n" "./wifidirectutl wifidirect_cfg_capability [ ]\n" "./wifidirectutl wifidirect_cfg_noa [ ]\n" "./wifidirectutl wifidirect_cfg_opp_ps [ ]\n" "./wifidirectutl wifidirect_cfg_invitation_list [mac_address]\n" "./wifidirectutl wifidirect_cfg_listen_channel [listenChannel]\n" "./wifidirectutl wifidirect_cfg_op_channel [operatingChannel]\n" "./wifidirecttul wifidirect_cfg_persistent_group_record [index] [role]\n" " [ ] [peermac1] [peermac2]\n" "./wifidirecttul wifidirect_cfg_persistent_group_invoke [index] | \n" "./wifidirectutl wifidirect_cfg_presence_req_params [ ]\n" "./wifidirectutl wifidirect_cfg_ext_listen_time [ ]\n"); - -} - -/** - * @brief Parses a command line - * - * @param line The line to parse - * @param args Pointer to the argument buffer to be filled in - * @param args_count Max number of elements which can be filled in buffer 'args' - * @return Number of arguments in the line or EOF - */ -static - int -parse_line(char *line, char *args[], t_u16 args_count) -{ - int arg_num = 0; - int is_start = 0; - int is_quote = 0; - int is_escape = 0; - int length = 0; - int i = 0; - int j = 0; - - arg_num = 0; - length = strlen(line); - /* Process line */ - - /* Find number of arguments */ - is_start = 0; - is_quote = 0; - for (i = 0; (i < length) && (arg_num < args_count); i++) { - /* Ignore leading spaces */ - if (is_start == 0) { - if (line[i] == ' ') { - continue; - } else if (line[i] == '\t') { - continue; - } else if (line[i] == '\n') { - break; - } else { - is_start = 1; - args[arg_num] = &line[i]; - arg_num++; - } - } - if (is_start == 1) { - if ((line[i] == '\\') && (i < (length - 1))) { - if (line[i + 1] == '"') { - is_escape = 1; - for (j = i; j < length - 1; j++) { - line[j] = line[j + 1]; - } - line[length - 1] = '\0'; - continue; - } - } - /* Ignore comments */ - if (line[i] == '#') { - if (is_quote == 0) { - line[i] = '\0'; - arg_num--; - } - break; - } - /* Separate by '=' */ - if (line[i] == '=') { - if (is_quote == 0) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - /* Separate by ',' */ - if (line[i] == ',') { - if (is_quote == 0) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - /* Change ',' to ' ', but not inside quotes */ - if ((line[i] == ',') && (is_quote == 0)) { - line[i] = ' '; - continue; - } - } - /* Remove newlines */ - if (line[i] == '\n') { - line[i] = '\0'; - } - /* Check for quotes */ - if (line[i] == '"') { - if (is_escape) { - is_escape = 0; - /* no change in is_quote */ - } else { - is_quote = (is_quote == 1) ? 0 : 1; - } - continue; - } - if (((line[i] == ' ') || (line[i] == '\t')) && (is_quote == 0)) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - return arg_num; -} - -/** - * @brief Get one line from the File - * - * @param fp File handler - * @param str Storage location for data. - * @param size Maximum number of characters to read. - * @param lineno A pointer to return current line number - * @return returns string or NULL - */ -char * -mlan_config_get_line(FILE * fp, char *str, t_s32 size, int *lineno) -{ - char *start, *end; - int out, next_line; - - if (!fp || !str) - return NULL; - - do { -read_line: - if (!fgets(str, size, fp)) - break; - start = str; - start[size - 1] = '\0'; - end = start + strlen(str); - (*lineno)++; - - out = 1; - while (out && (start < end)) { - next_line = 0; - /* Remove empty lines and lines starting with # */ - switch (start[0]) { - case ' ': /* White space */ - case '\t': /* Tab */ - start++; - break; - case '#': - case '\n': - case '\0': - next_line = 1; - break; - case '\r': - if (start[1] == '\n') - next_line = 1; - else - start++; - break; - default: - out = 0; - break; - } - if (next_line) - goto read_line; - } - - /* Remove # comments unless they are within a double quoted - * string. Remove trailing white space. */ - end = strstr(start, "\""); - if (end) { - end = strstr(end + 1, "\""); - if (!end) - end = start; - } else - end = start; - - end = strstr(end + 1, "#"); - if (end) - *end-- = '\0'; - else - end = start + strlen(start) - 1; - - out = 1; - while (out && (start < end)) { - switch (*end) { - case ' ': /* White space */ - case '\t': /* Tab */ - case '\n': - case '\r': - *end = '\0'; - end--; - break; - default: - out = 0; - break; - } - } - - if (*start == '\0') - continue; - - return start; - } while (1); - - return NULL; -} - -/** - * @brief Parse function for a configuration line - * - * @param s Storage buffer for data - * @param size Maximum size of data - * @param stream File stream pointer - * @param line Pointer to current line within the file - * @param _pos Output string or NULL - * @return String or NULL - */ -static -char * -config_get_line(char *s, int size, FILE * stream, int *line, char **_pos) -{ - *_pos = mlan_config_get_line(stream, s, size, line); - return *_pos; -} - -/** - * @brief Detects duplicates channel in array of strings - * - * @param argc Number of elements - * @param argv Array of strings - * @return UAP_FAILURE or UAP_SUCCESS - */ -static inline int -has_dup_channel(int argc, char *argv[]) -{ - int i, j; - /* Check for duplicate */ - for (i = 0; i < (argc - 1); i++) { - for (j = i + 1; j < argc; j++) { - if (atoi(argv[i]) == atoi(argv[j])) { - return FAILURE; - } - } - } - return SUCCESS; -} - -/** - * @brief Performs the ioctl operation to send the command to - * the driver. - * - * @param cmd Pointer to the command buffer - * @param size Pointer to the command size. This value is - * overwritten by the function with the size of the - * received response. - * @param buf_size Size of the allocated command buffer - * @return SUCCESS or FAILURE - */ -static - int -wifidirect_ioctl(t_u8 *cmd, t_u16 *size, t_u16 buf_size) -{ - struct ifreq ifr; - mrvl_priv_cmd *mrvl_cmd = NULL; - t_u8 *buf = NULL, *temp = NULL; - wifidirectcmdbuf *header = NULL; - t_s32 sockfd; - t_u16 mrvl_header_len = 0; - int ret = SUCCESS; - - if (buf_size < *size) { - printf("buf_size should not less than cmd buffer size\n"); - return FAILURE; - } - - /* Open socket */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("ERR:Cannot open socket\n"); - return FAILURE; - } - *(t_u32 *)cmd = buf_size - BUF_HEADER_SIZE; - - mrvl_header_len = strlen(CMD_NXP) + strlen(PRIV_CMD_HOSTCMD); - buf = (unsigned char *)malloc(buf_size + sizeof(mrvl_priv_cmd) + - mrvl_header_len); - if (buf == NULL) { - close(sockfd); - return FAILURE; - } - - memset(buf, 0, buf_size + sizeof(mrvl_priv_cmd) + mrvl_header_len); - /* Fill up buffer */ - mrvl_cmd = (mrvl_priv_cmd *)buf; - mrvl_cmd->buf = buf + sizeof(mrvl_priv_cmd); - mrvl_cmd->used_len = 0; - mrvl_cmd->total_len = buf_size + mrvl_header_len; - /* Copy NXP command string */ - temp = mrvl_cmd->buf; - strncpy((char *)temp, CMD_NXP, strlen(CMD_NXP)); - temp += (strlen(CMD_NXP)); - /* Insert command string */ - strncpy((char *)temp, PRIV_CMD_HOSTCMD, strlen(PRIV_CMD_HOSTCMD)); - temp += (strlen(PRIV_CMD_HOSTCMD)); - - memcpy(temp, (t_u8 *)cmd, *size); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1); - ifr.ifr_ifru.ifru_data = (void *)mrvl_cmd; - header = (wifidirectcmdbuf *)(buf + sizeof(mrvl_priv_cmd) + - mrvl_header_len); - header->size = *size - BUF_HEADER_SIZE; -#ifdef DEBUG - /* Debug print */ - hexdump(mrvl_cmd, *size + sizeof(mrvl_priv_cmd) + mrvl_header_len, ' '); -#endif - endian_convert_request_header(header); - - /* Perform ioctl */ - errno = 0; - if (ioctl(sockfd, MRVLPRIVCMD, &ifr)) { - perror(""); - printf("ERR:MRVLPRIVCMD is not supported by %s\n", dev_name); - ret = FAILURE; - goto done; - } - endian_convert_response_header(header); - header->cmd_code &= HostCmd_CMD_ID_MASK; - header->cmd_code |= WIFIDIRECTCMD_RESP_CHECK; - *size = header->size; - memcpy(cmd, buf + sizeof(mrvl_priv_cmd) + mrvl_header_len, - *size + BUF_HEADER_SIZE); -#ifdef DEBUG - /* Debug print */ - hexdump(mrvl_cmd, - *size + BUF_HEADER_SIZE + sizeof(mrvl_priv_cmd) + - mrvl_header_len, ' '); -#endif - - /* Validate response size */ - if (*size > (buf_size - BUF_HEADER_SIZE)) { - printf("ERR:Response size (%d) greater than buffer size (%d)! Aborting!\n", *size, buf_size); - ret = FAILURE; - goto done; - } -done: - /* Close socket */ - close(sockfd); - if (buf) - free(buf); - return ret; -} - -/** - * @brief Show usage information for the wifidirect_gas_comeback_discovery commands - * - * $return N/A - */ -static void -print_wifidirect_gas_comeback_usage(void) -{ - printf("\nUsage : wifidirect_gas_comeback_request/response [CONFIG_FILE]\n"); - printf("CONFIG_FILE contains WIFIDIRECT GAS comeback request/response payload.\n"); - return; -} - -/** - * @brief Creates a wifidirect_gas_comeback_service_discovery request/response and - * sends to the driver - * - * Usage: "Usage : wifidirect_gas_comeback_request/response [CONFIG_FILE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return SUCCESS or FAILURE - **/ -static void -wifidirectcmd_gas_comeback_discovery(int argc, char *argv[]) -{ - wifidirect_gas_comeback_request *req_buf = NULL; - wifidirect_gas_comeback_response *resp_buf = NULL; - char *line = NULL; - FILE *config_file = NULL; - int i, opt, li = 0, arg_num = 0, ret = 0, wifidirect_level = 0; - char *args[30], *pos = NULL, wifidirect_mac[20], wifidirect_cmd[40]; - t_u8 dev_address[ETH_ALEN], cmd_found = 0; - t_u8 *buffer = NULL, *tmp_buffer = NULL; - t_u8 req_resp = 0; /* req = 0, resp = 1 */ - t_u16 cmd_len = 0, query_len = 0, vendor_len = 0, service_len = 0; - t_u16 dns_len = 0, record_len = 0, upnp_len = 0; - - memset(wifidirect_mac, 0, sizeof(wifidirect_mac)); - - strncpy(wifidirect_cmd, argv[2], sizeof(wifidirect_cmd) - 1); - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_gas_comeback_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 3) { - printf("ERR:Incorrect number of arguments.\n"); - print_wifidirect_gas_comeback_usage(); - return; - } - - /* Check if file exists */ - config_file = fopen(argv[2], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - return; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, 30); - if (!cmd_found && - strncmp(args[0], wifidirect_cmd, strlen(args[0]))) - continue; - - if (strcmp(args[0], "wifidirect_gas_comeback_request") == 0) { - wifidirect_level = - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE; - /* For wifidirect_service_gas_comeback, basic initialization here */ - /* Subtract extra two bytes added as a part of query request structure */ - cmd_len = sizeof(wifidirect_gas_comeback_request) - 2; - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - req_buf = (wifidirect_gas_comeback_request *)buffer; - req_buf->cmd_code = - HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY; - req_buf->size = cmd_len; - req_buf->seq_num = 0; - req_buf->result = 0; - cmd_found = 1; - - } else if (strcmp(args[0], "wifidirect_gas_comeback_response") - == 0) { - wifidirect_level = - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE; - req_resp = 1; - /* For wifidirect_service_discovery, basic initialization here */ - /* Subtract extra two bytes added as a part of query response structure */ - cmd_len = sizeof(wifidirect_gas_comeback_response) - 2; - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - resp_buf = (wifidirect_gas_comeback_response *)buffer; - resp_buf->cmd_code = - HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY; - resp_buf->size = cmd_len; - resp_buf->seq_num = 0; - resp_buf->result = 0; - cmd_found = 1; - - } - if (!cmd_found) - break; - if (strcmp(args[0], "PeerAddr") == 0) { - strncpy(wifidirect_mac, args[1], - sizeof(wifidirect_mac) - 1); - if ((ret = - mac2raw(wifidirect_mac, dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - (!req_resp) ? memcpy(req_buf->peer_mac_addr, - dev_address, - ETH_ALEN) : memcpy(resp_buf-> - peer_mac_addr, - dev_address, - ETH_ALEN); - - } else if (strcmp(args[0], "Category") == 0) { - if (is_input_valid - (WIFIDIRECT_CATEGORY, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - - } - (!req_resp) ? (req_buf->category = - (t_u8)atoi(args[1])) : (resp_buf-> - category = - (t_u8) - atoi(args[1])); - } else if (strcmp(args[0], "Action") == 0) { - if (is_input_valid - (WIFIDIRECT_ACTION, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->action = - (t_u8)A2HEXDECIMAL(args[1])) - : (resp_buf->action = - (t_u8)A2HEXDECIMAL(args[1])); - } else if (strcmp(args[0], "DialogToken") == 0) { - if (is_input_valid - (WIFIDIRECT_DIALOGTOKEN, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->dialog_taken = - (t_u8)atoi(args[1])) : (resp_buf-> - dialog_taken = - (t_u8) - atoi(args[1])); - } else if (strcmp(args[0], "StatusCode") == 0) { - if (req_resp) { - resp_buf->status_code = - (t_u16)A2HEXDECIMAL(args[1]); - resp_buf->status_code = - cpu_to_le16(resp_buf->status_code); - } - } else if (strcmp(args[0], "GasComebackDelay") == 0) { - if (is_input_valid - (WIFIDIRECT_GAS_COMEBACK_DELAY, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) { - resp_buf->gas_reply = - (t_u16)A2HEXDECIMAL(args[1]); - resp_buf->gas_reply = - cpu_to_le16(resp_buf->gas_reply); - } - } else if (strcmp(args[0], "GasResponseFragID") == 0) { - if (req_resp) - resp_buf->gas_fragment_id = - (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "AdvertizementProtocolIE") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_ADPROTOIE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - for (i = 0; i < arg_num - 1; i++) { - if (req_resp) - resp_buf->advertize_protocol_ie[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - } else if (strcmp(args[0], "InfoId") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_INFOID, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - for (i = 0; i < arg_num - 1; i++) { - if (req_resp) - resp_buf->info_id[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - query_len += arg_num - 1; - } else if (strcmp(args[0], "OUI") == 0) { - if (is_input_valid - (WIFIDIRECT_OUI, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - for (i = 0; i < arg_num - 1; i++) { - if (req_resp) - resp_buf->oui[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - service_len += arg_num - 1; - query_len += arg_num - 1; - } else if (strcmp(args[0], "OUISubType") == 0) { - if (is_input_valid - (WIFIDIRECT_OUISUBTYPE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->oui_sub_type = (t_u8)atoi(args[1]); - service_len++; - query_len++; - } else if (strcmp(args[0], "QueryRequestLen") == 0 || - strcmp(args[0], "QueryResponseLen") == 0) { - wifidirect_level = WIFIDIRECT_DISCOVERY_QUERY; - } else if (strcmp(args[0], "RequestLen") == 0 || - strcmp(args[0], "ResponseLen") == 0) { - wifidirect_level = WIFIDIRECT_DISCOVERY_SERVICE; - query_len += 2; - } else if (strcmp(args[0], "VendorLen") == 0) { - wifidirect_level = WIFIDIRECT_DISCOVERY_VENDOR; - service_len += 2; - query_len += 2; - } else if (strcmp(args[0], "QueryData") == 0 || - strcmp(args[0], "ResponseData") == 0) { - wifidirect_level = - WIFIDIRECT_DISCOVERY_QUERY_RESPONSE_PER_PROTOCOL; - } else if (strcmp(args[0], "ServiceProtocol") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_SERVICEPROTO, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->service_protocol = - (t_u8)atoi(args[1]); - vendor_len++; - service_len++; - query_len++; - /* - * For uPnP, due to union allocation, a extra byte is allocated - * reduce it here for uPnP - */ - cmd_len--; - } else if (strcmp(args[0], "ServiceUpdateIndicator") == 0) { - if (is_input_valid - (WIFIDIRECT_SERVICEUPDATE_INDICATOR, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->service_update_indicator = - cpu_to_le16((t_u16)atoi(args[1])); - service_len += 2; - query_len += 2; - } else if (strcmp(args[0], "ServiceTransactionId") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_SERVICETRANSACID, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->service_transaction_id = - (t_u8)atoi(args[1]); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "ServiceStatus") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_SERVICE_STATUS, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->disc_status_code = - (t_u8)atoi(args[1]); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "DNSName") == 0) { - if (args[1][0] == '"') { - args[1]++; - if (args[1][strlen(args[1]) - 1] == '"') - args[1][strlen(args[1]) - 1] = '\0'; - - dns_len = strlen(args[1]); - tmp_buffer = realloc(buffer, cmd_len + dns_len); - if (!tmp_buffer) { - printf("ERR:Cannot add DNS name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (req_resp) - strncpy((char *)resp_buf->disc_resp.u. - bonjour.dns, args[1], - strlen(args[1])); - } else { - /* HEX input */ - dns_len = arg_num - 1; - tmp_buffer = realloc(buffer, cmd_len + dns_len); - if (!tmp_buffer) { - printf("ERR:Cannot add DNS name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - for (i = 0; i < arg_num - 1; i++) { - if (req_resp) - resp_buf->disc_resp.u.bonjour. - dns[i] = - (t_u8) - A2HEXDECIMAL(args - [i + 1]); - } - } - cmd_len += dns_len; - vendor_len += dns_len; - service_len += dns_len; - query_len += dns_len; - } else if (strcmp(args[0], "DNSType") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_DNSTYPE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - *(&resp_buf->disc_resp.u.bonjour.dns_type + - dns_len) = (t_u8)A2HEXDECIMAL(args[1]); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "BonjourVersion") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_BONJOUR_VERSION, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - *(&resp_buf->disc_resp.u.bonjour.version + - dns_len) = (t_u8)atoi(args[1]); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "uPnPVersion") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_UPNP_VERSION, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->disc_resp.u.upnp.version = - (t_u8)A2HEXDECIMAL(args[1]); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "uPnPQueryValue") == 0 || - strcmp(args[0], "uPnPResponseValue") == 0) { - if (args[1][0] == '"') { - args[1]++; - if (args[1][strlen(args[1]) - 1] == '"') - args[1][strlen(args[1]) - 1] = '\0'; - - upnp_len = strlen(args[1]); - tmp_buffer = - realloc(buffer, cmd_len + upnp_len); - if (!tmp_buffer) { - printf("ERR:Cannot add uPnP value to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (req_resp) - strncpy((char *)resp_buf->disc_resp.u. - upnp.value, args[1], upnp_len); - } else { - /* HEX input */ - upnp_len = arg_num - 1; - tmp_buffer = - realloc(buffer, cmd_len + upnp_len); - if (!tmp_buffer) { - printf("ERR:Cannot add uPnP value to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - for (i = 0; i < arg_num - 1; i++) { - if (req_resp) - resp_buf->disc_resp.u.upnp. - value[i] = - (t_u8) - A2HEXDECIMAL(args - [i + 1]); - } - } - cmd_len += upnp_len; - vendor_len += upnp_len; - service_len += upnp_len; - query_len += upnp_len; - } else if (strcmp(args[0], "RecordData") == 0) { - if (args[1][0] == '"') { - args[1]++; - if (args[1][strlen(args[1]) - 1] == '"') - args[1][strlen(args[1]) - 1] = '\0'; - - record_len = strlen(args[1]); - tmp_buffer = - realloc(buffer, cmd_len + record_len); - if (!tmp_buffer) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (!req_resp) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } - strncpy((char *)resp_buf->disc_resp.u.bonjour. - record, args[1], strlen(args[1])); - } else { - /* HEX input */ - record_len = arg_num - 1; - tmp_buffer = - realloc(buffer, cmd_len + record_len); - if (!tmp_buffer) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (!req_resp) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } - for (i = 0; i < arg_num - 1; i++) - resp_buf->disc_resp.u.bonjour. - record[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - - } - cmd_len += record_len; - vendor_len += record_len; - service_len += record_len; - query_len += record_len; - } else if (strcmp(args[0], "}") == 0) { - switch (wifidirect_level) { - case WIFIDIRECT_DISCOVERY_QUERY: - if (req_resp) - resp_buf->query_len = - cpu_to_le16(query_len); - break; - case WIFIDIRECT_DISCOVERY_SERVICE: - if (req_resp) - resp_buf->response_len = - cpu_to_le16(service_len); - break; - case WIFIDIRECT_DISCOVERY_VENDOR: - if (req_resp) - resp_buf->vendor_len = - cpu_to_le16(vendor_len); - break; - default: - break; - } - if (wifidirect_level) { - if (wifidirect_level == - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE) - break; - wifidirect_level--; - } - } - } - /* Send collective command */ - if (buffer) - wifidirect_ioctl((t_u8 *)buffer, &cmd_len, cmd_len); -done: - fclose(config_file); - if (buffer) - free(buffer); - if (line) - free(line); -} - -/** - * @brief Show usage information for the wifidirect_discovery commands - * - * $return N/A - */ -static void -print_wifidirect_discovery_usage(void) -{ - printf("\nUsage : wifidirect_discovery_request/response [CONFIG_FILE]\n"); - printf("CONFIG_FILE contains WIFIDIRECT service discovery payload.\n"); - return; -} - -/** - * @brief Creates a wifidirect_service_discovery request/response and - * sends to the driver - * - * Usage: "Usage : wifidirect_discovery_request/response [CONFIG_FILE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return SUCCESS or FAILURE - **/ -static void -wifidirectcmd_service_discovery(int argc, char *argv[]) -{ - wifidirect_discovery_request *req_buf = NULL; - wifidirect_discovery_response *resp_buf = NULL; - char *line = NULL; - FILE *config_file = NULL; - int i, opt, li = 0, arg_num = 0, ret = 0, wifidirect_level = 0; - char *args[30], *pos = NULL, wifidirect_mac[20], wifidirect_cmd[32]; - t_u8 dev_address[ETH_ALEN], cmd_found = 0; - t_u8 *buffer = NULL, *tmp_buffer = NULL; - t_u8 req_resp = 0; /* req = 0, resp = 1 */ - t_u16 cmd_len = 0, query_len = 0, vendor_len = 0, service_len = 0; - t_u16 dns_len = 0, record_len = 0, upnp_len = 0; - - memset(wifidirect_mac, 0, sizeof(wifidirect_mac)); - - strncpy(wifidirect_cmd, argv[2], sizeof(wifidirect_cmd) - 1); - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_discovery_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 3) { - printf("ERR:Incorrect number of arguments.\n"); - print_wifidirect_discovery_usage(); - return; - } - - /* Check if file exists */ - config_file = fopen(argv[2], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - return; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, 30); - if (!cmd_found && - strncmp(args[0], wifidirect_cmd, strlen(args[0]))) - continue; - - if (strcmp(args[0], "wifidirect_discovery_request") == 0) { - wifidirect_level = - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE; - /* For wifidirect_service_discovery, basic initialization here */ - cmd_len = sizeof(wifidirect_discovery_request); - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - req_buf = (wifidirect_discovery_request *)buffer; - req_buf->cmd_code = - HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY; - req_buf->size = cmd_len; - req_buf->seq_num = 0; - req_buf->result = 0; - cmd_found = 1; - } else if (strcmp(args[0], "wifidirect_discovery_response") == - 0) { - wifidirect_level = - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE; - req_resp = 1; - /* For wifidirect_service_discovery, basic initialization here */ - cmd_len = sizeof(wifidirect_discovery_response); - buffer = (t_u8 *)malloc(cmd_len); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - resp_buf = (wifidirect_discovery_response *)buffer; - resp_buf->cmd_code = - HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY; - resp_buf->size = cmd_len; - resp_buf->seq_num = 0; - resp_buf->result = 0; - cmd_found = 1; - - } - if (!cmd_found) - break; - if (strcmp(args[0], "PeerAddr") == 0) { - strncpy(wifidirect_mac, args[1], - sizeof(wifidirect_mac) - 1); - if ((ret = - mac2raw(wifidirect_mac, dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - (!req_resp) ? memcpy(req_buf->peer_mac_addr, - dev_address, - ETH_ALEN) : memcpy(resp_buf-> - peer_mac_addr, - dev_address, - ETH_ALEN); - - } else if (strcmp(args[0], "Category") == 0) { - if (is_input_valid - (WIFIDIRECT_CATEGORY, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - - } - (!req_resp) ? (req_buf->category = - (t_u8)atoi(args[1])) : (resp_buf-> - category = - (t_u8) - atoi(args[1])); - } else if (strcmp(args[0], "Action") == 0) { - if (is_input_valid - (WIFIDIRECT_ACTION, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->action = - (t_u8)A2HEXDECIMAL(args[1])) - : (resp_buf->action = - (t_u8)A2HEXDECIMAL(args[1])); - } else if (strcmp(args[0], "DialogToken") == 0) { - if (is_input_valid - (WIFIDIRECT_DIALOGTOKEN, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->dialog_taken = - (t_u8)atoi(args[1])) : (resp_buf-> - dialog_taken = - (t_u8) - atoi(args[1])); - } else if (strcmp(args[0], "StatusCode") == 0) { - if (req_resp) - resp_buf->status_code = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "GasComebackDelay") == 0) { - if (is_input_valid - (WIFIDIRECT_GAS_COMEBACK_DELAY, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) { - resp_buf->gas_reply = - (t_u16)A2HEXDECIMAL(args[1]); - resp_buf->gas_reply = - cpu_to_le16(resp_buf->gas_reply); - } - } else if (strcmp(args[0], "AdvertizementProtocolIE") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_ADPROTOIE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - if (!req_resp) { - for (i = 0; - i < MIN(arg_num - 1, MAX_ADPROTOIE_LEN); - i++) - req_buf->advertize_protocol_ie[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else { - for (i = 0; - i < MIN(arg_num - 1, MAX_ADPROTOIE_LEN); - i++) - resp_buf->advertize_protocol_ie[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - } else if (strcmp(args[0], "InfoId") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_INFOID, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - if (!req_resp) { - for (i = 0; - i < MIN(arg_num - 1, MAX_INFOID_LEN); i++) - req_buf->info_id[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else { - for (i = 0; - i < MIN(arg_num - 1, MAX_INFOID_LEN); i++) - resp_buf->info_id[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - query_len += arg_num - 1; - } else if (strcmp(args[0], "OUI") == 0) { - if (is_input_valid - (WIFIDIRECT_OUI, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - if (!req_resp) { - for (i = 0; i < MIN(arg_num - 1, MAX_OUI_LEN); - i++) - req_buf->oui[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else { - for (i = 0; i < MIN(arg_num - 1, MAX_OUI_LEN); - i++) - resp_buf->oui[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - service_len += arg_num - 1; - query_len += arg_num - 1; - } else if (strcmp(args[0], "OUISubType") == 0) { - if (is_input_valid - (WIFIDIRECT_OUISUBTYPE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->oui_sub_type = - (t_u8)atoi(args[1])) : (resp_buf-> - oui_sub_type = - (t_u8) - atoi(args[1])); - service_len++; - query_len++; - } else if (strcmp(args[0], "QueryRequestLen") == 0 || - strcmp(args[0], "QueryResponseLen") == 0) { - wifidirect_level = WIFIDIRECT_DISCOVERY_QUERY; - } else if (strcmp(args[0], "RequestLen") == 0 || - strcmp(args[0], "ResponseLen") == 0) { - wifidirect_level = WIFIDIRECT_DISCOVERY_SERVICE; - query_len += 2; - } else if (strcmp(args[0], "VendorLen") == 0) { - wifidirect_level = WIFIDIRECT_DISCOVERY_VENDOR; - service_len += 2; - query_len += 2; - } else if (strcmp(args[0], "QueryData") == 0 || - strcmp(args[0], "ResponseData") == 0) { - wifidirect_level = - WIFIDIRECT_DISCOVERY_QUERY_RESPONSE_PER_PROTOCOL; - } else if (strcmp(args[0], "ServiceProtocol") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_SERVICEPROTO, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (!req_resp) { - req_buf->service_protocol = (t_u8)atoi(args[1]); - /* - * For uPnP, due to union allocation, a extra byte - * is allocated reduce it here for uPnP - */ - if (req_buf->service_protocol == 2) - cmd_len--; - } else { - resp_buf->service_protocol = - (t_u8)atoi(args[1]); - if (resp_buf->service_protocol == 2) - cmd_len--; - } - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "ServiceUpdateIndicator") == 0) { - if (is_input_valid - (WIFIDIRECT_SERVICEUPDATE_INDICATOR, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->service_update_indicator = - cpu_to_le16((t_u16)atoi(args[1]))) : - (resp_buf->service_update_indicator = - cpu_to_le16((t_u16)atoi(args[1]))); - service_len += 2; - query_len += 2; - } else if (strcmp(args[0], "ServiceTransactionId") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_SERVICETRANSACID, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? (req_buf->service_transaction_id = - (t_u8)atoi(args[1])) : (resp_buf-> - service_transaction_id - = - (t_u8) - atoi(args[1])); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "ServiceStatus") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_SERVICE_STATUS, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - if (req_resp) - resp_buf->disc_status_code = - (t_u8)atoi(args[1]); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "DNSName") == 0) { - if (args[1][0] == '"') { - args[1]++; - if (args[1][strlen(args[1]) - 1] == '"') - args[1][strlen(args[1]) - 1] = '\0'; - - dns_len = strlen(args[1]); - tmp_buffer = realloc(buffer, cmd_len + dns_len); - if (!tmp_buffer) { - printf("ERR:Cannot add DNS name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - (!req_resp) ? - (strncpy - ((char *)req_buf->disc_query.u.bonjour. - dns, args[1], - strlen(args[1]))) : (strncpy((char *) - resp_buf-> - disc_resp. - u. - bonjour. - dns, - args[1], - strlen - (args - [1]))); - } else { - /* HEX input */ - dns_len = arg_num - 1; - tmp_buffer = realloc(buffer, cmd_len + dns_len); - if (!tmp_buffer) { - printf("ERR:Cannot add DNS name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (!req_resp) { - for (i = 0; i < arg_num - 1; i++) - req_buf->disc_query.u.bonjour. - dns[i] = - (t_u8) - A2HEXDECIMAL(args - [i + 1]); - } else { - for (i = 0; i < arg_num - 1; i++) - resp_buf->disc_resp.u.bonjour. - dns[i] = - (t_u8) - A2HEXDECIMAL(args - [i + 1]); - } - } - cmd_len += dns_len; - vendor_len += dns_len; - service_len += dns_len; - query_len += dns_len; - } else if (strcmp(args[0], "DNSType") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_DNSTYPE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? - (* - (&req_buf->disc_query.u.bonjour.dns_type + - dns_len) = - (t_u8)A2HEXDECIMAL(args[1])) : (*(&resp_buf-> - disc_resp.u. - bonjour. - dns_type + - dns_len) = - (t_u8) - A2HEXDECIMAL - (args[1])); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "BonjourVersion") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_BONJOUR_VERSION, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? - (* - (&req_buf->disc_query.u.bonjour.version + - dns_len) = - (t_u8)atoi(args[1])) : (*(&resp_buf->disc_resp. - u.bonjour.version + - dns_len) = - (t_u8)atoi(args[1])); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "uPnPVersion") == 0) { - if (is_input_valid - (WIFIDIRECT_DISC_UPNP_VERSION, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - (!req_resp) ? - (req_buf->disc_query.u.upnp.version = - (t_u8)A2HEXDECIMAL(args[1])) : (resp_buf-> - disc_resp.u. - upnp.version = - (t_u8) - A2HEXDECIMAL - (args[1])); - vendor_len++; - service_len++; - query_len++; - } else if (strcmp(args[0], "uPnPQueryValue") == 0 || - strcmp(args[0], "uPnPResponseValue") == 0) { - if (args[1][0] == '"') { - args[1]++; - if (args[1][strlen(args[1]) - 1] == '"') - args[1][strlen(args[1]) - 1] = '\0'; - - upnp_len = strlen(args[1]); - tmp_buffer = - realloc(buffer, cmd_len + upnp_len); - if (!tmp_buffer) { - printf("ERR:Cannot add uPnP value to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - (!req_resp) ? - (strncpy - ((char *)req_buf->disc_query.u.upnp. - value, args[1], - upnp_len)) : (strncpy((char *) - resp_buf-> - disc_resp.u. - upnp.value, - args[1], - upnp_len)); - } else { - /* HEX input */ - upnp_len = arg_num - 1; - tmp_buffer = - realloc(buffer, cmd_len + upnp_len); - if (!tmp_buffer) { - printf("ERR:Cannot add uPnP value to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (!req_resp) { - for (i = 0; i < arg_num - 1; i++) - req_buf->disc_query.u.upnp. - value[i] = - (t_u8) - A2HEXDECIMAL(args - [i + 1]); - } else { - for (i = 0; i < arg_num - 1; i++) - resp_buf->disc_resp.u.upnp. - value[i] = - (t_u8) - A2HEXDECIMAL(args - [i + 1]); - } - } - cmd_len += upnp_len; - vendor_len += upnp_len; - service_len += upnp_len; - query_len += upnp_len; - } else if (strcmp(args[0], "RecordData") == 0) { - if (args[1][0] == '"') { - args[1]++; - if (args[1][strlen(args[1]) - 1] == '"') - args[1][strlen(args[1]) - 1] = '\0'; - - record_len = strlen(args[1]); - tmp_buffer = - realloc(buffer, cmd_len + record_len); - if (!tmp_buffer) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (!req_resp) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } - strncpy((char *)resp_buf->disc_resp.u.bonjour. - record + dns_len, args[1], - strlen(args[1])); - } else { - /* HEX input */ - record_len = arg_num - 1; - tmp_buffer = - realloc(buffer, cmd_len + record_len); - if (!tmp_buffer) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } else { - buffer = tmp_buffer; - tmp_buffer = NULL; - } - if (!req_resp) { - printf("ERR:Cannot add Record name to buffer!\n"); - goto done; - } - for (i = 0; i < arg_num - 1; i++) - *(&resp_buf->disc_resp.u.bonjour. - record[i] + dns_len) = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } - cmd_len += record_len; - vendor_len += record_len; - service_len += record_len; - query_len += record_len; - } else if (strcmp(args[0], "}") == 0) { - switch (wifidirect_level) { - case WIFIDIRECT_DISCOVERY_QUERY: - (!req_resp) ? (req_buf->query_len = - cpu_to_le16(query_len)) - : (resp_buf->query_len = - cpu_to_le16(query_len)); - break; - case WIFIDIRECT_DISCOVERY_SERVICE: - (!req_resp) ? (req_buf->request_len = - cpu_to_le16(service_len)) - : (resp_buf->response_len = - cpu_to_le16(service_len)); - break; - case WIFIDIRECT_DISCOVERY_VENDOR: - (!req_resp) ? (req_buf->vendor_len = - cpu_to_le16(vendor_len)) - : (resp_buf->vendor_len = - cpu_to_le16(vendor_len)); - break; - default: - break; - } - if (wifidirect_level) { - if (wifidirect_level == - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE) - break; - wifidirect_level--; - } - } - } - /* Send collective command */ - if (buffer) - wifidirect_ioctl((t_u8 *)buffer, &cmd_len, cmd_len); -done: - fclose(config_file); - if (buffer) - free(buffer); - if (line) - free(line); -} - -/** - * @brief Show usage information for the wifidirect_config command - * - * $return N/A - */ -static void -print_wifidirect_config_usage(void) -{ - printf("\nUsage : wifidirect_config [CONFIG_FILE]\n"); - printf("\nIf CONFIG_FILE is provided, a 'set' is performed, else a 'get' is performed.\n"); - printf("CONFIG_FILE contains all WIFIDIRECT parameters.\n"); - return; -} - -/** - * @brief Read the wifidirect parameters and sends to the driver - * - * @param file_name File to open for configuration parameters. - * @param cmd_name Command Name for which parameters are read. - * @param pbuf Pointer to output buffer - * @param ie_len_wifidirect Length of wifidirect parameters to return - * @param ie_len_wps Length of WPS parameters to return - * @return SUCCESS or FAILURE - */ -static const t_u8 wifidirect_oui[] = { 0x50, 0x6F, 0x9A, 0x09 }; -static const t_u8 wps_oui[] = { 0x00, 0x50, 0xF2, 0x04 }; - -static void -wifidirect_file_params_config(char *file_name, char *cmd_name, t_u8 *pbuf, - t_u16 *ie_len_wifidirect, t_u16 *ie_len_wps) -{ - FILE *config_file = NULL; - char *line = NULL; - int i = 0, li = 0, arg_num = 0, ret = 0, wifidirect_level = - 0, no_of_chan_entries = 0, no_of_noa = 0; - int secondary_index = -1, flag = 1, group_secondary_index = -1; - char **args = NULL; - char *pos = NULL; - char wifidirect_mac[20], country[4], wifidirect_ssid[33]; - char WPS_manufacturer[33], WPS_modelname[33], WPS_devicename[33], - wifi_group_direct_ssid[33]; - t_u8 dev_channels[MAX_CHANNELS]; - t_u8 iface_list[ETH_ALEN * MAX_INTERFACE_ADDR_COUNT]; - t_u8 dev_address[ETH_ALEN]; - t_u8 group_dev_address[ETH_ALEN]; - t_u8 *extra = NULL; - t_u8 *buffer = pbuf; - t_u16 cmd_len_wifidirect = 0, cmd_len_wps = 0, tlv_len = 0, extra_len = - 0, temp = 0; - t_u16 wps_model_len = 0, wps_serial_len = 0, wps_vendor_len = 0; - t_u16 pri_category = 0, pri_sub_category = 0, config_methods = 0; - t_u16 sec_category = 0, sec_sub_category = 0, group_sec_sub_category = - 0, group_sec_category = 0; - t_u16 avail_period = 0, avail_interval = 0; - t_u8 secondary_oui[4], group_secondary_oui[4]; - t_u16 WPS_specconfigmethods = 0, WPS_associationstate = 0, - WPS_configurationerror = 0, WPS_devicepassword = 0; - t_u8 dev_capability = 0, group_capability = 0, cmd_found = 0, - group_owner_intent = 0, primary_oui[4], iface_count = 0, - regulatory_class = 0, channel_number = 0, manageability = 0, - op_regulatory_class = 0, op_channel_number = - 0, invitation_flag = 0; - t_u8 WPS_version = 0, WPS_setupstate = 0, WPS_requesttype = - 0, WPS_responsetype = - 0, WPS_UUID[WPS_UUID_MAX_LEN], - WPS_primarydevicetype[WPS_DEVICE_TYPE_MAX_LEN], WPS_RFband = - 0, WPS_modelnumber[32], WPS_serialnumber[32], WPS_VendorExt[32]; - t_u8 go_config_timeout = 0, client_config_timeout = 0; - t_u8 secondary_dev_count = 0, group_secondary_dev_count = 0; - t_u16 temp16 = 0; - t_u8 secondary_dev_info[WPS_DEVICE_TYPE_LEN * - MAX_SECONDARY_DEVICE_COUNT]; - t_u8 group_secondary_dev_info[WPS_DEVICE_TYPE_LEN * - MAX_GROUP_SECONDARY_DEVICE_COUNT]; - t_u8 wifidirect_client_dev_count = 0, wifidirect_client_dev_index = - 0, temp8 = 0; - wifidirect_client_dev_info - wifidirect_client_dev_info_list[MAX_SECONDARY_DEVICE_COUNT]; - t_u8 wifidirect_total_secondary_dev_count = 0; - t_u8 wifidirect_group_total_ssid_len = 0, tlv_offset = - 0, temp_dev_size = 0; - t_u8 noa_index = 0, opp_ps = 0, ctwindow_opp_ps = 0, count_type = 0; - t_u32 duration = 0, interval = 0, start_time = 0; - t_u16 total_chan_len = 0; - t_u8 chan_entry_regulatory_class = 0, chan_entry_num_of_channels = 0; - t_u8 *chan_entry_list = NULL; - t_u8 *chan_buf = NULL; - noa_descriptor noa_descriptor_list[MAX_NOA_DESCRIPTORS]; - /* Check if file exists */ - config_file = fopen(file_name, "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - return; - } - - /* Memory allocations */ - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - extra = (t_u8 *)malloc(MAX_CONFIG_LINE); - if (!extra) { - printf("ERR:Cannot allocate memory for extra\n"); - goto done; - } - memset(extra, 0, MAX_CONFIG_LINE); - - args = (char **)malloc(sizeof(char *) * MAX_ARGS_NUM); - if (!args) { - printf("ERR:Cannot allocate memory for args\n"); - goto done; - } - memset(args, 0, (sizeof(char *) * MAX_ARGS_NUM)); - - if (!wifidir_use_fixed_ie_indices()) { - special_mask_custom_ie_buf *wifidirect_ie_buf; - wifidirect_ie_buf = (special_mask_custom_ie_buf *)buffer; - memcpy(&wifidirect_ie_buf->Oui[0], wifidirect_oui, - sizeof(wifidirect_oui)); - cmd_len_wifidirect += sizeof(wifidirect_oui); - } - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, MAX_ARGS_NUM); - if (!cmd_found && strncmp(args[0], cmd_name, strlen(args[0]))) - continue; - cmd_found = 1; - if (strcmp(args[0], "wifidirect_config") == 0) { - wifidirect_level = WIFIDIRECT_PARAMS_CONFIG; - } else if (strcmp(args[0], "Capability") == 0) { - wifidirect_level = WIFIDIRECT_CAPABILITY_CONFIG; - } else if (strcmp(args[0], "GroupOwnerIntent") == 0) { - wifidirect_level = WIFIDIRECT_GROUP_OWNER_INTENT_CONFIG; - } else if (strcmp(args[0], "Channel") == 0) { - wifidirect_level = WIFIDIRECT_CHANNEL_CONFIG; - } else if (strcmp(args[0], "OperatingChannel") == 0) { - wifidirect_level = WIFIDIRECT_OPCHANNEL_CONFIG; - } else if (strcmp(args[0], "InfrastructureManageabilityInfo") == - 0) { - wifidirect_level = WIFIDIRECT_MANAGEABILITY_CONFIG; - } else if (strcmp(args[0], "InvitationFlagBitmap") == 0) { - wifidirect_level = WIFIDIRECT_INVITATION_FLAG_CONFIG; - } else if (strcmp(args[0], "ChannelList") == 0) { - wifidirect_level = WIFIDIRECT_CHANNEL_LIST_CONFIG; - } else if (strcmp(args[0], "NoticeOfAbsence") == 0) { - wifidirect_level = WIFIDIRECT_NOTICE_OF_ABSENCE; - } else if (strcmp(args[0], "NoA_descriptor") == 0) { - wifidirect_level = WIFIDIRECT_NOA_DESCRIPTOR; - } else if (strcmp(args[0], "DeviceInfo") == 0) { - wifidirect_level = WIFIDIRECT_DEVICE_INFO_CONFIG; - } else if (strcmp(args[0], "SecondaryDeviceType") == 0) { - wifidirect_level = WIFIDIRECT_DEVICE_SEC_INFO_CONFIG; - } else if (strcmp(args[0], "GroupInfo") == 0) { - wifidirect_level = WIFIDIRECT_GROUP_INFO_CONFIG; - } else if (strcmp(args[0], "GroupSecondaryDeviceTypes") == 0) { - wifidirect_level = WIFIDIRECT_GROUP_SEC_INFO_CONFIG; - } else if (strcmp(args[0], "GroupWifiDirectDeviceTypes") == 0) { - wifidirect_level = WIFIDIRECT_GROUP_CLIENT_INFO_CONFIG; - } else if (strcmp(args[0], "GroupId") == 0) { - wifidirect_level = WIFIDIRECT_GROUP_ID_CONFIG; - } else if (strcmp(args[0], "GroupBSSId") == 0) { - wifidirect_level = WIFIDIRECT_GROUP_BSS_ID_CONFIG; - } else if (strcmp(args[0], "DeviceId") == 0) { - wifidirect_level = WIFIDIRECT_DEVICE_ID_CONFIG; - } else if (strcmp(args[0], "Interface") == 0) { - wifidirect_level = WIFIDIRECT_INTERFACE_CONFIG; - } else if (strcmp(args[0], "ConfigurationTimeout") == 0) { - wifidirect_level = WIFIDIRECT_TIMEOUT_CONFIG; - } else if (strcmp(args[0], "ExtendedListenTime") == 0) { - wifidirect_level = WIFIDIRECT_EXTENDED_TIME_CONFIG; - } else if (strcmp(args[0], "IntendedIntfAddress") == 0) { - wifidirect_level = WIFIDIRECT_INTENDED_ADDR_CONFIG; - } else if (strcmp(args[0], "WPSIE") == 0) { - wifidirect_level = WIFIDIRECT_WPSIE; - } else if (strcmp(args[0], "Extra") == 0) { - wifidirect_level = WIFIDIRECT_EXTRA; - } else if (strcmp(args[0], "WIFIDIRECT_MAC") == 0 || - strcmp(args[0], "GroupAddr") == 0 || - strcmp(args[0], "GroupBssId") == 0 || - strcmp(args[0], "InterfaceAddress") == 0 || - strcmp(args[0], "GroupInterfaceAddress") == 0 || - strcmp(args[0], "DeviceAddress") == 0) { - strncpy(wifidirect_mac, args[1], 20 - 1); - if ((ret = - mac2raw(wifidirect_mac, dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - } else if (strncmp(args[0], "GroupWifiDirectDeviceAddress", 21) - == 0) { - strncpy(wifidirect_mac, args[1], 20 - 1); - if ((ret = - mac2raw(wifidirect_mac, - group_dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - wifidirect_client_dev_index++; - if (wifidirect_client_dev_index > - wifidirect_client_dev_count) { - printf("ERR: No of Client Dev count is less than no of client dev configs!!\n"); - goto done; - } - group_secondary_index = 0; - tlv_offset = - wifidirect_group_total_ssid_len + - wifidirect_total_secondary_dev_count * - WPS_DEVICE_TYPE_LEN; - memcpy(wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_dev_address + tlv_offset, - group_dev_address, ETH_ALEN); - } else if (strncmp(args[0], "GroupWifiDirectIntfAddress", 19) == - 0) { - strncpy(wifidirect_mac, args[1], 20 - 1); - if ((ret = - mac2raw(wifidirect_mac, - group_dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - memcpy(wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_intf_address + tlv_offset, - group_dev_address, ETH_ALEN); - } else if (strncmp(args[0], "GroupWifiDirectDeviceCapab", 19) == - 0) { - if (is_input_valid - (WIFIDIRECT_DEVICECAPABILITY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - temp8 = (t_u8)atoi(args[1]); - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_dev_capability + tlv_offset, - &temp8, sizeof(temp8)); - } else if (strncmp - (args[0], "GroupWifiDirectWPSConfigMethods", - 24) == 0) { - if (is_input_valid - (WIFIDIRECT_WPSCONFMETHODS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - temp16 = (t_u16)A2HEXDECIMAL(args[1]); - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].config_methods + tlv_offset, &temp16, - sizeof(temp16)); - (t_u16)A2HEXDECIMAL(args[1]); - } else if (strncmp - (args[0], "GroupPrimaryDeviceTypeCategory", - 30) == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPECATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - pri_category = (t_u16)atoi(args[1]); - temp16 = htons(pri_category); - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].primary_category + tlv_offset, &temp16, - sizeof(temp16)); - } else if (strncmp(args[0], "GroupPrimaryDeviceTypeOUI", 25) == - 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPEOUI, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < 4; i++) { - temp8 = (t_u8)A2HEXDECIMAL(args[i + 1]); - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].primary_oui[i] - + tlv_offset, &temp8, sizeof(temp8)); - } - } else if (strncmp - (args[0], "GroupPrimaryDeviceTypeSubCategory", - 33) == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPESUBCATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - pri_sub_category = (t_u16)atoi(args[1]); - temp16 = htons(pri_sub_category); - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].primary_subcategory + tlv_offset, &temp16, - sizeof(temp16)); - } else if (strncmp(args[0], "GroupSecondaryDeviceCount", 25) == - 0) { - if (is_input_valid - (WIFIDIRECT_GROUP_SECONDARYDEVCOUNT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - group_secondary_dev_count = (t_u8)atoi(args[1]); - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_secondary_dev_count + tlv_offset, - &group_secondary_dev_count, - sizeof(group_secondary_dev_count)); - wifidirect_total_secondary_dev_count += - group_secondary_dev_count; - if (group_secondary_dev_count) - memset(group_secondary_dev_info, 0, - sizeof(group_secondary_dev_info)); - } else if (strncmp - (args[0], "GroupSecondaryDeviceTypeCategory", - 30) == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPECATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - sec_category = (t_u16)atoi(args[1]); - group_sec_category = cpu_to_le16(sec_category); - group_secondary_index++; - } else if (strncmp(args[0], "GroupSecondaryDeviceTypeOUI", 27) - == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPEOUI, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < 4; i++) - group_secondary_oui[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else if (strncmp - (args[0], "GroupSecondaryDeviceTypeSubCategory", - 35) == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPESUBCATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - if (group_secondary_index < 0 || - group_secondary_index >= - MAX_SECONDARY_DEVICE_COUNT) { - printf("Error in configuration file %s:%d", - file_name, li); - goto done; - } - sec_sub_category = (t_u16)atoi(args[1]); - group_sec_sub_category = - cpu_to_le16(group_sec_sub_category); - if (group_secondary_dev_count) { - memcpy(&group_secondary_dev_info - [(group_secondary_index - - 1) * WPS_DEVICE_TYPE_LEN], - &group_sec_category, sizeof(t_u16)); - memcpy(&group_secondary_dev_info - [((group_secondary_index - - 1) * WPS_DEVICE_TYPE_LEN) + 2], - group_secondary_oui, - sizeof(secondary_oui)); - memcpy(&group_secondary_dev_info - [((group_secondary_index - - 1) * WPS_DEVICE_TYPE_LEN) + 6], - &group_sec_sub_category, sizeof(t_u16)); - } - - } else if (strncmp(args[0], "GroupWifiDirectDeviceCount", 19) == - 0) { - if (is_input_valid - (WIFIDIRECT_SECONDARYDEVCOUNT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - wifidirect_client_dev_count = (t_u8)atoi(args[1]); - } else if (strncmp(args[0], "GroupWifiDirectDeviceName", 18) == - 0) { - - if (is_input_valid - (WIFIDIRECT_GROUP_WIFIDIRECT_DEVICE_NAME, - arg_num - 1, args + 1) != SUCCESS) { - goto done; - } - - strncpy(wifi_group_direct_ssid, args[1] + 1, - strlen(args[1]) - 2); - wifi_group_direct_ssid[strlen(args[1]) - 2] = '\0'; - temp = htons(SC_Device_Name); - memcpy(((t_u8 *) - &wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_device_name_type + tlv_offset), - &temp, sizeof(temp)); - temp = htons(strlen(wifi_group_direct_ssid)); - memcpy(((t_u8 *) - &wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_device_name_len + tlv_offset), - &temp, sizeof(temp)); - memset(((t_u8 *) - &wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_device_name + tlv_offset), 0, - strlen(wifi_group_direct_ssid)); - memcpy(((t_u8 *) - &wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].wifidirect_device_name + tlv_offset), - &wifi_group_direct_ssid, - strlen(wifi_group_direct_ssid)); - wifidirect_group_total_ssid_len += - strlen(wifi_group_direct_ssid); - - if (wifidirect_client_dev_index - 1) { - temp_dev_size = - sizeof(wifidirect_client_dev_info) + - strlen(wifi_group_direct_ssid) + - group_secondary_dev_count * - WPS_DEVICE_TYPE_LEN; - memcpy(&wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].dev_length + (tlv_offset - - (group_secondary_dev_count - * - WPS_DEVICE_TYPE_LEN)), - &temp_dev_size, sizeof(temp_dev_size)); - } else { - - temp_dev_size = - sizeof(wifidirect_client_dev_info) + - strlen(wifi_group_direct_ssid) + - group_secondary_dev_count * - WPS_DEVICE_TYPE_LEN; - wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - 1].dev_length = - sizeof(wifidirect_client_dev_info) + - strlen(wifi_group_direct_ssid) + - group_secondary_dev_count * - WPS_DEVICE_TYPE_LEN; - } - } else if (strcmp(args[0], "DeviceCapability") == 0) { - if (is_input_valid - (WIFIDIRECT_DEVICECAPABILITY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - dev_capability = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "GroupCapability") == 0) { - if (is_input_valid - (WIFIDIRECT_GROUPCAPABILITY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - group_capability = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "Intent") == 0) { - /* Intent -> 0 - 15 */ - if (is_input_valid - (WIFIDIRECT_INTENT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - group_owner_intent = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "RegulatoryClass") == 0) { - if (is_input_valid - (WIFIDIRECT_REGULATORYCLASS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - regulatory_class = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "ChannelNumber") == 0) { - if (is_input_valid(CHANNEL, arg_num - 1, args + 1) != - SUCCESS) { - goto done; - } - channel_number = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "OpRegulatoryClass") == 0) { - if (is_input_valid - (WIFIDIRECT_REGULATORYCLASS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - op_regulatory_class = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "OpChannelNumber") == 0) { - if (is_input_valid(CHANNEL, arg_num - 1, args + 1) != - SUCCESS) { - goto done; - } - op_channel_number = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "Manageability") == 0) { - if (is_input_valid - (WIFIDIRECT_MANAGEABILITY, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - manageability = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "InvitationFlag") == 0) { - if (is_input_valid - (WIFIDIRECT_INVITATIONFLAG, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - invitation_flag = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "CountryString") == 0) { - if (is_input_valid - (WIFIDIRECT_COUNTRY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - strncpy(country, args[1] + 1, 3); - country[strlen(args[1]) - 2] = '\0'; - } else if (strncmp(args[0], "Regulatory_Class_", 17) == 0) { - if (is_input_valid - (WIFIDIRECT_REGULATORYCLASS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - if (!no_of_chan_entries) { - chan_entry_list = - (t_u8 *)malloc(MAX_BUFFER_SIZE); - if (!chan_entry_list) { - printf("ERR:cannot allocate memory for chan_entry_list!\n"); - goto done; - } - memset(chan_entry_list, 0, MAX_BUFFER_SIZE); - chan_buf = chan_entry_list; - } - no_of_chan_entries++; - chan_entry_regulatory_class = (t_u8)atoi(args[1]); - } else if (strncmp(args[0], "NumofChannels", 13) == 0) { - if (is_input_valid - (WIFIDIRECT_NO_OF_CHANNELS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - chan_entry_num_of_channels = (t_u8)atoi(args[1]); - } else if (strncmp(args[0], "ChanList", 8) == 0) { - if (chan_entry_num_of_channels != (arg_num - 1)) { - printf("ERR:no of channels in ChanList and NumofChannels do not match!\n"); - goto done; - } - if (is_input_valid(SCANCHANNELS, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - for (i = 0; i < chan_entry_num_of_channels; i++) - dev_channels[i] = (t_u8)atoi(args[i + 1]); - total_chan_len += chan_entry_num_of_channels; - memcpy(chan_buf, &chan_entry_regulatory_class, - sizeof(t_u8)); - memcpy(chan_buf + 1, &chan_entry_num_of_channels, - sizeof(t_u8)); - memcpy(chan_buf + 2, dev_channels, - chan_entry_num_of_channels); - chan_buf += - sizeof(t_u8) + sizeof(t_u8) + - chan_entry_num_of_channels; - } else if (strcmp(args[0], "NoA_Index") == 0) { - if (is_input_valid - (WIFIDIRECT_NOA_INDEX, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - noa_index = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "OppPS") == 0) { - if (is_input_valid - (WIFIDIRECT_OPP_PS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - opp_ps = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "CTWindow") == 0) { - if (is_input_valid - (WIFIDIRECT_CTWINDOW, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - if ((opp_ps != 0) && (atoi(args[1]) < 10)) { - printf("ERR: CTwindow should be greater than or equal to 10 if opp_ps is set!\n"); - goto done; - } - ctwindow_opp_ps = - (t_u8)atoi(args[1]) | SET_OPP_PS(opp_ps); - } else if (strncmp(args[0], "CountType", 9) == 0) { - if (is_input_valid - (WIFIDIRECT_COUNT_TYPE, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - no_of_noa++; - if (no_of_noa > MAX_NOA_DESCRIPTORS) { - printf("Number of descriptors should not be greater than %d\n", MAX_NOA_DESCRIPTORS); - goto done; - } - count_type = (t_u8)atoi(args[1]); - noa_descriptor_list[no_of_noa - 1].count_type = - count_type; - } else if (strncmp(args[0], "Duration", 8) == 0) { - if (is_input_valid - (WIFIDIRECT_DURATION, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - duration = (t_u32)atoi(args[1]); - duration = cpu_to_le32(duration); - noa_descriptor_list[no_of_noa - 1].duration = duration; - } else if (strncmp(args[0], "Interval", 8) == 0) { - if (is_input_valid - (WIFIDIRECT_INTERVAL, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - interval = (t_u32)atoi(args[1]); - interval = cpu_to_le32(interval); - noa_descriptor_list[no_of_noa - 1].interval = interval; - } else if (strncmp(args[0], "StartTime", 9) == 0) { - if (is_input_valid - (WIFIDIRECT_START_TIME, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - start_time = (t_u32)atoi(args[1]); - start_time = cpu_to_le32(start_time); - noa_descriptor_list[no_of_noa - 1].start_time = - start_time; - } else if (strcmp(args[0], "PrimaryDeviceTypeCategory") == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPECATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - pri_category = (t_u16)atoi(args[1]); - } else if (strcmp(args[0], "PrimaryDeviceTypeOUI") == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPEOUI, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < 4; i++) - primary_oui[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else if (strcmp(args[0], "PrimaryDeviceTypeSubCategory") == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPESUBCATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - pri_sub_category = (t_u16)atoi(args[1]); - } else if (strcmp(args[0], "SecondaryDeviceCount") == 0) { - if (is_input_valid - (WIFIDIRECT_SECONDARYDEVCOUNT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - secondary_dev_count = (t_u8)atoi(args[1]); - if (secondary_dev_count) - memset(secondary_dev_info, 0, - sizeof(secondary_dev_info)); - } else if (strncmp(args[0], "SecondaryDeviceTypeCategory", 27) - == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPECATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - sec_category = (t_u16)atoi(args[1]); - sec_category = htons(sec_category); - secondary_index++; - } else if (strncmp(args[0], "SecondaryDeviceTypeOUI", 22) == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPEOUI, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < 4; i++) - secondary_oui[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else if (strncmp - (args[0], "SecondaryDeviceTypeSubCategory", - 30) == 0) { - if (is_input_valid - (WIFIDIRECT_PRIDEVTYPESUBCATEGORY, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - if (secondary_index < 0 || - secondary_index >= MAX_SECONDARY_DEVICE_COUNT) { - printf("Error in configuration file %s:%d", - file_name, li); - goto done; - } - sec_sub_category = (t_u16)atoi(args[1]); - sec_sub_category = htons(sec_sub_category); - if (secondary_dev_count) { - memcpy(&secondary_dev_info - [secondary_index * WPS_DEVICE_TYPE_LEN], - &sec_category, sizeof(t_u16)); - memcpy(&secondary_dev_info - [(secondary_index * - WPS_DEVICE_TYPE_LEN) + 2], - secondary_oui, sizeof(secondary_oui)); - memcpy(&secondary_dev_info - [(secondary_index * - WPS_DEVICE_TYPE_LEN) + 6], - &sec_sub_category, sizeof(t_u16)); - } - } else if (strcmp(args[0], "InterfaceAddressCount") == 0) { - if (is_input_valid - (WIFIDIRECT_INTERFACECOUNT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - iface_count = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "InterfaceAddressList") == 0) { - if (iface_count != (arg_num - 1)) { - printf("Incorrect address list for %d entries.\n", iface_count); - goto done; - } - for (i = 0; - i < iface_count && i < MAX_INTERFACE_ADDR_COUNT; - i++) { - if ((ret = - mac2raw(args[i + 1], - &iface_list[i * ETH_ALEN])) != - SUCCESS) { - printf("ERR: %s Address \n", - ret == - FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - } - } else if (strcmp(args[0], "GroupConfigurationTimeout") == 0) { - if (is_input_valid - (WIFIDIRECT_ATTR_CONFIG_TIMEOUT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - go_config_timeout = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "ClientConfigurationTimeout") == 0) { - if (is_input_valid - (WIFIDIRECT_ATTR_CONFIG_TIMEOUT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - client_config_timeout = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "AvailabilityPeriod") == 0) { - if (is_input_valid - (WIFIDIRECT_ATTR_EXTENDED_TIME, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - avail_period = (t_u16)atoi(args[1]); - } else if (strcmp(args[0], "AvailabilityInterval") == 0) { - if (is_input_valid - (WIFIDIRECT_ATTR_EXTENDED_TIME, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - avail_interval = (t_u16)atoi(args[1]); - } else if (strcmp(args[0], "WPSConfigMethods") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSCONFMETHODS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - config_methods = (t_u16)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "DeviceName") == 0 || - strcmp(args[0], "GroupSsId") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSDEVICENAME, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - memset(wifidirect_ssid, 0, sizeof(wifidirect_ssid)); - strncpy(wifidirect_ssid, args[1], - sizeof(wifidirect_ssid) - 1); - } else if (strcmp(args[0], "WPSVersion") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSVERSION, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_version = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSSetupState") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSSETUPSTATE, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_setupstate = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSDeviceName") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSDEVICENAME, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - memset(WPS_devicename, 0, sizeof(WPS_devicename)); - strncpy(WPS_devicename, args[1], - sizeof(WPS_devicename) - 1); - } else if (strcmp(args[0], "WPSRequestType") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSREQRESPTYPE, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_requesttype = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSResponseType") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSREQRESPTYPE, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_responsetype = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSSpecConfigMethods") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSSPECCONFMETHODS, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_specconfigmethods = (t_u16)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSUUID") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSUUID, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < WPS_UUID_MAX_LEN; i++) - WPS_UUID[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); - } else if (strcmp(args[0], "WPSPrimaryDeviceType") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSPRIMARYDEVICETYPE, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < WPS_DEVICE_TYPE_MAX_LEN; i++) - WPS_primarydevicetype[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - } else if (strcmp(args[0], "WPSRFBand") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSRFBAND, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_RFband = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSAssociationState") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSASSOCIATIONSTATE, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_associationstate = (t_u16)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSConfigurationError") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSCONFIGURATIONERROR, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_configurationerror = (t_u16)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSDevicePassword") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSDEVICEPASSWORD, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - WPS_devicepassword = (t_u16)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "WPSManufacturer") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSMANUFACTURER, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - memset(WPS_manufacturer, 0, sizeof(WPS_manufacturer)); - strncpy(WPS_manufacturer, args[1], - sizeof(WPS_manufacturer)); - } else if (strcmp(args[0], "WPSModelName") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSMODELNAME, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - memset(WPS_modelname, 0, sizeof(WPS_modelname)); - strncpy(WPS_modelname, args[1], sizeof(WPS_modelname)); - } else if (strcmp(args[0], "WPSModelNumber") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSMODELNUMBER, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < arg_num - 1; i++) - WPS_modelnumber[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - wps_model_len = arg_num - 1; - } else if (strcmp(args[0], "WPSSerialNumber") == 0) { - if (is_input_valid - (WIFIDIRECT_WPSSERIALNUMBER, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - for (i = 0; i < arg_num - 1; i++) - WPS_serialnumber[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - wps_serial_len = arg_num - 1; - } else if (strcmp(args[0], "WPSVendorExtension") == 0) { - for (i = 0; i < arg_num - 1; i++) - WPS_VendorExt[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - wps_vendor_len = arg_num - 1; - } else if (strcmp(args[0], "Buffer") == 0) { - for (i = 0; i < arg_num - 1; i++) - extra[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); - extra_len = arg_num - 1; - } else if (strcmp(args[0], "}") == 0) { - /* Based on level, populate appropriate struct */ - switch (wifidirect_level) { - case WIFIDIRECT_DEVICE_ID_CONFIG: - { - tlvbuf_wifidirect_device_id *tlv = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_device_id); - tlv = (tlvbuf_wifidirect_device_id - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_DEVICE_ID; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->dev_mac_address, - dev_address, ETH_ALEN); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_CAPABILITY_CONFIG: - { - tlvbuf_wifidirect_capability *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_capability); - tlv = (tlvbuf_wifidirect_capability - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_CAPABILITY; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->dev_capability = dev_capability; - tlv->group_capability = - group_capability; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_GROUP_OWNER_INTENT_CONFIG: - { - tlvbuf_wifidirect_group_owner_intent - *tlv = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_group_owner_intent); - tlv = (tlvbuf_wifidirect_group_owner_intent *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->dev_intent = group_owner_intent; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_MANAGEABILITY_CONFIG: - { - tlvbuf_wifidirect_manageability *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_manageability); - tlv = (tlvbuf_wifidirect_manageability - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_MANAGEABILITY; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->manageability = manageability; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_INVITATION_FLAG_CONFIG: - { - tlvbuf_wifidirect_invitation_flag *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_invitation_flag); - tlv = (tlvbuf_wifidirect_invitation_flag - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_INVITATION_FLAG; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->invitation_flag |= invitation_flag; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_CHANNEL_LIST_CONFIG: - { - tlvbuf_wifidirect_channel_list *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_channel_list) - + - no_of_chan_entries * - sizeof(chan_entry) + - total_chan_len; - tlv = (tlvbuf_wifidirect_channel_list - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_CHANNEL_LIST; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->country_string, country, 3); - if (tlv->country_string[2] == 0) - tlv->country_string[2] = - WIFIDIRECT_COUNTRY_LAST_BYTE; - memcpy(tlv->wifidirect_chan_entry_list, - chan_entry_list, - (tlv->length - 3)); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_NOTICE_OF_ABSENCE: - { - tlvbuf_wifidirect_notice_of_absence *tlv - = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_notice_of_absence) - + - no_of_noa * - sizeof(noa_descriptor); - tlv = (tlvbuf_wifidirect_notice_of_absence *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->noa_index = noa_index; - tlv->ctwindow_opp_ps = ctwindow_opp_ps; - memcpy(tlv-> - wifidirect_noa_descriptor_list, - noa_descriptor_list, - no_of_noa * - sizeof(noa_descriptor)); - endian_convert_tlv_wifidirect_header_out - (tlv); - flag = 1; - break; - } - case WIFIDIRECT_NOA_DESCRIPTOR: - { - wifidirect_level = - WIFIDIRECT_NOTICE_OF_ABSENCE; - flag = 0; - break; - } - case WIFIDIRECT_CHANNEL_CONFIG: - { - tlvbuf_wifidirect_channel *tlv = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_channel); - tlv = (tlvbuf_wifidirect_channel - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = TLV_TYPE_WIFIDIRECT_CHANNEL; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->country_string, country, 3); - if (tlv->country_string[2] == 0) - tlv->country_string[2] = - WIFIDIRECT_COUNTRY_LAST_BYTE; - tlv->regulatory_class = - regulatory_class; - tlv->channel_number = channel_number; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_OPCHANNEL_CONFIG: - { - tlvbuf_wifidirect_channel *tlv = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_channel); - tlv = (tlvbuf_wifidirect_channel - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_OPCHANNEL; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->country_string, country, 3); - if (tlv->country_string[2] == 0) - tlv->country_string[2] = - WIFIDIRECT_COUNTRY_LAST_BYTE; - tlv->regulatory_class = - op_regulatory_class; - tlv->channel_number = op_channel_number; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - - case WIFIDIRECT_DEVICE_INFO_CONFIG: - { - tlvbuf_wifidirect_device_info *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_device_info) - + - secondary_dev_count * - WPS_DEVICE_TYPE_LEN + - strlen(wifidirect_ssid); - tlv = (tlvbuf_wifidirect_device_info - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_DEVICE_INFO; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->dev_address, dev_address, - ETH_ALEN); - tlv->config_methods = - htons(config_methods); - tlv->primary_category = - htons(pri_category); - memcpy(tlv->primary_oui, primary_oui, - 4); - tlv->primary_subcategory = - htons(pri_sub_category); - tlv->secondary_dev_count = - secondary_dev_count; - endian_convert_tlv_wifidirect_header_out - (tlv); - /* Parameters within secondary_dev_info are already htons'ed */ - memcpy(tlv->secondary_dev_info, - secondary_dev_info, - secondary_dev_count * - WPS_DEVICE_TYPE_LEN); - temp = htons(SC_Device_Name); - memcpy(((t_u8 *)(&tlv-> - device_name_type)) + - secondary_dev_count * - WPS_DEVICE_TYPE_LEN, &temp, - sizeof(temp)); - temp = htons(strlen(wifidirect_ssid)); - memcpy(((t_u8 *)(&tlv-> - device_name_len)) + - secondary_dev_count * - WPS_DEVICE_TYPE_LEN, &temp, - sizeof(temp)); - memcpy(((t_u8 *)(&tlv->device_name)) + - secondary_dev_count * - WPS_DEVICE_TYPE_LEN, - wifidirect_ssid, - strlen(wifidirect_ssid)); - flag = 1; - break; - } - case WIFIDIRECT_GROUP_INFO_CONFIG: - { - tlvbuf_wifidirect_group_info *tlv = - NULL; - /* Append a new TLV */ - tlv_offset = - wifidirect_group_total_ssid_len - + - wifidirect_total_secondary_dev_count - * WPS_DEVICE_TYPE_LEN; - tlv_len = - sizeof - (tlvbuf_wifidirect_group_info) - + - wifidirect_client_dev_count * - sizeof - (wifidirect_client_dev_info) + - tlv_offset; - tlv = (tlvbuf_wifidirect_group_info - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_GROUP_INFO; - tlv->length = tlv_len; - memcpy(tlv->wifidirect_client_dev_list, - wifidirect_client_dev_info_list, - wifidirect_client_dev_count * - sizeof - (wifidirect_client_dev_info) + - tlv_offset); - /* Parameters within secondary_dev_info are already htons'ed */ - //wps_hexdump(DEBUG_WLAN,"Group Info Hexdump:", (t_u8*)tlv, tlv_len); - endian_convert_tlv_wifidirect_header_out - (tlv); - flag = 1; - break; - } - case WIFIDIRECT_GROUP_SEC_INFO_CONFIG: - { - wifidirect_level = - WIFIDIRECT_GROUP_CLIENT_INFO_CONFIG; - - if (wifidirect_client_dev_index && - group_secondary_index) { - memset(((t_u8 *) - &wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - - 1]. - wifidirect_secondary_dev_info - + tlv_offset), 0, - group_secondary_index * - WPS_DEVICE_TYPE_LEN); - memcpy(((t_u8 *) - &wifidirect_client_dev_info_list - [wifidirect_client_dev_index - - - 1]. - wifidirect_secondary_dev_info - + tlv_offset), - &group_secondary_dev_info, - group_secondary_index * - WPS_DEVICE_TYPE_LEN); - } - tlv_offset = - wifidirect_group_total_ssid_len - + - wifidirect_total_secondary_dev_count - * WPS_DEVICE_TYPE_LEN; - flag = 0; - break; - } - case WIFIDIRECT_GROUP_CLIENT_INFO_CONFIG: - { - wifidirect_level = - WIFIDIRECT_GROUP_INFO_CONFIG; - flag = 0; - break; - } - case WIFIDIRECT_DEVICE_SEC_INFO_CONFIG: - { - wifidirect_level = - WIFIDIRECT_DEVICE_INFO_CONFIG; - flag = 0; - break; - } - case WIFIDIRECT_GROUP_ID_CONFIG: - { - tlvbuf_wifidirect_group_id *tlv = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_group_id) + - strlen(wifidirect_ssid); - tlv = (tlvbuf_wifidirect_group_id - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = TLV_TYPE_WIFIDIRECT_GROUP_ID; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->group_address, dev_address, - ETH_ALEN); - memcpy(tlv->group_ssid, wifidirect_ssid, - strlen(wifidirect_ssid)); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_GROUP_BSS_ID_CONFIG: - { - tlvbuf_wifidirect_group_bss_id *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_group_bss_id); - tlv = (tlvbuf_wifidirect_group_bss_id - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->group_bssid, dev_address, - ETH_ALEN); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_INTERFACE_CONFIG: - { - tlvbuf_wifidirect_interface *tlv = NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_interface) - + iface_count * ETH_ALEN; - tlv = (tlvbuf_wifidirect_interface - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_INTERFACE; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->interface_id, dev_address, - ETH_ALEN); - tlv->interface_count = iface_count; - memcpy(tlv->interface_idlist, - iface_list, - iface_count * ETH_ALEN); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - - case WIFIDIRECT_TIMEOUT_CONFIG: - { - tlvbuf_wifidirect_config_timeout *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_config_timeout); - tlv = (tlvbuf_wifidirect_config_timeout - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->group_config_timeout = - go_config_timeout; - tlv->device_config_timeout = - client_config_timeout; - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_EXTENDED_TIME_CONFIG: - { - tlvbuf_wifidirect_ext_listen_time *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_ext_listen_time); - tlv = (tlvbuf_wifidirect_ext_listen_time - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - tlv->availability_period = - le16_to_cpu(avail_period); - tlv->availability_interval = - le16_to_cpu(avail_interval); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - case WIFIDIRECT_INTENDED_ADDR_CONFIG: - { - tlvbuf_wifidirect_intended_addr *tlv = - NULL; - /* Append a new TLV */ - tlv_len = - sizeof - (tlvbuf_wifidirect_intended_addr); - tlv = (tlvbuf_wifidirect_intended_addr - *)(buffer + cmd_len_wifidirect); - cmd_len_wifidirect += tlv_len; - /* Set TLV fields */ - tlv->tag = - TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS; - tlv->length = - tlv_len - (sizeof(t_u8) + - sizeof(t_u16)); - memcpy(tlv->group_address, dev_address, - ETH_ALEN); - endian_convert_tlv_wifidirect_header_out - (tlv); - break; - } - - case WIFIDIRECT_WPSIE: - { -#ifdef DEBUG - /* Debug print */ - hexdump(buffer, cmd_len_wifidirect, - ' '); -#endif - /* Append TLV for WPSVersion */ - tlvbuf_wps_ie *tlv = NULL; - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_version); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - - if (!wifidir_use_fixed_ie_indices()) { - special_mask_custom_ie_buf - *wps_ie_buf; - wps_ie_buf = - (special_mask_custom_ie_buf - *)tlv; - memcpy(&wps_ie_buf->Oui[0], - wps_oui, - sizeof(wps_oui)); - cmd_len_wps += sizeof(wps_oui); - } - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Version; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - *(tlv->data) = WPS_version; - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSSetupState */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_setupstate); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Simple_Config_State; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - *(tlv->data) = WPS_setupstate; - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSRequestType */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_requesttype); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Request_Type; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - *(tlv->data) = WPS_requesttype; - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSResponseType */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_responsetype); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Response_Type; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - *(tlv->data) = WPS_responsetype; - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSSpecConfigMethods */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_specconfigmethods); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Config_Methods; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - temp = htons(WPS_specconfigmethods); - memcpy((t_u16 *)tlv->data, &temp, - sizeof(temp)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSUUID */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_UUID); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_UUID_E; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_UUID, - WPS_UUID_MAX_LEN); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSPrimaryDeviceType */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_primarydevicetype); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Primary_Device_Type; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_primarydevicetype, - WPS_DEVICE_TYPE_MAX_LEN); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSRFBand */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_RFband); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_RF_Band; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - *(tlv->data) = WPS_RFband; - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSAssociationState */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_associationstate); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Association_State; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - temp = htons(WPS_associationstate); - memcpy((t_u16 *)tlv->data, &temp, - sizeof(temp)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSConfigurationError */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_configurationerror); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Configuration_Error; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - temp = htons(WPS_configurationerror); - memcpy((t_u16 *)tlv->data, &temp, - sizeof(temp)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSDevicePassword */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - sizeof(WPS_devicepassword); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Device_Password_ID; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - temp = htons(WPS_devicepassword); - memcpy((t_u16 *)tlv->data, &temp, - sizeof(temp)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSDeviceName */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - strlen(WPS_devicename); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Device_Name; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_devicename, - strlen(WPS_devicename)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSManufacturer */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - strlen(WPS_manufacturer); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Manufacturer; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_manufacturer, - strlen(WPS_manufacturer)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSModelName */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - strlen(WPS_modelname); - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Model_Name; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_modelname, - strlen(WPS_modelname)); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSModelNumber */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - wps_model_len; - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Model_Number; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_modelnumber, - wps_model_len); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSSerialNumber */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - wps_serial_len; - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Serial_Number; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_serialnumber, - wps_serial_len); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; - - /* Append TLV for WPSVendorExtension */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - wps_vendor_len; - tlv = (tlvbuf_wps_ie *)(buffer + - cmd_len_wifidirect - + - sizeof - (custom_ie) + - cmd_len_wps); - tlv->tag = SC_Vendor_Extension; - tlv->length = - tlv_len - 2 * sizeof(t_u16); - memcpy(tlv->data, WPS_VendorExt, - wps_vendor_len); - endian_convert_tlv_wps_header_out(tlv); - cmd_len_wps += tlv_len; -#ifdef DEBUG - /* Debug print */ - hexdump(buffer + sizeof(custom_ie) + - cmd_len_wifidirect, cmd_len_wps, - ' '); -#endif - break; - } - case WIFIDIRECT_EXTRA: - { - memcpy(buffer + cmd_len_wifidirect, - extra, extra_len); - cmd_len_wifidirect += extra_len; - break; - } - default: - *ie_len_wifidirect = cmd_len_wifidirect; - if (ie_len_wps) - *ie_len_wps = cmd_len_wps; - break; - } - memset(country, 0, sizeof(country)); - if (wifidirect_level == 0) - cmd_found = 0; - if (flag) - wifidirect_level = 0; - } - } - -done: - fclose(config_file); - if (chan_entry_list) - free(chan_entry_list); - if (line) - free(line); - if (extra) - free(extra); - if (args) - free(args); - return; -} - -/** - * @brief Process and send ie config command - * @param ie_index A pointer to the IE buffer index - * @param data_len_wifidirect Length of WIFIDIRECT data, 0 to get, else set. - * @param data_len_wps Length of WPS data, 0 to get, else set. - * @param buf Pointer to buffer to set. - * @return SUCCESS--success, FAILURE--fail - */ -static int -wifidirect_ie_config(t_u16 *ie_index, t_u16 data_len_wifidirect, - t_u16 data_len_wps, t_u8 *buf) -{ - struct iwreq iwr; - t_s32 sockfd; - int i, ret = SUCCESS; - tlvbuf_custom_ie *tlv = NULL; - custom_ie *ie_ptr = NULL; - - tlv = (tlvbuf_custom_ie *)buf; - tlv->tag = MRVL_MGMT_IE_LIST_TLV_ID; - /* Locate headers */ - ie_ptr = (custom_ie *)(tlv->ie_data); - - /* Set TLV fields : WIFIDIRECT IE parameters */ - if (data_len_wifidirect) { - /* Set IE */ -#define MGMT_MASK_AUTO 0xffff - ie_ptr->mgmt_subtype_mask = MGMT_MASK_AUTO; - tlv->length = sizeof(custom_ie) + data_len_wifidirect; - ie_ptr->ie_length = data_len_wifidirect; - ie_ptr->ie_index = *ie_index; - } else { - /* Get WPS IE */ - tlv->length = 0; - } - - if (!wifidir_use_fixed_ie_indices()) { - if (*ie_index != 0xFFFF) { - (*ie_index)++; - } - } else { - (*ie_index)++; - } - /* Locate headers */ - ie_ptr = (custom_ie *)((t_u8 *)(tlv->ie_data) + sizeof(custom_ie) + - data_len_wifidirect); - - /* Set WPS IE parameters */ - if (data_len_wps) { - /* Set IE */ - /* Firmware Handled IE - mask should be set to -1 */ - ie_ptr->mgmt_subtype_mask = MGMT_MASK_AUTO; - tlv->length += sizeof(custom_ie) + data_len_wps; - ie_ptr->ie_length = data_len_wps; - ie_ptr->ie_index = *ie_index; - } - - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, (char *)dev_name, IFNAMSIZ - 1); - - iwr.u.data.pointer = (void *)buf; - iwr.u.data.length = - ((2 * sizeof(custom_ie)) + sizeof(tlvbuf_custom_ie) + - data_len_wifidirect + data_len_wps); - iwr.u.data.flags = 0; - - /* - * create a socket - */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("Cannot open socket.\n"); - ret = FAILURE; - goto _exit_; - } - - if (ioctl(sockfd, CUSTOM_IE, &iwr)) { - perror("ioctl[CUSTOM_IE]"); - printf("Failed to set/get/clear the IE buffer\n"); - ret = FAILURE; - close(sockfd); - goto _exit_; - } - close(sockfd); - -/** Max IE index */ -#define MAX_MGMT_IE_INDEX 12 - - if (!data_len_wifidirect) { - /* Get the IE buffer index number for MGMT_IE_LIST_TLV */ - tlv = (tlvbuf_custom_ie *)buf; - *ie_index = 0xFFFF; - if (tlv->tag == MRVL_MGMT_IE_LIST_TLV_ID) { - ie_ptr = (custom_ie *)(tlv->ie_data); - for (i = 0; i < MAX_MGMT_IE_INDEX; i++) { - /* zero mask indicates a wps IE, return previous index */ - if (ie_ptr->mgmt_subtype_mask == MGMT_MASK_AUTO - && ie_ptr->ie_length) { - *ie_index = ie_ptr->ie_index; - break; - } - if (i < (MAX_MGMT_IE_INDEX - 1)) - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) - + - ie_ptr-> - ie_length); - } - } - if (*ie_index == 0xFFFF) { - ret = FAILURE; - } - } -_exit_: - - return ret; -} - -/** - * @brief Creates a wifidirect_config request and sends to the driver - * - * Usage: "Usage : wifidirect_config [CONFIG_FILE]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirectcmd_config(int argc, char *argv[]) -{ - t_u8 *buf = NULL, *ptr, *dev_ptr, *array_ptr; - t_u16 ie_len_wifidirect = 0, ie_len_wps = 0, ie_len; - t_u16 ie_index, temp; - int i, opt, ret = SUCCESS; - tlvbuf_custom_ie *tlv = NULL; - custom_ie *ie_ptr = NULL; - t_u16 len = 0, len_wifidirect = 0; - t_u8 type = 0; - t_u16 wps_len = 0, wps_type = 0; - - if (!wifidir_use_fixed_ie_indices()) { - ie_index = 0xFFFF; - } else { - ie_index = 0; - } - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_config_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR:wrong number of arguments.\n"); - print_wifidirect_config_usage(); - return; - } - buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buf) { - printf("ERR:Cannot allocate memory!\n"); - return; - } - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - if (argc >= 3) { - /* Read parameters and send command to firmware */ - wifidirect_file_params_config(argv[2], argv[1], buf - + sizeof(tlvbuf_custom_ie) + - sizeof(custom_ie), - &ie_len_wifidirect, &ie_len_wps); - if (argc == 4) { - ie_index = atoi(argv[3]); - if (ie_index >= 4) { - printf("ERR:wrong argument %s.\n", argv[3]); - return; - } - } - if (ie_len_wifidirect > MAX_SIZE_IE_BUFFER || - ie_len_wps > MAX_SIZE_IE_BUFFER) { - printf("ERR:IE parameter size exceeds limit in %s.\n", - argv[2]); - free(buf); - return; - } - ie_len = ie_len_wifidirect + ie_len_wps + - sizeof(tlvbuf_custom_ie) + (2 * sizeof(custom_ie)); - if (ie_len >= MRVDRV_SIZE_OF_CMD_BUFFER) { - printf("ERR:Too much data in configuration file %s.\n", - argv[2]); - free(buf); - return; - } -#ifdef DEBUG - hexdump(buf, ie_len, ' '); -#endif - ret = wifidirect_ie_config(&ie_index, ie_len_wifidirect, - ie_len_wps, buf); - if (ret != SUCCESS) { - printf("ERR:Could not set wifidirect parameters\n"); - } - } else { - ret = wifidirect_ie_config(&ie_index, 0, 0, buf); - /* Print response */ - if (ret == SUCCESS && ie_index < 3) { - tlv = (tlvbuf_custom_ie *)buf; - if (tlv->tag == MRVL_MGMT_IE_LIST_TLV_ID) { - ie_ptr = (custom_ie *)(tlv->ie_data); - /* Goto appropriate Ie Index */ - for (i = 0; i < ie_index; i++) { - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) - + - ie_ptr-> - ie_length); - } - ie_len_wifidirect = ie_ptr->ie_length; - ptr = ie_ptr->ie_buffer; - /* Locate headers */ - printf("WIFIDIRECT settings:\n"); - if (!wifidir_use_fixed_ie_indices()) { - while (memcmp - (ptr, wifidirect_oui, - sizeof(wifidirect_oui))) { - ie_ptr = (custom_ie *)((t_u8 *) - ie_ptr + - sizeof - (custom_ie) - + - ie_ptr-> - ie_length); - ie_len_wifidirect = - ie_ptr->ie_length; - ptr = ie_ptr->ie_buffer; - } - ptr += sizeof(wifidirect_oui); - ie_len_wifidirect -= - sizeof(wifidirect_oui); - } - while (ie_len_wifidirect > - WIFIDIRECT_IE_HEADER_LEN) { - type = *ptr; - memcpy(&len, ptr + 1, sizeof(t_u16)); - len = le16_to_cpu(len); - switch (type) { - case TLV_TYPE_WIFIDIRECT_DEVICE_ID: - { - tlvbuf_wifidirect_device_id - *wifidirect_tlv - = - (tlvbuf_wifidirect_device_id - *)ptr; - printf("\t Device ID - "); - print_mac - (wifidirect_tlv-> - dev_mac_address); - printf("\n"); - } - break; - - case TLV_TYPE_WIFIDIRECT_CAPABILITY: - { - tlvbuf_wifidirect_capability - *wifidirect_tlv - = - (tlvbuf_wifidirect_capability - *)ptr; - printf("\t Device capability = %d\n", (int)wifidirect_tlv->dev_capability); - printf("\t Group capability = %d\n", (int)wifidirect_tlv->group_capability); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT: - { - tlvbuf_wifidirect_group_owner_intent - *wifidirect_tlv - = - (tlvbuf_wifidirect_group_owner_intent - *)ptr; - printf("\t Group owner intent = %d\n", (int)wifidirect_tlv->dev_intent); - } - break; - case TLV_TYPE_WIFIDIRECT_MANAGEABILITY: - { - tlvbuf_wifidirect_manageability - *wifidirect_tlv - = - (tlvbuf_wifidirect_manageability - *)ptr; - printf("\t Manageability = %d\n", (int)wifidirect_tlv->manageability); - } - break; - case TLV_TYPE_WIFIDIRECT_CHANNEL_LIST: - { - tlvbuf_wifidirect_channel_list - *wifidirect_tlv - = - (tlvbuf_wifidirect_channel_list - *)ptr; - chan_entry *temp_ptr; - printf("\t Country String \"%c%c\"", wifidirect_tlv->country_string[0], wifidirect_tlv->country_string[1]); - if (isalpha - (wifidirect_tlv-> - country_string[2])) - printf("\"%c\"", - wifidirect_tlv-> - country_string - [2]); - printf("\n"); - temp_ptr = - (chan_entry *) - wifidirect_tlv-> - wifidirect_chan_entry_list; - len_wifidirect = - le16_to_cpu - (wifidirect_tlv-> - length) - - (sizeof - (tlvbuf_wifidirect_channel_list) - - - WIFIDIRECT_IE_HEADER_LEN); - if (len_wifidirect) - printf("\t Channel List :- \n"); - while (len_wifidirect) { - printf("\t\t Regulatory_class = %d\n", (int)(temp_ptr->regulatory_class)); - printf("\t\t No of channels = %d\n", (int)temp_ptr->num_of_channels); - printf("\t\t Channel list = "); - for (i = 0; - i < - temp_ptr-> - num_of_channels; - i++) { - printf("%d ", *(temp_ptr->chan_list + i)); - } - len_wifidirect - -= - sizeof - (chan_entry) - + - temp_ptr-> - num_of_channels; - temp_ptr = - (chan_entry - *)((t_u8 *)temp_ptr + sizeof(chan_entry) + temp_ptr->num_of_channels); - printf("\n"); - } - } - break; - case TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE: - { - tlvbuf_wifidirect_notice_of_absence - *wifidirect_tlv - = - (tlvbuf_wifidirect_notice_of_absence - *)ptr; - noa_descriptor - *temp_ptr; - printf("\t Notice of Absence index = %d\n", (int)wifidirect_tlv->noa_index); - printf("\t CTWindow and opportunistic PS parameters = %d\n", (int)wifidirect_tlv->ctwindow_opp_ps); - temp_ptr = - (noa_descriptor - *) - wifidirect_tlv-> - wifidirect_noa_descriptor_list; - len_wifidirect = - le16_to_cpu - (wifidirect_tlv-> - length) - - (sizeof - (tlvbuf_wifidirect_notice_of_absence) - - - WIFIDIRECT_IE_HEADER_LEN); - while (len_wifidirect) { - printf("\t Count or Type = %d\n", (int)temp_ptr->count_type); - printf("\t Duration = %dms\n", le32_to_cpu(temp_ptr->duration)); - printf("\t Interval = %dms\n", le32_to_cpu(temp_ptr->interval)); - printf("\t Start Time = %d\n", le32_to_cpu(temp_ptr->start_time)); - printf("\n"); - temp_ptr += - sizeof - (noa_descriptor); - len_wifidirect - -= - sizeof - (noa_descriptor); - } - } - break; - case TLV_TYPE_WIFIDIRECT_DEVICE_INFO: - { - tlvbuf_wifidirect_device_info - *wifidirect_tlv - = - (tlvbuf_wifidirect_device_info - *)ptr; - printf("\t Device address - "); - print_mac - (wifidirect_tlv-> - dev_address); - printf("\n"); - /* display config_methods */ - printf("\t Config methods - 0x%02X\n", ntohs(wifidirect_tlv->config_methods)); - printf("\t Primary device type = %02d-%02X%02X%02X%02X-%02d\n", (int)ntohs(wifidirect_tlv->primary_category), (int)wifidirect_tlv->primary_oui[0], (int)wifidirect_tlv->primary_oui[1], (int)wifidirect_tlv->primary_oui[2], (int)wifidirect_tlv->primary_oui[3], (int)ntohs(wifidirect_tlv->primary_subcategory)); - printf("\t Secondary Device Count = %d\n", (int)wifidirect_tlv->secondary_dev_count); - array_ptr = - wifidirect_tlv-> - secondary_dev_info; - for (i = 0; - i < - wifidirect_tlv-> - secondary_dev_count; - i++) { - memcpy(&temp, - array_ptr, - sizeof - (t_u16)); - printf("\t\t Secondary device type = %02d-", ntohs(temp)); - array_ptr += - sizeof - (temp); - printf("%02X%02X%02X%02X", array_ptr[0], array_ptr[1], array_ptr[2], array_ptr[3]); - array_ptr += 4; - memcpy(&temp, - array_ptr, - sizeof - (t_u16)); - printf("-%02d\n", ntohs(temp)); - array_ptr += - sizeof - (temp); - } - array_ptr = - wifidirect_tlv-> - device_name + - wifidirect_tlv-> - secondary_dev_count - * - WPS_DEVICE_TYPE_LEN; - dev_ptr = - (((t_u8 - *) - (&wifidirect_tlv-> - device_name_len)) - + - wifidirect_tlv-> - secondary_dev_count - * - WPS_DEVICE_TYPE_LEN); - if (*(t_u16 *)dev_ptr) - printf("\t Device Name = "); - memcpy(&temp, dev_ptr, - sizeof(t_u16)); - for (i = 0; - i < ntohs(temp); - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUP_INFO: - { - tlvbuf_wifidirect_group_info - *wifidirect_tlv - = - (tlvbuf_wifidirect_group_info - *)ptr; - t_u8 no_of_wifidirect_clients = 0, wifidirect_client_dev_length = 0; - wifidirect_client_dev_info - *temp_ptr; - temp_ptr = - (wifidirect_client_dev_info - *) - wifidirect_tlv-> - wifidirect_client_dev_list; - if (temp_ptr == NULL) - break; - wifidirect_client_dev_length - = - temp_ptr-> - dev_length; - temp = le16_to_cpu - (wifidirect_tlv-> - length) - - wifidirect_client_dev_length; - while (temp && temp_ptr) { - - printf("\t Group WifiDirect Client Device address - "); - print_mac - (temp_ptr-> - wifidirect_dev_address); - printf("\n"); - printf("\t Group WifiDirect Client Interface address - "); - print_mac - (temp_ptr-> - wifidirect_intf_address); - printf("\n"); - printf("\t Group WifiDirect Client Device capability = %d\n", (int)temp_ptr->wifidirect_dev_capability); - printf("\t Group WifiDirect Client Config methods - 0x%02X\n", ntohs(temp_ptr->config_methods)); - printf("\t Group WifiDirect Client Primay device type = %02d-%02X%02X%02X%02X-%02d\n", (int)ntohs(temp_ptr->primary_category), (int)temp_ptr->primary_oui[0], (int)temp_ptr->primary_oui[1], (int)temp_ptr->primary_oui[2], (int)temp_ptr->primary_oui[3], (int)ntohs(temp_ptr->primary_subcategory)); - printf("\t Group WifiDirect Client Secondary Device Count = %d\n", (int)temp_ptr->wifidirect_secondary_dev_count); - array_ptr = - temp_ptr-> - wifidirect_secondary_dev_info; - for (i = 0; - i < - temp_ptr-> - wifidirect_secondary_dev_count; - i++) { - memcpy(&temp, array_ptr, sizeof(t_u16)); - printf("\t Group WifiDirect Client Secondary device type = %02d-", ntohs(temp)); - array_ptr - += - sizeof - (temp); - printf("%02X%02X%02X%02X", array_ptr[0], array_ptr[1], array_ptr[2], array_ptr[3]); - array_ptr - += - 4; - memcpy(&temp, array_ptr, sizeof(t_u16)); - printf("-%02d\n", ntohs(temp)); - array_ptr - += - sizeof - (temp); - } - /* display device name */ - array_ptr = - temp_ptr-> - wifidirect_device_name - + - temp_ptr-> - wifidirect_secondary_dev_count - * - WPS_DEVICE_TYPE_LEN; - printf("\t Group WifiDirect Device Name = "); - memcpy(&temp, - (((t_u8 - *) - (&temp_ptr-> - wifidirect_device_name_len)) - + - temp_ptr-> - wifidirect_secondary_dev_count - * - WPS_DEVICE_TYPE_LEN), - sizeof - (t_u16)); - temp = ntohs - (temp); - for (i = 0; - i < temp; - i++) - printf("%c", *array_ptr++); - printf("\n"); - temp_ptr += - wifidirect_client_dev_length; - temp -= wifidirect_client_dev_length; - no_of_wifidirect_clients++; - if (temp_ptr) - wifidirect_client_dev_length - = - temp_ptr-> - dev_length; - } - printf("\n"); - printf("\t Group WifiDirect Client Devices count = %d\n", no_of_wifidirect_clients); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUP_ID: - { - tlvbuf_wifidirect_group_id - *wifidirect_tlv - = - (tlvbuf_wifidirect_group_id - *)ptr; - printf("\t Group address - "); - print_mac - (wifidirect_tlv-> - group_address); - printf("\n"); - array_ptr = - wifidirect_tlv-> - group_ssid; - printf("\t Group ssid = "); - for (i = 0; - (unsigned int)i < - le16_to_cpu - (wifidirect_tlv-> - length) - - - (sizeof - (tlvbuf_wifidirect_group_id) - - - WIFIDIRECT_IE_HEADER_LEN); - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID: - { - tlvbuf_wifidirect_group_bss_id - *wifidirect_tlv - = - (tlvbuf_wifidirect_group_bss_id - *)ptr; - printf("\t Group BSS Id - "); - print_mac - (wifidirect_tlv-> - group_bssid); - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_INTERFACE: - { - tlvbuf_wifidirect_interface - *wifidirect_tlv - = - (tlvbuf_wifidirect_interface - *)ptr; - printf("\t Interface Id - "); - print_mac - (wifidirect_tlv-> - interface_id); - printf("\t Interface count = %d", (int)wifidirect_tlv->interface_count); - for (i = 0; - i < - wifidirect_tlv-> - interface_count; - i++) { - printf("\n\t Interface address [%d]", i + 1); - print_mac - (&wifidirect_tlv-> - interface_idlist - [i * - ETH_ALEN]); - } - printf("\n"); - } - break; - case TLV_TYPE_WIFIDIRECT_CHANNEL: - { - tlvbuf_wifidirect_channel - *wifidirect_tlv - = - (tlvbuf_wifidirect_channel - *)ptr; - printf("\t Listen Channel Country String \"%c%c\"", wifidirect_tlv->country_string[0], wifidirect_tlv->country_string[1]); - if (isalpha - (wifidirect_tlv-> - country_string[2])) - printf("\"%c\"", - wifidirect_tlv-> - country_string - [2]); - printf("\n"); - printf("\t Listern Channel regulatory class = %d\n", (int)wifidirect_tlv->regulatory_class); - printf("\t Listen Channel number = %d\n", (int)wifidirect_tlv->channel_number); - } - break; - - case TLV_TYPE_WIFIDIRECT_OPCHANNEL: - { - tlvbuf_wifidirect_channel - *wifidirect_tlv - = - (tlvbuf_wifidirect_channel - *)ptr; - printf("\t Operating Channel Country String %c%c", wifidirect_tlv->country_string[0], wifidirect_tlv->country_string[1]); - if (isalpha - (wifidirect_tlv-> - country_string[2])) - printf("%c", - wifidirect_tlv-> - country_string - [2]); - printf("\n"); - printf("\t Operating Channel regulatory class = %d\n", (int)wifidirect_tlv->regulatory_class); - printf("\t Operating Channel number = %d\n", (int)wifidirect_tlv->channel_number); - } - break; - case TLV_TYPE_WIFIDIRECT_INVITATION_FLAG: - { - tlvbuf_wifidirect_invitation_flag - *wifidirect_tlv - = - (tlvbuf_wifidirect_invitation_flag - *)ptr; - printf("\t Invitation flag = %d\n", (int)wifidirect_tlv->invitation_flag & INVITATION_FLAG_MASK); - } - break; - case TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT: - { - tlvbuf_wifidirect_config_timeout - *wifidirect_tlv - = - (tlvbuf_wifidirect_config_timeout - *)ptr; - printf("\t GO configuration timeout = %d msec\n", (int)wifidirect_tlv->group_config_timeout * 10); - printf("\t Client configuration timeout = %d msec\n", (int)wifidirect_tlv->device_config_timeout * 10); - } - break; - case TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME: - { - tlvbuf_wifidirect_ext_listen_time - *wifidirect_tlv - = - (tlvbuf_wifidirect_ext_listen_time - *)ptr; - printf("\t Availability Period = %d msec\n", (int)wifidirect_tlv->availability_period); - printf("\t Availability Interval = %d msec\n", (int)wifidirect_tlv->availability_interval); - } - break; - case TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS: - { - tlvbuf_wifidirect_intended_addr - *wifidirect_tlv - = - (tlvbuf_wifidirect_intended_addr - *)ptr; - printf("\t Intended Interface Address - "); - print_mac - (wifidirect_tlv-> - group_address); - printf("\n"); - } - break; - default: - printf("unknown ie=0x%x, len=%d\n", type, len); - break; - } - ptr += len + WIFIDIRECT_IE_HEADER_LEN; - ie_len_wifidirect -= - len + WIFIDIRECT_IE_HEADER_LEN; - } - - /* Goto next index, Locate headers */ - printf("WPS settings:\n"); - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) + - ie_ptr->ie_length); - ptr = ie_ptr->ie_buffer; - ie_len_wps = ie_ptr->ie_length; - if (!wifidir_use_fixed_ie_indices()) { - while (memcmp - (ptr, wps_oui, - sizeof(wps_oui))) { - ie_ptr = (custom_ie *)((t_u8 *) - ie_ptr + - sizeof - (custom_ie) - + - ie_ptr-> - ie_length); - ie_len_wps = ie_ptr->ie_length; - ptr = ie_ptr->ie_buffer; - } - ptr += sizeof(wps_oui); - ie_len_wifidirect -= sizeof(wps_oui); - } - while (ie_len_wps > sizeof(tlvbuf_wps_ie)) { - memcpy(&wps_type, ptr, sizeof(t_u16)); - memcpy(&wps_len, ptr + 2, - sizeof(t_u16)); - endian_convert_tlv_wps_header_in - (wps_type, wps_len); - switch (wps_type) { - case SC_Version: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - printf("\t WPS Version = 0x%2x\n", *(wps_tlv->data)); - } - break; - case SC_Simple_Config_State: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - printf("\t WPS setupstate = 0x%x\n", *(wps_tlv->data)); - } - break; - case SC_Request_Type: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - printf("\t WPS RequestType = 0x%x\n", *(wps_tlv->data)); - } - break; - case SC_Response_Type: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - printf("\t WPS ResponseType = 0x%x\n", *(wps_tlv->data)); - } - break; - case SC_Config_Methods: - { - t_u16 wps_config_methods - = 0; - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - memcpy(&wps_config_methods, wps_tlv->data, sizeof(t_u16)); - wps_config_methods = - ntohs - (wps_config_methods); - printf("\t WPS SpecConfigMethods = 0x%x\n", wps_config_methods); - } - break; - case SC_UUID_E: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS UUID = "); - for (i = 0; i < wps_len; - i++) - printf("%2X ", - *array_ptr++); - printf("\n"); - } - break; - case SC_Primary_Device_Type: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Primary Device Type = "); - for (i = 0; i < wps_len; - i++) - printf("%02X ", - *array_ptr++); - printf("\n"); - } - break; - case SC_RF_Band: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - printf("\t WPS RF Band = 0x%x\n", *(wps_tlv->data)); - } - break; - case SC_Association_State: - { - t_u16 wps_association_state = 0; - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - memcpy(&wps_association_state, wps_tlv->data, sizeof(t_u16)); - printf("\t WPS Association State = 0x%x\n", wps_association_state); - } - break; - case SC_Configuration_Error: - { - t_u16 wps_configuration_error = 0; - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - memcpy(&wps_configuration_error, wps_tlv->data, sizeof(t_u16)); - wps_configuration_error - = - ntohs - (wps_configuration_error); - printf("\t WPS Configuration Error = 0x%x\n", wps_configuration_error); - } - break; - case SC_Device_Password_ID: - { - t_u16 wps_device_password_id = 0; - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - memcpy(&wps_device_password_id, wps_tlv->data, sizeof(t_u16)); - wps_device_password_id = - ntohs - (wps_device_password_id); - printf("\t WPS Device Password ID = 0x%x\n", wps_device_password_id); - } - break; - case SC_Device_Name: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Device Name = "); - for (i = 0; i < wps_len; - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case SC_Manufacturer: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Manufacturer = "); - for (i = 0; i < wps_len; - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case SC_Model_Name: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Model Name = "); - for (i = 0; i < wps_len; - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case SC_Model_Number: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Model Number = "); - for (i = 0; i < wps_len; - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case SC_Serial_Number: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Serial Number = "); - for (i = 0; i < wps_len; - i++) - printf("%c", - *array_ptr++); - printf("\n"); - } - break; - case SC_Vendor_Extension: - { - tlvbuf_wps_ie *wps_tlv = - (tlvbuf_wps_ie - *)ptr; - array_ptr = - wps_tlv->data; - printf("\t WPS Vendor Extension = "); - for (i = 0; i < wps_len; - i++) - printf("0x%02x ", *array_ptr++); - printf("\n"); - } - break; - default: - printf("unknown ie=0x%x, len=%d\n", wps_type, wps_len); - break; - } - ptr += wps_len + sizeof(tlvbuf_wps_ie); - ie_len_wps -= - wps_len + sizeof(tlvbuf_wps_ie); - } - } - } else { - printf("ERR:Could not retrieve wifidirect parameters\n"); - } - } - - free(buf); - return; -} - -/** - * @brief Show usage information for the wifidirect_params_config command - * - * $return N/A - */ -static void -print_wifidirect_params_config_usage(void) -{ - printf("\nUsage : wifidirect_params_config \n"); - printf("\nIssue set or get request using parameters in the CONFIG_FILE.\n"); - return; -} - -/** - * @brief Creates a wifidirect_params_config request and sends to the driver - * - * Usage: "Usage : wifidirect_params_config " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirectcmd_params_config(int argc, char *argv[]) -{ - wifidirect_params_config *param_buf = NULL; - tlvbuf_wps_ie *new_tlv = NULL; - char *line = NULL, wifidirect_mac[20]; - FILE *config_file = NULL; - int i, opt, li = 0, arg_num = 0, ret = 0; - char *args[30], *pos = NULL; - t_u8 dev_address[ETH_ALEN], enable_scan; - t_u8 *buffer = NULL, WPS_primarydevicetype[WPS_DEVICE_TYPE_MAX_LEN]; - t_u16 device_state = 0, tlv_len = 0, max_disc_int = 0, min_disc_int = - 0, cmd_len = 0; - - memset(wifidirect_mac, 0, sizeof(wifidirect_mac)); - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_params_config_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR:wrong number of arguments.\n"); - print_wifidirect_params_config_usage(); - return; - } - - cmd_len = sizeof(wifidirect_params_config); - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - param_buf = (wifidirect_params_config *)buffer; - param_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - param_buf->seq_num = 0; - param_buf->result = 0; - - if (argc >= 3) { - /* Check if file exists */ - config_file = fopen(argv[2], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - goto done; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - param_buf->action = cpu_to_le16(ACTION_SET); - - /* Parse file and process */ - while (config_get_line - (line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, 30); - - if (strcmp(args[0], "EnableScan") == 0) { - if (is_input_valid - (WIFIDIRECT_ENABLE_SCAN, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - - } - enable_scan = (t_u8)atoi(args[1]); - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_wps_ie) + sizeof(t_u8); - new_tlv = (tlvbuf_wps_ie *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - new_tlv->tag = - MRVL_WIFIDIRECT_SCAN_ENABLE_TLV_ID; - new_tlv->length = tlv_len - 2 * sizeof(t_u16); - memcpy(new_tlv->data, &enable_scan, - sizeof(t_u8)); - endian_convert_tlv_header_out(new_tlv); - - } else if (strcmp(args[0], "ScanPeerDeviceId") == 0) { - strncpy(wifidirect_mac, args[1], - sizeof(wifidirect_mac) - 1); - if ((ret = - mac2raw(wifidirect_mac, - dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == - FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_wps_ie) + ETH_ALEN; - new_tlv = (tlvbuf_wps_ie *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - new_tlv->tag = - MRVL_WIFIDIRECT_PEER_DEVICE_TLV_ID; - new_tlv->length = tlv_len - 2 * sizeof(t_u16); - memcpy(new_tlv->data, dev_address, ETH_ALEN); - endian_convert_tlv_header_out(new_tlv); - - } else if (strcmp(args[0], "MinDiscoveryInterval") == 0) { - if (is_input_valid - (WIFIDIRECT_MINDISCOVERYINT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - min_disc_int = cpu_to_le16(atoi(args[1])); - } else if (strcmp(args[0], "MaxDiscoveryInterval") == 0) { - if (is_input_valid - (WIFIDIRECT_MAXDISCOVERYINT, arg_num - 1, - args + 1) != SUCCESS) { - goto done; - } - max_disc_int = cpu_to_le16(atoi(args[1])); - - /* Append a new TLV */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - 2 * sizeof(t_u16); - new_tlv = (tlvbuf_wps_ie *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - new_tlv->tag = - MRVL_WIFIDIRECT_DISC_PERIOD_TLV_ID; - new_tlv->length = tlv_len - 2 * sizeof(t_u16); - memcpy(&new_tlv->data, &min_disc_int, - sizeof(t_u16)); - memcpy((((t_u8 *)&new_tlv->data) + - sizeof(t_u16)), &max_disc_int, - sizeof(t_u16)); - endian_convert_tlv_header_out(new_tlv); - - } else if (strcmp(args[0], "ScanRequestDeviceType") == - 0) { - if (is_input_valid - (WIFIDIRECT_WPSPRIMARYDEVICETYPE, - arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - for (i = 0; i < WPS_DEVICE_TYPE_MAX_LEN; i++) - WPS_primarydevicetype[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - - /* Append a new TLV */ - tlv_len = - sizeof(tlvbuf_wps_ie) + - WPS_DEVICE_TYPE_MAX_LEN; - new_tlv = (tlvbuf_wps_ie *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - new_tlv->tag = - MRVL_WIFIDIRECT_SCAN_REQ_DEVICE_TLV_ID; - new_tlv->length = tlv_len - 2 * sizeof(t_u16); - memcpy(&new_tlv->data, WPS_primarydevicetype, - WPS_DEVICE_TYPE_MAX_LEN); - endian_convert_tlv_header_out(new_tlv); - - } else if (strcmp(args[0], "DeviceState") == 0) { - if (is_input_valid - (WIFIDIRECT_DEVICE_STATE, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - device_state = - cpu_to_le16((t_u16)atoi(args[1])); - - /* Append a new TLV */ - tlv_len = sizeof(tlvbuf_wps_ie) + sizeof(t_u16); - new_tlv = (tlvbuf_wps_ie *)(buffer + cmd_len); - cmd_len += tlv_len; - /* Set TLV fields */ - new_tlv->tag = - MRVL_WIFIDIRECT_DEVICE_STATE_TLV_ID; - new_tlv->length = tlv_len - 2 * sizeof(t_u16); - memcpy(new_tlv->data, &device_state, - sizeof(t_u16)); - endian_convert_tlv_header_out(new_tlv); - } - } - } - - param_buf->size = cmd_len; - /* Send collective command */ - wifidirect_ioctl((t_u8 *)buffer, &cmd_len, MRVDRV_SIZE_OF_CMD_BUFFER); - - /* Process response */ - if (argc < 3) { - /* Verify response */ - if (param_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (param_buf->result == CMD_SUCCESS) { - param_buf = (wifidirect_params_config *)buffer; - new_tlv = (tlvbuf_wps_ie *)param_buf->wifidirect_tlv; - tlv_len = - param_buf->size - - (sizeof(wifidirect_params_config) - - BUF_HEADER_SIZE); - if (tlv_len > sizeof(tlvbuf_wps_ie)) - printf("WifiDirect Parameter settings: \n"); - else - printf("WifiDirect Parameter settings are not received.\n"); - while (tlv_len > sizeof(tlvbuf_wps_ie)) { - endian_convert_tlv_header_in(new_tlv); - switch (new_tlv->tag) { - case MRVL_WIFIDIRECT_SCAN_ENABLE_TLV_ID: - { - enable_scan = - *((t_u8 *)&new_tlv-> - data); - printf("\t Scan %s\n", - (enable_scan == - 1) ? "enabled." : - "disabled."); - } - break; - case MRVL_WIFIDIRECT_PEER_DEVICE_TLV_ID: - { - memcpy(dev_address, - new_tlv->data, ETH_ALEN); - printf("\t Peer Device ID : "); - print_mac(dev_address); - printf("\n"); - } - break; - case MRVL_WIFIDIRECT_DISC_PERIOD_TLV_ID: - { - t_u16 temp; - memcpy(&temp, &new_tlv->data, - sizeof(t_u16)); - printf("\t Minimum Discovery Interval : %d\n", le16_to_cpu(temp)); - memcpy(&temp, - ((t_u8 *)&new_tlv-> - data) + sizeof(t_u16), - sizeof(t_u16)); - printf("\t Maximum Discovery Interval : %d\n", le16_to_cpu(temp)); - } - break; - case MRVL_WIFIDIRECT_SCAN_REQ_DEVICE_TLV_ID: - { - memcpy(WPS_primarydevicetype, - &new_tlv->data, - WPS_DEVICE_TYPE_MAX_LEN); - printf("\tType: %02x:%02x\n", - (unsigned int) - WPS_primarydevicetype[0], - (unsigned int) - WPS_primarydevicetype - [1]); - printf("\tOUI: %02x:%02x:%02x:%02x\n", (unsigned int)WPS_primarydevicetype[2], (unsigned int)WPS_primarydevicetype[3], (unsigned int)WPS_primarydevicetype[4], (unsigned int)WPS_primarydevicetype[5]); - printf("\tSubType: %02x:%02x\n", - (unsigned int) - WPS_primarydevicetype[6], - (unsigned int) - WPS_primarydevicetype - [7]); - } - break; - case MRVL_WIFIDIRECT_DEVICE_STATE_TLV_ID: - { - memcpy(&device_state, - &new_tlv->data, - sizeof(t_u16)); - printf("\t Device State %d\n", - le16_to_cpu - (device_state)); - } - break; - default: - printf("Unknown ie=0x%x, len=%d\n", - new_tlv->tag, new_tlv->length); - break; - } - tlv_len -= - new_tlv->length + sizeof(tlvbuf_wps_ie); - new_tlv = - (tlvbuf_wps_ie *)(((t_u8 *)new_tlv) + - new_tlv->length + - sizeof - (tlvbuf_wps_ie)); - } - } else { - printf("ERR:Could not retrieve wifidirect parameters.\n"); - } - } - -done: - if (config_file) - fclose(config_file); - if (line) - free(line); - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect_action_frame command - * - * $return N/A - */ -static void -print_wifidirect_action_frame_usage(void) -{ - printf("\nUsage : wifidirect_action_frame |" - " [ ]\n"); - printf("\nAction frame is sent using parameters in the CONFIG_FILE " - "or parameters specified on command line.\n"); - return; -} - -/** - * @brief Creates a wifidirect_action_frame request and sends to the driver - * - * Usage: "Usage : wifidirect_action_frame | - * [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirectcmd_action_frame(int argc, char *argv[]) -{ - wifidirect_action_frame *action_buf = NULL; - char *line = NULL, wifidirect_mac[20]; - FILE *config_file = NULL; - int i, opt, li = 0, arg_num = 0, ret = 0, cmd_found = 0; - char *args[30], *pos = NULL; - t_u8 dev_address[ETH_ALEN]; - t_u8 *buffer = NULL; - t_u16 ie_len = 0, cmd_len = 0; - - memset(wifidirect_mac, 0, sizeof(wifidirect_mac)); - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_action_frame_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc != 3) && (argc != 6)) { - printf("ERR:wrong number of arguments.\n"); - print_wifidirect_action_frame_usage(); - return; - } - - cmd_len = sizeof(wifidirect_action_frame); - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - action_buf = (wifidirect_action_frame *)buffer; - action_buf->cmd_code = HostCmd_CMD_802_11_ACTION_FRAME; - action_buf->seq_num = 0; - action_buf->result = 0; - - /* Check if file exists */ - config_file = fopen(argv[2], "r"); - if (config_file && argc == 3) { - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - - /* Parse file and process */ - while (config_get_line - (line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, 30); - - if (strcmp(args[0], argv[1]) == 0) { - cmd_found = 1; - } - if (cmd_found == 0) - continue; - - if (strcmp(args[0], "}") == 0) { - cmd_found = 0; - } else if (strcmp(args[0], "Category") == 0) { - if (is_input_valid - (WIFIDIRECT_CATEGORY, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - - } - action_buf->category = (t_u8)atoi(args[1]); - - } else if (strcmp(args[0], "PeerAddr") == 0) { - strncpy(wifidirect_mac, args[1], - sizeof(wifidirect_mac) - 1); - if ((ret = - mac2raw(wifidirect_mac, - dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == - FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? - "Broadcast" : "Multicast"); - goto done; - } - memcpy(action_buf->peer_mac_addr, dev_address, - ETH_ALEN); - } else if (strcmp(args[0], "Action") == 0) { - if (is_input_valid - (WIFIDIRECT_ACTION, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - action_buf->action = - (t_u8)A2HEXDECIMAL(args[1]); - - } else if (strcmp(args[0], "DialogToken") == 0) { - if (is_input_valid - (WIFIDIRECT_DIALOGTOKEN, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - action_buf->dialog_taken = (t_u8)atoi(args[1]); - - } else if (strcmp(args[0], "OUI") == 0) { - if (is_input_valid - (WIFIDIRECT_OUI, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - for (i = 0; i < MIN(arg_num - 1, MAX_OUI_LEN); - i++) - action_buf->oui[i] = - A2HEXDECIMAL(args[i + 1]); - } else if (strcmp(args[0], "OUIType") == 0) { - if (is_input_valid - (WIFIDIRECT_OUITYPE, arg_num - 1, args + 1) - != SUCCESS) { - goto done; - } - action_buf->oui_type = (t_u8)atoi(args[1]); - } else if (strcmp(args[0], "OUISubType") == 0) { - if (is_input_valid - (WIFIDIRECT_OUISUBTYPE, arg_num - 1, - args + 1) - != SUCCESS) { - goto done; - } - action_buf->oui_sub_type = (t_u8)atoi(args[1]); - } - } - fclose(config_file); - config_file = NULL; - - /* Now, read IE parameters from file */ - wifidirect_file_params_config(argv[2], argv[1], - action_buf->ie_list, &ie_len, - NULL); - if ((cmd_len + ie_len) >= MRVDRV_SIZE_OF_CMD_BUFFER) { - printf("ERR:Too much data in configuration file %s.\n", - argv[2]); - free(buffer); - return; - } - cmd_len += ie_len; - } else { - if (argc == 3) { - printf("ERR:Can not open config file.\n"); - goto done; - } - strncpy(wifidirect_mac, argv[2], sizeof(wifidirect_mac) - 1); - if ((ret = mac2raw(wifidirect_mac, dev_address)) != SUCCESS) { - printf("ERR: %s Address \n", - ret == FAILURE ? "Invalid MAC" : ret == - WIFIDIRECT_RET_MAC_BROADCAST ? "Broadcast" : - "Multicast"); - goto done; - } - memcpy(action_buf->peer_mac_addr, dev_address, ETH_ALEN); - - if (is_input_valid(WIFIDIRECT_CATEGORY, 1, &argv[3]) - != SUCCESS) { - goto done; - } - action_buf->category = (t_u8)atoi(argv[3]); - - if (is_input_valid(WIFIDIRECT_OUISUBTYPE, 1, &argv[4]) - != SUCCESS) { - goto done; - } - action_buf->oui_sub_type = (t_u8)atoi(argv[4]); - - if (is_input_valid(WIFIDIRECT_DIALOGTOKEN, 1, &argv[5]) - != SUCCESS) { - goto done; - } - action_buf->dialog_taken = (t_u8)atoi(argv[5]); - - action_buf->action = 0; - action_buf->oui[0] = 0x50; - action_buf->oui[1] = 0x6F; - action_buf->oui[2] = 0x9A; - action_buf->oui_type = OUI_TYPE_WFA_WIFIDIRECT; - } - action_buf->size = cmd_len; -#ifdef DEBUG - /* Debug print */ - hexdump(buffer, cmd_len, ' '); -#endif - /* Send collective command */ - wifidirect_ioctl((t_u8 *)buffer, &cmd_len, MRVDRV_SIZE_OF_CMD_BUFFER); - -done: - if (config_file) - fclose(config_file); - if (line) - free(line); - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect status command - * - * $return N/A - */ -static void -print_wifidirect_status_usage(void) -{ - printf("\nUsage : wifidirect_mode [STATUS]"); - printf("\nOptions: STATUS : 0 - stop wifidirect status"); - printf("\n 1 - start wifidirect status"); - printf("\n 2 - start wifidirect group owner mode"); - printf("\n 3 - start wifidirect client mode"); - printf("\n 4 - start wifidirect find phase"); - printf("\n 5 - stop wifidirect find phase"); - printf("\n empty - get current wifidirect status\n"); - return; -} - -/** - * @brief Creates wifidirect mode start or stop request and send to driver - * - * Usage: "Usage : wifidirect_mode [STATUS]" - * - * Options: STATUS : 0 - start wifidirect status - * 1 - stop wifidirect status - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return N/A - */ -static void -wifidirectcmd_status(int argc, char *argv[]) -{ - int opt, ret; - t_u16 data = 0; - t_u16 cmd_len = 0; - t_u8 *buffer = NULL; - wifidirect_mode_config *cmd_buf = NULL; - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_status_usage(); - return; - } - } - argc -= optind; - argv += optind; - /* Check arguments */ - if (argc < 2) { - printf("ERR:wrong arguments.\n"); - print_wifidirect_status_usage(); - return; - } - if (argc == 3) { - if ((ISDIGIT(argv[2]) == 0) || (atoi(argv[2]) < 0) || - (atoi(argv[2]) >= 0xFF)) { - printf("ERR:Illegal wifidirect mode %s. Must be in range from '0' to '5'.\n", argv[2]); - print_wifidirect_status_usage(); - return; - } - data = (t_u16)atoi(argv[2]); - } - - /* send hostcmd now */ - cmd_len = sizeof(wifidirect_mode_config); - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - return; - } - - cmd_buf = (wifidirect_mode_config *)buffer; - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_MODE_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - cmd_buf->mode = cpu_to_le16(data); - } - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - if (ret != SUCCESS) { - printf("Error executing wifidirect mode command\n"); - free(buffer); - return; - } - - data = le16_to_cpu(cmd_buf->mode); - switch (data) { - case 0: - printf("Wifidirect Device Mode = Not Configured\n"); - break; - case 1: - printf("Wifidirect Device Mode = Device\n"); - break; - case 2: - printf("Wifidirect Device Mode = Wifidirect Group Owner (GO)\n"); - break; - case 3: - printf("Wifidirect Device Mode = Wifidirect Group Client (GC)\n"); - break; - default: - printf("Wifidirect Device Mode = Not specified\n"); - break; - } - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect discovery period command - * - * @return N/A - */ -static void -print_wifidirect_cfg_discovery_period_usage(void) -{ - printf("Usage : wifidirect_cfg_discovery_period [ ]\n"); - printf("For 'Set' both MinDiscPeriod and MaxDiscPeriod should be specified.\n"); - printf("If no parameter is given, 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect discovery period - * - * Usage: "Usage : wifidirect_cfg_discovery_period [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_discovery_period(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_discovery_period *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_discovery_period_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc != 2) && (argc != 4)) { - printf("ERR:wrong number of arguments.\n"); - print_wifidirect_cfg_discovery_period_usage(); - return; - } else if ((argc > 2) && - ((is_input_valid(WIFIDIRECT_MINDISCOVERYINT, 1, &argv[2]) != - SUCCESS) || - (is_input_valid(WIFIDIRECT_MAXDISCOVERYINT, 1, &argv[3]) != - SUCCESS))) { - print_wifidirect_cfg_discovery_period_usage(); - return; - } - - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_discovery_period); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_discovery_period *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_DISC_PERIOD_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_discovery_period) - - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->min_disc_interval = cpu_to_le16((t_u16)atoi(argv[2])); - tlv->max_disc_interval = cpu_to_le16((t_u16)atoi(argv[3])); - } - endian_convert_tlv_header_out(tlv); - -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); - -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Min Discovery period = %d\n", - le16_to_cpu(tlv->min_disc_interval)); - printf("Max discovery period = %d\n", - le16_to_cpu(tlv->max_disc_interval)); - } else { - printf("Discovery period setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get min and max discovery period!\n"); - } else { - printf("ERR:Couldn't set min and max discovery period!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect Intent command - * - * @return N/A - */ -static void -print_wifidirect_cfg_intent_usage(void) -{ - printf("Usage : wifidirect_cfg_intent [IntentValue]\n"); - printf("If IntentValue parameter is provided, 'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect Intent - * - * Usage: "Usage : wifidirect_cfg_intent [IntentValue]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_intent(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_intent *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_intent_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_intent_usage(); - return; - } else if ((argc > 2) && - (is_input_valid(WIFIDIRECT_INTENT, argc - 2, argv + 2) != - SUCCESS)) { - print_wifidirect_cfg_intent_usage(); - return; - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_intent); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_intent *)(buffer + - sizeof(wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_INTENT_TLV_ID; - tlv->length = sizeof(tlvbuf_wifidirect_intent) - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->intent = (t_u8)atoi(argv[2]); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Intent Value = %d\n", (int)tlv->intent); - } else { - printf("Intent value setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Intent value!\n"); - } else { - printf("ERR:Couldn't set Intent value!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect Listen Channel command - * - * @return N/A - */ -static void -print_wifidirect_cfg_listen_channel_usage(void) -{ - printf("Usage : wifidirect_cfg_listen_channel [ListenChannel]\n"); - printf("If ListenChannel parameter is provided, 'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect ListenChannel - * - * Usage: "Usage : wifidirect_cfg_listen_channel [ListenChannel]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_listen_channel(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_listen_channel *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_listen_channel_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_listen_channel_usage(); - return; - } else if ((argc > 2) && - (is_input_valid(CHANNEL, argc - 2, argv + 2) != SUCCESS)) { - print_wifidirect_cfg_listen_channel_usage(); - return; - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_listen_channel); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_listen_channel *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_LISTEN_CHANNEL_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_listen_channel) - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->listen_channel = (t_u8)atoi(argv[2]); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Listen Channel = %d\n", - (int)tlv->listen_channel); - } else { - printf("Listen Channel setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Listen Channel!\n"); - } else { - printf("ERR:Couldn't set Listen Channel!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect Operating Channel command - * - * @return N/A - */ -static void -print_wifidirect_cfg_op_channel_usage(void) -{ - printf("Usage : wifidirect_cfg_op_channel [OperatingChannel]\n"); - printf("If OperatingChannel parameter is provided, 'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect OperatingChannel - * - * Usage: "Usage : wifidirect_cfg_op_channel [OperatingChannel]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_op_channel(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_operating_channel *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_op_channel_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_op_channel_usage(); - return; - } else if ((argc > 2) && - (is_input_valid(CHANNEL, argc - 2, argv + 2) != SUCCESS)) { - print_wifidirect_cfg_op_channel_usage(); - return; - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_operating_channel); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_operating_channel *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_OPERATING_CHANNEL_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_operating_channel) - - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->operating_channel = (t_u8)atoi(argv[2]); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Operating Channel = %d\n", - (int)tlv->operating_channel); - } else { - printf("Operating Channel setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Operating Channel!\n"); - } else { - printf("ERR:Couldn't set Operating Channel!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect Invitation List command - * - * @return N/A - */ -static void -print_wifidirect_cfg_invitation_list_usage(void) -{ - printf("\nUsage : wifidirect_cfg_invitation_list [mac_addr]"); - printf("\nIf mac_addr parameter is provided, 'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect InvitationList - * - * Usage: "Usage : wifidirect_cfg_invitation_list [mac_addr]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_invitation_list(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_invitation_list *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0, ctr = 1; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_invitation_list_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc < 2) || (argc > 3)) { - printf("ERR:Wrong number of arguments!\n"); - print_wifidirect_cfg_invitation_list_usage(); - return; - } - - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_invitation_list); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_invitation_list *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_INVITATION_LIST_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_invitation_list) - - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - cmd_len += (WIFIDIRECT_INVITATION_LIST_MAX - 1) * ETH_ALEN; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - if ((ret = mac2raw(argv[2], tlv->inv_peer_addr)) != SUCCESS) { - printf("ERR:Invalid MAC address %s\n", argv[2]); - goto done; - } - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - /* reusing variable cmd_len */ - cmd_len = tlv->length; - if (cmd_len > 0) { - printf("Invitation List =>"); - while (cmd_len >= ETH_ALEN) { - if (memcmp - (tlv->inv_peer_addr, - "\x00\x00\x00\x00\x00\x00", - ETH_ALEN)) { - printf("\n\t [%d] ", - ctr++); - print_mac(tlv-> - inv_peer_addr); - } - cmd_len -= ETH_ALEN; - tlv = (tlvbuf_wifidirect_invitation_list *)(((t_u8 *)(tlv)) + ETH_ALEN); - } - if (ctr == 1) - printf(" empty."); - } else - printf("Invitation List is empty.\n"); - printf("\n"); - } else { - printf("Invitation List setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Invitation List!\n"); - } else { - printf("ERR:Couldn't set Invitation List!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect noa config command - * - * @return N/A - */ -static void -print_wifidirect_cfg_noa_usage(void) -{ - printf("Usage : wifidirect_cfg_noa [ ]\n"); - printf("If NOA parameters are provided, 'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect NoA parameters - * - * Usage: "Usage : wifidirect_cfg_noa [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_noa(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_noa_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_noa_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc != 2) && (argc != 4) && (argc != 7)) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_noa_usage(); - return; - } - if (argc > 2) { - if (argc == 4) { - if (strcmp(argv[2], "enable") == 0) { - printf("ERR: index, count_type, duration and interval must be" " specified if noa is enabled!\n"); - print_wifidirect_cfg_noa_usage(); - return; - } else if (strcmp(argv[2], "disable")) { - print_wifidirect_cfg_noa_usage(); - return; - } - if (atoi(argv[3]) > WIFIDIRECT_NOA_DESC_MAX) { - print_wifidirect_cfg_noa_usage(); - return; - } - } else { - if (atoi(argv[3]) > WIFIDIRECT_NOA_DESC_MAX || - (is_input_valid(WIFIDIRECT_COUNT_TYPE, 1, &argv[4]) - != SUCCESS) || - (is_input_valid(WIFIDIRECT_DURATION, 1, &argv[5]) != - SUCCESS) || - (is_input_valid(WIFIDIRECT_INTERVAL, 1, &argv[6]) != - SUCCESS)) { - print_wifidirect_cfg_noa_usage(); - return; - } - } - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_noa_config); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_noa_config *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_NOA_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_noa_config) - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - cmd_len += - (sizeof(tlvbuf_wifidirect_noa_config) - - MRVL_TLV_HEADER_SIZE) - * (WIFIDIRECT_NOA_DESC_MAX - 1); - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - if (strcmp(argv[2], "disable")) { - /* enable case */ - tlv->enable_noa = 1; - tlv->enable_noa = cpu_to_le16(tlv->enable_noa); - } - tlv->noa_index = (t_u8)atoi(argv[3]); - - if (tlv->enable_noa) { - tlv->count_type = (t_u8)atoi(argv[4]); - tlv->duration = (t_u32)atoi(argv[5]); - tlv->duration = cpu_to_le32(tlv->duration); - tlv->interval = (t_u32)atoi(argv[6]); - tlv->interval = cpu_to_le32(tlv->interval); - } - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - if (tlv->length) - printf("NoA settings:\n"); - else - printf("NoA parameters are not configured.\n"); - if (tlv->length >= - sizeof(tlvbuf_wifidirect_noa_config) - - MRVL_TLV_HEADER_SIZE) { - tlv->enable_noa = - le16_to_cpu(tlv->enable_noa); - if (tlv->enable_noa) { - printf("[%d] NoA is enabled!\n", - (int)tlv->noa_index); - printf("CountType = %d\n", - (int)tlv->count_type); - printf("Duration = %dms\n", - le32_to_cpu(tlv-> - duration)); - printf("Interval = %dms\n", - le32_to_cpu(tlv-> - interval)); - } else { - printf("[%d] NoA is disabled!\n", (int)tlv->noa_index); - } - } - } else { - printf("NoA setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get NoA parameters!\n"); - } else { - printf("ERR:Couldn't set NoA parameters!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect opp_ps config command - * - * @return N/A - */ -static void -print_wifidirect_cfg_opp_ps_usage(void) -{ - printf("Usage : wifidirect_cfg_opp_ps []\n"); - printf("For 'set', both enable flag and CTWindow should be provided.\n"); - printf("If no parameter is specified,'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect Opportunistic Power Save - * - * Usage: "Usage : wifidirect_cfg_opp_ps []" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_opp_ps(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_opp_ps_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - t_u8 opp_ps = 0, ctwindow = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_opp_ps_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc < 2) || (argc > 4)) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_opp_ps_usage(); - return; - } - if (argc == 3) { - if (strcmp(argv[2], "enable") == 0) { - printf("ERR: If Opp PS is enabled, CTWindow must be specified!\n"); - print_wifidirect_cfg_opp_ps_usage(); - return; - } else if (strcmp(argv[2], "disable")) { - print_wifidirect_cfg_opp_ps_usage(); - return; - } - } - if (argc == 4) { - if (strcmp(argv[2], "disable") == 0) { - printf("ERR: Extra parameter %s for disable command.\n", - argv[3]); - return; - } - if (is_input_valid(WIFIDIRECT_CTWINDOW, 1, &argv[3]) != SUCCESS) { - print_wifidirect_cfg_opp_ps_usage(); - return; - } - } - - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_opp_ps_config); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_opp_ps_config *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_OPP_PS_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_opp_ps_config) - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - if (strcmp(argv[2], "disable")) - opp_ps = 1; - if (argc == 4) - tlv->ctwindow_opp_ps = - (t_u8)atoi(argv[3]) | SET_OPP_PS(opp_ps);; - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - opp_ps = GET_OPP_PS(tlv->ctwindow_opp_ps); - if (opp_ps) { - ctwindow = - (tlv-> - ctwindow_opp_ps) & - CT_WINDOW_MASK; - printf("Opportunistic Power Save enabled!\n"); - printf("CTWindow = %d\n", ctwindow); - } else { - printf("Opportunistic Power Save disabled!\n"); - } - } else { - printf("Opportunistic power save setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Opportunistic power save and CTWindow!\n"); - } else { - printf("ERR:Couldn't set Opportunistic power save and CTWindow!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect capability config command - * - * @return N/A - */ -static void -print_wifidirect_cfg_capability_usage(void) -{ - printf("Usage : wifidirect_capability [ ]\n"); - printf("For 'set' both DeviceCapability and GroupCapability should be provided.\n"); - printf("If no parameter is specified,'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect Capability - * - * Usage: "Usage : wifidirect_cfg_capability [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_capability(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_capability_config *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_capability_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc < 2) || (argc > 4) || (argc == 3)) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_capability_usage(); - return; - } - if (argc == 4) { - if ((is_input_valid(WIFIDIRECT_DEVICECAPABILITY, 1, &argv[2]) != - SUCCESS) || - (is_input_valid(WIFIDIRECT_GROUPCAPABILITY, 1, &argv[3]) != - SUCCESS)) { - print_wifidirect_cfg_capability_usage(); - return; - } - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_capability_config); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_capability_config *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_CAPABILITY_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_capability_config) - - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->dev_capability = (t_u8)atoi(argv[2]); - tlv->group_capability = (t_u8)atoi(argv[3]); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Device Capability = %d\n", - (int)tlv->dev_capability); - printf("Group Capability = %d\n", - (int)tlv->group_capability); - } else { - printf("Capability setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Capability info!\n"); - } else { - printf("ERR:Couldn't set Capability!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect_cfg_persistent_group_record command - * - * $return N/A - */ -static void -print_wifidirect_peristent_group_usage(void) -{ - printf("\nUsage : wifidirect_cfg_persistent_group_record [index] \ - > \ - [ ]\n"); - printf("\nIssue set or get request using appropriate parameters.\n"); - return; -} - -/** - * @brief Creates a wifidirect_persistent group record request and - * sends to the driver - * - * Usage: "Usage : wifidirect_cfg_cmd_persistent_group_record [index] < - * > - * [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return SUCCESS or FAILURE - **/ -static void -wifidirect_cfg_cmd_persistent_group_record(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_persistent_group *tlv = NULL; - t_u8 index = 0, role = 0, var_len = 0, psk_len = 0; - t_u8 *buffer = NULL; - int pi; - t_u16 cmd_len = 0, buf_len = 0; - int opt, ret; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_peristent_group_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 2 && argc != 3 && argc != 8 && argc != 9 && argc != 10) { - printf("ERR:wrong number of arguments.\n"); - print_wifidirect_peristent_group_usage(); - return; - } - /* error checks */ - if (argc > 2) { - index = atoi(argv[2]); - if (index >= WIFIDIRECT_PERSISTENT_GROUP_MAX) { - printf("ERR:wrong index. Value values are [0-3]\n"); - return; - } - } - if (argc > 3) { - role = atoi(argv[3]); - if ((role != 1) && (role != 2)) { - printf("ERR:Incorrect Role. Use 2 for client, 1 for group owner.\n"); - return; - } - if (role == 1 && argc == 8) { - printf("ERR:Insufficient arguments. Please provide peer mac address(es) for group owner.\n"); - return; - } - } - - cmd_len = sizeof(wifidirect_params_config); - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - cmd_buf = (wifidirect_params_config *)buffer; - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - tlv = (tlvbuf_wifidirect_persistent_group *)(buffer + - sizeof - (wifidirect_params_config)); - - tlv->tag = MRVL_WIFIDIRECT_PERSISTENT_GROUP_TLV_ID; - - /* parsing commands based on arguments */ - switch (argc) { - case 2: - cmd_buf->action = ACTION_GET; - tlv->length = 0; - cmd_len += MRVL_TLV_HEADER_SIZE + tlv->length; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - break; - - case 3: - cmd_buf->action = ACTION_GET; - tlv->rec_index = index; - tlv->length = sizeof(index); - cmd_len += MRVL_TLV_HEADER_SIZE + tlv->length; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - break; - - default: - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->rec_index = index; - tlv->dev_role = role; - if ((ret = mac2raw(argv[4], tlv->group_bssid)) != SUCCESS) { - printf("ERR:Invalid MAC address %s\n", argv[4]); - goto done; - } - if ((ret = mac2raw(argv[5], tlv->dev_mac_address)) != SUCCESS) { - printf("ERR:Invalid MAC address %s\n", argv[5]); - goto done; - } - - /* ssid */ - tlv->group_ssid_len = strlen(argv[6]); - var_len += tlv->group_ssid_len; - memcpy(tlv->group_ssid, argv[6], tlv->group_ssid_len); - - /* adjust pointer from here */ - /* psk */ - if (!strncasecmp("0x", argv[7], 2)) { - argv[7] += 2; - if (strlen(argv[7]) / 2 != WIFIDIRECT_PSK_LEN_MAX) { - printf("ERR:Incorrect PSK length %d. It should be %d.\n", (t_u32)strlen(argv[7]) / 2, WIFIDIRECT_PSK_LEN_MAX); - goto done; - } - string2raw(argv[7], tlv->psk + var_len); - *(&tlv->psk_len + var_len) = WIFIDIRECT_PSK_LEN_MAX; - var_len += WIFIDIRECT_PSK_LEN_MAX; - } else { - /* ascii */ - psk_len = strlen(argv[7]); - if (psk_len < WIFIDIRECT_PASSPHRASE_LEN_MIN || - psk_len >= WIFIDIRECT_PSK_LEN_MAX) { - printf("ERR:Incorrect passphrase length %d. Valid range is [8-63]\n", psk_len); - goto done; - } - memcpy(tlv->psk + var_len, argv[7], psk_len); - *(&tlv->psk_len + var_len) = psk_len; - var_len += psk_len; - } - - tlv->length = - sizeof(tlvbuf_wifidirect_persistent_group) - - MRVL_TLV_HEADER_SIZE + var_len; - *(&tlv->num_peers + var_len) = 0; - - if (argc == 9 || argc == 10) { - if ((ret = - mac2raw(argv[8], tlv->peer_mac_addrs[0] + var_len)) - != SUCCESS) { - printf("ERR:Invalid MAC address %s\n", argv[8]); - goto done; - } - *(&tlv->num_peers + var_len) = 1; - } - if (argc == 10) { - if ((ret = - mac2raw(argv[9], tlv->peer_mac_addrs[1] + var_len)) - != SUCCESS) { - printf("ERR:Invalid MAC address %s\n", argv[8]); - goto done; - } - *(&tlv->num_peers + var_len) = 2; - } - - tlv->length += *(&tlv->num_peers + var_len) * ETH_ALEN; - cmd_len += MRVL_TLV_HEADER_SIZE + tlv->length; - buf_len = cmd_len; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - break; - } -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - endian_convert_tlv_header_out(tlv); - - /* Send collective command */ - wifidirect_ioctl((t_u8 *)buffer, &cmd_len, buf_len); - - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - - if (argc == 2 || argc == 3) { - if (tlv->length > 0) - printf("Persistent group information =>\n"); - else - printf("Persistent group information is empty.\n"); - buf_len = tlv->length; - while (buf_len > - (sizeof(tlvbuf_wifidirect_persistent_group) - - 2 * ETH_ALEN)) { - printf("\n\t Index = [%d]\n", tlv->rec_index); - if (tlv->dev_role == 1) - printf("\t Role = Group owner\n"); - else - printf("\t Role = Client\n"); - printf("\t GroupBssId - "); - print_mac(tlv->group_bssid); - printf("\n\t DeviceId - "); - print_mac(tlv->dev_mac_address); - printf("\n\t SSID = "); - for (index = 0; index < tlv->group_ssid_len; index++) - printf("%c", tlv->group_ssid[index]); - var_len = tlv->group_ssid_len; - printf("\n\t PSK = "); - for (index = 0; index < *(&tlv->psk_len + var_len); - index++) { - if (index == 16) - printf("\n\t "); - printf("%02x ", *(&tlv->psk[index] + var_len)); - } - var_len += *(&tlv->psk_len + var_len); - if (tlv->dev_role == 1) { - for (pi = 0; pi < *(&tlv->num_peers + var_len); - pi++) { - printf("\n\t Peer Mac address(%d) = ", - pi); - print_mac(tlv->peer_mac_addrs[pi] + - var_len); - } - var_len += - (*(&tlv->num_peers + var_len) * - ETH_ALEN); - } - if (argc == 2) - printf("\n\t -----------------------------------------"); - if (tlv->dev_role == 1) { - buf_len -= - sizeof - (tlvbuf_wifidirect_persistent_group) - - MRVL_TLV_HEADER_SIZE + var_len; - tlv = (tlvbuf_wifidirect_persistent_group - *)(((t_u8 *)(tlv)) + - (sizeof - (tlvbuf_wifidirect_persistent_group) - - MRVL_TLV_HEADER_SIZE + var_len)); - } else { - /* num_peer field willnt be present */ - buf_len -= - sizeof - (tlvbuf_wifidirect_persistent_group) - - MRVL_TLV_HEADER_SIZE - sizeof(t_u8) + - var_len; - tlv = (tlvbuf_wifidirect_persistent_group - *)(((t_u8 *)(tlv)) + - (sizeof - (tlvbuf_wifidirect_persistent_group) - - MRVL_TLV_HEADER_SIZE - - sizeof(t_u8) + var_len)); - } - } - printf("\n"); - } else { - printf("Setting persistent group information successful!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect_cfg_persistent_group_invoke command - * - * $return N/A - */ -static void -print_wifidirect_peristent_group_invoke_usage(void) -{ - printf("\nUsage : wifidirect_cfg_persistent_group_invoke [index] | \n"); - return; -} - -/** - * @brief Creates a wifidirect_persistent group Invoke request and - * sends to the driver - * - * Usage: "Usage : wifidirect_cfg_cmd_persistent_group_invoke [index] | " - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return SUCCESS or FAILURE - **/ -static void -wifidirect_cfg_cmd_persistent_group_invoke(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_persistent_group *tlv = NULL; - t_u8 index; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_peristent_group_invoke_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc != 3) { - printf("ERR:wrong number of arguments.\n"); - print_wifidirect_peristent_group_invoke_usage(); - return; - } - - cmd_len = sizeof(wifidirect_params_config); - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - cmd_buf = (wifidirect_params_config *)buffer; - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv = (tlvbuf_wifidirect_persistent_group *)(buffer + - sizeof - (wifidirect_params_config)); - - tlv->tag = MRVL_WIFIDIRECT_PERSISTENT_GROUP_TLV_ID; - tlv->length = sizeof(index); - - index = atoi(argv[2]); - if (index >= WIFIDIRECT_PERSISTENT_GROUP_MAX) { - printf("ERR:wrong index. Value values are [0-3]\n"); - goto done; - } - if (!isdigit(argv[2][0])) { - if (strcmp(argv[2], "cancel")) { - printf("ERR:Incorrect input. Use index [0-3] or \"cancel\" \n"); - goto done; - } else - index = WIFIDIRECT_PERSISTENT_RECORD_CANCEL; - } - tlv->rec_index = index; - - cmd_len += MRVL_TLV_HEADER_SIZE + tlv->length; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - endian_convert_tlv_header_out(tlv); - - /* Send collective command */ - wifidirect_ioctl((t_u8 *)buffer, &cmd_len, MRVDRV_SIZE_OF_CMD_BUFFER); - -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - - printf("Persistent group %s successful!\n", - (index == - WIFIDIRECT_PERSISTENT_RECORD_CANCEL) ? "cancel" : "invoke"); -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect presence request parameters command - * - * @return N/A - */ -static void -print_wifidirect_cfg_presence_req_params_usage(void) -{ - printf("Usage : wifidirect_cfg_presence_req_params [ ]\n"); - printf(" : Type 1: preferred values, 2: acceptable values.\n"); - printf("If presence request parameters are provided, " - " 'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect presence request parameters - * - * Usage: "Usage : wifidirect_cfg_presence_req_params [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_presence_req_params(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_presence_req_params *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_presence_req_params_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_presence_req_params_usage(); - return; - } else if ((argc > 2) && ((argc != 5) - || - (is_input_valid - (WIFIDIRECT_PRESENCE_REQ_TYPE, 1, - &argv[2]) != SUCCESS) - || - (is_input_valid - (WIFIDIRECT_DURATION, 1, - &argv[3]) != SUCCESS) - || - (is_input_valid - (WIFIDIRECT_INTERVAL, 1, - &argv[4]) != SUCCESS))) { - print_wifidirect_cfg_presence_req_params_usage(); - return; - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_presence_req_params); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_presence_req_params *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_PRESENCE_REQ_PARAMS_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_presence_req_params) - - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->presence_req_type = (t_u8)atoi(argv[2]); - tlv->duration = (t_u32)atoi(argv[3]); - tlv->duration = cpu_to_le32(tlv->duration); - tlv->interval = (t_u32)atoi(argv[4]); - tlv->interval = cpu_to_le32(tlv->interval); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Presence request type = %d\n", - (int)tlv->presence_req_type); - printf("Duration of NoA descriptor = %d\n", - le32_to_cpu(tlv->duration)); - printf("Interval of NoA descriptor = %d\n", - le32_to_cpu(tlv->interval)); - } else { - printf("Presence request parameters setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get Presence request parameters!\n"); - } else { - printf("ERR:Couldn't set Presence request parameters!\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect extended listen timing parameters command - * - * @return N/A - */ -static void -print_wifidirect_cfg_ext_listen_time_usage(void) -{ - printf("Usage : wifidirect_cfg_ext_listen_time [ ]\n"); - printf("If extended listen timing parameters are provided, " - "'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect extended listen time parameters - * - * Usage: "Usage : wifidirect_cfg_ext_listen_time [ ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_ext_listen_time(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_mrvl_ext_listen_time *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_ext_listen_time_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_ext_listen_time_usage(); - return; - } else if ((argc > 2) && ((argc != 4) - || - (is_input_valid - (WIFIDIRECT_ATTR_EXTENDED_TIME, 1, - &argv[2]) != SUCCESS) - || - (is_input_valid - (WIFIDIRECT_ATTR_EXTENDED_TIME, 1, - &argv[3]) != SUCCESS))) { - print_wifidirect_cfg_ext_listen_time_usage(); - return; - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_mrvl_ext_listen_time); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_mrvl_ext_listen_time *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_EXTENDED_LISTEN_TIME_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_mrvl_ext_listen_time) - - MRVL_TLV_HEADER_SIZE; - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->duration = cpu_to_le16((t_u16)atoi(argv[2])); - tlv->interval = cpu_to_le16((t_u16)atoi(argv[3])); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Availability Period = %d\n", - le16_to_cpu(tlv->duration)); - printf("Availability Interval = %d\n", - le16_to_cpu(tlv->interval)); - } else { - printf("Extended listen timing parameters setting successful!\n"); - } - } else { - if (argc == 2) - printf("ERR:Couldn't get Extended listen time!\n"); - else - printf("ERR:Couldn't set Extended listen time!\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect provisioing parameters command - * - * @return N/A - */ -static void -print_wifidirect_cfg_provisioning_params_usage(void) -{ - printf("Usage : wifidirect_cfg_provisioning_params [ ]\n"); - printf(" : Action 1: Request parameters 2: Response parameters.\n"); - printf("If provisioning protocol parameters are provided, " - "'set' is performed otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect provisioning protocol related parameters - * - * Usage: "Usage : wifidirect_cfg_provisioning_params [ - * ]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_provisioning_params(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_provisioning_params *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_provisioning_params_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if (argc < 2) { - printf("ERR: Wrong number of arguments!\n"); - print_wifidirect_cfg_provisioning_params_usage(); - return; - } else if ((argc > 2) && (argc != 5)) { - print_wifidirect_cfg_provisioning_params_usage(); - return; - } - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_provisioning_params); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_provisioning_params *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_PROVISIONING_PARAMS_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_provisioning_params) - - MRVL_TLV_HEADER_SIZE; - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->action = cpu_to_le16((t_u16)A2HEXDECIMAL(argv[2])); - tlv->config_methods = cpu_to_le16((t_u16)A2HEXDECIMAL(argv[3])); - tlv->dev_password = cpu_to_le16((t_u16)A2HEXDECIMAL(argv[4])); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("Action = %s %s\n", - (le16_to_cpu(tlv->action)) == - 1 ? "Request" : "Response", - "parameters"); - printf("Config Methods = %02X\n", - le16_to_cpu(tlv->config_methods)); - printf("Device Password ID = %02X\n", - le16_to_cpu(tlv->dev_password)); - } else { - printf("Provisioning protocol parameters setting successful!\n"); - } - } else { - if (argc == 2) - printf("ERR:Couldn't get provisioing parameters!\n"); - else - printf("ERR:Couldn't set provisioing parameters!\n"); - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Show usage information for the wifidirect WPS params command - * - * @return N/A - */ -static void -print_wifidirect_cfg_wps_params_usage(void) -{ - printf("\nUsage : wifidirect_cfg_wps_params [pin/pbc/none]"); - printf("\nIf pin/pbc/none is provided, 'set' is performed" - " otherwise 'get' is performed.\n"); - return; -} - -/** - * @brief Set/get wifidirect WPS parametters - * - * Usage: "Usage : wifidirect_cfg_wps_params [pin/pbc/none]" - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return None - */ -static void -wifidirect_cfg_cmd_wps_params(int argc, char *argv[]) -{ - wifidirect_params_config *cmd_buf = NULL; - tlvbuf_wifidirect_wps_params *tlv = NULL; - t_u8 *buffer = NULL; - t_u16 cmd_len = 0; - int opt, ret = 0, param = 0; - - while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) { - switch (opt) { - default: - print_wifidirect_cfg_wps_params_usage(); - return; - } - } - argc -= optind; - argv += optind; - - /* Check arguments */ - if ((argc < 2) || (argc > 3)) { - printf("ERR:Wrong number of arguments!\n"); - print_wifidirect_cfg_wps_params_usage(); - return; - } - - cmd_len = - sizeof(wifidirect_params_config) + - sizeof(tlvbuf_wifidirect_wps_params); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - cmd_buf = (wifidirect_params_config *)buffer; - tlv = (tlvbuf_wifidirect_wps_params *)(buffer + - sizeof - (wifidirect_params_config)); - - cmd_buf->cmd_code = HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG; - cmd_buf->size = cmd_len - BUF_HEADER_SIZE; - cmd_buf->seq_num = 0; - cmd_buf->result = 0; - - tlv->tag = MRVL_WIFIDIRECT_WPS_PARAMS_TLV_ID; - tlv->length = - sizeof(tlvbuf_wifidirect_wps_params) - MRVL_TLV_HEADER_SIZE; - - if (argc == 2) { - cmd_buf->action = ACTION_GET; - } else { - if (strncmp(argv[2], "pin", 3) == 0) - param = 1; - else if (strncmp(argv[2], "pbc", 3) == 0) - param = 2; - else if (strncmp(argv[2], "none", 4)) { - printf("Invalid input, should be pin/pbc or none.\n"); - goto done; - } - cmd_buf->action = cpu_to_le16(ACTION_SET); - tlv->action = cpu_to_le16(param); - } - endian_convert_tlv_header_out(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len, ' '); -#endif - ret = wifidirect_ioctl((t_u8 *)buffer, &cmd_len, - MRVDRV_SIZE_OF_CMD_BUFFER); - endian_convert_tlv_header_in(tlv); -#ifdef DEBUG - hexdump(buffer, cmd_len + BUF_HEADER_SIZE, ' '); -#endif - /* Process Response */ - if (ret == SUCCESS) { - /* Verify response */ - if (cmd_buf->cmd_code != - (HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG | - WIFIDIRECTCMD_RESP_CHECK)) { - printf("ERR:Corrupted response!\n"); - goto done; - } - /* Print response */ - if (cmd_buf->result == CMD_SUCCESS) { - if (argc == 2) { - printf("WPS password parameter =>"); - switch (le16_to_cpu(tlv->action)) { - case 1: - printf("Pin\n"); - break; - case 2: - printf("PBC\n"); - break; - default: - printf("None\n"); - break; - } - } else { - printf("WPS parameter setting successful!\n"); - } - } else { - if (argc == 2) { - printf("ERR:Couldn't get WPS parameters !\n"); - } else { - printf("ERR:Couldn't set WPS parameters !\n"); - } - } - } else { - printf("ERR:Command sending failed!\n"); - } -done: - if (buffer) - free(buffer); - return; -} - -/** - * @brief Checkes a particular input for validatation. - * - * @param cmd Type of input - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return SUCCESS or FAILURE - */ -int -is_input_valid(valid_inputs cmd, int argc, char *argv[]) -{ - int i; - int ret = SUCCESS; - char country[6] = { ' ', ' ', 0, 0, 0, 0 }; - char wifidirect_dev_name[34]; - - memset(wifidirect_dev_name, 0, sizeof(wifidirect_dev_name)); - if (argc == 0) - return FAILURE; - switch (cmd) { - case WIFIDIRECT_MINDISCOVERYINT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for MinDiscoveryInterval\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) >= (1 << 16))) { - printf("ERR:MinDiscoveryInterval must be 2 bytes\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_MAXDISCOVERYINT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for MaxDiscoveryInterval\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) >= (1 << 16))) { - printf("ERR:MaxDiscoveryInterval must be 2 bytes\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DEVICECAPABILITY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DeviceCapability\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_DEV_CAPABILITY) || - (atoi(argv[0]) < 0)) { - printf("ERR:DeviceCapability must be in the range [0:%d]\n", MAX_DEV_CAPABILITY); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_GROUPCAPABILITY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for GroupCapability\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_GRP_CAPABILITY) || - (atoi(argv[0]) < 0)) { - printf("ERR:GroupCapability must be in the range [0:%d]\n", MAX_GRP_CAPABILITY); - ret = FAILURE; - } - } - break; - case CHANNEL: - if ((argc != 1) && (argc != 2)) { - printf("ERR: Incorrect arguments for channel.\n"); - ret = FAILURE; - } else { - if (argc == 2) { - if ((ISDIGIT(argv[1]) == 0) || - (atoi(argv[1]) < 0) || - (atoi(argv[1]) > 1)) { - printf("ERR: MODE must be either 0 or 1\n"); - ret = FAILURE; - } - if ((atoi(argv[1]) == 1) && - (atoi(argv[0]) != 0)) { - printf("ERR: Channel must be 0 for ACS; MODE = 1.\n"); - ret = FAILURE; - } - } - if ((argc == 1) || (atoi(argv[1]) == 0)) { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) < 1) || - (atoi(argv[0]) > MAX_CHANNELS)) { - printf("ERR: Channel must be in the range of 1 to %d, configured - %d\n", MAX_CHANNELS, atoi(argv[0])); - ret = FAILURE; - } - } - } - break; - case SCANCHANNELS: - if (argc > MAX_CHANNELS) { - printf("ERR: Invalid List of Channels\n"); - ret = FAILURE; - } else { - for (i = 0; i < argc; i++) { - if ((ISDIGIT(argv[i]) == 0) || - (atoi(argv[i]) < 1) || - (atoi(argv[i]) > MAX_CHANNELS)) { - printf("ERR: Channel must be in the range of 1 to %d, configured - %d\n", MAX_CHANNELS, atoi(argv[i])); - ret = FAILURE; - break; - } - } - if ((ret != FAILURE) && - (has_dup_channel(argc, argv) != SUCCESS)) { - printf("ERR: Duplicate channel values entered\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_INTENT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for intent\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_INTENT) || - (atoi(argv[0]) < 0)) { - printf("ERR:Intent must be in the range [0:%d]\n", MAX_INTENT); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_MANAGEABILITY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for manageability\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR:Manageability must be either 0 or 1\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_GROUP_WIFIDIRECT_DEVICE_NAME: - /* 2 extra characters for quotes around device name */ - if ((strlen(argv[0]) > 34)) { - printf("ERR:WIFIDIRECT Device name string length must not be more than 32\n"); - ret = FAILURE; - } else { - strncpy(wifidirect_dev_name, argv[0], - sizeof(wifidirect_dev_name) - 1); - if ((wifidirect_dev_name[0] != '"') || - (wifidirect_dev_name - [strlen(wifidirect_dev_name) - 1] != '"')) { - printf("ERR:WIFIDIRECT Device name must be within double quotes!\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_COUNTRY: - /* 2 extra characters for quotes around country */ - if ((strlen(argv[0]) > 5) || (strlen(argv[0]) < 4)) { - printf("ERR:Country string must have length 2 or 3\n"); - ret = FAILURE; - } else { - strncpy(country, argv[0], sizeof(country) - 1); - if ((country[0] != '"') || - (country[strlen(country) - 1] != '"')) { - printf("ERR:country code must be within double quotes!\n"); - ret = FAILURE; - } else { - for (i = 1; i < strlen(country) - 2; i++) { - if ((toupper(country[i]) < 'A') || - (toupper(country[i]) > 'Z')) { - printf("ERR:Invalid Country Code\n"); - ret = FAILURE; - } - } - } - } - break; - case WIFIDIRECT_NO_OF_CHANNELS: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for num of channels\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_CHANNELS)) { - printf("ERR:Number of channels should be less than %d\n", MAX_CHANNELS); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_NOA_INDEX: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for NoA Index\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) < MIN_NOA_INDEX) || - (atoi(argv[0]) > MAX_NOA_INDEX)) { - printf("ERR:NoA index should be in the range [%d:%d]\n", MIN_NOA_INDEX, MAX_NOA_INDEX); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_OPP_PS: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Opp PS\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 0) && - (atoi(argv[0]) != 1))) { - printf("ERR:Opp PS must be either 0 or 1\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_CTWINDOW: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for CTWindow\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_CTWINDOW) || - (atoi(argv[0]) < MIN_CTWINDOW)) { - printf("ERR:CT Window must be in the range [%d:%d]\n", MIN_CTWINDOW, MAX_CTWINDOW); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_COUNT_TYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Count/Type\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) == 0) || - (atoi(argv[0]) > MAX_COUNT_TYPE) || - (atoi(argv[0]) < MIN_COUNT_TYPE)) { - printf("ERR:Count/Type must be in the range [%d:%d] or 255\n", MIN_COUNT_TYPE, MAX_COUNT_TYPE); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_PRESENCE_REQ_TYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Presence request type\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 1) - && (atoi(argv[0]) != - 2))) { - printf("ERR:Presence Type must be 1 or 2.\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DURATION: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Duration\n"); - ret = FAILURE; - } - break; - case WIFIDIRECT_INTERVAL: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Interval\n"); - ret = FAILURE; - } - break; - case WIFIDIRECT_START_TIME: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Start Time\n"); - ret = FAILURE; - } - break; - case WIFIDIRECT_PRIDEVTYPEOUI: - if (argc > MAX_PRIMARY_OUI_LEN) { - printf("ERR: Incorrect number of PrimaryDeviceTypeOUI arguments.\n"); - ret = FAILURE; - break; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported OUI\n"); - ret = FAILURE; - break; - } - } - if (! - ((A2HEXDECIMAL(argv[0]) == 0x00) && - (A2HEXDECIMAL(argv[1]) == 0x50) - && (A2HEXDECIMAL(argv[2]) == 0xF2) && - (A2HEXDECIMAL(argv[3]) == 0x04))) { - printf("ERR:Unsupported OUI\n"); - ret = FAILURE; - break; - } - break; - case WIFIDIRECT_REGULATORYCLASS: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for RegulatoryClass\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_REG_CLASS) || - (atoi(argv[0]) < MIN_REG_CLASS)) { - printf("ERR:RegulatoryClass must be in the range [%d:%d] or 255\n", MIN_REG_CLASS, MAX_REG_CLASS); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_PRIDEVTYPECATEGORY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for PrimaryDeviceTypeCategory\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_PRIDEV_TYPE_CAT) || - (atoi(argv[0]) < MIN_PRIDEV_TYPE_CAT)) { - printf("ERR:PrimaryDeviceTypeCategory must be in the range [%d:%d]\n", MIN_PRIDEV_TYPE_CAT, MAX_PRIDEV_TYPE_CAT); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_SECONDARYDEVCOUNT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for SecondaryDeviceCount\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_SECONDARY_DEVICE_COUNT)) { - printf("ERR:SecondaryDeviceCount must be less than 15.\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_INTERFACECOUNT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for InterfaceCount\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_INTERFACE_ADDR_COUNT)) { - printf("ERR:IntefaceCount must be in range.[0-41]\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_GROUP_SECONDARYDEVCOUNT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for SecondaryDeviceCount\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > - MAX_GROUP_SECONDARY_DEVICE_COUNT)) { - printf("ERR:SecondaryDeviceCount must be less than 2.\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_ATTR_CONFIG_TIMEOUT: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Timeout Configuration\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) > 255)) { - printf("ERR:TimeoutConfig must be in the range [0:255]\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_ATTR_EXTENDED_TIME: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Extended time.\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) > 65535) - || (atoi(argv[0]) < 1)) { - printf("ERR:Extended Time must be in the range [1:65535]\n"); - ret = FAILURE; - } - } - break; - - case WIFIDIRECT_PRIDEVTYPESUBCATEGORY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for PrimaryDeviceTypeSubCategory\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - (atoi(argv[0]) > MAX_PRIDEV_TYPE_SUBCATEGORY) || - (atoi(argv[0]) < MIN_PRIDEV_TYPE_SUBCATEGORY)) { - printf("ERR:PrimaryDeviceTypeSubCategory must be in the range [%d:%d]\n", MIN_PRIDEV_TYPE_SUBCATEGORY, MAX_PRIDEV_TYPE_SUBCATEGORY); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_INVITATIONFLAG: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for InvitationFlag\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) || - (atoi(argv[0]) > 1)) { - printf("ERR:Invitation flag must be either 0 or 1\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSCONFMETHODS: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSConfigMethods\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - (A2HEXDECIMAL(argv[0]) > MAX_WPS_CONF_METHODS) || - (A2HEXDECIMAL(argv[0]) < MIN_WPS_CONF_METHODS)) { - printf("ERR:WPSConfigMethods must be in the range [%d:%d]\n", MIN_WPS_CONF_METHODS, MAX_WPS_CONF_METHODS); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSVERSION: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSVersion\n"); - ret = FAILURE; - } else { - if ((A2HEXDECIMAL(argv[0]) < 0x10) && - (A2HEXDECIMAL(argv[0]) > 0x20)) { - printf("ERR:Incorrect WPS Version %s\n", - argv[0]); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSSETUPSTATE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSSetupState\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - ((A2HEXDECIMAL(argv[0]) != 0x01) - && (A2HEXDECIMAL(argv[0]) != 0x02))) { - printf("ERR:Incorrect WPSSetupState %s\n", - argv[0]); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSREQRESPTYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSRequestType\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - (A2HEXDECIMAL(argv[0]) > WPS_MAX_REQUESTTYPE)) { - printf("ERR:Incorrect WPSRequestType %s\n", - argv[0]); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSSPECCONFMETHODS: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSSpecConfigMethods\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - ((t_u16)A2HEXDECIMAL(argv[0]) > - WPS_MAX_SPECCONFMETHODS) || - ((t_u16)A2HEXDECIMAL(argv[0]) < - WPS_MIN_SPECCONFMETHODS)) { - printf("ERR:WPSSpecConfigMethods must be in the range [%d:%d]\n", WPS_MIN_SPECCONFMETHODS, WPS_MAX_SPECCONFMETHODS); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSDEVICENAME: - if (argc != 1) { - printf("ERR:Incorrect number of arguments\n"); - ret = FAILURE; - } else { - if (argv[0][0] == '"') { - argv[0]++; - } - if (argv[0][strlen(argv[0]) - 1] == '"') { - argv[0][strlen(argv[0]) - 1] = '\0'; - } - if (strlen(argv[0]) > WPS_DEVICE_NAME_MAX_LEN) { - printf("ERR:Device name should contain" - " less than 32 charactors.\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSMANUFACTURER: - if (argc != 1) { - printf("ERR:Incorrect number of arguments\n"); - ret = FAILURE; - } else { - if (strlen(argv[0]) > WPS_MANUFACT_MAX_LEN) { - printf("ERR:Manufacturer name should contain" - "less than 64 charactors.\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSMODELNAME: - if (argc != 1) { - printf("ERR:Incorrect number of arguments\n"); - ret = FAILURE; - } else { - if (strlen(argv[0]) > WPS_MODEL_MAX_LEN) { - printf("ERR:Model name should contain" - " less than 64 charactors.\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSUUID: - if (argc > WPS_UUID_MAX_LEN) { - printf("ERR: Incorrect number of WPSUUID arguments.\n"); - ret = FAILURE; - } else { - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported UUID\n"); - ret = FAILURE; - break; - } - } - } - break; - case WIFIDIRECT_WPSPRIMARYDEVICETYPE: - if (argc > WPS_DEVICE_TYPE_MAX_LEN) { - printf("ERR: Incorrect number of WPSPrimaryDeviceType arguments.\n"); - ret = FAILURE; - break; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported primary device type\n"); - ret = FAILURE; - break; - } - } - if (! - ((A2HEXDECIMAL(argv[2]) == 0x00) && - (A2HEXDECIMAL(argv[3]) == 0x50) - && (A2HEXDECIMAL(argv[4]) == 0xF2) && - (A2HEXDECIMAL(argv[5]) == 0x04))) { - printf("ERR:Unsupported OUI\n"); - ret = FAILURE; - break; - } - break; - case WIFIDIRECT_WPSRFBAND: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSRFBand\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - ((A2HEXDECIMAL(argv[0]) != 0x01) - && (A2HEXDECIMAL(argv[0]) != 0x02))) { - printf("ERR:Incorrect WPSRFBand %s\n", argv[0]); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSASSOCIATIONSTATE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSAssociationState\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - ((t_u16)A2HEXDECIMAL(argv[0]) > - WPS_MAX_ASSOCIATIONSTATE)) { - printf("ERR:WPSAssociationState must be in the range [%d:%d]\n", WPS_MIN_ASSOCIATIONSTATE, WPS_MAX_ASSOCIATIONSTATE); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSCONFIGURATIONERROR: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSConfigurationError\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - ((t_u16)A2HEXDECIMAL(argv[0]) > - WPS_MAX_CONFIGURATIONERROR)) { - printf("ERR:WPSConfigurationError must be in the range [%d:%d]\n", WPS_MIN_CONFIGURATIONERROR, WPS_MAX_CONFIGURATIONERROR); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSDEVICEPASSWORD: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for WPSDevicePassword\n"); - ret = FAILURE; - } else { - if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || - ((t_u16)A2HEXDECIMAL(argv[0]) > - WPS_MAX_DEVICEPASSWORD)) { - printf("ERR:WPSDevicePassword must be in the range [%d:%d]\n", WPS_MIN_DEVICEPASSWORD, WPS_MAX_DEVICEPASSWORD); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_WPSMODELNUMBER: - if (argc > WPS_MODEL_MAX_LEN) { - printf("ERR: Incorrect number of WPSModelNumber arguments.\n"); - ret = FAILURE; - } else { - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported WPSModelNumber\n"); - ret = FAILURE; - break; - } - } - } - break; - case WIFIDIRECT_WPSSERIALNUMBER: - if (argc > WPS_SERIAL_MAX_LEN) { - printf("ERR: Incorrect number of WPSSerialNumber arguments.\n"); - ret = FAILURE; - } else { - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported WPSSerialNumber\n"); - ret = FAILURE; - break; - } - } - } - break; - case WIFIDIRECT_CATEGORY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Category\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:Category incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_ACTION: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Action\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || - ((atoi(argv[0]) > 0x10) && - (atoi(argv[0]) != 0xDD))) { - printf("ERR:Action must be less than 0x10 or 0xDD\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DIALOGTOKEN: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DialogToken\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:DialogToken incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_GAS_COMEBACK_DELAY: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for GAS Comeback Delay\n"); - ret = FAILURE; - } - break; - case WIFIDIRECT_DISC_ADPROTOIE: - if (argc > MAX_ADPROTOIE_LEN) { - printf("ERR: Incorrect number of AdvertisementProtocolIE arguments.\n"); - ret = FAILURE; - break; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported AdvertisementProtocolIE\n"); - ret = FAILURE; - break; - } - } - break; - case WIFIDIRECT_DISC_INFOID: - if (argc > MAX_INFOID_LEN) { - printf("ERR: Incorrect number of DiscoveryInformationID arguments.\n"); - ret = FAILURE; - break; - } - if (! - ((A2HEXDECIMAL(argv[0]) == 0xDD) && - (A2HEXDECIMAL(argv[1]) == 0xDD)) && - !((A2HEXDECIMAL(argv[0]) == 0xDE) && - (A2HEXDECIMAL(argv[1]) == 0x92))) { - printf("ERR:Unsupported DiscoveryInformationID\n"); - ret = FAILURE; - } - break; - case WIFIDIRECT_OUI: - if (argc > MAX_OUI_LEN) { - printf("ERR: Incorrect number of OUI arguments.\n"); - ret = FAILURE; - break; - } - for (i = 0; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == FAILURE) { - printf("ERR:Unsupported OUI\n"); - ret = FAILURE; - break; - } - } - break; - case WIFIDIRECT_OUITYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for OUIType\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:OUIType incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_OUISUBTYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for OUISubtype\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:OUISubtype incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DISC_SERVICEPROTO: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DiscoveryServiceProtocol\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) >= 4) && - (atoi(argv[0]) != - 0xFF))) { - printf("ERR:DiscoveryServiceProtocol incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_SERVICEUPDATE_INDICATOR: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for ServiceUpdateIndicator\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:ServiceUpdateIndicator incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DISC_SERVICETRANSACID: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DiscoveryServiceTransactionID\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:DiscoveryServiceTransactionID incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DISC_SERVICE_STATUS: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for ServiceStatus\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) >= 4)) { - printf("ERR:ServiceStatus incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DISC_DNSTYPE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DiscoveryDNSType\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:DiscoveryDNSType incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DISC_BONJOUR_VERSION: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Version\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:Version incorrect value\n"); - ret = FAILURE; - } - } - break; - case WIFIDIRECT_DISC_UPNP_VERSION: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for Version\n"); - ret = FAILURE; - } - break; - case WIFIDIRECT_ENABLE_SCAN: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for EnableScan\n"); - ret = FAILURE; - } else { - if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 0) && - (atoi(argv[0]) != 1))) { - printf("ERR:EnableScan must be 0 or 1.\n"); - ret = FAILURE; - } - } - break; - - case WIFIDIRECT_DEVICE_STATE: - if (argc != 1) { - printf("ERR:Incorrect number of arguments for DeviceState\n"); - ret = FAILURE; - } else { - if (ISDIGIT(argv[0]) == 0) { - printf("ERR:Incorrect DeviceState.\n"); - ret = FAILURE; - } - } - break; - - default: - printf("Parameter validity for %d ignored\n", cmd); - break; - } - return ret; -} - -/** Structure of command table*/ -typedef struct { - /** Command name */ - char *cmd; - /** Command function pointer */ - void (*func) (int argc, char *argv[]); - /** Command usuage */ - char *help; -} command_table; - -/** WIFIDIRECT command table */ -static command_table wifidirect_command[] = { - {"wifidirect_config", wifidirectcmd_config, - "\tSet/get wifidirect configuration"}, - {"wifidirect_params_config", wifidirectcmd_params_config, - "\tSet/get wifidirect parameter's configuration"}, - {"wifidirect_action_frame", wifidirectcmd_action_frame, - "\tSend wifidirect action frame."}, - {"wifidirect_mode", wifidirectcmd_status, - "\tSet/get WIFIDIRECT start/stop status"}, - {"wifidirect_discovery_request", wifidirectcmd_service_discovery, - "Send wifidirect service discovery request"}, - {"wifidirect_discovery_response", wifidirectcmd_service_discovery, - "Send wifidirect service discovery response"}, - {"wifidirect_gas_comeback_request", - wifidirectcmd_gas_comeback_discovery, - "Send wifidirect GAS comeback request frame"}, - {"wifidirect_gas_comeback_response", - wifidirectcmd_gas_comeback_discovery, - "Send wifidirect GAS comeback response frame"}, - {"wifidirect_cfg_persistent_group_record", - wifidirect_cfg_cmd_persistent_group_record, - "Set/get information about a persistent group"}, - {"wifidirect_cfg_persistent_group_invoke", - wifidirect_cfg_cmd_persistent_group_invoke, - "Invoke or disable a persistent group"}, - {"wifidirect_cfg_discovery_period", wifidirect_cfg_cmd_discovery_period, - "\tSet/get discovery period"}, - {"wifidirect_cfg_intent", wifidirect_cfg_cmd_intent, - "\tSet/get intent"}, - {"wifidirect_cfg_capability", wifidirect_cfg_cmd_capability, - "\tSet/get capability"}, - {"wifidirect_cfg_noa", wifidirect_cfg_cmd_noa, - "\tSet/get notice of absence"}, - {"wifidirect_cfg_opp_ps", wifidirect_cfg_cmd_opp_ps, - "\tSet/get Opportunistic PS"}, - {"wifidirect_cfg_invitation_list", wifidirect_cfg_cmd_invitation_list, - "\tSet/get invitation list"}, - {"wifidirect_cfg_listen_channel", wifidirect_cfg_cmd_listen_channel, - "\tSet/get listen channel"}, - {"wifidirect_cfg_op_channel", wifidirect_cfg_cmd_op_channel, - "\tSet/get operating channel"}, - {"wifidirect_cfg_presence_req_params", - wifidirect_cfg_cmd_presence_req_params, - "\tSet/get presence request parameters"}, - {"wifidirect_cfg_ext_listen_time", wifidirect_cfg_cmd_ext_listen_time, - "Set/get extended listen timing parameters"}, - {"wifidirect_cfg_provisioning_params", - wifidirect_cfg_cmd_provisioning_params, - "Set/get provisioning protocol related parameters"}, - {"wifidirect_cfg_wps_params", wifidirect_cfg_cmd_wps_params, - "Set/get WPS protocol related parameters"}, - {NULL, NULL, 0} -}; - -/** - * @brief Entry function for wifidirectutl - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return SUCCESS or FAILURE - */ -int -main(int argc, char *argv[]) -{ - int i; - - if (argc < 3) { - print_tool_usage(); - exit(1); - } - - strncpy(dev_name, argv[1], IFNAMSIZ); - /* Process command */ - for (i = 0; wifidirect_command[i].cmd; i++) { - if (strncmp - (wifidirect_command[i].cmd, argv[2], - strlen(wifidirect_command[i].cmd))) - continue; - if (strlen(wifidirect_command[i].cmd) != strlen(argv[2])) - continue; - wifidirect_command[i].func(argc, argv); - break; - } - if (!wifidirect_command[i].cmd) { - printf("ERR: %s is not supported\n", argv[2]); - exit(1); - } - return 0; - -} diff --git a/mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.h b/mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.h deleted file mode 100644 index 48ab6fc..0000000 --- a/mxm_wifiex/wlan_src/mapp/wifidirectutl/wifidirectutl.h +++ /dev/null @@ -1,1403 +0,0 @@ -/** @file wifidirectutl.h - * - * @brief Header file for wifidirectutl application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 07/10/09: Initial creation -************************************************************************/ -#ifndef _WIFIDIRECT_H -#define _WIFIDIRECT_H - -/** Character, 1 byte */ -typedef signed char t_s8; -/** Unsigned character, 1 byte */ -typedef unsigned char t_u8; - -/** Short integer */ -typedef signed short t_s16; -/** Unsigned short integer */ -typedef unsigned short t_u16; - -/** Integer */ -typedef signed int t_s32; -/** Unsigned integer */ -typedef unsigned int t_u32; - -/** Long long integer */ -typedef signed long long t_s64; -/** Unsigned long integer */ -typedef unsigned long long t_u64; - -#if (BYTE_ORDER == LITTLE_ENDIAN) -#undef BIG_ENDIAN_SUPPORT -#endif - -/** 16 bits byte swap */ -#define swap_byte_16(x) \ - ((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \ - (((t_u16)(x) & 0xff00U) >> 8))) - -/** 32 bits byte swap */ -#define swap_byte_32(x) \ - ((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \ - (((t_u32)(x) & 0x0000ff00UL) << 8) | \ - (((t_u32)(x) & 0x00ff0000UL) >> 8) | \ - (((t_u32)(x) & 0xff000000UL) >> 24))) - -/** 64 bits byte swap */ -#define swap_byte_64(x) \ - ((t_u64)((t_u64)(((t_u64)(x) & 0x00000000000000ffULL) << 56) | \ - (t_u64)(((t_u64)(x) & 0x000000000000ff00ULL) << 40) | \ - (t_u64)(((t_u64)(x) & 0x0000000000ff0000ULL) << 24) | \ - (t_u64)(((t_u64)(x) & 0x00000000ff000000ULL) << 8) | \ - (t_u64)(((t_u64)(x) & 0x000000ff00000000ULL) >> 8) | \ - (t_u64)(((t_u64)(x) & 0x0000ff0000000000ULL) >> 24) | \ - (t_u64)(((t_u64)(x) & 0x00ff000000000000ULL) >> 40) | \ - (t_u64)(((t_u64)(x) & 0xff00000000000000ULL) >> 56) )) - -/** Set opp_ps by shifting 7 bits left */ -#define SET_OPP_PS(x) ((x) << 7) - -/** Get opp_ps by masking and shifting 7 bits right */ -#define GET_OPP_PS(x) ((x) >> 7) - -/** CT window mask from opp_ps_ct_window combination */ -#define CT_WINDOW_MASK 0x7F -/** Invitation flag mask */ -#define INVITATION_FLAG_MASK 0x01 - -#ifdef BIG_ENDIAN_SUPPORT -/** Convert from 16 bit little endian format to CPU format */ -#define le16_to_cpu(x) swap_byte_16(x) -/** Convert from 32 bit little endian format to CPU format */ -#define le32_to_cpu(x) swap_byte_32(x) -/** Convert from 64 bit little endian format to CPU format */ -#define le64_to_cpu(x) swap_byte_64(x) -/** Convert to 16 bit little endian format from CPU format */ -#define cpu_to_le16(x) swap_byte_16(x) -/** Convert to 32 bit little endian format from CPU format */ -#define cpu_to_le32(x) swap_byte_32(x) -/** Convert to 64 bit little endian format from CPU format */ -#define cpu_to_le64(x) swap_byte_64(x) - -/** Convert WIFIDIRECTCMD header to little endian format from CPU format */ -#define endian_convert_request_header(x) \ - { \ - (x)->cmd_code = cpu_to_le16((x)->cmd_code); \ - (x)->size = cpu_to_le16((x)->size); \ - (x)->seq_num = cpu_to_le16((x)->seq_num); \ - (x)->result = cpu_to_le16((x)->result); \ - } - -/** Convert WIFIDIRECTCMD header from little endian format to CPU format */ -#define endian_convert_response_header(x) \ - { \ - (x)->cmd_code = le16_to_cpu((x)->cmd_code); \ - (x)->size = le16_to_cpu((x)->size); \ - (x)->seq_num = le16_to_cpu((x)->seq_num); \ - (x)->result = le16_to_cpu((x)->result); \ - } - -/** Convert WIFIDIRECT header to little endian format from CPU format */ -#define endian_convert_tlv_wifidirect_header_out(x) \ - { \ - (x)->length = cpu_to_le16((x)->length); \ - } - -/** Convert WIFIDIRECT header from little endian format to CPU format */ -#define endian_convert_tlv_wifidirect_header_in(x) \ - { \ - (x)->length = le16_to_cpu((x)->length); \ - } - -/** Convert TLV header to little endian format from CPU format */ -#define endian_convert_tlv_header_out(x) \ - { \ - (x)->tag = cpu_to_le16((x)->tag); \ - (x)->length = cpu_to_le16((x)->length); \ - } - -/** Convert TLV header from little endian format to CPU format */ -#define endian_convert_tlv_header_in(x) \ - { \ - (x)->tag = le16_to_cpu((x)->tag); \ - (x)->length = le16_to_cpu((x)->length); \ - } - -#else /* BIG_ENDIAN_SUPPORT */ -/** Do nothing */ -#define le16_to_cpu(x) x -/** Do nothing */ -#define le32_to_cpu(x) x -/** Do nothing */ -#define le64_to_cpu(x) x -/** Do nothing */ -#define cpu_to_le16(x) x -/** Do nothing */ -#define cpu_to_le32(x) x -/** Do nothing */ -#define cpu_to_le64(x) x - -/** Do nothing */ -#define endian_convert_request_header(x) -/** Do nothing */ -#define endian_convert_response_header(x) -/** Do nothing */ -#define endian_convert_tlv_wifidirect_header_out(x) -/** Do nothing */ -#define endian_convert_tlv_wifidirect_header_in(x) -/** Do nothing */ -#define endian_convert_tlv_header_out(x) -/** Do nothing */ -#define endian_convert_tlv_header_in(x) -#endif /* BIG_ENDIAN_SUPPORT */ - -/** Convert WPS TLV header to network order */ -#define endian_convert_tlv_wps_header_out(x) \ - { \ - (x)->tag = htons((x)->tag); \ - (x)->length = htons((x)->length); \ - } - -/** Convert WPS TLV header from network to host order */ -#define endian_convert_tlv_wps_header_in(t,l) \ - { \ - (t) = ntohs(t); \ - (l) = ntohs(l); \ - } - -/** Private command ID to set/get custom IE buffer */ -#define CUSTOM_IE (SIOCDEVPRIVATE + 13) - -/** TLV type ID definition */ -#define PROPRIETARY_TLV_BASE_ID 0x0100 -/** TLV: Management IE list */ -#define MRVL_MGMT_IE_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x69) //0x0169 -/** TLV: WifiDirect Discovery Period */ -#define MRVL_WIFIDIRECT_DISC_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7c) //0x017c -/** TLV: WifiDirect Scan Enable */ -#define MRVL_WIFIDIRECT_SCAN_ENABLE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7d) //0x017d -/** TLV: WifiDirect Peer Device */ -#define MRVL_WIFIDIRECT_PEER_DEVICE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7e) //0x017e -/** TLV: WifiDirect Scan Request Peer Device */ -#define MRVL_WIFIDIRECT_SCAN_REQ_DEVICE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x7f) //0x017f -/** TLV: WifiDirect Device State */ -#define MRVL_WIFIDIRECT_DEVICE_STATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x80) //0x0180 -/** TLV: WifiDirect Intent */ -#define MRVL_WIFIDIRECT_INTENT_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x81) //0x0181 -/** TLV: WifiDirect Capability */ -#define MRVL_WIFIDIRECT_CAPABILITY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x82) //0x0182 -/** TLV: WifiDirect Notice of Absence */ -#define MRVL_WIFIDIRECT_NOA_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x83) //0x0183 -/** TLV: WifiDirect Opportunistic Power Save */ -#define MRVL_WIFIDIRECT_OPP_PS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x84) //0x0184 -/** TLV: WifiDirect Invitation list */ -#define MRVL_WIFIDIRECT_INVITATION_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x85) //0x0185 -/** TLV: WifiDirect Listen channel */ -#define MRVL_WIFIDIRECT_LISTEN_CHANNEL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x86) //0x0186 -/** TLV: WifiDirect Operating Channel */ -#define MRVL_WIFIDIRECT_OPERATING_CHANNEL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x87) //0x0187 -/** TLV: WifiDirect Persistent Group */ -#define MRVL_WIFIDIRECT_PERSISTENT_GROUP_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x88) //0x0188 -/** TLV: WifiDirect Presence request parameters */ -#define MRVL_WIFIDIRECT_PRESENCE_REQ_PARAMS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8d) //0x018d -/** TLV: WifiDirect Extended Listen Time */ -#define MRVL_WIFIDIRECT_EXTENDED_LISTEN_TIME_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8e) //0x018e -/** TLV: WifiDirect Provisioning parameters */ -#define MRVL_WIFIDIRECT_PROVISIONING_PARAMS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x8f) //0x018f -/** TLV: WifiDirect WPS parameters */ -#define MRVL_WIFIDIRECT_WPS_PARAMS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x90) //0x0190 - -/** Max Device capability */ -#define MAX_DEV_CAPABILITY 255 -/** Max group capability */ -#define MAX_GRP_CAPABILITY 255 -/** Max Intent */ -#define MAX_INTENT 15 -/** Max length of Primary device type OUI */ -#define MAX_PRIMARY_OUI_LEN 4 -/** Min value of Regulatory class */ -#define MIN_REG_CLASS 1 -/** Max value of Regulatory class */ -#define MAX_REG_CLASS 255 -/** Min value of NoA index */ -#define MIN_NOA_INDEX 0 -/** Max value of NoA index */ -#define MAX_NOA_INDEX 255 -/** Min value of CTwindow */ -#define MIN_CTWINDOW 0 -/** Max value of CTwindow */ -#define MAX_CTWINDOW 63 -/** Min value of Count/Type */ -#define MIN_COUNT_TYPE 1 -/** Max value of Count/Type */ -#define MAX_COUNT_TYPE 255 -/** Min Primary Device type category */ -#define MIN_PRIDEV_TYPE_CAT 1 -/** Max Primary Device type category */ -#define MAX_PRIDEV_TYPE_CAT 11 -/** Min Primary Device type subcategory */ -#define MIN_PRIDEV_TYPE_SUBCATEGORY 1 -/** Max Primary Device type subcategory */ -#define MAX_PRIDEV_TYPE_SUBCATEGORY 9 -/** Min value of WPS config method */ -#define MIN_WPS_CONF_METHODS 0x01 -/** Max value of WPS config method */ -#define MAX_WPS_CONF_METHODS 0xffff -/** Max length of Advertisement Protocol IE */ -#define MAX_ADPROTOIE_LEN 4 -/** Max length of Discovery Information ID */ -#define MAX_INFOID_LEN 2 -/** Max length of OUI */ -#define MAX_OUI_LEN 3 -/** Max count of interface list */ -#define MAX_INTERFACE_ADDR_COUNT 41 -/** Max count of secondary device types */ -#define MAX_SECONDARY_DEVICE_COUNT 15 -/** Max count of group secondary device types*/ -#define MAX_GROUP_SECONDARY_DEVICE_COUNT 2 -/** Maximum length of lines in configuration file */ -#define MAX_CONFIG_LINE 1024 -/** Maximum number of arguments in configuration file */ -#define MAX_ARGS_NUM 256 -/** Maximum channels */ -#define MAX_CHANNELS 165 -/** Maximum number of NoA descriptors */ -#define MAX_NOA_DESCRIPTORS 8 -/** Maximum number of channel list entries */ -#define MAX_CHAN_LIST 8 -/** Maximum buffer size for channel entries */ -#define MAX_BUFFER_SIZE 64 -/** WPS Minimum version number */ -#define WPS_MIN_VERSION 0x10 -/** WPS Maximum version number */ -#define WPS_MAX_VERSION 0x20 -/** WPS Minimum request type */ -#define WPS_MIN_REQUESTTYPE 0x00 -/** WPS Maximum request type */ -#define WPS_MAX_REQUESTTYPE 0x04 -/** WPS Minimum config methods */ -#define WPS_MIN_SPECCONFMETHODS 0x0001 -/** WPS Maximum config methods */ -#define WPS_MAX_SPECCONFMETHODS 0xFFFF -/** WPS UUID maximum length */ -#define WPS_UUID_MAX_LEN 16 -/** WPS Device Type maximum length */ -#define WPS_DEVICE_TYPE_MAX_LEN 8 -/** WPS Minimum association state */ -#define WPS_MIN_ASSOCIATIONSTATE 0x0000 -/** WPS Maximum association state */ -#define WPS_MAX_ASSOCIATIONSTATE 0x0004 -/** WPS Minimum configuration error */ -#define WPS_MIN_CONFIGURATIONERROR 0x0000 -/** WPS Maximum configuration error */ -#define WPS_MAX_CONFIGURATIONERROR 0x0012 -/** WPS Minimum Device password ID */ -#define WPS_MIN_DEVICEPASSWORD 0x0000 -/** WPS Maximum Device password ID */ -#define WPS_MAX_DEVICEPASSWORD 0x000f -/** WPS Device Name maximum length */ -#define WPS_DEVICE_NAME_MAX_LEN 32 -/** WPS Model maximum length */ -#define WPS_MODEL_MAX_LEN 32 -/** WPS Serial maximum length */ -#define WPS_SERIAL_MAX_LEN 32 -/** WPS Manufacturer maximum length */ -#define WPS_MANUFACT_MAX_LEN 64 -/** WPS Device Info OUI+Type+SubType Length */ -#define WPS_DEVICE_TYPE_LEN 8 - -/** Maximum value of invitation list index */ -#define WIFIDIRECT_INVITATION_LIST_MAX 5 -/** Maximum value of persistent group index */ -#define WIFIDIRECT_PERSISTENT_GROUP_MAX 4 -/** Minimum length of Passphrase */ -#define WIFIDIRECT_PASSPHRASE_LEN_MIN 8 -/** Maximum length of PSK */ -#define WIFIDIRECT_PSK_LEN_MAX 64 -/** Persistent group cancel command */ -#define WIFIDIRECT_PERSISTENT_RECORD_CANCEL 0xFF -/** Maximum value of noA descriptors */ -#define WIFIDIRECT_NOA_DESC_MAX 2 -/** Country string last byte 0x04 */ -#define WIFIDIRECT_COUNTRY_LAST_BYTE 0x04 - -#ifdef __GNUC__ -/** Structure packing begins */ -#define PACK_START -/** Structure packeing end */ -#define PACK_END __attribute__ ((packed)) -#else -/** Structure packing begins */ -#define PACK_START __packed -/** Structure packeing end */ -#define PACK_END -#endif - -#ifndef ETH_ALEN -/** MAC address length */ -#define ETH_ALEN 6 -#endif - -/** Action field value : get */ -#define ACTION_GET 0 -/** Action field value : set */ -#define ACTION_SET 1 - -/** Success */ -#define SUCCESS 1 -/** Failure */ -#define FAILURE 0 -/** MAC BROADCAST */ -#define WIFIDIRECT_RET_MAC_BROADCAST 0x1FF -/** MAC MULTICAST */ -#define WIFIDIRECT_RET_MAC_MULTICAST 0x1FE - -/** Command is successful */ -#define CMD_SUCCESS 0 -/** Command fails */ -#define CMD_FAILURE -1 - -/** - * Hex or Decimal to Integer - * @param num string to convert into decimal or hex - */ -#define A2HEXDECIMAL(num) \ - (strncasecmp("0x", (num), 2)?(unsigned int) strtoll((num),NULL,0):a2hex((num)))\ - -/** - * Check of decimal or hex string - * @param num string - */ -#define IS_HEX_OR_DIGIT(num) \ - (strncasecmp("0x", (num), 2)?ISDIGIT((num)):ishexstring((num)))\ - -/** Find minimum value */ -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -/** Level of wifidirect parameters in the wifidirect.conf file */ -typedef enum { - WIFIDIRECT_PARAMS_CONFIG = 1, - WIFIDIRECT_CAPABILITY_CONFIG, - WIFIDIRECT_GROUP_OWNER_INTENT_CONFIG, - WIFIDIRECT_CHANNEL_CONFIG, - WIFIDIRECT_MANAGEABILITY_CONFIG, - WIFIDIRECT_CHANNEL_LIST_CONFIG, - WIFIDIRECT_NOTICE_OF_ABSENCE, - WIFIDIRECT_NOA_DESCRIPTOR, - WIFIDIRECT_DEVICE_INFO_CONFIG, - WIFIDIRECT_GROUP_INFO_CONFIG, - WIFIDIRECT_GROUP_SEC_INFO_CONFIG, - WIFIDIRECT_GROUP_CLIENT_INFO_CONFIG, - WIFIDIRECT_DEVICE_SEC_INFO_CONFIG, - WIFIDIRECT_GROUP_ID_CONFIG, - WIFIDIRECT_GROUP_BSS_ID_CONFIG, - WIFIDIRECT_DEVICE_ID_CONFIG, - WIFIDIRECT_INTERFACE_CONFIG, - WIFIDIRECT_TIMEOUT_CONFIG, - WIFIDIRECT_EXTENDED_TIME_CONFIG, - WIFIDIRECT_INTENDED_ADDR_CONFIG, - WIFIDIRECT_OPCHANNEL_CONFIG, - WIFIDIRECT_INVITATION_FLAG_CONFIG, - WIFIDIRECT_WPSIE, - WIFIDIRECT_DISCOVERY_REQUEST_RESPONSE = 0x20, - WIFIDIRECT_DISCOVERY_QUERY, - WIFIDIRECT_DISCOVERY_SERVICE, - WIFIDIRECT_DISCOVERY_VENDOR, - WIFIDIRECT_DISCOVERY_QUERY_RESPONSE_PER_PROTOCOL, - WIFIDIRECT_EXTRA, -} wifidirect_param_level; - -/** Valid Input Commands */ -typedef enum { - SCANCHANNELS, - CHANNEL, - WIFIDIRECT_DEVICECAPABILITY, - WIFIDIRECT_GROUPCAPABILITY, - WIFIDIRECT_INTENT, - WIFIDIRECT_REGULATORYCLASS, - WIFIDIRECT_MANAGEABILITY, - WIFIDIRECT_COUNTRY, - WIFIDIRECT_NO_OF_CHANNELS, - WIFIDIRECT_NOA_INDEX, - WIFIDIRECT_OPP_PS, - WIFIDIRECT_CTWINDOW, - WIFIDIRECT_COUNT_TYPE, - WIFIDIRECT_DURATION, - WIFIDIRECT_INTERVAL, - WIFIDIRECT_START_TIME, - WIFIDIRECT_PRIDEVTYPECATEGORY, - WIFIDIRECT_PRIDEVTYPEOUI, - WIFIDIRECT_PRIDEVTYPESUBCATEGORY, - WIFIDIRECT_SECONDARYDEVCOUNT, - WIFIDIRECT_GROUP_SECONDARYDEVCOUNT, - WIFIDIRECT_GROUP_WIFIDIRECT_DEVICE_NAME, - WIFIDIRECT_INTERFACECOUNT, - WIFIDIRECT_ATTR_CONFIG_TIMEOUT, - WIFIDIRECT_ATTR_EXTENDED_TIME, - WIFIDIRECT_WPSCONFMETHODS, - WIFIDIRECT_WPSVERSION, - WIFIDIRECT_WPSSETUPSTATE, - WIFIDIRECT_WPSREQRESPTYPE, - WIFIDIRECT_WPSSPECCONFMETHODS, - WIFIDIRECT_WPSUUID, - WIFIDIRECT_WPSPRIMARYDEVICETYPE, - WIFIDIRECT_WPSRFBAND, - WIFIDIRECT_WPSASSOCIATIONSTATE, - WIFIDIRECT_WPSCONFIGURATIONERROR, - WIFIDIRECT_WPSDEVICENAME, - WIFIDIRECT_WPSDEVICEPASSWORD, - WIFIDIRECT_WPSMANUFACTURER, - WIFIDIRECT_WPSMODELNAME, - WIFIDIRECT_WPSMODELNUMBER, - WIFIDIRECT_WPSSERIALNUMBER, - WIFIDIRECT_CATEGORY, - WIFIDIRECT_ACTION, - WIFIDIRECT_DIALOGTOKEN, - WIFIDIRECT_DISC_ADPROTOIE, - WIFIDIRECT_GAS_COMEBACK_DELAY, - WIFIDIRECT_DISC_INFOID, - WIFIDIRECT_OUI, - WIFIDIRECT_OUITYPE, - WIFIDIRECT_OUISUBTYPE, - WIFIDIRECT_SERVICEUPDATE_INDICATOR, - WIFIDIRECT_DISC_SERVICEPROTO, - WIFIDIRECT_DISC_SERVICETRANSACID, - WIFIDIRECT_DISC_SERVICE_STATUS, - WIFIDIRECT_MINDISCOVERYINT, - WIFIDIRECT_MAXDISCOVERYINT, - WIFIDIRECT_ENABLE_SCAN, - WIFIDIRECT_DEVICE_STATE, - WIFIDIRECT_INVITATIONFLAG, - WIFIDIRECT_DISC_DNSTYPE, - WIFIDIRECT_DISC_BONJOUR_VERSION, - WIFIDIRECT_DISC_UPNP_VERSION, - WIFIDIRECT_PRESENCE_REQ_TYPE, -} valid_inputs; - -/** WIFIDIRECT IE header len */ -#define WIFIDIRECT_IE_HEADER_LEN 3 - -/** AP CMD header */ -#define WIFIDIRECT_CMD_HEADER /** Buf Size */ \ - t_u32 buf_size; \ - /** Command Code */ \ - t_u16 cmd_code; \ - /** Size */ \ - t_u16 size; \ - /** Sequence Number */ \ - t_u16 seq_num; \ - /** Result */ \ - t_s16 result - -/** TLV header size */ -#define MRVL_TLV_HEADER_SIZE 4 - -/** NXP private command identifier */ -#define CMD_NXP "MRVL_CMD" -/** NXP private command for hostcmd */ -#define PRIV_CMD_HOSTCMD "hostcmd" - -/** WIFIDIRECTCMD buffer */ -typedef PACK_START struct _wifidirectcmdbuf { - /** Header */ - WIFIDIRECT_CMD_HEADER; -} PACK_END wifidirectcmdbuf; - -/** MRVL private CMD structure */ -typedef PACK_START struct _mrvl_priv_cmd { - /** Command buffer */ - t_u8 *buf; - /** Used length */ - t_u32 used_len; - /** Total length */ - t_u32 total_len; -} PACK_END mrvl_priv_cmd; - -/** TLV buffer : WifiDirect Custom IE Buffer Format*/ -typedef PACK_START struct special_mask_custom_ie_buf { - /** Vendor Specific OUI */ - t_u8 Oui[4]; - /** Vendor Specific Buffer */ - t_u8 wfd_ie[]; -} PACK_END special_mask_custom_ie_buf; - -/** TLV buffer : WifiDirect IE device Id */ -typedef PACK_START struct _tlvbuf_wifidirect_device_id { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device MAC address */ - t_u8 dev_mac_address[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_device_id; - -/** TLV buffer : WifiDirect IE capability */ -typedef PACK_START struct _tlvbuf_wifidirect_capability { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device capability */ - t_u8 dev_capability; - /** WIFIDIRECT group capability */ - t_u8 group_capability; -} PACK_END tlvbuf_wifidirect_capability; - -/** TLV buffer : WifiDirect IE Group owner intent */ -typedef PACK_START struct _tlvbuf_wifidirect_group_owner_intent { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device group owner intent */ - t_u8 dev_intent; -} PACK_END tlvbuf_wifidirect_group_owner_intent; - -/** TLV buffer : WifiDirect IE channel */ -typedef PACK_START struct _tlvbuf_wifidirect_channel { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT country string */ - t_u8 country_string[3]; - /** WIFIDIRECT regulatory class */ - t_u8 regulatory_class; - /** WIFIDIRECT channel number */ - t_u8 channel_number; -} PACK_END tlvbuf_wifidirect_channel; - -/** TLV buffer : WifiDirect IE invitation flag */ -typedef PACK_START struct _tlvbuf_wifidirect_invitation_flag { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT invitation flag */ - t_u8 invitation_flag; -} PACK_END tlvbuf_wifidirect_invitation_flag; - -/** Channel Entry */ -typedef PACK_START struct _chan_entry { - /** WIFIDIRECT regulatory class */ - t_u8 regulatory_class; - /** WIFIDIRECT no of channels */ - t_u8 num_of_channels; - /** WIFIDIRECT channel number */ - t_u8 chan_list[]; -} PACK_END chan_entry; - -/** NoA Descriptor */ -typedef PACK_START struct _noa_descriptor { - /** WIFIDIRECT count OR type */ - t_u8 count_type; - /** WIFIDIRECT duration */ - t_u32 duration; - /** WIFIDIRECT interval */ - t_u32 interval; - /** WIFIDIRECT start time */ - t_u32 start_time; -} PACK_END noa_descriptor; - -/** TLV buffer : WifiDirect IE channel list */ -typedef PACK_START struct _tlvbuf_wifidirect_channel_list { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT country string */ - t_u8 country_string[3]; - /** WIFIDIRECT channel entry list */ - chan_entry wifidirect_chan_entry_list[]; -} PACK_END tlvbuf_wifidirect_channel_list; - -/** TLV buffer : WifiDirect IE Manageability */ -typedef PACK_START struct _tlvbuf_wifidirect_manageability { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT Manageability */ - t_u8 manageability; -} PACK_END tlvbuf_wifidirect_manageability; - -/** TLV buffer : WifiDirect IE Notice of Absence */ -typedef PACK_START struct _tlvbuf_wifidirect_notice_of_absence { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT NoA Index */ - t_u8 noa_index; - /** WIFIDIRECT CTWindow and OppPS parameters */ - t_u8 ctwindow_opp_ps; - /** WIFIDIRECT NoA Descriptor list */ - noa_descriptor wifidirect_noa_descriptor_list[]; -} PACK_END tlvbuf_wifidirect_notice_of_absence; - -/** TLV buffer : WifiDirect IE device Info */ -typedef PACK_START struct _tlvbuf_wifidirect_device_info { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT device address */ - t_u8 dev_address[ETH_ALEN]; - /** WPS config methods */ - t_u16 config_methods; - /** Primary device type : category */ - t_u16 primary_category; - /** Primary device type : OUI */ - t_u8 primary_oui[4]; - /** Primary device type : sub-category */ - t_u16 primary_subcategory; - /** Secondary Device Count */ - t_u8 secondary_dev_count; - /** Secondary Device Info */ - t_u8 secondary_dev_info[0]; - /** WPS Device Name Tag */ - t_u16 device_name_type; - /** WPS Device Name Length */ - t_u16 device_name_len; - /** Device name */ - t_u8 device_name[]; -} PACK_END tlvbuf_wifidirect_device_info; - -/** TLV buffer : wifidirect IE WIFIDIRECT Group Info- Client Dev Info */ -typedef PACK_START struct _wifidirect_client_dev_info { - /** Length of each device */ - t_u8 dev_length; - /** WIFIDIRECT device address */ - t_u8 wifidirect_dev_address[ETH_ALEN]; - /** WIFIDIRECT Interface address */ - t_u8 wifidirect_intf_address[ETH_ALEN]; - /** WIFIDIRECT Device capability*/ - t_u8 wifidirect_dev_capability; - /** WPS config methods */ - t_u16 config_methods; - /** Primary device type : category */ - t_u16 primary_category; - /** Primary device type : OUI */ - t_u8 primary_oui[4]; - /** Primary device type : sub-category */ - t_u16 primary_subcategory; - /** Secondary Device Count */ - t_u8 wifidirect_secondary_dev_count; - /** Secondary Device Info */ - t_u8 wifidirect_secondary_dev_info[0]; - /** WPS WIFIDIRECT Device Name Tag */ - t_u16 wifidirect_device_name_type; - /** WPS WIFIDIRECT Device Name Length */ - t_u16 wifidirect_device_name_len; - /** WIFIDIRECT Device name */ - t_u8 wifidirect_device_name[]; -} PACK_END wifidirect_client_dev_info; - -/** TLV buffer : wifidirect IE WIFIDIRECT Group Info */ -typedef PACK_START struct _tlvbuf_wifidirect_group_info { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** Secondary Device Info */ - t_u8 wifidirect_client_dev_list[]; -} PACK_END tlvbuf_wifidirect_group_info; - -/** TLV buffer : WifiDirect IE group Id */ -typedef PACK_START struct _tlvbuf_wifidirect_group_id { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT group MAC address */ - t_u8 group_address[ETH_ALEN]; - /** WIFIDIRECT group SSID */ - t_u8 group_ssid[]; -} PACK_END tlvbuf_wifidirect_group_id; - -/** TLV buffer : WifiDirect IE group BSS Id */ -typedef PACK_START struct _tlvbuf_wifidirect_group_bss_id { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT group Bss Id */ - t_u8 group_bssid[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_group_bss_id; - -/** TLV buffer : WifiDirect IE Interface */ -typedef PACK_START struct _tlvbuf_wifidirect_interface { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT interface Id */ - t_u8 interface_id[ETH_ALEN]; - /** WIFIDIRECT interface count */ - t_u8 interface_count; - /** WIFIDIRECT interface addresslist */ - t_u8 interface_idlist[]; -} PACK_END tlvbuf_wifidirect_interface; - -/** TLV buffer : WifiDirect configuration timeout */ -typedef PACK_START struct _tlvbuf_wifidirect_config_timeout { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** Group configuration timeout */ - t_u8 group_config_timeout; - /** Device configuration timeout */ - t_u8 device_config_timeout; -} PACK_END tlvbuf_wifidirect_config_timeout; - -/** TLV buffer : WifiDirect extended listen time */ -typedef PACK_START struct _tlvbuf_wifidirect_ext_listen_time { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** Availability period */ - t_u16 availability_period; - /** Availability interval */ - t_u16 availability_interval; -} PACK_END tlvbuf_wifidirect_ext_listen_time; - -/** TLV buffer : WifiDirect Intended Interface Address */ -typedef PACK_START struct _tlvbuf_wifidirect_intended_addr { - /** TLV Header tag */ - t_u8 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT Group interface address */ - t_u8 group_address[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_intended_addr; - -/** TLV buffer : WifiDirect WPS IE */ -typedef PACK_START struct _tlvbuf_wifidirect_wps_ie { - /** TLV Header tag */ - t_u16 tag; - /** TLV Header length */ - t_u16 length; - /** WIFIDIRECT WPS IE data */ - t_u8 data[]; -} PACK_END tlvbuf_wps_ie; - -/** HostCmd_CMD_WIFIDIRECT_MODE_CONFIG */ -typedef PACK_START struct _wifidirect_mode_config { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - /** wifidirect mode data */ - t_u16 mode; -} PACK_END wifidirect_mode_config; - -/** HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG */ -typedef PACK_START struct _wifidirect_params_config { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - /** TLV data */ - t_u8 wifidirect_tlv[]; -} PACK_END wifidirect_params_config; - -/** Internal WIFIDIRECT structure for Query Data */ -typedef PACK_START struct wifidirect_query_data { - union { - PACK_START struct upnp_specific_query { - /** version field */ - t_u8 version; - /** value */ - t_u8 value[]; - } PACK_END upnp; - - PACK_START struct bonjour_specific_query { - /** DNS name */ - t_u8 dns[0]; - /** DNS type */ - t_u8 dns_type; - /** version field */ - t_u8 version; - } PACK_END bonjour; - } u; -} PACK_END wifidirect_query_data; - -/** Internal WIFIDIRECT structure for Response Data */ -typedef PACK_START struct wifidirect_Response_data { - union { - PACK_START struct upnp_specific_response { - /** version field */ - t_u8 version; - /** value */ - t_u8 value[]; - } PACK_END upnp; - - PACK_START struct bonjour_specific_response { - /** DNS name */ - t_u8 dns[0]; - /** DNS type */ - t_u8 dns_type; - /** version field */ - t_u8 version; - /** DNS name */ - t_u8 record[]; - } PACK_END bonjour; - } u; -} PACK_END wifidirect_response_data; - -/** HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY request */ -typedef PACK_START struct _wifidirect_discovery_request { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** Dialog taken */ - t_u8 dialog_taken; - /** Advertize protocol IE */ - t_u8 advertize_protocol_ie[MAX_ADPROTOIE_LEN]; - /** Query request Length */ - t_u16 query_len; - /** Information identifier */ - t_u8 info_id[MAX_INFOID_LEN]; - /** Request Length */ - t_u16 request_len; - /** OUI */ - t_u8 oui[MAX_OUI_LEN]; - /** OUI sub type */ - t_u8 oui_sub_type; - /** Service update indicator */ - t_u16 service_update_indicator; - /** Vendor Length */ - t_u16 vendor_len; - /** Service protocol */ - t_u8 service_protocol; - /** Service transaction Id */ - t_u8 service_transaction_id; - /** Query Data */ - wifidirect_query_data disc_query; -} PACK_END wifidirect_discovery_request; - -/** HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY response */ -typedef PACK_START struct _wifidirect_discovery_response { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** Dialog taken */ - t_u8 dialog_taken; - /** Status code */ - t_u16 status_code; - /** GAS comback reply */ - t_u16 gas_reply; - /** Advertize protocol IE */ - t_u8 advertize_protocol_ie[MAX_ADPROTOIE_LEN]; - /** Query response Length */ - t_u16 query_len; - /** Information identifier */ - t_u8 info_id[MAX_INFOID_LEN]; - /** Response Length */ - t_u16 response_len; - /** OUI */ - t_u8 oui[MAX_OUI_LEN]; - /** OUI sub type */ - t_u8 oui_sub_type; - /** Service update indicator */ - t_u16 service_update_indicator; - /** Vendor Length */ - t_u16 vendor_len; - /** Service protocol */ - t_u8 service_protocol; - /** Service transaction Id */ - t_u8 service_transaction_id; - /** Discovery status code */ - t_u8 disc_status_code; - /** Response Data */ - wifidirect_response_data disc_resp; -} PACK_END wifidirect_discovery_response; - -/** HostCmd_CMD_WIFIDIRECT_GAS_COMEBACK_SERVICE request */ -typedef PACK_START struct _wifidirect_gas_comeback_request { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** Dialog taken */ - t_u8 dialog_taken; -} PACK_END wifidirect_gas_comeback_request; - -/** HostCmd_CMD_WIFIDIRECT_GAS_COMEBACK_SERVICE response */ -typedef PACK_START struct _wifidirect_gas_comeback_response { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** Dialog taken */ - t_u8 dialog_taken; - /** Status code */ - t_u16 status_code; - /** Gas response fragment ID */ - t_u8 gas_fragment_id; - /** GAS comback reply */ - t_u16 gas_reply; - /** Advertize protocol IE */ - t_u8 advertize_protocol_ie[MAX_ADPROTOIE_LEN]; - /** Query response Length */ - t_u16 query_len; - /** Information identifier */ - t_u8 info_id[MAX_INFOID_LEN]; - /** Response Length */ - t_u16 response_len; - /** Response status code */ - t_u8 resp_status_code; - /** OUI */ - t_u8 oui[MAX_OUI_LEN]; - /** OUI sub type */ - t_u8 oui_sub_type; - /** Service update indicator */ - t_u16 service_update_indicator; - /** Vendor Length */ - t_u16 vendor_len; - /** Service protocol */ - t_u8 service_protocol; - /** Service transaction Id */ - t_u8 service_transaction_id; - /** Discovery status code */ - t_u8 disc_status_code; - /** Response Data */ - wifidirect_response_data disc_resp; -} PACK_END wifidirect_gas_comeback_response; - -/** HostCmd_CMD_WIFIDIRECT_ACTION_FRAME request */ -typedef PACK_START struct _wifidirect_action_frame { - /** Header */ - WIFIDIRECT_CMD_HEADER; - /** Peer mac address */ - t_u8 peer_mac_addr[ETH_ALEN]; - /** Category */ - t_u8 category; - /** Action */ - t_u8 action; - /** OUI */ - t_u8 oui[MAX_OUI_LEN]; - /** OUI type */ - t_u8 oui_type; - /** OUI sub type */ - t_u8 oui_sub_type; - /** Dialog taken */ - t_u8 dialog_taken; - /** IE List of TLVs */ - t_u8 ie_list[]; -} PACK_END wifidirect_action_frame; - -/** custom IE */ -typedef PACK_START struct _custom_ie { - /** IE Index */ - t_u16 ie_index; - /** Mgmt Subtype Mask */ - t_u16 mgmt_subtype_mask; - /** IE Length */ - t_u16 ie_length; - /** IE buffer */ - t_u8 ie_buffer[]; -} PACK_END custom_ie; - -/** TLV buffer : custom IE */ -typedef PACK_START struct _tlvbuf_custom_ie { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** custom IE data */ - custom_ie ie_data[]; -} PACK_END tlvbuf_custom_ie; - -/** TLV buffer : persistent group */ -typedef PACK_START struct _tlvbuf_wifidirect_persistent_group { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Record Index */ - t_u8 rec_index; - /** Device Role */ - t_u8 dev_role; - /** wifidirect group Bss Id */ - t_u8 group_bssid[ETH_ALEN]; - /** wifidirect device MAC address */ - t_u8 dev_mac_address[ETH_ALEN]; - /** wifidirect group SSID length */ - t_u8 group_ssid_len; - /** wifidirect group SSID */ - t_u8 group_ssid[0]; - /** wifidirect PSK length */ - t_u8 psk_len; - /** wifidirect PSK */ - t_u8 psk[0]; - /** Num of PEER MAC Addresses */ - t_u8 num_peers; - /** PEER MAC Addresses List */ - t_u8 peer_mac_addrs[][ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_persistent_group; - -/** TLV buffer : WifiDirect discovery period */ -typedef PACK_START struct _tlvbuf_wifidirect_discovery_period { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Min discovery interval */ - t_u16 min_disc_interval; - /** Max discovery interval */ - t_u16 max_disc_interval; -} PACK_END tlvbuf_wifidirect_discovery_period; - -/** TLV buffer : WifiDirect Intent */ -typedef PACK_START struct _tlvbuf_wifidirect_intent { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Intent value */ - t_u8 intent; -} PACK_END tlvbuf_wifidirect_intent; - -/** TLV buffer : WifiDirect Invitation List */ -typedef PACK_START struct _tlvbuf_wifidirect_invitation_list { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Invitation peer address*/ - t_u8 inv_peer_addr[ETH_ALEN]; -} PACK_END tlvbuf_wifidirect_invitation_list; - -/** TLV buffer : WifiDirect Listen Channel */ -typedef PACK_START struct _tlvbuf_wifidirect_listen_channel { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Country str */ - t_u8 country_str[3]; - /** operating class */ - t_u8 operating_class; - /** Listen Channel */ - t_u8 listen_channel; -} PACK_END tlvbuf_wifidirect_listen_channel; - -/** TLV buffer : WifiDirect Operating Channel */ -typedef PACK_START struct _tlvbuf_wifidirect_operating_channel { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Country str */ - t_u8 country_str[3]; - /** operating class */ - t_u8 operating_class; - /** Operating Channel */ - t_u8 operating_channel; -} PACK_END tlvbuf_wifidirect_operating_channel; - -/** TLV buffer : WifiDirect NoA config */ -typedef PACK_START struct _tlvbuf_wifidirect_noa_config { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Enable/Disable NoA */ - t_u16 enable_noa; - /** Index */ - t_u8 noa_index; - /** CountType */ - t_u8 count_type; - /** Duration */ - t_u32 duration; - /** Interval */ - t_u32 interval; -} PACK_END tlvbuf_wifidirect_noa_config; - -/** TLV buffer : wifidirect OppPS config */ -typedef PACK_START struct _tlvbuf_opp_ps_config { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** CTWindow and OppPS*/ - t_u8 ctwindow_opp_ps; -} PACK_END tlvbuf_wifidirect_opp_ps_config; - -/** TLV buffer : wifidirect capability config */ -typedef PACK_START struct _tlvbuf_capability_config { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Device capability */ - t_u8 dev_capability; - /** Group capability */ - t_u8 group_capability; -} PACK_END tlvbuf_wifidirect_capability_config; - -/** TLV buffer : WifiDirect Presence Request Parameters */ -typedef PACK_START struct _tlvbuf_wifidirect_presence_req_params { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Presence Request Type */ - t_u8 presence_req_type; - /** Duration */ - t_u32 duration; - /** Interval */ - t_u32 interval; -} PACK_END tlvbuf_wifidirect_presence_req_params; - -/** TLV buffer : WifiDirect Extended Listen Timing parameters*/ -typedef PACK_START struct _tlvbuf_mrvl_wifidirect_ext_listen_time { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** Duration */ - t_u16 duration; - /** Interval */ - t_u16 interval; -} PACK_END tlvbuf_wifidirect_mrvl_ext_listen_time; - -/** TLV buffer : WifiDirect Provisioning parameters*/ -typedef PACK_START struct _tlvbuf_wifidirect_provisioning_params { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** action */ - t_u16 action; - /** config methods */ - t_u16 config_methods; - /** config methods */ - t_u16 dev_password; -} PACK_END tlvbuf_wifidirect_provisioning_params; - -/** TLV buffer : WifiDirect WPS parameters*/ -typedef PACK_START struct _tlvbuf_wifidirect_wps_params { - /** Tag */ - t_u16 tag; - /** Length */ - t_u16 length; - /** action */ - t_u16 action; -} PACK_END tlvbuf_wifidirect_wps_params; - -/** Max size of custom IE buffer */ -#define MAX_SIZE_IE_BUFFER (256) -/** Size of command buffer */ -#define MRVDRV_SIZE_OF_CMD_BUFFER (3* 1024) -/** Maximum size of set/get configurations */ -#define MAX_CFG_DATA_SIZE 3000 /* less than MRVDRV_SIZE_OF_CMD_BUFFER */ -/** 4 byte header to store buf len*/ -#define BUF_HEADER_SIZE 4 -/** OUI Type WFA WIFIDIRECT */ -#define OUI_TYPE_WFA_WIFIDIRECT 9 - -/** MRVL private command ioctl number */ -#define MRVLPRIVCMD (SIOCDEVPRIVATE + 14) -/** Host Command ID bit mask (bit 11:0) */ -#define HostCmd_CMD_ID_MASK 0x0fff -/** WIFIDIRECTCMD response check */ -#define WIFIDIRECTCMD_RESP_CHECK 0x8000 - -/** Host Command ID : wifidirect mode config */ -#define HostCmd_CMD_WIFIDIRECT_MODE_CONFIG 0x00eb -/** Host Command ID: WIFIDIRECT_SET_PARAMS */ -#define HostCmd_CMD_WIFIDIRECT_PARAMS_CONFIG 0x00ea -/** Host Command ID: WIFIDIRECT_SERVICE_DISCOVERY */ -#define HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY 0x00ec -/** Host Command ID: WIFIDIRECT_ACTION_FRAME */ -#define HostCmd_CMD_802_11_ACTION_FRAME 0x00f4 - -/** TLV : WifiDirect param capability */ -#define TLV_TYPE_WIFIDIRECT_CAPABILITY 0x0002 -/** TLV : WifiDirect param device Id */ -#define TLV_TYPE_WIFIDIRECT_DEVICE_ID 0x0003 -/** TLV : WifiDirect param group owner intent */ -#define TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT 0x0004 -/** TLV : WifiDirect param config timeout */ -#define TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT 0x0005 -/** TLV : WifiDirect param channel */ -#define TLV_TYPE_WIFIDIRECT_CHANNEL 0x0006 -/** TLV : WifiDirect param group bssId */ -#define TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID 0x0007 -/** TLV : WifiDirect param extended listen time */ -#define TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME 0x0008 -/** TLV : WifiDirect param intended address */ -#define TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS 0x0009 -/** TLV : WifiDirect param manageability */ -#define TLV_TYPE_WIFIDIRECT_MANAGEABILITY 0x000a -/** TLV : WifiDirect param channel list */ -#define TLV_TYPE_WIFIDIRECT_CHANNEL_LIST 0x000b -/** TLV : WifiDirect Notice of Absence */ -#define TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE 0x000c -/** TLV : WifiDirect param device Info */ -#define TLV_TYPE_WIFIDIRECT_DEVICE_INFO 0x000d -/** TLV : WifiDirect param Group Info */ -#define TLV_TYPE_WIFIDIRECT_GROUP_INFO 0x000e -/** TLV : WifiDirect param group Id */ -#define TLV_TYPE_WIFIDIRECT_GROUP_ID 0x000f -/** TLV : WifiDirect param interface */ -#define TLV_TYPE_WIFIDIRECT_INTERFACE 0x0010 -/** TLV : WifiDirect param operating channel */ -#define TLV_TYPE_WIFIDIRECT_OPCHANNEL 0x0011 -/** TLV : WifiDirect param invitation flag */ -#define TLV_TYPE_WIFIDIRECT_INVITATION_FLAG 0x0012 - -/** enum : WPS attribute type */ -typedef enum { - SC_AP_Channel = 0x1001, - SC_Association_State = 0x1002, - SC_Authentication_Type = 0x1003, - SC_Authentication_Type_Flags = 0x1004, - SC_Authenticator = 0x1005, - SC_Config_Methods = 0x1008, - SC_Configuration_Error = 0x1009, - SC_Confirmation_URL4 = 0x100A, - SC_Confirmation_URL6 = 0x100B, - SC_Connection_Type = 0x100C, - SC_Connection_Type_Flags = 0x100D, - SC_Credential = 0x100E, - SC_Device_Name = 0x1011, - SC_Device_Password_ID = 0x1012, - SC_E_Hash1 = 0x1014, - SC_E_Hash2 = 0x1015, - SC_E_SNonce1 = 0x1016, - SC_E_SNonce2 = 0x1017, - SC_Encrypted_Settings = 0x1018, - SC_Encryption_Type = 0X100F, - SC_Encryption_Type_Flags = 0x1010, - SC_Enrollee_Nonce = 0x101A, - SC_Feature_ID = 0x101B, - SC_Identity = 0X101C, - SC_Identity_Proof = 0X101D, - SC_Key_Wrap_Authenticator = 0X101E, - SC_Key_Identifier = 0X101F, - SC_MAC_Address = 0x1020, - SC_Manufacturer = 0x1021, - SC_Message_Type = 0x1022, - SC_Model_Name = 0x1023, - SC_Model_Number = 0x1024, - SC_Network_Index = 0x1026, - SC_Network_Key = 0x1027, - SC_Network_Key_Index = 0x1028, - SC_New_Device_Name = 0x1029, - SC_New_Password = 0x102A, - SC_OOB_Device_Password = 0X102C, - SC_OS_Version = 0X102D, - SC_Power_Level = 0X102F, - SC_PSK_Current = 0x1030, - SC_PSK_Max = 0x1031, - SC_Public_Key = 0x1032, - SC_Radio_Enabled = 0x1033, - SC_Reboot = 0x1034, - SC_Registrar_Current = 0x1035, - SC_Registrar_Established = 0x1036, - SC_Registrar_List = 0x1037, - SC_Registrar_Max = 0x1038, - SC_Registrar_Nonce = 0x1039, - SC_Request_Type = 0x103A, - SC_Response_Type = 0x103B, - SC_RF_Band = 0X103C, - SC_R_Hash1 = 0X103D, - SC_R_Hash2 = 0X103E, - SC_R_SNonce1 = 0X103F, - SC_R_SNonce2 = 0x1040, - SC_Selected_Registrar = 0x1041, - SC_Serial_Number = 0x1042, - SC_Simple_Config_State = 0x1044, - SC_SSID = 0x1045, - SC_Total_Networks = 0x1046, - SC_UUID_E = 0x1047, - SC_UUID_R = 0x1048, - SC_Vendor_Extension = 0x1049, - SC_Version = 0x104A, - SC_X_509_Certificate_Request = 0x104B, - SC_X_509_Certificate = 0x104C, - SC_EAP_Identity = 0x104D, - SC_Message_Counter = 0x104E, - SC_Public_Key_Hash = 0x104F, - SC_Rekey_Key = 0x1050, - SC_Key_Lifetime = 0x1051, - SC_Permitted_Config_Methods = 0x1052, - SC_SelectedRegistrarConfigMethods = 0x1053, - SC_Primary_Device_Type = 0x1054, - SC_Secondary_Device_Type_List = 0x1055, - SC_Portable_Device = 0x1056, - SC_AP_Setup_Locked = 0x1057, - SC_Application_List = 0x1058, - SC_EAP_Type = 0x1059, - SC_Initialization_Vector = 0x1060, - SC_Key_Provided_Auto = 0x1061, - SC_8021x_Enabled = 0x1062, - SC_App_Session_key = 0x1063, - SC_WEP_Transmit_Key = 0x1064, -} wps_simple_config_attribute; - -/** Function Prototype Declaration */ -int is_input_valid(valid_inputs cmd, int argc, char *argv[]); -unsigned char hexc2bin(char chr); - -/** - * @brief isdigit for String. - * - * @param x Char string - * @return FAILURE for non-digit. - * SUCCESS for digit - */ -static inline int -ISDIGIT(char *x) -{ - unsigned int i; - for (i = 0; i < strlen(x); i++) - if (isdigit(x[i]) == 0) - return FAILURE; - return SUCCESS; -} -#endif /* _WIFIDIRECT_H */ diff --git a/mxm_wifiex/wlan_src/script/usbconfig b/mxm_wifiex/wlan_src/script/usbconfig deleted file mode 100644 index bc61a611036a4979cf18cac41f20a436f352c382..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9098 zcmds6eQ;FQb-!9IuvTP{h=OGx&a+z?|~vU^t%%x2wJwTI#-I?*ZADdXT6$)RAL^klzVf4!R2jHAFM$HqcVghd}ip zx|MxafIbYO?2mxnFL4}`XovKbuBbB&I;Z~^>+%PX)AzS)%xsx1FG0QtbO&f9NctD~ z{6szJXVy20Th&?`h13F~O%nu2cY}yuAwY6K#E%dly@Ys1xJ5eT8l>X*`Ua{7-1ic_4lRH2P97L_apd`Z|nv$%oIP zp2-7|zX$E)XI%sAU$6E1scwIc4M^Vyk^dF}lF^@Q;k9RtzPF1h*($`-$jN_?miNyZ ze^a;rj>dcDjc=j8L+iu&*s1%!sre5BkNNan1?*vbW$$9C7g%Mo@c*DH&R~J{U&!~a zX$!CA>hBQtwnz4E-m`0~u=|qfq_B7F-nV7*ZhPPM?fWA=cF*Q5yCb%+A3S1rC;F3l zH<8<#isti)ys+*5flS)YyV0C$+X6xbj75xd<-=4`P(vmTkNF}2A zgq=)dfWBxfA!}o)OkS5VX*ZWi*#r50*^+m2iCiv|lK^VFG%H4f){DFw&lFrS5KW~r zG0~UJL1-Upb1{q%8_3F{%;Jy%Gw`3z*kF#j$xK=#1|iPgwGWoXlWDt~JVTfol1Xg$fJo?d(T26K5Qhub@B$nRT!Z6#IT z%yB66Fvmf0kU4h2A?7&H4l~CA6K9S?&0&s_Q_P`EmN^!<%N&Q$Aafjif504v&~fHC zd`>XO=6r@Z4#WecH;Xqz-e=gVEl~4w9v7LUyzuVI;)9KOH7L$&d~UAiD|jBfjBEMJ>YZ_ zAC{P&aCQ=RNlcG8UBsOd(=*ON;x>utA?Gl$B{4na(4g@KiRm#XODrU&=bS;}iFZ-a zLJvB}iLXmcPdd*Kk4a3AI;V+8f!DtEnbPaU8xvhU-Ogd02Tncy9(vfR|6(xYWgu_z z^lA8hzlRRu(cz0LaBy{(i_>U1IqC+gV+S9-a`Cj}!TcQG^ctiKcS+?VBS%DWH2C%B zfveYEWL9oCd96@+bpcswu3Rj=t>*N_LwJlp)}7}$1PTqsoAnMWt7FAW4UoeD6z}E8 zG?|J+(}AO_iZ_Gh$aJ;i)1%sNeV4T>R~~(&`|9Ncz>ouoE$BL(4iEWsw`IGMlVOE==O4CN()}8l`2O< zOU@m?yFrMJk?AF0{3D9o6OzOH{q-6SRXhCKXe~u1AVZBfvE*E5aARcZbBXeS35X=q zmikiU=Hie^2cSHaYJ_x>7x58@dWr_<_rYGIxyw512pcO-JY%R8o)TVE-1uCF+B zP83#B>OM;SfRTEJQpdThuuPYHCvvV!cD|8dN4>afl<-+yAg0Et=V$E=+cVa_hEl%|n2kV5p3~~UZ^4?WB zegoCw(KE^Y^KWxp;eMFY<1Ut?PkNh_irO8OLy%M)Y!>cvc^FPf5zszV?rfH)C$^Sk zX^;bRHCD3?@~rgEs}a2(Fg7HH*6qSkqrP3uN^IzOhGVbEj3+rt5eLN!k=@s`sxRMvPK zQ0e8##uJ{>t8ES)incc80Cg@^-A!P@WMLI>spXaH@C@mMKC>r0CZu|X0-Tj!f(GZ6 z29*_5`aaa?=f>DCq~hLbj4#c_g9p!!-+g#L^fC{?<#=iF(%>8^He)G_e3}37R_oZ> zw=YZuKKW{XS?Ncmx2sKO%X=nT-`RfQoxmrrmVTN0S@BZ+qo1+$a}P3&z$tw zy3dRf!zf+e!?64jw5acKzE9>7y_t+Fx@Bf<%cK+HKt9@^xZe_%W#MH!mPz*|`>i!c zENk_VL@tk4-Buj=GYwimOTJF*N*{@)l5tDDxm)SNKyM;fCvM*wO|Nn-zT{ic^fBwe z{w7 zgl7urc%4uq@$*2BaKF`(w^p~rTkFL3Xfl)ONFHnI0$ zm(Ol(GQ{{L_^pj)1_q)qEuT%ql6}cU{BHB@jmfO?kT5yRe0CZ7G0Obz=XWc=#rZwR z@3Ec3co#?BbOP__%%2K|C^LhO{C3A9Ox_tF6a234z{=*A!B;`%4uRkA(|51HA+~3wi}~4fF=cC~^=B{3d+UNn>^TZ(vidqPz$P%sn8nW9!!Yt<|`W zX|+Bc?g)2S?QL!A+CI^~)>_?->E9W3RsEXwR`LIzIh;Q>;6{5z7~iofcT7osGiOB@ z+b0p;yk*xKH`*`4PBia`aQs*r9aZk;M7Td)2M%5kxOn^*v`FUKSg_wfTDE^En${oaHIxgk-K=@pjeQtp71{iog7kM9K^ zUk~_t-iPnceSG}(J@h`~z6?J4nB&U3Zt#tv%=u-ae$?aJAlgB`Has8N@BlEnqe_;E zzY8*ae2#R0?;sg;A`j^z$nc#4-zo5QXdY%p_7#*lKF8(j-YEFE&P_6WS5ZNECXsKk zufh~zo|I+yu4424$N=Pqk2&Yoq!2FLyWlA9f9lC`sR!3Gbu;N8?!eX?rBG?)nRb89 z^MhDLLsTq5VKp+(1BKNHd~PeO2H^8tVKrOkd0Q)IRP9&Qt`<7?rNT0k&vS)o#q51| zE$+LSxSyEU%AKj=H45`BWA?teR^R+{AEsnzogIvD~b5?NYH-j;G zNaj7DR-dq3cdW0KZzZ$$)3y5Th3iPQtLOvQi^BesgZ+6j&8AuzP4Q#@jwk;LIgbs` zD0u=mWV$A_UrQ(z<;XekM>;vHi`EA zEdcMuIP=u^hsd9YKA%EP{@0O@0W%Im{1)=oQZV$Y#sO@E{{k*+{6XM&IT-pEjqe3c zoC=1%ukl9Uwvk}yCmMem_=ztBL;nf96!L!$*sKr6C;EUNK>vGn`xC%SEg-I@Q@~uG z+&PViTzy%$->uufp|PX!Ujm!?YzW+{@{X9v#Fzd-<9^gp{!cajmd3Y$PwV+@3@j7x z0`op}i)^nKi}m4R;y3qcY~oKFf&KBP&AQ#hpZ04!tj9Z~F;_PAc^sJQU)g(y7y{;H zroqnw^En7s>Cdm|{+{mt4Pf4o8UC}tet-N8Ft2vIb^m_^Hv5h7tJm3%J70dVaK8Q> zn90PmYH_6bg$zmQuT*(*t60w|{cME-e;TYmTTYL6(+q-w|??FJ!wzthe z4{n`l$|5p^ci?O);U?nYwP1~B?EX}yH=45Lo3tG*3?jsYH*7mz7#KKaL`U{+o0V+9 z_U_GlBDO&s#*}BJ%GY!$b>@p73Kw`oAmYhvunSNCr& zxS9RZztEZAZrXeqt@WEBb@B%=WpwjB@yu-{_%Sf>a$Nt6;HUqZ)ZgM5qep9q>=0|>gcKqfr N_*@%|hvx*x{|6e$5-I=y