]> git.proxmox.com Git - mirror_frr.git/blobdiff - babeld/babeld.c
*: require semicolon after DEFINE_MTYPE & co
[mirror_frr.git] / babeld / babeld.c
index a7a348199879c5ad44157f07ae777129b3206d4c..72080bd7eb48e52b4025155399a033eadaa6b0aa 100644 (file)
@@ -30,6 +30,7 @@ THE SOFTWARE.
 #include "filter.h"
 #include "plist.h"
 #include "lib_errors.h"
+#include "network.h"
 
 #include "babel_main.h"
 #include "babeld.h"
@@ -45,8 +46,8 @@ THE SOFTWARE.
 #include "babel_zebra.h"
 #include "babel_errors.h"
 
-DEFINE_MGROUP(BABELD, "babeld")
-DEFINE_MTYPE_STATIC(BABELD, BABEL, "Babel Structure")
+DEFINE_MGROUP(BABELD, "babeld");
+DEFINE_MTYPE_STATIC(BABELD, BABEL, "Babel Structure");
 
 static int babel_init_routing_process(struct thread *thread);
 static void babel_get_myid(void);
@@ -69,11 +70,14 @@ static time_t expiry_time;
 static time_t source_expiry_time;
 
 /* Babel node structure. */
+static int babel_config_write (struct vty *vty);
 static struct cmd_node cmd_babel_node =
 {
+    .name = "babel",
     .node   = BABEL_NODE,
+    .parent_node = CONFIG_NODE,
     .prompt = "%s(config-router)# ",
-    .vtysh  = 1,
+    .config_write = babel_config_write,
 };
 
 /* print current babel configuration on vty */
@@ -210,7 +214,7 @@ babel_read_protocol (struct thread *thread)
 static int
 babel_init_routing_process(struct thread *thread)
 {
-    myseqno = (random() & 0xFFFF);
+    myseqno = (frr_weak_random() & 0xFFFF);
     babel_get_myid();
     babel_load_state_file();
     debugf(BABEL_DEBUG_COMMON, "My ID is : %s.", format_eui64(myid));
@@ -261,8 +265,7 @@ babel_get_myid(void)
         return;
     }
 
-    flog_err(EC_BABEL_CONFIG,
-             "Warning: couldn't find router id -- using random value.");
+    flog_err(EC_BABEL_CONFIG, "Couldn't find router id -- using random value.");
 
     rc = read_random_bytes(myid, 8);
     if(rc < 0) {
@@ -313,13 +316,9 @@ babel_clean_routing_process(void)
     flush_all_routes();
     babel_interface_close_all();
 
-    /* cancel threads */
-    if (babel_routing_process->t_read != NULL) {
-        thread_cancel(babel_routing_process->t_read);
-    }
-    if (babel_routing_process->t_update != NULL) {
-        thread_cancel(babel_routing_process->t_update);
-    }
+    /* cancel events */
+    thread_cancel(&babel_routing_process->t_read);
+    thread_cancel(&babel_routing_process->t_update);
 
     distribute_list_delete(&babel_routing_process->distribute_ctx);
     XFREE(MTYPE_BABEL, babel_routing_process);
@@ -499,9 +498,7 @@ static void
 babel_set_timer(struct timeval *timeout)
 {
     long msecs = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
-    if (babel_routing_process->t_update != NULL) {
-        thread_cancel(babel_routing_process->t_update);
-    }
+    thread_cancel(&(babel_routing_process->t_update));
     thread_add_timer_msec(master, babel_main_loop, NULL, msecs, &babel_routing_process->t_update);
 }
 
@@ -719,7 +716,7 @@ void
 babeld_quagga_init(void)
 {
 
-    install_node(&cmd_babel_node, &babel_config_write);
+    install_node(&cmd_babel_node);
 
     install_element(CONFIG_NODE, &router_babel_cmd);
     install_element(CONFIG_NODE, &no_router_babel_cmd);