| From 4523c7caabe32b1d99ade410f7353371caeb471a Mon Sep 17 00:00:00 2001 |
| From: "Allen.Ye" <allen.ye@mediatek.com> |
| Date: Thu, 16 Jun 2022 17:29:02 +0800 |
| Subject: [PATCH] HAL: refactor wifi_acl function |
| |
| --- |
| source/wifi/wifi_hal.c | 31 ++++++++++++++++++++----------- |
| 1 file changed, 20 insertions(+), 11 deletions(-) |
| |
| diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
| index 98e5681..5cad1e7 100644 |
| --- a/source/wifi/wifi_hal.c |
| +++ b/source/wifi/wifi_hal.c |
| @@ -4181,10 +4181,20 @@ INT wifi_delApAclDevice(INT apIndex, CHAR *DeviceMacAddress) |
| // outputs the number of devices in the filter list |
| INT wifi_getApAclDeviceNum(INT apIndex, UINT *output_uint) |
| { |
| - if (NULL == output_uint) |
| + char cmd[MAX_BUF_SIZE]={0}; |
| + char buf[MAX_CMD_SIZE]={0}; |
| + |
| + WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__); |
| + if(output_uint == NULL) |
| return RETURN_ERR; |
| - *output_uint = 0; |
| - return RETURN_ERR; |
| + |
| + snprintf(cmd, sizeof(cmd), "cat %s%d | wc -l | tr -d '\\n'", ACL_PREFIX, apIndex); |
| + _syscmd(cmd, buf, sizeof(buf)); |
| + |
| + *output_uint = atoi(buf); |
| + |
| + WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__); |
| + return RETURN_OK; |
| } |
| |
| INT apply_rules(INT apIndex, CHAR *client_mac,CHAR *action,CHAR *interface) |
| @@ -7722,15 +7732,14 @@ INT wifi_delApAclDevices(INT apIndex) |
| if(_syscmd(cmd,buf,sizeof(buf))) |
| return RETURN_ERR; |
| #endif |
| - char fname[100]; |
| - FILE *fp; |
| + char cmd[MAX_CMD_SIZE]={0}; |
| + char buf[MAX_BUF_SIZE]={0}; |
| |
| - snprintf(fname, sizeof(fname), "%s%d", ACL_PREFIX, apIndex); |
| - fp = fopen(fname, "w"); |
| - if (!fp) { |
| - return RETURN_ERR; |
| - } |
| - fclose(fp); |
| + WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__); |
| + sprintf(cmd, "rm %s%d 2>&1 && touch %s%d", ACL_PREFIX, apIndex, ACL_PREFIX, apIndex); |
| + if(_syscmd(cmd, buf, sizeof(buf))) |
| + return RETURN_ERR; |
| + WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__); |
| |
| return RETURN_OK; |
| } |
| -- |
| 2.18.0 |
| |