Moved link-layer addresses into endpoints.

The link-layer addresses are now part of the connection endpoints
following the originator-responder-pattern. The addresses are printed
with leading zeros. Additionally link-layer addresses are also extracted
for 802.11 plus RadioTap.
This commit is contained in:
Jan Grashoefer 2016-06-02 01:46:26 +02:00
parent a2423f7d43
commit 50cf694aae
19 changed files with 470 additions and 442 deletions

View file

@ -1,8 +1,6 @@
#ifndef packet_h
#define packet_h
#include <netinet/ether.h>
#include "Desc.h"
#include "IP.h"
#include "NetVar.h"
@ -53,7 +51,7 @@ public:
Packet(int link_type, struct timeval *ts, uint32 caplen,
uint32 len, const u_char *data, int copy = false,
std::string tag = std::string(""))
: data(0), eth_src(), eth_dst()
: data(0), l2_src(0), l2_dst(0)
{
Init(link_type, ts, caplen, len, data, copy, tag);
}
@ -61,7 +59,7 @@ public:
/**
* Default constructor. For internal use only.
*/
Packet() : data(0), eth_src(), eth_dst()
Packet() : data(0), l2_src(0), l2_dst(0)
{
struct timeval ts = {0, 0};
Init(0, &ts, 0, 0, 0);
@ -154,7 +152,7 @@ public:
double time; /// Timestamp reconstituted as float
struct timeval ts; /// Capture timestamp
const u_char* data; /// Packet data.
uint32 len; /// Actual length on wire
uint32 len; /// Actual length on wire
uint32 cap_len; /// Captured packet length
uint32 link_type; /// pcap link_type (DLT_EN10MB, DLT_RAW, etc)
@ -179,16 +177,15 @@ public:
uint32 eth_type;
/**
* If layer 2 is Ethernet, the source MAC address. Valid iff
* Layer2Valid() returns true.
* Layer 2 source address. Valid iff Layer2Valid() returns true.
*/
ether_addr eth_src[6];
const u_char* l2_src;
/**
* If layer 2 is Ethernet, the destiantion MAC address. Valid iff
* Layer2Valid() returns true.
* Layer 2 destination address. Valid iff Layer2Valid() returns
* true.
*/
ether_addr eth_dst[6];
const u_char* l2_dst;
/**
* (Outermost) VLAN tag if any, else 0. Valid iff Layer2Valid()