#include "sockopt.h"
-static __inline int iface_compare(struct iface *, struct iface *);
+static __inline int iface_compare(const struct iface *, const struct iface *);
static struct if_addr *if_addr_new(struct kaddr *);
static struct if_addr *if_addr_lookup(struct if_addr_head *, struct kaddr *);
static int if_start(struct iface *, int);
RB_GENERATE(iface_head, iface, entry, iface_compare)
static __inline int
-iface_compare(struct iface *a, struct iface *b)
+iface_compare(const struct iface *a, const struct iface *b)
{
- return (strcmp(a->name, b->name));
+ return if_cmp_name_func(a->name, b->name);
}
struct iface *
/* ipv4 */
iface->ipv4.iface = iface;
iface->ipv4.state = IF_STA_DOWN;
- RB_INIT(&iface->ipv4.adj_tree);
+ RB_INIT(ia_adj_head, &iface->ipv4.adj_tree);
/* ipv6 */
iface->ipv6.iface = iface;
iface->ipv6.state = IF_STA_DOWN;
- RB_INIT(&iface->ipv6.adj_tree);
+ RB_INIT(ia_adj_head, &iface->ipv6.adj_tree);
}
void
while ((if_addr = LIST_FIRST(&iface->addr_list)) != NULL) {
LIST_REMOVE(if_addr, entry);
+ assert(if_addr != LIST_FIRST(&iface->addr_list));
free(if_addr);
}
}
}
send_hello(HELLO_LINK, ia, NULL);
-
if_start_hello_timer(ia);
+ ia->state = IF_STA_ACTIVE;
+
return (0);
}
ia = iface_af_get(iface, af);
if_stop_hello_timer(ia);
- while ((adj = RB_ROOT(&ia->adj_tree)) != NULL)
+ while (!RB_EMPTY(ia_adj_head, &ia->adj_tree)) {
+ adj = RB_ROOT(ia_adj_head, &ia->adj_tree);
+
adj_del(adj, S_SHUTDOWN);
+ }
/* try to cleanup */
switch (af) {
if_leave_ipv6_group(iface, &global.mcast_addr_v6);
break;
default:
- fatalx("if_start: unknown af");
+ fatalx("if_reset: unknown af");
}
+ ia->state = IF_STA_DOWN;
+
return (0);
}
!socket_ok || !rtr_id_ok)
return;
- ia->state = IF_STA_ACTIVE;
if_start(ia->iface, ia->af);
} else if (ia->state == IF_STA_ACTIVE) {
if (ia->enabled && ia->iface->operative && addr_ok &&
socket_ok && rtr_id_ok)
return;
- ia->state = IF_STA_DOWN;
if_reset(ia->iface, ia->af);
}
}
if_start_hello_timer(struct iface_af *ia)
{
THREAD_TIMER_OFF(ia->hello_timer);
- ia->hello_timer = thread_add_timer(master, if_hello_timer, ia,
- if_get_hello_interval(ia));
+ ia->hello_timer = NULL;
+ thread_add_timer(master, if_hello_timer, ia, if_get_hello_interval(ia),
+ &ia->hello_timer);
}
static void