wireshark: add radiotap header
This commit is contained in:
@@ -37,7 +37,7 @@ wireshark_connector_impl::wireshark_connector_impl(LinkType type, bool debug) :
|
|||||||
|
|
||||||
message_port_register_in(pmt::mp("in"));
|
message_port_register_in(pmt::mp("in"));
|
||||||
|
|
||||||
pcap_global *hdr = (pcap_global*)d_msg;
|
pcap_file_hdr *hdr = (pcap_file_hdr*)d_msg;
|
||||||
hdr->magic_number = 0xa1b2c3d4;
|
hdr->magic_number = 0xa1b2c3d4;
|
||||||
hdr->version_major = 2;
|
hdr->version_major = 2;
|
||||||
hdr->version_minor = 4;
|
hdr->version_minor = 4;
|
||||||
@@ -45,7 +45,7 @@ wireshark_connector_impl::wireshark_connector_impl(LinkType type, bool debug) :
|
|||||||
hdr->sigfigs = 0;
|
hdr->sigfigs = 0;
|
||||||
hdr->snaplen = 65535;
|
hdr->snaplen = 65535;
|
||||||
hdr->network = d_link;
|
hdr->network = d_link;
|
||||||
d_msg_len = sizeof(pcap_global);
|
d_msg_len = sizeof(pcap_file_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
wireshark_connector_impl::~wireshark_connector_impl() {
|
wireshark_connector_impl::~wireshark_connector_impl() {
|
||||||
@@ -56,16 +56,48 @@ wireshark_connector_impl::copy_message(const char *buf, int len) {
|
|||||||
|
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
gettimeofday(&t, NULL);
|
gettimeofday(&t, NULL);
|
||||||
|
std::size_t offset = 0;
|
||||||
|
|
||||||
pcap_pkt hdr;
|
// radiotap header
|
||||||
hdr.ts_sec = t.tv_sec;
|
switch(d_link) {
|
||||||
hdr.ts_usec = t.tv_usec;
|
case WIFI: {
|
||||||
hdr.incl_len = len;
|
// pcap header
|
||||||
hdr.orig_len = len;
|
pcap_hdr *hdr = reinterpret_cast<pcap_hdr*>(d_msg);
|
||||||
|
hdr->ts_sec = t.tv_sec;
|
||||||
|
hdr->ts_usec = t.tv_usec;
|
||||||
|
hdr->incl_len = len + sizeof(radiotap_hdr);
|
||||||
|
hdr->orig_len = len + sizeof(radiotap_hdr);
|
||||||
|
offset += sizeof(struct pcap_hdr);
|
||||||
|
|
||||||
memcpy(d_msg, &hdr, sizeof(pcap_pkt));
|
radiotap_hdr *rhdr = reinterpret_cast<radiotap_hdr*>(d_msg + offset);
|
||||||
memcpy(d_msg + sizeof(pcap_pkt), buf, len);
|
rhdr->version = 0;
|
||||||
d_msg_len = sizeof(pcap_pkt) + len;
|
rhdr->hdr_length = sizeof(radiotap_hdr);
|
||||||
|
rhdr->bitmap = 0x0000086e;
|
||||||
|
rhdr->flags = 0;
|
||||||
|
rhdr->rate = 12;
|
||||||
|
rhdr->channel = 178;
|
||||||
|
rhdr->signal = 42;
|
||||||
|
rhdr->noise = 23;
|
||||||
|
rhdr->antenna = 1;
|
||||||
|
offset += sizeof(struct radiotap_hdr);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ZIGBEE: {
|
||||||
|
|
||||||
|
pcap_hdr *hdr = reinterpret_cast<pcap_hdr*>(d_msg);
|
||||||
|
hdr->ts_sec = t.tv_sec;
|
||||||
|
hdr->ts_usec = t.tv_usec;
|
||||||
|
hdr->incl_len = len;
|
||||||
|
hdr->orig_len = len;
|
||||||
|
offset += sizeof(pcap_hdr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(d_msg + offset, buf, len);
|
||||||
|
d_msg_len = offset + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace foo {
|
|||||||
void copy_message(const char *buf, int len);
|
void copy_message(const char *buf, int len);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pcap_global {
|
struct pcap_file_hdr {
|
||||||
uint32_t magic_number; /* magic number */
|
uint32_t magic_number; /* magic number */
|
||||||
uint16_t version_major; /* major version number */
|
uint16_t version_major; /* major version number */
|
||||||
uint16_t version_minor; /* minor version number */
|
uint16_t version_minor; /* minor version number */
|
||||||
@@ -49,13 +49,25 @@ namespace foo {
|
|||||||
uint32_t network; /* data link type */
|
uint32_t network; /* data link type */
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
|
||||||
struct pcap_pkt {
|
struct pcap_hdr {
|
||||||
uint32_t ts_sec; /* timestamp seconds */
|
uint32_t ts_sec; /* timestamp seconds */
|
||||||
uint32_t ts_usec; /* timestamp microseconds */
|
uint32_t ts_usec; /* timestamp microseconds */
|
||||||
uint32_t incl_len; /* number of octets of packet saved in file */
|
uint32_t incl_len; /* number of octets of packet saved in file */
|
||||||
uint32_t orig_len; /* actual length of packet */
|
uint32_t orig_len; /* actual length of packet */
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
struct radiotap_hdr {
|
||||||
|
uint16_t version;
|
||||||
|
uint16_t hdr_length;
|
||||||
|
uint32_t bitmap;
|
||||||
|
uint8_t flags;
|
||||||
|
uint8_t rate;
|
||||||
|
uint32_t channel;
|
||||||
|
uint8_t signal;
|
||||||
|
uint8_t noise;
|
||||||
|
uint8_t antenna;
|
||||||
|
}__attribute__((packed));
|
||||||
|
|
||||||
} // namespace foo
|
} // namespace foo
|
||||||
} // namespace gr
|
} // namespace gr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user