xref: /openbsd/usr.bin/systat/cache.h (revision 404b540a)
1 /* $Id: cache.h,v 1.2 2008/07/16 10:23:39 canacar Exp $ */
2 /*
3  * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _CACHE_H_
19 #define _CACHE_H_
20 
21 #include <sys/queue.h>
22 #include <sys/tree.h>
23 #include <net/pfvar.h>
24 
25 struct sc_ent {
26         RB_ENTRY(sc_ent)    tlink;
27 	TAILQ_ENTRY(sc_ent) qlink;
28 	u_int32_t	    id[2];
29 	double		    peak;
30 	double		    rate;
31 	time_t		    t;
32 	u_int32_t	    bytes;
33 };
34 
35 int cache_init(int);
36 void cache_endupdate(void);
37 struct sc_ent *cache_state(struct pfsync_state *);
38 extern int cache_max, cache_size;
39 
40 #define COUNTER(c) ((((u_int64_t) ntohl(c[0]))<<32) + ntohl(c[1]))
41 
42 
43 #endif
44