2 * Copyright (C) 2006 Mike McCauley
3 * Copyright (C) 2010 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
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>.
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
23 typedef struct private_tnc_imv_t private_tnc_imv_t
;
25 struct private_tnc_imv_t
{
28 * Public members of imv_t.
43 * List of message types supported by IMC
45 TNC_MessageTypeList supported_types
;
48 * Number of supported message types
50 TNC_UInt32 type_count
;
53 METHOD(imv_t
, set_id
, void,
54 private_tnc_imv_t
*this, TNC_IMVID id
)
59 METHOD(imv_t
, get_id
, TNC_IMVID
,
60 private_tnc_imv_t
*this)
65 METHOD(imv_t
, get_name
, char*,
66 private_tnc_imv_t
*this)
71 METHOD(imv_t
, set_message_types
, void,
72 private_tnc_imv_t
*this, TNC_MessageTypeList supported_types
,
73 TNC_UInt32 type_count
)
75 free(this->supported_types
);
76 this->supported_types
= NULL
;
77 this->type_count
= type_count
;
78 if (type_count
&& supported_types
)
80 size_t size
= type_count
* sizeof(TNC_MessageType
);
82 this->supported_types
= malloc(size
);
83 memcpy(this->supported_types
, supported_types
, size
);
87 METHOD(imv_t
, destroy
, void,
88 private_tnc_imv_t
*this)
91 free(this->supported_types
);
96 * Described in header.
98 imv_t
* tnc_imv_create(char *name
, char *filename
)
100 private_tnc_imv_t
*this;
107 .get_name
= _get_name
,
108 .set_message_types
= _set_message_types
,
113 handle
= dlopen(filename
, RTLD_NOW
);
116 DBG1(DBG_TNC
, "IMV '%s' failed to load from '%s': %s",
117 name
, filename
, dlerror());
122 /* we do not store or free dlopen() handles, leak_detective requires
123 * the modules to keep loaded until leak report */
125 this->public.initialize
= dlsym(handle
, "TNC_IMV_Initialize");
126 if (!this->public.initialize
)
128 DBG1(DBG_TNC
, "could not resolve TNC_IMV_Initialize in %s: %s\n",
129 filename
, dlerror());
133 this->public.notify_connection_change
=
134 dlsym(handle
, "TNC_IMV_NotifyConnectionChange");
135 this->public.solicit_recommendation
=
136 dlsym(handle
, "TNC_IMV_SolicitRecommendation");
137 if (!this->public.solicit_recommendation
)
139 DBG1(DBG_TNC
, "could not resolve TNC_IMV_SolicitRecommendation in %s: %s\n",
140 filename
, dlerror());
144 this->public.receive_message
=
145 dlsym(handle
, "TNC_IMV_ReceiveMessage");
146 this->public.batch_ending
=
147 dlsym(handle
, "TNC_IMV_BatchEnding");
148 this->public.terminate
=
149 dlsym(handle
, "TNC_IMV_Terminate");
150 this->public.provide_bind_function
=
151 dlsym(handle
, "TNC_IMV_ProvideBindFunction");
152 if (!this->public.provide_bind_function
)
154 DBG1(DBG_TNC
, "could not resolve TNC_IMV_ProvideBindFunction in %s: %s\n",
155 filename
, dlerror());
159 this->name
= strdup(name
);
161 return &this->public;