1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)tcp.h 7.5 (Berkeley) 06/29/88 18 */ 19 20 typedef u_long tcp_seq; 21 /* 22 * TCP header. 23 * Per RFC 793, September, 1981. 24 */ 25 struct tcphdr { 26 u_short th_sport; /* source port */ 27 u_short th_dport; /* destination port */ 28 tcp_seq th_seq; /* sequence number */ 29 tcp_seq th_ack; /* acknowledgement number */ 30 #if BYTE_ORDER == LITTLE_ENDIAN 31 u_char th_x2:4, /* (unused) */ 32 th_off:4; /* data offset */ 33 #endif 34 #if BYTE_ORDER == BIG_ENDIAN 35 u_char th_off:4, /* data offset */ 36 th_x2:4; /* (unused) */ 37 #endif 38 u_char th_flags; 39 #define TH_FIN 0x01 40 #define TH_SYN 0x02 41 #define TH_RST 0x04 42 #define TH_PUSH 0x08 43 #define TH_ACK 0x10 44 #define TH_URG 0x20 45 u_short th_win; /* window */ 46 u_short th_sum; /* checksum */ 47 u_short th_urp; /* urgent pointer */ 48 }; 49 50 #define TCPOPT_EOL 0 51 #define TCPOPT_NOP 1 52 #define TCPOPT_MAXSEG 2 53 54 /* 55 * Default maximum segment size for TCP. 56 * With an IP MSS of 576, this is 536, 57 * but 512 is probably more convenient. 58 */ 59 #ifdef lint 60 #define TCP_MSS 536 61 #else 62 #define TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr)) 63 #endif 64 65 /* 66 * User-settable options (used with setsockopt). 67 */ 68 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 69 #define TCP_MAXSEG 0x02 /* set maximum segment size */ 70