1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 1997, 2002-2003 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef	_INET_SACK_H
28#define	_INET_SACK_H
29
30#pragma ident	"%Z%%M%	%I%	%E% SMI"
31
32#include <netinet/tcp.h>	/* for tcp_seq */
33
34#ifdef	__cplusplus
35extern "C" {
36#endif
37
38/* Maximum num of receiver's SACK blocks */
39#define	MAX_SACK_BLK	5
40
41/* Receiver's SACK blk structure */
42typedef struct sack_blk
43{
44	tcp_seq	begin;
45	tcp_seq	end;
46} sack_blk_t;
47
48/* Sender's notsack'ed blk structure */
49typedef struct notsack_blk
50{
51	struct notsack_blk	*next;
52	tcp_seq			begin;
53	tcp_seq			end;
54	uint32_t		sack_cnt; /* Dup SACK count */
55} notsack_blk_t;
56
57
58/* SACK information in the tcp_t structure. */
59typedef struct
60{
61	int32_t	tcp_pipe;	/* # of bytes in network */
62	tcp_seq	tcp_fack;	/* highest sack'ed seq num */
63	tcp_seq	tcp_sack_snxt;	/* next seq num to be rexmited using SACK. */
64
65	int32_t	tcp_max_sack_blk; /* max # of SACK info blk in a segment */
66	int32_t	tcp_num_sack_blk; /* num of blks in sack list */
67	sack_blk_t	tcp_sack_list[MAX_SACK_BLK]; /* the sack list */
68
69	/* num of blks in notsack list */
70	int32_t		tcp_num_notsack_blk;
71	/* # of bytes represented in blks in notsack list */
72	uint32_t	tcp_cnt_notsack_list;
73	/* the notsack list */
74	notsack_blk_t	*tcp_notsack_list;
75} tcp_sack_info_t;
76
77extern void tcp_sack_insert(sack_blk_t *, tcp_seq, tcp_seq, int32_t *);
78extern void tcp_sack_remove(sack_blk_t *, tcp_seq, int32_t *);
79extern void tcp_notsack_insert(notsack_blk_t **, tcp_seq, tcp_seq,
80    int32_t *, uint32_t *);
81extern void tcp_notsack_remove(notsack_blk_t **, tcp_seq, int32_t *,
82    uint32_t *);
83extern void tcp_notsack_update(notsack_blk_t **, tcp_seq, tcp_seq,
84    int32_t *, uint32_t *);
85
86
87/*
88 * Macro to remove all the notsack'ed blks in sender.
89 *
90 * Param:
91 * notsack_blk_t *head: pointer to the head of the list of notsack'ed blks.
92 */
93#define	TCP_NOTSACK_REMOVE_ALL(head) \
94{ \
95	notsack_blk_t *prev, *tmp; \
96	tmp = (head); \
97	do { \
98		prev = tmp; \
99		tmp = tmp->next; \
100		bkmem_free((caddr_t)prev, sizeof (notsack_blk_t)); \
101	} while (tmp != NULL); \
102	(head) = NULL; \
103}
104
105#ifdef	__cplusplus
106}
107#endif
108
109#endif	/* _INET_SACK_H */
110