ifmap plugin subscribes to assing_vip bus signal
[strongswan.git] / src / libcharon / plugins / tnc_ifmap / tnc_ifmap_listener.c
index 4b2538e..1603c93 100644 (file)
@@ -71,8 +71,9 @@ static bool publish_device_ip_addresses(private_tnc_ifmap_listener_t *this)
  */
 static bool reload_metadata(private_tnc_ifmap_listener_t *this)
 {
-       enumerator_t *enumerator;
+       enumerator_t *enumerator, *evips;
        ike_sa_t *ike_sa;
+       host_t *vip;
        bool success = TRUE;
 
        enumerator = charon->controller->create_ike_sa_enumerator(
@@ -88,6 +89,16 @@ static bool reload_metadata(private_tnc_ifmap_listener_t *this)
                        success = FALSE;
                        break;
                }
+               evips = ike_sa->create_virtual_ip_enumerator(ike_sa, FALSE);
+               while (evips->enumerate(evips, &vip))
+               {
+                       if (!this->ifmap->publish_virtual_ip(this->ifmap, ike_sa, vip, TRUE))
+                       {
+                               success = FALSE;
+                               break;
+                       }
+               }
+               evips->destroy(evips);
        }
        enumerator->destroy(enumerator);
 
@@ -104,6 +115,14 @@ METHOD(listener_t, ike_updown, bool,
        return TRUE;
 }
 
+METHOD(listener_t, assign_vip, bool,
+       private_tnc_ifmap_listener_t *this, ike_sa_t *ike_sa, host_t *vip,
+       bool assign)
+{
+       this->ifmap->publish_virtual_ip(this->ifmap, ike_sa, vip, assign);
+       return TRUE;
+}
+
 METHOD(listener_t, alert, bool,
        private_tnc_ifmap_listener_t *this, ike_sa_t *ike_sa, alert_t alert,
        va_list args)
@@ -144,6 +163,7 @@ tnc_ifmap_listener_t *tnc_ifmap_listener_create(bool reload)
                .public = {
                        .listener = {
                                .ike_updown = _ike_updown,
+                               .assign_vip = _assign_vip,
                                .alert = _alert,
                        },
                        .destroy = _destroy,