1 |
1254 |
phoenix |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/netinet/tcp.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
9 |
|
|
//
|
10 |
|
|
// -------------------------------------------
|
11 |
|
|
//
|
12 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
13 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
14 |
|
|
//
|
15 |
|
|
// -------------------------------------------
|
16 |
|
|
//
|
17 |
|
|
//####BSDCOPYRIGHTEND####
|
18 |
|
|
//==========================================================================
|
19 |
|
|
//#####DESCRIPTIONBEGIN####
|
20 |
|
|
//
|
21 |
|
|
// Author(s): gthomas
|
22 |
|
|
// Contributors: gthomas
|
23 |
|
|
// Date: 2000-01-10
|
24 |
|
|
// Purpose:
|
25 |
|
|
// Description:
|
26 |
|
|
//
|
27 |
|
|
//
|
28 |
|
|
//####DESCRIPTIONEND####
|
29 |
|
|
//
|
30 |
|
|
//==========================================================================
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/* $OpenBSD: tcp.h,v 1.8 1999/07/06 20:17:52 cmetz Exp $ */
|
34 |
|
|
/* $NetBSD: tcp.h,v 1.8 1995/04/17 05:32:58 cgd Exp $ */
|
35 |
|
|
|
36 |
|
|
/*
|
37 |
|
|
* Copyright (c) 1982, 1986, 1993
|
38 |
|
|
* The Regents of the University of California. All rights reserved.
|
39 |
|
|
*
|
40 |
|
|
* Redistribution and use in source and binary forms, with or without
|
41 |
|
|
* modification, are permitted provided that the following conditions
|
42 |
|
|
* are met:
|
43 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
44 |
|
|
* notice, this list of conditions and the following disclaimer.
|
45 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
46 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
47 |
|
|
* documentation and/or other materials provided with the distribution.
|
48 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
49 |
|
|
* must display the following acknowledgement:
|
50 |
|
|
* This product includes software developed by the University of
|
51 |
|
|
* California, Berkeley and its contributors.
|
52 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
53 |
|
|
* may be used to endorse or promote products derived from this software
|
54 |
|
|
* without specific prior written permission.
|
55 |
|
|
*
|
56 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
57 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
58 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
59 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
60 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
61 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
62 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
63 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
64 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
65 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
66 |
|
|
* SUCH DAMAGE.
|
67 |
|
|
*
|
68 |
|
|
* @(#)tcp.h 8.1 (Berkeley) 6/10/93
|
69 |
|
|
*/
|
70 |
|
|
|
71 |
|
|
#ifndef _NETINET_TCP_H_
|
72 |
|
|
#define _NETINET_TCP_H_
|
73 |
|
|
|
74 |
|
|
typedef u_int32_t tcp_seq;
|
75 |
|
|
|
76 |
|
|
/*
|
77 |
|
|
* TCP header.
|
78 |
|
|
* Per RFC 793, September, 1981.
|
79 |
|
|
*/
|
80 |
|
|
struct tcphdr {
|
81 |
|
|
u_int16_t th_sport; /* source port */
|
82 |
|
|
u_int16_t th_dport; /* destination port */
|
83 |
|
|
tcp_seq th_seq; /* sequence number */
|
84 |
|
|
tcp_seq th_ack; /* acknowledgement number */
|
85 |
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
86 |
|
|
u_int8_t th_x2:4, /* (unused) */
|
87 |
|
|
th_off:4; /* data offset */
|
88 |
|
|
#endif
|
89 |
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
90 |
|
|
u_int8_t th_off:4, /* data offset */
|
91 |
|
|
th_x2:4; /* (unused) */
|
92 |
|
|
#endif
|
93 |
|
|
u_int8_t th_flags;
|
94 |
|
|
#define TH_FIN 0x01
|
95 |
|
|
#define TH_SYN 0x02
|
96 |
|
|
#define TH_RST 0x04
|
97 |
|
|
#define TH_PUSH 0x08
|
98 |
|
|
#define TH_ACK 0x10
|
99 |
|
|
#define TH_URG 0x20
|
100 |
|
|
u_int16_t th_win; /* window */
|
101 |
|
|
u_int16_t th_sum; /* checksum */
|
102 |
|
|
u_int16_t th_urp; /* urgent pointer */
|
103 |
|
|
} __attribute__ ((aligned(1), packed));
|
104 |
|
|
#define th_reseqlen th_urp /* TCP data length for
|
105 |
|
|
resequencing/reassembly */
|
106 |
|
|
|
107 |
|
|
#define TCPOPT_EOL 0
|
108 |
|
|
#define TCPOPT_NOP 1
|
109 |
|
|
#define TCPOPT_MAXSEG 2
|
110 |
|
|
#define TCPOLEN_MAXSEG 4
|
111 |
|
|
#define TCPOPT_WINDOW 3
|
112 |
|
|
#define TCPOLEN_WINDOW 3
|
113 |
|
|
#define TCPOPT_SACK_PERMITTED 4 /* Experimental */
|
114 |
|
|
#define TCPOLEN_SACK_PERMITTED 2
|
115 |
|
|
#define TCPOPT_SACK 5 /* Experimental */
|
116 |
|
|
#define TCPOLEN_SACK 8 /* 2*sizeof(tcp_seq) */
|
117 |
|
|
#define TCPOPT_TIMESTAMP 8
|
118 |
|
|
#define TCPOLEN_TIMESTAMP 10
|
119 |
|
|
#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
|
120 |
|
|
#define TCPOPT_SIGNATURE 19
|
121 |
|
|
#define TCPOLEN_SIGNATURE 18
|
122 |
|
|
|
123 |
|
|
#define MAX_TCPOPTLEN 40 /* Absolute maximum TCP options len */
|
124 |
|
|
|
125 |
|
|
#define TCPOPT_TSTAMP_HDR \
|
126 |
|
|
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
|
127 |
|
|
|
128 |
|
|
/* Option definitions */
|
129 |
|
|
#define TCPOPT_SACK_PERMIT_HDR \
|
130 |
|
|
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK_PERMITTED<<8|TCPOLEN_SACK_PERMITTED)
|
131 |
|
|
#define TCPOPT_SACK_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK<<8)
|
132 |
|
|
/* Miscellaneous constants */
|
133 |
|
|
#define MAX_SACK_BLKS 6 /* Max # SACK blocks stored at sender side */
|
134 |
|
|
#define TCP_MAX_SACK 3 /* MAX # SACKs sent in any segment */
|
135 |
|
|
|
136 |
|
|
#define TCP_MAXBURST 4 /* Max # packets after leaving Fast Rxmit */
|
137 |
|
|
|
138 |
|
|
/*
|
139 |
|
|
* Default maximum segment size for TCP.
|
140 |
|
|
* With an IP MSS of 576, this is 536,
|
141 |
|
|
* but 512 is probably more convenient.
|
142 |
|
|
* This should be defined as min(512, IP_MSS - sizeof (struct tcpiphdr)).
|
143 |
|
|
*/
|
144 |
|
|
#define TCP_MSS 512
|
145 |
|
|
|
146 |
|
|
#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
|
147 |
|
|
|
148 |
|
|
#define TCP_MAX_WINSHIFT 14 /* maximum window shift */
|
149 |
|
|
|
150 |
|
|
/*
|
151 |
|
|
* User-settable options (used with setsockopt).
|
152 |
|
|
*/
|
153 |
|
|
#define TCP_NODELAY 0x01 /* don't delay send to coalesce pkts */
|
154 |
|
|
#define TCP_MAXSEG 0x02 /* set maximum segment size */
|
155 |
|
|
#define TCP_SIGNATURE_ENABLE 0x04 /* enable TCP MD5 signature option */
|
156 |
|
|
#define TCP_SACK_DISABLE 0x300 /* disable SACKs (if enabled by def.) */
|
157 |
|
|
|
158 |
|
|
#endif /* !_NETINET_TCP_H_ */
|