#include <assert.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "common/avl.h"#include "common/avl_comp.h"#include "olsr_clock.h"#include "olsr_logging.h"#include "olsr_memcookie.h"#include "olsr_timer.h"
Go to the source code of this file.
Functions | |
| static uint32_t | calc_jitter (unsigned int rel_time, uint8_t jitter_pct, unsigned int random_val) |
| void | olsr_timer_init (void) |
| void | olsr_timer_cleanup (void) |
| struct olsr_timer_info * | olsr_timer_add (const char *name, timer_cb_func callback, bool periodic) |
| void | olsr_timer_remove (struct olsr_timer_info *info) |
| struct olsr_timer_entry * | olsr_timer_start (unsigned int rel_time, uint8_t jitter_pct, void *context, struct olsr_timer_info *ti) |
| void | olsr_timer_stop (struct olsr_timer_entry *timer) |
| void | olsr_timer_change (struct olsr_timer_entry *timer, unsigned int rel_time, uint8_t jitter_pct) |
| void | olsr_timer_set (struct olsr_timer_entry **timer_ptr, unsigned int rel_time, uint8_t jitter_pct, void *context, struct olsr_timer_info *ti) |
| void | olsr_timer_walk (void) |
Variables | |
| static struct list_entity | timer_wheel [TIMER_WHEEL_SLOTS] |
| static uint32_t | timer_last_run |
| struct list_entity | timerinfo_list |
| static struct olsr_memcookie_info * | timer_mem_cookie = NULL |
| static struct olsr_memcookie_info * | timerinfo_cookie = NULL |
| static uint32_t calc_jitter | ( | unsigned int | rel_time, | |
| uint8_t | jitter_pct, | |||
| unsigned int | random_val | |||
| ) | [static] |
Decrement a relative timer by a random number range.
| the | relative timer expressed in units of milliseconds. | |
| the | jitter in percent | |
| cached | result of random() at system init. |
Definition at line 347 of file olsr_timer.c.
References LOG_TIMER, olsr_clock_getAbsolute(), and OLSR_DEBUG.
Referenced by olsr_timer_change(), and olsr_timer_start().

| struct olsr_timer_info* olsr_timer_add | ( | const char * | name, | |
| timer_cb_func | callback, | |||
| bool | periodic | |||
| ) | [read] |
Add a new group of timers to the scheduler
| name | ||
| callback | timer event function | |
| periodic | true if the timer is periodic, false otherwise |
Definition at line 140 of file olsr_timer.c.
References olsr_timer_info::callback, list_add_tail(), olsr_timer_info::name, olsr_timer_info::node, olsr_memcookie_malloc(), olsr_timer_info::periodic, and timerinfo_list.
Referenced by arproaming_init(), debuginfo_enable(), init_interfaces(), init_net(), InitOBAMP(), lq_etxff_initialize(), main(), mapwrite_init(), name_constructor(), olsr_com_init(), olsr_com_init_txt(), olsr_init_duplicate_set(), olsr_init_hna_set(), olsr_init_link_set(), olsr_init_mid_set(), olsr_init_neighbor_table(), olsr_init_spf(), olsr_init_tc(), olsr_init_willingness(), olsrd_plugin_init(), and secure_plugin_init().

| void olsr_timer_change | ( | struct olsr_timer_entry * | timer, | |
| unsigned int | rel_time, | |||
| uint8_t | jitter_pct | |||
| ) |
Change a olsr_timer_entry.
| olsr_timer_entry | to be changed. | |
| new | relative time expressed in units of milliseconds. | |
| new | jitter expressed in percent. |
Definition at line 276 of file olsr_timer.c.
References calc_jitter(), list_add_before(), list_remove(), LOG_TIMER, olsr_timer_info::name, olsr_clock_toClockString(), OLSR_DEBUG, olsr_timer_info::periodic, olsr_timer_entry::timer_cb_context, olsr_timer_entry::timer_clock, olsr_timer_entry::timer_info, olsr_timer_entry::timer_jitter_pct, olsr_timer_entry::timer_list, olsr_timer_entry::timer_period, olsr_timer_entry::timer_random, timer_wheel, and TIMER_WHEEL_MASK.
Referenced by olsr_com_parse_txt(), olsr_expire_link_loss_timer(), olsr_is_duplicate_message(), olsr_link_nbr_nbr2(), olsr_timer_set(), and olsr_timer_walk().

