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

📄 p80211types.c

📁 对于无线网卡采用prism芯片的linux的开源驱动.
💻 C
📖 第 1 页 / 共 5 页
字号:
	UINT32		result = 0;	p80211meta_t	*msgmeta = NULL;	p80211meta_t	*mibmeta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	p80211itemd_t	*mibitem;	if ( item->status == P80211ENUM_msgitem_status_data_ok ) {		if ( (msgmeta = p80211_did2item(metalist, did)) != NULL ) {			/* set up the pointers */			mibitem = (p80211itemd_t *)(item->data);			if ( (mibmeta =				p80211_did2item(mib_catlist, mibitem->did))				!= NULL ) {					result = 1;			} else {				item->status =				P80211ENUM_msgitem_status_invalid_mib_did;			}		} else {			item->status =			P80211ENUM_msgitem_status_invalid_msg_did;		}	}	return result;}/*----------------------------------------------------------------* p80211_isvalid_setmibattribute** This function checks the validity of the data portion of the* mibattribute DID-LEN-DATA triple.  The DATA portion of the* mibattribute's "DID-LEN-DATA" triple is itself a "DID-LEN-DATA"* triple storing the mib item's did, length and data, so it's this* "data" that is actually checked for validity.** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		item triple {DID, len, value}.** Returns: *	0	- data in itembuf is invalid*	~0	- data in itembuf is valid----------------------------------------------------------------*/UINT32 p80211_isvalid_setmibattribute( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf ){	UINT32		result = 0;	p80211meta_t	*msgmeta = NULL;	p80211meta_t	*mibmeta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	p80211itemd_t	*mibitem;	if ( item->status == P80211ENUM_msgitem_status_data_ok ) {		if ( (msgmeta = p80211_did2item(metalist, did)) != NULL ) {			/* set up the pointers */			mibitem = (p80211itemd_t *)(item->data);			if ( (mibmeta =				p80211_did2item(mib_catlist, mibitem->did))				!= NULL ) {				/* call the valid function for the mib */				if ( mibmeta->validfunptr != NULL ) {					if ( (*(mibmeta->validfunptr))						(mib_catlist, mibitem->did,						(UINT8 *)mibitem) ) {						result = 1;					} else if ( (mibitem->status) != P80211ENUM_msgitem_status_data_ok ) {						item->status = mibitem->status;					}				} else {					item->status =					P80211ENUM_msgitem_status_missing_valid_func;				}			} else {				item->status = P80211ENUM_msgitem_status_invalid_mib_did;			}		} else {			item->status =				P80211ENUM_msgitem_status_invalid_msg_did;		}	}	return result;}/*----------------------------------------------------------------* p80211_totext_intarray** UINT32[] ==> %d,%d,%d,...** Converts an array of UINT32's to a comma-separated list.  The number* of array elements is taken from the "maxlen" field of the DID metadata.** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		item triple {DID, len, value}.*	textbuf		(out) character buffer to receive textual*			representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	textbuf.----------------------------------------------------------------*/void p80211_totext_intarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t   *meta;	p80211itemd_t  *item;	UINT32         *data;	int            i;	char           *buf, error_msg[MSG_BUFF_LEN];	*textbuf = '\0';	item = (p80211itemd_t *) itembuf;	data = (UINT32 *) item->data;	meta = p80211_did2item(metalist, did);	if (meta == NULL) {		p80211_error2text(P80211ENUM_msgitem_status_invalid_msg_did, error_msg);		sprintf(textbuf, "0x%08x=\"%s\"", did, error_msg);		return;	}	if (item->status != P80211ENUM_msgitem_status_data_ok) {		p80211_error2text(item->status, error_msg);		sprintf(textbuf, "%s=\"%s\"", meta->name, error_msg);		return;	}	if (item->did == 0UL) {		sprintf(textbuf, "%s=%s", meta->name, NOT_SUPPORTED);		return;	}	buf = textbuf + sprintf(textbuf, "%s=", meta->name);	for (i = 0; i < meta->maxlen; i++)		buf += sprintf(buf, (i == 0) ? "%u" : ",%u", data[i]);	return;}/*----------------------------------------------------------------* p80211_fromtext_intarray** %d,%d,%d,... ==> UINT32[]** Converts a C string containing the "<item name>=<value>,<value>,..." format* to a wlan data item triple.  The "values" must be integers.  The number* of array elements is taken from the "maxlen" field of the DID metadata.* There must be at least 1 element in the array.** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		(out) item triple {DID, len, value}.*	textbuf		character buffer containing textual representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	itembuf.----------------------------------------------------------------*/void p80211_fromtext_intarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t   *meta;	p80211itemd_t  *item;	UINT32         *data;	int            cnt;	char           *buf, *end, dlm;	item = (p80211itemd_t *) itembuf;	data = (UINT32 *) item->data;	meta = p80211_did2item(metalist, did);	if (meta == NULL) {		item->did = did;		item->len = sizeof(int);		item->status = P80211ENUM_msgitem_status_invalid_itemname;		return;	}	/*	** Set the DID and OR in the partial DID for safety.	*/	item->did = did | meta->did;	item->len = p80211item_maxdatalen(metalist, item->did);	/*	** Skip past the item name to its value before converting.  The	** delimiter will be '='.	*/	dlm = '=';	buf = strchr(textbuf, dlm);	if (buf == NULL) {		memset(data, 0, item->len);		item->status = P80211ENUM_msgitem_status_missing_itemdata;		return;	}	/*	** Keep reading array elements...	*/	cnt = 0;	while (1) {		/*		** Quit if we now have all array elements.		*/		if (cnt >= meta->maxlen) break;		/*		** If we're not pointing at the delimiter, then something went		** wrong.  Note that the first delimiter will be '=' and all		** subsequent delimiters will be ','.  Skip past the delimiter		** and any following whitespace.		*/		if (*buf != dlm) goto invalid;		dlm = ',';		buf++;		buf += strspn(buf, " \t\n\r\f\v");		/*		** Get the next array element.  Make sure that at least		** something was found (i.e. end != buf).  Skip any trailing		** whitespace.  This should leave us at either the next ',' or		** at '\0'.		*/		data[cnt] = strtol(buf, &end, 10);		if (end == buf) goto invalid;		cnt++;		buf = end + strspn(end, " \t\n\r\f\v");	}	/*	** Make sure there is no left-over stuff at the end of the sting.	*/	if (*buf != '\0') goto invalid;	item->status = P80211ENUM_msgitem_status_data_ok;	return;invalid:	memset(data, 0, item->len);	item->status = P80211ENUM_msgitem_status_invalid_itemdata;	return;}/*----------------------------------------------------------------* p80211_isvalid_intarray** Tests an item triple for valid range.  Uses the validation* information in the metadata.  All values are valid, so this * function always returns success.** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		item triple {DID, len, value}.** Returns: *	0	- data in itembuf is invalid*	~0	- data in itembuf is valid----------------------------------------------------------------*/UINT32 p80211_isvalid_intarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf ){	UINT32		result = 0;	p80211meta_t	*meta;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	if ( item->status == P80211ENUM_msgitem_status_data_ok ) {		/* collect the metadata item */		if ( (meta = p80211_did2item(metalist, did)) != NULL ) {			/* since integers aren't bounded, there's			nothing to check */			result = 1;		} else {			item->status = P80211ENUM_msgitem_status_invalid_did;		}	}	return result;}/*----------------------------------------------------------------* p80211_totext_bitarray** UINT32 ==> %d,%d,%d,...** Converts the first "maxlen" bits of a UINT32 to a comma-separated list* of bit numbers of the bits which are set.  Other bits are ignored.** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		item triple {DID, len, value}.*	textbuf		(out) character buffer to receive textual*			representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	textbuf.----------------------------------------------------------------*/void p80211_totext_bitarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t   *meta;	p80211itemd_t  *item;	UINT32         array;	int            found, i;	char           *buf, error_msg[MSG_BUFF_LEN];	*textbuf = '\0';	item = (p80211itemd_t *) itembuf;	meta = p80211_did2item(metalist, did);	if (meta == NULL) {		p80211_error2text(P80211ENUM_msgitem_status_invalid_msg_did, error_msg);		sprintf(textbuf, "0x%08x=\"%s\"", did, error_msg);		return;	}	if (item->status != P80211ENUM_msgitem_status_data_ok) {		p80211_error2text(item->status, error_msg);		sprintf(textbuf, "%s=\"%s\"", meta->name, error_msg);		return;	}	if (item->did == 0UL) {		sprintf(textbuf, "%s=%s", meta->name, NOT_SUPPORTED);		return;	}	array = *((UINT32 *) item->data);	buf = textbuf + sprintf(textbuf, "%s=", meta->name);	found = 0;	for (i = meta->min; i <= meta->max; i++)		if (array & (0x1 << i)) {			found = 1;			buf += sprintf(buf, "%u,", (UINT32) i);		}	if (found != 0) *(buf-1) = '\0';	return;}/*----------------------------------------------------------------* p80211_fromtext_bitarray** %d,%d,%d,... ==> UINT32** Converts a C string containing the "<item name>=<value>,<value>,..." format* to a wlan data item triple.  Bit numbers must be less than "maxlen".** The C string format  is always  "<item name>=<value>,<value>,<value>,...".** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		(out) item triple {DID, len, value}.*	textbuf		character buffer containing textual representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	itembuf.----------------------------------------------------------------*/void p80211_fromtext_bitarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t   *meta;	p80211itemd_t  *item;	UINT32         array, value;	item = (p80211itemd_t *) itembuf;	meta = p80211_did2item(metalist, did);	if (meta == NULL) {		item->did = did;		item->len = sizeof(int);		item->status = P80211ENUM_msgitem_status_invalid_itemname;		return;	}	/*	** Set the DID and OR in the partial DID for safety.	*/	item->did = did | meta->did;	item->len = p80211item_maxdatalen(metalist, item->did);	/*	** Skip past the item name to its value before converting.	*/	textbuf = strchr(textbuf, '=');	if (textbuf == NULL) {		*((UINT32 *) item->data) = 0;		item->status = P80211ENUM_msgitem_status_missing_itemdata;		return;	}	array = 0;	while (textbuf != NULL) {		/* OK, got the '=' or ',', bump to the next char */		textbuf++;		if (textbuf[0] == '\0') break;		if (sscanf(textbuf, "%u", &value) != 1) {			*((UINT32 *) item->data) = 0;			item->status = P80211ENUM_msgitem_status_invalid_itemdata;			return;		}		if (value < meta->min || value > meta->max) {			*((UINT32 *) item->data) = 0;			item->status = P80211ENUM_msgitem_status_invalid_itemdata;			return;		}		array |= 0x1 << value;		textbuf = strchr(textbuf, ',');	}	*((UINT32 *) item->data) = array;	item->status = P80211ENUM_msgitem_status_data_ok;	return;}/*----------------------------------------------------------------* p80211_isvalid_bitarray** Tests an item triple for valid range.  Uses the validation* information in the metadata.** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		item triple {DID, len, value}.** Returns: *	0	- data in itembuf is invalid*	~0	- data in itembuf is valid----------------------------------------------------------------*/UINT32 p80211_isvalid_bitarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf ){	UINT32		result = 0;	p80211meta_t	*meta;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	UINT32          i, value, mask;

⌨️ 快捷键说明

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