1 /* 2 3 p0f - portable TCP/IP headers 4 ----------------------------- 5 6 Well. 7 8 Copyright (C) 2003 by Michal Zalewski <lcamtuf@coredump.cx> 9 10 */ 11 12 #ifndef _HAVE_TCP_H 13 #define _HAVE_TCP_H 14 15 #define TCPOPT_EOL 0 /* End of options */ 16 #define TCPOPT_NOP 1 /* Nothing */ 17 #define TCPOPT_MAXSEG 2 /* MSS */ 18 #define TCPOPT_WSCALE 3 /* Window scaling */ 19 #define TCPOPT_SACKOK 4 /* Selective ACK permitted */ 20 #define TCPOPT_TIMESTAMP 8 /* Stamp out timestamping! */ 21 22 #define IP_DF 0x4000 /* dont fragment flag */ 23 #define IP_MF 0x2000 /* more fragments flag */ 24 25 #define TH_FIN 0x01 26 #define TH_SYN 0x02 27 #define TH_RST 0x04 28 #define TH_PUSH 0x08 29 #define TH_ACK 0x10 30 #define TH_URG 0x20 31 /* Stupid ECN flags: */ 32 #define TH_ECE 0x40 33 #define TH_CWR 0x80 34 35 struct ip_header { 36 uint8_t ihl, /* IHL */ 37 tos; /* type of service */ 38 uint16_t tot_len, /* total length */ 39 id, /* identification */ 40 off; /* fragment offset + DF/MF */ 41 uint8_t ttl, /* time to live */ 42 proto; /* protocol */ 43 uint16_t cksum; /* checksum */ 44 uint32_t saddr, /* source */ 45 daddr; /* destination */ 46 }; 47 48 49 struct tcp_header { 50 uint16_t sport, /* source port */ 51 dport; /* destination port */ 52 uint32_t seq, /* sequence number */ 53 ack; /* ack number */ 54 #if BYTE_ORDER == LITTLE_ENDIAN 55 uint8_t _x2:4, /* unused */ 56 doff:4; /* data offset */ 57 #else /* BYTE_ORDER == BIG_ENDIAN */ 58 uint8_t doff:4, /* data offset */ 59 _x2:4; /* unused */ 60 #endif 61 uint8_t flags; /* flags, d'oh */ 62 uint16_t win; /* wss */ 63 uint16_t cksum; /* checksum */ 64 uint16_t urg; /* urgent pointer */ 65 }; 66 67 #endif /* ! _HAVE_TCP_H */ 68