• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef HOSTAPD_COMMON_CMD_H
16 #define HOSTAPD_COMMON_CMD_H
17 
18 #include "../hostapd_impl.h"
19 #include <pthread.h>
20 
21 #define BUFFSIZE_REQUEST 4096
22 #define CMD_SIZE 100
23 #define REPLY_SIZE 1024
24 #define MAX_WPA_MAIN_ARGC_NUM 20
25 #define MAX_WPA_MAIN_ARGV_LEN 128
26 #define WPA_HOSTAPD_NAME "hostapd"
27 #define WPA_SLEEP_TIME (100 * 1000) /* 100ms */
28 #ifdef OHOS_EUPDATER
29 #define CONFIG_ROOR_DIR "/tmp/service/el1/public/wifi"
30 #else
31 #define CONFIG_ROOR_DIR "/data/service/el1/public/wifi"
32 #endif // OHOS_EUPDATER
33 #define START_CMD "hostapd "CONFIG_ROOR_DIR"/wpa_supplicant/hostapd.conf"
34 
35 int32_t HostapdInterfaceStartAp(struct IHostapdInterface *self);
36 
37 int32_t HostapdInterfaceStopAp(struct IHostapdInterface *self);
38 
39 int32_t HostapdInterfaceEnableAp(struct IHostapdInterface *self,
40     const char *ifName, int32_t id);
41 
42 int32_t HostapdInterfaceDisableAp(struct IHostapdInterface *self,
43     const char *ifName, int32_t id);
44 
45 int32_t HostapdInterfaceSetApPasswd(struct IHostapdInterface *self,
46     const char *ifName, const char *pass, int32_t id);
47 
48 int32_t HostapdInterfaceSetApName(struct IHostapdInterface *self,
49     const char *ifName, const char *name, int32_t id);
50 
51 int32_t HostapdInterfaceSetApWpaValue(struct IHostapdInterface *self,
52     const char *ifName, int32_t securityType, int32_t id);
53 
54 int32_t HostapdInterfaceSetApBand(struct IHostapdInterface *self,
55     const char *ifName, int32_t band, int32_t id);
56 
57 int32_t HostapdInterfaceSetAp80211n(struct IHostapdInterface *self,
58     const char *ifName, int32_t value, int32_t id);
59 
60 int32_t HostapdInterfaceSetApWmm(struct IHostapdInterface *self,
61     const char *ifName, int32_t value, int32_t id);
62 
63 int32_t HostapdInterfaceSetApChannel(struct IHostapdInterface *self,
64     const char *ifName, int32_t channel, int32_t id);
65 
66 int32_t HostapdInterfaceSetApMaxConn(struct IHostapdInterface *self,
67     const char *ifName, int32_t maxConn, int32_t id);
68 
69 int32_t HostapdInterfaceSetMacFilter(struct IHostapdInterface *self,
70     const char *ifName, const char *mac, int32_t id);
71 
72 int32_t HostapdInterfaceDelMacFilter(struct IHostapdInterface *self,
73     const char *ifName, const char *mac, int32_t id);
74 
75 int32_t HostapdInterfaceGetStaInfos(struct IHostapdInterface *self,
76     const char *ifName, char *buf, uint32_t bufLen, int32_t size, int32_t id);
77 
78 int32_t HostapdInterfaceDisassociateSta(struct IHostapdInterface *self,
79     const char *ifName, const char *mac, int32_t id);
80 
81 int32_t HostapdInterfaceRegisterEventCallback(struct IHostapdInterface *self,
82     struct IHostapdCallback *cbFunc, const char *ifName);
83 
84 int32_t HostapdInterfaceUnregisterEventCallback(struct IHostapdInterface *self,
85     struct IHostapdCallback *cbFunc, const char *ifName);
86 
87 void HostapdEventReport(const char *ifName, uint32_t event, void *data);
88 
89 int32_t HostApdInterfaceShellCmd(struct IHostapdInterface *self, const char *ifName, const char *cmd);
90 
91 struct StApMainParam {
92     int argc;
93     char argv[MAX_WPA_MAIN_ARGC_NUM][MAX_WPA_MAIN_ARGV_LEN];
94 };
95 
96 typedef enum KeyMgmt {
97     /* WPA not used. */
98     NONE = 0,
99     /* WPA pre-share key ({@ preSharedKey} needs to be specified.) */
100     WPA_PSK = 1,
101     /**
102      * WPA2 pre-shared key, which is used for soft APs({@ preSharedKey} needs to
103      * be specified).
104      */
105     WPA2_PSK = 2
106 } KeyMgmt;
107 
108 typedef enum ApBand {
109     /* Unknown Band */
110     AP_NONE_BAND = 0,
111     /* 2.4GHz Band */
112     AP_2GHZ_BAND = 1,
113     /* 5GHz Band */
114     AP_5GHZ_BAND = 2
115 } ApBand;
116 
117 #endif
118