xref: /csrg-svn/sys/netinet/tcp_seq.h (revision 32789)
123192Smckusick /*
229151Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
3*32789Sbostic  * All rights reserved.
423192Smckusick  *
5*32789Sbostic  * Redistribution and use in source and binary forms are permitted
6*32789Sbostic  * provided that this notice is preserved and that due credit is given
7*32789Sbostic  * to the University of California at Berkeley. The name of the University
8*32789Sbostic  * may not be used to endorse or promote products derived from this
9*32789Sbostic  * software without specific prior written permission. This software
10*32789Sbostic  * is provided ``as is'' without express or implied warranty.
11*32789Sbostic  *
12*32789Sbostic  *	@(#)tcp_seq.h	7.2 (Berkeley) 12/07/87
1323192Smckusick  */
145124Swnj 
155124Swnj /*
165124Swnj  * TCP sequence numbers are 32 bit integers operated
175124Swnj  * on with modular arithmetic.  These macros can be
185124Swnj  * used to compare such integers.
195124Swnj  */
205124Swnj #define	SEQ_LT(a,b)	((int)((a)-(b)) < 0)
215124Swnj #define	SEQ_LEQ(a,b)	((int)((a)-(b)) <= 0)
225124Swnj #define	SEQ_GT(a,b)	((int)((a)-(b)) > 0)
235124Swnj #define	SEQ_GEQ(a,b)	((int)((a)-(b)) >= 0)
245124Swnj 
255124Swnj /*
265124Swnj  * Macros to initialize tcp sequence numbers for
275124Swnj  * send and receive from initial send and receive
285124Swnj  * sequence numbers.
295124Swnj  */
305124Swnj #define	tcp_rcvseqinit(tp) \
3125203Skarels 	(tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1
325124Swnj 
335124Swnj #define	tcp_sendseqinit(tp) \
345124Swnj 	(tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \
355124Swnj 	    (tp)->iss
365124Swnj 
3725204Skarels #define	TCP_ISSINCR	(125*1024)	/* increment for tcp_iss each second */
385124Swnj 
395124Swnj #ifdef KERNEL
405124Swnj tcp_seq	tcp_iss;		/* tcp initial send seq # */
415124Swnj #endif
42