tcp.h revision 60067
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 60067 2000-05-06 03:31:09Z jlemon $ 351541Srgrimes */ 361541Srgrimes 372169Spaul#ifndef _NETINET_TCP_H_ 382169Spaul#define _NETINET_TCP_H_ 392169Spaul 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 706247Swollman#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) 716348Swollman 721541Srgrimes u_short th_win; /* window */ 731541Srgrimes u_short th_sum; /* checksum */ 741541Srgrimes u_short th_urp; /* urgent pointer */ 751541Srgrimes}; 761541Srgrimes 771541Srgrimes#define TCPOPT_EOL 0 781541Srgrimes#define TCPOPT_NOP 1 791541Srgrimes#define TCPOPT_MAXSEG 2 801541Srgrimes#define TCPOLEN_MAXSEG 4 811541Srgrimes#define TCPOPT_WINDOW 3 821541Srgrimes#define TCPOLEN_WINDOW 3 831541Srgrimes#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ 841541Srgrimes#define TCPOLEN_SACK_PERMITTED 2 851541Srgrimes#define TCPOPT_SACK 5 /* Experimental */ 861541Srgrimes#define TCPOPT_TIMESTAMP 8 871541Srgrimes#define TCPOLEN_TIMESTAMP 10 881541Srgrimes#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 896247Swollman#define TCPOPT_TSTAMP_HDR \ 901541Srgrimes (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 911541Srgrimes 926247Swollman#define TCPOPT_CC 11 /* CC options: RFC-1644 */ 936247Swollman#define TCPOPT_CCNEW 12 946247Swollman#define TCPOPT_CCECHO 13 956247Swollman#define TCPOLEN_CC 6 966247Swollman#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) 976247Swollman#define TCPOPT_CC_HDR(ccopt) \ 986247Swollman (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) 996247Swollman 1001541Srgrimes/* 1011541Srgrimes * Default maximum segment size for TCP. 1021541Srgrimes * With an IP MSS of 576, this is 536, 1031541Srgrimes * but 512 is probably more convenient. 1041541Srgrimes * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). 1051541Srgrimes */ 1061541Srgrimes#define TCP_MSS 512 1071541Srgrimes 10852904Sshin/* 10952904Sshin * Default maximum segment size for TCP6. 11052904Sshin * With an IP6 MSS of 1280, this is 1220, 11152904Sshin * but 1024 is probably more convenient. (xxx kazu in doubt) 11252904Sshin * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) 11352904Sshin */ 11452904Sshin#define TCP6_MSS 1024 11552904Sshin 1161541Srgrimes#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ 1176247Swollman#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ 1181541Srgrimes 1191541Srgrimes#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ 1201541Srgrimes 12160067Sjlemon#define TCP_MAXBURST 4 /* maximum segments in a burst */ 12260067Sjlemon 1236247Swollman#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ 1246247Swollman#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) 1256247Swollman /* max space left for options */ 1266247Swollman 1271541Srgrimes/* 1281541Srgrimes * User-settable options (used with setsockopt). 1291541Srgrimes */ 1301541Srgrimes#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 1311541Srgrimes#define TCP_MAXSEG 0x02 /* set maximum segment size */ 1326247Swollman#define TCP_NOPUSH 0x04 /* don't push last block of write */ 1336247Swollman#define TCP_NOOPT 0x08 /* don't use TCP options */ 1342169Spaul 1352169Spaul#endif 136