diff options
Diffstat (limited to 'usr.sbin/rpki-client/output-bird.c')
-rw-r--r-- | usr.sbin/rpki-client/output-bird.c | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/usr.sbin/rpki-client/output-bird.c b/usr.sbin/rpki-client/output-bird.c index fca66050797..f824271d324 100644 --- a/usr.sbin/rpki-client/output-bird.c +++ b/usr.sbin/rpki-client/output-bird.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output-bird.c,v 1.19 2024/02/22 12:49:42 job Exp $ */ +/* $OpenBSD: output-bird.c,v 1.20 2025/01/02 12:29:30 job Exp $ */ /* * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2020 Robert Scheck <robert@fedoraproject.org> @@ -21,16 +21,21 @@ #include "extern.h" int -output_bird1v4(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, +output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, struct vap_tree *vaps, struct vsp_tree *vsps, struct stats *st) { extern const char *bird_tablename; struct vrp *v; + time_t now = get_current_time(); if (outputheader(out, st) < 0) return -1; - if (fprintf(out, "\nroa table %s {\n", bird_tablename) < 0) + if (fprintf(out, "\ndefine 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) { @@ -38,28 +43,14 @@ output_bird1v4(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, 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, + if (fprintf(out, "\troute %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, struct brk_tree *brks, - struct vap_tree *vaps, struct vsp_tree *vsps, struct stats *st) -{ - extern const char *bird_tablename; - struct vrp *v; - - if (outputheader(out, st) < 0) - return -1; - - if (fprintf(out, "\nroa table %s {\n", bird_tablename) < 0) + if (fprintf(out, "}\n\nprotocol static {\n\troa6 { table %s6; };\n\n", + bird_tablename) < 0) return -1; RB_FOREACH(v, vrp_tree, vrps) { @@ -67,7 +58,7 @@ output_bird1v6(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, 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, + if (fprintf(out, "\troute %s max %u as %u;\n", buf, v->maxlength, v->asid) < 0) return -1; } @@ -79,20 +70,29 @@ output_bird1v6(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, } int -output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, +output_bird3(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, struct vap_tree *vaps, struct vsp_tree *vsps, struct stats *st) { extern const char *bird_tablename; struct vrp *v; + struct vap *vap; time_t now = get_current_time(); + size_t i; if (outputheader(out, st) < 0) return -1; if (fprintf(out, "\ndefine 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, + "roa4 table %s4;\nroa6 table %s6;\n", (long long)now, + bird_tablename, bird_tablename) < 0) + return -1; + + if (!excludeaspa) { + if (fprintf(out, "aspa table ASPAS;\n") < 0) + return -1; + } + + if (fprintf(out, "\nprotocol static {\n\troa4 { table %s4; };\n\n", bird_tablename) < 0) return -1; @@ -122,7 +122,34 @@ output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, } } + if (fprintf(out, "}") < 0) + return -1; + + if (excludeaspa) + return 0; + + if (fprintf(out, "\n\nprotocol static {\n\taspa { table ASPAS; " + "};\n\n") < 0) + return -1; + + RB_FOREACH(vap, vap_tree, vaps) { + if (vap->overflowed) + continue; + if (fprintf(out, "\troute aspa %d providers ", vap->custasid) <0) + return -1; + for (i = 0; i < vap->num_providers; i++) { + if (fprintf(out, "%u", vap->providers[i]) < 0) + return -1; + if (i + 1 < vap->num_providers) + if (fprintf(out, ", ") < 0) + return -1; + } + if (fprintf(out, ";\n") < 0) + return -1; + } + if (fprintf(out, "}\n") < 0) return -1; + return 0; } |