imc/imv->send_message() uses attr_list
[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 imc_state_t *state;
460 pa_tnc_attr_t *attr;
461 pa_tnc_msg_t *pa_tnc_msg;
462 chunk_t msg;
463
464 state = find_connection(this, connection_id);
465 if (!state)
466 {
467 DBG1(DBG_IMV, "IMC %u \"%s\" has no state for Connection ID %u",
468 this->id, this->name, connection_id);
469 return TNC_RESULT_FATAL;
470 }
471
472 pa_tnc_msg = pa_tnc_msg_create();
473
474 while (attr_list->remove_first(attr_list, (void**)&attr) == SUCCESS)
475 {
476 pa_tnc_msg->add_attribute(pa_tnc_msg, attr);
477 }
478 pa_tnc_msg->build(pa_tnc_msg);
479 msg = pa_tnc_msg->get_encoding(pa_tnc_msg);
480
481 if (state->has_long(state) && this->send_message_long)
482 {
483 if (!src_imc_id)
484 {
485 src_imc_id = this->id;
486 }
487 msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
488
489 return this->send_message_long(src_imc_id, connection_id, msg_flags,
490 msg.ptr, msg.len, this->vendor_id,
491 this->subtype, dst_imv_id);
492 }
493 if (this->send_message)
494 {
495 type = (this->vendor_id << 8) | this->subtype;
496
497 return this->send_message(this->id, connection_id, msg.ptr, msg.len,
498 type);
499 }
500 return TNC_RESULT_FATAL;
501 }
502
503 METHOD(imc_agent_t, receive_message, TNC_Result,
504 private_imc_agent_t *this, imc_state_t *state, chunk_t msg,
505 TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype,
506 TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id, pa_tnc_msg_t **pa_tnc_msg)
507 {
508 pa_tnc_msg_t *pa_msg, *error_msg;
509 pa_tnc_attr_t *error_attr;
510 enumerator_t *enumerator;
511 TNC_MessageType msg_type;
512 TNC_UInt32 msg_flags, src_imc_id, dst_imv_id;
513 TNC_ConnectionID connection_id;
514 TNC_Result result;
515
516 connection_id = state->get_connection_id(state);
517
518 if (state->has_long(state))
519 {
520 if (dst_imc_id != TNC_IMCID_ANY)
521 {
522 DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u "
523 "from IMV %u to IMC %u", this->id, this->name,
524 connection_id, src_imv_id, dst_imc_id);
525 }
526 else
527 {
528 DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u "
529 "from IMV %u", this->id, this->name, connection_id,
530 src_imv_id);
531 }
532 }
533 else
534 {
535 DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u",
536 this->id, this->name, connection_id);
537 }
538
539 *pa_tnc_msg = NULL;
540 pa_msg = pa_tnc_msg_create_from_data(msg);
541
542 switch (pa_msg->process(pa_msg))
543 {
544 case SUCCESS:
545 *pa_tnc_msg = pa_msg;
546 break;
547 case VERIFY_ERROR:
548 /* build error message */
549 error_msg = pa_tnc_msg_create();
550 enumerator = pa_msg->create_error_enumerator(pa_msg);
551 while (enumerator->enumerate(enumerator, &error_attr))
552 {
553 error_msg->add_attribute(error_msg,
554 error_attr->get_ref(error_attr));
555 }
556 enumerator->destroy(enumerator);
557 error_msg->build(error_msg);
558
559 /* send error message */
560 if (state->has_long(state) && this->send_message_long)
561 {
562 if (state->has_excl(state))
563 {
564 msg_flags = TNC_MESSAGE_FLAGS_EXCLUSIVE;
565 dst_imv_id = src_imv_id;
566 }
567 else
568 {
569 msg_flags = 0;
570 dst_imv_id = TNC_IMVID_ANY;
571 }
572 src_imc_id = (dst_imc_id == TNC_IMCID_ANY) ? this->id
573 : dst_imc_id;
574
575 result = this->send_message_long(src_imc_id, connection_id,
576 msg_flags, msg.ptr, msg.len, msg_vid,
577 msg_subtype, dst_imv_id);
578 }
579 else if (this->send_message)
580 {
581 msg_type = (msg_vid << 8) | msg_subtype;
582
583 result = this->send_message(this->id, connection_id,
584 msg.ptr, msg.len, msg_type);
585 }
586 else
587 {
588 result = TNC_RESULT_FATAL;
589 }
590
591 /* clean up */
592 error_msg->destroy(error_msg);
593 pa_msg->destroy(pa_msg);
594 return result;
595 case FAILED:
596 default:
597 pa_msg->destroy(pa_msg);
598 return TNC_RESULT_FATAL;
599 }
600 return TNC_RESULT_SUCCESS;
601 }
602
603 METHOD(imc_agent_t, reserve_additional_ids, TNC_Result,
604 private_imc_agent_t *this, int count)
605 {
606 TNC_Result result;
607 TNC_UInt32 id;
608 void *pointer;
609
610 if (!this->reserve_additional_id)
611 {
612 DBG1(DBG_IMC, "IMC %u \"%s\" did not detect the capability to reserve "
613 "additional IMC IDs from the TNCC", this->id, this->name);
614 return TNC_RESULT_ILLEGAL_OPERATION;
615 }
616 while (count > 0)
617 {
618 result = this->reserve_additional_id(this->id, &id);
619 if (result != TNC_RESULT_SUCCESS)
620 {
621 DBG1(DBG_IMC, "IMC %u \"%s\" failed to reserve %d additional IMC IDs",
622 this->id, this->name, count);
623 return result;
624 }
625 count--;
626
627 /* store the scalar value in the pointer */
628 pointer = (void*)id;
629 this->additional_ids->insert_last(this->additional_ids, pointer);
630 DBG2(DBG_IMC, "IMC %u \"%s\" reserved additional ID %u",
631 this->id, this->name, id);
632 }
633 return TNC_RESULT_SUCCESS;
634 }
635
636 METHOD(imc_agent_t, count_additional_ids, int,
637 private_imc_agent_t *this)
638 {
639 return this->additional_ids->get_count(this->additional_ids);
640 }
641
642 METHOD(imc_agent_t, create_id_enumerator, enumerator_t*,
643 private_imc_agent_t *this)
644 {
645 return this->additional_ids->create_enumerator(this->additional_ids);
646 }
647
648 METHOD(imc_agent_t, destroy, void,
649 private_imc_agent_t *this)
650 {
651 DBG1(DBG_IMC, "IMC %u \"%s\" terminated", this->id, this->name);
652 this->additional_ids->destroy(this->additional_ids);
653 this->connections->destroy_function(this->connections, free);
654 this->connection_lock->destroy(this->connection_lock);
655 free(this);
656
657 /* decrease the reference count or terminate */
658 libimcv_deinit();
659 }
660
661 /**
662 * Described in header.
663 */
664 imc_agent_t *imc_agent_create(const char *name,
665 pen_t vendor_id, u_int32_t subtype,
666 TNC_IMCID id, TNC_Version *actual_version)
667 {
668 private_imc_agent_t *this;
669
670 /* initialize or increase the reference count */
671 if (!libimcv_init())
672 {
673 return NULL;
674 }
675
676 INIT(this,
677 .public = {
678 .bind_functions = _bind_functions,
679 .create_state = _create_state,
680 .delete_state = _delete_state,
681 .change_state = _change_state,
682 .get_state = _get_state,
683 .send_message = _send_message,
684 .receive_message = _receive_message,
685 .reserve_additional_ids = _reserve_additional_ids,
686 .count_additional_ids = _count_additional_ids,
687 .create_id_enumerator = _create_id_enumerator,
688 .destroy = _destroy,
689 },
690 .name = name,
691 .vendor_id = vendor_id,
692 .subtype = subtype,
693 .id = id,
694 .additional_ids = linked_list_create(),
695 .connections = linked_list_create(),
696 .connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
697 );
698
699 *actual_version = TNC_IFIMC_VERSION_1;
700 DBG1(DBG_IMC, "IMC %u \"%s\" initialized", this->id, this->name);
701
702 return &this->public;
703 }
704