1998-05-20 11:54:33 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- Protocols
|
|
|
|
*
|
|
|
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
1998-06-03 08:38:53 +00:00
|
|
|
#define LOCAL_DEBUG
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
1998-05-20 11:54:33 +00:00
|
|
|
#include "nest/bird.h"
|
|
|
|
#include "nest/protocol.h"
|
|
|
|
#include "lib/resource.h"
|
|
|
|
#include "lib/lists.h"
|
1998-06-03 08:38:53 +00:00
|
|
|
#include "nest/confile.h"
|
1998-05-20 11:54:33 +00:00
|
|
|
|
1998-06-03 08:38:53 +00:00
|
|
|
list protocol_list;
|
1998-05-20 11:54:33 +00:00
|
|
|
list proto_list;
|
|
|
|
|
1998-06-03 08:38:53 +00:00
|
|
|
void *
|
|
|
|
proto_new(struct protocol *pr, unsigned size)
|
|
|
|
{
|
|
|
|
struct proto *p = mp_alloc(cfg_mem, size);
|
|
|
|
|
|
|
|
debug("proto_new(%s)\n", pr->name);
|
|
|
|
bzero(p, sizeof(*p));
|
|
|
|
p->proto = pr;
|
|
|
|
p->name = pr->name;
|
|
|
|
p->debug = pr->debug;
|
|
|
|
p->pool = rp_new(&root_pool, pr->name);
|
|
|
|
add_tail(&proto_list, &p->n);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
1998-05-20 11:54:33 +00:00
|
|
|
void
|
1998-06-03 08:38:53 +00:00
|
|
|
protos_preconfig(void)
|
1998-05-20 11:54:33 +00:00
|
|
|
{
|
1998-06-03 08:38:53 +00:00
|
|
|
struct protocol *p;
|
|
|
|
|
1998-05-20 11:54:33 +00:00
|
|
|
init_list(&proto_list);
|
1998-06-03 08:38:53 +00:00
|
|
|
debug("Protocol preconfig\n");
|
|
|
|
WALK_LIST(p, protocol_list)
|
|
|
|
{
|
|
|
|
debug("...%s\n", p->name);
|
|
|
|
p->preconfig(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
protos_postconfig(void)
|
|
|
|
{
|
|
|
|
struct protocol *p;
|
|
|
|
|
|
|
|
debug("Protocol postconfig\n");
|
|
|
|
WALK_LIST(p, protocol_list)
|
|
|
|
{
|
|
|
|
debug("...%s\n", p->name);
|
|
|
|
p->postconfig(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
protos_start(void)
|
|
|
|
{
|
|
|
|
struct proto *p;
|
|
|
|
|
|
|
|
debug("Protocol start\n");
|
|
|
|
WALK_LIST(p, proto_list)
|
|
|
|
{
|
|
|
|
debug("...%s\n", p->name);
|
|
|
|
if (p->start)
|
|
|
|
p->start(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-09 19:36:52 +00:00
|
|
|
void
|
|
|
|
protos_dump_all(void)
|
|
|
|
{
|
|
|
|
struct proto *p;
|
|
|
|
|
|
|
|
debug("Protocols:\n");
|
|
|
|
|
|
|
|
WALK_LIST(p, proto_list)
|
|
|
|
{
|
|
|
|
debug(" protocol %s:\n", p->name);
|
|
|
|
if (p->dump)
|
|
|
|
p->dump(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-03 08:38:53 +00:00
|
|
|
void
|
|
|
|
protos_init(void)
|
|
|
|
{
|
|
|
|
struct protocol *p;
|
|
|
|
|
|
|
|
debug("Initializing protocols\n");
|
|
|
|
init_list(&protocol_list);
|
|
|
|
add_tail(&protocol_list, &proto_device.n);
|
1998-07-09 19:36:52 +00:00
|
|
|
add_tail(&protocol_list, &proto_rip.n); /* HACK: We should really read this from config */
|
1998-06-03 08:38:53 +00:00
|
|
|
WALK_LIST(p, protocol_list)
|
|
|
|
p->init(p);
|
1998-05-20 11:54:33 +00:00
|
|
|
}
|