]> git.saurik.com Git - apple/xnu.git/blob - bsd/netinet/tcp.h
xnu-517.tar.gz
[apple/xnu.git] / bsd / netinet / tcp.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (c) 1982, 1986, 1993
27 * The Regents of the University of California. All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * This product includes software developed by the University of
40 * California, Berkeley and its contributors.
41 * 4. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 *
57 * @(#)tcp.h 8.1 (Berkeley) 6/10/93
58 * $FreeBSD: src/sys/netinet/tcp.h,v 1.13.2.3 2001/03/01 22:08:42 jlemon Exp $
59 */
60
61 #ifndef _NETINET_TCP_H_
62 #define _NETINET_TCP_H_
63 #include <sys/appleapiopts.h>
64
65 typedef u_int32_t tcp_seq;
66 typedef u_int32_t tcp_cc; /* connection count per rfc1644 */
67
68 #define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */
69 #define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */
70
71 /*
72 * TCP header.
73 * Per RFC 793, September, 1981.
74 */
75 struct tcphdr {
76 u_short th_sport; /* source port */
77 u_short th_dport; /* destination port */
78 tcp_seq th_seq; /* sequence number */
79 tcp_seq th_ack; /* acknowledgement number */
80 #if BYTE_ORDER == LITTLE_ENDIAN
81 u_int th_x2:4, /* (unused) */
82 th_off:4; /* data offset */
83 #endif
84 #if BYTE_ORDER == BIG_ENDIAN
85 u_int th_off:4, /* data offset */
86 th_x2:4; /* (unused) */
87 #endif
88 u_char th_flags;
89 #define TH_FIN 0x01
90 #define TH_SYN 0x02
91 #define TH_RST 0x04
92 #define TH_PUSH 0x08
93 #define TH_ACK 0x10
94 #define TH_URG 0x20
95 #define TH_ECE 0x40
96 #define TH_CWR 0x80
97 #define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)
98
99 u_short th_win; /* window */
100 u_short th_sum; /* checksum */
101 u_short th_urp; /* urgent pointer */
102 };
103
104 #define TCPOPT_EOL 0
105 #define TCPOPT_NOP 1
106 #define TCPOPT_MAXSEG 2
107 #define TCPOLEN_MAXSEG 4
108 #define TCPOPT_WINDOW 3
109 #define TCPOLEN_WINDOW 3
110 #define TCPOPT_SACK_PERMITTED 4 /* Experimental */
111 #define TCPOLEN_SACK_PERMITTED 2
112 #define TCPOPT_SACK 5 /* Experimental */
113 #define TCPOPT_TIMESTAMP 8
114 #define TCPOLEN_TIMESTAMP 10
115 #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
116 #define TCPOPT_TSTAMP_HDR \
117 (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
118
119 #define TCPOPT_CC 11 /* CC options: RFC-1644 */
120 #define TCPOPT_CCNEW 12
121 #define TCPOPT_CCECHO 13
122 #define TCPOLEN_CC 6
123 #define TCPOLEN_CC_APPA (TCPOLEN_CC+2)
124 #define TCPOPT_CC_HDR(ccopt) \
125 (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC)
126
127 /*
128 * Default maximum segment size for TCP.
129 * With an IP MSS of 576, this is 536,
130 * but 512 is probably more convenient.
131 * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
132 */
133 #define TCP_MSS 512
134
135 /*
136 * Default maximum segment size for TCP6.
137 * With an IP6 MSS of 1280, this is 1220,
138 * but 1024 is probably more convenient. (xxx kazu in doubt)
139 * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr))
140 */
141 #define TCP6_MSS 1024
142
143 #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
144 #define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */
145
146 #define TCP_MAX_WINSHIFT 14 /* maximum window shift */
147
148 #define TCP_MAXBURST 4 /* maximum segments in a burst */
149
150 #define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */
151 #define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr))
152 /* max space left for options */
153
154 /*
155 * User-settable options (used with setsockopt).
156 */
157 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
158 #define TCP_MAXSEG 0x02 /* set maximum segment size */
159 #define TCP_NOPUSH 0x04 /* don't push last block of write */
160 #define TCP_NOOPT 0x08 /* don't use TCP options */
161 #define TCP_KEEPALIVE 0x10 /* idle time used when SO_KEEPALIVE is enabled */
162
163 #endif