diff options
author | Neale Ranns <neale@graphiant.com> | 2022-02-15 09:02:27 +0000 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2022-02-15 09:02:27 +0000 |
commit | f7040f01a57618c899de8d1feb30bcc70b0a45b9 (patch) | |
tree | f23942c61b8a3b8cc496c054d0d2071a85b330c9 /src/vnet/tcp/tcp_packet.h | |
parent | cdaf0d8c884ae0f337ef94b0ceb7449c991a3e6c (diff) |
tcp: Do not include the tcp_packet.h file in the ip4_packet.h
Type: refactor
IP4 does not depend on TCP (it's the other way around).
This upside down dependency leads to some nasty circular includes when trying to use ip46_address.h in interface.h
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I4a1bd21543b08b9c1cf1e5563da738414734a878
Diffstat (limited to 'src/vnet/tcp/tcp_packet.h')
-rw-r--r-- | src/vnet/tcp/tcp_packet.h | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/src/vnet/tcp/tcp_packet.h b/src/vnet/tcp/tcp_packet.h index b0636d871d5..c137ea68108 100644 --- a/src/vnet/tcp/tcp_packet.h +++ b/src/vnet/tcp/tcp_packet.h @@ -16,7 +16,8 @@ #ifndef included_tcp_packet_h #define included_tcp_packet_h -#include <vnet/vnet.h> +#include <vnet/ip/ip4_packet.h> +#include <vnet/ip/ip6_packet.h> /* TCP flags bit 0 first. */ #define foreach_tcp_flag \ @@ -185,6 +186,100 @@ typedef struct #define timestamp_lt(_t1, _t2) ((i32)((_t1)-(_t2)) < 0) #define timestamp_leq(_t1, _t2) ((i32)((_t1)-(_t2)) <= 0) +always_inline void +ip4_tcp_reply_x1 (ip4_header_t *ip0, tcp_header_t *tcp0) +{ + u32 src0, dst0; + + src0 = ip0->src_address.data_u32; + dst0 = ip0->dst_address.data_u32; + ip0->src_address.data_u32 = dst0; + ip0->dst_address.data_u32 = src0; + + src0 = tcp0->src; + dst0 = tcp0->dst; + tcp0->src = dst0; + tcp0->dst = src0; +} + +always_inline void +ip4_tcp_reply_x2 (ip4_header_t *ip0, ip4_header_t *ip1, tcp_header_t *tcp0, + tcp_header_t *tcp1) +{ + u32 src0, dst0, src1, dst1; + + src0 = ip0->src_address.data_u32; + src1 = ip1->src_address.data_u32; + dst0 = ip0->dst_address.data_u32; + dst1 = ip1->dst_address.data_u32; + ip0->src_address.data_u32 = dst0; + ip1->src_address.data_u32 = dst1; + ip0->dst_address.data_u32 = src0; + ip1->dst_address.data_u32 = src1; + + src0 = tcp0->src; + src1 = tcp1->src; + dst0 = tcp0->dst; + dst1 = tcp1->dst; + tcp0->src = dst0; + tcp1->src = dst1; + tcp0->dst = src0; + tcp1->dst = src1; +} + +always_inline void +ip6_tcp_reply_x1 (ip6_header_t *ip0, tcp_header_t *tcp0) +{ + { + ip6_address_t src0, dst0; + + src0 = ip0->src_address; + dst0 = ip0->dst_address; + ip0->src_address = dst0; + ip0->dst_address = src0; + } + + { + u16 src0, dst0; + + src0 = tcp0->src; + dst0 = tcp0->dst; + tcp0->src = dst0; + tcp0->dst = src0; + } +} + +always_inline void +ip6_tcp_reply_x2 (ip6_header_t *ip0, ip6_header_t *ip1, tcp_header_t *tcp0, + tcp_header_t *tcp1) +{ + { + ip6_address_t src0, dst0, src1, dst1; + + src0 = ip0->src_address; + src1 = ip1->src_address; + dst0 = ip0->dst_address; + dst1 = ip1->dst_address; + ip0->src_address = dst0; + ip1->src_address = dst1; + ip0->dst_address = src0; + ip1->dst_address = src1; + } + + { + u16 src0, dst0, src1, dst1; + + src0 = tcp0->src; + src1 = tcp1->src; + dst0 = tcp0->dst; + dst1 = tcp1->dst; + tcp0->src = dst0; + tcp1->src = dst1; + tcp0->dst = src0; + tcp1->dst = src1; + } +} + /** * Parse TCP header options. * |