#include "common/avl.h"#include "common/string.h"#include "defs.h"#include "avl_olsr_comp.h"#include "interfaces.h"#include "olsr_timer.h"#include "olsr_socket.h"#include "olsr.h"#include "parser.h"#include "net_olsr.h"#include "ipcalc.h"#include "olsr_logging.h"#include "os_net.h"#include <assert.h>#include <sys/time.h>#include <sys/select.h>#include "olsr_types.h"#include <signal.h>#include <unistd.h>

Go to the source code of this file.
| #define BUFSPACE (127*1024) |
Definition at line 61 of file interfaces.c.
Referenced by add_interface().
| void add_ifchgf | ( | ifchg_cb_func | f | ) |
Add an ifchange function. These functions are called on all (non-initial) changes in the interface set.
Definition at line 525 of file interfaces.c.
References ifchgf::function, ifchgf::next, and olsr_malloc().
Referenced by olsrd_plugin_init().

| struct interface* add_interface | ( | struct olsr_if_config * | iface | ) | [read] |
Definition at line 184 of file interfaces.c.
References all_zero, BUFSPACE, olsr_if_config::cnf, olsr_msg_params::emission_interval, olsr_socket_entry::fd, interface::hello_gen_timer, interface::hello_interval, HELLO_JITTER, olsr_if_options::hello_params, interface::hello_validity, interface::if_cfg, IFCHG_IF_ADD, interface::int_multicast, interface::int_name, interface::int_node, olsr_if_config::interf, interface_head, interface::ip_addr, olsr_config::ip_version, list_add_before(), lock_interface(), LOG_INTERFACE, olsr_if_options::mode, interface::mode, olsr_if_config::name, net_add_buffer(), olsr_change_myself_tc(), olsr_cnf, OLSR_ERROR, olsr_exit(), OLSR_INFO, olsr_input(), olsr_ip_to_string(), olsr_ipcmp(), olsr_memcookie_free(), olsr_memcookie_malloc(), olsr_config::olsr_port, interface::olsr_seqnum, interface::olsr_socket, olsr_socket_add(), OLSR_SOCKET_READ, olsr_timer_start(), os_getsocket46(), os_init_interface(), os_socket_set_olsr_options(), random(), olsr_config::router_id, run_ifchg_cbs(), interface::send_socket_fd, set_buffer_timer(), and olsr_msg_params::validity_time.
Referenced by check_interface_updates(), and init_interfaces().

| static void add_lost_interface_ip | ( | union olsr_ip_addr * | ip, | |
| uint32_t | hello_timeout | |||
| ) | [static] |
Definition at line 141 of file interfaces.c.
References avl_insert(), interface_lost_tree, LOG_INTERFACE, olsr_clock_getAbsolute(), OLSR_DEBUG, olsr_ip_to_string(), and olsr_memcookie_malloc().
Referenced by remove_interface().

| static void check_interface_updates | ( | void *foo | __attribute__(unused) | ) | [static] |
Callback function for periodic check of interface parameters.
Definition at line 273 of file interfaces.c.
References add_interface(), olsr_if_options::autodetect_chg, chk_if_changed(), olsr_if_config::cnf, get_lost_interface_ip(), olsr_config::if_configs, olsr_if_config::interf, interface::ip_addr, LOG_INTERFACE, olsr_if_config::name, olsr_if_config::next, olsr_clock_isPast(), olsr_cnf, OLSR_DEBUG, OLSR_FOR_ALL_LOSTIF_ENTRIES, remove_lost_interface_ip(), and interface_lost::valid_until.

| static void check_interface_updates | ( | void * | ) | [static] |
Referenced by init_interfaces().
| void destroy_interfaces | ( | void | ) |
Definition at line 170 of file interfaces.c.
References OLSR_FOR_ALL_INTERFACES, OLSR_FOR_ALL_LOSTIF_ENTRIES, remove_interface(), and remove_lost_interface_ip().
Referenced by olsr_shutdown().

| static struct interface_lost* get_lost_interface_ip | ( | union olsr_ip_addr * | ip | ) | [static, read] |
Definition at line 157 of file interfaces.c.
References avl_find_element, interface_lost_tree, and interface_lost::node.
Referenced by check_interface_updates(), and is_lost_interface_ip().
| struct interface* if_ifwithaddr | ( | const union olsr_ip_addr * | addr | ) | [read] |
Find the local interface with a given address.
| addr | the address to check. |
Definition at line 392 of file interfaces.c.
References interface::ip_addr, OLSR_FOR_ALL_INTERFACES, and olsr_ipcmp().
Referenced by BmfEncapsulationPacketReceived(), CreateBmfNetworkInterfaces(), FindNeighbors(), olsr_input(), os_init_interface(), parse_challenge(), parse_cres(), parse_rres(), process_message_neighbors(), and set_loss_link_multiplier().

| struct interface* if_ifwithindex | ( | const int | if_index | ) | [read] |
Find the interface with a given interface index.
| iif_index | of the interface to find. |
Definition at line 462 of file interfaces.c.
References interface::if_index, and OLSR_FOR_ALL_INTERFACES.
Referenced by if_ifwithindex_name().
| const char* if_ifwithindex_name | ( | const int | if_index | ) |
Get an interface name for a given interface index
| iif_index | of the interface to find. |
Definition at line 481 of file interfaces.c.
References if_ifwithindex(), and interface::int_name.
Referenced by add_del_route(), and olsr_new_netlink_route().

