xref: /freebsd/contrib/wpa/wpa_supplicant/binder/binder_manager.h (revision 18054d0220cfc8df9c9568c437bd6fbb59d53c3c)
1 /*
2  * binder interface for wpa_supplicant daemon
3  * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
5  *
6  * This software may be distributed under the terms of the BSD license.
7  * See README for more details.
8  */
9 
10 #ifndef WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H
11 #define WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H
12 
13 #include <map>
14 #include <string>
15 
16 #include "iface.h"
17 #include "supplicant.h"
18 
19 struct wpa_global;
20 struct wpa_supplicant;
21 
22 namespace wpa_supplicant_binder {
23 
24 /**
25  * BinderManager is responsible for managing the lifetime of all
26  * binder objects created by wpa_supplicant. This is a singleton
27  * class which is created by the supplicant core and can be used
28  * to get references to the binder objects.
29  */
30 class BinderManager
31 {
32 public:
33 	static BinderManager *getInstance();
34 	static void destroyInstance();
35 	int registerBinderService(struct wpa_global *global);
36 	int registerInterface(struct wpa_supplicant *wpa_s);
37 	int unregisterInterface(struct wpa_supplicant *wpa_s);
38 	int getIfaceBinderObjectByKey(
39 	    const void *iface_object_key,
40 	    android::sp<fi::w1::wpa_supplicant::IIface> *iface_object);
41 
42 private:
43 	BinderManager() = default;
44 	~BinderManager() = default;
45 
46 	/* Singleton instance of this class. */
47 	static BinderManager *instance_;
48 	/* The main binder service object. */
49 	android::sp<Supplicant> supplicant_object_;
50 	/* Map of all the interface specific binder objects controlled by
51 	 * wpa_supplicant. This map is keyed in by the corresponding
52 	 * wpa_supplicant structure pointer. */
53 	std::map<const void *, android::sp<Iface>> iface_object_map_;
54 };
55 
56 } /* namespace wpa_supplicant_binder */
57 
58 #endif /* WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H */
59