vici: Return local and remote virtual IPs when listing SAs
authorTobias Brunner <tobias@strongswan.org>
Mon, 19 Oct 2015 14:05:47 +0000 (16:05 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 10 Nov 2015 09:43:24 +0000 (10:43 +0100)
src/libcharon/plugins/vici/README.md
src/libcharon/plugins/vici/vici_query.c

index 51a17e2..a0522b5 100644 (file)
@@ -600,6 +600,12 @@ command.
                        established = <seconds the IKE_SA has been established>
                        rekey-time = <seconds before IKE_SA gets rekeyed>
                        reauth-time = <seconds before IKE_SA gets re-authenticated>
+                       local-vips = [
+                               <list of virtual IPs assigned by the remote peer, installed locally>
+                       ]
+                       remote-vips = [
+                               <list of virtual IPs assigned to the remote peer>
+                       ]
                        tasks-queued = [
                                <list of currently queued tasks for execution>
                        ]
index 265a17e..9a3d832 100644 (file)
@@ -234,6 +234,33 @@ static void add_condition(vici_builder_t *b, ike_sa_t *ike_sa,
 }
 
 /**
+ * List virtual IPs
+ */
+static void list_vips(private_vici_query_t *this, vici_builder_t *b,
+                                         ike_sa_t *ike_sa, bool local, char *name)
+{
+       enumerator_t *enumerator;
+       bool has = FALSE;
+       host_t *vip;
+
+       enumerator = ike_sa->create_virtual_ip_enumerator(ike_sa, local);
+       while (enumerator->enumerate(enumerator, &vip))
+       {
+               if (!has)
+               {
+                       b->begin_list(b, name);
+                       has = TRUE;
+               }
+               b->add_li(b, "%H", vip);
+       }
+       enumerator->destroy(enumerator);
+       if (has)
+       {
+               b->end_list(b);
+       }
+}
+
+/**
  * List details of an IKE_SA
  */
 static void list_ike(private_vici_query_t *this, vici_builder_t *b,
@@ -327,6 +354,9 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
                }
        }
 
+       list_vips(this, b, ike_sa, TRUE, "local-vips");
+       list_vips(this, b, ike_sa, FALSE, "remote-vips");
+
        list_task_queue(this, b, ike_sa, TASK_QUEUE_QUEUED, "tasks-queued");
        list_task_queue(this, b, ike_sa, TASK_QUEUE_ACTIVE, "tasks-active");
        list_task_queue(this, b, ike_sa, TASK_QUEUE_PASSIVE, "tasks-passive");