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

📄 p80211types.c

📁 对于无线网卡采用prism芯片的linux的开源驱动.
💻 C
📖 第 1 页 / 共 5 页
字号:
			*((UINT32 *)(item->data)) = 0UL;			item->status = P80211ENUM_msgitem_status_missing_itemdata;		}	} else {		item->did = did;		item->len = sizeof(UINT32);		item->status = P80211ENUM_msgitem_status_invalid_itemname;	}	return;}/*----------------------------------------------------------------* p80211_isvalid_enumint** Tests an item triple for valid range.  Uses the validation* information in the metadata.  Enumint's are validated against* their enumeration structure.** 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_enumint( 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 ( (*((UINT32 *)(item->data))) != P80211ENUM_BAD ) {				result = 1;			} else {				item->status =					P80211ENUM_msgitem_status_invalid_itemdata;			}		} else {			item->status = P80211ENUM_msgitem_status_invalid_did;		}	}	return result;}/*----------------------------------------------------------------* p80211_totext_getmibattribute** Converts the mibattribute of a "mibget" message into* a text string.  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.  In other words:** DID-LEN-DATA*           ^*           |__________ where DATA = DID-LEN-DATA for a MIB Item** If message text format is:*      "mibattribute=<mibitemname>=<mibvalue>"** 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 mib value to the buffer pointed at by*	textbuf.----------------------------------------------------------------*/void p80211_totext_getmibattribute( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	char		tmpbuf[MSG_BUFF_LEN];	UINT32		mibdid;	p80211meta_t	*meta = NULL;	p80211meta_t	*mibmeta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	*textbuf = '\0';	/* get the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		if ( item->status == P80211ENUM_msgitem_status_data_ok ) {			mibdid = *((UINT32 *)(item->data));			if ( (mibmeta =				p80211_did2item(mib_catlist,mibdid)) != NULL ) {				if ( item->did != 0UL ) {					if ( mibmeta->totextptr != NULL) {						(*(mibmeta->totextptr))						(mib_catlist, mibdid,						item->data, tmpbuf);						/* now, print to the textbuf */						sprintf( textbuf,							"%s=%s",meta->name,							tmpbuf);					} else {						sprintf( textbuf,							"%s=%s=%s",							meta->name,							mibmeta->name,							NOT_SUPPORTED);					}				} else {					sprintf( textbuf, "%s=%s=%s",						meta->name, mibmeta->name,						NOT_SUPPORTED);				}			} else {				char		error_msg[MSG_BUFF_LEN];				p80211_error2text(					P80211ENUM_msgitem_status_invalid_mib_did,					error_msg);				sprintf( textbuf, "0x%08x=\"%s\"", mibdid,					error_msg);			}		} 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_totext_setmibattribute** Converts the mibattribute of a "mibset" message into* a text string.  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.  In other words:** DID-LEN-DATA*           ^*           |__________ where DATA = DID-LEN-DATA for a MIB Item** If message text format is:*      "mibattribute=<mibitemname>=<mibvalue>"** 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 mib value to the buffer pointed at by*	textbuf.----------------------------------------------------------------*/void p80211_totext_setmibattribute( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	char		tmpbuf[MSG_BUFF_LEN];	UINT32		mibdid;	p80211meta_t	*meta = NULL;	p80211meta_t	*mibmeta = NULL;	p80211itemd_t	*item = (p80211itemd_t*)itembuf;	*textbuf = '\0';	/* get the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		if ( item->status == P80211ENUM_msgitem_status_data_ok ) {			mibdid = *((UINT32 *)(item->data));			if ( (mibmeta =				p80211_did2item(mib_catlist,mibdid)) != NULL ) {				if ( item->did != 0UL ) {					if ( mibmeta->totextptr != NULL) {						(*(mibmeta->totextptr))						(mib_catlist, mibdid,						item->data, tmpbuf);						/* now, print to the textbuf */						sprintf( textbuf,							"%s=%s",meta->name,							tmpbuf);					} else {						sprintf( textbuf,							"%s=%s=%s",							meta->name,							mibmeta->name,							NOT_SUPPORTED);					}				} else {					sprintf( textbuf, "%s=%s=%s",						meta->name, mibmeta->name,						NOT_SUPPORTED);				}			} else {				char		error_msg[MSG_BUFF_LEN];				p80211_error2text(					P80211ENUM_msgitem_status_invalid_mib_did,					error_msg);				sprintf( textbuf, "0x%08x=\"%s\"", mibdid,					error_msg);			}		} 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_getmibattribute** If message is mibget, then the text format is:*      "mibattribute=<mibitemname>"* If message is mibset, then the text format is:*      "mibattribute=<mibitemname>=<mibvalue>"** Takes the mibattribute argument of a "mibget" message, and coverts* the mib item name into a mib DID and converts the mib's value.** 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.  In other words:** DID-LEN-DATA*           ^*           |__________ where DATA = DID-LEN-DATA for a MIB Item** 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 MIB DID to the buffer pointed at by*	itembuf.----------------------------------------------------------------*/void p80211_fromtext_getmibattribute( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t		*meta;	p80211meta_t		*mibmeta;	p80211itemd_t		*item = (p80211itemd_t*)itembuf;	char			*mibstr;	UINT32			mibdid;	/* collect the metadata item */	if ( (meta = p80211_did2item(metalist, did)) != NULL ) {		/* set the DID (OR in the partial DID for safety)		and set the length */		item->did = did | meta->did;		item->len = p80211item_maxdatalen(metalist, item->did);		/* collect the mib item name */		textbuf = strchr(textbuf, '=');		if ( textbuf == NULL ) {			*((UINT32 *)(item->data)) = 0UL;			item->status = P80211ENUM_msgitem_status_missing_itemdata;			return;		}		textbuf++;		mibstr = textbuf;		/* get DID of mib item based on mib name */		mibdid = p80211_metaname2did(mib_catlist,mibstr);		if ( mibdid != 0UL ) {			if ( (mibmeta = p80211_did2item(mib_catlist,				mibdid)) != NULL ) {				item= (p80211itemd_t *)(item->data);				item->did = mibdid;				if ( mibmeta-> maxlen > 0 ) {					item->len =						p80211item_maxdatalen(							mib_catlist,							item->did);				} else {					item->len = 4;				}				*((UINT32 *)(item->data)) = 0UL;				item->status =					P80211ENUM_msgitem_status_data_ok;			} else {				item->status =				P80211ENUM_msgitem_status_invalid_mib_did;				*((UINT32 *)(item->data)) = 0UL;				return;			}		} else {			item->status =				P80211ENUM_msgitem_status_invalid_mib_did;			*((UINT32 *)(item->data)) = 0UL;			return;		}	} else {		item->did = did;		item->len = 4;		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_invalid_itemname;	}	return;}/*----------------------------------------------------------------* p80211_fromtext_setmibattribute** If message is mibget, then the text format is:*      "mibattribute=<mibitemname>"* If message is mibset, then the text format is:*      "mibattribute=<mibitemname>=<mibvalue>"** Takes the mibattribute argument of a "mibset" message, and coverts* the mib item name into a mib DID and converts the mib's value.** 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.  In other words:** DID-LEN-DATA*           ^*           |__________ where DATA = DID-LEN-DATA for a MIB Item** 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 MIB DID to the buffer pointed at by*	itembuf.  If message is "mibset", then the mib value is*	coverted from text and stored after the DID and LEN----------------------------------------------------------------*/void p80211_fromtext_setmibattribute( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){	p80211meta_t		*meta;	p80211meta_t		*mibmeta;	p80211itemd_t		*item = (p80211itemd_t*)itembuf;	char			*mibstr;	UINT32			mibdid;	/* collect the metadata item */	meta = p80211_did2item(metalist, did);	if (meta == NULL) {		item->did = did;		item->len = 4;		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_invalid_msg_did;                return;	}	/* set the DID (OR in the partial DID for safety) and set the length */	item->did = did | meta->did;	item->len = p80211item_maxdatalen(metalist, item->did);	/* collect the mib item name */	textbuf = strchr(textbuf, '=');	if ( textbuf == NULL ) {		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_missing_itemdata;		return;	}	textbuf++;	mibstr = textbuf;	/* set the '=' between mib name and mib value to	end of string character for call to metaname2did */	textbuf = strchr(textbuf, '=');	if (textbuf == NULL) {		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_incomplete_itemdata;		return;	}	*textbuf = '\0';	/* get DID of mib item based on mib name */	mibdid = p80211_metaname2did(mib_catlist,mibstr);	if (mibdid == 0UL) {		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_invalid_mib_did;		return;	}	/* put '=' back for call to mib's fromtext function */	*textbuf = '=';	mibmeta = p80211_did2item(mib_catlist, mibdid);	if (mibmeta == NULL) {		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_invalid_mib_did;		return;	}	if (mibmeta->fromtextptr == NULL) {		*((UINT32 *)(item->data)) = 0UL;		item->status = P80211ENUM_msgitem_status_missing_conv_func;		return;	}	(*(mibmeta->fromtextptr)) (mib_catlist, mibdid, item->data, mibstr);	item->status = ((p80211itemd_t *)(item->data))->status;	return;}/*----------------------------------------------------------------* p80211_isvalid_getmibattribute** 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_getmibattribute( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf ){

⌨️ 快捷键说明

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