~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to driver_ndis_.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2008-03-12 20:03:04 UTC
  • mfrom: (1.1.10 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080312200304-4331y9wj46pdd34z
Tags: 0.6.3-1
* New upstream release.
* Drop patches applied upstream:
  - debian/patches/30_wpa_gui_qt4_eventhistoryui_rework.patch
  - debian/patches/31_wpa_gui_qt4_eventhistory_always_scrollbar.patch
  - debian/patches/32_wpa_gui_qt4_eventhistory_scroll_with_events.patch
  - debian/patches/40_dbus_ssid_data.patch
* Tidy up the clean target of debian/rules. Now that the madwifi headers are
  handled differently we no longer need to do any cleanup.
* Fix formatting error in debian/ifupdown/wpa_action.8 to make lintian
  quieter.
* Add patch to fix formatting errors in manpages build from sgml source. Use
  <emphasis> tags to hightlight keywords instead of surrounding them in
  strong quotes.
  - debian/patches/41_manpage_format_fixes.patch
* wpasupplicant binary package no longer suggests pcscd, guessnet, iproute
  or wireless-tools, nor does it recommend dhcp3-client. These are not
  needed.
* Add debian/patches/10_silence_siocsiwauth_icotl_failure.patch to disable
  ioctl failure messages that occur under normal conditions.
* Cherry pick two upstream git commits concerning the dbus interface:
  - debian/patches/11_avoid_dbus_version_namespace.patch
  - debian/patches/12_fix_potential_use_after_free.patch
* Add debian/patches/42_manpage_explain_available_drivers.patch to explain
  that not all of the driver backends are available in the provided
  wpa_supplicant binary, and that the canonical list of supported driver
  backends can be retrieved from the wpa_supplicant -h (help) output.
  (Closes: #466910)
* Add debian/patches/20_wpa_gui_qt4_disable_link_prl.patch to remove
  link_prl CONFIG compile flag added by qmake-qt4 >= 4.3.4-2 to avoid excess
  linking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * WPA Supplicant - Windows/NDIS driver interface - event processing
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
 
#include "includes.h"
16
 
 
17
 
#include "common.h"
18
 
#include "driver.h"
19
 
#include "wpa_supplicant.h"
20
 
#include "l2_packet.h"
21
 
#include "eloop.h"
22
 
#include "wpa.h"
23
 
 
24
 
/* Keep this event processing in a separate file and without WinPcap headers to
25
 
 * avoid conflicts with some of the header files. */
26
 
struct _ADAPTER;
27
 
typedef struct _ADAPTER * LPADAPTER;
28
 
#include "driver_ndis.h"
29
 
 
30
 
 
31
 
void wpa_driver_ndis_event_connect(struct wpa_driver_ndis_data *drv);
32
 
void wpa_driver_ndis_event_disconnect(struct wpa_driver_ndis_data *drv);
33
 
void wpa_driver_ndis_event_media_specific(struct wpa_driver_ndis_data *drv,
34
 
                                          const u8 *data, size_t data_len);
35
 
void wpa_driver_ndis_event_adapter_arrival(struct wpa_driver_ndis_data *drv);
36
 
void wpa_driver_ndis_event_adapter_removal(struct wpa_driver_ndis_data *drv);
37
 
 
38
 
 
39
 
enum event_types { EVENT_CONNECT, EVENT_DISCONNECT,
40
 
                   EVENT_MEDIA_SPECIFIC, EVENT_ADAPTER_ARRIVAL,
41
 
                   EVENT_ADAPTER_REMOVAL };
42
 
 
43
 
/* Event data:
44
 
 * enum event_types (as int, i.e., 4 octets)
45
 
 * data length (2 octets (big endian), optional)
46
 
 * data (variable len, optional)
47
 
 */
48
 
 
49
 
 
50
 
static void wpa_driver_ndis_event_process(struct wpa_driver_ndis_data *drv,
51
 
                                          u8 *buf, size_t len)
52
 
{
53
 
        u8 *pos, *data = NULL;
54
 
        enum event_types type;
55
 
        size_t data_len = 0;
56
 
 
57
 
        wpa_hexdump(MSG_MSGDUMP, "NDIS: received event data", buf, len);
58
 
        if (len < sizeof(int))
59
 
                return;
60
 
        type = *((int *) buf);
61
 
        pos = buf + sizeof(int);
62
 
        wpa_printf(MSG_DEBUG, "NDIS: event - type %d", type);
63
 
 
64
 
        if (buf + len - pos > 2) {
65
 
                data_len = (int) *pos++ << 8;
66
 
                data_len += *pos++;
67
 
                if (data_len > (size_t) (buf + len - pos)) {
68
 
                        wpa_printf(MSG_DEBUG, "NDIS: event data overflow");
69
 
                        return;
70
 
                }
71
 
                data = pos;
72
 
                wpa_hexdump(MSG_MSGDUMP, "NDIS: event data", data, data_len);
73
 
        }
74
 
 
75
 
        switch (type) {
76
 
        case EVENT_CONNECT:
77
 
                wpa_driver_ndis_event_connect(drv);
78
 
                break;
79
 
        case EVENT_DISCONNECT:
80
 
                wpa_driver_ndis_event_disconnect(drv);
81
 
                break;
82
 
        case EVENT_MEDIA_SPECIFIC:
83
 
                wpa_driver_ndis_event_media_specific(drv, data, data_len);
84
 
                break;
85
 
        case EVENT_ADAPTER_ARRIVAL:
86
 
                wpa_driver_ndis_event_adapter_arrival(drv);
87
 
                break;
88
 
        case EVENT_ADAPTER_REMOVAL:
89
 
                wpa_driver_ndis_event_adapter_removal(drv);
90
 
                break;
91
 
        }
92
 
}
93
 
 
94
 
 
95
 
void wpa_driver_ndis_event_pipe_cb(void *eloop_data, void *user_data)
96
 
{
97
 
        struct wpa_driver_ndis_data *drv = eloop_data;
98
 
        u8 buf[512];
99
 
        DWORD len;
100
 
 
101
 
        ResetEvent(drv->event_avail);
102
 
        if (ReadFile(drv->events_pipe, buf, sizeof(buf), &len, NULL))
103
 
                wpa_driver_ndis_event_process(drv, buf, len);
104
 
        else {
105
 
                wpa_printf(MSG_DEBUG, "%s: ReadFile() failed: %d", __func__,
106
 
                           (int) GetLastError());
107
 
        }
108
 
}