add timer cookies for the Hello/TC/MID/HNA timers
authorHannes Gredler <hannes@gredler.at>
Mon, 25 Aug 2008 18:00:14 +0000 (20:00 +0200)
committerHannes Gredler <hannes@gredler.at>
Mon, 25 Aug 2008 18:00:14 +0000 (20:00 +0200)
src/interfaces.c
src/interfaces.h
src/olsr_cookie.h
src/unix/ifnet.c
src/win32/ifnet.c

index 2985e7b..60d6261 100644 (file)
@@ -59,6 +59,14 @@ struct ifchgf
 
 static struct ifchgf *ifchgf_list;
 
+
+/* Some cookies for stats keeping */
+struct olsr_cookie_info *interface_poll_timer_cookie = NULL;
+struct olsr_cookie_info *hello_gen_timer_cookie = NULL;
+struct olsr_cookie_info *tc_gen_timer_cookie = NULL;
+struct olsr_cookie_info *mid_gen_timer_cookie = NULL;
+struct olsr_cookie_info *hna_gen_timer_cookie = NULL;
+
 /**
  *Do initialization of various data needed for
  *network interface management.
@@ -74,6 +82,21 @@ ifinit(void)
   /* Initial values */
   ifnet = NULL;
 
+  /*
+   * Get some cookies for getting stats to ease troubleshooting.
+   */
+  interface_poll_timer_cookie =
+    olsr_alloc_cookie("Interface Polling", OLSR_COOKIE_TYPE_TIMER);
+
+  hello_gen_timer_cookie =
+    olsr_alloc_cookie("Hello Generation", OLSR_COOKIE_TYPE_TIMER);
+  tc_gen_timer_cookie =
+    olsr_alloc_cookie("TC Generation", OLSR_COOKIE_TYPE_TIMER);
+  mid_gen_timer_cookie =
+    olsr_alloc_cookie("MID Generation", OLSR_COOKIE_TYPE_TIMER);
+  hna_gen_timer_cookie =
+    olsr_alloc_cookie("HNA Generation", OLSR_COOKIE_TYPE_TIMER);
+
   OLSR_PRINTF(1, "\n ---- Interface configuration ---- \n\n");
   /* Run trough all interfaces immedeatly */
   for (tmp_if = olsr_cnf->interfaces; tmp_if != NULL; tmp_if = tmp_if->next) {
@@ -87,7 +110,8 @@ ifinit(void)
   
   /* Kick a periodic timer for the network interface update function */
   olsr_start_timer((unsigned int)olsr_cnf->nic_chgs_pollrate * MSEC_PER_SEC, 5,
-                   OLSR_TIMER_PERIODIC, &check_interface_updates, NULL, 0);
+                   OLSR_TIMER_PERIODIC, &check_interface_updates, NULL,
+                   interface_poll_timer_cookie->ci_id);
 
   return (ifnet == NULL) ? 0 : 1;
 }
index 493e9aa..a1f5833 100644 (file)
@@ -219,6 +219,12 @@ add_ifchgf(int (*f)(struct interface *, int));
 int
 del_ifchgf(int (*f)(struct interface *, int));
 
+extern struct olsr_cookie_info *interface_poll_timer_cookie;
+extern struct olsr_cookie_info *hello_gen_timer_cookie;
+extern struct olsr_cookie_info *tc_gen_timer_cookie;
+extern struct olsr_cookie_info *mid_gen_timer_cookie;
+extern struct olsr_cookie_info *hna_gen_timer_cookie;
+
 #endif
 
 /*
index 24a38d1..0595df4 100644 (file)
@@ -44,7 +44,7 @@
 #ifndef _OLSR_COOKIE_H
 #define _OLSR_COOKIE_H
 
-#define COOKIE_ID_MAX  20      /* maximum number of cookies in the system */
+#define COOKIE_ID_MAX  25      /* maximum number of cookies in the system */
 
 typedef enum olsr_cookie_type_ {
   OLSR_COOKIE_TYPE_MIN,
index 4f17f4b..3722e2f 100644 (file)
@@ -623,18 +623,20 @@ add_hemu_if(struct olsr_if *iface)
     olsr_start_timer(iface->cnf->hello_params.emission_interval * MSEC_PER_SEC,
                      HELLO_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_hello : &olsr_output_lq_hello,
-                     ifp, 0);
+                     ifp, hello_gen_timer_cookie->ci_id);
   ifp->tc_gen_timer =
     olsr_start_timer(iface->cnf->tc_params.emission_interval * MSEC_PER_SEC,
                      TC_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_tc : &olsr_output_lq_tc,
-                     ifp, 0);
+                     ifp, tc_gen_timer_cookie->ci_id);
   ifp->mid_gen_timer =
     olsr_start_timer(iface->cnf->mid_params.emission_interval * MSEC_PER_SEC,
-                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, ifp, 0);
+                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, ifp,
+                     mid_gen_timer_cookie->ci_id);
   ifp->hna_gen_timer =
     olsr_start_timer(iface->cnf->hna_params.emission_interval * MSEC_PER_SEC,
-                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, ifp, 0);
+                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, ifp,
+                     hna_gen_timer_cookie->ci_id);
 
   /* Recalculate max topology hold time */
   if(olsr_cnf->max_tc_vtime < iface->cnf->tc_params.emission_interval)
