From f8613abc8a89e26ccf33298cbdf8a5e8c4009d1f Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 24 Jul 2014 14:12:50 +0200 Subject: [PATCH] ip-packet: Define our own structs to handle TCP/UDP headers --- src/libipsec/ip_packet.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libipsec/ip_packet.c b/src/libipsec/ip_packet.c index f6e08c0cb..806526292 100644 --- a/src/libipsec/ip_packet.c +++ b/src/libipsec/ip_packet.c @@ -22,12 +22,37 @@ #include #include #include -#include -#include #ifdef HAVE_NETINET_IP6_H #include #endif +/** + * TCP header, defined here because platforms disagree regarding member names + * and unfortunately Android does not define a variant with BSD names. + */ +struct tcphdr { + u_int16_t source; + u_int16_t dest; + u_int32_t seq; + u_int32_t ack_seq; + u_int16_t flags; + u_int16_t window; + u_int16_t check; + u_int16_t urg_ptr; +} __attribute__((packed)); + +/** + * UDP header, similar to the TCP header the system headers disagree on member + * names. Linux uses a union and on Android we could define __FAVOR_BSD to get + * the BSD member names, but this is simpler and more consistent with the above. + */ +struct udphdr { + u_int16_t source; + u_int16_t dest; + u_int16_t len; + u_int16_t check; +} __attribute__((packed)); + typedef struct private_ip_packet_t private_ip_packet_t; /**