mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 14:34:22 +00:00
ospf6d: use nth_prefix() in ospf6_intra_prefix_lsa_get_prefix_str()
Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
This commit is contained in:
parent
6a7751b38a
commit
9eef5e6483
@ -769,49 +769,22 @@ static char *ospf6_intra_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
|||||||
char *buf, int buflen,
|
char *buf, int buflen,
|
||||||
int pos)
|
int pos)
|
||||||
{
|
{
|
||||||
char *start, *end, *current;
|
struct ospf6_prefix *prefix = nth_prefix(lsa->header, pos);
|
||||||
struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
|
struct in6_addr in6 = { 0 };
|
||||||
struct in6_addr in6;
|
|
||||||
int prefixnum, cnt = 0;
|
|
||||||
struct ospf6_prefix *prefix;
|
|
||||||
char tbuf[16];
|
char tbuf[16];
|
||||||
|
|
||||||
if (lsa) {
|
/* ensure buflen >= INET6_ADDRSTRLEN + '/128\0' */
|
||||||
intra_prefix_lsa = lsa_after_header(lsa->header);
|
if (!lsa || !prefix || !buf || buflen < (5 + INET6_ADDRSTRLEN))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
prefixnum = ntohs(intra_prefix_lsa->prefix_num);
|
memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
|
||||||
if ((pos + 1) > prefixnum)
|
OSPF6_PREFIX_SPACE(prefix->prefix_length));
|
||||||
return NULL;
|
inet_ntop(AF_INET6, &in6, buf, buflen);
|
||||||
|
|
||||||
start = (char *)intra_prefix_lsa
|
snprintf(tbuf, sizeof(tbuf), "/%d", prefix->prefix_length);
|
||||||
+ sizeof(struct ospf6_intra_prefix_lsa);
|
strlcat(buf, tbuf, buflen);
|
||||||
end = ospf6_lsa_end(lsa->header);
|
|
||||||
current = start;
|
|
||||||
|
|
||||||
while (current + sizeof(struct ospf6_prefix) <= end) {
|
return buf;
|
||||||
prefix = (struct ospf6_prefix *)current;
|
|
||||||
if (prefix->prefix_length == 0
|
|
||||||
|| current + OSPF6_PREFIX_SIZE(prefix) > end) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt < pos) {
|
|
||||||
current += OSPF6_PREFIX_SIZE(prefix);
|
|
||||||
cnt++;
|
|
||||||
} else {
|
|
||||||
memset(&in6, 0, sizeof(in6));
|
|
||||||
memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
|
|
||||||
OSPF6_PREFIX_SPACE(
|
|
||||||
prefix->prefix_length));
|
|
||||||
inet_ntop(AF_INET6, &in6, buf, buflen);
|
|
||||||
snprintf(tbuf, sizeof(tbuf), "/%d",
|
|
||||||
prefix->prefix_length);
|
|
||||||
strlcat(buf, tbuf, buflen);
|
|
||||||
return (buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
Loading…
Reference in New Issue
Block a user