define mac_header in utils
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "ether_encap_impl.h"
|
#include "ether_encap_impl.h"
|
||||||
#include "ofdm_parse_mac_impl.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
@@ -48,12 +47,12 @@ ether_encap_impl::from_wifi(pmt::pmt_t msg) {
|
|||||||
int data_len = pmt::blob_length(msg);
|
int data_len = pmt::blob_length(msg);
|
||||||
const mac_header *mhdr = reinterpret_cast<const mac_header*>(pmt::blob_data(msg));
|
const mac_header *mhdr = reinterpret_cast<const mac_header*>(pmt::blob_data(msg));
|
||||||
|
|
||||||
if(d_last_seq == mhdr->seq_control) {
|
if(d_last_seq == mhdr->seq_nr) {
|
||||||
dout << "Ether Encap: frame already seen -- skipping" << std::endl;
|
dout << "Ether Encap: frame already seen -- skipping" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_last_seq = mhdr->seq_control;
|
d_last_seq = mhdr->seq_nr;
|
||||||
|
|
||||||
|
|
||||||
if(data_len < 33) {
|
if(data_len < 33) {
|
||||||
|
|||||||
+27
-33
@@ -100,46 +100,39 @@ void app_in (pmt::pmt_t msg) {
|
|||||||
|
|
||||||
void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int *psdu_size) {
|
void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int *psdu_size) {
|
||||||
|
|
||||||
//mac frame
|
// mac header
|
||||||
MAC_DATAFRAME_HEADER header;
|
mac_header header;
|
||||||
//frame check sequence
|
header.frame_control = 0x0008;
|
||||||
unsigned int fcs;
|
header.duration = 0x002e;
|
||||||
|
|
||||||
// TODO: change this back to 0x08
|
header.addr1[0] = 0x30;
|
||||||
header.frame_control[0] = 0x08;//0x20; //00000100 00100000 indicate DATA frame (LOL, not), to_ds, from_ds, more frag, retry
|
header.addr1[1] = 0x14;
|
||||||
header.frame_control[1] = 0x00;//0x40; //all other flags, unutilized //00000010 01000000
|
header.addr1[2] = 0x4a;
|
||||||
|
header.addr1[3] = 0xe6;
|
||||||
|
header.addr1[4] = 0x46;
|
||||||
|
header.addr1[5] = 0xe4;
|
||||||
|
|
||||||
header.duration[0] = 0x00; //TODO: set accordingly to payload
|
header.addr2[0] = 0x12;
|
||||||
header.duration[1] = 0x2e; //0x74; //2e = 00101110 -> 01110100 -> 74
|
header.addr2[1] = 0x34;
|
||||||
|
header.addr2[2] = 0x56;
|
||||||
|
header.addr2[3] = 0x78;
|
||||||
|
header.addr2[4] = 0x90;
|
||||||
|
header.addr2[5] = 0xab;
|
||||||
|
|
||||||
header.address1[0] = 0x30;
|
header.addr3[0] = 0x42;
|
||||||
header.address1[1] = 0x14;
|
header.addr3[1] = 0x42;
|
||||||
header.address1[2] = 0x4a;
|
header.addr3[2] = 0x42;
|
||||||
header.address1[3] = 0xe6;
|
header.addr3[3] = 0x42;
|
||||||
header.address1[4] = 0x46;
|
header.addr3[4] = 0x42;
|
||||||
header.address1[5] = 0xe4;
|
header.addr3[5] = 0x42;
|
||||||
|
|
||||||
header.address2[0] = 0x12;
|
header.seq_nr = 0;
|
||||||
header.address2[1] = 0x34;
|
|
||||||
header.address2[2] = 0x56;
|
|
||||||
header.address2[3] = 0x78;
|
|
||||||
header.address2[4] = 0x90;
|
|
||||||
header.address2[5] = 0xab;
|
|
||||||
|
|
||||||
header.address3[0] = 0x42;
|
|
||||||
header.address3[1] = 0x42;
|
|
||||||
header.address3[2] = 0x42;
|
|
||||||
header.address3[3] = 0x42;
|
|
||||||
header.address3[4] = 0x42;
|
|
||||||
header.address3[5] = 0x42;
|
|
||||||
|
|
||||||
header.sequence = 0;
|
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
if(d_seq_nr & (1 << i)) {
|
if(d_seq_nr & (1 << i)) {
|
||||||
header.sequence |= (1 << (i + 4));
|
header.seq_nr |= (1 << (i + 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header.sequence = htole16(header.sequence);
|
header.seq_nr = htole16(header.seq_nr);
|
||||||
d_seq_nr++;
|
d_seq_nr++;
|
||||||
|
|
||||||
//header size is 24, plus 4 for FCS means 28 bytes
|
//header size is 24, plus 4 for FCS means 28 bytes
|
||||||
@@ -153,7 +146,8 @@ void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int *
|
|||||||
//compute and store fcs
|
//compute and store fcs
|
||||||
boost::crc_32_type result;
|
boost::crc_32_type result;
|
||||||
result.process_bytes(*psdu, msdu_size + 24);
|
result.process_bytes(*psdu, msdu_size + 24);
|
||||||
fcs = result.checksum();
|
|
||||||
|
unsigned int fcs = result.checksum();
|
||||||
memcpy(*psdu + msdu_size + 24, &fcs, sizeof(unsigned int));
|
memcpy(*psdu + msdu_size + 24, &fcs, sizeof(unsigned int));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <ieee802-11/ofdm_parse_mac.h>
|
#include <ieee802-11/ofdm_parse_mac.h>
|
||||||
#include "ofdm_parse_mac_impl.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
@@ -179,7 +178,7 @@ void parse_management(char *buf, int length) {
|
|||||||
}
|
}
|
||||||
dout << std::endl;
|
dout << std::endl;
|
||||||
|
|
||||||
dout << "seq nr: " << int(h->seq_control >> 4) << std::endl;
|
dout << "seq nr: " << int(h->seq_nr >> 4) << std::endl;
|
||||||
dout << "mac 1: ";
|
dout << "mac 1: ";
|
||||||
print_mac_address(h->addr1, true);
|
print_mac_address(h->addr1, true);
|
||||||
dout << "mac 2: ";
|
dout << "mac 2: ";
|
||||||
@@ -252,7 +251,7 @@ void parse_data(char *buf, int length) {
|
|||||||
}
|
}
|
||||||
dout << std::endl;
|
dout << std::endl;
|
||||||
|
|
||||||
dout << "seq nr: " << int(h->seq_control >> 4) << std::endl;
|
dout << "seq nr: " << int(h->seq_nr >> 4) << std::endl;
|
||||||
dout << "mac 1: ";
|
dout << "mac 1: ";
|
||||||
print_mac_address(h->addr1, true);
|
print_mac_address(h->addr1, true);
|
||||||
dout << "mac 2: ";
|
dout << "mac 2: ";
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef INCLUDED_IEEE802_11_OFDM_PARSE_MAC_IMPL_H
|
|
||||||
#define INCLUDED_IEEE802_11_OFDM_PARSE_MAC_IMPL_H
|
|
||||||
|
|
||||||
struct mac_header {
|
|
||||||
uint16_t frame_control;
|
|
||||||
uint16_t duration;
|
|
||||||
uint8_t addr1[6];
|
|
||||||
uint8_t addr2[6];
|
|
||||||
uint8_t addr3[6];
|
|
||||||
uint16_t seq_control;
|
|
||||||
}__attribute__((packed));
|
|
||||||
|
|
||||||
#endif /* INCLUDED_IEEE802_11_OFDM_PARSE_MAC_IMPL_H */
|
|
||||||
|
|
||||||
+7
-7
@@ -36,14 +36,14 @@ extern const std::complex<double> QPSK_D[4];
|
|||||||
extern const std::complex<double> QAM16_D[16];
|
extern const std::complex<double> QAM16_D[16];
|
||||||
extern const std::complex<double> QAM64_D[64];
|
extern const std::complex<double> QAM64_D[64];
|
||||||
|
|
||||||
struct MAC_DATAFRAME_HEADER {
|
struct mac_header {
|
||||||
//protocol version, type, subtype, to_ds, from_ds, ...
|
//protocol version, type, subtype, to_ds, from_ds, ...
|
||||||
char frame_control[2];
|
uint16_t frame_control;
|
||||||
char duration[2];
|
uint16_t duration;
|
||||||
char address1[6];
|
uint8_t addr1[6];
|
||||||
char address2[6];
|
uint8_t addr2[6];
|
||||||
char address3[6];
|
uint8_t addr3[6];
|
||||||
uint16_t sequence;
|
uint16_t seq_nr;
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user