]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
list pools and usage in ipsec statusall
authorMartin Willi <martin@strongswan.org>
Tue, 9 Dec 2008 13:24:12 +0000 (13:24 -0000)
committerMartin Willi <martin@strongswan.org>
Tue, 9 Dec 2008 13:24:12 +0000 (13:24 -0000)
src/charon/plugins/stroke/stroke_list.c
src/charon/plugins/stroke/stroke_list.h
src/charon/plugins/stroke/stroke_socket.c

index 7d0ad4557433836899d66d50ee3d339d27b578d9..61ed7dd6cdafef7edc3ef8172ba85d40a659b7ae 100644 (file)
@@ -47,6 +47,11 @@ struct private_stroke_list_t {
         * timestamp of daemon start
         */
        time_t uptime;
+       
+       /**
+        * strokes attribute provider
+        */
+       stroke_attribute_t *attribute;
 };
 
 /**
@@ -248,11 +253,13 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
        if (all)
        {
                peer_cfg_t *peer_cfg;
-               char *plugin;
+               char *plugin, *name;
                host_t *host;
                u_int32_t dpd;
                time_t uptime = time(NULL) - this->uptime;
-
+               bool first = TRUE;
+               u_int size, online, offline;
+               
                fprintf(out, "Performance:\n");
                fprintf(out, "  uptime: %V, since %#T\n", &uptime, &this->uptime, FALSE);
                fprintf(out, "  worker threads: %d idle of %d,",
@@ -271,6 +278,18 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                enumerator->destroy(enumerator);
                fprintf(out, "\n");
                
+               enumerator = this->attribute->create_pool_enumerator(this->attribute);
+               while (enumerator->enumerate(enumerator, &name, &size, &online, &offline))
+               {
+                       if (first)
+                       {
+                               first = FALSE;
+                               fprintf(out, "Virtual IP pools (size/online/offline):\n");
+                       }
+                       fprintf(out, "  %s: %lu/%lu/%lu\n", name, size, online, offline);
+               }
+               enumerator->destroy(enumerator);
+               
                enumerator = charon->kernel_interface->create_address_enumerator(
                                                                charon->kernel_interface, FALSE, FALSE);
                fprintf(out, "Listening IP addresses:\n");
@@ -979,7 +998,7 @@ static void destroy(private_stroke_list_t *this)
 /*
  * see header file
  */
-stroke_list_t *stroke_list_create()
+stroke_list_t *stroke_list_create(stroke_attribute_t *attribute)
 {
        private_stroke_list_t *this = malloc_thing(private_stroke_list_t);
        
@@ -988,6 +1007,7 @@ stroke_list_t *stroke_list_create()
        this->public.destroy = (void(*)(stroke_list_t*))destroy;
        
        this->uptime = time(NULL);
+       this->attribute = attribute;
        
        return &this->public;
 }
index dabdbff39b8c1495eb3fba1c6cc266934d1190ad..525e955c65470dcb2ddb38467692a1cecbfe42d6 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef STROKE_LIST_H_
 #define STROKE_LIST_H_
 
+#include "stroke_attribute.h"
+
 #include <stroke_msg.h>
 #include <library.h>
 
@@ -58,7 +60,9 @@ struct stroke_list_t {
 
 /**
  * Create a stroke_list instance.
+ *
+ * @param attribute            strokes attribute provider
  */
-stroke_list_t *stroke_list_create();
+stroke_list_t *stroke_list_create(stroke_attribute_t *attribute);
 
 #endif /* STROKE_LIST_H_ @}*/
index 8c4ab7804cb03311cfc7212dd35d1764119aec8a..45358d375a46b9302a627c283201f13b8e6d5351 100644 (file)
@@ -621,7 +621,7 @@ stroke_socket_t *stroke_socket_create()
        this->ca = stroke_ca_create(this->cred);
        this->config = stroke_config_create(this->ca, this->cred);
        this->control = stroke_control_create();
-       this->list = stroke_list_create();
+       this->list = stroke_list_create(this->attribute);
        
        charon->credentials->add_set(charon->credentials, &this->ca->set);
        charon->credentials->add_set(charon->credentials, &this->cred->set);