]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Bare skeleton of the BGP.
authorMartin Mares <mj@ucw.cz>
Sun, 19 Mar 2000 22:09:07 +0000 (22:09 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 19 Mar 2000 22:09:07 +0000 (22:09 +0000)
nest/proto.c
nest/protocol.h
proto/bgp/Makefile [new file with mode: 0644]
proto/bgp/bgp.c [new file with mode: 0644]
proto/bgp/bgp.h [new file with mode: 0644]
proto/bgp/config.Y [new file with mode: 0644]

index 937cda2de5aa363d56241b28c66377c881ddf0ed..95988ce51481fe10b4c69c58d36dba8d56d8b75b 100644 (file)
@@ -366,6 +366,9 @@ protos_build(void)
 #endif
 #ifdef CONFIG_PIPE
   add_tail(&protocol_list, &proto_pipe.n);
+#endif
+#ifdef CONFIG_BGP
+  add_tail(&protocol_list, &proto_bgp.n);
 #endif
   proto_pool = rp_new(&root_pool, "Protocols");
   proto_flush_event = ev_new(proto_pool);
index 9dd32fc400cd6bc3f38139046cf6f4752e0f0126..b02ea0229139f2cb62473cbc8b4413a9b8230ec6 100644 (file)
@@ -61,11 +61,9 @@ extern list protocol_list;
  *     Known protocols
  */
 
-extern struct protocol proto_device;
-extern struct protocol proto_rip;
-extern struct protocol proto_static;
-extern struct protocol proto_ospf;
-extern struct protocol proto_pipe;
+extern struct protocol
+  proto_device, proto_rip, proto_static,
+  proto_ospf, proto_pipe, proto_bgp;
 
 /*
  *     Routing Protocol Instance
diff --git a/proto/bgp/Makefile b/proto/bgp/Makefile
new file mode 100644 (file)
index 0000000..8358bc8
--- /dev/null
@@ -0,0 +1,5 @@
+source=bgp.c
+root-rel=../../
+dir-name=proto/bgp
+
+include ../../Rules
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
new file mode 100644 (file)
index 0000000..26e3906
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *     BIRD -- The Border Gateway Protocol
+ *
+ *     (c) 2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#define LOCAL_DEBUG
+
+#include "nest/bird.h"
+#include "nest/iface.h"
+#include "nest/protocol.h"
+#include "nest/route.h"
+#include "conf/conf.h"
+
+#include "bgp.h"
+
+static void
+bgp_rt_notify(struct proto *P, net *n, rte *new, rte *old, ea_list *tmpa)
+{
+}
+
+static struct proto *
+bgp_init(struct proto_config *C)
+{
+  struct bgp_config *c = (struct bgp_config *) C;
+  struct proto *P = proto_new(C, sizeof(struct bgp_proto));
+  struct bgp_proto *p = (struct bgp_proto *) P;
+
+  P->rt_notify = bgp_rt_notify;
+  return P;
+}
+
+static int
+bgp_start(struct proto *P)
+{
+  return PS_UP;
+}
+
+static int
+bgp_shutdown(struct proto *P)
+{
+  return PS_DOWN;
+}
+
+void
+bgp_check(struct bgp_config *c)
+{
+  if (!c->local_as)
+    cf_error("Local AS number must be set");
+  if (!c->remote_as)
+    cf_error("Neighbor must be configured");
+}
+
+struct protocol proto_bgp = {
+  name:                        "BGP",
+  template:            "bgp%d",
+  init:                        bgp_init,
+  start:               bgp_start,
+  shutdown:            bgp_shutdown,
+#if 0
+  dump:                        bgp_dump,
+  get_status:          bgp_get_status,
+  get_route_info:      bgp_get_route_info,
+  show_route_data:     bgp_show_route_data
+#endif
+};
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
new file mode 100644 (file)
index 0000000..2e352be
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *     BIRD -- The Border Gateway Protocol
+ *
+ *     (c) 2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_BGP_H_
+#define _BIRD_BGP_H_
+
+struct bgp_config {
+  struct proto_config c;
+  unsigned int local_as, remote_as;
+  ip_addr remote_ip;
+  int multihop;                                /* Number of hops if multihop */
+};
+
+struct bgp_proto {
+  struct proto p;
+};
+
+struct bgp_route {
+};
+
+struct bgp_attrs {
+};
+
+void bgp_check(struct bgp_config *c);
+
+#endif
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
new file mode 100644 (file)
index 0000000..f66f358
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *     BIRD -- Border Gateway Protocol Configuration
+ *
+ *     (c) 2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "proto/bgp/bgp.h"
+
+#define BGP_CFG ((struct bgp_config *) this_proto)
+
+CF_DECLS
+
+CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS)
+
+CF_GRAMMAR
+
+CF_ADDTO(proto, bgp_proto '}' { bgp_check(BGP_CFG); } )
+
+bgp_proto_start: proto_start BGP {
+     this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config));
+     this_proto->preference = DEF_PREF_BGP;
+  }
+ ;
+
+bgp_proto:
+   bgp_proto_start proto_name '{'
+ | bgp_proto proto_item ';'
+ | bgp_proto LOCAL AS NUM ';' {
+     if ($4 < 0 || $4 > 65535) cf_error("AS number out of range");
+     BGP_CFG->local_as = $4;
+   }
+ | bgp_proto NEIGHBOR IPA AS NUM ';' {
+     if ($5 < 0 || $5 > 65535) cf_error("AS number out of range");
+     BGP_CFG->remote_ip = $3;
+     BGP_CFG->remote_as = $5;
+   }
+ ;
+
+CF_CODE
+
+CF_END