[hipl-commit] [tiny] Rev 3725: Moved hip_icmp_statistics to HEARTBEAT module.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Fri, 26 Mar 2010 17:59:06 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: 26/03/2010 at 17:59:06
Revision: 3725
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Moved hip_icmp_statistics to HEARTBEAT module.
  
  This function is only used in the HEARTBEAT module and should therefore
  be defined in it.
  
  Also changed the linking order to avoid problems. Now the standard libs
  are linked before the module libs.

Modified:
  M  Makefile.am
  M  hipd/maintenance.c
  M  hipd/maintenance.h
  M  modules/heartbeat/hipd/heartbeat.c

=== modified file 'Makefile.am'
--- Makefile.am 2010-03-26 13:05:32 +0000
+++ Makefile.am 2010-03-26 15:59:00 +0000
@@ -216,6 +216,15 @@
 lib_performance_libperformance_la_SOURCES = lib/performance/performance.c
 
 ### *_LDADD ###
+# Initialize LDADD lists empty, because modules might add entries to LDADD in
+# Makefile.modules. This file needs to be included before the standard LDADDs,
+# because the linking order is from right to left.
+hipd_hipd_LDADD =
+firewall_hipfw_LDADD =
+tools_hipconf_LDADD =
+
+include Makefile.modules
+
 test_certteststub_LDADD = lib/core/libhipcore.la \
                           lib/tool/libhiptool.la
 if HIP_PERFORMANCE
@@ -250,9 +259,9 @@
 test_modularization_LDADD += lib/performance/libperformance.la
 endif
 
-tools_hipconf_LDADD = lib/conf/libhipconf.la \
-                      lib/core/libhipcore.la \
-                      lib/tool/libhiptool.la
+tools_hipconf_LDADD += lib/conf/libhipconf.la \
+                       lib/core/libhipcore.la \
+                       lib/tool/libhiptool.la
 
 # required by libhipconf
 if HIP_PERFORMANCE
@@ -266,10 +275,10 @@
 tools_pisacert_LDADD += lib/performance/libperformance.la
 endif
 
-hipd_hipd_LDADD = lib/modularization/libmod.la \
-                  lib/core/libhipcore.la \
-                  lib/conf/libhipconf.la \
-                  lib/tool/libhiptool.la
+hipd_hipd_LDADD += lib/modularization/libmod.la \
+                   lib/core/libhipcore.la \
+                   lib/conf/libhipconf.la \
+                   lib/tool/libhiptool.la
 
 if HIP_PERFORMANCE
 hipd_hipd_LDADD += lib/performance/libperformance.la
@@ -280,8 +289,8 @@
 endif
 
 if HIP_FIREWALL
-firewall_hipfw_LDADD = lib/core/libhipcore.la \
-                       lib/tool/libhiptool.la
+firewall_hipfw_LDADD += lib/core/libhipcore.la \
+                        lib/tool/libhiptool.la
 
 if HIP_PERFORMANCE
 firewall_hipfw_LDADD += lib/performance/libperformance.la
@@ -289,8 +298,6 @@
 
 endif # HIP_FIREWALL
 
-include Makefile.modules
-
 CLEANFILES = tools/hipdnsproxy tools/hipdnskeyparse
 
 ###### PYTHON stuff below ######

