xref: /csrg-svn/sys/netinet/tcp.h (revision 32787)
123187Smckusick /*
229147Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
3*32787Sbostic  * All rights reserved.
423187Smckusick  *
5*32787Sbostic  * Redistribution and use in source and binary forms are permitted
6*32787Sbostic  * provided that this notice is preserved and that due credit is given
7*32787Sbostic  * to the University of California at Berkeley. The name of the University
8*32787Sbostic  * may not be used to endorse or promote products derived from this
9*32787Sbostic  * software without specific prior written permission. This software
10*32787Sbostic  * is provided ``as is'' without express or implied warranty.
11*32787Sbostic  *
12*32787Sbostic  *	@(#)tcp.h	7.3 (Berkeley) 12/07/87
1323187Smckusick  */
144573Swnj 
155085Swnj typedef	u_long	tcp_seq;
164573Swnj /*
174899Swnj  * TCP header.
184924Swnj  * Per RFC 793, September, 1981.
194573Swnj  */
204899Swnj struct tcphdr {
214899Swnj 	u_short	th_sport;		/* source port */
224899Swnj 	u_short	th_dport;		/* destination port */
235085Swnj 	tcp_seq	th_seq;			/* sequence number */
245085Swnj 	tcp_seq	th_ack;			/* acknowledgement number */
2529923Skarels #if ENDIAN == LITTLE
269992Ssam 	u_char	th_x2:4,		/* (unused) */
274899Swnj 		th_off:4;		/* data offset */
289992Ssam #endif
2929923Skarels #if ENDIAN == BIG
3029923Skarels 	u_char	th_off:4,		/* data offset */
3129923Skarels 		th_x2:4;		/* (unused) */
3229923Skarels #endif
334575Swnj 	u_char	th_flags;
345065Swnj #define	TH_FIN	0x01
355065Swnj #define	TH_SYN	0x02
365065Swnj #define	TH_RST	0x04
375065Swnj #define	TH_PUSH	0x08
385065Swnj #define	TH_ACK	0x10
395065Swnj #define	TH_URG	0x20
404899Swnj 	u_short	th_win;			/* window */
414899Swnj 	u_short	th_sum;			/* checksum */
424899Swnj 	u_short	th_urp;			/* urgent pointer */
434499Swnj };
445440Swnj 
455440Swnj #define	TCPOPT_EOL	0
465440Swnj #define	TCPOPT_NOP	1
475440Swnj #define	TCPOPT_MAXSEG	2
4817316Skarels 
4917316Skarels /*
5026259Skarels  * Default maximum segment size for TCP.
5126259Skarels  * With an IP MSS of 576, this is 536,
5226259Skarels  * but 512 is probably more convenient.
5317316Skarels  */
5426259Skarels #ifdef	lint
5526259Skarels #define	TCP_MSS	536
5626259Skarels #else
5717316Skarels #define	TCP_MSS	MIN(512, IP_MSS - sizeof (struct tcpiphdr))
5826259Skarels #endif
5925895Skarels 
6025895Skarels /*
6125895Skarels  * User-settable options (used with setsockopt).
6225895Skarels  */
6325895Skarels #define	TCP_NODELAY	0x01	/* don't delay send to coalesce packets */
6425895Skarels #define	TCP_MAXSEG	0x02	/* set maximum segment size */
65