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

📄 p80211types.c

📁 对于无线网卡采用prism芯片的linux的开源驱动.
💻 C
📖 第 1 页 / 共 5 页
字号:
	return;}/*----------------------------------------------------------------* p80211_fromtext_octetstr** "xx:xx:...." ==> pstr** Converts a C string containing the "<item name>=<item value>" format* to a wlan data item triple.** The C string format  is always  "<item name>=<item value>".** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		(out>item triple {DID, len, value}.*	textbuf		character buffer to receive textual*			representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	itembuf.----------------------------------------------------------------*/void p80211_fromtext_octetstr( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t	*meta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	p80211pstrd_t	*pstr;	UINT		hexnum;	INT		n;	/* set up the pascal string pointer, i.e. the display str data item */	pstr = (p80211pstrd_t*)item->data;	/* collect the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		/* set the DID and OR in the partial DID for safety */		item->did = did | meta->did;		/* adding 1 to the metadata maxlen takes into account		the first byte of the pascal string containing the		actual number of data bytes.  NOTE: the '\0' of a display		string is included in the metadata maxlen */		item->len = p80211item_maxdatalen(metalist, item->did);		/* skip past the item name to its value before converting */		textbuf = strchr(textbuf, '=');		if ( textbuf != NULL ) {			item->status = P80211ENUM_msgitem_status_data_ok;			for ( n=0, pstr->len = (UINT8)0; (textbuf != NULL) &&				(item->status == P80211ENUM_msgitem_status_data_ok); n++ ) {				/* OK, got the '=' or ':', bump to the				next char */				textbuf++;				if ( pstr->len < meta->maxlen ) {					if ( sscanf( textbuf, "%x", &hexnum)						== 1 ) {						pstr->data[n] = (UINT8)(hexnum);						pstr->len =							pstr->len + (UINT8)(1);					} else {					item->status = 					P80211ENUM_msgitem_status_invalid_itemdata;					}				} else {					item->status = 					P80211ENUM_msgitem_status_string_too_long;				}				textbuf = strchr(textbuf, ':');			}			if ( pstr->len < meta->minlen )				item->status =					P80211ENUM_msgitem_status_string_too_short;		} else {		/* bogus text string, set the item to an empty string */			pstr->len = 1;			pstr->data[0] = '\0';			item->status = P80211ENUM_msgitem_status_missing_itemdata;		}	} else {		pstr->len = 1;		pstr->data[0] = '\0';		item->did = did;		item->len = pstr->len + 1;		item->status = P80211ENUM_msgitem_status_invalid_itemname;	}	return;}/*----------------------------------------------------------------* p80211_isvalid_octetstr** Tests an item triple for valid range.  Uses the validation* information in the metadata. Octetstr's are validated for* length.** 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_octetstr( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf ){	UINT32		result = 0;	p80211meta_t	*meta;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	p80211pstrd_t	*pstr;	if ( item->status == P80211ENUM_msgitem_status_data_ok ) {		/* collect the metadata item */		if ( (meta = p80211_did2item(metalist, did)) != NULL ) {			/* set up the pointers */			pstr = (p80211pstrd_t*)item->data;			/* in the case of an octet string, the total number 			   of raw data bytes must be equal or less than maximum			   length and equal or greater than minimum length			   specified in the metadata */			if ( pstr->len < meta->minlen ) {				item->status =					P80211ENUM_msgitem_status_string_too_short;			} else if ( pstr->len > meta->maxlen ) {				item->status =					P80211ENUM_msgitem_status_string_too_long;			} else {				result =1;			}		} else { 			item->status = P80211ENUM_msgitem_status_invalid_did;		}	}	return result;}/*----------------------------------------------------------------* p80211_totext_int** UINT32 ==> %d** Converts a UINT32 to a C string appropriate for display.* The C string format  is always  "<item name>=<item value>".* Note: for now, this function is identical to totext_boundedint** 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_int( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t	*meta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	*textbuf = '\0';	/* collect the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		if ( item->status == P80211ENUM_msgitem_status_data_ok ) {			if ( item->did != 0UL ) {				/* now, print the data item name and				value into the textbuf */				sprintf( textbuf, "%s=%u", meta->name,					*((UINT32 *)(item->data)));			} else {				sprintf( textbuf, "%s=%s", meta->name,					NOT_SUPPORTED);			}		} else {			char		error_msg[MSG_BUFF_LEN];			p80211_error2text( item->status, error_msg);			sprintf( textbuf, "%s=\"%s\"", meta->name,				error_msg);		}	} else {		char		error_msg[MSG_BUFF_LEN];		p80211_error2text( P80211ENUM_msgitem_status_invalid_msg_did,			error_msg);		sprintf( textbuf, "0x%08x=\"%s\"", did,			error_msg);	}	return;}/*----------------------------------------------------------------* p80211_fromtext_int** %d ==> UINT32** Converts a C string containing the "<item name>=<item value>" format* to a wlan data item triple.** The C string format  is always  "<item name>=<item value>".** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		(out>item triple {DID, len, value}.*	textbuf		character buffer to receive textual*			representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	itembuf.----------------------------------------------------------------*/void p80211_fromtext_int( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t	*meta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	/* collect the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		/* 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 ) {			/* OK, got the '=', bump to the next */			textbuf++;			*((UINT32 *)(item->data)) = strtoul(textbuf, NULL, 0);			item->status =				P80211ENUM_msgitem_status_data_ok;		} else	{			/* bogus text string, set the item data value to zero */			*((UINT32 *)(item->data)) = 0UL;			item->status = P80211ENUM_msgitem_status_missing_itemdata;		}	} else {		/* invalid did */		item->did = did;		item->len = sizeof(int);		item->status = P80211ENUM_msgitem_status_invalid_itemname;	}	return;}/*----------------------------------------------------------------* p80211_isvalid_int** 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_int( 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 ) {			/* if either min or max is non-zero, we are bound */			if (meta->min || meta->max) {				if ( ((*((UINT32 *)(item->data))) >= meta->min) &&				     ((*((UINT32 *)(item->data))) <= meta->max)) {					result = 1;				} else {					item->status =						P80211ENUM_msgitem_status_data_out_of_range;				}      			} else {				result = 1;			}					} else {			item->status = P80211ENUM_msgitem_status_invalid_did;		}	}	return result;}/*----------------------------------------------------------------* p80211_totext_enumint** UINT32 ==> <valuename>** Converts a enumerated integer item quantity to it a C string * appropriate for display.* The C string format  is always  "<item name>=<item value>".** 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_enumint( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t		*meta = NULL;	p80211itemd_t		*item = (p80211itemd_t*)itembuf;	p80211enumpair_t	*enumlist = NULL;	INT			nitems;	INT			n;	INT			found;	*textbuf = '\0';	/* collect the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		if ( item->status == P80211ENUM_msgitem_status_data_ok ) {			nitems = meta->enumptr->nitems;			enumlist = meta->enumptr->list;			if ( item->did != 0UL ) {				for ( n=0, found = 0;					(!found) && (n < nitems); n++ ) {					if ( enumlist[n].val ==						(*((UINT32 *)(item->data))) ) {						/* now, print the data item						name and enum text value 						into textbuf */						sprintf( textbuf, "%s=%s",							meta->name,							enumlist[n].name );						found = 1;					}				}				if ( !found ) {					char	error_msg[MSG_BUFF_LEN];					p80211_error2text(					P80211ENUM_msgitem_status_invalid_itemdata,					error_msg);					sprintf( textbuf, "%s=\"%s\"",						meta->name, error_msg);				}			} else {				sprintf( textbuf, "%s=%s", meta->name,					NOT_SUPPORTED);			}		} else {			char		error_msg[MSG_BUFF_LEN];			p80211_error2text( item->status, error_msg);			sprintf( textbuf, "%s=\"%s\"", meta->name,				error_msg);		}	} else {		char		error_msg[MSG_BUFF_LEN];		p80211_error2text( P80211ENUM_msgitem_status_invalid_msg_did,			error_msg);		sprintf( textbuf, "0x%08x=\"%s\"", did,			error_msg);	}	return;}/*----------------------------------------------------------------* p80211_fromtext_enumint** <valuename> ==> UINT32** Converts a C string containing the "<item name>=<item value>" format* to a wlan data item triple.** The C string format  is always  "<item name>=<item value>".** Arguments:*	metalist	pointer to a category metadata list*	did		complete, validated, DID.*	itembuf		(out>item triple {DID, len, value}.*	textbuf		character buffer to receive textual*			representation.** Returns: *	nothing** Side effects:*	Writes the converted value to the buffer pointed at by*	itembuf.----------------------------------------------------------------*/void p80211_fromtext_enumint( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t		*meta = NULL;	p80211itemd_t		*item = (p80211itemd_t*)itembuf;	p80211enumpair_t	*enumlist = NULL;	INT			nitems;	INT			n;	INT			found;	/* collect the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		nitems = meta->enumptr->nitems;		enumlist = meta->enumptr->list;		/* 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 ) {			/* OK, got the '=', bump to the next */			textbuf++;			for ( n=0, found = 0; (!found) && (n < nitems); n++ ) {				if ( strcmp(enumlist[n].name, textbuf) == 0 ) {					*((UINT32 *)(item->data)) =						enumlist[n].val;					item->status =					P80211ENUM_msgitem_status_data_ok;					found = 1;				}			}			if ( !found ) {				*((UINT32 *)(item->data)) = P80211ENUM_BAD;				item->status =					P80211ENUM_msgitem_status_invalid_itemdata;			}		} else {			/* bogus text string, set the item data value to zero */

⌨️ 快捷键说明

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