=== modified file 'hipd/maintenance.c'
--- hipd/maintenance.c  2010-03-19 14:29:54 +0000
+++ hipd/maintenance.c  2010-03-26 15:59:00 +0000
@@ -405,58 +405,6 @@
 }
 
 /**
- * This function calculates RTT and then stores them to correct entry
- *
- * @param src HIT
- * @param dst HIT
- * @param time when sent
- * @param time when received
- *
- * @return zero on success or negative on failure
- */
-int hip_icmp_statistics(struct in6_addr *src, struct in6_addr *dst,
-                        struct timeval *stval, struct timeval *rtval)
-{
-    int err                  = 0;
-    uint32_t rcvd_heartbeats = 0;
-    uint64_t rtt             = 0;
-    double avg               = 0.0, std_dev = 0.0;
-    char hit[INET6_ADDRSTRLEN];
-    hip_ha_t *entry          = NULL;
-    uint8_t *heartbeat_counter = NULL;
-
-    hip_in6_ntop(src, hit);
-
-    /* Find the correct entry */
-    entry = hip_hadb_find_byhits(src, dst);
-    HIP_IFEL((!entry), -1, "Entry not found\n");
-
-    /* Calculate the RTT from given timevals */
-    rtt   = calc_timeval_diff(stval, rtval);
-
-    /* add the heartbeat item to the statistics */
-    add_statistics_item(&entry->heartbeats_statistics, rtt);
-
-    /* calculate the statistics for immediate output */
-    calc_statistics(&entry->heartbeats_statistics, &rcvd_heartbeats, NULL, 
NULL, &avg,
-                    &std_dev, STATS_IN_MSECS);
-
-    heartbeat_counter = lmod_get_state_item(entry->hip_modular_state,
-                                            "heartbeat_update");
-
-    *heartbeat_counter = 0;
-    HIP_DEBUG("heartbeat_counter: %d\n", *heartbeat_counter);
-
-    HIP_DEBUG("\nHeartbeat from %s, RTT %.6f ms,\n%.6f ms mean, "
-              "%.6f ms std dev, packets sent %d recv %d lost %d\n",
-              hit, ((float) rtt / STATS_IN_MSECS), avg, std_dev, 
entry->heartbeats_sent,
-              rcvd_heartbeats, (entry->heartbeats_sent - rcvd_heartbeats));
-
-out_err:
-    return err;
-}
-
-/**
  * tell firewall to turn on or off the ESP relay mode
  *
  * @param action HIP_MSG_OFFER_FULLRELAY or HIP_MSG_CANCEL_FULLRELAY

=== modified file 'hipd/maintenance.h'
--- hipd/maintenance.h  2010-03-19 14:29:54 +0000
+++ hipd/maintenance.h  2010-03-26 15:59:00 +0000
@@ -22,9 +22,6 @@
 void hip_set_firewall_status(void);
 int hip_get_firewall_status(void);
 
-int hip_icmp_statistics(struct in6_addr *src, struct in6_addr *dst,
-                        struct timeval *stval, struct timeval *rtval);
-
 /*Communication with firewall daemon*/
 int hip_firewall_set_bex_data(int action, hip_ha_t *entry, struct in6_addr 
*hit_s,
                               struct in6_addr *hit_r);

=== modified file 'modules/heartbeat/hipd/heartbeat.c'
--- modules/heartbeat/hipd/heartbeat.c  2010-03-25 18:33:07 +0000
+++ modules/heartbeat/hipd/heartbeat.c  2010-03-26 15:59:00 +0000
@@ -44,6 +44,7 @@
 #include "hipd/init.h"
 #include "hipd/hip_socket.h"
 #include "hipd/pkt_handling.h"
+#include "lib/core/hip_statistics.h"
 
 #define HIP_HEARTBEAT_INTERVAL 20
 
@@ -157,6 +158,60 @@
 }
 
 /**
+ * This function calculates RTT and then stores them to correct entry
+ *
+ * @param src HIT
+ * @param dst HIT
+ * @param time when sent
+ * @param time when received
+ *
+ * @return zero on success or negative on failure
+ */
+static int hip_icmp_statistics(struct in6_addr *src,
+                               struct in6_addr *dst,
+                               struct timeval *stval,
+                               struct timeval *rtval)
+{
+    int err                  = 0;
+    uint32_t rcvd_heartbeats = 0;
+    uint64_t rtt             = 0;
+    double avg               = 0.0, std_dev = 0.0;
+    char hit[INET6_ADDRSTRLEN];
+    hip_ha_t *entry          = NULL;
+    uint8_t *heartbeat_counter = NULL;
+
+    hip_in6_ntop(src, hit);
+
+    /* Find the correct entry */
+    entry = hip_hadb_find_byhits(src, dst);
+    HIP_IFEL((!entry), -1, "Entry not found\n");
+
+    /* Calculate the RTT from given timevals */
+    rtt   = calc_timeval_diff(stval, rtval);
+
+    /* add the heartbeat item to the statistics */
+    add_statistics_item(&entry->heartbeats_statistics, rtt);
+
+    /* calculate the statistics for immediate output */
+    calc_statistics(&entry->heartbeats_statistics, &rcvd_heartbeats, NULL, 
NULL, &avg,
+                    &std_dev, STATS_IN_MSECS);
+
+    heartbeat_counter = lmod_get_state_item(entry->hip_modular_state,
+                                            "heartbeat_update");
+
+    *heartbeat_counter = 0;
+    HIP_DEBUG("heartbeat_counter: %d\n", *heartbeat_counter);
+
+    HIP_DEBUG("\nHeartbeat from %s, RTT %.6f ms,\n%.6f ms mean, "
+              "%.6f ms std dev, packets sent %d recv %d lost %d\n",
+              hit, ((float) rtt / STATS_IN_MSECS), avg, std_dev, 
entry->heartbeats_sent,
+              rcvd_heartbeats, (entry->heartbeats_sent - rcvd_heartbeats));
+
+out_err:
+    return err;
+}
+
+/**
  * This function receives ICMPv6 msgs (heartbeats)
  *
  * @param sockfd to recv from

Other related posts:

  • » [hipl-commit] [tiny] Rev 3725: Moved hip_icmp_statistics to HEARTBEAT module. - Tim Just