mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Refactoring L2 parsing code to reside in the Packet class.
That way it can be reused more easily. This also avoid having to change the serialization structure for packets, which is a problem as external sources of packets (via Broccoli) wouldn't have the new attributes available to send. Also moving Packet.{h,cc} and Layer2.{h,cc} into iosource/, and removing header size from properties that packet sources have to provide, as we can now compute that easily from the link type. Plus some more cleanup.
This commit is contained in:
parent
64a478dbd5
commit
c72d191ab5
17 changed files with 43 additions and 437 deletions
|
@ -1136,9 +1136,7 @@ bool Packet::Serialize(SerialInfo* info) const
|
|||
return SERIALIZE(uint32(ts.tv_sec)) &&
|
||||
SERIALIZE(uint32(ts.tv_usec)) &&
|
||||
SERIALIZE(uint32(len)) &&
|
||||
SERIALIZE(uint32(link_type)) &&
|
||||
SERIALIZE(uint32(hdr_size)) &&
|
||||
SERIALIZE(uint32(l3_proto)) &&
|
||||
SERIALIZE(link_type) &&
|
||||
info->s->Write(tag.c_str(), tag.length(), "tag") &&
|
||||
info->s->Write((const char*)data, cap_len, "data");
|
||||
}
|
||||
|
@ -1152,14 +1150,12 @@ static iosource::PktDumper* dump = 0;
|
|||
Packet* Packet::Unserialize(UnserialInfo* info)
|
||||
{
|
||||
struct timeval ts;
|
||||
uint32 len, link_type, hdr_size, l3_proto;
|
||||
uint32 len, link_type;
|
||||
|
||||
if ( ! (UNSERIALIZE((uint32 *)&ts.tv_sec) &&
|
||||
UNSERIALIZE((uint32 *)&ts.tv_usec) &&
|
||||
UNSERIALIZE(&len) &&
|
||||
UNSERIALIZE(&link_type) &&
|
||||
UNSERIALIZE(&hdr_size) &&
|
||||
UNSERIALIZE(&l3_proto)) )
|
||||
UNSERIALIZE(&link_type)) )
|
||||
return 0;
|
||||
|
||||
char* tag;
|
||||
|
@ -1175,7 +1171,7 @@ Packet* Packet::Unserialize(UnserialInfo* info)
|
|||
}
|
||||
|
||||
Packet *p = new Packet(link_type, &ts, caplen, len, pkt, true,
|
||||
std::string(tag), hdr_size, (Layer3Proto) l3_proto);
|
||||
std::string(tag));
|
||||
delete [] tag;
|
||||
|
||||
// For the global timer manager, we take the global network_time as the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue