support IPv4 & IPv6 frag reassemble
This commit is contained in:
@@ -861,12 +861,12 @@ static inline const char *parse_ipv4(struct packet *handler, const char *data, u
|
||||
return data;
|
||||
}
|
||||
struct ip *hdr = (struct ip *)data;
|
||||
uint8_t next_proto = ipv4_get_proto(hdr);
|
||||
uint8_t next_proto = ipv4_hdr_get_proto(hdr);
|
||||
uint16_t hdr_len = ipv4_hdr_get_hdr_len(hdr);
|
||||
SET_LAYER(handler, layer, LAYER_TYPE_IPV4, hdr_len, data, len);
|
||||
|
||||
// ip fragmented
|
||||
if ((ntohs(hdr->ip_off) & IP_MF) || (ntohs(hdr->ip_off) & IP_OFFMASK))
|
||||
if (ipv4_hdr_get_mf_flag(hdr) || ipv4_hdr_get_frag_offset(hdr))
|
||||
{
|
||||
PACKET_LOG_DEBUG("ip is fragmented");
|
||||
handler->frag_layer = layer;
|
||||
@@ -893,7 +893,13 @@ static inline const char *parse_ipv6(struct packet *handler, const char *data, u
|
||||
uint8_t next_proto = ipv6_hdr_get_next_header((const struct ip6_hdr *)data);
|
||||
SET_LAYER(handler, layer, LAYER_TYPE_IPV6, sizeof(struct ip6_hdr), data, len);
|
||||
|
||||
// TODO ipv6 fragment
|
||||
// ipv6 fragment
|
||||
if (next_proto == IPPROTO_FRAGMENT)
|
||||
{
|
||||
PACKET_LOG_DEBUG("ipv6 is fragmented");
|
||||
handler->frag_layer = layer;
|
||||
return layer->pld_ptr;
|
||||
}
|
||||
|
||||
// TESTED
|
||||
return parse_l4(handler, next_proto, layer->pld_ptr, layer->pld_len);
|
||||
@@ -1132,6 +1138,11 @@ void packet_print(const struct packet *handler)
|
||||
i, layer, layer_type_tostring(layer->type), layer->hdr_offset,
|
||||
layer->hdr_ptr, layer->hdr_len, layer->pld_ptr, layer->pld_len);
|
||||
}
|
||||
for (uint16_t i = 0; i < handler->data_len; i++)
|
||||
{
|
||||
printf("0x%02x, ", (uint8_t)handler->data_ptr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// return 0 : found
|
||||
|
||||
Reference in New Issue
Block a user