Added add_segment() method to IETF attributes
[strongswan.git] / src / libimcv / plugins / imv_scanner / imv_scanner_state.h
1 /*
2 * Copyright (C) 2011-2013 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
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 imv_scanner imv_scanner
18 * @ingroup libimcv_plugins
19 *
20 * @defgroup imv_scanner_state_t imv_scanner_state
21 * @{ @ingroup imv_scanner
22 */
23
24 #ifndef IMV_SCANNER_STATE_H_
25 #define IMV_SCANNER_STATE_H_
26
27 #include <imv/imv_state.h>
28 #include <ietf/ietf_attr_port_filter.h>
29
30 #include <library.h>
31
32 typedef struct imv_scanner_state_t imv_scanner_state_t;
33 typedef enum imv_scanner_handshake_state_t imv_scanner_handshake_state_t;
34
35 /**
36 * IMV Scanner Handshake States (state machine)
37 */
38 enum imv_scanner_handshake_state_t {
39 IMV_SCANNER_STATE_INIT,
40 IMV_SCANNER_STATE_ATTR_REQ,
41 IMV_SCANNER_STATE_WORKITEMS,
42 IMV_SCANNER_STATE_END
43 };
44
45 /**
46 * Internal state of an imv_scanner_t connection instance
47 */
48 struct imv_scanner_state_t {
49
50 /**
51 * imv_state_t interface
52 */
53 imv_state_t interface;
54
55 /**
56 * Set state of the handshake
57 *
58 * @param new_state the handshake state of IMV
59 */
60 void (*set_handshake_state)(imv_scanner_state_t *this,
61 imv_scanner_handshake_state_t new_state);
62
63 /**
64 * Get state of the handshake
65 *
66 * @return the handshake state of IMV
67 */
68 imv_scanner_handshake_state_t (*get_handshake_state)(imv_scanner_state_t *this);
69
70 /**
71 * Store an IETF Port Filter attribute for later evaluation
72 *
73 * @param attr IETF Port Filter attribute
74 */
75 void (*set_port_filter_attr)(imv_scanner_state_t *this,
76 ietf_attr_port_filter_t *attr);
77
78 /**
79 * Get the stored IETF Port Filter attribute
80 *
81 * @return IETF Port Filter attribute
82 */
83 ietf_attr_port_filter_t* (*get_port_filter_attr)(imv_scanner_state_t *this);
84
85 /**
86 * add a violating TCP or UDP port
87 */
88 void (*add_violating_port)(imv_scanner_state_t *this, char *port);
89 };
90
91 /**
92 * Create an imv_scanner_state_t instance
93 *
94 * @param id connection ID
95 */
96 imv_state_t* imv_scanner_state_create(TNC_ConnectionID id);
97
98 #endif /** IMV_SCANNER_STATE_H_ @}*/