mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Changes to IPv6 ext. header parsing (addresses #795).
In response to feedback from Robin: - rename "ip_hdr" to "ip4_hdr" - pkt_hdr$ip6 is now of type "ip6_hdr" instead of "ip6_hdr_chain" - "ip6_hdr_chain" no longer contains an "ip6_hdr" field, instead it's the other way around, "ip6_hdr" contains an "ip6_hdr_chain" - other internal refactoring
This commit is contained in:
parent
f11fca588e
commit
1c1d657039
10 changed files with 491 additions and 449 deletions
18
src/Frag.cc
18
src/Frag.cc
|
@ -34,10 +34,13 @@ FragReassembler::FragReassembler(NetSessions* arg_s,
|
|||
key = k;
|
||||
|
||||
// [Robin] Can't we merge these two cases now?
|
||||
// [Jon] I think we'll always have to check v4 versus v6 to get the correct
|
||||
// proto_hdr_len unless IP_Hdr::HdrLen itself makes a special case for
|
||||
// IPv6 fragments (but that seems more confusing to me)
|
||||
const struct ip* ip4 = ip->IP4_Hdr();
|
||||
if ( ip4 )
|
||||
{
|
||||
proto_hdr_len = ip4->ip_hl * 4; // [Robin] HdrLen?
|
||||
proto_hdr_len = ip->HdrLen();
|
||||
proto_hdr = new u_char[64]; // max IP header + slop
|
||||
// Don't do a structure copy - need to pick up options, too.
|
||||
memcpy((void*) proto_hdr, (const void*) ip4, proto_hdr_len);
|
||||
|
@ -247,12 +250,7 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */)
|
|||
reassembled_pkt = new IP_Hdr(reassem4, true);
|
||||
}
|
||||
|
||||
// [Robin] Please always check for IP version explicitly, like here
|
||||
// do "if ... ip_v == 6", and then catch other values via
|
||||
// weird/errors. Even of it shouldn't happen (because of earlier
|
||||
// checks), it's better to be safe. I believe there are more places
|
||||
// like this elsewhere, please check.
|
||||
else
|
||||
else if ( ((const struct ip*)pkt_start)->ip_v == 6 )
|
||||
{
|
||||
struct ip6_hdr* reassem6 = (struct ip6_hdr*) pkt_start;
|
||||
reassem6->ip6_plen = htons(frag_size + proto_hdr_len - 40);
|
||||
|
@ -260,6 +258,12 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */)
|
|||
reassembled_pkt = new IP_Hdr(reassem6, true, chain);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
reporter->InternalError("bad IP version in fragment reassembly");
|
||||
}
|
||||
|
||||
|
||||
DeleteTimer();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue