My Project
tcp_hdr.h
1 #ifndef TCP_HDR_H
2 #define TCP_HDR_H
3 
4 /* TCP header */
5 typedef u_int tcp_seq;
6 
11 struct sniff_tcp {
12  u_short th_sport; /* source port */
13  u_short th_dport; /* destination port */
14  tcp_seq th_seq; /* sequence number */
15  tcp_seq th_ack; /* acknowledgement number */
16  u_char th_offx2; /* data offset, rsvd */
17 #define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4)
18  u_char th_flags;
19  #define TH_FIN 0x01
20  #define TH_SYN 0x02
21  #define TH_RST 0x04
22  #define TH_PUSH 0x08
23  #define TH_ACK 0x10
24  #define TH_URG 0x20
25  #define TH_ECE 0x40
26  #define TH_CWR 0x80
27  #define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)
28  u_short th_win; /* window */
29  u_short th_sum; /* checksum */
30  u_short th_urp; /* urgent pointer */
31 };
32 
33 #endif // TCP_HDR_H
The sniff_tcp struct contains the TCP header. We use the first two members to extract the src and dst...
Definition: tcp_hdr.h:11