hostap_imc.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Minimal example IMC for TNC testing
  3. * Copyright (c) 2014, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "includes.h"
  9. #include "common.h"
  10. #include "common/tnc.h"
  11. static int initialized = 0;
  12. static TNC_IMCID my_id = -1;
  13. TNC_Result TNC_IMC_Initialize(
  14. /*in*/ TNC_IMCID imcID,
  15. /*in*/ TNC_Version minVersion,
  16. /*in*/ TNC_Version maxVersion,
  17. /*out*/ TNC_Version *pOutActualVersion)
  18. {
  19. wpa_printf(MSG_INFO, "IMC(hostap) %s", __func__);
  20. if (initialized)
  21. return TNC_RESULT_ALREADY_INITIALIZED;
  22. if (minVersion < TNC_IFIMC_VERSION_1 ||
  23. maxVersion > TNC_IFIMC_VERSION_1)
  24. return TNC_RESULT_NO_COMMON_VERSION;
  25. if (!pOutActualVersion)
  26. return TNC_RESULT_INVALID_PARAMETER;
  27. *pOutActualVersion = TNC_IFIMC_VERSION_1;
  28. my_id = imcID;
  29. initialized = 1;
  30. return TNC_RESULT_SUCCESS;
  31. }
  32. TNC_Result TNC_IMC_BeginHandshake(
  33. /*in*/ TNC_IMCID imcID,
  34. /*in*/ TNC_ConnectionID connectionID)
  35. {
  36. wpa_printf(MSG_INFO, "IMC(hostap) %s", __func__);
  37. if (!initialized)
  38. return TNC_RESULT_NOT_INITIALIZED;
  39. if (imcID != my_id)
  40. return TNC_RESULT_INVALID_PARAMETER;
  41. return TNC_RESULT_SUCCESS;
  42. }
  43. TNC_Result TNC_IMC_ProvideBindFunction(
  44. /*in*/ TNC_IMCID imcID,
  45. /*in*/ TNC_TNCC_BindFunctionPointer bindFunction)
  46. {
  47. wpa_printf(MSG_INFO, "IMC(hostap) %s", __func__);
  48. if (!initialized)
  49. return TNC_RESULT_NOT_INITIALIZED;
  50. if (imcID != my_id)
  51. return TNC_RESULT_INVALID_PARAMETER;
  52. return TNC_RESULT_SUCCESS;
  53. }