| void olsr_timer_cleanup | ( | void | ) |
Cleanup timer scheduler, this stops and deletes all timers
Definition at line 97 of file olsr_timer.c.
References list_first_element, list_is_empty(), list_remove(), olsr_timer_info::name, list_entity::next, olsr_timer_info::node, OLSR_FOR_ALL_TIMERS, olsr_memcookie_free(), olsr_memcookie_remove(), olsr_timer_stop(), list_entity::prev, olsr_timer_entry::timer_list, timer_wheel, TIMER_WHEEL_MASK, TIMER_WHEEL_SLOTS, and timerinfo_list.
Referenced by olsr_shutdown().

| void olsr_timer_init | ( | void | ) |
Init datastructures for maintaining timers.
Definition at line 70 of file olsr_timer.c.
References list_init_head(), LOG_SCHEDULER, olsr_clock_getNow(), OLSR_INFO, olsr_memcookie_add(), timer_last_run, timer_wheel, TIMER_WHEEL_SLOTS, and timerinfo_list.
Referenced by main().

| void olsr_timer_remove | ( | struct olsr_timer_info * | info | ) |
Removes a group of timers from the scheduler All pointers to timers of this timer_info will be invalid after this.
| info | pointer to timer info |
Definition at line 158 of file olsr_timer.c.
References list_for_each_element_safe, list_remove(), olsr_timer_info::name, olsr_timer_info::node, olsr_memcookie_free(), olsr_timer_stop(), olsr_timer_entry::timer_info, olsr_timer_entry::timer_list, timer_wheel, and TIMER_WHEEL_SLOTS.

| void olsr_timer_set | ( | struct olsr_timer_entry ** | timer_ptr, | |
| unsigned int | rel_time, | |||
| uint8_t | jitter_pct, | |||
| void * | context, | |||
| struct olsr_timer_info * | ti | |||
| ) |
This is the one stop shop for all sort of timer manipulation. Depending on the passed in parameters a new timer is started, or an existing timer is started or an existing timer is terminated.
| timer_ptr | pointer to timer_entry pointer | |
| rel_time | time until the new timer should fire, 0 to stop timer | |
| jitter_pct | jitter of timer in percent | |
| context | context pointer of timer | |
| ti | timer_info of timer |
Definition at line 319 of file olsr_timer.c.
References olsr_timer_change(), olsr_timer_start(), and olsr_timer_stop().
Referenced by add_link_entry(), insert_new_name_in_list(), olsr_calculate_routing_table(), olsr_delete_tc_edge_entry(), olsr_input_tc(), olsr_set_link_timer(), olsr_set_mid_timer(), olsr_update_hna_entry(), olsr_update_packet_loss(), and update_link_entry().

| struct olsr_timer_entry* olsr_timer_start | ( | unsigned int | rel_time, | |
| uint8_t | jitter_pct, | |||
| void * | context, | |||
| struct olsr_timer_info * | ti | |||
| ) | [read] |
Start a new timer.
| relative | time expressed in milliseconds | |
| jitter | expressed in percent | |
| timer | callback function | |
| context | for the callback function |
Definition at line 187 of file olsr_timer.c.
References calc_jitter(), olsr_timer_info::changes, list_add_before(), LOG_TIMER, olsr_timer_info::name, olsr_clock_toClockString(), OLSR_DEBUG, olsr_memcookie_malloc(), olsr_timer_info::periodic, random(), olsr_timer_entry::timer_cb_context, olsr_timer_entry::timer_clock, olsr_timer_entry::timer_info, olsr_timer_entry::timer_jitter_pct, olsr_timer_entry::timer_list, olsr_timer_entry::timer_period, olsr_timer_entry::timer_random, olsr_timer_entry::timer_running, timer_wheel, TIMER_WHEEL_MASK, and olsr_timer_info::usage.
Referenced by add_interface(), arproaming_init(), check_for_route(), debuginfo_enable(), init_interfaces(), InitOBAMP(), lq_etxff_initialize(), main(), mapwrite_init(), name_init(), olsr_com_parse_request(), olsr_init_willingness(), olsr_is_duplicate_message(), olsr_link_nbr_nbr2(), olsr_start_write_file_timer(), olsr_timer_set(), olsr_txtcmd_repeat(), olsrd_plugin_init(), secure_plugin_init(), and set_buffer_timer().

