#include <assert.h>#include <stdio.h>#include <stdlib.h>#include "common/avl.h"#include "avl_olsr_comp.h"#include "tc_set.h"#include "olsr.h"#include "lq_packet.h"#include "net_olsr.h"#include "link_set.h"#include "mid_set.h"#include "neighbor_table.h"#include "olsr_logging.h"
Go to the source code of this file.
Functions | |
| static bool | delete_outdated_tc_edges (struct tc_entry *) |
| static void | olsr_expire_tc_entry (void *context) |
| static void | olsr_expire_tc_edge_gc (void *context) |
| static struct tc_entry * | olsr_add_tc_entry (const union olsr_ip_addr *adr) |
| void | olsr_init_tc (void) |
| void | olsr_change_myself_tc (void) |
| void | olsr_delete_tc_entry (struct tc_entry *tc) |
| struct tc_entry * | olsr_lookup_tc_entry (const union olsr_ip_addr *adr) |
| struct tc_entry * | olsr_locate_tc_entry (const union olsr_ip_addr *adr) |
| static char * | olsr_tc_edge_to_string (struct tc_edge_entry *tc_edge) |
| struct tc_edge_entry * | olsr_add_tc_edge_entry (struct tc_entry *tc, const union olsr_ip_addr *addr, uint16_t ansn) |
| static void | internal_delete_tc_edge_entry (struct tc_edge_entry *tc_edge) |
| void | olsr_delete_tc_edge_entry (struct tc_edge_entry *tc_edge) |
| static int | olsr_delete_revoked_tc_edges (struct tc_entry *tc, uint16_t ansn, union olsr_ip_addr *lower_border, union olsr_ip_addr *upper_border) |
| static int | olsr_tc_update_edge (struct tc_entry *tc, uint16_t ansn, const unsigned char **curr, union olsr_ip_addr *neighbor) |
| struct tc_edge_entry * | olsr_lookup_tc_edge (struct tc_entry *tc, const union olsr_ip_addr *edge_addr) |
| void | olsr_print_tc_table (void) |
| static int | olsr_calculate_tc_border (uint8_t lower_border, union olsr_ip_addr *lower_border_ip, uint8_t upper_border, union olsr_ip_addr *upper_border_ip) |
| void | olsr_input_tc (struct olsr_message *msg, struct interface *input_if __attribute__((unused)), union olsr_ip_addr *from_addr, enum duplicate_status status) |
| uint32_t | getRelevantTcCount (void) |
| void | olsr_delete_all_tc_entries (void) |
| static uint8_t | calculate_border_flag (void *lower_border, void *higher_border) |
| uint16_t | get_local_ansn_number (void) |
| void | increase_local_ansn_number (void) |
| static bool | olsr_output_lq_tc_internal (void *ctx __attribute__((unused)), union olsr_ip_addr *nextIp, bool skip) |
| void | olsr_output_lq_tc (void *ctx) |
Variables | |
| struct avl_tree | tc_tree |
| struct tc_entry * | tc_myself = NULL |
| struct olsr_memcookie_info * | tc_mem_cookie = NULL |
| static struct olsr_timer_info * | tc_edge_gc_timer_info = NULL |
| static struct olsr_timer_info * | tc_validity_timer_info = NULL |
| static uint32_t | relevantTcCount = 0 |
| static int | ttl_index = -32 |
| static uint16_t | local_ansn_number = 0 |
| static uint8_t calculate_border_flag | ( | void * | lower_border, | |
| void * | higher_border | |||
| ) | [static] |
Definition at line 911 of file tc_set.c.
References olsr_config::ipsize, and olsr_cnf.
Referenced by olsr_output_lq_tc_internal().
| static bool delete_outdated_tc_edges | ( | struct tc_entry * | tc | ) | [static] |
Delete all destinations that have a lower ANSN.
| tc | the entry to delete edges from |
Definition at line 508 of file tc_set.c.
References tc_edge_entry::ansn, tc_entry::ansn, changes_topology, LOG_TC, OLSR_DEBUG, olsr_delete_tc_edge_entry(), OLSR_FOR_ALL_TC_EDGE_ENTRIES, and SEQNO_GREATER_THAN.
Referenced by olsr_expire_tc_edge_gc().

