Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7574
b: refs/heads/master
c: 6582c16
h: refs/heads/master
v: v3
  • Loading branch information
Jean Tourrilhes authored and Jeff Garzik committed Sep 7, 2005
1 parent 9309e0b commit a894b46
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 54 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 054034dbf5b1a6aef800af4eb22d421d1c7d4b6d
refs/heads/master: 6582c164f2b3b6e58d1f13c1c031b19ee691eb14
47 changes: 33 additions & 14 deletions trunk/include/linux/wireless.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file define a set of standard wireless extensions
*
* Version : 18 12.3.05
* Version : 19 18.3.05
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
* Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
Expand Down Expand Up @@ -69,11 +69,12 @@

/***************************** INCLUDES *****************************/

/* To minimise problems in user space, I might remove those headers
* at some point. Jean II */
#include <linux/types.h> /* for "caddr_t" et al */
#include <linux/socket.h> /* for "struct sockaddr" et al */
#include <linux/if.h> /* for IFNAMSIZ and co... */
/* Do not put any header in this file, this creates a mess when
* exported to user space. Most users have included all the
* relevant headers anyway... Jean II */
/*#include <linux/types.h>*/ /* for "caddr_t" et al */
/*#include <linux/socket.h>*/ /* for "struct sockaddr" et al */
/*#include <linux/if.h>*/ /* for IFNAMSIZ and co... */

/***************************** VERSION *****************************/
/*
Expand All @@ -82,7 +83,7 @@
* (there is some stuff that will be added in the future...)
* I just plan to increment with each new version.
*/
#define WIRELESS_EXT 18
#define WIRELESS_EXT 19

/*
* Changes :
Expand Down Expand Up @@ -197,6 +198,15 @@
* related parameters (extensible up to 4096 parameter values)
* - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
* IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
*
* V18 to V19
* ----------
* - Remove (struct iw_point *)->pointer from events and streams
* - Remove header includes to help user space
* - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
* - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
* - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
* - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
*/

/**************************** CONSTANTS ****************************/
Expand Down Expand Up @@ -322,6 +332,7 @@
/* The first and the last (range) */
#define SIOCIWFIRST 0x8B00
#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)

/* Even : get (world access), odd : set (root access) */
#define IW_IS_SET(cmd) (!((cmd) & 0x1))
Expand Down Expand Up @@ -366,6 +377,7 @@
* (struct iw_pmkid_cand) */

#define IWEVFIRST 0x8C00
#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)

/* ------------------------- PRIVATE INFO ------------------------- */
/*
Expand Down Expand Up @@ -427,12 +439,15 @@
#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */

/* Statistics flags (bitmask in updated) */
#define IW_QUAL_QUAL_UPDATED 0x1 /* Value was updated since last read */
#define IW_QUAL_LEVEL_UPDATED 0x2
#define IW_QUAL_NOISE_UPDATED 0x4
#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
#define IW_QUAL_LEVEL_UPDATED 0x02
#define IW_QUAL_NOISE_UPDATED 0x04
#define IW_QUAL_ALL_UPDATED 0x07
#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
#define IW_QUAL_LEVEL_INVALID 0x20
#define IW_QUAL_NOISE_INVALID 0x40
#define IW_QUAL_ALL_INVALID 0x70

/* Frequency flags */
#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
Expand All @@ -443,7 +458,7 @@
#define IW_MAX_ENCODING_SIZES 8

/* Maximum size of the encoding token in bytes */
#define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */

/* Flags for encoding (along with the token) */
#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
Expand Down Expand Up @@ -1039,12 +1054,16 @@ struct iw_event
#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))

/* Note : in the case of iw_point, the extra data will come at the
* end of the event */
/* iw_point events are special. First, the payload (extra data) come at
* the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
* we omit the pointer, so start at an offset. */
#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
(char *) NULL)
#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
IW_EV_POINT_OFF)

#endif /* _LINUX_WIRELESS_H */
123 changes: 108 additions & 15 deletions trunk/include/net/iw_handler.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* This file define the new driver API for Wireless Extensions
*
* Version : 6 21.6.04
* Version : 7 18.3.05
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
* Copyright (c) 2001-2004 Jean Tourrilhes, All Rights Reserved.
* Copyright (c) 2001-2005 Jean Tourrilhes, All Rights Reserved.
*/

#ifndef _IW_HANDLER_H
Expand Down Expand Up @@ -207,7 +207,7 @@
* will be needed...
* I just plan to increment with each new version.
*/
#define IW_HANDLER_VERSION 6
#define IW_HANDLER_VERSION 7

/*
* Changes :
Expand All @@ -232,6 +232,13 @@
* - Remove spy #ifdef, they are always on -> cleaner code
* - Add IW_DESCR_FLAG_NOMAX flag for very large requests
* - Start migrating get_wireless_stats to struct iw_handler_def
*
* V6 to V7
* --------
* - Add struct ieee80211_device pointer in struct iw_public_data
* - Remove (struct iw_point *)->pointer from events and streams
* - Remove spy_offset from struct iw_handler_def
* - Add "check" version of event macros for ieee802.11 stack
*/

/**************************** CONSTANTS ****************************/
Expand Down Expand Up @@ -334,9 +341,6 @@ struct iw_handler_def
* We will automatically export that to user space... */
const struct iw_priv_args * private_args;

/* This field will be *removed* in the next version of WE */
long spy_offset; /* DO NOT USE */

