forked from Mirrors/sngrep
ip: skip IP headers from fragments data
This commit is contained in:
parent
90da49360c
commit
e5f1053174
@ -49,14 +49,12 @@ packet_ip_fragment_sort(const PacketIpFragment **a, const PacketIpFragment **b)
|
||||
}
|
||||
|
||||
static PacketIpFragment *
|
||||
packet_ip_fragment_new(Packet *packet, GBytes *data)
|
||||
packet_ip_fragment_new(Packet *packet)
|
||||
{
|
||||
// Reserve memory for storing fragment information
|
||||
PacketIpFragment *fragment = g_malloc0(sizeof(PacketIpFragment));
|
||||
// Store packet information
|
||||
fragment->packet = packet_ref(packet);
|
||||
// Set fragment payload for future reassembly
|
||||
fragment->data = g_bytes_ref(data);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@ -69,6 +67,13 @@ packet_ip_fragment_free(PacketIpFragment *fragment)
|
||||
g_free(fragment);
|
||||
}
|
||||
|
||||
static void
|
||||
packet_ip_fragment_set_data(PacketIpFragment *fragment, GBytes *data)
|
||||
{
|
||||
// Set fragment payload for future reassembly
|
||||
fragment->data = g_bytes_ref(data);
|
||||
}
|
||||
|
||||
static PacketIpDatagram *
|
||||
packet_ip_datagram_new(const PacketIpFragment *fragment)
|
||||
{
|
||||
@ -160,7 +165,7 @@ packet_dissector_ip_dissect(PacketDissector *self, Packet *packet, GBytes *data)
|
||||
#endif
|
||||
|
||||
// Create an IP fragment for current data
|
||||
PacketIpFragment *fragment = packet_ip_fragment_new(packet, data);
|
||||
PacketIpFragment *fragment = packet_ip_fragment_new(packet);
|
||||
|
||||
// Set IP version
|
||||
fragment->version = ip4->ip_v;
|
||||
@ -227,6 +232,9 @@ packet_dissector_ip_dissect(PacketDissector *self, Packet *packet, GBytes *data)
|
||||
// Get pending payload
|
||||
data = g_bytes_offset(data, fragment->hl);
|
||||
|
||||
// Set fragment data
|
||||
packet_ip_fragment_set_data(fragment, data);
|
||||
|
||||
// If no fragmentation
|
||||
if (fragment->frag == 0) {
|
||||
// Single fragment packet
|
||||
|
Loading…
Reference in New Issue
Block a user