child_sa_t.get_usestats() can additionally return the number of processed packets
authorMartin Willi <martin@revosec.ch>
Wed, 13 Mar 2013 10:38:02 +0000 (11:38 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 14 Mar 2013 13:20:54 +0000 (14:20 +0100)
src/libcharon/plugins/eap_radius/eap_radius_accounting.c
src/libcharon/plugins/stroke/stroke_list.c
src/libcharon/processing/jobs/dpd_timeout_job.c
src/libcharon/processing/jobs/inactivity_job.c
src/libcharon/sa/child_sa.c
src/libcharon/sa/child_sa.h
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ikev1/tasks/quick_delete.c
src/libcharon/sa/ikev2/tasks/child_delete.c

index 3c72c12..440a4f3 100644 (file)
@@ -102,8 +102,8 @@ static void update_usage(private_eap_radius_accounting_t *this,
        u_int64_t sent, received;
        entry_t *entry;
 
-       child_sa->get_usestats(child_sa, FALSE, NULL, &sent);
-       child_sa->get_usestats(child_sa, TRUE, NULL, &received);
+       child_sa->get_usestats(child_sa, FALSE, NULL, &sent, NULL);
+       child_sa->get_usestats(child_sa, TRUE, NULL, &received, NULL);
 
        this->mutex->lock(this->mutex);
        entry = this->sessions->get(this->sessions,
index b3a20a6..de5fa0e 100644 (file)
@@ -273,14 +273,14 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
                                }
                        }
 
-                       child_sa->get_usestats(child_sa, TRUE, &use_in, &bytes_in);
+                       child_sa->get_usestats(child_sa, TRUE, &use_in, &bytes_in, NULL);
                        fprintf(out, ", %" PRIu64 " bytes_i", bytes_in);
                        if (use_in)
                        {
                                fprintf(out, " (%" PRIu64 "s ago)", (u_int64_t)(now - use_in));
                        }
 
-                       child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out);
+                       child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out, NULL);
                        fprintf(out, ", %" PRIu64 " bytes_o", bytes_out);
                        if (use_out)
                        {
@@ -1541,4 +1541,3 @@ stroke_list_t *stroke_list_create(stroke_attribute_t *attribute)
 
        return &this->public;
 }
-
index 64a9785..0f82376 100644 (file)
@@ -68,7 +68,7 @@ METHOD(job_t, execute, job_requeue_t,
                enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
                while (enumerator->enumerate(enumerator, &child_sa))
                {
-                       child_sa->get_usestats(child_sa, TRUE, &current, NULL);
+                       child_sa->get_usestats(child_sa, TRUE, &current, NULL, NULL);
                        use_time = max(use_time, current);
                }
                enumerator->destroy(enumerator);
index 3c56b0c..9ab69b4 100644 (file)
@@ -75,8 +75,8 @@ METHOD(job_t, execute, job_requeue_t,
                        {
                                time_t in, out, diff;
 
-                               child_sa->get_usestats(child_sa, TRUE, &in, NULL);
-                               child_sa->get_usestats(child_sa, FALSE, &out, NULL);
+                               child_sa->get_usestats(child_sa, TRUE, &in, NULL, NULL);
+                               child_sa->get_usestats(child_sa, FALSE, &out, NULL, NULL);
 
                                diff = time_monotonic(NULL) - max(in, out);
 
@@ -155,4 +155,3 @@ inactivity_job_t *inactivity_job_create(u_int32_t reqid, u_int32_t timeout,
 
        return &this->public;
 }
-
index 30ec001..463ad2e 100644 (file)
@@ -524,7 +524,8 @@ static void update_usetime(private_child_sa_t *this, bool inbound)
 }
 
 METHOD(child_sa_t, get_usestats, void,
-          private_child_sa_t *this, bool inbound, time_t *time, u_int64_t *bytes)
+       private_child_sa_t *this, bool inbound,
+       time_t *time, u_int64_t *bytes, u_int64_t *packets)
 {
        if (update_usebytes(this, inbound) != FAILED)
        {
@@ -541,6 +542,10 @@ METHOD(child_sa_t, get_usestats, void,
        {
                *bytes = inbound ? this->my_usebytes : this->other_usebytes;
        }
+       if (packets)
+       {
+               *packets = inbound ? this->my_usepackets : this->other_usepackets;
+       }
 }
 
 METHOD(child_sa_t, get_mark, mark_t,
index dae3f2c..44511ed 100644 (file)
@@ -270,9 +270,10 @@ struct child_sa_t {
         * @param inbound               TRUE for inbound traffic, FALSE for outbound
         * @param[out] time             time of last use in seconds (NULL to ignore)
         * @param[out] bytes    number of processed bytes (NULL to ignore)
+        * @param[out] packets  number of processed packets (NULL to ignore)
         */
        void (*get_usestats)(child_sa_t *this, bool inbound, time_t *time,
-                                                u_int64_t *bytes);
+                                                u_int64_t *bytes, u_int64_t *packets);
 
        /**
         * Get the mark used with this CHILD_SA.
index 0157599..45920d1 100644 (file)
@@ -285,7 +285,7 @@ static time_t get_use_time(private_ike_sa_t* this, bool inbound)
        enumerator = this->child_sas->create_enumerator(this->child_sas);
        while (enumerator->enumerate(enumerator, &child_sa))
        {
-               child_sa->get_usestats(child_sa, inbound, &current, NULL);
+               child_sa->get_usestats(child_sa, inbound, &current, NULL, NULL);
                use_time = max(use_time, current);
        }
        enumerator->destroy(enumerator);
index db48bc5..e9f06cb 100644 (file)
@@ -97,8 +97,8 @@ static bool delete_child(private_quick_delete_t *this,
        }
        else
        {
-               child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
-               child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
+               child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in, NULL);
+               child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out, NULL);
 
                DBG0(DBG_IKE, "closing CHILD_SA %s{%d} with SPIs "
                         "%.8x_i (%llu bytes) %.8x_o (%llu bytes) and TS %#R=== %#R",
index 644af78..8652942 100644 (file)
@@ -264,8 +264,8 @@ static void log_children(private_child_delete_t *this)
                }
                else
                {
-                       child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
-                       child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
+                       child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in, NULL);
+                       child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out, NULL);
 
                        DBG0(DBG_IKE, "closing CHILD_SA %s{%d} with SPIs %.8x_i "
                                 "(%llu bytes) %.8x_o (%llu bytes) and TS %#R=== %#R",