1
0
mirror of https://code.semirocket.science/wrapsix synced 2024-09-19 15:01:06 +03:00

Better way to filter out IPv4 flags

This commit is contained in:
Michal Zima 2013-06-15 16:33:03 +02:00
parent b61eec5bc8
commit 252467f956

View File

@ -67,7 +67,7 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
if ((ip4->flags_offset | htons(IPV4_FLAG_DONT_FRAGMENT)) == if ((ip4->flags_offset | htons(IPV4_FLAG_DONT_FRAGMENT)) ==
htons(IPV4_FLAG_DONT_FRAGMENT) || htons(IPV4_FLAG_DONT_FRAGMENT) ||
((ip4->flags_offset & htons(IPV4_FLAG_MORE_FRAGMENTS)) && ((ip4->flags_offset & htons(IPV4_FLAG_MORE_FRAGMENTS)) &&
(ip4->flags_offset & 0xff1f) == 0x0000 && (ip4->flags_offset & htons(0x1fff)) == 0x0000 &&
payload_size >= sizeof(struct s_tcp))) { payload_size >= sizeof(struct s_tcp))) {
/* parse TCP header */ /* parse TCP header */
tcp = (struct s_tcp *) payload; tcp = (struct s_tcp *) payload;
@ -398,7 +398,7 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
sizeof(struct s_ipv6_fragment) - sizeof(struct s_ipv6_fragment) -
FRAGMENT_LEN); FRAGMENT_LEN);
frag->offset_flag = htons(((htons(ip4->flags_offset) & frag->offset_flag = htons(((htons(ip4->flags_offset) &
0xfffc) + 0x1fff) +
FRAGMENT_LEN / 8) << 3); FRAGMENT_LEN / 8) << 3);
if (ip4->flags_offset & if (ip4->flags_offset &
htons(IPV4_FLAG_MORE_FRAGMENTS)) { htons(IPV4_FLAG_MORE_FRAGMENTS)) {