iw_handler.h

来自「linux 内核源代码」· C头文件 代码 · 共 643 行 · 第 1/2 页

H
643
字号
 */struct iw_handler_def{	/* Number of handlers defined (more precisely, index of the	 * last defined handler + 1) */	__u16			num_standard;	__u16			num_private;	/* Number of private arg description */	__u16			num_private_args;	/* Array of handlers for standard ioctls	 * We will call dev->wireless_handlers->standard[ioctl - SIOCSIWCOMMIT]	 */	const iw_handler *	standard;	/* Array of handlers for private ioctls	 * Will call dev->wireless_handlers->private[ioctl - SIOCIWFIRSTPRIV]	 */	const iw_handler *	private;	/* Arguments of private handler. This one is just a list, so you	 * can put it in any order you want and should not leave holes...	 * We will automatically export that to user space... */	const struct iw_priv_args *	private_args;	/* 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... */	struct iw_statistics*	(*get_wireless_stats)(struct net_device *dev);};/* ---------------------- IOCTL DESCRIPTION ---------------------- *//* * One of the main goal of the new interface is to deal entirely with * user space/kernel space memory move. * For that, we need to know : *	o if iwreq is a pointer or contain the full data *	o what is the size of the data to copy * * For private IOCTLs, we use the same rules as used by iwpriv and * defined in struct iw_priv_args. * * For standard IOCTLs, things are quite different and we need to * use the stuctures below. Actually, this struct is also more * efficient, but that's another story... *//* * Describe how a standard IOCTL looks like. */struct iw_ioctl_description{	__u8	header_type;		/* NULL, iw_point or other */	__u8	token_type;		/* Future */	__u16	token_size;		/* Granularity of payload */	__u16	min_tokens;		/* Min acceptable token number */	__u16	max_tokens;		/* Max acceptable token number */	__u32	flags;			/* Special handling of the request */};/* Need to think of short header translation table. Later. *//* --------------------- ENHANCED SPY SUPPORT --------------------- *//* * In the old days, the driver was handling spy support all by itself. * Now, the driver can delegate this task to Wireless Extensions. * It needs to include this struct in its private part and use the * standard spy iw_handler. *//* * Instance specific spy data, i.e. addresses spied and quality for them. */struct iw_spy_data{	/* --- Standard spy support --- */	int			spy_number;	u_char			spy_address[IW_MAX_SPY][ETH_ALEN];	struct iw_quality	spy_stat[IW_MAX_SPY];	/* --- Enhanced spy support (event) */	struct iw_quality	spy_thr_low;	/* Low threshold */	struct iw_quality	spy_thr_high;	/* High threshold */	u_char			spy_thr_under[IW_MAX_SPY];};/* --------------------- DEVICE WIRELESS DATA --------------------- *//* * This is all the wireless data specific to a device instance that * 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;	/* Structure managed by the in-kernel IEEE 802.11 layer */	struct ieee80211_device *	ieee80211;};/**************************** PROTOTYPES ****************************//* * Functions part of the Wireless Extensions (defined in net/core/wireless.c). * Those may be called only within the kernel. *//* First : function strictly used inside the kernel *//* Handle /proc/net/wireless, called in net/code/dev.c */extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,				 int length);/* Second : functions that may be called by driver modules *//* 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... *//* Standard handler for SIOCSIWSPY */extern int iw_handler_set_spy(struct net_device *	dev,			      struct iw_request_info *	info,			      union iwreq_data *	wrqu,			      char *			extra);/* Standard handler for SIOCGIWSPY */extern int iw_handler_get_spy(struct net_device *	dev,			      struct iw_request_info *	info,			      union iwreq_data *	wrqu,			      char *			extra);/* Standard handler for SIOCSIWTHRSPY */extern int iw_handler_set_thrspy(struct net_device *	dev,				 struct iw_request_info *info,				 union iwreq_data *	wrqu,				 char *			extra);/* Standard handler for SIOCGIWTHRSPY */extern int iw_handler_get_thrspy(struct net_device *	dev,				 struct iw_request_info *info,				 union iwreq_data *	wrqu,				 char *			extra);/* Driver call to update spy records */extern void wireless_spy_update(struct net_device *	dev,				unsigned char *		address,				struct iw_quality *	wstats);/************************* 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(likely((stream + event_len) < ends)) {		iwe->len = event_len;		/* Beware of alignement issues on 64 bits */		memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);		memcpy(stream + IW_EV_LCP_LEN,		       ((char *) iwe) + IW_EV_LCP_LEN,		       event_len - IW_EV_LCP_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 length + flags */		     char *	extra)		/* More payload */{	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_PK_LEN);		memcpy(stream + IW_EV_LCP_LEN,		       ((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF,		       IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_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(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);	}	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;		/* Beware of alignement issues on 64 bits */		memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);		memcpy(stream + IW_EV_LCP_LEN,		       ((char *) iwe) + IW_EV_LCP_LEN,		       event_len - IW_EV_LCP_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_PK_LEN);		memcpy(stream + IW_EV_LCP_LEN,		       ((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF,		       IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_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 */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?