fixed a memory leak in imc|imv_agent
[strongswan.git] / src / libimcv / imc / imc_agent.c
1 /*
2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #include "imcv.h"
16 #include "imc_agent.h"
17
18 #include <tncif_names.h>
19
20 #include <debug.h>
21 #include <threading/rwlock.h>
22
23 typedef struct private_imc_agent_t private_imc_agent_t;
24
25 /**
26 * Private data of an imc_agent_t object.
27 */
28 struct private_imc_agent_t {
29
30 /**
31 * Public members of imc_agent_t
32 */
33 imc_agent_t public;
34
35 /**
36 * name of IMC
37 */
38 const char *name;
39
40 /**
41 * message vendor ID of IMC
42 */
43 TNC_VendorID vendor_id;
44
45 /**
46 * message subtype of IMC
47 */
48 TNC_MessageSubtype subtype;
49
50 /**
51 * ID of IMC as assigned by TNCC
52 */
53 TNC_IMCID id;
54
55 /**
56 * List of additional IMC IDs assigned by TNCC
57 */
58 linked_list_t *additional_ids;
59
60 /**
61 * list of TNCC connection entries
62 */
63 linked_list_t *connections;
64
65 /**
66 * rwlock to lock TNCC connection entries
67 */
68 rwlock_t *connection_lock;
69
70 /**
71 * Inform a TNCC about the set of message types the IMC is able to receive
72 *
73 * @param imc_id IMC ID assigned by TNCC
74 * @param supported_types list of supported message types
75 * @param type_count number of list elements
76 * @return TNC result code
77 */
78 TNC_Result (*report_message_types)(TNC_IMCID imc_id,
79 TNC_MessageTypeList supported_types,
80 TNC_UInt32 type_count);
81
82 /**
83 * Inform a TNCC about the set of message types the IMC is able to receive
84 *
85 * @param imc_id IMC ID assigned by TNCC
86 * @param supported_vids list of supported message vendor IDs
87 * @param supported_subtypes list of supported message subtypes
88 * @param type_count number of list elements
89 * @return TNC result code
90 */
91 TNC_Result (*report_message_types_long)(TNC_IMCID imc_id,
92 TNC_VendorIDList supported_vids,
93 TNC_MessageSubtypeList supported_subtypes,
94 TNC_UInt32 type_count);
95
96 /**
97 * Call when an IMC-IMC message is to be sent
98 *
99 * @param imc_id IMC ID assigned by TNCC
100 * @param connection_id network connection ID assigned by TNCC
101 * @param msg message to send
102 * @param msg_len message length in bytes
103 * @param msg_type message type
104 * @return TNC result code
105 */
106 TNC_Result (*send_message)(TNC_IMCID imc_id,
107 TNC_ConnectionID connection_id,
108 TNC_BufferReference msg,
109 TNC_UInt32 msg_len,
110 TNC_MessageType msg_type);
111
112
113 /**
114 * Call when an IMC-IMC message is to be sent with long message types
115 *
116 * @param imc_id IMC ID assigned by TNCC
117 * @param connection_id network connection ID assigned by TNCC
118 * @param msg_flags message flags
119 * @param msg message to send
120 * @param msg_len message length in bytes
121 * @param msg_vid message vendor ID
122 * @param msg_subtype message subtype
123 * @param dst_imc_id destination IMV ID
124 * @return TNC result code
125 */
126 TNC_Result (*send_message_long)(TNC_IMCID imc_id,
127 TNC_ConnectionID connection_id,
128 TNC_UInt32 msg_flags,
129 TNC_BufferReference msg,
130 TNC_UInt32 msg_len,
131 TNC_VendorID msg_vid,
132 TNC_MessageSubtype msg_subtype,
133 TNC_UInt32 dst_imv_id);
134
135 /**
136 * Get the value of an attribute associated with a connection
137 * or with the TNCC as a whole.
138 *
139 * @param imc_id IMC ID assigned by TNCC
140 * @param connection_id network connection ID assigned by TNCC
141 * @param attribute_id attribute ID
142 * @param buffer_len length of buffer in bytes
143 * @param buffer buffer
144 * @param out_value_len size in bytes of attribute stored in buffer
145 * @return TNC result code
146 */
147 TNC_Result (*get_attribute)(TNC_IMCID imc_id,
148 TNC_ConnectionID connection_id,
149 TNC_AttributeID attribute_id,
150 TNC_UInt32 buffer_len,
151 TNC_BufferReference buffer,
152 TNC_UInt32 *out_value_len);
153
154 /**
155 * Set the value of an attribute associated with a connection
156 * or with the TNCC as a whole.
157 *
158 * @param imc_id IMV ID assigned by TNCC
159 * @param connection_id network connection ID assigned by TNCC
160 * @param attribute_id attribute ID
161 * @param buffer_len length of buffer in bytes
162 * @param buffer buffer
163 * @return TNC result code
164 */
165 TNC_Result (*set_attribute)(TNC_IMCID imc_id,
166 TNC_ConnectionID connection_id,
167 TNC_AttributeID attribute_id,
168 TNC_UInt32 buffer_len,
169 TNC_BufferReference buffer);
170
171 /**
172 * Reserve an additional IMC ID
173 *
174 * @param imc_id primary IMC ID assigned by TNCC
175 * @param out_imc_id additional IMC ID assigned by TNCC
176 * @return TNC result code
177 */
178 TNC_Result (*reserve_additional_id)(TNC_IMCID imc_id,
179 TNC_UInt32 *out_imc_id);
180
181 };
182
183 METHOD(imc_agent_t, bind_functions, TNC_Result,
184 private_imc_agent_t *this, TNC_TNCC_BindFunctionPointer bind_function)
185 {
186 if (!bind_function)
187 {
188 DBG1(DBG_IMC, "TNC client failed to provide bind function");
189 return TNC_RESULT_INVALID_PARAMETER;
190 }
191 if (bind_function(this->id, "TNC_TNCC_ReportMessageTypes",
192 (void**)&this->report_message_types) != TNC_RESULT_SUCCESS)
193 {
194 this->report_message_types = NULL;
195 }
196 if (bind_function(this->id, "TNC_TNCC_ReportMessageTypesLong",
197 (void**)&this->report_message_types_long) != TNC_RESULT_SUCCESS)
198 {
199 this->report_message_types_long = NULL;
200 }
201 if (bind_function(this->id, "TNC_TNCC_RequestHandshakeRetry",
202 (void**)&this->public.request_handshake_retry) != TNC_RESULT_SUCCESS)
203 {
204 this->public.request_handshake_retry = NULL;
205 }
206 if (bind_function(this->id, "TNC_TNCC_SendMessage",
207 (void**)&this->send_message) != TNC_RESULT_SUCCESS)
208 {
209 this->send_message = NULL;
210 }
211 if (bind_function(this->id, "TNC_TNCC_SendMessageLong",
212 (void**)&this->send_message_long) != TNC_RESULT_SUCCESS)
213 {
214 this->send_message_long = NULL;
215 }
216 if (bind_function(this->id, "TNC_TNCC_GetAttribute",
217 (void**)&this->get_attribute) != TNC_RESULT_SUCCESS)
218 {
219 this->get_attribute = NULL;
220 }
221 if (bind_function(this->id, "TNC_TNCC_SetAttribute",
222 (void**)&this->set_attribute) != TNC_RESULT_SUCCESS)
223 {
224 this->set_attribute = NULL;
225 }
226 if (bind_function(this->id, "TNC_TNCC_ReserveAdditionalIMCID",
227 (void**)&this->reserve_additional_id) != TNC_RESULT_SUCCESS)
228 {
229 this->reserve_additional_id = NULL;
230 }
231 DBG2(DBG_IMC, "IMC %u \"%s\" provided with bind function",
232 this->id, this->name);
233
234 if (this->report_message_types_long)
235 {
236 this->report_message_types_long(this->id, &this->vendor_id,
237 &this->subtype, 1);
238 }
239 else if (this->report_message_types &&
240 this->vendor_id <= TNC_VENDORID_ANY &&
241 this->subtype <= TNC_SUBTYPE_ANY)
242 {
243 TNC_MessageType type;
244
245 type = (this->vendor_id << 8) | this->subtype;
246 this->report_message_types(this->id, &type, 1);
247 }
248 return TNC_RESULT_SUCCESS;
249 }
250
251 /**
252 * finds a connection state based on its Connection ID
253 */
254 static imc_state_t* find_connection(private_imc_agent_t *this,
255 TNC_ConnectionID id)
256 {
257 enumerator_t *enumerator;
258 imc_state_t *state, *found = NULL;
259
260 this->connection_lock->read_lock(this->connection_lock);
261 enumerator = this->connections->create_enumerator(this->connections);
262 while (enumerator->enumerate(enumerator, &state))
263 {
264 if (id == state->get_connection_id(state))
265 {
266 found = state;
267 break;
268 }
269 }
270 enumerator->destroy(enumerator);
271 this->connection_lock->unlock(this->connection_lock);
272
273 return found;
274 }
275
276 /**
277 * delete a connection state with a given Connection ID
278 */
279 static bool delete_connection(private_imc_agent_t *this, TNC_ConnectionID id)
280 {
281 enumerator_t *enumerator;
282 imc_state_t *state;
283 bool found = FALSE;
284
285 this->connection_lock->write_lock(this->connection_lock);
286 enumerator = this->connections->create_enumerator(this->connections);
287 while (enumerator->enumerate(enumerator, &state))
288 {
289 if (id == state->get_connection_id(state))
290 {
291 found = TRUE;
292 state->destroy(state);
293 this->connections->remove_at(this->connections, enumerator);
294 break;
295 }
296 }
297 enumerator->destroy(enumerator);
298 this->connection_lock->unlock(this->connection_lock);
299
300 return found;
301 }
302
303 /**
304 * Read a boolean attribute
305 */
306 static bool get_bool_attribute(private_imc_agent_t *this, TNC_ConnectionID id,
307 TNC_AttributeID attribute_id)
308 {
309 TNC_UInt32 len;
310 char buf[4];
311
312 return this->get_attribute &&
313 this->get_attribute(this->id, id, attribute_id, 4, buf, &len) ==
314 TNC_RESULT_SUCCESS && len == 1 && *buf == 0x01;
315 }
316
317 /**
318 * Read a string attribute
319 */
320 static char* get_str_attribute(private_imc_agent_t *this, TNC_ConnectionID id,
321 TNC_AttributeID attribute_id)
322 {
323 TNC_UInt32 len;
324 char buf[BUF_LEN];
325
326 if (this->get_attribute &&
327 this->get_attribute(this->id, id, attribute_id, BUF_LEN, buf, &len) ==
328 TNC_RESULT_SUCCESS && len <= BUF_LEN)
329 {
330 return strdup(buf);
331 }
332 return NULL;
333 }
334
335 METHOD(imc_agent_t, create_state, TNC_Result,
336 private_imc_agent_t *this, imc_state_t *state)
337 {
338 TNC_ConnectionID conn_id;
339 char *tnccs_p = NULL, *tnccs_v = NULL, *t_p = NULL, *t_v = NULL;
340 bool has_long = FALSE, has_excl = FALSE, has_soh = FALSE;
341
342 conn_id = state->get_connection_id(state);
343 if (find_connection(this, conn_id))
344 {
345 DBG1(DBG_IMC, "IMC %u \"%s\" already created a state for Connection ID %u",
346 this->id, this->name, conn_id);
347 state->destroy(state);
348 return TNC_RESULT_OTHER;
349 }
350
351 /* Get and display attributes from TNCC via IF-IMC */
352 has_long = get_bool_attribute(this, conn_id, TNC_ATTRIBUTEID_HAS_LONG_TYPES);
353 has_excl = get_bool_attribute(this, conn_id, TNC_ATTRIBUTEID_HAS_EXCLUSIVE);
354 has_soh = get_bool_attribute(this, conn_id, TNC_ATTRIBUTEID_HAS_SOH);
355 tnccs_p = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFTNCCS_PROTOCOL);
356 tnccs_v = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFTNCCS_VERSION);
357 t_p = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFT_PROTOCOL);
358 t_v = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFT_VERSION);
359
360 state->set_flags(state, has_long, has_excl);
361
362 DBG2(DBG_IMC, "IMC %u \"%s\" created a state for Connection ID %u: "
363 "%s %s with %slong %sexcl %ssoh over %s %s",
364 this->id, this->name, conn_id, tnccs_p ? tnccs_p:"?",
365 tnccs_v ? tnccs_v:"?", has_long ? "+":"-", has_excl ? "+":"-",
366 has_soh ? "+":"-", t_p ? t_p:"?", t_v ? t_v :"?");
367 free(tnccs_p);
368 free(tnccs_v);
369 free(t_p);
370 free(t_v);
371
372 this->connection_lock->write_lock(this->connection_lock);
373 this->connections->insert_last(this->connections, state);
374 this->connection_lock->unlock(this->connection_lock);
375 return TNC_RESULT_SUCCESS;
376 }
377
378 METHOD(imc_agent_t, delete_state, TNC_Result,
379 private_imc_agent_t *this, TNC_ConnectionID connection_id)
380 {
381 if (!delete_connection(this, connection_id))
382 {
383 DBG1(DBG_IMC, "IMC %u \"%s\" has no state for Connection ID %u",
384 this->id, this->name, connection_id);
385 return TNC_RESULT_FATAL;
386 }
387 DBG2(DBG_IMC, "IMC %u \"%s\" deleted the state of Connection ID %u",
388 this->id, this->name, connection_id);
389 return TNC_RESULT_SUCCESS;
390 }
391
392 METHOD(imc_agent_t, change_state, TNC_Result,
393 private_imc_agent_t *this, TNC_ConnectionID connection_id,
394 TNC_ConnectionState new_state,
395 imc_state_t **state_p)
396 {
397 imc_state_t *state;
398
399 switch (new_state)
400 {
401 case TNC_CONNECTION_STATE_HANDSHAKE:
402 case TNC_CONNECTION_STATE_ACCESS_ALLOWED:
403 case TNC_CONNECTION_STATE_ACCESS_ISOLATED:
404 case TNC_CONNECTION_STATE_ACCESS_NONE:
405 state = find_connection(this, connection_id);
406
407 if (!state)
408 {
409 DBG1(DBG_IMC, "IMC %u \"%s\" has no state for Connection ID %u",
410 this->id, this->name, connection_id);
411 return TNC_RESULT_FATAL;
412 }
413 state->change_state(state, new_state);
414 DBG2(DBG_IMC, "IMC %u \"%s\" changed state of Connection ID %u to '%N'",
415 this->id, this->name, connection_id,
416 TNC_Connection_State_names, new_state);
417 if (state_p)
418 {
419 *state_p = state;
420 }
421 break;
422 case TNC_CONNECTION_STATE_CREATE:
423 DBG1(DBG_IMC, "state '%N' should be handled by create_state()",
424 TNC_Connection_State_names, new_state);
425 return TNC_RESULT_FATAL;
426 case TNC_CONNECTION_STATE_DELETE:
427 DBG1(DBG_IMC, "state '%N' should be handled by delete_state()",
428 TNC_Connection_State_names, new_state);
429 return TNC_RESULT_FATAL;
430 default:
431 DBG1(DBG_IMC, "IMC %u \"%s\" was notified of unknown state %u "
432 "for Connection ID %u",
433 this->id, this->name, new_state, connection_id);
434 return TNC_RESULT_INVALID_PARAMETER;
435 }
436 return TNC_RESULT_SUCCESS;
437 }
438
439 METHOD(imc_agent_t, get_state, bool,
440 private_imc_agent_t *this, TNC_ConnectionID connection_id,
441 imc_state_t **state)
442 {
443 *state = find_connection(this, connection_id);
444 if (!*state)
445 {
446 DBG1(DBG_IMC, "IMC %u \"%s\" has no state for Connection ID %u",
447 this->id, this->name, connection_id);
448 return FALSE;
449 }
450 return TRUE;
451 }
452
453 METHOD(imc_agent_t, send_message, TNC_Result,
454 private_imc_agent_t *this, TNC_ConnectionID connection_id, bool excl,
455 TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id, linked_list_t *attr_list)
456 {
457 TNC_MessageType type;
458 TNC_UInt32 msg_flags;
459 TNC_Result result = TNC_RESULT_FATAL;
460 imc_state_t *state;
461 pa_tnc_attr_t *attr;
462 pa_tnc_msg_t *pa_tnc_msg;
463 chunk_t msg;
464
465 state = find_connection(this, connection_id);
466 if (!state)
467 {
468 DBG1(DBG_IMV, "IMC %u \"%s\" has no state for Connection ID %u",
469 this->id, this->name, connection_id);
470 return TNC_RESULT_FATAL;
471 }
472
473 pa_tnc_msg = pa_tnc_msg_create();
474
475 while (attr_list->remove_first(attr_list, (void**)&attr) == SUCCESS)
476 {
477 pa_tnc_msg->add_attribute(pa_tnc_msg, attr);
478 }
479 pa_tnc_msg->build(pa_tnc_msg);
480 msg = pa_tnc_msg->get_encoding(pa_tnc_msg);
481
482 if (state->has_long(state) && this->send_message_long)
483 {
484 if (!src_imc_id)
485 {
486 src_imc_id = this->id;
487 }
488 msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
489
490 result = this->send_message_long(src_imc_id, connection_id, msg_flags,
491 msg.ptr, msg.len, this->vendor_id,
492 this->subtype, dst_imv_id);
493 }
494 else if (this->send_message)
495 {
496 type = (this->vendor_id << 8) | this->subtype;
497
498 result = this->send_message(this->id, connection_id, msg.ptr, msg.len,
499 type);
500 }
501 pa_tnc_msg->destroy(pa_tnc_msg);
502
503 return result;
504 }
505
506 METHOD(imc_agent_t, receive_message, TNC_Result,
507 private_imc_agent_t *this, imc_state_t *state, chunk_t msg,
508 TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype,
509 TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id, pa_tnc_msg_t **pa_tnc_msg)
510 {
511 pa_tnc_msg_t *pa_msg, *error_msg;
512 pa_tnc_attr_t *error_attr;
513 enumerator_t *enumerator;
514 TNC_MessageType msg_type;
515 TNC_UInt32 msg_flags, src_imc_id, dst_imv_id;
516 TNC_ConnectionID connection_id;
517 TNC_Result result;
518
519 connection_id = state->get_connection_id(state);
520
521 if (state->has_long(state))
522 {
523 if (dst_imc_id != TNC_IMCID_ANY)
524 {
525 DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u "
526 "from IMV %u to IMC %u", this->id, this->name,
527 connection_id, src_imv_id, dst_imc_id);
528 }
529 else
530 {
531 DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u "
532 "from IMV %u", this->id, this->name, connection_id,
533 src_imv_id);
534 }
535 }
536 else
537 {
538 DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u",
539 this->id, this->name, connection_id);
540 }
541
542 *pa_tnc_msg = NULL;
543 pa_msg = pa_tnc_msg_create_from_data(msg);
544
545 switch (pa_msg->process(pa_msg))
546 {
547 case SUCCESS:
548 *pa_tnc_msg = pa_msg;
549 break;
550 case VERIFY_ERROR:
551 /* build error message */
552 error_msg = pa_tnc_msg_create();
553 enumerator = pa_msg->create_error_enumerator(pa_msg);
554 while (enumerator->enumerate(enumerator, &error_attr))
555 {
556 error_msg->add_attribute(error_msg,
557 error_attr->get_ref(error_attr));
558 }
559 enumerator->destroy(enumerator);
560 error_msg->build(error_msg);
561
562 /* send error message */
563 if (state->has_long(state) && this->send_message_long)
564 {
565 if (state->has_excl(state))
566 {
567 msg_flags = TNC_MESSAGE_FLAGS_EXCLUSIVE;
568 dst_imv_id = src_imv_id;
569 }
570 else
571 {
572 msg_flags = 0;
573 dst_imv_id = TNC_IMVID_ANY;
574 }
575 src_imc_id = (dst_imc_id == TNC_IMCID_ANY) ? this->id
576 : dst_imc_id;
577
578 result = this->send_message_long(src_imc_id, connection_id,
579 msg_flags, msg.ptr, msg.len, msg_vid,
580 msg_subtype, dst_imv_id);
581 }
582 else if (this->send_message)
583 {
584 msg_type = (msg_vid << 8) | msg_subtype;
585
586 result = this->send_message(this->id, connection_id,
587 msg.ptr, msg.len, msg_type);
588 }
589 else
590 {
591 result = TNC_RESULT_FATAL;
592 }
593
594 /* clean up */
595 error_msg->destroy(error_msg);
596 pa_msg->destroy(pa_msg);
597 return result;
598 case FAILED:
599 default:
600 pa_msg->destroy(pa_msg);
601 return TNC_RESULT_FATAL;
602 }
603 return TNC_RESULT_SUCCESS;
604 }
605
606 METHOD(imc_agent_t, reserve_additional_ids, TNC_Result,
607 private_imc_agent_t *this, int count)
608 {
609 TNC_Result result;
610 TNC_UInt32 id;
611 void *pointer;
612
613 if (!this->reserve_additional_id)
614 {
615 DBG1(DBG_IMC, "IMC %u \"%s\" did not detect the capability to reserve "
616 "additional IMC IDs from the TNCC", this->id, this->name);
617 return TNC_RESULT_ILLEGAL_OPERATION;
618 }
619 while (count > 0)
620 {
621 result = this->reserve_additional_id(this->id, &id);
622 if (result != TNC_RESULT_SUCCESS)
623 {
624 DBG1(DBG_IMC, "IMC %u \"%s\" failed to reserve %d additional IMC IDs",
625 this->id, this->name, count);
626 return result;
627 }
628 count--;
629
630 /* store the scalar value in the pointer */
631 pointer = (void*)id;
632 this->additional_ids->insert_last(this->additional_ids, pointer);
633 DBG2(DBG_IMC, "IMC %u \"%s\" reserved additional ID %u",
634 this->id, this->name, id);
635 }
636 return TNC_RESULT_SUCCESS;
637 }
638
639 METHOD(imc_agent_t, count_additional_ids, int,
640 private_imc_agent_t *this)
641 {
642 return this->additional_ids->get_count(this->additional_ids);
643 }
644
645 METHOD(imc_agent_t, create_id_enumerator, enumerator_t*,
646 private_imc_agent_t *this)
647 {
648 return this->additional_ids->create_enumerator(this->additional_ids);
649 }
650
651 METHOD(imc_agent_t, destroy, void,
652 private_imc_agent_t *this)
653 {
654 DBG1(DBG_IMC, "IMC %u \"%s\" terminated", this->id, this->name);
655 this->additional_ids->destroy(this->additional_ids);
656 this->connections->destroy_function(this->connections, free);
657 this->connection_lock->destroy(this->connection_lock);
658 free(this);
659
660 /* decrease the reference count or terminate */
661 libimcv_deinit();
662 }
663
664 /**
665 * Described in header.
666 */
667 imc_agent_t *imc_agent_create(const char *name,
668 pen_t vendor_id, u_int32_t subtype,
669 TNC_IMCID id, TNC_Version *actual_version)
670 {
671 private_imc_agent_t *this;
672
673 /* initialize or increase the reference count */
674 if (!libimcv_init())
675 {
676 return NULL;
677 }
678
679 INIT(this,
680 .public = {
681 .bind_functions = _bind_functions,
682 .create_state = _create_state,
683 .delete_state = _delete_state,
684 .change_state = _change_state,
685 .get_state = _get_state,
686 .send_message = _send_message,
687 .receive_message = _receive_message,
688 .reserve_additional_ids = _reserve_additional_ids,
689 .count_additional_ids = _count_additional_ids,
690 .create_id_enumerator = _create_id_enumerator,
691 .destroy = _destroy,
692 },
693 .name = name,
694 .vendor_id = vendor_id,
695 .subtype = subtype,
696 .id = id,
697 .additional_ids = linked_list_create(),
698 .connections = linked_list_create(),
699 .connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
700 );
701
702 *actual_version = TNC_IFIMC_VERSION_1;
703 DBG1(DBG_IMC, "IMC %u \"%s\" initialized", this->id, this->name);
704
705 return &this->public;
706 }
707