Lines Matching refs:r

43 static int init_children_and_leaves(struct rtentry *r, vifi_t parent);
71 init_children_and_leaves(struct rtentry *r, vifi_t parent) in init_children_and_leaves() argument
77 VIFM_COPY(r->rt_children, old_children); in init_children_and_leaves()
78 VIFM_COPY(r->rt_leaves, old_leaves ); in init_children_and_leaves()
80 VIFM_CLRALL(r->rt_children); in init_children_and_leaves()
81 VIFM_CLRALL(r->rt_leaves); in init_children_and_leaves()
82 r->rt_flags &= ~RTF_LEAF_TIMING; in init_children_and_leaves()
85 r->rt_dominants [vifi] = 0; in init_children_and_leaves()
86 r->rt_subordinates[vifi] = 0; in init_children_and_leaves()
89 VIFM_SET(vifi, r->rt_children); in init_children_and_leaves()
91 VIFM_SET(vifi, r->rt_leaves); in init_children_and_leaves()
92 r->rt_leaf_timers[vifi] = 0; in init_children_and_leaves()
95 r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME; in init_children_and_leaves()
96 r->rt_flags |= RTF_LEAF_TIMING; in init_children_and_leaves()
100 r->rt_leaf_timers[vifi] = 0; in init_children_and_leaves()
104 return (!VIFM_SAME(r->rt_children, old_children) || in init_children_and_leaves()
105 !VIFM_SAME(r->rt_leaves, old_leaves)); in init_children_and_leaves()
116 struct rtentry *r; in add_vif_to_routes() local
120 for (r = routing_table; r != NULL; r = r->rt_next) { in add_vif_to_routes()
121 if (r->rt_metric != UNREACHABLE && in add_vif_to_routes()
122 !VIFM_ISSET(vifi, r->rt_children)) { in add_vif_to_routes()
123 VIFM_SET(vifi, r->rt_children); in add_vif_to_routes()
124 r->rt_dominants [vifi] = 0; in add_vif_to_routes()
125 r->rt_subordinates[vifi] = 0; in add_vif_to_routes()
127 VIFM_SET(vifi, r->rt_leaves); in add_vif_to_routes()
128 r->rt_leaf_timers[vifi] = 0; in add_vif_to_routes()
131 VIFM_CLR(vifi, r->rt_leaves); in add_vif_to_routes()
132 r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME; in add_vif_to_routes()
133 r->rt_flags |= RTF_LEAF_TIMING; in add_vif_to_routes()
135 update_table_entry(r); in add_vif_to_routes()
149 struct rtentry *r; in delete_vif_from_routes() local
151 for (r = routing_table; r != NULL; r = r->rt_next) { in delete_vif_from_routes()
152 if (r->rt_metric != UNREACHABLE) { in delete_vif_from_routes()
153 if (vifi == r->rt_parent) { in delete_vif_from_routes()
154 del_table_entry(r, 0, DEL_ALL_ROUTES); in delete_vif_from_routes()
155 r->rt_timer = ROUTE_EXPIRE_TIME; in delete_vif_from_routes()
156 r->rt_metric = UNREACHABLE; in delete_vif_from_routes()
157 r->rt_flags |= RTF_CHANGED; in delete_vif_from_routes()
160 else if (VIFM_ISSET(vifi, r->rt_children)) { in delete_vif_from_routes()
161 VIFM_CLR(vifi, r->rt_children); in delete_vif_from_routes()
162 VIFM_CLR(vifi, r->rt_leaves); in delete_vif_from_routes()
163 r->rt_subordinates[vifi] = 0; in delete_vif_from_routes()
164 r->rt_leaf_timers [vifi] = 0; in delete_vif_from_routes()
165 update_table_entry(r); in delete_vif_from_routes()
168 r->rt_dominants[vifi] = 0; in delete_vif_from_routes()
183 struct rtentry *r; in delete_neighbor_from_routes() local
187 for (r = routing_table; r != NULL; r = r->rt_next) { in delete_neighbor_from_routes()
188 if (r->rt_metric != UNREACHABLE) { in delete_neighbor_from_routes()
189 if (r->rt_dominants[vifi] == addr) { in delete_neighbor_from_routes()
190 VIFM_SET(vifi, r->rt_children); in delete_neighbor_from_routes()
191 r->rt_dominants [vifi] = 0; in delete_neighbor_from_routes()
192 r->rt_subordinates[vifi] = 0; in delete_neighbor_from_routes()
194 VIFM_SET(vifi, r->rt_leaves); in delete_neighbor_from_routes()
195 r->rt_leaf_timers[vifi] = 0; in delete_neighbor_from_routes()
198 VIFM_CLR(vifi, r->rt_leaves); in delete_neighbor_from_routes()
199 r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME; in delete_neighbor_from_routes()
200 r->rt_flags |= RTF_LEAF_TIMING; in delete_neighbor_from_routes()
202 update_table_entry(r); in delete_neighbor_from_routes()
204 else if (r->rt_subordinates[vifi] == addr) { in delete_neighbor_from_routes()
205 r->rt_subordinates[vifi] = 0; in delete_neighbor_from_routes()
207 VIFM_SET(vifi, r->rt_leaves); in delete_neighbor_from_routes()
208 update_table_entry(r); in delete_neighbor_from_routes()
211 r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME; in delete_neighbor_from_routes()
212 r->rt_flags |= RTF_LEAF_TIMING; in delete_neighbor_from_routes()
216 r->rt_leaf_timers[vifi] != 0) { in delete_neighbor_from_routes()
217 VIFM_SET(vifi, r->rt_leaves); in delete_neighbor_from_routes()
218 r->rt_leaf_timers[vifi] = 0; in delete_neighbor_from_routes()
219 update_table_entry(r); in delete_neighbor_from_routes()
253 struct rtentry *r; in find_route() local
255 r = rtp->rt_next; in find_route()
256 while (r != NULL) { in find_route()
257 if (origin == r->rt_origin && mask == r->rt_originmask) { in find_route()
258 rtp = r; in find_route()
261 if (ntohl(mask) < ntohl(r->rt_originmask) || in find_route()
262 (mask == r->rt_originmask && in find_route()
263 ntohl(origin) < ntohl(r->rt_origin))) { in find_route()
264 rtp = r; in find_route()
265 r = r->rt_next; in find_route()
284 struct rtentry *r; in create_route() local
286 if ((r = malloc(sizeof(struct rtentry) + in create_route()
291 r->rt_origin = origin; in create_route()
292 r->rt_originmask = mask; in create_route()
293 if (((char *)&mask)[3] != 0) r->rt_originwidth = 4; in create_route()
294 else if (((char *)&mask)[2] != 0) r->rt_originwidth = 3; in create_route()
295 else if (((char *)&mask)[1] != 0) r->rt_originwidth = 2; in create_route()
296 else r->rt_originwidth = 1; in create_route()
297 r->rt_flags = 0; in create_route()
298 r->rt_dominants = (u_int32_t *)(r + 1); in create_route()
299 r->rt_subordinates = (u_int32_t *)(r->rt_dominants + numvifs); in create_route()
300 r->rt_leaf_timers = (u_int *)(r->rt_subordinates + numvifs); in create_route()
301 r->rt_groups = NULL; in create_route()
303 r->rt_next = rtp->rt_next; in create_route()
304 rtp->rt_next = r; in create_route()
305 r->rt_prev = rtp; in create_route()
306 if (r->rt_next != NULL) in create_route()
307 (r->rt_next)->rt_prev = r; in create_route()
309 rt_end = r; in create_route()
310 rtp = r; in create_route()
321 struct rtentry *r; in discard_route() local
323 r = prev_r->rt_next; in discard_route()
324 prev_r->rt_next = r->rt_next; in discard_route()
329 free((char *)r); in discard_route()
344 struct rtentry *r; in update_route() local
399 r = rtp; in update_route()
400 if (r->rt_metric == UNREACHABLE) { in update_route()
409 r->rt_parent = vifi; in update_route()
410 init_children_and_leaves(r, vifi); in update_route()
412 r->rt_gateway = src; in update_route()
413 r->rt_timer = 0; in update_route()
414 r->rt_metric = adj_metric; in update_route()
415 r->rt_flags |= RTF_CHANGED; in update_route()
417 update_table_entry(r); in update_route()
419 else if (src == r->rt_gateway) { in update_route()
428 r->rt_timer = 0; in update_route()
429 if (adj_metric == r->rt_metric) in update_route()
433 del_table_entry(r, 0, DEL_ALL_ROUTES); in update_route()
434 r->rt_timer = ROUTE_EXPIRE_TIME; in update_route()
436 else if (adj_metric < r->rt_metric) { in update_route()
437 if (init_children_and_leaves(r, vifi)) { in update_route()
438 update_table_entry(r); in update_route()
441 r->rt_metric = adj_metric; in update_route()
442 r->rt_flags |= RTF_CHANGED; in update_route()
446 (r->rt_gateway != 0 && in update_route()
447 (adj_metric < r->rt_metric || in update_route()
448 (adj_metric == r->rt_metric && in update_route()
449 (ntohl(src) < ntohl(r->rt_gateway) || in update_route()
450 r->rt_timer >= ROUTE_SWITCH_TIME))))) { in update_route()
466 if (r->rt_parent != vifi || adj_metric < r->rt_metric) { in update_route()
470 r->rt_parent = vifi; in update_route()
471 if (init_children_and_leaves(r, vifi)) { in update_route()
472 update_table_entry(r); in update_route()
475 r->rt_gateway = src; in update_route()
476 r->rt_timer = 0; in update_route()
477 r->rt_metric = adj_metric; in update_route()
478 r->rt_flags |= RTF_CHANGED; in update_route()
481 else if (vifi != r->rt_parent) { in update_route()
486 if (VIFM_ISSET(vifi, r->rt_children)) { in update_route()
490 if (metric < r->rt_metric || in update_route()
491 (metric == r->rt_metric && in update_route()
498 VIFM_CLR(vifi, r->rt_children); in update_route()
499 VIFM_CLR(vifi, r->rt_leaves); in update_route()
500 r->rt_dominants [vifi] = src; in update_route()
501 r->rt_subordinates[vifi] = 0; in update_route()
502 r->rt_leaf_timers [vifi] = 0; in update_route()
503 update_table_entry(r); in update_route()
511 if (r->rt_subordinates[vifi] == 0) { in update_route()
512 VIFM_CLR(vifi, r->rt_leaves); in update_route()
513 r->rt_subordinates[vifi] = src; in update_route()
514 r->rt_leaf_timers [vifi] = 0; in update_route()
515 update_table_entry(r); in update_route()
518 else if (src == r->rt_subordinates[vifi]) { in update_route()
525 r->rt_subordinates[vifi] = 0; in update_route()
528 VIFM_SET(vifi, r->rt_leaves); in update_route()
529 update_table_entry(r); in update_route()
532 r->rt_leaf_timers [vifi] = LEAF_CONFIRMATION_TIME; in update_route()
533 r->rt_flags |= RTF_LEAF_TIMING; in update_route()
538 else if (src == r->rt_dominants[vifi] && in update_route()
539 (metric > r->rt_metric || in update_route()
540 (metric == r->rt_metric && in update_route()
547 VIFM_SET(vifi, r->rt_children); in update_route()
548 r->rt_dominants [vifi] = 0; in update_route()
550 r->rt_subordinates[vifi] = src; in update_route()
554 VIFM_SET(vifi, r->rt_leaves); in update_route()
557 r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME; in update_route()
558 r->rt_flags |= RTF_LEAF_TIMING; in update_route()
560 update_table_entry(r); in update_route()
572 struct rtentry *r; in age_routes() local
576 for (prev_r = RT_ADDR, r = routing_table; in age_routes()
577 r != NULL; in age_routes()
578 prev_r = r, r = r->rt_next) { in age_routes()
580 if ((r->rt_timer += TIMER_INTERVAL) < ROUTE_EXPIRE_TIME) { in age_routes()
585 if (r->rt_flags & RTF_LEAF_TIMING) { in age_routes()
586 r->rt_flags &= ~RTF_LEAF_TIMING; in age_routes()
588 if (r->rt_leaf_timers[vifi] != 0) { in age_routes()
592 if ((r->rt_leaf_timers[vifi] -= TIMER_INTERVAL) == 0){ in age_routes()
601 VIFM_SET(vifi, r->rt_leaves); in age_routes()
602 update_table_entry(r); in age_routes()
608 r->rt_flags |= RTF_LEAF_TIMING; in age_routes()
614 else if (r->rt_timer >= ROUTE_DISCARD_TIME) { in age_routes()
618 del_table_entry(r, 0, DEL_ALL_ROUTES); in age_routes()
620 r = prev_r; in age_routes()
622 else if (r->rt_metric != UNREACHABLE) { in age_routes()
629 if (r->rt_gateway == 0) { in age_routes()
630 r->rt_timer = 0; in age_routes()
633 del_table_entry(r, 0, DEL_ALL_ROUTES); in age_routes()
634 r->rt_metric = UNREACHABLE; in age_routes()
635 r->rt_flags |= RTF_CHANGED; in age_routes()
654 struct rtentry *r; in expire_all_routes() local
656 for (r = routing_table; r != NULL; r = r->rt_next) { in expire_all_routes()
657 r->rt_metric = UNREACHABLE; in expire_all_routes()
658 r->rt_flags |= RTF_CHANGED; in expire_all_routes()
670 struct rtentry *r; in free_all_routes() local
672 r = RT_ADDR; in free_all_routes()
674 while (r->rt_next) in free_all_routes()
675 discard_route(r); in free_all_routes()
830 struct rtentry *r; in report() local
860 for (r = rt_end; r != RT_ADDR; r = r->rt_prev) { in report()
862 if (which_routes == CHANGED_ROUTES && !(r->rt_flags & RTF_CHANGED)) in report()
869 if (datalen + ((r->rt_originmask == mask) ? in report()
871 (r->rt_originwidth + 4)) > MAX_DVMRP_DATA_LEN) { in report()
881 if (r->rt_originmask != mask || datalen == 0) { in report()
882 mask = r->rt_originmask; in report()
883 width = r->rt_originwidth; in report()
892 *p++ = ((char *)&(r->rt_origin))[i]; in report()
894 *p++ = (r->rt_parent == vifi && r->rt_metric != UNREACHABLE) ? in report()
895 (char)(r->rt_metric + UNREACHABLE) : /* "poisoned reverse" */ in report()
896 (char)(r->rt_metric); in report()
918 struct rtentry *r; in report_to_all_neighbors() local
945 for (r = routing_table; r != NULL; r = r->rt_next) { in report_to_all_neighbors()
946 r->rt_flags &= ~RTF_CHANGED; in report_to_all_neighbors()
964 struct rtentry *r; in report_chunk() local
979 for (r = start_rt; r != RT_ADDR; r = r->rt_prev) { in report_chunk()
983 if ((vifs_with_neighbors == 1) && (r->rt_parent == vifi) in report_chunk()
984 && (r->rt_metric > 1)) { in report_chunk()
994 if (datalen + ((r->rt_originmask == mask) ? in report_chunk()
996 (r->rt_originwidth + 4)) > MAX_DVMRP_DATA_LEN) { in report_chunk()
1002 if (r->rt_originmask != mask || datalen == 0) { in report_chunk()
1003 mask = r->rt_originmask; in report_chunk()
1004 width = r->rt_originwidth; in report_chunk()
1012 *p++ = ((char *)&(r->rt_origin))[i]; in report_chunk()
1014 *p++ = (r->rt_parent == vifi && r->rt_metric != UNREACHABLE) ? in report_chunk()
1015 (char)(r->rt_metric + UNREACHABLE) : /* "poisoned reverse" */ in report_chunk()
1016 (char)(r->rt_metric); in report_chunk()
1088 struct rtentry *r; in dump_routes() local
1097 for (r = routing_table; r != NULL; r = r->rt_next) { in dump_routes()
1100 inet_fmts(r->rt_origin, r->rt_originmask, s1), in dump_routes()
1101 (r->rt_gateway == 0) ? "" : inet_fmt(r->rt_gateway, s2)); in dump_routes()
1103 fprintf(fp, (r->rt_metric == UNREACHABLE) ? " NR " : "%4u ", in dump_routes()
1104 r->rt_metric); in dump_routes()
1106 fprintf(fp, " %3u %3u ", r->rt_timer, r->rt_parent); in dump_routes()
1109 if (VIFM_ISSET(i, r->rt_children)) { in dump_routes()
1111 i, VIFM_ISSET(i, r->rt_leaves) ? '*' : ' '); in dump_routes()