sync with OpenBSD -current
This commit is contained in:
parent
18e54d401d
commit
9394581c89
58 changed files with 711 additions and 763 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: output_json.c,v 1.38 2024/01/11 13:09:41 claudio Exp $ */
|
||||
/* $OpenBSD: output_json.c,v 1.39 2024/01/23 16:16:15 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -589,12 +589,13 @@ json_attr(u_char *data, size_t len, int reqflags, int addpath)
|
|||
{
|
||||
struct bgpd_addr prefix;
|
||||
struct in_addr id;
|
||||
struct ibuf ibuf, *buf = &ibuf;
|
||||
char *aspath;
|
||||
u_char *path;
|
||||
uint32_t as, pathid;
|
||||
uint16_t alen, afi, off, short_as;
|
||||
uint8_t flags, type, safi, aid, prefixlen;
|
||||
int e4, e2, pos;
|
||||
int e4, e2;
|
||||
|
||||
if (len < 3) {
|
||||
warnx("Too short BGP attribute");
|
||||
|
@ -780,48 +781,39 @@ bad_len:
|
|||
json_do_string("nexthop", log_addr(&nexthop));
|
||||
}
|
||||
|
||||
ibuf_from_buffer(buf, data, alen);
|
||||
|
||||
json_do_array("NLRI");
|
||||
while (alen > 0) {
|
||||
while (ibuf_size(buf) > 0) {
|
||||
json_do_object("prefix", 1);
|
||||
if (addpath) {
|
||||
if (alen <= sizeof(pathid)) {
|
||||
json_do_string("error", "bad path-id");
|
||||
break;
|
||||
}
|
||||
memcpy(&pathid, data, sizeof(pathid));
|
||||
pathid = ntohl(pathid);
|
||||
data += sizeof(pathid);
|
||||
alen -= sizeof(pathid);
|
||||
}
|
||||
if (addpath)
|
||||
if (ibuf_get_n32(buf, &pathid) == -1)
|
||||
goto bad_len;
|
||||
switch (aid) {
|
||||
case AID_INET6:
|
||||
pos = nlri_get_prefix6(data, alen, &prefix,
|
||||
&prefixlen);
|
||||
if (nlri_get_prefix6(buf, &prefix,
|
||||
&prefixlen) == -1)
|
||||
goto bad_len;
|
||||
break;
|
||||
case AID_VPN_IPv4:
|
||||
pos = nlri_get_vpn4(data, alen, &prefix,
|
||||
&prefixlen, 1);
|
||||
break;
|
||||
if (nlri_get_vpn4(buf, &prefix,
|
||||
&prefixlen, 1) == -1)
|
||||
goto bad_len;
|
||||
break;
|
||||
case AID_VPN_IPv6:
|
||||
pos = nlri_get_vpn6(data, alen, &prefix,
|
||||
&prefixlen, 1);
|
||||
break;
|
||||
if (nlri_get_vpn6(buf, &prefix,
|
||||
&prefixlen, 1) == -1)
|
||||
goto bad_len;
|
||||
break;
|
||||
default:
|
||||
json_do_printf("error", "unhandled AID: %d",
|
||||
aid);
|
||||
return;
|
||||
}
|
||||
if (pos == -1) {
|
||||
json_do_printf("error", "bad %s prefix",
|
||||
aid2str(aid));
|
||||
break;
|
||||
}
|
||||
json_do_printf("prefix", "%s/%u", log_addr(&prefix),
|
||||
prefixlen);
|
||||
if (addpath)
|
||||
json_do_uint("path_id", pathid);
|
||||
data += pos;
|
||||
alen -= pos;
|
||||
json_do_end();
|
||||
}
|
||||
json_do_end();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue