📄 prframe.c
字号:
* phdr - pointer to header of a wireless network frame* index - represents the index into the global array of * frame types * len - length of frame** returns: nothing*----------------------------------------------------------------*/void print_80211_data_header( p80211_hdr_t *phdr, int index, UINT16 len ){ int toDS; int fromDS; print_80211_frame_ctl( phdr, index ); toDS = WLAN_GET_FC_TODS(phdr->a3.fc); fromDS = WLAN_GET_FC_FROMDS(phdr->a3.fc); if ( !toDS && !fromDS ) /* toDS == 0, fromDS == 0 */ { printf("\nDA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a1[0], phdr->a3.a1[1], phdr->a3.a1[2], phdr->a3.a1[3], phdr->a3.a1[4], phdr->a3.a1[5]); printf("SA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a2[0], phdr->a3.a2[1], phdr->a3.a2[2], phdr->a3.a2[3], phdr->a3.a2[4], phdr->a3.a2[5]); printf("BSSID=%02x:%02x:%02x:%02x:%02x:%02x", phdr->a3.a3[0], phdr->a3.a3[1], phdr->a3.a3[2], phdr->a3.a3[3], phdr->a3.a3[4], phdr->a3.a3[5]); } if ( !toDS && fromDS ) /* toDS == 0, fromDS == 1 */ { printf("\nDA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a1[0], phdr->a3.a1[1], phdr->a3.a1[2], phdr->a3.a1[3], phdr->a3.a1[4], phdr->a3.a1[5]); printf("BSSID=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a2[0], phdr->a3.a2[1], phdr->a3.a2[2], phdr->a3.a2[3], phdr->a3.a2[4], phdr->a3.a2[5]); printf("SA=%02x:%02x:%02x:%02x:%02x:%02x", phdr->a3.a3[0], phdr->a3.a3[1], phdr->a3.a3[2], phdr->a3.a3[3], phdr->a3.a3[4], phdr->a3.a3[5]); } if ( toDS && !fromDS ) /* toDS == 1, fromDS == 0 */ { printf("\nBSSID%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a1[0], phdr->a3.a1[1], phdr->a3.a1[2], phdr->a3.a1[3], phdr->a3.a1[4], phdr->a3.a1[5]); printf("SA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a2[0], phdr->a3.a2[1], phdr->a3.a2[2], phdr->a3.a2[3], phdr->a3.a2[4], phdr->a3.a2[5]); printf("DA=%02x:%02x:%02x:%02x:%02x:%02x", phdr->a3.a3[0], phdr->a3.a3[1], phdr->a3.a3[2], phdr->a3.a3[3], phdr->a3.a3[4], phdr->a3.a3[5]); } if ( toDS && fromDS ) /* toDS == 1, fromDS == 1 */ { printf("\nRA%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a1[0], phdr->a3.a1[1], phdr->a3.a1[2], phdr->a3.a1[3], phdr->a3.a1[4], phdr->a3.a1[5]); printf("TA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a2[0], phdr->a3.a2[1], phdr->a3.a2[2], phdr->a3.a2[3], phdr->a3.a2[4], phdr->a3.a2[5]); printf("DA=%02x:%02x:%02x:%02x:%02x:%02x", phdr->a3.a3[0], phdr->a3.a3[1], phdr->a3.a3[2], phdr->a3.a3[3], phdr->a3.a3[4], phdr->a3.a3[5]); printf(" SA=%02x:%02x:%02x:%02x:%02x:%02x", phdr->a4.a4[0], phdr->a4.a4[1], phdr->a4.a4[2], phdr->a4.a4[3], phdr->a4.a4[4], phdr->a4.a4[5]); } printf("\ndur=0x%04x|", phdr->a3.dur); printf("seq fragnum=%u,seq seqnum=%u\n", WLAN_GET_SEQ_FRGNUM(phdr->a3.seq), WLAN_GET_SEQ_SEQNUM(phdr->a3.seq)); if( WLAN_GET_FC_ISWEP(phdr->a3.fc) ) { UINT8 *ptr; ptr = ((UINT8 *)phdr) + WLAN_HDR_A3_LEN; printf("wep.iv=%02x%02x%02x, wep.keyid=%02d, ", ptr[0], ptr[1], ptr[2], (ptr[3] >> 6)); } printf("frame len=%u\n", len );}/*----------------------------------------------------------------* print_80211_mgmt_header** This function decodes and prints the frame header for 802.11* management frames.** Arguments:* phdr - pointer to header of a wireless network frame* index - represents the index into the global array of * frame types * len - length of frame** returns: nothing*----------------------------------------------------------------*/void print_80211_mgmt_header( p80211_hdr_t *phdr, int index, UINT16 len ){ print_80211_frame_ctl( phdr, index ); if( WLAN_GET_FC_ISWEP(phdr->a3.fc) ) { UINT8 *ptr; ptr = ((UINT8 *)phdr) + ((UINT8)(sizeof(p80211_hdr_t))); printf("\nWEP Init Vector=%02x%02x%02x, KeyID=%02d\n", ptr[0], ptr[1], ptr[2], (ptr[3] >> 6)); } printf("\nDA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a1[0], phdr->a3.a1[1], phdr->a3.a1[2], phdr->a3.a1[3], phdr->a3.a1[4], phdr->a3.a1[5]); printf("SA=%02x:%02x:%02x:%02x:%02x:%02x ", phdr->a3.a2[0], phdr->a3.a2[1], phdr->a3.a2[2], phdr->a3.a2[3], phdr->a3.a2[4], phdr->a3.a2[5]); printf("BSSID=%02x:%02x:%02x:%02x:%02x:%02x", phdr->a3.a3[0], phdr->a3.a3[1], phdr->a3.a3[2], phdr->a3.a3[3], phdr->a3.a3[4], phdr->a3.a3[5]); printf("\ndur=0x%04x|", phdr->a3.dur); printf("seq fragnum=%u,seq seqnum=%u\n", WLAN_GET_SEQ_FRGNUM(phdr->a3.seq), WLAN_GET_SEQ_SEQNUM(phdr->a3.seq)); printf("len=%u", len );}/*----------------------------------------------------------------* print_ctl_ack** This function decodes and prints control frames of subtype* acknowledgement.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_ctl_ack( UINT8 *pbuf, int index, UINT16 len ){ /* print 802.11 frame header */ print_80211_ctl_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */}/*----------------------------------------------------------------* print_ctl_cfend** This function decodes and prints control frames of subtype* contention-free end.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_ctl_cfend( UINT8 *pbuf, int index, UINT16 len ){ /* print 802.11 frame header */ print_80211_ctl_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */}/*----------------------------------------------------------------* print_ctl_cfendcfack** This function decodes and prints control frames of subtype* contention-free end acknowledge.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_ctl_cfendcfack( UINT8 *pbuf, int index, UINT16 len ){ /* print 802.11 frame header */ print_80211_ctl_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */}/*----------------------------------------------------------------* print_ctl_cts** This function decodes and prints control frames of subtype* clear to send.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_ctl_cts( UINT8 *pbuf, int index, UINT16 len ){ /* print 802.11 frame header */ print_80211_ctl_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */}/*----------------------------------------------------------------* print_ctl_pspoll** This function decodes and prints control frames of subtype* power-save poll.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_ctl_pspoll( UINT8 *pbuf, int index, UINT16 len ){ /* print 802.11 frame header */ print_80211_ctl_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */}/*----------------------------------------------------------------* print_ctl_rts** This function decodes and prints control frames of subtype* request to send.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_ctl_rts( UINT8 *pbuf, int index, UINT16 len ){ /* print 802.11 frame header */ print_80211_ctl_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */}/*----------------------------------------------------------------* print_data_frame** This function decodes and prints all data type frames.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_data_frame( UINT8 *pbuf, int index, UINT16 len ){ int i; p80211_hdr_t *phdr; /* print 802.11 frame header */ print_80211_data_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for the data frame */ phdr = (p80211_hdr_t *)pbuf; if( WLAN_GET_FC_TODS(phdr->a3.fc) && WLAN_GET_FC_FROMDS(phdr->a3.fc) ) { pbuf = pbuf + WLAN_HDR_A4_LEN; len = len - WLAN_HDR_A4_LEN; } else { pbuf = pbuf + WLAN_HDR_A3_LEN; len = len - WLAN_HDR_A3_LEN; } /* printing of data frame body doesn't include the 4 trailing bytes for the FCS */ len = len - 4; printf(" "); for ( i = 0; i < len && i < opt_showdatalen; i++, pbuf++ ) { printf("%02x ", *pbuf ); if ( (i % 16) == 15 ) { printf("\n "); } }}/*----------------------------------------------------------------* print_mgmt_assocreq** This function decodes and prints management frames of subtype* association request.** Arguments:* pbuf - pointer to the frame buffer* index - index into the global array of frame types for a* particular frame type and subtype* len - the number of bytes in the frame** returns: nothing*----------------------------------------------------------------*/void print_mgmt_assocreq( UINT8 *pbuf, int index, UINT16 len ){ wlan_fr_assocreq_t frame; wlan_p80211_frame_fields_t fixed_fields[TOTAL_MGMT_FIXED_FIELDS]; wlan_p80211_frame_fields_t info_elements[TOTAL_MGMT_INFO_ELEMENTS]; /* print 802.11 frame header */ print_80211_mgmt_header( (p80211_hdr_t *)pbuf, index, len ); /* print management frame body for this management frame subtype */ memset( (void *)fixed_fields, 0, (sizeof(wlan_p80211_frame_fields_t) * TOTAL_MGMT_FIXED_FIELDS)); memset( (void *)info_elements, 0, (sizeof(wlan_p80211_frame_fields_t) * TOTAL_MGMT_INFO_ELEMENTS)); memset( (void *)&frame, 0, sizeof(wlan_fr_assocreq_t) ); frame.buf = pbuf; /* decode functions assume the 4 trailing bytes for the FCS aren't included in the length */ frame.len = len - 4; wlan_mgmt_decode_assocreq( &frame ); fixed_fields[MGMT_FF_CAP_INFO].exists = TRUE; fixed_fields[MGMT_FF_CAP_INFO].info = (void *)frame.cap_info; fixed_fields[MGMT_FF_LISTEN_INT].exists = TRUE; fixed_fields[MGMT_FF_LISTEN_INT].info = (void *)frame.listen_int; info_elements[MGMT_IE_SSID].exists = TRUE; info_elements[MGMT_IE_SSID].info = (void *)frame.ssid; info_elements[MGMT_IE_SUPP_RATES].exists = TRUE; info_elements[MGMT_IE_SUPP_RATES].info = (void *)frame.supp_rates; print_fixed_fields( fixed_fields, len ); print_info_elements( info_elements, len );}/*----------------------------------------------------------------* print_mgmt_assocresp** This function decodes and prints management frames of subtype* association response.*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -