00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef _OLSR_NEIGH_TBL
00044 #define _OLSR_NEIGH_TBL
00045
00046 #include "defs.h"
00047 #include "olsr_clock.h"
00048 #include "olsr_types.h"
00049 #include "common/avl.h"
00050 #include "tc_set.h"
00051
00052 #define NB2S_COVERED 0x1
00053
00054
00055
00056
00057 struct nbr_con {
00058 struct avl_node nbr_tree_node;
00059 struct avl_node nbr2_tree_node;
00060
00061 struct nbr_entry *nbr;
00062 struct nbr2_entry *nbr2;
00063
00064 struct olsr_timer_entry *nbr2_con_timer;
00065
00066 olsr_linkcost second_hop_linkcost;
00067 olsr_linkcost path_linkcost;
00068 };
00069
00070
00071 #define OLSR_NBR2_LIST_JITTER 5
00072
00073 struct nbr_entry {
00074 struct avl_node nbr_node;
00075 union olsr_ip_addr nbr_addr;
00076 struct tc_edge_entry *tc_edge;
00077 unsigned int willingness:3;
00078 unsigned int is_sym:1;
00079 unsigned int is_mpr:1;
00080 unsigned int was_mpr:1;
00081 unsigned int skip:1;
00082 unsigned int mprs_count:16;
00083 unsigned int linkcount;
00084 struct avl_tree con_tree;
00085 };
00086
00087
00088 struct nbr2_entry {
00089 struct avl_node nbr2_node;
00090 union olsr_ip_addr nbr2_addr;
00091 unsigned int mpr_covered_count;
00092 unsigned int processed:1;
00093 struct avl_tree con_tree;
00094 };
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 #define OLSR_FOR_ALL_NBR_ENTRIES(nbr, iterator) avl_for_each_element_safe(&nbr_tree, nbr, nbr_node, iterator)
00106
00107 #define OLSR_FOR_ALL_NBR_CON_ENTRIES(nbr, con, iterator) avl_for_each_element_safe(&nbr->con_tree, con, nbr_tree_node, iterator)
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #define OLSR_FOR_ALL_NBR2_ENTRIES(nbr2, iterator) avl_for_each_element_safe(&nbr2_tree, nbr2, nbr2_node, iterator)
00118
00119 #define OLSR_FOR_ALL_NBR2_CON_ENTRIES(nbr2, con, iterator) avl_for_each_element_safe(&nbr2->con_tree, con, nbr2_tree_node, iterator)
00120
00121
00122
00123
00124 extern struct avl_tree EXPORT(nbr_tree);
00125 extern struct avl_tree EXPORT(nbr2_tree);
00126
00127 void olsr_init_neighbor_table(void);
00128
00129
00130 struct nbr_entry *olsr_add_nbr_entry(const union olsr_ip_addr *);
00131 void olsr_delete_nbr_entry(struct nbr_entry *);
00132 struct nbr_entry *EXPORT(olsr_lookup_nbr_entry) (const union olsr_ip_addr *, bool aliaslookup);
00133
00134 void olsr_update_nbr_status(struct nbr_entry *);
00135
00136
00137 struct nbr2_entry *olsr_add_nbr2_entry(const union olsr_ip_addr *);
00138 void olsr_delete_nbr2_entry(struct nbr2_entry *);
00139 struct nbr2_entry *EXPORT(olsr_lookup_nbr2_entry)(const union olsr_ip_addr *, bool aliaslookup);
00140
00141
00142 struct nbr_con *olsr_link_nbr_nbr2(struct nbr_entry *, const union olsr_ip_addr *, uint32_t);
00143 void olsr_delete_nbr_con(struct nbr_con *);
00144 struct nbr_con *EXPORT(olsr_lookup_nbr_con_entry)(struct nbr_entry *, const union olsr_ip_addr *);
00145 struct nbr_con *EXPORT(olsr_lookup_nbr2_con_entry)(struct nbr2_entry *, const union olsr_ip_addr *);
00146
00147 void olsr_print_neighbor_table(void);
00148
00149 #endif
00150
00151
00152
00153
00154
00155
00156