]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
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 3c72c122d305b7554698ad3897277fcc1c22b0e4..440a4f3d27d5cbcc2b5692c59e48131fe6aa51e4 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 b3a20a6c7d2359a86e011ee83a5208a5a70ec4e1..de5fa0eade72e70b8f69ff58229fd45650f8d5e5 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 64a9785a6159c8aaa7aee75232ed579912327305..0f823769a20ba7c8051506bb3cb4adc8cfef5ac9 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 3c56b0cd74b25ca076158bed273f6cf7b78a1dd7..9ab69b417a94ee56a517210b3d2fb06c12004f4f 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 30ec00175333409ed14274c36ff20c13a2d92524..463ad2e22820435bf0b3267da7142cdb61567801 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 dae3f2c1888bba9732ba2ac06d4f49ce7c85bdfb..44511edf838c12e69c44e1a787b05a844d557b20 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 0157599c13e74d836ada71a1597137e37cb46277..45920d1cf7de0fb37fef9a28ed97a12fb18b3178 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 db48bc58ece494bebcb6bdc053db81e3b2f0f8b8..e9f06cbe32edfc16b838d5bc878ee8b0fddc3559 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 644af782c47d05470a809cb35b61c0b2da60b85b..8652942ad68eba49a0fff909b02de998eed2c74d 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",