| void olsr_timer_stop | ( | struct olsr_timer_entry * | timer | ) |
Delete a timer.
| the | olsr_timer_entry that shall be removed |
Definition at line 240 of file olsr_timer.c.
References olsr_timer_info::changes, list_remove(), LOG_TIMER, olsr_timer_info::name, list_entity::next, OLSR_DEBUG, olsr_memcookie_free(), list_entity::prev, olsr_timer_entry::timer_cb_context, olsr_timer_entry::timer_in_callback, olsr_timer_entry::timer_info, olsr_timer_entry::timer_list, olsr_timer_entry::timer_running, and olsr_timer_info::usage.
Referenced by arproaming_exit(), check_ping_result(), internal_delete_nbr_con(), lq_etxff_deinitialize(), main(), name_destructor(), olsr_com_parse_connection(), olsr_delete_duplicate_entry(), olsr_delete_hna_net(), olsr_delete_link_entry(), olsr_delete_mid_entry(), olsr_delete_tc_entry(), olsr_namesvc_delete_db_entry(), olsr_timer_cleanup(), olsr_timer_remove(), olsr_timer_set(), olsr_timer_walk(), olsr_txt_repeat_stophandler(), remove_interface(), and update_link_entry().

| void olsr_timer_walk | ( | void | ) |
Walk through the timer list and check if any timer is ready to fire. Callback the provided function with the context pointer.
Definition at line 375 of file olsr_timer.c.
References olsr_timer_info::callback, olsr_timer_info::changes, olsr_memcookie_info::ci_usage, list_add_after(), list_first_element, list_init_head(), list_is_empty(), list_merge(), list_remove(), LOG_TIMER, olsr_timer_info::name, olsr_clock_getNow(), olsr_clock_getWallclockString(), olsr_clock_isPast(), OLSR_DEBUG, olsr_memcookie_free(), olsr_timer_change(), olsr_timer_stop(), random(), olsr_timer_entry::timer_cb_context, olsr_timer_entry::timer_clock, olsr_timer_entry::timer_in_callback, olsr_timer_entry::timer_info, olsr_timer_entry::timer_jitter_pct, timer_last_run, olsr_timer_entry::timer_list, olsr_timer_entry::timer_period, olsr_timer_entry::timer_random, olsr_timer_entry::timer_running, timer_wheel, TIMER_WHEEL_MASK, and TIMER_WHEEL_SLOTS.
Referenced by main().

uint32_t timer_last_run [static] |
Definition at line 56 of file olsr_timer.c.
Referenced by olsr_timer_init(), and olsr_timer_walk().
struct olsr_memcookie_info* timer_mem_cookie = NULL [static] |
Definition at line 60 of file olsr_timer.c.
struct list_entity timer_wheel[TIMER_WHEEL_SLOTS] [static] |
Definition at line 55 of file olsr_timer.c.
Referenced by olsr_timer_change(), olsr_timer_cleanup(), olsr_timer_init(), olsr_timer_remove(), olsr_timer_start(), and olsr_timer_walk().
struct olsr_memcookie_info* timerinfo_cookie = NULL [static] |
Definition at line 61 of file olsr_timer.c.
| struct list_entity timerinfo_list |
Definition at line 59 of file olsr_timer.c.
Referenced by olsr_timer_add(), olsr_timer_cleanup(), and olsr_timer_init().
1.6.3