implemented provide_recommendation callback function
[strongswan.git] / src / libcharon / tnc / tnccs / tnccs_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 tnccs_manager tnccs_manager
18 * @{ @ingroup tnccs
19 */
20
21 #ifndef TNCCS_MANAGER_H_
22 #define TNCCS_MANAGER_H_
23
24 #include "tnccs.h"
25
26 typedef struct tnccs_manager_t tnccs_manager_t;
27
28 /**
29 * The TNCCS manager manages all TNCCS implementations and creates instances.
30 *
31 * A plugin registers its implemented TNCCS protocol with the manager by
32 * providing type and a constructor function. The manager then creates
33 * TNCCS protocol instances via the provided constructor.
34 */
35 struct tnccs_manager_t {
36
37 /**
38 * Register a TNCCS protocol implementation.
39 *
40 * @param type TNCCS protocol type
41 * @param constructor constructor, returns a TNCCS protocol implementation
42 */
43 void (*add_method)(tnccs_manager_t *this, tnccs_type_t type,
44 tnccs_constructor_t constructor);
45
46 /**
47 * Unregister a TNCCS protocol implementation using it's constructor.
48 *
49 * @param constructor constructor function to remove, as added in add_method
50 */
51 void (*remove_method)(tnccs_manager_t *this, tnccs_constructor_t constructor);
52
53 /**
54 * Create a new TNCCS protocol instance.
55 *
56 * @param type type of the TNCCS protocol
57 * @param is_server TRUE if TNC Server, FALSE if TNC Client
58 * @return TNCCS protocol instance, NULL if no constructor found
59 */
60 tnccs_t* (*create_instance)(tnccs_manager_t *this, tnccs_type_t type,
61 bool is_server);
62
63 /**
64 * Create a TNCCS connection and assign a unique connection ID as well as
65 * callback functions for adding a message to a TNCCS batch and delivering
66 * an IMV recommendation, respectively
67 *
68 * @param tnccs TNCCS connection instance
69 * @param send_message TNCCS callback function
70 * @param provide_recommendation TNCS callback function
71 * @return assigned connection ID
72 */
73 TNC_ConnectionID (*create_connection)(tnccs_manager_t *this, tnccs_t *tnccs,
74 tnccs_send_message_t send_message,
75 tnccs_provide_recommendation_t provide_recommendation);
76
77 /**
78 * Remove a TNCCS connection using its connection ID.
79 *
80 * @param id connection ID of the connection to be removed
81 */
82 void (*remove_connection)(tnccs_manager_t *this, TNC_ConnectionID id);
83
84 /**
85 * Add an IMC/IMV message to the batch of a given connection ID.
86 *
87 * @param id target connection ID
88 * @param message message to be added
89 * @param message_len message length
90 * @param message_type message type
91 * @return return code
92 */
93 TNC_Result (*send_message)(tnccs_manager_t *this,
94 TNC_ConnectionID id,
95 TNC_BufferReference message,
96 TNC_UInt32 message_len,
97 TNC_MessageType message_type);
98
99 /**
100 * Deliver an IMV Action Recommendation and IMV Evaluation Result to the TNCS
101 *
102 * @param imv_id ID of the IMV providing the recommendation
103 * @param connection_id target connection ID
104 * @param recommendation action recommendation
105 * @param evaluation evaluation result
106 */
107 TNC_Result (*provide_recommendation)(tnccs_manager_t *this,
108 TNC_IMVID imv_id,
109 TNC_ConnectionID connection_id,
110 TNC_IMV_Action_Recommendation recommendation,
111 TNC_IMV_Evaluation_Result evaluation);
112
113 /**
114 * Destroy a tnccs_manager instance.
115 */
116 void (*destroy)(tnccs_manager_t *this);
117 };
118
119 /**
120 * Create a tnccs_manager instance.
121 */
122 tnccs_manager_t *tnccs_manager_create();
123
124 #endif /** TNCCS_MANAGER_H_ @}*/