2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004, Andreas TÃ
\83¸nnesen(andreto@olsr.org)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of olsr.org, olsrd nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * Visit http://www.olsr.org for more information.
35 * If you find this software useful feel free to make a donation
36 * to the project. For more information see the website or contact
37 * the copyright holders.
43 * Link sensing database for the OLSR routing daemon
49 #include "lq_plugin.h"
51 #include "common/list.h"
53 #define MID_ALIAS_HACK_VTIME 10.0
57 union olsr_ip_addr local_iface_addr;
58 union olsr_ip_addr neighbor_iface_addr;
59 const struct interface *inter;
61 struct timer_entry *link_timer;
62 struct timer_entry *link_sym_timer;
65 struct neighbor_entry *neighbor;
66 olsr_u8_t prev_status;
73 clock_t L_LOST_LINK_time;
74 struct timer_entry *link_hello_timer; /* When we should receive a new HELLO */
76 olsr_bool olsr_seqno_valid;
77 olsr_u16_t olsr_seqno;
82 double loss_hello_int;
83 struct timer_entry *link_loss_timer;
85 float loss_link_multiplier; // user defined multiplies for link quality
88 olsr_linkcost linkcost;
90 struct list_node link_list; /* double linked list of all link entries */
94 /* inline to recast from link_list back to link_entry */
95 LISTNODE2STRUCT(list2link, struct link_entry, link_list);
97 #define OLSR_LINK_JITTER 5 /* percent */
98 #define OLSR_LINK_HELLO_JITTER 0 /* percent jitter */
99 #define OLSR_LINK_SYM_JITTER 0 /* percent jitter */
100 #define OLSR_LINK_LOSS_JITTER 0 /* percent jitter */
102 /* deletion safe macro for link entry traversal */
103 #define OLSR_FOR_ALL_LINK_ENTRIES(link) \
105 struct list_node *link_head_node, *link_node, *next_link_node; \
106 link_head_node = &link_entry_head; \
107 for (link_node = link_head_node->next; \
108 link_node != link_head_node; link_node = next_link_node) { \
109 next_link_node = link_node->next; \
110 link = list2link(link_node);
111 #define OLSR_FOR_ALL_LINK_ENTRIES_END(link) }}
114 extern struct list_node link_entry_head;
115 extern olsr_bool link_changes;
117 /* Function prototypes */
119 void olsr_set_link_timer(struct link_entry *, unsigned int );
120 void olsr_init_link_set(void);
121 void olsr_delete_link_entry_by_ip(const union olsr_ip_addr *);
122 void olsr_expire_link_hello_timer(void *);
123 void olsr_update_packet_loss_worker(struct link_entry *, olsr_bool);
124 void signal_link_changes(olsr_bool); /* XXX ugly */
128 get_best_link_to_neighbor(const union olsr_ip_addr *);
131 lookup_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *remote_main, const struct interface *);
134 update_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *, const struct hello_message *, const struct interface *);
137 check_neighbor_link(const union olsr_ip_addr *);
140 replace_neighbor_link_set(const struct neighbor_entry *,
141 struct neighbor_entry *);
144 lookup_link_status(const struct link_entry *);
147 olsr_update_packet_loss_hello_int(struct link_entry *, double);
150 olsr_update_packet_loss(struct link_entry *entry);
153 olsr_print_link_set(void);