44
44
* enum event_types (as int, i.e., 4 octets)
45
* InstanceName length (1 octet)
46
* InstanceName (variable len)
47
* data length (1 octet, optional)
45
* data length (2 octets (big endian), optional)
48
46
* data (variable len, optional)
53
51
u8 *buf, size_t len)
55
53
u8 *pos, *data = NULL;
57
54
enum event_types type;
58
unsigned char instance_len;
60
55
size_t data_len = 0;
62
57
wpa_hexdump(MSG_MSGDUMP, "NDIS: received event data", buf, len);
63
if (len < sizeof(int) + 1)
58
if (len < sizeof(int))
65
60
type = *((int *) buf);
66
61
pos = buf + sizeof(int);
67
62
wpa_printf(MSG_DEBUG, "NDIS: event - type %d", type);
68
instance_len = *pos++;
69
if (instance_len > buf + len - pos) {
70
wpa_printf(MSG_DEBUG, "NDIS: event InstanceName overflow");
75
wpa_hexdump_ascii(MSG_MSGDUMP, "NDIS: event InstanceName",
76
instance, instance_len);
78
if (buf + len - pos > 1) {
64
if (buf + len - pos > 2) {
65
data_len = (int) *pos++ << 8;
80
67
if (data_len > (size_t) (buf + len - pos)) {
81
68
wpa_printf(MSG_DEBUG, "NDIS: event data overflow");
85
72
wpa_hexdump(MSG_MSGDUMP, "NDIS: event data", data, data_len);
88
if (drv->adapter_desc) {
89
desc_len = strlen(drv->adapter_desc);
90
if (instance_len < desc_len ||
91
strncmp(drv->adapter_desc, instance, desc_len)) {
92
wpa_printf(MSG_DEBUG, "NDIS: ignored event for "
98
* <driver desc> #<num>
99
* <driver desc> #<num> - <intermediate drv name> Miniport
101
for (i = desc_len + 1; i < instance_len; i++) {
102
if (instance[i] == '-') {
103
wpa_printf(MSG_DEBUG, "NDIS: ignored event "
104
"for intermediate miniport");
111
76
case EVENT_CONNECT:
112
77
wpa_driver_ndis_event_connect(drv);
143
106
(int) GetLastError());
147
#else /* CONFIG_NDIS_EVENTS_INTEGRATED */
149
static void wpa_driver_ndis_event_cb(int sock, void *eloop_ctx, void *sock_ctx)
151
struct wpa_driver_ndis_data *drv = eloop_ctx;
155
res = recv(sock, buf, sizeof(buf), 0);
157
perror("wpa_driver_ndis_event_cb - recv");
160
wpa_driver_ndis_event_process(drv, buf, (size_t) res);
164
int wpa_driver_register_event_cb(struct wpa_driver_ndis_data *drv)
166
struct sockaddr_in addr;
168
drv->event_sock = socket(PF_INET, SOCK_DGRAM, 0);
169
if (drv->event_sock < 0) {
174
/* These events are received from an external program, ndis_events,
175
* which is converting WMI events to more "UNIX-like" input for
176
* wpa_supplicant, i.e., UDP packets that can be received through the
177
* eloop mechanism. */
178
memset(&addr, 0, sizeof(addr));
179
addr.sin_family = AF_INET;
180
addr.sin_addr.s_addr = htonl((127 << 24) | 1);
181
addr.sin_port = htons(9876);
182
if (bind(drv->event_sock, (struct sockaddr *) &addr, sizeof(addr)) < 0)
185
close(drv->event_sock);
186
drv->event_sock = -1;
190
eloop_register_read_sock(drv->event_sock, wpa_driver_ndis_event_cb,
196
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */