1 /* 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)tcp.h 8.1 (Berkeley) 06/10/93 8 */ 9 10 typedef u_long tcp_seq; 11 /* 12 * TCP header. 13 * Per RFC 793, September, 1981. 14 */ 15 struct tcphdr { 16 u_short th_sport; /* source port */ 17 u_short th_dport; /* destination port */ 18 tcp_seq th_seq; /* sequence number */ 19 tcp_seq th_ack; /* acknowledgement number */ 20 #if BYTE_ORDER == LITTLE_ENDIAN 21 u_char th_x2:4, /* (unused) */ 22 th_off:4; /* data offset */ 23 #endif 24 #if BYTE_ORDER == BIG_ENDIAN 25 u_char th_off:4, /* data offset */ 26 th_x2:4; /* (unused) */ 27 #endif 28 u_char th_flags; 29 #define TH_FIN 0x01 30 #define TH_SYN 0x02 31 #define TH_RST 0x04 32 #define TH_PUSH 0x08 33 #define TH_ACK 0x10 34 #define TH_URG 0x20 35 u_short th_win; /* window */ 36 u_short th_sum; /* checksum */ 37 u_short th_urp; /* urgent pointer */ 38 }; 39 40 #define TCPOPT_EOL 0 41 #define TCPOPT_NOP 1 42 #define TCPOPT_MAXSEG 2 43 #define TCPOLEN_MAXSEG 4 44 #define TCPOPT_WINDOW 3 45 #define TCPOLEN_WINDOW 3 46 #define TCPOPT_SACK_PERMITTED 4 /* Experimental */ 47 #define TCPOLEN_SACK_PERMITTED 2 48 #define TCPOPT_SACK 5 /* Experimental */ 49 #define TCPOPT_TIMESTAMP 8 50 #define TCPOLEN_TIMESTAMP 10 51 #define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ 52 53 #define TCPOPT_TSTAMP_HDR \ 54 (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) 55 56 /* 57 * Default maximum segment size for TCP. 58 * With an IP MSS of 576, this is 536, 59 * but 512 is probably more convenient. 60 * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). 61 */ 62 #define TCP_MSS 512 63 64 #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ 65 66 #define TCP_MAX_WINSHIFT 14 /* maximum window shift */ 67 68 /* 69 * User-settable options (used with setsockopt). 70 */ 71 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 72 #define TCP_MAXSEG 0x02 /* set maximum segment size */ 73