| uint16_t get_local_ansn_number | ( | void | ) |
Definition at line 940 of file tc_set.c.
References local_ansn_number.
Referenced by olsr_output_lq_tc_internal().
| uint32_t getRelevantTcCount | ( | void | ) |
Definition at line 878 of file tc_set.c.
References relevantTcCount.
| void increase_local_ansn_number | ( | void | ) |
Definition at line 945 of file tc_set.c.
References local_ansn_number.
Referenced by olsr_process_changes().
| static void internal_delete_tc_edge_entry | ( | struct tc_edge_entry * | tc_edge | ) | [static] |
Definition at line 439 of file tc_set.c.
References tc_entry::addr, avl_delete(), avl_tree::count, tc_edge_entry::edge_inv, tc_edge_entry::edge_node, tc_entry::edge_tree, LOG_TC, OLSR_DEBUG, olsr_free_tc_edge_entry(), olsr_ip_to_string(), and tc_edge_entry::tc.
Referenced by olsr_delete_all_tc_entries(), and olsr_delete_tc_edge_entry().

| struct tc_edge_entry* olsr_add_tc_edge_entry | ( | struct tc_entry * | tc, | |
| const union olsr_ip_addr * | addr, | |||
| uint16_t | ansn | |||
| ) | [read] |
Add a new tc_edge_entry to the tc_edge_tree
| (last)adr | address of the entry |
Definition at line 368 of file tc_set.c.
References tc_entry::addr, avl_insert(), tc_edge_entry::edge_inv, tc_entry::edge_tree, LOG_TC, olsr_add_tc_edge_entry(), olsr_add_tc_entry(), olsr_calc_tc_cost(), OLSR_DEBUG, olsr_ip_to_string(), olsr_lookup_tc_edge(), olsr_lookup_tc_entry(), olsr_malloc_tc_edge_entry(), olsr_tc_edge_to_string(), and tc_edge_entry::virtual.
Referenced by olsr_add_nbr_entry(), olsr_add_tc_edge_entry(), olsr_change_myself_tc(), and olsr_tc_update_edge().

| static struct tc_entry* olsr_add_tc_entry | ( | const union olsr_ip_addr * | adr | ) | [static, read] |
Add a new tc_entry to the tc tree
| (last)adr | address of the entry |
Definition at line 87 of file tc_set.c.
References tc_entry::addr, all_zero, avl_comp_default, avl_comp_prefix_default, avl_comp_prefix_origin_default, avl_init(), avl_insert(), tc_entry::edge_tree, tc_entry::hna_seq, tc_entry::hna_tree, olsr_config::ipsize, avl_node::key, LOG_TC, tc_entry::mid_seq, tc_entry::mid_tree, olsr_cnf, OLSR_DEBUG, olsr_insert_routing_table(), olsr_ip_to_string(), olsr_ipcmp(), olsr_memcookie_malloc(), OLSR_RT_ORIGIN_TC, tc_entry::prefix_tree, olsr_config::router_id, tc_entry::tc_seq, tc_tree, and tc_entry::vertex_node.
Referenced by olsr_add_tc_edge_entry(), olsr_change_myself_tc(), olsr_input_tc(), and olsr_locate_tc_entry().

| static int olsr_calculate_tc_border | ( | uint8_t | lower_border, | |
| union olsr_ip_addr * | lower_border_ip, | |||
| uint8_t | upper_border, | |||
| union olsr_ip_addr * | upper_border_ip | |||
| ) | [static] |
Definition at line 714 of file tc_set.c.
References olsr_config::ipsize, olsr_cnf, in6_addr::s6_addr, and olsr_ip_addr::v6.
Referenced by olsr_input_tc().
| void olsr_change_myself_tc | ( | void | ) |
The main ip address has changed. Do the needful.
check if a main ip change destroyed our TC entries
Definition at line 164 of file tc_set.c.
References tc_entry::addr, changes_topology, nbr_entry::nbr_addr, tc_edge_entry::neighbor, olsr_add_tc_edge_entry(), olsr_add_tc_entry(), olsr_cnf, olsr_delete_tc_edge_entry(), olsr_delete_tc_entry(), OLSR_FOR_ALL_NBR_ENTRIES, olsr_ipcmp(), olsr_config::router_id, and nbr_entry::tc_edge.
Referenced by add_interface(), and olsr_calculate_routing_table().

