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