Merge branch 'stroke-counters'
[strongswan.git] / src / libcharon / plugins / stroke / stroke_counter.h
1 /*
2 * Copyright (C) 2012 Martin Willi
3 * Copyright (C) 2012 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup stroke_counter stroke_counter
18 * @{ @ingroup stroke
19 */
20
21 #ifndef STROKE_COUNTER_H_
22 #define STROKE_COUNTER_H_
23
24 #include <bus/listeners/listener.h>
25
26 typedef struct stroke_counter_t stroke_counter_t;
27 typedef enum stroke_counter_type_t stroke_counter_type_t;
28
29 enum stroke_counter_type_t {
30 /** initiated IKE_SA rekeyings */
31 COUNTER_INIT_IKE_SA_REKEY,
32 /** responded IKE_SA rekeyings */
33 COUNTER_RESP_IKE_SA_REKEY,
34 /** completed CHILD_SA rekeyings */
35 COUNTER_CHILD_SA_REKEY,
36 /** messages with invalid types, length, or a value out of range */
37 COUNTER_IN_INVALID,
38 /** messages with an invalid IKE SPI */
39 COUNTER_IN_INVALID_IKE_SPI,
40 /** received IKE_SA_INIT requests */
41 COUNTER_IN_IKE_SA_INIT_REQ,
42 /** received IKE_SA_INIT responses */
43 COUNTER_IN_IKE_SA_INIT_RSP,
44 /** sent IKE_SA_INIT requests */
45 COUNTER_OUT_IKE_SA_INIT_REQ,
46 /** sent IKE_SA_INIT responses */
47 COUNTER_OUT_IKE_SA_INIT_RES,
48 /** received IKE_AUTH requests */
49 COUNTER_IN_IKE_AUTH_REQ,
50 /** received IKE_AUTH responses */
51 COUNTER_IN_IKE_AUTH_RSP,
52 /** sent IKE_AUTH requests */
53 COUNTER_OUT_IKE_AUTH_REQ,
54 /** sent IKE_AUTH responses */
55 COUNTER_OUT_IKE_AUTH_RSP,
56 /** received CREATE_CHILD_SA requests */
57 COUNTER_IN_CREATE_CHILD_SA_REQ,
58 /** received CREATE_CHILD_SA responses */
59 COUNTER_IN_CREATE_CHILD_SA_RSP,
60 /** sent CREATE_CHILD_SA requests */
61 COUNTER_OUT_CREATE_CHILD_SA_REQ,
62 /** sent CREATE_CHILD_SA responses */
63 COUNTER_OUT_CREATE_CHILD_SA_RSP,
64 /** received INFORMATIONAL requests */
65 COUNTER_IN_INFORMATIONAL_REQ,
66 /** received INFORMATIONAL responses */
67 COUNTER_IN_INFORMATIONAL_RSP,
68 /** sent INFORMATIONAL requests */
69 COUNTER_OUT_INFORMATIONAL_REQ,
70 /** sent INFORMATIONAL responses */
71 COUNTER_OUT_INFORMATIONAL_RSP,
72 /** number of counter types */
73 COUNTER_MAX
74 };
75
76 /**
77 * Collection of counter values for different IKE events.
78 */
79 struct stroke_counter_t {
80
81 /**
82 * Implements listener_t.
83 */
84 listener_t listener;
85
86 /**
87 * Print counter values to an output stream.
88 *
89 * @param out output stream to write to
90 * @param name connection name to get counters for, NULL for global
91 */
92 void (*print)(stroke_counter_t *this, FILE *out, char *name);
93
94 /**
95 * Reset global or connection specific counters.
96 *
97 * @param name name of connection counters to reset, NULL for global
98 */
99 void (*reset)(stroke_counter_t *this, char *name);
100
101 /**
102 * Destroy a stroke_counter_t.
103 */
104 void (*destroy)(stroke_counter_t *this);
105 };
106
107 /**
108 * Create a stroke_counter instance.
109 */
110 stroke_counter_t *stroke_counter_create();
111
112 #endif /** STROKE_COUNTER_H_ @}*/