tcp.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* tcp.h - tcp header file */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. /*
  4.  * Copyright (c) 1982, 1986, 1993
  5.  * The Regents of the University of California.  All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  * 3. All advertising materials mentioning features or use of this software
  16.  *    must display the following acknowledgement:
  17.  * This product includes software developed by the University of
  18.  * California, Berkeley and its contributors.
  19.  * 4. Neither the name of the University nor the names of its contributors
  20.  *    may be used to endorse or promote products derived from this software
  21.  *    without specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  *
  35.  * @(#)tcp.h 8.1 (Berkeley) 6/10/93
  36.  */
  37. /*
  38. modification history
  39. --------------------
  40. 01a,03mar96,vin  created from BSD4.4 stuff. integrated with 02k of tcp.h
  41.  Corrected bit fields according to ansi spec.
  42. */
  43. #ifndef __INCtcph
  44. #define __INCtcph
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. #ifndef _BYTE_ORDER
  49. /*
  50.  * Definitions for byte order,
  51.  * according to byte significance from low address to high.
  52.  */
  53. #define _LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
  54. #define _BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
  55. #define _PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
  56. #ifdef vax
  57. #define _BYTE_ORDER      _LITTLE_ENDIAN
  58. #else
  59. #define _BYTE_ORDER      _BIG_ENDIAN      /* mc68000, tahoe, most others */
  60. #endif
  61. #endif /* _BYTE_ORDER */
  62. typedef u_long tcp_seq;
  63. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  64. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  65. #endif /* CPU_FAMILY==I960 */
  66. /*
  67.  * TCP header.
  68.  * Per RFC 793, September, 1981.
  69.  */
  70. struct tcphdr {
  71. u_short th_sport; /* source port */
  72. u_short th_dport; /* destination port */
  73. tcp_seq th_seq; /* sequence number */
  74. tcp_seq th_ack; /* acknowledgement number */
  75. #if _BYTE_ORDER == _LITTLE_ENDIAN
  76. u_int th_x2:4, /* (unused) */
  77. th_off:4, /* data offset */
  78. #endif
  79. #if _BYTE_ORDER == _BIG_ENDIAN
  80. u_int th_off:4, /* data offset */
  81. th_x2:4, /* (unused) */
  82. #endif
  83. th_flags:8,
  84. #define TH_FIN 0x01
  85. #define TH_SYN 0x02
  86. #define TH_RST 0x04
  87. #define TH_PUSH 0x08
  88. #define TH_ACK 0x10
  89. #define TH_URG 0x20
  90. th_win:16; /* window */
  91. u_short th_sum; /* checksum */
  92. u_short th_urp; /* urgent pointer */
  93. };
  94. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  95. #pragma align 0                 /* turn off alignment requirement */
  96. #endif /* CPU_FAMILY==I960 */
  97. #define TCPOPT_EOL 0
  98. #define TCPOPT_NOP 1
  99. #define TCPOPT_MAXSEG 2
  100. #define TCPOLEN_MAXSEG 4
  101. #define TCPOPT_WINDOW 3
  102. #define TCPOLEN_WINDOW 3
  103. #define TCPOPT_SACK_PERMITTED 4 /* Experimental */
  104. #define TCPOLEN_SACK_PERMITTED 2
  105. #define TCPOPT_SACK 5 /* Experimental */
  106. #define TCPOPT_TIMESTAMP 8
  107. #define TCPOLEN_TIMESTAMP 10
  108. #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
  109. #define TCPOPT_TSTAMP_HDR
  110.     (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
  111. /*
  112.  * Default maximum segment size for TCP.
  113.  * With an IP MSS of 576, this is 536,
  114.  * but 512 is probably more convenient.
  115.  * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
  116.  */
  117. #define TCP_MSS 512
  118. #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
  119. #define TCP_MAX_WINSHIFT 14 /* maximum window shift */
  120. /*
  121.  * User-settable options (used with setsockopt).
  122.  */
  123. #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
  124. #define TCP_MAXSEG 0x02 /* set maximum segment size */
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif /* __INCtcph */