]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
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 51a17e2a42a50c7c593d70133771a03104dbb942..a0522b5c4905ee79970c16ae29cd9ba9e6dcc454 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 265a17e52f3cc1105c8121a2cb530089f83d1ff7..9a3d832da36d455640120847d38a28bb5c7c568d 100644 (file)
@@ -233,6 +233,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
  */
@@ -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");