• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hdf_mac80211_sta_event.c
3  *
4  * hdf driver
5  *
6  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  */
22 
23 #include <net/netlink.h>
24 #include <net/cfg80211.h>
25 #include <securec.h>
26 #include <linux/kernel.h>
27 #include <linux/skbuff.h>
28 #include <linux/slab.h>
29 #include <linux/printk.h>
30 #include <linux/in6.h>
31 #include <linux/wireless.h>
32 
33 #include "osal_mem.h"
34 #include "net_device.h"
35 #include "net_device_impl.h"
36 #include "net_device_adapter.h"
37 #include "wifi_mac80211_ops.h"
38 #include "hdf_wifi_cmd.h"
39 #include "hdf_wifi_event.h"
40 #include "hdf_wl_interface.h"
41 #include "hdf_public_ap6275s.h"
42 #include "hdf_bdh_event.h"
43 
44 #define HDF_LOG_TAG BDH6Driver
45 
HdfInformBssFrameEventCallback(struct net_device * ndev,const struct InnerBssInfo * innerBssInfo)46 void HdfInformBssFrameEventCallback(struct net_device *ndev, const struct InnerBssInfo *innerBssInfo)
47 {
48     int32_t retVal = 0;
49     NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev);
50     struct ScannedBssInfo bssInfo;
51     struct WlanChannel hdfchannel;
52 
53     if (innerBssInfo->channel == NULL || netDev == NULL || innerBssInfo->mgmt == NULL) {
54         HDF_LOGE("%s: inform_bss_frame channel = null or netDev = null!", __func__);
55         return;
56     }
57     netDev = get_hdf_netdev(g_scan_event_ifidx);
58     bssInfo.signal = innerBssInfo->signal;
59     bssInfo.freq = innerBssInfo->freq;
60     bssInfo.mgmtLen = innerBssInfo->mgmtLen;
61     bssInfo.mgmt = (struct Ieee80211Mgmt *)innerBssInfo->mgmt;
62 
63     hdfchannel.flags = innerBssInfo->channel->flags;
64     hdfchannel.channelId = innerBssInfo->channel->hw_value;
65     hdfchannel.centerFreq = innerBssInfo->channel->center_freq;
66     retVal = HdfWifiEventInformBssFrame(netDev, &hdfchannel, &bssInfo);
67     if (retVal < 0) {
68         HDF_LOGE("%s: hdf wifi event inform bss frame failed!", __func__);
69     }
70 }
71 
HdfScanEventCallback(struct net_device * ndev,HdfWifiScanStatus _status)72 int32_t HdfScanEventCallback(struct net_device *ndev, HdfWifiScanStatus _status)
73 {
74     int32_t ret = 0;
75 
76     NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev);
77     WifiScanStatus status = _status;
78     netDev = get_hdf_netdev(g_scan_event_ifidx);
79     HDF_LOGI("%s: %d, scandone!", __func__, _status);
80     ret = HdfWifiEventScanDone(netDev, status);
81 
82     return ret;
83 }
84 
HdfConnectResultEventCallback(struct net_device * ndev,const struct InnerConnetResult * innerConnResult)85 int32_t HdfConnectResultEventCallback(struct net_device *ndev, const struct InnerConnetResult *innerConnResult)
86 {
87     int32_t retVal = 0;
88     NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev);
89     struct ConnetResult connResult;
90     // for check p2p0 report
91     netDev = get_hdf_netdev(g_conn_event_ifidx);
92 
93     HDF_LOGI("%s: enter", __func__);
94 
95     if (netDev == NULL || innerConnResult->bssid == NULL || innerConnResult->rspIe == NULL
96         || innerConnResult->reqIe == NULL) {
97         HDF_LOGE("%s: netDev / bssid / rspIe / reqIe  null!", __func__);
98         return -1;
99     }
100 
101     memcpy_s(&connResult.bssid[0], ETH_ADDR_LEN, innerConnResult->bssid, ETH_ADDR_LEN);
102 
103     connResult.rspIe = innerConnResult->rspIe;
104     connResult.rspIeLen = innerConnResult->rspIeLen;
105     connResult.reqIe = innerConnResult->reqIe;
106     connResult.reqIeLen = innerConnResult->reqIeLen;
107     connResult.connectStatus = innerConnResult->connectStatus;
108     connResult.freq = innerConnResult->freq;
109     connResult.statusCode = innerConnResult->statusCode;
110 
111     retVal = HdfWifiEventConnectResult(netDev, &connResult);
112     if (retVal < 0) {
113         HDF_LOGE("%s: hdf wifi event inform connect result failed!", __func__);
114     }
115     return retVal;
116 }
117 
HdfDisconnectedEventCallback(struct net_device * ndev,uint16_t reason,uint8_t * ie,uint32_t len)118 int32_t HdfDisconnectedEventCallback(struct net_device *ndev, uint16_t reason, uint8_t *ie, uint32_t len)
119 {
120     int32_t ret = 0;
121 
122     NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev);
123     netDev = get_hdf_netdev(g_conn_event_ifidx);
124     HDF_LOGI("%s: leave", __func__);
125 
126     ret = HdfWifiEventDisconnected(netDev, reason, ie, len);
127     return ret;
128 }
129