| void olsr_delete_all_tc_entries | ( | void | ) |
Definition at line 884 of file tc_set.c.
References tc_edge_entry::edge_inv, internal_delete_tc_edge_entry(), tc_edge_entry::neighbor, olsr_delete_tc_entry(), OLSR_FOR_ALL_TC_EDGE_ENTRIES, OLSR_FOR_ALL_TC_ENTRIES, and nbr_entry::tc_edge.
Referenced by olsr_shutdown().

| static int olsr_delete_revoked_tc_edges | ( | struct tc_entry * | tc, | |
| uint16_t | ansn, | |||
| union olsr_ip_addr * | lower_border, | |||
| union olsr_ip_addr * | upper_border | |||
| ) | [static] |
Delete all destinations that are inside the borders but not updated in the last tc.
| tc | the entry to delete edges from | |
| ansn | the advertised neighbor set sequence number |
Definition at line 536 of file tc_set.c.
References tc_edge_entry::ansn, avl_comp_default, changes_topology, tc_edge_entry::common_cost, tc_edge_entry::cost, tc_edge_entry::edge_inv, LINK_COST_BROKEN, LOG_TC, OLSR_DEBUG, olsr_delete_tc_edge_entry(), OLSR_FOR_ALL_TC_EDGE_ENTRIES, SEQNO_GREATER_THAN, and tc_edge_entry::T_dest_addr.
Referenced by olsr_input_tc().

| void olsr_delete_tc_edge_entry | ( | struct tc_edge_entry * | tc_edge | ) |
Delete a TC edge entry.
| tc | the TC entry | |
| tc_edge | the TC edge entry |
Definition at line 460 of file tc_set.c.
References changes_topology, tc_edge_entry::edge_inv, internal_delete_tc_edge_entry(), LOG_TC, tc_edge_entry::neighbor, OLSR_DEBUG, olsr_tc_edge_to_string(), olsr_timer_set(), tc_edge_entry::tc, tc_entry::validity_timer, tc_entry::virtual, and tc_edge_entry::virtual.
Referenced by delete_outdated_tc_edges(), olsr_change_myself_tc(), olsr_delete_nbr_entry(), olsr_delete_revoked_tc_edges(), and olsr_delete_tc_entry().

| void olsr_delete_tc_entry | ( | struct tc_entry * | tc | ) |
Attempts to delete a tc entry. This will work unless there are virtual edges left that cannot be removed
| entry | the TC entry to delete |
Definition at line 228 of file tc_set.c.
References tc_entry::addr, tc_entry::ansn, avl_delete(), avl_tree::count, tc_entry::edge_gc_timer, tc_entry::edge_tree, LOG_TC, OLSR_DEBUG, olsr_delete_rt_path(), olsr_delete_tc_edge_entry(), olsr_flush_hna_nets(), olsr_flush_mid_entries(), OLSR_FOR_ALL_PREFIX_ENTRIES, OLSR_FOR_ALL_TC_EDGE_ENTRIES, olsr_ip_to_string(), olsr_memcookie_free(), olsr_timer_stop(), tc_tree, tc_entry::validity_timer, tc_entry::vertex_node, and tc_entry::virtual.
Referenced by olsr_change_myself_tc(), olsr_delete_all_tc_entries(), olsr_expire_tc_entry(), and olsr_flush_tc_duplicates().

| static void olsr_expire_tc_edge_gc | ( | void * | context | ) | [static] |
Wrapper for the timer callback. Does the garbage collection of older ansn entries after no edge addition to the TC entry has happened for OLSR_TC_EDGE_GC_TIME.
Definition at line 345 of file tc_set.c.
References tc_entry::addr, changes_topology, delete_outdated_tc_edges(), tc_entry::edge_gc_timer, LOG_TC, OLSR_DEBUG, and olsr_ip_to_string().
Referenced by olsr_init_tc().

| static void olsr_expire_tc_entry | ( | void * | context | ) | [static] |
Wrapper for the timer callback. A TC entry has not been refreshed in time. Remove it from the link-state database.
Definition at line 324 of file tc_set.c.
References tc_entry::addr, changes_topology, LOG_TC, OLSR_DEBUG, olsr_delete_tc_entry(), olsr_ip_to_string(), and tc_entry::validity_timer.
Referenced by olsr_init_tc().

