ifmap plugin subscribes to assing_vip bus signal
[strongswan.git] / src / libcharon / plugins / tnc_ifmap / tnc_ifmap_soap.c
index 8d5da58..fb97a6d 100644 (file)
@@ -579,6 +579,48 @@ METHOD(tnc_ifmap_soap_t, publish_device_ip, bool,
        return success;
 }
 
+METHOD(tnc_ifmap_soap_t, publish_virtual_ip, bool,
+       private_tnc_ifmap_soap_t *this, ike_sa_t *ike_sa, host_t *vip, bool assign)
+{
+       tnc_ifmap_soap_msg_t *soap_msg;
+       xmlNodePtr request, node;
+       u_int32_t ike_sa_id;
+       bool success;
+
+       /* extract relevant data from IKE_SA*/
+       ike_sa_id = ike_sa->get_unique_id(ike_sa);
+
+       /* build publish request */
+       request = create_publish_request(this);
+
+       /**
+        * update or delete access-request-ip metadata for a virtual IP address
+        */
+       if (assign)
+       {
+               node = xmlNewNode(NULL, "update");
+       }
+       else
+       {
+               node = create_delete_filter(this, "access-request-ip");
+       }
+       xmlAddChild(request, node);
+
+       /* add access-request, virtual ip-address and [if assign] metadata */
+       xmlAddChild(node, create_access_request(this, ike_sa_id));
+       xmlAddChild(node, create_ip_address(this, vip));
+       if (assign)
+       {
+               xmlAddChild(node, create_metadata(this, "access-request-ip"));
+       }
+
+       soap_msg = tnc_ifmap_soap_msg_create(this->uri, this->user_pass, this->tls);
+       success = soap_msg->post(soap_msg, request, "publishReceived", NULL);
+       soap_msg->destroy(soap_msg);
+
+       return success;
+}
+
 METHOD(tnc_ifmap_soap_t, publish_enforcement_report, bool,
        private_tnc_ifmap_soap_t *this, host_t *host, char *action, char *reason)
 {
@@ -851,6 +893,7 @@ tnc_ifmap_soap_t *tnc_ifmap_soap_create()
                        .purgePublisher = _purgePublisher,
                        .publish_ike_sa = _publish_ike_sa,
                        .publish_device_ip = _publish_device_ip,
+                       .publish_virtual_ip = _publish_virtual_ip,
                        .publish_enforcement_report = _publish_enforcement_report,
                        .endSession = _endSession,
                        .get_session_id = _get_session_id,