0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

RPKI: add new protocol skeleton

This commit is contained in:
Pavel Tvrdík 2015-09-17 17:15:30 +02:00
parent c7b99a932c
commit 98bf329be6
10 changed files with 185 additions and 3 deletions

View 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

View 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);

View 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

View File

@ -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

1
proto/rpki/Doc Normal file
View File

@ -0,0 +1 @@
C rpki.c

5
proto/rpki/Makefile Normal file
View File

@ -0,0 +1,5 @@
source=rpki.c
root-rel=../../
dir-name=proto/rpki
include ../../Rules

48
proto/rpki/config.Y Normal file
View File

@ -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

93
proto/rpki/rpki.c Normal file
View File

@ -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
};

30
proto/rpki/rpki.h Normal file
View File

@ -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_ */

View File

@ -43,6 +43,7 @@
#undef CONFIG_BGP
#undef CONFIG_OSPF
#undef CONFIG_PIPE
#undef CONFIG_RPKI
/* We use multithreading */
#undef USE_PTHREADS