#ifndef __TCP_LOADED #define __TCP_LOADED /**************************************************************************** ** ** - TCP descriptions ** ***************************************************************************** ** Header is nonstandard ***************************************************************************** ** ** Copyright 2005 Hewlett-Packard Development Company, L.P. ** ** Confidential computer software. Valid license from HP and/or ** its subsidiaries required for possession, use, or copying. ** ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, ** Computer Software Documentation, and Technical Data for Commercial ** Items are licensed to the U.S. Government under vendor's standard ** commercial license. ** ** Neither HP nor any of its subsidiaries shall be liable for technical ** or editorial errors or omissions contained herein. The information ** in this document is provided "as is" without warranty of any kind and ** is subject to change without notice. The warranties for HP products ** are set forth in the express limited warranty statements accompanying ** such products. Nothing herein should be construed as constituting an ** additional warranty. ** ***************************************************************************** ** ** Copyright (c) 1982 Regents of the University of California. ** All rights reserved. The Berkeley software License Agreement ** specifies the terms and conditions for redistribution. ** ** @(#)tcp.h 6.3 (Berkeley) 6/8/85 ** ****************************************************************************** */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 32 #endif /* ** Set __nomember_alignment to avoid internal and tail ** padding in structures; default base alignment. ** Required for consistency across programming languages. */ #pragma __member_alignment __save #pragma __nomember_alignment /* ** Disable messages */ #pragma __message __save #pragma __message __disable (__MISALGNDSTRCT) #pragma __message __disable (__MISALGNDMEM) #if defined __DECC # pragma __message __disable (__BITNOTINT) #endif /* ** Define a caddr_t if not defined elsewhere */ #if !defined __CADDR_T && !defined CADDR_T # define __CADDR_T 1 # ifndef __HIDE_FORBIDDEN_NAMES # define CADDR_T 1 # endif typedef __caddr_t caddr_t; #endif /* ** Define non-standard BSD socket compatible typedefs */ #ifndef __SOCKET_TYPEDEFS # define __SOCKET_TYPEDEFS 1 typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned long u_long; #endif typedef u_long tcp_seq; /* ** TCP header. Per RFC 793, September, 1981. */ struct tcphdr { u_short th_sport; /* source port */ u_short th_dport; /* destination port */ tcp_seq th_seq; /* sequence number */ tcp_seq th_ack; /* acknowledgement number */ /* LITTLE_ENDIAN defn */ u_char th_x2:4; /* (unused) */ u_char th_off:4; /* data offset */ u_char th_flags; /* */ u_short th_win; /* window */ u_short th_sum; /* checksum */ u_short th_urp; /* urgent pointer */ }; /* ** Define th_flags values */ #define TH_FIN 0x01 #define TH_SYN 0x02 #define TH_RST 0x04 #define TH_PUSH 0x08 #define TH_ACK 0x10 #define TH_URG 0x20 #define TCPOPT_MAX_LEN 40 #define TCPOPT_EOL 0 #define TCPOPT_NOP 1 #define TCPOPT_MAXSEG 2 #define TCPOLEN_MAXSEG 4 #define TCPOPT_WINDOW 3 #define TCPOLEN_WINDOW 3 #define TCPOPT_SACK_REQ 4 /* rfc 2018 Sack option requested SYN only */ #define TCPOLEN_SACK_PERMITTED 2 #define TCPOPT_SACK 5 /* Experimental */ #define TCPOPT_TS 8 /* rfc 1323 timestamp option */ #define TCPOLEN_TIMESTAMP 10 #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ #define TCPOPT_TSTAMP_HDR \ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) /* * sack defines */ #define TCP_SACK_ELEMENT_LEN 8 /* Sack element have 2 int fields */ #define TCPOPT_SACK_LEN_OK( len ) ((len>=10) && (((((len-2)/8)*8)+2)==len)) /* * timestamp defines */ #define TCPOPT_TS_LEN 10 /* tcp timestamp option length */ #define TCPOLEN_TSTAMP_APPA ((TCPOPT_NOP<<24)|(TCPOPT_NOP<<16)|(TCPOPT_TS<<8)|TCPOPT_TS_LEN) #define TCPOPT_CREATE_TSOPT(opt, optlen, TSVAL, TSECR) \ { \ int *__tmp=(int*)(opt) ; \ __tmp[0]=htonl(TCPOLEN_TSTAMP_APPA) ; \ __tmp[1]=htonl(TSVAL) ; \ __tmp[2]=htonl(TSECR) ; \ optlen+=TCPOPT_TS_LEN+2 ; \ } #define TCPOPT_EXTRACT_TSOPT(opt, TSVAL, TSECR) \ { \ bcopy((__caddr_t)(&(opt)[2]), &(TSVAL), sizeof(TSVAL)) ; \ TSVAL=ntohl(TSVAL) ; \ bcopy(&(opt)[2+sizeof(TSVAL)], &(TSECR) , sizeof(TSECR)) ; \ TSECR=ntohl(TSECR) ; \ } /* * Default maximum segment size for TCP. * For RFC1122 MUST conformance, this needs to be 536. * With an IP MSS of 576, this is 536, * but 512 is probably more convenient. * This should be defined as min(512, IP_MSS - sizeof (struct tcpiphdr)). */ #define TCP_MSS 536 /* XXX - BSD4.4lite uses 512 */ #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ #define TCP_MAX_WINSHIFT 14 /* maximum window shift */ /* * User-settable options (used with set/getsockopt). */ #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ #define TCP_MAXSEG 0x02 /* set maximum segment size */ /* * Number of retransmissions before dropping connection. Larger than * TCP_MAXRXTSHIFT or -1 for infinity */ #define TCP_RPTR2RXT 0x03 /* set repeat count for R2 RXT timer */ #define TCP_KEEPIDLE 0x04 /* seconds before initial keepalive probe */ #define TCP_KEEPINTVL 0x05 /* seconds between keepalive probes */ #define TCP_KEEPCNT 0x06 /* number of keepalive probes before drop */ #define TCP_KEEPINIT 0x07 /* initial connect timeout (seconds) */ #define TCP_PUSH 0x08 /* set push bit in outbound data packets */ #define TCP_NODELACK 0x09 /* don't delay send to coalesce packets */ #define TCP_TSOPTENA 0x10 /* time stamp option */ #define TCP_PAWS 0x20 /* PAWS option */ #define TCP_SACKENA 0x40 /* SACK enabled */ #define TCP_PROBE_IDLE 0x80 /* Probe idle */ #define TCP_DROP_IDLE 0x81 /* Drop idle */ /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __message __restore #pragma __member_alignment __restore #pragma __standard #endif /* __TCP_LOADED */