tcp.h revision 130989
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1982, 1986, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * @(#)tcp.h 8.1 (Berkeley) 6/10/93 3050477Speter * $FreeBSD: head/sys/netinet/tcp.h 130989 2004-06-23 21:04:37Z ps $ 311541Srgrimes */ 321541Srgrimes 332169Spaul#ifndef _NETINET_TCP_H_ 342169Spaul#define _NETINET_TCP_H_ 352169Spaul 36104343Smike#include <sys/cdefs.h> 37104343Smike 38104342Smike#if __BSD_VISIBLE 39104342Smike 4037622Sbdetypedef u_int32_t tcp_seq; 4137622Sbdetypedef u_int32_t tcp_cc; /* connection count per rfc1644 */ 426247Swollman 4355679Sshin#define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */ 4455679Sshin#define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */ 4555679Sshin 461541Srgrimes/* 471541Srgrimes * TCP header. 481541Srgrimes * Per RFC 793, September, 1981. 491541Srgrimes */ 501541Srgrimesstruct tcphdr { 511541Srgrimes u_short th_sport; /* source port */ 521541Srgrimes u_short th_dport; /* destination port */ 531541Srgrimes tcp_seq th_seq; /* sequence number */ 541541Srgrimes tcp_seq th_ack; /* acknowledgement number */ 558876Srgrimes#if BYTE_ORDER == LITTLE_ENDIAN 5636767Sbde u_int th_x2:4, /* (unused) */ 571541Srgrimes th_off:4; /* data offset */ 581541Srgrimes#endif 598876Srgrimes#if BYTE_ORDER == BIG_ENDIAN 6036767Sbde u_int th_off:4, /* data offset */ 611541Srgrimes th_x2:4; /* (unused) */ 621541Srgrimes#endif 631541Srgrimes u_char th_flags; 641541Srgrimes#define TH_FIN 0x01 651541Srgrimes#define TH_SYN 0x02 661541Srgrimes#define TH_RST 0x04 671541Srgrimes#define TH_PUSH 0x08 681541Srgrimes#define TH_ACK 0x10 691541Srgrimes#define TH_URG 0x20 7070826Srwatson#define TH_ECE 0x40 7170826Srwatson#define TH_CWR 0x80 7270854Srwatson#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR) 736348Swollman 741541Srgrimes u_short th_win; /* window */ 751541Srgrimes u_short th_sum; /* checksum */ 761541Srgrimes u_short th_urp; /* urgent pointer */ 771541Srgrimes}; 781541Srgrimes 791541Srgrimes#define TCPOPT_EOL 0 801541Srgrimes#define TCPOPT_NOP 1 811541Srgrimes#define TCPOPT_MAXSEG 2 821541Srgrimes#define TCPOLEN_MAXSEG 4 831541Srgrimes#define TCPOPT_WINDOW 3 841541Srgrimes#define TCPOLEN_WINDOW 3 851541Srgrimes#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ 861541Srgrimes#define TCPOLEN_SACK_PERMITTED 2 871541Srgrimes#define TCPOPT_SACK 5 /* Experimental */ 88130989Sps#define TCPOLEN_SACK 8 /* 2*sizeof(tcp_seq) */ 891541Srgrimes#define TCPOPT_TIMESTAMP 8 901541Srgrimes#define TCPOLEN_TIMESTAMP 10 911541Srgrimes#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 926247Swollman#define TCPOPT_TSTAMP_HDR \ 931541Srgrimes (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 941541Srgrimes 95130989Sps#define MAX_TCPOPTLEN 40 /* Absolute maximum TCP options len */ 96130989Sps 976247Swollman#define TCPOPT_CC 11 /* CC options: RFC-1644 */ 986247Swollman#define TCPOPT_CCNEW 12 996247Swollman#define TCPOPT_CCECHO 13 1006247Swollman#define TCPOLEN_CC 6 1016247Swollman#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) 1026247Swollman#define TCPOPT_CC_HDR(ccopt) \ 1036247Swollman (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) 104125680Sbms#define TCPOPT_SIGNATURE 19 /* Keyed MD5: RFC 2385 */ 105125680Sbms#define TCPOLEN_SIGNATURE 18 1066247Swollman 107130989Sps/* Option definitions */ 108130989Sps#define TCPOPT_SACK_PERMIT_HDR \ 109130989Sps(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK_PERMITTED<<8|TCPOLEN_SACK_PERMITTED) 110130989Sps#define TCPOPT_SACK_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK<<8) 111130989Sps/* Miscellaneous constants */ 112130989Sps#define MAX_SACK_BLKS 6 /* Max # SACK blocks stored at sender side */ 113130989Sps#define TCP_MAX_SACK 3 /* MAX # SACKs sent in any segment */ 114130989Sps 115130989Sps 1161541Srgrimes/* 1171541Srgrimes * Default maximum segment size for TCP. 118124258Sandre * With an IP MTU of 576, this is 536, 1191541Srgrimes * but 512 is probably more convenient. 1201541Srgrimes * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). 1211541Srgrimes */ 1221541Srgrimes#define TCP_MSS 512 123124258Sandre/* 124124290Sandre * TCP_MINMSS is defined to be 216 which is fine for the smallest 125124290Sandre * link MTU (256 bytes, AX.25 packet radio) in the Internet. 126124258Sandre * However it is very unlikely to come across such low MTU interfaces 127124258Sandre * these days (anno dato 2003). 128124258Sandre * See tcp_subr.c tcp_minmss SYSCTL declaration for more comments. 129124258Sandre * Setting this to "0" disables the minmss check. 130124258Sandre */ 131124290Sandre#define TCP_MINMSS 216 132124258Sandre/* 133124258Sandre * TCP_MINMSSOVERLOAD is defined to be 1000 which should cover any type 134124258Sandre * of interactive TCP session. 135124258Sandre * See tcp_subr.c tcp_minmssoverload SYSCTL declaration and tcp_input.c 136124258Sandre * for more comments. 137124258Sandre * Setting this to "0" disables the minmssoverload check. 138124258Sandre */ 139124437Sandre#define TCP_MINMSSOVERLOAD 0 /* XXX: Disabled until refined */ 1401541Srgrimes 14152904Sshin/* 14252904Sshin * Default maximum segment size for TCP6. 14352904Sshin * With an IP6 MSS of 1280, this is 1220, 14452904Sshin * but 1024 is probably more convenient. (xxx kazu in doubt) 14552904Sshin * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) 14652904Sshin */ 14752904Sshin#define TCP6_MSS 1024 14852904Sshin 1491541Srgrimes#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ 1506247Swollman#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ 1511541Srgrimes 1521541Srgrimes#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ 1531541Srgrimes 15460067Sjlemon#define TCP_MAXBURST 4 /* maximum segments in a burst */ 15560067Sjlemon 1566247Swollman#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ 1576247Swollman#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) 1586247Swollman /* max space left for options */ 159104342Smike#endif /* __BSD_VISIBLE */ 1606247Swollman 1611541Srgrimes/* 1621541Srgrimes * User-settable options (used with setsockopt). 1631541Srgrimes */ 1641541Srgrimes#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 165104342Smike#if __BSD_VISIBLE 1661541Srgrimes#define TCP_MAXSEG 0x02 /* set maximum segment size */ 1676247Swollman#define TCP_NOPUSH 0x04 /* don't push last block of write */ 1686247Swollman#define TCP_NOOPT 0x08 /* don't use TCP options */ 169125890Sbms#define TCP_MD5SIG 0x10 /* use MD5 digests (RFC2385) */ 170104342Smike#endif 1712169Spaul 172104342Smike#endif /* !_NETINET_TCP_H_ */ 173