tcp.h revision 124258
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 * 3. All advertising materials mentioning features or use of this software 141541Srgrimes * must display the following acknowledgement: 151541Srgrimes * This product includes software developed by the University of 161541Srgrimes * California, Berkeley and its contributors. 171541Srgrimes * 4. Neither the name of the University nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes * 331541Srgrimes * @(#)tcp.h 8.1 (Berkeley) 6/10/93 3450477Speter * $FreeBSD: head/sys/netinet/tcp.h 124258 2004-01-08 17:40:07Z andre $ 351541Srgrimes */ 361541Srgrimes 372169Spaul#ifndef _NETINET_TCP_H_ 382169Spaul#define _NETINET_TCP_H_ 392169Spaul 40104343Smike#include <sys/cdefs.h> 41104343Smike 42104342Smike#if __BSD_VISIBLE 43104342Smike 4437622Sbdetypedef u_int32_t tcp_seq; 4537622Sbdetypedef u_int32_t tcp_cc; /* connection count per rfc1644 */ 466247Swollman 4755679Sshin#define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */ 4855679Sshin#define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */ 4955679Sshin 501541Srgrimes/* 511541Srgrimes * TCP header. 521541Srgrimes * Per RFC 793, September, 1981. 531541Srgrimes */ 541541Srgrimesstruct tcphdr { 551541Srgrimes u_short th_sport; /* source port */ 561541Srgrimes u_short th_dport; /* destination port */ 571541Srgrimes tcp_seq th_seq; /* sequence number */ 581541Srgrimes tcp_seq th_ack; /* acknowledgement number */ 598876Srgrimes#if BYTE_ORDER == LITTLE_ENDIAN 6036767Sbde u_int th_x2:4, /* (unused) */ 611541Srgrimes th_off:4; /* data offset */ 621541Srgrimes#endif 638876Srgrimes#if BYTE_ORDER == BIG_ENDIAN 6436767Sbde u_int th_off:4, /* data offset */ 651541Srgrimes th_x2:4; /* (unused) */ 661541Srgrimes#endif 671541Srgrimes u_char th_flags; 681541Srgrimes#define TH_FIN 0x01 691541Srgrimes#define TH_SYN 0x02 701541Srgrimes#define TH_RST 0x04 711541Srgrimes#define TH_PUSH 0x08 721541Srgrimes#define TH_ACK 0x10 731541Srgrimes#define TH_URG 0x20 7470826Srwatson#define TH_ECE 0x40 7570826Srwatson#define TH_CWR 0x80 7670854Srwatson#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR) 776348Swollman 781541Srgrimes u_short th_win; /* window */ 791541Srgrimes u_short th_sum; /* checksum */ 801541Srgrimes u_short th_urp; /* urgent pointer */ 811541Srgrimes}; 821541Srgrimes 831541Srgrimes#define TCPOPT_EOL 0 841541Srgrimes#define TCPOPT_NOP 1 851541Srgrimes#define TCPOPT_MAXSEG 2 861541Srgrimes#define TCPOLEN_MAXSEG 4 871541Srgrimes#define TCPOPT_WINDOW 3 881541Srgrimes#define TCPOLEN_WINDOW 3 891541Srgrimes#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ 901541Srgrimes#define TCPOLEN_SACK_PERMITTED 2 911541Srgrimes#define TCPOPT_SACK 5 /* Experimental */ 921541Srgrimes#define TCPOPT_TIMESTAMP 8 931541Srgrimes#define TCPOLEN_TIMESTAMP 10 941541Srgrimes#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 956247Swollman#define TCPOPT_TSTAMP_HDR \ 961541Srgrimes (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 971541Srgrimes 986247Swollman#define TCPOPT_CC 11 /* CC options: RFC-1644 */ 996247Swollman#define TCPOPT_CCNEW 12 1006247Swollman#define TCPOPT_CCECHO 13 1016247Swollman#define TCPOLEN_CC 6 1026247Swollman#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) 1036247Swollman#define TCPOPT_CC_HDR(ccopt) \ 1046247Swollman (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) 1056247Swollman 1061541Srgrimes/* 1071541Srgrimes * Default maximum segment size for TCP. 108124258Sandre * With an IP MTU of 576, this is 536, 1091541Srgrimes * but 512 is probably more convenient. 1101541Srgrimes * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). 1111541Srgrimes */ 1121541Srgrimes#define TCP_MSS 512 113124258Sandre/* 114124258Sandre * TCP_MINMSS is defined to be 256 which is fine for the smallest 115124258Sandre * link MTU (296 bytes, SLIP interface) in the Internet. 116124258Sandre * However it is very unlikely to come across such low MTU interfaces 117124258Sandre * these days (anno dato 2003). 118124258Sandre * Probably it can be set to 512 without ill effects. But we play safe. 119124258Sandre * See tcp_subr.c tcp_minmss SYSCTL declaration for more comments. 120124258Sandre * Setting this to "0" disables the minmss check. 121124258Sandre */ 122124258Sandre#define TCP_MINMSS 256 123124258Sandre/* 124124258Sandre * TCP_MINMSSOVERLOAD is defined to be 1000 which should cover any type 125124258Sandre * of interactive TCP session. 126124258Sandre * See tcp_subr.c tcp_minmssoverload SYSCTL declaration and tcp_input.c 127124258Sandre * for more comments. 128124258Sandre * Setting this to "0" disables the minmssoverload check. 129124258Sandre */ 130124258Sandre#define TCP_MINMSSOVERLOAD 1000 1311541Srgrimes 13252904Sshin/* 13352904Sshin * Default maximum segment size for TCP6. 13452904Sshin * With an IP6 MSS of 1280, this is 1220, 13552904Sshin * but 1024 is probably more convenient. (xxx kazu in doubt) 13652904Sshin * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) 13752904Sshin */ 13852904Sshin#define TCP6_MSS 1024 13952904Sshin 1401541Srgrimes#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ 1416247Swollman#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ 1421541Srgrimes 1431541Srgrimes#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ 1441541Srgrimes 14560067Sjlemon#define TCP_MAXBURST 4 /* maximum segments in a burst */ 14660067Sjlemon 1476247Swollman#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ 1486247Swollman#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) 1496247Swollman /* max space left for options */ 150104342Smike#endif /* __BSD_VISIBLE */ 1516247Swollman 1521541Srgrimes/* 1531541Srgrimes * User-settable options (used with setsockopt). 1541541Srgrimes */ 1551541Srgrimes#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 156104342Smike#if __BSD_VISIBLE 1571541Srgrimes#define TCP_MAXSEG 0x02 /* set maximum segment size */ 1586247Swollman#define TCP_NOPUSH 0x04 /* don't push last block of write */ 1596247Swollman#define TCP_NOOPT 0x08 /* don't use TCP options */ 160104342Smike#endif 1612169Spaul 162104342Smike#endif /* !_NETINET_TCP_H_ */ 163