| void olsr_init_tc | ( | void | ) |
Initialize the topology set
Definition at line 141 of file tc_set.c.
References avl_comp_default, avl_init(), local_ansn_number, LOG_TC, olsr_expire_tc_edge_gc(), olsr_expire_tc_entry(), OLSR_INFO, olsr_memcookie_add(), olsr_timer_add(), random(), and tc_tree.
Referenced by main().

| void olsr_input_tc | ( | struct olsr_message * | msg, | |
| struct interface *input_if | __attribute__(unused), | |||
| union olsr_ip_addr * | from_addr, | |||
| enum duplicate_status | status | |||
| ) |
Definition at line 761 of file tc_set.c.
References tc_entry::ansn, changes_topology, check_neighbor_link(), tc_entry::edge_gc_timer, olsr_message::end, olsr_message::hopcnt, olsr_config::ipsize, LOG_TC, tc_entry::msg_hops, olsr_add_tc_entry(), olsr_calculate_tc_border(), olsr_cnf, OLSR_DEBUG, olsr_delete_revoked_tc_edges(), olsr_get_TC_MessageId(), olsr_ip_to_string(), olsr_lookup_tc_entry(), olsr_seqno_diff(), olsr_sizeof_TCLQ(), OLSR_TC_EDGE_GC_JITTER, OLSR_TC_EDGE_GC_TIME, olsr_tc_update_edge(), OLSR_TC_VTIME_JITTER, olsr_timer_set(), olsr_message::originator, olsr_message::payload, pkt_get_u16(), pkt_get_u8(), relevantTcCount, RESET_SEQNO_OLSR_MESSAGE, olsr_message::seqno, SYM_LINK, tc_entry::tc_seq, olsr_message::type, tc_entry::validity_timer, tc_entry::virtual, and olsr_message::vtime.
Referenced by olsr_deinit_package_process(), and olsr_init_package_process().

| struct tc_entry* olsr_locate_tc_entry | ( | const union olsr_ip_addr * | adr | ) | [read] |
Definition at line 290 of file tc_set.c.
References olsr_add_tc_entry(), and olsr_lookup_tc_entry().
Referenced by olsr_input_hna(), olsr_input_mid(), olsr_insert_mid_entry(), olsr_insert_routing_table(), and olsr_update_hna_entry().

| struct tc_edge_entry* olsr_lookup_tc_edge | ( | struct tc_entry * | tc, | |
| const union olsr_ip_addr * | edge_addr | |||
| ) | [read] |
Lookup an edge hanging off a TC entry.
| entry | the entry to check | |
| dst_addr | the destination address to check for |
Definition at line 645 of file tc_set.c.
References avl_find_element, tc_edge_entry::edge_node, and tc_entry::edge_tree.
Referenced by FindNeighbors(), olsr_add_nbr_entry(), olsr_add_tc_edge_entry(), and olsr_tc_update_edge().
| struct tc_entry* olsr_lookup_tc_entry | ( | const union olsr_ip_addr * | adr | ) | [read] |
Look up a entry from the TC tree based on address
| adr | the address to look for |
Definition at line 278 of file tc_set.c.
References avl_find_element, tc_tree, and tc_entry::vertex_node.
Referenced by FindNeighbors(), olsr_add_tc_edge_entry(), olsr_delete_routing_table(), olsr_flush_tc_duplicates(), olsr_input_tc(), olsr_locate_tc_entry(), and write_hosts_file().
| void olsr_output_lq_tc | ( | void * | ctx | ) |
Definition at line 1089 of file tc_set.c.
References olsr_output_lq_tc_internal().
Referenced by main().

| static bool olsr_output_lq_tc_internal | ( | void *ctx | __attribute__(unused), | |
| union olsr_ip_addr * | nextIp, | |||
| bool | skip | |||
| ) | [static] |
Definition at line 950 of file tc_set.c.
References __attribute__(), ARRAYSIZE, avl_prev_element, calculate_border_flag(), get_best_link_to_neighbor_ip(), get_local_ansn_number(), get_msg_seqno(), olsr_config::ipsize, nbr_entry::is_mpr, nbr_entry::is_sym, LINK_COST_BROKEN, link_entry::linkcost, LOG_PACKET_CREATION, LOG_TC, olsr_config::lq_fish, MAX_TTL, MAXMESSAGESIZE, nbr_entry::mprs_count, nbr_entry::nbr_addr, nbr_entry::nbr_node, net_outbuffer_bytes_left(), net_outbuffer_push(), net_output(), olsr_cnf, OLSR_DEBUG, OLSR_FOR_ALL_INTERFACES, OLSR_FOR_ALL_NBR_ENTRIES, olsr_get_TC_MessageId(), OLSR_HEADERSIZE, OLSR_INFO, olsr_ipcmp(), olsr_serialize_tc_lq(), olsr_sizeof_TCLQ(), pkt_put_ipaddress(), pkt_put_reltime(), pkt_put_u16(), pkt_put_u8(), olsr_config::router_id, set_buffer_timer(), olsr_config::tc_params, olsr_config::tc_redundancy, ttl_index, and olsr_msg_params::validity_time.
Referenced by olsr_output_lq_tc().

