Synced kernel interface to new interface.
This commit is contained in:
parent
e9e3dc2659
commit
10d807d000
8 changed files with 81 additions and 50 deletions
|
@ -21,7 +21,7 @@ CF_ADDTO(kern_proto, kern_proto krt_if_item ';')
|
||||||
krt_if_item:
|
krt_if_item:
|
||||||
SCAN TIME expr {
|
SCAN TIME expr {
|
||||||
/* Scan time of 0 means scan on startup only */
|
/* 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;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- Unix Kernel Interface Syncer -- Setting Parameters
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -13,4 +13,7 @@ struct krt_if_params {
|
||||||
int scan_time;
|
int scan_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct krt_if_status {
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- Unix Routing Table Syncing
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -115,8 +115,8 @@ krt_add_route(rte *new)
|
||||||
void
|
void
|
||||||
krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
|
krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
|
||||||
{
|
{
|
||||||
if (x->state != PRS_UP)
|
if (x->proto_state != PS_UP)
|
||||||
return;
|
bug("FIXME: krt_set_notify called for downed protocol");
|
||||||
if (old)
|
if (old)
|
||||||
krt_remove_route(old);
|
krt_remove_route(old);
|
||||||
if (new)
|
if (new)
|
||||||
|
@ -124,9 +124,14 @@ krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
krt_set_preconfig(struct krt_proto *x)
|
krt_set_start(struct krt_proto *x)
|
||||||
{
|
{
|
||||||
if (if_scan_sock < 0)
|
if (if_scan_sock < 0)
|
||||||
bug("krt set: missing socket");
|
bug("krt set: missing socket");
|
||||||
x->p.rt_notify = krt_set_notify;
|
x->p.rt_notify = krt_set_notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
krt_set_preconfig(struct krt_config *c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- Unix Kernel Route Syncer -- Setting Parameters
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -12,8 +12,12 @@
|
||||||
struct krt_set_params {
|
struct krt_set_params {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct krt_set_status {
|
||||||
|
};
|
||||||
|
|
||||||
void krt_remove_route(rte *old);
|
void krt_remove_route(rte *old);
|
||||||
void krt_add_route(rte *new);
|
void krt_add_route(rte *new);
|
||||||
int krt_capable(rte *e);
|
int krt_capable(rte *e);
|
||||||
|
void krt_set_notify(struct proto *x, net *net, rte *new, rte *old);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,8 +21,8 @@ CF_GRAMMAR
|
||||||
CF_ADDTO(proto, kern_proto '}')
|
CF_ADDTO(proto, kern_proto '}')
|
||||||
|
|
||||||
kern_proto_start: proto_start KERNEL {
|
kern_proto_start: proto_start KERNEL {
|
||||||
if (!(this_proto = cf_krt_proto)) cf_error("Kernel protocol already defined");
|
if (!(this_proto = cf_krt)) cf_error("Kernel protocol already defined");
|
||||||
cf_krt_proto = NULL;
|
cf_krt = NULL;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -25,29 +25,37 @@
|
||||||
|
|
||||||
extern struct protocol proto_unix_kernel;
|
extern struct protocol proto_unix_kernel;
|
||||||
|
|
||||||
struct krt_proto {
|
struct krt_config {
|
||||||
struct proto p;
|
struct proto_config c;
|
||||||
struct krt_set_params setopt;
|
struct krt_set_params setopt;
|
||||||
struct krt_scan_params scanopt;
|
struct krt_scan_params scanopt;
|
||||||
struct krt_if_params ifopt;
|
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 */
|
/* 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_start(struct krt_proto *);
|
||||||
void krt_scan_shutdown(struct krt_proto *);
|
void krt_scan_shutdown(struct krt_proto *);
|
||||||
void krt_scan_ifaces_done(struct krt_proto *);
|
void krt_scan_ifaces_done(struct krt_proto *);
|
||||||
|
|
||||||
/* krt-set.c */
|
/* 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 */
|
/* 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_start(struct krt_proto *);
|
||||||
void krt_if_shutdown(struct krt_proto *);
|
void krt_if_shutdown(struct krt_proto *);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- Unix Interface Scanning and Syncing
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -174,25 +174,26 @@ scan_if(timer *t)
|
||||||
void
|
void
|
||||||
krt_if_start(struct krt_proto *p)
|
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->hook = scan_if;
|
||||||
if_scan_timer->data = p;
|
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);
|
scan_if(if_scan_timer);
|
||||||
tm_start(if_scan_timer, p->ifopt.scan_time);
|
tm_start(if_scan_timer, c->ifopt.scan_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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
|
void
|
||||||
krt_if_shutdown(struct krt_proto *p)
|
krt_if_shutdown(struct krt_proto *p)
|
||||||
{
|
{
|
||||||
tm_stop(if_scan_timer);
|
tm_stop(if_scan_timer);
|
||||||
rfree(if_scan_timer);
|
|
||||||
/* FIXME: What should we do with interfaces? */
|
/* FIXME: What should we do with interfaces? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- Unix Routing Table Scanning and Syncing
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -23,43 +23,53 @@
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
#include "krt.h"
|
#include "krt.h"
|
||||||
|
|
||||||
struct proto *cf_krt_proto;
|
struct proto_config *cf_krt;
|
||||||
|
|
||||||
void
|
static int
|
||||||
krt_start(struct proto *P)
|
krt_start(struct proto *p)
|
||||||
{
|
{
|
||||||
struct krt_proto *p = (struct krt_proto *) P;
|
struct krt_proto *k = (struct krt_proto *) p;
|
||||||
krt_scan_start(p);
|
|
||||||
krt_if_start(p);
|
krt_scan_start(k);
|
||||||
|
krt_set_start(k);
|
||||||
|
krt_if_start(k);
|
||||||
|
return PS_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
krt_shutdown(struct proto *P, int time)
|
krt_shutdown(struct proto *p)
|
||||||
{
|
{
|
||||||
struct krt_proto *p = (struct krt_proto *) P;
|
struct krt_proto *k = (struct krt_proto *) p;
|
||||||
krt_scan_shutdown(p);
|
|
||||||
krt_if_shutdown(p);
|
krt_scan_shutdown(k);
|
||||||
|
krt_if_shutdown(k);
|
||||||
|
return PS_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
krt_preconfig(struct protocol *x)
|
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;
|
cf_krt = &z->c;
|
||||||
p->p.preference = DEF_PREF_UKR;
|
z->c.preference = DEF_PREF_UKR;
|
||||||
p->p.start = krt_start;
|
krt_scan_preconfig(z);
|
||||||
p->p.shutdown = krt_shutdown;
|
krt_set_preconfig(z);
|
||||||
krt_scan_preconfig(p);
|
krt_if_preconfig(z);
|
||||||
krt_set_preconfig(p);
|
}
|
||||||
krt_if_preconfig(p);
|
|
||||||
|
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 = {
|
struct protocol proto_unix_kernel = {
|
||||||
{ NULL, NULL },
|
name: "Kernel",
|
||||||
"kernel",
|
preconfig: krt_preconfig,
|
||||||
0,
|
init: krt_init,
|
||||||
NULL, /* init */
|
start: krt_start,
|
||||||
krt_preconfig,
|
shutdown: krt_shutdown,
|
||||||
NULL /* postconfig */
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue