No Description

tcp_hdr.h 1.2KB

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