summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>1999-04-14 17:13:44 +0200
committerOndrej Filip <feela@network.cz>1999-04-14 17:13:44 +0200
commitb11d8a4f59b3559779938b0a37914a7bc8c07a6b (patch)
treed91e82f8587aa630fb15904e468160d8c52c07d0
parentb31568a516142e905712bad498914fb6a82dc25b (diff)
downloadbird-b11d8a4f59b3559779938b0a37914a7bc8c07a6b.tar
bird-b11d8a4f59b3559779938b0a37914a7bc8c07a6b.zip
Redesigned struct ospf_iface & new struct ospf_sock.
-rw-r--r--proto/ospf/ospf.c23
-rw-r--r--proto/ospf/ospf.h20
2 files changed, 25 insertions, 18 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index 6008eeb..b98e75d 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -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);
}
}
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 324cdb1..ae4bba7 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -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;