Downing of interface should work.

This commit is contained in:
Ondrej Filip 2000-05-16 23:59:38 +00:00
parent 8fb0c2c298
commit 18a0c0bb76
3 changed files with 64 additions and 30 deletions

View file

@ -67,7 +67,37 @@ iface_chstate(struct ospf_iface *ifa, u8 state)
void
downint(struct ospf_iface *ifa)
{
/* FIXME: Delete all neighbors! */
struct ospf_neighbor *n;
struct proto *p=&ifa->proto->proto;
struct proto_ospf *po=ifa->proto;
WALK_LIST(n,ifa->neigh_list)
{
debug("%s: Removing neighbor %I", p->name, n->ip);
ospf_neigh_remove(n);
}
rem_node(NODE ifa);
if(ifa->hello_sk!=NULL)
{
sk_close(ifa->hello_sk);
rfree(ifa->hello_sk);
}
if(ifa->dr_sk!=NULL)
{
sk_close(ifa->dr_sk);
rfree(ifa->dr_sk);
}
if(ifa->ip_sk!=NULL)
{
sk_close(ifa->ip_sk);
rfree(ifa->ip_sk);
}
if(ifa->wait_timer!=NULL)
{
tm_stop(ifa->wait_timer);
rfree(ifa->wait_timer);
}
mb_free(ifa);
}
void
@ -150,34 +180,27 @@ ospf_open_mc_socket(struct ospf_iface *ifa)
p=(struct proto *)(ifa->proto);
/* FIXME: No NBMA and PTP networks */
if(ifa->iface->flags & IF_MULTICAST)
mcsk=sk_new(p->pool);
mcsk->type=SK_IP_MC;
mcsk->dport=OSPF_PROTO;
mcsk->saddr=AllSPFRouters;
mcsk->daddr=AllSPFRouters;
mcsk->tos=IP_PREC_INTERNET_CONTROL;
mcsk->ttl=1;
mcsk->rx_hook=ospf_rx_hook;
mcsk->tx_hook=ospf_tx_hook;
mcsk->err_hook=ospf_err_hook;
mcsk->iface=ifa->iface;
mcsk->rbsize=ifa->iface->mtu;
mcsk->tbsize=ifa->iface->mtu;
mcsk->data=(void *)ifa;
if(sk_open(mcsk)!=0)
{
mcsk=sk_new(p->pool);
mcsk->type=SK_IP_MC;
mcsk->dport=OSPF_PROTO;
mcsk->saddr=AllSPFRouters;
mcsk->daddr=AllSPFRouters;
mcsk->tos=IP_PREC_INTERNET_CONTROL;
mcsk->ttl=1;
mcsk->rx_hook=ospf_rx_hook;
mcsk->tx_hook=ospf_tx_hook;
mcsk->err_hook=ospf_err_hook;
mcsk->iface=ifa->iface;
mcsk->rbsize=ifa->iface->mtu;
mcsk->tbsize=ifa->iface->mtu;
mcsk->data=(void *)ifa;
if(sk_open(mcsk)!=0)
{
DBG("%s: SK_OPEN: mc open failed.\n",p->name);
return(NULL);
}
DBG("%s: SK_OPEN: mc opened.\n",p->name);
return(mcsk);
DBG("%s: SK_OPEN: mc open failed.\n",p->name);
return(NULL);
}
else return(NULL);
DBG("%s: SK_OPEN: mc opened.\n",p->name);
return(mcsk);
}
sock *
@ -323,7 +346,7 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
{
debug("%s: using interface %s.\n", p->name, iface->name);
/* FIXME: Latter I'll use config - this is incorrect */
ifa=mb_alloc(p->pool, sizeof(struct ospf_iface));
ifa=mb_allocz(p->pool, sizeof(struct ospf_iface));
ifa->proto=(struct proto_ospf *)p;
ifa->iface=iface;
ospf_iface_default(ifa);

View file

@ -434,6 +434,17 @@ neighbor_timer_hook(timer *timer)
p=(struct proto *)(ifa->proto);
debug("%s: Inactivity timer fired on interface %s for neighbor %I.\n",
p->name, ifa->iface->name, n->rid);
ospf_neigh_remove(n);
}
void
ospf_neigh_remove(struct ospf_neighbor *n)
{
struct ospf_iface *ifa;
struct proto *p;
ifa=n->ifa;
p=(struct proto *)(ifa->proto);
neigh_chstate(n, NEIGHBOR_DOWN);
tm_stop(n->inactim);
rfree(n->inactim);
@ -467,5 +478,4 @@ neighbor_timer_hook(timer *timer)
rem_node(NODE n);
mb_free(n);
debug("%s: Deleting neigbor.\n", p->name);
}
}

View file

@ -21,5 +21,6 @@ struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
struct ospf_neighbor *find_neigh_noifa(struct proto_ospf *po, u32 rid);
struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
void neighbor_timer_hook(timer *timer);
void ospf_neigh_remove(struct ospf_neighbor *n);
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */