Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

TCP.H

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1982, 1986, 1993
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. All advertising materials mentioning features or use of this software
00014  *    must display the following acknowledgement:
00015  *      This product includes software developed by the University of
00016  *      California, Berkeley and its contributors.
00017  * 4. Neither the name of the University nor the names of its contributors
00018  *    may be used to endorse or promote products derived from this software
00019  *    without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00027  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  *      @(#)tcp.h       8.1 (Berkeley) 6/10/93
00034  */
00035 
00036 typedef u_int   tcp_seq;
00037 /*
00038  * TCP header.
00039  * Per RFC 793, September, 1981.
00040  */
00041 struct tcphdr {
00042         u_short th_sport;               /* source port */
00043         u_short th_dport;               /* destination port */
00044         tcp_seq th_seq;                 /* sequence number */
00045         tcp_seq th_ack;                 /* acknowledgement number */
00046 #if BYTE_ORDER == LITTLE_ENDIAN 
00047         u_char  th_x2:4,                /* (unused) */
00048                 th_off:4;               /* data offset */
00049 #endif
00050 #if BYTE_ORDER == BIG_ENDIAN 
00051         u_char  th_off:4,               /* data offset */
00052                 th_x2:4;                /* (unused) */
00053 #endif
00054         u_char  th_flags;
00055 #define TH_FIN  0x01
00056 #define TH_SYN  0x02
00057 #define TH_RST  0x04
00058 #define TH_PUSH 0x08
00059 #define TH_ACK  0x10
00060 #define TH_URG  0x20
00061         u_short th_win;                 /* window */
00062         u_short th_sum;                 /* checksum */
00063         u_short th_urp;                 /* urgent pointer */
00064 };
00065 
00066 #define TCPOPT_EOL              0
00067 #define TCPOPT_NOP              1
00068 #define TCPOPT_MAXSEG           2
00069 #define    TCPOLEN_MAXSEG               4
00070 #define TCPOPT_WINDOW           3
00071 #define    TCPOLEN_WINDOW               3
00072 #define TCPOPT_SACK_PERMITTED   4               /* Experimental */
00073 #define    TCPOLEN_SACK_PERMITTED       2
00074 #define TCPOPT_SACK             5               /* Experimental */
00075 #define TCPOPT_TIMESTAMP        8
00076 #define    TCPOLEN_TIMESTAMP            10
00077 #define    TCPOLEN_TSTAMP_APPA          (TCPOLEN_TIMESTAMP+2) /* appendix A */
00078 
00079 #define TCPOPT_TSTAMP_HDR       \
00080     (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
00081 
00082 /*
00083  * Default maximum segment size for TCP.
00084  * With an IP MSS of 576, this is 536,
00085  * but 512 is probably more convenient.
00086  * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
00087  */
00088 #define TCP_MSS 512
00089 
00090 #define TCP_MAXWIN      65535   /* largest value for (unscaled) window */
00091 
00092 #define TCP_MAX_WINSHIFT        14      /* maximum window shift */
00093 
00094 /*
00095  * User-settable options (used with setsockopt).
00096  */
00097 #ifndef TCP_NODELAY
00098 #define TCP_NODELAY     0x01    /* don't delay send to coalesce packets */
00099 #endif
00100 #ifndef TCP_MAXSEG
00101 #define TCP_MAXSEG      0x02    /* set maximum segment size */
00102 #endif

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2