ray_cs.c

来自「LINUX 2.6.17.4的源码」· C语言 代码 · 共 1,911 行 · 第 1/5 页

C
1,911
字号
	ray_dev_t *local = (ray_dev_t *)dev->priv;	fwrq->m = local->sparm.b5.a_hop_pattern;	fwrq->e = 0;	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set ESSID */static int ray_set_essid(struct net_device *dev,			 struct iw_request_info *info,			 struct iw_point *dwrq,			 char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	/* Reject if card is already initialised */	if(local->card_status != CARD_AWAITING_PARAM)		return -EBUSY;	/* Check if we asked for `any' */	if(dwrq->flags == 0) {		/* Corey : can you do that ? */		return -EOPNOTSUPP;	} else {		/* Check the size of the string */		if(dwrq->length > IW_ESSID_MAX_SIZE + 1) {			return -E2BIG;		}		/* Set the ESSID in the card */		memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE);		memcpy(local->sparm.b5.a_current_ess_id, extra, dwrq->length);	}	return -EINPROGRESS;		/* Call commit handler */}/*------------------------------------------------------------------*//* * Wireless Handler : get ESSID */static int ray_get_essid(struct net_device *dev,			 struct iw_request_info *info,			 struct iw_point *dwrq,			 char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	/* Get the essid that was set */	memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);	extra[IW_ESSID_MAX_SIZE] = '\0';	/* Push it out ! */	dwrq->length = strlen(extra);	dwrq->flags = 1; /* active */	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : get AP address */static int ray_get_wap(struct net_device *dev,			struct iw_request_info *info,			struct sockaddr *awrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	memcpy(awrq->sa_data, local->bss_id, ETH_ALEN);	awrq->sa_family = ARPHRD_ETHER;	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set Bit-Rate */static int ray_set_rate(struct net_device *dev,			struct iw_request_info *info,			struct iw_param *vwrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	/* Reject if card is already initialised */	if(local->card_status != CARD_AWAITING_PARAM)		return -EBUSY;	/* Check if rate is in range */	if((vwrq->value != 1000000) && (vwrq->value != 2000000))		return -EINVAL;	/* Hack for 1.5 Mb/s instead of 2 Mb/s */	if((local->fw_ver == 0x55) &&		/* Please check */	   (vwrq->value == 2000000))		local->net_default_tx_rate = 3;	else		local->net_default_tx_rate = vwrq->value/500000;	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : get Bit-Rate */static int ray_get_rate(struct net_device *dev,			struct iw_request_info *info,			struct iw_param *vwrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	if(local->net_default_tx_rate == 3)		vwrq->value = 2000000;		/* Hum... */	else		vwrq->value = local->net_default_tx_rate * 500000;	vwrq->fixed = 0;		/* We are in auto mode */	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set RTS threshold */static int ray_set_rts(struct net_device *dev,		       struct iw_request_info *info,		       struct iw_param *vwrq,		       char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	int rthr = vwrq->value;	/* Reject if card is already initialised */	if(local->card_status != CARD_AWAITING_PARAM)		return -EBUSY;	/* if(wrq->u.rts.fixed == 0) we should complain */	if(vwrq->disabled)		rthr = 32767;	else {		if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */			return -EINVAL;	}	local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;	local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF;	return -EINPROGRESS;		/* Call commit handler */}/*------------------------------------------------------------------*//* * Wireless Handler : get RTS threshold */static int ray_get_rts(struct net_device *dev,		       struct iw_request_info *info,		       struct iw_param *vwrq,		       char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	vwrq->value = (local->sparm.b5.a_rts_threshold[0] << 8)		+ local->sparm.b5.a_rts_threshold[1];	vwrq->disabled = (vwrq->value == 32767);	vwrq->fixed = 1;	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set Fragmentation threshold */static int ray_set_frag(struct net_device *dev,			struct iw_request_info *info,			struct iw_param *vwrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	int fthr = vwrq->value;	/* Reject if card is already initialised */	if(local->card_status != CARD_AWAITING_PARAM)		return -EBUSY;	/* if(wrq->u.frag.fixed == 0) should complain */	if(vwrq->disabled)		fthr = 32767;	else {		if((fthr < 256) || (fthr > 2347)) /* To check out ! */			return -EINVAL;	}	local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;	local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF;	return -EINPROGRESS;		/* Call commit handler */}/*------------------------------------------------------------------*//* * Wireless Handler : get Fragmentation threshold */static int ray_get_frag(struct net_device *dev,			struct iw_request_info *info,			struct iw_param *vwrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	vwrq->value = (local->sparm.b5.a_frag_threshold[0] << 8)		+ local->sparm.b5.a_frag_threshold[1];	vwrq->disabled = (vwrq->value == 32767);	vwrq->fixed = 1;	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : set Mode of Operation */static int ray_set_mode(struct net_device *dev,			struct iw_request_info *info,			__u32 *uwrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	int err = -EINPROGRESS;		/* Call commit handler */	char card_mode = 1;	/* Reject if card is already initialised */	if(local->card_status != CARD_AWAITING_PARAM)		return -EBUSY;	switch (*uwrq)	{	case IW_MODE_ADHOC:		card_mode = 0;		// Fall through	case IW_MODE_INFRA:		local->sparm.b5.a_network_type = card_mode;		break;	default:		err = -EINVAL;	}	return err;}/*------------------------------------------------------------------*//* * Wireless Handler : get Mode of Operation */static int ray_get_mode(struct net_device *dev,			struct iw_request_info *info,			__u32 *uwrq,			char *extra){	ray_dev_t *local = (ray_dev_t *)dev->priv;	if(local->sparm.b5.a_network_type)		*uwrq = IW_MODE_INFRA;	else		*uwrq = IW_MODE_ADHOC;	return 0;}/*------------------------------------------------------------------*//* * Wireless Handler : get range info */static int ray_get_range(struct net_device *dev,			 struct iw_request_info *info,			 struct iw_point *dwrq,			 char *extra){	struct iw_range *range = (struct iw_range *) extra;	memset((char *) range, 0, sizeof(struct iw_range));	/* Set the length (very important for backward compatibility) */	dwrq->length = sizeof(struct iw_range);	/* Set the Wireless Extension versions */	range->we_version_compiled = WIRELESS_EXT;	range->we_version_source = 9;	/* Set information in the range struct */	range->throughput = 1.1 * 1000 * 1000;	/* Put the right number here */	range->num_channels = hop_pattern_length[(int)country]; 	range->num_frequency = 0;	range->max_qual.qual = 0;	range->max_qual.level = 255;	/* What's the correct value ? */	range->max_qual.noise = 255;	/* Idem */	range->num_bitrates = 2;	range->bitrate[0] = 1000000;	/* 1 Mb/s */	range->bitrate[1] = 2000000;	/* 2 Mb/s */	return 0;}/*------------------------------------------------------------------*//* * Wireless Private Handler : set framing mode */static int ray_set_framing(struct net_device *dev,			   struct iw_request_info *info,			   union iwreq_data *wrqu,			   char *extra){	translate = *(extra);	/* Set framing mode */	return 0;}/*------------------------------------------------------------------*//* * Wireless Private Handler : get framing mode */static int ray_get_framing(struct net_device *dev,			   struct iw_request_info *info,			   union iwreq_data *wrqu,			   char *extra){	*(extra) = translate;	return 0;}/*------------------------------------------------------------------*//* * Wireless Private Handler : get country */static int ray_get_country(struct net_device *dev,			   struct iw_request_info *info,			   union iwreq_data *wrqu,			   char *extra){	*(extra) = country;	return 0;}/*------------------------------------------------------------------*//* * Commit handler : called after a bunch of SET operations */static int ray_commit(struct net_device *dev,		      struct iw_request_info *info,	/* NULL */		      void *zwrq,			/* NULL */		      char *extra)			/* NULL */{	return 0;}/*------------------------------------------------------------------*//* * Stats handler : return Wireless Stats */static iw_stats * ray_get_wireless_stats(struct net_device *	dev){  ray_dev_t *	local = (ray_dev_t *) dev->priv;  struct pcmcia_device *link = local->finder;  struct status __iomem *p = local->sram + STATUS_BASE;  if(local == (ray_dev_t *) NULL)    return (iw_stats *) NULL;  local->wstats.status = local->card_status;#ifdef WIRELESS_SPY  if((local->spy_data.spy_number > 0) && (local->sparm.b5.a_network_type == 0))    {      /* Get it from the first node in spy list */      local->wstats.qual.qual = local->spy_data.spy_stat[0].qual;      local->wstats.qual.level = local->spy_data.spy_stat[0].level;

⌨️ 快捷键说明

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