mirror of https://github.com/hak5/openwrt.git
hostapd: use patches to add the nl80211 driver instead of copying the files.
SVN-Revision: 10475lede-17.01
parent
f116c50a80
commit
306caa660a
|
@ -77,11 +77,6 @@ define Build/ConfigureTarget
|
|||
$(PKG_BUILD_DIR)/hostapd \
|
||||
$(PKG_BUILD_DIR)/src \
|
||||
$(PKG_BUILD_DIR)/hostapd.$(1)/
|
||||
$(CP) ./files/driver_nl80211.c $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/
|
||||
$(CP) ./files/radiotap.c $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/
|
||||
$(CP) ./files/radiotap.h $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/
|
||||
$(CP) ./files/radiotap_iter.h $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/
|
||||
|
||||
$(CP) ./files/$(1).config $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/.config
|
||||
$(if $(CONFIG_PACKAGE_kmod-mac80211),,$(SED) 's,^CONFIG_DRIVER_DEVICESCAPE,#CONFIG_DRIVER_DEVICESCAPE,g' $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/.config)
|
||||
$(if $(CONFIG_PACKAGE_kmod-madwifi),,$(SED) 's,^CONFIG_DRIVER_MADWIFI,#CONFIG_DRIVER_MADWIFI,g' $(PKG_BUILD_DIR)/hostapd.$(1)/hostapd/.config)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,287 +0,0 @@
|
|||
/*
|
||||
* Radiotap parser
|
||||
*
|
||||
* Copyright 2007 Andy Green <andy@warmcat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*
|
||||
*
|
||||
* Modified for userspace by Johannes Berg <johannes@sipsolutions.net>
|
||||
* I only modified some things on top to ease syncing should bugs be found.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "radiotap_iter.h"
|
||||
|
||||
#define le16_to_cpu le_to_host16
|
||||
#define le32_to_cpu le_to_host32
|
||||
#define __le32 uint32_t
|
||||
#define ulong unsigned long
|
||||
#define unlikely(cond) (cond)
|
||||
#define get_unaligned(p) \
|
||||
({ \
|
||||
struct packed_dummy_struct { \
|
||||
typeof(*(p)) __val; \
|
||||
} __attribute__((packed)) *__ptr = (void *) (p); \
|
||||
\
|
||||
__ptr->__val; \
|
||||
})
|
||||
|
||||
/* function prototypes and related defs are in radiotap_iter.h */
|
||||
|
||||
/**
|
||||
* ieee80211_radiotap_iterator_init - radiotap parser iterator initialization
|
||||
* @iterator: radiotap_iterator to initialize
|
||||
* @radiotap_header: radiotap header to parse
|
||||
* @max_length: total length we can parse into (eg, whole packet length)
|
||||
*
|
||||
* Returns: 0 or a negative error code if there is a problem.
|
||||
*
|
||||
* This function initializes an opaque iterator struct which can then
|
||||
* be passed to ieee80211_radiotap_iterator_next() to visit every radiotap
|
||||
* argument which is present in the header. It knows about extended
|
||||
* present headers and handles them.
|
||||
*
|
||||
* How to use:
|
||||
* call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator
|
||||
* struct ieee80211_radiotap_iterator (no need to init the struct beforehand)
|
||||
* checking for a good 0 return code. Then loop calling
|
||||
* __ieee80211_radiotap_iterator_next()... it returns either 0,
|
||||
* -ENOENT if there are no more args to parse, or -EINVAL if there is a problem.
|
||||
* The iterator's @this_arg member points to the start of the argument
|
||||
* associated with the current argument index that is present, which can be
|
||||
* found in the iterator's @this_arg_index member. This arg index corresponds
|
||||
* to the IEEE80211_RADIOTAP_... defines.
|
||||
*
|
||||
* Radiotap header length:
|
||||
* You can find the CPU-endian total radiotap header length in
|
||||
* iterator->max_length after executing ieee80211_radiotap_iterator_init()
|
||||
* successfully.
|
||||
*
|
||||
* Alignment Gotcha:
|
||||
* You must take care when dereferencing iterator.this_arg
|
||||
* for multibyte types... the pointer is not aligned. Use
|
||||
* get_unaligned((type *)iterator.this_arg) to dereference
|
||||
* iterator.this_arg for type "type" safely on all arches.
|
||||
*
|
||||
* Example code:
|
||||
* See Documentation/networking/radiotap-headers.txt
|
||||
*/
|
||||
|
||||
int ieee80211_radiotap_iterator_init(
|
||||
struct ieee80211_radiotap_iterator *iterator,
|
||||
struct ieee80211_radiotap_header *radiotap_header,
|
||||
int max_length)
|
||||
{
|
||||
/* Linux only supports version 0 radiotap format */
|
||||
if (radiotap_header->it_version)
|
||||
return -EINVAL;
|
||||
|
||||
/* sanity check for allowed length and radiotap length field */
|
||||
if (max_length < le16_to_cpu(get_unaligned(&radiotap_header->it_len)))
|
||||
return -EINVAL;
|
||||
|
||||
iterator->rtheader = radiotap_header;
|
||||
iterator->max_length = le16_to_cpu(get_unaligned(
|
||||
&radiotap_header->it_len));
|
||||
iterator->arg_index = 0;
|
||||
iterator->bitmap_shifter = le32_to_cpu(get_unaligned(
|
||||
&radiotap_header->it_present));
|
||||
iterator->arg = (u8 *)radiotap_header + sizeof(*radiotap_header);
|
||||
iterator->this_arg = NULL;
|
||||
|
||||
/* find payload start allowing for extended bitmap(s) */
|
||||
|
||||
if (unlikely(iterator->bitmap_shifter & (1<<IEEE80211_RADIOTAP_EXT))) {
|
||||
while (le32_to_cpu(get_unaligned((__le32 *)iterator->arg)) &
|
||||
(1<<IEEE80211_RADIOTAP_EXT)) {
|
||||
iterator->arg += sizeof(u32);
|
||||
|
||||
/*
|
||||
* check for insanity where the present bitmaps
|
||||
* keep claiming to extend up to or even beyond the
|
||||
* stated radiotap header length
|
||||
*/
|
||||
|
||||
if (((ulong)iterator->arg - (ulong)iterator->rtheader)
|
||||
> (ulong)iterator->max_length)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
iterator->arg += sizeof(u32);
|
||||
|
||||
/*
|
||||
* no need to check again for blowing past stated radiotap
|
||||
* header length, because ieee80211_radiotap_iterator_next
|
||||
* checks it before it is dereferenced
|
||||
*/
|
||||
}
|
||||
|
||||
/* we are all initialized happily */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
|
||||
* @iterator: radiotap_iterator to move to next arg (if any)
|
||||
*
|
||||
* Returns: 0 if there is an argument to handle,
|
||||
* -ENOENT if there are no more args or -EINVAL
|
||||
* if there is something else wrong.
|
||||
*
|
||||
* This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*)
|
||||
* in @this_arg_index and sets @this_arg to point to the
|
||||
* payload for the field. It takes care of alignment handling and extended
|
||||
* present fields. @this_arg can be changed by the caller (eg,
|
||||
* incremented to move inside a compound argument like
|
||||
* IEEE80211_RADIOTAP_CHANNEL). The args pointed to are in
|
||||
* little-endian format whatever the endianess of your CPU.
|
||||
*
|
||||
* Alignment Gotcha:
|
||||
* You must take care when dereferencing iterator.this_arg
|
||||
* for multibyte types... the pointer is not aligned. Use
|
||||
* get_unaligned((type *)iterator.this_arg) to dereference
|
||||
* iterator.this_arg for type "type" safely on all arches.
|
||||
*/
|
||||
|
||||
int ieee80211_radiotap_iterator_next(
|
||||
struct ieee80211_radiotap_iterator *iterator)
|
||||
{
|
||||
|
||||
/*
|
||||
* small length lookup table for all radiotap types we heard of
|
||||
* starting from b0 in the bitmap, so we can walk the payload
|
||||
* area of the radiotap header
|
||||
*
|
||||
* There is a requirement to pad args, so that args
|
||||
* of a given length must begin at a boundary of that length
|
||||
* -- but note that compound args are allowed (eg, 2 x u16
|
||||
* for IEEE80211_RADIOTAP_CHANNEL) so total arg length is not
|
||||
* a reliable indicator of alignment requirement.
|
||||
*
|
||||
* upper nybble: content alignment for arg
|
||||
* lower nybble: content length for arg
|
||||
*/
|
||||
|
||||
static const u8 rt_sizes[] = {
|
||||
[IEEE80211_RADIOTAP_TSFT] = 0x88,
|
||||
[IEEE80211_RADIOTAP_FLAGS] = 0x11,
|
||||
[IEEE80211_RADIOTAP_RATE] = 0x11,
|
||||
[IEEE80211_RADIOTAP_CHANNEL] = 0x24,
|
||||
[IEEE80211_RADIOTAP_FHSS] = 0x22,
|
||||
[IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DBM_ANTNOISE] = 0x11,
|
||||
[IEEE80211_RADIOTAP_LOCK_QUALITY] = 0x22,
|
||||
[IEEE80211_RADIOTAP_TX_ATTENUATION] = 0x22,
|
||||
[IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = 0x22,
|
||||
[IEEE80211_RADIOTAP_DBM_TX_POWER] = 0x11,
|
||||
[IEEE80211_RADIOTAP_ANTENNA] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DB_ANTSIGNAL] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DB_ANTNOISE] = 0x11,
|
||||
[IEEE80211_RADIOTAP_RX_FLAGS] = 0x22,
|
||||
[IEEE80211_RADIOTAP_TX_FLAGS] = 0x22,
|
||||
[IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11,
|
||||
/*
|
||||
* add more here as they are defined in
|
||||
* include/net/ieee80211_radiotap.h
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* for every radiotap entry we can at
|
||||
* least skip (by knowing the length)...
|
||||
*/
|
||||
|
||||
while (iterator->arg_index < (int) sizeof(rt_sizes)) {
|
||||
int hit = 0;
|
||||
int pad;
|
||||
|
||||
if (!(iterator->bitmap_shifter & 1))
|
||||
goto next_entry; /* arg not present */
|
||||
|
||||
/*
|
||||
* arg is present, account for alignment padding
|
||||
* 8-bit args can be at any alignment
|
||||
* 16-bit args must start on 16-bit boundary
|
||||
* 32-bit args must start on 32-bit boundary
|
||||
* 64-bit args must start on 64-bit boundary
|
||||
*
|
||||
* note that total arg size can differ from alignment of
|
||||
* elements inside arg, so we use upper nybble of length
|
||||
* table to base alignment on
|
||||
*
|
||||
* also note: these alignments are ** relative to the
|
||||
* start of the radiotap header **. There is no guarantee
|
||||
* that the radiotap header itself is aligned on any
|
||||
* kind of boundary.
|
||||
*
|
||||
* the above is why get_unaligned() is used to dereference
|
||||
* multibyte elements from the radiotap area
|
||||
*/
|
||||
|
||||
pad = (((ulong)iterator->arg) -
|
||||
((ulong)iterator->rtheader)) &
|
||||
((rt_sizes[iterator->arg_index] >> 4) - 1);
|
||||
|
||||
if (pad)
|
||||
iterator->arg +=
|
||||
(rt_sizes[iterator->arg_index] >> 4) - pad;
|
||||
|
||||
/*
|
||||
* this is what we will return to user, but we need to
|
||||
* move on first so next call has something fresh to test
|
||||
*/
|
||||
iterator->this_arg_index = iterator->arg_index;
|
||||
iterator->this_arg = iterator->arg;
|
||||
hit = 1;
|
||||
|
||||
/* internally move on the size of this arg */
|
||||
iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
|
||||
|
||||
/*
|
||||
* check for insanity where we are given a bitmap that
|
||||
* claims to have more arg content than the length of the
|
||||
* radiotap section. We will normally end up equalling this
|
||||
* max_length on the last arg, never exceeding it.
|
||||
*/
|
||||
|
||||
if (((ulong)iterator->arg - (ulong)iterator->rtheader) >
|
||||
(ulong) iterator->max_length)
|
||||
return -EINVAL;
|
||||
|
||||
next_entry:
|
||||
iterator->arg_index++;
|
||||
if (unlikely((iterator->arg_index & 31) == 0)) {
|
||||
/* completed current u32 bitmap */
|
||||
if (iterator->bitmap_shifter & 1) {
|
||||
/* b31 was set, there is more */
|
||||
/* move to next u32 bitmap */
|
||||
iterator->bitmap_shifter = le32_to_cpu(
|
||||
get_unaligned(iterator->next_bitmap));
|
||||
iterator->next_bitmap++;
|
||||
} else
|
||||
/* no more bitmaps: end */
|
||||
iterator->arg_index = sizeof(rt_sizes);
|
||||
} else /* just try the next bit */
|
||||
iterator->bitmap_shifter >>= 1;
|
||||
|
||||
/* if we found a valid arg earlier, return it now */
|
||||
if (hit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* we don't know how to handle any more args, we're done */
|
||||
return -ENOENT;
|
||||
}
|
|
@ -1,242 +0,0 @@
|
|||
/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
|
||||
/* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004 David Young. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of David Young may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
|
||||
* YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modifications to fit into the linux IEEE 802.11 stack,
|
||||
* Mike Kershaw (dragorn@kismetwireless.net)
|
||||
*/
|
||||
|
||||
#ifndef IEEE80211RADIOTAP_H
|
||||
#define IEEE80211RADIOTAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Base version of the radiotap packet header data */
|
||||
#define PKTHDR_RADIOTAP_VERSION 0
|
||||
|
||||
/* A generic radio capture format is desirable. There is one for
|
||||
* Linux, but it is neither rigidly defined (there were not even
|
||||
* units given for some fields) nor easily extensible.
|
||||
*
|
||||
* I suggest the following extensible radio capture format. It is
|
||||
* based on a bitmap indicating which fields are present.
|
||||
*
|
||||
* I am trying to describe precisely what the application programmer
|
||||
* should expect in the following, and for that reason I tell the
|
||||
* units and origin of each measurement (where it applies), or else I
|
||||
* use sufficiently weaselly language ("is a monotonically nondecreasing
|
||||
* function of...") that I cannot set false expectations for lawyerly
|
||||
* readers.
|
||||
*/
|
||||
|
||||
/* The radio capture header precedes the 802.11 header.
|
||||
* All data in the header is little endian on all platforms.
|
||||
*/
|
||||
struct ieee80211_radiotap_header {
|
||||
uint8_t it_version; /* Version 0. Only increases
|
||||
* for drastic changes,
|
||||
* introduction of compatible
|
||||
* new fields does not count.
|
||||
*/
|
||||
uint8_t it_pad;
|
||||
uint16_t it_len; /* length of the whole
|
||||
* header in bytes, including
|
||||
* it_version, it_pad,
|
||||
* it_len, and data fields.
|
||||
*/
|
||||
uint32_t it_present; /* A bitmap telling which
|
||||
* fields are present. Set bit 31
|
||||
* (0x80000000) to extend the
|
||||
* bitmap by another 32 bits.
|
||||
* Additional extensions are made
|
||||
* by setting bit 31.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Name Data type Units
|
||||
* ---- --------- -----
|
||||
*
|
||||
* IEEE80211_RADIOTAP_TSFT __le64 microseconds
|
||||
*
|
||||
* Value in microseconds of the MAC's 64-bit 802.11 Time
|
||||
* Synchronization Function timer when the first bit of the
|
||||
* MPDU arrived at the MAC. For received frames, only.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
|
||||
*
|
||||
* Tx/Rx frequency in MHz, followed by flags (see below).
|
||||
*
|
||||
* IEEE80211_RADIOTAP_FHSS uint16_t see below
|
||||
*
|
||||
* For frequency-hopping radios, the hop set (first byte)
|
||||
* and pattern (second byte).
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RATE u8 500kb/s
|
||||
*
|
||||
* Tx/Rx data rate
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from
|
||||
* one milliwatt (dBm)
|
||||
*
|
||||
* RF signal power at the antenna, decibel difference from
|
||||
* one milliwatt.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from
|
||||
* one milliwatt (dBm)
|
||||
*
|
||||
* RF noise power at the antenna, decibel difference from one
|
||||
* milliwatt.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB)
|
||||
*
|
||||
* RF signal power at the antenna, decibel difference from an
|
||||
* arbitrary, fixed reference.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB)
|
||||
*
|
||||
* RF noise power at the antenna, decibel difference from an
|
||||
* arbitrary, fixed reference point.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
|
||||
*
|
||||
* Quality of Barker code lock. Unitless. Monotonically
|
||||
* nondecreasing with "better" lock strength. Called "Signal
|
||||
* Quality" in datasheets. (Is there a standard way to measure
|
||||
* this?)
|
||||
*
|
||||
* IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
|
||||
*
|
||||
* Transmit power expressed as unitless distance from max
|
||||
* power set at factory calibration. 0 is max power.
|
||||
* Monotonically nondecreasing with lower power levels.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
|
||||
*
|
||||
* Transmit power expressed as decibel distance from max power
|
||||
* set at factory calibration. 0 is max power. Monotonically
|
||||
* nondecreasing with lower power levels.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from
|
||||
* one milliwatt (dBm)
|
||||
*
|
||||
* Transmit power expressed as dBm (decibels from a 1 milliwatt
|
||||
* reference). This is the absolute power level measured at
|
||||
* the antenna port.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_FLAGS u8 bitmap
|
||||
*
|
||||
* Properties of transmitted and received frames. See flags
|
||||
* defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_ANTENNA u8 antenna index
|
||||
*
|
||||
* Unitless indication of the Rx/Tx antenna for this packet.
|
||||
* The first antenna is antenna 0.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
|
||||
*
|
||||
* Properties of received frames. See flags defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_TX_FLAGS uint16_t bitmap
|
||||
*
|
||||
* Properties of transmitted frames. See flags defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RTS_RETRIES u8 data
|
||||
*
|
||||
* Number of rts retries a transmitted frame used.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DATA_RETRIES u8 data
|
||||
*
|
||||
* Number of unicast retries a transmitted frame used.
|
||||
*
|
||||
*/
|
||||
enum ieee80211_radiotap_type {
|
||||
IEEE80211_RADIOTAP_TSFT = 0,
|
||||
IEEE80211_RADIOTAP_FLAGS = 1,
|
||||
IEEE80211_RADIOTAP_RATE = 2,
|
||||
IEEE80211_RADIOTAP_CHANNEL = 3,
|
||||
IEEE80211_RADIOTAP_FHSS = 4,
|
||||
IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
|
||||
IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
|
||||
IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
|
||||
IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
|
||||
IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
|
||||
IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
|
||||
IEEE80211_RADIOTAP_ANTENNA = 11,
|
||||
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
|
||||
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
|
||||
IEEE80211_RADIOTAP_RX_FLAGS = 14,
|
||||
IEEE80211_RADIOTAP_TX_FLAGS = 15,
|
||||
IEEE80211_RADIOTAP_RTS_RETRIES = 16,
|
||||
IEEE80211_RADIOTAP_DATA_RETRIES = 17,
|
||||
IEEE80211_RADIOTAP_EXT = 31
|
||||
};
|
||||
|
||||
/* Channel flags. */
|
||||
#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
|
||||
#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
|
||||
#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
|
||||
#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
|
||||
#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
|
||||
#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
|
||||
#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
|
||||
#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
|
||||
|
||||
/* For IEEE80211_RADIOTAP_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
|
||||
* during CFP
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
|
||||
* with short
|
||||
* preamble
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
|
||||
* with WEP encryption
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
|
||||
* with fragmentation
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
|
||||
#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
|
||||
* 802.11 header and payload
|
||||
* (to 32-bit boundary)
|
||||
*/
|
||||
/* For IEEE80211_RADIOTAP_RX_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
|
||||
|
||||
/* For IEEE80211_RADIOTAP_TX_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
|
||||
* retries */
|
||||
#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
|
||||
#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
|
||||
|
||||
#endif /* IEEE80211_RADIOTAP_H */
|
|
@ -1,41 +0,0 @@
|
|||
#ifndef __RADIOTAP_ITER_H
|
||||
#define __RADIOTAP_ITER_H
|
||||
|
||||
#include "radiotap.h"
|
||||
|
||||
/* Radiotap header iteration
|
||||
* implemented in radiotap.c
|
||||
*/
|
||||
/**
|
||||
* struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
|
||||
* @rtheader: pointer to the radiotap header we are walking through
|
||||
* @max_length: length of radiotap header in cpu byte ordering
|
||||
* @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
|
||||
* @this_arg: pointer to current radiotap arg
|
||||
* @arg_index: internal next argument index
|
||||
* @arg: internal next argument pointer
|
||||
* @next_bitmap: internal pointer to next present u32
|
||||
* @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
|
||||
*/
|
||||
|
||||
struct ieee80211_radiotap_iterator {
|
||||
struct ieee80211_radiotap_header *rtheader;
|
||||
int max_length;
|
||||
int this_arg_index;
|
||||
unsigned char *this_arg;
|
||||
|
||||
int arg_index;
|
||||
unsigned char *arg;
|
||||
uint32_t *next_bitmap;
|
||||
uint32_t bitmap_shifter;
|
||||
};
|
||||
|
||||
extern int ieee80211_radiotap_iterator_init(
|
||||
struct ieee80211_radiotap_iterator *iterator,
|
||||
struct ieee80211_radiotap_header *radiotap_header,
|
||||
int max_length);
|
||||
|
||||
extern int ieee80211_radiotap_iterator_next(
|
||||
struct ieee80211_radiotap_iterator *iterator);
|
||||
|
||||
#endif /* __RADIOTAP_ITER_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
hostapd/driver_devicescape.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- hostap.orig/hostapd/driver_devicescape.c 2007-11-14 17:30:47.000000000 +0100
|
||||
+++ hostap/hostapd/driver_devicescape.c 2007-11-14 17:31:07.000000000 +0100
|
||||
@@ -1264,6 +1264,7 @@ static void dump_frame_info(struct ieee8
|
||||
}
|
||||
|
||||
|
||||
+/*
|
||||
static void hostapd_michael_mic_failure(struct hostapd_data *hapd, u8 *buf,
|
||||
size_t len)
|
||||
{
|
||||
@@ -1278,6 +1279,7 @@ static void hostapd_michael_mic_failure(
|
||||
|
||||
mlme_michaelmicfailure_indication(hapd, hdr->addr2);
|
||||
}
|
||||
+*/
|
||||
|
||||
|
||||
static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
|
||||
@@ -1386,10 +1388,10 @@ static void handle_frame(struct hostapd_
|
||||
case ieee80211_msg_wep_frame_unknown_key:
|
||||
ieee802_11_rx_unknown_key(hapd, buf, data_len);
|
||||
return;
|
||||
- */
|
||||
case ieee80211_msg_michael_mic_failure:
|
||||
hostapd_michael_mic_failure(hapd, buf, data_len);
|
||||
return;
|
||||
+ */
|
||||
/*
|
||||
* TODO
|
||||
* We should be telling them to go away. But we don't support that now.
|
|
@ -1,112 +0,0 @@
|
|||
---
|
||||
hostapd/driver_devicescape.c | 93 ++++++++++++++++++++++++++++++-------------
|
||||
1 file changed, 67 insertions(+), 26 deletions(-)
|
||||
|
||||
--- hostap.orig/hostapd/driver_devicescape.c 2007-11-09 13:41:12.000000000 +0100
|
||||
+++ hostap/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
|
||||
@@ -150,38 +150,79 @@ static int i802_set_encryption(const cha
|
||||
size_t key_len, int txkey)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param *param;
|
||||
- u8 *buf;
|
||||
- size_t blen;
|
||||
- int ret = 0;
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
+ int err = 0;
|
||||
|
||||
- blen = sizeof(*param) + key_len;
|
||||
- buf = os_zalloc(blen);
|
||||
- if (buf == NULL)
|
||||
- return -1;
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
|
||||
- param = (struct prism2_hostapd_param *) buf;
|
||||
- param->cmd = PRISM2_SET_ENCRYPTION;
|
||||
- if (addr == NULL)
|
||||
- memset(param->sta_addr, 0xff, ETH_ALEN);
|
||||
- else
|
||||
- memcpy(param->sta_addr, addr, ETH_ALEN);
|
||||
- os_strlcpy((char *) param->u.crypt.alg, alg,
|
||||
- HOSTAP_CRYPT_ALG_NAME_LEN);
|
||||
- param->u.crypt.flags = txkey ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
|
||||
- param->u.crypt.idx = idx;
|
||||
- param->u.crypt.key_len = key_len;
|
||||
- memcpy(param->u.crypt.key, key, key_len);
|
||||
+ if (strcmp(alg, "none") == 0) {
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_DEL_KEY, 0);
|
||||
+ } else {
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_NEW_KEY, 0);
|
||||
+ NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
|
||||
+ if (strcmp(alg, "WEP") == 0) {
|
||||
+ if (key_len == 5)
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
|
||||
+ 0x000FAC01);
|
||||
+ else
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
|
||||
+ 0x000FAC05);
|
||||
+ } else if (strcmp(alg, "TKIP") == 0)
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
|
||||
+ else if (strcmp(alg, "CCMP") == 0)
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
|
||||
+ else
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
- if (hostapd_ioctl_iface(iface, drv, param, blen) && errno != ENOENT) {
|
||||
- printf("%s: Failed to set encryption to alg '%s' addr " MACSTR
|
||||
- " errno=%d\n",
|
||||
- iface, alg, MAC2STR(param->sta_addr), errno);
|
||||
- ret = -1;
|
||||
+ if (addr)
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+ NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ (err = nl_wait_for_ack(drv->nl_handle)) < 0) {
|
||||
+ if (err != -ENOENT) {
|
||||
+ err = 0;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
- free(buf);
|
||||
+ if (!txkey) {
|
||||
+ ret = 0;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ nlmsg_free(msg);
|
||||
+
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_SET_KEY, 0);
|
||||
+ NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
|
||||
+ NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ (err = nl_wait_for_ack(drv->nl_handle)) < 0) {
|
||||
+ if (err != -ENOENT) {
|
||||
+ err = 0;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ out:
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
---
|
||||
hostapd/driver_devicescape.c | 111 +++++++++++++++++++++++++++++++------------
|
||||
1 file changed, 82 insertions(+), 29 deletions(-)
|
||||
|
||||
--- hostap.orig/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
|
||||
+++ hostap/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
|
||||
@@ -68,6 +68,8 @@ struct i802_driver_data {
|
||||
struct nl_handle *nl_handle;
|
||||
struct nl_cache *nl_cache;
|
||||
struct genl_family *nl80211;
|
||||
+ int dtim_period;
|
||||
+ unsigned int beacon_set:1;
|
||||
};
|
||||
|
||||
|
||||
@@ -908,37 +910,44 @@ static int i802_bss_remove(void *priv, c
|
||||
}
|
||||
|
||||
|
||||
-static int i802_set_beacon(const char *ifname, void *priv,
|
||||
+static int i802_set_beacon(const char *iface, void *priv,
|
||||
u8 *head, size_t head_len,
|
||||
u8 *tail, size_t tail_len)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param *param;
|
||||
- int len, ret = 0;
|
||||
+ struct nl_msg *msg;
|
||||
+ u8 cmd = NL80211_CMD_NEW_BEACON;
|
||||
+ int ret = -1;
|
||||
|
||||
- param = os_zalloc(sizeof(*param) + head_len + tail_len);
|
||||
- if (param == NULL) {
|
||||
- printf("Failed to alloc memory for beacon ioctl\n");
|
||||
- return -1;
|
||||
- }
|
||||
- len = (¶m->u.beacon.data[0] - (u8 *) param) + head_len + tail_len;
|
||||
- param->cmd = PRISM2_HOSTAPD_SET_BEACON;
|
||||
- param->u.beacon.head_len = head_len;
|
||||
- param->u.beacon.tail_len = tail_len;
|
||||
- memcpy(¶m->u.beacon.data[0], head, head_len);
|
||||
- memcpy(¶m->u.beacon.data[0] + head_len, tail, tail_len);
|
||||
-
|
||||
- if (len < (int) sizeof(*param))
|
||||
- len = sizeof(*param);
|
||||
- if (hostapd_ioctl_iface(ifname, drv, param, len)) {
|
||||
- printf("Could not set beacon data to kernel driver.\n");
|
||||
- printf("ifname='%s' head=%p head_len=%d tail=%p tail_len=%d "
|
||||
- "cmd=%d\n",
|
||||
- ifname, head, head_len, tail, tail_len, param->cmd);
|
||||
- ret = -1;
|
||||
- }
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
|
||||
- free(param);
|
||||
+ if (drv->beacon_set)
|
||||
+ cmd = NL80211_CMD_SET_BEACON;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, cmd, 0);
|
||||
+ NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
|
||||
+ NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, 1000);
|
||||
+
|
||||
+ if (!drv->dtim_period)
|
||||
+ drv->dtim_period = 2;
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ drv->beacon_set = 1;
|
||||
+
|
||||
+ out:
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -985,15 +994,59 @@ static int i802_set_internal_bridge(void
|
||||
static int i802_set_beacon_int(void *priv, int value)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- return hostap_ioctl_prism2param(drv, PRISM2_PARAM_BEACON_INT, value);
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
+
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_SET_BEACON, 0);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
|
||||
+
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ out:
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
-static int i802_set_dtim_period(const char *ifname, void *priv, int value)
|
||||
+static int i802_set_dtim_period(const char *iface, void *priv, int value)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- return hostap_ioctl_prism2param_iface(ifname, drv,
|
||||
- PRISM2_PARAM_DTIM_PERIOD, value);
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
+
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_SET_BEACON, 0);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
|
||||
+
|
||||
+ drv->dtim_period = value;
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ out:
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
---
|
||||
hostapd/driver_devicescape.c | 96 ++++++++++++++++++++++++++++++++++---------
|
||||
1 file changed, 76 insertions(+), 20 deletions(-)
|
||||
|
||||
--- hostap.orig/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
|
||||
+++ hostap/hostapd/driver_devicescape.c 2007-11-09 13:41:14.000000000 +0100
|
||||
@@ -228,33 +228,89 @@ static int i802_set_encryption(const cha
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static inline int min_int(int a, int b)
|
||||
+{
|
||||
+ if (a<b)
|
||||
+ return a;
|
||||
+ return b;
|
||||
+}
|
||||
+
|
||||
+static int get_key_handler(struct nl_msg *msg, void *arg)
|
||||
+{
|
||||
+ struct nlattr *tb[NL80211_ATTR_MAX];
|
||||
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
|
||||
+
|
||||
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
|
||||
+ genlmsg_attrlen(gnlh, 0), NULL);
|
||||
+
|
||||
+ /*
|
||||
+ * TODO: validate the key index and mac address!
|
||||
+ * Otherwise, there's a race condition as soon as
|
||||
+ * the kernel starts sending key notifications.
|
||||
+ */
|
||||
+
|
||||
+ if (tb[NL80211_ATTR_KEY_SEQ])
|
||||
+ memcpy(arg, nla_data(tb[NL80211_ATTR_KEY_SEQ]),
|
||||
+ min_int(nla_len(tb[NL80211_ATTR_KEY_SEQ]), 6));
|
||||
+ return NL_SKIP;
|
||||
+}
|
||||
+
|
||||
+static int ack_wait_handler(struct nl_msg *msg, void *arg)
|
||||
+{
|
||||
+ int *finished = arg;
|
||||
+
|
||||
+ *finished = 1;
|
||||
+ return NL_STOP;
|
||||
+}
|
||||
|
||||
static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
|
||||
int idx, u8 *seq)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param *param;
|
||||
- size_t param_len;
|
||||
- int ret;
|
||||
+ struct nl_msg *msg;
|
||||
+ struct nl_cb *cb = NULL;
|
||||
+ int ret = -1;
|
||||
+ int err = 0;
|
||||
+ int finished = 0;
|
||||
|
||||
- param_len = sizeof(struct prism2_hostapd_param) + 32;
|
||||
- param = os_zalloc(param_len);
|
||||
- if (param == NULL)
|
||||
- return -1;
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
|
||||
- param->cmd = PRISM2_GET_ENCRYPTION;
|
||||
- if (addr == NULL)
|
||||
- memset(param->sta_addr, 0xff, ETH_ALEN);
|
||||
- else
|
||||
- memcpy(param->sta_addr, addr, ETH_ALEN);
|
||||
- param->u.crypt.idx = idx;
|
||||
-
|
||||
- ret = hostapd_ioctl_iface(iface, drv, param, param_len);
|
||||
- if (ret == 0) {
|
||||
- memcpy(seq, param->u.crypt.seq_counter,
|
||||
- HOSTAP_SEQ_COUNTER_SIZE);
|
||||
- }
|
||||
- free(param);
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_GET_KEY, 0);
|
||||
+
|
||||
+ if (addr)
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+ NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
|
||||
+
|
||||
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
|
||||
+ if (!cb)
|
||||
+ goto out;
|
||||
+
|
||||
+ memset(seq, 0, 6);
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_key_handler, seq);
|
||||
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, &finished);
|
||||
+
|
||||
+ err = nl_recvmsgs(drv->nl_handle, cb);
|
||||
+
|
||||
+ if (!finished)
|
||||
+ err = nl_wait_for_ack(drv->nl_handle);
|
||||
+
|
||||
+ if (err < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ out:
|
||||
+ nl_cb_put(cb);
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,413 +0,0 @@
|
|||
---
|
||||
hostapd/driver_devicescape.c | 332 ++++++++++++++++++++++++++++++++-----------
|
||||
1 file changed, 251 insertions(+), 81 deletions(-)
|
||||
|
||||
--- hostap.orig/hostapd/driver_devicescape.c 2007-11-14 17:31:15.000000000 +0100
|
||||
+++ hostap/hostapd/driver_devicescape.c 2007-11-14 17:31:16.000000000 +0100
|
||||
@@ -75,8 +75,14 @@ struct i802_driver_data {
|
||||
|
||||
#define HAPD_DECL struct hostapd_data *hapd = iface->bss[0]
|
||||
|
||||
-static int i802_sta_set_flags(void *priv, const u8 *addr,
|
||||
- int total_flags, int flags_or, int flags_and);
|
||||
+/* helper for netlink get routines */
|
||||
+static int ack_wait_handler(struct nl_msg *msg, void *arg)
|
||||
+{
|
||||
+ int *finished = arg;
|
||||
+
|
||||
+ *finished = 1;
|
||||
+ return NL_STOP;
|
||||
+}
|
||||
|
||||
|
||||
static int hostapd_set_iface_flags(struct i802_driver_data *drv, int dev_up)
|
||||
@@ -255,14 +261,6 @@ static int get_key_handler(struct nl_msg
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
-static int ack_wait_handler(struct nl_msg *msg, void *arg)
|
||||
-{
|
||||
- int *finished = arg;
|
||||
-
|
||||
- *finished = 1;
|
||||
- return NL_STOP;
|
||||
-}
|
||||
-
|
||||
static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
|
||||
int idx, u8 *seq)
|
||||
{
|
||||
@@ -629,43 +627,126 @@ static int i802_get_retry(void *priv, in
|
||||
static int i802_flush(void *priv)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_FLUSH;
|
||||
- return hostapd_ioctl(drv, ¶m, sizeof(param));
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_NEW_STATION, 0);
|
||||
+
|
||||
+ /*
|
||||
+ * XXX: FIX! this needs to flush all VLANs too
|
||||
+ */
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
|
||||
+ if_nametoindex(drv->iface));
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0) {
|
||||
+ ret = -1;
|
||||
+ }
|
||||
+
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+
|
||||
+ out:
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
+static int get_sta_handler(struct nl_msg *msg, void *arg)
|
||||
+{
|
||||
+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
|
||||
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
|
||||
+ struct hostap_sta_driver_data *data = arg;
|
||||
+ struct nlattr *stats[NL80211_STA_STAT_MAX + 1];
|
||||
+ static struct nla_policy stats_policy[NL80211_STA_STAT_MAX + 1] = {
|
||||
+ [NL80211_STA_STAT_INACTIVE_TIME] = { .type = NLA_U32 },
|
||||
+ [NL80211_STA_STAT_RX_BYTES] = { .type = NLA_U32 },
|
||||
+ [NL80211_STA_STAT_TX_BYTES] = { .type = NLA_U32 },
|
||||
+ };
|
||||
+
|
||||
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
|
||||
+ genlmsg_attrlen(gnlh, 0), NULL);
|
||||
+
|
||||
+ /*
|
||||
+ * TODO: validate the interface and mac address!
|
||||
+ * Otherwise, there's a race condition as soon as
|
||||
+ * the kernel starts sending station notifications.
|
||||
+ */
|
||||
+
|
||||
+ if (!tb[NL80211_ATTR_STA_STATS]) {
|
||||
+ printf("sta stats missing!\n");
|
||||
+ return NL_SKIP;
|
||||
+ }
|
||||
+ if (nla_parse_nested(stats, NL80211_STA_STAT_MAX,
|
||||
+ tb[NL80211_ATTR_STA_STATS],
|
||||
+ stats_policy)) {
|
||||
+ printf("failed to parse nested attributes!\n");
|
||||
+ return NL_SKIP;
|
||||
+ }
|
||||
+
|
||||
+ if (stats[NL80211_STA_STAT_INACTIVE_TIME])
|
||||
+ data->inactive_msec =
|
||||
+ nla_get_u32(stats[NL80211_STA_STAT_INACTIVE_TIME]);
|
||||
+ if (stats[NL80211_STA_STAT_RX_BYTES])
|
||||
+ data->rx_bytes = nla_get_u32(stats[NL80211_STA_STAT_RX_BYTES]);
|
||||
+ if (stats[NL80211_STA_STAT_TX_BYTES])
|
||||
+ data->rx_bytes = nla_get_u32(stats[NL80211_STA_STAT_TX_BYTES]);
|
||||
+
|
||||
+ return NL_SKIP;
|
||||
+}
|
||||
+
|
||||
static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data,
|
||||
const u8 *addr)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
+ struct nl_msg *msg;
|
||||
+ struct nl_cb *cb = NULL;
|
||||
+ int ret = -1;
|
||||
+ int err = 0;
|
||||
+ int finished = 0;
|
||||
+
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
|
||||
- memset(data, 0, sizeof(*data));
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_GET_STATION, 0);
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_GET_INFO_STA;
|
||||
- memcpy(param.sta_addr, addr, ETH_ALEN);
|
||||
- if (hostapd_ioctl(drv, ¶m, sizeof(param))) {
|
||||
- printf(" Could not get station info from kernel driver.\n");
|
||||
- return -1;
|
||||
- }
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
|
||||
+
|
||||
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
|
||||
+ if (!cb)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_sta_handler, data);
|
||||
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, &finished);
|
||||
+
|
||||
+ err = nl_recvmsgs(drv->nl_handle, cb);
|
||||
+
|
||||
+ if (!finished)
|
||||
+ err = nl_wait_for_ack(drv->nl_handle);
|
||||
+
|
||||
+ if (err < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ out:
|
||||
+ nl_cb_put(cb);
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+ return ret;
|
||||
|
||||
- data->inactive_msec = param.u.get_info_sta.inactive_msec;
|
||||
- data->rx_packets = param.u.get_info_sta.rx_packets;
|
||||
- data->tx_packets = param.u.get_info_sta.tx_packets;
|
||||
- data->rx_bytes = param.u.get_info_sta.rx_bytes;
|
||||
- data->tx_bytes = param.u.get_info_sta.tx_bytes;
|
||||
- data->current_tx_rate = param.u.get_info_sta.current_tx_rate;
|
||||
- data->flags = param.u.get_info_sta.flags;
|
||||
- data->num_ps_buf_frames = param.u.get_info_sta.num_ps_buf_frames;
|
||||
- data->tx_retry_failed = param.u.get_info_sta.tx_retry_failed;
|
||||
- data->tx_retry_count = param.u.get_info_sta.tx_retry_count;
|
||||
- data->last_rssi = param.u.get_info_sta.last_rssi;
|
||||
- data->last_ack_rssi = param.u.get_info_sta.last_ack_rssi;
|
||||
- return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -744,35 +825,70 @@ static int i802_sta_add(const char *ifna
|
||||
size_t supp_rates_len, int flags)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
- size_t len;
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_ADD_STA;
|
||||
- memcpy(param.sta_addr, addr, ETH_ALEN);
|
||||
- param.u.add_sta.aid = aid;
|
||||
- param.u.add_sta.capability = capability;
|
||||
- len = supp_rates_len;
|
||||
- if (len > sizeof(param.u.add_sta.supp_rates))
|
||||
- len = sizeof(param.u.add_sta.supp_rates);
|
||||
- memcpy(param.u.add_sta.supp_rates, supp_rates, len);
|
||||
- return hostapd_ioctl_iface(ifname, drv, ¶m, sizeof(param));
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_NEW_STATION, 0);
|
||||
+
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
|
||||
+ if_nametoindex(drv->iface));
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+ NLA_PUT_U16(msg, NL80211_ATTR_STA_AID, aid);
|
||||
+ NLA_PUT(msg, NL80211_ATTR_STA_SUPPORTED_RATES, supp_rates_len,
|
||||
+ supp_rates);
|
||||
+ NLA_PUT_U16(msg, NL80211_ATTR_STA_LISTEN_INTERVAL, 0);
|
||||
+
|
||||
+ ret = nl_send_auto_complete(drv->nl_handle, msg);
|
||||
+ if (ret < 0)
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
+ ret = nl_wait_for_ack(drv->nl_handle);
|
||||
+ /* ignore EEXIST, this happens if a STA associates while associated */
|
||||
+ if (ret == -EEXIST || ret >= 0)
|
||||
+ ret = 0;
|
||||
+
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+
|
||||
+ out:
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
static int i802_sta_remove(void *priv, const u8 *addr)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
|
||||
- i802_sta_set_flags(drv, addr, 0, 0, ~WLAN_STA_AUTHORIZED);
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_REMOVE_STA;
|
||||
- memcpy(param.sta_addr, addr, ETH_ALEN);
|
||||
- if (hostapd_ioctl(drv, ¶m, sizeof(param)))
|
||||
- return -1;
|
||||
- return 0;
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_DEL_STATION, 0);
|
||||
+
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
|
||||
+ if_nametoindex(drv->iface));
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0) {
|
||||
+ ret = -1;
|
||||
+ }
|
||||
+
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+
|
||||
+ out:
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -780,14 +896,51 @@ static int i802_sta_set_flags(void *priv
|
||||
int total_flags, int flags_or, int flags_and)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
+ struct nl_msg *msg, *flags = NULL;
|
||||
+ int ret = -1;
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_SET_FLAGS_STA;
|
||||
- memcpy(param.sta_addr, addr, ETH_ALEN);
|
||||
- param.u.set_flags_sta.flags_or = flags_or;
|
||||
- param.u.set_flags_sta.flags_and = flags_and;
|
||||
- return hostapd_ioctl(drv, ¶m, sizeof(param));
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
+
|
||||
+ flags = nlmsg_alloc();
|
||||
+ if (!flags)
|
||||
+ goto free_msg;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_SET_STATION, 0);
|
||||
+
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
|
||||
+ if_nametoindex(drv->iface));
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+
|
||||
+ if (total_flags & WLAN_STA_AUTHORIZED)
|
||||
+ NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED);
|
||||
+
|
||||
+ if (total_flags & WLAN_STA_WME)
|
||||
+ NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME);
|
||||
+
|
||||
+ if (total_flags & WLAN_STA_SHORT_PREAMBLE)
|
||||
+ NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE);
|
||||
+
|
||||
+ if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags))
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0) {
|
||||
+ ret = -1;
|
||||
+ }
|
||||
+
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(flags);
|
||||
+
|
||||
+ free_msg:
|
||||
+ nlmsg_free(msg);
|
||||
+
|
||||
+ out:
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1257,18 +1410,38 @@ static struct hostapd_hw_modes * i802_ge
|
||||
}
|
||||
|
||||
|
||||
-static int i802_set_sta_vlan(void *priv, const u8 *addr, const char *ifname,
|
||||
- int vlan_id)
|
||||
+static int i802_set_sta_vlan(void *priv, const u8 *addr,
|
||||
+ const char *ifname, int vlan_id)
|
||||
{
|
||||
struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
+ struct nl_msg *msg;
|
||||
+ int ret = -1;
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_SET_STA_VLAN;
|
||||
- memcpy(param.sta_addr, addr, ETH_ALEN);
|
||||
- os_strlcpy(param.u.set_sta_vlan.vlan_name, ifname, IFNAMSIZ);
|
||||
- param.u.set_sta_vlan.vlan_id = vlan_id;
|
||||
- return hostapd_ioctl(drv, ¶m, sizeof(param));
|
||||
+ msg = nlmsg_alloc();
|
||||
+ if (!msg)
|
||||
+ goto out;
|
||||
+
|
||||
+ genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
|
||||
+ 0, NL80211_CMD_SET_STATION, 0);
|
||||
+
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
|
||||
+ if_nametoindex(drv->iface));
|
||||
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
|
||||
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
|
||||
+ if_nametoindex(ifname));
|
||||
+
|
||||
+ ret = 0;
|
||||
+
|
||||
+ if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
|
||||
+ nl_wait_for_ack(drv->nl_handle) < 0) {
|
||||
+ ret = -1;
|
||||
+ }
|
||||
+
|
||||
+ nla_put_failure:
|
||||
+ nlmsg_free(msg);
|
||||
+
|
||||
+ out:
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1752,17 +1925,14 @@ static int i802_init_sockets(struct i802
|
||||
|
||||
static int i802_get_inact_sec(void *priv, const u8 *addr)
|
||||
{
|
||||
- struct i802_driver_data *drv = priv;
|
||||
- struct prism2_hostapd_param param;
|
||||
+ struct hostap_sta_driver_data data;
|
||||
+ int ret;
|
||||
|
||||
- memset(¶m, 0, sizeof(param));
|
||||
- param.cmd = PRISM2_HOSTAPD_GET_INFO_STA;
|
||||
- memcpy(param.sta_addr, addr, ETH_ALEN);
|
||||
- if (hostapd_ioctl(drv, ¶m, sizeof(param))) {
|
||||
+ data.inactive_msec = -1;
|
||||
+ ret = i802_read_sta_data(priv, &data, addr);
|
||||
+ if (ret || data.inactive_msec == -1)
|
||||
return -1;
|
||||
- }
|
||||
-
|
||||
- return param.u.get_info_sta.inactive_msec / 1000;
|
||||
+ return data.inactive_msec / 1000;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue