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
23 typedef struct private_tnc_imc_t private_tnc_imc_t
;
25 struct private_tnc_imc_t
{
28 * Public members of imc_t.
43 METHOD(imc_t
, set_id
, void,
44 private_tnc_imc_t
*this, TNC_IMCID id
)
49 METHOD(imc_t
, get_id
, TNC_IMCID
,
50 private_tnc_imc_t
*this)
55 METHOD(imc_t
, get_name
, char*,
56 private_tnc_imc_t
*this)
61 METHOD(imc_t
, destroy
, void,
62 private_tnc_imc_t
*this)
69 * Described in header.
71 imc_t
* tnc_imc_create(char* name
, char *filename
)
73 private_tnc_imc_t
*this;
80 .get_name
= _get_name
,
85 handle
= dlopen(filename
, RTLD_NOW
);
88 DBG1(DBG_TNC
, "IMC '%s' failed to load from '%s': %s",
89 name
, filename
, dlerror());
94 /* we do not store or free dlopen() handles, leak_detective requires
95 * the modules to keep loaded until leak report */
97 this->public.initialize
= dlsym(handle
, "TNC_IMC_Initialize");
98 if (!this->public.initialize
)
100 DBG1(DBG_TNC
, "could not resolve TNC_IMC_Initialize in %s: %s\n",
101 filename
, dlerror());
105 this->public.notify_connection_change
=
106 dlsym(handle
, "TNC_IMC_NotifyConnectionChange");
107 this->public.begin_handshake
= dlsym(handle
, "TNC_IMC_BeginHandshake");
108 if (!this->public.begin_handshake
)
110 DBG1(DBG_TNC
, "could not resolve TNC_IMC_BeginHandshake in %s: %s\n",
111 filename
, dlerror());
115 this->public.receive_message
=
116 dlsym(handle
, "TNC_IMC_ReceiveMessage");
117 this->public.batch_ending
=
118 dlsym(handle
, "TNC_IMC_BatchEnding");
119 this->public.terminate
=
120 dlsym(handle
, "TNC_IMC_Terminate");
121 this->public.provide_bind_function
=
122 dlsym(handle
, "TNC_IMC_ProvideBindFunction");
123 if (!this->public.provide_bind_function
)
125 DBG1(DBG_TNC
, "could not resolve TNC_IMC_ProvideBindFunction in %s: %s\n",
126 filename
, dlerror());
130 this->name
= strdup(name
);
132 return &this->public;
136 * Called by the IMC to inform a TNCC about the set of message types the IMC
139 TNC_Result
TNC_TNCC_ReportMessageTypes(TNC_IMCID imc_id
,
140 TNC_MessageTypeList supported_types
,
141 TNC_UInt32 type_count
)
143 DBG2(DBG_TNC
,"TNCC_ReportMessageTypes %u %u", imc_id
, type_count
);
144 return TNC_RESULT_SUCCESS
;
148 * Called by the IMC to ask a TNCC to retry an Integrity Check Handshake
150 TNC_Result
TNC_TNCC_RequestHandshakeRetry(TNC_IMCID imc_id
,
151 TNC_ConnectionID connection_id
,
152 TNC_RetryReason reason
)
154 DBG2(DBG_TNC
,"TNCC_RequestHandshakeRetry %u %u", imc_id
, connection_id
);
155 return TNC_RESULT_SUCCESS
;
159 * Called by the IMC when an IMC-IMV message is to be sent
161 TNC_Result
TNC_TNCC_SendMessage(TNC_IMCID imc_id
,
162 TNC_ConnectionID connection_id
,
163 TNC_BufferReference message
,
164 TNC_UInt32 message_len
,
165 TNC_MessageType message_type
)
167 DBG2(DBG_TNC
,"TNCC_SendMessage %u %u '%s' %u %0x", imc_id
, connection_id
,
168 message
, message_len
, message_type
);
169 return charon
->tnccs
->send_message(charon
->tnccs
, connection_id
, message
,
170 message_len
, message_type
);
174 * Called by the IMC when it needs a function pointer
176 TNC_Result
TNC_TNCC_BindFunction(TNC_IMCID id
,
178 void **function_pointer
)
180 if (streq(function_name
, "TNC_TNCC_ReportMessageTypes"))
182 *function_pointer
= (void*)TNC_TNCC_ReportMessageTypes
;
184 else if (streq(function_name
, "TNC_TNCC_RequestHandshakeRetry"))
186 *function_pointer
= (void*)TNC_TNCC_RequestHandshakeRetry
;
188 else if (streq(function_name
, "TNC_TNCC_SendMessage"))
190 *function_pointer
= (void*)TNC_TNCC_SendMessage
;
194 return TNC_RESULT_INVALID_PARAMETER
;
196 return TNC_RESULT_SUCCESS
;