mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 18:38:10 +00:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
			release/v1
			...
			v1.0.4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 7bcd7093d2 | ||
|   | f273ec572e | ||
|   | 5fd49f6b64 | ||
|   | f3fc398eac | ||
|   | 7aea689d9a | ||
|   | 7a634d80ed | 
| @@ -1,626 +0,0 @@ | ||||
| include $(TOPDIR)/rules.mk | ||||
| include $(INCLUDE_DIR)/kernel.mk | ||||
|  | ||||
| PKG_NAME:=qca-nss-clients | ||||
| PKG_SOURCE_PROTO:=git | ||||
| PKG_BRANCH:=master | ||||
| PKG_RELEASE:=2 | ||||
| PKG_SOURCE_URL:=https://source.codeaurora.org/quic/qsdk/oss/lklm/nss-clients/ | ||||
| PKG_VERSION:=9136ef60bf68ceed760781d3acbeddb05470e432 | ||||
|  | ||||
| PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | ||||
| PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) | ||||
| PKG_SOURCE_VERSION:=$(PKG_VERSION) | ||||
|  | ||||
| #PKG_BUILD_DEPENDS := PACKAGE_kmod-qca-nss-crypto:kmod-qca-nss-crypto | ||||
| MAKE_OPTS:= | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| # Keep default as ipq806x for branches that does not have subtarget framework | ||||
| ifeq ($(CONFIG_TARGET_ipq),y) | ||||
| subtarget:=$(SUBTARGET) | ||||
| else | ||||
| subtarget:=$(CONFIG_TARGET_BOARD) | ||||
| endif | ||||
|  | ||||
| ifneq (, $(findstring $(subtarget), "ipq807x" "ipq807x_ipq807x" "ipq60xx" "ipq807x_ipq60xx")) | ||||
| # DTLS Manager v2.0 for Hawkeye/Cypress | ||||
|   DTLSMGR_DIR:=v2.0 | ||||
| # IPsec Manager v2.0 for Hawkeye/Cypress | ||||
|   IPSECMGR_DIR:=v2.0 | ||||
| else | ||||
| # DTLS Manager v1.0 for Akronite. | ||||
|   DTLSMGR_DIR:=v1.0 | ||||
| # IPsec Manager v1.0 for Akronite. | ||||
|   IPSECMGR_DIR:=v1.0 | ||||
| endif | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-tun6rd | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - tun6rd | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-sit @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/qca-nss-tun6rd.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,60,qca-nss-tun6rd) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-tun6rd/Description | ||||
| Kernel modules for NSS connection manager - Support for 6rd tunnel | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-dtlsmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - dtlsmgr | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-cfi-cryptoapi @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/dtls/$(DTLSMGR_DIR)/qca-nss-dtlsmgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-dtls/Description | ||||
| Kernel modules for NSS connection manager - Support for DTLS sessions | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-tlsmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - tlsmgr | ||||
|   DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx +kmod-qca-nss-drv +kmod-qca-nss-cfi @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/tls/qca-nss-tlsmgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-tls/Description | ||||
| Kernel modules for NSS connection manager - Support for TLS sessions | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-l2tpv2 | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - l2tp | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-ppp +kmod-l2tp @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/l2tp/l2tpv2/qca-nss-l2tpv2.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-l2tpv2) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-l2tp/Description | ||||
| Kernel modules for NSS connection manager - Support for l2tp tunnel | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-pptp | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - PPTP | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-pptp @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/pptp/qca-nss-pptp.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-pptp) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-pptp/Description | ||||
| Kernel modules for NSS connection manager - Support for PPTP tunnel | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-pppoe | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - PPPoE | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-pppoe @!LINUX_3_18 \ | ||||
| 		+!(TARGET_ipq_ipq807x_QSDK_256||TARGET_ipq_ipq60xx_QSDK_256):kmod-bonding | ||||
|   FILES:=$(PKG_BUILD_DIR)/pppoe/qca-nss-pppoe.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-pppoe) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-pppoe/Description | ||||
| Kernel modules for NSS connection manager - Support for PPPoE | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-map-t | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - MAP-T | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-nat46 @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/map/map-t/qca-nss-map-t.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-map-t) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-map-t/Description | ||||
| Kernel modules for NSS connection manager - Support for MAP-T | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-gre | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - GRE | ||||
|   DEPENDS:=@TARGET_ipq_ipq806x||TARGET_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \ | ||||
| 	   +kmod-qca-nss-drv @!LINUX_3_18 +kmod-gre6 | ||||
|   FILES:=$(PKG_BUILD_DIR)/gre/qca-nss-gre.ko $(PKG_BUILD_DIR)/gre/test/qca-nss-gre-test.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-gre) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-gre/Description | ||||
| Kernel modules for NSS connection manager - Support for GRE | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-tunipip6 | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (connection manager) - DS-lite and ipip6 Tunnel | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-iptunnel6 +kmod-ip6-tunnel @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/tunipip6/qca-nss-tunipip6.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,60,qca-nss-tunipip6) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-tunipip6/Description | ||||
| Kernel modules for NSS connection manager | ||||
| Add support for DS-lite and ipip6 tunnel | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-profile | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18 | ||||
|   TITLE:=Profiler for QCA NSS driver (IPQ806x) | ||||
|   FILES:=$(PKG_BUILD_DIR)/profiler/qca-nss-profile-drv.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-profile/Description | ||||
| This package contains a NSS driver profiler for QCA chipset | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ipsecmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (ipsec manager) - ipsecmgr | ||||
|   DEPENDS:=@TARGET_ipq806x||TARGET_ipq_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx \ | ||||
| 		+kmod-qca-nss-drv +kmod-qca-nss-cfi-cryptoapi +kmod-qca-nss-cfi-ocf @!LINUX_3_18 | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2),) | ||||
|   DEPENDS:=+kmod-qca-nss-drv-l2tpv2 | ||||
| endif | ||||
|   FILES:=$(PKG_BUILD_DIR)/ipsecmgr/$(IPSECMGR_DIR)/qca-nss-ipsecmgr.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,60,qca-nss-ipsecmgr) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ipsecmgr/Description | ||||
| Kernel module for NSS IPsec offload manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ipsecmgr-klips | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS (ipsec klips) | ||||
|   DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx \ | ||||
| 		+kmod-qca-nss-drv-ipsecmgr kmod-qca-nss-ecm | ||||
|   FILES:=$(PKG_BUILD_DIR)/ipsecmgr/$(IPSECMGR_DIR)/plugins/klips/qca-nss-ipsec-klips.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ipsecmgr-klips/Description | ||||
| NSS Kernel module for IPsec klips offload | ||||
| endef | ||||
|  | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-capwapmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-drv-dtlsmgr @!LINUX_3_18 | ||||
|   TITLE:=NSS CAPWAP Manager for QCA NSS driver (IPQ806x) | ||||
|   FILES:=$(PKG_BUILD_DIR)/capwapmgr/qca-nss-capwapmgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-capwapmgr/Description | ||||
| This package contains a NSS CAPWAP Manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-bridge-mgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS bridge manager | ||||
|   DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx \ | ||||
| 		+TARGET_ipq_ipq807x:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 		+TARGET_ipq_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 		+TARGET_ipq807x:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 		+TARGET_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 		+TARGET_ipq_ipq60xx:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 		+TARGET_ipq807x_ipq60xx:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \ | ||||
| 		+!(TARGET_ipq_ipq807x_QSDK_256||TARGET_ipq_ipq60xx_QSDK_256):kmod-bonding | ||||
|   FILES:=$(PKG_BUILD_DIR)/bridge/qca-nss-bridge-mgr.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-bridge-mgr) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-bridge-mgr/Description | ||||
| Kernel modules for NSS bridge manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-vlan-mgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS vlan manager | ||||
|   DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx +kmod-qca-nss-drv @!LINUX_3_18 \ | ||||
| 		+!(TARGET_ipq_ipq807x_QSDK_256||TARGET_ipq_ipq60xx_QSDK_256):kmod-bonding | ||||
|   FILES:=$(PKG_BUILD_DIR)/vlan/qca-nss-vlan.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-vlan) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-vlan-mgr/Description | ||||
| Kernel modules for NSS vlan manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-qdisc | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Support | ||||
|   TITLE:=Qdisc for configuring shapers in NSS | ||||
|   DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/nss_qdisc/qca-nss-qdisc.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,58,qca-nss-qdisc) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-qdisc/Description | ||||
| Linux qdisc that aids in configuring shapers in the NSS | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-igs | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Support | ||||
|   TITLE:=Action for offloading traffic to an IFB interface to perform ingress shaping. | ||||
|   DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \ | ||||
| 	+kmod-qca-nss-drv +kmod-sched-core +kmod-ifb +kmod-qca-nss-drv-qdisc @!LINUX_3_18 | ||||
|   FILES:=$(PKG_BUILD_DIR)/nss_qdisc/igs/act_nssmirred.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-igs/Description | ||||
| Linux action that helps in offloading traffic to an IFB interface to perform ingress shaping. | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-lag-mgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS LAG manager | ||||
|   DEPENDS:=+kmod-qca-nss-drv  @!LINUX_3_18 \ | ||||
| 	   +TARGET_ipq_ipq807x:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 	   +TARGET_ipq_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \ | ||||
| 	   +TARGET_ipq807x:kmod-qca-nss-drv-vlan-mgr \ | ||||
| 	   +TARGET_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \ | ||||
| 	   +TARGET_ipq_ipq60xx:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \ | ||||
| 	   +TARGET_ipq807x_ipq60xx:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \ | ||||
| 	   +kmod-bonding | ||||
|   FILES:=$(PKG_BUILD_DIR)/lag/qca-nss-lag-mgr.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-lag-mgr) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-lag-mgr/Description | ||||
| Kernel modules for NSS LAG manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-netlink | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=@TARGET_ipq807x||TARGET_ipq_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \ | ||||
| 		+kmod-qca-nss-drv @!LINUX_3_18 \ | ||||
| 		+PACKAGE_kmod-qca-nss-drv-ipsecmgr:kmod-qca-nss-drv-ipsecmgr \ | ||||
| 		+PACKAGE_kmod-qca-nss-drv-dtlsmgr:kmod-qca-nss-drv-dtlsmgr \ | ||||
| 		+PACKAGE_kmod-qca-nss-drv-capwapmgr:kmod-qca-nss-drv-capwapmgr @!LINUX_3_18 | ||||
|   TITLE:=NSS NETLINK Manager for QCA NSS driver | ||||
|   FILES:=$(PKG_BUILD_DIR)/netlink/qca-nss-netlink.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-netlink/Description | ||||
| Kernel module for NSS netlink manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ovpn-mgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for NSS OpenVPN manager | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-cfi +kmod-tun +kmod-ipt-conntrack @!LINUX_3_18 \ | ||||
| 	  @TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx | ||||
|   FILES:=$(PKG_BUILD_DIR)/openvpn/src/qca-nss-ovpn-mgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ovpn-mgr/Description | ||||
| Kernel module for NSS OpenVPN manager | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ovpn-link | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   TITLE:=Kernel driver for interfacing NSS OpenVPN manager with ECM | ||||
|   DEPENDS:=+kmod-qca-nss-drv-ovpn-mgr +kmod-qca-nss-ecm-premium @!LINUX_3_18 \ | ||||
| 	  @TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx | ||||
|   FILES:=$(PKG_BUILD_DIR)/openvpn/plugins/qca-nss-ovpn-link.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ovpn-link/Description | ||||
| This module registers with ECM and communicates with NSS OpenVPN manager for supporting OpenVPN offload. | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-pvxlanmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18 | ||||
|   TITLE:=NSS PVXLAN Manager for QCA NSS driver | ||||
|   FILES:=$(PKG_BUILD_DIR)/pvxlanmgr/qca-nss-pvxlanmgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-pvxlanmgr/Description | ||||
| Kernel module for managing NSS PVxLAN | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-eogremgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-drv-gre @!LINUX_3_18 | ||||
|   TITLE:=NSS EOGRE Manager for QCA NSS driver | ||||
|   FILES:=$(PKG_BUILD_DIR)/eogremgr/qca-nss-eogremgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-eogremgr/Description | ||||
| Kernel module for managing NSS EoGRE | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-clmapmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-drv-eogremgr @!LINUX_3_18 | ||||
|   TITLE:=NSS clmap Manager for QCA NSS driver | ||||
|   FILES:=$(PKG_BUILD_DIR)/clmapmgr/qca-nss-clmapmgr.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-clmapmgr/Description | ||||
| Kernel module for managing NSS clmap | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-vxlanmgr | ||||
|   SECTION:=kernel | ||||
|   CATEGORY:=Kernel modules | ||||
|   SUBMENU:=Network Devices | ||||
|   DEPENDS:=+kmod-qca-nss-drv +kmod-vxlan @!LINUX_3_18 | ||||
|   TITLE:=NSS VxLAN Manager for QCA NSS driver | ||||
|   FILES:=$(PKG_BUILD_DIR)/vxlanmgr/qca-nss-vxlanmgr.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,51,qca-nss-vxlanmgr) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-vxlanmgr/Description | ||||
| Kernel module for managing NSS VxLAN | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-match | ||||
|  SECTION:=kernel | ||||
|  CATEGORY:=Kernel modules | ||||
|  SUBMENU:=Network Devices | ||||
|  DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18 | ||||
|  TITLE:=NSS Match for QCA NSS driver | ||||
|  FILES:=$(PKG_BUILD_DIR)/match/qca-nss-match.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-match/Description | ||||
| Kernel module for managing NSS Match | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-mirror | ||||
|  SECTION:=kernel | ||||
|  CATEGORY:=Kernel modules | ||||
|  SUBMENU:=Network Support | ||||
|  TITLE:=Module for mirroring packets from NSS to host. | ||||
|  DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18 | ||||
|  FILES:=$(PKG_BUILD_DIR)/mirror/qca-nss-mirror.ko | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-mirror/Description | ||||
| Kernel module for managing NSS Mirror | ||||
| endef | ||||
|  | ||||
| define Build/InstallDev/qca-nss-clients | ||||
| 	$(INSTALL_DIR) $(1)/usr/include/qca-nss-clients | ||||
| 	$(CP) $(PKG_BUILD_DIR)/netlink/include/* $(1)/usr/include/qca-nss-clients/ | ||||
| 	$(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-clients/ | ||||
| endef | ||||
|  | ||||
| define Build/InstallDev | ||||
| 	$(call Build/InstallDev/qca-nss-clients,$(1)) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ovpn-mgr/install | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(INSTALL_BIN) ./files/qca-nss-ovpn.init $(1)/etc/init.d/qca-nss-ovpn | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-ipsecmgr-klips/install | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(INSTALL_BIN) ./files/qca-nss-ipsec $(1)/etc/init.d/qca-nss-ipsec | ||||
| endef | ||||
|  | ||||
| define KernelPackage/qca-nss-drv-igs/install | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(INSTALL_BIN) ./files/qca-nss-mirred.init $(1)/etc/init.d/qca-nss-mirred | ||||
| endef | ||||
|  | ||||
| EXTRA_CFLAGS+= \ | ||||
| 	-I$(STAGING_DIR)/usr/include/qca-nss-drv \ | ||||
| 	-I$(STAGING_DIR)/usr/include/qca-nss-crypto \ | ||||
| 	-I$(STAGING_DIR)/usr/include/qca-nss-cfi \ | ||||
| 	-I$(STAGING_DIR)/usr/include/qca-nss-gmac \ | ||||
| 	-I$(STAGING_DIR)/usr/include/qca-ssdk \ | ||||
| 	-I$(STAGING_DIR)/usr/include/qca-ssdk/fal \ | ||||
| 	-I$(STAGING_DIR)/usr/include/nat46 | ||||
|  | ||||
| # Build individual packages if selected | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-profile),) | ||||
| MAKE_OPTS+=profile=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-capwapmgr),) | ||||
| MAKE_OPTS+=capwapmgr=y | ||||
| EXTRA_CFLAGS += -DNSS_CAPWAPMGR_ONE_NETDEV | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tun6rd),) | ||||
| MAKE_OPTS+=tun6rd=m | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-dtlsmgr),) | ||||
| MAKE_OPTS+=dtlsmgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tlsmgr),) | ||||
| MAKE_OPTS+=tlsmgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2),) | ||||
| MAKE_OPTS+=l2tpv2=y | ||||
| EXTRA_CFLAGS += -DNSS_L2TPV2_ENABLED | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pptp),) | ||||
| MAKE_OPTS+=pptp=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-map-t),) | ||||
| MAKE_OPTS+=map-t=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tunipip6),) | ||||
| MAKE_OPTS+=tunipip6=m | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-qdisc),) | ||||
| MAKE_OPTS+=qdisc=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-igs),) | ||||
| MAKE_OPTS+=igs=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ipsecmgr),) | ||||
| EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports | ||||
| MAKE_OPTS+=ipsecmgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ipsecmgr-klips),) | ||||
| EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-nss-ecm | ||||
| MAKE_OPTS+=ipsecmgr-klips=m | ||||
| endif | ||||
|  | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-bridge-mgr),) | ||||
| MAKE_OPTS+=bridge-mgr=y | ||||
| #enable OVS bridge if ovsmgr is enabled | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-ovsmgr),) | ||||
| MAKE_OPTS+= NSS_BRIDGE_MGR_OVS_ENABLE=y | ||||
| EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-ovsmgr | ||||
| endif | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vlan-mgr),) | ||||
| MAKE_OPTS+=vlan-mgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-lag-mgr),) | ||||
| MAKE_OPTS+=lag-mgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-gre),) | ||||
| EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports | ||||
| MAKE_OPTS+=gre=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe),) | ||||
| MAKE_OPTS+=pppoe=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-netlink),) | ||||
| MAKE_OPTS+=netlink=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-mgr),) | ||||
| MAKE_OPTS+=ovpn-mgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-link),) | ||||
| MAKE_OPTS+=ovpn-link=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pvxlanmgr),) | ||||
| MAKE_OPTS+=pvxlanmgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-eogremgr),) | ||||
| MAKE_OPTS+=eogremgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-clmapmgr),) | ||||
| MAKE_OPTS+=clmapmgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vxlanmgr),) | ||||
| MAKE_OPTS+=vxlanmgr=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-match),) | ||||
| MAKE_OPTS+=match=y | ||||
| endif | ||||
|  | ||||
| ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-mirror),) | ||||
| MAKE_OPTS+=mirror=y | ||||
| endif | ||||
|  | ||||
| define Build/Compile | ||||
| 	$(MAKE) -C "$(LINUX_DIR)" $(strip $(MAKE_OPTS)) \ | ||||
| 		CROSS_COMPILE="$(TARGET_CROSS)" \ | ||||
| 		ARCH="$(LINUX_KARCH)" \ | ||||
| 		M="$(PKG_BUILD_DIR)" \ | ||||
| 		EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ | ||||
| 		SoC="$(subtarget)" \ | ||||
| 		DTLSMGR_DIR="$(DTLSMGR_DIR)" \ | ||||
| 		IPSECMGR_DIR="$(IPSECMGR_DIR)" \ | ||||
| 		modules | ||||
| endef | ||||
|  | ||||
| $(eval $(call KernelPackage,qca-nss-drv-profile)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-capwapmgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-tun6rd)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-dtlsmgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-l2tpv2)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-pptp)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-pppoe)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-map-t)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-tunipip6)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-qdisc)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-igs)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-netlink)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-ipsecmgr)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-ipsecmgr-klips)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-bridge-mgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-vlan-mgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-lag-mgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-gre)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-ovpn-mgr)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-ovpn-link)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-pvxlanmgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-eogremgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-clmapmgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-vxlanmgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-match)) | ||||
| #$(eval $(call KernelPackage,qca-nss-drv-tlsmgr)) | ||||
| $(eval $(call KernelPackage,qca-nss-drv-mirror)) | ||||
| @@ -1,92 +0,0 @@ | ||||
| #!/bin/sh  /etc/rc.common | ||||
| # | ||||
| # Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. | ||||
| # | ||||
| # Permission to use, copy, modify, and/or distribute this software for any | ||||
| # purpose with or without fee is hereby granted, provided that the above | ||||
| # copyright notice and this permission notice appear in all copies. | ||||
| # | ||||
| # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
| # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
|  | ||||
| NSS_IPSEC_LOG_FILE=/tmp/.nss_ipsec_log | ||||
| NSS_IPSEC_LOG_STR_ECM="ECM_Loaded" | ||||
|  | ||||
| ecm_load () { | ||||
| 	if [ ! -d /sys/module/ecm ]; then | ||||
| 		/etc/init.d/qca-nss-ecm start | ||||
| 		if [ -d /sys/module/ecm ]; then | ||||
| 			echo ${NSS_IPSEC_LOG_STR_ECM} >> ${NSS_IPSEC_LOG_FILE} | ||||
| 		fi | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| ecm_unload () { | ||||
| 	if [ -f /tmp/.nss_ipsec_log ]; then | ||||
| 		str=`grep ${NSS_IPSEC_LOG_STR_ECM} ${NSS_IPSEC_LOG_FILE}` | ||||
| 		if [[ $str == ${NSS_IPSEC_LOG_STR_ECM} ]]; then | ||||
| 			/etc/init.d/qca-nss-ecm stop | ||||
| 			`sed 's/${NSS_IPSEC_LOG_STR_ECM}/ /g' $NSS_IPSEC_LOG_FILE >  $NSS_IPSEC_LOG_FILE` | ||||
| 		fi | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| ecm_disable() { | ||||
|  | ||||
| 	if [ ! -d /sys/module/ecm ]; then | ||||
| 		return; | ||||
| 	fi | ||||
|  | ||||
| 	echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop | ||||
| 	echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop | ||||
| 	echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all | ||||
| 	sleep 2 | ||||
| } | ||||
|  | ||||
| ecm_enable() { | ||||
| 	if [ ! -d /sys/module/ecm ]; then | ||||
| 		return; | ||||
| 	fi | ||||
|  | ||||
| 	echo 0 > /sys/kernel/debug/ecm/ecm_db/defunct_all | ||||
| 	echo 0 > /sys/kernel/debug/ecm/front_end_ipv4_stop | ||||
| 	echo 0 > /sys/kernel/debug/ecm/front_end_ipv6_stop | ||||
| } | ||||
|  | ||||
| start() { | ||||
| 	ecm_load | ||||
|  | ||||
| 	local kernel_version=$(uname -r) | ||||
|  | ||||
| 	insmod /lib/modules/${kernel_version}/qca-nss-ipsec-klips.ko | ||||
| 	if [ "$?" -gt 0 ]; then | ||||
| 		echo "Failed to load plugin. Please start ecm if not done already" | ||||
| 		ecm_enable | ||||
| 		return | ||||
| 	fi | ||||
|  | ||||
| 	/etc/init.d/ipsec start | ||||
| 	sleep 2 | ||||
| 	ipsec eroute | ||||
|  | ||||
| 	ecm_enable | ||||
| } | ||||
|  | ||||
| stop() { | ||||
| 	ecm_disable | ||||
|  | ||||
| 	/etc/init.d/ipsec stop | ||||
| 	rmmod qca-nss-ipsec-klips | ||||
|  | ||||
| 	ecm_unload | ||||
| } | ||||
|  | ||||
| restart() { | ||||
| 	stop | ||||
| 	start | ||||
| } | ||||
| @@ -1,28 +0,0 @@ | ||||
| #!/bin/sh /etc/rc.common | ||||
|  | ||||
| ########################################################################### | ||||
| # Copyright (c) 2019, The Linux Foundation. All rights reserved. | ||||
| # Permission to use, copy, modify, and/or distribute this software for | ||||
| # any purpose with or without fee is hereby granted, provided that the | ||||
| # above copyright notice and this permission notice appear in all copies. | ||||
| # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | ||||
| # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| ########################################################################### | ||||
|  | ||||
| restart() { | ||||
| 	rmmod act_nssmirred.ko | ||||
| 	insmod act_nssmirred.ko | ||||
| } | ||||
|  | ||||
| start() { | ||||
| 	insmod act_nssmirred.ko | ||||
| } | ||||
|  | ||||
| stop() { | ||||
| 	rmmod act_nssmirred.ko | ||||
| } | ||||
| @@ -1,69 +0,0 @@ | ||||
| #!/bin/sh /etc/rc.common | ||||
|  | ||||
| ########################################################################### | ||||
| # Copyright (c) 2019, The Linux Foundation. All rights reserved. | ||||
| # Permission to use, copy, modify, and/or distribute this software for | ||||
| # any purpose with or without fee is hereby granted, provided that the | ||||
| # above copyright notice and this permission notice appear in all copies. | ||||
| # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | ||||
| # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| ########################################################################### | ||||
|  | ||||
| ecm_disable() { | ||||
| 	if [ ! -d /sys/module/ecm ]; then | ||||
| 	   return | ||||
| 	fi | ||||
|  | ||||
| 	echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop | ||||
| 	echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop | ||||
| 	echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all | ||||
| 	sleep 2 | ||||
| } | ||||
|  | ||||
| ecm_enable() { | ||||
| 	if [ ! -d /sys/module/ecm ]; then | ||||
| 	   return | ||||
| 	fi | ||||
|  | ||||
| 	echo 0 > /sys/kernel/debug/ecm/ecm_db/defunct_all | ||||
| 	echo 0 > /sys/kernel/debug/ecm/front_end_ipv4_stop | ||||
| 	echo 0 > /sys/kernel/debug/ecm/front_end_ipv6_stop | ||||
| } | ||||
|  | ||||
| restart() { | ||||
| 	ecm_disable | ||||
|  | ||||
| 	/etc/init.d/openvpn stop | ||||
| 	rmmod qca-nss-ovpn-link | ||||
| 	rmmod qca-nss-ovpn-mgr | ||||
|  | ||||
| 	insmod qca-nss-ovpn-mgr | ||||
| 	insmod qca-nss-ovpn-link | ||||
|  | ||||
| 	if [ "$?" -gt 0 ]; then | ||||
| 		echo "Failed to load plugin. Please start ecm if not done already" | ||||
| 		ecm_enable | ||||
| 		return | ||||
| 	fi | ||||
|  | ||||
| 	ecm_enable | ||||
| } | ||||
|  | ||||
| start() { | ||||
| 	restart | ||||
| } | ||||
|  | ||||
| stop() { | ||||
| 	ecm_disable | ||||
|  | ||||
| 	/etc/init.d/openvpn stop | ||||
| 	rmmod qca-nss-ovpn-link | ||||
| 	rmmod qca-nss-ovpn-mgr | ||||
|  | ||||
| 	ecm_enable | ||||
| } | ||||
| @@ -47,15 +47,6 @@ hostapd_append_wpa_key_mgmt() { | ||||
| 			[ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-${auth_type_l}-SHA256" | ||||
| 			[ "${ieee80211ai:-0}" -gt 0 ] && append wpa_key_mgmt "FILS-SHA256" | ||||
| 		;; | ||||
| 		eap-only) | ||||
| 			append wpa_key_mgmt "WPA-EAP-SHA256" | ||||
| 			[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP" | ||||
| 		;; | ||||
| 		eap-transition) | ||||
| 			append wpa_key_mgmt "WPA-EAP" | ||||
| 			append wpa_key_mgmt "WPA-EAP-SHA256" | ||||
| 			[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP" | ||||
| 		;; | ||||
| 		eap192) | ||||
| 			append wpa_key_mgmt "WPA-EAP-SUITE-B-192" | ||||
| 			[ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-EAP-SHA256" | ||||
| @@ -214,9 +205,6 @@ hostapd_common_add_bss_config() { | ||||
| 	config_add_int maxassoc max_inactivity | ||||
| 	config_add_boolean disassoc_low_ack isolate short_preamble | ||||
|  | ||||
| config_add_int signal_connect signal_stay signal_poll_time \ | ||||
| 		signal_drop_reason signal_strikes | ||||
|  | ||||
| 	config_add_int \ | ||||
| 		wep_rekey eap_reauth_period \ | ||||
| 		wpa_group_rekey wpa_pair_rekey wpa_master_rekey | ||||
| @@ -324,15 +312,14 @@ config_add_int signal_connect signal_stay signal_poll_time \ | ||||
| 	config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp | ||||
|  | ||||
| 	config_add_boolean interworking internet | ||||
| 	config_add_int access_network_type asra esr uesa venue_group venue_type  \ | ||||
| 	config_add_int access_network_type asra esr uesa venue_group venue_type ipaddr_type_availability \ | ||||
| 		gas_address3 | ||||
| 	config_add_string hessid network_auth_type ipaddr_type_availability \ | ||||
| 	config_add_string hessid network_auth_type \ | ||||
| 		anqp_3gpp_cell_net anqp_elem domain_name qos_map_set hs20_t_c_server_url | ||||
|  | ||||
| 	config_add_array airtime_sta_weight | ||||
| 	config_add_int airtime_bss_weight airtime_bss_limit | ||||
| 	config_add_int rts_threshold | ||||
| 	config_add_boolean multicast_to_unicast proxy_arp | ||||
| } | ||||
|  | ||||
| hostapd_set_vlan_file() { | ||||
| @@ -488,7 +475,6 @@ hostapd_set_bss_options() { | ||||
| 	local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt | ||||
|  | ||||
| 	json_get_vars \ | ||||
| 	signal_connect signal_stay signal_poll_time signal_drop_reason signal_strikes \ | ||||
| 		wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_strict_rekey \ | ||||
| 		wpa_disable_eapol_key_retries tdls_prohibit \ | ||||
| 		maxassoc max_inactivity disassoc_low_ack isolate auth_cache \ | ||||
| @@ -500,8 +486,7 @@ hostapd_set_bss_options() { | ||||
| 		bss_load_update_period chan_util_avg_period sae_require_mfp \ | ||||
| 		multi_ap multi_ap_backhaul_ssid multi_ap_backhaul_key \ | ||||
| 		airtime_bss_weight airtime_bss_limit airtime_sta_weight \ | ||||
| 		rssi_reject_assoc_rssi rssi_ignore_probe_request rts_threshold \ | ||||
| 		proxy_arp multicast_to_unicast | ||||
| 		rssi_reject_assoc_rssi rssi_ignore_probe_request rts_threshold  | ||||
|  | ||||
| 	set_default isolate 0 | ||||
| 	set_default maxassoc 0 | ||||
| @@ -524,14 +509,6 @@ hostapd_set_bss_options() { | ||||
| 	set_default rssi_reject_assoc_rssi 0 | ||||
| 	set_default rssi_ignore_probe_request 0 | ||||
| 	set_default rts_threshold -1 | ||||
| 	set_default signal_connect -128 | ||||
| 	set_default signal_stay -128 | ||||
| 	set_default signal_poll_time 5 | ||||
| 	set_default signal_drop_reason 3 | ||||
| 	set_default signal_strikes 3 | ||||
| 	set_default proxy_arp 1 | ||||
| 	set_default multicast_to_unicast 0 | ||||
|  | ||||
|  | ||||
| 	append bss_conf "ctrl_interface=/var/run/hostapd" | ||||
| 	if [ "$isolate" -gt 0 ]; then | ||||
| @@ -560,14 +537,6 @@ hostapd_set_bss_options() { | ||||
| 	append bss_conf "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N" | ||||
| 	append bss_conf "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N" | ||||
| 	append bss_conf "rts_threshold=$rts_threshold" "$N" | ||||
| 	append bss_conf "signal_connect=$signal_connect" "$N" | ||||
| 	append bss_conf "signal_stay=$signal_stay" "$N" | ||||
| 	append bss_conf "signal_poll_time=$signal_poll_time" "$N" | ||||
| 	append bss_conf "signal_strikes=$signal_strikes" "$N" | ||||
| 	append bss_conf "signal_drop_reason=$signal_drop_reason" "$N" | ||||
|  | ||||
| 	[ -n "$proxy_arp" ] && append bss_conf "proxy_arp=$proxy_arp" "$N" | ||||
| 	[ -n "$multicast_to_unicast" ] && append bss_conf "multicast_to_unicast=$multicast_to_unicast" "$N" | ||||
|  | ||||
| 	[ "$tdls_prohibit" -gt 0 ] && append bss_conf "tdls_prohibit=$tdls_prohibit" "$N" | ||||
|  | ||||
| @@ -589,11 +558,11 @@ hostapd_set_bss_options() { | ||||
| 	} | ||||
|  | ||||
| 	case "$auth_type" in | ||||
| 		sae|owe|eap192|eap-eap192|eap-only) | ||||
| 		sae|owe|eap192|eap-eap192) | ||||
| 			set_default ieee80211w 2 | ||||
| 			set_default sae_require_mfp 1 | ||||
| 		;; | ||||
| 		psk-sae|eap-transition) | ||||
| 		psk-sae) | ||||
| 			set_default ieee80211w 1 | ||||
| 			set_default sae_require_mfp 1 | ||||
| 		;; | ||||
| @@ -635,7 +604,7 @@ hostapd_set_bss_options() { | ||||
| 			vlan_possible=1 | ||||
| 			wps_possible=1 | ||||
| 		;; | ||||
| 		eap|eap192|eap-eap192|eap-only|eap-transition) | ||||
| 		eap|eap192|eap-eap192) | ||||
| 			json_get_vars \ | ||||
| 				auth_server auth_secret auth_port \ | ||||
| 				dae_client dae_secret dae_port \ | ||||
| @@ -847,15 +816,7 @@ hostapd_set_bss_options() { | ||||
| 				json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout | ||||
| 				append bss_conf "ieee80211w=$ieee80211w" "$N" | ||||
| 				[ "$ieee80211w" -gt "0" ] && { | ||||
| 					case "$auth_type" in | ||||
| 						eap192) | ||||
| 							append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N" | ||||
| 							append bss_conf "group_cipher=GCMP-256" "$N" | ||||
| 						;; | ||||
| 						*) | ||||
| 							append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N" | ||||
| 						;; | ||||
| 					esac | ||||
| 					append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N" | ||||
| 					[ -n "$ieee80211w_max_timeout" ] && \ | ||||
| 						append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N" | ||||
| 					[ -n "$ieee80211w_retry_timeout" ] && \ | ||||
| @@ -980,15 +941,16 @@ hostapd_set_bss_options() { | ||||
| 	set_default access_network_type 0 | ||||
| 	set_default venue_group 0 | ||||
| 	set_default venue_type 0 | ||||
| 	set_default ipaddr_type_availability 0 | ||||
| 	set_default gas_address3 0 | ||||
| 	set_default hs20_deauth_req_timeout 60 | ||||
| 	if [ "$hs20" = "1" ]; then | ||||
| 		append bss_conf "hs20=1" "$N" | ||||
| 		append_hs20_icons | ||||
| 		[ -n "$disable_dgaf" ] && append bss_conf "disable_dgaf=$disable_dgaf" "$N" | ||||
| 		[ -n "$osen" ] && append bss_conf "osen=$osen" "$N" | ||||
| 		[ -n "$disable_dgaf"] && append bss_conf "disable_dgaf=$disable_dgaf" "$N" | ||||
| 		[ -n "$osen"] && append bss_conf "osen=$osen" "$N" | ||||
| 		[ "$anqp_domain_id" -gt 0 ] && append bss_conf "anqp_domain_id=$anqp_domain_id" "$N" | ||||
| 		[ -n "$hs20_deauth_req_timeout" ] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N" | ||||
| 		[ -n "$hs20_deauth_req_timeout"] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N" | ||||
| 		[ -n "$osu_ssid" ] && append bss_conf "osu_ssid=$osu_ssid" "$N" | ||||
| 		[ -n "$hs20_wan_metrics" ] && append bss_conf "hs20_wan_metrics=$hs20_wan_metrics" "$N" | ||||
| 		[ -n "$hs20_operating_class" ] && append bss_conf "hs20_operating_class=$hs20_operating_class" "$N" | ||||
| @@ -1000,6 +962,7 @@ hostapd_set_bss_options() { | ||||
| 		json_for_each_item append_venue_url venue_url | ||||
| 		json_for_each_item append_nai_realm nai_realm | ||||
| 		json_for_each_item append_hs20_conn_capab hs20_conn_capab | ||||
| 		json_for_each_item append_hs20_oper_friendly_name hs20_oper_friendly_name | ||||
| 		json_for_each_item append_osu_provider osu_provider | ||||
| 		json_for_each_item append_operator_icon operator_icon | ||||
| 		[ -n "$interworking" ] && append bss_conf "interworking=$interworking" "$N" | ||||
| @@ -1010,7 +973,7 @@ hostapd_set_bss_options() { | ||||
| 		[ "$uesa" -gt 0 ] && append bss_conf "uesa=$uesa" "$N" | ||||
| 		[ "$venue_group" -gt 0 ] && append bss_conf "venue_group=$venue_group" "$N" | ||||
| 		[ "$venue_type" -gt 0 ] && append bss_conf "venue_type=$venue_type" "$N" | ||||
| 		[ -n "$ipaddr_type_availability" ] && append bss_conf "ipaddr_type_availability=$ipaddr_type_availability" "$N" | ||||
| 		[ "$ipaddr_type_availability" -gt 0 ] && append bss_conf "ipaddr_type_availability=$ipaddr_type_availability" "$N" | ||||
| 		[ "$gas_address3" -gt 0 ] && append bss_conf "gas_address3=$gas_address3" "$N" | ||||
| 		[ -n "$hessid" ] && append bss_conf "hessid=$hessid" "$N" | ||||
| 		[ -n "$network_auth_type" ] && append bss_conf "network_auth_type=$network_auth_type" "$N" | ||||
|   | ||||
| @@ -1,28 +0,0 @@ | ||||
| Index: hostapd-2020-06-08-5a8b3662/src/ap/ieee802_11.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-06-08-5a8b3662.orig/src/ap/ieee802_11.c | ||||
| +++ hostapd-2020-06-08-5a8b3662/src/ap/ieee802_11.c | ||||
| @@ -3675,6 +3675,13 @@ static int add_associated_sta(struct hos | ||||
|  	 * drivers to accept the STA parameter configuration. Since this is | ||||
|  	 * after a new FT-over-DS exchange, a new TK has been derived, so key | ||||
|  	 * reinstallation is not a concern for this case. | ||||
| +	 * | ||||
| +	 * If the STA was associated and authorized earlier, but came for a new | ||||
| +	 * connection (!added_unassoc + !reassoc), remove the existing STA entry | ||||
| +	 * so that it can be re-added. This case is rarely seen when the AP could | ||||
| +	 * not receive the deauth/disassoc frame from the STA. And the STA comes | ||||
| +	 * back with new connection within a short period or before the inactive | ||||
| +	 * STA entry is removed from the list. | ||||
|  	 */ | ||||
|  	wpa_printf(MSG_DEBUG, "Add associated STA " MACSTR | ||||
|  		   " (added_unassoc=%d auth_alg=%u ft_over_ds=%u reassoc=%d authorized=%d ft_tk=%d fils_tk=%d)", | ||||
| @@ -3688,7 +3695,8 @@ static int add_associated_sta(struct hos | ||||
|  	    (!(sta->flags & WLAN_STA_AUTHORIZED) || | ||||
|  	     (reassoc && sta->ft_over_ds && sta->auth_alg == WLAN_AUTH_FT) || | ||||
|  	     (!wpa_auth_sta_ft_tk_already_set(sta->wpa_sm) && | ||||
| -	      !wpa_auth_sta_fils_tk_already_set(sta->wpa_sm)))) { | ||||
| +	      !wpa_auth_sta_fils_tk_already_set(sta->wpa_sm)) || | ||||
| +	     (!reassoc && (sta->flags & WLAN_STA_AUTHORIZED)))) { | ||||
|  		hostapd_drv_sta_remove(hapd, sta->addr); | ||||
|  		wpa_auth_sm_event(sta->wpa_sm, WPA_DRV_STA_REMOVED); | ||||
|  		set = 0; | ||||
| @@ -1,32 +0,0 @@ | ||||
| --- a/src/ap/ieee802_11.c | ||||
| +++ b/src/ap/ieee802_11.c | ||||
| @@ -4463,6 +4463,14 @@ static void handle_assoc(struct hostapd_ | ||||
|  			ieee802_11_set_beacons(hapd->iface); | ||||
|  	} | ||||
|   | ||||
| +	ubus_resp = hostapd_ubus_handle_event(hapd, &req); | ||||
| +	if (ubus_resp) { | ||||
| +		wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", | ||||
| +		       MAC2STR(mgmt->sa)); | ||||
| +		resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE; | ||||
| +		goto fail; | ||||
| +	} | ||||
| + | ||||
|  	update_ht_state(hapd, sta); | ||||
|   | ||||
|  	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, | ||||
| @@ -4568,14 +4576,6 @@ static void handle_assoc(struct hostapd_ | ||||
|  					    pos, left, rssi, omit_rsnxe); | ||||
|  	os_free(tmp); | ||||
|   | ||||
| -	ubus_resp = hostapd_ubus_handle_event(hapd, &req); | ||||
| -	if (ubus_resp) { | ||||
| -		wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", | ||||
| -		       MAC2STR(mgmt->sa)); | ||||
| -		resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE; | ||||
| -		goto fail; | ||||
| -	} | ||||
| - | ||||
|  	/* | ||||
|  	 * Remove the station in case tranmission of a success response fails | ||||
|  	 * (the STA was added associated to the driver) or if the station was | ||||
| @@ -1,68 +0,0 @@ | ||||
| Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| @@ -1483,7 +1483,63 @@ static int hostapd_get_bss_list(struct u | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +enum { | ||||
| +	MOD_IFACE, | ||||
| +	MOD_PARAM, | ||||
| +	MOD_PARAM_VAL, | ||||
| +	__PARAM_MAX | ||||
| +}; | ||||
| + | ||||
| +static const struct blobmsg_policy mod_param_policy[__PARAM_MAX] = { | ||||
| +	[MOD_IFACE] = { "iface", BLOBMSG_TYPE_STRING }, | ||||
| +	[MOD_PARAM] = { "param", BLOBMSG_TYPE_STRING }, | ||||
| +	[MOD_PARAM_VAL] = { "param_val", BLOBMSG_TYPE_STRING }, | ||||
| +}; | ||||
| + | ||||
| + | ||||
| +static int | ||||
| +hostapd_param_modify(struct ubus_context *ctx, struct ubus_object *obj, | ||||
| +		   struct ubus_request_data *req, const char *method, | ||||
| +		   struct blob_attr *msg) | ||||
| +{ | ||||
| +	struct blob_attr *tb[__PARAM_MAX]; | ||||
| +	struct hapd_interfaces *interfaces = NULL; | ||||
| +	struct hostapd_data *hapd_bss = NULL; | ||||
| +	struct hostapd_config *iconf = NULL; | ||||
| +	struct hostapd_iface *iface = NULL; | ||||
| +	size_t i = 0; | ||||
| + | ||||
| +	interfaces = get_hapd_interfaces_from_object(obj); | ||||
| +	blobmsg_parse(mod_param_policy, __PARAM_MAX, tb, blob_data(msg), | ||||
| +		      blob_len(msg)); | ||||
| + | ||||
| +	if (!tb[MOD_PARAM] || !tb[MOD_IFACE] || !tb[MOD_PARAM_VAL]) | ||||
| +		return UBUS_STATUS_INVALID_ARGUMENT; | ||||
| + | ||||
| +	wpa_printf(MSG_DEBUG, "Modifyint %s=%s for %s", | ||||
| +		blobmsg_get_string(tb[MOD_PARAM]), | ||||
| +		blobmsg_get_string(tb[MOD_PARAM_VAL]), | ||||
| +		blobmsg_get_string(tb[MOD_IFACE])); | ||||
| +	 | ||||
| +	hapd_bss = hostapd_get_iface(interfaces, | ||||
| +				     blobmsg_get_string(tb[MOD_IFACE])); | ||||
| + | ||||
| +	if (hapd_bss) { | ||||
| +		iconf = hapd_bss->iconf; | ||||
| +		if (os_strcmp(blobmsg_get_string(tb[MOD_PARAM]), | ||||
| +			      "rssi_ignore_probe_request") == 0) { | ||||
| +			iconf->rssi_ignore_probe_request = atoi(blobmsg_get_string(tb[MOD_PARAM_VAL])); | ||||
| + | ||||
| +		} | ||||
| +	} | ||||
| + | ||||
| +	return UBUS_STATUS_OK; | ||||
| +} | ||||
| + | ||||
| + | ||||
| + | ||||
|  static const struct ubus_method daemon_methods[] = { | ||||
| +	UBUS_METHOD("param_mod", hostapd_param_modify, mod_param_policy), | ||||
|  	UBUS_METHOD("config_add", hostapd_config_add, config_add_policy), | ||||
|  	UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy), | ||||
|  	UBUS_METHOD_NOARG("get_bss_list", hostapd_get_bss_list), | ||||
| @@ -1,14 +0,0 @@ | ||||
| Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| @@ -1655,7 +1655,8 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  	session_id = sta->cl_session_id; | ||||
|   | ||||
|  	/* find by session id */ | ||||
| -	rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl); | ||||
| +	if (session_id) | ||||
| +		rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl); | ||||
|   | ||||
|  	/* prepare rec if not found */ | ||||
|  	if (!rec) { | ||||
| @@ -1,28 +0,0 @@ | ||||
| Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| @@ -528,6 +528,7 @@ enum { | ||||
|  	CSA_SEC_CHANNEL_OFFSET, | ||||
|  	CSA_HT, | ||||
|  	CSA_VHT, | ||||
| +	CSA_HE, | ||||
|  	CSA_BLOCK_TX, | ||||
|  	__CSA_MAX | ||||
|  }; | ||||
| @@ -541,6 +542,7 @@ static const struct blobmsg_policy csa_p | ||||
|  	[CSA_SEC_CHANNEL_OFFSET] = { "sec_channel_offset", BLOBMSG_TYPE_INT32 }, | ||||
|  	[CSA_HT] = { "ht", BLOBMSG_TYPE_BOOL }, | ||||
|  	[CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL }, | ||||
| +	[CSA_HE] = { "he", BLOBMSG_TYPE_BOOL }, | ||||
|  	[CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL }, | ||||
|  }; | ||||
|   | ||||
| @@ -783,6 +785,7 @@ hostapd_switch_chan(struct ubus_context | ||||
|  	SET_CSA_SETTING(CSA_SEC_CHANNEL_OFFSET, freq_params.sec_channel_offset, u32); | ||||
|  	SET_CSA_SETTING(CSA_HT, freq_params.ht_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool); | ||||
| +	SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool); | ||||
|   | ||||
|  	for (i = 0; i < hapd->iface->num_bss; i++) { | ||||
| @@ -1,299 +0,0 @@ | ||||
| Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c | ||||
| @@ -21,6 +21,7 @@ | ||||
|  #include "rrm.h" | ||||
|  #include "wnm_ap.h" | ||||
|  #include "taxonomy.h" | ||||
| +#include "common/hw_features_common.h" | ||||
|   | ||||
|  static struct ubus_context *ctx; | ||||
|  static struct blob_buf b; | ||||
| @@ -754,6 +755,207 @@ static int hostapd_get_chan_switch_event | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +#define HOSTAPD_DFS_CSA_DUR 1 | ||||
| +int csa_ch_id, csa_cf0_id, csa_cf1_id = 0; | ||||
| +int csa_bw = CHANWIDTH_USE_HT; | ||||
| +struct csa_settings css; | ||||
| + | ||||
| +struct hostapd_channel_data *freq_to_chan(struct hostapd_iface *iface, int freq) | ||||
| +{ | ||||
| +	struct hostapd_hw_modes *mode; | ||||
| +	struct hostapd_channel_data *chan; | ||||
| +	int i; | ||||
| + | ||||
| +	mode = iface->current_mode; | ||||
| +	if (mode == NULL || freq == 0) { | ||||
| +		wpa_printf(MSG_INFO, "%s: mode is NULL", __func__); | ||||
| +		return NULL; | ||||
| +	} | ||||
| + | ||||
| +	for (i = 0; i < iface->current_mode->num_channels; i++) { | ||||
| +		chan = &iface->current_mode->channels[i]; | ||||
| +		if (chan->freq == freq) { | ||||
| +			return chan; /* Channel found */ | ||||
| +		} | ||||
| +	} | ||||
| +	return NULL; | ||||
| +} | ||||
| + | ||||
| +void hostapd_dfs_csa_timeout(void *eloop_data, void *user_data) | ||||
| +{ | ||||
| +	struct hostapd_data *hapd = eloop_data; | ||||
| +	struct hostapd_iface *iface = hapd->iface; | ||||
| +	struct csa_settings *css = user_data;	 | ||||
| +	int ret = 0; | ||||
| + | ||||
| +	wpa_printf(MSG_DEBUG, "%s Stopping CSA in dfs ", __func__); | ||||
| + | ||||
| +	hapd->csa_in_progress = 0; | ||||
| + | ||||
| +	hostapd_disable_iface(iface); | ||||
| + | ||||
| +	iface->freq = css->freq_params.freq; | ||||
| +	iface->conf->channel = csa_ch_id; | ||||
| +	iface->conf->secondary_channel = css->freq_params.sec_channel_offset; | ||||
| +	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id); | ||||
| +	hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id); | ||||
| +	hostapd_set_oper_chwidth(iface->conf, csa_bw); | ||||
| +	iface->conf->ieee80211n = css->freq_params.ht_enabled; | ||||
| +	iface->conf->ieee80211ac = css->freq_params.vht_enabled; | ||||
| +	iface->conf->ieee80211ax = css->freq_params.he_enabled; | ||||
| +	wpa_printf(MSG_INFO, "%s: freq=%d chan=%d sec_ch=%d cf0=%d cf1=%d bw=%d 11n=%d, ac=%d, ax=%d", | ||||
| + 		   __func__, iface->freq, iface->conf->channel, | ||||
| +		   iface->conf->secondary_channel, csa_cf0_id, csa_cf1_id,  | ||||
| +		   css->freq_params.bandwidth, iface->conf->ieee80211n, | ||||
| +		   iface->conf->ieee80211ac, iface->conf->ieee80211ax); | ||||
| + | ||||
| +	ret = hostapd_enable_iface(iface); | ||||
| +	if (ret == 0) | ||||
| +		hostapd_ubus_handle_channel_switch_event(iface, | ||||
| +						HOSTAPD_UBUS_HIGH_INTERFERENCE, | ||||
| +						iface->freq); | ||||
| +} | ||||
| + | ||||
| +int hostapd_dfs_set_beacon_csa(struct hostapd_iface *iface, struct csa_settings *css) | ||||
| +{ | ||||
| +	struct hostapd_data *hapd = iface->bss[0]; | ||||
| +	struct hostapd_data *hapd_bss = NULL; | ||||
| +	struct csa_settings csa_settings; | ||||
| +	int secondary_channel = 0; | ||||
| +	u8 vht_oper_centr_freq_seg0_idx; | ||||
| +	u8 vht_oper_centr_freq_seg1_idx; | ||||
| +	int err = 0, i = 0; | ||||
| + | ||||
| +	if (hapd->csa_in_progress == 1) { | ||||
| +		wpa_printf(MSG_ERROR, "CSA in progress, cannot switch channel"); | ||||
| +		return -1; | ||||
| +	} | ||||
| + | ||||
| +	eloop_cancel_timeout(hostapd_dfs_csa_timeout, hapd, NULL); | ||||
| + | ||||
| +	/* Setup Beacon CSA request */ | ||||
| +	secondary_channel = iface->conf->secondary_channel; | ||||
| +	vht_oper_centr_freq_seg0_idx = | ||||
| +			iface->conf->vht_oper_centr_freq_seg0_idx; | ||||
| +	vht_oper_centr_freq_seg1_idx = | ||||
| +			iface->conf->vht_oper_centr_freq_seg1_idx; | ||||
| + | ||||
| +	os_memset(&csa_settings, 0, sizeof(csa_settings)); | ||||
| +	err = hostapd_set_freq_params(&csa_settings.freq_params, | ||||
| +				      iface->conf->hw_mode, | ||||
| +				      iface->freq, | ||||
| +				      iface->conf->channel, | ||||
| +				      iface->conf->enable_edmg, | ||||
| +				      iface->conf->edmg_channel, | ||||
| +				      iface->conf->ieee80211n, | ||||
| +				      iface->conf->ieee80211ac, | ||||
| +				      iface->conf->ieee80211ax, | ||||
| +				      secondary_channel, | ||||
| +				      hostapd_get_oper_chwidth(iface->conf), | ||||
| +				      vht_oper_centr_freq_seg0_idx, | ||||
| +				      vht_oper_centr_freq_seg1_idx, | ||||
| +				      iface->current_mode->vht_capab, | ||||
| +				      &iface->current_mode->he_capab[IEEE80211_MODE_AP]); | ||||
| +	if (err) { | ||||
| +		wpa_printf(MSG_ERROR, "DFS failed to calculate CSA freq params"); | ||||
| +		return -1; | ||||
| +	} | ||||
| + | ||||
| +	if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { | ||||
| +		wpa_printf(MSG_ERROR, "CSA is not supported"); | ||||
| +		return -1; | ||||
| +	} | ||||
| + | ||||
| +	/* Set Beacon */ | ||||
| +	for (i = 0; i < hapd->iface->num_bss; i++) { | ||||
| +		hapd_bss = iface->bss[i]; | ||||
| +		hapd_bss->cs_freq_params = csa_settings.freq_params; | ||||
| +		hapd_bss->cs_count = css->cs_count; | ||||
| +		hapd_bss->cs_block_tx = css->block_tx; | ||||
| +		err = ieee802_11_set_beacon(hapd_bss); | ||||
| +		if (err) | ||||
| +			wpa_printf(MSG_ERROR, "CSA beacon set failed, changing channel without an Announcement"); | ||||
| +	} | ||||
| + | ||||
| +	hapd->csa_in_progress = 1; | ||||
| + | ||||
| +	/* Switch Channel after a timeout */ | ||||
| +	eloop_register_timeout(HOSTAPD_DFS_CSA_DUR, 0, | ||||
| +			       hostapd_dfs_csa_timeout, hapd, css); | ||||
| + | ||||
| +	return 0; | ||||
| +} | ||||
| + | ||||
| +int hostapd_switch_chan_dfs(struct hostapd_iface *iface, | ||||
| +			     struct csa_settings *css) | ||||
| +{ | ||||
| +	struct hostapd_channel_data *ch, *cf1, *cf2 = NULL; | ||||
| +	int res = 0; | ||||
| + | ||||
| +	if (iface == NULL) | ||||
| +		return -1; | ||||
| + | ||||
| +	/* Set channel id and center frequecies id */ | ||||
| +	if (css->freq_params.freq > 0) { | ||||
| +		ch = freq_to_chan(iface, css->freq_params.freq); | ||||
| +		csa_ch_id = ch->chan; | ||||
| +	} | ||||
| + | ||||
| +	if (css->freq_params.center_freq1 > 0) { | ||||
| +		csa_cf0_id = 36 + (css->freq_params.center_freq1 - 5180) / 5; | ||||
| +	} | ||||
| + | ||||
| +	if (css->freq_params.center_freq2 > 0) { | ||||
| +		csa_cf1_id = 36 + (css->freq_params.center_freq2 - 5180) / 5; | ||||
| +	} | ||||
| + | ||||
| +	wpa_printf(MSG_DEBUG, "%s freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds, ieee80211n=%d, ieee80211ac=%d, ieee80211ax=%d ", __func__, | ||||
| +		css->freq_params.freq, | ||||
| +		csa_ch_id, css->freq_params.sec_channel_offset, | ||||
| +		css->freq_params.bandwidth, csa_cf0_id, csa_cf1_id, | ||||
| +		iface->dfs_cac_ms / 1000, iface->conf->ieee80211n, | ||||
| +		iface->conf->ieee80211ac, iface->conf->ieee80211ax); | ||||
| + | ||||
| +	/* Set bandwidth */ | ||||
| +	switch (css->freq_params.bandwidth) { | ||||
| +	case 0: | ||||
| +	case 20: | ||||
| +	case 40: | ||||
| +		csa_bw = CHANWIDTH_USE_HT; | ||||
| +		break; | ||||
| +	case 80: | ||||
| +		if (css->freq_params.center_freq2) | ||||
| +			csa_bw = CHANWIDTH_80P80MHZ; | ||||
| +		else | ||||
| +			csa_bw = CHANWIDTH_80MHZ; | ||||
| +		break; | ||||
| +	case 160: | ||||
| +		csa_bw = CHANWIDTH_160MHZ; | ||||
| +		break; | ||||
| +	default: | ||||
| +		wpa_printf(MSG_WARNING, "Unknown CSA bandwidth: %d", | ||||
| +			   css->freq_params.bandwidth); | ||||
| +		break; | ||||
| +	} | ||||
| + | ||||
| +	/* Set new frequency info */ | ||||
| +	iface->freq = css->freq_params.freq; | ||||
| +	iface->conf->channel = csa_ch_id; | ||||
| +	iface->conf->secondary_channel = css->freq_params.sec_channel_offset; | ||||
| +	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id); | ||||
| +	hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id); | ||||
| +	hostapd_set_oper_chwidth(iface->conf, csa_bw); | ||||
| +	iface->conf->ieee80211n = css->freq_params.ht_enabled; | ||||
| +	iface->conf->ieee80211ac = css->freq_params.vht_enabled; | ||||
| +	iface->conf->ieee80211ax = css->freq_params.he_enabled; | ||||
| + | ||||
| +	/*Set beacon for CSA*/ | ||||
| +	hostapd_dfs_set_beacon_csa(iface, css); | ||||
| + | ||||
| +	return 0; | ||||
| + | ||||
| +} | ||||
| + | ||||
|  static int | ||||
|  hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj, | ||||
|  		    struct ubus_request_data *req, const char *method, | ||||
| @@ -761,14 +963,19 @@ hostapd_switch_chan(struct ubus_context | ||||
|  { | ||||
|  	struct blob_attr *tb[__CSA_MAX]; | ||||
|  	struct hostapd_data *hapd = get_hapd_from_object(obj); | ||||
| -	struct csa_settings css; | ||||
| +	struct hostapd_iface *iface = hapd->iface; | ||||
| +	struct hostapd_channel_data *chan =NULL; | ||||
|  	int i; | ||||
| +	int freq = 0; | ||||
|   | ||||
|  	blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg)); | ||||
|   | ||||
|  	if (!tb[CSA_FREQ]) | ||||
|  		return UBUS_STATUS_INVALID_ARGUMENT; | ||||
|   | ||||
| +	freq = blobmsg_get_u32(tb[CSA_FREQ]); | ||||
| +	chan = freq_to_chan(iface, freq); | ||||
| + | ||||
|  	memset(&css, 0, sizeof(css)); | ||||
|  	css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]); | ||||
|   | ||||
| @@ -788,6 +995,21 @@ hostapd_switch_chan(struct ubus_context | ||||
|  	SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool); | ||||
|   | ||||
| +	wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__, | ||||
| +		css.freq_params.freq, | ||||
| +		chan->chan, css.freq_params.sec_channel_offset, | ||||
| +		css.freq_params.bandwidth, | ||||
| +		css.freq_params.center_freq1, | ||||
| +		css.freq_params.center_freq2); | ||||
| + | ||||
| +	if ((chan->flag & HOSTAPD_CHAN_RADAR) && | ||||
| +	    ((chan->flag & HOSTAPD_CHAN_DFS_MASK) | ||||
| +	     != HOSTAPD_CHAN_DFS_AVAILABLE)) { | ||||
| +		wpa_printf(MSG_INFO, "%s: DFS chan need CAC", __func__); | ||||
| +		hostapd_switch_chan_dfs(iface, &css); | ||||
| +		return UBUS_STATUS_OK; | ||||
| +	} | ||||
| + | ||||
|  	for (i = 0; i < hapd->iface->num_bss; i++) { | ||||
|  		if (hostapd_switch_channel(hapd->iface->bss[i], &css) != 0) | ||||
|  			return UBUS_STATUS_NOT_SUPPORTED; | ||||
| @@ -1454,10 +1676,16 @@ void hostapd_ubus_free_bss(struct hostap | ||||
|  	} | ||||
|   | ||||
|  	free(name); | ||||
| -	for (size_t i = 0; i < bss_nr; i++) | ||||
| -		os_free(bss_lst[i]); | ||||
| -	free(bss_lst); | ||||
| -	bss_lst = NULL; | ||||
| + | ||||
| +	if (bss_lst != NULL) { | ||||
| +		for (size_t i = 0; i < bss_nr; i++) { | ||||
| +			os_free(bss_lst[i]); | ||||
| +			bss_lst[i] = NULL; | ||||
| +		} | ||||
| +		free(bss_lst); | ||||
| +		bss_lst = NULL; | ||||
| +		bss_nr = 0; | ||||
| +	} | ||||
|  } | ||||
|   | ||||
|  static int hostapd_get_bss_list(struct ubus_context *ctx, | ||||
| @@ -1477,9 +1705,11 @@ static int hostapd_get_bss_list(struct u | ||||
|  	a = blobmsg_open_array(&b_ev, "bss_list"); | ||||
|  	/* check bss list from hapd */ | ||||
|  	for (size_t i = 0; i < bss_nr; i++) { | ||||
| -		b = blobmsg_open_table(&b_ev, NULL); | ||||
| -		blobmsg_add_string(&b_ev, "name", bss_lst[i]); | ||||
| -		blobmsg_close_table(&b_ev, b); | ||||
| +		if (bss_lst[i] != NULL) { | ||||
| +			b = blobmsg_open_table(&b_ev, NULL); | ||||
| +			blobmsg_add_string(&b_ev, "name", bss_lst[i]); | ||||
| +			blobmsg_close_table(&b_ev, b); | ||||
| +		} | ||||
|  	} | ||||
|  	blobmsg_close_array(&b_ev, a); | ||||
|  	ubus_send_reply(ctx, req, b_ev.head); | ||||
| @@ -1,64 +0,0 @@ | ||||
| --- a/src/ap/ubus.c | ||||
| +++ b/src/ap/ubus.c | ||||
| @@ -531,6 +531,7 @@ enum { | ||||
|  	CSA_VHT, | ||||
|  	CSA_HE, | ||||
|  	CSA_BLOCK_TX, | ||||
| +	CSA_REASON, | ||||
|  	__CSA_MAX | ||||
|  }; | ||||
|   | ||||
| @@ -545,6 +546,7 @@ static const struct blobmsg_policy csa_p | ||||
|  	[CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL }, | ||||
|  	[CSA_HE] = { "he", BLOBMSG_TYPE_BOOL }, | ||||
|  	[CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL }, | ||||
| +	[CSA_REASON] = { "reason", BLOBMSG_TYPE_INT32 }, | ||||
|  }; | ||||
|   | ||||
|  #ifdef NEED_AP_MLME | ||||
| @@ -810,7 +812,7 @@ void hostapd_dfs_csa_timeout(void *eloop | ||||
|  		   iface->conf->ieee80211ac, iface->conf->ieee80211ax); | ||||
|   | ||||
|  	ret = hostapd_enable_iface(iface); | ||||
| -	if (ret == 0) | ||||
| +	if (ret == 0 && css->reason == 0) | ||||
|  		hostapd_ubus_handle_channel_switch_event(iface, | ||||
|  						HOSTAPD_UBUS_HIGH_INTERFERENCE, | ||||
|  						iface->freq); | ||||
| @@ -994,6 +996,7 @@ hostapd_switch_chan(struct ubus_context | ||||
|  	SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool); | ||||
| +	SET_CSA_SETTING(CSA_REASON, reason, u32); | ||||
|   | ||||
|  	wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__, | ||||
|  		css.freq_params.freq, | ||||
| @@ -1015,7 +1018,9 @@ hostapd_switch_chan(struct ubus_context | ||||
|  			return UBUS_STATUS_NOT_SUPPORTED; | ||||
|  	} | ||||
|   | ||||
| -	hostapd_ubus_handle_channel_switch_event(hapd->iface, HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq); | ||||
| +	if (css.reason == 0) { | ||||
| +		hostapd_ubus_handle_channel_switch_event(hapd->iface, HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq); | ||||
| +	} | ||||
|   | ||||
|  	return UBUS_STATUS_OK; | ||||
|  #undef SET_CSA_SETTING | ||||
| --- a/src/drivers/driver.h | ||||
| +++ b/src/drivers/driver.h | ||||
| @@ -2404,6 +2404,7 @@ struct beacon_data { | ||||
|   * @freq_params: Next channel frequency parameter | ||||
|   * @beacon_csa: Beacon/probe resp/asooc resp info for CSA period | ||||
|   * @beacon_after: Next beacon/probe resp/asooc resp info | ||||
| + * @reason: The reason why we are switching the channel | ||||
|   * @counter_offset_beacon: Offset to the count field in beacon's tail | ||||
|   * @counter_offset_presp: Offset to the count field in probe resp. | ||||
|   */ | ||||
| @@ -2414,6 +2415,7 @@ struct csa_settings { | ||||
|  	struct hostapd_freq_params freq_params; | ||||
|  	struct beacon_data beacon_csa; | ||||
|  	struct beacon_data beacon_after; | ||||
| +	u32 reason; | ||||
|   | ||||
|  	u16 counter_offset_beacon[2]; | ||||
|  	u16 counter_offset_presp[2]; | ||||
| @@ -1,112 +0,0 @@ | ||||
| --- a/src/ap/ubus.c | ||||
| +++ b/src/ap/ubus.c | ||||
| @@ -580,6 +580,7 @@ static int hostapd_clear_session(struct | ||||
|  	{ | ||||
|  		if (session_id == rec->session_id) { | ||||
|  			/* dec counter and delete */ | ||||
| +			wpa_printf(MSG_INFO, "%s Deleting client session with session id %llu", __func__, session_id); | ||||
|  			cached_events_nr -= rec->rec_nr; | ||||
|  			avl_delete(&hapd->ubus.rt_events, &rec->avl); | ||||
|  			os_free(rec->records); | ||||
| @@ -633,6 +634,11 @@ static int hostapd_sessions(struct ubus_ | ||||
|  		/* messages for current session */ | ||||
|  		for (size_t i = 0; i < rec->rec_nr; i++) { | ||||
|  			c_rec = &rec->records[i]; | ||||
| +			if (c_rec->processed) { | ||||
| +				/* Record is already reported, continue */ | ||||
| +				continue; | ||||
| +			} | ||||
| + | ||||
|  			/* check message type */ | ||||
|  			switch (c_rec->type) { | ||||
|  			/* ClientAuthEvent */ | ||||
| @@ -646,6 +652,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u32(&b_ev, "auth_status", p->auth_status); | ||||
|  				blobmsg_add_string(&b_ev, "ssid", p->ssid); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -665,6 +672,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u8(&b_ev, "using11v", p->using11v); | ||||
|  				blobmsg_add_string(&b_ev, "ssid", p->ssid); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -680,6 +688,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u32(&b_ev, "internal_rc", p->internal_rc); | ||||
|  				blobmsg_add_string(&b_ev, "ssid", p->ssid); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -693,6 +702,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u64(&b_ev, "fdata_tx_up_ts_in_us", p->tx_ts.tv_sec * (uint64_t)1000000); | ||||
|  				blobmsg_add_u64(&b_ev, "fdata_rx_up_ts_in_us", p->rx_ts.tv_sec * (uint64_t)1000000); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -705,6 +715,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_string(&b_ev, "sta_mac", p->sta_mac); | ||||
|  				blobmsg_add_string(&b_ev, "ip_address", p->ip_addr); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -1912,6 +1923,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_AUTH; | ||||
|  		rp->u.auth.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|   | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
| @@ -1942,6 +1954,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_ASSOC; | ||||
|  		rp->u.assoc.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* frequency */ | ||||
| @@ -1986,6 +1999,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_DISASSOC; | ||||
|  		rp->u.disassoc.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* frequency */ | ||||
| @@ -2017,6 +2031,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_FDATA; | ||||
|  		rp->u.fdata.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* STA MAC */ | ||||
| @@ -2045,6 +2060,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_IP; | ||||
|  		rp->u.ip.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* STA MAC */ | ||||
| --- a/src/ap/ubus.h | ||||
| +++ b/src/ap/ubus.h | ||||
| @@ -110,6 +110,7 @@ struct client_ip_event { | ||||
|  }; | ||||
|   | ||||
|  struct client_session_record { | ||||
| +	bool processed; | ||||
|  	int type; | ||||
|  	uint64_t timestamp; | ||||
|  	union { | ||||
| @@ -1,31 +0,0 @@ | ||||
| --- a/drivers/net/wireless/ath/ath11k/wmi.c | ||||
| +++ b/drivers/net/wireless/ath/ath11k/wmi.c | ||||
| @@ -7339,16 +7339,18 @@ | ||||
|   | ||||
|  	survey = &ar->survey[idx]; | ||||
|   | ||||
| -	survey->noise     = bss_ch_info_ev.noise_floor; | ||||
| -	survey->time      = div_u64(total, cc_freq_hz); | ||||
| -	survey->time_busy = div_u64(busy, cc_freq_hz); | ||||
| -	survey->time_rx   = div_u64(rx_bss, cc_freq_hz); | ||||
| -	survey->time_tx   = div_u64(tx, cc_freq_hz); | ||||
| -	survey->filled   |= (SURVEY_INFO_NOISE_DBM | | ||||
| -			     SURVEY_INFO_TIME | | ||||
| -			     SURVEY_INFO_TIME_BUSY | | ||||
| -			     SURVEY_INFO_TIME_RX | | ||||
| -			     SURVEY_INFO_TIME_TX); | ||||
| +	survey->noise       = bss_ch_info_ev.noise_floor; | ||||
| +	survey->time        = div_u64(total, cc_freq_hz); | ||||
| +	survey->time_busy   = div_u64(busy, cc_freq_hz); | ||||
| +	survey->time_rx     = div_u64(rx, cc_freq_hz); | ||||
| +	survey->time_bss_rx = div_u64(rx_bss, cc_freq_hz); | ||||
| +	survey->time_tx     = div_u64(tx, cc_freq_hz); | ||||
| +	survey->filled     |= (SURVEY_INFO_NOISE_DBM | | ||||
| +			       SURVEY_INFO_TIME | | ||||
| +			       SURVEY_INFO_TIME_BUSY | | ||||
| +			       SURVEY_INFO_TIME_RX | | ||||
| +			       SURVEY_INFO_TIME_TX | | ||||
| +			       SURVEY_INFO_TIME_BSS_RX); | ||||
|  exit: | ||||
|  	spin_unlock_bh(&ar->data_lock); | ||||
|  	complete(&ar->bss_survey_done); | ||||
| @@ -1,84 +0,0 @@ | ||||
| From 0e23a88c63d6abbeaef8ec90bd29584b7c5068bd Mon Sep 17 00:00:00 2001 | ||||
| From: Sriram R <srirrama@codeaurora.org> | ||||
| Date: Thu, 10 Dec 2020 14:20:50 +0530 | ||||
| Subject: [PATCH] ath11k: Clear the fragment cache during key install | ||||
|  | ||||
| Currently the fragment cache setup during peer assoc is | ||||
| cleared during peer delete. In case a key reinstallation | ||||
| happens with the same peer, possibilitites are same fragment cache | ||||
| where some fragments were added before key installation could be clubbed | ||||
| with fragments received after. In ideal cases where | ||||
| this could result in wrong PN since we expect all fragments to | ||||
| have incrementing PN, this behavior could be explioted | ||||
| to mix fragments of different data resulting in a proper | ||||
| unintended reassembled packet to be passed up the stack. | ||||
|  | ||||
| Signed-off-by: Sriram R <srirrama@codeaurora.org> | ||||
| --- | ||||
|  drivers/net/wireless/ath/ath11k/dp_rx.c | 19 +++++++++++++++++++ | ||||
|  drivers/net/wireless/ath/ath11k/dp_rx.h |  1 + | ||||
|  drivers/net/wireless/ath/ath11k/mac.c   |  6 ++++++ | ||||
|  3 files changed, 26 insertions(+) | ||||
|  | ||||
| diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c | ||||
| index 0fa25c1..06bbd6e 100644 | ||||
| --- a/drivers/net/wireless/ath/ath11k/dp_rx.c | ||||
| +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c | ||||
| @@ -844,6 +844,25 @@ static void ath11k_dp_rx_frags_cleanup(struct dp_rx_tid *rx_tid, bool rel_link_d | ||||
|  	__skb_queue_purge(&rx_tid->rx_frags); | ||||
|  } | ||||
|   | ||||
| +void ath11k_peer_frags_flush(struct ath11k *ar, struct ath11k_peer *peer) | ||||
| +{ | ||||
| +	struct dp_rx_tid *rx_tid; | ||||
| +	int i; | ||||
| + | ||||
| +	lockdep_assert_held(&ar->ab->base_lock); | ||||
| + | ||||
| +	for (i = 0; i <= IEEE80211_NUM_TIDS; i++) { | ||||
| +		rx_tid = &peer->rx_tid[i]; | ||||
| + | ||||
| +		spin_unlock_bh(&ar->ab->base_lock); | ||||
| +		del_timer_sync(&rx_tid->frag_timer); | ||||
| +		spin_lock_bh(&ar->ab->base_lock); | ||||
| + | ||||
| +		ath11k_dp_rx_frags_cleanup(rx_tid, true); | ||||
| + | ||||
| +	} | ||||
| +} | ||||
| + | ||||
|  void ath11k_peer_rx_tid_cleanup(struct ath11k *ar, struct ath11k_peer *peer) | ||||
|  { | ||||
|  	struct dp_rx_tid *rx_tid; | ||||
| diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.h b/drivers/net/wireless/ath/ath11k/dp_rx.h | ||||
| index f005ded..732f9a7 100644 | ||||
| --- a/drivers/net/wireless/ath/ath11k/dp_rx.h | ||||
| +++ b/drivers/net/wireless/ath/ath11k/dp_rx.h | ||||
| @@ -68,6 +68,7 @@ int ath11k_dp_peer_rx_pn_replay_config(struct ath11k_vif *arvif, | ||||
|  				       const u8 *peer_addr, | ||||
|  				       enum set_key_cmd key_cmd, | ||||
|  				       struct ieee80211_key_conf *key); | ||||
| +void ath11k_peer_frags_flush(struct ath11k *ar, struct ath11k_peer *peer); | ||||
|  void ath11k_peer_rx_tid_cleanup(struct ath11k *ar, struct ath11k_peer *peer); | ||||
|  void ath11k_peer_rx_tid_delete(struct ath11k *ar, | ||||
|  			       struct ath11k_peer *peer, u8 tid); | ||||
| diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c | ||||
| index 4c88eab..91d645e 100644 | ||||
| --- a/drivers/net/wireless/ath/ath11k/mac.c | ||||
| +++ b/drivers/net/wireless/ath/ath11k/mac.c | ||||
| @@ -3707,6 +3707,12 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | ||||
|  	 */ | ||||
|  	spin_lock_bh(&ab->base_lock); | ||||
|  	peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr); | ||||
| + | ||||
| +	/* flush the fragments cache during key (re)install to | ||||
| +	 * ensure all frags in the new frag list  belong to the same key. | ||||
| +	 */ | ||||
| +	if (peer && cmd == SET_KEY) | ||||
| +		ath11k_peer_frags_flush(ar, peer); | ||||
|  	spin_unlock_bh(&ab->base_lock); | ||||
|   | ||||
|  	if (!peer) { | ||||
| --  | ||||
| 2.7.4 | ||||
|  | ||||
| @@ -1,242 +0,0 @@ | ||||
| From patchwork Tue May 11 18:02:44 2021 | ||||
| Content-Type: text/plain; charset="utf-8" | ||||
| MIME-Version: 1.0 | ||||
| Content-Transfer-Encoding: 7bit | ||||
| X-Patchwork-Submitter: Johannes Berg <johannes@sipsolutions.net> | ||||
| X-Patchwork-Id: 12251641 | ||||
| X-Patchwork-Delegate: johannes@sipsolutions.net | ||||
| Return-Path: <linux-wireless-owner@kernel.org> | ||||
| X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on | ||||
| 	aws-us-west-2-korg-lkml-1.web.codeaurora.org | ||||
| X-Spam-Level:  | ||||
| X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, | ||||
| 	HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, | ||||
| 	MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT | ||||
| 	autolearn=unavailable autolearn_force=no version=3.4.0 | ||||
| Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) | ||||
| 	by smtp.lore.kernel.org (Postfix) with ESMTP id 5E0C4C43617 | ||||
| 	for <linux-wireless@archiver.kernel.org>; | ||||
|  Tue, 11 May 2021 18:03:20 +0000 (UTC) | ||||
| Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) | ||||
| 	by mail.kernel.org (Postfix) with ESMTP id 2E1D461625 | ||||
| 	for <linux-wireless@archiver.kernel.org>; | ||||
|  Tue, 11 May 2021 18:03:20 +0000 (UTC) | ||||
| Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand | ||||
|         id S231693AbhEKSEZ (ORCPT | ||||
|         <rfc822;linux-wireless@archiver.kernel.org>); | ||||
|         Tue, 11 May 2021 14:04:25 -0400 | ||||
| Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41156 "EHLO | ||||
|         lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org | ||||
|         with ESMTP id S231561AbhEKSEV (ORCPT | ||||
|         <rfc822;linux-wireless@vger.kernel.org>); | ||||
|         Tue, 11 May 2021 14:04:21 -0400 | ||||
| Received: from sipsolutions.net (s3.sipsolutions.net | ||||
|  [IPv6:2a01:4f8:191:4433::2]) | ||||
|         by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D055CC06175F; | ||||
|         Tue, 11 May 2021 11:03:10 -0700 (PDT) | ||||
| Received: by sipsolutions.net with esmtpsa | ||||
|  (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) | ||||
|         (Exim 4.94.2) | ||||
|         (envelope-from <johannes@sipsolutions.net>) | ||||
|         id 1lgWir-007aAS-9o; Tue, 11 May 2021 20:03:09 +0200 | ||||
| From: Johannes Berg <johannes@sipsolutions.net> | ||||
| To: linux-wireless@vger.kernel.org | ||||
| Cc: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>, stable@vger.kernel.org | ||||
| Subject: [PATCH 03/18] mac80211: properly handle A-MSDUs that start with an | ||||
|  RFC 1042 header | ||||
| Date: Tue, 11 May 2021 20:02:44 +0200 | ||||
| Message-Id:  | ||||
|  <20210511200110.0b2b886492f0.I23dd5d685fe16d3b0ec8106e8f01b59f499dffed@changeid> | ||||
| X-Mailer: git-send-email 2.30.2 | ||||
| In-Reply-To: <20210511180259.159598-1-johannes@sipsolutions.net> | ||||
| References: <20210511180259.159598-1-johannes@sipsolutions.net> | ||||
| MIME-Version: 1.0 | ||||
| Precedence: bulk | ||||
| List-ID: <linux-wireless.vger.kernel.org> | ||||
| X-Mailing-List: linux-wireless@vger.kernel.org | ||||
|  | ||||
| From: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be> | ||||
|  | ||||
| Properly parse A-MSDUs whose first 6 bytes happen to equal a rfc1042 | ||||
| header. This can occur in practice when the destination MAC address | ||||
| equals AA:AA:03:00:00:00. More importantly, this simplifies the next | ||||
| patch to mitigate A-MSDU injection attacks. | ||||
|  | ||||
| Cc: stable@vger.kernel.org | ||||
| Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be> | ||||
| Signed-off-by: Johannes Berg <johannes.berg@intel.com> | ||||
| --- | ||||
|  include/net/cfg80211.h | 4 ++-- | ||||
|  net/mac80211/rx.c      | 2 +- | ||||
|  net/wireless/util.c    | 4 ++-- | ||||
|  3 files changed, 5 insertions(+), 5 deletions(-) | ||||
|  | ||||
| Index: backports-20200902_001-4.4.60-931c337125/include/net/cfg80211.h | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/include/net/cfg80211.h | ||||
| +++ backports-20200902_001-4.4.60-931c337125/include/net/cfg80211.h | ||||
| @@ -5631,7 +5631,7 @@ unsigned int ieee80211_get_mesh_hdrlen(s | ||||
|   */ | ||||
|  int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, | ||||
|  				  const u8 *addr, enum nl80211_iftype iftype, | ||||
| -				  u8 data_offset); | ||||
| +				  u8 data_offset, bool is_amsdu); | ||||
|   | ||||
|  /** | ||||
|   * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 | ||||
| @@ -5643,7 +5643,7 @@ int ieee80211_data_to_8023_exthdr(struct | ||||
|  static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | ||||
|  					 enum nl80211_iftype iftype) | ||||
|  { | ||||
| -	return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0); | ||||
| +	return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false); | ||||
|  } | ||||
|   | ||||
|  /** | ||||
| Index: backports-20200902_001-4.4.60-931c337125/net/mac80211/rx.c | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/net/mac80211/rx.c | ||||
| +++ backports-20200902_001-4.4.60-931c337125/net/mac80211/rx.c | ||||
| @@ -6,7 +6,7 @@ | ||||
|   * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net> | ||||
|   * Copyright 2013-2014  Intel Mobile Communications GmbH | ||||
|   * Copyright(c) 2015 - 2017 Intel Deutschland GmbH | ||||
| - * Copyright (C) 2018-2020 Intel Corporation | ||||
| + * Copyright (C) 2018-2021 Intel Corporation | ||||
|   */ | ||||
|   | ||||
|  #include <linux/jiffies.h> | ||||
| @@ -2555,13 +2555,13 @@ static bool ieee80211_frame_allowed(stru | ||||
|  	struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; | ||||
|   | ||||
|  	/* | ||||
| -	 * Allow EAPOL frames to us/the PAE group address regardless | ||||
| -	 * of whether the frame was encrypted or not. | ||||
| -	 */ | ||||
| -	if (ehdr->h_proto == rx->sdata->control_port_protocol && | ||||
| -	    (ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) || | ||||
| -	     ether_addr_equal(ehdr->h_dest, pae_group_addr))) | ||||
| -		return true; | ||||
| +	 * Allow EAPOL frames to us/the PAE group address regardless of | ||||
| +	 * whether the frame was encrypted or not, and always disallow | ||||
| +	 * all other destination addresses for them. | ||||
| +	 */ | ||||
| +	if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol)) | ||||
| +		return ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) || | ||||
| +		       ether_addr_equal(ehdr->h_dest, pae_group_addr); | ||||
|   | ||||
|  	if (ieee80211_802_1x_port_control(rx) || | ||||
|  	    ieee80211_drop_unencrypted(rx, fc)) | ||||
| @@ -2632,7 +2632,26 @@ static void ieee80211_deliver_skb_to_loc | ||||
|  		cfg80211_rx_control_port(dev, skb, noencrypt); | ||||
|  		dev_kfree_skb(skb); | ||||
|  	} else { | ||||
| +		struct ethhdr *ehdr = (void *)skb_mac_header(skb); | ||||
|  		memset(skb->cb, 0, sizeof(skb->cb)); | ||||
| +		/* | ||||
| +		 * 802.1X over 802.11 requires that the authenticator address | ||||
| +		 * be used for EAPOL frames. However, 802.1X allows the use of | ||||
| +		 * the PAE group address instead. If the interface is part of | ||||
| +		 * a bridge and we pass the frame with the PAE group address, | ||||
| +		 * then the bridge will forward it to the network (even if the | ||||
| +		 * client was not associated yet), which isn't supposed to | ||||
| +		 * happen. | ||||
| +		 * To avoid that, rewrite the destination address to our own | ||||
| +		 * address, so that the authenticator (e.g. hostapd) will see | ||||
| +		 * the frame, but bridge won't forward it anywhere else. Note | ||||
| +		 * that due to earlier filtering, the only other address can | ||||
| +		 * be the PAE group address. | ||||
| +		 */ | ||||
| +		if (unlikely(skb->protocol == sdata->control_port_protocol && | ||||
| +			     !ether_addr_equal(ehdr->h_dest, sdata->vif.addr))) | ||||
| +			ether_addr_copy(ehdr->h_dest, sdata->vif.addr); | ||||
| + | ||||
|  		netif_rx_nss(rx, skb); | ||||
|  	} | ||||
|  } | ||||
| @@ -2672,6 +2691,7 @@ ieee80211_deliver_skb(struct ieee80211_r | ||||
|  	if ((sdata->vif.type == NL80211_IFTYPE_AP || | ||||
|  	     sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && | ||||
|  	    !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && | ||||
| +	    ehdr->h_proto != rx->sdata->control_port_protocol && | ||||
|  	    (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) { | ||||
|  		if (is_multicast_ether_addr(ehdr->h_dest) && | ||||
|  		    ieee80211_vif_get_num_mcast_if(sdata) != 0) { | ||||
| @@ -2781,7 +2801,7 @@ __ieee80211_rx_h_amsdu(struct ieee80211_ | ||||
|  	if (ieee80211_data_to_8023_exthdr(skb, ðhdr, | ||||
|  					  rx->sdata->vif.addr, | ||||
|  					  rx->sdata->vif.type, | ||||
| -					  data_offset)) | ||||
| +					  data_offset, true)) | ||||
|  		return RX_DROP_UNUSABLE; | ||||
|   | ||||
|  	ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, | ||||
| @@ -2838,6 +2858,23 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx | ||||
|  	if (is_multicast_ether_addr(hdr->addr1)) | ||||
|  		return RX_DROP_UNUSABLE; | ||||
|   | ||||
| +	if (rx->key) { | ||||
| +		/* | ||||
| +		 * We should not receive A-MSDUs on pre-HT connections, | ||||
| +		 * and HT connections cannot use old ciphers. Thus drop | ||||
| +		 * them, as in those cases we couldn't even have SPP | ||||
| +		 * A-MSDUs or such. | ||||
| +		 */ | ||||
| +		switch (rx->key->conf.cipher) { | ||||
| +		case WLAN_CIPHER_SUITE_WEP40: | ||||
| +		case WLAN_CIPHER_SUITE_WEP104: | ||||
| +		case WLAN_CIPHER_SUITE_TKIP: | ||||
| +			return RX_DROP_UNUSABLE; | ||||
| +		default: | ||||
| +			break; | ||||
| +		} | ||||
| +	} | ||||
| + | ||||
|  	return __ieee80211_rx_h_amsdu(rx, 0); | ||||
|  } | ||||
|   | ||||
| Index: backports-20200902_001-4.4.60-931c337125/net/wireless/util.c | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/net/wireless/util.c | ||||
| +++ backports-20200902_001-4.4.60-931c337125/net/wireless/util.c | ||||
| @@ -474,7 +474,7 @@ EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen) | ||||
|   | ||||
|  int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, | ||||
|  				  const u8 *addr, enum nl80211_iftype iftype, | ||||
| -				  u8 data_offset) | ||||
| +				  u8 data_offset, bool is_amsdu) | ||||
|  { | ||||
|  	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||||
|  	struct { | ||||
| @@ -562,7 +562,7 @@ int ieee80211_data_to_8023_exthdr(struct | ||||
|  	skb_copy_bits(skb, hdrlen, &payload, sizeof(payload)); | ||||
|  	tmp.h_proto = payload.proto; | ||||
|   | ||||
| -	if (likely((ether_addr_equal(payload.hdr, rfc1042_header) && | ||||
| +	if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) && | ||||
|  		    tmp.h_proto != htons(ETH_P_AARP) && | ||||
|  		    tmp.h_proto != htons(ETH_P_IPX)) || | ||||
|  		   ether_addr_equal(payload.hdr, bridge_tunnel_header))) | ||||
| @@ -708,6 +708,9 @@ void ieee80211_amsdu_to_8023s(struct sk_ | ||||
|  		remaining = skb->len - offset; | ||||
|  		if (subframe_len > remaining) | ||||
|  			goto purge; | ||||
| +		/* mitigate A-MSDU aggregation injection attacks */ | ||||
| +		if (ether_addr_equal(eth.h_dest, rfc1042_header)) | ||||
| +			goto purge; | ||||
|   | ||||
|  		offset += sizeof(struct ethhdr); | ||||
|  		last = remaining <= subframe_len + padding; | ||||
| Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/nss.c | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/nss.c | ||||
| +++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/nss.c | ||||
| @@ -477,7 +477,7 @@ static int ath11k_nss_deliver_rx(struct | ||||
|  	} | ||||
|   | ||||
|  	if (ieee80211_data_to_8023_exthdr(skb, NULL, vif->addr, vif->type, | ||||
| -					  data_offs - hdr_len)) { | ||||
| +					  data_offs - hdr_len, false)) { | ||||
|  		dev_kfree_skb_any(skb); | ||||
|  		return -EINVAL; | ||||
|  	} | ||||
| @@ -1,392 +0,0 @@ | ||||
| Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/debug.c | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/debug.c | ||||
| +++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/debug.c | ||||
| @@ -1838,6 +1838,230 @@ static const struct file_operations fops | ||||
|  	.open = simple_open | ||||
|  }; | ||||
|   | ||||
| +static ssize_t ath11k_read_set_rates(struct file *file, | ||||
| +				     char __user *user_buf, | ||||
| +				     size_t count, loff_t *ppos) | ||||
| +{ | ||||
| +	const char buf[] = | ||||
| +		"This is to set fixed bcast, mcast, and beacon rates.  Normal rate-ctrl\n" | ||||
| +		"is handled through normal API using 'iw', etc.\n" | ||||
| +		"To set a value, you specify the dev-name, type, band and rate-code:\n" | ||||
| +		"types: bcast, mcast, beacon, mgmt\n" | ||||
| +		"bands: 2, 5\n" | ||||
| +		"rate-codes: 1M (0x10000103), 2M (0x10000102), 5.5M (0x10000101),\n 11M (0x10000100), 6M (0x10000003),9M (0x10000007),\n 12M (0x10000002), 18M (0x10000006),\n 24M (0x10000001), 36M (0x10000005), 48M (0x10000000),\n 54M (0x10000004) , 0xFF default\n" | ||||
| +		"Example, set beacon to 18Mbps on wlan0(2.4G):\n  echo \"wlan0 beacon 2 0x10000006\" > /sys/kernel/debug/ieee80211/phy0/ath11k/set_rates\n"; | ||||
| + | ||||
| +	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); | ||||
| +} | ||||
| + | ||||
| +bool check_band_rate_compat(struct ath11k *ar, long rc, int band) | ||||
| +{ | ||||
| +	struct ieee80211_supported_band *sband = NULL; | ||||
| +	int br, i = 0; | ||||
| +	long rcode = 0; | ||||
| + | ||||
| +	sband = ar->hw->wiphy->bands[band]; | ||||
| +	if (sband == NULL) { | ||||
| +		ath11k_err(ar->ab, "band not valid\n"); | ||||
| +		return false; | ||||
| +	} | ||||
| + | ||||
| +	for (i = 0; i < sband->n_bitrates; i++) { | ||||
| +		br = sband->bitrates[i].bitrate; | ||||
| +		rcode = ath11k_mac_get_rate_hw_value(sband->bitrates[i].bitrate); | ||||
| +		if (rcode == rc){ | ||||
| +			return true; | ||||
| +		} | ||||
| +	} | ||||
| +	ath11k_err(ar->ab, "rate-code not found rc=%ld(0x%lx)", rc, rc); | ||||
| +	return false; | ||||
| +} | ||||
| + | ||||
| +/* Set the rates for specific types of traffic. */ | ||||
| +static ssize_t ath11k_write_set_rates(struct file *file, | ||||
| +				      const char __user *user_buf, | ||||
| +				      size_t count, loff_t *ppos) | ||||
| +{ | ||||
| +	struct ath11k *ar = file->private_data; | ||||
| +	char buf[80]; | ||||
| +	int ret; | ||||
| +	struct ath11k_vif *arvif; | ||||
| +	struct ieee80211_vif *vif; | ||||
| +	unsigned int vdev_id = 0xFFFF; | ||||
| +	char* bufptr = buf; | ||||
| +	long rc; | ||||
| +	int cfg_band; | ||||
| +	struct cfg80211_chan_def def; | ||||
| +	char dev_name_match[IFNAMSIZ + 2]; | ||||
| +	struct wireless_dev *wdev; | ||||
| +	int set_rate_type; | ||||
| + | ||||
| +	memset(buf, 0, sizeof(buf)); | ||||
| + | ||||
| +	simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); | ||||
| + | ||||
| +	/* make sure that buf is null terminated */ | ||||
| +	buf[sizeof(buf) - 1] = 0; | ||||
| + | ||||
| +	/* drop the possible '\n' from the end */ | ||||
| +	if (buf[count - 1] == '\n') | ||||
| +		buf[count - 1] = 0; | ||||
| + | ||||
| +	mutex_lock(&ar->conf_mutex); | ||||
| + | ||||
| +	/* Ignore empty lines, 'echo' appends them sometimes at least. */ | ||||
| +	if (buf[0] == 0) { | ||||
| +		ret = count; | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	/* String starts with vdev name, ie 'wlan0'  Find the proper vif that | ||||
| +	 * matches the name. | ||||
| +	 */ | ||||
| +	list_for_each_entry(arvif, &ar->arvifs, list) { | ||||
| +		vif = arvif->vif; | ||||
| +		wdev = ieee80211_vif_to_wdev(vif); | ||||
| + | ||||
| +		if (!wdev) | ||||
| +			continue; | ||||
| +		snprintf(dev_name_match, sizeof(dev_name_match) - 1, "%s ", | ||||
| +			 wdev->netdev->name); | ||||
| +		if (strncmp(dev_name_match, buf, strlen(dev_name_match)) == 0) { | ||||
| +			vdev_id = arvif->vdev_id; | ||||
| +			bufptr = buf + strlen(dev_name_match); | ||||
| +			break; | ||||
| +		} | ||||
| +	} | ||||
| + | ||||
| +	if (vdev_id == 0xFFFF) { | ||||
| +		ath11k_warn(ar->ab, "set-rate, unknown netdev name: %s\n", buf); | ||||
| +		ret = -EINVAL; | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	/* Now, check the type. */ | ||||
| +	if (strncmp(bufptr, "beacon ", strlen("beacon ")) == 0) { | ||||
| +		set_rate_type = WMI_VDEV_PARAM_BEACON_RATE; | ||||
| +		bufptr += strlen("beacon "); | ||||
| +	} | ||||
| +	else if (strncmp(bufptr, "mgmt ", strlen("mgmt ")) == 0) { | ||||
| +		set_rate_type = WMI_VDEV_PARAM_MGMT_RATE; | ||||
| +		bufptr += strlen("mgmt "); | ||||
| +	} | ||||
| +	else if (strncmp(bufptr, "bcast ", strlen("bcast ")) == 0) { | ||||
| +		set_rate_type = WMI_VDEV_PARAM_BCAST_DATA_RATE; | ||||
| +		bufptr += strlen("bcast "); | ||||
| +	} | ||||
| +	else if (strncmp(bufptr, "mcast ", strlen("mcast ")) == 0) { | ||||
| +		set_rate_type = WMI_VDEV_PARAM_MCAST_DATA_RATE; | ||||
| +		bufptr += strlen("mcast "); | ||||
| +	} | ||||
| +	else { | ||||
| +		ath11k_warn(ar->ab, "set-rate, invalid rate type: %s\n", | ||||
| +			    bufptr); | ||||
| +		ret = -EINVAL; | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	/* And the band */ | ||||
| +	if (strncmp(bufptr, "2 ", 2) == 0) { | ||||
| +		cfg_band = NL80211_BAND_2GHZ; | ||||
| +		bufptr += 2; | ||||
| +	} | ||||
| +	else if (strncmp(bufptr, "5 ", 2) == 0) { | ||||
| +		cfg_band = NL80211_BAND_5GHZ; | ||||
| +		bufptr += 2; | ||||
| +	} | ||||
| +	else if (strncmp(bufptr, "60 ", 3) == 0) { | ||||
| +		cfg_band = NL80211_BAND_60GHZ; | ||||
| +		bufptr += 3; | ||||
| +	} | ||||
| +	else { | ||||
| +		ath11k_warn(ar->ab, "set-rate, invalid band: %s\n", | ||||
| +			    bufptr); | ||||
| +		ret = -EINVAL; | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	/* Parse the rate-code. */ | ||||
| +	ret = kstrtol(bufptr, 0, &rc); | ||||
| +	if (ret != 0) { | ||||
| +		ath11k_warn(ar->ab, "set-rate, invalid rate-code: %s\n", | ||||
| +			    bufptr); | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	/* Store the value so we can re-apply it if firmware is restarted. */ | ||||
| +	if (set_rate_type == WMI_VDEV_PARAM_MGMT_RATE) { | ||||
| +		arvif->mgt_rate[cfg_band] = rc; | ||||
| +		arvif->mgt_rate_set[cfg_band] = true; | ||||
| +	} | ||||
| +	else if (set_rate_type == WMI_VDEV_PARAM_BCAST_DATA_RATE) { | ||||
| +		arvif->bcast_rate[cfg_band] = rc; | ||||
| +		arvif->bcast_rate_set[cfg_band] = true; | ||||
| +	} | ||||
| +	else if (set_rate_type == WMI_VDEV_PARAM_MCAST_DATA_RATE) { | ||||
| +		arvif->mcast_rate[cfg_band] = rc; | ||||
| +		arvif->mcast_rate_set[cfg_band] = true; | ||||
| +	} | ||||
| +	else if (set_rate_type == WMI_VDEV_PARAM_BEACON_RATE) { | ||||
| +		arvif->bcn_rate[cfg_band] = rc; | ||||
| +		arvif->bcn_rate_set[cfg_band] = true; | ||||
| +	} | ||||
| + | ||||
| +	if (ar->state != ATH11K_STATE_ON && | ||||
| +	    ar->state != ATH11K_STATE_RESTARTED) { | ||||
| +		/* OK, we will set it when vdev comes up */ | ||||
| +		ath11k_warn(ar->ab, "set-rates, deferred-state is down, vdev %i type: 0x%x rc: 0x%lx band: %d\n", | ||||
| +			    arvif->vdev_id, set_rate_type, rc, cfg_band); | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	if (ath11k_mac_vif_chan(vif, &def) == 0) { | ||||
| +		if (def.chan->band != cfg_band) { | ||||
| +			/* We stored value, will apply it later if we move to | ||||
| +			 * the different band. | ||||
| +			 */ | ||||
| +			ath11k_warn(ar->ab, "set-rates, deferred-other-band, vdev %i type: 0x%x rc: 0x%lx band: %d\n", | ||||
| +				    arvif->vdev_id, set_rate_type, | ||||
| +				    rc, cfg_band); | ||||
| +			goto exit; | ||||
| +		} | ||||
| + | ||||
| +		if (check_band_rate_compat(ar, rc, def.chan->band) == false) { | ||||
| +			ath11k_warn(ar->ab, "set-rate, wrong rate code\n"); | ||||
| +			ret = -EINVAL; | ||||
| +			goto exit; | ||||
| +		} | ||||
| +	} | ||||
| + | ||||
| +	/* finally, send results to the firmware */ | ||||
| +	ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, | ||||
| +					    set_rate_type, rc); | ||||
| +	if (ret) { | ||||
| +		ath11k_warn(ar->ab, "set-rates: vdev %i failed to set fixed rate, param 0x%x rate-code 0x%02lx\n", | ||||
| +			    arvif->vdev_id, set_rate_type, rc); | ||||
| +		goto exit; | ||||
| +	} | ||||
| + | ||||
| +	ath11k_warn(ar->ab, "set-rates, vdev %i type: 0x%x rc: 0x%lx band: %d\n", | ||||
| +		    arvif->vdev_id, set_rate_type, rc, cfg_band); | ||||
| + | ||||
| +	ret = count; | ||||
| + | ||||
| +exit: | ||||
| +	mutex_unlock(&ar->conf_mutex); | ||||
| +	return ret; | ||||
| +} | ||||
| + | ||||
| +static const struct file_operations fops_set_rates = { | ||||
| +	.read = ath11k_read_set_rates, | ||||
| +	.write = ath11k_write_set_rates, | ||||
| +	.open = simple_open, | ||||
| +	.owner = THIS_MODULE, | ||||
| +	.llseek = default_llseek, | ||||
| +}; | ||||
| + | ||||
|  static ssize_t ath11k_write_enable_m3_dump(struct file *file, | ||||
|  					   const char __user *ubuf, | ||||
|  					   size_t count, loff_t *ppos) | ||||
| @@ -2532,6 +2756,9 @@ int ath11k_debug_register(struct ath11k | ||||
|  	                    &fops__btcoex_duty_cycle); | ||||
|  	debugfs_create_file("dump_mgmt_stats", 0644, ar->debug.debugfs_pdev, | ||||
|  			    ar, &fops_dump_mgmt_stats); | ||||
| +	debugfs_create_file("set_rates", 0600, ar->debug.debugfs_pdev, | ||||
| +			    ar, &fops_set_rates); | ||||
| + | ||||
|   | ||||
|  	if (ar->hw->wiphy->bands[NL80211_BAND_5GHZ]) { | ||||
|  		debugfs_create_file("dfs_simulate_radar", 0200, | ||||
| Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.c | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/mac.c | ||||
| +++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.c | ||||
| @@ -414,8 +414,8 @@ static u8 ath11k_parse_mpdudensity(u8 mp | ||||
|  	} | ||||
|  } | ||||
|   | ||||
| -static int ath11k_mac_vif_chan(struct ieee80211_vif *vif, | ||||
| -			       struct cfg80211_chan_def *def) | ||||
| +int ath11k_mac_vif_chan(struct ieee80211_vif *vif, | ||||
| +			struct cfg80211_chan_def *def) | ||||
|  { | ||||
|  	struct ieee80211_chanctx_conf *conf; | ||||
|   | ||||
| @@ -2633,7 +2633,7 @@ static void ath11k_bss_disassoc(struct i | ||||
|  	/* TODO: cancel connection_loss_work */ | ||||
|  } | ||||
|   | ||||
| -static u32 ath11k_mac_get_rate_hw_value(int bitrate) | ||||
| +u32 ath11k_mac_get_rate_hw_value(int bitrate) | ||||
|  { | ||||
|  	u32 preamble; | ||||
|  	u16 hw_value; | ||||
| @@ -2672,6 +2672,11 @@ static void ath11k_recalculate_mgmt_rate | ||||
|   | ||||
|  	lockdep_assert_held(&ar->conf_mutex); | ||||
|   | ||||
| +	/* If user has over-ridden the mgt rate, don't muck with it here. */ | ||||
| +	if (arvif->mgt_rate_set[def->chan->band] || | ||||
| +	    arvif->bcn_rate_set[def->chan->band]) | ||||
| +		return; | ||||
| + | ||||
|  	sband = ar->hw->wiphy->bands[def->chan->band]; | ||||
|  	basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1; | ||||
|  	bitrate = sband->bitrates[basic_rate_idx].bitrate; | ||||
| @@ -2682,12 +2687,14 @@ static void ath11k_recalculate_mgmt_rate | ||||
|  		return; | ||||
|  	} | ||||
|   | ||||
| +	arvif->mgt_rate[def->chan->band] = hw_rate_code; | ||||
|  	vdev_param = WMI_VDEV_PARAM_MGMT_RATE; | ||||
|  	ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, | ||||
|  					    hw_rate_code); | ||||
|  	if (ret) | ||||
|  		ath11k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret); | ||||
|   | ||||
| +	arvif->bcn_rate[def->chan->band] = hw_rate_code; | ||||
|  	vdev_param = WMI_VDEV_PARAM_BEACON_RATE; | ||||
|  	ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, | ||||
|  					    hw_rate_code); | ||||
| @@ -3116,17 +3123,23 @@ static void ath11k_mac_op_bss_info_chang | ||||
|  		rate = ATH11K_HW_RATE_CODE(hw_value, 0, preamble); | ||||
|   | ||||
|  		ath11k_dbg(ar->ab, ATH11K_DBG_MAC, | ||||
| -			   "mac vdev %d mcast_rate %x\n", | ||||
| -			   arvif->vdev_id, rate); | ||||
| - | ||||
| -		vdev_param = WMI_VDEV_PARAM_MCAST_DATA_RATE; | ||||
| -		ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, | ||||
| -						    vdev_param, rate); | ||||
| -		if (ret) | ||||
| -			ath11k_warn(ar->ab, | ||||
| -				    "failed to set mcast rate on vdev %i: %d\n", | ||||
| -				    arvif->vdev_id,  ret); | ||||
| +			   "mac vdev %d mcast_rate %x  override-set-mcast: %d  override-set-bcast: %d\n", | ||||
| +			   arvif->vdev_id, rate, arvif->mcast_rate_set[band], | ||||
| +			   arvif->bcast_rate_set[band]); | ||||
| + | ||||
| +		if (!arvif->mcast_rate_set[band]) { | ||||
| +			arvif->mcast_rate[band] = rate; | ||||
| +			vdev_param = WMI_VDEV_PARAM_MCAST_DATA_RATE; | ||||
| +			ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, | ||||
| +							    vdev_param, rate); | ||||
| +			if (ret) | ||||
| +				ath11k_warn(ar->ab, | ||||
| +					    "failed to set mcast rate on vdev %i: %d\n", | ||||
| +					    arvif->vdev_id,  ret); | ||||
| +		} | ||||
|   | ||||
| +		if (!arvif->bcast_rate_set[band]) { | ||||
| +			arvif->bcast_rate[band] = rate; | ||||
|  		vdev_param = WMI_VDEV_PARAM_BCAST_DATA_RATE; | ||||
|  		ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, | ||||
|  						    vdev_param, rate); | ||||
| @@ -3134,6 +3147,7 @@ static void ath11k_mac_op_bss_info_chang | ||||
|  			ath11k_warn(ar->ab, | ||||
|  				    "failed to set bcast rate on vdev %i: %d\n", | ||||
|  				    arvif->vdev_id,  ret); | ||||
| +		} | ||||
|  	} | ||||
|   | ||||
|  	if (changed & BSS_CHANGED_BASIC_RATES && | ||||
| @@ -5832,6 +5846,12 @@ static int ath11k_mac_op_add_interface(s | ||||
|   | ||||
|  	memset(arvif, 0, sizeof(*arvif)); | ||||
|   | ||||
| +	memset(&arvif->bcast_rate, WMI_FIXED_RATE_NONE, | ||||
| +	       sizeof(arvif->bcast_rate)); | ||||
| +	memset(&arvif->mcast_rate, WMI_FIXED_RATE_NONE, | ||||
| +	       sizeof(arvif->mcast_rate)); | ||||
| +	memset(&arvif->mgt_rate, WMI_FIXED_RATE_NONE, sizeof(arvif->mgt_rate)); | ||||
| + | ||||
|  	arvif->ar = ar; | ||||
|  	arvif->vif = vif; | ||||
|   | ||||
| Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.h | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/mac.h | ||||
| +++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.h | ||||
| @@ -164,4 +164,8 @@ u8 ath11k_mac_bw_to_mac80211_bw(u8 bw); | ||||
|  enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw(enum rate_info_bw bw); | ||||
|  enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32 cipher); | ||||
|  void ath11k_mac_bcn_tx_event(struct ath11k_vif *arvif); | ||||
| +int ath11k_mac_vif_chan(struct ieee80211_vif *vif, | ||||
| +			struct cfg80211_chan_def *def); | ||||
| + | ||||
| +u32 ath11k_mac_get_rate_hw_value(int bitrate); | ||||
|  #endif | ||||
| Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/core.h | ||||
| =================================================================== | ||||
| --- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/core.h | ||||
| +++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/core.h | ||||
| @@ -265,6 +265,23 @@ struct ath11k_vif { | ||||
|  #ifdef CPTCFG_ATH11K_NSS_SUPPORT | ||||
|  	struct arvif_nss nss; | ||||
|  #endif | ||||
| +	/* Firmware allows configuring rate of each of these traffic types. | ||||
| +	 * 0xFF will mean value has not been set by user, and in that case, | ||||
| +	 * we will auto-adjust the rates based on the legacy rate mask. | ||||
| +	 **/ | ||||
| +	/* TODO-BEN:  This may conflict with upstream code? */ | ||||
| +	u8 mcast_rate[NUM_NL80211_BANDS]; | ||||
| +	u8 bcast_rate[NUM_NL80211_BANDS]; | ||||
| +	u8 mgt_rate[NUM_NL80211_BANDS]; | ||||
| +	u8 bcn_rate[NUM_NL80211_BANDS]; | ||||
| + | ||||
| +	/* Flag if these rates are set through debugfs, in that case, ignore | ||||
| +	 * setting from farther up the stack. | ||||
| +	 */ | ||||
| +	bool mcast_rate_set[NUM_NL80211_BANDS]; | ||||
| +	bool bcast_rate_set[NUM_NL80211_BANDS]; | ||||
| +	bool mgt_rate_set[NUM_NL80211_BANDS]; | ||||
| +	bool bcn_rate_set[NUM_NL80211_BANDS]; | ||||
|  }; | ||||
|   | ||||
|  struct ath11k_vif_iter { | ||||
| @@ -1,22 +0,0 @@ | ||||
| diff -Naur a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c | ||||
| --- a/drivers/net/wireless/ath/ath11k/mac.c	2021-06-09 10:02:12.040840722 -0400 | ||||
| +++ b/drivers/net/wireless/ath/ath11k/mac.c	2021-06-10 10:40:12.094003411 -0400 | ||||
| @@ -3472,13 +3472,14 @@ | ||||
|  		scan_timeout = min_t(u32, arg->max_rest_time * | ||||
|  				    (arg->chan_list.num_chan - 1) + (req->duration + | ||||
|  				     ATH11K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) * | ||||
| -				     arg->chan_list.num_chan, arg->max_scan_time + | ||||
| -				     ATH11K_MAC_SCAN_TIMEOUT_MSECS); | ||||
| +				     arg->chan_list.num_chan, arg->max_scan_time); | ||||
|  	} else { | ||||
| -		/* Add a 200ms margin to account for event/command processing */ | ||||
| -		scan_timeout = arg->max_scan_time + ATH11K_MAC_SCAN_TIMEOUT_MSECS; | ||||
| +		scan_timeout = arg->max_scan_time; | ||||
|  	} | ||||
|   | ||||
| +	/* Add a 200ms margin to account for event/command processing */ | ||||
| +	scan_timeout += ATH11K_MAC_SCAN_TIMEOUT_MSECS; | ||||
| + | ||||
|  	ret = ath11k_start_scan(ar, arg); | ||||
|  	if (ret) { | ||||
|  		ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret); | ||||
| @@ -1,22 +0,0 @@ | ||||
| diff -Naur a/ath10k-5.7/mac.c b/ath10k-5.7/mac.c | ||||
| --- a/ath10k-5.7/mac.c	2021-06-09 16:30:17.793556032 -0400 | ||||
| +++ b/ath10k-5.7/mac.c	2021-06-09 17:38:08.587733979 -0400 | ||||
| @@ -7103,13 +7103,15 @@ | ||||
|  		scan_timeout = min_t(u32, arg.max_rest_time * | ||||
|  				(arg.n_channels - 1) + (req->duration + | ||||
|  				ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) * | ||||
| -				arg.n_channels, arg.max_scan_time + 200); | ||||
| +				arg.n_channels, arg.max_scan_time); | ||||
|   | ||||
|  	} else { | ||||
| -		/* Add a 200ms margin to account for event/command processing */ | ||||
| -		scan_timeout = arg.max_scan_time + 200; | ||||
| +		scan_timeout = arg.max_scan_time; | ||||
|  	} | ||||
|   | ||||
| +	/* Add a 200ms margin to account for event/command processing */ | ||||
| +	scan_timeout += 200; | ||||
| + | ||||
|  	ret = ath10k_start_scan(ar, &arg); | ||||
|  	if (ret) { | ||||
|  		ath10k_warn(ar, "failed to start hw scan: %d\n", ret); | ||||
| @@ -1,11 +0,0 @@ | ||||
| --- a/ath10k-5.7/mac.c	2021-07-06 11:12:56.022146449 -0700 | ||||
| +++ b/ath10k-5.7/mac.c	2021-07-06 19:37:52.352753693 -0700 | ||||
| @@ -8286,7 +8286,7 @@ | ||||
|  				  struct ieee80211_channel *channel) | ||||
|  { | ||||
|  	int ret; | ||||
| -	enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR; | ||||
| +	enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ; | ||||
|   | ||||
|  	lockdep_assert_held(&ar->conf_mutex); | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| --- a/ath10k-5.7/wmi.c | ||||
| +++ b/ath10k-5.7/wmi.c | ||||
| @@ -6347,16 +6347,18 @@ | ||||
|   | ||||
|  	survey = &ar->survey[idx]; | ||||
|   | ||||
| -	survey->noise     = noise_floor; | ||||
| -	survey->time      = div_u64(total, cc_freq_hz); | ||||
| -	survey->time_busy = div_u64(busy, cc_freq_hz); | ||||
| -	survey->time_rx   = div_u64(rx_bss, cc_freq_hz); | ||||
| -	survey->time_tx   = div_u64(tx, cc_freq_hz); | ||||
| -	survey->filled   |= (SURVEY_INFO_NOISE_DBM | | ||||
| -			     SURVEY_INFO_TIME | | ||||
| -			     SURVEY_INFO_TIME_BUSY | | ||||
| -			     SURVEY_INFO_TIME_RX | | ||||
| -			     SURVEY_INFO_TIME_TX); | ||||
| +	survey->noise       = noise_floor; | ||||
| +	survey->time        = div_u64(total, cc_freq_hz); | ||||
| +	survey->time_busy   = div_u64(busy, cc_freq_hz); | ||||
| +	survey->time_rx     = div_u64(rx, cc_freq_hz); | ||||
| +	survey->time_bss_rx = div_u64(rx_bss, cc_freq_hz); | ||||
| +	survey->time_tx     = div_u64(tx, cc_freq_hz); | ||||
| +	survey->filled     |= (SURVEY_INFO_NOISE_DBM | | ||||
| +			       SURVEY_INFO_TIME | | ||||
| +			       SURVEY_INFO_TIME_BUSY | | ||||
| +			       SURVEY_INFO_TIME_RX | | ||||
| +			       SURVEY_INFO_TIME_TX | | ||||
| +			       SURVEY_INFO_TIME_BSS_RX); | ||||
|  exit: | ||||
|  	spin_unlock_bh(&ar->data_lock); | ||||
|  	complete(&ar->bss_survey_done); | ||||
| @@ -47,15 +47,6 @@ hostapd_append_wpa_key_mgmt() { | ||||
| 			[ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-${auth_type_l}-SHA256" | ||||
| 			[ "${ieee80211ai:-0}" -gt 0 ] && append wpa_key_mgmt "FILS-SHA256" | ||||
| 		;; | ||||
| 		eap-only) | ||||
| 			append wpa_key_mgmt "WPA-EAP-SHA256" | ||||
| 			[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP" | ||||
| 		;; | ||||
| 		eap-transition) | ||||
| 			append wpa_key_mgmt "WPA-EAP" | ||||
| 			append wpa_key_mgmt "WPA-EAP-SHA256" | ||||
| 			[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP" | ||||
| 		;; | ||||
| 		eap192) | ||||
| 			append wpa_key_mgmt "WPA-EAP-SUITE-B-192" | ||||
| 			[ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-EAP-SHA256" | ||||
| @@ -304,17 +295,15 @@ hostapd_common_add_bss_config() { | ||||
| 	config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp | ||||
|  | ||||
| 	config_add_boolean interworking internet | ||||
| 	config_add_int access_network_type asra esr uesa venue_group venue_type \ | ||||
| 	config_add_int access_network_type asra esr uesa venue_group venue_type ipaddr_type_availability \ | ||||
| 		gas_address3 | ||||
| 	config_add_string hessid network_auth_type ipaddr_type_availability \ | ||||
| 	config_add_string hessid network_auth_type \ | ||||
| 		anqp_3gpp_cell_net anqp_elem domain_name qos_map_set hs20_t_c_server_url | ||||
|  | ||||
| 	config_add_int airtime_bss_weight airtime_bss_limit | ||||
| 	config_add_int rts_threshold | ||||
| 	config_add_array radius_auth_req_attr | ||||
| 	config_add_array radius_acct_req_attr | ||||
|  | ||||
| 	config_add_boolean multicast_to_unicast proxy_arp | ||||
| } | ||||
|  | ||||
| hostapd_set_vlan_file() { | ||||
| @@ -458,8 +447,7 @@ hostapd_set_bss_options() { | ||||
| 		bss_load_update_period chan_util_avg_period sae_require_mfp \ | ||||
| 		multi_ap multi_ap_backhaul_ssid multi_ap_backhaul_key \ | ||||
| 		airtime_bss_weight airtime_bss_limit \ | ||||
| 		rssi_reject_assoc_rssi rssi_ignore_probe_request rts_threshold \ | ||||
| 		proxy_arp multicast_to_unicast | ||||
| 		rssi_reject_assoc_rssi rssi_ignore_probe_request rts_threshold  | ||||
|  | ||||
| 	set_default isolate 0 | ||||
| 	set_default maxassoc 0 | ||||
| @@ -487,9 +475,6 @@ hostapd_set_bss_options() { | ||||
| 	set_default signal_poll_time 5 | ||||
| 	set_default signal_drop_reason 3 | ||||
| 	set_default signal_strikes 3 | ||||
| 	set_default proxy_arp 0 | ||||
| 	set_default multicast_to_unicast 0 | ||||
|  | ||||
|  | ||||
| 	append bss_conf "ctrl_interface=/var/run/hostapd" | ||||
| 	if [ "$isolate" -gt 0 ]; then | ||||
| @@ -523,9 +508,6 @@ hostapd_set_bss_options() { | ||||
| 	append bss_conf "signal_strikes=$signal_strikes" "$N" | ||||
| 	append bss_conf "signal_drop_reason=$signal_drop_reason" "$N" | ||||
|  | ||||
| 	[ -n "$proxy_arp" ] && append bss_conf "proxy_arp=$proxy_arp" "$N" | ||||
| 	[ -n "$multicast_to_unicast" ] && append bss_conf "multicast_to_unicast=$multicast_to_unicast" "$N" | ||||
|  | ||||
| 	[ "$tdls_prohibit" -gt 0 ] && append bss_conf "tdls_prohibit=$tdls_prohibit" "$N" | ||||
|  | ||||
| 	[ "$wpa" -gt 0 ] && { | ||||
| @@ -548,11 +530,11 @@ hostapd_set_bss_options() { | ||||
| 	} | ||||
|  | ||||
| 	case "$auth_type" in | ||||
| 		sae|owe|eap192|eap-eap192|eap-only) | ||||
| 		sae|owe|eap192|eap-eap192) | ||||
| 			set_default ieee80211w 2 | ||||
| 			set_default sae_require_mfp 1 | ||||
| 		;; | ||||
| 		psk-sae|eap-transition) | ||||
| 		psk-sae) | ||||
| 			set_default ieee80211w 1 | ||||
| 			set_default sae_require_mfp 1 | ||||
| 		;; | ||||
| @@ -594,7 +576,7 @@ hostapd_set_bss_options() { | ||||
| 			vlan_possible=1 | ||||
| 			wps_possible=1 | ||||
| 		;; | ||||
| 		eap|eap192|eap-eap192|eap-only|eap-transition) | ||||
| 		eap|eap192|eap-eap192) | ||||
| 			json_get_vars \ | ||||
| 				auth_server auth_secret auth_port \ | ||||
| 				dae_client dae_secret dae_port \ | ||||
| @@ -810,15 +792,7 @@ hostapd_set_bss_options() { | ||||
| 				json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout | ||||
| 				append bss_conf "ieee80211w=$ieee80211w" "$N" | ||||
| 				[ "$ieee80211w" -gt "0" ] && { | ||||
| 					case "$auth_type" in | ||||
| 						eap192) | ||||
| 							append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N" | ||||
| 							append bss_conf "group_cipher=GCMP-256" "$N" | ||||
| 						;; | ||||
| 						*) | ||||
| 							append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N" | ||||
| 						;; | ||||
| 					esac | ||||
| 					append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N" | ||||
| 					[ -n "$ieee80211w_max_timeout" ] && \ | ||||
| 						append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N" | ||||
| 					[ -n "$ieee80211w_retry_timeout" ] && \ | ||||
| @@ -898,15 +872,16 @@ hostapd_set_bss_options() { | ||||
| 	set_default access_network_type 0 | ||||
| 	set_default venue_group 0 | ||||
| 	set_default venue_type 0 | ||||
| 	set_default ipaddr_type_availability 0 | ||||
| 	set_default gas_address3 0 | ||||
| 	set_default hs20_deauth_req_timeout 60 | ||||
| 	if [ "$hs20" = "1" ]; then | ||||
| 		append bss_conf "hs20=1" "$N" | ||||
| 		append_hs20_icons | ||||
| 		[ -n "$disable_dgaf" ] && append bss_conf "disable_dgaf=$disable_dgaf" "$N" | ||||
| 		[ -n "$osen" ] && append bss_conf "osen=$osen" "$N" | ||||
| 		[ -n "$disable_dgaf"] && append bss_conf "disable_dgaf=$disable_dgaf" "$N" | ||||
| 		[ -n "$osen"] && append bss_conf "osen=$osen" "$N" | ||||
| 		[ "$anqp_domain_id" -gt 0 ] && append bss_conf "anqp_domain_id=$anqp_domain_id" "$N" | ||||
| 		[ -n "$hs20_deauth_req_timeout" ] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N" | ||||
| 		[ -n "$hs20_deauth_req_timeout"] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N" | ||||
| 		[ -n "$osu_ssid" ] && append bss_conf "osu_ssid=$osu_ssid" "$N" | ||||
| 		[ -n "$hs20_wan_metrics" ] && append bss_conf "hs20_wan_metrics=$hs20_wan_metrics" "$N" | ||||
| 		[ -n "$hs20_operating_class" ] && append bss_conf "hs20_operating_class=$hs20_operating_class" "$N" | ||||
| @@ -918,6 +893,7 @@ hostapd_set_bss_options() { | ||||
| 		json_for_each_item append_venue_url venue_url | ||||
| 		json_for_each_item append_nai_realm nai_realm | ||||
| 		json_for_each_item append_hs20_conn_capab hs20_conn_capab | ||||
| 		json_for_each_item append_hs20_oper_friendly_name hs20_oper_friendly_name | ||||
| 		json_for_each_item append_osu_provider osu_provider | ||||
| 		json_for_each_item append_operator_icon operator_icon | ||||
| 		[ -n "$interworking" ] && append bss_conf "interworking=$interworking" "$N" | ||||
| @@ -928,7 +904,7 @@ hostapd_set_bss_options() { | ||||
| 		[ "$uesa" -gt 0 ] && append bss_conf "uesa=$uesa" "$N" | ||||
| 		[ "$venue_group" -gt 0 ] && append bss_conf "venue_group=$venue_group" "$N" | ||||
| 		[ "$venue_type" -gt 0 ] && append bss_conf "venue_type=$venue_type" "$N" | ||||
| 		[ -n "$ipaddr_type_availability" ] && append bss_conf "ipaddr_type_availability=$ipaddr_type_availability" "$N" | ||||
| 		[ "$ipaddr_type_availability" -gt 0 ] && append bss_conf "ipaddr_type_availability=$ipaddr_type_availability" "$N" | ||||
| 		[ "$gas_address3" -gt 0 ] && append bss_conf "gas_address3=$gas_address3" "$N" | ||||
| 		[ -n "$hessid" ] && append bss_conf "hessid=$hessid" "$N" | ||||
| 		[ -n "$network_auth_type" ] && append bss_conf "network_auth_type=$network_auth_type" "$N" | ||||
|   | ||||
| @@ -1,28 +0,0 @@ | ||||
| Index: hostapd-2020-06-08-5a8b3662/src/ap/ieee802_11.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-06-08-5a8b3662.orig/src/ap/ieee802_11.c | ||||
| +++ hostapd-2020-06-08-5a8b3662/src/ap/ieee802_11.c | ||||
| @@ -3675,6 +3675,13 @@ static int add_associated_sta(struct hos | ||||
|  	 * drivers to accept the STA parameter configuration. Since this is | ||||
|  	 * after a new FT-over-DS exchange, a new TK has been derived, so key | ||||
|  	 * reinstallation is not a concern for this case. | ||||
| +	 * | ||||
| +	 * If the STA was associated and authorized earlier, but came for a new | ||||
| +	 * connection (!added_unassoc + !reassoc), remove the existing STA entry | ||||
| +	 * so that it can be re-added. This case is rarely seen when the AP could | ||||
| +	 * not receive the deauth/disassoc frame from the STA. And the STA comes | ||||
| +	 * back with new connection within a short period or before the inactive | ||||
| +	 * STA entry is removed from the list. | ||||
|  	 */ | ||||
|  	wpa_printf(MSG_DEBUG, "Add associated STA " MACSTR | ||||
|  		   " (added_unassoc=%d auth_alg=%u ft_over_ds=%u reassoc=%d authorized=%d ft_tk=%d fils_tk=%d)", | ||||
| @@ -3688,7 +3695,8 @@ static int add_associated_sta(struct hos | ||||
|  	    (!(sta->flags & WLAN_STA_AUTHORIZED) || | ||||
|  	     (reassoc && sta->ft_over_ds && sta->auth_alg == WLAN_AUTH_FT) || | ||||
|  	     (!wpa_auth_sta_ft_tk_already_set(sta->wpa_sm) && | ||||
| -	      !wpa_auth_sta_fils_tk_already_set(sta->wpa_sm)))) { | ||||
| +	      !wpa_auth_sta_fils_tk_already_set(sta->wpa_sm)) || | ||||
| +	     (!reassoc && (sta->flags & WLAN_STA_AUTHORIZED)))) { | ||||
|  		hostapd_drv_sta_remove(hapd, sta->addr); | ||||
|  		wpa_auth_sm_event(sta->wpa_sm, WPA_DRV_STA_REMOVED); | ||||
|  		set = 0; | ||||
| @@ -1,32 +0,0 @@ | ||||
| --- a/src/ap/ieee802_11.c | ||||
| +++ b/src/ap/ieee802_11.c | ||||
| @@ -4463,6 +4463,14 @@ static void handle_assoc(struct hostapd_ | ||||
|  			ieee802_11_set_beacons(hapd->iface); | ||||
|  	} | ||||
|   | ||||
| +	ubus_resp = hostapd_ubus_handle_event(hapd, &req); | ||||
| +	if (ubus_resp) { | ||||
| +		wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", | ||||
| +		       MAC2STR(mgmt->sa)); | ||||
| +		resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE; | ||||
| +		goto fail; | ||||
| +	} | ||||
| + | ||||
|  	update_ht_state(hapd, sta); | ||||
|   | ||||
|  	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, | ||||
| @@ -4568,14 +4576,6 @@ static void handle_assoc(struct hostapd_ | ||||
|  					    pos, left, rssi, omit_rsnxe); | ||||
|  	os_free(tmp); | ||||
|   | ||||
| -	ubus_resp = hostapd_ubus_handle_event(hapd, &req); | ||||
| -	if (ubus_resp) { | ||||
| -		wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", | ||||
| -		       MAC2STR(mgmt->sa)); | ||||
| -		resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE; | ||||
| -		goto fail; | ||||
| -	} | ||||
| - | ||||
|  	/* | ||||
|  	 * Remove the station in case tranmission of a success response fails | ||||
|  	 * (the STA was added associated to the driver) or if the station was | ||||
| @@ -1,65 +0,0 @@ | ||||
| Index: hostapd-2020-06-08-5a8b3662/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-06-08-5a8b3662.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-06-08-5a8b3662/src/ap/ubus.c | ||||
| @@ -1486,7 +1486,60 @@ static int hostapd_get_bss_list(struct u | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +enum { | ||||
| +	MOD_IFACE, | ||||
| +	MOD_PARAM, | ||||
| +	MOD_PARAM_VAL, | ||||
| +	__PARAM_MAX | ||||
| +}; | ||||
| + | ||||
| +static const struct blobmsg_policy mod_param_policy[__PARAM_MAX] = { | ||||
| +	[MOD_IFACE] = { "iface", BLOBMSG_TYPE_STRING }, | ||||
| +	[MOD_PARAM] = { "param", BLOBMSG_TYPE_STRING }, | ||||
| +	[MOD_PARAM_VAL] = { "param_val", BLOBMSG_TYPE_STRING }, | ||||
| +}; | ||||
| + | ||||
| +static int | ||||
| +hostapd_param_modify(struct ubus_context *ctx, struct ubus_object *obj, | ||||
| +		   struct ubus_request_data *req, const char *method, | ||||
| +		   struct blob_attr *msg) | ||||
| +{ | ||||
| +	struct blob_attr *tb[__PARAM_MAX]; | ||||
| +	struct hapd_interfaces *interfaces = NULL; | ||||
| +	struct hostapd_data *hapd_bss = NULL; | ||||
| +	struct hostapd_config *iconf = NULL; | ||||
| +	struct hostapd_iface *iface = NULL; | ||||
| +	size_t i = 0; | ||||
| + | ||||
| +	interfaces = get_hapd_interfaces_from_object(obj); | ||||
| +	blobmsg_parse(mod_param_policy, __PARAM_MAX, tb, blob_data(msg), | ||||
| +		      blob_len(msg)); | ||||
| +	if (!tb[MOD_PARAM] || !tb[MOD_IFACE] || !tb[MOD_PARAM_VAL]) | ||||
| +		return UBUS_STATUS_INVALID_ARGUMENT; | ||||
| + | ||||
| +	wpa_printf(MSG_DEBUG, "Modifyint %s=%s for %s", | ||||
| +		blobmsg_get_string(tb[MOD_PARAM]), | ||||
| +		blobmsg_get_string(tb[MOD_PARAM_VAL]), | ||||
| +		blobmsg_get_string(tb[MOD_IFACE])); | ||||
| +	 | ||||
| +	hapd_bss = hostapd_get_iface(interfaces, | ||||
| +				     blobmsg_get_string(tb[MOD_IFACE])); | ||||
| + | ||||
| +	if (hapd_bss) { | ||||
| +		iconf = hapd_bss->iconf; | ||||
| +		if (os_strcmp(blobmsg_get_string(tb[MOD_PARAM]), | ||||
| +			      "rssi_ignore_probe_request") == 0) { | ||||
| +			iconf->rssi_ignore_probe_request = atoi(blobmsg_get_string(tb[MOD_PARAM_VAL])); | ||||
| + | ||||
| +		} | ||||
| +	} | ||||
| + | ||||
| +	return UBUS_STATUS_OK; | ||||
| +} | ||||
| + | ||||
| + | ||||
|  static const struct ubus_method daemon_methods[] = { | ||||
| +	UBUS_METHOD("param_mod", hostapd_param_modify, mod_param_policy), | ||||
|  	UBUS_METHOD("config_add", hostapd_config_add, config_add_policy), | ||||
|  	UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy), | ||||
|  	UBUS_METHOD_NOARG("get_bss_list", hostapd_get_bss_list), | ||||
| @@ -1,14 +0,0 @@ | ||||
| Index: hostapd-2020-06-08-5a8b3662/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-06-08-5a8b3662.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-06-08-5a8b3662/src/ap/ubus.c | ||||
| @@ -1657,7 +1657,8 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  	session_id = sta->cl_session_id; | ||||
|   | ||||
|  	/* find by session id */ | ||||
| -	rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl); | ||||
| +	if (session_id) | ||||
| +		rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl); | ||||
|   | ||||
|  	/* prepare rec if not found */ | ||||
|  	if (!rec) { | ||||
| @@ -1,299 +0,0 @@ | ||||
| Index: hostapd-2020-06-08-5a8b3662/src/ap/ubus.c | ||||
| =================================================================== | ||||
| --- hostapd-2020-06-08-5a8b3662.orig/src/ap/ubus.c | ||||
| +++ hostapd-2020-06-08-5a8b3662/src/ap/ubus.c | ||||
| @@ -21,6 +21,7 @@ | ||||
|  #include "rrm.h" | ||||
|  #include "wnm_ap.h" | ||||
|  #include "taxonomy.h" | ||||
| +#include "common/hw_features_common.h" | ||||
|   | ||||
|  static struct ubus_context *ctx; | ||||
|  static struct blob_buf b; | ||||
| @@ -754,6 +755,208 @@ static int hostapd_get_chan_switch_event | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +#define HOSTAPD_DFS_CSA_DUR 1 | ||||
| +int csa_ch_id, csa_cf0_id, csa_cf1_id = 0; | ||||
| +int csa_bw = CHANWIDTH_USE_HT; | ||||
| +struct csa_settings css; | ||||
| + | ||||
| +struct hostapd_channel_data *freq_to_chan(struct hostapd_iface *iface, int freq) | ||||
| +{ | ||||
| +	struct hostapd_hw_modes *mode; | ||||
| +	struct hostapd_channel_data *chan; | ||||
| +	int i; | ||||
| + | ||||
| +	mode = iface->current_mode; | ||||
| +	if (mode == NULL || freq == 0) { | ||||
| +		wpa_printf(MSG_INFO, "%s: mode is NULL", __func__); | ||||
| +		return NULL; | ||||
| +	} | ||||
| + | ||||
| +	for (i = 0; i < iface->current_mode->num_channels; i++) { | ||||
| +		chan = &iface->current_mode->channels[i]; | ||||
| +		if (chan->freq == freq) { | ||||
| +			return chan; /* Channel found */ | ||||
| +		} | ||||
| +	} | ||||
| +	return NULL; | ||||
| +} | ||||
| + | ||||
| +void hostapd_dfs_csa_timeout(void *eloop_data, void *user_data) | ||||
| +{ | ||||
| +	struct hostapd_data *hapd = eloop_data; | ||||
| +	struct hostapd_iface *iface = hapd->iface; | ||||
| +	struct csa_settings *css = user_data; | ||||
| +	int ret = 0; | ||||
| + | ||||
| +	wpa_printf(MSG_DEBUG, "%s Stopping CSA in dfs ", __func__); | ||||
| + | ||||
| +	hapd->csa_in_progress = 0; | ||||
| + | ||||
| +	hostapd_disable_iface(iface); | ||||
| + | ||||
| +	iface->freq = css->freq_params.freq; | ||||
| +	iface->conf->channel = csa_ch_id; | ||||
| +	iface->conf->secondary_channel = css->freq_params.sec_channel_offset; | ||||
| +	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id); | ||||
| +	hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id); | ||||
| +	hostapd_set_oper_chwidth(iface->conf, csa_bw); | ||||
| +	iface->conf->ieee80211n = css->freq_params.ht_enabled; | ||||
| +	iface->conf->ieee80211ac = css->freq_params.vht_enabled; | ||||
| +	iface->conf->ieee80211ax = css->freq_params.he_enabled; | ||||
| +	wpa_printf(MSG_INFO, "%s: freq=%d chan=%d sec_ch=%d cf0=%d cf1=%d bw=%d 11n=%d, ac=%d, ax=%d", | ||||
| + 		   __func__, iface->freq, iface->conf->channel, | ||||
| +		   iface->conf->secondary_channel, csa_cf0_id, csa_cf1_id,  | ||||
| +		   css->freq_params.bandwidth, iface->conf->ieee80211n, | ||||
| +		   iface->conf->ieee80211ac, iface->conf->ieee80211ax); | ||||
| + | ||||
| +	ret = hostapd_enable_iface(iface); | ||||
| +	if (ret == 0) | ||||
| +		hostapd_ubus_handle_channel_switch_event(iface, | ||||
| +						HOSTAPD_UBUS_HIGH_INTERFERENCE, | ||||
| +						iface->freq); | ||||
| +  | ||||
| +} | ||||
| + | ||||
| +int hostapd_dfs_set_beacon_csa(struct hostapd_iface *iface, struct csa_settings *css) | ||||
| +{ | ||||
| +	struct hostapd_data *hapd = iface->bss[0]; | ||||
| +	struct hostapd_data *hapd_bss = NULL; | ||||
| +	struct csa_settings csa_settings; | ||||
| +	int secondary_channel = 0; | ||||
| +	u8 vht_oper_centr_freq_seg0_idx; | ||||
| +	u8 vht_oper_centr_freq_seg1_idx; | ||||
| +	int err = 0, i = 0; | ||||
| + | ||||
| +	if (hapd->csa_in_progress == 1) { | ||||
| +		wpa_printf(MSG_ERROR, "CSA in progress, cannot switch channel"); | ||||
| +		return -1; | ||||
| +	} | ||||
| + | ||||
| +	eloop_cancel_timeout(hostapd_dfs_csa_timeout, hapd, NULL); | ||||
| + | ||||
| +	/* Setup Beacon CSA request */ | ||||
| +	secondary_channel = iface->conf->secondary_channel; | ||||
| +	vht_oper_centr_freq_seg0_idx = | ||||
| +			iface->conf->vht_oper_centr_freq_seg0_idx; | ||||
| +	vht_oper_centr_freq_seg1_idx = | ||||
| +			iface->conf->vht_oper_centr_freq_seg1_idx; | ||||
| + | ||||
| +	os_memset(&csa_settings, 0, sizeof(csa_settings)); | ||||
| +	err = hostapd_set_freq_params(&csa_settings.freq_params, | ||||
| +				      iface->conf->hw_mode, | ||||
| +				      iface->freq, | ||||
| +				      iface->conf->channel, | ||||
| +				      iface->conf->enable_edmg, | ||||
| +				      iface->conf->edmg_channel, | ||||
| +				      iface->conf->ieee80211n, | ||||
| +				      iface->conf->ieee80211ac, | ||||
| +				      iface->conf->ieee80211ax, | ||||
| +				      secondary_channel, | ||||
| +				      hostapd_get_oper_chwidth(iface->conf), | ||||
| +				      vht_oper_centr_freq_seg0_idx, | ||||
| +				      vht_oper_centr_freq_seg1_idx, | ||||
| +				      iface->current_mode->vht_capab, | ||||
| +				      &iface->current_mode->he_capab[IEEE80211_MODE_AP]); | ||||
| +	if (err) { | ||||
| +		wpa_printf(MSG_ERROR, "DFS failed to calculate CSA freq params"); | ||||
| +		return -1; | ||||
| +	} | ||||
| + | ||||
| + | ||||
| +	if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { | ||||
| +		wpa_printf(MSG_ERROR, "CSA is not supported"); | ||||
| +		return -1; | ||||
| +	} | ||||
| + | ||||
| +	/* Set Beacon */ | ||||
| +	for (i = 0; i < hapd->iface->num_bss; i++) { | ||||
| +		hapd_bss = iface->bss[i]; | ||||
| +		hapd_bss->cs_freq_params = csa_settings.freq_params; | ||||
| +		hapd_bss->cs_count = css->cs_count; | ||||
| +		hapd_bss->cs_block_tx = css->block_tx; | ||||
| +		err = ieee802_11_set_beacon(hapd_bss); | ||||
| +		if (err) | ||||
| +			wpa_printf(MSG_ERROR, "CSA beacon set failed, changing channel without an Announcement"); | ||||
| +	} | ||||
| + | ||||
| +	hapd->csa_in_progress = 1; | ||||
| + | ||||
| +	/* Switch Channel after a timeout */ | ||||
| +	eloop_register_timeout(HOSTAPD_DFS_CSA_DUR, 0, | ||||
| +			       hostapd_dfs_csa_timeout, hapd, css); | ||||
| + | ||||
| +	return 0; | ||||
| +} | ||||
| + | ||||
| +int hostapd_switch_chan_dfs(struct hostapd_iface *iface, | ||||
| +			     struct csa_settings *css) | ||||
| +{ | ||||
| +	struct hostapd_channel_data *ch, *cf1, *cf2 = NULL; | ||||
| +	int res = 0; | ||||
| + | ||||
| +	if (iface == NULL) | ||||
| +		return -1; | ||||
| + | ||||
| +	/* Set channel id and center frequecies id */ | ||||
| +	if (css->freq_params.freq > 0) { | ||||
| +		ch = freq_to_chan(iface, css->freq_params.freq); | ||||
| +		csa_ch_id = ch->chan; | ||||
| +	} | ||||
| + | ||||
| +	if (css->freq_params.center_freq1 > 0) { | ||||
| +		csa_cf0_id = 36 + (css->freq_params.center_freq1 - 5180) / 5; | ||||
| +	} | ||||
| + | ||||
| +	if (css->freq_params.center_freq2 > 0) { | ||||
| +		csa_cf1_id = 36 + (css->freq_params.center_freq2 - 5180) / 5; | ||||
| +	} | ||||
| + | ||||
| +	wpa_printf(MSG_DEBUG, "%s freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds, ieee80211n=%d, ieee80211ac=%d, ieee80211ax=%d ", __func__, | ||||
| +		css->freq_params.freq, | ||||
| +		csa_ch_id, css->freq_params.sec_channel_offset, | ||||
| +		css->freq_params.bandwidth, csa_cf0_id, csa_cf1_id, | ||||
| +		iface->dfs_cac_ms / 1000, iface->conf->ieee80211n, | ||||
| +		iface->conf->ieee80211ac, iface->conf->ieee80211ax); | ||||
| + | ||||
| +	/* Set bandwidth */ | ||||
| +	switch (css->freq_params.bandwidth) { | ||||
| +	case 0: | ||||
| +	case 20: | ||||
| +	case 40: | ||||
| +		csa_bw = CHANWIDTH_USE_HT; | ||||
| +		break; | ||||
| +	case 80: | ||||
| +		if (css->freq_params.center_freq2) | ||||
| +			csa_bw = CHANWIDTH_80P80MHZ; | ||||
| +		else | ||||
| +			csa_bw = CHANWIDTH_80MHZ; | ||||
| +		break; | ||||
| +	case 160: | ||||
| +		csa_bw = CHANWIDTH_160MHZ; | ||||
| +		break; | ||||
| +	default: | ||||
| +		wpa_printf(MSG_WARNING, "Unknown CSA bandwidth: %d", | ||||
| +			   css->freq_params.bandwidth); | ||||
| +		break; | ||||
| +	} | ||||
| + | ||||
| +	/* Set new frequency info */ | ||||
| +	iface->freq = css->freq_params.freq; | ||||
| +	iface->conf->channel = csa_ch_id; | ||||
| +	iface->conf->secondary_channel = css->freq_params.sec_channel_offset; | ||||
| +	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id); | ||||
| +	hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id); | ||||
| +	hostapd_set_oper_chwidth(iface->conf, csa_bw); | ||||
| +	iface->conf->ieee80211n = css->freq_params.ht_enabled; | ||||
| +	iface->conf->ieee80211ac = css->freq_params.vht_enabled; | ||||
| +	iface->conf->ieee80211ax = css->freq_params.he_enabled; | ||||
| + | ||||
| +	/*Set beacon for CSA*/ | ||||
| +	hostapd_dfs_set_beacon_csa(iface, css); | ||||
| + | ||||
| +	return 0; | ||||
| +} | ||||
| + | ||||
|  static int | ||||
|  hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj, | ||||
|  		    struct ubus_request_data *req, const char *method, | ||||
| @@ -761,14 +964,19 @@ hostapd_switch_chan(struct ubus_context | ||||
|  { | ||||
|  	struct blob_attr *tb[__CSA_MAX]; | ||||
|  	struct hostapd_data *hapd = get_hapd_from_object(obj); | ||||
| -	struct csa_settings css; | ||||
| +	struct hostapd_iface *iface = hapd->iface; | ||||
| +	struct hostapd_channel_data *chan =NULL; | ||||
|  	int i; | ||||
| +	int freq = 0; | ||||
|   | ||||
|  	blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg)); | ||||
|   | ||||
|  	if (!tb[CSA_FREQ]) | ||||
|  		return UBUS_STATUS_INVALID_ARGUMENT; | ||||
|   | ||||
| +	freq = blobmsg_get_u32(tb[CSA_FREQ]); | ||||
| +	chan = freq_to_chan(iface, freq); | ||||
| + | ||||
|  	memset(&css, 0, sizeof(css)); | ||||
|  	css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]); | ||||
|   | ||||
| @@ -787,6 +995,20 @@ hostapd_switch_chan(struct ubus_context | ||||
|  	SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool); | ||||
|   | ||||
| +	wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__, | ||||
| +		css.freq_params.freq, | ||||
| +		chan->chan, css.freq_params.sec_channel_offset, | ||||
| +		css.freq_params.bandwidth, | ||||
| +		css.freq_params.center_freq1, | ||||
| +		css.freq_params.center_freq2); | ||||
| + | ||||
| +	if ((chan->flag & HOSTAPD_CHAN_RADAR) && | ||||
| +	    ((chan->flag & HOSTAPD_CHAN_DFS_MASK) | ||||
| +	     != HOSTAPD_CHAN_DFS_AVAILABLE)) { | ||||
| +		wpa_printf(MSG_INFO, "%s: DFS chan need CAC", __func__); | ||||
| +		hostapd_switch_chan_dfs(iface, &css); | ||||
| +		return UBUS_STATUS_OK; | ||||
| +	} | ||||
|   | ||||
|  	for (i = 0; i < hapd->iface->num_bss; i++) { | ||||
|  		if (hostapd_switch_channel(hapd->iface->bss[i], &css) != 0) | ||||
| @@ -1454,10 +1676,16 @@ void hostapd_ubus_free_bss(struct hostap | ||||
|  	} | ||||
|   | ||||
|  	free(name); | ||||
| -	for (size_t i = 0; i < bss_nr; i++) | ||||
| -		os_free(bss_lst[i]); | ||||
| -	free(bss_lst); | ||||
| -	bss_lst = NULL; | ||||
| + | ||||
| +	if (bss_lst != NULL) { | ||||
| +		for (size_t i = 0; i < bss_nr; i++) { | ||||
| +			os_free(bss_lst[i]); | ||||
| +			bss_lst[i] = NULL; | ||||
| +		} | ||||
| +		free(bss_lst); | ||||
| +		bss_lst = NULL; | ||||
| +		bss_nr = 0; | ||||
| +	} | ||||
|  } | ||||
|   | ||||
|  static int hostapd_get_bss_list(struct ubus_context *ctx, | ||||
| @@ -1477,9 +1705,11 @@ static int hostapd_get_bss_list(struct u | ||||
|  	a = blobmsg_open_array(&b_ev, "bss_list"); | ||||
|  	/* check bss list from hapd */ | ||||
|  	for (size_t i = 0; i < bss_nr; i++) { | ||||
| -		b = blobmsg_open_table(&b_ev, NULL); | ||||
| -		blobmsg_add_string(&b_ev, "name", bss_lst[i]); | ||||
| -		blobmsg_close_table(&b_ev, b); | ||||
| +		if (bss_lst[i] != NULL) { | ||||
| +			b = blobmsg_open_table(&b_ev, NULL); | ||||
| +			blobmsg_add_string(&b_ev, "name", bss_lst[i]); | ||||
| +			blobmsg_close_table(&b_ev, b); | ||||
| +		} | ||||
|  	} | ||||
|  	blobmsg_close_array(&b_ev, a); | ||||
|  	ubus_send_reply(ctx, req, b_ev.head); | ||||
| @@ -1,64 +0,0 @@ | ||||
| --- a/src/ap/ubus.c | ||||
| +++ b/src/ap/ubus.c | ||||
| @@ -530,6 +530,7 @@ enum { | ||||
|  	CSA_HT, | ||||
|  	CSA_VHT, | ||||
|  	CSA_BLOCK_TX, | ||||
| +	CSA_REASON, | ||||
|  	__CSA_MAX | ||||
|  }; | ||||
|   | ||||
| @@ -543,6 +544,7 @@ static const struct blobmsg_policy csa_p | ||||
|  	[CSA_HT] = { "ht", BLOBMSG_TYPE_BOOL }, | ||||
|  	[CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL }, | ||||
|  	[CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL }, | ||||
| +	[CSA_REASON] = { "reason", BLOBMSG_TYPE_INT32 }, | ||||
|  }; | ||||
|   | ||||
|  #ifdef NEED_AP_MLME | ||||
| @@ -810,7 +812,7 @@ void hostapd_dfs_csa_timeout(void *eloop | ||||
|  		   iface->conf->ieee80211ac, iface->conf->ieee80211ax); | ||||
|   | ||||
|  	ret = hostapd_enable_iface(iface); | ||||
| -	if (ret == 0) | ||||
| +	if (ret == 0 && css->reason == 0) | ||||
|  		hostapd_ubus_handle_channel_switch_event(iface, | ||||
|  						HOSTAPD_UBUS_HIGH_INTERFERENCE, | ||||
|  						iface->freq); | ||||
| @@ -994,6 +996,7 @@ hostapd_switch_chan(struct ubus_context | ||||
|  	SET_CSA_SETTING(CSA_HT, freq_params.ht_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool); | ||||
|  	SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool); | ||||
| +	SET_CSA_SETTING(CSA_REASON, reason, u32); | ||||
|   | ||||
|  	wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__, | ||||
|  		css.freq_params.freq, | ||||
| @@ -1015,7 +1018,9 @@ hostapd_switch_chan(struct ubus_context | ||||
|  			return UBUS_STATUS_NOT_SUPPORTED; | ||||
|  	} | ||||
|   | ||||
| -	hostapd_ubus_handle_channel_switch_event(hapd->iface,HOSTAPD_UBUS_HIGH_INTERFERENCE,  css.freq_params.freq); | ||||
| +	if (css.reason == 0) { | ||||
| +		hostapd_ubus_handle_channel_switch_event(hapd->iface, HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq); | ||||
| +	} | ||||
|   | ||||
|  	return UBUS_STATUS_OK; | ||||
|  #undef SET_CSA_SETTING | ||||
| --- a/src/drivers/driver.h | ||||
| +++ b/src/drivers/driver.h | ||||
| @@ -2291,6 +2291,7 @@ struct beacon_data { | ||||
|   * @freq_params: Next channel frequency parameter | ||||
|   * @beacon_csa: Beacon/probe resp/asooc resp info for CSA period | ||||
|   * @beacon_after: Next beacon/probe resp/asooc resp info | ||||
| + * @reason: The reason why we are switching the channel | ||||
|   * @counter_offset_beacon: Offset to the count field in beacon's tail | ||||
|   * @counter_offset_presp: Offset to the count field in probe resp. | ||||
|   */ | ||||
| @@ -2301,6 +2302,7 @@ struct csa_settings { | ||||
|  	struct hostapd_freq_params freq_params; | ||||
|  	struct beacon_data beacon_csa; | ||||
|  	struct beacon_data beacon_after; | ||||
| +	u32 reason; | ||||
|   | ||||
|  	u16 counter_offset_beacon[2]; | ||||
|  	u16 counter_offset_presp[2]; | ||||
| @@ -1,111 +0,0 @@ | ||||
| --- a/src/ap/ubus.c | ||||
| +++ b/src/ap/ubus.c | ||||
| @@ -578,6 +578,7 @@ static int hostapd_clear_session(struct | ||||
|  	{ | ||||
|  		if (session_id == rec->session_id) { | ||||
|  			/* dec counter and delete */ | ||||
| +			wpa_printf(MSG_INFO, "%s Deleting client session with session id %llu", __func__, session_id); | ||||
|  			cached_events_nr -= rec->rec_nr; | ||||
|  			avl_delete(&hapd->ubus.rt_events, &rec->avl); | ||||
|  			os_free(rec->records); | ||||
| @@ -631,6 +632,10 @@ static int hostapd_sessions(struct ubus_ | ||||
|  		/* messages for current session */ | ||||
|  		for (size_t i = 0; i < rec->rec_nr; i++) { | ||||
|  			c_rec = &rec->records[i]; | ||||
| +			if (c_rec->processed) { | ||||
| +				/* Record is already reported, continue */ | ||||
| +				continue; | ||||
| +			} | ||||
|  			/* check message type */ | ||||
|  			switch (c_rec->type) { | ||||
|  			/* ClientAuthEvent */ | ||||
| @@ -644,6 +649,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u32(&b_ev, "auth_status", p->auth_status); | ||||
|  				blobmsg_add_string(&b_ev, "ssid", p->ssid); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -663,6 +669,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u8(&b_ev, "using11v", p->using11v); | ||||
|  				blobmsg_add_string(&b_ev, "ssid", p->ssid); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -678,6 +685,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u32(&b_ev, "internal_rc", p->internal_rc); | ||||
|  				blobmsg_add_string(&b_ev, "ssid", p->ssid); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -691,6 +699,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_u64(&b_ev, "fdata_tx_up_ts_in_us", p->tx_ts.tv_sec * (uint64_t)1000000); | ||||
|  				blobmsg_add_u64(&b_ev, "fdata_rx_up_ts_in_us", p->rx_ts.tv_sec * (uint64_t)1000000); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -703,6 +712,7 @@ static int hostapd_sessions(struct ubus_ | ||||
|  				blobmsg_add_string(&b_ev, "sta_mac", p->sta_mac); | ||||
|  				blobmsg_add_string(&b_ev, "ip_address", p->ip_addr); | ||||
|  				blobmsg_close_table(&b_ev, t_msg); | ||||
| +				c_rec->processed = true; | ||||
|  				break; | ||||
|  			} | ||||
|   | ||||
| @@ -1911,6 +1921,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_AUTH; | ||||
|  		rp->u.auth.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|   | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
| @@ -1941,6 +1952,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_ASSOC; | ||||
|  		rp->u.assoc.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* frequency */ | ||||
| @@ -1985,6 +1997,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_DISASSOC; | ||||
|  		rp->u.disassoc.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* frequency */ | ||||
| @@ -2016,6 +2029,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_FDATA; | ||||
|  		rp->u.fdata.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* STA MAC */ | ||||
| @@ -2044,6 +2058,7 @@ int hostapd_ubus_handle_rt_event(struct | ||||
|  		struct client_session_record *rp = &rec->records[rec->rec_nr - 1]; | ||||
|  		rp->type = CST_IP; | ||||
|  		rp->u.ip.session_id = rec->session_id; | ||||
| +		rp->processed = false; | ||||
|  		/* timestamp */ | ||||
|  		rp->timestamp = timestamp; | ||||
|  		/* STA MAC */ | ||||
| --- a/src/ap/ubus.h | ||||
| +++ b/src/ap/ubus.h | ||||
| @@ -110,6 +110,7 @@ struct client_ip_event { | ||||
|  }; | ||||
|   | ||||
|  struct client_session_record { | ||||
| +	bool processed; | ||||
|  	int type; | ||||
|  	uint64_t timestamp; | ||||
|  	union { | ||||
| @@ -253,10 +253,6 @@ static void check_timer_handler(struct uloop_timeout *timeout) | ||||
| 		if (CheckIp && (MyIpAddr != CheckIp)) | ||||
| 		{ | ||||
| 			printf("IP address changed from %x to %x - restart APC election\n", MyIpAddr, CheckIp); | ||||
| 			system("/usr/opensync/bin/ovsh u APC_State dr_addr:=0.0.0.0 bdr_addr:=0.0.0.0 enabled:=false mode:=NC"); | ||||
| 			uloop_done(); | ||||
| 			ubus_done(); | ||||
| 			interap_rcv_close(); | ||||
| 			exit(0); | ||||
| 		} | ||||
| 		 | ||||
| @@ -270,9 +266,6 @@ static void check_timer_handler(struct uloop_timeout *timeout) | ||||
|  | ||||
| static void handle_signal(int signo) | ||||
| { | ||||
| 	uloop_done(); | ||||
| 	ubus_done(); | ||||
| 	interap_rcv_close(); | ||||
| 	system("/usr/opensync/bin/ovsh u APC_State dr_addr:=0.0.0.0 bdr_addr:=0.0.0.0 enabled:=false mode:=NC"); | ||||
| } | ||||
|  | ||||
| @@ -334,10 +327,8 @@ int main(int argc, char *const* argv) | ||||
| 	callback cb = receive_from_socket; | ||||
|  | ||||
| 	if (interap_recv(IAC_APC_ELECTION_PORT, cb, 1000, | ||||
| 			 NULL, NULL) < 0) { | ||||
| 			 NULL, NULL) < 0) | ||||
| 		printf("Error: Failed InterAP receive"); | ||||
| 		return 1; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	memset(Timers, 0, sizeof(Timers)); | ||||
| @@ -360,7 +351,6 @@ int main(int argc, char *const* argv) | ||||
| 	uloop_run(); | ||||
| 	uloop_done(); | ||||
| 	ubus_done(); | ||||
| 	interap_rcv_close(); | ||||
|  | ||||
| 	return(1); | ||||
| } | ||||
|   | ||||
| @@ -189,11 +189,8 @@ void apc_send_hello(struct apc_iface * ifa, int kind ) | ||||
| 			else | ||||
| 				ApcSpec.FloatIp = ApcSpecSaved.FloatIp; | ||||
| 		} | ||||
| 		else if (ApcSpec.IsApc == I_AM_BAPC ) | ||||
| 		else | ||||
| 		{ | ||||
| 			ifa->priority = 0x12; | ||||
| 		} | ||||
| 		else { | ||||
| 			ifa->priority = 0x11; | ||||
| 			if ((ApcSpecSaved.IsApc == I_AM_APC) || BackingUpRadius ) | ||||
| 			{ | ||||
|   | ||||
| @@ -168,7 +168,7 @@ void apc_iface_new( void ) | ||||
| 	ifa->priority = 0x11; | ||||
| 	ifa->drip = MyIpAddr; | ||||
| 	ifa->helloint = 4; | ||||
| 	ifa->deadint = 12; | ||||
| 	ifa->deadint = 16; | ||||
| 	ifa->waitint = 16; | ||||
| 	 | ||||
| 	ifa->type = APC_IT_BCAST; | ||||
|   | ||||
| @@ -482,17 +482,13 @@ static void inactivity_timer_hook(struct _timer * tmr) | ||||
| 			n_neigh += 1; | ||||
| 			//Radius stuff | ||||
| 			BackingUpRadius = 1; | ||||
| 			apc_ifa->priority = 0x33; | ||||
| 		} | ||||
| 		else | ||||
| 			apc_ifa->priority = 0x11; | ||||
|  | ||||
|  | ||||
| 		apc_ifa->drip = MyIpAddr; | ||||
| 		apc_ifa->priority = 0x11; | ||||
| 		apc_ifa->bdrip = 0; | ||||
| 		memset(&ApcSpec, 0, sizeof(struct apc_spec)); | ||||
| 		WaitingToReelect = 3; | ||||
|  | ||||
| 		WaitingToReelect = 12; | ||||
| 		return; | ||||
| 	} | ||||
| 	printf("Inactivity timer expired for nbr %x on %s", n->rid,  | ||||
|   | ||||
| @@ -14,16 +14,10 @@ | ||||
| struct ubus_context *ubus_ctx = NULL; | ||||
| static struct blob_buf b; | ||||
| static struct blob_buf nb; | ||||
| static const char *ubus_path; | ||||
| timer *notify_timer; | ||||
| extern struct apc_iface * apc_ifa; | ||||
| /* Mandatorily Notify APC_State period */ | ||||
| #define APC_NOTIFY_INTERVAL 10 | ||||
| /* Check if any change in APC State and notify period */ | ||||
| #define APC_NOTIFY_CHECK 1 | ||||
| static ip_addr old_drip; | ||||
| static ip_addr old_bdrip; | ||||
| static u8 old_state; | ||||
| static unsigned int ucount = 0; | ||||
| #define APC_NOTIFY_INTERVAL 30 | ||||
|  | ||||
| struct apc_state { | ||||
| 	char mode[4]; | ||||
| @@ -100,67 +94,35 @@ apc_info_handle(struct ubus_context *ctx, struct ubus_object *obj, | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static char apc_mode[APC_MAX_MODE][8] = {"DOWN", "LOOP", "WT", "PTP", "OR", "BDR", "DR"}; | ||||
| int apc_update_state(void) | ||||
| static char apc_mode[APC_MAX_MODE][8] = {"DOWN", "LOOP", "WAITING", "PTP", "OR", "BDR", "DR"}; | ||||
| void apc_update_state() | ||||
| { | ||||
| 	struct in_addr dr_addr; | ||||
| 	struct in_addr bdr_addr; | ||||
| 	ip_addr cur_drip; | ||||
| 	ip_addr cur_bdrip; | ||||
| 	u8 cur_state; | ||||
|  | ||||
| 	cur_drip = apc_ifa->drip; | ||||
| 	cur_bdrip = apc_ifa->bdrip; | ||||
| 	cur_state = apc_ifa->state; | ||||
| 	ucount++; | ||||
|  | ||||
| 	if (cur_drip == old_drip && | ||||
| 	    cur_bdrip == old_bdrip && | ||||
| 	    cur_state == old_state && ucount < APC_NOTIFY_INTERVAL) { | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	printf("APC State update %u", ucount); | ||||
| 	ucount = 0; | ||||
|  | ||||
| 	dr_addr.s_addr = htonl(cur_drip); | ||||
| 	bdr_addr.s_addr = htonl(cur_bdrip); | ||||
| 	dr_addr.s_addr = htonl(apc_ifa->drip); | ||||
| 	bdr_addr.s_addr = htonl(apc_ifa->bdrip); | ||||
|  | ||||
| 	state.enabled = true; | ||||
| 	if ((cur_state == APC_IS_DR) || | ||||
| 	    (cur_state == APC_IS_BACKUP) || | ||||
| 	    (cur_state == APC_IS_DROTHER)) { | ||||
| 	if ((apc_ifa->state == APC_IS_DR) || | ||||
| 	    (apc_ifa->state == APC_IS_BACKUP) || | ||||
| 	    (apc_ifa->state == APC_IS_DROTHER)) { | ||||
| 		snprintf(state.mode, sizeof(state.mode), "%s", | ||||
| 			 &apc_mode[cur_state][0]); | ||||
| 			 &apc_mode[apc_ifa->state][0]); | ||||
| 		snprintf(state.dr_addr, sizeof(state.dr_addr), | ||||
| 			 "%s", inet_ntoa(dr_addr)); | ||||
| 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), | ||||
| 			 "%s", inet_ntoa(bdr_addr)); | ||||
| 	} else if (apc_ifa->state == APC_IS_WAITING) { | ||||
| 		snprintf(state.mode, sizeof(state.mode), "%s", | ||||
| 			 &apc_mode[cur_state][0]); | ||||
| 		snprintf(state.dr_addr, sizeof(state.dr_addr), "0.0.0.0"); | ||||
| 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), "0.0.0.0"); | ||||
| 	} else { | ||||
| 	} | ||||
| 	else { | ||||
| 		snprintf(state.mode, sizeof(state.mode), "NC"); | ||||
| 		snprintf(state.dr_addr, sizeof(state.dr_addr), "0.0.0.0"); | ||||
| 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), "0.0.0.0"); | ||||
| 	} | ||||
|  | ||||
| 	old_drip = cur_drip; | ||||
| 	old_bdrip = cur_bdrip; | ||||
| 	old_state = cur_state; | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| void apc_send_notification(struct _timer * tmr) | ||||
| { | ||||
| 	int ustate = 0; | ||||
|  | ||||
| 	ustate = apc_update_state(); | ||||
| 	if(ustate != 0) | ||||
| 		return; | ||||
| 	apc_update_state(); | ||||
|  | ||||
| 	printf("APC send ubus notification\n"); | ||||
| 	blob_buf_init(&nb, 0); | ||||
| @@ -193,10 +155,10 @@ ubus_init(void) { | ||||
| #endif | ||||
| 	add_object(&apc_object); | ||||
| 	notify_timer = tm_new_set(apc_send_notification, NULL, | ||||
| 				  0, APC_NOTIFY_CHECK); | ||||
| 				  0, APC_NOTIFY_INTERVAL); | ||||
| 	if (notify_timer) { | ||||
| 		printf("APC Start state check and notify timer\n"); | ||||
| 		tm_start(notify_timer, APC_NOTIFY_CHECK); | ||||
| 		printf("APC Start notify timer\n"); | ||||
| 		tm_start(notify_timer, APC_NOTIFY_INTERVAL); | ||||
| 	} | ||||
|  | ||||
| 	ubus_ctx->connection_lost = ubus_connection_lost; | ||||
|   | ||||
| @@ -30,8 +30,5 @@ endef | ||||
| define Package/libinterapcomm/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/lib | ||||
| 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/libinterapcomm.so $(1)/usr/lib/ | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(INSTALL_BIN) ./files/interap.init $(1)/etc/init.d/interap | ||||
|  | ||||
| endef | ||||
| $(eval $(call BuildPackage,libinterapcomm)) | ||||
|   | ||||
| @@ -1,35 +0,0 @@ | ||||
| #!/bin/sh /etc/rc.common | ||||
|  | ||||
| START=12 | ||||
| STOP=12 | ||||
|  | ||||
| start() { | ||||
| 	apc=`cat /etc/config/firewall | grep Allow-APC` | ||||
| 	ucc=`cat /etc/config/firewall | grep Allow-UCC` | ||||
|  | ||||
| 	if [ -z "$apc" ]; then | ||||
| 		uci add firewall rule | ||||
| 		uci set firewall.@rule[-1].name='Allow-APC' | ||||
| 		uci set firewall.@rule[-1].src='wan' | ||||
| 		uci set firewall.@rule[-1].proto='udp' | ||||
| 		uci set firewall.@rule[-1].dst_port='50010' | ||||
| 		uci set firewall.@rule[-1].target='ACCEPT' | ||||
| 		uci set firewall.@rule[-1].family='ipv4' | ||||
| 		uci commit firewall | ||||
| 	fi | ||||
|  | ||||
| 	if [ -z "$ucc" ]; then | ||||
| 		uci add firewall rule | ||||
| 		uci set firewall.@rule[-1].name='Allow-UCC' | ||||
| 		uci set firewall.@rule[-1].src='wan' | ||||
| 		uci set firewall.@rule[-1].proto='udp' | ||||
| 		uci set firewall.@rule[-1].dst_port='50000' | ||||
| 		uci set firewall.@rule[-1].target='ACCEPT' | ||||
| 		uci set firewall.@rule[-1].family='ipv4' | ||||
| 		uci commit firewall | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| stop() { | ||||
| 	echo stop | ||||
| } | ||||
| @@ -5,7 +5,6 @@ int interap_send(unsigned short port, char *dst_ip, | ||||
| int interap_recv(unsigned short port, int (*recv_cb)(void *, ssize_t), | ||||
| 		 unsigned int len, struct ev_loop *loop, | ||||
| 		 ev_io *io); | ||||
| void interap_rcv_close(void); | ||||
|  | ||||
| typedef int (*callback)(void *, ssize_t); | ||||
| typedef struct recv_arg { | ||||
|   | ||||
| @@ -22,10 +22,8 @@ static void receive_data_uloop(struct uloop_fd *fd, unsigned int events) | ||||
| 	recv_data = malloc(ra.len); | ||||
| 	memset(recv_data, 0, ra.len); | ||||
| 	if ((recv_data_len = recvfrom(recv_sock, recv_data, ra.len, | ||||
| 				      0, NULL, 0)) < 0) { | ||||
| 				      0, NULL, 0)) < 0) | ||||
| 		printf("recvfrom() failed"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	ra.cb(recv_data, recv_data_len); | ||||
| 	free(recv_data); | ||||
| @@ -101,11 +99,6 @@ int interap_recv(unsigned short port, int (*recv_cb)(void *, ssize_t), | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| void interap_rcv_close(void) | ||||
| { | ||||
| 	close(recv_sock); | ||||
| } | ||||
|  | ||||
| int interap_send(unsigned short port, char *dst_ip, void *data, | ||||
| 		 unsigned int len) | ||||
| { | ||||
|   | ||||
| @@ -444,10 +444,6 @@ return view.extend({ | ||||
| 		o.datatype = 'ip4addr("nomask")'; | ||||
| 		o.depends('proto', 'static'); | ||||
|  | ||||
| 		o = s.option(form.Button, 'save', _('')); | ||||
| 		o.inputtitle = _('Save Settings'); | ||||
| 		o.onclick = ui.createHandlerFn(this, 'handleSettingsSave', m); | ||||
|  | ||||
| 		s = m.section(form.NamedSection, 'lan', 'lan', _('LAN')); | ||||
|  | ||||
| 		o = s.option(form.Value, 'addr', _('IP Address')); | ||||
| @@ -460,7 +456,7 @@ return view.extend({ | ||||
|  | ||||
| 		o = s.option(form.Button, 'save', _('')); | ||||
| 		o.inputtitle = _('Save Settings'); | ||||
| 		o.onclick = ui.createHandlerFn(this, 'handleLANSettingsSave', m); | ||||
| 		o.onclick = ui.createHandlerFn(this, 'handleSettingsSave', m); | ||||
|  | ||||
| 		s = m.section(form.NamedSection, 'maintenance', 'maintenance', _('System Maintenance')); | ||||
|  | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| @@ -1,12 +1,4 @@ | ||||
| /* latin */ | ||||
| @font-face { | ||||
| 	font-family: 'Montserrat'; | ||||
| 	font-style: normal; | ||||
| 	font-weight: 400; | ||||
| 	font-display: swap; | ||||
| 	src: url(Montserrat_latin.woff2) format('woff2'); | ||||
| 	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; | ||||
| } | ||||
| @import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap'); | ||||
|  | ||||
| :root { | ||||
| 	--main-bright-color: #1B465C; | ||||
|   | ||||
| @@ -52,6 +52,7 @@ define Package/opennds/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/lib/opennds | ||||
|  | ||||
| 	$(CP) ./files/lib/splash.css $(1)/etc/opennds/htdocs/ | ||||
| 	$(CP) ./files/lib/Tip.png $(1)/etc/opennds/htdocs/images/ | ||||
| 	$(CP) ./files/lib/opennds $(1)/etc/config/ | ||||
| 	$(CP) ./files/etc/init.d/opennds $(1)/etc/init.d/ | ||||
| 	$(CP) ./files/lib/login.sh $(1)/usr/lib/opennds/ | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								feeds/wlan-ap/opennds/files/lib/Tip.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/wlan-ap/opennds/files/lib/Tip.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 21 KiB | 
| @@ -1,17 +0,0 @@ | ||||
| #!/bin/sh | ||||
| # Finds the highest settings an AP can support for various settings when set to "auto" in config | ||||
|  | ||||
| find_auto_hwmode() { | ||||
| 	# This function finds the highest mode (hw_mode) that the AP can support | ||||
|  | ||||
| 	# Arguments | ||||
| 	device=$1 | ||||
|  | ||||
| 	mode='11n' | ||||
| 	iw phy "$device" info | grep -q 'VHT Capabilities*' && mode="11ac" | ||||
| 	iw phy "$device" info | grep -q 'HE.*Capabilities' && mode="11ax" | ||||
|  | ||||
| 	echo "$mode" | ||||
| } | ||||
|  | ||||
| find_auto_hwmode $1 | ||||
| @@ -1,7 +0,0 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| if="$(uci get network.wan.ifname)" | ||||
| [ "$(cat /sys/class/net/"${if}"/carrier)" = 0 ] && { | ||||
| 	return 0 | ||||
| } | ||||
| return 1 | ||||
| @@ -1,55 +0,0 @@ | ||||
| #! /bin/sh | ||||
|  | ||||
| usage() { | ||||
|    echo "Usage: ${0} <realm>" | ||||
|    exit 1 | ||||
| } | ||||
|  | ||||
| test -n "${1}" || usage | ||||
|  | ||||
| REALM="${1}" | ||||
| DIGCMD=$(command -v dig) | ||||
| PRINTCMD=$(command -v printf) | ||||
|  | ||||
| validate_host() { | ||||
|          echo ${@} | tr -d '\n\t\r' | grep -E '^[_0-9a-zA-Z][-._0-9a-zA-Z]*$' | ||||
| } | ||||
|  | ||||
| validate_port() { | ||||
|          echo ${@} | tr -d '\n\t\r' | grep -E '^[0-9]+$' | ||||
| } | ||||
|  | ||||
| srv_lookup() { | ||||
|    ${DIGCMD} +short srv $SRV_HOST | sort -n -k1 | | ||||
|    while read line ; do | ||||
|       set $line ; PORT=$(validate_port $3) ; HOST=$(validate_host $4) | ||||
|       if [ -n "${HOST}" ] && [ -n "${PORT}" ]; then  | ||||
|          $PRINTCMD "\thost ${HOST%.}:${PORT}\n" | ||||
|       fi | ||||
|    done | ||||
| } | ||||
|  | ||||
| naptr_lookup() { | ||||
|     ${DIGCMD} +short naptr ${REALM} | grep aaa+auth:radius.tls.tcp | sort -n -k1 | | ||||
|     while read line; do | ||||
|     set $line ; TYPE=$3 ; HOST=$6 | ||||
|     if [ "$TYPE" = "\"s\"" -o "$TYPE" = "\"S\"" ]; then | ||||
|         SRV_HOST=${HOST%.} | ||||
|         srv_lookup | ||||
|     fi | ||||
|     done | ||||
| } | ||||
|  | ||||
| if test -x "${DIGCMD}" ; then | ||||
|    SERVERS=$(naptr_lookup) | ||||
| else | ||||
|    echo "${0} requires \"dig\" command." | ||||
|    exit 1 | ||||
| fi | ||||
|  | ||||
| if test -n "${SERVERS}" ; then | ||||
|         $PRINTCMD "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}\n" | ||||
|         exit 0 | ||||
| fi | ||||
|  | ||||
| exit 10				# No server found. | ||||
| @@ -24,8 +24,7 @@ | ||||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||
| # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| # Get the most recent upgrade file available | ||||
| IMGFILE="$(ls -t1 ${1}.* | head -n 1)" | ||||
| IMGFILE="$(ls ${1}.*)" | ||||
|  | ||||
| if [ -z "$IMGFILE" ] || [ ! -f "$IMGFILE" ] ; then | ||||
|   echo | ||||
| @@ -35,14 +34,11 @@ fi | ||||
|  | ||||
| # Set the current version as inactive before the upgrade | ||||
| FW_VERSION=`sed -n 's/FW_IMAGE_ACTIVE:\(.*\)/\1/p' < /usr/opensync/.versions` | ||||
| FW_BACKUP=$(uci get system.tip.inactivefw) | ||||
| uci set system.tip.inactivefw="${FW_VERSION}" | ||||
| uci commit system | ||||
| uci commit | ||||
|  | ||||
| /sbin/sysupgrade $IMGFILE | ||||
| if [ "$?" != "0" ] ; then | ||||
|   uci set system.tip.inactivefw="${FW_BACKUP}" | ||||
|   uci commit system | ||||
|   echo "$0: Sysupgrade failed." | ||||
|   exit 1 | ||||
| fi | ||||
|   | ||||
| @@ -1,15 +0,0 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| if [ "$#" -ne 1 ]; then | ||||
|     echo "Illegal number of parameters" | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| action=$1 | ||||
|  | ||||
| [ "$action" = "enable" ] && [ ! -f /etc/ssh-flag ] && uci set firewall.lan_ssh_rule.target='REJECT' | ||||
| [ "$action" = "disable" ] && uci set firewall.lan_ssh_rule.target='ACCEPT' | ||||
| uci commit firewall | ||||
| /etc/init.d/firewall restart | ||||
|  | ||||
| exit 0 | ||||
| @@ -1,5 +0,0 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| #Blink AP's LED | ||||
| /usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_blink" value:="on" | ||||
|  | ||||
| @@ -1,5 +0,0 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| #Turnoff blinking of AP's LED | ||||
| /usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_off" value:="off" | ||||
|  | ||||
| @@ -40,9 +40,6 @@ else | ||||
|   redirector_addr=$1 | ||||
| fi | ||||
|  | ||||
| # Enable lan ssh accsess | ||||
| lan-ssh-firewall disable | ||||
|  | ||||
| echo "${redirector_addr}" > /usr/opensync/certs/redirector.txt | ||||
| /etc/init.d/uhttpd enable | ||||
| /etc/init.d/uhttpd start | ||||
|   | ||||
| @@ -13,21 +13,8 @@ hwmode=$(uci get wireless.${radio}.hwmode) | ||||
| bcn_rate=$(($(uci get wireless.${DEVICENAME}.bcn_rate)/10)) | ||||
| mcast_rate=$(uci get wireless.${DEVICENAME}.mcast_rate) | ||||
|  | ||||
| ATH10K_FILE="/sys/kernel/debug/ieee80211/${phy}/ath10k/set_rates" | ||||
| if [ -f "$ATH10K_FILE" ]; then | ||||
| # ath10k rate-codes: 0x43 1M, 0x42 2M, 0x41 5.5M, 0x40 11M, 0x3 6M, 0x7 9M, 0x2 12M, 0x6 18M, 0x1 24M, 0x5 36M, 0x0 48M, 0x4 54M, 0xFF default | ||||
|  | ||||
| 	rate_codes="1:0x43 2:0x42 5:0x41 11:0x40 6:0x3 9:0x7 12:0x2 18:0x6 24:0x1 36:0x5 48:0x0 54:0x4" | ||||
| 	SET_RATES_PATH=${ATH10K_FILE} | ||||
| fi | ||||
|  | ||||
| ATH11K_FILE="/sys/kernel/debug/ieee80211/${phy}/ath11k/set_rates" | ||||
| if [ -f "$ATH11K_FILE" ]; then | ||||
| # ath11k rate-codes: 0x10000103 1M, 0x10000102 2M, 0x10000101 5.5M, 0x10000100 11M, 0x10000003 6M, 0x10000007 9M, 0x10000002 12M, 0x10000006 18M, 0x10000001 24M, 0x10000005 36M, 0x10000000 48M, 0x10000004 54M | ||||
|  | ||||
| 	rate_codes="1:0x10000103 2:0x10000102 5:0x10000101 11:0x10000100 6:0x10000003 9:0x10000007 12:0x10000002 18:0x10000006 24:0x10000001 36:0x10000005 48:0x10000000 54:0x10000004" | ||||
| 	SET_RATES_PATH=${ATH11K_FILE} | ||||
| fi | ||||
| rate_codes="1:0x43 2:0x42 5:0x41 11:0x40 6:0x3 9:0x7 12:0x2 18:0x6 24:0x1 36:0x5 48:0x0 54:0x4" | ||||
|  | ||||
| # Default codes | ||||
| beacon_code=0xFF | ||||
| @@ -47,15 +34,5 @@ done | ||||
| # set rates | ||||
| logger -t hotplug "Set Tx rates for device ${DEVICENAME}" | ||||
| sleep 20 | ||||
|  | ||||
| [ "${beacon_code}" = "0xFF" ] || { | ||||
| 	echo "${DEVICENAME} beacon ${band} ${beacon_code}" > ${SET_RATES_PATH} | ||||
|  | ||||
| 	if [ -f "$ATH11K_FILE" ]; then | ||||
| 		echo "${DEVICENAME} mgmt ${band} ${beacon_code}" > ${SET_RATES_PATH} | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| [ "${mcast_code}" = "0xFF" ] || { | ||||
| 	echo "${DEVICENAME} mcast ${band} ${mcast_code}" > ${SET_RATES_PATH} | ||||
| } | ||||
| echo "${DEVICENAME} beacon ${band} ${beacon_code}" > /sys/kernel/debug/ieee80211/${phy}/ath10k/set_rates | ||||
| echo "${DEVICENAME} mcast ${band} ${mcast_code}" > /sys/kernel/debug/ieee80211/${phy}/ath10k/set_rates | ||||
|   | ||||
| @@ -1,10 +0,0 @@ | ||||
| /tmp/log/openvswitch/*.log { | ||||
|     daily | ||||
|     rotate 5 | ||||
|     size 1M | ||||
|     compress | ||||
|     delaycompress | ||||
|     dateext | ||||
|     dateformat -%s | ||||
|     notifempty | ||||
| } | ||||
| @@ -1,75 +0,0 @@ | ||||
| -----BEGIN CERTIFICATE----- | ||||
| MIIEcTCCA1mgAwIBAgIUJFhIMlIJHJ7hW4gEzZuLBUaWjNcwDQYJKoZIhvcNAQEL | ||||
| BQAwbDELMAkGA1UEBhMCVVMxJDAiBgNVBAoTG1RlbGVjb20gSW5mcmEgUHJvamVj | ||||
| dCwgSW5jLjEMMAoGA1UECxMDVElQMSkwJwYDVQQDEyBUZWxlY29tIEluZnJhIFBy | ||||
| b2plY3QgSXNzdWluZyBDQTAeFw0yMTA0MjUyMDMzNTRaFw0yNjA0MTMyMjM4NDZa | ||||
| MCMxITAfBgNVBAMTGGNhY2VydHMub25lLmRpZ2ljZXJ0LmNvbTCCASIwDQYJKoZI | ||||
| hvcNAQEBBQADggEPADCCAQoCggEBAJwKRHdkdEQkp32bNi9TdgN4FNRG0nRppguQ | ||||
| mdCysJHA6/SuyAXNwKSbENysjFrcBkfYTlALjvIMqSu4d26ix6Mv4HnVxLjDzapV | ||||
| TZhOhfxIbRQa3HNieNup2vMi8jJvgwLcK/4CwhBJsbEMkB5lbyL8UnCBxzW9GGbM | ||||
| IvurvDFkUDUpUmiFg47nTpjub79KME6NqK38DxKzlUHvJge1TKFM73kZ3YkfWExQ | ||||
| yRQPRiU5KxMi/Wkr30FOf/rMTx4XNacOgyTJvzcStGwrlr0iGr8eLC1/XVXoOQz3 | ||||
| 0lyOeUzTB+HPU1Z2JrbPW5PnGxcQ0f7v/3qkWV1B2wuvFcQk+D0CAwEAAaOCAVIw | ||||
| ggFOMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFIj2Mhdk10e46DeI+aEZKSSK8Hj+ | ||||
| MB8GA1UdIwQYMBaAFLMbVLjgR6s98ziA5Dzl/QBhbdHoMA4GA1UdDwEB/wQEAwIE | ||||
| 8DAWBgNVHSUBAf8EDDAKBggrBgEFBQcDAjCBhgYIKwYBBQUHAQEEejB4MCgGCCsG | ||||
| AQUFBzABhhxodHRwOi8vb2NzcC5vbmUuZGlnaWNlcnQuY29tMEwGCCsGAQUFBzAC | ||||
| hkBodHRwOi8vY2FjZXJ0cy5vbmUuZGlnaWNlcnQuY29tL1RlbGVjb21JbmZyYVBy | ||||
| b2plY3RJc3N1aW5nQ0EuY3J0ME0GA1UdHwRGMEQwQqBAoD6GPGh0dHA6Ly9jcmwu | ||||
| b25lLmRpZ2ljZXJ0LmNvbS9UZWxlY29tSW5mcmFQcm9qZWN0SXNzdWluZ0NBLmNy | ||||
| bDANBgkqhkiG9w0BAQsFAAOCAQEADlFwshNPkeI2Gl6ooIauZL9d+6k+RWa5RTle | ||||
| JWziYL23XVEBT11+dvp4IB9HwVw5dByl3XAfTd1r4qyncwgXQpc6j2X8e45E8izI | ||||
| z2S1zhLMe1bA2lOiZz/sdpbonvxIHdiISyQI7q3mWQsvNkpkbjivjxLAJTcGPmOS | ||||
| gc/95YL+2xqPV45XAnPcl5qkLThtmb57Xst1sLWiSS2fUId6HMVuCgZa5su+aAl9 | ||||
| iMXv9YfHcvyfwXBaOtoBlItyMGl60uy0E/Fr5uEhEWi53EIqhty6KQckQBB7wdjQ | ||||
| eiXNI5Ox5cf+TFdesuKPaoEn3WNpFL9PCA3S5nGegJlZQ4N9Eg== | ||||
| -----END CERTIFICATE----- | ||||
| -----BEGIN CERTIFICATE----- | ||||
| MIIEnDCCA4SgAwIBAgIUVpyCUx1MUeUwxg+7I1BvGFTz7HkwDQYJKoZIhvcNAQEL | ||||
| BQAwaTELMAkGA1UEBhMCVVMxJDAiBgNVBAoTG1RlbGVjb20gSW5mcmEgUHJvamVj | ||||
| dCwgSW5jLjEMMAoGA1UECxMDVElQMSYwJAYDVQQDEx1UZWxlY29tIEluZnJhIFBy | ||||
| b2plY3QgUm9vdCBDQTAeFw0yMTA0MTMyMjUxMjZaFw0yNjA0MTMyMjM4NDZaMGwx | ||||
| CzAJBgNVBAYTAlVTMSQwIgYDVQQKExtUZWxlY29tIEluZnJhIFByb2plY3QsIElu | ||||
| Yy4xDDAKBgNVBAsTA1RJUDEpMCcGA1UEAxMgVGVsZWNvbSBJbmZyYSBQcm9qZWN0 | ||||
| IElzc3VpbmcgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDtKBrq | ||||
| qd2aKVSk25KfL5xHu8X7/8rJrz3IvyPuVKWhk/N1zabot3suBcGaYNKjnRHxg78R | ||||
| yKwKzajKYWtiQFqztu24g16LQeAnoUxZnF6a0z3JkkRPsz14A2y8TUhdEe1tx+UU | ||||
| 4VGsk3n+FMmOQHL+79FO57zQC1LwylgfLSltrI6mF3jowVUQvnwzKhUzT87AJ6EO | ||||
| ndK/q0T/Bgi+aI39zfVOjJjsTJwghvrmYW3iarP1THSKxeib2s02bZKrvvHa5HL4 | ||||
| UI8+LvREpVZl4mzt1z6Nl344Y6f+UeJlYa/Ci0jJqaXJmyVnUbAz+c0i5JfwAVn3 | ||||
| YQzfC4eLnZCmdF8zAgMBAAGjggE3MIIBMzAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud | ||||
| DgQWBBSzG1S44EerPfM4gOQ85f0AYW3R6DAfBgNVHSMEGDAWgBQCRpZgebFT9qny | ||||
| 98WfIUDk6ZEB+jAOBgNVHQ8BAf8EBAMCAYYwgYMGCCsGAQUFBwEBBHcwdTAoBggr | ||||
| BgEFBQcwAYYcaHR0cDovL29jc3Aub25lLmRpZ2ljZXJ0LmNvbTBJBggrBgEFBQcw | ||||
| AoY9aHR0cDovL2NhY2VydHMub25lLmRpZ2ljZXJ0LmNvbS9UZWxlY29tSW5mcmFQ | ||||
| cm9qZWN0Um9vdENBLmNydDBKBgNVHR8EQzBBMD+gPaA7hjlodHRwOi8vY3JsLm9u | ||||
| ZS5kaWdpY2VydC5jb20vVGVsZWNvbUluZnJhUHJvamVjdFJvb3RDQS5jcmwwDQYJ | ||||
| KoZIhvcNAQELBQADggEBAFbz+K94bHIkBMJqps0dApniUmOn0pO6Q6cGh47UP/kX | ||||
| IiPIsnYgG+hqYD/qtsiqJhaWi0hixRWn38UmvZxMRk27aSTGE/TWx0JTC3qDGsSe | ||||
| XkUagumbSfmS0ZyiTwMPeGAjXwyzGorqZWeA95eKfImntMiOf3E7//GK0K7HpCx8 | ||||
| IPCnLZsZD2q/mLyBsduImFIRQJbLAhwIxpcd1qYJk+BlGFL+HtBpEbq6JxW2Xy+v | ||||
| DpNWc2WIsUTle0rTc9JNJrLX4ChUJmKqf8obKHap3Xh3//qw/jDB9pOAinA33FLJ | ||||
| EmCnwBvQr9mfNmPBGMYZVU8cPruDQJ57GjmmvdisbJY= | ||||
| -----END CERTIFICATE----- | ||||
| -----BEGIN CERTIFICATE----- | ||||
| MIIDojCCAoqgAwIBAgIUPVYBpqNbcLYygF6Mx+qxSWwQyFowDQYJKoZIhvcNAQEL | ||||
| BQAwaTELMAkGA1UEBhMCVVMxJDAiBgNVBAoTG1RlbGVjb20gSW5mcmEgUHJvamVj | ||||
| dCwgSW5jLjEMMAoGA1UECxMDVElQMSYwJAYDVQQDEx1UZWxlY29tIEluZnJhIFBy | ||||
| b2plY3QgUm9vdCBDQTAeFw0yMTA0MTMyMjQyNDRaFw0zMTA0MTMyMjM4NDZaMGkx | ||||
| CzAJBgNVBAYTAlVTMSQwIgYDVQQKExtUZWxlY29tIEluZnJhIFByb2plY3QsIElu | ||||
| Yy4xDDAKBgNVBAsTA1RJUDEmMCQGA1UEAxMdVGVsZWNvbSBJbmZyYSBQcm9qZWN0 | ||||
| IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIGCibwf5u | ||||
| AAwZ+1H8U0e3u2V+0d2gSctucoK86XwUmfe1V2a/qlCYZd29r80IuN1IIeB0naIm | ||||
| KnK/MzXW87clF6tFd1+HzEvmlY/W4KyIXalVCTEzirFSvBEG2oZpM0yC3AefytAO | ||||
| aOpA00LaM3xTfTqMKIRhJBuLy0I4ANUVG6ixVebbGuc78IodleqiLoWy2Q9QHyEO | ||||
| t/7hZndJhiVogh0PveRhho45EbsACu7ymDY+JhlIleevqwlE3iQoq0YcmYADHno6 | ||||
| Eq8vcwLpZFxihupUafkd1T3WJYQAJf9coCjBu2qIhNgrcrGD8R9fGswwNRzMRMpX | ||||
| 720+GjcDW3bJAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFAJG | ||||
| lmB5sVP2qfL3xZ8hQOTpkQH6MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF | ||||
| AAOCAQEAVjl9dm4epG9NUYnagT9sg7scVQEPfz3Lt6w1NXJXgD8mAUlK0jXmEyvM | ||||
| dCPD4514n+8+lM7US8fh+nxc7jO//LwK17Wm9FblgjNFR7+anv0Q99T9fP19DLlF | ||||
| PSNHL2emogy1bl1lLTAoj8nxg2wVKPDSHBGviQ5LR9fsWUIJDv9Bs5k0qWugWYSj | ||||
| 19S6qnHeskRDB8MqRLhKMG82oDVLerSnhD0P6HjySBHgTTU7/tYS/OZr1jI6MPbG | ||||
| L+/DtiR5fDVMNdBSGU89UNTi0wHY9+RFuNlIuvZC+x/swF0V9R5mN+ywquTPtDLA | ||||
| 5IOM7ItsRmen6u3qu+JXros54e4juQ== | ||||
| -----END CERTIFICATE----- | ||||
| @@ -2,7 +2,7 @@ Index: opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/interfaces/opensync.ovsschema | ||||
| +++ opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||
| @@ -9368,6 +9368,69 @@ | ||||
| @@ -9368,6 +9368,68 @@ | ||||
|              } | ||||
|         }, | ||||
|        "isRoot": true | ||||
| @@ -57,7 +57,6 @@ Index: opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||
| +                  "DR", | ||||
| +                  "BDR", | ||||
| +                  "OR", | ||||
| +                  "WT", | ||||
| +                  "NC" | ||||
| +                ] | ||||
| +              ] | ||||
| @@ -72,6 +71,63 @@ Index: opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||
|      } | ||||
|    } | ||||
|  } | ||||
| Index: opensync-2.0.5.0/platform/openwrt/src/lib/target/src/radio_ubus.c | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/platform/openwrt/src/lib/target/src/radio_ubus.c | ||||
| +++ opensync-2.0.5.0/platform/openwrt/src/lib/target/src/radio_ubus.c | ||||
| @@ -10,6 +10,7 @@ | ||||
|  extern struct ev_loop *wifihal_evloop; | ||||
|  static struct ubus_context *ubus; | ||||
|  extern struct ev_loop *wifihal_evloop; | ||||
| +extern void apc_state_set(struct blob_attr *msg); | ||||
|   | ||||
|  int hapd_rrm_enable(char *name, int neighbor, int beacon) | ||||
|  { | ||||
| @@ -179,6 +180,7 @@ radio_ubus_add_vif_cb(struct ubus_contex | ||||
|  	return UBUS_STATUS_OK; | ||||
|  } | ||||
|   | ||||
| + | ||||
|  static const struct ubus_method radio_ubus_methods[] = { | ||||
|          UBUS_METHOD("dbg_add_vif", radio_ubus_add_vif_cb, add_vif_policy), | ||||
|          UBUS_METHOD("dummy", radio_ubus_dummy_cb, dummy_policy), | ||||
| @@ -201,8 +203,36 @@ static void radio_ubus_connect(struct ub | ||||
|  	ubus_add_object(ubus, &radio_ubus_object); | ||||
|  } | ||||
|   | ||||
| +static int radio_ubus_notify(struct ubus_context *ctx, struct ubus_object *obj, | ||||
| +			     struct ubus_request_data *req, const char *method, | ||||
| +			     struct blob_attr *msg) | ||||
| +{ | ||||
| +	char *str; | ||||
| + | ||||
| +	str = blobmsg_format_json(msg, true); | ||||
| +	LOGD("ubus: Received ubus notify '%s': %s\n", method, str); | ||||
| +	free(str); | ||||
| + | ||||
| +	if (!strncmp(method, "apc", 3)) { | ||||
| +		LOGD("APC notification Received"); | ||||
| +		apc_state_set(msg); | ||||
| +	} | ||||
| + | ||||
| +	return 0; | ||||
| +} | ||||
| + | ||||
| + | ||||
| + | ||||
|  static struct ubus_instance ubus_instance = { | ||||
|  	.connect = radio_ubus_connect, | ||||
| +	.notify = radio_ubus_notify, | ||||
| +	.list = { | ||||
| +			{ | ||||
| +				.path = "apc", | ||||
| +			}, | ||||
| +		}, | ||||
| +	.len = 1, | ||||
| + | ||||
|  }; | ||||
|   | ||||
|  int radio_ubus_init(void) | ||||
| Index: opensync-2.0.5.0/src/lib/schema/inc/schema_consts.h | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/src/lib/schema/inc/schema_consts.h | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| --- a/interfaces/opensync.ovsschema | ||||
| +++ b/interfaces/opensync.ovsschema | ||||
| @@ -9493,6 +9493,146 @@ | ||||
| @@ -9439,6 +9439,110 @@ | ||||
|        }, | ||||
|        "isRoot": true, | ||||
|        "maxRows": 1 | ||||
| @@ -25,15 +25,6 @@ | ||||
| +                "max": 1 | ||||
| +              } | ||||
| +            }, | ||||
| +            "auto_discover": { | ||||
| +                "type": { | ||||
| +                "key": { | ||||
| +                  "type": "boolean" | ||||
| +                }, | ||||
| +                "min": 1, | ||||
| +                "max": 1 | ||||
| +              } | ||||
| +            }, | ||||
| +            "server": { | ||||
| +                "type": { | ||||
| +                "key": { | ||||
| @@ -61,33 +52,6 @@ | ||||
| +                "max": 1 | ||||
| +              } | ||||
| +            }, | ||||
| +            "acct_server": { | ||||
| +                "type": { | ||||
| +                "key": { | ||||
| +                  "type": "string" | ||||
| +                }, | ||||
| +                "min": 0, | ||||
| +                "max": 1 | ||||
| +              } | ||||
| +            }, | ||||
| +            "acct_port": { | ||||
| +              "type": { | ||||
| +                "key": { | ||||
| +                  "type": "integer" | ||||
| +                }, | ||||
| +                "min": 0, | ||||
| +                "max": 1 | ||||
| +              } | ||||
| +            }, | ||||
| +            "acct_secret": { | ||||
| +                "type": { | ||||
| +                "key": { | ||||
| +                  "type": "string" | ||||
| +                }, | ||||
| +                "min": 0, | ||||
| +                "max": 1 | ||||
| +              } | ||||
| +            }, | ||||
| +            "ca_cert": { | ||||
| +                "type": { | ||||
| +                    "key": { | ||||
|   | ||||
| @@ -1,13 +0,0 @@ | ||||
| Index: opensync-2.0.5.0/src/lib/schema/inc/schema_consts.h | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/src/lib/schema/inc/schema_consts.h | ||||
| +++ opensync-2.0.5.0/src/lib/schema/inc/schema_consts.h | ||||
| @@ -155,6 +155,8 @@ typedef enum { | ||||
|  #define SCHEMA_CONSTS_IEEE80211k	"ieee80211k" | ||||
|  #define SCHEMA_CONSTS_DYNAMIC_VLAN	"dynamic_vlan" | ||||
|  #define SCHEMA_CONSTS_RADPROXY	"radproxy" | ||||
| +#define SCHEMA_CONSTS_PROXY_ARP		"proxy_arp" | ||||
| +#define SCHEMA_CONSTS_MCAST_TO_UCAST	"mcast_to_ucast" | ||||
|   | ||||
|  /* radio Custom options */ | ||||
|  #define SCHEMA_CONSTS_LOCAL_PWR_CONSTRAINT "local_pwr_constraint" | ||||
| @@ -1,66 +0,0 @@ | ||||
| Index: opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/interfaces/opensync.ovsschema | ||||
| +++ opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||
| @@ -8982,6 +8982,61 @@ | ||||
|                      "min": 0, | ||||
|                      "max": 1 | ||||
|                  } | ||||
| +            }, | ||||
| +            "noise_floor_thresh": { | ||||
| +                "type": { | ||||
| +                    "key": { | ||||
| +                        "type": "integer", | ||||
| +                        "minInteger": -90, | ||||
| +                        "maxInteger": -10 | ||||
| +                    }, | ||||
| +                    "min": 0, | ||||
| +                    "max": 1 | ||||
| +                } | ||||
| +            }, | ||||
| +            "noise_floor_time": { | ||||
| +                "type": { | ||||
| +                    "key": { | ||||
| +                        "type": "integer", | ||||
| +                        "minInteger": 60, | ||||
| +                        "maxInteger": 600 | ||||
| +                    }, | ||||
| +                    "min": 0, | ||||
| +                    "max": 1 | ||||
| +                } | ||||
| +            }, | ||||
| +            "non_wifi_thresh": { | ||||
| +                "type": { | ||||
| +                    "key": { | ||||
| +                        "type": "integer", | ||||
| +                        "minInteger": 0, | ||||
| +                        "maxInteger": 100 | ||||
| +                    }, | ||||
| +                    "min": 0, | ||||
| +                    "max": 1 | ||||
| +                } | ||||
| +            }, | ||||
| +            "non_wifi_time": { | ||||
| +                "type": { | ||||
| +                    "key": { | ||||
| +                        "type": "integer", | ||||
| +                        "minInteger": 60, | ||||
| +                        "maxInteger": 600 | ||||
| +                    }, | ||||
| +                    "min": 0, | ||||
| +                    "max": 1 | ||||
| +                } | ||||
| +            }, | ||||
| +            "obss_hop_mode": { | ||||
| +                "type": { | ||||
| +                    "key": { | ||||
| +                        "type": "integer", | ||||
| +                        "minInteger": 1, | ||||
| +                        "maxInteger": 2 | ||||
| +                    }, | ||||
| +                    "min": 0, | ||||
| +                    "max": 1 | ||||
| +                } | ||||
|              } | ||||
|          }, | ||||
|          "isRoot": true | ||||
| @@ -1,12 +0,0 @@ | ||||
| --- a/interfaces/opensync.ovsschema | ||||
| +++ b/interfaces/opensync.ovsschema | ||||
| @@ -1357,7 +1357,8 @@ | ||||
|                    "11n", | ||||
|                    "11ab", | ||||
|                    "11ac", | ||||
| -                  "11ax" | ||||
| +                  "11ax", | ||||
| +                  "auto" | ||||
|                  ] | ||||
|                ] | ||||
|              }, | ||||
| @@ -1,19 +0,0 @@ | ||||
| --- a/interfaces/opensync.ovsschema | ||||
| +++ b/interfaces/opensync.ovsschema | ||||
| @@ -1880,7 +1880,15 @@ | ||||
|              "min": 0, | ||||
|              "max": "unlimited" | ||||
|            } | ||||
| -        } | ||||
| +        }, | ||||
| +        "channel_max_power": { | ||||
| +          "type": { | ||||
| +            "key": "integer", | ||||
| +            "value": "integer", | ||||
| +            "min": 0, | ||||
| +            "max": "unlimited" | ||||
| +          } | ||||
| +        } | ||||
|        }, | ||||
|        "isRoot": true, | ||||
|        "maxRows": 256 | ||||
| @@ -1,13 +0,0 @@ | ||||
| Index: opensync-2.0.5.0/src/lib/target/src/target_linux.c | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/src/lib/target/src/target_linux.c | ||||
| +++ opensync-2.0.5.0/src/lib/target/src/target_linux.c | ||||
| @@ -249,7 +249,7 @@ static bool linux_device_cpuutil_get(dpp | ||||
|          } | ||||
|   | ||||
|          /* Calculate percentage and round */ | ||||
| -        busy = (1.0 - ((double)diff.hz_idle / (double)hz_total_diff)) * 100.0; | ||||
| +       	busy = (100.0 - (((double)diff.hz_idle *100.0) / (double)hz_total_diff)); | ||||
|   | ||||
|          cpuutil->cpu_util = (uint32_t) (busy + 0.5); | ||||
|   | ||||
| @@ -1,16 +0,0 @@ | ||||
| Index: opensync-2.0.5.0/src/lib/datapipeline/inc/dpp_types.h | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/src/lib/datapipeline/inc/dpp_types.h | ||||
| +++ opensync-2.0.5.0/src/lib/datapipeline/inc/dpp_types.h | ||||
| @@ -148,10 +148,9 @@ typedef enum | ||||
|      RADIO_SCAN_TYPE_FULL, | ||||
|      RADIO_SCAN_TYPE_ONCHAN, | ||||
|      RADIO_SCAN_TYPE_OFFCHAN, | ||||
| +    RADIO_SCAN_MAX_TYPE_QTY | ||||
|  } radio_scan_type_t; | ||||
|   | ||||
| -#define RADIO_SCAN_MAX_TYPE_QTY       3 | ||||
| - | ||||
|  typedef enum | ||||
|  { | ||||
|      RADIO_QUEUE_TYPE_VI = 0, | ||||
| @@ -1,12 +0,0 @@ | ||||
| --- a/src/um/src/um_ovsdb.c | ||||
| +++ b/src/um/src/um_ovsdb.c | ||||
| @@ -356,7 +356,8 @@ static void callback_AWLAN_Node( | ||||
|                  //TODO Is there something that needs to be done here? | ||||
|              } | ||||
|   | ||||
| -            if(awlan_node->upgrade_timer_changed){ | ||||
| +            if(awlan_node->upgrade_timer_changed | ||||
| +                || ((awlan_node->firmware_url_changed) && (strlen(awlan_node->firmware_url) > 0))) { | ||||
|                  if (awlan_node->upgrade_timer > 0) | ||||
|                  { | ||||
|                      /* if there is active timer, stop it to set new value   */ | ||||
| @@ -1,32 +0,0 @@ | ||||
| --- a/src/um/inc/um.h | ||||
| +++ b/src/um/inc/um.h | ||||
| @@ -32,6 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI | ||||
|   | ||||
|  #define UM_STS_FW_DL_START     (10)    /* FW download started                      */ | ||||
|  #define UM_STS_FW_DL_END       (11)    /* FW download successfully completed       */ | ||||
| +#define UM_STS_RB_END          (12)    /* Reboot has been started                  */ | ||||
| +#define UM_STS_FR_END          (13)    /* Factory reset has been started           */ | ||||
|  #define UM_STS_FW_WR_START     (20)    /* FW write on alt partition started        */ | ||||
|  #define UM_STS_FW_WR_END       (21)    /* FW image write successfully completed    */ | ||||
|  #define UM_STS_FW_BC_START     (30)    /* Bootconfig partition update started      */ | ||||
| --- a/src/um/src/um_ovsdb.c | ||||
| +++ b/src/um/src/um_ovsdb.c | ||||
| @@ -248,8 +248,16 @@ static void cb_upg(const osp_upg_op_t op | ||||
|          case OSP_UPG_DL: | ||||
|              if (status == OSP_UPG_OK) | ||||
|              { | ||||
| -                LOG(INFO, "Download successfully completed"); | ||||
| -                ret_status = UM_STS_FW_DL_END; | ||||
| +                if (!strcmp(upg_url, "reboot")) { | ||||
| +                    LOG(INFO, "Reboot successfully initiated"); | ||||
| +                    ret_status = UM_STS_RB_END; | ||||
| +                } else if (!strcmp(upg_url, "factory"))  { | ||||
| +                    LOG(INFO, "Factory reset successfully initiated"); | ||||
| +                    ret_status = UM_STS_FR_END; | ||||
| +                } else { | ||||
| +                    LOG(INFO, "Download successfully completed"); | ||||
| +                    ret_status = UM_STS_FW_DL_END; | ||||
| +                } | ||||
|              } | ||||
|              else | ||||
|              { | ||||
| @@ -1,11 +0,0 @@ | ||||
| --- a/src/lib/ovsdb/src/ovsdb_table.c | ||||
| +++ b/src/lib/ovsdb/src/ovsdb_table.c | ||||
| @@ -560,7 +560,7 @@ void ovsdb_table_update_cb(ovsdb_update_ | ||||
|          return; | ||||
|      } | ||||
|   | ||||
| -    LOG(INFO, "MON upd: %s table: %s row: %s", typestr, table->table_name, mon_uuid ); | ||||
| +    LOG(TRACE, "MON upd: %s table: %s row: %s", typestr, table->table_name, mon_uuid ); | ||||
|   | ||||
|      if (LOG_SEVERITY_TRACE <= log_module_severity_get(MODULE_ID)) | ||||
|      { | ||||
| @@ -1,44 +0,0 @@ | ||||
| Index: opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c | ||||
| =================================================================== | ||||
| --- opensync-2.0.5.0.orig/src/sm/src/sm_scan_schedule.c | ||||
| +++ opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c | ||||
| @@ -155,6 +155,12 @@ clean: | ||||
|   | ||||
|      /* Remove processed context */ | ||||
|      ds_dlist_remove_head(&g_scan_ctx_list); | ||||
| +    LOG(DEBUG, "sm_scan_schedule_cb. Scan done. Deleting scan_ctx. %p. %s %s %d\n", | ||||
| +		scan_ctx, | ||||
| +		radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type), | ||||
| +		radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type), | ||||
| +		scan_ctx->scan_request.chan_list[0]); | ||||
| + | ||||
|      sm_scan_ctx_free(scan_ctx); | ||||
|      scan_ctx = NULL; | ||||
|   | ||||
| @@ -163,6 +169,13 @@ clean: | ||||
|      if (scan_ctx) | ||||
|      { | ||||
|          scan_status = true; | ||||
| + | ||||
| +	LOG(DEBUG, "sm_scan_schedule_cb. Schedule next scan request. %p. %s %s %d\n", | ||||
| +		scan_ctx, | ||||
| +		radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type), | ||||
| +		radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type), | ||||
| +		scan_ctx->scan_request.chan_list[0]); | ||||
| + | ||||
|          rc = | ||||
|              sm_scan_schedule_process ( | ||||
|                      scan_ctx); | ||||
| @@ -303,6 +316,12 @@ bool sm_scan_schedule( | ||||
|   | ||||
|      if (NULL == scan_in_progress) { | ||||
|          /* Trigger the scan and wait for results */ | ||||
| +	LOG(DEBUG, "sm_scan_schedule. Schedule scan request. %p. %s %s %d\n", | ||||
| +		scan_ctx, | ||||
| +		radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type), | ||||
| +		radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type), | ||||
| +		scan_ctx->scan_request.chan_list[0]); | ||||
| + | ||||
|          rc = | ||||
|              sm_scan_schedule_process( | ||||
|                      scan_ctx); | ||||
| @@ -40,20 +40,17 @@ start_service() { | ||||
|     echo "Checking Redirector" | ||||
|     redirector=$(uci get system.tip.redirector) | ||||
|     if [ -z "$redirector" ]; then | ||||
|         [[ -f /usr/opensync/certs/redirector.txt ]] && saved_redirector=$(cat /usr/opensync/certs/redirector.txt | tr -d '\r\n') | ||||
|         logger -t opensync "Contacting DigiCert for redirector address" | ||||
|         wlan_ap_redirector.sh | ||||
|         new_redirector=$(uci get system.tip.redirector) | ||||
|         if [ -z "$new_redirector" && -n "$saved_redirector" ]; then | ||||
|             logger -t opensync "No response from DigiCert, using saved redirector address ${saved_redirector}" | ||||
|             wlan_ap_redirector.sh ${saved_redirector} | ||||
|         [[ -f /usr/opensync/certs/redirector.txt ]] && redirector=$(cat /usr/opensync/certs/redirector.txt | tr -d '\r\n') | ||||
|         if [ -z "$redirector" ]; then | ||||
|             logger -t opensync "Contacting DigiCert for redirector address" | ||||
|             wlan_ap_redirector.sh | ||||
|         else | ||||
|             logger -t opensync "DigiCert returned redirector address ${new_redirector}" | ||||
|             logger -t opensync "Restoring redirector ${redirector} after factory reset" | ||||
|             wlan_ap_redirector.sh ${redirector} | ||||
|         fi | ||||
|     else | ||||
|         logger -t opensync "Using existing redirector address ${redirector}" | ||||
|         [[ -f /usr/opensync/certs/redirector.txt ]] || echo "${redirector}" > /usr/opensync/certs/redirector.txt | ||||
|     fi | ||||
|     [[ -f /usr/opensync/certs/redirector.txt ]] || echo "${redirector}" > /usr/opensync/certs/redirector.txt | ||||
|   | ||||
|     echo "Starting OpenSync" | ||||
|     procd_set_param command ${PROG} | ||||
|     procd_close_instance | ||||
|   | ||||
| @@ -215,7 +215,6 @@ pid_t cmd_handler_tcpdump_wifi(struct task *task) | ||||
| 	char *argv[] = { "/usr/sbin/tcpdump", "-c", "1000", "-G", duration, "-W", "1", "-w", pcap, "-i", phy, NULL }; | ||||
| 	char iw[128]; | ||||
| 	pid_t pid; | ||||
| 	int ret = 0; | ||||
|  | ||||
| 	task->arg = SCHEMA_KEY_VAL(task->conf.payload, "wifi"); | ||||
| 	if (!task->arg) { | ||||
| @@ -226,23 +225,15 @@ pid_t cmd_handler_tcpdump_wifi(struct task *task) | ||||
|  | ||||
| 	blob_buf_init(&b, 0); | ||||
| 	uci = uci_alloc_context(); | ||||
|  | ||||
| 	ret = uci_load(uci, "wireless", &p); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		uci_free_context(uci); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	uci_load(uci, "wireless", &p); | ||||
| 	s = uci_lookup_section(uci, p, task->arg); | ||||
| 	if (!s) { | ||||
|         if (!s) { | ||||
| 		task_status(task, TASK_FAILED, "unknown wifi"); | ||||
| 		uci_unload(uci, p); | ||||
| 		uci_free_context(uci); | ||||
| 		return -1; | ||||
|                 return -1; | ||||
| 	} | ||||
|  | ||||
| 	uci_to_blob(&b, s, &phy_param); | ||||
| 	uci_unload(uci, p); | ||||
|         uci_to_blob(&b, s, &phy_param); | ||||
| 	uci_free_context(uci); | ||||
|  | ||||
| 	blobmsg_parse(phy_policy, __PHY_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | ||||
|   | ||||
| @@ -1,10 +1,6 @@ | ||||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
|  | ||||
| #include <string.h> | ||||
| #include <glob.h> | ||||
| #include <linux/limits.h> | ||||
| #include <libgen.h> | ||||
| #include <stdio.h> | ||||
| #include <libubox/blobmsg_json.h> | ||||
|  | ||||
| #include "uci.h" | ||||
| #include "command.h" | ||||
| @@ -92,14 +88,9 @@ static void syslog_state(int config) | ||||
| 	struct uci_element *e = NULL; | ||||
| 	struct uci_section *s = NULL; | ||||
| 	char val[128]; | ||||
| 	int ret = 0; | ||||
|  | ||||
| 	blob_buf_init(&b, 0); | ||||
| 	ret = uci_load(uci, "system", &system); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		return; | ||||
| 	} | ||||
| 	uci_load(uci, "system", &system); | ||||
| 	uci_foreach_element(&system->sections, e) { | ||||
| 		s = uci_to_section(e); | ||||
| 		if (!strcmp(s->type, "system")) | ||||
| @@ -160,6 +151,7 @@ static void syslog_handler(int type, | ||||
| 	blob_to_uci_section(uci, "system", "@system[-1]", "system", | ||||
| 			    b.head, &log_param, NULL); | ||||
| 	uci_commit_all(uci); | ||||
| 	system("/sbin/reload_config"); | ||||
| 	if (del) | ||||
| 		node_state_del("syslog"); | ||||
| 	else | ||||
| @@ -187,20 +179,14 @@ static void ntp_state(int config) | ||||
|         struct uci_section *s; | ||||
| 	struct blob_attr *cur = NULL; | ||||
| 	char val[128] = {}; | ||||
| 	int first = 1, rem = 0, ret = 0; | ||||
| 	int first = 1, rem = 0; | ||||
|  | ||||
| 	blob_buf_init(&b, 0); | ||||
| 	ret = uci_load(uci, "system", &p); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		return; | ||||
| 	} | ||||
| 	uci_load(uci, "system", &p); | ||||
|  | ||||
| 	s = uci_lookup_section(uci, p, "ntp"); | ||||
| 	if (!s) { | ||||
| 		uci_unload(uci, p); | ||||
| 	if (!s) | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	uci_to_blob(&b, s, &ntp_param); | ||||
| 	blobmsg_parse(ntp_policy, __NTP_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | ||||
| @@ -252,205 +238,10 @@ static void ntp_handler(int type, | ||||
| 	blob_to_uci_section(uci, "system", "ntp", "timeserver", | ||||
| 			    b.head, &ntp_param, NULL); | ||||
| 	uci_commit_all(uci); | ||||
| 	system("/sbin/reload_config"); | ||||
| 	ntp_state(0); | ||||
| } | ||||
|  | ||||
| enum { | ||||
| 	LED_ATTR_SYSFS, | ||||
| 	LED_ATTR_TRIGGER, | ||||
| 	LED_ATTR_DELAYON, | ||||
| 	LED_ATTR_DELAYOFF, | ||||
| 	LED_ATTR_VALUE, | ||||
| 	LED_ATTR_KEY, | ||||
| 	__LED_ATTR_MAX, | ||||
| }; | ||||
|  | ||||
| static const struct blobmsg_policy led_policy[__LED_ATTR_MAX] = { | ||||
| 	[LED_ATTR_SYSFS] = { .name = "sysfs", .type = BLOBMSG_TYPE_STRING }, | ||||
| 	[LED_ATTR_TRIGGER] = { .name = "trigger", .type = BLOBMSG_TYPE_STRING }, | ||||
| 	[LED_ATTR_DELAYON] = { .name = "delayon", .type = BLOBMSG_TYPE_STRING}, | ||||
| 	[LED_ATTR_DELAYOFF] = { .name = "delayoff", .type = BLOBMSG_TYPE_STRING}, | ||||
| 	[LED_ATTR_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING}, | ||||
| 	[LED_ATTR_KEY] = { .name = "key", .type = BLOBMSG_TYPE_STRING}, | ||||
| }; | ||||
|  | ||||
| static const struct uci_blob_param_list led_param = { | ||||
| 	.n_params = __LED_ATTR_MAX, | ||||
| 	.params = led_policy, | ||||
| }; | ||||
|  | ||||
| static char led[][8]={"lan", "wan", "eth", "wifi2", "wifi5", "wlan2g", "wlan5g", "power","eth0", | ||||
| 			  "status", "eth1", "wifi2g", "eth2", "wifi5g", "plug", "world", "usb", "linksys", "wps", "bt"}; | ||||
|  | ||||
| static struct blob_buf b; | ||||
| #define DEFAULT_BOARD_JSON		"/etc/board.json" | ||||
| static struct blob_attr *board_info; | ||||
|  | ||||
| static void led_state(int config) | ||||
| { | ||||
| 	struct blob_attr *tb[__LED_ATTR_MAX] = { }; | ||||
| 	struct uci_package *system; | ||||
| 	struct uci_section *s = NULL; | ||||
| 	struct uci_element *e = NULL; | ||||
| 	char val[8]; | ||||
| 	char key[16]; | ||||
| 	blob_buf_init(&b, 0); | ||||
| 	uci_load(uci, "system", &system); | ||||
| 	uci_foreach_element(&system->sections, e) { | ||||
| 		s = uci_to_section(e); | ||||
| 		if (!strcmp(s->type, "led")) { | ||||
| 			uci_to_blob(&b, s, &led_param); | ||||
| 			blobmsg_parse(led_policy, __LED_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | ||||
| 			if(tb[LED_ATTR_KEY]) | ||||
| 				strcpy(key, blobmsg_get_string(tb[LED_ATTR_KEY])); | ||||
| 			if(tb[LED_ATTR_VALUE]) | ||||
| 				strcpy(val, blobmsg_get_string(tb[LED_ATTR_VALUE])); | ||||
| 			break; | ||||
| 		} | ||||
| 		s = NULL; | ||||
| 	} | ||||
| 	if (!s) | ||||
| 		goto out; | ||||
| 	if (config) | ||||
| 		node_config_set("led", key, val); | ||||
| 	node_state_set("led", key, val); | ||||
| out: | ||||
| 	uci_unload(uci, system); | ||||
| } | ||||
|  | ||||
| int available_led_check(char *led_name) | ||||
| { | ||||
| 	unsigned int i; | ||||
| 	for (i = 0; i < ARRAY_SIZE(led); i++) { | ||||
| 		if(!strcmp(led_name,led[i])) { | ||||
| 			return 1; | ||||
| 		} | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static void set_led_config(char *trigger_name, char *key, char* value, char* led_string, char* led_section) | ||||
| { | ||||
| 	blob_buf_init(&b, 0); | ||||
| 	blobmsg_add_string(&b, "sysfs", led_string); | ||||
| 	blobmsg_add_string(&b, "trigger", trigger_name); | ||||
| 	blobmsg_add_string(&b, "value", value); | ||||
| 	blobmsg_add_string(&b, "key", key); | ||||
| 	blob_to_uci_section(uci, "system", led_section, "led", b.head, &led_param, NULL); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| static struct blob_attr* config_find_blobmsg_attr(struct blob_attr *attr, const char *name, int type) | ||||
| { | ||||
| 	struct blobmsg_policy policy = { .name = name, .type = type }; | ||||
| 	struct blob_attr *cur; | ||||
|  | ||||
| 	blobmsg_parse(&policy, 1, &cur, blobmsg_data(attr), blobmsg_len(attr)); | ||||
|  | ||||
| 	return cur; | ||||
| } | ||||
|  | ||||
| static char* get_phy_map_led_info(char* wifi) | ||||
| { | ||||
| 	struct blob_attr *cur; | ||||
|  | ||||
| 	blob_buf_init(&b, 0); | ||||
|  | ||||
| 	if (!blobmsg_add_json_from_file(&b, DEFAULT_BOARD_JSON)) { | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	if (board_info != NULL) { | ||||
| 		free(board_info); | ||||
| 		board_info = NULL; | ||||
| 	} | ||||
| 	cur = config_find_blobmsg_attr(b.head, "led", BLOBMSG_TYPE_TABLE); | ||||
| 	if (!cur) { | ||||
| 		LOGD("Failed to find led objet in board.json file"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	board_info = blob_memdup(cur); | ||||
| 	if (!board_info) | ||||
| 		return NULL; | ||||
| 	cur = config_find_blobmsg_attr(board_info, wifi, BLOBMSG_TYPE_TABLE); | ||||
| 	if (!cur) { | ||||
| 		LOGD("Failed to find %s objet in board.json file", wifi); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	cur = config_find_blobmsg_attr(cur, "trigger", BLOBMSG_TYPE_STRING); | ||||
| 	if (!cur) { | ||||
| 		LOGD("Failed to find trigger in board.json file"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	return blobmsg_get_string(cur); | ||||
| } | ||||
|  | ||||
| static void get_led_info_from_sys_config(char* key, char* value) | ||||
| { | ||||
| 	char led_string[32]; | ||||
| 	char ap_name[16]; | ||||
| 	char color[16]; | ||||
| 	char led_section[16]; | ||||
| 	char led_name_final[24]; | ||||
| 	char sys[8]; | ||||
| 	char class[8]; | ||||
| 	char leds[8]; | ||||
| 	char sysled[PATH_MAX]; | ||||
| 	glob_t gl; | ||||
| 	unsigned int i; | ||||
|  | ||||
| 	if (glob("/sys/class/leds/*", GLOB_NOSORT, NULL, &gl)) | ||||
| 		return; | ||||
| 	for (i = 0; i < gl.gl_pathc; i++) { | ||||
| 		strncpy(sysled, gl.gl_pathv[i], sizeof(sysled)); | ||||
| 		sscanf(sysled,"/%[^/]/%[^/]/%[^/]/%s", sys, class, leds, led_string); | ||||
| 		sscanf(led_string,"%[^:]:%[^:]:%s",ap_name, color, led_section); | ||||
| 		if(available_led_check(led_section)) { | ||||
| 			snprintf(led_name_final, sizeof(led_name_final), "%s%s","led_",led_section); | ||||
| 			if(!strcmp(key, "led_blink")) { | ||||
| 				set_led_config("heartbeat", key, value, led_string, led_name_final); | ||||
| 			} | ||||
| 			else if(!strcmp(key, "led_off")) { | ||||
| 				set_led_config("none", key, value, led_string, led_name_final); | ||||
| 			} | ||||
| 			else { | ||||
| 				if(!strcmp(led_section, "wifi2g") || !strcmp(led_section, "wifi5g")) { | ||||
| 					set_led_config(get_phy_map_led_info(led_section), key, value, led_string, led_name_final); | ||||
| 				} | ||||
| 				else | ||||
| 					set_led_config("none", key, value, led_string, led_name_final); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	globfree(&gl); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| static void led_handler(int type, | ||||
| 			struct schema_Node_Config *old, | ||||
| 			struct schema_Node_Config *conf) | ||||
| { | ||||
| 	int del=1; | ||||
| 	switch (type) { | ||||
| 	case OVSDB_UPDATE_NEW: | ||||
| 	case OVSDB_UPDATE_MODIFY: | ||||
| 		if (!strcmp(conf->key, "led_blink") || !strcmp(conf->key, "led_off")) { | ||||
| 			get_led_info_from_sys_config(conf->key, conf->value); | ||||
| 			del=0; | ||||
| 		} | ||||
| 		break; | ||||
| 	case OVSDB_UPDATE_DEL: | ||||
| 		get_led_info_from_sys_config("led_state", "default"); | ||||
| 		break; | ||||
| 	default: | ||||
| 		LOGD("Invalid Command"); | ||||
| 	} | ||||
| 	uci_commit_all(uci); | ||||
| 	if(del) | ||||
| 		node_state_del("led"); | ||||
| 	else | ||||
| 		led_state(0); | ||||
| } | ||||
|  | ||||
| static struct node_handler { | ||||
| 	char *name; | ||||
| 	void (*handler)(int type, | ||||
| @@ -468,11 +259,6 @@ static struct node_handler { | ||||
| 		.handler = ntp_handler, | ||||
| 		.state = ntp_state, | ||||
| 	}, | ||||
| 	{ | ||||
| 		.name = "led", | ||||
| 		.handler = led_handler, | ||||
| 		.state = led_state, | ||||
| 	}, | ||||
| }; | ||||
|  | ||||
| static void callback_Node_Config(ovsdb_update_monitor_t *mon, | ||||
|   | ||||
| @@ -10,13 +10,6 @@ | ||||
| static ovsdb_table_t table_Manager; | ||||
| static int done; | ||||
|  | ||||
|  | ||||
| static void disable_ssh()  | ||||
| { | ||||
| 	LOGN("Disabling LAN ssh access"); | ||||
| 	system("lan-ssh-firewall enable"); | ||||
| } | ||||
|  | ||||
| static void stop_http(void *arg) | ||||
| { | ||||
| 	LOGN("Stopping webserver"); | ||||
| @@ -24,8 +17,6 @@ static void stop_http(void *arg) | ||||
| 	system("uci commit system"); | ||||
| 	system("/etc/init.d/uhttpd stop"); | ||||
| 	system("/etc/init.d/uhttpd disable"); | ||||
|  | ||||
| 	disable_ssh(); | ||||
| } | ||||
|  | ||||
| static void callback_Manager(ovsdb_update_monitor_t *mon, | ||||
|   | ||||
| @@ -54,7 +54,7 @@ UNIT_CFLAGS := -I$(UNIT_PATH)/inc | ||||
| UNIT_CFLAGS += -Isrc/lib/common/inc/ | ||||
| UNIT_CFLAGS += -Isrc/lib/version/inc/ | ||||
|  | ||||
| UNIT_LDFLAGS += -lev -lubox -luci -lubus -lwebsocket -lblobmsg_json | ||||
| UNIT_LDFLAGS += -lev -lubox -luci -lubus -lwebsocket | ||||
| UNIT_LDFLAGS += -lrt | ||||
|  | ||||
| UNIT_EXPORT_CFLAGS := $(UNIT_CFLAGS) | ||||
|   | ||||
| @@ -10,7 +10,7 @@ extern const struct schema_Wifi_VIF_Config *vconf; | ||||
| extern void vif_captive_portal_set (const struct schema_Wifi_VIF_Config *vconf, char *ifname); | ||||
| extern void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate); | ||||
| extern void captive_portal_init(); | ||||
| extern void captive_portal_files_download(char* dest_file,char* src_url); | ||||
| extern void splash_page_logo(char* dest_file,char* src_url); | ||||
| extern void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname); | ||||
| extern void vif_state_dhcp_allowlist_get(struct schema_Wifi_VIF_State *vstate); | ||||
|  | ||||
|   | ||||
| @@ -1,30 +0,0 @@ | ||||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
|  | ||||
| #ifndef _FIXUP_H__ | ||||
| #define _FIXUP_H__ | ||||
|  | ||||
| struct vif_fixup { | ||||
|         struct avl_node avl; | ||||
|         char name[IF_NAMESIZE]; | ||||
|         bool has_captive; | ||||
| }; | ||||
|  | ||||
| struct vif_fixup * vif_fixup_find(const char *name); | ||||
| void vif_fixup_del(char *ifname); | ||||
|  | ||||
|  | ||||
| bool vif_fixup_captive_enabled(void); | ||||
| bool vif_fixup_iface_captive_enabled(const char *ifname); | ||||
| void vif_fixup_set_iface_captive(const char *ifname, bool en); | ||||
|  | ||||
| struct radio_fixup { | ||||
|         struct avl_node avl; | ||||
|         char rname[IF_NAMESIZE]; | ||||
|         char hw_mode[8]; | ||||
| }; | ||||
|  | ||||
| struct radio_fixup * radio_fixup_find(const char *name); | ||||
| void radio_fixup_del(char *ifname); | ||||
| void radio_fixup_set_hw_mode(const char *ifname, char *hw_mode); | ||||
| char *radio_fixup_get_hw_mode(const char *ifname); | ||||
| #endif | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -5,14 +5,13 @@ | ||||
|  | ||||
| extern int phy_from_path(char *path, char *phy); | ||||
| extern int phy_get_mac(char *phy, char *mac); | ||||
| extern int phy_find_hwmon(char *phy, char *hwmon, bool *DegreesNotMilliDegrees); | ||||
| extern int phy_find_hwmon(char *path, char *hwmon); | ||||
| extern int phy_get_tx_chainmask(const char *name); | ||||
| extern int phy_get_rx_chainmask(const char *name); | ||||
| extern int phy_get_tx_available_antenna(const char *name); | ||||
| extern int phy_get_rx_available_antenna(const char *name); | ||||
| extern int phy_get_max_tx_power(const char *name , int channel); | ||||
| extern int phy_get_channels(const char *name, int *channel); | ||||
| extern int phy_get_dfs_channels(const char *name, int *channel); | ||||
| extern int phy_get_channels_state(const char *name, | ||||
| 			struct schema_Wifi_Radio_State *rstate); | ||||
| extern int phy_get_band(const char *name, char *band); | ||||
|   | ||||
| @@ -3,10 +3,6 @@ | ||||
| #ifndef _RADIO_H__ | ||||
| #define _RADIO_H__ | ||||
|  | ||||
| #include "ovsdb_update.h" | ||||
|  | ||||
| #define CONFIG_APPLY_TIMEOUT 35 | ||||
|  | ||||
| struct rrm_neighbor { | ||||
| 	char *mac; | ||||
| 	char *ssid; | ||||
| @@ -14,24 +10,17 @@ struct rrm_neighbor { | ||||
| }; | ||||
|  | ||||
| extern const struct target_radio_ops *radio_ops; | ||||
| extern int reload_config; | ||||
| extern struct blob_buf b; | ||||
| extern struct uci_context *uci; | ||||
|  | ||||
| extern int radio_ubus_init(void); | ||||
|  | ||||
| int ubus_set_hapd_param(const char *if_name, const char *param, const char *pval); | ||||
| int ubus_set_signal_thresholds(const char *if_name, int connect, int stay); | ||||
| extern int hapd_rrm_enable(char *name, int neighbor, int beacon); | ||||
| extern int hapd_rrm_set_neighbors(char *name, struct rrm_neighbor *neigh, int count); | ||||
|  | ||||
| extern void radio_maverick(void *arg); | ||||
|  | ||||
| int nl80211_channel_get(char *name, unsigned int *chan); | ||||
| void set_config_apply_timeout(ovsdb_update_monitor_t *mon); | ||||
| bool apc_read_conf(struct schema_APC_Config *apcconf); | ||||
| bool apc_read_state(struct schema_APC_State *apcst); | ||||
| int ubus_set_channel_switch(const char *if_name, uint32_t frequency, | ||||
| 			    const char *hw_mode, int channel_bandwidth, | ||||
| 			    int sec_chan_offset, int reason); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -33,7 +33,6 @@ extern ovsdb_table_t table_Radius_Proxy_Config; | ||||
|  | ||||
| void callback_Radius_Proxy_Config(ovsdb_update_monitor_t *mon, | ||||
| 		struct schema_Radius_Proxy_Config *old, struct schema_Radius_Proxy_Config *conf); | ||||
| void radius_proxy_fixup(void); | ||||
|  | ||||
| #endif /* RADIUS_PROXY_H_INCLUDED */ | ||||
|  | ||||
|   | ||||
| @@ -34,12 +34,8 @@ extern ovsdb_table_t table_Wifi_RRM_Config; | ||||
| void rrm_config_vif(struct blob_buf *b, struct blob_buf *del,  | ||||
| 		const char * freq_band, const char * if_name); | ||||
| int rrm_get_backup_channel(const char * freq_band); | ||||
| bool rrm_config_txpower(const char *rname, unsigned int txpower); | ||||
|  | ||||
| void callback_Wifi_RRM_Config(ovsdb_update_monitor_t *mon, | ||||
| 		struct schema_Wifi_RRM_Config *old, struct schema_Wifi_RRM_Config *conf); | ||||
|  | ||||
|  | ||||
| void rrm_radio_rebalance_channel(const struct schema_Wifi_Radio_Config *rconf); | ||||
| #endif /* RRM_CONFIG_H_INCLUDED */ | ||||
|  | ||||
|   | ||||
| @@ -45,14 +45,14 @@ typedef struct | ||||
| typedef struct | ||||
| { | ||||
| 	DPP_TARGET_SURVEY_RECORD_COMMON_STRUCT; | ||||
| 	uint64_t chan_active; | ||||
| 	uint64_t chan_busy; | ||||
| 	uint64_t chan_busy_ext; | ||||
| 	uint64_t chan_self; | ||||
| 	uint64_t chan_rx; | ||||
| 	uint64_t chan_tx; | ||||
| 	uint32_t chan_active; | ||||
| 	uint32_t chan_busy; | ||||
| 	uint32_t chan_busy_ext; | ||||
| 	uint32_t chan_self; | ||||
| 	uint32_t chan_rx; | ||||
| 	uint32_t chan_tx; | ||||
| 	uint32_t chan_noise; | ||||
| 	uint64_t duration_ms; | ||||
| 	uint32_t duration_ms; | ||||
| } target_survey_record_t; | ||||
|  | ||||
| typedef void target_capacity_data_t; | ||||
|   | ||||
| @@ -1,20 +0,0 @@ | ||||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
|  | ||||
| #ifndef __TIMER_H__ | ||||
| #define __TIMER_H__ | ||||
|  | ||||
| #include <sys/time.h> | ||||
|  | ||||
| struct timeout; | ||||
| typedef void (*timeout_handler)(struct timeout *t); | ||||
|  | ||||
| struct timeout { | ||||
| 	bool pending; | ||||
| 	timeout_handler cb; | ||||
| 	struct timeval time; | ||||
| }; | ||||
|  | ||||
| int timeout_set(struct timeout *timeout, int msecs); | ||||
| void timer_expiry_check(struct timeout *timeout); | ||||
|  | ||||
| #endif | ||||
| @@ -6,7 +6,6 @@ | ||||
| #include <libubox/blobmsg.h> | ||||
|  | ||||
| #define min(a,b) (((a) < (b)) ? (a) : (b)) | ||||
| #define ATH_DRIVER_NAME_LEN 16 | ||||
|  | ||||
| struct mode_map { | ||||
| 	int fiveg; | ||||
| @@ -42,8 +41,4 @@ extern int net_get_mtu(char *iface); | ||||
| extern int net_get_mac(char *iface, char *mac); | ||||
| extern int net_is_bridge(char *iface); | ||||
| extern char* get_max_channel_bw_channel(int channel_freq, const char* htmode); | ||||
| int phy_find_hwmon_helper(char *dir, char *file, char *hwmon); | ||||
| extern double dBm_to_mwatts(double dBm); | ||||
| extern double mWatts_to_dBm(double mW); | ||||
| extern int phy_get_ath_driver_name(char *phy, char *ath_driver); | ||||
| #endif | ||||
|   | ||||
| @@ -19,7 +19,6 @@ | ||||
| #define OVSDB_SECURITY_ENCRYPTION_WPA_SAE   "WPA-SAE" | ||||
| #define OVSDB_SECURITY_ENCRYPTION_WPA_EAP   "WPA-EAP" | ||||
| #define OVSDB_SECURITY_ENCRYPTION_WPA3_EAP  "WPA3-EAP" | ||||
| #define OVSDB_SECURITY_ENCRYPTION_WPA3_EAP_192  "WPA3-EAP-192" | ||||
| #define OVSDB_SECURITY_RADIUS_SERVER_IP     "radius_server_ip" | ||||
| #define OVSDB_SECURITY_RADIUS_SERVER_PORT   "radius_server_port" | ||||
| #define OVSDB_SECURITY_RADIUS_SERVER_SECRET "radius_server_secret" | ||||
| @@ -38,6 +37,5 @@ void vif_hs20_update(struct schema_Hotspot20_Config *hs2conf); | ||||
| void vif_hs20_osu_update(struct schema_Hotspot20_OSU_Providers *hs2osuconf); | ||||
| void vif_hs20_icon_update(struct schema_Hotspot20_Icon_Config *hs2iconconf); | ||||
| void vif_section_del(char *section_name); | ||||
| void vif_check_radius_proxy(void); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -47,8 +47,6 @@ UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/dhcpdiscovery.c | ||||
| UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/radius_probe.c | ||||
| UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/rrm_config.c | ||||
| UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/radius_proxy.c | ||||
| UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/timer.c | ||||
| UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/fixup.c | ||||
|  | ||||
| CONFIG_USE_KCONFIG=y | ||||
| CONFIG_INET_ETH_LINUX=y | ||||
|   | ||||
| @@ -20,18 +20,10 @@ | ||||
| #include "nl80211.h" | ||||
| #include "utils.h" | ||||
| #include "captive.h" | ||||
| #include <libubox/avl-cmp.h> | ||||
| #include <libubox/avl.h> | ||||
| #include <libubox/vlist.h> | ||||
| #include <net/if.h> | ||||
| #include "fixup.h" | ||||
|  | ||||
| static struct blob_buf cap={ }; | ||||
| static struct blob_buf cap_blob={ }; | ||||
| static struct blob_buf url_buf={ }; | ||||
| struct blob_buf cap={ }; | ||||
| static struct uci_package *opennds; | ||||
| static struct uci_context *caps_uci; | ||||
| static struct uci_context *capg_uci; | ||||
| static struct uci_context *cap_uci; | ||||
| struct blob_attr *d; | ||||
|  | ||||
| #define SCHEMA_CAPTIVE_PORTAL_OPT_SZ            255 | ||||
| @@ -148,10 +140,6 @@ void vif_state_dhcp_allowlist_get(struct schema_Wifi_VIF_State *vstate) | ||||
| 	char read_ifname[8]; | ||||
| 	char set[8]; | ||||
| 	struct blob_attr *td[__DNS_ATTR_MAX] = { }; | ||||
|  | ||||
| 	if (vif_fixup_iface_captive_enabled(vstate->if_name) == false) | ||||
| 		return; | ||||
|  | ||||
| 	uci_load(dns, "dhcp", &dhcp); | ||||
| 	ip_section = uci_lookup_section(dns, dhcp,"dnsmasq"); | ||||
| 	if(!ip_section) { | ||||
| @@ -194,16 +182,12 @@ void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, | ||||
| 	int i; | ||||
| 	char ips[128]; | ||||
| 	char buff[64]; | ||||
|  | ||||
| 	if (vif_fixup_iface_captive_enabled(vconf->if_name) == false) | ||||
| 		return; | ||||
|  | ||||
| 	ipset_flush(ifname); | ||||
| 	e = blobmsg_open_array(&dnsmas, "ipset"); | ||||
| 	for (i = 0; i < vconf->captive_allowlist_len; i++) | ||||
| 	{ | ||||
| 		strcpy(buff,(char*)vconf->captive_allowlist[i]); | ||||
| 		snprintf(ips, sizeof(ips), "/%s/set_%s", buff,"opennds"); | ||||
| 		sprintf(ips,"/%s/set_%s", buff,"opennds"); | ||||
| 		blobmsg_add_string(&dnsmas, NULL,ips); | ||||
| 	} | ||||
| 	blobmsg_close_array(&dnsmas, e); | ||||
| @@ -251,13 +235,10 @@ void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate) | ||||
| 	struct blob_attr *tc[__NDS_ATTR_MAX] = { }; | ||||
| 	struct uci_section *cp_section; | ||||
|  | ||||
| 	if (vif_fixup_iface_captive_enabled(vstate->if_name) == false) | ||||
| 		return; | ||||
|  | ||||
| 	uci_load(capg_uci, "opennds", &opennds); | ||||
| 	cp_section = uci_lookup_section(capg_uci, opennds,"opennds"); | ||||
| 	uci_load(cap_uci, "opennds", &opennds); | ||||
| 	cp_section = uci_lookup_section(cap_uci, opennds,"opennds"); | ||||
| 	if(!cp_section) { | ||||
| 		uci_unload(capg_uci, opennds); | ||||
| 		uci_unload(cap_uci, opennds); | ||||
| 		return; | ||||
| 	} | ||||
| 	blob_buf_init(&cap, 0); | ||||
| @@ -370,14 +351,15 @@ void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| uci_unload(capg_uci, opennds); | ||||
| uci_unload(cap_uci, opennds); | ||||
| return; | ||||
| } | ||||
|  | ||||
| void clean_up(CURL *curl,FILE* imagefile) | ||||
| void clean_up(CURL *curl,FILE* imagefile, FILE* headerfile) | ||||
| { | ||||
| 	curl_easy_cleanup(curl); | ||||
| 	fclose(imagefile); | ||||
| 	fclose(headerfile); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| @@ -386,27 +368,33 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { | ||||
|     return written; | ||||
| } | ||||
|  | ||||
| void captive_portal_files_download(char* dest_file, char* src_url) | ||||
| void splash_page_logo(char* dest_file, char* src_url) | ||||
| { | ||||
| 	CURL *curl; | ||||
| 	CURLcode res; | ||||
| 	FILE *imagefile; | ||||
| 	const char *clientcert = "/usr/opensync/certs/client.pem"; | ||||
| 	FILE *headerfile; | ||||
| 	static const char *clientcert = "/usr/opensync/certs/client.pem"; | ||||
| 	const char *clientkey = "/usr/opensync/certs/client_dec.key"; | ||||
| 	static const char *pHeaderFile = "/etc/opennds/splashlogo_header"; | ||||
| 	const char *keytype = "PEM"; | ||||
|  | ||||
| 	char errbuf[CURL_ERROR_SIZE]; | ||||
| 	headerfile = fopen(pHeaderFile, "wb"); | ||||
| 	imagefile = fopen(dest_file, "wb"); | ||||
| 	if(imagefile == NULL){ | ||||
| 		LOG(ERR, "fopen failed"); | ||||
| 		if(headerfile) | ||||
| 			fclose(headerfile); | ||||
| 		return; | ||||
| 	} | ||||
| 	curl = curl_easy_init(); | ||||
|  | ||||
| 	if (curl == NULL){ | ||||
| 		LOG(ERR, "curl_easy_init failed"); | ||||
| 		clean_up(curl,imagefile); | ||||
| 		clean_up(curl,imagefile,headerfile); | ||||
| 		return; | ||||
| 	} | ||||
| 	curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile); | ||||
| 	curl_easy_setopt(curl, CURLOPT_URL, src_url); | ||||
| 	curl_easy_setopt(curl, CURLOPT_SSLCERT, clientcert); | ||||
| 	curl_easy_setopt(curl, CURLOPT_SSLKEY, clientkey); | ||||
| @@ -415,22 +403,23 @@ void captive_portal_files_download(char* dest_file, char* src_url) | ||||
| 	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); | ||||
| 	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); | ||||
| 	curl_easy_setopt(curl, CURLOPT_WRITEDATA, imagefile); | ||||
| 	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); | ||||
| 	curl_easy_setopt(curl, CURLOPT_HEADER, 0L); | ||||
|  | ||||
| 	res = curl_easy_perform(curl); | ||||
| 	if (res != CURLE_OK){ | ||||
| 		clean_up(curl,imagefile); | ||||
| 		clean_up(curl,imagefile,headerfile); | ||||
| 		remove(dest_file); | ||||
| 		return; | ||||
| 	} | ||||
| 	clean_up(curl,imagefile); | ||||
| 	clean_up(curl,imagefile,headerfile); | ||||
| 	return ; | ||||
| } | ||||
|  | ||||
| int ipset_create(char *ifnds) | ||||
| { | ||||
| 	char command[64]; | ||||
| 	snprintf(command, sizeof(command), "ipset create set_%s hash:ip", ifnds); | ||||
| 	sprintf(command,"ipset create set_%s hash:ip", ifnds); | ||||
| 	return (system(command)); | ||||
| } | ||||
|  | ||||
| @@ -438,19 +427,18 @@ void captive_portal_get_current_urls(char *ifname, char *splash_logo, char *back | ||||
| { | ||||
| 	char *buf = NULL; | ||||
| 	struct blob_attr *tc[__NDS_ATTR_MAX] = { }; | ||||
| 	struct uci_section *cp_section = NULL; | ||||
| 	struct uci_package *opennds = NULL; | ||||
| 	struct blob_buf url_buf={ }; | ||||
| 	struct uci_section *cp_section; | ||||
|  | ||||
| 	uci_load(caps_uci, "opennds", &opennds); | ||||
| 	cp_section = uci_lookup_section(caps_uci, opennds,"opennds"); | ||||
| 	uci_load(cap_uci, "opennds", &opennds); | ||||
| 	cp_section = uci_lookup_section(cap_uci, opennds,"opennds"); | ||||
| 	if(!cp_section) { | ||||
| 		uci_unload(caps_uci, opennds); | ||||
| 		uci_unload(cap_uci, opennds); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	blob_buf_init(&url_buf, 0); | ||||
| 	uci_to_blob(&url_buf, cp_section, &opennds_param); | ||||
|  | ||||
| 	blobmsg_parse(opennds_policy, __NDS_ATTR_MAX, tc, blob_data(url_buf.head), blob_len(url_buf.head)); | ||||
|  | ||||
| 	if (tc[NDS_ATTR_SPLASH_PAGE_LOGO]) { | ||||
| @@ -472,8 +460,7 @@ void captive_portal_get_current_urls(char *ifname, char *splash_logo, char *back | ||||
| 	} else { | ||||
| 		user_file[0]=0; | ||||
| 	} | ||||
| 	uci_unload(caps_uci, opennds); | ||||
|  | ||||
| 	uci_unload(cap_uci, opennds); | ||||
| 	return; | ||||
| } | ||||
| void opennds_parameters(char *ifname) | ||||
| @@ -482,7 +469,7 @@ void opennds_parameters(char *ifname) | ||||
| 	char users_router[7][64] = { "allow tcp port 53","allow udp port 53", | ||||
| 				"allow udp port 67","allow tcp port 22", | ||||
| 				"allow tcp port 23", "allow tcp port 80", "allow tcp port 443"}; | ||||
|  | ||||
| 	struct blob_buf cap_blob={ }; | ||||
| 	blob_buf_init(&cap_blob, 0); | ||||
|  | ||||
| 	blobmsg_add_string(&cap_blob, "fwhook_enabled","1"); | ||||
| @@ -506,8 +493,8 @@ void opennds_parameters(char *ifname) | ||||
| 		blobmsg_add_string(&cap_blob, NULL, users_router[i]); | ||||
| 	} | ||||
| 	blobmsg_close_array(&cap_blob, d); | ||||
| 	blob_to_uci_section(caps_uci, "opennds", "opennds", "opennds", cap_blob.head, &opennds_param, NULL); | ||||
| 	uci_commit_all(caps_uci); | ||||
| 	blob_to_uci_section(cap_uci, "opennds", "opennds", "opennds", cap_blob.head, &opennds_param, NULL); | ||||
| 	uci_commit_all(cap_uci); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| @@ -515,26 +502,25 @@ void opennds_section_del(char *section_name) | ||||
| { | ||||
| 	struct uci_package *opennds; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
| 	int ret = 0; | ||||
| 	int ret=0; | ||||
|  | ||||
| 	ret = uci_load(caps_uci, "opennds", &opennds); | ||||
| 	ret= uci_load(uci, "opennds", &opennds); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: %s uci_load() failed with rc %d", section_name, __func__, ret); | ||||
| 		uci_unload(caps_uci, opennds); | ||||
| 		LOGD("%s: uci_load() failed with rc %d", section_name, ret); | ||||
| 		return; | ||||
| 	} | ||||
| 	uci_foreach_element_safe(&opennds->sections, tmp, e) { | ||||
| 		struct uci_section *s = uci_to_section(e); | ||||
| 		if (!strcmp(s->e.name, section_name)) { | ||||
| 			uci_section_del(caps_uci, "vif", "opennds", (char *)s->e.name, section_name); | ||||
| 			uci_section_del(uci, "vif", "opennds", (char *)s->e.name, section_name); | ||||
| 		} | ||||
| 		else { | ||||
| 			continue; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	uci_commit(caps_uci, &opennds, false); | ||||
| 	uci_unload(caps_uci, opennds); | ||||
| 	uci_commit(uci, &opennds, false); | ||||
| 	uci_unload(uci, opennds); | ||||
| 	reload_config = 1; | ||||
| } | ||||
|  | ||||
| void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname) | ||||
| @@ -544,26 +530,23 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if | ||||
| 	const char *opt; | ||||
| 	const char *val; | ||||
| 	blob_buf_init(&cap, 0); | ||||
| 	char path[64] = {0}; | ||||
| 	char webroot[64] = {0}; | ||||
|  | ||||
| 	char path[64]; | ||||
| 	char webroot[64]; | ||||
| 	char ipset_tcp80[64]; | ||||
| 	char ipset_tcp443[64]; | ||||
| 	char splash_logo[84]; | ||||
| 	char back_image[84]; | ||||
| 	char user_file[84]; | ||||
|  | ||||
| 	char splash_logo[84] = {0}; | ||||
| 	char back_image[84] = {0}; | ||||
| 	char user_file[84] = {0}; | ||||
|  | ||||
| 	snprintf(path, sizeof(path), "/etc/opennds/htdocs/images/"); | ||||
| 	snprintf(webroot, sizeof(webroot), "/etc/opennds/htdocs"); | ||||
|  | ||||
| 	snprintf(ipset_tcp80, sizeof(ipset_tcp80),"allow tcp port 80 ipset set_opennds"); | ||||
| 	snprintf(ipset_tcp443, sizeof(ipset_tcp443), "allow tcp port 443 ipset set_opennds"); | ||||
|  | ||||
| 	sprintf(path,"/etc/opennds/htdocs/images/"); | ||||
| 	sprintf(webroot,"/etc/opennds/htdocs"); | ||||
| 	sprintf(ipset_tcp80,"allow tcp port 80 ipset set_opennds"); | ||||
| 	sprintf(ipset_tcp443,"allow tcp port 443 ipset set_opennds"); | ||||
| 	char file_path[128]; | ||||
| 	struct stat st = {0}; | ||||
| 	if (stat(path, &st) == -1) | ||||
| 		mkdir(path, 0755); | ||||
|  | ||||
| 	captive_portal_get_current_urls(ifname, splash_logo, back_image, user_file); | ||||
|  | ||||
| 	for (j = 0; j < SCHEMA_CAPTIVE_PORTAL_OPTS_MAX; j++) { | ||||
| @@ -588,7 +571,6 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if | ||||
| 				blobmsg_add_string(&cap, NULL, ipset_tcp80); | ||||
| 				blobmsg_add_string(&cap, NULL, ipset_tcp443); | ||||
| 				blobmsg_close_array(&cap, d); | ||||
| 				vif_fixup_set_iface_captive(ifname, true); | ||||
|  | ||||
| 			} else if (strcmp(value,"username")==0) { | ||||
| 				blobmsg_add_string(&cap, "webroot",webroot); | ||||
| @@ -603,8 +585,6 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if | ||||
| 				blobmsg_add_string(&cap, NULL, ipset_tcp443); | ||||
| 				blobmsg_close_array(&cap, d); | ||||
|  | ||||
| 				vif_fixup_set_iface_captive(ifname, true); | ||||
|  | ||||
| 			} else if (strcmp(value,"radius")==0)  { | ||||
| 				blobmsg_add_string(&cap, "webroot",webroot); | ||||
| 				opennds_parameters("opennds"); | ||||
| @@ -612,19 +592,14 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if | ||||
| 				blobmsg_add_string(&cap, "enabled", "1"); | ||||
| 				blobmsg_add_string(&cap, "gatewayinterface","br-lan"); | ||||
| 				blobmsg_add_string(&cap, "preauth", "/usr/lib/opennds/radius.sh"); | ||||
|  | ||||
| 				ipset_create("opennds"); | ||||
| 				d = blobmsg_open_array(&cap, "preauthenticated_users"); | ||||
| 				blobmsg_add_string(&cap, NULL, ipset_tcp80); | ||||
| 				blobmsg_add_string(&cap, NULL, ipset_tcp443); | ||||
| 				blobmsg_close_array(&cap, d); | ||||
|  | ||||
| 				vif_fixup_set_iface_captive(ifname, true); | ||||
| 			} | ||||
| 			else { | ||||
| 				vif_fixup_set_iface_captive(ifname, false); | ||||
| 				if (vif_fixup_captive_enabled() == false) | ||||
| 					opennds_section_del("opennds"); | ||||
| 				opennds_section_del("opennds"); | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
| @@ -651,21 +626,17 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if | ||||
| 			blobmsg_add_string(&cap, "gatewayname", value); | ||||
|  | ||||
| 		else if (strcmp(opt, "splash_page_logo") == 0) { | ||||
| 			if (value[0] != '\0') { | ||||
| 				blobmsg_add_string(&cap, "splash_page_logo", value); | ||||
| 				if (strcmp(splash_logo,value) !=0) { | ||||
| 					snprintf(file_path, sizeof(file_path), "%s%s",path,"TipLogo.png"); | ||||
| 					captive_portal_files_download(file_path,value); | ||||
| 				} | ||||
| 			blobmsg_add_string(&cap, "splash_page_logo", value); | ||||
| 			if (strcmp(splash_logo,value) !=0) { | ||||
| 				sprintf(file_path,"%s%s",path,"TipLogo.png"); | ||||
| 				splash_page_logo(file_path,value); | ||||
| 			} | ||||
|  | ||||
| 		} else if (strcmp(opt, "splash_page_background_logo") == 0) { | ||||
| 			if (value[0] != '\0') { | ||||
| 				blobmsg_add_string(&cap, "page_background_logo", value); | ||||
| 				if (strcmp(back_image,value) !=0) { | ||||
| 					snprintf(file_path, sizeof(file_path),"%s%s",path,"TipBackLogo.png"); | ||||
| 					captive_portal_files_download(file_path,value); | ||||
| 				} | ||||
| 			blobmsg_add_string(&cap, "page_background_logo", value); | ||||
| 			if (strcmp(back_image,value) !=0) { | ||||
| 				sprintf(file_path,"%s%s",path,"TipBackLogo.png"); | ||||
| 				splash_page_logo(file_path,value); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @@ -683,24 +654,20 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if | ||||
| 			blobmsg_add_string(&cap, "login_success_text", value); | ||||
|  | ||||
| 		else if (strcmp(opt, "username_password_file") == 0) { | ||||
| 			if (value[0] != '\0') { | ||||
| 				blobmsg_add_string(&cap, "username_password_file", value); | ||||
| 				if (strcmp(user_file,value) !=0) { | ||||
| 					snprintf(file_path, sizeof(file_path),"%s%s",path,"userpass.dat"); | ||||
| 					captive_portal_files_download(file_path,value); | ||||
| 				} | ||||
| 			blobmsg_add_string(&cap, "username_password_file", value); | ||||
| 			if (strcmp(user_file,value) !=0) { | ||||
| 				sprintf(file_path,"%s%s",path,"userpass.dat"); | ||||
| 				splash_page_logo(file_path,value); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	blob_to_uci_section(caps_uci, "opennds", "opennds", "opennds", cap.head, &opennds_param, NULL); | ||||
| 	uci_commit_all(caps_uci); | ||||
| 	blob_to_uci_section(cap_uci, "opennds", "opennds", "opennds", cap.head, &opennds_param, NULL); | ||||
| 	uci_commit_all(cap_uci); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| void captive_portal_init() | ||||
| { | ||||
| 	caps_uci=uci_alloc_context(); | ||||
| 	capg_uci=uci_alloc_context(); | ||||
| 	cap_uci=uci_alloc_context(); | ||||
| 	dns=uci_alloc_context(); | ||||
| 	return; | ||||
| } | ||||
|   | ||||
| @@ -17,7 +17,6 @@ | ||||
| #include <sys/ioctl.h> | ||||
| #include "target.h" | ||||
| #include "dhcp_opt.h" | ||||
| #include "log.h" | ||||
| #include "dhcpdiscovery.h" | ||||
| //#include "wc-dhcpdiscoveryDebug.h" | ||||
|  | ||||
| @@ -56,15 +55,14 @@ struct Answer_t | ||||
| /** | ||||
|  * Use to setup the DHCP client | ||||
|  */ | ||||
| bool dhcp_setup(const char * serveripaddress, const char * device, int *fd) | ||||
| int dhcp_setup(const char * serveripaddress, const char * device) | ||||
| { | ||||
|    struct hostent *hostent; | ||||
|    const int flag = 1; | ||||
|    struct sockaddr_in name; | ||||
|    struct ifreq ifr; | ||||
|    int dhcp_socket = -1; | ||||
|    int dhcp_socket; | ||||
|  | ||||
|    *fd = -1; | ||||
|    /* We populate the interface info */ | ||||
|    memset(&ifr, 0, sizeof(ifr)); | ||||
|    snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s\n", device); | ||||
| @@ -73,7 +71,7 @@ bool dhcp_setup(const char * serveripaddress, const char * device, int *fd) | ||||
|     * setup sending socket | ||||
|     */ | ||||
|    if ((hostent=gethostbyname(serveripaddress))==NULL) { | ||||
|       goto err; | ||||
|       return 0; | ||||
|    } | ||||
|  | ||||
|    dhcp_to.sin_family=AF_INET; | ||||
| @@ -83,16 +81,17 @@ bool dhcp_setup(const char * serveripaddress, const char * device, int *fd) | ||||
|  | ||||
|    dhcp_to.sin_port=htons(67); | ||||
|  | ||||
|    if ((dhcp_socket=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP))==-1) { | ||||
|       goto err; | ||||
|    if ((dhcp_socket=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP))==-1) | ||||
|    { | ||||
|       return 0; | ||||
|    } | ||||
|  | ||||
|    if (setsockopt (dhcp_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof flag) < 0) { | ||||
|       goto err; | ||||
|       return 0; | ||||
|    } | ||||
|  | ||||
|    if (setsockopt(dhcp_socket,SOL_SOCKET,SO_BROADCAST,(char *)&flag, sizeof flag) < 0) { | ||||
|       goto err; | ||||
|       return 0; | ||||
|    } | ||||
|  | ||||
|    name.sin_family = AF_INET; | ||||
| @@ -102,16 +101,10 @@ bool dhcp_setup(const char * serveripaddress, const char * device, int *fd) | ||||
|    memset (name.sin_zero, 0, sizeof (name.sin_zero)); | ||||
|  | ||||
|    if (bind (dhcp_socket, (struct sockaddr *)&name, sizeof name) < 0) { | ||||
|       goto err; | ||||
|       return 0; | ||||
|    } | ||||
|  | ||||
|    *fd = dhcp_socket; | ||||
|    return true; | ||||
|  | ||||
| err: | ||||
|    if (dhcp_socket >= 0) | ||||
|       close(dhcp_socket); | ||||
|    return false; | ||||
|    return dhcp_socket; | ||||
| } | ||||
|  | ||||
| void parseDhcpMessage(unsigned char *buffer,int size, struct Answer_t * response) | ||||
| @@ -447,39 +440,41 @@ bool generateQuery(const char *ifname) | ||||
|    const char * serverIP = "255.255.255.255"; | ||||
|    const char * mac_address = getMACAddress(device); | ||||
|    struct Answer_t response; | ||||
|    int dhcp_socket = -1; | ||||
|  | ||||
|    if (!dhcp_setup(serverIP, device, &dhcp_socket)) { | ||||
|       LOGE("%s dhcp client setup failed at line %d", __func__, __LINE__); | ||||
|       goto clean; | ||||
|    } | ||||
|    int dhcp_socket = dhcp_setup(serverIP, device); | ||||
|  | ||||
|    // We sent a DISCOVER | ||||
|    send_dhcp_packet(dhcp_socket, DISCOVER,"0.0.0.0",NULL,"0.0.0.0",mac_address); | ||||
|    if( dhcp_socket != 0) | ||||
|    { | ||||
|       // We sent a DISCOVER | ||||
|       send_dhcp_packet(dhcp_socket, DISCOVER,"0.0.0.0",NULL,"0.0.0.0",mac_address); | ||||
|  | ||||
|    if (waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, OFFER, &response) == OFFER /* DHCP TYPE: Offer */) { | ||||
|       /* We close our initial socket (which is configured for broadcasting) */ | ||||
|       if (dhcp_socket >= 0) | ||||
|       if(waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, OFFER, &response) == OFFER /* DHCP TYPE: Offer */) | ||||
|       { | ||||
|          /* We close our initial socket (which is configured for broadcasting) */ | ||||
|          close(dhcp_socket); | ||||
|  | ||||
|       /* We open a direct connection (as opposed to broadcasted one) */ | ||||
|       dhcp_socket = -1; | ||||
|       if (!dhcp_setup(response.serverIP, device, &dhcp_socket)) { | ||||
|          LOGE("%s dhcp client setup failed at line %d", __func__, __LINE__); | ||||
|          goto clean; | ||||
|          /* We open a direct connection (as opposed to broadcasted one) */ | ||||
|          dhcp_socket = dhcp_setup(response.serverIP, device); | ||||
|  | ||||
|          /* We send a request */ | ||||
|          send_dhcp_packet(dhcp_socket, REQUEST /* Request */, response.serverIP, response.offeredIP, "0.0.0.0", mac_address); | ||||
|  | ||||
|          if(waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, ACK_REQUEST, &response) == ACK_REQUEST /* DHCP TYPE: ACK */) | ||||
|          { | ||||
| 		rc = true; | ||||
|          } | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|                 close(dhcp_socket); | ||||
| 		rc = false; | ||||
|       } | ||||
|  | ||||
|       /* We send a request */ | ||||
|       send_dhcp_packet(dhcp_socket, REQUEST /* Request */, response.serverIP, response.offeredIP, "0.0.0.0", mac_address); | ||||
|  | ||||
|       if (waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, ACK_REQUEST, &response) == ACK_REQUEST /* DHCP TYPE: ACK */) | ||||
|          rc = true; | ||||
|    } | ||||
|  | ||||
| clean: | ||||
|    if (mac_address) | ||||
|    if(mac_address) | ||||
|    { | ||||
|       free( (void*) mac_address); | ||||
|    if (dhcp_socket >= 0) | ||||
|       close(dhcp_socket); | ||||
|    } | ||||
|  | ||||
|    return rc; | ||||
| } | ||||
|   | ||||
| @@ -1,140 +0,0 @@ | ||||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| #include <fcntl.h> | ||||
| #include <ctype.h> | ||||
| #include <stdbool.h> | ||||
| #include <errno.h> | ||||
| #include <stdlib.h> | ||||
|  | ||||
| #include "log.h" | ||||
| #include "const.h" | ||||
| #include "target.h" | ||||
|  | ||||
| #include <libubox/avl-cmp.h> | ||||
| #include <libubox/avl.h> | ||||
| #include <libubox/vlist.h> | ||||
| #include <net/if.h> | ||||
|  | ||||
| #include "fixup.h" | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * VIF Fixup | ||||
|  */ | ||||
|  | ||||
| static struct avl_tree vif_fixup_tree = AVL_TREE_INIT(vif_fixup_tree, avl_strcmp, false, NULL); | ||||
| static struct avl_tree radio_fixup_tree = AVL_TREE_INIT(radio_fixup_tree, avl_strcmp, false, NULL); | ||||
|  | ||||
| struct vif_fixup * vif_fixup_find(const char *ifname) | ||||
| { | ||||
|         struct vif_fixup *vif = avl_find_element(&vif_fixup_tree, ifname, vif, avl); | ||||
|         if (vif) | ||||
|                 return vif; | ||||
|  | ||||
| 	/* Not found, add */ | ||||
|         vif = malloc(sizeof(*vif)); | ||||
|         if (!vif) | ||||
|                 return NULL; | ||||
|  | ||||
|         memset(vif, 0, sizeof(*vif)); | ||||
|         strncpy(vif->name, ifname, IF_NAMESIZE); | ||||
|         vif->avl.key = vif->name; | ||||
|         avl_insert(&vif_fixup_tree, &vif->avl); | ||||
|         return vif; | ||||
| } | ||||
|  | ||||
| void vif_fixup_del(char *ifname) | ||||
| { | ||||
|         struct vif_fixup *vif = NULL; | ||||
|         vif = avl_find_element(&vif_fixup_tree, ifname, vif, avl); | ||||
|         if (vif) { | ||||
| 		avl_delete(&vif_fixup_tree, &vif->avl); | ||||
| 		free(vif); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| bool vif_fixup_captive_enabled(void) | ||||
| { | ||||
|         struct vif_fixup *vif_ptr = NULL; | ||||
|         struct vif_fixup *vif = NULL; | ||||
|  | ||||
| 	avl_for_each_element_safe(&vif_fixup_tree, vif, avl, vif_ptr) { | ||||
| 		if (vif->has_captive == true) | ||||
| 			return true; | ||||
| 	} | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| bool vif_fixup_iface_captive_enabled(const char *ifname) | ||||
| { | ||||
| 	struct vif_fixup * vif = NULL; | ||||
|  | ||||
| 	vif = vif_fixup_find(ifname); | ||||
|  | ||||
| 	if (vif) | ||||
| 		return vif->has_captive; | ||||
| 	else | ||||
| 		return false; | ||||
| } | ||||
|  | ||||
| void vif_fixup_set_iface_captive(const char *ifname, bool en) | ||||
| { | ||||
| 	struct vif_fixup * vif = NULL; | ||||
|  | ||||
| 	vif = vif_fixup_find(ifname); | ||||
|  | ||||
| 	if (vif) | ||||
| 		vif->has_captive = en; | ||||
| } | ||||
|  | ||||
| struct radio_fixup * radio_fixup_find(const char *ifname) | ||||
| { | ||||
|         struct radio_fixup *radio = avl_find_element(&radio_fixup_tree, ifname, radio, avl); | ||||
|         if (radio) | ||||
|                 return radio; | ||||
|  | ||||
| 	/* Not found, add */ | ||||
|         radio = malloc(sizeof(*radio)); | ||||
|         if (!radio) | ||||
|                 return NULL; | ||||
|  | ||||
|         memset(radio, 0, sizeof(*radio)); | ||||
|         strncpy(radio->rname, ifname, IF_NAMESIZE); | ||||
|         radio->avl.key = radio->rname; | ||||
|         avl_insert(&radio_fixup_tree, &radio->avl); | ||||
|         return radio; | ||||
| } | ||||
|  | ||||
| void radio_fixup_del(char *ifname) | ||||
| { | ||||
|         struct radio_fixup *radio = NULL; | ||||
|         radio = avl_find_element(&radio_fixup_tree, ifname, radio, avl); | ||||
|         if (radio) { | ||||
| 		avl_delete(&radio_fixup_tree, &radio->avl); | ||||
| 		free(radio); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void radio_fixup_set_hw_mode(const char *ifname, char *hw_mode) | ||||
| { | ||||
| 	struct radio_fixup * radio = NULL; | ||||
|  | ||||
| 	radio = radio_fixup_find(ifname); | ||||
|  | ||||
| 	if (radio) | ||||
| 		strncpy(radio->hw_mode, hw_mode, strlen(hw_mode)); | ||||
| } | ||||
|  | ||||
| char * radio_fixup_get_hw_mode(const char *ifname) | ||||
| { | ||||
| 	struct radio_fixup * radio = NULL; | ||||
|  | ||||
| 	radio = radio_fixup_find(ifname); | ||||
|  | ||||
| 	if (radio) | ||||
| 		return radio->hw_mode; | ||||
| 	else | ||||
| 		return NULL; | ||||
| } | ||||
| @@ -27,26 +27,20 @@ | ||||
| #include "rrm_config.h" | ||||
| #include "vlan.h" | ||||
| #include "radius_proxy.h" | ||||
| #include "timer.h" | ||||
| #include "fixup.h" | ||||
|  | ||||
| ovsdb_table_t table_Hotspot20_Config; | ||||
| ovsdb_table_t table_Hotspot20_OSU_Providers; | ||||
| ovsdb_table_t table_Hotspot20_Icon_Config; | ||||
| ovsdb_table_t table_Radius_Proxy_Config; | ||||
|  | ||||
| ovsdb_table_t table_APC_Config; | ||||
| ovsdb_table_t table_APC_State; | ||||
| ovsdb_table_t table_Wifi_VIF_Config; | ||||
| ovsdb_table_t table_Wifi_Inet_Config; | ||||
| ovsdb_table_t table_Node_Config; | ||||
|  | ||||
| unsigned int radproxy_apc = 0; | ||||
| unsigned int radproxy_apc; | ||||
|  | ||||
| static struct uci_package *wireless; | ||||
| struct uci_context *uci; | ||||
| struct blob_buf b = { }; | ||||
| struct blob_buf del = { }; | ||||
| int reload_config = 0; | ||||
| static struct timespec startup_time; | ||||
|  | ||||
| enum { | ||||
| @@ -62,7 +56,7 @@ enum { | ||||
| 	WDEV_ATTR_TX_ANTENNA, | ||||
| 	WDEV_ATTR_RX_ANTENNA, | ||||
| 	WDEV_ATTR_FREQ_BAND, | ||||
| 	WDEV_ATTR_CHANNELS, | ||||
| 	WDEV_AATR_CHANNELS, | ||||
| 	WDEV_ATTR_DISABLE_B_RATES, | ||||
| 	WDEV_ATTR_MAXASSOC_CLIENTS, | ||||
| 	WDEV_ATTR_LOCAL_PWR_CONSTRAINT, | ||||
| @@ -82,8 +76,8 @@ static const struct blobmsg_policy wifi_device_policy[__WDEV_ATTR_MAX] = { | ||||
| 	[WDEV_ATTR_TX_ANTENNA] = { .name = "txantenna", .type = BLOBMSG_TYPE_INT32 }, | ||||
| 	[WDEV_ATTR_RX_ANTENNA] = { .name = "rxantenna", .type = BLOBMSG_TYPE_INT32 }, | ||||
| 	[WDEV_ATTR_FREQ_BAND] = { .name = "freq_band", .type = BLOBMSG_TYPE_STRING }, | ||||
| 	[WDEV_ATTR_CHANNELS] = {.name = "channels", .type = BLOBMSG_TYPE_ARRAY}, | ||||
| 	[WDEV_ATTR_DISABLE_B_RATES] = { .name = "legacy_rates", .type = BLOBMSG_TYPE_BOOL }, | ||||
| 	[WDEV_AATR_CHANNELS] = {.name = "channels", .type = BLOBMSG_TYPE_ARRAY}, | ||||
|         [WDEV_ATTR_DISABLE_B_RATES] = { .name = "legacy_rates", .type = BLOBMSG_TYPE_BOOL }, | ||||
| 	[WDEV_ATTR_MAXASSOC_CLIENTS] = { .name = "maxassoc", .type = BLOBMSG_TYPE_INT32 }, | ||||
| 	[WDEV_ATTR_LOCAL_PWR_CONSTRAINT] = { .name = "local_pwr_constraint", .type = BLOBMSG_TYPE_INT32 }, | ||||
| }; | ||||
| @@ -186,106 +180,6 @@ static void radio_state_custom_options_get(struct schema_Wifi_Radio_State *rstat | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void set_channel_max_power(struct schema_Wifi_Radio_State *rstate, | ||||
|                                     int *index, int channel, | ||||
|                                     int max_power) | ||||
| { | ||||
| 	rstate->channel_max_power_keys[*index] = channel; | ||||
| 	rstate->channel_max_power[*index] = max_power; | ||||
| 	*index += 1; | ||||
| 	rstate->channel_max_power_len = *index; | ||||
| } | ||||
|  | ||||
| // Update the entire channel_max_power map in the radio state | ||||
| static void update_channel_max_power(char* phy, struct schema_Wifi_Radio_State *rstate) { | ||||
| 	int channels[64]; | ||||
| 	int channel_count = phy_get_channels(phy, channels); | ||||
| 	channel_count += phy_get_dfs_channels(phy, channels + channel_count); | ||||
|  | ||||
| 	// Clear the data previously stored in channel_max_power | ||||
| 	memset(rstate->channel_max_power_keys, 0, sizeof(rstate->channel_max_power_keys)); | ||||
| 	memset(rstate->channel_max_power, 0, sizeof(rstate->channel_max_power)); | ||||
| 	rstate->channel_max_power_len = 0; | ||||
|  | ||||
| 	// Set the new values for channel_max_power | ||||
| 	int i, index = 0; | ||||
| 	for (i = 0; i < channel_count && i < 64; i++) { | ||||
| 		int channel = channels[i]; | ||||
| 		int max_tx_power = phy_get_max_tx_power(phy, channel); | ||||
| 		set_channel_max_power(rstate, &index, channel, max_tx_power); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static int get_channel_tx_power_debugfs(char *stats_path, int *tx_power) | ||||
| { | ||||
| 	bool found = false; | ||||
| 	char str[512]; | ||||
| 	FILE * fp = NULL; | ||||
| 	int txpower = -1; | ||||
| 	int ret = -1; | ||||
|  | ||||
| 	fp = fopen(stats_path, "r"); | ||||
| 	if (!fp) { | ||||
| 		LOGE("%s: Failed to get tx power, stats file does not exist", __func__); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	const char *substr = "Channel TX power"; | ||||
|  | ||||
| 	while(fgets(str, 512, fp)) { | ||||
| 		if((strstr(str, substr)) != NULL) { | ||||
| 			char * plast = NULL, * pcur = str; | ||||
| 			while ((pcur = strtok( pcur, " "))) { | ||||
| 				plast = pcur; | ||||
| 				pcur = NULL; | ||||
| 			} | ||||
| 			txpower = atoi(plast); | ||||
| 			found = true; | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	if (!found) { | ||||
| 		LOGE("%s: Unable to find Tx Power in stats", __func__); | ||||
| 	} else { | ||||
| 		/* txpower is set as 2 units per dBm in FW */ | ||||
| 		*tx_power = txpower/2; | ||||
| 		ret = 0; | ||||
| 	} | ||||
| 	if (fp) | ||||
| 		fclose(fp); | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| static int get_channel_tx_power(char* phy, int *tx_power) | ||||
| { | ||||
| 	char ath_driver[ATH_DRIVER_NAME_LEN] = {'\0'}; | ||||
| 	char stats_path[128]; | ||||
|  | ||||
| 	if (phy_get_ath_driver_name(phy, ath_driver)) { | ||||
| 		LOGE("%s: Failed to get ATH driver name", __func__); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	if (!strncmp(ath_driver, "ath10k", ATH_DRIVER_NAME_LEN)) { | ||||
| 		snprintf(stats_path, sizeof(stats_path), | ||||
| 				"/sys/kernel/debug/ieee80211/%s/%s/fw_stats", phy, | ||||
| 				ath_driver); | ||||
| 	} else if (!strncmp(ath_driver, "ath11k", ATH_DRIVER_NAME_LEN)) { | ||||
| 		snprintf(stats_path, sizeof(stats_path), | ||||
| 				"/sys/kernel/debug/ieee80211/%s/%s/fw_stats/pdev_stats", phy, | ||||
| 				ath_driver); | ||||
| 	} else { | ||||
| 		LOGE("%s: Unknown ATH driver", __func__); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	if (get_channel_tx_power_debugfs(stats_path, tx_power)) { | ||||
| 		LOGE("%s: Failed to get Channel Tx Power", __func__); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| const struct uci_blob_param_list wifi_device_param = { | ||||
| 	.n_params = __WDEV_ATTR_MAX, | ||||
| 	.params = wifi_device_policy, | ||||
| @@ -297,7 +191,6 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C | ||||
| 	struct schema_Wifi_Radio_State  rstate; | ||||
| 	char phy[6]; | ||||
| 	int antenna; | ||||
| 	int tx_power = -1; | ||||
| 	uint32_t chan = 0; | ||||
|  | ||||
| 	LOGT("%s: get state", s->e.name); | ||||
| @@ -322,8 +215,6 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	update_channel_max_power(phy, &rstate); | ||||
|  | ||||
| 	if (tb[WDEV_ATTR_CHANNEL]) { | ||||
| 		nl80211_channel_get(phy, &chan); | ||||
| 		if(chan) | ||||
| @@ -338,14 +229,13 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C | ||||
| 	else | ||||
| 		SCHEMA_SET_INT(rstate.enabled, 1); | ||||
|  | ||||
| 	if (!get_channel_tx_power(phy, &tx_power)) { | ||||
| 		SCHEMA_SET_INT(rstate.tx_power, tx_power); | ||||
| 	} else { | ||||
| 		LOGE("%s: Failed to update Channel Tx Power", __func__); | ||||
| 		/* Set Tx Power to max OVSDB value */ | ||||
| 	if (tb[WDEV_ATTR_TXPOWER]) { | ||||
| 		SCHEMA_SET_INT(rstate.tx_power, blobmsg_get_u32(tb[WDEV_ATTR_TXPOWER])); | ||||
| 		/* 0 means max in UCI, 32 is max in OVSDB */ | ||||
| 		if (rstate.tx_power == 0) | ||||
| 			rstate.tx_power = 32; | ||||
| 	} else | ||||
| 		SCHEMA_SET_INT(rstate.tx_power, 32); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	if (tb[WDEV_ATTR_BEACON_INT]) | ||||
| 		SCHEMA_SET_INT(rstate.bcn_int, blobmsg_get_u32(tb[WDEV_ATTR_BEACON_INT])); | ||||
| @@ -386,8 +276,6 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C | ||||
|  | ||||
| 		if (m) { | ||||
| 			SCHEMA_SET_STR(rstate.hw_mode, m->hwmode); | ||||
| 			radio_fixup_set_hw_mode(rstate.if_name, m->hwmode); | ||||
|  | ||||
| 			if (m->htmode) | ||||
| 				SCHEMA_SET_STR(rstate.ht_mode, m->htmode); | ||||
| 			else | ||||
| @@ -401,6 +289,8 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C | ||||
|  | ||||
| 	if (tb[WDEV_ATTR_COUNTRY]) | ||||
| 		SCHEMA_SET_STR(rstate.country, blobmsg_get_string(tb[WDEV_ATTR_COUNTRY])); | ||||
| 	else | ||||
| 		SCHEMA_SET_STR(rstate.country, "CA"); | ||||
|  | ||||
| 	rstate.allowed_channels_len = phy_get_channels(phy, rstate.allowed_channels); | ||||
| 	rstate.allowed_channels_present = true; | ||||
| @@ -451,10 +341,8 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf, | ||||
| 	strncpy(ifname, rconf->if_name, sizeof(ifname)); | ||||
| 	strncpy(phy, target_map_ifname(ifname), sizeof(phy)); | ||||
|  | ||||
| 	if (changed->channel && rconf->channel) { | ||||
| 	if (changed->channel && rconf->channel) | ||||
| 		blobmsg_add_u32(&b, "channel", rconf->channel); | ||||
| 		rrm_radio_rebalance_channel(rconf); | ||||
| 	} | ||||
|  | ||||
| 	if (changed->enabled) | ||||
| 		blobmsg_add_u8(&b, "disabled", rconf->enabled ? 0 : 1); | ||||
| @@ -463,12 +351,9 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf, | ||||
| 		int max_tx_power; | ||||
| 		max_tx_power=phy_get_max_tx_power(phy,rconf->channel); | ||||
| 		if (rconf->tx_power<=max_tx_power) { | ||||
|  | ||||
| 			rrm_config_txpower(rconf->if_name, rconf->tx_power); | ||||
| 			blobmsg_add_u32(&b, "txpower", rconf->tx_power); | ||||
| 		} | ||||
| 		else { | ||||
| 			rrm_config_txpower(rconf->if_name, max_tx_power); | ||||
| 			blobmsg_add_u32(&b, "txpower", max_tx_power); | ||||
| 		} | ||||
| 	} | ||||
| @@ -522,31 +407,12 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf, | ||||
|  | ||||
| 	if ((changed->ht_mode) || (changed->hw_mode) || (changed->freq_band)) { | ||||
| 		int channel_freq; | ||||
| 		char buffer[8]; | ||||
| 		FILE *confFile_p; | ||||
| 		const char* hw_mode = rconf->hw_mode; | ||||
|  | ||||
| 		channel_freq = ieee80211_channel_to_frequency(rconf->channel); | ||||
| 		if (!strcmp(rconf->hw_mode, "auto")) { | ||||
| 			char command[] = "auto-conf "; | ||||
| 			strcat(command, phy); | ||||
| 			confFile_p = popen(command, "r"); | ||||
| 			 | ||||
| 			if (confFile_p) | ||||
| 			{ | ||||
| 				fgets(buffer, sizeof(buffer), confFile_p); | ||||
| 				pclose(confFile_p); | ||||
| 				buffer[strlen(buffer) - 1] = '\0'; // Remove extra \n that got added from 'echo' in script | ||||
| 				hw_mode = buffer; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		struct mode_map *m = mode_map_get_uci(rconf->freq_band, get_max_channel_bw_channel(channel_freq, rconf->ht_mode), hw_mode); | ||||
| 		struct mode_map *m = mode_map_get_uci(rconf->freq_band, get_max_channel_bw_channel(channel_freq, rconf->ht_mode), rconf->hw_mode); | ||||
| 		if (m) { | ||||
| 			blobmsg_add_string(&b, "htmode", m->ucihtmode); | ||||
| 			blobmsg_add_string(&b, "hwmode", m->ucihwmode); | ||||
| 			blobmsg_add_u32(&b, "chanbw", 20); | ||||
| 			radio_fixup_set_hw_mode(rconf->if_name, m->hwmode); | ||||
| 		} else | ||||
| 			 LOGE("%s: failed to set ht/hwmode", rconf->if_name); | ||||
| 	} | ||||
| @@ -570,14 +436,19 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf, | ||||
| 	blob_to_uci_section(uci, "wireless", rconf->if_name, "wifi-device", | ||||
| 			    b.head, &wifi_device_param, del.head); | ||||
|  | ||||
| 	uci_commit_all(uci); | ||||
| 	reload_config = 1; | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| static void periodic_task(void *arg) | ||||
| { | ||||
| 	int ret = 0; | ||||
| 	static int counter = 0; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
|  | ||||
| 	if ((counter % 15) && !reload_config) | ||||
| 		goto done; | ||||
|  | ||||
| 	if (startup_time.tv_sec) { | ||||
| 		static struct timespec current_time; | ||||
|  | ||||
| @@ -588,12 +459,18 @@ static void periodic_task(void *arg) | ||||
| 			radio_maverick(NULL); | ||||
| 		} | ||||
| 	} | ||||
| 	LOGD("periodic: start state update "); | ||||
| 	ret = uci_load(uci, "wireless", &wireless); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		goto out; | ||||
|  | ||||
| 	if (reload_config) { | ||||
| 		LOGT("periodic: reload config"); | ||||
| 		reload_config = 0; | ||||
| 		uci_commit_all(uci); | ||||
| 		sync(); | ||||
| 		system("reload_config"); | ||||
| 	} | ||||
|  | ||||
| 	LOGT("periodic: start state update "); | ||||
|  | ||||
| 	uci_load(uci, "wireless", &wireless); | ||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | ||||
| 		struct uci_section *s = uci_to_section(e); | ||||
|  | ||||
| @@ -608,10 +485,11 @@ static void periodic_task(void *arg) | ||||
| 			vif_state_update(s, NULL); | ||||
| 	} | ||||
| 	uci_unload(uci, wireless); | ||||
| 	LOGD("periodic: stop state update "); | ||||
| 	LOGT("periodic: stop state update "); | ||||
|  | ||||
| out: | ||||
| 	evsched_task_reschedule_ms(EVSCHED_SEC(15)); | ||||
| done: | ||||
| 	counter++; | ||||
| 	evsched_task_reschedule_ms(EVSCHED_SEC(1)); | ||||
| } | ||||
|  | ||||
| bool target_radio_config_init2(void) | ||||
| @@ -644,6 +522,7 @@ bool target_radio_config_init2(void) | ||||
| 	} | ||||
| 	if (invalidVifFound) { | ||||
| 		uci_commit(uci, &wireless, false); | ||||
| 		reload_config = 1; | ||||
| 	} | ||||
| 	uci_unload(uci, wireless); | ||||
|  | ||||
| @@ -726,7 +605,6 @@ void radio_maverick(void *arg) | ||||
| 	uci_unload(uci, wireless); | ||||
| } | ||||
|  | ||||
|  | ||||
| static void callback_Hotspot20_Config(ovsdb_update_monitor_t *mon, | ||||
| 				 struct schema_Hotspot20_Config *old, | ||||
| 				 struct schema_Hotspot20_Config *conf) | ||||
| @@ -746,7 +624,6 @@ static void callback_Hotspot20_Config(ovsdb_update_monitor_t *mon, | ||||
| 		LOG(ERR, "Hotspot20_Config: unexpected mon_type %d %s", mon->mon_type, mon->mon_uuid); | ||||
| 		break; | ||||
| 	} | ||||
| 	set_config_apply_timeout(mon); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| @@ -770,7 +647,6 @@ static void callback_Hotspot20_OSU_Providers(ovsdb_update_monitor_t *mon, | ||||
| 				mon->mon_type, mon->mon_uuid); | ||||
| 		break; | ||||
| 	} | ||||
| 	set_config_apply_timeout(mon); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| @@ -795,7 +671,6 @@ static void callback_Hotspot20_Icon_Config(ovsdb_update_monitor_t *mon, | ||||
| 				mon->mon_type, mon->mon_uuid); | ||||
| 		break; | ||||
| 	} | ||||
| 	set_config_apply_timeout(mon); | ||||
| 	return; | ||||
|  | ||||
| } | ||||
| @@ -816,34 +691,43 @@ const struct uci_blob_param_list apc_param = { | ||||
|  | ||||
| void APC_config_update(struct schema_APC_Config *conf) | ||||
| { | ||||
| 	struct uci_package *apc; | ||||
| 	struct blob_buf apcb = { }; | ||||
| 	struct uci_context *apc_uci; | ||||
| 	int rc = 0; | ||||
|  | ||||
| 	apc_uci = uci_alloc_context(); | ||||
| 	LOGD("APC: APC_config_update"); | ||||
|  | ||||
| 	blob_buf_init(&apcb, 0); | ||||
| 	if (conf && conf->enabled == true) { | ||||
| 		blobmsg_add_bool(&apcb, "enabled", 1); | ||||
| 		system("/etc/init.d/apc start"); | ||||
| 	} else { | ||||
| 		blobmsg_add_bool(&apcb, "enabled", 0); | ||||
| 		system("/etc/init.d/apc stop"); | ||||
| 	rc = uci_load(uci, "apc", &apc); | ||||
| 	if (rc) | ||||
| 	{ | ||||
| 		LOGD("%s: uci_load failed with rc %d", __func__, rc); | ||||
| 	} | ||||
|  | ||||
| 	blob_to_uci_section(apc_uci, "apc", "apc", "apc", | ||||
| 			apcb.head, &apc_param, NULL); | ||||
| 	blob_buf_init(&apcb, 0); | ||||
|  | ||||
| 	uci_commit_all(apc_uci); | ||||
| 	uci_free_context(apc_uci); | ||||
|  	if (conf->enabled_changed) { | ||||
| 		if (conf->enabled == true) { | ||||
| 			blobmsg_add_bool(&apcb, "enabled", 1); | ||||
| 			system("/etc/init.d/apc start"); | ||||
| 		} | ||||
| 		else { | ||||
| 			blobmsg_add_bool(&apcb, "enabled", 0); | ||||
| 			system("/etc/init.d/apc stop"); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|         blob_to_uci_section(uci, "apc", "apc", "apc", | ||||
|                             apcb.head, &apc_param, NULL); | ||||
|  | ||||
| 	uci_commit(uci, &apc, false); | ||||
| 	uci_unload(uci, apc); | ||||
| } | ||||
|  | ||||
| static void callback_APC_Config(ovsdb_update_monitor_t *mon, | ||||
|                                 struct schema_APC_Config *old, | ||||
|                                 struct schema_APC_Config *conf) | ||||
| { | ||||
| 	if (mon->mon_type == OVSDB_UPDATE_DEL) | ||||
| 		APC_config_update(NULL); | ||||
| 	else | ||||
| 	if (mon->mon_type != OVSDB_UPDATE_DEL) | ||||
| 		APC_config_update(conf); | ||||
|  | ||||
| } | ||||
| @@ -863,10 +747,6 @@ static void callback_APC_State(ovsdb_update_monitor_t *mon, | ||||
| 		radproxy_apc = 0; | ||||
| 		system("ubus call service event '{\"type\": \"config.change\", \"data\": { \"package\": \"wireless\" }}'"); | ||||
| 	} | ||||
|  | ||||
| 	/* APC changed: start / stop radius proxy service if needed */ | ||||
| 	vif_check_radius_proxy(); | ||||
|  | ||||
| } | ||||
|  | ||||
| struct schema_APC_State apc_state; | ||||
| @@ -887,105 +767,9 @@ static const struct blobmsg_policy apc_policy[__APC_ATTR_MAX] = { | ||||
|  | ||||
| struct schema_APC_Config apc_conf; | ||||
|  | ||||
|  | ||||
| bool apc_read_conf(struct schema_APC_Config *apcconf) | ||||
| { | ||||
| 	json_t *jrows; | ||||
| 	int cnt = 0; | ||||
| 	int i = 0; | ||||
| 	pjs_errmsg_t perr; | ||||
|  | ||||
| 	jrows = ovsdb_sync_select_where(SCHEMA_TABLE(APC_Config), NULL); | ||||
| 	if(!jrows) | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| 	cnt = json_array_size(jrows); | ||||
| 	if(!cnt) | ||||
| 	{ | ||||
| 		json_decref(jrows); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	for (i = 0; i < cnt; i++) | ||||
| 	{ | ||||
| 		if(!schema_APC_Config_from_json(apcconf, json_array_get(jrows, i), | ||||
| 						false, perr)) | ||||
| 		{ | ||||
| 			LOGE("Unable to parse APC Config column: %s", perr); | ||||
| 			json_decref(jrows); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	json_decref(jrows); | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool apc_read_state(struct schema_APC_State *apcst) | ||||
| { | ||||
| 	json_t *jrows; | ||||
| 	int cnt = 0; | ||||
| 	int i = 0; | ||||
| 	pjs_errmsg_t perr; | ||||
|  | ||||
| 	jrows = ovsdb_sync_select_where(SCHEMA_TABLE(APC_State), NULL); | ||||
| 	if(!jrows) | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| 	cnt = json_array_size(jrows); | ||||
| 	if(!cnt) | ||||
| 	{ | ||||
| 		json_decref(jrows); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	for (i = 0; i < cnt; i++) | ||||
| 	{ | ||||
| 		if(!schema_APC_State_from_json(apcst, json_array_get(jrows, i), | ||||
| 						false, perr)) | ||||
| 		{ | ||||
| 			LOGE("Unable to parse APC State column: %s", perr); | ||||
| 			json_decref(jrows); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	json_decref(jrows); | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| /* Check if apc conf is disabled, if disabled the update state | ||||
|  * with NC mode and return, this is to avoid the apc ubus | ||||
|  * notifications which come after the APC is disabled */ | ||||
| bool apc_conf_en() | ||||
| { | ||||
| 	struct schema_APC_Config apcconf; | ||||
| 	struct schema_APC_State apc_state; | ||||
|  | ||||
| 	if(apc_read_conf(&apcconf) == false) | ||||
| 		return true; | ||||
|  | ||||
| 	if (apcconf.enabled == false) { | ||||
| 		SCHEMA_SET_STR(apc_state.mode, "NC"); | ||||
| 		SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0"); | ||||
| 		SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0"); | ||||
| 		SCHEMA_SET_INT(apc_state.enabled, false); | ||||
| 		if (!ovsdb_table_update(&table_APC_State, &apc_state)) | ||||
| 			LOG(ERR, "APC_state: failed to update"); | ||||
| 		return false; | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| void apc_state_set(struct blob_attr *msg) | ||||
| { | ||||
| 	struct blob_attr *tb[__APC_ATTR_MAX] = { }; | ||||
| 	struct schema_APC_State apc_state; | ||||
|  | ||||
| 	if(apc_conf_en() == false) | ||||
| 		return; | ||||
|  | ||||
| 	blobmsg_parse(apc_policy, __APC_ATTR_MAX, tb, | ||||
| 		      blob_data(msg), blob_len(msg)); | ||||
| @@ -996,12 +780,12 @@ void apc_state_set(struct blob_attr *msg) | ||||
| 			       blobmsg_get_string(tb[APC_ATTR_MODE])); | ||||
| 	} | ||||
| 	if (tb[APC_ATTR_DR_ADDR]) { | ||||
| 		LOGD("APC dr-addr: %s", blobmsg_get_string(tb[APC_ATTR_DR_ADDR])); | ||||
| 		LOGD("APC br-addr: %s", blobmsg_get_string(tb[APC_ATTR_DR_ADDR])); | ||||
| 		SCHEMA_SET_STR(apc_state.dr_addr, | ||||
| 			       blobmsg_get_string(tb[APC_ATTR_DR_ADDR])); | ||||
| 	} | ||||
| 	if (tb[APC_ATTR_BDR_ADDR]) { | ||||
| 		LOGD("APC bdr-addr: %s", blobmsg_get_string(tb[APC_ATTR_BDR_ADDR])); | ||||
| 		LOGD("APC dbr-addr: %s", blobmsg_get_string(tb[APC_ATTR_BDR_ADDR])); | ||||
| 		SCHEMA_SET_STR(apc_state.bdr_addr, | ||||
| 			       blobmsg_get_string(tb[APC_ATTR_BDR_ADDR])); | ||||
| 	} | ||||
| @@ -1015,137 +799,21 @@ void apc_state_set(struct blob_attr *msg) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	LOGI("APC_state Updating: mode: %s, dr-addr: %s bdr-addr: %s",  | ||||
| 	     apc_state.mode, apc_state.dr_addr, apc_state.bdr_addr); | ||||
|  | ||||
| 	LOGD("APC_state Updating"); | ||||
| 	if (!ovsdb_table_update(&table_APC_State, &apc_state)) | ||||
| 		LOG(ERR, "APC_state: failed to update"); | ||||
|  | ||||
| } | ||||
|  | ||||
| static ovsdb_table_t table_Manager; | ||||
| static int conn_since = 0; | ||||
| #define APC_CLOUD_MON_PERIOD 60 | ||||
|  | ||||
| static void apc_enable(bool flag) { | ||||
|  | ||||
| 	struct schema_APC_State apc_state; | ||||
| 	 | ||||
| 	LOGI("APC %s: %s APC", __func__, flag?"enable":"disable"); | ||||
| 	if (flag == false) { | ||||
| 		if(apc_read_state(&apc_state) == false) { | ||||
| 			LOG(ERR, "%s: APC_State read failed", __func__); | ||||
| 			apc_state.enabled = true; | ||||
| 		} | ||||
|  | ||||
| 		if (apc_state.enabled == true) { | ||||
| 			SCHEMA_SET_INT(apc_conf.enabled, flag); | ||||
| 			if (!ovsdb_table_update(&table_APC_Config, &apc_conf)) { | ||||
| 				LOG(ERR, "%s:APC_Config: failed to update", __func__); | ||||
| 				return; | ||||
| 			} | ||||
| 			SCHEMA_SET_STR(apc_state.mode, "NC"); | ||||
| 			SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0"); | ||||
| 			SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0"); | ||||
| 			SCHEMA_SET_INT(apc_state.enabled, false); | ||||
| 			if (!ovsdb_table_update(&table_APC_State, &apc_state)) | ||||
| 				LOG(ERR, "APC_state: failed to update"); | ||||
| 		} | ||||
| 	} else { | ||||
| 		SCHEMA_SET_INT(apc_conf.enabled, flag); | ||||
| 		if (!ovsdb_table_update(&table_APC_Config, &apc_conf)) { | ||||
| 			LOG(ERR, "%s:APC_Config: failed to update", __func__); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void | ||||
| apc_cld_mon_cb(struct schema_Manager *mgr) | ||||
| { | ||||
| 	int i = 0; | ||||
| 	conn_since = 0; | ||||
| 	struct schema_APC_State apc_state; | ||||
| 	int ret = 0; | ||||
| 	int link = 1; | ||||
|  | ||||
| 	if(apc_read_state(&apc_state) == false) { | ||||
| 		LOG(ERR, "%s: APC_State read failed", __func__); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	/*Checks if wan ethernet port is down and disables apc*/ | ||||
| 	ret = system("/bin/check_wan_link.sh"); | ||||
| 	if (WIFEXITED(ret)) { | ||||
| 		link = WEXITSTATUS(ret); | ||||
| 		if (link == 0) { | ||||
| 			LOGD("APC link down"); | ||||
| 			apc_enable(false); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/*if cloud conn is false then disable apc*/ | ||||
| 	if (mgr->is_connected == false) { | ||||
| 			apc_enable(false); | ||||
| 	} | ||||
| 	else { | ||||
| 		for(i=0; i < mgr->status_len; i++) { | ||||
| 			if(!strncmp(mgr->status_keys[i] , "sec_since_connect", | ||||
| 					       strlen("sec_since_connect"))) { | ||||
| 				conn_since = atoi(mgr->status[i]); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		/*if the APC was stopped earlier, start it if connection good | ||||
| 		 * for atleast 60 secs*/ | ||||
| 		if (!apc_state.enabled && conn_since > APC_CLOUD_MON_PERIOD) { | ||||
| 			apc_enable(true); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /*Monitor the cloud connection*/ | ||||
| static void callback_Manager(ovsdb_update_monitor_t *mon, | ||||
| 			     struct schema_Manager *old, | ||||
| 			     struct schema_Manager *conf) | ||||
| { | ||||
| 	switch (mon->mon_type) | ||||
| 	{ | ||||
| 	case OVSDB_UPDATE_NEW: | ||||
| 	case OVSDB_UPDATE_MODIFY: | ||||
| 		apc_cld_mon_cb(conf); | ||||
| 		break; | ||||
|  | ||||
| 	case OVSDB_UPDATE_DEL: | ||||
| 		apc_enable(false); | ||||
| 		break; | ||||
|  | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| void cloud_disconn_mon(void) | ||||
| { | ||||
| 	OVSDB_TABLE_INIT_NO_KEY(Manager); | ||||
| 	OVSDB_TABLE_MONITOR(Manager, false); | ||||
| } | ||||
|  | ||||
| void apc_init() | ||||
| { | ||||
| 	/* APC Config */ | ||||
| 	OVSDB_TABLE_INIT_NO_KEY(APC_Config); | ||||
| 	OVSDB_TABLE_INIT(APC_Config, _uuid); | ||||
| 	OVSDB_TABLE_MONITOR(APC_Config, false); | ||||
| 	/* Disable APC by default, enable when cloud connected*/ | ||||
| 	SCHEMA_SET_INT(apc_conf.enabled, false); | ||||
| 	SCHEMA_SET_INT(apc_conf.enabled, true); | ||||
| 	LOGI("APC state/config Initialize"); | ||||
| 	if (!ovsdb_table_insert(&table_APC_Config, &apc_conf)) { | ||||
| 	if (!ovsdb_table_insert(&table_APC_Config, &apc_conf)) | ||||
| 		LOG(ERR, "APC_Config: failed to initialize"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	/* APC State */ | ||||
| 	OVSDB_TABLE_INIT_NO_KEY(APC_State); | ||||
| @@ -1154,62 +822,8 @@ void apc_init() | ||||
| 	SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0"); | ||||
| 	SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0"); | ||||
| 	SCHEMA_SET_INT(apc_state.enabled, false); | ||||
| 	if (!ovsdb_table_insert(&table_APC_State, &apc_state)) { | ||||
| 	if (!ovsdb_table_insert(&table_APC_State, &apc_state)) | ||||
| 		LOG(ERR, "APC_state: failed to initialize"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	/* Cloud connection monitor - if cloud unreachable | ||||
| 	 * for certain time, disable APC and enable after the | ||||
| 	 * cloud connection becomes stable. */ | ||||
| 	cloud_disconn_mon(); | ||||
|  | ||||
| } | ||||
|  | ||||
| static void apply_config_handler(struct timeout *timeout) | ||||
| { | ||||
| 	radius_proxy_fixup(); | ||||
| 	uci_commit_all(uci); | ||||
| 	sync(); | ||||
| 	LOGI("====Calling reload_config===="); | ||||
| 	system("/sbin/reload_config"); | ||||
| } | ||||
|  | ||||
| static struct timeout config_timer = { | ||||
| 		.cb = apply_config_handler | ||||
| }; | ||||
|  | ||||
| static void config_timer_task(void *arg) | ||||
| { | ||||
| 	timer_expiry_check(&config_timer); | ||||
| 	evsched_task_reschedule_ms(EVSCHED_SEC(1)); | ||||
| } | ||||
|  | ||||
| void set_config_apply_timeout(ovsdb_update_monitor_t *mon) | ||||
| { | ||||
| 	static bool firstconfig = true; | ||||
| 	LOGI("=====Received config update - table:%s uuid:%s Action:%d======", mon->mon_table, mon->mon_uuid, mon->mon_type); | ||||
| 	if(firstconfig) { | ||||
| 		firstconfig = false; | ||||
| 		timeout_set(&config_timer, CONFIG_APPLY_TIMEOUT * 1000); | ||||
| 		evsched_task(&config_timer_task, NULL, EVSCHED_SEC(1)); | ||||
| 	} else { | ||||
| 		timeout_set(&config_timer, CONFIG_APPLY_TIMEOUT * 1000); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon, | ||||
| 		struct schema_Wifi_Inet_Config *old_rec, | ||||
| 		struct schema_Wifi_Inet_Config *iconf) | ||||
| { | ||||
| 	set_config_apply_timeout(mon); | ||||
| } | ||||
|  | ||||
| static void callback_Node_Config(ovsdb_update_monitor_t *mon, | ||||
| 		struct schema_Node_Config *old, | ||||
| 		struct schema_Node_Config *conf) | ||||
| { | ||||
| 	set_config_apply_timeout(mon); | ||||
| } | ||||
|  | ||||
| bool target_radio_init(const struct target_radio_ops *ops) | ||||
| @@ -1240,17 +854,12 @@ bool target_radio_init(const struct target_radio_ops *ops) | ||||
| 	OVSDB_TABLE_INIT(Radius_Proxy_Config, _uuid); | ||||
| 	OVSDB_TABLE_MONITOR(Radius_Proxy_Config, false); | ||||
|  | ||||
| 	OVSDB_TABLE_INIT(Wifi_Inet_Config, _uuid); | ||||
| 	OVSDB_TABLE_MONITOR(Wifi_Inet_Config, false); | ||||
|  | ||||
| 	OVSDB_TABLE_INIT(Node_Config, _uuid); | ||||
| 	OVSDB_TABLE_MONITOR(Node_Config, false); | ||||
| 	apc_init(); | ||||
|  | ||||
| 	evsched_task(&periodic_task, NULL, EVSCHED_SEC(5)); | ||||
|  | ||||
| 	radio_nl80211_init(); | ||||
| 	radio_ubus_init(); | ||||
| 	apc_init(); | ||||
|  | ||||
| 	clock_gettime(CLOCK_MONOTONIC, &startup_time); | ||||
|  | ||||
|   | ||||
| @@ -14,6 +14,7 @@ | ||||
| #include <sys/types.h> | ||||
|  | ||||
| #include <linux/sockios.h> | ||||
| #include <linux/nl80211.h> | ||||
|  | ||||
| #include <netlink/msg.h> | ||||
| #include <netlink/attr.h> | ||||
| @@ -32,7 +33,6 @@ | ||||
|  | ||||
| #include <sys/time.h> | ||||
|  | ||||
| #include "nl80211_cpy.h" | ||||
| #include "target.h" | ||||
| #include "nl80211.h" | ||||
| #include "phy.h" | ||||
| @@ -50,8 +50,7 @@ | ||||
| extern struct ev_loop *wifihal_evloop; | ||||
| extern ovsdb_table_t table_Wifi_VIF_State; | ||||
| extern ovsdb_table_t table_Wifi_Associated_Clients; | ||||
| static struct unl unl_req; | ||||
| static struct unl unl_notify; | ||||
| static struct unl unl; | ||||
| static ev_io unl_io; | ||||
|  | ||||
| static int avl_addrcmp(const void *k1, const void *k2, void *ptr) | ||||
| @@ -149,31 +148,13 @@ static void nl80211_add_station(struct nlattr **tb, char *ifname) | ||||
|  | ||||
| 	addr = nla_data(tb[NL80211_ATTR_MAC]); | ||||
| 	vif_add_sta_rate_rule(addr, ifname); | ||||
| 	sta = avl_find_element(&sta_tree, addr, sta, avl); | ||||
| 	if (sta) | ||||
| 		return; | ||||
|  | ||||
| 	wif = avl_find_element(&wif_tree, ifname, wif, avl); | ||||
| 	if (!wif) | ||||
| 		return; | ||||
|  | ||||
| 	sta = avl_find_element(&sta_tree, addr, sta, avl); | ||||
| 	/* In case of roaming between interfaces (wif) the sta would | ||||
| 	 * already be in the sta_tree, but however it should be inserted | ||||
| 	 * again with new parent wif. Also, sta should be detached from | ||||
| 	 * old wif and attached to new wif. | ||||
| 	 * When the client roams between wifs, the sta assocs | ||||
| 	 * first to new wif(NEW_STATION nlevent) and then the hostapd | ||||
| 	 * deletes (DEL_STATION nlevent) the stale client from old wif. | ||||
| 	 */ | ||||
| 	if (sta) { | ||||
| 		if (!strcasecmp(wif->name, sta->parent->name)) { | ||||
| 			return; | ||||
| 		} | ||||
| 		else { | ||||
| 			list_del(&sta->iface); | ||||
| 			sta->parent = wif; | ||||
| 			list_add(&sta->iface, &wif->stas); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	sta = malloc(sizeof(*sta)); | ||||
| 	if (!sta) | ||||
| 		return; | ||||
| @@ -192,11 +173,6 @@ static void _nl80211_del_station(char *ifname, struct wifi_station *sta) | ||||
| { | ||||
| 	vif_del_sta_rate_rule(sta->addr, ifname); | ||||
| 	vif_add_station(sta, ifname, 0); | ||||
|  | ||||
| 	/* Dont delete sta if it has roamed to a new interface */ | ||||
| 	if (strcasecmp(ifname, sta->parent->name)) | ||||
| 		return; | ||||
|  | ||||
| 	list_del(&sta->iface); | ||||
| 	avl_delete(&sta_tree, &sta->avl); | ||||
| 	free(sta); | ||||
| @@ -418,7 +394,6 @@ static void nl80211_add_phy(struct nlattr **tb, char *name) | ||||
|  | ||||
| 					if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) { | ||||
| 						phy->chandfs[chan] = 1; | ||||
| 						phy->chanpwr[chan] = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]); | ||||
| 						phy->chandisabled[chan] = 0; | ||||
| 						LOG(DEBUG, "%s: found dfs channel %d", phy->name, chan); | ||||
| 						continue; | ||||
| @@ -496,10 +471,10 @@ int nl80211_channel_get(char *name, unsigned int *chan) | ||||
| 	if (!idx) | ||||
| 		return -1; | ||||
|  | ||||
| 	msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_INTERFACE, true); | ||||
| 	msg = unl_genl_msg(&unl, NL80211_CMD_GET_INTERFACE, true); | ||||
| 	nla_put_u32(msg, NL80211_ATTR_IFINDEX, idx); | ||||
|  | ||||
| 	unl_genl_request(&unl_req, msg, nl80211_channel_recv, chan); | ||||
| 	unl_genl_request(&unl, msg, nl80211_channel_recv, chan); | ||||
|  | ||||
| 	phy->current_channel = *chan; | ||||
|  | ||||
| @@ -587,7 +562,7 @@ static void nl80211_ev(struct ev_loop *ev, struct ev_io *io, int event) | ||||
| 	nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, NULL); | ||||
| 	nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); | ||||
| 	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_recv, NULL); | ||||
| 	nl_recvmsgs(unl_notify.sock, cb); | ||||
| 	nl_recvmsgs(unl.sock, cb); | ||||
| 	nl_cb_put(cb); | ||||
| } | ||||
|  | ||||
| @@ -601,51 +576,28 @@ static void vif_poll_stations(void *arg) | ||||
| 	evsched_task_reschedule_ms(EVSCHED_SEC(STA_POLL_INTERVAL)); | ||||
| } | ||||
|  | ||||
| void vif_get_assoc_stations(void) | ||||
| { | ||||
| 	struct wifi_iface *wif = NULL; | ||||
|  | ||||
|  	avl_for_each_element(&wif_tree, wif, avl) { | ||||
| 		struct nl_msg *msg; | ||||
| 		msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_STATION, true); | ||||
| 		nla_put_u32(msg, NL80211_ATTR_IFINDEX, wif->ifidx); | ||||
| 		unl_genl_request(&unl_req, msg, nl80211_recv, NULL); | ||||
|  	} | ||||
| } | ||||
|  | ||||
| int radio_nl80211_init(void) | ||||
| { | ||||
| 	struct nl_msg *msg; | ||||
|  | ||||
| 	if (unl_genl_init(&unl_req, "nl80211") < 0) { | ||||
| 	if (unl_genl_init(&unl, "nl80211") < 0) { | ||||
| 		syslog(0, "nl80211: failed to connect\n"); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	if (unl_genl_init(&unl_notify, "nl80211") < 0) { | ||||
| 		syslog(0, "nl80211: failed to connect\n"); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	msg = unl_genl_msg(&unl, NL80211_CMD_GET_WIPHY, true); | ||||
| 	unl_genl_request(&unl, msg, nl80211_recv, NULL); | ||||
| 	msg = unl_genl_msg(&unl, NL80211_CMD_GET_INTERFACE, true); | ||||
| 	unl_genl_request(&unl, msg, nl80211_recv, NULL); | ||||
|  | ||||
| 	msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_WIPHY, true); | ||||
| 	unl_genl_request(&unl_req, msg, nl80211_recv, NULL); | ||||
| 	msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_INTERFACE, true); | ||||
| 	unl_genl_request(&unl_req, msg, nl80211_recv, NULL); | ||||
| 	unl_genl_subscribe(&unl, "config"); | ||||
| 	unl_genl_subscribe(&unl, "mlme"); | ||||
| 	unl_genl_subscribe(&unl, "vendor"); | ||||
|  | ||||
| 	unl_genl_subscribe(&unl_notify, "config"); | ||||
| 	unl_genl_subscribe(&unl_notify, "mlme"); | ||||
| 	unl_genl_subscribe(&unl_notify, "vendor"); | ||||
|  | ||||
|  | ||||
| 	if (nl_socket_set_buffer_size(unl_notify.sock, 262144, 0) < 0) | ||||
| 	if (nl_socket_set_buffer_size(unl.sock, 262144, 0) < 0) | ||||
| 		LOGE("radio_nl80211: Failed to set nl socket buffer size"); | ||||
|  | ||||
| 	if (nl_socket_set_nonblocking(unl_notify.sock)) | ||||
| 		LOGE("radio_nl80211: Failed to set socket in the non blocking mode"); | ||||
| 	/* Get already associated stations if any */ | ||||
| 	vif_get_assoc_stations(); | ||||
|  | ||||
| 	ev_io_init(&unl_io, nl80211_ev, unl_notify.sock->s_fd, EV_READ); | ||||
| 	ev_io_init(&unl_io, nl80211_ev, unl.sock->s_fd, EV_READ); | ||||
|         ev_io_start(wifihal_evloop, &unl_io); | ||||
| 	evsched_task(&vif_poll_stations, NULL, EVSCHED_SEC(5)); | ||||
|  | ||||
|   | ||||
| @@ -10,47 +10,6 @@ | ||||
| extern struct ev_loop *wifihal_evloop; | ||||
| static struct ubus_context *ubus; | ||||
| extern struct ev_loop *wifihal_evloop; | ||||
| extern void apc_state_set(struct blob_attr *msg); | ||||
| struct blob_buf ub = { }; | ||||
|  | ||||
| int ubus_set_signal_thresholds(const char *if_name, int connect, int stay) | ||||
| { | ||||
| 	uint32_t id; | ||||
| 	char path[64]; | ||||
|  | ||||
| 	if (connect > 0 && stay > 0) | ||||
| 		return -1; | ||||
|  | ||||
| 	snprintf(path, sizeof(path), "hostapd.%s", if_name); | ||||
|  | ||||
| 	if (ubus_lookup_id(ubus, path, &id)) | ||||
| 		return -1; | ||||
| 	blob_buf_init(&b, 0); | ||||
|  | ||||
| 	blobmsg_add_u32(&b, "connect", connect); | ||||
| 	blobmsg_add_u32(&b, "stay", stay); | ||||
|  | ||||
| 	return ubus_invoke(ubus, id, "set_required_signal", b.head, NULL, NULL, 1000); | ||||
| } | ||||
|  | ||||
| int ubus_set_hapd_param(const char *if_name, const char *param, const char *pval) | ||||
| { | ||||
|  | ||||
| 	uint32_t id; | ||||
| 	char path[64]; | ||||
|  | ||||
| 	snprintf(path, sizeof(path), "hostapd"); | ||||
|  | ||||
| 	if (ubus_lookup_id(ubus, path, &id)) | ||||
| 		return -1; | ||||
| 	blob_buf_init(&b, 0); | ||||
|  | ||||
| 	blobmsg_add_string(&b, "iface", if_name); | ||||
| 	blobmsg_add_string(&b, "param", param); | ||||
| 	blobmsg_add_string(&b, "param_val", pval); | ||||
|  | ||||
| 	return ubus_invoke(ubus, id, "param_mod", b.head, NULL, NULL, 1000); | ||||
| } | ||||
|  | ||||
| int hapd_rrm_enable(char *name, int neighbor, int beacon) | ||||
| { | ||||
| @@ -91,48 +50,6 @@ int hapd_rrm_set_neighbors(char *name, struct rrm_neighbor *neigh, int count) | ||||
| 	return ubus_invoke(ubus, id, "rrm_nr_set", b.head, NULL, NULL, 1000); | ||||
| } | ||||
|  | ||||
| int ubus_set_channel_switch(const char *if_name, uint32_t frequency, | ||||
| 			    const char *hw_mode, int channel_bandwidth, | ||||
| 			    int sec_chan_offset, int reason) | ||||
| { | ||||
| 	uint32_t id; | ||||
| 	char path[64]; | ||||
|  | ||||
| 	snprintf(path, sizeof(path), "hostapd.%s", if_name); | ||||
|  | ||||
| 	if (ubus_lookup_id(ubus, path, &id)) | ||||
| 		return -1; | ||||
| 	blob_buf_init(&ub, 0); | ||||
|  | ||||
| 	if (!strncmp(hw_mode, "11n", strlen("11n"))) { | ||||
| 		blobmsg_add_u8(&ub, "ht", 1); | ||||
| 	} else if (!strncmp(hw_mode, "11ac", strlen("11ac"))) { | ||||
| 		blobmsg_add_u8(&ub, "ht", 1); | ||||
| 		blobmsg_add_u8(&ub, "vht", 1); | ||||
| 	} else if (!strncmp(hw_mode, "11ax", strlen("11ax"))) { | ||||
| 		blobmsg_add_u8(&ub, "ht", 1); | ||||
| 		blobmsg_add_u8(&ub, "vht", 1); | ||||
| 		blobmsg_add_u8(&ub, "he", 1); | ||||
| 	} | ||||
|  | ||||
| 	if (channel_bandwidth == 40) | ||||
| 		blobmsg_add_u32(&ub, "center_freq1", frequency+10); | ||||
| 	else if (channel_bandwidth == 80) | ||||
| 		blobmsg_add_u32(&ub, "center_freq1", frequency+30); | ||||
| 	else if (channel_bandwidth == 20) | ||||
| 		blobmsg_add_u32(&ub, "center_freq1", frequency); | ||||
| 	else if (channel_bandwidth == 160) | ||||
| 		blobmsg_add_u32(&ub, "center_freq1", frequency+70); | ||||
|  | ||||
| 	blobmsg_add_u32(&ub, "freq", frequency); | ||||
| 	blobmsg_add_u32(&ub, "bcn_count", 5); | ||||
| 	blobmsg_add_u32(&ub, "bandwidth", channel_bandwidth); | ||||
| 	blobmsg_add_u32(&ub, "sec_channel_offset", sec_chan_offset); | ||||
| 	blobmsg_add_u32(&ub, "reason", reason); | ||||
| 	 | ||||
| 	return ubus_invoke(ubus, id, "switch_chan", ub.head, NULL, NULL, 1000); | ||||
| } | ||||
|  | ||||
| enum { | ||||
| 	DUMMY_PARAMETER, | ||||
| 	__DUMMY_MAX, | ||||
| @@ -284,33 +201,8 @@ static void radio_ubus_connect(struct ubus_context *ctx) | ||||
| 	ubus_add_object(ubus, &radio_ubus_object); | ||||
| } | ||||
|  | ||||
| static int radio_ubus_notify(struct ubus_context *ctx, struct ubus_object *obj, | ||||
| 			     struct ubus_request_data *req, const char *method, | ||||
| 			     struct blob_attr *msg) | ||||
| { | ||||
| 	char *str; | ||||
|  | ||||
| 	str = blobmsg_format_json(msg, true); | ||||
| 	LOGD("ubus: Received ubus notify '%s': %s\n", method, str); | ||||
| 	free(str); | ||||
|  | ||||
| 	if (!strncmp(method, "apc", 3)) { | ||||
| 		LOGD("APC notification Received"); | ||||
| 		apc_state_set(msg); | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static struct ubus_instance ubus_instance = { | ||||
| 	.connect = radio_ubus_connect, | ||||
| 	.notify = radio_ubus_notify, | ||||
| 	.list = { | ||||
| 			{ | ||||
| 				.path = "apc", | ||||
| 			}, | ||||
| 		}, | ||||
| 	.len = 1, | ||||
| }; | ||||
|  | ||||
| int radio_ubus_init(void) | ||||
|   | ||||
| @@ -27,6 +27,7 @@ | ||||
| #include "utils.h" | ||||
| #include "radius_proxy.h" | ||||
|  | ||||
| ovsdb_table_t table_Radius_Proxy_Config; | ||||
| struct blob_buf uci_buf = {}; | ||||
| struct blob_attr *n; | ||||
| extern ovsdb_table_t table_APC_State; | ||||
| @@ -34,13 +35,11 @@ extern json_t* ovsdb_table_where(ovsdb_table_t *table, void *record); | ||||
|  | ||||
| enum { | ||||
| 	RADIUS_PROXY_OPTIONS_LISTEN_UDP, | ||||
| 	RADIUS_PROXY_OPTIONS_NAME, | ||||
| 	__RADIUS_PROXY_OPTIONS_MAX | ||||
| }; | ||||
|  | ||||
| enum { | ||||
| 	RADIUS_PROXY_CLIENT_NAME, | ||||
| 	RADIUS_PROXY_CLIENT_HOST, | ||||
| 	RADIUS_PROXY_CLIENT_TYPE, | ||||
| 	RADIUS_PROXY_CLIENT_SECRET, | ||||
| 	__RADIUS_PROXY_CLIENT_MAX | ||||
| @@ -48,14 +47,11 @@ enum { | ||||
|  | ||||
| enum { | ||||
| 	RADIUS_PROXY_SERVER_NAME, | ||||
| 	RADIUS_PROXY_SERVER_HOST, | ||||
| 	RADIUS_PROXY_SERVER_TYPE, | ||||
| 	RADIUS_PROXY_SERVER_SECRET, | ||||
| 	RADIUS_PROXY_SERVER_PORT, | ||||
| 	RADIUS_PROXY_SERVER_STATUS, | ||||
| 	RADIUS_PROXY_SERVER_TLS, | ||||
| 	RADIUS_PROXY_SERVER_CERT_NAME_CHECK, | ||||
| 	RADIUS_PROXY_SERVER_DYNAMIC_LOOKUP, | ||||
| 	__RADIUS_PROXY_SERVER_MAX | ||||
| }; | ||||
|  | ||||
| @@ -78,12 +74,10 @@ enum { | ||||
|  | ||||
| static const struct blobmsg_policy radius_proxy_options_policy[__RADIUS_PROXY_OPTIONS_MAX] = { | ||||
| 		[RADIUS_PROXY_OPTIONS_LISTEN_UDP] = { .name = "ListenUDP", BLOBMSG_TYPE_ARRAY }, | ||||
| 		[RADIUS_PROXY_OPTIONS_NAME] = { .name = "name", BLOBMSG_TYPE_STRING }, | ||||
| }; | ||||
|  | ||||
| static const struct blobmsg_policy radius_proxy_client_policy[__RADIUS_PROXY_CLIENT_MAX] = { | ||||
| 		[RADIUS_PROXY_CLIENT_NAME] = { .name = "name", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_CLIENT_HOST] = { .name = "host", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_CLIENT_TYPE] = { .name = "type", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_CLIENT_SECRET] = { .name = "secret", BLOBMSG_TYPE_STRING }, | ||||
| }; | ||||
| @@ -98,14 +92,11 @@ static const struct blobmsg_policy radius_proxy_tls_policy[__RADIUS_PROXY_TLS_MA | ||||
|  | ||||
| static const struct blobmsg_policy radius_proxy_server_policy[__RADIUS_PROXY_SERVER_MAX] = { | ||||
| 		[RADIUS_PROXY_SERVER_NAME] = { .name = "name", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_SERVER_HOST] = { .name = "host", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_SERVER_TYPE] = { .name = "type", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_SERVER_SECRET] = { .name = "secret", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_SERVER_PORT] = { .name = "port", BLOBMSG_TYPE_INT32 }, | ||||
| 		[RADIUS_PROXY_SERVER_STATUS] = { .name = "statusServer", BLOBMSG_TYPE_BOOL }, | ||||
| 		[RADIUS_PROXY_SERVER_TLS] = { .name = "tls", BLOBMSG_TYPE_STRING }, | ||||
| 		[RADIUS_PROXY_SERVER_CERT_NAME_CHECK] = { .name = "certificateNameCheck", BLOBMSG_TYPE_BOOL }, | ||||
| 		[RADIUS_PROXY_SERVER_DYNAMIC_LOOKUP] = { .name = "dynamicLookupCommand", BLOBMSG_TYPE_STRING }, | ||||
| }; | ||||
|  | ||||
| static const struct blobmsg_policy radius_proxy_realm_policy[__RADIUS_PROXY_REALM_MAX] = { | ||||
| @@ -149,31 +140,21 @@ static bool radsec_download_cert(char *cert_name, char *dir_name, char *cert_url | ||||
| { | ||||
| 	CURL *curl; | ||||
| 	FILE *fp; | ||||
| 	CURLcode curl_ret; | ||||
| 	CURLcode res; | ||||
| 	char path[200]; | ||||
| 	char dir_path[200]; | ||||
| 	char name[32]; | ||||
| 	char dir[32]; | ||||
| 	char *gw_clientcert = "/usr/opensync/certs/client.pem"; | ||||
| 	char *gw_clientkey = "/usr/opensync/certs/client_dec.key"; | ||||
| 	struct stat stat_buf; | ||||
|  | ||||
| 	strcpy(name, cert_name); | ||||
| 	strcpy(dir, dir_name); | ||||
| 	sprintf(dir_path, "/tmp/radsec/certs/%s", dir); | ||||
| 	sprintf(path, "/tmp/radsec/certs/%s/%s", dir, name); | ||||
|  | ||||
| 	if (stat(dir_path, &stat_buf) == -1) | ||||
| 	{ | ||||
| 		char cmd[200]; | ||||
| 		sprintf(cmd, "mkdir -p %s", dir_path); | ||||
| 		system(cmd); | ||||
| 	} | ||||
|  | ||||
| 	curl = curl_easy_init(); | ||||
| 	if (curl) | ||||
| 	{ | ||||
| 		fp = fopen(path, "wb"); | ||||
| 		fp = fopen(path,"wb"); | ||||
|  | ||||
| 		if (fp == NULL) | ||||
| 		{ | ||||
| @@ -196,60 +177,55 @@ static bool radsec_download_cert(char *cert_name, char *dir_name, char *cert_url | ||||
| 		curl_easy_setopt(curl, CURLOPT_URL, cert_url); | ||||
| 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, file_write); | ||||
| 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); | ||||
| 		curl_ret = curl_easy_perform(curl); | ||||
|  | ||||
| 		if (curl_ret != CURLE_OK) | ||||
| 		{ | ||||
| 			LOGE("radsec: certificate download failed %s", curl_easy_strerror(curl_ret)); | ||||
| 			curl_easy_cleanup(curl); | ||||
| 			fclose(fp); | ||||
| 			remove(path); | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		res = curl_easy_perform(curl); | ||||
| 		curl_easy_cleanup(curl); | ||||
| 		fclose(fp); | ||||
| 		return res; | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf) | ||||
| static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | ||||
| { | ||||
| 	int i = 0; | ||||
| 	int i=0; | ||||
| 	char path[200]; | ||||
| 	char name[256]; | ||||
| 	char server_name[256] = {}; | ||||
| 	char acct_server_name[256] = {}; | ||||
| 	char tls_name[256] = {}; | ||||
| 	struct schema_APC_State apc_conf; | ||||
|  | ||||
| 	/* Configure only if APC selects this as master AP (DR) */ | ||||
| 	json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf); | ||||
| 	if (false == ovsdb_table_select_one_where(&table_APC_State, | ||||
| 			where, &apc_conf)) { | ||||
| 		LOG(INFO, "APC_State read failed"); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	if (!strncmp(apc_conf.mode, "OR", 2) || !strncmp(apc_conf.mode, "BDR", 2)) | ||||
| 		return false; | ||||
|  | ||||
| 	/* Configure options block */ | ||||
| 	blob_buf_init(&uci_buf, 0); | ||||
| 	n = blobmsg_open_array(&uci_buf,"ListenUDP"); | ||||
| 	blobmsg_add_string(&uci_buf, NULL, "*:1812"); | ||||
| 	blobmsg_add_string(&uci_buf, NULL, "*:1813"); | ||||
| 	blobmsg_add_string(&uci_buf, NULL, "127.0.0.1:1812"); | ||||
| 	blobmsg_add_string(&uci_buf, NULL, "127.0.0.1:1813"); | ||||
| 	blobmsg_close_array(&uci_buf, n); | ||||
| 	memset(name, '\0', sizeof(name)); | ||||
| 	sprintf(name, "%s%s", conf->radius_config_name, "options"); | ||||
| 	blobmsg_add_string(&uci_buf, "name", name); | ||||
| 	blob_to_uci_section(uci, "radsecproxy", name, "options", | ||||
| 			uci_buf.head, &radius_proxy_options_param, NULL); | ||||
|  | ||||
| 	/* Configure client block */ | ||||
| 	blob_buf_init(&uci_buf, 0); | ||||
| 	blobmsg_add_string(&uci_buf, "host", "0.0.0.0/0"); | ||||
| 	blobmsg_add_string(&uci_buf, "name", "localhost"); | ||||
| 	blobmsg_add_string(&uci_buf, "type", "udp"); | ||||
| 	blobmsg_add_string(&uci_buf, "secret", "secret"); | ||||
| 	memset(name, '\0', sizeof(name)); | ||||
| 	sprintf(name, "%s%s", conf->radius_config_name, "client"); | ||||
| 	blobmsg_add_string(&uci_buf, "name", name); | ||||
| 	blob_to_uci_section(uci, "radsecproxy", name, "client", | ||||
| 			uci_buf.head, &radius_proxy_client_param, NULL); | ||||
|  | ||||
| 	/* Configure TLS/non-TLS and server blocks */ | ||||
| 	sprintf(server_name, "%s%s", conf->radius_config_name, "server"); | ||||
| 	sprintf(acct_server_name, "%s%s", conf->radius_config_name, "Acctserver"); | ||||
| 	sprintf(tls_name, "%s%s", conf->radius_config_name, "tls"); | ||||
| 	if (conf->radsec) | ||||
| 	{ | ||||
| 		blob_buf_init(&uci_buf, 0); | ||||
| @@ -260,7 +236,7 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf) | ||||
| 		radsec_download_cert("clientdec.key", | ||||
| 				conf->radius_config_name, conf->client_key); | ||||
|  | ||||
| 		blobmsg_add_string(&uci_buf, "name", tls_name); | ||||
| 		blobmsg_add_string(&uci_buf, "name", conf->server); | ||||
|  | ||||
| 		memset(path, '\0', sizeof(path)); | ||||
| 		sprintf(path, "/tmp/radsec/certs/%s/cacert.pem", | ||||
| @@ -280,56 +256,34 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf) | ||||
| 		if (strlen(conf->passphrase) > 0) | ||||
| 			blobmsg_add_string(&uci_buf, "certificateKeyPassword", conf->passphrase); | ||||
|  | ||||
| 		blob_to_uci_section(uci, "radsecproxy", tls_name, | ||||
| 		memset(name, '\0', sizeof(name)); | ||||
| 		sprintf(name, "%s%s", conf->radius_config_name, "tls"); | ||||
| 		blob_to_uci_section(uci, "radsecproxy", name, | ||||
| 				"tls", uci_buf.head, &radius_proxy_tls_param, NULL); | ||||
|  | ||||
| 		blob_buf_init(&uci_buf, 0); | ||||
| 		if (conf->auto_discover) | ||||
| 		{ /* auto discover radsec server address via realm DNS NAPTR record */ | ||||
| 			blobmsg_add_string(&uci_buf, "dynamicLookupCommand", "/bin/dynamic_lookup.sh"); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			blobmsg_add_string(&uci_buf, "host", conf->server); | ||||
| 			blobmsg_add_u32(&uci_buf, "port", conf->port); | ||||
| 			blobmsg_add_string(&uci_buf, "secret", "radsec"); | ||||
| 		} | ||||
| 		blobmsg_add_string(&uci_buf, "name", server_name); | ||||
| 		blobmsg_add_string(&uci_buf, "name", conf->server); | ||||
| 		blobmsg_add_string(&uci_buf, "type", "tls"); | ||||
| 		blobmsg_add_string(&uci_buf, "tls", tls_name); | ||||
| 		blobmsg_add_string(&uci_buf, "tls", conf->server); | ||||
| 		blobmsg_add_string(&uci_buf, "secret", "radsec"); | ||||
| 		blobmsg_add_bool(&uci_buf, "statusServer", 0); | ||||
| 		blobmsg_add_bool(&uci_buf, "certificateNameCheck", 0); | ||||
| 		blob_to_uci_section(uci, "radsecproxy", server_name, "server", | ||||
| 		memset(name, '\0', sizeof(name)); | ||||
| 		sprintf(name, "%s%s", conf->radius_config_name, "server"); | ||||
| 		blob_to_uci_section(uci, "radsecproxy", name, "server", | ||||
| 				uci_buf.head, &radius_proxy_server_param, NULL); | ||||
| 	} | ||||
| 	else /* non-TLS block */ | ||||
| 	{ | ||||
| 		/* Authentication server */ | ||||
| 		blob_buf_init(&uci_buf, 0); | ||||
| 		blobmsg_add_string(&uci_buf, "name", server_name); | ||||
| 		blobmsg_add_string(&uci_buf, "host", conf->server); | ||||
| 		blobmsg_add_string(&uci_buf, "name", conf->server); | ||||
| 		blobmsg_add_string(&uci_buf, "type", "udp"); | ||||
| 		if (strlen(conf->secret) > 0) | ||||
| 			blobmsg_add_string(&uci_buf, "secret", conf->secret); | ||||
| 		if (conf->port > 0) | ||||
| 			blobmsg_add_u32(&uci_buf, "port", conf->port); | ||||
| 		blob_to_uci_section(uci, "radsecproxy", server_name, "server", | ||||
| 		memset(name, '\0', sizeof(name)); | ||||
| 		sprintf(name, "%s%s", conf->radius_config_name, "server"); | ||||
| 		blob_to_uci_section(uci, "radsecproxy", name, "server", | ||||
| 				uci_buf.head, &radius_proxy_server_param, NULL); | ||||
|  | ||||
| 		/* Accounting server */ | ||||
| 		if (strlen(conf->acct_server) > 0) | ||||
| 		{ | ||||
| 			blob_buf_init(&uci_buf, 0); | ||||
| 			blobmsg_add_string(&uci_buf, "name", acct_server_name); | ||||
| 			blobmsg_add_string(&uci_buf, "host", conf->acct_server); | ||||
| 			blobmsg_add_string(&uci_buf, "type", "udp"); | ||||
| 			if (strlen(conf->secret) > 0) | ||||
| 				blobmsg_add_string(&uci_buf, "secret", conf->acct_secret); | ||||
| 			if (conf->acct_port > 0) | ||||
| 				blobmsg_add_u32(&uci_buf, "port", conf->acct_port); | ||||
| 			blob_to_uci_section(uci, "radsecproxy", acct_server_name, "server", | ||||
| 								uci_buf.head, &radius_proxy_server_param, NULL); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* Configure realm block */ | ||||
| @@ -338,142 +292,41 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf) | ||||
| 		blob_buf_init(&uci_buf, 0); | ||||
| 		blobmsg_add_string(&uci_buf, "name", conf->realm[i]); | ||||
| 		n = blobmsg_open_array(&uci_buf,"server"); | ||||
| 		blobmsg_add_string(&uci_buf, NULL, server_name); | ||||
| 		blobmsg_add_string(&uci_buf, NULL, conf->server); | ||||
| 		blobmsg_close_array(&uci_buf, n); | ||||
| 		n = blobmsg_open_array(&uci_buf,"accountingServer"); | ||||
| 		blobmsg_add_string(&uci_buf, NULL, conf->server); | ||||
| 		blobmsg_close_array(&uci_buf, n); | ||||
| 		if (conf->radsec) | ||||
| 		{ /* Accounting server same as auth server */ | ||||
| 			n = blobmsg_open_array(&uci_buf, "accountingServer"); | ||||
| 			blobmsg_add_string(&uci_buf, NULL, server_name); | ||||
| 			blobmsg_close_array(&uci_buf, n); | ||||
| 		} | ||||
| 		else if (strlen(conf->acct_server) > 0) | ||||
| 		{ /* non-TLS case where accounting server is configured */ | ||||
| 			n = blobmsg_open_array(&uci_buf, "accountingServer"); | ||||
| 			blobmsg_add_string(&uci_buf, NULL, acct_server_name); | ||||
| 			blobmsg_close_array(&uci_buf, n); | ||||
| 		} | ||||
| 		memset(name, '\0', sizeof(name)); | ||||
| 		sprintf(name, "%s%s%d", conf->radius_config_name, "realm", i); | ||||
| 		blob_to_uci_section(uci, "radsecproxy", name, "realm", | ||||
| 				uci_buf.head, &radius_proxy_realm_param, NULL); | ||||
| 	} | ||||
|  | ||||
| 	uci_commit_all(uci); | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| void radius_proxy_fixup() | ||||
| { | ||||
| 	struct uci_package *radsecproxy; | ||||
| 	struct uci_context *proxy_ctx; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
| 	int ret=0, wildcard_count=0, j=0, section_count=0; | ||||
| 	char *acct_server = NULL, *auth_server = NULL; | ||||
| 	struct uci_section *wildcard_section = NULL; | ||||
| 	struct blob_attr *tb[__RADIUS_PROXY_REALM_MAX] = {}; | ||||
| 	struct blob_attr *n; | ||||
| 	char section_name[128] = {}; | ||||
|  | ||||
| 	if (!ovsdb_table_select_where(&table_Radius_Proxy_Config, NULL, &j)) | ||||
| 		return; | ||||
|  | ||||
| 	proxy_ctx = uci_alloc_context(); | ||||
| 	ret = uci_load(proxy_ctx, "radsecproxy", &radsecproxy); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		if (proxy_ctx) | ||||
| 			uci_free_context(proxy_ctx); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	uci_foreach_element_safe(&radsecproxy->sections, tmp, e) { | ||||
| 		struct uci_section *s = uci_to_section(e); | ||||
| 		if ((s == NULL) || (s->type == NULL)) continue; | ||||
| 		if (!strcmp(s->type, "realm")) { | ||||
| 			const char *realm_name; | ||||
| 			section_count++; | ||||
| 			realm_name = uci_lookup_option_string(proxy_ctx, s, "name"); | ||||
| 			if (wildcard_count == 0 && (!strcmp((char *)realm_name, "*"))) { | ||||
| 				wildcard_section = s; | ||||
| 				wildcard_count = section_count; | ||||
| 			} | ||||
| 		} | ||||
| 		else { | ||||
| 			continue; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	TRACEF("wildcard_count: %d section_count: %d", wildcard_count, section_count); | ||||
|  | ||||
| 	if ((wildcard_count != section_count) && (wildcard_section != NULL)) { | ||||
| 		blob_buf_init(&b, 0); | ||||
| 		uci_to_blob(&b, wildcard_section, &radius_proxy_realm_param); | ||||
| 		blobmsg_parse(radius_proxy_realm_policy, __RADIUS_PROXY_REALM_MAX, tb, | ||||
| 						blob_data(b.head), blob_len(b.head)); | ||||
|  | ||||
| 		/* Delete and re-add the wildcard section */ | ||||
| 		struct blob_attr *ttb[1]; | ||||
| 		blobmsg_parse_array(radius_proxy_realm_policy, ARRAY_SIZE(ttb), ttb, | ||||
| 							blobmsg_data(tb[RADIUS_PROXY_REALM_AUTH_SERVER]), | ||||
| 							blobmsg_data_len(tb[RADIUS_PROXY_REALM_AUTH_SERVER])); | ||||
| 		if (ttb[0]) { | ||||
| 			auth_server = blobmsg_get_string(ttb[0]); | ||||
| 		} | ||||
|  | ||||
| 		blobmsg_parse_array(radius_proxy_realm_policy, ARRAY_SIZE(ttb), ttb, | ||||
| 							blobmsg_data(tb[RADIUS_PROXY_REALM_ACCT_SERVER]), | ||||
| 							blobmsg_data_len(tb[RADIUS_PROXY_REALM_ACCT_SERVER])); | ||||
| 		if (ttb[0]) { | ||||
| 			acct_server = blobmsg_get_string(ttb[0]); | ||||
| 		} | ||||
|  | ||||
| 		strcpy(section_name, (char *)wildcard_section->e.name); | ||||
|  | ||||
| 		TRACEF("Delete section: %s", section_name); | ||||
|  | ||||
| 		uci_section_del(proxy_ctx, "radsecproxy", "radsecproxy", | ||||
| 							(char *)wildcard_section->e.name, "realm"); | ||||
|  | ||||
| 		blob_buf_init(&uci_buf, 0); | ||||
| 		blobmsg_add_string(&uci_buf, "name", "*"); | ||||
| 		n = blobmsg_open_array(&uci_buf, "server"); | ||||
| 		blobmsg_add_string(&uci_buf, NULL, auth_server); | ||||
| 		blobmsg_close_array(&uci_buf, n); | ||||
| 		n = blobmsg_open_array(&uci_buf, "accountingServer"); | ||||
| 		blobmsg_add_string(&uci_buf, NULL, acct_server); | ||||
| 		blobmsg_close_array(&uci_buf, n); | ||||
| 		blob_to_uci_section(proxy_ctx, "radsecproxy", section_name, "realm", | ||||
| 				uci_buf.head, &radius_proxy_realm_param, NULL); | ||||
| 		TRACEF("Add section: %s %s %s", section_name, auth_server, acct_server); | ||||
|  | ||||
| 		uci_commit_all(proxy_ctx); | ||||
| 	} | ||||
| 	uci_free_context(proxy_ctx); | ||||
| } | ||||
|  | ||||
| static bool radius_proxy_config_delete() | ||||
| { | ||||
| 	struct uci_package *radsecproxy; | ||||
| 	struct uci_context *rad_uci; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
| 	int ret = 0; | ||||
| 	int ret=0; | ||||
|  | ||||
| 	rad_uci = uci_alloc_context(); | ||||
|  | ||||
| 	ret = uci_load(rad_uci, "radsecproxy", &radsecproxy); | ||||
| 	ret= uci_load(uci, "radsecproxy", &radsecproxy); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		uci_free_context(rad_uci); | ||||
| 		LOGD("%s: uci_load() failed with rc %d", __func__, ret); | ||||
| 		return false; | ||||
| 	} | ||||
| 	uci_foreach_element_safe(&radsecproxy->sections, tmp, e) { | ||||
| 		struct uci_section *s = uci_to_section(e); | ||||
| 		if ((s == NULL) || (s->type == NULL)) continue; | ||||
| 		uci_section_del(rad_uci, "radsecproxy", "radsecproxy", | ||||
| 		uci_section_del(uci, "radsecproxy", "radsecproxy", | ||||
| 				(char *)s->e.name, s->type); | ||||
| 	} | ||||
| 	uci_commit(rad_uci, &radsecproxy, false); | ||||
| 	uci_unload(rad_uci, radsecproxy); | ||||
| 	uci_free_context(rad_uci); | ||||
| 	uci_commit(uci, &radsecproxy, false); | ||||
| 	uci_unload(uci, radsecproxy); | ||||
| 	reload_config = 1; | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| @@ -486,12 +339,11 @@ void callback_Radius_Proxy_Config(ovsdb_update_monitor_t *self, | ||||
| 	case OVSDB_UPDATE_NEW: | ||||
| 	case OVSDB_UPDATE_MODIFY: | ||||
| 		(void) radius_proxy_config_set(conf); | ||||
| 		vif_check_radius_proxy(); | ||||
| 		break; | ||||
|  | ||||
| 	case OVSDB_UPDATE_DEL: | ||||
| 		(void) radius_proxy_config_delete(); | ||||
| 		vif_check_radius_proxy(); | ||||
| 		(void) radius_proxy_config_set(conf); | ||||
| 		break; | ||||
|  | ||||
| 	default: | ||||
| @@ -499,7 +351,6 @@ void callback_Radius_Proxy_Config(ovsdb_update_monitor_t *self, | ||||
| 				self->mon_type, self->mon_uuid); | ||||
| 		break; | ||||
| 	}	 | ||||
| 	set_config_apply_timeout(self); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -24,190 +24,10 @@ | ||||
| #include "uci.h" | ||||
| #include "utils.h" | ||||
| #include "captive.h" | ||||
| #include <fcntl.h> | ||||
| #include "fixup.h" | ||||
|  | ||||
| ovsdb_table_t table_Wifi_RRM_Config; | ||||
| extern ovsdb_table_t table_Wifi_Radio_Config; | ||||
| extern ovsdb_table_t table_Wifi_VIF_Config; | ||||
| #define PHY_NAME_LEN 32 | ||||
|  | ||||
| bool rrm_config_txpower(const char *rname, unsigned int txpower) | ||||
| { | ||||
| 	char cmd[126] = {0}; | ||||
| 	int rid = 0; | ||||
| 	txpower = txpower * 100; | ||||
|  | ||||
| 	sscanf(rname, "radio%d", &rid); | ||||
|  | ||||
| 	memset(cmd, 0, sizeof(cmd)); | ||||
| 	/* iw dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>]*/ | ||||
| 	snprintf(cmd, sizeof(cmd), | ||||
| 		"iw phy phy%d set txpower fixed %d", rid, txpower); | ||||
| 	system(cmd); | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| /* Mcast & Beacon rate set */ | ||||
| #define NUM_OF_RATES 12 | ||||
| enum { | ||||
| 	ATH10K_DRIVER, | ||||
| 	ATH11K_DRIVER, | ||||
| 	ATH_DRIVER_MAX | ||||
| }; | ||||
|  | ||||
| typedef struct ath_rate_codes { | ||||
| 	unsigned int rate; | ||||
| 	unsigned long code[ATH_DRIVER_MAX]; | ||||
| } ath_rc; | ||||
|  | ||||
| char ath_driver_name[ATH_DRIVER_MAX][16] = {"ath10k", "ath11k"}; | ||||
| ath_rc  ath_rcodes[NUM_OF_RATES] = {{1,  {0x43, 0x10000103}}, | ||||
| 				    {2,  {0x42, 0x10000102}}, | ||||
| 				    {5,  {0x41, 0x10000101}}, | ||||
| 				    {11, {0x40, 0x10000100}}, | ||||
| 				    {6,  {0x3, 0x10000003}}, | ||||
| 				    {9,  {0x7, 0x10000007}}, | ||||
| 				    {12, {0x2, 0x10000002}}, | ||||
| 				    {18, {0x6, 0x10000006}}, | ||||
| 				    {24, {0x1, 0x10000001}}, | ||||
| 				    {36, {0x5, 0x10000005}}, | ||||
| 				    {48, {0x0, 0x10000000}}, | ||||
| 				    {54, {0x4, 0x10000004}}}; | ||||
|  | ||||
|  | ||||
| /* get phy name */ | ||||
| bool get_80211phy(const char *ifname, char *phy) | ||||
| { | ||||
| 	char path[126] = {0}; | ||||
| 	int fd, l = 0; | ||||
|  | ||||
| 	snprintf(path, sizeof(path), "/sys/class/net/%s/phy80211/name", ifname); | ||||
|  | ||||
| 	fd = open(path, O_RDONLY); | ||||
| 	if (fd < 0) { | ||||
| 		LOGE("%s: Unable to read sysfs phy name", __func__); | ||||
| 		close(fd); | ||||
| 		return false; | ||||
| 	} | ||||
| 	read(fd, phy, PHY_NAME_LEN); | ||||
| 	close(fd); | ||||
| 	l = strlen(phy); | ||||
| 	phy[l-1] = '\0'; | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool set_rates_sysfs(const char *type, int rate_code, const char *ifname, | ||||
| 		     char *band, int dn) | ||||
| { | ||||
| 	int fd = 0; | ||||
| 	char path[126] = {0}; | ||||
| 	char value[126] = {0}; | ||||
| 	char phy[PHY_NAME_LEN] = {0}; | ||||
| 	unsigned int band_id = 0; | ||||
|  | ||||
| 	/* get phy name */ | ||||
| 	if (!get_80211phy(ifname, phy)) | ||||
| 		return false; | ||||
|  | ||||
| 	if (!strcmp(band, "2.4G")) | ||||
| 		band_id = 2; | ||||
| 	else | ||||
| 		band_id = 5; | ||||
|  | ||||
| 	snprintf(path, sizeof(path), | ||||
| 		"/sys/kernel/debug/ieee80211/%s/%s/set_rates", phy, | ||||
| 		ath_driver_name[dn]); | ||||
|  | ||||
| 	snprintf(value, sizeof(value), "%s %s %d 0x%x", | ||||
| 		 ifname, type, band_id, rate_code); | ||||
|  | ||||
| 	fd = open(path, O_WRONLY); | ||||
| 	if (fd < 0) { | ||||
| 		LOGE("%s: Unable to read sysfs set_rates", __func__); | ||||
| 		close(fd); | ||||
| 		return false; | ||||
| 	} | ||||
| 	write(fd, value, sizeof(value)); | ||||
| 	close(fd); | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| int find_ath_driver_name(const char *ifname) | ||||
| { | ||||
| 	int dn = -1; | ||||
| 	char path[126] = {0}; | ||||
| 	char phy[PHY_NAME_LEN] = {0}; | ||||
|  | ||||
| 	/* get phy name */ | ||||
| 	if (!get_80211phy(ifname, phy)) | ||||
| 		return -1; | ||||
|  | ||||
| 	for (dn = 0; dn < ATH_DRIVER_MAX; dn++) { | ||||
| 		snprintf(path, sizeof(path), | ||||
| 			"/sys/kernel/debug/ieee80211/%s/%s/set_rates", phy, | ||||
| 			ath_driver_name[dn]); | ||||
|  | ||||
| 		if (access(path, F_OK) == 0) { | ||||
| 			return dn; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| int rrm_config_mcast_bcast_rate(const char *ifname, char *band, | ||||
| 				 unsigned int bcn_rate, unsigned int mcast_rate) | ||||
| { | ||||
| 	int i = 0; | ||||
| 	bool rc = 0; | ||||
| 	unsigned int bcn_code = 0xFF; | ||||
| 	unsigned int mcast_code = 0xFF; | ||||
| 	int dn = 0; | ||||
|  | ||||
| 	/*Find ath driver version ath10/11k*/ | ||||
| 	dn = find_ath_driver_name(ifname); | ||||
| 	if (dn < -1) { | ||||
| 		LOG(ERR, "%s: No set_rate path exists", __func__); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	/* beacon rate given by cloud in multiples of 10 */ | ||||
| 	if (bcn_rate > 0) | ||||
| 		bcn_rate = bcn_rate/10; | ||||
|  | ||||
| 	/* Get rate code of given rate */ | ||||
| 	for (i = 0; i < NUM_OF_RATES; i++) | ||||
| 	{ | ||||
| 		if (ath_rcodes[i].rate == bcn_rate) | ||||
| 			bcn_code = ath_rcodes[i].code[dn]; | ||||
|  | ||||
| 		if (ath_rcodes[i].rate == mcast_rate) | ||||
| 			mcast_code = ath_rcodes[i].code[dn]; | ||||
| 	} | ||||
|  | ||||
| 	/* Set the rates to sysfs */ | ||||
| 	if (bcn_code != 0xFF) | ||||
| 	{ | ||||
| 		if (set_rates_sysfs("beacon", bcn_code, ifname, band, dn) == false) | ||||
| 			rc = -1; | ||||
|  | ||||
| 		/*Ath11k sets mgmt and beacon rates separately*/ | ||||
| 		if (dn == ATH11K_DRIVER) | ||||
| 			if (set_rates_sysfs("mgmt", bcn_code, ifname, band, dn) == false) | ||||
| 				rc = -1; | ||||
| 	} | ||||
|  | ||||
| 	if (mcast_code != 0xFF) | ||||
| 	{ | ||||
| 		if (set_rates_sysfs("mcast", mcast_code, ifname, band, dn) == false) | ||||
| 			rc = -1; | ||||
| 	} | ||||
|  | ||||
| 	return rc; | ||||
| } | ||||
|  | ||||
| void rrm_config_vif(struct blob_buf *b, struct blob_buf *del, const char * freq_band, const char * if_name) | ||||
| { | ||||
| @@ -227,19 +47,8 @@ void rrm_config_vif(struct blob_buf *b, struct blob_buf *del, const char * freq_ | ||||
| 		blobmsg_add_u32(b, "rssi_ignore_probe_request", conf.probe_resp_threshold); | ||||
| 		blobmsg_add_u32(b, "signal_connect", conf.client_disconnect_threshold); | ||||
| 		blobmsg_add_u32(b, "signal_stay", conf.client_disconnect_threshold); | ||||
| 		blobmsg_add_u32(b, "bcn_rate", conf.beacon_rate); | ||||
| 		blobmsg_add_u32(b, "mcast_rate", conf.mcast_rate); | ||||
|  | ||||
| 		if (conf.beacon_rate == 0) { | ||||
| 			// Default to the lowest possible bit rate for each frequency band | ||||
| 			if (!strcmp(freq_band, "2.4G")) { | ||||
| 				blobmsg_add_u32(b, "bcn_rate", 10); | ||||
| 			} else { | ||||
| 				blobmsg_add_u32(b, "bcn_rate", 60); | ||||
| 			} | ||||
| 		} else { | ||||
| 			blobmsg_add_u32(b, "bcn_rate", conf.beacon_rate); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 	return; | ||||
| } | ||||
| @@ -260,103 +69,6 @@ int rrm_get_backup_channel(const char * freq_band) | ||||
|  | ||||
| } | ||||
|  | ||||
| void rrm_noreload_config(struct schema_Wifi_RRM_Config *conf, const char *wlanif) | ||||
| { | ||||
| 	char pval[16]; | ||||
| 	int rc = 0; | ||||
|  | ||||
| 	if (conf->probe_resp_threshold_changed) { | ||||
| 		/* rssi_ignore_probe_request and signal_connect should | ||||
| 		 * both be probe_resp_threshold */  | ||||
| 		snprintf(pval, sizeof(pval), "%d", | ||||
| 			 conf->probe_resp_threshold); | ||||
| 		rc = ubus_set_hapd_param(wlanif, | ||||
| 				    "rssi_ignore_probe_request", pval); | ||||
| 		if (rc < 0) | ||||
| 			LOG(ERR, "RRM: Set rssi_ignore_probe_req failed"); | ||||
| 		rc = ubus_set_signal_thresholds(wlanif, | ||||
| 					   conf->probe_resp_threshold, | ||||
| 					   conf->client_disconnect_threshold); | ||||
| 		if (rc < 0) | ||||
| 			LOG(ERR, "RRM: Set probe_resp_threshold failed"); | ||||
|  | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	if (conf->client_disconnect_threshold_changed) { | ||||
| 		rc = ubus_set_signal_thresholds(wlanif, | ||||
| 					   conf->probe_resp_threshold, | ||||
| 					   conf->client_disconnect_threshold); | ||||
| 		if (rc < 0) | ||||
| 			LOG(ERR, "RRM: Set client_disconnect_thres failed"); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	if (conf->mcast_rate_changed) { | ||||
| 		rc = rrm_config_mcast_bcast_rate(wlanif, conf->freq_band, 0, | ||||
| 					    conf->mcast_rate); | ||||
| 		if (rc < 0) | ||||
| 			LOG(ERR, "RRM: Set mcast rate failed"); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	if (conf->beacon_rate_changed) { | ||||
| 		rrm_config_mcast_bcast_rate(wlanif, conf->freq_band, | ||||
| 					    conf->beacon_rate, 0); | ||||
| 		if (rc < 0) | ||||
| 			LOG(ERR, "RRM: Set beacon rate failed"); | ||||
|  | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void get_channel_bandwidth(const char* htmode, int *channel_bandwidth) | ||||
| { | ||||
| 	if(!strcmp(htmode, "HT20")) | ||||
| 		*channel_bandwidth=20; | ||||
| 	else if (!strcmp(htmode, "HT40")) | ||||
| 		*channel_bandwidth=40; | ||||
| 	else if(!strcmp(htmode, "HT80")) | ||||
| 		*channel_bandwidth=80; | ||||
| } | ||||
|  | ||||
| void rrm_radio_rebalance_channel(const struct schema_Wifi_Radio_Config *rconf) | ||||
| { | ||||
| 	int channel_bandwidth; | ||||
| 	int sec_chan_offset=0; | ||||
| 	struct mode_map *m = NULL; | ||||
| 	int freq = 0; | ||||
| 	char *mode = NULL; | ||||
| 	int rid = 0; | ||||
| 	char wlanif[16] = {0}; | ||||
| 	char *hw_mode; | ||||
|  | ||||
| 	sscanf(rconf->if_name, "radio%d", &rid); | ||||
| 	snprintf(wlanif, sizeof(wlanif), "wlan%d", rid); | ||||
|  | ||||
| 	freq = ieee80211_channel_to_frequency(rconf->channel); | ||||
| 	mode = get_max_channel_bw_channel(freq,	rconf->ht_mode); | ||||
|  | ||||
| 	hw_mode = radio_fixup_get_hw_mode(rconf->if_name); | ||||
| 	if (hw_mode == NULL) { | ||||
| 		LOGE("Failed to get hw mode"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	m = mode_map_get_uci(rconf->freq_band, mode, hw_mode); | ||||
|  | ||||
| 	if (m) | ||||
| 		sec_chan_offset = m->sec_channel_offset; | ||||
| 	else | ||||
| 		LOGE("failed to get channel offset"); | ||||
|  | ||||
| 	get_channel_bandwidth(mode, &channel_bandwidth); | ||||
|  | ||||
|  | ||||
| 	ubus_set_channel_switch(wlanif, freq, hw_mode, | ||||
| 				channel_bandwidth, sec_chan_offset, 1); | ||||
|  | ||||
| } | ||||
|  | ||||
| static bool rrm_config_update( struct schema_Wifi_RRM_Config *conf, bool addNotDelete) | ||||
| { | ||||
| 	struct schema_Wifi_Radio_Config rconf; | ||||
| @@ -366,40 +78,12 @@ static bool rrm_config_update( struct schema_Wifi_RRM_Config *conf, bool addNotD | ||||
| 	int i; | ||||
|  | ||||
| 	if (false == ovsdb_table_select_one(&table_Wifi_Radio_Config, | ||||
| 			SCHEMA_COLUMN(Wifi_Radio_Config, freq_band), | ||||
| 			conf->freq_band, &rconf)) | ||||
| 			SCHEMA_COLUMN(Wifi_Radio_Config, freq_band), conf->freq_band, &rconf)) | ||||
| 	{ | ||||
| 		LOG(WARN, "Wifi_RRM_Config: No radio for band %s", | ||||
| 						conf->freq_band ); | ||||
| 		LOG(WARN, "Wifi_RRM_Config: No radio for band %s", conf->freq_band ); | ||||
| 		return false; | ||||
| 	}	 | ||||
|  | ||||
| 	/* Set RRM configurations which do not require a wifi vifs reload | ||||
| 	 * and return */ | ||||
| 	if (conf->mcast_rate_changed || conf->beacon_rate_changed || | ||||
| 	    conf->probe_resp_threshold_changed || | ||||
| 	    conf->client_disconnect_threshold_changed) { | ||||
| 		LOGI("RRM Config: beacon_rate:%s mcast_rate:%s probe_resp_threshold:%s client_disconnect_threshold_changed:%s", | ||||
| 		     (conf->beacon_rate_changed)? "changed":"unchanged",  | ||||
| 		     (conf->mcast_rate_changed)? "changed":"unchanged",  | ||||
| 		     (conf->probe_resp_threshold_changed)? "changed":"unchanged", | ||||
| 		     (conf->client_disconnect_threshold_changed)? "changed":"unchanged"); | ||||
|  | ||||
| 		for (i = 0; i < rconf.vif_configs_len; i++) { | ||||
| 			if (!(where = ovsdb_where_uuid("_uuid", | ||||
| 						rconf.vif_configs[i].uuid))) | ||||
| 				continue; | ||||
|  | ||||
| 			memset(&vconf, 0, sizeof(vconf)); | ||||
| 			if (ovsdb_table_select_one_where(&table_Wifi_VIF_Config, | ||||
| 							 where, &vconf)) | ||||
| 			{ | ||||
| 				rrm_noreload_config(conf, vconf.if_name); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/*Reload the vifs to configure the RRM configurations*/ | ||||
| 	memset(&changed, 0, sizeof(changed)); | ||||
| 	for (i = 0; i < rconf.vif_configs_len; i++) { | ||||
| 		if (!(where = ovsdb_where_uuid("_uuid", rconf.vif_configs[i].uuid))) | ||||
|   | ||||
| @@ -242,9 +242,9 @@ bool target_stats_survey_get(radio_entry_t *radio_cfg, uint32_t *chan_list, | ||||
| 	while (!ds_dlist_is_empty(&raw_survey_list)) { | ||||
| 		survey = ds_dlist_head(&raw_survey_list); | ||||
| 		ds_dlist_remove(&raw_survey_list, survey); | ||||
| 		LOGD("Survey entry dur %llu busy %llu tx %llu rx %llu rx_self %llu chan %d type %d", | ||||
| 		LOGD("Survey entry dur %d busy %d tx %d rx %d chan %d active %d type %d", | ||||
| 				survey->duration_ms, survey->chan_busy, survey->chan_tx, survey->chan_rx, | ||||
| 				survey->chan_self, survey->info.chan, scan_type); | ||||
| 				survey->info.chan, survey->chan_active, scan_type ); | ||||
| 		if ((scan_type == RADIO_SCAN_TYPE_ONCHAN) && (survey->duration_ms != 0)) { | ||||
| 			if (survey->info.chan == chan_list[0]) { | ||||
| 				ds_dlist_insert_tail(survey_list, survey); | ||||
| @@ -267,57 +267,25 @@ bool target_stats_survey_get(radio_entry_t *radio_cfg, uint32_t *chan_list, | ||||
| } | ||||
|  | ||||
| #define PERCENT(v1, v2) (v2 > 0 ? ((v1 > v2) ? 100 : (v1*100/v2)) : 0) | ||||
| #define DELTA(n, p) ((n) < (p) ? (n) : (n) - (p)) | ||||
|  | ||||
| bool target_stats_survey_convert(radio_entry_t *radio_cfg, radio_scan_type_t scan_type, | ||||
| 				 target_survey_record_t *data_new, target_survey_record_t *data_old, | ||||
| 				 dpp_survey_record_t *survey_record) | ||||
| { | ||||
| 	target_survey_record_t delta; | ||||
|  | ||||
| 	if (data_new->info.chan != data_old->info.chan) { | ||||
| 		/* Do not consider the old channel's data */ | ||||
| 		memset(data_old, 0, sizeof(*data_old)); | ||||
| 	} else if ((data_new->duration_ms <= data_old->duration_ms) && | ||||
| 			(data_new->chan_busy <= data_old->chan_busy)) { | ||||
| 		/* | ||||
| 		 * Take care of survey data from CHAN_INFO events which are Read-On-Clear | ||||
| 		 * in nature, whereas survey data from BSS_CHAN_INFO events are Read only. | ||||
| 		 * Chan_info event down in the driver updates only the duration, noise floor | ||||
| 		 * and the chan_busy data. | ||||
| 		 */ | ||||
| 		data_new->duration_ms += data_old->duration_ms; | ||||
| 		data_new->chan_busy += data_old->chan_busy; | ||||
| 	} | ||||
|  | ||||
| 	LOGD("Survey convert scan_type %d chan %d duration_new:%llu duration_old:%llu " | ||||
| 	     "busy_new %llu busy_old:%llu tx_new %llu tx_old:%llu rx_new %llu rx_old:%llu " | ||||
| 	     "rx_self_new %llu rx_self_old:%llu", | ||||
| 	     scan_type, data_new->info.chan, data_new->duration_ms, data_old->duration_ms, | ||||
| 	     data_new->chan_busy, data_old->chan_busy, data_new->chan_tx, data_old->chan_tx, | ||||
| 	     data_new->chan_rx, data_old->chan_rx, data_new->chan_self, data_old->chan_self); | ||||
|  | ||||
| 	memset(&delta, 0, sizeof(delta)); | ||||
|  | ||||
| 	delta.duration_ms = DELTA(data_new->duration_ms, data_old->duration_ms); | ||||
| 	delta.chan_busy = DELTA(data_new->chan_busy, data_old->chan_busy); | ||||
| 	delta.chan_busy_ext = DELTA(data_new->chan_busy_ext, data_old->chan_busy_ext); | ||||
| 	delta.chan_tx = DELTA(data_new->chan_tx, data_old->chan_tx); | ||||
| 	delta.chan_rx = DELTA(data_new->chan_rx, data_old->chan_rx); | ||||
| 	delta.chan_self = DELTA(data_new->chan_self, data_old->chan_self); | ||||
|  | ||||
| 	LOGD("Survey convert scan_type %d chan %d", scan_type, data_new->info.chan); | ||||
| 	survey_record->info.chan     = data_new->info.chan; | ||||
| 	survey_record->chan_tx       = PERCENT(delta.chan_tx, delta.duration_ms); | ||||
| 	survey_record->chan_self     = PERCENT(delta.chan_self, delta.duration_ms); | ||||
| 	survey_record->chan_rx       = PERCENT(delta.chan_rx, delta.duration_ms); | ||||
| 	survey_record->chan_busy_ext = PERCENT(delta.chan_busy_ext, delta.duration_ms); | ||||
| 	survey_record->chan_busy     = PERCENT(delta.chan_busy, delta.duration_ms); | ||||
| 	survey_record->chan_tx       = PERCENT(data_new->chan_tx, data_new->duration_ms); | ||||
| 	survey_record->chan_self     = PERCENT(data_new->chan_self, data_new->duration_ms); | ||||
| 	survey_record->chan_rx       = PERCENT(data_new->chan_rx, data_new->duration_ms); | ||||
| 	survey_record->chan_busy_ext = PERCENT(data_new->chan_busy_ext, data_new->duration_ms); | ||||
| 	survey_record->chan_busy     = PERCENT(data_new->chan_busy, data_new->duration_ms); | ||||
| 	survey_record->chan_noise    = data_new->chan_noise; | ||||
| 	survey_record->duration_ms   = delta.duration_ms; | ||||
| 	survey_record->duration_ms   = data_new->duration_ms; | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *  NEIGHBORS definitions | ||||
|  *****************************************************************************/ | ||||
| @@ -382,12 +350,12 @@ bool target_stats_device_temp_get(radio_entry_t *radio_cfg, dpp_device_temp_t *t | ||||
| 	char hwmon_path[PATH_MAX]; | ||||
| 	int32_t temperature; | ||||
| 	FILE *fp = NULL; | ||||
| 	bool DegreesNotMilliDegrees; | ||||
|  | ||||
| 	if (phy_find_hwmon(target_map_ifname(radio_cfg->phy_name), hwmon_path, &DegreesNotMilliDegrees)) { | ||||
| 	if (phy_find_hwmon(target_map_ifname(radio_cfg->phy_name), hwmon_path)) { | ||||
| 		LOG(ERR, "%s: hwmon is missing", radio_cfg->phy_name); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	fp = fopen(hwmon_path, "r"); | ||||
| 	if (!fp) { | ||||
| 		LOG(ERR, "%s: Failed to open temp input files", radio_cfg->phy_name); | ||||
| @@ -404,10 +372,7 @@ bool target_stats_device_temp_get(radio_entry_t *radio_cfg, dpp_device_temp_t *t | ||||
|  | ||||
| 	fclose(fp); | ||||
| 	temp_entry->type  = radio_cfg->type; | ||||
| 	if(DegreesNotMilliDegrees) | ||||
| 		temp_entry->value = temperature; | ||||
| 	else | ||||
| 		temp_entry->value = temperature / 1000; | ||||
| 	temp_entry->value = temperature / 1000; | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|   | ||||
| @@ -13,6 +13,7 @@ | ||||
| #include <sys/types.h> | ||||
|  | ||||
| #include <linux/sockios.h> | ||||
| #include <linux/nl80211.h> | ||||
|  | ||||
| #include <netlink/msg.h> | ||||
| #include <netlink/attr.h> | ||||
| @@ -29,7 +30,6 @@ | ||||
| #include <libubox/vlist.h> | ||||
| #include <unl.h> | ||||
|  | ||||
| #include "nl80211_cpy.h" | ||||
| #include "target.h" | ||||
| #include "nl80211.h" | ||||
| #include "phy.h" | ||||
| @@ -38,12 +38,9 @@ | ||||
|  | ||||
| extern struct ev_loop *wifihal_evloop; | ||||
| static int nl80211_scan_started; | ||||
| static struct unl unl_req; | ||||
| static struct unl unl_notify; | ||||
| static struct unl unl; | ||||
| static ev_io unl_io; | ||||
|  | ||||
| #define NF_OFFSET_24G 14 | ||||
| #define NF_OFFSET_5G  10 | ||||
| struct nl80211_scan { | ||||
| 	char name[IF_NAMESIZE]; | ||||
| 	target_scan_cb_t *scan_cb; | ||||
| @@ -54,8 +51,6 @@ struct nl80211_scan { | ||||
|  | ||||
| static struct avl_tree nl80211_scan_tree = AVL_TREE_INIT(nl80211_scan_tree, avl_strcmp, false, NULL); | ||||
|  | ||||
| static void nl80211_scan_del(struct nl80211_scan *nl80211_scan); | ||||
|  | ||||
| static int nl80211_chainmask_recv(struct nl_msg *msg, void *arg) | ||||
| { | ||||
| 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); | ||||
| @@ -196,19 +191,6 @@ static int nl80211_assoclist_recv(struct nl_msg *msg, void *arg) | ||||
| 	return NL_OK; | ||||
| } | ||||
|  | ||||
| static int add_chan_noise_offset(unsigned int chan, int chan_noise) | ||||
| { | ||||
| 	int adjusted_chan_noise = 0; | ||||
|  | ||||
| 	if (chan > 13) { | ||||
| 		adjusted_chan_noise = chan_noise + NF_OFFSET_5G; | ||||
| 	} else { | ||||
| 		adjusted_chan_noise = chan_noise + NF_OFFSET_24G; | ||||
| 	} | ||||
|  | ||||
| 	return adjusted_chan_noise; | ||||
| } | ||||
|  | ||||
| static int nl80211_survey_recv(struct nl_msg *msg, void *arg) | ||||
| { | ||||
| 	static struct nla_policy sp[NL80211_SURVEY_INFO_MAX + 1] = { | ||||
| @@ -220,7 +202,6 @@ static int nl80211_survey_recv(struct nl_msg *msg, void *arg) | ||||
| 		[NL80211_SURVEY_INFO_TIME_EXT_BUSY]	= { .type = NLA_U64 }, | ||||
| 		[NL80211_SURVEY_INFO_TIME_SCAN]		= { .type = NLA_U64 }, | ||||
| 		[NL80211_SURVEY_INFO_NOISE]		= { .type = NLA_U8 }, | ||||
| 		[NL80211_SURVEY_INFO_TIME_BSS_RX]	= { .type = NLA_U64 }, | ||||
| 	}; | ||||
|  | ||||
| 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); | ||||
| @@ -249,7 +230,7 @@ static int nl80211_survey_recv(struct nl_msg *msg, void *arg) | ||||
| 						nla_get_u32(si[NL80211_SURVEY_INFO_FREQUENCY])); | ||||
|  | ||||
| 	if (si[NL80211_SURVEY_INFO_TIME_RX]) | ||||
| 		survey_record->chan_self = nla_get_u64(si[NL80211_SURVEY_INFO_TIME_BSS_RX]); | ||||
| 		survey_record->chan_self = nla_get_u64(si[NL80211_SURVEY_INFO_TIME_RX]); | ||||
|  | ||||
| 	if (si[NL80211_SURVEY_INFO_TIME_TX]) | ||||
| 		survey_record->chan_tx = nla_get_u64(si[NL80211_SURVEY_INFO_TIME_TX]); | ||||
| @@ -267,8 +248,7 @@ static int nl80211_survey_recv(struct nl_msg *msg, void *arg) | ||||
| 		survey_record->duration_ms = nla_get_u64(si[NL80211_SURVEY_INFO_TIME]); | ||||
|  | ||||
| 	if (si[NL80211_SURVEY_INFO_NOISE]) | ||||
| 		survey_record->chan_noise = add_chan_noise_offset(survey_record->info.chan,  | ||||
| 			nla_get_u8(si[NL80211_SURVEY_INFO_NOISE])); | ||||
| 		survey_record->chan_noise = nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]); | ||||
|  | ||||
| 	survey_record->chan_in_use=si[NL80211_SURVEY_INFO_IN_USE] ? 1:0; | ||||
|  | ||||
| @@ -365,7 +345,7 @@ static struct nl_msg *nl80211_call_phy(char *name, int cmd, bool dump) | ||||
| 	if (idx < 0) | ||||
| 		return NULL; | ||||
|  | ||||
| 	msg = unl_genl_msg(&unl_req, cmd, dump); | ||||
| 	msg = unl_genl_msg(&unl, cmd, dump); | ||||
| 	nla_put_u32(msg, NL80211_ATTR_WIPHY, idx); | ||||
|  | ||||
| 	return msg; | ||||
| @@ -385,17 +365,16 @@ static int nl80211_scan_add(char *name, target_scan_cb_t *scan_cb, void *scan_ct | ||||
| { | ||||
| 	struct nl80211_scan *nl80211_scan = avl_find_element(&nl80211_scan_tree, name, nl80211_scan, avl); | ||||
|  | ||||
| 	if (nl80211_scan) | ||||
| 		nl80211_scan_del(nl80211_scan); | ||||
|  | ||||
| 	nl80211_scan = malloc(sizeof(*nl80211_scan)); | ||||
| 	if (!nl80211_scan) | ||||
| 		return -1; | ||||
| 	memset(nl80211_scan, 0, sizeof(*nl80211_scan)); | ||||
| 	strncpy(nl80211_scan->name, name, IF_NAMESIZE); | ||||
| 	nl80211_scan->avl.key = nl80211_scan->name; | ||||
| 	avl_insert(&nl80211_scan_tree, &nl80211_scan->avl); | ||||
| 	LOGD("%s: added scan context", name); | ||||
| 	if (!nl80211_scan) { | ||||
| 		nl80211_scan = malloc(sizeof(*nl80211_scan)); | ||||
| 		if (!nl80211_scan) | ||||
| 			return -1; | ||||
| 		memset(nl80211_scan, 0, sizeof(*nl80211_scan)); | ||||
| 		strncpy(nl80211_scan->name, name, IF_NAMESIZE); | ||||
| 		nl80211_scan->avl.key = nl80211_scan->name; | ||||
| 		avl_insert(&nl80211_scan_tree, &nl80211_scan->avl); | ||||
| 		LOGD("%s: added scan context", name); | ||||
| 	} | ||||
|  | ||||
| 	nl80211_scan->scan_cb = scan_cb; | ||||
| 	nl80211_scan->scan_ctx = scan_ctx; | ||||
| @@ -417,6 +396,7 @@ static void nl80211_scan_finish(char *name, bool state) | ||||
| 	if (nl80211_scan) { | ||||
| 		LOGD("%s: calling context cb", nl80211_scan->name); | ||||
| 		(*nl80211_scan->scan_cb)(nl80211_scan->scan_ctx, state); | ||||
| 		nl80211_scan_del(nl80211_scan); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -481,7 +461,7 @@ static void nl80211_ev(struct ev_loop *ev, struct ev_io *io, int event) | ||||
| 	nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, NULL); | ||||
| 	nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); | ||||
| 	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_recv, NULL); | ||||
| 	nl_recvmsgs(unl_notify.sock, cb); | ||||
| 	nl_recvmsgs(unl.sock, cb); | ||||
| 	nl_cb_put(cb); | ||||
| } | ||||
|  | ||||
| @@ -491,9 +471,9 @@ static struct nl_msg *nl80211_call_vif(struct nl_call_param *nl_call_param, int | ||||
| 	struct nl_msg *msg; | ||||
|  | ||||
| 	if (!nl80211_scan_started) { | ||||
| 		unl_genl_subscribe(&unl_notify, "scan"); | ||||
| 		unl_genl_subscribe(&unl, "scan"); | ||||
|  | ||||
| 		ev_io_init(&unl_io, nl80211_ev, unl_notify.sock->s_fd, EV_READ); | ||||
| 		ev_io_init(&unl_io, nl80211_ev, unl.sock->s_fd, EV_READ); | ||||
| 		ev_io_start(wifihal_evloop, &unl_io); | ||||
| 		nl80211_scan_started = 1; | ||||
| 	} | ||||
| @@ -501,7 +481,7 @@ static struct nl_msg *nl80211_call_vif(struct nl_call_param *nl_call_param, int | ||||
| 	if (!idx) | ||||
| 		return NULL; | ||||
|  | ||||
| 	msg = unl_genl_msg(&unl_req, cmd, dump); | ||||
| 	msg = unl_genl_msg(&unl, cmd, dump); | ||||
| 	nla_put_u32(msg, NL80211_ATTR_IFINDEX, idx); | ||||
|  | ||||
| 	return msg; | ||||
| @@ -514,7 +494,7 @@ int nl80211_get_tx_chainmask(char *name, unsigned int *mask) | ||||
| 	if (!msg) | ||||
| 		return -1; | ||||
|  | ||||
| 	return unl_genl_request(&unl_req, msg, nl80211_chainmask_recv, mask); | ||||
| 	return unl_genl_request(&unl, msg, nl80211_chainmask_recv, mask); | ||||
| } | ||||
|  | ||||
| int nl80211_get_oper_channel(char *name, unsigned int *chan) | ||||
| @@ -525,10 +505,10 @@ int nl80211_get_oper_channel(char *name, unsigned int *chan) | ||||
| 	if (!idx) | ||||
| 		return -1; | ||||
|  | ||||
| 	msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_INTERFACE, true); | ||||
| 	msg = unl_genl_msg(&unl, NL80211_CMD_GET_INTERFACE, true); | ||||
| 	nla_put_u32(msg, NL80211_ATTR_IFINDEX, idx); | ||||
|  | ||||
| 	return unl_genl_request(&unl_req, msg, nl80211_channel_recv, chan); | ||||
| 	return unl_genl_request(&unl, msg, nl80211_channel_recv, chan); | ||||
| } | ||||
|  | ||||
| int nl80211_get_ssid(struct nl_call_param *nl_call_param) | ||||
| @@ -538,7 +518,7 @@ int nl80211_get_ssid(struct nl_call_param *nl_call_param) | ||||
|         if (!msg) | ||||
|                 return -1; | ||||
|  | ||||
|         return unl_genl_request(&unl_req, msg, nl80211_interface_recv, nl_call_param); | ||||
|         return unl_genl_request(&unl, msg, nl80211_interface_recv, nl_call_param); | ||||
| } | ||||
|  | ||||
| int nl80211_get_assoclist(struct nl_call_param *nl_call_param) | ||||
| @@ -548,7 +528,7 @@ int nl80211_get_assoclist(struct nl_call_param *nl_call_param) | ||||
| 	if (!msg) | ||||
| 		return -1; | ||||
|  | ||||
| 	return unl_genl_request(&unl_req, msg, nl80211_assoclist_recv, nl_call_param); | ||||
| 	return unl_genl_request(&unl, msg, nl80211_assoclist_recv, nl_call_param); | ||||
| } | ||||
|  | ||||
| int nl80211_get_survey(struct nl_call_param *nl_call_param) | ||||
| @@ -558,7 +538,7 @@ int nl80211_get_survey(struct nl_call_param *nl_call_param) | ||||
| 	if (!msg) | ||||
| 		return -1; | ||||
|  | ||||
| 	return unl_genl_request(&unl_req, msg, nl80211_survey_recv, nl_call_param); | ||||
| 	return unl_genl_request(&unl, msg, nl80211_survey_recv, nl_call_param); | ||||
| } | ||||
|  | ||||
| int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_list, uint32_t chan_num, | ||||
| @@ -569,39 +549,20 @@ int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_lis | ||||
| 	struct nlattr *freq; | ||||
| 	unsigned int i, flags = 0; | ||||
| 	int ret = 0; | ||||
| 	uint32_t oper_chan; | ||||
|  | ||||
| 	if (!msg) | ||||
| 		return -1; | ||||
|  | ||||
| 	if (nl80211_get_oper_channel(nl_call_param->ifname, &oper_chan) < 0) { | ||||
| 		/* Could not get the current operating channel */ | ||||
| 		oper_chan = 0; | ||||
| 		LOGE("%s: Could not get the current operating channel\n", | ||||
| 			nl_call_param->ifname); | ||||
| 	} | ||||
| 	LOGT("%s: not setting dwell time\n", nl_call_param->ifname); | ||||
| 	//nla_put_u16(msg, NL80211_ATTR_MEASUREMENT_DURATION, dwell_time); | ||||
|  | ||||
| 	/* Add the ap-force flag, otherwise the scan fails on wifi6 APs */ | ||||
| 	flags |= NL80211_SCAN_FLAG_AP; | ||||
| 	nla_put(msg, NL80211_ATTR_SCAN_FLAGS, sizeof(uint32_t), &flags); | ||||
|  | ||||
| 	if ((scan_type == RADIO_SCAN_TYPE_OFFCHAN) && dwell_time) | ||||
| 		nla_put_u16(msg, NL80211_ATTR_MEASUREMENT_DURATION, dwell_time); | ||||
|  | ||||
| 	freq = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES); | ||||
| 	for (i = 0; i < chan_num; i ++) { | ||||
| 		if (!oper_chan || (scan_type == RADIO_SCAN_TYPE_FULL)) { | ||||
| 			nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i])); | ||||
| 		} | ||||
| 		else if ((scan_type == RADIO_SCAN_TYPE_OFFCHAN) && | ||||
| 			(chan_list[i] != oper_chan)) { | ||||
| 			nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i])); | ||||
| 		} | ||||
| 		else if ((scan_type == RADIO_SCAN_TYPE_ONCHAN) && | ||||
| 			(chan_list[i] == oper_chan)) { | ||||
| 			nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i])); | ||||
| 		} | ||||
| 	} | ||||
| 	for (i = 0; i < chan_num; i ++) | ||||
| 		nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i])); | ||||
| 	nla_nest_end(msg, freq); | ||||
|  | ||||
| 	ret = nl80211_scan_add(nl_call_param->ifname, scan_cb, scan_ctx);  | ||||
| @@ -610,10 +571,8 @@ int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_lis | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	ret = unl_genl_request(&unl_req, msg, nl80211_scan_trigger_recv, NULL); | ||||
| 	if (ret) | ||||
| 		LOG(DEBUG, "%s: scan request failed %d\n", nl_call_param->ifname, ret); | ||||
|  | ||||
| 	ret = unl_genl_request(&unl, msg, nl80211_scan_trigger_recv, NULL); | ||||
| 	if (ret)	LOG(DEBUG, "%s: scan request failed %d\n", nl_call_param->ifname, ret); | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| @@ -628,7 +587,7 @@ int nl80211_scan_abort(struct nl_call_param *nl_call_param) | ||||
| 	if (nl80211_scan) | ||||
| 		nl80211_scan_del(nl80211_scan); | ||||
|  | ||||
| 	return unl_genl_request(&unl_req, msg, nl80211_scan_abort_recv, NULL); | ||||
| 	return unl_genl_request(&unl, msg, nl80211_scan_abort_recv, NULL); | ||||
| } | ||||
|  | ||||
| int nl80211_scan_dump(struct nl_call_param *nl_call_param) | ||||
| @@ -638,26 +597,18 @@ int nl80211_scan_dump(struct nl_call_param *nl_call_param) | ||||
| 	if (!msg) | ||||
| 		return -1; | ||||
|  | ||||
| 	return unl_genl_request(&unl_req, msg, nl80211_scan_dump_recv, nl_call_param); | ||||
| 	return unl_genl_request(&unl, msg, nl80211_scan_dump_recv, nl_call_param); | ||||
| } | ||||
|  | ||||
| int stats_nl80211_init(void) | ||||
| { | ||||
| 	if (unl_genl_init(&unl_req, "nl80211") < 0) { | ||||
| 	if (unl_genl_init(&unl, "nl80211") < 0) { | ||||
| 		LOGE("failed to spawn nl80211"); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	if (unl_genl_init(&unl_notify, "nl80211") < 0) { | ||||
| 		LOGE("failed to spawn nl80211"); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	if (nl_socket_set_buffer_size(unl_notify.sock, 262144, 0) < 0) | ||||
| 	if (nl_socket_set_buffer_size(unl.sock, 262144, 0) < 0) | ||||
| 		LOGE("stats_nl80211: Failed to set nl socket buffer size"); | ||||
|  | ||||
| 	if (nl_socket_set_nonblocking(unl_notify.sock)) | ||||
| 		LOGE("stats_nl80211: Failed to set stats nl socket in the non blocking mode"); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|   | ||||
| @@ -1,62 +0,0 @@ | ||||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include <stdbool.h> | ||||
| #include <time.h> | ||||
|  | ||||
| #include "log.h" | ||||
| #include "evsched.h" | ||||
|  | ||||
| #include "timer.h" | ||||
|  | ||||
| static int tv_diff(struct timeval *t1, struct timeval *t2) | ||||
| { | ||||
| 	return | ||||
| 			(t1->tv_sec - t2->tv_sec) * 1000 + | ||||
| 			(t1->tv_usec - t2->tv_usec) / 1000; | ||||
| } | ||||
|  | ||||
| static void gettime(struct timeval *tv) | ||||
| { | ||||
| 	struct timespec ts; | ||||
|  | ||||
| 	clock_gettime(CLOCK_MONOTONIC, &ts); | ||||
| 	tv->tv_sec = ts.tv_sec; | ||||
| 	tv->tv_usec = ts.tv_nsec / 1000; | ||||
| } | ||||
|  | ||||
| int timeout_set(struct timeout *timeout, int msecs) | ||||
| { | ||||
| 	if (!timeout) { | ||||
| 		LOGE("%s No timer data", __func__); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	struct timeval *time = &timeout->time; | ||||
|  | ||||
| 	if (timeout->pending) | ||||
| 		timeout->pending = false; | ||||
|  | ||||
| 	gettime(time); | ||||
|  | ||||
| 	time->tv_sec += msecs / 1000; | ||||
| 	time->tv_usec += (msecs % 1000) * 1000; | ||||
|  | ||||
| 	if (time->tv_usec > 1000000) { | ||||
| 		time->tv_sec++; | ||||
| 		time->tv_usec -= 1000000; | ||||
| 	} | ||||
| 	timeout->pending = true; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| void timer_expiry_check(struct timeout *t) | ||||
| { | ||||
| 	struct timeval tv; | ||||
| 	gettime(&tv); | ||||
| 	if (t->pending && tv_diff(&t->time, &tv) <= 0) { | ||||
| 		t->pending = false; | ||||
| 		LOGI("%s Timer Expired..Executing callback", __func__); | ||||
| 		if (t->cb) | ||||
| 			t->cb(t); | ||||
| 	} | ||||
| } | ||||
| @@ -210,10 +210,8 @@ int uci_section_to_blob(struct uci_context *uci, char *package, char *section, | ||||
|  | ||||
| 	if (uci_load(uci, package, &p)) | ||||
| 		p = uci_lookup_package(uci, package); | ||||
| 	if (!p) { | ||||
| 		uci_unload(uci, p); | ||||
| 	if (!p) | ||||
| 		return -1; | ||||
| 	} | ||||
| 	s = uci_lookup_section(uci, p, section); | ||||
| 	if (!s) | ||||
| 		goto out; | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
|  | ||||
| #include <string.h> | ||||
| #include <math.h> | ||||
| #include <glob.h> | ||||
| #include <libgen.h> | ||||
| #include <fcntl.h> | ||||
| @@ -196,34 +195,22 @@ int phy_from_path(char *_path, char *phy, unsigned int idx) | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| int phy_find_hwmon_helper(char *dir, char *file, char *hwmon) | ||||
| { | ||||
| 	glob_t gl; | ||||
| 	if (glob(dir, GLOB_NOSORT | GLOB_MARK, NULL, &gl)) | ||||
| 		return -1; | ||||
| 	if (gl.gl_pathc) { | ||||
| 		strcpy(hwmon, gl.gl_pathv[0]); | ||||
| 		strncat(hwmon, file, PATH_MAX); | ||||
| 	} | ||||
| 	globfree(&gl); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| int phy_find_hwmon(char *phy, char *hwmon, bool *DegreesNotMilliDegrees) | ||||
| int phy_find_hwmon(char *phy, char *hwmon) | ||||
| { | ||||
| 	char tmp[PATH_MAX]; | ||||
| 	glob_t gl; | ||||
|  | ||||
| 	*hwmon = '\0'; | ||||
| 	snprintf(tmp, sizeof(tmp), "/sys/class/ieee80211/%s/device/hwmon/*", phy); | ||||
| 	if (!phy_find_hwmon_helper(tmp, "temp1_input", hwmon)) { | ||||
| 		*DegreesNotMilliDegrees=false; | ||||
| 		return 0; | ||||
| 	if (glob(tmp, GLOB_NOSORT | GLOB_MARK, NULL, &gl)) | ||||
|                 return -1; | ||||
| 	if (gl.gl_pathc) { | ||||
| 		strcpy(hwmon, gl.gl_pathv[0]); | ||||
| 		strncat(hwmon, "temp1_input", PATH_MAX); | ||||
| 	} | ||||
| 	snprintf(tmp, sizeof(tmp), "/sys/class/ieee80211/%s/cooling_device/subsystem/thermal_zone0/", phy); | ||||
| 	if (!phy_find_hwmon_helper(tmp, "temp", hwmon)) { | ||||
| 		*DegreesNotMilliDegrees=true; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	return -1; | ||||
| 	globfree(&gl); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| int phy_get_mac(char *phy, char *mac) | ||||
| @@ -309,21 +296,6 @@ int phy_get_channels(const char *name, int *channel) | ||||
| 	return j; | ||||
| } | ||||
|  | ||||
| // Gets all the dfs channels avaible for a radio | ||||
| int phy_get_dfs_channels(const char *name, int *dfs_channels) | ||||
| { | ||||
| 	struct wifi_phy *phy = phy_find(name); | ||||
| 	int i, j = 0; | ||||
|  | ||||
| 	if (!phy) | ||||
| 		return 0; | ||||
|  | ||||
| 	for (i = 0; (i < IEEE80211_CHAN_MAX) && (j < 64); i++) | ||||
| 		if (phy->chandfs[i]) | ||||
| 			dfs_channels[j++] = i; | ||||
| 	return j; | ||||
| } | ||||
|  | ||||
| static void update_channels_state(struct schema_Wifi_Radio_State *rstate, | ||||
| 			int *index, const char *key, int *value, int value_len) | ||||
| { | ||||
| @@ -418,22 +390,6 @@ int phy_lookup(char *name) | ||||
| 	return atoi(buf); | ||||
| } | ||||
|  | ||||
| int phy_get_ath_driver_name(char *phy, char *ath_driver) | ||||
| { | ||||
| 	glob_t gl; | ||||
| 	char path[128]; | ||||
| 	snprintf(path, sizeof(path), | ||||
| 			"/sys/kernel/debug/ieee80211/%s/[ath]*", phy); | ||||
| 	if (glob(path, GLOB_NOSORT | GLOB_MARK, NULL, &gl)) | ||||
| 		return -1; | ||||
| 	if (gl.gl_pathc) { | ||||
| 		memset(ath_driver, '\0', ATH_DRIVER_NAME_LEN); | ||||
| 		strncpy(ath_driver, basename(gl.gl_pathv[0]), ATH_DRIVER_NAME_LEN - 1); | ||||
| 	} | ||||
| 	globfree(&gl); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| int vif_get_mac(char *vap, char *mac) | ||||
| { | ||||
| 	int sz = ETH_ALEN * 3; | ||||
| @@ -528,17 +484,6 @@ bool vif_state_to_conf(struct schema_Wifi_VIF_State *vstate, | ||||
| 	} | ||||
| 	vconf->custom_options_len = vstate->custom_options_len; | ||||
|  | ||||
| 	for (i = 0; i < vstate->captive_allowlist_len; i++) | ||||
| 		STRSCPY(vconf->captive_allowlist[i], vstate->captive_allowlist[i]); | ||||
| 	vconf->captive_allowlist_len = vstate->captive_allowlist_len; | ||||
|  | ||||
| 	for (i = 0; i < vstate->captive_portal_len; i++) { | ||||
| 		STRSCPY(vconf->captive_portal_keys[i], | ||||
| 			vstate->captive_portal_keys[i]); | ||||
| 		STRSCPY(vconf->captive_portal[i], vstate->captive_portal[i]); | ||||
| 	} | ||||
| 	vconf->captive_portal_len = vstate->captive_portal_len; | ||||
|  | ||||
| 	return true; | ||||
|  | ||||
| #undef VIF_COPY | ||||
| @@ -736,14 +681,3 @@ bool vif_get_key_for_key_distr(const char *secret, char *key_str) | ||||
| 	fclose(fp); | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| double dBm_to_mwatts(double dBm) | ||||
| { | ||||
| 	return (pow(10,(dBm/10))); | ||||
| } | ||||
|  | ||||
| double mWatts_to_dBm(double mW) | ||||
| { | ||||
| 	return (10*log10(mW)); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -26,14 +26,12 @@ | ||||
| #include "ovsdb_table.h" | ||||
| #include "ovsdb_sync.h" | ||||
| #include "rrm_config.h" | ||||
| #include "fixup.h" | ||||
|  | ||||
| #define MODULE_ID LOG_MODULE_ID_VIF | ||||
| #define UCI_BUFFER_SIZE 80 | ||||
|  | ||||
| extern ovsdb_table_t table_Wifi_VIF_Config; | ||||
| extern ovsdb_table_t table_Hotspot20_Icon_Config; | ||||
| extern ovsdb_table_t table_Radius_Proxy_Config; | ||||
|  | ||||
| extern struct blob_buf b; | ||||
| extern struct blob_buf del; | ||||
| @@ -96,7 +94,6 @@ enum { | ||||
| 	WIF_ATTR_VENUE_URL, | ||||
| 	WIF_ATTR_NETWORK_AUTH_TYPE, | ||||
| 	WIF_ATTR_IPADDR_TYPE_AVAILABILITY, | ||||
| 	WIF_ATTR_CONNECTION_CAPABILITY, | ||||
| 	WIF_ATTR_DOMAIN_NAME, | ||||
| 	WIF_ATTR_MCC_MNC, | ||||
| 	WIF_ATTR_NAI_REALM, | ||||
| @@ -135,9 +132,6 @@ enum { | ||||
| 	WIF_ATTR_11R_R0KH, | ||||
| 	WIF_ATTR_11R_R1KH, | ||||
| 	WIF_ATTR_RADPROXY, | ||||
| 	WIF_ATTR_PROXY_ARP, | ||||
| 	WIF_ATTR_MCAST_TO_UCAST, | ||||
| 	WIF_ATTR_AUTH_CACHE, | ||||
| 	__WIF_ATTR_MAX, | ||||
| }; | ||||
|  | ||||
| @@ -193,8 +187,7 @@ static const struct blobmsg_policy wifi_iface_policy[__WIF_ATTR_MAX] = { | ||||
| 	[WIF_ATTR_VENUE_TYPE] = { .name = "venue_type", BLOBMSG_TYPE_INT32 }, | ||||
| 	[WIF_ATTR_VENUE_URL] = { .name = "venue_url", BLOBMSG_TYPE_ARRAY }, | ||||
| 	[WIF_ATTR_NETWORK_AUTH_TYPE] = { .name = "network_auth_type", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_IPADDR_TYPE_AVAILABILITY] = { .name = "ipaddr_type_availability", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_CONNECTION_CAPABILITY] = { .name = "hs20_conn_capab", BLOBMSG_TYPE_ARRAY }, | ||||
| 	[WIF_ATTR_IPADDR_TYPE_AVAILABILITY] = { .name = "ipaddr_type_availability", BLOBMSG_TYPE_INT32 }, | ||||
| 	[WIF_ATTR_DOMAIN_NAME] = { .name = "domain_name", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_MCC_MNC] = { .name = "anqp_3gpp_cell_net", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_NAI_REALM] = { .name = "nai_realm", BLOBMSG_TYPE_ARRAY }, | ||||
| @@ -233,9 +226,6 @@ static const struct blobmsg_policy wifi_iface_policy[__WIF_ATTR_MAX] = { | ||||
| 	[WIF_ATTR_11R_R0KH] = { .name = "r0kh", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_11R_R1KH] = { .name = "r1kh", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_RADPROXY] = { .name = "radproxy", BLOBMSG_TYPE_STRING }, | ||||
| 	[WIF_ATTR_PROXY_ARP] = { .name = "proxy_arp", BLOBMSG_TYPE_BOOL }, | ||||
| 	[WIF_ATTR_MCAST_TO_UCAST] = { .name = "multicast_to_unicast", BLOBMSG_TYPE_BOOL }, | ||||
| 	[WIF_ATTR_AUTH_CACHE] = { .name = "auth_cache", BLOBMSG_TYPE_BOOL }, | ||||
| }; | ||||
|  | ||||
| const struct uci_blob_param_list wifi_iface_param = { | ||||
| @@ -323,17 +313,17 @@ static struct vif_crypto { | ||||
| 	{ "wpa-mixed", OVSDB_SECURITY_ENCRYPTION_WPA_EAP, OVSDB_SECURITY_MODE_MIXED, 1 }, | ||||
| 	{ "sae", OVSDB_SECURITY_ENCRYPTION_WPA_SAE, OVSDB_SECURITY_MODE_WPA3, 0 }, | ||||
| 	{ "sae-mixed", OVSDB_SECURITY_ENCRYPTION_WPA_SAE, OVSDB_SECURITY_MODE_MIXED, 0 }, | ||||
| 	{ "wpa3-only", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP, OVSDB_SECURITY_MODE_WPA3, 1 }, | ||||
| 	{ "wpa3", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP, OVSDB_SECURITY_MODE_WPA3, 1 }, | ||||
| 	{ "wpa3-mixed", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP, OVSDB_SECURITY_MODE_MIXED, 1 }, | ||||
| 	{ "wpa3", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP_192, OVSDB_SECURITY_MODE_WPA3, 1 }, | ||||
| }; | ||||
|  | ||||
| extern ovsdb_table_t table_APC_State; | ||||
| extern json_t* ovsdb_table_where(ovsdb_table_t *table, void *record); | ||||
| extern unsigned int radproxy_apc; | ||||
|  | ||||
| /* Custom options table */ | ||||
| #define SCHEMA_CUSTOM_OPT_SZ            20 | ||||
| #define SCHEMA_CUSTOM_OPTS_MAX          15 | ||||
| #define SCHEMA_CUSTOM_OPTS_MAX          13 | ||||
|  | ||||
| const char custom_options_table[SCHEMA_CUSTOM_OPTS_MAX][SCHEMA_CUSTOM_OPT_SZ] = | ||||
| { | ||||
| @@ -350,8 +340,6 @@ const char custom_options_table[SCHEMA_CUSTOM_OPTS_MAX][SCHEMA_CUSTOM_OPT_SZ] = | ||||
| 	SCHEMA_CONSTS_RADIUS_NAS_IP, | ||||
| 	SCHEMA_CONSTS_DYNAMIC_VLAN, | ||||
| 	SCHEMA_CONSTS_RADPROXY, | ||||
| 	SCHEMA_CONSTS_PROXY_ARP, | ||||
| 	SCHEMA_CONSTS_MCAST_TO_UCAST, | ||||
| }; | ||||
|  | ||||
| static bool vif_config_custom_opt_get_proxy( | ||||
| @@ -391,8 +379,7 @@ static int vif_config_security_set(struct blob_buf *b, | ||||
| 	const char *mode = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_MODE); | ||||
| 	unsigned int i; | ||||
| 	unsigned int acct_interval; | ||||
| 	const char *auth_server, *auth_port, *auth_secret, *security_key; | ||||
| 	const char *acct_server, *acct_port, *acct_secret; | ||||
| 	const char *auth_server, *auth_port, *auth_secret, *security_key, *acct_server; | ||||
| 	char key_str[64], key_holder_str[128]; | ||||
| 	struct schema_APC_State apc_conf; | ||||
| 	const char *local_server = "127.0.0.1"; | ||||
| @@ -414,14 +401,14 @@ static int vif_config_security_set(struct blob_buf *b, | ||||
|  | ||||
| 		if (vif_crypto[i].enterprise) { | ||||
|  | ||||
| 			if (vif_config_custom_opt_get_proxy(vconf)) { /* Radius Proxy Enabled */ | ||||
| 			if (vif_config_custom_opt_get_proxy(vconf)) { | ||||
| 				LOGN("%s: Apply Proxy Security Settings", vconf->if_name); | ||||
| 				if(apc_read_state(&apc_conf) == false) | ||||
| 				{ | ||||
| 					LOGI("APC_State read failed"); | ||||
| 				json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf); | ||||
| 				if (false == ovsdb_table_select_one_where(&table_APC_State, | ||||
| 						where, &apc_conf)) { | ||||
| 					LOG(INFO, "APC_State read failed"); | ||||
| 					return -1; | ||||
| 				} | ||||
|  | ||||
| 				if (!strncmp(apc_conf.mode, "DR", 2)) { | ||||
| 					auth_server = local_server; | ||||
| 					acct_server = local_server; | ||||
| @@ -434,22 +421,16 @@ static int vif_config_security_set(struct blob_buf *b, | ||||
| 					auth_server = local_server; | ||||
| 					acct_server = local_server; | ||||
| 				} | ||||
| 				auth_port = "1812"; | ||||
| 				auth_secret = "secret"; | ||||
| 				acct_port = "1813"; | ||||
| 				acct_secret = "secret"; | ||||
| 			} | ||||
| 			else /* Radius Proxy Disabled */ | ||||
| 			else | ||||
| 			{ | ||||
| 				auth_server = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_IP); | ||||
| 				acct_server = SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_IP); | ||||
| 				auth_port   = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_PORT); | ||||
| 				auth_secret = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_SECRET); | ||||
| 				acct_port = SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_PORT); | ||||
| 				acct_secret = SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_SECRET); | ||||
| 			} | ||||
|  | ||||
| 			acct_interval = 0; | ||||
| 			auth_port   = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_PORT); | ||||
| 			auth_secret = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_SECRET); | ||||
|  | ||||
| 			LOGT("%s: Server IP %s port %s secret %s", vconf->if_name, auth_server, auth_port, auth_secret); | ||||
| 			if (!auth_server[0] || !auth_port[0] || !auth_secret[0]) { | ||||
| @@ -461,8 +442,10 @@ static int vif_config_security_set(struct blob_buf *b, | ||||
| 			blobmsg_add_string(b, "auth_port",   auth_port ); | ||||
| 			blobmsg_add_string(b, "auth_secret", auth_secret ); | ||||
| 			blobmsg_add_string(b, "acct_server", acct_server); | ||||
| 			blobmsg_add_string(b, "acct_port", acct_port); | ||||
| 			blobmsg_add_string(b, "acct_secret", acct_secret); | ||||
| 			blobmsg_add_string(b, "acct_port", | ||||
| 					   SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_PORT)); | ||||
| 			blobmsg_add_string(b, "acct_secret", | ||||
| 					   SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_SECRET)); | ||||
| 			blobmsg_add_bool(b, "request_cui", 1); | ||||
| 			acct_interval = atoi(SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_INTERVAL)); | ||||
|  | ||||
| @@ -490,7 +473,6 @@ static int vif_config_security_set(struct blob_buf *b, | ||||
| 				strcat(key_holder_str, key_str); | ||||
| 				blobmsg_add_string(b, "r1kh", key_holder_str); | ||||
| 			} | ||||
| 			blobmsg_add_bool(b, "auth_cache", 1); | ||||
| 		} else { | ||||
| 			security_key = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_KEY); | ||||
| 			if (security_key == NULL) { | ||||
| @@ -672,19 +654,8 @@ static void vif_config_custom_opt_set(struct blob_buf *b, struct blob_buf *del, | ||||
| 				strncpy(value, "br-wan.", 20); | ||||
| 				blobmsg_add_string(del, "vlan_bridge", value); | ||||
| 			} | ||||
| 		} else if (strcmp(opt, "radproxy") == 0) { | ||||
| 		} else if (strcmp(opt, "radproxy") == 0) | ||||
| 			blobmsg_add_string(b, "radproxy", value); | ||||
| 		} else if (strcmp(opt, "proxy_arp") == 0) { | ||||
| 			if (strcmp(value, "1") == 0) | ||||
| 				blobmsg_add_bool(b, "proxy_arp", 1); | ||||
| 			else if (strcmp(value, "0") == 0) | ||||
| 				blobmsg_add_bool(del, "proxy_arp", 1); | ||||
| 		} else if (strcmp(opt, "mcast_to_ucast") == 0) { | ||||
| 			if (strcmp(value, "1") == 0) | ||||
| 				blobmsg_add_bool(b, "multicast_to_unicast", 1); | ||||
| 			else if (strcmp(value, "0") == 0) | ||||
| 				blobmsg_add_bool(del, "multicast_to_unicast", 1); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* No NASID was found from blob, so use BSSID as NASID */ | ||||
| @@ -834,33 +805,8 @@ static void vif_state_custom_options_get(struct schema_Wifi_VIF_State *vstate, | ||||
| 							custom_options_table[i], | ||||
| 							buf); | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 		} else if (strcmp(opt, "proxy_arp") == 0) { | ||||
| 			if (tb[WIF_ATTR_PROXY_ARP]) { | ||||
| 				if (blobmsg_get_bool(tb[WIF_ATTR_PROXY_ARP])) { | ||||
| 					set_custom_option_state(vstate, &index, | ||||
| 								custom_options_table[i], | ||||
| 								"1"); | ||||
| 				} else { | ||||
| 					set_custom_option_state(vstate, &index, | ||||
| 								custom_options_table[i], | ||||
| 								"0"); | ||||
| 				} | ||||
| 			} | ||||
| 		} else if (strcmp(opt, "mcast_to_ucast") == 0) { | ||||
| 			if (tb[WIF_ATTR_MCAST_TO_UCAST]) { | ||||
| 				if (blobmsg_get_bool(tb[WIF_ATTR_MCAST_TO_UCAST])) { | ||||
| 					set_custom_option_state(vstate, &index, | ||||
| 								custom_options_table[i], | ||||
| 								"1"); | ||||
| 				} else { | ||||
| 					set_custom_option_state(vstate, &index, | ||||
| 								custom_options_table[i], | ||||
| 								"0"); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -1030,69 +976,93 @@ size_t write_file(void *ptr, size_t size, size_t nmemb, FILE *stream) { | ||||
|  | ||||
| void vif_section_del(char *section_name) | ||||
| { | ||||
|  | ||||
| 	struct uci_package *wireless; | ||||
| 	struct uci_context *sec_ctx; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
| 	int ret=0; | ||||
| 	sec_ctx = uci_alloc_context(); | ||||
| 	ret= uci_load(sec_ctx, "wireless", &wireless); | ||||
|  | ||||
| 	ret= uci_load(uci, "wireless", &wireless); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: %s uci_load() failed with rc %d", section_name, __func__, ret); | ||||
| 		if (sec_ctx) | ||||
| 			uci_free_context(sec_ctx); | ||||
| 		LOGD("%s: uci_load() failed with rc %d", section_name, ret); | ||||
| 		return; | ||||
| 	} | ||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | ||||
| 		struct uci_section *s = uci_to_section(e); | ||||
| 		if ((s == NULL) || (s->type == NULL)) continue; | ||||
| 		if (!strcmp(s->type, section_name)) { | ||||
| 			uci_section_del(sec_ctx, "vif", "wireless", (char *)s->e.name, section_name); | ||||
| 			uci_section_del(uci, "vif", "wireless", (char *)s->e.name, section_name); | ||||
| 		} | ||||
| 		else { | ||||
| 			continue; | ||||
| 		} | ||||
| 	} | ||||
| 	uci_commit(sec_ctx, &wireless, false); | ||||
| 	uci_unload(sec_ctx, wireless); | ||||
| 	if (sec_ctx) | ||||
| 		uci_free_context(sec_ctx); | ||||
| 	uci_commit(uci, &wireless, false); | ||||
| 	uci_unload(uci, wireless); | ||||
| 	reload_config = 1; | ||||
|  | ||||
| } | ||||
|  | ||||
| void vif_check_radius_proxy() | ||||
| static void vif_check_radius_proxy() | ||||
| { | ||||
| 	struct uci_context *uci_ctx; | ||||
| 	struct uci_package *wireless; | ||||
| 	struct schema_APC_State apc_conf; | ||||
| 	int n = 0; | ||||
| 	void *buf = NULL; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
| 	char *buf = NULL; | ||||
| 	int rc = 0; | ||||
|  | ||||
| 	if(apc_read_state(&apc_conf) == false) | ||||
| 	json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf); | ||||
| 	if (false == ovsdb_table_select_one_where(&table_APC_State, where, &apc_conf)) | ||||
| 	{ | ||||
| 		LOGI("APC_State read failed"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	buf = ovsdb_table_select_where(&table_Radius_Proxy_Config, NULL, &n); | ||||
| 	if (!buf) | ||||
| 	{ | ||||
| 		LOGI("Radius_Proxy_Config table doesn't exist.  Stop radsecproxy service."); | ||||
| 		system("/etc/init.d/radsecproxy stop"); | ||||
| 		return; | ||||
| 	} | ||||
| 	else if (!strcmp(apc_conf.mode, "DR")) | ||||
| 	{ | ||||
| 		if (!system("pidof radsecproxy")) | ||||
| 			goto out; | ||||
| 	uci_ctx = uci_alloc_context(); | ||||
|  | ||||
| 		LOGI("Start radsecproxy service."); | ||||
| 		system("/etc/init.d/radsecproxy start"); | ||||
| 	} | ||||
| 	else | ||||
| 	rc = uci_load(uci_ctx, "wireless", &wireless); | ||||
|  | ||||
| 	if (rc) | ||||
| 	{ | ||||
| 		LOGI("Not DR. Stop radsecproxy service."); | ||||
| 		system("/etc/init.d/radsecproxy stop"); | ||||
| 		LOGD("%s: uci_load() failed with rc %d", __func__, rc); | ||||
| 		goto free; | ||||
| 	} | ||||
|  | ||||
| out: | ||||
| 	free(buf); | ||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) | ||||
| 	{ | ||||
| 		struct blob_attr *tb[__WIF_ATTR_MAX]; | ||||
| 		struct uci_section *s = uci_to_section(e); | ||||
| 		if ((s == NULL) || (s->type == NULL)) | ||||
| 			continue; | ||||
|  | ||||
| 		if (strcmp(s->type, "wifi-iface")) | ||||
| 			continue; | ||||
|  | ||||
| 		blob_buf_init(&b, 0); | ||||
| 		uci_to_blob(&b, s, &wifi_iface_param); | ||||
| 		blobmsg_parse(wifi_iface_policy, __WIF_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | ||||
|  | ||||
| 		if (tb[WIF_ATTR_RADPROXY]) | ||||
| 		{ | ||||
| 			buf = blobmsg_get_string(tb[WIF_ATTR_RADPROXY]); | ||||
|  | ||||
| 			if (!strcmp(buf, "1") && !strcmp(apc_conf.mode, "DR")) | ||||
| 			{ | ||||
| 				if (!system("pidof radsecproxy")) | ||||
| 					goto free; | ||||
|  | ||||
| 				system("/etc/init.d/radsecproxy start"); | ||||
|  | ||||
| 				goto free; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	system("/etc/init.d/radsecproxy stop"); | ||||
|  | ||||
| free: | ||||
| 	uci_unload(uci_ctx, wireless); | ||||
| 	uci_free_context(uci_ctx); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| @@ -1150,7 +1120,6 @@ static void hs20_vif_config(struct blob_buf *b, | ||||
| 	int i = 0; | ||||
| 	unsigned int len = 0; | ||||
| 	char domain_name[256]; | ||||
| 	char str[3] = {}; | ||||
|  | ||||
| 	if (hs2conf->enable) { | ||||
| 		blobmsg_add_bool(b, "interworking", 1); | ||||
| @@ -1263,20 +1232,6 @@ static void hs20_vif_config(struct blob_buf *b, | ||||
| 	if (strlen(hs2conf->wan_metrics)) | ||||
| 		blobmsg_add_string(b, "hs20_wan_metrics", hs2conf->wan_metrics); | ||||
|  | ||||
| 	len = strlen(hs2conf->ipaddr_type_availability); | ||||
| 	if (len) | ||||
| 	{ | ||||
| 		if (len == 1) | ||||
| 		{ | ||||
| 			snprintf(str, sizeof(str), "0%s", hs2conf->ipaddr_type_availability); | ||||
| 			blobmsg_add_string(b, "ipaddr_type_availability", str); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			blobmsg_add_string(b, "ipaddr_type_availability", hs2conf->ipaddr_type_availability); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	n = blobmsg_open_array(b, "hs20_oper_friendly_name"); | ||||
| 	for (i = 0; i < hs2conf->operator_friendly_name_len; i++) | ||||
| 	{ | ||||
| @@ -1293,13 +1248,6 @@ static void hs20_vif_config(struct blob_buf *b, | ||||
| 		blobmsg_add_u32(b, "venue_type", venue_type); | ||||
| 	} | ||||
|  | ||||
| 	n = blobmsg_open_array(b, "hs20_conn_capab"); | ||||
| 	for (i = 0; i < hs2conf->connection_capability_len; i++) | ||||
| 	{ | ||||
| 		blobmsg_add_string(b, NULL, hs2conf->connection_capability[i]); | ||||
| 	} | ||||
| 	blobmsg_close_array(b, n); | ||||
|  | ||||
| 	if (hs2conf->operator_icons_len) | ||||
| 	{ | ||||
| 		n = blobmsg_open_array(b, "operator_icon"); | ||||
| @@ -1320,19 +1268,14 @@ static void hs20_vif_config(struct blob_buf *b, | ||||
| bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf) | ||||
| { | ||||
| 	struct uci_package *wireless; | ||||
| 	struct uci_context *vif_ctx; | ||||
| 	struct uci_element *e = NULL, *tmp = NULL; | ||||
| 	const char *ifname; | ||||
| 	int ret = 0; | ||||
| 	int ret=0; | ||||
|  | ||||
| 	vif_fixup_del((char *)vconf->if_name); | ||||
| 	vlan_del((char *)vconf->if_name); | ||||
| 	vif_ctx = uci_alloc_context(); | ||||
| 	ret= uci_load(vif_ctx, "wireless", &wireless); | ||||
| 	ret= uci_load(uci, "wireless", &wireless); | ||||
| 	if (ret) { | ||||
| 		LOGE("%s: %s uci_load() failed with rc %d", vconf->if_name, __func__, ret); | ||||
| 		if (vif_ctx) | ||||
| 			uci_free_context(vif_ctx); | ||||
| 		LOGD("%s: uci_load() failed with rc %d", vconf->if_name, ret); | ||||
| 		return false; | ||||
| 	} | ||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | ||||
| @@ -1340,20 +1283,15 @@ bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf) | ||||
| 		if ((s == NULL) || (s->type == NULL)) continue;  | ||||
| 		if (strcmp(s->type, "wifi-iface")) continue; | ||||
|  | ||||
| 		ifname = uci_lookup_option_string( vif_ctx, s, "ifname" ); | ||||
| 		if (ifname == NULL) { | ||||
| 			/* Delete this section because it doesn't have an ifname - it is invalid */ | ||||
| 			uci_section_del(vif_ctx, "vif", "wireless", (char *)s->e.name, "wifi-iface"); | ||||
| 		} else if (!strcmp(ifname,vconf->if_name)) { | ||||
| 			/* Delete this section because it matches the if_name we are trying to delete */ | ||||
| 			uci_section_del(vif_ctx, "vif", "wireless", (char *)s->e.name, "wifi-iface"); | ||||
| 		ifname = uci_lookup_option_string( uci, s, "ifname" ); | ||||
| 		if (!strcmp(ifname,vconf->if_name)) { | ||||
| 			uci_section_del(uci, "vif", "wireless", (char *)s->e.name, "wifi-iface"); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	uci_commit(vif_ctx, &wireless, false); | ||||
| 	uci_unload(vif_ctx, wireless); | ||||
| 	if (vif_ctx) | ||||
| 		uci_free_context(vif_ctx); | ||||
| 	uci_commit(uci, &wireless, false); | ||||
| 	uci_unload(uci, wireless); | ||||
| 	reload_config = 1; | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| @@ -1408,7 +1346,7 @@ void vif_hs20_osu_update(struct schema_Hotspot20_OSU_Providers *osuconf) | ||||
|  | ||||
| 	blob_to_uci_section(uci, "wireless", osuconf->osu_provider_name, "osu-provider", | ||||
| 			osu.head, &wifi_hs20_osu_param, NULL); | ||||
| 	uci_commit_all(uci); | ||||
| 	reload_config = 1; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1439,7 +1377,7 @@ void vif_hs20_icon_update(struct schema_Hotspot20_Icon_Config *iconconf) | ||||
|  | ||||
| 		blob_to_uci_section(uci, "wireless", iconconf->icon_config_name, "hs20-icon", | ||||
| 				hs20.head, &wifi_hs20_icon_param, NULL); | ||||
| 		uci_commit_all(uci); | ||||
| 		reload_config = 1; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -1462,9 +1400,9 @@ void vif_hs20_update(struct schema_Hotspot20_Config *hs2conf) | ||||
| 			hs20_vif_config(&b, hs2conf); | ||||
| 			blob_to_uci_section(uci, "wireless", vconf.if_name, "wifi-iface", | ||||
| 					b.head, &wifi_iface_param, NULL); | ||||
| 			reload_config = 1; | ||||
| 		} | ||||
| 	} | ||||
| 	uci_commit_all(uci); | ||||
| } | ||||
|  | ||||
| /* Mesh options table */ | ||||
| @@ -1532,7 +1470,8 @@ static int mesh_vif_config_set(const struct schema_Wifi_Radio_Config *rconf, | ||||
| 	blobmsg_add_string(&mesh, "master", "bat0"); | ||||
| 	blob_to_uci_section(uci, "network", vconf->if_name, "interface", | ||||
| 			mesh.head, &wifi_mesh_param, NULL); | ||||
| 	uci_commit_all(uci); | ||||
|  | ||||
| 	reload_config = 1; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| @@ -1544,6 +1483,7 @@ static int ap_vif_config_set(const struct schema_Wifi_Radio_Config *rconf, | ||||
|  | ||||
| 	blob_buf_init(&b, 0); | ||||
| 	blob_buf_init(&del,0); | ||||
|  | ||||
| 	blobmsg_add_string(&b, "ifname", vconf->if_name); | ||||
| 	blobmsg_add_string(&b, "device", rconf->if_name); | ||||
| 	blobmsg_add_string(&b, "mode", "ap"); | ||||
| @@ -1651,7 +1591,11 @@ static int ap_vif_config_set(const struct schema_Wifi_Radio_Config *rconf, | ||||
| 	{ | ||||
| 		vif_dhcp_opennds_allowlist_set(vconf,(char*)vconf->if_name); | ||||
| 	} | ||||
| 	uci_commit_all(uci); | ||||
|  | ||||
| 	if (changed->custom_options) | ||||
| 		vif_check_radius_proxy(); | ||||
|  | ||||
| 	reload_config = 1; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -75,6 +75,7 @@ const struct uci_blob_param_list network_param = { | ||||
| 	.params = network_policy, | ||||
| }; | ||||
|  | ||||
| int reload_config = 0; | ||||
| ovsdb_table_t table_Wifi_Inet_Config; | ||||
| struct blob_buf b = { }; | ||||
| struct blob_buf del = { }; | ||||
| @@ -341,6 +342,7 @@ static int wifi_inet_conf_add(struct schema_Wifi_Inet_Config *iconf) | ||||
| 	} | ||||
|  | ||||
| 	uci_commit_all(uci); | ||||
| 	reload_config = 1; | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| @@ -359,6 +361,7 @@ static void wifi_inet_conf_del(struct schema_Wifi_Inet_Config *iconf) | ||||
|  | ||||
| 	uci_section_del(uci, "network", "network", iconf->if_name, "interface"); | ||||
| 	uci_commit_all(uci); | ||||
| 	reload_config = 1; | ||||
| } | ||||
|  | ||||
| static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon, | ||||
| @@ -367,24 +370,10 @@ static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon, | ||||
| { | ||||
| 	switch (mon->mon_type) { | ||||
| 	case OVSDB_UPDATE_NEW: | ||||
| 		if (iconf->parent_ifname_exists && iconf->vlan_id > 2) { | ||||
| 			if(!strncmp(iconf->parent_ifname, "lan", strlen("lan"))) { | ||||
| 				/* Skip adding VLAN interface for lan */ | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		wifi_inet_conf_add(iconf); | ||||
| 		netifd_add_inet_conf(iconf); | ||||
| 		break; | ||||
| 	case OVSDB_UPDATE_MODIFY: | ||||
| 		if (iconf->parent_ifname_exists && iconf->vlan_id > 2) { | ||||
| 			if(!strncmp(iconf->parent_ifname, "lan", strlen("lan"))) { | ||||
| 				/* Skip adding VLAN interface for lan */ | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		wifi_inet_conf_add(iconf); | ||||
| 		netifd_modify_inet_conf(iconf); | ||||
| 		break; | ||||
| @@ -399,6 +388,17 @@ static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon, | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| static void periodic_task(void *arg) | ||||
| { | ||||
| 	if (reload_config) { | ||||
| 		uci_commit_all(uci); | ||||
| 		system("reload_config"); | ||||
| 		reload_config = 0; | ||||
| 	} | ||||
|  | ||||
| 	evsched_task_reschedule_ms(EVSCHED_SEC(5)); | ||||
| } | ||||
|  | ||||
| void wifi_inet_config_init(void) | ||||
| { | ||||
| 	struct uci_element *e = NULL; | ||||
| @@ -418,6 +418,7 @@ void wifi_inet_config_init(void) | ||||
| 	} | ||||
| 	uci_unload(uci, network); | ||||
| 	OVSDB_TABLE_MONITOR(Wifi_Inet_Config, false); | ||||
| 	evsched_task(&periodic_task, NULL, EVSCHED_SEC(5)); | ||||
|  | ||||
| 	return; | ||||
| } | ||||
|   | ||||
| @@ -48,12 +48,6 @@ typedef struct | ||||
| 	ds_tree_node_t                  node; | ||||
| } rrm_vif_state_t; | ||||
|  | ||||
| #define RRM_CHANNEL_INTERVAL     15 | ||||
|  | ||||
| #define RRM_MAX_NF_SAMPLES 100 | ||||
| #define RRM_OBSS_HOP_MODE_NON_WIFI		1 | ||||
| #define RRM_OBSS_HOP_MODE_NON_WIFI_AND_OBSS	2 | ||||
|  | ||||
| typedef struct | ||||
| { | ||||
| 	// Cached data | ||||
| @@ -65,17 +59,9 @@ typedef struct | ||||
| 	uint32_t min_load; | ||||
| 	uint32_t beacon_rate; | ||||
| 	uint32_t mcast_rate; | ||||
| 	int32_t noise_floor_thresh; | ||||
| 	uint32_t noise_floor_time; | ||||
| 	int32_t non_wifi_thresh; | ||||
| 	uint32_t non_wifi_time; | ||||
| 	uint32_t obss_hop_mode; | ||||
|  | ||||
| 	// Internal state data | ||||
| 	int32_t avg_nf; | ||||
| 	int32_t rrm_chan_nf_next_el; | ||||
| 	int32_t rrm_chan_nf_num_el; | ||||
| 	double rrm_chan_nf_samples[RRM_MAX_NF_SAMPLES]; | ||||
| 	int32_t noise_lwm; | ||||
| } rrm_entry_t; | ||||
|  | ||||
| typedef struct | ||||
| @@ -89,12 +75,10 @@ int rrm_setup_monitor(void); | ||||
| void rrm_channel_init(void); | ||||
| int rrm_ubus_init(struct ev_loop *loop); | ||||
| int ubus_get_noise(const char *if_name, uint32_t *noise); | ||||
| int ubus_set_channel_switch(const char *if_name, uint32_t frequency, const char *hw_mode, int channel_bandwidth, int sec_chan_offset, int reason); | ||||
| int ubus_set_channel_switch(const char *if_name, uint32_t frequency, int channel_bandwidth, int sec_chan_offset); | ||||
| void set_rrm_parameters(rrm_entry_t *rrm_data); | ||||
| ds_tree_t* rrm_get_rrm_config_list(void); | ||||
| ds_tree_t* rrm_get_radio_list(void); | ||||
| ds_tree_t* rrm_get_vif_list(void); | ||||
| void rrm_reset_noise_floor_samples(rrm_entry_t *rrm_data); | ||||
| void rrm_radio_rebalance_channel(const struct schema_Wifi_Radio_Config *rconf); | ||||
|  | ||||
| #endif /* RRM_H_INCLUDED */ | ||||
|   | ||||
| @@ -9,6 +9,8 @@ | ||||
| #include "uci.h" | ||||
| #include "utils.h" | ||||
|  | ||||
| #define RRM_CHANNEL_INTERVAL     15.0 | ||||
|  | ||||
| struct blob_buf b = { }; | ||||
| struct blob_buf del = { }; | ||||
| struct uci_context *uci; | ||||
| @@ -101,57 +103,6 @@ void get_channel_bandwidth(const char* htmode, int *channel_bandwidth) | ||||
| 	else if(!strcmp(htmode, "HT80")) | ||||
| 		*channel_bandwidth=80; | ||||
| } | ||||
| /* | ||||
|  * A simple average is calculated against the Noise floor samples. | ||||
|  * - Returns a zero, if there are not enough samples in the list. | ||||
|  * - Or, returns a calculated avg of the noise samples. | ||||
|  * - A circular buffer is considered for storing the samples. New elements replace the | ||||
|  * old ones in this buffer. | ||||
|  * - The number of samples required is an integer value calculated based on the | ||||
|  * configuration time and the sample time. | ||||
|  * Example: If the config_time is 120 sec, and sample time is 15 sec, then number of | ||||
|  * samples required for averaging is 120/15 = 8 samples. | ||||
|  */ | ||||
| int rrm_calculate_avg_noise_floor(rrm_entry_t *rrm_data, int nf, int config_time, int sample_time) | ||||
| { | ||||
| 	int ii; | ||||
| 	double avg_mW = 0; | ||||
| 	int num_samples = config_time/sample_time; | ||||
|  | ||||
| 	if (num_samples >= RRM_MAX_NF_SAMPLES) | ||||
| 		num_samples = RRM_MAX_NF_SAMPLES; | ||||
|  | ||||
| 	/* | ||||
| 	 * Convert dBm to milliWatts,  | ||||
| 	 * and replace the oldest element in the list with the new element | ||||
| 	 */ | ||||
| 	rrm_data->rrm_chan_nf_samples[rrm_data->rrm_chan_nf_next_el] = dBm_to_mwatts(nf); | ||||
|  | ||||
| 	/* Update the index to the oldest element index taking care of the boundary */ | ||||
| 	rrm_data->rrm_chan_nf_next_el = (rrm_data->rrm_chan_nf_next_el+1)%num_samples; | ||||
|  | ||||
| 	if (rrm_data->rrm_chan_nf_num_el < num_samples) | ||||
| 	{ | ||||
| 		rrm_data->rrm_chan_nf_num_el++; | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	/* calculate average */ | ||||
| 	for (ii = 0; ii < num_samples; ii++) | ||||
| 	{ | ||||
| 		avg_mW += rrm_data->rrm_chan_nf_samples[ii]; | ||||
| 	} | ||||
| 	avg_mW = avg_mW/num_samples; | ||||
|  | ||||
| 	 /* convert the averaged milliWats back to dBm */ | ||||
| 	return ((int)(mWatts_to_dBm(avg_mW))); | ||||
| } | ||||
|  | ||||
| void rrm_reset_noise_floor_samples(rrm_entry_t *rrm_data) | ||||
| { | ||||
| 	rrm_data->rrm_chan_nf_next_el = 0; | ||||
| 	rrm_data->rrm_chan_nf_num_el = 0; | ||||
| } | ||||
|  | ||||
| void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents) | ||||
| { | ||||
| @@ -162,6 +113,7 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents) | ||||
| 	rrm_radio_state_t       *radio = NULL; | ||||
| 	uint32_t                 noise; | ||||
| 	int32_t                  nf; | ||||
| 	int32_t                  nf_drop_threshold; | ||||
| 	rrm_config_t             *rrm_config; | ||||
|  | ||||
| 	ds_tree_t *radio_list = rrm_get_radio_list(); | ||||
| @@ -170,13 +122,14 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents) | ||||
| 	{ | ||||
| 		noise = 0; | ||||
| 		rrm_config = NULL; | ||||
| 		nf_drop_threshold = 0; | ||||
|  | ||||
| 		if (ubus_get_noise(radio->config.if_name, &noise)) | ||||
| 			continue; | ||||
|  | ||||
| 		nf = (int32_t)noise; | ||||
|  | ||||
| 		if ((nf > -10) || (nf < -120)) | ||||
| 		if (nf > -1 || nf < -120) | ||||
| 			continue; | ||||
|  | ||||
| 		rrm_config = rrm_get_rrm_config(radio->config.type); | ||||
| @@ -184,39 +137,43 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents) | ||||
| 		if (rrm_config == NULL) | ||||
| 			continue; | ||||
|  | ||||
| 		if ((rrm_config->rrm_data.backup_channel == 0) || | ||||
| 			(rrm_config->rrm_data.backup_channel == radio->config.chan)) | ||||
| 		if (nf < rrm_config->rrm_data.noise_lwm ) | ||||
| 		{ | ||||
| 			rrm_config->rrm_data.noise_lwm = nf; | ||||
| 			LOGD("[%s] noise_lwm set to %d", radio->config.if_name, nf); | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		if (rrm_config->rrm_data.snr_percentage_drop == 0) | ||||
| 			continue; | ||||
|  | ||||
| 		if (rrm_config->rrm_data.noise_floor_thresh == 0) | ||||
| 		if (rrm_config->rrm_data.backup_channel == 0) | ||||
| 			continue; | ||||
|  | ||||
| 		if (rrm_config->rrm_data.noise_floor_time == 0) | ||||
| 			continue; | ||||
| 		nf_drop_threshold = ((int32_t)(100 - rrm_config->rrm_data.snr_percentage_drop) * | ||||
| 				rrm_config->rrm_data.noise_lwm) / 100; | ||||
|  | ||||
| 		LOGD("[%s] backup=%d nf=%d nf_thresh=%d", | ||||
| 		LOGD("[%s] backup=%d nf=%d nf_lwm=%d drop=%d thresh=%d", | ||||
| 				radio->config.if_name, | ||||
| 				rrm_config->rrm_data.backup_channel, | ||||
| 				nf, | ||||
| 				rrm_config->rrm_data.noise_floor_thresh); | ||||
| 				rrm_config->rrm_data.noise_lwm, | ||||
| 				rrm_config->rrm_data.snr_percentage_drop, | ||||
| 				nf_drop_threshold); | ||||
|  | ||||
| 		rrm_config->rrm_data.avg_nf = rrm_calculate_avg_noise_floor(&(rrm_config->rrm_data),  | ||||
| 			nf, rrm_config->rrm_data.noise_floor_time, RRM_CHANNEL_INTERVAL); | ||||
|  | ||||
| 		if (rrm_config->rrm_data.avg_nf && | ||||
| 			(rrm_config->rrm_data.avg_nf > rrm_config->rrm_data.noise_floor_thresh)) | ||||
| 		if (nf > nf_drop_threshold) | ||||
| 		{ | ||||
| 			LOGI("Interference detected on [%s]," | ||||
| 				" switching to backup_channel=%d avg_nf=%d nfthresh=%d", | ||||
| 			LOGI("Interference detected on [%s], switching to backup_channel=%d nf=%d nf_lwm=%d drop=%d thresh=%d", | ||||
| 					radio->config.if_name, | ||||
| 					rrm_config->rrm_data.backup_channel, | ||||
| 					rrm_config->rrm_data.avg_nf, | ||||
| 					rrm_config->rrm_data.noise_floor_thresh); | ||||
| 					nf, | ||||
| 					rrm_config->rrm_data.noise_lwm, | ||||
| 					rrm_config->rrm_data.snr_percentage_drop, | ||||
| 					nf_drop_threshold); | ||||
| 			int channel_bandwidth; | ||||
| 			int sec_chan_offset=0; | ||||
| 			struct mode_map *m = mode_map_get_uci(radio->schema.freq_band, | ||||
| 					get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), | ||||
| 					radio->schema.ht_mode), radio->schema.hw_mode); | ||||
| 			struct mode_map *m = mode_map_get_uci(radio->schema.freq_band, get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), | ||||
| 						radio->schema.ht_mode), radio->schema.hw_mode); | ||||
| 			if (m) { | ||||
| 				sec_chan_offset = m->sec_channel_offset; | ||||
| 			} else | ||||
| @@ -225,9 +182,7 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents) | ||||
| 			get_channel_bandwidth(get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), | ||||
| 					radio->schema.ht_mode), &channel_bandwidth); | ||||
| 			ubus_set_channel_switch(radio->config.if_name, | ||||
| 					ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), radio->schema.hw_mode, channel_bandwidth, sec_chan_offset, 0); | ||||
|  | ||||
| 			rrm_reset_noise_floor_samples(&(rrm_config->rrm_data)); | ||||
| 					ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), channel_bandwidth, sec_chan_offset); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user