Lines Matching refs:nr_node
55 static struct nr_node *nr_node_list;
67 struct nr_node *nr_node; in nr_add_node() local
80 for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next) in nr_add_node()
81 if (ax25cmp(nr, &nr_node->callsign) == 0) in nr_add_node()
95 struct nr_node *node; in nr_add_node()
107 if (quality == 0 && nr_neigh != NULL && nr_node != NULL) in nr_add_node()
146 if (nr_node == NULL) { in nr_add_node()
147 if ((nr_node = kmalloc(sizeof(*nr_node), GFP_ATOMIC)) == NULL) in nr_add_node()
150 nr_node->callsign = *nr; in nr_add_node()
151 strcpy(nr_node->mnemonic, mnemonic); in nr_add_node()
153 nr_node->which = 0; in nr_add_node()
154 nr_node->count = 1; in nr_add_node()
156 nr_node->routes[0].quality = quality; in nr_add_node()
157 nr_node->routes[0].obs_count = obs_count; in nr_add_node()
158 nr_node->routes[0].neighbour = nr_neigh; in nr_add_node()
163 nr_node->next = nr_node_list; in nr_add_node()
164 nr_node_list = nr_node; in nr_add_node()
174 strcpy(nr_node->mnemonic, mnemonic); in nr_add_node()
176 for (found = 0, i = 0; i < nr_node->count; i++) { in nr_add_node()
177 if (nr_node->routes[i].neighbour == nr_neigh) { in nr_add_node()
178 nr_node->routes[i].quality = quality; in nr_add_node()
179 nr_node->routes[i].obs_count = obs_count; in nr_add_node()
187 if (nr_node->count < 3) { in nr_add_node()
188 nr_node->routes[2] = nr_node->routes[1]; in nr_add_node()
189 nr_node->routes[1] = nr_node->routes[0]; in nr_add_node()
191 nr_node->routes[0].quality = quality; in nr_add_node()
192 nr_node->routes[0].obs_count = obs_count; in nr_add_node()
193 nr_node->routes[0].neighbour = nr_neigh; in nr_add_node()
195 nr_node->which++; in nr_add_node()
196 nr_node->count++; in nr_add_node()
200 if (quality > nr_node->routes[2].quality) { in nr_add_node()
201 nr_node->routes[2].neighbour->count--; in nr_add_node()
203 if (nr_node->routes[2].neighbour->count == 0 && !nr_node->routes[2].neighbour->locked) in nr_add_node()
204 nr_remove_neigh(nr_node->routes[2].neighbour); in nr_add_node()
206 nr_node->routes[2].quality = quality; in nr_add_node()
207 nr_node->routes[2].obs_count = obs_count; in nr_add_node()
208 nr_node->routes[2].neighbour = nr_neigh; in nr_add_node()
216 switch (nr_node->count) { in nr_add_node()
218 if (nr_node->routes[1].quality > nr_node->routes[0].quality) { in nr_add_node()
219 switch (nr_node->which) { in nr_add_node()
220 case 0: nr_node->which = 1; break; in nr_add_node()
221 case 1: nr_node->which = 0; break; in nr_add_node()
224 nr_route = nr_node->routes[0]; in nr_add_node()
225 nr_node->routes[0] = nr_node->routes[1]; in nr_add_node()
226 nr_node->routes[1] = nr_route; in nr_add_node()
228 if (nr_node->routes[2].quality > nr_node->routes[1].quality) { in nr_add_node()
229 switch (nr_node->which) { in nr_add_node()
230 case 1: nr_node->which = 2; break; in nr_add_node()
231 case 2: nr_node->which = 1; break; in nr_add_node()
234 nr_route = nr_node->routes[1]; in nr_add_node()
235 nr_node->routes[1] = nr_node->routes[2]; in nr_add_node()
236 nr_node->routes[2] = nr_route; in nr_add_node()
239 if (nr_node->routes[1].quality > nr_node->routes[0].quality) { in nr_add_node()
240 switch (nr_node->which) { in nr_add_node()
241 case 0: nr_node->which = 1; break; in nr_add_node()
242 case 1: nr_node->which = 0; break; in nr_add_node()
245 nr_route = nr_node->routes[0]; in nr_add_node()
246 nr_node->routes[0] = nr_node->routes[1]; in nr_add_node()
247 nr_node->routes[1] = nr_route; in nr_add_node()
253 for (i = 0; i < nr_node->count; i++) { in nr_add_node()
254 if (nr_node->routes[i].neighbour == nr_neigh) { in nr_add_node()
255 if (i < nr_node->which) in nr_add_node()
256 nr_node->which = i; in nr_add_node()
264 static void nr_remove_node(struct nr_node *nr_node) in nr_remove_node() argument
266 struct nr_node *s; in nr_remove_node()
272 if ((s = nr_node_list) == nr_node) { in nr_remove_node()
273 nr_node_list = nr_node->next; in nr_remove_node()
275 kfree(nr_node); in nr_remove_node()
280 if (s->next == nr_node) { in nr_remove_node()
281 s->next = nr_node->next; in nr_remove_node()
283 kfree(nr_node); in nr_remove_node()
334 struct nr_node *nr_node; in nr_del_node() local
338 for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next) in nr_del_node()
339 if (ax25cmp(callsign, &nr_node->callsign) == 0) in nr_del_node()
342 if (nr_node == NULL) return -EINVAL; in nr_del_node()
350 for (i = 0; i < nr_node->count; i++) { in nr_del_node()
351 if (nr_node->routes[i].neighbour == nr_neigh) { in nr_del_node()
357 nr_node->count--; in nr_del_node()
359 if (nr_node->count == 0) { in nr_del_node()
360 nr_remove_node(nr_node); in nr_del_node()
364 nr_node->routes[0] = nr_node->routes[1]; in nr_del_node()
366 nr_node->routes[1] = nr_node->routes[2]; in nr_del_node()
460 struct nr_node *s, *nr_node; in nr_dec_obs() local
463 nr_node = nr_node_list; in nr_dec_obs()
465 while (nr_node != NULL) { in nr_dec_obs()
466 s = nr_node; in nr_dec_obs()
467 nr_node = nr_node->next; in nr_dec_obs()
515 struct nr_node *t, *nr_node; in nr_rt_device_down() local
523 nr_node = nr_node_list; in nr_rt_device_down()
525 while (nr_node != NULL) { in nr_rt_device_down()
526 t = nr_node; in nr_rt_device_down()
527 nr_node = nr_node->next; in nr_rt_device_down()
710 struct nr_node *nr_node; in nr_link_failed() local
722 for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next) in nr_link_failed()
723 if (nr_node->which < nr_node->count && nr_node->routes[nr_node->which].neighbour == nr_neigh) in nr_link_failed()
724 nr_node->which++; in nr_link_failed()
735 struct nr_node *nr_node; in nr_route_frame() local
766 for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next) in nr_route_frame()
767 if (ax25cmp(nr_dest, &nr_node->callsign) == 0) in nr_route_frame()
770 if (nr_node == NULL || nr_node->which >= nr_node->count) in nr_route_frame()
773 nr_neigh = nr_node->routes[nr_node->which].neighbour; in nr_route_frame()
790 struct nr_node *nr_node; in nr_nodes_get_info() local
800 for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next) { in nr_nodes_get_info()
802 ax2asc(&nr_node->callsign), in nr_nodes_get_info()
803 (nr_node->mnemonic[0] == '\0') ? "*" : nr_node->mnemonic, in nr_nodes_get_info()
804 nr_node->which + 1, in nr_nodes_get_info()
805 nr_node->count); in nr_nodes_get_info()
807 for (i = 0; i < nr_node->count; i++) { in nr_nodes_get_info()
809 nr_node->routes[i].quality, in nr_nodes_get_info()
810 nr_node->routes[i].obs_count, in nr_nodes_get_info()
811 nr_node->routes[i].neighbour->number); in nr_nodes_get_info()
893 struct nr_node *t, *nr_node = nr_node_list; in nr_rt_free() local
895 while (nr_node != NULL) { in nr_rt_free()
896 t = nr_node; in nr_rt_free()
897 nr_node = nr_node->next; in nr_rt_free()