1 /* 2 * Copyright 2006, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef NETINET_TCP_H 6 #define NETINET_TCP_H 7 8 9 #include <endian.h> 10 #include <stdint.h> 11 12 13 struct tcphdr { 14 uint16_t th_sport; /* source port */ 15 uint16_t th_dport; /* destination port */ 16 uint32_t th_seq; 17 uint32_t th_ack; 18 19 #if BIG_ENDIAN 20 uint8_t th_off : 4; /* data offset */ 21 uint8_t th_x2 : 4; /* unused */ 22 #else 23 uint8_t th_x2 : 4; 24 uint8_t th_off : 4; 25 #endif 26 uint8_t th_flags; 27 uint16_t th_win; 28 uint16_t th_sum; 29 uint16_t th_urp; /* end of urgent data offset */ 30 } _PACKED; 31 32 #if 0 33 #define TH_FIN 0x01 34 #define TH_SYN 0x02 35 #define TH_RST 0x04 36 #define TH_PUSH 0x08 37 #define TH_ACK 0x10 38 #define TH_URG 0x20 39 #define TH_ECE 0x40 40 #define TH_CWR 0x80 41 42 #define TCPOPT_EOL 0 43 #define TCPOPT_NOP 1 44 #define TCPOPT_MAXSEG 2 45 #define TCPOPT_WINDOW 3 46 #define TCPOPT_SACK_PERMITTED 4 47 #define TCPOPT_SACK 5 48 #define TCPOPT_TIMESTAMP 8 49 #define TCPOPT_SIGNATURE 19 50 51 #define MAX_TCPOPTLEN 40 52 /* absolute maximum TCP options length */ 53 54 #define TCPOLEN_MAXSEG 4 55 #define TCPOLEN_WINDOW 3 56 #define TCPOLEN_SACK 8 57 #define TCPOLEN_SACK_PERMITTED 2 58 #define TCPOLEN_TIMESTAMP 10 59 #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP + 2) 60 /* see RFC 1323, appendix A */ 61 #define TCPOLEN_SIGNATURE 18 62 63 #define TCPOPT_TSTAMP_HDR \ 64 (TCPOPT_NOP << 24 | TCPOPT_NOP << 16 | TCPOPT_TIMESTAMP << 8 | TCPOLEN_TIMESTAMP) 65 66 #define TCP_MSS 536 67 #define TCP_MAXWIN 65535 68 #define TCP_MAX_WINSHIFT 14 69 70 #endif 71 72 /* options that can be set using setsockopt() and level IPPROTO_TCP */ 73 74 #define TCP_NODELAY 0x01 75 /* don't delay sending smaller packets */ 76 #define TCP_MAXSEG 0x02 77 /* set maximum segment size */ 78 #define TCP_NOPUSH 0x04 79 /* don't use TH_PUSH */ 80 #define TCP_NOOPT 0x08 81 /* don't use any TCP options */ 82 83 #endif /* NETINET_TCP_H */ 84