📄 p80211frm.c
字号:
(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_REASSOCRESP_OFF_SUPP_RATES); return;}/*--------------------------------------------------------------* wlan_mgmt_encode_probereq** Receives an fr_mgmt struct with its len and buf set. Fills* in the rest of the members as far as possible. On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields. For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len, buf, and priv are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_encode_probereq( wlan_fr_probereq_t *f ){ f->type = WLAN_FSTYPE_PROBEREQ; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT( f->len >= WLAN_PROBEREQ_FR_MAXLEN ); f->len = WLAN_HDR_A3_LEN; return;}/*--------------------------------------------------------------* wlan_mgmt_decode_probereq** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len and buf are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_decode_probereq( wlan_fr_probereq_t *f ){ wlan_ie_t *ie_ptr; f->type = WLAN_FSTYPE_PROBEREQ; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT(WLAN_FTYPE_MGMT == WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc))); WLAN_ASSERT(WLAN_FSTYPE_PROBEREQ == WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc))); /*-- Fixed Fields ----*/ /*-- Information elements */ ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBEREQ_OFF_SSID); while( ((UINT8*)ie_ptr) < (f->buf + f->len) ) { switch (ie_ptr->eid) { case WLAN_EID_SSID: f->ssid = (wlan_ie_ssid_t*)ie_ptr; break; case WLAN_EID_SUPP_RATES: f->supp_rates = (wlan_ie_supp_rates_t*)ie_ptr; break; default: WLAN_LOG_WARNING1( "Unrecognized EID=%dd in probereq decode.\n", ie_ptr->eid); WLAN_HEX_DUMP(3, "frm w/ bad eid:", f->buf, f->len ); break; } ie_ptr = (wlan_ie_t*)(((UINT8*)ie_ptr) + 2 + ie_ptr->len); } return;}/*--------------------------------------------------------------* wlan_mgmt_encode_proberesp** Receives an fr_mgmt struct with its len and buf set. Fills* in the rest of the members as far as possible. On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields. For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len, buf, and priv are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_encode_proberesp( wlan_fr_proberesp_t *f ){ f->type = WLAN_FSTYPE_PROBERESP; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT( f->len >= WLAN_PROBERESP_FR_MAXLEN ); /*-- Fixed Fields ----*/ f->ts =(UINT64*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_TS); f->bcn_int =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_BCN_INT); f->cap_info =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_CAP_INFO); f->len = WLAN_HDR_A3_LEN + WLAN_PROBERESP_OFF_CAP_INFO + sizeof(*(f->cap_info)); return;}/*--------------------------------------------------------------* wlan_mgmt_decode_proberesp** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len and buf are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_decode_proberesp( wlan_fr_proberesp_t *f ){ wlan_ie_t *ie_ptr; f->type = WLAN_FSTYPE_PROBERESP; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT(WLAN_FTYPE_MGMT == WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc))); WLAN_ASSERT(WLAN_FSTYPE_PROBERESP == WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc))); /*-- Fixed Fields ----*/ f->ts =(UINT64*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_TS); f->bcn_int =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_BCN_INT); f->cap_info =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_CAP_INFO); /*-- Information elements */ ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_PROBERESP_OFF_SSID); while( ((UINT8*)ie_ptr) < (f->buf + f->len) ) { switch (ie_ptr->eid) { case WLAN_EID_SSID: f->ssid = (wlan_ie_ssid_t*)ie_ptr; break; case WLAN_EID_SUPP_RATES: f->supp_rates = (wlan_ie_supp_rates_t*)ie_ptr; break; case WLAN_EID_FH_PARMS: f->fh_parms = (wlan_ie_fh_parms_t*)ie_ptr; break; case WLAN_EID_DS_PARMS: f->ds_parms = (wlan_ie_ds_parms_t*)ie_ptr; break; case WLAN_EID_CF_PARMS: f->cf_parms = (wlan_ie_cf_parms_t*)ie_ptr; break; case WLAN_EID_IBSS_PARMS: f->ibss_parms = (wlan_ie_ibss_parms_t*)ie_ptr; break; default: WLAN_LOG_WARNING2( "Bad EID=%dd in proberesp, off=%d .\n", ie_ptr->eid, f->buf - (UINT8*)ie_ptr); WLAN_HEX_DUMP(3, "frm w/ bad eid:", f->buf, f->len ); break; } ie_ptr = (wlan_ie_t*)(((UINT8*)ie_ptr) + 2 + ie_ptr->len); } return;}/*--------------------------------------------------------------* wlan_mgmt_encode_authen** Receives an fr_mgmt struct with its len and buf set. Fills* in the rest of the members as far as possible. On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields. For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len, buf, and priv are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_encode_authen( wlan_fr_authen_t *f ){ f->type = WLAN_FSTYPE_AUTHEN; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT( f->len >= WLAN_AUTHEN_FR_MAXLEN ); /*-- Fixed Fields ----*/ f->auth_alg =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_AUTH_ALG); f->auth_seq =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_AUTH_SEQ); f->status =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_STATUS); f->len = WLAN_HDR_A3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(f->status)); return;}/*--------------------------------------------------------------* wlan_mgmt_decode_authen** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len and buf are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_decode_authen( wlan_fr_authen_t *f ){ wlan_ie_t *ie_ptr; f->type = WLAN_FSTYPE_AUTHEN; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT(WLAN_FTYPE_MGMT == WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc))); WLAN_ASSERT(WLAN_FSTYPE_AUTHEN == WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc))); /*-- Fixed Fields ----*/ f->auth_alg =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_AUTH_ALG); f->auth_seq =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_AUTH_SEQ); f->status =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_STATUS); /*-- Information elements */ ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_AUTHEN_OFF_CHALLENGE); if ((((UINT8*)ie_ptr) < (f->buf + f->len)) && (ie_ptr->eid == WLAN_EID_CHALLENGE) ) { f->challenge = (wlan_ie_challenge_t*)ie_ptr; } return;}/*--------------------------------------------------------------* wlan_mgmt_encode_deauthen** Receives an fr_mgmt struct with its len and buf set. Fills* in the rest of the members as far as possible. On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields. For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len, buf, and priv are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_encode_deauthen( wlan_fr_deauthen_t *f ){ f->type = WLAN_FSTYPE_DEAUTHEN; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT( f->len >= WLAN_DEAUTHEN_FR_MAXLEN ); /*-- Fixed Fields ----*/ f->reason =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_DEAUTHEN_OFF_REASON); f->len = WLAN_HDR_A3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(f->reason)); return;}/*--------------------------------------------------------------* wlan_mgmt_decode_deauthen** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:* 1) f->len and f->buf are already set* 2) f->len is the length of the MAC header + data, the CRC* is NOT included* 3) all members except len and buf are zero** Arguments:* f frame structure ** Returns:* nothing** Side effects:* frame structure members are pointing at their* respective portions of the frame buffer.--------------------------------------------------------------*/void wlan_mgmt_decode_deauthen( wlan_fr_deauthen_t *f ){ f->type = WLAN_FSTYPE_DEAUTHEN; f->hdr = (p80211_hdr_t*)f->buf; WLAN_ASSERT(WLAN_FTYPE_MGMT == WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc))); WLAN_ASSERT(WLAN_FSTYPE_DEAUTHEN == WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc))); /*-- Fixed Fields ----*/ f->reason =(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + WLAN_DEAUTHEN_OFF_REASON); /*-- Information elements */ return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -