implement set_attribute() callback function

This commit is contained in:
Andreas Steffen
2010-11-16 21:07:02 +01:00
parent 92477a0625
commit 343f4793a8
3 changed files with 124 additions and 3 deletions
@@ -81,6 +81,26 @@ struct recommendations_t {
*/
void (*set_preferred_language)(recommendations_t *this, chunk_t pref_lang);
/**
* Set the reason string
*
* @param id ID of IMV setting the reason string
* @param reason reason string
* @result return code
*/
TNC_Result (*set_reason_string)(recommendations_t *this, TNC_IMVID id,
chunk_t reason);
/**
* Set the language for reason strings
*
* @param id ID of IMV setting the reason language
* @param reason_lang reason language
* @result return code
*/
TNC_Result (*set_reason_language)(recommendations_t *this, TNC_IMVID id,
chunk_t reason_lang);
/**
* Destroys an imv_t object.
*/
+36
View File
@@ -352,6 +352,42 @@ METHOD(tnccs_manager_t, set_attribute, TNC_Result,
TNC_UInt32 buffer_len,
TNC_BufferReference buffer)
{
enumerator_t *enumerator;
tnccs_connection_entry_t *entry;
recommendations_t *recs = NULL;
if (attribute_id != TNC_ATTRIBUTEID_REASON_STRING &&
attribute_id != TNC_ATTRIBUTEID_REASON_LANGUAGE)
{
return TNC_RESULT_INVALID_PARAMETER;
}
this->connection_lock->read_lock(this->connection_lock);
enumerator = this->connections->create_enumerator(this->connections);
while (enumerator->enumerate(enumerator, &entry))
{
if (id == entry->id)
{
recs = entry->recs;
break;
}
}
enumerator->destroy(enumerator);
this->connection_lock->unlock(this->connection_lock);
if (recs)
{
chunk_t attribute = { buffer, buffer_len };
if (attribute_id == TNC_ATTRIBUTEID_REASON_STRING)
{
return recs->set_reason_string(recs, imv_id, attribute);
}
else
{
return recs->set_reason_language(recs, imv_id, attribute);
}
}
return TNC_RESULT_INVALID_PARAMETER;
}