@@ -969,18 +971,20 @@ chk_if_up(struct olsr_if *iface, int debuglvl __attribute__((unused)))
     olsr_start_timer(iface->cnf->hello_params.emission_interval * MSEC_PER_SEC,
                      HELLO_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_hello : &olsr_output_lq_hello,
-                     ifp, 0);
+                     ifp, hello_gen_timer_cookie->ci_id);
   ifp->tc_gen_timer =
     olsr_start_timer(iface->cnf->tc_params.emission_interval * MSEC_PER_SEC,
                      TC_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_tc : &olsr_output_lq_tc,
-                     ifp, 0);
+                     ifp, tc_gen_timer_cookie->ci_id);
   ifp->mid_gen_timer =
     olsr_start_timer(iface->cnf->mid_params.emission_interval * MSEC_PER_SEC,
-                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, ifp, 0);
+                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, ifp,
+                     mid_gen_timer_cookie->ci_id);
   ifp->hna_gen_timer =
     olsr_start_timer(iface->cnf->hna_params.emission_interval * MSEC_PER_SEC,
-                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, ifp, 0);
+                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, ifp,
+                     hna_gen_timer_cookie->ci_id);
 
   /* Recalculate max topology hold time */
   if(olsr_cnf->max_tc_vtime < iface->cnf->tc_params.emission_interval) {
index ee4789f..e2b4a72 100644 (file)
@@ -712,18 +712,20 @@ int add_hemu_if(struct olsr_if *iface)
     olsr_start_timer(iface->cnf->hello_params.emission_interval * MSEC_PER_SEC,
                      HELLO_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_hello : &olsr_output_lq_hello,
-                     ifp, 0);
+                     ifp, hello_gen_timer_cookie->ci_id);
   ifp->tc_gen_timer =
     olsr_start_timer(iface->cnf->tc_params.emission_interval * MSEC_PER_SEC,
                      TC_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_tc : &olsr_output_lq_tc,
-                     ifp, 0);
+                     ifp, tc_gen_timer_cookie->ci_id);
   ifp->mid_gen_timer =
     olsr_start_timer(iface->cnf->mid_params.emission_interval * MSEC_PER_SEC,
-                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, ifp, 0);
+                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, ifp,
+                     mid_gen_timer_cookie->ci_id);
   ifp->hna_gen_timer =
     olsr_start_timer(iface->cnf->hna_params.emission_interval * MSEC_PER_SEC,
-                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, ifp, 0);
+                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, ifp,
+                     hna_gen_timer_cookie->ci_id);
 
   /* Recalculate max topology hold time */
   if(olsr_cnf->max_tc_vtime < iface->cnf->tc_params.emission_interval)
@@ -1011,18 +1013,20 @@ int chk_if_up(struct olsr_if *IntConf, int DebugLevel __attribute__((unused)))
     olsr_start_timer(IntConf->cnf->hello_params.emission_interval * MSEC_PER_SEC,
                      HELLO_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_hello : &olsr_output_lq_hello,
-                     New, 0);
+                     New, hello_gen_timer_cookie->ci_id);
   New->tc_gen_timer =
     olsr_start_timer(IntConf->cnf->tc_params.emission_interval * MSEC_PER_SEC,
                      TC_JITTER, OLSR_TIMER_PERIODIC,
                      olsr_cnf->lq_level == 0 ? &generate_tc : &olsr_output_lq_tc,
-                     New, 0);
+                     New, tc_gen_timer_cookie->ci_id);
   New->mid_gen_timer =
     olsr_start_timer(IntConf->cnf->mid_params.emission_interval * MSEC_PER_SEC,
-                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, New, 0);
+                     MID_JITTER, OLSR_TIMER_PERIODIC, &generate_mid, New,
+                     mid_gen_timer_cookie->ci_id);
   New->hna_gen_timer =
     olsr_start_timer(IntConf->cnf->hna_params.emission_interval * MSEC_PER_SEC,
-                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, New, 0);
+                     HNA_JITTER, OLSR_TIMER_PERIODIC, &generate_hna, New,
+                     hna_gen_timer_cookie->ci_id);
 
   if(olsr_cnf->max_tc_vtime < IntConf->cnf->tc_params.emission_interval)
     olsr_cnf->max_tc_vtime = IntConf->cnf->tc_params.emission_interval;