Lines Matching defs:imc
2 * EAP-TNC - TNCC (IF-IMC and IF-TNCCS)
39 /* TNC IF-IMC */
144 struct tnc_if_imc *imc;
160 struct tnc_if_imc *imc;
174 imc = tnc_imc[imcID];
175 os_free(imc->supported_types);
176 imc->supported_types =
178 if (imc->supported_types == NULL)
180 os_memcpy(imc->supported_types, supportedTypes,
182 imc->num_supported_types = typeCount;
195 struct tnc_if_imc *imc;
212 imc = tnc_imc[imcID];
213 os_free(imc->imc_send);
214 imc->imc_send_len = 0;
215 imc->imc_send = os_zalloc(b64len + 100);
216 if (imc->imc_send == NULL) {
221 imc->imc_send_len =
222 os_snprintf((char *) imc->imc_send, b64len + 100,
223 "<IMC-IMV-Message><Type>%08X</Type>"
224 "<Base64>%s</Base64></IMC-IMV-Message>",
245 * require that the IMC continues to be loaded in memory afer
323 static int tncc_imc_resolve_funcs(struct tnc_if_imc *imc)
325 void *handle = imc->dlhandle;
327 /* Mandatory IMC functions */
328 imc->Initialize = tncc_get_sym(handle, "TNC_IMC_Initialize");
329 if (imc->Initialize == NULL) {
330 wpa_printf(MSG_ERROR, "TNC: IMC does not export "
335 imc->BeginHandshake = tncc_get_sym(handle, "TNC_IMC_BeginHandshake");
336 if (imc->BeginHandshake == NULL) {
337 wpa_printf(MSG_ERROR, "TNC: IMC does not export "
342 imc->ProvideBindFunction =
344 if (imc->ProvideBindFunction == NULL) {
345 wpa_printf(MSG_ERROR, "TNC: IMC does not export "
350 /* Optional IMC functions */
351 imc->NotifyConnectionChange =
353 imc->ReceiveMessage = tncc_get_sym(handle, "TNC_IMC_ReceiveMessage");
354 imc->BatchEnding = tncc_get_sym(handle, "TNC_IMC_BatchEnding");
355 imc->Terminate = tncc_get_sym(handle, "TNC_IMC_Terminate");
361 static int tncc_imc_initialize(struct tnc_if_imc *imc)
366 wpa_printf(MSG_DEBUG, "TNC: Calling TNC_IMC_Initialize for IMC '%s'",
367 imc->name);
368 res = imc->Initialize(imc->imcID, TNC_IFIMC_VERSION_1,
377 static int tncc_imc_terminate(struct tnc_if_imc *imc)
381 if (imc->Terminate == NULL)
384 wpa_printf(MSG_DEBUG, "TNC: Calling TNC_IMC_Terminate for IMC '%s'",
385 imc->name);
386 res = imc->Terminate(imc->imcID);
394 static int tncc_imc_provide_bind_function(struct tnc_if_imc *imc)
399 "IMC '%s'", imc->name);
400 res = imc->ProvideBindFunction(imc->imcID, TNC_TNCC_BindFunction);
408 static int tncc_imc_notify_connection_change(struct tnc_if_imc *imc,
413 if (imc->NotifyConnectionChange == NULL)
417 " for IMC '%s'", (int) state, imc->name);
418 res = imc->NotifyConnectionChange(imc->imcID, imc->connectionID,
427 static int tncc_imc_begin_handshake(struct tnc_if_imc *imc)
431 wpa_printf(MSG_DEBUG, "TNC: Calling TNC_IMC_BeginHandshake for IMC "
432 "'%s'", imc->name);
433 res = imc->BeginHandshake(imc->imcID, imc->connectionID);
441 static int tncc_load_imc(struct tnc_if_imc *imc)
443 if (imc->path == NULL) {
444 wpa_printf(MSG_DEBUG, "TNC: No IMC configured");
448 wpa_printf(MSG_DEBUG, "TNC: Opening IMC: %s (%s)",
449 imc->name, imc->path);
453 TCHAR *lib = wpa_strdup_tchar(imc->path);
456 imc->dlhandle = LoadLibrary(lib);
460 imc->dlhandle = LoadLibrary(imc->path);
462 if (imc->dlhandle == NULL) {
463 wpa_printf(MSG_ERROR, "TNC: Failed to open IMC '%s' (%s): %d",
464 imc->name, imc->path, (int) GetLastError());
468 imc->dlhandle = dlopen(imc->path, RTLD_LAZY);
469 if (imc->dlhandle == NULL) {
470 wpa_printf(MSG_ERROR, "TNC: Failed to open IMC '%s' (%s): %s",
471 imc->name, imc->path, dlerror());
476 if (tncc_imc_resolve_funcs(imc) < 0) {
477 wpa_printf(MSG_ERROR, "TNC: Failed to resolve IMC functions");
481 if (tncc_imc_initialize(imc) < 0 ||
482 tncc_imc_provide_bind_function(imc) < 0) {
483 wpa_printf(MSG_ERROR, "TNC: Failed to initialize IMC");
491 static void tncc_unload_imc(struct tnc_if_imc *imc)
493 tncc_imc_terminate(imc);
494 tnc_imc[imc->imcID] = NULL;
496 if (imc->dlhandle) {
498 FreeLibrary(imc->dlhandle);
500 dlclose(imc->dlhandle);
503 os_free(imc->name);
504 os_free(imc->path);
505 os_free(imc->supported_types);
506 os_free(imc->imc_send);
510 static int tncc_supported_type(struct tnc_if_imc *imc, unsigned int type)
515 if (imc == NULL || imc->supported_types == NULL)
521 for (i = 0; i < imc->num_supported_types; i++) {
523 svendor = imc->supported_types[i] >> 8;
524 ssubtype = imc->supported_types[i] & 0xff;
537 struct tnc_if_imc *imc;
540 wpa_hexdump_ascii(MSG_MSGDUMP, "TNC: Message to IMC(s)", msg, len);
542 for (imc = tncc->imc; imc; imc = imc->next) {
543 if (imc->ReceiveMessage == NULL ||
544 !tncc_supported_type(imc, type))
547 wpa_printf(MSG_DEBUG, "TNC: Call ReceiveMessage for IMC '%s'",
548 imc->name);
549 res = imc->ReceiveMessage(imc->imcID, imc->connectionID,
560 struct tnc_if_imc *imc;
562 for (imc = tncc->imc; imc; imc = imc->next) {
564 imc, TNC_CONNECTION_STATE_CREATE);
566 imc, TNC_CONNECTION_STATE_HANDSHAKE);
568 os_free(imc->imc_send);
569 imc->imc_send = NULL;
570 imc->imc_send_len = 0;
572 tncc_imc_begin_handshake(imc);
579 struct tnc_if_imc *imc;
582 for (imc = tncc->imc; imc; imc = imc->next)
583 len += imc->imc_send_len;
590 struct tnc_if_imc *imc;
592 for (imc = tncc->imc; imc; imc = imc->next) {
593 if (imc->imc_send == NULL)
596 os_memcpy(pos, imc->imc_send, imc->imc_send_len);
597 pos += imc->imc_send_len;
598 os_free(imc->imc_send);
599 imc->imc_send = NULL;
600 imc->imc_send_len = 0;
632 struct tnc_if_imc *imc;
649 for (imc = tncc->imc; imc; imc = imc->next)
650 tncc_imc_notify_connection_change(imc, state);
793 * <IMC-IMV-Message>
796 * </IMC-IMV-Message>
803 pos = os_strstr(start, "<IMC-IMV-Message>");
807 end = os_strstr(start, "</IMC-IMV-Message>");
819 wpa_printf(MSG_DEBUG, "TNC: IMC-IMV-Message Type 0x%x", type);
934 struct tnc_if_imc *imc, *last;
937 last = tncc->imc;
967 wpa_printf(MSG_DEBUG, "TNC: IMC '" TSTR "'", name);
971 wpa_printf(MSG_DEBUG, "Could not open IMC key '" TSTR
980 "IMC key '" TSTR "'", name);
1002 wpa_printf(MSG_DEBUG, "TNC: IMC Path '%s'", (char *) val);
1014 imc = os_zalloc(sizeof(*imc));
1015 if (imc == NULL) {
1020 imc->imcID = j;
1023 imc->name = os_strdup((char *) name);
1024 imc->path = os_strdup((char *) val);
1029 tncc->imc = imc;
1031 last->next = imc;
1032 last = imc;
1034 tnc_imc[imc->imcID] = imc;
1055 struct tnc_if_imc *imc;
1068 imc = os_zalloc(sizeof(*imc));
1069 if (imc == NULL) {
1074 imc->imcID = i;
1077 wpa_printf(MSG_DEBUG, "TNC: Configured IMC: %s", pos);
1079 wpa_printf(MSG_ERROR, "TNC: Ignoring invalid IMC line '%s' "
1081 os_free(imc);
1090 wpa_printf(MSG_ERROR, "TNC: Ignoring invalid IMC line '%s' "
1092 os_free(imc);
1097 imc->name = os_strdup(pos);
1101 wpa_printf(MSG_ERROR, "TNC: Ignoring invalid IMC line '%s' "
1103 os_free(imc->name);
1104 os_free(imc);
1109 wpa_printf(MSG_DEBUG, "TNC: IMC file: '%s'", pos);
1110 imc->path = os_strdup(pos);
1111 tnc_imc[imc->imcID] = imc;
1113 return imc;
1121 struct tnc_if_imc *imc, *last;
1140 if (os_strncmp(pos, "IMC ", 4) == 0) {
1143 imc = tncc_parse_imc(pos + 4, line_end, &error);
1146 if (imc) {
1148 tncc->imc = imc;
1150 last->next = imc;
1151 last = imc;
1167 struct tnc_if_imc *imc;
1183 for (imc = tncc->imc; imc; imc = imc->next) {
1184 if (tncc_load_imc(imc)) {
1185 wpa_printf(MSG_ERROR, "TNC: Failed to load IMC '%s'",
1186 imc->name);
1201 struct tnc_if_imc *imc, *prev;
1203 imc = tncc->imc;
1204 while (imc) {
1205 tncc_unload_imc(imc);
1207 prev = imc;
1208 imc = imc->next;