From: job Date: Thu, 20 Apr 2023 15:05:44 +0000 (+0000) Subject: ASPAs solely containing providers limited to one AFI, imply AS 0 for the other AFI X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=14b6717b9dd86f0924e19eb2fabf01152a9d9cf0;p=openbsd ASPAs solely containing providers limited to one AFI, imply AS 0 for the other AFI OK claudio@ --- diff --git a/usr.sbin/rpki-client/output-json.c b/usr.sbin/rpki-client/output-json.c index 95bb5b1fdb2..cf752e7ed02 100644 --- a/usr.sbin/rpki-client/output-json.c +++ b/usr.sbin/rpki-client/output-json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output-json.c,v 1.31 2023/01/13 08:58:36 claudio Exp $ */ +/* $OpenBSD: output-json.c,v 1.32 2023/04/20 15:05:44 job Exp $ */ /* * Copyright (c) 2019 Claudio Jeker * @@ -115,6 +115,7 @@ static int print_vap(FILE *out, struct vap *v, enum afi afi) { size_t i; + int foundafi = 0; if (fprintf(out, "\t\t\t{ \"customer_asid\": %u, \"providers\": [", v->custasid) < 0) @@ -122,12 +123,19 @@ print_vap(FILE *out, struct vap *v, enum afi afi) for (i = 0; i < v->providersz; i++) { if (v->providers[i].afi != 0 && v->providers[i].afi != afi) continue; + foundafi = 1; if (fprintf(out, "%u", v->providers[i].as) < 0) return -1; if (i + 1 < v->providersz) if (fprintf(out, ", ") < 0) return -1; } + + if (!foundafi) { + if (fprintf(out, "0") < 0) + return -1; + } + if (fprintf(out, "], \"expires\": %lld }", (long long)v->expires) < 0) return -1;