1 /* 2 * The olsr.org Optimized Link-State Routing daemon (olsrd) 3 * 4 * (c) by the OLSR project 5 * 6 * See our Git repository to find out who worked on this file 7 * and thus is a copyright holder on it. 8 * 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 15 * * Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * * Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in 19 * the documentation and/or other materials provided with the 20 * distribution. 21 * * Neither the name of olsr.org, olsrd nor the names of its 22 * contributors may be used to endorse or promote products derived 23 * from this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 28 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 29 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 31 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 * 38 * Visit http://www.olsr.org for more information. 39 * 40 * If you find this software useful feel free to make a donation 41 * to the project. For more information see the website or contact 42 * the copyright holders. 43 * 44 */ 45 46 /* 47 * Link sensing database for the OLSR routing daemon 48 */ 49 50 #ifndef _LINK_SET_H 51 #define _LINK_SET_H 52 53 #include "lq_plugin.h" 54 #include "packet.h" 55 #include "common/list.h" 56 #include "mantissa.h" 57 58 #define MID_ALIAS_HACK_VTIME 10.0 59 60 #define LINK_LOSS_MULTIPLIER (1u<<16) 61 62 struct link_entry { 63 union olsr_ip_addr local_iface_addr; 64 union olsr_ip_addr neighbor_iface_addr; 65 const struct interface_olsr *inter; 66 char *if_name; 67 struct timer_entry *link_timer; 68 struct timer_entry *link_sym_timer; 69 uint32_t ASYM_time; 70 olsr_reltime vtime; 71 struct neighbor_entry *neighbor; 72 uint8_t prev_status; 73 74 /* 75 * Hysteresis 76 */ 77 float L_link_quality; 78 int L_link_pending; 79 uint32_t L_LOST_LINK_time; 80 struct timer_entry *link_hello_timer; /* When we should receive a new HELLO */ 81 olsr_reltime last_htime; 82 bool olsr_seqno_valid; 83 uint16_t olsr_seqno; 84 85 /* 86 * packet loss 87 */ 88 olsr_reltime loss_helloint; 89 struct timer_entry *link_loss_timer; 90 91 /* user defined multiplies for link quality, multiplied with 65536 */ 92 uint32_t loss_link_multiplier; 93 94 /* cost of this link */ 95 olsr_linkcost linkcost; 96 97 struct list_node link_list; /* double linked list of all link entries */ 98 uint32_t linkquality[0]; 99 }; 100 101 /* INLINE to recast from link_list back to link_entry */ 102 LISTNODE2STRUCT(list2link, struct link_entry, link_list); 103 104 #define OLSR_LINK_JITTER 5 /* percent */ 105 #define OLSR_LINK_HELLO_JITTER 0 /* percent jitter */ 106 #define OLSR_LINK_SYM_JITTER 0 /* percent jitter */ 107 #define OLSR_LINK_LOSS_JITTER 0 /* percent jitter */ 108 109 /* deletion safe macro for link entry traversal */ 110 #define OLSR_FOR_ALL_LINK_ENTRIES(link) \ 111 { \ 112 struct list_node *link_head_node, *link_node, *next_link_node; \ 113 link_head_node = &link_entry_head; \ 114 for (link_node = link_head_node->next; \ 115 link_node != link_head_node; link_node = next_link_node) { \ 116 next_link_node = link_node->next; \ 117 link = list2link(link_node); 118 #define OLSR_FOR_ALL_LINK_ENTRIES_END(link) }} 119 120 /* Externals */ 121 extern struct list_node link_entry_head; 122 extern bool link_changes; 123 124 /* Function prototypes */ 125 126 void olsr_set_link_timer(struct link_entry *, unsigned int); 127 void olsr_init_link_set(void); 128 void olsr_reset_all_links(void); 129 void olsr_delete_link_entry_by_ip(const union olsr_ip_addr *); 130 void olsr_expire_link_hello_timer(void *); 131 void signal_link_changes(bool); /* XXX ugly */ 132 133 struct link_entry *get_best_link_to_neighbor(const union olsr_ip_addr *); 134 135 struct link_entry *lookup_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *remote_main, const struct interface_olsr *); 136 137 struct link_entry *update_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *, const struct hello_message *, 138 const struct interface_olsr *); 139 140 int check_neighbor_link(const union olsr_ip_addr *); 141 int replace_neighbor_link_set(const struct neighbor_entry *, struct neighbor_entry *); 142 int lookup_link_status(const struct link_entry *); 143 void olsr_update_packet_loss_hello_int(struct link_entry *, olsr_reltime); 144 void olsr_received_hello_handler(struct link_entry *entry); 145 #ifndef NODEBUG 146 void olsr_print_link_set(void); 147 #else 148 #define olsr_print_link_set() do { } while(0) 149 #endif 150 151 #endif /* _LINK_SET_H */ 152 153 /* 154 * Local Variables: 155 * c-basic-offset: 2 156 * indent-tabs-mode: nil 157 * End: 158 */ 159