Synced kernel interface to new interface.

This commit is contained in:
Martin Mares 1999-02-05 21:38:50 +00:00
parent e9e3dc2659
commit 10d807d000
8 changed files with 81 additions and 50 deletions

View file

@ -21,7 +21,7 @@ CF_ADDTO(kern_proto, kern_proto krt_if_item ';')
krt_if_item:
SCAN TIME expr {
/* Scan time of 0 means scan on startup only */
((struct krt_proto *) this_proto)->ifopt.scan_time = $3;
((struct krt_config *) this_proto)->ifopt.scan_time = $3;
}
;

View file

@ -1,7 +1,7 @@
/*
* BIRD -- Unix Kernel Interface Syncer -- Setting Parameters
*
* (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.
*/
@ -13,4 +13,7 @@ struct krt_if_params {
int scan_time;
};
struct krt_if_status {
};
#endif

View file

@ -1,7 +1,7 @@
/*
* BIRD -- Unix Routing Table Syncing
*
* (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.
*/
@ -115,8 +115,8 @@ krt_add_route(rte *new)
void
krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
{
if (x->state != PRS_UP)
return;
if (x->proto_state != PS_UP)
bug("FIXME: krt_set_notify called for downed protocol");
if (old)
krt_remove_route(old);
if (new)
@ -124,9 +124,14 @@ krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
}
void
krt_set_preconfig(struct krt_proto *x)
krt_set_start(struct krt_proto *x)
{
if (if_scan_sock < 0)
bug("krt set: missing socket");
x->p.rt_notify = krt_set_notify;
}
void
krt_set_preconfig(struct krt_config *c)
{
}

View file

@ -1,7 +1,7 @@
/*
* BIRD -- Unix Kernel Route Syncer -- Setting Parameters
*
* (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.
*/
@ -12,8 +12,12 @@
struct krt_set_params {
};
struct krt_set_status {
};
void krt_remove_route(rte *old);
void krt_add_route(rte *new);
int krt_capable(rte *e);
void krt_set_notify(struct proto *x, net *net, rte *new, rte *old);
#endif

View file

@ -21,8 +21,8 @@ CF_GRAMMAR
CF_ADDTO(proto, kern_proto '}')
kern_proto_start: proto_start KERNEL {
if (!(this_proto = cf_krt_proto)) cf_error("Kernel protocol already defined");
cf_krt_proto = NULL;
if (!(this_proto = cf_krt)) cf_error("Kernel protocol already defined");
cf_krt = NULL;
}
;

View file

@ -25,29 +25,37 @@
extern struct protocol proto_unix_kernel;
struct krt_proto {
struct proto p;
struct krt_config {
struct proto_config c;
struct krt_set_params setopt;
struct krt_scan_params scanopt;
struct krt_if_params ifopt;
};
extern struct proto *cf_krt_proto;
struct krt_proto {
struct proto p;
struct krt_set_status setstat;
struct krt_scan_status scanstat;
struct krt_if_status ifstat;
};
extern struct proto_config *cf_krt;
/* krt-scan.c */
void krt_scan_preconfig(struct krt_proto *);
void krt_scan_preconfig(struct krt_config *);
void krt_scan_start(struct krt_proto *);
void krt_scan_shutdown(struct krt_proto *);
void krt_scan_ifaces_done(struct krt_proto *);
/* krt-set.c */
void krt_set_preconfig(struct krt_proto *);
void krt_set_preconfig(struct krt_config *);
void krt_set_start(struct krt_proto *);
/* sync-if.c */
void krt_if_preconfig(struct krt_proto *);
void krt_if_preconfig(struct krt_config *);
void krt_if_start(struct krt_proto *);
void krt_if_shutdown(struct krt_proto *);

View file

@ -1,7 +1,7 @@
/*
* BIRD -- Unix Interface Scanning and Syncing
*
* (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.
*/
@ -174,25 +174,26 @@ scan_if(timer *t)
void
krt_if_start(struct krt_proto *p)
{
if_scan_timer = tm_new(&root_pool);
struct krt_config *c = (struct krt_config *) p->p.cf;
if_scan_timer = tm_new(p->p.pool);
if_scan_timer->hook = scan_if;
if_scan_timer->data = p;
if_scan_timer->recurrent = p->ifopt.scan_time;
if_scan_timer->recurrent = c->ifopt.scan_time;
scan_if(if_scan_timer);
tm_start(if_scan_timer, p->ifopt.scan_time);
tm_start(if_scan_timer, c->ifopt.scan_time);
}
void
krt_if_preconfig(struct krt_proto *p)
krt_if_preconfig(struct krt_config *c)
{
p->ifopt.scan_time = 60;
c->ifopt.scan_time = 60;
}
void
krt_if_shutdown(struct krt_proto *p)
{
tm_stop(if_scan_timer);
rfree(if_scan_timer);
/* FIXME: What should we do with interfaces? */
}

View file

@ -1,7 +1,7 @@
/*
* BIRD -- Unix Routing Table Scanning and Syncing
*
* (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.
*/
@ -23,43 +23,53 @@
#include "unix.h"
#include "krt.h"
struct proto *cf_krt_proto;
struct proto_config *cf_krt;
void
krt_start(struct proto *P)
static int
krt_start(struct proto *p)
{
struct krt_proto *p = (struct krt_proto *) P;
krt_scan_start(p);
krt_if_start(p);
struct krt_proto *k = (struct krt_proto *) p;
krt_scan_start(k);
krt_set_start(k);
krt_if_start(k);
return PS_UP;
}
void
krt_shutdown(struct proto *P, int time)
int
krt_shutdown(struct proto *p)
{
struct krt_proto *p = (struct krt_proto *) P;
krt_scan_shutdown(p);
krt_if_shutdown(p);
struct krt_proto *k = (struct krt_proto *) p;
krt_scan_shutdown(k);
krt_if_shutdown(k);
return PS_DOWN;
}
void
krt_preconfig(struct protocol *x)
static void
krt_preconfig(struct protocol *x, struct config *c)
{
struct krt_proto *p = (struct krt_proto *) proto_new(&proto_unix_kernel, sizeof(struct krt_proto));
struct krt_config *z = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config));
cf_krt_proto = &p->p;
p->p.preference = DEF_PREF_UKR;
p->p.start = krt_start;
p->p.shutdown = krt_shutdown;
krt_scan_preconfig(p);
krt_set_preconfig(p);
krt_if_preconfig(p);
cf_krt = &z->c;
z->c.preference = DEF_PREF_UKR;
krt_scan_preconfig(z);
krt_set_preconfig(z);
krt_if_preconfig(z);
}
static struct proto *
krt_init(struct proto_config *c)
{
struct krt_proto *p = proto_new(c, sizeof(struct krt_proto));
return &p->p;
}
struct protocol proto_unix_kernel = {
{ NULL, NULL },
"kernel",
0,
NULL, /* init */
krt_preconfig,
NULL /* postconfig */
name: "Kernel",
preconfig: krt_preconfig,
init: krt_init,
start: krt_start,
shutdown: krt_shutdown,
};