]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RPKI: add new protocol skeleton
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Thu, 17 Sep 2015 15:15:30 +0000 (17:15 +0200)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Thu, 17 Sep 2015 16:37:11 +0000 (18:37 +0200)
configure.in
nest/proto.c
nest/protocol.h
proto/Doc
proto/rpki/Doc [new file with mode: 0644]
proto/rpki/Makefile [new file with mode: 0644]
proto/rpki/config.Y [new file with mode: 0644]
proto/rpki/rpki.c [new file with mode: 0644]
proto/rpki/rpki.h [new file with mode: 0644]
sysdep/autoconf.h.in

index c81709e61bf4fec0d099306845814002b92d1e1a..41838d3b711decd0f24303bb776adbc818484391 100644 (file)
@@ -205,7 +205,7 @@ fi
 
 AC_SUBST(iproutedir)
 
-all_protocols="$proto_bfd bgp ospf pipe $proto_radv rip static"
+all_protocols="$proto_bfd bgp ospf pipe $proto_radv rip rpki static"
 all_protocols=`echo $all_protocols | sed 's/ /,/g'`
 
 if test "$with_protocols" = all ; then
index 6531083cf804d9027e470b8211fb086bdaced45c..e86b69b7ad2bf357f74178667f03fa94eba36893 100644 (file)
@@ -919,6 +919,9 @@ protos_build(void)
   proto_build(&proto_bfd);
   bfd_init_all();
 #endif
+#ifdef CONFIG_RPKI
+  proto_build(&proto_rpki);
+#endif
 
   proto_pool = rp_new(&root_pool, "Protocols");
   proto_flush_event = ev_new(proto_pool);
index 8c49154ffc656d11c932bd21b04c0007cb93af9c..384f805b4002f43a00cadf329a8ec496bf3db479 100644 (file)
@@ -76,7 +76,7 @@ void protos_dump_all(void);
 
 extern struct protocol
   proto_device, proto_radv, proto_rip, proto_static,
-  proto_ospf, proto_pipe, proto_bgp, proto_bfd;
+  proto_ospf, proto_pipe, proto_bgp, proto_bfd, proto_rpki;
 
 /*
  *     Routing Protocol Instance
index 7863472f3c36dfa725d93f32357dfe04a2821a7c..48f754ceb5ee1503e9ee9736c02393a20cd00d38 100644 (file)
--- a/proto/Doc
+++ b/proto/Doc
@@ -3,7 +3,8 @@ C bfd
 C bgp
 C ospf
 C pipe
-C rip
 C radv
+C rip
+C rpki
 C static
 S ../nest/rt-dev.c
diff --git a/proto/rpki/Doc b/proto/rpki/Doc
new file mode 100644 (file)
index 0000000..3ffa7cb
--- /dev/null
@@ -0,0 +1 @@
+C rpki.c
diff --git a/proto/rpki/Makefile b/proto/rpki/Makefile
new file mode 100644 (file)
index 0000000..66da9ad
--- /dev/null
@@ -0,0 +1,5 @@
+source=rpki.c
+root-rel=../../
+dir-name=proto/rpki
+
+include ../../Rules
diff --git a/proto/rpki/config.Y b/proto/rpki/config.Y
new file mode 100644 (file)
index 0000000..b45e3a1
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *     BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol
+ *
+ *     (c) 2015 CZ.NIC
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "proto/rpki/rpki.h"
+
+CF_DEFINES
+
+#define RPKI_CFG ((struct rpki_config *) this_proto)
+
+CF_DECLS
+
+CF_KEYWORDS(RPKI, CACHE, SERVER, SERVERS)
+
+CF_GRAMMAR
+
+CF_ADDTO(proto, rpki_proto)
+
+rpki_proto_start: proto_start RPKI {
+     this_proto = proto_config_new(&proto_rpki, $1);
+ }
+ ;
+
+rpki_proto_item:
+   proto_item
+ | CACHE SERVER ipa expr {
+       RPKI_CFG->remote.ip = $3;
+       RPKI_CFG->remote.port = $4;
+ }
+ ;
+
+rpki_proto_opts:
+   /* empty */
+ | rpki_proto_opts rpki_proto_item ';'
+ ;
+
+rpki_proto:
+   rpki_proto_start proto_name '{' rpki_proto_opts '}'
+
+CF_CODE
+
+CF_END
diff --git a/proto/rpki/rpki.c b/proto/rpki/rpki.c
new file mode 100644 (file)
index 0000000..301769f
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ *     BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol
+ *
+ *     (c) 2015 CZ.NIC
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+/**
+ * DOC: The Resource Public Key Infrastructure (RPKI) to Router Protocol
+ */
+
+#define LOCAL_DEBUG
+
+#include "proto/rpki/rpki.h"
+
+static struct proto *
+rpki_init(struct proto_config *c)
+{
+  struct proto *p = proto_new(c, sizeof(struct rpki_proto));
+
+  log(L_DEBUG "------------- rpki_init -------------");
+
+  /* TODO: Add defaults */
+  return p;
+}
+
+static int
+rpki_start(struct proto *p)
+{
+  struct proto_rpki *rpki = (struct proto_rpki *) p;
+  struct rpki_config *cf = (struct rpki_config *) (p->cf);
+
+  log(L_DEBUG "------------- rpki_start -------------");
+
+  return PS_UP;
+}
+
+static int
+rpki_shutdown(struct proto *p)
+{
+  struct proto_rpki *rp = (struct proto_rpki *) p;
+
+  log(L_DEBUG "------------- rpki_shutdown -------------");
+
+  return PS_DOWN;
+}
+
+static int
+rpki_reconfigure(struct proto *p, struct proto_config *c)
+{
+  struct proto_rpki *rpki = (struct proto_rpki *) p;
+  struct rpki_config *new = (struct rpki_config *) c;
+
+  log(L_DEBUG "------------- rpki_reconfigure -------------");
+
+  return 1;
+}
+
+static void
+rpki_copy_config(struct proto_config *dest, struct proto_config *src)
+{
+  struct rpki_config *d = (struct rpki_config *) dest;
+  struct rpki_config *s = (struct rpki_config *) src;
+
+  log(L_DEBUG "------------- rpki_copy_config -------------");
+}
+
+static void
+rpki_get_status(struct proto *p, byte *buf)
+{
+  struct proto_rpki *rpki = (struct proto_rpki *) p;
+
+  log(L_DEBUG "------------- rpki_get_status -------------");
+}
+
+struct protocol proto_rpki = {
+  .name =              "RPKI",
+  .template =          "rpki%d",
+//  .attr_class =      EAP_BGP,
+//  .preference =      DEF_PREF_BGP,
+  .config_size =       sizeof(struct rpki_config),
+  .init =              rpki_init,
+  .start =             rpki_start,
+  .shutdown =          rpki_shutdown,
+//  .cleanup =                 rpki_cleanup,
+  .reconfigure =       rpki_reconfigure,
+  .copy_config =       rpki_copy_config,
+  .get_status =        rpki_get_status,
+//  .get_attr =                rpki_get_attr,
+//  .get_route_info =  rpki_get_route_info,
+//  .show_proto_info =         rpki_show_proto_info
+};
diff --git a/proto/rpki/rpki.h b/proto/rpki/rpki.h
new file mode 100644 (file)
index 0000000..6e79053
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *     BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol
+ *
+ *     (c) 2015 CZ.NIC
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_RPKI_H_
+#define _BIRD_RPKI_H_
+
+#include "nest/bird.h"
+#include "nest/protocol.h"
+
+struct cache_server {
+  ip_addr ip;
+  u16 port;
+};
+
+struct rpki_config {
+  struct proto_config c;
+  struct cache_server remote;
+};
+
+struct rpki_proto {
+  struct proto p;
+};
+
+
+#endif /* _BIRD_RPKI_H_ */
index a9e46e274c2f85488bf4f3b2f88295404ad139a6..047a49ca2d49ec08f6134a1ab0f746f295bc90ae 100644 (file)
@@ -43,6 +43,7 @@
 #undef CONFIG_BGP
 #undef CONFIG_OSPF
 #undef CONFIG_PIPE
+#undef CONFIG_RPKI
 
 /* We use multithreading */
 #undef USE_PTHREADS