]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Basic protocol operations.
authorMartin Mares <mj@ucw.cz>
Wed, 3 Jun 1998 08:38:53 +0000 (08:38 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 3 Jun 1998 08:38:53 +0000 (08:38 +0000)
nest/proto.c

index 53e7d6e9030db62472ffe8db5a234837bf6bf140..f0c4fc632f44d060d44fcc1f5ce3d06cfb2dd473 100644 (file)
@@ -6,15 +6,84 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
+#define LOCAL_DEBUG
+
+#include <string.h>
+
 #include "nest/bird.h"
 #include "nest/protocol.h"
 #include "lib/resource.h"
 #include "lib/lists.h"
+#include "nest/confile.h"
 
+list protocol_list;
 list proto_list;
 
+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;
+}
+
 void
-protos_init(void)
+protos_preconfig(void)
 {
+  struct protocol *p;
+
   init_list(&proto_list);
+  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);
+    }
+}
+
+void
+protos_init(void)
+{
+  struct protocol *p;
+
+  debug("Initializing protocols\n");
+  init_list(&protocol_list);
+  add_tail(&protocol_list, &proto_device.n);
+  WALK_LIST(p, protocol_list)
+    p->init(p);
 }