2 * WPA Supplicant / UNIX domain socket -based control interface
3 * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #ifdef CONFIG_CTRL_IFACE
20 /* Shared functions from ctrl_iface.c; to be called by ctrl_iface backends */
23 * wpa_supplicant_ctrl_iface_process - Process ctrl_iface command
24 * @wpa_s: Pointer to wpa_supplicant data
25 * @buf: Received command buffer (nul terminated string)
26 * @resp_len: Variable to be set to the response length
27 * Returns: Response (*resp_len bytes) or %NULL on failure
29 * Control interface backends call this function when receiving a message that
30 * they do not process internally, i.e., anything else than ATTACH, DETACH,
31 * and LEVEL. The return response value is then sent to the external program
32 * that sent the command. Caller is responsible for freeing the buffer after
33 * this. If %NULL is returned, *resp_len can be set to two special values:
34 * 1 = send "FAIL\n" response, 2 = send "OK\n" response. If *resp_len has any
35 * other value, no response is sent.
37 char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
38 char *buf, size_t *resp_len);
41 * wpa_supplicant_ctrl_iface_process - Process global ctrl_iface command
42 * @global: Pointer to global data from wpa_supplicant_init()
43 * @buf: Received command buffer (nul terminated string)
44 * @resp_len: Variable to be set to the response length
45 * Returns: Response (*resp_len bytes) or %NULL on failure
47 * Control interface backends call this function when receiving a message from
48 * the global ctrl_iface connection. The return response value is then sent to
49 * the external program that sent the command. Caller is responsible for
50 * freeing the buffer after this. If %NULL is returned, *resp_len can be set to
51 * two special values: 1 = send "FAIL\n" response, 2 = send "OK\n" response. If
52 * *resp_len has any other value, no response is sent.
54 char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
55 char *buf, size_t *resp_len);
58 /* Functions that each ctrl_iface backend must implement */
61 * wpa_supplicant_ctrl_iface_init - Initialize control interface
62 * @wpa_s: Pointer to wpa_supplicant data
63 * Returns: Pointer to private data on success, %NULL on failure
65 * Initialize the control interface and start receiving commands from external
68 * Required to be implemented in each control interface backend.
70 struct ctrl_iface_priv *
71 wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s);
74 * wpa_supplicant_ctrl_iface_deinit - Deinitialize control interface
75 * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
77 * Deinitialize the control interface that was initialized with
78 * wpa_supplicant_ctrl_iface_init().
80 * Required to be implemented in each control interface backend.
82 void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv);
85 * wpa_supplicant_ctrl_iface_wait - Wait for ctrl_iface monitor
86 * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
88 * Wait until the first message from an external program using the control
89 * interface is received. This function can be used to delay normal startup
90 * processing to allow control interface programs to attach with
91 * %wpa_supplicant before normal operations are started.
93 * Required to be implemented in each control interface backend.
95 void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv);
98 * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response
99 * @wpa_s: Pointer to wpa_supplicant data
100 * @ssid: Pointer to the network block the reply is for
101 * @field: field the response is a reply for
102 * @value: value (ie, password, etc) for @field
103 * Returns: 0 on success, non-zero on error
105 * Helper function to handle replies to control interface requests.
107 int wpa_supplicant_ctrl_iface_ctrl_rsp_handle(struct wpa_supplicant *wpa_s,
108 struct wpa_ssid *ssid,
113 * wpa_supplicant_global_ctrl_iface_init - Initialize global control interface
114 * @global: Pointer to global data from wpa_supplicant_init()
115 * Returns: Pointer to private data on success, %NULL on failure
117 * Initialize the global control interface and start receiving commands from
120 * Required to be implemented in each control interface backend.
122 struct ctrl_iface_global_priv *
123 wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global);
126 * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface
127 * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init()
129 * Deinitialize the global control interface that was initialized with
130 * wpa_supplicant_global_ctrl_iface_init().
132 * Required to be implemented in each control interface backend.
134 void wpa_supplicant_global_ctrl_iface_deinit(
135 struct ctrl_iface_global_priv *priv);
137 #else /* CONFIG_CTRL_IFACE */
139 static inline struct ctrl_iface_priv *
140 wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
146 wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
151 wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level,
152 char *buf, size_t len)
157 wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv)
161 static inline struct ctrl_iface_global_priv *
162 wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
168 wpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv)
172 #endif /* CONFIG_CTRL_IFACE */
174 #endif /* CTRL_IFACE_H */