summaryrefslogtreecommitdiff
path: root/common/include/decode_tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/include/decode_tcp.h')
-rw-r--r--common/include/decode_tcp.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/common/include/decode_tcp.h b/common/include/decode_tcp.h
new file mode 100644
index 0000000..27cc14b
--- /dev/null
+++ b/common/include/decode_tcp.h
@@ -0,0 +1,46 @@
+#ifndef _DECODE_TCP_H
+#define _DECODE_TCP_H
+
+#ifdef __cpluscplus
+extern "C"
+{
+#endif
+
+#include "public.h"
+
+#define TCP_HEADER_LEN 20
+
+ typedef struct tcp_header_s
+ {
+ uint16_t th_sport; /**< source port */
+ uint16_t th_dport; /**< destination port */
+ uint32_t th_seq; /**< sequence number */
+ uint32_t th_ack; /**< acknowledgement number */
+ uint8_t th_offx2; /**< offset and reserved */
+ uint8_t th_flags; /**< pkt flags */
+ uint16_t th_win; /**< pkt window */
+ uint16_t th_sum; /**< checksum */
+ uint16_t th_urp; /**< urgent pointer */
+ } __attribute__((__packed__)) tcp_header_t;
+
+ typedef struct tcp_info_s
+ {
+ uint16_t src_port;
+ uint16_t dst_port;
+
+ tcp_header_t *hdr;
+ uint8_t *payload;
+
+ uint32_t opt_len;
+ uint32_t hdr_len;
+ uint32_t payload_len;
+ } tcp_info_t;
+
+ int decode_tcp(tcp_info_t *packet, const uint8_t *data, uint32_t len);
+ void dump_tcp_info(uint32_t pkt_id, tcp_info_t *packet);
+
+#ifdef __cpluscplus
+}
+#endif
+
+#endif \ No newline at end of file