blob: 98f23c9d95ee58b5023ba0200436fc8f4e981017 [file] [log] [blame]
From 5175e19e0a628baff0aad73d2397e9a23bc3dc7d Mon Sep 17 00:00:00 2001
From: "howard.hsu" <howard-yh.hsu@mediatek.com>
Date: Mon, 14 Mar 2022 19:40:08 +0800
Subject: [PATCH] HAL: refactor wifi_setApMacAddressControlMode()
Change-Id: Ia9bdb3b6ac683a8634bd726b6d472eb133d258d0
---
source/wifi/wifi_hal.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c
index 5f5ac68..0ed1e85 100644
--- a/source/wifi/wifi_hal.c
+++ b/source/wifi/wifi_hal.c
@@ -68,6 +68,7 @@ Licensed under the ISC license
#define IF_NAME_SIZE 50
#define CONFIG_PREFIX "/nvram/hostapd"
#define ACL_PREFIX "/tmp/hostapd-acl"
+#define DENY_PREFIX "/tmp/hostapd-deny"
//#define ACL_PREFIX "/tmp/wifi_acl_list" //RDKB convention
#define SOCK_PREFIX "/var/run/hostapd/wifi"
#define VAP_STATUS_FILE "/tmp/vap-status"
@@ -4308,17 +4309,41 @@ INT wifi_setApMacAddressControlMode(INT apIndex, INT filterMode)
struct params list[2];
char buf[MAX_BUF_SIZE] = {0};
char config_file[MAX_BUF_SIZE] = {0}, acl_file[MAX_BUF_SIZE] = {0};
+ char deny_file[MAX_BUF_SIZE] = {0};
list[0].name = "macaddr_acl";
- sprintf(buf, "%d", filterMode);
- list[0].value = buf ;
- if (filterMode == 1 || filterMode == 2) {//TODO: check for filterMode(2)
+ if (filterMode == 0) {
+ sprintf(buf, "%d", 0);
+ list[0].value = buf;
+
+ char cmd[128], rtn[128];
+ snprintf(cmd, sizeof(cmd), "hostapd_cli -i %s%d deny_acl CLEAR", AP_PREFIX, apIndex);
+ _syscmd(cmd, rtn, sizeof(rtn));
+ memset(cmd,0,sizeof(cmd));
+ // Delete deny_mac_file in hostapd configuration
+ snprintf(cmd, sizeof(cmd), "sed -i '/deny_mac_file=/d' %s%d.conf ", CONFIG_PREFIX, apIndex);
+ _syscmd(cmd, rtn, sizeof(rtn));
+ }
+ else if (filterMode == 1) {
+ sprintf(buf, "%d", filterMode);
+ list[0].value = buf;
sprintf(acl_file,"%s%d",ACL_PREFIX,apIndex);
list[1].name = "accept_mac_file";
list[1].value = acl_file;
items = 2;
+ } else if (filterMode == 2) {
+ //TODO: deny_mac_file
+ sprintf(buf, "%d", 0);
+ list[0].value = buf;
+ list[1].name = "deny_mac_file";
+ sprintf(deny_file,"%s%d", DENY_PREFIX,apIndex);
+ list[1].value = deny_file;
+ items = 2;
+ } else {
+ return RETURN_ERR;
}
+
sprintf(config_file,"%s%d.conf",CONFIG_PREFIX,apIndex);
wifi_hostapdWrite(config_file, list, items);
--
2.18.0