1185420Szec/*-
2185420Szec * Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG
3185420Szec * All rights reserved.
4185420Szec *
5185420Szec * Redistribution and use in source and binary forms, with or without
6185420Szec * modification, are permitted provided that the following conditions
7185420Szec * are met:
8185420Szec * 1. Redistributions of source code must retain the above copyright
9185420Szec *    notice, this list of conditions and the following disclaimer.
10185420Szec * 2. Redistributions in binary form must reproduce the above copyright
11185420Szec *    notice, this list of conditions and the following disclaimer in the
12185420Szec *    documentation and/or other materials provided with the distribution.
13185420Szec * 3. The name of the author may not be used to endorse or promote
14185420Szec *    products derived from this software without specific prior written
15185420Szec *    permission.
16185420Szec *
17185420Szec * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18185420Szec * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19185420Szec * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20185420Szec * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21185420Szec * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22185420Szec * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23185420Szec * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24185420Szec * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25185420Szec * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26185420Szec * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27185420Szec * SUCH DAMAGE.
28185420Szec *
29185420Szec * $FreeBSD: stable/11/sys/netinet/tcp_hostcache.h 369631 2021-04-16 22:12:37Z rscheff $
30185420Szec */
31185420Szec
32185420Szec/*
33185420Szec * Many thanks to jlemon for basic structure of tcp_syncache which is being
34185420Szec * followed here.
35185420Szec */
36185420Szec
37185420Szec#ifndef _NETINET_TCP_HOSTCACHE_H_
38185420Szec#define _NETINET_TCP_HOSTCACHE_H_
39185420Szec
40185420SzecTAILQ_HEAD(hc_qhead, hc_metrics);
41185420Szec
42185420Szecstruct hc_head {
43185420Szec	struct hc_qhead	hch_bucket;
44185420Szec	u_int		hch_length;
45185420Szec	struct mtx	hch_mtx;
46185420Szec};
47185420Szec
48185420Szecstruct hc_metrics {
49185420Szec	/* housekeeping */
50185420Szec	TAILQ_ENTRY(hc_metrics) rmx_q;
51185420Szec	struct	hc_head *rmx_head; /* head of bucket tail queue */
52185420Szec	struct	in_addr ip4;	/* IP address */
53185420Szec	struct	in6_addr ip6;	/* IP6 address */
54271400Sae	uint32_t ip6_zoneid;	/* IPv6 scope zone id */
55185420Szec	/* endpoint specific values for tcp */
56185420Szec	u_long	rmx_mtu;	/* MTU for this path */
57185420Szec	u_long	rmx_ssthresh;	/* outbound gateway buffer limit */
58185420Szec	u_long	rmx_rtt;	/* estimated round trip time */
59185420Szec	u_long	rmx_rttvar;	/* estimated rtt variance */
60185420Szec	u_long	rmx_cwnd;	/* congestion window */
61185420Szec	u_long	rmx_sendpipe;	/* outbound delay-bandwidth product */
62185420Szec	u_long	rmx_recvpipe;	/* inbound delay-bandwidth product */
63185420Szec	/* TCP hostcache internal data */
64185420Szec	int	rmx_expire;	/* lifetime for object */
65185420Szec	u_long	rmx_hits;	/* number of hits */
66185420Szec	u_long	rmx_updates;	/* number of updates */
67185420Szec};
68185420Szec
69185420Szecstruct tcp_hostcache {
70369630Srscheff	struct hc_head	*hashbase;
71369630Srscheff	uma_zone_t	zone;
72369630Srscheff	u_int		hashsize;
73369630Srscheff	u_int		hashmask;
74369630Srscheff	u_int		bucket_limit;
75369631Srscheff	u_int		cache_count;
76369630Srscheff	u_int		cache_limit;
77369630Srscheff	int		expire;
78369630Srscheff	int		prune;
79369630Srscheff	int		purgeall;
80185420Szec};
81185420Szec
82185420Szec#endif /* !_NETINET_TCP_HOSTCACHE_H_*/
83