]> git.ipfire.org Git - thirdparty/hostap.git/blame - wpa_supplicant/ctrl_iface.h
AOSP: These files have been removed from AOSP
[thirdparty/hostap.git] / wpa_supplicant / ctrl_iface.h
CommitLineData
6fc6879b
JM
1/*
2 * WPA Supplicant / UNIX domain socket -based control interface
3 * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
4 *
0f3d578e
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
6fc6879b
JM
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 */
31char * 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 */
48char * 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 */
64struct ctrl_iface_priv *
65wpa_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 */
76void 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 */
89void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv);
90
7de5688d
DW
91/**
92 * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response
93 * @wpa_s: Pointer to wpa_supplicant data
94 * @ssid: Pointer to the network block the reply is for
95 * @field: field the response is a reply for
96 * @value: value (ie, password, etc) for @field
97 * Returns: 0 on success, non-zero on error
98 *
99 * Helper function to handle replies to control interface requests.
100 */
101int wpa_supplicant_ctrl_iface_ctrl_rsp_handle(struct wpa_supplicant *wpa_s,
102 struct wpa_ssid *ssid,
103 const char *field,
104 const char *value);
105
6fc6879b
JM
106/**
107 * wpa_supplicant_global_ctrl_iface_init - Initialize global control interface
108 * @global: Pointer to global data from wpa_supplicant_init()
109 * Returns: Pointer to private data on success, %NULL on failure
110 *
111 * Initialize the global control interface and start receiving commands from
112 * external programs.
113 *
114 * Required to be implemented in each control interface backend.
115 */
116struct ctrl_iface_global_priv *
117wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global);
118
119/**
120 * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface
121 * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init()
122 *
123 * Deinitialize the global control interface that was initialized with
124 * wpa_supplicant_global_ctrl_iface_init().
125 *
126 * Required to be implemented in each control interface backend.
127 */
128void wpa_supplicant_global_ctrl_iface_deinit(
129 struct ctrl_iface_global_priv *priv);
130
131#else /* CONFIG_CTRL_IFACE */
132
133static inline struct ctrl_iface_priv *
134wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
135{
136 return (void *) -1;
137}
138
139static inline void
140wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
141{
142}
143
144static inline void
145wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level,
146 char *buf, size_t len)
147{
148}
149
150static inline void
151wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv)
152{
153}
154
155static inline struct ctrl_iface_global_priv *
156wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
157{
158 return (void *) 1;
159}
160
161static inline void
162wpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv)
163{
164}
165
166#endif /* CONFIG_CTRL_IFACE */
167
168#endif /* CTRL_IFACE_H */