1 /* $OpenBSD: cache.h,v 1.6 2019/01/17 05:56:29 tedu 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_int64_t id; 29 u_int32_t creatorid; 30 double peak; 31 double rate; 32 time_t t; 33 u_int64_t bytes; 34 }; 35 36 int cache_init(int); 37 void cache_endupdate(void); 38 struct sc_ent *cache_state(struct pfsync_state *); 39 extern int cache_max, cache_size; 40 41 #define COUNTER(c) ((((u_int64_t) ntohl(c[0]))<<32) + ntohl(c[1])) 42 43 #endif 44