mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Cleanup in iosource/Packet
This commit is contained in:
parent
c6f7665953
commit
ce17a1f38b
2 changed files with 13 additions and 11 deletions
|
@ -43,16 +43,16 @@ void Packet::Init(int arg_link_type, pkt_timeval *arg_ts, uint32_t arg_caplen,
|
||||||
|
|
||||||
time = ts.tv_sec + double(ts.tv_usec) / 1e6;
|
time = ts.tv_sec + double(ts.tv_usec) / 1e6;
|
||||||
hdr_size = GetLinkHeaderSize(arg_link_type);
|
hdr_size = GetLinkHeaderSize(arg_link_type);
|
||||||
l3_proto = L3_UNKNOWN;
|
|
||||||
eth_type = 0;
|
eth_type = 0;
|
||||||
vlan = 0;
|
vlan = 0;
|
||||||
inner_vlan = 0;
|
inner_vlan = 0;
|
||||||
l2_src = 0;
|
|
||||||
l2_dst = 0;
|
|
||||||
|
|
||||||
|
l2_src = nullptr;
|
||||||
|
l2_dst = nullptr;
|
||||||
l2_valid = false;
|
l2_valid = false;
|
||||||
|
|
||||||
l2_checksummed = false;
|
l2_checksummed = false;
|
||||||
|
|
||||||
|
l3_proto = L3_UNKNOWN;
|
||||||
l3_checksummed = false;
|
l3_checksummed = false;
|
||||||
|
|
||||||
if ( data && cap_len < hdr_size )
|
if ( data && cap_len < hdr_size )
|
||||||
|
|
|
@ -19,12 +19,14 @@ class RecordVal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Layer 3 type of a packet, as determined by the parsing code in Packet.
|
* The Layer 3 type of a packet, as determined by the parsing code in Packet.
|
||||||
|
* This enum is sized as an int32_t to make the Packet structure align
|
||||||
|
* correctly.
|
||||||
*/
|
*/
|
||||||
enum Layer3Proto {
|
enum Layer3Proto : int32_t {
|
||||||
L3_UNKNOWN = -1, /// Layer 3 type could not be determined.
|
L3_UNKNOWN = -1, /// Layer 3 type could not be determined.
|
||||||
L3_IPV4 = 1, /// Layer 3 is IPv4.
|
L3_IPV4 = 1, /// Layer 3 is IPv4.
|
||||||
L3_IPV6 = 2, /// Layer 3 is IPv6.
|
L3_IPV6 = 2, /// Layer 3 is IPv6.
|
||||||
L3_ARP = 3, /// Layer 3 is ARP.
|
L3_ARP = 3, /// Layer 3 is ARP.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +112,7 @@ public:
|
||||||
* Returns true if parsing the layer 2 fields failed, including when
|
* Returns true if parsing the layer 2 fields failed, including when
|
||||||
* no data was passed into the constructor in the first place.
|
* no data was passed into the constructor in the first place.
|
||||||
*/
|
*/
|
||||||
bool Layer2Valid()
|
bool Layer2Valid() const
|
||||||
{
|
{
|
||||||
return l2_valid;
|
return l2_valid;
|
||||||
}
|
}
|
||||||
|
@ -212,14 +214,14 @@ public:
|
||||||
bool l3_checksummed;
|
bool l3_checksummed;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Calculate layer 2 attributes. Sets
|
// Calculate layer 2 attributes.
|
||||||
void ProcessLayer2();
|
void ProcessLayer2();
|
||||||
|
|
||||||
// Wrapper to generate a packet-level weird.
|
// Wrapper to generate a packet-level weird.
|
||||||
void Weird(const char* name);
|
void Weird(const char* name);
|
||||||
|
|
||||||
// Renders an MAC address into its ASCII representation.
|
// Renders an MAC address into its ASCII representation.
|
||||||
Val *FmtEUI48(const u_char *mac) const;
|
Val* FmtEUI48(const u_char *mac) const;
|
||||||
|
|
||||||
// True if we need to delete associated packet memory upon
|
// True if we need to delete associated packet memory upon
|
||||||
// destruction.
|
// destruction.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue