3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2004-2009, the olsr.org team - see HISTORY file
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of olsr.org, olsrd nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * Visit http://www.olsr.org for more information.
36 * If you find this software useful feel free to make a donation
37 * to the project. For more information see the website or contact
38 * the copyright holders.
48 #include "lq_packet.h"
49 #include "common/avl.h"
51 #define LINK_COST_BROKEN (1<<22)
52 #define ROUTE_COST_BROKEN (0xffffffff)
53 #define ZERO_ROUTE_COST 0
55 #define MINIMAL_USEFUL_LQ 0.1
56 #define LQ_PLUGIN_RELEVANT_COSTCHANGE 16
58 #define LQ_QUICKSTART_STEPS 12
59 #define LQ_QUICKSTART_AGING 0.25
68 void (*initialize) (void);
69 void (*deinitialize) (void);
71 olsr_linkcost(*calc_link_entry_cost) (struct link_entry *);
72 olsr_linkcost(*calc_lq_hello_neighbor_cost) (struct lq_hello_neighbor *);
73 olsr_linkcost(*calc_tc_mpr_addr_cost) (struct tc_mpr_addr *);
74 olsr_linkcost(*calc_tc_edge_entry_cost) (struct tc_edge_entry *);
76 bool(*is_relevant_costchange) (olsr_linkcost c1, olsr_linkcost c2);
78 olsr_linkcost(*packet_loss_handler) (struct link_entry *, bool);
80 void (*memorize_foreign_hello) (struct link_entry *, struct lq_hello_neighbor *);
81 void (*copy_link_entry_lq_into_tc_mpr_addr) (struct tc_mpr_addr *, struct link_entry *);
82 void (*copy_link_entry_lq_into_tc_edge_entry) (struct tc_edge_entry *, struct link_entry *);
83 void (*copy_link_lq_into_neighbor) (struct lq_hello_neighbor *, struct link_entry *);
85 void (*clear_link_entry) (struct link_entry *);
86 void (*clear_lq_hello_neighbor) (struct lq_hello_neighbor *);
87 void (*clear_tc_mpr_addr) (struct tc_mpr_addr *);
88 void (*clear_tc_edge_entry) (struct tc_edge_entry *);
90 int (*serialize_hello_lq) (unsigned char *, struct lq_hello_neighbor *);
91 int (*serialize_tc_lq) (unsigned char *, struct tc_mpr_addr *);
92 void (*deserialize_hello_lq) (uint8_t const **, struct lq_hello_neighbor *);
93 void (*deserialize_tc_lq) (uint8_t const **, struct tc_edge_entry *);
95 char *(*print_link_entry_lq) (struct link_entry *, char, struct lqtextbuffer *);
96 char *(*print_tc_edge_entry_lq) (struct tc_edge_entry *, char, struct lqtextbuffer *);
97 char *(*print_cost) (olsr_linkcost cost, struct lqtextbuffer *);
100 size_t size_tc_mpr_addr;
101 size_t size_lq_hello_neighbor;
102 size_t size_link_entry;
104 uint8_t messageid_hello;
105 uint8_t messageid_tc;
108 void init_lq_handler(void);
109 void deinit_lq_handler(void);
111 olsr_linkcost olsr_calc_tc_cost(struct tc_edge_entry *);
112 bool olsr_is_relevant_costchange(olsr_linkcost c1, olsr_linkcost c2);
114 int olsr_serialize_hello_lq_pair(unsigned char *, struct lq_hello_neighbor *);
115 void olsr_deserialize_hello_lq_pair(const uint8_t **, struct lq_hello_neighbor *);
116 int olsr_serialize_tc_lq_pair(unsigned char *, struct tc_mpr_addr *);
117 void olsr_deserialize_tc_lq_pair(const uint8_t **, struct tc_edge_entry *);
119 void olsr_update_packet_loss_worker(struct link_entry *, bool);
120 void olsr_memorize_foreign_hello_lq(struct link_entry *, struct lq_hello_neighbor *);
122 const char *EXPORT(get_link_entry_text) (struct link_entry *, char, struct lqtextbuffer *);
123 const char *EXPORT(get_tc_edge_entry_text) (struct tc_edge_entry *, char, struct lqtextbuffer *);
124 const char *EXPORT(get_linkcost_text) (olsr_linkcost, bool, struct lqtextbuffer *);
126 void olsr_copy_hello_lq(struct lq_hello_neighbor *, struct link_entry *);
127 void olsr_copylq_link_entry_2_tc_mpr_addr(struct tc_mpr_addr *, struct link_entry *);
128 void olsr_copylq_link_entry_2_tc_edge_entry(struct tc_edge_entry *, struct link_entry *);
130 void olsr_clear_tc_lq(struct tc_mpr_addr *);
133 struct tc_edge_entry *olsr_malloc_tc_edge_entry(void);
134 struct tc_mpr_addr *olsr_malloc_tc_mpr_addr(void);
135 struct lq_hello_neighbor *olsr_malloc_lq_hello_neighbor(void);
136 struct link_entry *olsr_malloc_link_entry(void);
138 void olsr_free_link_entry(struct link_entry *);
139 void olsr_free_lq_hello_neighbor(struct lq_hello_neighbor *);
140 void olsr_free_tc_edge_entry(struct tc_edge_entry *);
141 void olsr_free_tc_mpr_addr(struct tc_mpr_addr *);
143 uint8_t olsr_get_Hello_MessageId(void);
144 uint8_t olsr_get_TC_MessageId(void);
147 extern struct lq_handler *EXPORT(active_lq_handler);
150 #endif /*LQPLUGIN_H_ */
155 * indent-tabs-mode: nil