• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef WIFI_COMMON_CMD_H
17 #define WIFI_COMMON_CMD_H
18 
19 #include "wifi_driver_client.h"
20 
21 enum PlatformServiceID {
22     INTERFACE_SERVICE_ID = 0,
23     BASE_SERVICE_ID,
24     AP_SERVICE_ID,
25     STA_SERVICE_ID,
26     P2P_SERVICE_ID,
27     AUTO_ALLOC_SERVICE_ID_START = 300
28 };
29 
30 enum BaseCommands {
31     CMD_BASE_NEW_KEY,
32     CMD_BASE_DEL_KEY,
33     CMD_BASE_SET_DEFAULT_KEY,
34     CMD_BASE_SEND_MLME,
35     CMD_BASE_SEND_EAPOL,
36     CMD_BASE_RECEIVE_EAPOL = 5,
37     CMD_BASE_ENALBE_EAPOL,
38     CMD_BASE_DISABLE_EAPOL,
39     CMD_BASE_GET_ADDR,
40     CMD_BASE_SET_MODE,
41     CMD_BASE_GET_HW_FEATURE = 10,
42     CMD_BASE_SET_NETDEV,
43     CMD_BASE_SEND_ACTION,
44     CMD_BASE_SET_CLIENT,
45     CMD_BASE_GET_NETWORK_INFO = 15,
46     CMD_BASE_IS_SUPPORT_COMBO,
47     CMD_BASE_GET_SUPPORT_COMBO,
48     CMD_BASE_GET_DEV_MAC_ADDR,
49     CMD_BASE_SET_MAC_ADDR,
50     CMD_BASE_GET_VALID_FREQ = 20,
51     CMD_BASE_SET_TX_POWER,
52     CMD_BASE_GET_CHIPID,
53     CMD_BASE_GET_IFNAMES,
54     CMD_BASE_RESET_DRIVER,
55     CMD_BASE_GET_NETDEV_INFO,
56     CMD_BASE_DO_RESET_PRIVATE,
57     CMD_BASE_GET_POWER_MODE,
58     CMD_BASE_SET_POWER_MODE,
59     CMD_BASE_START_CHANNEL_MEAS,
60     CMD_BASE_SET_PROJECTION_SCREEN_PARAM,
61     CMD_BASE_SEND_CMD_IOCTL,
62     CMD_BASE_GET_STATION_INFO
63 };
64 
65 enum APCommands {
66     CMD_AP_START = 0,
67     CMD_AP_STOP,
68     CMD_AP_CHANGE_BEACON,
69     CMD_AP_DEL_STATION,
70     CMD_AP_GET_ASSOC_STA,
71     CMD_AP_SET_COUNTRY_CODE,
72 };
73 
74 enum STACommands {
75     CMD_STA_CONNECT = 0,
76     CMD_STA_DISCONNECT,
77     CMD_STA_SCAN,
78     CMD_STA_ABORT_SCAN,
79     CMD_STA_SET_SCAN_MAC_ADDR,
80     CMD_STA_START_PNO_SCAN,
81     CMD_STA_STOP_PNO_SCAN,
82     CMD_STA_GET_SIGNAL_INFO
83 };
84 
85 enum P2PCommands {
86     CMD_P2P_PROBE_REQ_REPORT = 0,
87     CMD_P2P_REMAIN_ON_CHANNEL,
88     CMD_P2P_CANCEL_REMAIN_ON_CHANNEL,
89     CMD_P2P_ADD_IF,
90     CMD_P2P_REMOVE_IF,
91     CMD_P2P_SET_AP_WPS_P2P_IE,
92     CMD_P2P_GET_DRIVER_FLAGS
93 };
94 
95 #define MESSAGE_CMD_BITS 16
96 #define HDF_WIFI_CMD(SERVICEID, CMDID) ((((uint32_t)SERVICEID) << MESSAGE_CMD_BITS) | (CMDID))
97 
98 typedef enum {
99     WIFI_HAL_CMD_GET_NETWORK_INFO = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_NETWORK_INFO),
100     WIFI_HAL_CMD_IS_SUPPORT_COMBO = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_IS_SUPPORT_COMBO),
101     WIFI_HAL_CMD_GET_SUPPORT_COMBO  = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_SUPPORT_COMBO),
102     WIFI_HAL_CMD_GET_DEV_MAC_ADDR   = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_DEV_MAC_ADDR),
103     WIFI_HAL_CMD_SET_MAC_ADDR = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_MAC_ADDR),
104     WIFI_HAL_CMD_GET_VALID_FREQ = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_VALID_FREQ),
105     WIFI_HAL_CMD_SET_TX_POWER = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_TX_POWER),
106     WIFI_HAL_CMD_GET_ASSOC_STA = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_GET_ASSOC_STA),
107     WIFI_HAL_CMD_SET_COUNTRY_CODE = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_SET_COUNTRY_CODE),
108     WIFI_HAL_CMD_SET_SCAN_MAC_ADDR = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_SET_SCAN_MAC_ADDR),
109     WIFI_HAL_CMD_GET_CHIPID = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_CHIPID),
110     WIFI_HAL_CMD_GET_IFNAMES = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_IFNAMES),
111     WIFI_HAL_CMD_RESET_DRIVER = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_RESET_DRIVER),
112     WIFI_HAL_CMD_GET_NETDEV_INFO = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_NETDEV_INFO),
113     WIFI_HAL_CMD_GET_POWER_MODE = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_POWER_MODE),
114     WIFI_HAL_CMD_SET_POWER_MODE = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_POWER_MODE),
115     WIFI_HAL_CMD_START_CHANNEL_MEAS = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_START_CHANNEL_MEAS),
116     WIFI_HAL_CMD_CONFIG_PROJECTION_SCREEN = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_PROJECTION_SCREEN_PARAM),
117     WIFI_HAL_CMD_SET_CMD_IOCTL = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SEND_CMD_IOCTL),
118     WIFI_HAL_CMD_GET_STATION_INFO = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_STATION_INFO),
119     WIFI_HAL_CMD_START_PNO_SCAN = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_START_PNO_SCAN),
120     WIFI_HAL_CMD_STOP_PNO_SCAN = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_STOP_PNO_SCAN),
121     WIFI_HAL_CMD_GET_SIGNAL_INFO = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_GET_SIGNAL_INFO),
122 } WifiHalCmd;
123 
124 typedef enum {
125     WIFI_WPA_CMD_SET_AP = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_START),
126     WIFI_WPA_CMD_NEW_KEY = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_NEW_KEY),
127     WIFI_WPA_CMD_DEL_KEY = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_DEL_KEY),
128     WIFI_WPA_CMD_SET_KEY = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_DEFAULT_KEY),
129     WIFI_WPA_CMD_SEND_MLME = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SEND_MLME),
130     WIFI_WPA_CMD_SEND_EAPOL = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SEND_EAPOL),
131     WIFI_WPA_CMD_RECEIVE_EAPOL = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_RECEIVE_EAPOL),
132     WIFI_WPA_CMD_ENALBE_EAPOL = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_ENALBE_EAPOL),
133     WIFI_WPA_CMD_DISABLE_EAPOL = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_DISABLE_EAPOL),
134     WIFI_WPA_CMD_GET_ADDR = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_ADDR),
135     WIFI_WPA_CMD_SET_MODE = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_MODE),
136     WIFI_WPA_CMD_GET_HW_FEATURE = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_GET_HW_FEATURE),
137     WIFI_WPA_CMD_STOP_AP = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_STOP),
138     WIFI_WPA_CMD_SCAN = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_SCAN),
139     WIFI_WPA_CMD_DISCONNECT = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_DISCONNECT),
140     WIFI_WPA_CMD_ASSOC = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_CONNECT),
141     WIFI_WPA_CMD_SET_NETDEV = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_NETDEV),
142     WIFI_WPA_CMD_CHANGE_BEACON = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_CHANGE_BEACON),
143     WIFI_WPA_CMD_STA_REMOVE = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_DEL_STATION),
144     WIFI_WPA_CMD_SEND_ACTION = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SEND_ACTION),
145     WIFI_CLIENT_CMD_SET_CLIENT = HDF_WIFI_CMD(BASE_SERVICE_ID, CMD_BASE_SET_CLIENT),
146     WIFI_WPA_CMD_PROBE_REQ_REPORT = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_PROBE_REQ_REPORT),
147     WIFI_WPA_CMD_REMAIN_ON_CHANNEL = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_REMAIN_ON_CHANNEL),
148     WIFI_WPA_CMD_CANCEL_REMAIN_ON_CHANNEL = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_CANCEL_REMAIN_ON_CHANNEL),
149     WIFI_WPA_CMD_ADD_IF = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_ADD_IF),
150     WIFI_WPA_CMD_REMOVE_IF = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_REMOVE_IF),
151     WIFI_WPA_CMD_SET_AP_WPS_P2P_IE = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_SET_AP_WPS_P2P_IE),
152     WIFI_WPA_CMD_GET_DRIVER_FLAGS = HDF_WIFI_CMD(P2P_SERVICE_ID, CMD_P2P_GET_DRIVER_FLAGS),
153     WIFI_WPA_CMD_BUTT
154 } WifiWPACmdType;
155 
156 struct CallbackEvent {
157     uint32_t eventType; /* eventmap */
158     char ifName[IFNAMSIZ + 1];
159     OnReceiveFunc onRecFunc;
160 };
161 
162 struct Hid2dEvent {
163     char ifName[IFNAMSIZ + 1];
164     Hid2dCallback func;
165 };
166 
167 void WifiEventReport(const char *ifName, uint32_t event, void *data);
168 void Hid2dEventReport(const char *ifName, const uint8_t *msg, uint32_t msgLen);
169 void FreeScanResult(WifiScanResult *res);
170 void FreeScanResults(WifiScanResults *res);
171 
172 #endif /* end of wifi_common_cmd.h */
173