/** * Init datastructures for maintaining timers. */ void olsr_init_timers(void) { int idx; OLSR_PRINTF(3, "Initializing scheduler.\n"); /* Grab initial timestamp */ if (gettimeofday(&first_tv, NULL)) { olsr_exit("OS clock is not working, have to shut down OLSR", 1); } last_tv = first_tv; now_times = olsr_times(); for (idx = 0; idx < TIMER_WHEEL_SLOTS; idx++) { list_head_init(&timer_wheel[idx]); } /* * Reset the last timer run. */ timer_last_run = now_times; /* Allocate a cookie for the block based memeory manager. */ timer_mem_cookie = olsr_alloc_cookie("timer_entry", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(timer_mem_cookie, sizeof(struct timer_entry)); }
/** * Initialize the routingtree and kernel change queues. */ void olsr_init_routing_table(void) { OLSR_PRINTF(5, "RIB: init routing tree\n"); /* the routing tree */ avl_init(&routingtree, avl_comp_prefix_default); routingtree_version = 0; /* * Get some cookies for memory stats and memory recycling. */ rt_mem_cookie = olsr_alloc_cookie("rt_entry", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(rt_mem_cookie, sizeof(struct rt_entry)); rtp_mem_cookie = olsr_alloc_cookie("rt_path", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(rtp_mem_cookie, sizeof(struct rt_path)); }
/** * Initialize the HNA set */ int olsr_init_hna_set(void) { int idx; for (idx = 0; idx < HASHSIZE; idx++) { hna_set[idx].next = &hna_set[idx]; hna_set[idx].prev = &hna_set[idx]; } hna_net_timer_cookie = olsr_alloc_cookie("HNA Network", OLSR_COOKIE_TYPE_TIMER); hna_net_mem_cookie = olsr_alloc_cookie("hna_net", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(hna_net_mem_cookie, sizeof(struct hna_net)); hna_entry_mem_cookie = olsr_alloc_cookie("hna_entry", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(hna_entry_mem_cookie, sizeof(struct hna_entry)); return 1; }
/** * Initialize the topology set * */ void olsr_init_tc(void) { OLSR_PRINTF(5, "TC: init topo\n"); avl_init(&tc_tree, avl_comp_default); /* * Get some cookies for getting stats to ease troubleshooting. */ tc_edge_gc_timer_cookie = olsr_alloc_cookie("TC edge GC", OLSR_COOKIE_TYPE_TIMER); tc_validity_timer_cookie = olsr_alloc_cookie("TC validity", OLSR_COOKIE_TYPE_TIMER); tc_edge_mem_cookie = olsr_alloc_cookie("tc_edge_entry", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(tc_edge_mem_cookie, sizeof(struct tc_edge_entry) + active_lq_handler->tc_lq_size); tc_mem_cookie = olsr_alloc_cookie("tc_entry", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(tc_mem_cookie, sizeof(struct tc_entry)); /* * Add a TC entry for ourselves. */ tc_myself = olsr_add_tc_entry(&olsr_cnf->main_addr); }
int olsr_os_init_iptunnel(const char * dev) { tunnel_cookie = olsr_alloc_cookie("iptunnel", OLSR_COOKIE_TYPE_MEMORY); olsr_cookie_set_memory_size(tunnel_cookie, sizeof(struct olsr_iptunnel_entry)); avl_init(&tunnel_tree, avl_comp_default); store_iptunnel_state = olsr_if_isup(dev); if (store_iptunnel_state) { return 0; } if (olsr_if_set_state(dev, true)) { return -1; } return olsr_os_ifip(if_nametoindex(dev), &olsr_cnf->main_addr, true); }