support of reportMessageTypes() function
[strongswan.git] / src / libcharon / plugins / tnc_imv / tnc_imv_bind_function.c
1 /*
2 * Copyright (C) 2006 Mike McCauley
3 * Copyright (C) 2010 Andreas Steffen, 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 #include "tnc_imv.h"
17
18 #include <debug.h>
19 #include <daemon.h>
20
21 /**
22 * Called by the IMV to inform a TNCS about the set of message types the IMV
23 * is able to receive
24 */
25 TNC_Result TNC_TNCS_ReportMessageTypes(TNC_IMVID imv_id,
26 TNC_MessageTypeList supported_types,
27 TNC_UInt32 type_count)
28 {
29 DBG2(DBG_TNC,"TNCS_ReportMessageTypes %u %u", imv_id, type_count);
30 return charon->imvs->set_message_types(charon->imvs, imv_id,
31 supported_types, type_count);
32 }
33
34 /**
35 * Called by the IMV to ask a TNCS to retry an Integrity Check Handshake
36 */
37 TNC_Result TNC_TNCS_RequestHandshakeRetry(TNC_IMVID imv_id,
38 TNC_ConnectionID connection_id,
39 TNC_RetryReason reason)
40 {
41 DBG2(DBG_TNC,"TNCS_RequestHandshakeRetry %u %u", imv_id, connection_id);
42 return TNC_RESULT_SUCCESS;
43 }
44
45 /**
46 * Called by the IMV when an IMV-IMC message is to be sent
47 */
48 TNC_Result TNC_TNCS_SendMessage(TNC_IMVID imv_id,
49 TNC_ConnectionID connection_id,
50 TNC_BufferReference message,
51 TNC_UInt32 message_len,
52 TNC_MessageType message_type)
53 {
54 DBG2(DBG_TNC,"TNCS_SendMessage %u %u '%s' %u %0x", imv_id, connection_id,
55 message, message_len, message_type);
56 return charon->tnccs->send_message(charon->tnccs, connection_id, message,
57 message_len, message_type);
58 }
59
60 /**
61 * Called by the IMV to deliver its IMV Action Recommendation and IMV Evaluation
62 * Result to the TNCS
63 */
64 TNC_Result TNC_TNCS_ProvideRecommendation(TNC_IMVID imv_id,
65 TNC_ConnectionID connection_id,
66 TNC_IMV_Action_Recommendation recommendation,
67 TNC_IMV_Evaluation_Result evaluation)
68 {
69 DBG2(DBG_TNC,"TNCS_ProvideRecommendation %u %u", imv_id, connection_id);
70 return TNC_RESULT_SUCCESS;
71 }
72
73 /**
74 * Called by the IMV when it needs a function pointer
75 */
76 TNC_Result TNC_TNCS_BindFunction(TNC_IMVID id,
77 char *function_name,
78 void **function_pointer)
79 {
80 if (streq(function_name, "TNC_TNCS_ReportMessageTypes"))
81 {
82 *function_pointer = (void*)TNC_TNCS_ReportMessageTypes;
83 }
84 else if (streq(function_name, "TNC_TNCS_RequestHandshakeRetry"))
85 {
86 *function_pointer = (void*)TNC_TNCS_RequestHandshakeRetry;
87 }
88 else if (streq(function_name, "TNC_TNCS_SendMessage"))
89 {
90 *function_pointer = (void*)TNC_TNCS_SendMessage;
91 }
92 else if (streq(function_name, "TNC_TNCS_ProvideRecommendation"))
93 {
94 *function_pointer = (void*)TNC_TNCS_ProvideRecommendation;
95 }
96 else
97 {
98 return TNC_RESULT_INVALID_PARAMETER;
99 }
100 return TNC_RESULT_SUCCESS;
101 }