⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wvlan_cs.c

📁 pcmcia source code
💻 C
📖 第 1 页 / 共 5 页
字号:
// Show CardServices error message (syslog)static void cs_error (client_handle_t handle, int func, int ret){	error_info_t err = { func, ret };	CardServices(ReportError, handle, &err);}/******************************************************************** * FUNCTION PROTOTYPES */static int wvlan_hw_setmaxdatalen (IFBP ifbp, int maxlen);static int wvlan_hw_getmacaddr (IFBP ifbp, char *mac, int len);static int wvlan_hw_getchannellist (IFBP ifbp);static int wvlan_hw_setporttype (IFBP ifbp, int ptype);static int wvlan_hw_getporttype (IFBP ifbp);static int wvlan_hw_setallowibssflag (IFBP ifbp, int flag);static int wvlan_hw_getallowibssflag (IFBP ifbp);static int wvlan_hw_setstationname (IFBP ifbp, char *name);static int wvlan_hw_getstationname (IFBP ifbp, char *name, int len);static int wvlan_hw_setssid (IFBP ifbp, char *name, int ptype);static int wvlan_hw_getssid (IFBP ifbp, char *name, int len, int cur, int ptype);static int wvlan_hw_getbssid (IFBP ifbp, char *mac, int len);static int wvlan_hw_setchannel (IFBP ifbp, int channel);static int wvlan_hw_getchannel (IFBP ifbp);static int wvlan_hw_getcurrentchannel (IFBP ifbp);static int wvlan_hw_setthreshold (IFBP ifbp, int thrh, int cmd);static int wvlan_hw_getthreshold (IFBP ifbp, int cmd);static int wvlan_hw_setbitrate (IFBP ifbp, int brate);static int wvlan_hw_getbitrate (IFBP ifbp, int cur);static int wvlan_hw_getratelist (IFBP ifbp, char *brlist, int len);#ifdef WIRELESS_EXTstatic int wvlan_hw_getfrequencylist (IFBP ifbp, iw_freq *list, int max);static int wvlan_getbitratelist (IFBP ifbp, __s32 *list, int max);static int wvlan_hw_setpower (IFBP ifbp, int enabled, int cmd);static int wvlan_hw_getpower (IFBP ifbp, int cmd);static int wvlan_hw_setpmsleep (IFBP ifbp, int duration);static int wvlan_hw_getpmsleep (IFBP ifbp);static int wvlan_hw_getprivacy (IFBP ifbp);static int wvlan_hw_setprivacy (IFBP ifbp, int mode, int transmit, KEY_STRCT *keys);#endif /* WIRELESS_EXT */static int wvlan_hw_setpromisc (IFBP ifbp, int promisc);static int wvlan_hw_getfirmware (IFBP ifbp, int *first, int *major, int *minor);static int wvlan_hw_config (struct net_device *dev);static int wvlan_hw_shutdown (struct net_device *dev);static int wvlan_hw_reset (struct net_device *dev);struct net_device_stats *wvlan_get_stats (struct net_device *dev);#ifdef WIRELESS_EXTint wvlan_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);struct iw_statistics *wvlan_get_wireless_stats (struct net_device *dev);#ifdef WIRELESS_SPYstatic inline void wvlan_spy_gather (struct net_device *dev, u_char *mac, u_char *stats);#endif#ifdef HISTOGRAMstatic inline void wvlan_his_gather (struct net_device *dev, u_char *stats);#endif#endif /* WIRELESS_EXT */int wvlan_change_mtu (struct net_device *dev, int new_mtu);static void wvlan_set_multicast_list (struct net_device *dev);static void wvlan_watchdog (struct net_device *dev);int wvlan_tx (struct sk_buff *skb, struct net_device *dev);void wvlan_rx (struct net_device *dev, int len);static int wvlan_open (struct net_device *dev);static int wvlan_close (struct net_device *dev);static void wvlan_interrupt (int irq, void *dev_id, struct pt_regs *regs);static int wvlan_config (dev_link_t *link);static void wvlan_release (u_long arg);static dev_link_t *wvlan_attach (void);static void wvlan_detach (dev_link_t *link);static int wvlan_event (event_t event, int priority, event_callback_args_t *args);extern int init_wvlan_cs (void);extern void exit_wvlan_cs (void);/********************** SPIN LOCK SUBROUTINES **********************//* * These 2 routines help to see what's happening with spinlock. * They are inline, so optimised away ;-) *//*------------------------------------------------------------------*//* * Wrapper for disabling interrupts. Useful for debugging ;-) * (note : inline, so optimised away) */static inline voidwv_driver_lock(struct net_local *	local,	       unsigned long *		pflags){  /* Disable interrupts and aquire the lock */  spin_lock_irqsave(&local->slock, *pflags);}/*------------------------------------------------------------------*//* * Wrapper for re-enabling interrupts. */static inline voidwv_driver_unlock(struct net_local *	local,		 unsigned long *	pflags){  /* Release the lock and reenable interrupts */  spin_unlock_irqrestore(&local->slock, *pflags);}/******************************************************************** * HARDWARE SETTINGS *//* Note : most function below are called once in the code, so I added * the "inline" modifier. If a function is used more than once, please * remove the "inline"... * Jean II */// Stupid constants helping clarity#define WVLAN_CURRENT	1#define WVLAN_DESIRED	0static inline int wvlan_hw_setmaxdatalen (IFBP ifbp, int maxlen){	CFG_ID_STRCT ltv;	int rc;	ltv.len = 2;	ltv.typ = CFG_CNF_MAX_DATA_LEN;	ltv.id[0] = cpu_to_le16(maxlen);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_CNF_MAX_DATA_LEN:0x%x) returned 0x%x\n", dev_info, maxlen, rc);	return rc;}static inline int wvlan_hw_getmacaddr (IFBP ifbp, char *mac, int len){	CFG_MAC_ADDR_STRCT ltv;	int rc, l;	ltv.len = 4;	ltv.typ = CFG_CNF_OWN_MAC_ADDR;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_OWN_MAC_ADDR) returned 0x%x\n", dev_info, rc);	if (rc)		return rc;	l = _min(len, ltv.len*2);	memcpy(mac, (char *)ltv.mac_addr, l);	return 0;}static int wvlan_hw_getchannellist (IFBP ifbp){	CFG_ID_STRCT ltv;	int rc, chlist;	ltv.len = 2;	ltv.typ = CFG_CHANNEL_LIST;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	chlist = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CHANNEL_LIST):0x%x returned 0x%x\n", dev_info, chlist, rc);	return rc ? 0 : chlist;}static inline int wvlan_hw_setporttype (IFBP ifbp, int ptype){	CFG_ID_STRCT ltv;	int rc;	ltv.len = 2;	ltv.typ = CFG_CNF_PORT_TYPE;	ltv.id[0] = cpu_to_le16(ptype);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_CNF_PORT_TYPE:0x%x) returned 0x%x\n", dev_info, ptype, rc);	return rc;}static inline int wvlan_hw_getporttype (IFBP ifbp){	CFG_ID_STRCT ltv;	int rc, ptype;	ltv.len = 2;	ltv.typ = CFG_CNF_PORT_TYPE;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	ptype = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_PORT_TYPE):0x%x returned 0x%x\n", dev_info, ptype, rc);	return rc ? 0 : ptype;}static inline int wvlan_hw_setallowibssflag (IFBP ifbp, int flag){	CFG_ID_STRCT ltv;	int rc;	ltv.len = 2;	ltv.typ = CFG_CREATE_IBSS;	ltv.id[0] = cpu_to_le16(flag);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_CREATE_IBSS:0x%x) returned 0x%x\n", dev_info, flag, rc);	return rc;}static inline int wvlan_hw_getallowibssflag (IFBP ifbp){	CFG_ID_STRCT ltv;	int rc, flag;	ltv.len = 2;	ltv.typ = CFG_CREATE_IBSS;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	flag = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CREATE_IBSS):0x%x returned 0x%x\n", dev_info, flag, rc);	return rc ? 0 : flag;}static inline int wvlan_hw_setstationname (IFBP ifbp, char *name){	CFG_ID_STRCT ltv;	int rc, l;	ltv.len = 18;	ltv.typ = CFG_CNF_OWN_NAME;	l = _min(strlen(name), ltv.len*2);	ltv.id[0] = cpu_to_le16(l);	memcpy((char *) &ltv.id[1], name, l);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_CNF_OWN_NAME:'%s') returned 0x%x\n", dev_info, name, rc);	return rc;}static inline int wvlan_hw_getstationname (IFBP ifbp, char *name, int len){	CFG_ID_STRCT ltv;	int rc, l;	ltv.len = 18;	ltv.typ = CFG_CNF_OWN_NAME;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_OWN_NAME) returned 0x%x\n", dev_info, rc);	if (rc)		return rc;	l = le16_to_cpup(&ltv.id[0]);	if (l)		l = _min(len, l);	else		l = _min(len, ltv.len*2);	/* It's a feature */	memcpy(name, (char *) &ltv.id[1], l);	name[l] = 0;	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_OWN_NAME):'%s'\n", dev_info, name);	return 0;}static inline int wvlan_hw_setssid (IFBP ifbp, char *name, int ptype){	CFG_ID_STRCT ltv;	int rc, l;	ltv.len = 18;	if (ptype == 3)		ltv.typ = CFG_CNF_OWN_SSID;	else		ltv.typ = CFG_CNF_DESIRED_SSID;	l = _min(strlen(name), ltv.len*2);	ltv.id[0] = cpu_to_le16(l);	memcpy((char *) &ltv.id[1], name, l);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_CNF_OWN/DESIRED_SSID:'%s') returned 0x%x\n", dev_info, name, rc);	return rc;}static int wvlan_hw_getssid (IFBP ifbp, char *name, int len, int cur, int ptype){	CFG_ID_STRCT ltv;	int rc, l;	ltv.len = 18;	if (cur)		ltv.typ = CFG_CURRENT_SSID;	else		if (ptype == 3)			ltv.typ = CFG_CNF_OWN_SSID;		else			ltv.typ = CFG_CNF_DESIRED_SSID;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_OWN/DESIRED/CURRENT_SSID) returned 0x%x\n", dev_info, rc);	if (rc)		return rc;	l = le16_to_cpup(&ltv.id[0]);	if (l)	{		l = _min(len, l);		memcpy(name, (char *) &ltv.id[1], l);	}	name[l] = '\0';	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_OWN/DESIRED/CURRENT_SSID):'%s'\n", dev_info, name);	return 0;}static inline int wvlan_hw_getbssid (IFBP ifbp, char *mac, int len){	CFG_MAC_ADDR_STRCT ltv;	int rc, l;	ltv.len = 4;	ltv.typ = CFG_CURRENT_BSSID;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CURRENT_BSSID) returned 0x%x\n", dev_info, rc);	if (rc)		return rc;	l = _min(len, ltv.len*2);	memcpy(mac, (char *)ltv.mac_addr, l);	return 0;}static inline int wvlan_hw_setchannel (IFBP ifbp, int channel){	CFG_ID_STRCT ltv;	int rc;	ltv.len = 2;	ltv.typ = CFG_CNF_OWN_CHANNEL;	ltv.id[0] = cpu_to_le16(channel);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_CNF_OWN_CHANNEL:0x%x) returned 0x%x\n", dev_info, channel, rc);	return rc;}/* Unused ??? */static int wvlan_hw_getchannel (IFBP ifbp){	CFG_ID_STRCT ltv;	int rc, channel;	ltv.len = 2;	ltv.typ = CFG_CNF_OWN_CHANNEL;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	channel = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CNF_OWN_CHANNEL):0x%x returned 0x%x\n", dev_info, channel, rc);	return rc ? 0 : channel;}static int wvlan_hw_getcurrentchannel (IFBP ifbp){	CFG_ID_STRCT ltv;	int rc, channel;	ltv.len = 2;	ltv.typ = CFG_CURRENT_CHANNEL;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	channel = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CURRENT_CHANNEL):0x%x returned 0x%x\n", dev_info, channel, rc);	return rc ? 0 : channel;}static int wvlan_hw_setthreshold (IFBP ifbp, int thrh, int cmd){	CFG_ID_STRCT ltv;	int rc;	ltv.len = 2;	ltv.typ = cmd;	ltv.id[0] = cpu_to_le16(thrh);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(0x%x:0x%x) returned 0x%x\n", dev_info, cmd, thrh, rc);	return rc;}static int wvlan_hw_getthreshold (IFBP ifbp, int cmd){	CFG_ID_STRCT ltv;	int rc, thrh;	ltv.len = 2;	ltv.typ = cmd;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	thrh = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(0x%x):0x%x returned 0x%x\n", dev_info, cmd, thrh, rc);	return rc ? 0 : thrh;}/* Unused ? */static int wvlan_hw_setbitrate (IFBP ifbp, int brate){	CFG_ID_STRCT ltv;	int rc;	ltv.len = 2;	ltv.typ = CFG_TX_RATE_CONTROL;	ltv.id[0] = cpu_to_le16(brate);	rc = hcf_put_info(ifbp, (LTVP) &ltv);	DEBUG(DEBUG_NOISY, "%s: hcf_put_info(CFG_TX_RATE_CONTROL:0x%x) returned 0x%x\n", dev_info, brate, rc);	return rc;}static int wvlan_hw_getbitrate (IFBP ifbp, int cur){	CFG_ID_STRCT ltv;	int rc, brate;	ltv.len = 2;	ltv.typ = cur ? CFG_CURRENT_TX_RATE : CFG_TX_RATE_CONTROL;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	brate = le16_to_cpup(&ltv.id[0]);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_TX_RATE_CONTROL):0x%x returned 0x%x\n", dev_info, brate, rc);	return rc ? 0 : brate;}static int wvlan_hw_getratelist(IFBP ifbp, char *brlist, int brmaxlen){	CFG_ID_STRCT ltv;	int rc, brnum;	ltv.len = 10;	ltv.typ = CFG_SUPPORTED_DATA_RATES;	rc = hcf_get_info(ifbp, (LTVP) &ltv);	brnum = le16_to_cpup(&ltv.id[0]);	if (brnum > brmaxlen)		brnum = brmaxlen;	memcpy(brlist, (char *) &ltv.id[1], brnum);	DEBUG(DEBUG_NOISY, "%s: hcf_get_info(CFG_CHANNEL_LIST):0x%x returned 0x%x\n", dev_info, brnum, rc);	return rc ? 0 : brnum;}#ifdef WIRELESS_EXTstatic inline int wvlan_hw_getfrequencylist(IFBP ifbp, iw_freq *list, int max)

⌨️ 快捷键说明

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