Commit a31ea717 authored by Jean Tourrilhes's avatar Jean Tourrilhes Committed by Linus Torvalds

[PATCH] New wireless driver API part 2

	Quick summary : this patch build on the first part to offer
two important new features :
		o Wireless Events
		o Wireless Cell Scanning
	Wireless Events are events generated by device, driver or the
wireless subsystem. It allows for example a device to notify user
space when it register to a new cell (roaming) or loose contact with
the current Access Points. Currently, the other defined events include
some configuration changes and packet drop due to excessive retries,
more may come in the future. All those events are useful for MobileIP,
V-Handoff and Ad-Hoc routing.
	Wireless Cell Scanning is a generic API to allow device/drive
to report Wireless Cells discovered (including ESSID, frequency and
QoS). This is similar to what is available in WindowsXP (except that
it's compliant to Wireless Extensions).

	This patch has been submitted for review on this list a couple
of time in January, has been on my web page since and used intensively
by other people. It was rediffed to 2.5.6. Driver patches have been
submitted to maintainers.
parent 9fbca834
......@@ -440,12 +440,14 @@ enum
#define IFLA_COST IFLA_COST
IFLA_PRIORITY,
#define IFLA_PRIORITY IFLA_PRIORITY
IFLA_MASTER
IFLA_MASTER,
#define IFLA_MASTER IFLA_MASTER
IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
#define IFLA_WIRELESS IFLA_WIRELESS
};
#define IFLA_MAX IFLA_MASTER
#define IFLA_MAX IFLA_WIRELESS
#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
......
/*
* This file define a set of standard wireless extensions
*
* Version : 13 6.12.01
* Version : 14 25.1.02
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
* Copyright (c) 1997-2001 Jean Tourrilhes, All Rights Reserved.
* Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
*/
#ifndef _LINUX_WIRELESS_H
......@@ -40,7 +40,7 @@
* # include/linux/netdevice.h (one place)
* # include/linux/proc_fs.h (one place)
*
* New driver API (2001 -> onward) :
* New driver API (2002 -> onward) :
* -------------------------------
* This file is only concerned with the user space API and common definitions.
* The new driver API is defined and documented in :
......@@ -49,6 +49,11 @@
* Note as well that /proc/net/wireless implementation has now moved in :
* # include/linux/wireless.c
*
* Wireless Events (2002 -> onward) :
* --------------------------------
* Events are defined at the end of this file, and implemented in :
* # include/linux/wireless.c
*
* Other comments :
* --------------
* Do not add here things that are redundant with other mechanisms
......@@ -75,7 +80,7 @@
* (there is some stuff that will be added in the future...)
* I just plan to increment with each new version.
*/
#define WIRELESS_EXT 13
#define WIRELESS_EXT 14
/*
* Changes :
......@@ -141,6 +146,13 @@
* - Document creation of new driver API.
* - Extract union iwreq_data from struct iwreq (for new driver API).
* - Rename SIOCSIWNAME as SIOCSIWCOMMIT
*
* V13 to V14
* ----------
* - Wireless Events support : define struct iw_event
* - Define additional specific event numbers
* - Add "addr" and "param" fields in union iwreq_data
* - AP scanning stuff (SIOCSIWSCAN and friends)
*/
/**************************** CONSTANTS ****************************/
......@@ -175,6 +187,8 @@
#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
#define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
#define SIOCSIWSCAN 0x8B18 /* trigger scanning */
#define SIOCGIWSCAN 0x8B19 /* get scanning results */
/* 802.11 specific support */
#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
......@@ -238,6 +252,15 @@
#define IW_IS_SET(cmd) (!((cmd) & 0x1))
#define IW_IS_GET(cmd) ((cmd) & 0x1)
/* ----------------------- WIRELESS EVENTS ----------------------- */
/* Those are *NOT* ioctls, do not issue request on them !!! */
/* Most events use the same identifier as ioctl requests */
#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
#define IWEVQUAL 0x8C01 /* Quality part of statistics */
#define IWEVFIRST 0x8C00
/* ------------------------- PRIVATE INFO ------------------------- */
/*
* The following is used with SIOCGIWPRIV. It allow a driver to define
......@@ -340,6 +363,19 @@
#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
/* Scanning request flags */
#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
/* Maximum size of returned data */
#define IW_SCAN_MAX_DATA 4096 /* In bytes */
/****************************** TYPES ******************************/
/* --------------------------- SUBTYPES --------------------------- */
......@@ -466,9 +502,12 @@ union iwreq_data
struct iw_point encoding; /* Encoding stuff : tokens */
struct iw_param power; /* PM duration/timeout */
struct iw_quality qual; /* Quality part of statistics */
struct sockaddr ap_addr; /* Access point address */
struct sockaddr addr; /* Destination address (hw) */
struct iw_param param; /* Other small parameters */
struct iw_point data; /* Other large parameters */
};
......@@ -596,4 +635,35 @@ struct iw_priv_args
char name[IFNAMSIZ]; /* Name of the extension */
};
/* ----------------------- WIRELESS EVENTS ----------------------- */
/*
* Wireless events are carried through the rtnetlink socket to user
* space. They are encapsulated in the IFLA_WIRELESS field of
* a RTM_NEWLINK message.
*/
/*
* A Wireless Event. Contains basically the same data as the ioctl...
*/
struct iw_event
{
__u16 len; /* Real lenght of this stuff */
__u16 cmd; /* Wireless IOCTL */
union iwreq_data u; /* IOCTL fixed payload */
};
/* Size of the Event prefix (including padding and alignement junk) */
#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
/* Size of the various events */
#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 */
#endif /* _LINUX_WIRELESS_H */
/*
* This file define the new driver API for Wireless Extensions
*
* Version : 2 6.12.01
* Version : 3 17.1.02
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
* Copyright (c) 2001 Jean Tourrilhes, All Rights Reserved.
* Copyright (c) 2001-2002 Jean Tourrilhes, All Rights Reserved.
*/
#ifndef _IW_HANDLER_H
......@@ -33,7 +33,7 @@
* o The user space interface is tied to ioctl because of the use
* copy_to/from_user.
*
* New driver API (2001 -> onward) :
* New driver API (2002 -> onward) :
* -------------------------------
* The new driver API is just a bunch of standard functions (handlers),
* each handling a specific Wireless Extension. The driver just export
......@@ -206,7 +206,18 @@
* will be needed...
* I just plan to increment with each new version.
*/
#define IW_HANDLER_VERSION 2
#define IW_HANDLER_VERSION 3
/*
* Changes :
*
* V2 to V3
* --------
* - Move event definition in <linux/wireless.h>
* - Add Wireless Event support :
* o wireless_send_event() prototype
* o iwe_stream_add_event/point() inline functions
*/
/**************************** CONSTANTS ****************************/
......@@ -225,6 +236,7 @@
#define IW_HEADER_TYPE_POINT 6 /* struct iw_point */
#define IW_HEADER_TYPE_PARAM 7 /* struct iw_param */
#define IW_HEADER_TYPE_ADDR 8 /* struct sockaddr */
#define IW_HEADER_TYPE_QUAL 9 /* struct iw_quality */
/* Handling flags */
/* Most are not implemented. I just use them as a reminder of some
......@@ -303,25 +315,6 @@ struct iw_handler_def
* 'struct net_device' to here, to minimise bloat. */
};
/* ----------------------- WIRELESS EVENTS ----------------------- */
/*
* Currently we don't support events, so let's just plan for the
* future...
*/
/*
* A Wireless Event.
*/
// How do we define short header ? We don't want a flag on length.
// Probably a flag on event ? Highest bit to zero...
struct iw_event
{
__u16 length; /* Lenght of this stuff */
__u16 event; /* Wireless IOCTL */
union iwreq_data header; /* IOCTL fixed payload */
char extra[0]; /* Optional IOCTL data */
};
/* ---------------------- IOCTL DESCRIPTION ---------------------- */
/*
* One of the main goal of the new interface is to deal entirely with
......@@ -369,6 +362,88 @@ extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,
extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd);
/* Second : functions that may be called by driver modules */
/* None yet */
#endif /* _LINUX_WIRELESS_H */
/* Send a single event to user space */
extern void wireless_send_event(struct net_device * dev,
unsigned int cmd,
union iwreq_data * wrqu,
char * extra);
/* We may need a function to send a stream of events to user space.
* More on that later... */
/************************* INLINE FUNTIONS *************************/
/*
* Function that are so simple that it's more efficient inlining them
*/
/*------------------------------------------------------------------*/
/*
* Wrapper to add an Wireless Event to a stream of events.
*/
static inline char *
iwe_stream_add_event(char * stream, /* Stream of events */
char * ends, /* End of stream */
struct iw_event *iwe, /* Payload */
int event_len) /* Real size of payload */
{
/* Check if it's possible */
if((stream + event_len) < ends) {
iwe->len = event_len;
memcpy(stream, (char *) iwe, event_len);
stream += event_len;
}
return stream;
}
/*------------------------------------------------------------------*/
/*
* Wrapper to add an short Wireless Event containing a pointer to a
* 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)
{
int event_len = IW_EV_POINT_LEN + iwe->u.data.length;
/* Check if it's possible */
if((stream + event_len) < ends) {
iwe->len = event_len;
memcpy(stream, (char *) iwe, IW_EV_POINT_LEN);
memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length);
stream += event_len;
}
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).
*/
static inline char *
iwe_stream_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) /* Real size of payload */
{
/* Don't duplicate LCP */
event_len -= IW_EV_LCP_LEN;
/* Check if it's possible */
if((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);
}
return value;
}
#endif /* _IW_HANDLER_H */
This diff is collapsed.
......@@ -588,4 +588,11 @@ EXPORT_SYMBOL(register_gifconf);
EXPORT_SYMBOL(net_call_rx_atomic);
EXPORT_SYMBOL(softnet_data);
#if defined(CONFIG_NET_RADIO) || defined(CONFIG_NET_PCMCIA_RADIO)
/* Don't include the whole header mess for a single function */
union iwreq_data;
extern void wireless_send_event(struct net_device *dev, unsigned int cmd, union iwreq_data *wrqu, char *extra);
EXPORT_SYMBOL(wireless_send_event);
#endif /* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
#endif /* CONFIG_NET */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment