Annotation of embedaddon/strongswan/src/libimcv/imv/imv_if.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2012-2013 Andreas Steffen
3: * HSR Hochschule fuer Technik Rapperswil
4: *
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>.
9: *
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
13: * for more details.
14: */
15:
16: /**
17: * Define the following two static constants externally:
18: * static const char imv_name[] = "xx";
19: * static const imv_agent_create_t imv_agent_create = imv_xx_agent_create;
20: */
21:
22: #include <utils/debug.h>
23:
24: static imv_agent_if_t *imv_agent;
25:
26: /*
27: * see section 3.8.1 of TCG TNC IF-IMV Specification 1.3
28: */
29: TNC_Result TNC_IMV_API TNC_IMV_Initialize(TNC_IMVID imv_id,
30: TNC_Version min_version,
31: TNC_Version max_version,
32: TNC_Version *actual_version)
33: {
34: if (imv_agent)
35: {
36: DBG1(DBG_IMV, "IMV \"%s\" has already been initialized", imv_name);
37: return TNC_RESULT_ALREADY_INITIALIZED;
38: }
39:
40: imv_agent = imv_agent_create(imv_name, imv_id, actual_version);
41:
42: if (!imv_agent)
43: {
44: return TNC_RESULT_FATAL;
45: }
46: if (min_version > TNC_IFIMV_VERSION_1 || max_version < TNC_IFIMV_VERSION_1)
47: {
48: DBG1(DBG_IMV, "no common IF-IMV version");
49: return TNC_RESULT_NO_COMMON_VERSION;
50: }
51: return TNC_RESULT_SUCCESS;
52: }
53:
54: /**
55: * see section 3.8.2 of TCG TNC IF-IMV Specification 1.3
56: */
57: TNC_Result TNC_IMV_API TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
58: TNC_ConnectionID connection_id,
59: TNC_ConnectionState new_state)
60: {
61: if (!imv_agent)
62: {
63: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
64: return TNC_RESULT_NOT_INITIALIZED;
65: }
66: return imv_agent->notify_connection_change(imv_agent, connection_id,
67: new_state);
68: }
69:
70: /**
71: * see section 3.8.4 of TCG TNC IF-IMV Specification 1.3
72: */
73: TNC_Result TNC_IMV_API TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
74: TNC_ConnectionID connection_id,
75: TNC_BufferReference msg,
76: TNC_UInt32 msg_len,
77: TNC_MessageType msg_type)
78: {
79: if (!imv_agent)
80: {
81: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
82: return TNC_RESULT_NOT_INITIALIZED;
83: }
84: return imv_agent->receive_message(imv_agent, connection_id, msg_type,
85: chunk_create(msg, msg_len));
86: }
87:
88: /**
89: * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3
90: */
91: TNC_Result TNC_IMV_API TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
92: TNC_ConnectionID connection_id,
93: TNC_UInt32 msg_flags,
94: TNC_BufferReference msg,
95: TNC_UInt32 msg_len,
96: TNC_VendorID msg_vid,
97: TNC_MessageSubtype msg_subtype,
98: TNC_UInt32 src_imc_id,
99: TNC_UInt32 dst_imv_id)
100: {
101: if (!imv_agent)
102: {
103: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
104: return TNC_RESULT_NOT_INITIALIZED;
105: }
106: return imv_agent->receive_message_long(imv_agent, connection_id,
107: src_imc_id, dst_imv_id,
108: msg_vid, msg_subtype, chunk_create(msg, msg_len));
109: }
110:
111: /**
112: * see section 3.8.7 of TCG TNC IF-IMV Specification 1.3
113: */
114: TNC_Result TNC_IMV_API TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
115: TNC_ConnectionID connection_id)
116: {
117:
118: if (!imv_agent)
119: {
120: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
121: return TNC_RESULT_NOT_INITIALIZED;
122: }
123: return imv_agent->solicit_recommendation(imv_agent, connection_id);
124: }
125:
126: /**
127: * see section 3.8.8 of TCG TNC IF-IMV Specification 1.3
128: */
129: TNC_Result TNC_IMV_API TNC_IMV_BatchEnding(TNC_IMVID imv_id,
130: TNC_ConnectionID connection_id)
131: {
132: if (!imv_agent)
133: {
134: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
135: return TNC_RESULT_NOT_INITIALIZED;
136: }
137: return imv_agent->batch_ending(imv_agent, connection_id);
138: }
139:
140: /**
141: * see section 3.8.9 of TCG TNC IF-IMV Specification 1.3
142: */
143: TNC_Result TNC_IMV_API TNC_IMV_Terminate(TNC_IMVID imv_id)
144: {
145: if (!imv_agent)
146: {
147: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
148: return TNC_RESULT_NOT_INITIALIZED;
149: }
150: imv_agent->destroy(imv_agent);
151: imv_agent = NULL;
152:
153: return TNC_RESULT_SUCCESS;
154: }
155:
156: /**
157: * see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.3
158: */
159: TNC_Result TNC_IMV_API TNC_IMV_ProvideBindFunction(TNC_IMVID imv_id,
160: TNC_TNCS_BindFunctionPointer bind_function)
161: {
162: if (!imv_agent)
163: {
164: DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
165: return TNC_RESULT_NOT_INITIALIZED;
166: }
167: return imv_agent->bind_functions(imv_agent, bind_function);
168: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>