2 * Copyright (C) 2015 Andreas Steffen
3 * 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
16 #include "imc_hcd_state.h"
18 #include <imc/imc_agent.h>
19 #include <imc/imc_msg.h>
20 #include <imc/imc_os_info.h>
21 #include <generic/generic_attr_bool.h>
22 #include <generic/generic_attr_chunk.h>
23 #include <generic/generic_attr_string.h>
24 #include <ietf/ietf_attr.h>
25 #include <ietf/ietf_attr_attr_request.h>
26 #include "ietf/ietf_attr_fwd_enabled.h"
27 #include <pwg/pwg_attr.h>
28 #include <pwg/pwg_attr_vendor_smi_code.h>
30 #include <tncif_pa_subtypes.h>
33 #include <utils/debug.h>
37 static const char imc_name
[] = "HCD";
39 static pen_type_t msg_types
[] = {
40 { PEN_PWG
, PA_SUBTYPE_PWG_HCD_SYSTEM
},
41 { PEN_PWG
, PA_SUBTYPE_PWG_HCD_CONSOLE
},
42 { PEN_PWG
, PA_SUBTYPE_PWG_HCD_MARKER
},
43 { PEN_PWG
, PA_SUBTYPE_PWG_HCD_FINISHER
},
44 { PEN_PWG
, PA_SUBTYPE_PWG_HCD_INTERFACE
},
45 { PEN_PWG
, PA_SUBTYPE_PWG_HCD_SCANNER
}
48 static imc_agent_t
*imc_hcd
;
49 static imc_os_info_t
*os
;
51 typedef struct section_subtype_t section_subtype_t
;
53 struct section_subtype_t
{
55 pa_subtype_pwg_t subtype
;
58 static section_subtype_t section_subtypes
[] = {
59 { "system", PA_SUBTYPE_PWG_HCD_SYSTEM
},
60 { "console", PA_SUBTYPE_PWG_HCD_CONSOLE
},
61 { "marker", PA_SUBTYPE_PWG_HCD_MARKER
},
62 { "finisher", PA_SUBTYPE_PWG_HCD_FINISHER
},
63 { "interface", PA_SUBTYPE_PWG_HCD_INTERFACE
},
64 { "scanner" , PA_SUBTYPE_PWG_HCD_SCANNER
}
67 typedef struct quadruple_t quadruple_t
;
72 pwg_attr_t patches_attr
;
73 pwg_attr_t string_version_attr
;
74 pwg_attr_t version_attr
;
77 static quadruple_t quadruples
[] = {
79 PWG_HCD_FIRMWARE_NAME
, PWG_HCD_FIRMWARE_PATCHES
,
80 PWG_HCD_FIRMWARE_STRING_VERSION
, PWG_HCD_FIRMWARE_VERSION
},
81 { "resident_application",
82 PWG_HCD_RESIDENT_APP_NAME
, PWG_HCD_RESIDENT_APP_PATCHES
,
83 PWG_HCD_RESIDENT_APP_STRING_VERSION
, PWG_HCD_RESIDENT_APP_VERSION
},
85 PWG_HCD_USER_APP_NAME
, PWG_HCD_USER_APP_PATCHES
,
86 PWG_HCD_USER_APP_STRING_VERSION
, PWG_HCD_USER_APP_VERSION
}
90 * see section 3.8.1 of TCG TNC IF-IMC Specification 1.3
92 TNC_Result TNC_IMC_API
TNC_IMC_Initialize(TNC_IMCID imc_id
,
93 TNC_Version min_version
,
94 TNC_Version max_version
,
95 TNC_Version
*actual_version
)
99 DBG1(DBG_IMC
, "IMC \"%s\" has already been initialized", imc_name
);
100 return TNC_RESULT_ALREADY_INITIALIZED
;
102 imc_hcd
= imc_agent_create(imc_name
, msg_types
, countof(msg_types
),
103 imc_id
, actual_version
);
106 return TNC_RESULT_FATAL
;
109 os
= imc_os_info_create();
112 imc_hcd
->destroy(imc_hcd
);
115 return TNC_RESULT_FATAL
;
118 if (min_version
> TNC_IFIMC_VERSION_1
|| max_version
< TNC_IFIMC_VERSION_1
)
120 DBG1(DBG_IMC
, "no common IF-IMC version");
121 return TNC_RESULT_NO_COMMON_VERSION
;
123 return TNC_RESULT_SUCCESS
;
127 * see section 3.8.2 of TCG TNC IF-IMC Specification 1.3
129 TNC_Result TNC_IMC_API
TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id
,
130 TNC_ConnectionID connection_id
, TNC_ConnectionState new_state
)
136 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
137 return TNC_RESULT_NOT_INITIALIZED
;
141 case TNC_CONNECTION_STATE_CREATE
:
142 state
= imc_hcd_state_create(connection_id
);
143 return imc_hcd
->create_state(imc_hcd
, state
);
144 case TNC_CONNECTION_STATE_HANDSHAKE
:
145 if (imc_hcd
->change_state(imc_hcd
, connection_id
, new_state
,
146 &state
) != TNC_RESULT_SUCCESS
)
148 return TNC_RESULT_FATAL
;
150 state
->set_result(state
, imc_id
,
151 TNC_IMV_EVALUATION_RESULT_DONT_KNOW
);
152 return TNC_RESULT_SUCCESS
;
153 case TNC_CONNECTION_STATE_DELETE
:
154 return imc_hcd
->delete_state(imc_hcd
, connection_id
);
156 return imc_hcd
->change_state(imc_hcd
, connection_id
,
162 * Add AttributesNaturalLanguage attribute to send queue
164 static void add_attrs_natural_lang(imc_msg_t
*msg
, char *section
)
169 string
= lib
->settings
->get_str(lib
->settings
,
170 "%s.plugins.imc-hcd.subtypes.%s.attributes_natural_language",
171 "en", lib
->ns
, section
);
172 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_ATTRS_NATURAL_LANG
,
174 attr
= generic_attr_string_create(chunk_from_str(string
),
175 pen_type_create(PEN_PWG
, PWG_HCD_ATTRS_NATURAL_LANG
));
176 msg
->add_attribute(msg
, attr
);
180 * Add DefaultPasswordEnabled attribute to send queue
182 static void add_default_pwd_enabled(imc_msg_t
*msg
)
187 status
= os
->get_default_pwd_status(os
);
188 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_DEFAULT_PWD_ENABLED
,
189 status
? "yes" : "no");
190 attr
= generic_attr_bool_create(status
,
191 pen_type_create(PEN_PWG
, PWG_HCD_DEFAULT_PWD_ENABLED
));
192 msg
->add_attribute(msg
, attr
);
196 * Add ForwardingEnabled attribute to send queue
198 static void add_forwarding_enabled(imc_msg_t
*msg
)
201 os_fwd_status_t fwd_status
;
203 fwd_status
= os
->get_fwd_status(os
);
204 DBG2(DBG_IMC
, " %N: %N", pwg_attr_names
, PWG_HCD_FORWARDING_ENABLED
,
205 os_fwd_status_names
, fwd_status
);
206 attr
= ietf_attr_fwd_enabled_create(fwd_status
,
207 pen_type_create(PEN_PWG
, PWG_HCD_FORWARDING_ENABLED
));
208 msg
->add_attribute(msg
, attr
);
212 * Add MachineTypeModel attribute to send queue
214 static void add_machine_type_model(imc_msg_t
*msg
)
219 string
= lib
->settings
->get_str(lib
->settings
,
220 "%s.plugins.imc-hcd.subtypes.system.machine_type_model",
222 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_MACHINE_TYPE_MODEL
,
224 attr
= generic_attr_string_create(chunk_from_str(string
),
225 pen_type_create(PEN_PWG
, PWG_HCD_MACHINE_TYPE_MODEL
));
226 msg
->add_attribute(msg
, attr
);
230 * Add PSTNFaxEnabled attribute to send queue
232 static void add_pstn_fax_enabled(imc_msg_t
*msg
)
237 status
= lib
->settings
->get_bool(lib
->settings
,
238 "%s.plugins.imc-hcd.subtypes.system.pstn_fax_enabled",
240 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_PSTN_FAX_ENABLED
,
241 status
? "yes" : "no");
242 attr
= generic_attr_bool_create(status
,
243 pen_type_create(PEN_PWG
, PWG_HCD_PSTN_FAX_ENABLED
));
244 msg
->add_attribute(msg
, attr
);
248 * Add TimeSource attribute to send queue
250 static void add_time_source(imc_msg_t
*msg
)
255 string
= lib
->settings
->get_str(lib
->settings
,
256 "%s.plugins.imc-hcd.subtypes.system.time_source",
258 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_TIME_SOURCE
,
260 attr
= generic_attr_string_create(chunk_from_str(string
),
261 pen_type_create(PEN_PWG
, PWG_HCD_TIME_SOURCE
));
262 msg
->add_attribute(msg
, attr
);
266 * Add UserApplicationEnabled attribute to send queue
268 static void add_user_app_enabled(imc_msg_t
*msg
)
273 status
= lib
->settings
->get_bool(lib
->settings
,
274 "%s.plugins.imc-hcd.subtypes.system.user_application_enabled",
276 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_USER_APP_ENABLED
,
277 status
? "yes" : "no");
278 attr
= generic_attr_bool_create(status
,
279 pen_type_create(PEN_PWG
, PWG_HCD_USER_APP_ENABLED
));
280 msg
->add_attribute(msg
, attr
);
284 * Add UserApplicationPersistenceEnabled attribute to send queue
286 static void add_user_app_persist_enabled(imc_msg_t
*msg
)
291 status
= lib
->settings
->get_bool(lib
->settings
,
292 "%s.plugins.imc-hcd.subtypes.system.user_application_persistence.enabled",
294 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_USER_APP_PERSIST_ENABLED
,
295 status
? "yes" : "no");
296 attr
= generic_attr_bool_create(status
,
297 pen_type_create(PEN_PWG
, PWG_HCD_USER_APP_PERSIST_ENABLED
));
298 msg
->add_attribute(msg
, attr
);
302 * Add VendorName attribute to send queue
304 static void add_vendor_name(imc_msg_t
*msg
)
309 string
= lib
->settings
->get_str(lib
->settings
,
310 "%s.plugins.imc-hcd.subtypes.system.vendor_name",
312 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, PWG_HCD_VENDOR_NAME
,
314 attr
= generic_attr_string_create(chunk_from_str(string
),
315 pen_type_create(PEN_PWG
, PWG_HCD_VENDOR_NAME
));
316 msg
->add_attribute(msg
, attr
);
320 * Add VendorSMICode attribute to send queue
322 static void add_vendor_smi_code(imc_msg_t
*msg
)
327 smi_code
= lib
->settings
->get_int(lib
->settings
,
328 "%s.plugins.imc-hcd.subtypes.system.vendor_smi_code",
330 DBG2(DBG_IMC
, " %N: 0x%06x (%d)", pwg_attr_names
, PWG_HCD_VENDOR_SMI_CODE
,
332 attr
= pwg_attr_vendor_smi_code_create(smi_code
);
333 msg
->add_attribute(msg
, attr
);
337 * Add CertificationState attribute to send queue
339 static void add_certification_state(imc_msg_t
*msg
)
345 hex_string
= lib
->settings
->get_str(lib
->settings
,
346 "%s.plugins.imc-hcd.subtypes.system.certification_state",
350 blob
= chunk_from_hex(chunk_from_str(hex_string
), NULL
);
352 DBG2(DBG_IMC
, " %N: %B", pwg_attr_names
, PWG_HCD_CERTIFICATION_STATE
,
354 attr
= generic_attr_chunk_create(blob
,
355 pen_type_create(PEN_PWG
, PWG_HCD_CERTIFICATION_STATE
));
356 msg
->add_attribute(msg
, attr
);
362 * Add CertificationState attribute to send queue
364 static void add_configuration_state(imc_msg_t
*msg
)
370 hex_string
= lib
->settings
->get_str(lib
->settings
,
371 "%s.plugins.imc-hcd.subtypes.system.configuration_state",
375 blob
= chunk_from_hex(chunk_from_str(hex_string
), NULL
);
377 DBG2(DBG_IMC
, " %N: %B", pwg_attr_names
, PWG_HCD_CONFIGURATION_STATE
,
379 attr
= generic_attr_chunk_create(blob
,
380 pen_type_create(PEN_PWG
, PWG_HCD_CONFIGURATION_STATE
));
381 msg
->add_attribute(msg
, attr
);
387 * Add Correlated Attributes to send queue
389 static void add_quadruple(imc_msg_t
*msg
, char *section
, quadruple_t
*quad
)
392 const size_t version_len
= 16;
393 char version
[version_len
];
394 char hex_version_default
[] = "00000000000000000000000000000000";
395 char *app
, *name
, *patches
, *string_version
, *hex_version
;
398 enumerator_t
*enumerator
;
400 enumerator
= lib
->settings
->create_section_enumerator(lib
->settings
,
401 "%s.plugins.imc-hcd.subtypes.%s.%s",
402 lib
->ns
, section
, quad
->section
);
403 while (enumerator
->enumerate(enumerator
, &app
))
405 name
= lib
->settings
->get_str(lib
->settings
,
406 "%s.plugins.imc-hcd.subtypes.%s.%s.%s.name",
407 "", lib
->ns
, section
, quad
->section
, app
);
408 patches
= lib
->settings
->get_str(lib
->settings
,
409 "%s.plugins.imc-hcd.subtypes.%s.%s.%s.patches",
410 "", lib
->ns
, section
, quad
->section
, app
);
411 string_version
= lib
->settings
->get_str(lib
->settings
,
412 "%s.plugins.imc-hcd.subtypes.%s.%s.%s.string_version",
413 "", lib
->ns
, section
, quad
->section
, app
);
414 hex_version
= lib
->settings
->get_str(lib
->settings
,
415 "%s.plugins.imc-hcd.subtypes.%s.%s.%s.version",
416 hex_version_default
, lib
->ns
, section
, quad
->section
, app
);
418 /* convert hex string into binary chunk */
419 if (strlen(hex_version
) > 2 * version_len
)
421 hex_version
= hex_version_default
;
423 num_version
= chunk_from_hex(chunk_from_str(hex_version
), version
);
425 DBG2(DBG_IMC
, "--- %s ---", app
);
427 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, quad
->name_attr
, name
);
428 attr
= generic_attr_string_create(chunk_from_str(name
),
429 pen_type_create(PEN_PWG
, quad
->name_attr
));
430 msg
->add_attribute(msg
, attr
);
432 /* remove any trailing LF from patches string for logging */
433 len
= strlen(patches
);
434 if (len
&& (patches
[len
- 1] == '\n'))
438 DBG2(DBG_IMC
, " %N:%s%.*s", pwg_attr_names
, quad
->patches_attr
,
439 len
? "\n" : " ", len
, patches
);
440 attr
= generic_attr_string_create(chunk_from_str(patches
),
441 pen_type_create(PEN_PWG
, quad
->patches_attr
));
442 msg
->add_attribute(msg
, attr
);
444 DBG2(DBG_IMC
, " %N: %s", pwg_attr_names
, quad
->string_version_attr
,
446 attr
= generic_attr_string_create(chunk_from_str(string_version
),
447 pen_type_create(PEN_PWG
, quad
->string_version_attr
));
448 msg
->add_attribute(msg
, attr
);
450 DBG2(DBG_IMC
, " %N: %#B", pwg_attr_names
, quad
->version_attr
, &num_version
);
451 attr
= generic_attr_chunk_create(num_version
,
452 pen_type_create(PEN_PWG
, quad
->version_attr
));
453 msg
->add_attribute(msg
, attr
);
455 enumerator
->destroy(enumerator
);
459 * see section 3.8.3 of TCG TNC IF-IMC Specification 1.3
461 TNC_Result TNC_IMC_API
TNC_IMC_BeginHandshake(TNC_IMCID imc_id
,
462 TNC_ConnectionID connection_id
)
466 TNC_Result result
= TNC_RESULT_SUCCESS
;
467 pa_subtype_pwg_t subtype
;
469 enumerator_t
*enumerator
;
475 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
476 return TNC_RESULT_NOT_INITIALIZED
;
478 if (!imc_hcd
->get_state(imc_hcd
, connection_id
, &state
))
480 return TNC_RESULT_FATAL
;
483 /* Enumerate over all HCD subtype sections */
484 enumerator
= lib
->settings
->create_section_enumerator(lib
->settings
,
485 "%s.plugins.imc-hcd.subtypes", lib
->ns
);
486 while (enumerator
->enumerate(enumerator
, §ion
) &&
487 result
== TNC_RESULT_SUCCESS
)
489 subtype
= PA_SUBTYPE_PWG_HCD_UNKNOWN
;
491 for (i
= 0; i
< countof(section_subtypes
); i
++)
493 if (streq(section
, section_subtypes
[i
].section
))
495 subtype
= section_subtypes
[i
].subtype
;
499 if (subtype
== PA_SUBTYPE_PWG_HCD_UNKNOWN
)
501 DBG1(DBG_IMC
, "HCD subtype '%s' not supported", section
);
504 DBG2(DBG_IMC
, "retrieving attributes for PA subtype %N/%N",
505 pen_names
, PEN_PWG
, pa_subtype_pwg_names
, subtype
);
507 msg_type
= pen_type_create(PEN_PWG
, subtype
);
508 out_msg
= imc_msg_create(imc_hcd
, state
, connection_id
, imc_id
,
509 TNC_IMVID_ANY
, msg_type
);
511 /* mandatory attributes that are always sent without request */
512 add_attrs_natural_lang(out_msg
, section
);
513 if (subtype
== PA_SUBTYPE_PWG_HCD_SYSTEM
)
515 add_default_pwd_enabled(out_msg
);
516 add_forwarding_enabled(out_msg
);
517 add_machine_type_model(out_msg
);
518 add_pstn_fax_enabled(out_msg
);
519 add_time_source(out_msg
);
520 add_vendor_name(out_msg
);
521 add_vendor_smi_code(out_msg
);
522 add_user_app_enabled(out_msg
);
523 add_user_app_persist_enabled(out_msg
);
525 if (lib
->settings
->get_bool(lib
->settings
,
526 "%s.plugins.imc-hcd.push_info", FALSE
, lib
->ns
))
528 /* correlated attributes */
529 for (i
= 0; i
< countof(quadruples
); i
++)
531 add_quadruple(out_msg
, section
, &quadruples
[i
]);
535 /* send PA-TNC message with the excl flag not set */
536 result
= out_msg
->send(out_msg
, FALSE
);
537 out_msg
->destroy(out_msg
);
539 enumerator
->destroy(enumerator
);
544 static TNC_Result
receive_message(imc_state_t
*state
, imc_msg_t
*in_msg
)
547 enumerator_t
*enumerator
;
549 pen_type_t type
, msg_type
;
551 char *section
= NULL
;
553 bool fatal_error
= FALSE
, pushed_info
;
555 /* generate an outgoing PA-TNC message - we might need it */
556 out_msg
= imc_msg_create_as_reply(in_msg
);
558 /* parse received PA-TNC message and handle local and remote errors */
559 result
= in_msg
->receive(in_msg
, out_msg
, &fatal_error
);
560 if (result
!= TNC_RESULT_SUCCESS
)
562 out_msg
->destroy(out_msg
);
565 msg_type
= in_msg
->get_msg_type(in_msg
);
567 for (i
= 0; i
< countof(section_subtypes
); i
++)
569 if (msg_type
.type
== section_subtypes
[i
].subtype
)
571 section
= section_subtypes
[i
].section
;
575 pushed_info
= lib
->settings
->get_bool(lib
->settings
,
576 "%s.plugins.imc-hcd.push_info", FALSE
, lib
->ns
);
578 /* analyze PA-TNC attributes */
579 enumerator
= in_msg
->create_attribute_enumerator(in_msg
);
580 while (enumerator
->enumerate(enumerator
, &attr
))
582 type
= attr
->get_type(attr
);
584 if (type
.vendor_id
== PEN_IETF
)
586 if (type
.type
== IETF_ATTR_ATTRIBUTE_REQUEST
)
588 ietf_attr_attr_request_t
*attr_cast
;
592 attr_cast
= (ietf_attr_attr_request_t
*)attr
;
594 e
= attr_cast
->create_enumerator(attr_cast
);
595 while (e
->enumerate(e
, &entry
))
597 if (entry
->vendor_id
== PEN_PWG
)
601 case PWG_HCD_ATTRS_NATURAL_LANG
:
602 add_attrs_natural_lang(out_msg
, section
);
604 case PWG_HCD_DEFAULT_PWD_ENABLED
:
605 add_default_pwd_enabled(out_msg
);
607 case PWG_HCD_FORWARDING_ENABLED
:
608 add_forwarding_enabled(out_msg
);
610 case PWG_HCD_MACHINE_TYPE_MODEL
:
611 add_machine_type_model(out_msg
);
613 case PWG_HCD_PSTN_FAX_ENABLED
:
614 add_pstn_fax_enabled(out_msg
);
616 case PWG_HCD_TIME_SOURCE
:
617 add_time_source(out_msg
);
619 case PWG_HCD_USER_APP_ENABLED
:
620 add_user_app_enabled(out_msg
);
622 case PWG_HCD_USER_APP_PERSIST_ENABLED
:
623 add_user_app_persist_enabled(out_msg
);
625 case PWG_HCD_VENDOR_NAME
:
626 add_vendor_name(out_msg
);
628 case PWG_HCD_VENDOR_SMI_CODE
:
629 add_vendor_smi_code(out_msg
);
631 case PWG_HCD_CERTIFICATION_STATE
:
632 add_certification_state(out_msg
);
634 case PWG_HCD_CONFIGURATION_STATE
:
635 add_configuration_state(out_msg
);
644 /* if not pushed, deliver on request */
647 case PWG_HCD_FIRMWARE_NAME
:
648 add_quadruple(out_msg
, section
, &quadruples
[0]);
650 case PWG_HCD_RESIDENT_APP_NAME
:
651 add_quadruple(out_msg
, section
, &quadruples
[1]);
653 case PWG_HCD_USER_APP_NAME
:
654 add_quadruple(out_msg
, section
, &quadruples
[2]);
665 enumerator
->destroy(enumerator
);
669 result
= TNC_RESULT_FATAL
;
673 /* send PA-TNC message with the EXCL flag set */
674 result
= out_msg
->send(out_msg
, TRUE
);
676 out_msg
->destroy(out_msg
);
682 * see section 3.8.4 of TCG TNC IF-IMC Specification 1.3
684 TNC_Result TNC_IMC_API
TNC_IMC_ReceiveMessage(TNC_IMCID imc_id
,
685 TNC_ConnectionID connection_id
,
686 TNC_BufferReference msg
,
688 TNC_MessageType msg_type
)
696 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
697 return TNC_RESULT_NOT_INITIALIZED
;
699 if (!imc_hcd
->get_state(imc_hcd
, connection_id
, &state
))
701 return TNC_RESULT_FATAL
;
703 in_msg
= imc_msg_create_from_data(imc_hcd
, state
, connection_id
, msg_type
,
704 chunk_create(msg
, msg_len
));
705 result
= receive_message(state
, in_msg
);
706 in_msg
->destroy(in_msg
);
712 * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3
714 TNC_Result TNC_IMC_API
TNC_IMC_ReceiveMessageLong(TNC_IMCID imc_id
,
715 TNC_ConnectionID connection_id
,
716 TNC_UInt32 msg_flags
,
717 TNC_BufferReference msg
,
719 TNC_VendorID msg_vid
,
720 TNC_MessageSubtype msg_subtype
,
721 TNC_UInt32 src_imv_id
,
722 TNC_UInt32 dst_imc_id
)
730 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
731 return TNC_RESULT_NOT_INITIALIZED
;
733 if (!imc_hcd
->get_state(imc_hcd
, connection_id
, &state
))
735 return TNC_RESULT_FATAL
;
737 in_msg
= imc_msg_create_from_long_data(imc_hcd
, state
, connection_id
,
738 src_imv_id
, dst_imc_id
,msg_vid
, msg_subtype
,
739 chunk_create(msg
, msg_len
));
740 result
=receive_message(state
, in_msg
);
741 in_msg
->destroy(in_msg
);
747 * see section 3.8.7 of TCG TNC IF-IMC Specification 1.3
749 TNC_Result TNC_IMC_API
TNC_IMC_BatchEnding(TNC_IMCID imc_id
,
750 TNC_ConnectionID connection_id
)
754 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
755 return TNC_RESULT_NOT_INITIALIZED
;
757 return TNC_RESULT_SUCCESS
;
761 * see section 3.8.8 of TCG TNC IF-IMC Specification 1.3
763 TNC_Result TNC_IMC_API
TNC_IMC_Terminate(TNC_IMCID imc_id
)
767 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
768 return TNC_RESULT_NOT_INITIALIZED
;
770 imc_hcd
->destroy(imc_hcd
);
776 return TNC_RESULT_SUCCESS
;
780 * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.3
782 TNC_Result TNC_IMC_API
TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id
,
783 TNC_TNCC_BindFunctionPointer bind_function
)
787 DBG1(DBG_IMC
, "IMC \"%s\" has not been initialized", imc_name
);
788 return TNC_RESULT_NOT_INITIALIZED
;
790 return imc_hcd
->bind_functions(imc_hcd
, bind_function
);