output PEP device addresses as metadata
[strongswan.git] / src / libcharon / plugins / tnc_ifmap / tnc_ifmap_listener.c
index aee36d6..4a2a226 100644 (file)
@@ -17,6 +17,7 @@
 #include "tnc_ifmap_soap.h"
 
 #include <daemon.h>
+#include <hydra.h>
 #include <debug.h>
 
 typedef struct private_tnc_ifmap_listener_t private_tnc_ifmap_listener_t;
@@ -62,6 +63,30 @@ static bool publish_ike_sa(private_tnc_ifmap_listener_t *this,
 }
 
 /**
+ * Publish PEP device-ip metadata
+ */
+static bool publish_device_ip_addresses(private_tnc_ifmap_listener_t *this)
+{
+       enumerator_t *enumerator;
+       host_t *host;
+       bool success = TRUE;
+
+       enumerator = hydra->kernel_interface->create_address_enumerator(
+                                                       hydra->kernel_interface, FALSE, FALSE);
+       while (enumerator->enumerate(enumerator, &host))
+       {
+               if (!this->ifmap->publish_device_ip(this->ifmap, host))
+               {
+                       success = FALSE;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+
+       return success;
+}
+
+/**
  * Publish all IKE_SA metadata
  */
 static bool reload_metadata(private_tnc_ifmap_listener_t *this)
@@ -136,6 +161,11 @@ tnc_ifmap_listener_t *tnc_ifmap_listener_create(bool reload)
                destroy(this);
                return NULL;
        }
+       if (!publish_device_ip_addresses(this))
+       {
+               destroy(this);
+               return NULL;
+       }
        if (reload)
        {
                if (!reload_metadata(this))