| void olsr_print_tc_table | ( | void | ) |
Print the topology table to stdout
Definition at line 657 of file tc_set.c.
References tc_entry::addr, tc_edge_entry::ansn, millitxt_buf::buf, tc_edge_entry::common_cost, tc_edge_entry::cost, olsr_config::ip_version, LOG_TC, LQTEXT_MAXLENGTH, olsr_clock_getRelative(), olsr_clock_getWallclockString(), olsr_clock_to_string(), olsr_cnf, OLSR_FOR_ALL_TC_EDGE_ENTRIES, OLSR_FOR_ALL_TC_ENTRIES, olsr_get_linkcost_text(), olsr_get_linklabel(), olsr_get_linklabel_maxlength(), OLSR_INFO, OLSR_INFO_NH, olsr_ip_to_string(), tc_edge_entry::T_dest_addr, olsr_timer_entry::timer_clock, tc_entry::validity_timer, and tc_edge_entry::virtual.
Referenced by olsr_process_changes().

| static char* olsr_tc_edge_to_string | ( | struct tc_edge_entry * | tc_edge | ) | [static] |
Format tc_edge contents into a buffer.
Definition at line 302 of file tc_set.c.
References tc_entry::addr, tc_edge_entry::ansn, tc_edge_entry::cost, LQTEXT_MAXLENGTH, olsr_get_linkcost_text(), olsr_ip_to_string(), tc_edge_entry::T_dest_addr, and tc_edge_entry::tc.
Referenced by olsr_add_tc_edge_entry(), olsr_delete_tc_edge_entry(), and olsr_tc_update_edge().

| static int olsr_tc_update_edge | ( | struct tc_entry * | tc, | |
| uint16_t | ansn, | |||
| const unsigned char ** | curr, | |||
| union olsr_ip_addr * | neighbor | |||
| ) | [static] |
Update an edge registered on an entry. Creates new edge-entries if not registered. Bases update on a received TC message
| entry | the TC entry to check the TC edge entry in the packet |
Definition at line 583 of file tc_set.c.
References tc_edge_entry::ansn, tc_edge_entry::common_cost, tc_edge_entry::cost, tc_edge_entry::edge_inv, LOG_TC, olsr_add_tc_edge_entry(), olsr_calc_tc_cost(), OLSR_DEBUG, olsr_deserialize_tc_lq_pair(), olsr_lookup_tc_edge(), olsr_tc_edge_to_string(), olsr_validate_address(), pkt_get_ipaddress(), tc_entry::virtual, and tc_edge_entry::virtual.
Referenced by olsr_input_tc().

uint16_t local_ansn_number = 0 [static] |
Definition at line 78 of file tc_set.c.
Referenced by get_local_ansn_number(), increase_local_ansn_number(), and olsr_init_tc().
uint32_t relevantTcCount = 0 [static] |
Definition at line 73 of file tc_set.c.
Referenced by getRelevantTcCount(), and olsr_input_tc().
struct olsr_timer_info* tc_edge_gc_timer_info = NULL [static] |
| struct olsr_memcookie_info* tc_mem_cookie = NULL |
Definition at line 66 of file tc_set.c.
Referenced by olsr_add_nbr_entry(), and olsr_calculate_routing_table().
Definition at line 65 of file tc_set.c.
Referenced by olsr_add_tc_entry(), olsr_delete_tc_entry(), olsr_init_tc(), and olsr_lookup_tc_entry().
struct olsr_timer_info* tc_validity_timer_info = NULL [static] |
int ttl_index = -32 [static] |
Definition at line 76 of file tc_set.c.
Referenced by olsr_output_lq_tc_internal().
1.6.3