Redesigned struct ospf_iface & new struct ospf_sock.

This commit is contained in:
Ondrej Filip 1999-04-14 15:13:44 +00:00
parent b31568a516
commit b11d8a4f59
2 changed files with 25 additions and 18 deletions

View file

@ -55,7 +55,7 @@ ospf_open_socket(struct proto *p, struct ospf_iface *ifa)
/* No NBMA networks now */
if(((struct iface *)ifa)->flags & IF_MULTICAST)
if(ifa->iface->flags & IF_MULTICAST)
{
mcsk=sk_new(p->pool);
mcsk->type=SK_IP_MC;
@ -66,9 +66,9 @@ ospf_open_socket(struct proto *p, struct ospf_iface *ifa)
mcsk->rx_hook=ospf_rx_hook;
mcsk->tx_hook=ospf_tx_hook;
mcsk->err_hook=ospf_err_hook;
mcsk->iface=(struct iface *)ifa;
mcsk->rbsize=((struct iface *)ifa)->mtu;
mcsk->tbsize=((struct iface *)ifa)->mtu;
mcsk->iface=ifa->iface;
mcsk->rbsize=ifa->iface->mtu;
mcsk->tbsize=ifa->iface->mtu;
if(sk_open(mcsk)!=0)
{
DBG(" OSPF: SK_OPEN: failed\n");
@ -119,7 +119,7 @@ void
wait_timer_hook(timer *timer)
{
debug(" OSPF: Wait timer expired for interface %s.\n",
((struct iface *)timer->data)->name);
((struct ospf_iface *)(timer->data))->iface->name);
}
void
@ -158,7 +158,7 @@ ospf_iface_default(struct ospf_iface *ifa)
ifa->drid=0;
ifa->bdrip=ipa_from_u32(0x00000000);
ifa->bdrid=0;
ifa->type=ospf_iface_clasify((struct iface *)ifa);
ifa->type=ospf_iface_clasify(ifa->iface);
}
struct ospf_iface*
@ -167,7 +167,7 @@ find_iface(struct proto_ospf *p, struct iface *what)
struct ospf_iface *i;
WALK_LIST (i, p->iface_list)
if (((struct iface *)i)->index == what->index)
if ((i)->iface == what)
return i;
return NULL;
}
@ -177,6 +177,7 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface
{
struct ospf_iface *ifa;
sock *mcsk, *newsk;
struct ospf_sock *osk;
struct ospf_config *c;
c=(struct ospf_config *)(p->cf);
@ -190,16 +191,16 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface
debug(" OSPF: using interface %s.\n", new->name);
/* FIXME: Latter I'll use config - this is incorrect */
ifa=mb_alloc(p->pool, sizeof(struct ospf_iface));
memcpy(ifa, new, sizeof(struct iface));
ifa->iface=new;
add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa);
ospf_iface_default(ifa);
add_wait_timer(ifa,p->pool,0);
init_list(&(ifa->sk_list));
if((mcsk=ospf_open_socket(p, ifa))!=NULL)
{
#if 0 /* FIXME: You cannot do this: the socket nodes are used internally by the resource manager */
add_tail(&(ifa->sk_list),NODE mcsk);
#endif
osk=(struct ospf_sock *)mb_alloc(p->pool, sizeof(struct ospf_sock));
osk->sk=mcsk;
add_tail(&(ifa->sk_list),NODE osk);
}
}

View file

@ -20,12 +20,13 @@
struct ospf_config {
struct proto_config c;
u32 area; /* Area ID !!! This is wrong !!!
u32 area; /* FIXME: Area ID !!! This is wrong !!!
* Should respect interface */
};
struct ospf_iface {
struct iface i; /* Nest's iface */
node n;
struct iface *iface; /* Nest's iface */
list sk_list; /* List of active sockets */
u32 area; /* OSPF Area */
u16 cost; /* Cost of iface */
@ -48,11 +49,12 @@ struct ospf_iface {
#define OSPF_IT_NBMA 1
#define OSPF_IT_PTP 2
int state; /* Interface state machine */
#define OSPF_IS_WAITING 0 /* Waiting for Wait timer */
#define OSPF_IS_PTP 1 /* PTP operational */
#define OSPF_IS_DROTHER 2 /* I'm on BCAST or NBMA and I'm not DR */
#define OSPF_IS_BACKUP 3 /* I'm BDR */
#define OSPF_IS_DR 4 /* I'm DR */
#define OSPF_IS_DOWN 0 /* Should never happen */
#define OSPF_IS_WAITING 1 /* Waiting for Wait timer */
#define OSPF_IS_PTP 2 /* PTP operational */
#define OSPF_IS_DROTHER 3 /* I'm on BCAST or NBMA and I'm not DR */
#define OSPF_IS_BACKUP 4 /* I'm BDR */
#define OSPF_IS_DR 5 /* I'm DR */
timer *wait_timer; /* One shot Wait timer - used after DOWN->UP */
/* Default values for interface parameters */
@ -66,6 +68,10 @@ struct ospf_iface {
};
struct ospf_sock {
node n;
sock *sk;
};
struct ospf_patt {
struct iface_patt i;