#include <stdio.h>
#include <errno.h>
+#include "swanctl.h"
#include "command.h"
#include <collections/hashtable.h>
}
printf("\n");
+ print_label(" label: ", child->get(child, "label"));
printf(" local: %s\n", child->get(child, "local-ts"));
printf(" remote: %s\n", child->get(child, "remote-ts"));
#include <errno.h>
#include "command.h"
+#include "swanctl.h"
#include <collections/hashtable.h>
ret = vici_parse_cb(res, NULL, policy_values, policy_list, pol);
printf("%s, %s\n", name, pol->get(pol, "mode"));
+ print_label(" label: ", pol->get(pol, "label"));
printf(" local: %s\n", pol->get(pol, "local-ts"));
printf(" remote: %s\n", pol->get(pol, "remote-ts"));
#include <errno.h>
#include "command.h"
+#include "swanctl.h"
#include <collections/hashtable.h>
return 0;
}
-
CALLBACK(sa_list, int,
hashtable_t *sa, vici_res_t *res, char *name, void *value, int len)
{
}
printf("\n");
+ print_label(" label ", child->get(child, "label"));
printf(" local %s\n", child->get(child, "local-ts"));
printf(" remote %s\n", child->get(child, "remote-ts"));
}
#include <unistd.h>
#include <library.h>
+#include <selectors/sec_label.h>
/*
* Described in header
return cfg;
}
+/*
+ * Described in header
+ */
+void print_label(const char *prefix, const char *value)
+{
+ sec_label_t *label;
+ chunk_t encoding;
+
+ if (value)
+ {
+ encoding = chunk_from_hex(chunk_from_str((char*)value), NULL);
+ label = sec_label_from_encoding(encoding);
+ if (label)
+ {
+ printf("%s%s\n", prefix, label->get_string(label));
+ label->destroy(label);
+ }
+ chunk_free(&encoding);
+ }
+}
+
/**
* Cleanup library atexit()
*/
*/
settings_t *load_swanctl_conf(char *file);
+/**
+ * Print the given security label (hex-encoded) on a separate line with the
+ * given prefix.
+ *
+ * @param prefix prefix to print before the string-version of the label
+ * @param value hex-encoded security label
+ */
+void print_label(const char *prefix, const char *value);
+
#endif /** SWANCTL_H_ @}*/