forked from DataSoft/Honeyd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeycount.h
101 lines (80 loc) · 2.8 KB
/
keycount.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright (c) 2002, 2003, 2004 Niels Provos <[email protected]>
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _KEYCOUNT_H_
#define _KEYCOUNT_H_
struct keycount {
SPLAY_ENTRY(keycount) node;
const void *key;
size_t keylen;
void *auxilary;
void (*aux_free)(void *);
struct count *count;
};
int kc_compare(const struct keycount *a, const struct keycount *b);
SPLAY_HEAD(kctree, keycount);
SPLAY_PROTOTYPE(kctree, keycount, node, kc_compare);
struct keycount *keycount_new(const void *key, size_t len,
void *(*)(void), void (*)(void *));
void keycount_free(struct keycount *);
/* Time-series keeping */
#define TIME_ENTRIES 64
struct timeentry {
TAILQ_ENTRY(timeentry) next;
struct timeval tv;
uint32_t entries[TIME_ENTRIES];
int nentries;
};
struct timekey {
SPLAY_ENTRY(timekey) node;
TAILQ_HEAD(timeq, timeentry) entries;
void *key;
size_t keylen;
};
SPLAY_HEAD(timetree, timekey);
struct kctree;
struct keycount;
struct timeseries {
SPLAY_ENTRY(timeseries) node;
SPLAY_ENTRY(timeseries) update_node;
char *name;
struct kctree *tree;
void (*extract)(struct keycount *, void **, size_t *);
void (*print)(void *, size_t);
struct timeval tv_start;
struct timeval tv_update;
struct timeval tv_next;
struct timetree entries;
};
void timeseries_init(void);
void timeseries_update(struct timeval *tv);
int key_compare(const void *a, size_t alen, const void *b, size_t blen);
#endif /* _KEYCOUNT_H_ */