added get_count() method to IMC/IMV managers
[strongswan.git] / src / libcharon / tnc / imc / imc_manager.h
1 /*
2 * Copyright (C) 2010 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 imc_manager imc_manager
18 * @{ @ingroup imc
19 */
20
21 #ifndef IMC_MANAGER_H_
22 #define IMC_MANAGER_H_
23
24 #include "imc.h"
25
26 #include <library.h>
27
28 typedef struct imc_manager_t imc_manager_t;
29
30 /**
31 * The IMC manager controls all IMC instances.
32 */
33 struct imc_manager_t {
34
35 /**
36 * Add an IMC instance
37 *
38 * @param imc IMC instance
39 * @return TRUE if initialization successful
40 */
41 bool (*add)(imc_manager_t *this, imc_t *imc);
42
43 /**
44 * Remove an IMC instance from the list and return it
45 *
46 * @param id ID of IMC instance
47 * @return removed IMC instance
48 */
49 imc_t* (*remove)(imc_manager_t *this, TNC_IMCID id);
50
51 /**
52 * Return the number of registered IMCs
53 *
54 * @return number of IMCs
55 */
56 int (*get_count)(imc_manager_t *this);
57
58 /**
59 * Notify all IMC instances
60 *
61 * @param state communicate the state a connection has reached
62 */
63 void (*notify_connection_change)(imc_manager_t *this,
64 TNC_ConnectionID id,
65 TNC_ConnectionState state);
66
67 /**
68 * Begin a handshake between the IMCs and a connection
69 *
70 * @param id Connection ID
71 */
72 void (*begin_handshake)(imc_manager_t *this, TNC_ConnectionID id);
73
74 /**
75 * Sets the supported message types reported by a given IMC
76 *
77 * @param id ID of reporting IMC
78 * @param supported_types list of messages type supported by IMC
79 * @param type_count number of supported message types
80 * @return TNC result code
81 */
82 TNC_Result (*set_message_types)(imc_manager_t *this,
83 TNC_IMCID id,
84 TNC_MessageTypeList supported_types,
85 TNC_UInt32 type_count);
86
87 /**
88 * Delivers a message to interested IMCs.
89 *
90 * @param connection_id ID of connection over which message was received
91 * @param message message
92 * @param message_len message length
93 * @param message_type message type
94 */
95 void (*receive_message)(imc_manager_t *this,
96 TNC_ConnectionID connection_id,
97 TNC_BufferReference message,
98 TNC_UInt32 message_len,
99 TNC_MessageType message_type);
100
101 /**
102 * Destroy an IMC manager and all its controlled instances.
103 */
104 void (*destroy)(imc_manager_t *this);
105 };
106
107 #endif /** IMC_MANAGER_H_ @}*/