Back to index

lightning-sunbird  0.9+nobinonly
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 Deleted as of 22Jul99, see
00014  *     ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
00015  *        for details]
00016  * 4. Neither the name of the University nor the names of its contributors
00017  *    may be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  *     @(#)tcp.h     8.1 (Berkeley) 6/10/93
00033  */
00034 
00035 /* Adapted for GUSI by Matthias Neeracher <neeri@iis.ee.ethz.ch> */
00036 
00037 typedef       u_long tcp_seq;
00038 /*
00039  * TCP header.
00040  * Per RFC 793, September, 1981.
00041  */
00042 struct tcphdr {
00043        u_short       th_sport;            /* source port */
00044        u_short       th_dport;            /* destination port */
00045        tcp_seq       th_seq;                     /* sequence number */
00046        tcp_seq       th_ack;                     /* acknowledgement number */
00047        u_char th_off:4,            /* data offset */
00048               th_x2:4;             /* (unused) */
00049        u_char th_flags;
00050 #define       TH_FIN 0x01
00051 #define       TH_SYN 0x02
00052 #define       TH_RST 0x04
00053 #define       TH_PUSH       0x08
00054 #define       TH_ACK 0x10
00055 #define       TH_URG 0x20
00056        u_short       th_win;                     /* window */
00057        u_short       th_sum;                     /* checksum */
00058        u_short       th_urp;                     /* urgent pointer */
00059 };
00060 
00061 #define       TCPOPT_EOL           0
00062 #define       TCPOPT_NOP           1
00063 #define       TCPOPT_MAXSEG        2
00064 #define    TCPOLEN_MAXSEG          4
00065 #define TCPOPT_WINDOW              3
00066 #define    TCPOLEN_WINDOW          3
00067 #define TCPOPT_SACK_PERMITTED      4             /* Experimental */
00068 #define    TCPOLEN_SACK_PERMITTED  2
00069 #define TCPOPT_SACK         5             /* Experimental */
00070 #define TCPOPT_TIMESTAMP    8
00071 #define    TCPOLEN_TIMESTAMP              10
00072 #define    TCPOLEN_TSTAMP_APPA            (TCPOLEN_TIMESTAMP+2) /* appendix A */
00073 
00074 #define TCPOPT_TSTAMP_HDR   \
00075     (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
00076 
00077 /*
00078  * Default maximum segment size for TCP.
00079  * With an IP MSS of 576, this is 536,
00080  * but 512 is probably more convenient.
00081  * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
00082  */
00083 #define       TCP_MSS       512
00084 
00085 #define       TCP_MAXWIN    65535  /* largest value for (unscaled) window */
00086 
00087 #define TCP_MAX_WINSHIFT    14     /* maximum window shift */
00088 
00089 /*
00090  * User-settable options (used with setsockopt).
00091  */
00092 #define       TCP_NODELAY          0x01   /* don't delay send to coalesce packets */
00093 #define       TCP_MAXSEG           0x02   /* set maximum segment size */
00094 #define TCP_KEEPALIVE       0x08   /* seconds between keepalive packets */