xref: /original-bsd/sys/netinet/tcp.h (revision 100ae74e)
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.4.1.1 (Berkeley) 02/07/88
13  */
14 #ifndef BYTE_ORDER
15 /*
16  * Definitions for byte order,
17  * according to byte significance from low address to high.
18  */
19 #define	LITTLE_ENDIAN	1234	/* least-significant byte first (vax) */
20 #define	BIG_ENDIAN	4321	/* most-significant byte first (IBM, net) */
21 #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long (pdp) */
22 
23 #ifdef vax
24 #define	BYTE_ORDER	LITTLE_ENDIAN
25 #else
26 #define	BYTE_ORDER	BIG_ENDIAN	/* mc68000, tahoe, most others */
27 #endif
28 #endif BYTE_ORDER
29 
30 typedef	u_long	tcp_seq;
31 /*
32  * TCP header.
33  * Per RFC 793, September, 1981.
34  */
35 struct tcphdr {
36 	u_short	th_sport;		/* source port */
37 	u_short	th_dport;		/* destination port */
38 	tcp_seq	th_seq;			/* sequence number */
39 	tcp_seq	th_ack;			/* acknowledgement number */
40 #if BYTE_ORDER == LITTLE_ENDIAN
41 	u_char	th_x2:4,		/* (unused) */
42 		th_off:4;		/* data offset */
43 #endif
44 #if BYTE_ORDER == BIG_ENDIAN
45 	u_char	th_off:4,		/* data offset */
46 		th_x2:4;		/* (unused) */
47 #endif
48 	u_char	th_flags;
49 #define	TH_FIN	0x01
50 #define	TH_SYN	0x02
51 #define	TH_RST	0x04
52 #define	TH_PUSH	0x08
53 #define	TH_ACK	0x10
54 #define	TH_URG	0x20
55 	u_short	th_win;			/* window */
56 	u_short	th_sum;			/* checksum */
57 	u_short	th_urp;			/* urgent pointer */
58 };
59 
60 #define	TCPOPT_EOL	0
61 #define	TCPOPT_NOP	1
62 #define	TCPOPT_MAXSEG	2
63 
64 /*
65  * Default maximum segment size for TCP.
66  * With an IP MSS of 576, this is 536,
67  * but 512 is probably more convenient.
68  */
69 #ifdef	lint
70 #define	TCP_MSS	536
71 #else
72 #ifndef IP_MSS
73 #define	IP_MSS	576
74 #endif
75 #define	TCP_MSS	MIN(512, IP_MSS - sizeof (struct tcpiphdr))
76 #endif
77 
78 /*
79  * User-settable options (used with setsockopt).
80  */
81 #define	TCP_NODELAY	0x01	/* don't delay send to coalesce packets */
82 #define	TCP_MAXSEG	0x02	/* set maximum segment size */
83