diff options
| author | Andrew Cooks <acooks.at.bda@gmail.com> | 2024-06-10 14:11:47 +1000 |
|---|---|---|
| committer | Andrew Cooks <acooks.at.bda@gmail.com> | 2024-09-16 18:38:16 +1000 |
| commit | 8ea50a44b5b98e542e0c3d0d3043dc3090f87e82 (patch) | |
| tree | f036f328cd3c1fb44367b56538ee00ff44a0348a /ospf6d | |
| parent | cd6d36fd82603d803666d04fd8e539362ae9fcfa (diff) | |
ospf6d: use nth_lsdesc() in ospf6_network_lsa_get_ar_id()
Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
Diffstat (limited to 'ospf6d')
| -rw-r--r-- | ospf6d/ospf6_intra.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 470fc66084..ebecd41ad6 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -419,30 +419,13 @@ void ospf6_router_lsa_originate(struct event *thread) static char *ospf6_network_lsa_get_ar_id(struct ospf6_lsa *lsa, char *buf, int buflen, int pos) { - char *start, *end, *current; - struct ospf6_network_lsa *network_lsa; - struct ospf6_network_lsdesc *lsdesc; - - if (lsa) { - network_lsa = (struct ospf6_network_lsa - *)((caddr_t)lsa->header - + sizeof(struct ospf6_lsa_header)); - - start = (char *)network_lsa + sizeof(struct ospf6_network_lsa); - end = (char *)lsa->header + ntohs(lsa->header->length); - current = start + pos * (sizeof(struct ospf6_network_lsdesc)); + struct ospf6_network_lsdesc *lsdesc = nth_lsdesc(lsa->header, pos); - if ((current + sizeof(struct ospf6_network_lsdesc)) <= end) { - lsdesc = (struct ospf6_network_lsdesc *)current; - if (buf) { - inet_ntop(AF_INET, &lsdesc->router_id, buf, - buflen); - return buf; - } - } - } + if (!lsdesc || !buf || buflen < (1 + INET_ADDRSTRLEN)) + return NULL; - return NULL; + inet_ntop(AF_INET, &lsdesc->router_id, buf, buflen); + return buf; } static int ospf6_network_lsa_show(struct vty *vty, struct ospf6_lsa *lsa, |
