xref: /csrg-svn/sys/netinet/tcp.h (revision 32787)
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 this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  *	@(#)tcp.h	7.3 (Berkeley) 12/07/87
13  */
14 
15 typedef	u_long	tcp_seq;
16 /*
17  * TCP header.
18  * Per RFC 793, September, 1981.
19  */
20 struct tcphdr {
21 	u_short	th_sport;		/* source port */
22 	u_short	th_dport;		/* destination port */
23 	tcp_seq	th_seq;			/* sequence number */
24 	tcp_seq	th_ack;			/* acknowledgement number */
25 #if ENDIAN == LITTLE
26 	u_char	th_x2:4,		/* (unused) */
27 		th_off:4;		/* data offset */
28 #endif
29 #if ENDIAN == BIG
30 	u_char	th_off:4,		/* data offset */
31 		th_x2:4;		/* (unused) */
32 #endif
33 	u_char	th_flags;
34 #define	TH_FIN	0x01
35 #define	TH_SYN	0x02
36 #define	TH_RST	0x04
37 #define	TH_PUSH	0x08
38 #define	TH_ACK	0x10
39 #define	TH_URG	0x20
40 	u_short	th_win;			/* window */
41 	u_short	th_sum;			/* checksum */
42 	u_short	th_urp;			/* urgent pointer */
43 };
44 
45 #define	TCPOPT_EOL	0
46 #define	TCPOPT_NOP	1
47 #define	TCPOPT_MAXSEG	2
48 
49 /*
50  * Default maximum segment size for TCP.
51  * With an IP MSS of 576, this is 536,
52  * but 512 is probably more convenient.
53  */
54 #ifdef	lint
55 #define	TCP_MSS	536
56 #else
57 #define	TCP_MSS	MIN(512, IP_MSS - sizeof (struct tcpiphdr))
58 #endif
59 
60 /*
61  * User-settable options (used with setsockopt).
62  */
63 #define	TCP_NODELAY	0x01	/* don't delay send to coalesce packets */
64 #define	TCP_MAXSEG	0x02	/* set maximum segment size */
65