summaryrefslogtreecommitdiffstats
path: root/proto/static
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-02-05 22:38:22 +0100
committerMartin Mares <mj@ucw.cz>1999-02-05 22:38:22 +0100
commite9e3dc265971fbf985c5df09cb1d98494c386581 (patch)
tree1ffb35e0025ff9eee1b325d2deaf2ccec418a08d /proto/static
parent31b3e1bbf5bc823ec5cf6d88931132f00e6c52b9 (diff)
downloadbird-e9e3dc265971fbf985c5df09cb1d98494c386581.tar
bird-e9e3dc265971fbf985c5df09cb1d98494c386581.zip
Modified static router to use new interface.
Diffstat (limited to 'proto/static')
-rw-r--r--proto/static/config.Y10
-rw-r--r--proto/static/static.c75
-rw-r--r--proto/static/static.h6
3 files changed, 39 insertions, 52 deletions
diff --git a/proto/static/config.Y b/proto/static/config.Y
index ff50651..df9e55b 100644
--- a/proto/static/config.Y
+++ b/proto/static/config.Y
@@ -1,7 +1,7 @@
/*
* BIRD -- Static Protocol Configuration
*
- * (c) 1998 Martin Mares <mj@ucw.cz>
+ * (c) 1998--1999 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
@@ -21,8 +21,8 @@ CF_GRAMMAR
CF_ADDTO(proto, static_proto '}')
static_proto_start: proto_start STATIC {
- this_proto = proto_new(&proto_static, sizeof(struct static_proto));
- static_init_instance((struct static_proto *) this_proto);
+ this_proto = proto_config_new(&proto_static, sizeof(struct static_config));
+ static_init_config((struct static_config *) this_proto);
}
;
@@ -34,7 +34,7 @@ static_proto:
stat_route0: ROUTE IPA pxlen {
this_srt = cfg_allocz(sizeof(struct static_route));
- add_tail(&((struct static_proto *) this_proto)->other_routes, &this_srt->n);
+ add_tail(&((struct static_config *) this_proto)->other_routes, &this_srt->n);
if (!ip_is_prefix($2, $3)) cf_error("Invalid network prefix: %I/%d", $2, $3);
this_srt->net = $2;
this_srt->masklen = $3;
@@ -50,7 +50,7 @@ stat_route:
this_srt->dest = RTD_DEVICE;
this_srt->if_name = $3;
rem_node(&this_srt->n);
- add_tail(&((struct static_proto *) this_proto)->iface_routes, &this_srt->n);
+ add_tail(&((struct static_config *) this_proto)->iface_routes, &this_srt->n);
}
| stat_route0 DROP { this_srt->dest = RTD_BLACKHOLE; }
| stat_route0 REJECT { this_srt->dest = RTD_UNREACHABLE; }
diff --git a/proto/static/static.c b/proto/static/static.c
index 7844460..f34996b 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -1,7 +1,7 @@
/*
* BIRD -- Static Route Generator
*
- * (c) 1998 Martin Mares <mj@ucw.cz>
+ * (c) 1998--1999 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
@@ -18,10 +18,8 @@
#include "static.h"
-#define GET_DATA struct static_proto *p = (struct static_proto *) P
-
static void
-static_install(struct static_proto *p, struct static_route *r, struct iface *ifa)
+static_install(struct proto *p, struct static_route *r, struct iface *ifa)
{
net *n;
rta a, *aa;
@@ -29,7 +27,7 @@ static_install(struct static_proto *p, struct static_route *r, struct iface *ifa
DBG("Installing static route %I/%d, rtd=%d\n", r->net, r->masklen, r->dest);
bzero(&a, sizeof(a));
- a.proto = &p->p;
+ a.proto = p;
a.source = (r->dest == RTD_DEVICE) ? RTS_STATIC_DEVICE : RTS_STATIC;
a.scope = SCOPE_UNIVERSE;
a.cast = RTC_UNICAST;
@@ -43,33 +41,33 @@ static_install(struct static_proto *p, struct static_route *r, struct iface *ifa
e = rte_get_temp(aa);
e->net = n;
e->pflags = 0;
- rte_update(n, &p->p, e);
+ rte_update(n, p, e);
}
static void
-static_remove(struct static_proto *p, struct static_route *r)
+static_remove(struct proto *p, struct static_route *r)
{
net *n;
DBG("Removing static route %I/%d\n", r->net, r->masklen);
n = net_find(&master_table, 0, r->net, r->masklen);
if (n)
- rte_update(n, &p->p, NULL);
+ rte_update(n, p, NULL);
}
-static void
-static_start(struct proto *P)
+static int
+static_start(struct proto *p)
{
- GET_DATA;
+ struct static_config *c = (void *) p->cf;
struct static_route *r;
DBG("Static: take off!\n");
- WALK_LIST(r, p->other_routes)
+ WALK_LIST(r, c->other_routes)
switch (r->dest)
{
case RTD_ROUTER:
{
- struct neighbor *n = neigh_find(P, &r->via, NEF_STICKY);
+ struct neighbor *n = neigh_find(p, &r->via, NEF_STICKY);
if (n)
{
r->chain = n->data;
@@ -87,12 +85,13 @@ static_start(struct proto *P)
default:
static_install(p, r, NULL);
}
+ return PS_UP;
}
static void
static_neigh_notify(struct neighbor *n)
{
- struct static_proto *p = (struct static_proto *) n->proto;
+ struct proto *p = n->proto;
struct static_route *r;
DBG("Static: neighbor notify for %I: iface %p\n", n->addr, n->iface);
@@ -122,52 +121,40 @@ static_dump_rt(struct static_route *r)
}
static void
-static_dump(struct proto *P)
+static_dump(struct proto *p)
{
- GET_DATA;
+ struct static_config *c = (void *) p->cf;
struct static_route *r;
debug("Independent static routes:\n");
- WALK_LIST(r, p->other_routes)
+ WALK_LIST(r, c->other_routes)
static_dump_rt(r);
debug("Device static routes:\n");
- WALK_LIST(r, p->iface_routes)
+ WALK_LIST(r, c->iface_routes)
static_dump_rt(r);
}
void
-static_init_instance(struct static_proto *P)
+static_init_config(struct static_config *c)
{
- struct proto *p = &P->p;
-
- p->preference = DEF_PREF_STATIC;
- p->start = static_start;
- p->neigh_notify = static_neigh_notify;
- p->dump = static_dump;
- init_list(&P->iface_routes);
- init_list(&P->other_routes);
+ c->c.preference = DEF_PREF_STATIC;
+ init_list(&c->iface_routes);
+ init_list(&c->other_routes);
}
-static void
-static_init(struct protocol *p)
+static struct proto *
+static_init(struct proto_config *c)
{
-}
+ struct proto *p = proto_new(c, sizeof(struct proto));
-static void
-static_preconfig(struct protocol *x)
-{
-}
-
-static void
-static_postconfig(struct protocol *p)
-{
+ p->neigh_notify = static_neigh_notify;
+ return p;
}
struct protocol proto_static = {
- { NULL, NULL },
- "Static",
- 0,
- static_init,
- static_preconfig,
- static_postconfig
+ name: "Static",
+ init: static_init,
+ dump: static_dump,
+ start: static_start,
+ /* FIXME: We'll need a shutdown function here */
};
diff --git a/proto/static/static.h b/proto/static/static.h
index ba66c80..5299a9f 100644
--- a/proto/static/static.h
+++ b/proto/static/static.h
@@ -9,13 +9,13 @@
#ifndef _BIRD_STATIC_H_
#define _BIRD_STATIC_H_
-struct static_proto {
- struct proto p;
+struct static_config {
+ struct proto_config c;
list iface_routes; /* Routes to search on interface events */
list other_routes; /* Routes hooked to neighbor cache and reject routes */
};
-void static_init_instance(struct static_proto *);
+void static_init_config(struct static_config *);
struct static_route {
node n;