]>
Commit | Line | Data |
---|---|---|
48831246 | 1 | /** @file\r |
2 | Declarations for TCP.\r | |
3 | \r | |
4 | Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials are licensed and made available under\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
7 | The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
8db9424e | 12 | \r |
8db9424e | 13 | * Copyright (c) 1982, 1986, 1993\r |
48831246 | 14 | * The Regents of the University of California. All rights reserved.\r |
8db9424e | 15 | *\r |
16 | * Redistribution and use in source and binary forms, with or without\r | |
17 | * modification, are permitted provided that the following conditions\r | |
18 | * are met:\r | |
19 | * 1. Redistributions of source code must retain the above copyright\r | |
20 | * notice, this list of conditions and the following disclaimer.\r | |
21 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
22 | * notice, this list of conditions and the following disclaimer in the\r | |
23 | * documentation and/or other materials provided with the distribution.\r | |
24 | * 3. Neither the name of the University nor the names of its contributors\r | |
25 | * may be used to endorse or promote products derived from this software\r | |
26 | * without specific prior written permission.\r | |
27 | *\r | |
28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r | |
29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r | |
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
38 | * SUCH DAMAGE.\r | |
39 | *\r | |
48831246 | 40 | * @(#)tcp.h 8.1 (Berkeley) 6/10/93\r |
41 | NetBSD: tcp.h,v 1.28 2007/12/25 18:33:47 perry Exp\r | |
8db9424e | 42 | */\r |
8db9424e | 43 | #ifndef _NETINET_TCP_H_\r |
44 | #define _NETINET_TCP_H_\r | |
45 | \r | |
46 | #include <sys/featuretest.h>\r | |
47 | \r | |
8db9424e | 48 | typedef u_int32_t tcp_seq;\r |
48831246 | 49 | \r |
50 | /* Flag definitions for tcphdr.th_flags */\r | |
51 | #define TH_FIN 0x01\r | |
52 | #define TH_SYN 0x02\r | |
53 | #define TH_RST 0x04\r | |
54 | #define TH_PUSH 0x08\r | |
55 | #define TH_ACK 0x10\r | |
56 | #define TH_URG 0x20\r | |
57 | #define TH_ECE 0x40\r | |
58 | #define TH_CWR 0x80\r | |
59 | \r | |
60 | #pragma pack(1)\r | |
8db9424e | 61 | /*\r |
62 | * TCP header.\r | |
63 | * Per RFC 793, September, 1981.\r | |
64 | * Updated by RFC 3168, September, 2001.\r | |
65 | */\r | |
66 | struct tcphdr {\r | |
48831246 | 67 | u_int16_t th_sport; /* source port */\r |
68 | u_int16_t th_dport; /* destination port */\r | |
69 | tcp_seq th_seq; /* sequence number */\r | |
70 | tcp_seq th_ack; /* acknowledgement number */\r | |
8db9424e | 71 | #if BYTE_ORDER == LITTLE_ENDIAN\r |
48831246 | 72 | /*LINTED non-portable bitfields*/\r |
73 | u_int8_t th_x2:4, /* (unused) */\r | |
74 | th_off:4; /* data offset */\r | |
8db9424e | 75 | #endif\r |
76 | #if BYTE_ORDER == BIG_ENDIAN\r | |
48831246 | 77 | /*LINTED non-portable bitfields*/\r |
78 | u_int8_t th_off:4, /* data offset */\r | |
79 | th_x2:4; /* (unused) */\r | |
8db9424e | 80 | #endif\r |
48831246 | 81 | u_int8_t th_flags;\r |
82 | u_int16_t th_win; /* window */\r | |
83 | u_int16_t th_sum; /* checksum */\r | |
84 | u_int16_t th_urp; /* urgent pointer */\r | |
85 | };\r | |
86 | #pragma pack()\r | |
87 | \r | |
88 | #define TCPOPT_EOL 0\r | |
89 | #define TCPOPT_NOP 1\r | |
90 | #define TCPOPT_MAXSEG 2\r | |
91 | #define TCPOLEN_MAXSEG 4\r | |
92 | #define TCPOPT_WINDOW 3\r | |
93 | #define TCPOLEN_WINDOW 3\r | |
94 | #define TCPOPT_SACK_PERMITTED 4 /* Experimental */\r | |
95 | #define TCPOLEN_SACK_PERMITTED 2\r | |
96 | #define TCPOPT_SACK 5 /* Experimental */\r | |
97 | #define TCPOPT_TIMESTAMP 8\r | |
98 | #define TCPOLEN_TIMESTAMP 10\r | |
99 | #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */\r | |
100 | \r | |
101 | #define TCPOPT_TSTAMP_HDR \\r | |
8db9424e | 102 | (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)\r |
103 | \r | |
48831246 | 104 | #define TCPOPT_SIGNATURE 19 /* Keyed MD5: RFC 2385 */\r |
105 | #define TCPOLEN_SIGNATURE 18\r | |
106 | #define TCPOLEN_SIGLEN (TCPOLEN_SIGNATURE+2) /* padding */\r | |
8db9424e | 107 | \r |
48831246 | 108 | #define MAX_TCPOPTLEN 40 /* max # bytes that go in options */\r |
8db9424e | 109 | \r |
48831246 | 110 | /* Default maximum segment size for TCP.\r |
111 | * This is defined by RFC 1112 Sec 4.2.2.6.\r | |
8db9424e | 112 | */\r |
48831246 | 113 | #define TCP_MSS 536\r |
8db9424e | 114 | \r |
48831246 | 115 | #define TCP_MINMSS 216\r |
8db9424e | 116 | \r |
48831246 | 117 | #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */\r |
8db9424e | 118 | \r |
48831246 | 119 | #define TCP_MAX_WINSHIFT 14 /* maximum window shift */\r |
8db9424e | 120 | \r |
48831246 | 121 | #define TCP_MAXBURST 4 /* maximum segments in a burst */\r |
8db9424e | 122 | \r |
48831246 | 123 | /* User-settable options (used with setsockopt). */\r |
124 | #define TCP_NODELAY 1 /* don't delay send to coalesce packets */\r | |
125 | #define TCP_MAXSEG 2 /* set maximum segment size */\r | |
126 | #define TCP_KEEPIDLE 3\r | |
8db9424e | 127 | \r |
8db9424e | 128 | #ifdef notyet\r |
48831246 | 129 | #define TCP_NOPUSH 4 /* reserved for FreeBSD compat */\r |
8db9424e | 130 | #endif\r |
48831246 | 131 | \r |
132 | #define TCP_KEEPINTVL 5\r | |
133 | #define TCP_KEEPCNT 6\r | |
134 | #define TCP_KEEPINIT 7\r | |
135 | \r | |
8db9424e | 136 | #ifdef notyet\r |
48831246 | 137 | #define TCP_NOOPT 8 /* reserved for FreeBSD compat */\r |
8db9424e | 138 | #endif\r |
48831246 | 139 | \r |
140 | #define TCP_MD5SIG 0x10 /* use MD5 digests (RFC2385) */\r | |
141 | #define TCP_CONGCTL 0x20 /* selected congestion control */\r | |
8db9424e | 142 | \r |
143 | #endif /* !_NETINET_TCP_H_ */\r |