| struct interface* if_ifwithname | ( | const char * | if_name | ) | [read] |
Find the interface with a given label.
| if_name | the label of the interface to find. |
Definition at line 440 of file interfaces.c.
References interface::int_name, and OLSR_FOR_ALL_INTERFACES.
| struct interface* if_ifwithsock | ( | int | fd | ) | [read] |
Find the interface with a given number.
| nr | the number of the interface to find. |
Definition at line 415 of file interfaces.c.
References olsr_socket_entry::fd, OLSR_FOR_ALL_INTERFACES, interface::olsr_socket, and interface::send_socket_fd.
Referenced by olsr_input(), os_recvfrom(), and os_sendto().
| bool init_interfaces | ( | void | ) |
Do initialization of various data needed for network interface management. This function also tries to set up the given interfaces.
Definition at line 98 of file interfaces.c.
References add_interface(), avl_comp_default, avl_init(), check_interface_updates(), generate_hello(), olsr_config::if_configs, interface_head, interface_lost_tree, list_init_head(), list_is_empty(), LOG_INTERFACE, olsr_if_config::next, olsr_config::nic_chgs_pollrate, olsr_cnf, OLSR_INFO, olsr_memcookie_add(), olsr_timer_add(), and olsr_timer_start().
Referenced by main().

| bool is_lost_interface_ip | ( | union olsr_ip_addr * | ip | ) |
Definition at line 165 of file interfaces.c.
References get_lost_interface_ip().
Referenced by deserialize_hello().

| void lock_interface | ( | struct interface * | ifp | ) |
Lock an interface.
Definition at line 491 of file interfaces.c.
References interface::refcount.
Referenced by add_interface(), add_link_entry(), olsr_add_route(), and olsr_update_rt_path().
| void remove_interface | ( | struct interface * | ifp | ) |
Remove and cleanup a physical interface.
Definition at line 312 of file interfaces.c.
References add_lost_interface_ip(), olsr_config::allow_no_interfaces, interface::buffer_hold_timer, olsr_socket_entry::fd, interface::hello_gen_timer, interface::hello_validity, interface::if_cfg, IFCHG_IF_REMOVE, interface::int_name, interface::int_node, olsr_if_config::interf, interface_head, interface::ip_addr, list_is_empty(), list_remove(), LOG_INTERFACE, net_remove_buffer(), olsr_cnf, olsr_delete_link_entry_by_if(), OLSR_ERROR, olsr_exit(), OLSR_INFO, interface::olsr_socket, olsr_socket_remove(), olsr_timer_stop(), os_cleanup_interface(), os_close(), run_ifchg_cbs(), interface::send_socket_fd, and unlock_interface().
Referenced by chk_if_changed(), and destroy_interfaces().

| static void remove_lost_interface_ip | ( | struct interface_lost * | lost | ) | [static] |
Definition at line 130 of file interfaces.c.
References avl_delete(), interface_lost_tree, interface_lost::ip, LOG_INTERFACE, interface_lost::node, OLSR_DEBUG, olsr_ip_to_string(), and olsr_memcookie_free().
Referenced by check_interface_updates(), and destroy_interfaces().

| void run_ifchg_cbs | ( | struct interface * | ifp, | |
| int | flag | |||
| ) |
Definition at line 376 of file interfaces.c.
References ifchgf::function, and ifchgf::next.
Referenced by add_interface(), chk_if_changed(), and remove_interface().
| void unlock_interface | ( | struct interface * | ifp | ) |
Unlock an interface and free it if the refcount went down to zero.
Definition at line 502 of file interfaces.c.
References interface::int_name, interface::int_node, list_node_added(), olsr_memcookie_free(), and interface::refcount.
Referenced by olsr_del_route(), olsr_delete_link_entry(), olsr_delete_rt_path(), olsr_update_rt_path(), and remove_interface().

struct olsr_timer_info* hello_gen_timerinfo = NULL [static] |
Definition at line 87 of file interfaces.c.
struct ifchgf* ifchgf_list = NULL [static] |
Definition at line 80 of file interfaces.c.
| struct list_entity interface_head |
Definition at line 69 of file interfaces.c.
Referenced by add_interface(), init_interfaces(), and remove_interface().
struct olsr_memcookie_info* interface_lost_mem_cookie = NULL [static] |
Definition at line 84 of file interfaces.c.
| struct avl_tree interface_lost_tree |
Definition at line 72 of file interfaces.c.
Referenced by add_lost_interface_ip(), get_lost_interface_ip(), init_interfaces(), and remove_lost_interface_ip().
struct olsr_memcookie_info* interface_mem_cookie = NULL [static] |
Definition at line 83 of file interfaces.c.
| const char* INTERFACE_MODE_NAMES[] |
{
"mesh",
"ether"
}
Definition at line 63 of file interfaces.c.
Referenced by parse_cfg_interface().
struct olsr_timer_info* interface_poll_timerinfo = NULL [static] |
Definition at line 86 of file interfaces.c.
1.6.3