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