📄 p80211types.c
字号:
if ( item->status == P80211ENUM_msgitem_status_data_ok ) { /* collect the metadata item */ if ( (meta = p80211_did2item(metalist, did)) != NULL ) { mask = 0; for (i = meta->min; i <= meta->max; i++) mask |= 1 << i; value = *((UINT32 *)(item->data)); if ( value == (value & mask) ) { result = 1; } else { item->status = P80211ENUM_msgitem_status_invalid_itemdata; } } else { item->status = P80211ENUM_msgitem_status_invalid_did; } } return result;}/*----------------------------------------------------------------* p80211_totext_macarray** Converts an array of MAC addresses to a comma-separated list.** 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_macarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){ p80211meta_t *meta; p80211itemd_t *item; p80211macarray_t *macarray; int i, cnt; char 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; } macarray = (p80211macarray_t *) item->data; cnt = sprintf(textbuf, "%s=", meta->name); for (i = 0; i < macarray->cnt; i++) cnt += sprintf(textbuf+cnt, (i==0) ? "%02x:%02x:%02x:%02x:%02x:%02x" : ",%02x:%02x:%02x:%02x:%02x:%02x", (UINT) macarray->data[i][0], (UINT) macarray->data[i][1], (UINT) macarray->data[i][2], (UINT) macarray->data[i][3], (UINT) macarray->data[i][4], (UINT) macarray->data[i][5]); return;}/*----------------------------------------------------------------* p80211_fromtext_macarray** Converts a C string containing the "<item name>=<value>,<value>,..." format* to a wlan data item triple.** 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_macarray( catlistitem_t *metalist, UINT32 did, UINT8 *itembuf, char *textbuf ){ p80211meta_t *meta; p80211itemd_t *item; p80211macarray_t *macarray; int cnt, x1, x2, x3, x4, x5, x6; 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. */ macarray = (p80211macarray_t *) item->data; macarray->cnt = 0; textbuf = strchr(textbuf, '='); if (textbuf == NULL) { item->status = P80211ENUM_msgitem_status_missing_itemdata; return; } cnt = 0; while (textbuf != NULL) { /* OK, got the '=' or ',', bump to the next char */ textbuf++; if (textbuf[0] == '\0') break; if (cnt >= meta->maxlen) { item->status = P80211ENUM_msgitem_status_invalid_itemdata; return; } if (sscanf(textbuf, "%x:%x:%x:%x:%x:%x", &x1, &x2, &x3, &x4, &x5, &x6) != 6) { item->status = P80211ENUM_msgitem_status_invalid_itemdata; return; } macarray->data[cnt][0] = (UINT8) x1; macarray->data[cnt][1] = (UINT8) x2; macarray->data[cnt][2] = (UINT8) x3; macarray->data[cnt][3] = (UINT8) x4; macarray->data[cnt][4] = (UINT8) x5; macarray->data[cnt][5] = (UINT8) x6; cnt++; textbuf = strchr(textbuf, ','); } macarray->cnt = cnt; item->status = P80211ENUM_msgitem_status_data_ok; return;}/*----------------------------------------------------------------* p80211_isvalid_macarray** 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_macarray( 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_error2text** This function converts an error code into an appropriate error* string.** Arguments:* err_code error code reflecting index into * the error enumerated list.* err_str (out) will contain the appropriate* error string.** Returns: * Nothing----------------------------------------------------------------*/void p80211_error2text( int err_code, char *err_str ){ p80211enum_int2text(&MKENUMNAME(msgitem_status), err_code, err_str);}/*--------------------------------------------------------------------*//* Item enumerations *//* The following arrays list the numbers and names for each of the *//* enumerations present in the 802.11 MIB and MLME. */MKENUMPAIRLIST(truth){ MKENUMPAIR( 0, "false" ), MKENUMPAIR( 1, "true")};MKENUM(truth);MKENUMPAIRLIST(ifstate){ MKENUMPAIR( 0, "disable" ), MKENUMPAIR( 1, "fwload"), MKENUMPAIR( 2, "enable")};MKENUM(ifstate);MKENUMPAIRLIST(powermgmt){ MKENUMPAIR( 1, "active" ), MKENUMPAIR( 2, "powersave" )};MKENUM(powermgmt);MKENUMPAIRLIST(bsstype){ MKENUMPAIR( 1, "infrastructure" ), MKENUMPAIR( 2, "independent" ), MKENUMPAIR( 3, "any" )};MKENUM(bsstype);MKENUMPAIRLIST(authalg){ MKENUMPAIR( 1, "opensystem" ), MKENUMPAIR( 2, "sharedkey" ), MKENUMPAIR( 3, "not_set" )};MKENUM(authalg);MKENUMPAIRLIST(phytype){ MKENUMPAIR( 1, "fhss" ), MKENUMPAIR( 2, "dsss" ), MKENUMPAIR( 3, "irbaseband" )};MKENUM(phytype);MKENUMPAIRLIST(temptype){ MKENUMPAIR( 1, "commercial" ), MKENUMPAIR( 2, "industrial" )};MKENUM(temptype);MKENUMPAIRLIST(regdomain){ MKENUMPAIR( 0x10, "fcc" ), MKENUMPAIR( 0x20, "doc" ), MKENUMPAIR( 0x30, "etsi" ), MKENUMPAIR( 0x31, "spain" ), MKENUMPAIR( 0x32, "france" ), MKENUMPAIR( 0x40, "mkk" )};MKENUM(regdomain);MKENUMPAIRLIST(ccamode){ MKENUMPAIR( 0x01, "edonly" ), MKENUMPAIR( 0x02, "csonly" ), MKENUMPAIR( 0x04, "edandcs" ), MKENUMPAIR( 0x08, "cswithtimer" ), MKENUMPAIR( 0x0f, "hrcsanded" )};MKENUM(ccamode);MKENUMPAIRLIST(diversity){ MKENUMPAIR( 1, "fixedlist" ), MKENUMPAIR( 2, "notsupported" ), MKENUMPAIR( 3, "dynamic" )};MKENUM(diversity);MKENUMPAIRLIST(scantype){ MKENUMPAIR( 1, "active" ), MKENUMPAIR( 2, "passive" ), MKENUMPAIR( 3, "both" ),};MKENUM(scantype);MKENUMPAIRLIST(resultcode){ MKENUMPAIR( P80211ENUM_resultcode_success, "success" ), MKENUMPAIR( P80211ENUM_resultcode_invalid_parameters, "invalid_parameters" ), MKENUMPAIR( P80211ENUM_resultcode_not_supported, "not_supported" ), MKENUMPAIR( P80211ENUM_resultcode_timeout, "timeout" ), MKENUMPAIR( P80211ENUM_resultcode_too_many_req, "too_many_req" ), MKENUMPAIR( P80211ENUM_resultcode_refused, "refused" ), MKENUMPAIR( P80211ENUM_resultcode_bss_already, "bss_already" ), MKENUMPAIR( P80211ENUM_resultcode_invalid_access, "invalid_access" ), MKENUMPAIR( P80211ENUM_resultcode_invalid_mibattribute, "invalid_mibattribute" ), MKENUMPAIR( P80211ENUM_resultcode_cant_set_readonly_mib, "cant_set_readonly_mib" ), MKENUMPAIR( P80211ENUM_resultcode_implementation_failure, "implementation_failure" ), MKENUMPAIR( P80211ENUM_resultcode_cant_get_writeonly_mib, "cant_get_writeonly_mib" )};MKENUM(resultcode);/*--------------------------------------------------------------------*//* Note: the following names are from the 802.11 SDL, the comment *//* lists the 802.11 Chapter 7 description. */MKENUMPAIRLIST(reason){ MKENUMPAIR( 1, "unspec_reason" ), /* Unspecified Reason */ MKENUMPAIR( 2, "auth_not_valid" ), /* Previous authentication no longer valid */ MKENUMPAIR( 3, "deauth_lv_ss" ), /* Deauthenticated because sending station is leaving (has left) IBSS or ESS */ MKENUMPAIR( 4, "inactivity" ), /* Disassociated due to inactivity */ MKENUMPAIR( 5, "ap_overload" ), /* Disassociated because AP is unable to handle all currently associated stations */ MKENUMPAIR( 6, "class23_err" ), /* Class 2 or 3 frame received from nonauthenticated station */ MKENUMPAIR( 7, "class3_err" ), /* Class 3 frame received from nonassociated station */ MKENUMPAIR( 8, "disas_lv_ss" ), /* Disassociated because sending station is leaving (has left BSS) */ MKENUMPAIR( 9, "asoc_not_auth" ) /* Station requesting (re)association is not authenticated with responding station */};MKENUM(reason);/*--------------------------------------------------------------------*//* Note: the following names are from the 802.11 SDL, the comment *//* lists the 802.11 Chapter 7 description. */MKENUMPAIRLIST(status){ MKENUMPAIR( 0, "successful" ), /* Successful */ MKENUMPAIR( 1, "unspec_failure" ), /* Unspecified failure */ MKENUMPAIR( 10, "unsup_cap" ), /* Cannot support all requested capabilities in Capability Information field */ MKENUMPAIR( 11, "reasoc_no_asoc" ), /* Reassociation denied due to inability to confirm that association exists */ MKENUMPAIR( 12, "fail_other" ), /* Association denied due to to reason outside scope of this standard */ MKENUMPAIR( 13, "unspt_alg" ), /* Responding station does not support the specified authentication algorithm */ MKENUMPAIR( 14, "auth_seq_fail" ), /* Received and authentication frame with authentication transaction sequence number out of expected sequence */ MKENUMPAIR( 15, "chlng_fail" ), /* Authentication rejected because of challenge failure */ MKENUMPAIR( 16, "auth_timeout" ), /* Authentication rejected due to timeout waiting for next frame in sequence */ MKENUMPAIR( 17, "ap_full" ), /* Association denied because AP is unable to handle additional associated stations */ MKENUMPAIR( 18, "unsup_rate" ) /* Association denied due to requesting station not supporting all of the data rates in the BSSBasicRateSet parameter */};MKENUM(status);/*--------------------------------------------------------------------*//* Note: the following are various error codes for command line input */MKENUMPAIRLIST(msgitem_status){ MKENUMPAIR( 1, "no_value"), /* the argument data doesn't have a value; it wasn't set */ MKENUMPAIR( 2, "argument_item_name_is_invalid" ), /* the argument name doesn't exist in any item name */ MKENUMPAIR( 3, "argument_item_data_is_invalid" ), /* the argument data isn't valid */ MKENUMPAIR( 4, "argument_item_data_is_missing" ), /* the argument data is missing */ MKENUMPAIR( 5, "argument_item_data_is_incomplete" ), /* the argument data is incomplete */ MKENUMPAIR( 6, "invalid_message_did_for_item" ), /* the message did is invalid for argument name */ MKENUMPAIR( 7, "invalid_mib_did_for_item" ), /* the mib did is invalid for argument name */ MKENUMPAIR( 8, "conversion_function_missing_for_item" ), /* a conversion function for the item doesn't exist */ MKENUMPAIR( 9, "data_string_too_long" ), /* the data string exceeds maximum allowed length */ MKENUMPAIR( 10, "data_out_of_range" ), /* the data is out of the allowed range */ MKENUMPAIR( 11, "data_string_too_short" ), /* the data string less than required length */ MKENUMPAIR( 12, "validity_function_missing_for_item" ), /* a validity function for the item doesn't exist */ MKENUMPAIR( 13, "invalid_for_unknown_reason" ), /* data or message is invalid for an unknown reason not caught */ MKENUMPAIR( 14, "invalid_did" ), /* invalid did; not certain if it's a msg or mib did */ MKENUMPAIR( 15, "print_function_missing_for_item" ) /* a print function for the item doesn't exist */};MKENUM(msgitem_status);MKENUMPAIRLIST(lnxroam_reason){ MKENUMPAIR(0, "unknown"), MKENUMPAIR(1, "beacon"), MKENUMPAIR(2, "signal"), MKENUMPAIR(3, "txretry"), MKENUMPAIR(4, "notjoined")};MKENUM(lnxroam_reason);MKENUMPAIRLIST(p2preamble){ MKENUMPAIR( 0, "long"), MKENUMPAIR( 2, "short"), MKENUMPAIR( 3, "mi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -