hostap_imv.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Minimal example IMV 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_IMVID my_id = -1;
  13. TNC_Result TNC_IMV_Initialize(
  14. /*in*/ TNC_IMVID imvID,
  15. /*in*/ TNC_Version minVersion,
  16. /*in*/ TNC_Version maxVersion,
  17. /*out*/ TNC_Version *pOutActualVersion)
  18. {
  19. if (initialized)
  20. return TNC_RESULT_ALREADY_INITIALIZED;
  21. if (minVersion < TNC_IFIMV_VERSION_1 ||
  22. maxVersion > TNC_IFIMV_VERSION_1)
  23. return TNC_RESULT_NO_COMMON_VERSION;
  24. if (!pOutActualVersion)
  25. return TNC_RESULT_INVALID_PARAMETER;
  26. *pOutActualVersion = TNC_IFIMV_VERSION_1;
  27. initialized = 1;
  28. my_id = imvID;
  29. return TNC_RESULT_SUCCESS;
  30. }
  31. TNC_Result TNC_IMV_SolicitRecommendation(
  32. /*in*/ TNC_IMVID imvID,
  33. /*in*/ TNC_ConnectionID connectionID)
  34. {
  35. if (!initialized)
  36. return TNC_RESULT_NOT_INITIALIZED;
  37. if (imvID != my_id)
  38. return TNC_RESULT_INVALID_PARAMETER;
  39. return TNC_RESULT_SUCCESS;
  40. }
  41. TNC_Result TNC_IMV_ProvideBindFunction(
  42. /*in*/ TNC_IMVID imvID,
  43. /*in*/ TNC_TNCS_BindFunctionPointer bindFunction)
  44. {
  45. if (!initialized)
  46. return TNC_RESULT_NOT_INITIALIZED;
  47. if (imvID != my_id)
  48. return TNC_RESULT_INVALID_PARAMETER;
  49. return TNC_RESULT_SUCCESS;
  50. }