我正在通过pcap和无线工作.根据我之前的问题回复发布的示例,我试图从无线帧中提取mac地址.我已经为radiotap头和基本管理框架创建了结构.出于某种原因,当涉及到尝试输出mac地址时,我打印出错误的数据.当我与wireshark比较时,我不明白为什么无线电数据打印正确但mac地址不正确.当我查看数据包并比较我捕获的数据包时,我看不到wireshark显示的十六进制转储中的任何额外填充.我有点熟悉c但不是专家所以也许我没有正确使用指针和结构有人可以帮助告诉我我做错了什么?
谢谢,昆汀
// main.c
// MacSniffer
//
#include <pcap.h>
#include <string.h>
#include <stdlib.h>
#define MAXBYTES2CAPTURE 65535
#ifdef WORDS_BIGENDIAN
typedef struct frame_control
{
unsigned int subtype:4; /*frame subtype field*/
unsigned int protoVer:2; /*frame type field*/
unsigned int version:2; /*protocol version*/
unsigned int order:1;
unsigned int protected:1;
unsigned int moreDate:1;
unsigned int power_management:1;
unsigned int retry:1;
unsigned int moreFrag:1;
unsigned int fromDS:1;
unsigned int toDS:1;
}frame_control;
struct ieee80211_radiotap_header{
u_int8_t it_version;
u_int8_t it_pad;
u_int16_t it_len;
u_int32_t it_present;
u_int64_t MAC_timestamp;
u_int8_t flags;
u_int8_t dataRate; …
Run Code Online (Sandbox Code Playgroud)