• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hostapd / UNIX domain socket -based control interface
3  * Copyright (c) 2004-2014, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * This software may be distributed under the terms of the BSD license.
18  * See README for more details.
19  */
20 
21 #include "utils/common.h"
22 #include "ap/hostapd.h"
23 #include "utils/eloop.h"
24 #include "wifi_api.h"
25 #include "wpa_supplicant/ctrl_iface.h"
26 #include "wpa_supplicant/wpa_supplicant_i.h"
27 
hostapd_ctrl_iface_init(struct hostapd_data * hapd)28 int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
29 {
30 	if (hapd == NULL)
31 		return -1;
32 	struct ctrl_iface_priv *priv = los_ctrl_iface_init(hapd);
33 	if (priv == NULL) {
34 		return -1;
35 	}
36 	hapd->ctrl_iface = priv;
37 	return 0;
38 }
39 
hostapd_ctrl_iface_deinit(struct hostapd_data * hapd)40 void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
41 {
42 	unsigned int int_save;
43 
44 	if (hapd == NULL) {
45 		wpa_error_log0(MSG_ERROR, "hostapd_ctrl_iface_deinit hapd is NULL");
46 		return;
47 	}
48 
49 	struct ctrl_iface_priv *priv = NULL;
50 	struct ext_wifi_dev *wifi_dev = wpa_get_other_existed_wpa_wifi_dev(NULL);
51 	priv = hapd->ctrl_iface;
52 	if (priv != NULL) {
53 		eloop_unregister_cli_event(priv->event_queue, 0); // 0:useless
54 		os_free(priv);
55 		hapd->ctrl_iface = NULL;
56 	}
57 	if ((wifi_dev != NULL) && (wifi_dev->priv != NULL)) {
58 		os_intlock(&int_save);
59 		g_ctrl_iface_data = ((struct wpa_supplicant *)(wifi_dev->priv))->ctrl_iface;
60 		os_intrestore(int_save);
61 	} else {
62 		os_intlock(&int_save);
63 		g_ctrl_iface_data = NULL;
64 		os_intrestore(int_save);
65 	}
66 }
67 
hostapd_global_ctrl_iface_init(struct hapd_interfaces * interface)68 int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
69 {
70 	(void)interface;
71 	return 0;
72 }
73 
hostapd_global_ctrl_iface_deinit(struct hapd_interfaces * interfaces)74 void hostapd_global_ctrl_iface_deinit(struct hapd_interfaces *interfaces)
75 {
76 	(void)interfaces;
77 }
78