implemented get_remediation_instructions()

This commit is contained in:
Andreas Steffen
2012-11-10 23:47:06 +01:00
parent b217e16f7e
commit af83700f88
8 changed files with 156 additions and 19 deletions
+5 -6
View File
@@ -585,8 +585,8 @@ static bool language_enumerator_enumerate(language_enumerator_t *this, ...)
}
else
{
pos = this->lang_pos + len;
len = this->lang_len;
pos = this->lang_pos + len;
this->lang_pos = NULL;
this->lang_len = 0;
}
@@ -619,18 +619,17 @@ METHOD(imv_agent_t, create_language_enumerator, enumerator_t*,
/* Create a language enumerator instance */
e = malloc_thing(language_enumerator_t);
e->public.enumerate = (void*)language_enumerator_enumerate;
e->public.destroy = (void*)language_enumerator_destroy;
if (!this->get_attribute ||
if (!this->get_attribute ||
!this->get_attribute(this->id, state->get_connection_id(state),
TNC_ATTRIBUTEID_PREFERRED_LANGUAGE, BUF_LEN,
e->lang_buf, &e->lang_len) == TNC_RESULT_SUCCESS ||
e->lang_len >= BUF_LEN)
{
free(e);
return NULL;
e->lang_len = 0;
}
e->public.enumerate = (void*)language_enumerator_enumerate;
e->public.destroy = (void*)language_enumerator_destroy;
e->lang_buf[e->lang_len] = '\0';
e->lang_pos = e->lang_buf;
+18
View File
@@ -17,6 +17,7 @@
#include "ietf/ietf_attr.h"
#include "ietf/ietf_attr_assess_result.h"
#include "ietf/ietf_attr_remediation_instr.h"
#include <tncif_names.h>
@@ -190,6 +191,8 @@ METHOD(imv_msg_t, send_assessment, TNC_Result,
TNC_IMV_Action_Recommendation rec;
TNC_IMV_Evaluation_Result eval;
pa_tnc_attr_t *attr;
char *string, *lang_code;
enumerator_t *e;
/* Send an IETF Assessment Result attribute if enabled */
if (lib->settings->get_bool(lib->settings, "libimcv.assessment_result",
@@ -199,6 +202,21 @@ METHOD(imv_msg_t, send_assessment, TNC_Result,
attr = ietf_attr_assess_result_create(eval);
add_attribute(this, attr);
if (eval != TNC_IMV_EVALUATION_RESULT_COMPLIANT)
{
e = this->agent->create_language_enumerator(this->agent,
this->state);
if (this->state->get_remediation_instructions(this->state,
e, &string, &lang_code))
{
attr = ietf_attr_remediation_instr_create_from_string(
chunk_create(string, strlen(string)),
chunk_create(lang_code, strlen(lang_code)));
add_attribute(this, attr);
}
e->destroy(e);
}
/* send PA-TNC message with the excl flag set */
return send_(this, TRUE);
}
+14 -2
View File
@@ -111,12 +111,24 @@ struct imv_state_t {
*
* @param language_enumerator language enumerator
* @param reason_string reason string
* @param language code language of the returned reason string
* @param reason_language language of the returned reason string
* @return TRUE if a reason string was found
*/
bool (*get_reason_string)(imv_state_t *this,
enumerator_t *language_enumerator,
char **reason_string, char **language_code);
char **reason_string, char **reason_language);
/**
* Get remediation instructions based on the preferred language
*
* @param language_enumerator language enumerator
* @param string remediation instruction string
* @param lang_code language of the remediation instructions
* @return TRUE if remediation instructions were found
*/
bool (*get_remediation_instructions)(imv_state_t *this,
enumerator_t *language_enumerator,
char **string, char **lang_code);
/**
* Destroys an imv_state_t object