Back to index

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