]> git.ipfire.org Git - thirdparty/hostap.git/blob - wpa_supplicant/ctrl_iface.h
Fix D-Bus build without ctrl_iface
[thirdparty/hostap.git] / wpa_supplicant / ctrl_iface.h
1 /*
2 * WPA Supplicant / UNIX domain socket -based control interface
3 * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #ifndef CTRL_IFACE_H
10 #define CTRL_IFACE_H
11
12 #ifdef CONFIG_CTRL_IFACE
13
14 /* Shared functions from ctrl_iface.c; to be called by ctrl_iface backends */
15
16 /**
17 * wpa_supplicant_ctrl_iface_process - Process ctrl_iface command
18 * @wpa_s: Pointer to wpa_supplicant data
19 * @buf: Received command buffer (nul terminated string)
20 * @resp_len: Variable to be set to the response length
21 * Returns: Response (*resp_len bytes) or %NULL on failure
22 *
23 * Control interface backends call this function when receiving a message that
24 * they do not process internally, i.e., anything else than ATTACH, DETACH,
25 * and LEVEL. The return response value is then sent to the external program
26 * that sent the command. Caller is responsible for freeing the buffer after
27 * this. If %NULL is returned, *resp_len can be set to two special values:
28 * 1 = send "FAIL\n" response, 2 = send "OK\n" response. If *resp_len has any
29 * other value, no response is sent.
30 */
31 char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
32 char *buf, size_t *resp_len);
33
34 /**
35 * wpa_supplicant_ctrl_iface_process - Process global ctrl_iface command
36 * @global: Pointer to global data from wpa_supplicant_init()
37 * @buf: Received command buffer (nul terminated string)
38 * @resp_len: Variable to be set to the response length
39 * Returns: Response (*resp_len bytes) or %NULL on failure
40 *
41 * Control interface backends call this function when receiving a message from
42 * the global ctrl_iface connection. The return response value is then sent to
43 * the external program that sent the command. Caller is responsible for
44 * freeing the buffer after this. If %NULL is returned, *resp_len can be set to
45 * two special values: 1 = send "FAIL\n" response, 2 = send "OK\n" response. If
46 * *resp_len has any other value, no response is sent.
47 */
48 char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
49 char *buf, size_t *resp_len);
50
51
52 /* Functions that each ctrl_iface backend must implement */
53
54 /**
55 * wpa_supplicant_ctrl_iface_init - Initialize control interface
56 * @wpa_s: Pointer to wpa_supplicant data
57 * Returns: Pointer to private data on success, %NULL on failure
58 *
59 * Initialize the control interface and start receiving commands from external
60 * programs.
61 *
62 * Required to be implemented in each control interface backend.
63 */
64 struct ctrl_iface_priv *
65 wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s);
66
67 /**
68 * wpa_supplicant_ctrl_iface_deinit - Deinitialize control interface
69 * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
70 *
71 * Deinitialize the control interface that was initialized with
72 * wpa_supplicant_ctrl_iface_init().
73 *
74 * Required to be implemented in each control interface backend.
75 */
76 void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv);
77
78 /**
79 * wpa_supplicant_ctrl_iface_wait - Wait for ctrl_iface monitor
80 * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
81 *
82 * Wait until the first message from an external program using the control
83 * interface is received. This function can be used to delay normal startup
84 * processing to allow control interface programs to attach with
85 * %wpa_supplicant before normal operations are started.
86 *
87 * Required to be implemented in each control interface backend.
88 */
89 void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv);
90
91 /**
92 * wpa_supplicant_global_ctrl_iface_init - Initialize global control interface
93 * @global: Pointer to global data from wpa_supplicant_init()
94 * Returns: Pointer to private data on success, %NULL on failure
95 *
96 * Initialize the global control interface and start receiving commands from
97 * external programs.
98 *
99 * Required to be implemented in each control interface backend.
100 */
101 struct ctrl_iface_global_priv *
102 wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global);
103
104 /**
105 * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface
106 * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init()
107 *
108 * Deinitialize the global control interface that was initialized with
109 * wpa_supplicant_global_ctrl_iface_init().
110 *
111 * Required to be implemented in each control interface backend.
112 */
113 void wpa_supplicant_global_ctrl_iface_deinit(
114 struct ctrl_iface_global_priv *priv);
115
116 #else /* CONFIG_CTRL_IFACE */
117
118 static inline struct ctrl_iface_priv *
119 wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
120 {
121 return (void *) -1;
122 }
123
124 static inline void
125 wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
126 {
127 }
128
129 static inline void
130 wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level,
131 char *buf, size_t len)
132 {
133 }
134
135 static inline void
136 wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv)
137 {
138 }
139
140 static inline struct ctrl_iface_global_priv *
141 wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
142 {
143 return (void *) 1;
144 }
145
146 static inline void
147 wpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv)
148 {
149 }
150
151 #endif /* CONFIG_CTRL_IFACE */
152
153 #endif /* CTRL_IFACE_H */