~ubuntu-branches/ubuntu/karmic/wpasupplicant/karmic

« back to all changes in this revision

Viewing changes to wpa_supplicant/ctrl_iface.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-12-02 20:52:16 UTC
  • mfrom: (2.1.30 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081202205216-72fqozu84sdt89a8
Tags: 0.6.4-3
Bugfix: "Missing -d in testing for a directory in init script". 
Thanks to Braun Gábor <braung@renyi.hu> for reporting and the patch.
(Closes: #506328)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * WPA Supplicant / UNIX domain socket -based control interface
 
3
 * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
 
4
 *
 
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.
 
8
 *
 
9
 * Alternatively, this software may be distributed under the terms of BSD
 
10
 * license.
 
11
 *
 
12
 * See README and COPYING for more details.
 
13
 */
 
14
 
 
15
#ifndef CTRL_IFACE_H
 
16
#define CTRL_IFACE_H
 
17
 
 
18
#ifdef CONFIG_CTRL_IFACE
 
19
 
 
20
/* Shared functions from ctrl_iface.c; to be called by ctrl_iface backends */
 
21
 
 
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
 
28
 *
 
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.
 
36
 */
 
37
char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
 
38
                                         char *buf, size_t *resp_len);
 
39
 
 
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
 
46
 *
 
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.
 
53
 */
 
54
char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
 
55
                                                char *buf, size_t *resp_len);
 
56
 
 
57
 
 
58
/* Functions that each ctrl_iface backend must implement */
 
59
 
 
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
 
64
 *
 
65
 * Initialize the control interface and start receiving commands from external
 
66
 * programs.
 
67
 *
 
68
 * Required to be implemented in each control interface backend.
 
69
 */
 
70
struct ctrl_iface_priv *
 
71
wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s);
 
72
 
 
73
/**
 
74
 * wpa_supplicant_ctrl_iface_deinit - Deinitialize control interface
 
75
 * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
 
76
 *
 
77
 * Deinitialize the control interface that was initialized with
 
78
 * wpa_supplicant_ctrl_iface_init().
 
79
 *
 
80
 * Required to be implemented in each control interface backend.
 
81
 */
 
82
void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv);
 
83
 
 
84
/**
 
85
 * wpa_supplicant_ctrl_iface_wait - Wait for ctrl_iface monitor
 
86
 * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
 
87
 *
 
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.
 
92
 *
 
93
 * Required to be implemented in each control interface backend.
 
94
 */
 
95
void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv);
 
96
 
 
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
 
101
 *
 
102
 * Initialize the global control interface and start receiving commands from
 
103
 * external programs.
 
104
 *
 
105
 * Required to be implemented in each control interface backend.
 
106
 */
 
107
struct ctrl_iface_global_priv *
 
108
wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global);
 
109
 
 
110
/**
 
111
 * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface
 
112
 * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init()
 
113
 *
 
114
 * Deinitialize the global control interface that was initialized with
 
115
 * wpa_supplicant_global_ctrl_iface_init().
 
116
 *
 
117
 * Required to be implemented in each control interface backend.
 
118
 */
 
119
void wpa_supplicant_global_ctrl_iface_deinit(
 
120
        struct ctrl_iface_global_priv *priv);
 
121
 
 
122
#else /* CONFIG_CTRL_IFACE */
 
123
 
 
124
static inline struct ctrl_iface_priv *
 
125
wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
 
126
{
 
127
        return (void *) -1;
 
128
}
 
129
 
 
130
static inline void
 
131
wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
 
132
{
 
133
}
 
134
 
 
135
static inline void
 
136
wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level,
 
137
                               char *buf, size_t len)
 
138
{
 
139
}
 
140
 
 
141
static inline void
 
142
wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv)
 
143
{
 
144
}
 
145
 
 
146
static inline struct ctrl_iface_global_priv *
 
147
wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
 
148
{
 
149
        return (void *) 1;
 
150
}
 
151
 
 
152
static inline void
 
153
wpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv)
 
154
{
 
155
}
 
156
 
 
157
#endif /* CONFIG_CTRL_IFACE */
 
158
 
 
159
#endif /* CTRL_IFACE_H */