iwlib.h

来自「AMLOGIC DPF source code」· C头文件 代码 · 共 360 行

H
360
字号
/******************************************************************* * *  Copyright (c) 2006 Amlogic, Inc. All Rights Reserved. * *  Description: Wireless configuration library based on  *  Linux wireless tool v28. * *  Author: Jerry Cao *  Created: Mon Nov 7 15:15:16 2006 * *******************************************************************//* *	Wireless Tools * *		Jean II - HPLB 97->99 - HPL 99->04 * * Common header for the Wireless Extension library... * * This file is released under the GPL license. *     Copyright (c) 1997-2004 Jean Tourrilhes <jt@hpl.hp.com> */#ifndef IWLIB_H#define IWLIB_H/***************************** INCLUDES *****************************/#include "includes.h"#include "lwip/netif.h"#include <errno.h>#include <sys/socket.h>#include <sys/wireless.h>#include <net/iw_handler.h>/************************ CONSTANTS & MACROS ************************//* Various versions information *//* Recommended Wireless Extension version */#define WE_VERSION	20/* Maximum forward compatibility built in this version of WT */#define WE_MAX_VERSION	21/* Version of Wireless Tools */#define WT_VERSION	28/* Some usefull constants */#define KILO	1e3#define MEGA	1e6#define GIGA	1e9#define IW_SECURITY_NONE	0#define IW_SECURITY_WEP		1#define IW_SECURITY_WPA		2#define IW_SECURITY_WPA2	3/* For doing log10/exp10 without libm */#define LOG10_MAGIC	1.25892541179#define iw_get_kernel_we_version() WIRELESS_EXT/****************************** TYPES ******************************//* Shortcuts */typedef struct iw_statistics	iwstats;typedef struct iw_range		iwrange;typedef struct iw_param		iwparam;typedef struct iw_freq		iwfreq;typedef struct iw_quality	iwqual;typedef struct iw_priv_args	iwprivargs;typedef struct sockaddr		sockaddr;/* Structure for storing all wireless information for each device * This is a cut down version of the one above, containing only * the things *truly* needed to configure a card. * Don't add other junk, I'll remove it... */typedef struct wireless_config{  char		name[IFNAMSIZ + 1];	/* Wireless/protocol name */  int		has_nwid;  iwparam	nwid;			/* Network ID */  int		has_freq;  double	freq;			/* Frequency/channel */  int		freq_flags;  int		has_key;  unsigned char	key[IW_ENCODING_TOKEN_MAX];	/* Encoding key used */  int		key_size;		/* Number of bytes */  int		key_flags;		/* Various flags */  int		has_essid;  int		essid_on;  char		essid[IW_ESSID_MAX_SIZE + 1];	/* ESSID (extended network) */  int		has_mode;  int		mode;			/* Operation mode */} wireless_config;/* Structure for storing all wireless information for each device * This is pretty exhaustive... */typedef struct wireless_info{  struct wireless_config	b;	/* Basic information */  int		has_sens;  iwparam	sens;			/* sensitivity */  int		has_nickname;  char		nickname[IW_ESSID_MAX_SIZE + 1]; /* NickName */  int		has_ap_addr;  sockaddr	ap_addr;		/* Access point address */  int		has_bitrate;  iwparam	bitrate;		/* Bit rate in bps */  int		has_rts;  iwparam	rts;			/* RTS threshold in bytes */  int		has_frag;  iwparam	frag;			/* Fragmentation threshold in bytes */  int		has_power;  iwparam	power;			/* Power management parameters */  int		has_txpower;  iwparam	txpower;		/* Transmit Power in dBm */  int		has_retry;  iwparam	retry;			/* Retry limit or lifetime */  /* Stats */  iwstats	stats;  int		has_stats;  iwrange	range;  int		has_range;  /* Auth params for WPA/802.1x/802.11i */  int		auth_key_mgmt;  int		has_auth_key_mgmt;  int		auth_cipher_pairwise;  int		has_auth_cipher_pairwise;  int		auth_cipher_group;  int		has_auth_cipher_group;} wireless_info;/* Structure for storing an entry of a wireless scan. * This is only a subset of all possible information, the flexible * structure of scan results make it impossible to capture all * information in such a static structure. */typedef struct wireless_scan{  /* Linked list */  struct wireless_scan *	next;  /* Cell identifiaction */  int		has_ap_addr;  sockaddr	ap_addr;		/* Access point address */  /* Other information */  struct wireless_config	b;	/* Basic information */  iwstats	stats;			/* Signal strength */  int		has_stats;  int       has_security;	/* AVOS extension. IW_SECURITY_* type. */} wireless_scan;/* Structure used for parsing event streams, such as Wireless Events * and scan results */typedef struct stream_descr{  char *	end;		/* End of the stream */  char *	current;	/* Current event in stream of events */  char *	value;		/* Current value in event */} stream_descr;struct ether_addr{    unsigned char ether_addr_octet[6];};typedef void (*iw_notify_func) (void *state);/* * Scan state and meta-information, used to decode events... */typedef struct iwscan_state{    char ifname[IFNAMSIZ + 1];      /* Interface name, ignored for now. */    int delay;                      /* Scan period. */    int interval;                   /* Notification interval. */    int progress;                   /* Current progress. */    int errno;                      /* Errno in case of error. */    int has_range;    struct iw_range range;          /* Wireless range information. */    struct wireless_scan *scan;		/* Scan result. */    iw_notify_func notify_func;     /* Notification function pointer. */    void *cookie;                   /* Application cookie. */    AVTimer_t timer;                /* Timer handler. */} iwscan_state;/* * */typedef struct iwconfig_state{  char		name[IFNAMSIZ + 1];	/* Wireless interface name */  int		has_channel;  int		channel;			/* Channel */  int		has_key;  unsigned char	key[IW_ENCODING_TOKEN_MAX];	/* Encoding key used */  int		key_size;		/* Number of bytes */  int		key_flags;		/* Various flags */  int		has_essid;  int		essid_on;  char		essid[IW_ESSID_MAX_SIZE + 1];	/* ESSID (extended network) */  int		has_mode;  int		mode;			/* Operation mode */  /* Configuration status notification. */  int 		timeout;        /* Scan period. */  int 		interval;       /* Notification interval. */  int 		progress;       /* Current progress. */  int 		errno;          /* Errno in case of error. */  AVTimer_t timer;  iw_notify_func notify_func;     /* Notification function pointer. */} iwconfig_state;/**************************** PROTOTYPES ****************************//* --------------------- WIRELESS SUBROUTINES ----------------------*/int	iw_get_range_info(const char *ifname,                      iwrange *range);int	iw_get_basic_config(const char *ifname,                        wireless_config *info);int	iw_set_basic_config(const char *ifname,                        wireless_config *info);/* -------------------- FREQUENCY SUBROUTINES --------------------- */void	iw_float2freq(double in,                  iwfreq *out);double	iw_freq2float(const iwfreq *in);void	iw_print_freq(char *buffer,                  int buflen,                  double freq,                  int channel,                  int freq_flags);int	iw_freq_to_channel(double freq,                       const struct iw_range *range);int	iw_channel_to_freq(int channel,                       double *pfreq,                       const struct iw_range *range);/* --------------------- ENCODING SUBROUTINES --------------------- */void	iw_print_key(char *			buffer,                 int			buflen,                 const unsigned char *	key,                 int			key_size,                 int			key_flags);int	iw_in_key(const char *		input,              unsigned char *	key);/* --------------------- ADDRESS SUBROUTINES ---------------------- */int	iw_check_mac_addr_type(const char *	ifname);char *	iw_mac_ntop(const unsigned char *	mac,		    int				maclen,		    char *			buf,		    int				buflen);void	iw_ether_ntop(const struct ether_addr *	eth,                  char *			buf);char *	iw_sawap_ntop(const struct sockaddr *	sap,                  char *			buf);char *	iw_saether_ntop(const struct sockaddr *sap, char* bufp);int	iw_mac_aton(const char *	orig,                unsigned char *	mac,                int			macmax);int	iw_saether_aton(const char *bufp, struct sockaddr *sap);int	iw_ether_aton(const char *orig, struct ether_addr *eth);void	iw_broad_ether(struct sockaddr *sap);void	iw_null_ether(struct sockaddr *sap);int	iw_ether_cmp(const struct ether_addr * eth1,                  const struct ether_addr * eth2);intiw_in_addr(const char *	ifname,           char *	bufp,           struct sockaddr *sap);/* ----------------------- MISC SUBROUTINES ------------------------ */int	iw_set_ext(const char *		ifname,               int			request,               struct iwreq *	pwrq);int	iw_get_ext(const char *		ifname,               int			request,               struct iwreq *	pwrq);/* ---------------------- EVENT SUBROUTINES ---------------------- */void	iw_init_event_stream(struct stream_descr *	stream,                         char *			data,                         int			len);int	iw_extract_event_stream(struct stream_descr *	stream,                            struct iw_event *	iwe,                            int			we_version);/* --------------------- SCANNING SUBROUTINES --------------------- */int	iw_read_scan(char *ifname,                 struct iwscan_state *state);int	iw_scan(char *ifname,            int delay,            int interval,            iw_notify_func notify_func,            struct iwscan_state *cookie);struct iwscan_state *	iw_create_scan(char *ifname);void	iw_free_scan(struct iwscan_state *state);void	iw_free_scan_list(struct iwscan_state *state);#if 0void	iw_print_scan(struct iwscan_state *state);#endif /* 0 *//************************* DISPLAY ROUTINES **************************/int	iw_get_info(char * ifname,                struct wireless_info * info);void	iw_display_info(struct wireless_info *info,                    char *ifname);int	iw_print_info(char *ifname);int	iw_set_info(char *		args[],                int			count,                char *		ifname);int	iw_set_config(struct iwconfig_state *config,                  iw_notify_func notify_func,                  void *cookie);/***************************** VARIABLES *****************************//* Modes as human readable strings */extern const char * const	iw_operation_mode[];#define IW_NUM_OPER_MODE	7#endif	/* IWLIB_H */

⌨️ 快捷键说明

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