tcp.h revision 8876
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 348876Srgrimes * $Id: tcp.h,v 1.5 1995/02/14 02:35:14 wollman Exp $ 351541Srgrimes */ 361541Srgrimes 372169Spaul#ifndef _NETINET_TCP_H_ 382169Spaul#define _NETINET_TCP_H_ 392169Spaul 401541Srgrimestypedef u_long tcp_seq; 416247Swollmantypedef u_long tcp_cc; /* connection count per rfc1644 */ 426247Swollman 431541Srgrimes/* 441541Srgrimes * TCP header. 451541Srgrimes * Per RFC 793, September, 1981. 461541Srgrimes */ 471541Srgrimesstruct tcphdr { 481541Srgrimes u_short th_sport; /* source port */ 491541Srgrimes u_short th_dport; /* destination port */ 501541Srgrimes tcp_seq th_seq; /* sequence number */ 511541Srgrimes tcp_seq th_ack; /* acknowledgement number */ 528876Srgrimes#if BYTE_ORDER == LITTLE_ENDIAN 531541Srgrimes u_char th_x2:4, /* (unused) */ 541541Srgrimes th_off:4; /* data offset */ 551541Srgrimes#endif 568876Srgrimes#if BYTE_ORDER == BIG_ENDIAN 571541Srgrimes u_char th_off:4, /* data offset */ 581541Srgrimes th_x2:4; /* (unused) */ 591541Srgrimes#endif 601541Srgrimes u_char th_flags; 611541Srgrimes#define TH_FIN 0x01 621541Srgrimes#define TH_SYN 0x02 631541Srgrimes#define TH_RST 0x04 641541Srgrimes#define TH_PUSH 0x08 651541Srgrimes#define TH_ACK 0x10 661541Srgrimes#define TH_URG 0x20 676247Swollman#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) 686348Swollman 691541Srgrimes u_short th_win; /* window */ 701541Srgrimes u_short th_sum; /* checksum */ 711541Srgrimes u_short th_urp; /* urgent pointer */ 721541Srgrimes}; 731541Srgrimes 741541Srgrimes#define TCPOPT_EOL 0 751541Srgrimes#define TCPOPT_NOP 1 761541Srgrimes#define TCPOPT_MAXSEG 2 771541Srgrimes#define TCPOLEN_MAXSEG 4 781541Srgrimes#define TCPOPT_WINDOW 3 791541Srgrimes#define TCPOLEN_WINDOW 3 801541Srgrimes#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ 811541Srgrimes#define TCPOLEN_SACK_PERMITTED 2 821541Srgrimes#define TCPOPT_SACK 5 /* Experimental */ 831541Srgrimes#define TCPOPT_TIMESTAMP 8 841541Srgrimes#define TCPOLEN_TIMESTAMP 10 851541Srgrimes#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 866247Swollman#define TCPOPT_TSTAMP_HDR \ 871541Srgrimes (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 881541Srgrimes 896247Swollman#define TCPOPT_CC 11 /* CC options: RFC-1644 */ 906247Swollman#define TCPOPT_CCNEW 12 916247Swollman#define TCPOPT_CCECHO 13 926247Swollman#define TCPOLEN_CC 6 936247Swollman#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) 946247Swollman#define TCPOPT_CC_HDR(ccopt) \ 956247Swollman (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) 966247Swollman 971541Srgrimes/* 981541Srgrimes * Default maximum segment size for TCP. 991541Srgrimes * With an IP MSS of 576, this is 536, 1001541Srgrimes * but 512 is probably more convenient. 1011541Srgrimes * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). 1021541Srgrimes */ 1031541Srgrimes#define TCP_MSS 512 1041541Srgrimes 1051541Srgrimes#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ 1066247Swollman#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ 1071541Srgrimes 1081541Srgrimes#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ 1091541Srgrimes 1106247Swollman#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ 1116247Swollman#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) 1126247Swollman /* max space left for options */ 1136247Swollman 1141541Srgrimes/* 1151541Srgrimes * User-settable options (used with setsockopt). 1161541Srgrimes */ 1171541Srgrimes#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 1181541Srgrimes#define TCP_MAXSEG 0x02 /* set maximum segment size */ 1196247Swollman#define TCP_NOPUSH 0x04 /* don't push last block of write */ 1206247Swollman#define TCP_NOOPT 0x08 /* don't use TCP options */ 1212169Spaul 1222169Spaul#endif 123