2 * Copyright (C) 2006 Mike McCauley
3 * Copyright (C) 2010 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
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>.
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
17 #include <tnc/imc/imc_manager.h>
18 #include <tnc/tnccs/tnccs_manager.h>
23 * Called by the IMC to inform a TNCC about the set of message types the IMC
26 TNC_Result
TNC_TNCC_ReportMessageTypes(TNC_IMCID imc_id
,
27 TNC_MessageTypeList supported_types
,
28 TNC_UInt32 type_count
)
30 if (!tnc
->imcs
->is_registered(tnc
->imcs
, imc_id
))
32 DBG1(DBG_TNC
, "ignoring ReportMessageTypes() from unregistered IMC %u",
34 return TNC_RESULT_INVALID_PARAMETER
;
36 return tnc
->imcs
->set_message_types(tnc
->imcs
, imc_id
, supported_types
,
41 * Called by the IMC to inform a TNCC about the set of message types the IMC
42 * is able to receive. This function supports long message types.
44 TNC_Result
TNC_TNCC_ReportMessageTypesLong(TNC_IMCID imc_id
,
45 TNC_VendorIDList supported_vids
,
46 TNC_MessageSubtypeList supported_subtypes
,
47 TNC_UInt32 type_count
)
49 if (!tnc
->imcs
->is_registered(tnc
->imcs
, imc_id
))
51 DBG1(DBG_TNC
, "ignoring ReportMessageTypesLong() from unregistered IMC %u",
53 return TNC_RESULT_INVALID_PARAMETER
;
55 return tnc
->imcs
->set_message_types_long(tnc
->imcs
, imc_id
, supported_vids
,
56 supported_subtypes
, type_count
);
60 * Called by the IMC to ask a TNCC to retry an Integrity Check Handshake
62 TNC_Result
TNC_TNCC_RequestHandshakeRetry(TNC_IMCID imc_id
,
63 TNC_ConnectionID connection_id
,
64 TNC_RetryReason reason
)
66 if (!tnc
->imcs
->is_registered(tnc
->imcs
, imc_id
))
68 DBG1(DBG_TNC
, "ignoring RequestHandshakeRetry() from unregistered IMC %u",
70 return TNC_RESULT_INVALID_PARAMETER
;
72 return tnc
->tnccs
->request_handshake_retry(tnc
->tnccs
, TRUE
, imc_id
,
73 connection_id
, reason
);
77 * Called by the IMC when an IMC-IMV message is to be sent
79 TNC_Result
TNC_TNCC_SendMessage(TNC_IMCID imc_id
,
80 TNC_ConnectionID connection_id
,
81 TNC_BufferReference msg
,
83 TNC_MessageType msg_type
)
86 TNC_MessageSubtype msg_subtype
;
88 if (!tnc
->imcs
->is_registered(tnc
->imcs
, imc_id
))
90 DBG1(DBG_TNC
, "ignoring SendMessage() from unregistered IMC %u",
92 return TNC_RESULT_INVALID_PARAMETER
;
94 msg_vid
= (msg_type
>> 8) & TNC_VENDORID_ANY
;
95 msg_subtype
= msg_type
& TNC_SUBTYPE_ANY
;
97 return tnc
->tnccs
->send_message(tnc
->tnccs
, imc_id
, TNC_IMVID_ANY
,
98 connection_id
, 0, msg
, msg_len
, msg_vid
, msg_subtype
);
102 * Called by the IMC when an IMC-IMV message is to be sent over IF-TNCCS 2.0
104 TNC_Result
TNC_TNCC_SendMessageLong(TNC_IMCID imc_id
,
105 TNC_ConnectionID connection_id
,
106 TNC_UInt32 msg_flags
,
107 TNC_BufferReference msg
,
109 TNC_VendorID msg_vid
,
110 TNC_MessageSubtype msg_subtype
,
113 if (!tnc
->imcs
->is_registered(tnc
->imcs
, imc_id
))
115 DBG1(DBG_TNC
, "ignoring SendMessage() from unregistered IMC %u",
117 return TNC_RESULT_INVALID_PARAMETER
;
119 return tnc
->tnccs
->send_message(tnc
->tnccs
, imc_id
, imv_id
, connection_id
,
120 msg_flags
, msg
, msg_len
, msg_vid
, msg_subtype
);
124 * Called by the IMC when it needs a function pointer
126 TNC_Result
TNC_TNCC_BindFunction(TNC_IMCID id
,
128 void **function_pointer
)
130 if (streq(function_name
, "TNC_TNCC_ReportMessageTypes"))
132 *function_pointer
= (void*)TNC_TNCC_ReportMessageTypes
;
134 else if (streq(function_name
, "TNC_TNCC_ReportMessageTypesLong"))
136 *function_pointer
= (void*)TNC_TNCC_ReportMessageTypesLong
;
138 else if (streq(function_name
, "TNC_TNCC_RequestHandshakeRetry"))
140 *function_pointer
= (void*)TNC_TNCC_RequestHandshakeRetry
;
142 else if (streq(function_name
, "TNC_TNCC_SendMessage"))
144 *function_pointer
= (void*)TNC_TNCC_SendMessage
;
146 else if (streq(function_name
, "TNC_TNCC_SendMessageLong"))
148 *function_pointer
= (void*)TNC_TNCC_SendMessageLong
;
152 return TNC_RESULT_INVALID_PARAMETER
;
154 return TNC_RESULT_SUCCESS
;