Updated through tag hostap_2_5 from git://w1.fi/hostap.git
[mech_eap.git] / libeap / tests / hwsim / tnc / hostap_imv.c
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
9 #include "includes.h"
10
11 #include "common.h"
12 #include "common/tnc.h"
13
14 static int initialized = 0;
15 static TNC_IMVID my_id = -1;
16
17 TNC_Result TNC_IMV_Initialize(
18         /*in*/ TNC_IMVID imvID,
19         /*in*/ TNC_Version minVersion,
20         /*in*/ TNC_Version maxVersion,
21         /*out*/ TNC_Version *pOutActualVersion)
22 {
23         if (initialized)
24                 return TNC_RESULT_ALREADY_INITIALIZED;
25
26         if (minVersion < TNC_IFIMV_VERSION_1 ||
27             maxVersion > TNC_IFIMV_VERSION_1)
28                 return TNC_RESULT_NO_COMMON_VERSION;
29
30         if (!pOutActualVersion)
31                 return TNC_RESULT_INVALID_PARAMETER;
32         *pOutActualVersion = TNC_IFIMV_VERSION_1;
33
34         initialized = 1;
35         my_id = imvID;
36
37         return TNC_RESULT_SUCCESS;
38 }
39
40
41 TNC_Result TNC_IMV_SolicitRecommendation(
42         /*in*/ TNC_IMVID imvID,
43         /*in*/ TNC_ConnectionID connectionID)
44 {
45         if (!initialized)
46                 return TNC_RESULT_NOT_INITIALIZED;
47
48         if (imvID != my_id)
49                 return TNC_RESULT_INVALID_PARAMETER;
50
51         return TNC_RESULT_SUCCESS;
52 }
53
54
55 TNC_Result TNC_IMV_ProvideBindFunction(
56         /*in*/ TNC_IMVID imvID,
57         /*in*/ TNC_TNCS_BindFunctionPointer bindFunction)
58 {
59         if (!initialized)
60                 return TNC_RESULT_NOT_INITIALIZED;
61
62         if (imvID != my_id)
63                 return TNC_RESULT_INVALID_PARAMETER;
64
65         return TNC_RESULT_SUCCESS;
66 }