| From 31bc9c1435e62e442d0dbd68a4445d3b4d8f862f Mon Sep 17 00:00:00 2001 |
| From: "Allen.Ye" <allen.ye@mediatek.com> |
| Date: Wed, 7 Sep 2022 14:17:50 +0800 |
| Subject: [PATCH] HAL: refactor SSIDTrafficStats2 function |
| |
| --- |
| source/wifi/wifi_hal.c | 77 +++++++++++++++++++++++++++++++++++------- |
| 1 file changed, 64 insertions(+), 13 deletions(-) |
| |
| diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
| index e8c9acf..33259dd 100644 |
| --- a/source/wifi/wifi_hal.c |
| +++ b/source/wifi/wifi_hal.c |
| @@ -8288,38 +8288,89 @@ INT wifi_getSSIDTrafficStats2(INT ssidIndex,wifi_ssidTrafficStats2_t *output_str |
| |
| sprintf(HConf_file,"%s%d%s","/nvram/hostapd",ssidIndex,".conf"); |
| GetInterfaceName(interface_name,HConf_file); |
| - sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f11 | tr -d '\n'"); |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f11 | tr -d '\\n'"); |
| fp = popen(pipeCmd, "r"); |
| fgets(str, MAX_BUF_SIZE,fp); |
| out->ssid_BytesSent = atol(str); |
| pclose(fp); |
| |
| - sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f3 | tr -d '\n'"); |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f3 | tr -d '\\n'"); |
| fp = popen(pipeCmd, "r"); |
| fgets(str, MAX_BUF_SIZE,fp); |
| out->ssid_BytesReceived = atol(str); |
| pclose(fp); |
| |
| - sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f12 | tr -d '\n'"); |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f12 | tr -d '\\n'"); |
| fp = popen(pipeCmd, "r"); |
| fgets(str, MAX_BUF_SIZE,fp); |
| out->ssid_PacketsSent = atol(str); |
| pclose(fp); |
| |
| - sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f4 | tr -d '\n'"); |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f4 | tr -d '\\n'"); |
| fp = popen(pipeCmd, "r"); |
| fgets(str, MAX_BUF_SIZE,fp); |
| out->ssid_PacketsReceived = atol(str); |
| pclose(fp); |
| - /* |
| - //TODO: |
| - out->ssid_UnicastPacketsSent = uni->ims_tx_data_packets; |
| - out->ssid_UnicastPacketsReceived = uni->ims_rx_data_packets; |
| - out->ssid_MulticastPacketsSent = multi->ims_tx_data_packets - multi->ims_tx_bcast_data_packets; |
| - out->ssid_MulticastPacketsReceived = multi->ims_rx_data_packets - multi->ims_rx_bcast_data_packets; |
| - out->ssid_BroadcastPacketsSent = multi->ims_tx_bcast_data_packets; |
| - out->ssid_BroadcastPacketsRecevied = multi->ims_rx_bcast_data_packets; |
| - */ |
| + |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f13 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_ErrorsSent = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f5 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_ErrorsReceived = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f14 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_DiscardedPacketsSent = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s%s%s","cat /proc/net/dev | grep ",interface_name," | tr -s ' ' | cut -d ' ' -f6 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_DiscardedPacketsReceived = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s","tail -n1 /proc/net/netstat | cut -d ' ' -f5 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_MulticastPacketsSent = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s","tail -n1 /proc/net/netstat | cut -d ' ' -f4 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_MulticastPacketsReceived = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s","tail -n1 /proc/net/netstat | cut -d ' ' -f7 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_BroadcastPacketsSent = atol(str); |
| + pclose(fp); |
| + |
| + sprintf(pipeCmd,"%s","tail -n1 /proc/net/netstat | cut -d ' ' -f6 | tr -d '\\n'"); |
| + fp = popen(pipeCmd, "r"); |
| + fgets(str, MAX_BUF_SIZE,fp); |
| + out->ssid_BroadcastPacketsRecevied = atol(str); |
| + pclose(fp); |
| + |
| + out->ssid_UnicastPacketsSent = out->ssid_PacketsSent - out->ssid_MulticastPacketsSent - out->ssid_BroadcastPacketsSent - out->ssid_DiscardedPacketsSent; |
| + out->ssid_UnicastPacketsReceived = out->ssid_PacketsReceived - out->ssid_MulticastPacketsReceived - out->ssid_BroadcastPacketsRecevied - out->ssid_DiscardedPacketsReceived; |
| + |
| + // Not supported |
| + output_struct->ssid_RetransCount = 0; |
| + output_struct->ssid_FailedRetransCount = 0; |
| + output_struct->ssid_RetryCount = 0; |
| + output_struct->ssid_MultipleRetryCount = 0; |
| + output_struct->ssid_ACKFailureCount = 0; |
| + output_struct->ssid_AggregatedPacketCount = 0; |
| + |
| return RETURN_OK; |
| } |
| |
| -- |
| 2.18.0 |
| |