summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rpki-client/extern.h6
-rw-r--r--usr.sbin/rpki-client/output-bird.c79
-rw-r--r--usr.sbin/rpki-client/output.c6
3 files changed, 82 insertions, 9 deletions
diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h
index 127db60fa37..9ca0d4d2441 100644
--- a/usr.sbin/rpki-client/extern.h
+++ b/usr.sbin/rpki-client/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.23 2019/12/06 09:27:12 claudio Exp $ */
+/* $OpenBSD: extern.h,v 1.24 2020/03/06 17:36:42 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -374,7 +374,9 @@ FILE *output_createtmp(char *);
void output_cleantmp(void);
void output_finish(FILE *);
int output_bgpd(FILE *, struct vrp_tree *);
-int output_bird(FILE *, struct vrp_tree *);
+int output_bird1v4(FILE *, struct vrp_tree *);
+int output_bird1v6(FILE *, struct vrp_tree *);
+int output_bird2(FILE *, struct vrp_tree *);
int output_csv(FILE *, struct vrp_tree *);
int output_json(FILE *, struct vrp_tree *);
diff --git a/usr.sbin/rpki-client/output-bird.c b/usr.sbin/rpki-client/output-bird.c
index a15faa69164..e9067b402ed 100644
--- a/usr.sbin/rpki-client/output-bird.c
+++ b/usr.sbin/rpki-client/output-bird.c
@@ -1,6 +1,7 @@
-/* $OpenBSD: output-bird.c,v 1.6 2019/12/04 23:03:05 benno Exp $ */
+/* $OpenBSD: output-bird.c,v 1.7 2020/03/06 17:36:42 benno Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
+ * Copyright (c) 2020 Robert Scheck <robert@fedoraproject.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -21,7 +22,7 @@
#include "extern.h"
int
-output_bird(FILE *out, struct vrp_tree *vrps)
+output_bird1v4(FILE *out, struct vrp_tree *vrps)
{
extern const char *bird_tablename;
char buf[64];
@@ -31,10 +32,78 @@ output_bird(FILE *out, struct vrp_tree *vrps)
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
- ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
- if (fprintf(out, "\troa %s max %u as %u;\n", buf, v->maxlength,
- v->asid) < 0)
+ if (v->afi == AFI_IPV4) {
+ ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
+ if (fprintf(out, "\troa %s max %u as %u;\n", buf,
+ v->maxlength, v->asid) < 0)
+ return -1;
+ }
+ }
+
+ if (fprintf(out, "}\n") < 0)
return -1;
+ return 0;
+}
+
+int
+output_bird1v6(FILE *out, struct vrp_tree *vrps)
+{
+ extern const char *bird_tablename;
+ char buf[64];
+ struct vrp *v;
+
+ if (fprintf(out, "roa table %s {\n", bird_tablename) < 0)
+ return -1;
+
+ RB_FOREACH(v, vrp_tree, vrps) {
+ if (v->afi == AFI_IPV6) {
+ ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
+ if (fprintf(out, "\troa %s max %u as %u;\n", buf,
+ v->maxlength, v->asid) < 0)
+ return -1;
+ }
+ }
+
+ if (fprintf(out, "}\n") < 0)
+ return -1;
+ return 0;
+}
+
+int
+output_bird2(FILE *out, struct vrp_tree *vrps)
+{
+ extern const char *bird_tablename;
+ char buf[64];
+ struct vrp *v;
+ time_t now = time(NULL);
+
+ if (fprintf(out, "define force_roa_table_update = %lld;\n\n"
+ "roa4 table %s4;\nroa6 table %s6;\n\n"
+ "protocol static {\n\troa4 { table %s4; };\n\n",
+ (long long) now, bird_tablename, bird_tablename,
+ bird_tablename) < 0)
+ return -1;
+
+ RB_FOREACH(v, vrp_tree, vrps) {
+ if (v->afi == AFI_IPV4) {
+ ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
+ if (fprintf(out, "\troute %s max %u as %u;\n", buf,
+ v->maxlength, v->asid) < 0)
+ return -1;
+ }
+ }
+
+ if (fprintf(out, "}\n\nprotocol static {\n\troa6 { table %s6; };\n\n",
+ bird_tablename) < 0)
+ return -1;
+
+ RB_FOREACH(v, vrp_tree, vrps) {
+ if (v->afi == AFI_IPV6) {
+ ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
+ if (fprintf(out, "\troute %s max %u as %u;\n", buf,
+ v->maxlength, v->asid) < 0)
+ return -1;
+ }
}
if (fprintf(out, "}\n") < 0)
diff --git a/usr.sbin/rpki-client/output.c b/usr.sbin/rpki-client/output.c
index adafc5c0b53..41c2a87b690 100644
--- a/usr.sbin/rpki-client/output.c
+++ b/usr.sbin/rpki-client/output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output.c,v 1.5 2019/12/19 16:32:44 claudio Exp $ */
+/* $OpenBSD: output.c,v 1.6 2020/03/06 17:36:42 benno Exp $ */
/*
* Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org>
*
@@ -40,7 +40,9 @@ struct outputs {
int (*fn)(FILE *, struct vrp_tree *);
} outputs[] = {
{ FORMAT_OPENBGPD, "openbgpd", output_bgpd },
- { FORMAT_BIRD, "bird", output_bird },
+ { FORMAT_BIRD, "bird1v4", output_bird1v4 },
+ { FORMAT_BIRD, "bird1v6", output_bird1v6 },
+ { FORMAT_BIRD, "bird", output_bird2 },
{ FORMAT_CSV, "csv", output_csv },
{ FORMAT_JSON, "json", output_json },
{ 0, NULL }