*/
#include "imv_test_state.h"
+#include "imv/imv_lang_string.h"
+#include "imv/imv_reason_string.h"
#include <utils/lexparser.h>
#include <collections/linked_list.h>
TNC_IMV_Evaluation_Result eval;
/**
+ * TNC Reason String
+ */
+ imv_reason_string_t *reason_string;
+
+ /**
* List of IMCs
*/
linked_list_t *imcs;
int rounds;
};
-typedef struct entry_t entry_t;
-
/**
- * Define an internal reason string entry
+ * Supported languages
*/
-struct entry_t {
- char *lang;
- char *string;
-};
+static char* languages[] = { "en", "de", "fr", "pl" };
/**
- * Table of multi-lingual reason string entries
+ * Table of reason strings
*/
-static entry_t reasons[] = {
+static imv_lang_string_t reasons[] = {
{ "en", "IMC Test was not configured with \"command = allow\"" },
{ "de", "IMC Test wurde nicht mit \"command = allow\" konfiguriert" },
{ "fr", "IMC Test n'etait pas configuré avec \"command = allow\"" },
- { "pl", "IMC Test nie zostało skonfigurowany z \"command = allow\"" }
+ { "pl", "IMC Test nie zostało skonfigurowany z \"command = allow\"" },
+ { NULL, NULL }
};
METHOD(imv_state_t, get_connection_id, TNC_ConnectionID,
METHOD(imv_state_t, get_reason_string, bool,
private_imv_test_state_t *this, enumerator_t *language_enumerator,
- char **reason_string, char **reason_language)
+ chunk_t *reason_string, char **reason_language)
{
- bool match = FALSE;
- char *lang;
- int i;
-
- /* set the default language */
- *reason_language = reasons[0].lang;
- *reason_string = reasons[0].string;
+ *reason_language = imv_lang_string_select_lang(language_enumerator,
+ languages, countof(languages));
- while (language_enumerator->enumerate(language_enumerator, &lang))
- {
- for (i = 0 ; i < countof(reasons); i++)
- {
- if (streq(lang, reasons[i].lang))
- {
- match = TRUE;
- *reason_language = reasons[i].lang;
- *reason_string = reasons[i].string;
- break;
- }
- }
- if (match)
- {
- break;
- }
- }
+ /* Instantiate a TNC Reason String object */
+ DESTROY_IF(this->reason_string);
+ this->reason_string = imv_reason_string_create(*reason_language);
+ this->reason_string->add_reason(this->reason_string, reasons);
+ *reason_string = this->reason_string->get_encoding(this->reason_string);
return TRUE;
}
METHOD(imv_state_t, get_remediation_instructions, bool,
private_imv_test_state_t *this, enumerator_t *language_enumerator,
- char **string, char **lang_code, char **uri)
+ chunk_t *string, char **lang_code, char **uri)
{
return FALSE;
}
METHOD(imv_state_t, destroy, void,
private_imv_test_state_t *this)
{
+ DESTROY_IF(this->reason_string);
this->imcs->destroy_function(this->imcs, free);
free(this);
}