blob: 2b1474aaa65e751e583b2b280df129e1a9eebe57 [file] [log] [blame]
developer1118a232022-06-16 17:35:22 +08001From 4523c7caabe32b1d99ade410f7353371caeb471a Mon Sep 17 00:00:00 2001
2From: "Allen.Ye" <allen.ye@mediatek.com>
3Date: Thu, 16 Jun 2022 17:29:02 +0800
4Subject: [PATCH] HAL: refactor wifi_acl function
5
6---
7 source/wifi/wifi_hal.c | 31 ++++++++++++++++++++-----------
8 1 file changed, 20 insertions(+), 11 deletions(-)
9
10diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c
11index 98e5681..5cad1e7 100644
12--- a/source/wifi/wifi_hal.c
13+++ b/source/wifi/wifi_hal.c
14@@ -4181,10 +4181,20 @@ INT wifi_delApAclDevice(INT apIndex, CHAR *DeviceMacAddress)
15 // outputs the number of devices in the filter list
16 INT wifi_getApAclDeviceNum(INT apIndex, UINT *output_uint)
17 {
18- if (NULL == output_uint)
19+ char cmd[MAX_BUF_SIZE]={0};
20+ char buf[MAX_CMD_SIZE]={0};
21+
22+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
23+ if(output_uint == NULL)
24 return RETURN_ERR;
25- *output_uint = 0;
26- return RETURN_ERR;
27+
28+ snprintf(cmd, sizeof(cmd), "cat %s%d | wc -l | tr -d '\\n'", ACL_PREFIX, apIndex);
29+ _syscmd(cmd, buf, sizeof(buf));
30+
31+ *output_uint = atoi(buf);
32+
33+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
34+ return RETURN_OK;
35 }
36
37 INT apply_rules(INT apIndex, CHAR *client_mac,CHAR *action,CHAR *interface)
38@@ -7722,15 +7732,14 @@ INT wifi_delApAclDevices(INT apIndex)
39 if(_syscmd(cmd,buf,sizeof(buf)))
40 return RETURN_ERR;
41 #endif
42- char fname[100];
43- FILE *fp;
44+ char cmd[MAX_CMD_SIZE]={0};
45+ char buf[MAX_BUF_SIZE]={0};
46
47- snprintf(fname, sizeof(fname), "%s%d", ACL_PREFIX, apIndex);
48- fp = fopen(fname, "w");
49- if (!fp) {
50- return RETURN_ERR;
51- }
52- fclose(fp);
53+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
54+ sprintf(cmd, "rm %s%d 2>&1 && touch %s%d", ACL_PREFIX, apIndex, ACL_PREFIX, apIndex);
55+ if(_syscmd(cmd, buf, sizeof(buf)))
56+ return RETURN_ERR;
57+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
58
59 return RETURN_OK;
60 }
61--
622.18.0
63