Merge commit 'crater/master'
[dragonfly.git] / contrib / wpa_supplicant-0.5.8 / ctrl_iface.h
blob051d99a67dc6020f3ce324d5567a7b3cce868aba
1 /*
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
10 * license.
12 * See README and COPYING for more details.
15 #ifndef CTRL_IFACE_H
16 #define CTRL_IFACE_H
18 #ifdef CONFIG_CTRL_IFACE
20 /* Shared functions from ctrl_iface.c; to be called by ctrl_iface backends */
22 /**
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);
40 /**
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 */
60 /**
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
66 * programs.
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);
73 /**
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);
84 /**
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);
97 /**
98 * wpa_supplicant_global_ctrl_iface_init - Initialize global control interface
99 * @global: Pointer to global data from wpa_supplicant_init()
100 * Returns: Pointer to private data on success, %NULL on failure
102 * Initialize the global control interface and start receiving commands from
103 * external programs.
105 * Required to be implemented in each control interface backend.
107 struct ctrl_iface_global_priv *
108 wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global);
111 * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface
112 * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init()
114 * Deinitialize the global control interface that was initialized with
115 * wpa_supplicant_global_ctrl_iface_init().
117 * Required to be implemented in each control interface backend.
119 void wpa_supplicant_global_ctrl_iface_deinit(
120 struct ctrl_iface_global_priv *priv);
122 #else /* CONFIG_CTRL_IFACE */
124 static inline struct ctrl_iface_priv *
125 wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
127 return (void *) -1;
130 static inline void
131 wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
135 static inline void
136 wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level,
137 char *buf, size_t len)
141 static inline void
142 wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv)
146 static inline struct ctrl_iface_global_priv *
147 wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
149 return (void *) 1;
152 static inline void
153 wpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv)
157 #endif /* CONFIG_CTRL_IFACE */
159 #endif /* CTRL_IFACE_H */