-/* $OpenBSD: output.c,v 1.16 2021/04/26 18:23:20 claudio Exp $ */
+/* $OpenBSD: output.c,v 1.17 2021/05/27 08:29:07 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
printf("\n");
}
+static void
+show_neighbor_capa_add_path(struct capabilities *capa)
+{
+ const char *mode;
+ int comma;
+ u_int8_t i;
+
+ printf(" Add-path: ");
+ for (i = 0, comma = 0; i < AID_MAX; i++) {
+ switch (capa->add_path[i]) {
+ case 0:
+ default:
+ continue;
+ case CAPA_AP_RECV:
+ mode = "recv";
+ break;
+ case CAPA_AP_SEND:
+ mode = "send";
+ break;
+ case CAPA_AP_BIDIR:
+ mode = "bidir";
+ }
+ printf("%s%s %s", comma ? ", " : "", aid2str(i), mode);
+ comma = 1;
+ }
+ printf("\n");
+}
+
static void
show_neighbor_capa_restart(struct capabilities *capa)
{
p->stats.prefix_sent_withdraw, p->stats.prefix_rcvd_withdraw);
printf(" %-15s %10llu %10llu\n", "End-of-Rib",
p->stats.prefix_sent_eor, p->stats.prefix_rcvd_eor);
+ printf(" Route Refresh statistics:\n");
+ printf(" %-15s %10llu %10llu\n", "Request",
+ p->stats.refresh_sent_req, p->stats.refresh_rcvd_req);
+ printf(" %-15s %10llu %10llu\n", "Begin-of-RR",
+ p->stats.refresh_sent_borr, p->stats.refresh_rcvd_borr);
+ printf(" %-15s %10llu %10llu\n", "End-of-RR",
+ p->stats.refresh_sent_eorr, p->stats.refresh_rcvd_eorr);
}
static void
const char *errstr;
struct in_addr ina;
char *s;
- int hascapamp = 0;
+ int hascapamp, hascapaap;
u_int8_t i;
if ((p->conf.remote_addr.aid == AID_INET &&
fmt_monotime(p->stats.last_read),
p->holdtime, p->holdtime/3);
printf(" Last write %s\n", fmt_monotime(p->stats.last_write));
- for (i = 0; i < AID_MAX; i++)
+
+ hascapamp = 0;
+ hascapaap = 0;
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.peer.mp[i])
hascapamp = 1;
- if (hascapamp || p->capa.peer.refresh ||
- p->capa.peer.grestart.restart || p->capa.peer.as4byte) {
+ if (p->capa.peer.add_path[i])
+ hascapaap = 1;
+ }
+ if (hascapamp || hascapaap || p->capa.peer.grestart.restart ||
+ p->capa.peer.refresh || p->capa.peer.enhanced_rr ||
+ p->capa.peer.as4byte) {
printf(" Neighbor capabilities:\n");
if (hascapamp)
show_neighbor_capa_mp(&p->capa.peer);
+ if (p->capa.peer.as4byte)
+ printf(" 4-byte AS numbers\n");
if (p->capa.peer.refresh)
printf(" Route Refresh\n");
+ if (p->capa.peer.enhanced_rr)
+ printf(" Enhanced Route Refresh\n");
if (p->capa.peer.grestart.restart)
show_neighbor_capa_restart(&p->capa.peer);
- if (p->capa.peer.as4byte)
- printf(" 4-byte AS numbers\n");
+ if (hascapaap)
+ show_neighbor_capa_add_path(&p->capa.peer);
}
- for (i = 0; i < AID_MAX; i++)
+
+ hascapamp = 0;
+ hascapaap = 0;
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.neg.mp[i])
hascapamp = 1;
- if (hascapamp || p->capa.neg.refresh ||
- p->capa.neg.grestart.restart || p->capa.neg.as4byte) {
+ if (p->capa.neg.add_path[i])
+ hascapaap = 1;
+ }
+ if (hascapamp || hascapaap || p->capa.neg.grestart.restart ||
+ p->capa.neg.refresh || p->capa.neg.enhanced_rr ||
+ p->capa.neg.as4byte) {
printf(" Negotiated capabilities:\n");
if (hascapamp)
show_neighbor_capa_mp(&p->capa.neg);
+ if (p->capa.neg.as4byte)
+ printf(" 4-byte AS numbers\n");
if (p->capa.neg.refresh)
printf(" Route Refresh\n");
+ if (p->capa.neg.enhanced_rr)
+ printf(" Enhanced Route Refresh\n");
if (p->capa.neg.grestart.restart)
show_neighbor_capa_restart(&p->capa.neg);
- if (p->capa.neg.as4byte)
- printf(" 4-byte AS numbers\n");
+ if (hascapaap)
+ show_neighbor_capa_add_path(&p->capa.neg);
}
printf("\n");
-/* $OpenBSD: output_json.c,v 1.10 2021/05/03 14:01:56 claudio Exp $ */
+/* $OpenBSD: output_json.c,v 1.11 2021/05/27 08:29:07 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
static void
json_neighbor_capabilities(struct capabilities *capa)
{
- int hascapamp;
+ int hascapamp = 0, hascapaap = 0;
uint8_t i;
- for (i = 0; i < AID_MAX; i++)
+ for (i = 0; i < AID_MAX; i++) {
if (capa->mp[i])
hascapamp = 1;
- if (!hascapamp && !capa->refresh && !capa->grestart.restart &&
- !capa->as4byte)
+ if (capa->add_path[i])
+ hascapaap = 1;
+ }
+ if (!hascapamp && !hascapaap && !capa->grestart.restart &&
+ !capa->refresh && !capa->enhanced_rr && !capa->as4byte)
return;
json_do_object("capabilities");
json_do_bool("as4byte", capa->as4byte);
json_do_bool("refresh", capa->refresh);
+ json_do_bool("enhanced_refresh", capa->enhanced_rr);
if (hascapamp) {
json_do_array("multiprotocol");
json_do_end();
}
+ if (hascapaap) {
+ json_do_array("add-path");
+ for (i = 0; i < AID_MAX; i++)
+ if (capa->add_path[i]) {
+ json_do_object("add-path-elm");
+ json_do_printf("family", "%s", aid2str(i));
+ switch (capa->add_path[i]) {
+ case CAPA_AP_RECV:
+ json_do_printf("mode", "recv");
+ break;
+ case CAPA_AP_SEND:
+ json_do_printf("mode", "send");
+ break;
+ case CAPA_AP_BIDIR:
+ json_do_printf("mode", "bidir");
+ break;
+ default:
+ json_do_printf("mode", "unknown %d",
+ capa->add_path[i]);
+ break;
+ }
+ json_do_end();
+ }
+ json_do_end();
+ }
json_do_end();
}
json_do_end();
+ json_do_object("route-refresh");
+
+ json_do_object("sent");
+ json_do_uint("request", p->stats.refresh_sent_req);
+ json_do_uint("borr", p->stats.refresh_sent_borr);
+ json_do_uint("eorr", p->stats.refresh_sent_eorr);
+ json_do_end();
+
+ json_do_object("received");
+ json_do_uint("request", p->stats.refresh_rcvd_req);
+ json_do_uint("borr", p->stats.refresh_rcvd_borr);
+ json_do_uint("eorr", p->stats.refresh_rcvd_eorr);
+ json_do_end();
+
+ json_do_end();
+
json_do_end();
}