if (ifa->type == OSPF_IT_NBMA)
{
if ((ifa->priority == 0) && (n->priority > 0))
- ospf_hello_send(NULL, OHS_HELLO, n);
+ ospf_hello_send(n->ifa, OHS_HELLO, n);
}
ospf_neigh_sm(n, INM_HELLOREC);
}
void
-ospf_hello_send(timer *timer, int kind, struct ospf_neighbor *dirn)
+ospf_hello_send(struct ospf_iface *ifa, int kind, struct ospf_neighbor *dirn)
{
- struct ospf_iface *ifa;
struct ospf_hello_packet *pkt;
struct ospf_packet *op;
struct proto *p;
int i;
struct nbma_node *nb;
- if (timer == NULL)
- ifa = dirn->ifa;
- else
- ifa = (struct ospf_iface *) timer->data;
-
if (ifa->state <= OSPF_IS_LOOP)
return;
break;
case OSPF_IT_NBMA:
- if (timer == NULL) /* Response to received hello */
+ if (dirn) /* Response to received hello */
{
ospf_send_to(ifa, dirn->ip);
break;
static void
poll_timer_hook(timer * timer)
{
- ospf_hello_send(timer, OHS_POLL, NULL);
+ ospf_hello_send(timer->data, OHS_POLL, NULL);
}
static void
hello_timer_hook(timer * timer)
{
- ospf_hello_send(timer, OHS_HELLO, NULL);
+ ospf_hello_send(timer->data, OHS_HELLO, NULL);
}
static void
ospf_iface_shutdown(struct ospf_iface *ifa)
{
if (ifa->state > OSPF_IS_DOWN)
- ospf_hello_send(ifa->hello_timer, OHS_SHUTDOWN, NULL);
+ ospf_hello_send(ifa, OHS_SHUTDOWN, NULL);
}
/**
else
{
ospf_iface_chstate(ifa, OSPF_IS_WAITING);
- tm_start(ifa->wait_timer, ifa->waitint);
+ if (ifa->wait_timer)
+ tm_start(ifa->wait_timer, ifa->waitint);
}
}
- tm_start(ifa->hello_timer, ifa->helloint);
+ if (ifa->hello_timer)
+ tm_start(ifa->hello_timer, ifa->helloint);
if (ifa->poll_timer)
tm_start(ifa->poll_timer, ifa->pollint);
- hello_timer_hook(ifa->hello_timer);
+ ospf_hello_send(ifa, OHS_HELLO, NULL);
schedule_link_lsa(ifa);
}
break;
ifa->stub = 1;
}
+ if (! ifa->stub)
+ {
+ ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
+
+ if (ifa->type == OSPF_IT_NBMA)
+ ifa->poll_timer = tm_new_set(ifa->pool, poll_timer_hook, ifa, 0, ifa->pollint);
+
+ if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
+ ifa->wait_timer = tm_new_set(ifa->pool, wait_timer_hook, ifa, 0, 0);
+ }
+
/* Do iface UP, unless there is no link and we use link detection */
ospf_iface_sm(ifa, (ifa->check_link && !(ifa->iface->flags & IF_LINK_UP)) ? ISM_LOOP : ISM_UP);
}
if (ipa_in_net(nb->ip, addr->prefix, addr->pxlen))
add_nbma_node(ifa, nb, 0);
- DBG("%s: Installing hello timer. (%u)\n", p->name, ifa->helloint);
- ifa->hello_timer = tm_new(pool);
- ifa->hello_timer->data = ifa;
- ifa->hello_timer->randomize = 0;
- ifa->hello_timer->hook = hello_timer_hook;
- ifa->hello_timer->recurrent = ifa->helloint;
-
- if (ifa->type == OSPF_IT_NBMA)
- {
- DBG("%s: Installing poll timer. (%u)\n", p->name, ifa->pollint);
- ifa->poll_timer = tm_new(pool);
- ifa->poll_timer->data = ifa;
- ifa->poll_timer->randomize = 0;
- ifa->poll_timer->hook = poll_timer_hook;
- ifa->poll_timer->recurrent = ifa->pollint;
- }
-
- if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
- {
- DBG("%s: Installing wait timer. (%u)\n", p->name, ifa->waitint);
- ifa->wait_timer = tm_new(pool);
- ifa->wait_timer->data = ifa;
- ifa->wait_timer->randomize = 0;
- ifa->wait_timer->hook = wait_timer_hook;
- ifa->wait_timer->recurrent = 0;
- }
-
ifa->state = OSPF_IS_DOWN;
add_tail(&oa->po->iface_list, NODE ifa);
olock_acquire(lock);
}
+static void
+ospf_iface_change_timer(timer *tm, unsigned val)
+{
+ if (!tm)
+ return;
+
+ tm->recurrent = val;
+
+ if (tm->expires)
+ tm_start(tm, val);
+}
+
int
ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
{
ifname, ifa->helloint, new->helloint);
ifa->helloint = new->helloint;
- ifa->hello_timer->recurrent = ifa->helloint;
- tm_start(ifa->hello_timer, ifa->helloint);
+ ospf_iface_change_timer(ifa->hello_timer, ifa->helloint);
}
/* RXMT TIMER */
OSPF_TRACE(D_EVENTS, "Changing poll interval on interface %s from %d to %d",
ifname, ifa->pollint, new->pollint);
- ifa->pollint = new->helloint;
- ifa->poll_timer->recurrent = ifa->pollint;
- tm_start(ifa->poll_timer, ifa->pollint);
+ ifa->pollint = new->pollint;
+ ospf_iface_change_timer(ifa->poll_timer, ifa->pollint);
}
/* WAIT TIMER */
ifname, ifa->waitint, new->waitint);
ifa->waitint = new->waitint;
- if (ifa->wait_timer->expires != 0)
+ if (ifa->wait_timer && ifa->wait_timer->expires)
tm_start(ifa->wait_timer, ifa->waitint);
}