]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: use nth_lsdesc() in ospf6_network_lsa_get_ar_id()
authorAndrew Cooks <acooks.at.bda@gmail.com>
Mon, 10 Jun 2024 04:11:47 +0000 (14:11 +1000)
committerAndrew Cooks <acooks.at.bda@gmail.com>
Mon, 16 Sep 2024 08:38:16 +0000 (18:38 +1000)
Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
ospf6d/ospf6_intra.c

index 470fc66084bd3fe02f339873e58c005669318040..ebecd41ad6b1eb1b96ad8b8486ea85b735562795 100644 (file)
@@ -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,