developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 1 | From 5175e19e0a628baff0aad73d2397e9a23bc3dc7d Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Mon, 14 Mar 2022 19:40:08 +0800 |
| 4 | Subject: [PATCH] HAL: refactor wifi_setApMacAddressControlMode() |
| 5 | |
| 6 | Change-Id: Ia9bdb3b6ac683a8634bd726b6d472eb133d258d0 |
| 7 | --- |
| 8 | source/wifi/wifi_hal.c | 31 ++++++++++++++++++++++++++++--- |
| 9 | 1 file changed, 28 insertions(+), 3 deletions(-) |
| 10 | |
| 11 | diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
| 12 | index 5f5ac68..0ed1e85 100644 |
| 13 | --- a/source/wifi/wifi_hal.c |
| 14 | +++ b/source/wifi/wifi_hal.c |
| 15 | @@ -68,6 +68,7 @@ Licensed under the ISC license |
| 16 | #define IF_NAME_SIZE 50 |
| 17 | #define CONFIG_PREFIX "/nvram/hostapd" |
| 18 | #define ACL_PREFIX "/tmp/hostapd-acl" |
| 19 | +#define DENY_PREFIX "/tmp/hostapd-deny" |
| 20 | //#define ACL_PREFIX "/tmp/wifi_acl_list" //RDKB convention |
| 21 | #define SOCK_PREFIX "/var/run/hostapd/wifi" |
| 22 | #define VAP_STATUS_FILE "/tmp/vap-status" |
| 23 | @@ -4308,17 +4309,41 @@ INT wifi_setApMacAddressControlMode(INT apIndex, INT filterMode) |
| 24 | struct params list[2]; |
| 25 | char buf[MAX_BUF_SIZE] = {0}; |
| 26 | char config_file[MAX_BUF_SIZE] = {0}, acl_file[MAX_BUF_SIZE] = {0}; |
| 27 | + char deny_file[MAX_BUF_SIZE] = {0}; |
| 28 | |
| 29 | list[0].name = "macaddr_acl"; |
| 30 | - sprintf(buf, "%d", filterMode); |
| 31 | - list[0].value = buf ; |
| 32 | |
| 33 | - if (filterMode == 1 || filterMode == 2) {//TODO: check for filterMode(2) |
| 34 | + if (filterMode == 0) { |
| 35 | + sprintf(buf, "%d", 0); |
| 36 | + list[0].value = buf; |
| 37 | + |
| 38 | + char cmd[128], rtn[128]; |
| 39 | + snprintf(cmd, sizeof(cmd), "hostapd_cli -i %s%d deny_acl CLEAR", AP_PREFIX, apIndex); |
| 40 | + _syscmd(cmd, rtn, sizeof(rtn)); |
| 41 | + memset(cmd,0,sizeof(cmd)); |
| 42 | + // Delete deny_mac_file in hostapd configuration |
| 43 | + snprintf(cmd, sizeof(cmd), "sed -i '/deny_mac_file=/d' %s%d.conf ", CONFIG_PREFIX, apIndex); |
| 44 | + _syscmd(cmd, rtn, sizeof(rtn)); |
| 45 | + } |
| 46 | + else if (filterMode == 1) { |
| 47 | + sprintf(buf, "%d", filterMode); |
| 48 | + list[0].value = buf; |
| 49 | sprintf(acl_file,"%s%d",ACL_PREFIX,apIndex); |
| 50 | list[1].name = "accept_mac_file"; |
| 51 | list[1].value = acl_file; |
| 52 | items = 2; |
| 53 | + } else if (filterMode == 2) { |
| 54 | + //TODO: deny_mac_file |
| 55 | + sprintf(buf, "%d", 0); |
| 56 | + list[0].value = buf; |
| 57 | + list[1].name = "deny_mac_file"; |
| 58 | + sprintf(deny_file,"%s%d", DENY_PREFIX,apIndex); |
| 59 | + list[1].value = deny_file; |
| 60 | + items = 2; |
| 61 | + } else { |
| 62 | + return RETURN_ERR; |
| 63 | } |
| 64 | + |
| 65 | sprintf(config_file,"%s%d.conf",CONFIG_PREFIX,apIndex); |
| 66 | wifi_hostapdWrite(config_file, list, items); |
| 67 | |
| 68 | -- |
| 69 | 2.18.0 |
| 70 | |