]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
First attempt at protocol configuration (now done only for RIP).
authorMartin Mares <mj@ucw.cz>
Fri, 27 Nov 1998 21:09:57 +0000 (21:09 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 27 Nov 1998 21:09:57 +0000 (21:09 +0000)
bird.conf
conf/confbase.Y
nest/config.Y
proto/rip/config.Y
sysdep/unix/main.c

index 1704af60a5d436004bd90b84c9f025f7e393d5aa..57df7ec72c26e2dee3fcf5a41518929113a11bbe 100644 (file)
--- a/bird.conf
+++ b/bird.conf
@@ -5,3 +5,7 @@
 # Yet another comment
 
 router id 62.168.0.1
+
+protocol rip MyRIP_test {
+       preference 130
+}
index 3eb104d0d32403b3188d93a7a36644134775a4fa..b20986aee30d7c12195f1c49848643c6da1ffe70 100644 (file)
@@ -10,6 +10,10 @@ CF_HDR
 
 #include "nest/bird.h"
 #include "conf/conf.h"
+#include "lib/resource.h"
+#include "lib/socket.h"
+#include "lib/timer.h"
+#include "nest/protocol.h"
 
 CF_DECLS
 
index f14331b3f5acad77b61aa977e6cdb31fa6bcd92c..1de0446bbf780a6900965925f4274a25a1fae491 100644 (file)
@@ -8,18 +8,22 @@
 
 CF_HDR
 
+static struct proto *this_proto;
+
 CF_DECLS
 
-CF_KEYWORDS(ROUTER, ID)
+CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE)
 
 %type <i> idval
 
 CF_GRAMMAR
 
+/* Setting of router ID */
+
 CF_ADDTO(conf, rtrid)
 rtrid: ROUTER ID idval {
    router_id = $3;
- }
  }
  ;
 
 idval:
@@ -27,6 +31,35 @@ idval:
  | IPA { $$ = ipa_to_u32($1); }
  ;
 
+/* Definition of protocols */
+
+CF_ADDTO(conf, proto)
+
+proto_start: PROTOCOL
+
+proto_name:
+   /* EMPTY */ {
+     struct symbol *s = cf_default_name(this_proto->proto->name);
+     s->class = SYM_PROTO;
+     s->def = this_proto;
+     this_proto->name = s->name;
+     }
+ | SYM {
+     if ($1->class) cf_error("Symbol already defined");
+     $1->class = SYM_PROTO;
+     $1->def = this_proto;
+     this_proto->name = $1->name;
+   }
+ ;
+
+proto_item:
+   /* EMPTY */
+ | PREFERENCE NUM {
+     if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
+     this_proto->preference = $2;
+   }
+ ;
+
 CF_CODE
 
 CF_END
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c89e59c8816a0fa6f61b2c2f8c7553fea6688611 100644 (file)
@@ -0,0 +1,32 @@
+/*
+ *     BIRD -- RIP Configuration
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "proto/rip/rip.h"
+
+CF_DECLS
+
+CF_KEYWORDS(RIP)
+
+CF_GRAMMAR
+
+CF_ADDTO(proto, rip_proto '}')
+
+rip_proto_start: proto_start RIP {
+     this_proto = proto_new(&proto_rip, sizeof(struct rip_data));
+     rip_init_instance(this_proto);
+   }
+ ;
+
+rip_proto:
+   rip_proto_start proto_name '{'
+ | rip_proto proto_item ';'
+ ;
+
+CF_CODE
+
+CF_END
index c649cb27d36b0d172205a98d58e1c6721d4506ce..4aeb9c1976bae9dcf02aa0075a73fc10aeb38928 100644 (file)
@@ -78,9 +78,12 @@ read_config(void)
   conf_fd = open(PATH_CONFIG, O_RDONLY);
   if (conf_fd < 0)
     die("Unable to open configuration file " PATH_CONFIG ": %m");
+  protos_preconfig();
   cf_read_hook = cf_read;
   cf_lex_init(1);
   cf_parse();
+  add_tail(&protocol_list, &proto_unix_kernel.n); /* FIXME: Must be _always_ the last one */
+  protos_postconfig();
 }
 
 /*
@@ -93,29 +96,25 @@ main(void)
   log(L_INFO "Launching BIRD -1.-1-pre-omega...");
 
   log_init_debug(NULL);
-  resource_init();
-
-  debug("Reading configuration file.\n");
-  read_config();
 
   debug("Initializing.\n");
+  resource_init();
   io_init();
   rt_init();
   if_init();
+
   protos_build();
-  add_tail(&protocol_list, &proto_unix_kernel.n); /* FIXME: Must be _always_ the last one */
   protos_init();
-  protos_preconfig();
-  protos_postconfig();
+
+  debug("Reading configuration file.\n");
+  read_config();
 
   signal_init();
 
   scan_if_init();
   auto_router_id();
 
-#if 0
   protos_start();
-#endif
 
   handle_sigusr(0);