3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2004, Andreas Tonnesen(andreto@olsr.org)
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.
42 #ifndef _OLSR_NEIGH_TBL
43 #define _OLSR_NEIGH_TBL
45 #include "olsr_types.h"
48 struct neighbor_2_list_entry {
49 struct neighbor_entry *nbr2_nbr; /* backpointer to owning nbr entry */
50 struct neighbor_2_entry *neighbor_2;
51 struct timer_entry *nbr2_list_timer;
52 struct neighbor_2_list_entry *next;
53 struct neighbor_2_list_entry *prev;
56 #define OLSR_NBR2_LIST_JITTER 5 /* percent */
58 struct neighbor_entry {
59 union olsr_ip_addr neighbor_main_addr;
63 bool was_mpr; /* Used to detect changes in MPR */
67 struct neighbor_2_list_entry neighbor_2_list;
68 struct neighbor_entry *next;
69 struct neighbor_entry *prev;
72 #define OLSR_FOR_ALL_NBR_ENTRIES(nbr) \
75 for (_idx = 0; _idx < HASHSIZE; _idx++) { \
76 for(nbr = neighbortable[_idx].next; \
77 nbr != &neighbortable[_idx]; \
79 #define OLSR_FOR_ALL_NBR_ENTRIES_END(nbr) }}
84 extern struct neighbor_entry neighbortable[HASHSIZE];
86 void olsr_init_neighbor_table(void);
88 int olsr_delete_neighbor_2_pointer(struct neighbor_entry *, struct neighbor_2_entry *);
90 struct neighbor_2_list_entry *olsr_lookup_my_neighbors(const struct neighbor_entry *, const union olsr_ip_addr *);
92 int olsr_delete_neighbor_table(const union olsr_ip_addr *);
94 struct neighbor_entry *olsr_insert_neighbor_table(const union olsr_ip_addr *);
96 struct neighbor_entry *olsr_lookup_neighbor_table(const union olsr_ip_addr *);
98 struct neighbor_entry *olsr_lookup_neighbor_table_alias(const union olsr_ip_addr *);
100 void olsr_time_out_two_hop_neighbors(struct neighbor_entry *);
102 void olsr_time_out_neighborhood_tables(void);
103 void olsr_expire_nbr2_list(void *);
106 void olsr_print_neighbor_table(void);
108 #define olsr_print_neighbor_table() do { } while(0)
111 void olsr_update_neighbor_main_addr(struct neighbor_entry *, const union olsr_ip_addr *);
113 int update_neighbor_status(struct neighbor_entry *, int);
115 #endif /* _OLSR_NEIGH_TBL */
120 * indent-tabs-mode: nil