1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
3*7c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
4*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
5*7c478bd9Sstevel@tonic-gate  */
6*7c478bd9Sstevel@tonic-gate 
7*7c478bd9Sstevel@tonic-gate #ifndef	_NETINET_TCP_SEQ_H
8*7c478bd9Sstevel@tonic-gate #define	_NETINET_TCP_SEQ_H
9*7c478bd9Sstevel@tonic-gate 
10*7c478bd9Sstevel@tonic-gate /* tcp_seq.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/85	*/
11*7c478bd9Sstevel@tonic-gate 
12*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
13*7c478bd9Sstevel@tonic-gate extern "C" {
14*7c478bd9Sstevel@tonic-gate #endif
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate /*
17*7c478bd9Sstevel@tonic-gate  * TCP sequence numbers are 32 bit integers operated
18*7c478bd9Sstevel@tonic-gate  * on with modular arithmetic.  These macros can be
19*7c478bd9Sstevel@tonic-gate  * used to compare such integers.
20*7c478bd9Sstevel@tonic-gate  */
21*7c478bd9Sstevel@tonic-gate #define	SEQ_LT(a, b)	((int32_t)((a)-(b)) < 0)
22*7c478bd9Sstevel@tonic-gate #define	SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
23*7c478bd9Sstevel@tonic-gate #define	SEQ_GT(a, b)	((int32_t)((a)-(b)) > 0)
24*7c478bd9Sstevel@tonic-gate #define	SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Macros to initialize tcp sequence numbers for
28*7c478bd9Sstevel@tonic-gate  * send and receive from initial send and receive
29*7c478bd9Sstevel@tonic-gate  * sequence numbers.
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate #define	tcp_rcvseqinit(tp) \
32*7c478bd9Sstevel@tonic-gate 	(tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #define	tcp_sendseqinit(tp) \
35*7c478bd9Sstevel@tonic-gate 	(tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \
36*7c478bd9Sstevel@tonic-gate 	    (tp)->iss
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define	TCP_ISSINCR	(125*1024)	/* increment for tcp_iss each second */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
41*7c478bd9Sstevel@tonic-gate }
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #endif	/* _NETINET_TCP_SEQ_H */
45