46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#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);
|
|
int dump_tcp_info(tcp_info_t *packet, char *buff, size_t size);
|
|
|
|
#ifdef __cpluscplus
|
|
}
|
|
#endif
|
|
|
|
#endif |