/* New location of get_wireless_stats, to de-bloat struct net_device.
* The old pointer in struct net_device will be gradually phased
* out, and drivers are encouraged to use this one... */
Expand Down Expand Up @@ -400,16 +404,21 @@ struct iw_spy_data
/* --------------------- DEVICE WIRELESS DATA --------------------- */
/*
* This is all the wireless data specific to a device instance that
* is managed by the core of Wireless Extensions.
* is managed by the core of Wireless Extensions or the 802.11 layer.
* We only keep pointer to those structures, so that a driver is free
* to share them between instances.
* This structure should be initialised before registering the device.
* Access to this data follow the same rules as any other struct net_device
* data (i.e. valid as long as struct net_device exist, same locking rules).
*/
/* Forward declaration */
struct ieee80211_device;
/* The struct */
struct iw_public_data {
/* Driver enhanced spy support */
struct iw_spy_data * spy_data;
struct iw_spy_data * spy_data;
/* Structure managed by the in-kernel IEEE 802.11 layer */
struct ieee80211_device * ieee80211;
};

/**************************** PROTOTYPES ****************************/
Expand All @@ -424,7 +433,7 @@ struct iw_public_data {
extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,
int length);

/* Handle IOCTLs, called in net/code/dev.c */
/* Handle IOCTLs, called in net/core/dev.c */
extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd);

/* Second : functions that may be called by driver modules */
Expand Down Expand Up @@ -479,7 +488,7 @@ iwe_stream_add_event(char * stream, /* Stream of events */
int event_len) /* Real size of payload */
{
/* Check if it's possible */
if((stream + event_len) < ends) {
if(likely((stream + event_len) < ends)) {
iwe->len = event_len;
memcpy(stream, (char *) iwe, event_len);
stream += event_len;
Expand All @@ -495,14 +504,17 @@ iwe_stream_add_event(char * stream, /* Stream of events */
static inline char *
iwe_stream_add_point(char * stream, /* Stream of events */
char * ends, /* End of stream */
struct iw_event *iwe, /* Payload */
char * extra)
struct iw_event *iwe, /* Payload length + flags */
char * extra) /* More payload */
{
int event_len = IW_EV_POINT_LEN + iwe->u.data.length;
/* Check if it's possible */
if((stream + event_len) < ends) {
if(likely((stream + event_len) < ends)) {
iwe->len = event_len;
memcpy(stream, (char *) iwe, IW_EV_POINT_LEN);
memcpy(stream, (char *) iwe, IW_EV_LCP_LEN);
memcpy(stream + IW_EV_LCP_LEN,
((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
IW_EV_POINT_LEN - IW_EV_LCP_LEN);
memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length);
stream += event_len;
}
Expand All @@ -526,7 +538,7 @@ iwe_stream_add_value(char * event, /* Event in the stream */
event_len -= IW_EV_LCP_LEN;

/* Check if it's possible */
if((value + event_len) < ends) {
if(likely((value + event_len) < ends)) {
/* Add new value */
memcpy(value, (char *) iwe + IW_EV_LCP_LEN, event_len);
value += event_len;
Expand All @@ -537,4 +549,85 @@ iwe_stream_add_value(char * event, /* Event in the stream */
return value;
}

/*------------------------------------------------------------------*/
/*
* Wrapper to add an Wireless Event to a stream of events.
* Same as above, with explicit error check...
*/
static inline char *
iwe_stream_check_add_event(char * stream, /* Stream of events */
char * ends, /* End of stream */
struct iw_event *iwe, /* Payload */
int event_len, /* Size of payload */
int * perr) /* Error report */
{
/* Check if it's possible, set error if not */
if(likely((stream + event_len) < ends)) {
iwe->len = event_len;
memcpy(stream, (char *) iwe, event_len);
stream += event_len;
} else
*perr = -E2BIG;
return stream;
}

/*------------------------------------------------------------------*/
/*
* Wrapper to add an short Wireless Event containing a pointer to a
* stream of events.
* Same as above, with explicit error check...
*/
static inline char *
iwe_stream_check_add_point(char * stream, /* Stream of events */
char * ends, /* End of stream */
struct iw_event *iwe, /* Payload length + flags */
char * extra, /* More payload */
int * perr) /* Error report */
{
int event_len = IW_EV_POINT_LEN + iwe->u.data.length;
/* Check if it's possible */
if(likely((stream + event_len) < ends)) {
iwe->len = event_len;
memcpy(stream, (char *) iwe, IW_EV_LCP_LEN);
memcpy(stream + IW_EV_LCP_LEN,
((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
IW_EV_POINT_LEN - IW_EV_LCP_LEN);
memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length);
stream += event_len;
} else
*perr = -E2BIG;
return stream;
}

/*------------------------------------------------------------------*/
/*
* Wrapper to add a value to a Wireless Event in a stream of events.
* Be careful, this one is tricky to use properly :
* At the first run, you need to have (value = event + IW_EV_LCP_LEN).
* Same as above, with explicit error check...
*/
static inline char *
iwe_stream_check_add_value(char * event, /* Event in the stream */
char * value, /* Value in event */
char * ends, /* End of stream */
struct iw_event *iwe, /* Payload */
int event_len, /* Size of payload */
int * perr) /* Error report */
{
/* Don't duplicate LCP */
event_len -= IW_EV_LCP_LEN;

/* Check if it's possible */
if(likely((value + event_len) < ends)) {
/* Add new value */
memcpy(value, (char *) iwe + IW_EV_LCP_LEN, event_len);
value += event_len;
/* Patch LCP */
iwe->len = value - event;
memcpy(event, (char *) iwe, IW_EV_LCP_LEN);
} else
*perr = -E2BIG;
return value;
}

#endif /* _IW_HANDLER_H */
Loading

0 comments on commit a894b46

Please sign in to comment.