Deleted Added
sdiff udiff text old ( 151214 ) new ( 151223 )
full compact
1/*-
2 * Copyright (c) 2005
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/usr.sbin/wpa/ndis_events/ndis_events.c 151214 2005-10-10 17:51:12Z wpaul $");
35
36/*
37 * This program simulates the behavior of the ndis_events utility
38 * supplied with wpa_supplicant for Windows. The original utility
39 * is designed to translate Windows WMI events. We don't have WMI,
40 * but we need to supply certain event info to wpa_supplicant in
41 * order to make WPA2 work correctly, so we fake up the interface.
42 */

--- 20 unchanged lines hidden (view full) ---

63#include <stdlib.h>
64#include <unistd.h>
65#include <err.h>
66#include <syslog.h>
67#include <stdarg.h>
68
69static int verbose = 0;
70static int debug = 0;
71
72#define PROGNAME "ndis_events"
73
74#define WPA_SUPPLICANT_PORT 9876
75#define NDIS_INDICATION_LEN 2048
76
77#define EVENT_CONNECT 0
78#define EVENT_DISCONNECT 1

--- 105 unchanged lines hidden (view full) ---

184 e = (struct ndis_evt *)indication;
185 e->ne_len = NDIS_INDICATION_LEN - sizeof(struct ndis_evt);
186
187 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
188 ifr.ifr_data = indication;
189
190 if (ioctl(s, SIOCGPRIVATE_0, &ifr) < 0) {
191 close(s);
192 dbgmsg("failed to read event info from %s\n", ifname);
193 return;
194 }
195
196 if (e->ne_sts == NDIS_STATUS_MEDIA_CONNECT) {
197 type = EVENT_CONNECT;
198 if (verbose)
199 dbgmsg("Received a connect event for %s", ifname);
200 }
201 if (e->ne_sts == NDIS_STATUS_MEDIA_DISCONNECT) {
202 type = EVENT_DISCONNECT;
203 if (verbose)
204 dbgmsg("Received a disconnect event for %s", ifname);
205 }
206 if (e->ne_sts == NDIS_STATUS_MEDIA_SPECIFIC_INDICATION) {
207 type = EVENT_MEDIA_SPECIFIC;
208 if (verbose)
209 dbgmsg("Received a media-specific event for %s",
210 ifname);
211 }
212

--- 26 unchanged lines hidden (view full) ---

239 close(s);
240 return;
241}
242
243static void
244usage(progname)
245 char *progname;
246{
247 fprintf(stderr, "Usage: ndis_events [-d] [-v]\n", progname);
248 exit(1);
249}
250
251int
252main(argc, argv)
253 int argc;
254 char *argv[];
255{
256 int s, r, n;
257 struct sockaddr_in sin;
258 char msg[NDIS_INDICATION_LEN];
259 struct rt_msghdr *rtm;
260 struct if_msghdr *ifm;
261 char ifname[IFNAMSIZ];
262 int ch;
263
264 while ((ch = getopt(argc, argv, "dv")) != -1) {
265 switch(ch) {
266 case 'd':
267 debug++;
268 break;
269 case 'v':
270 verbose++;
271 break;
272 default:
273 usage(PROGNAME);
274 break;
275 }
276 }
277
278 if (!debug && daemon(0, 0))
279 err(1, "failed to daemonize ourselves");

--- 51 unchanged lines hidden ---