]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_snmp.c
Merge pull request #8465 from opensourcerouting/vtysh-scan-snafu
[mirror_frr.git] / ospfd / ospf_snmp.c
index 66dd9c7ca4ac9dbbf4d650a1aa7f7c0b70efa3ae..43b998ac5bfc1f182fe8405b1f70e5136f5a42ca 100644 (file)
@@ -674,7 +674,7 @@ static struct ospf_area *ospfAreaLookup(struct variable *v, oid name[],
                if (area == NULL)
                        return NULL;
 
-               oid_copy_addr(name + v->namelen, addr, sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen, addr);
                *length = sizeof(struct in_addr) + v->namelen;
 
                return area;
@@ -800,7 +800,7 @@ static struct ospf_area *ospfStubAreaLookup(struct variable *v, oid name[],
                if (area == NULL)
                        return NULL;
 
-               oid_copy_addr(name + v->namelen, addr, sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen, addr);
                /* Set TOS 0. */
                name[v->namelen + sizeof(struct in_addr)] = 0;
                *length = v->namelen + sizeof(struct in_addr) + 1;
@@ -1008,15 +1008,14 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
 
                                /* Fill in value. */
                                offset = name + v->namelen;
-                               oid_copy_addr(offset, area_id, IN_ADDR_SIZE);
+                               oid_copy_in_addr(offset, area_id);
                                offset += IN_ADDR_SIZE;
                                *offset = lsa->data->type;
                                offset++;
-                               oid_copy_addr(offset, &lsa->data->id,
-                                             IN_ADDR_SIZE);
+                               oid_copy_in_addr(offset, &lsa->data->id);
                                offset += IN_ADDR_SIZE;
-                               oid_copy_addr(offset, &lsa->data->adv_router,
-                                             IN_ADDR_SIZE);
+                               oid_copy_in_addr(offset,
+                                                &lsa->data->adv_router);
 
                                return lsa;
                        }
@@ -1170,9 +1169,9 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
 
                                /* Fill in value. */
                                offset = name + v->namelen;
-                               oid_copy_addr(offset, area_id, IN_ADDR_SIZE);
+                               oid_copy_in_addr(offset, area_id);
                                offset += IN_ADDR_SIZE;
-                               oid_copy_addr(offset, range_net, IN_ADDR_SIZE);
+                               oid_copy_in_addr(offset, range_net);
 
                                return range;
                        }
@@ -1236,7 +1235,6 @@ static struct ospf_nbr_nbma *ospfHostLookup(struct variable *v, oid *name,
                                            size_t *length,
                                            struct in_addr *addr, int exact)
 {
-       int len;
        struct ospf_nbr_nbma *nbr_nbma;
        struct ospf *ospf;
 
@@ -1257,29 +1255,9 @@ static struct ospf_nbr_nbma *ospfHostLookup(struct variable *v, oid *name,
 
                nbr_nbma = ospf_nbr_nbma_lookup(ospf, *addr);
 
-               return nbr_nbma;
-       } else {
-               len = *length - v->namelen;
-               if (len > 4)
-                       len = 4;
-
-               oid2in_addr(name + v->namelen, len, addr);
-
-               nbr_nbma =
-                       ospf_nbr_nbma_lookup_next(ospf, addr, len == 0 ? 1 : 0);
-
-               if (nbr_nbma == NULL)
-                       return NULL;
-
-               oid_copy_addr(name + v->namelen, addr, IN_ADDR_SIZE);
-
-               /* Set TOS 0. */
-               name[v->namelen + IN_ADDR_SIZE] = 0;
-
-               *length = v->namelen + IN_ADDR_SIZE + 1;
-
                return nbr_nbma;
        }
+
        return NULL;
 }
 
@@ -1594,7 +1572,7 @@ static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
                if (oi) {
                        *length = v->namelen + IN_ADDR_SIZE + 1;
                        offset = name + v->namelen;
-                       oid_copy_addr(offset, ifaddr, IN_ADDR_SIZE);
+                       oid_copy_in_addr(offset, ifaddr);
                        offset += IN_ADDR_SIZE;
                        *offset = *ifindex;
                        return oi;
@@ -1738,7 +1716,7 @@ static struct ospf_interface *ospfIfMetricLookup(struct variable *v, oid *name,
                if (oi) {
                        *length = v->namelen + IN_ADDR_SIZE + 1 + 1;
                        offset = name + v->namelen;
-                       oid_copy_addr(offset, ifaddr, IN_ADDR_SIZE);
+                       oid_copy_in_addr(offset, ifaddr);
                        offset += IN_ADDR_SIZE;
                        *offset = *ifindex;
                        offset++;
@@ -1927,9 +1905,9 @@ ospfVirtIfLookup(struct variable *v, oid *name, size_t *length,
 
                if (vl_data) {
                        *length = v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE;
-                       oid_copy_addr(name + v->namelen, area_id, IN_ADDR_SIZE);
-                       oid_copy_addr(name + v->namelen + IN_ADDR_SIZE,
-                                     neighbor, IN_ADDR_SIZE);
+                       oid_copy_in_addr(name + v->namelen, area_id);
+                       oid_copy_in_addr(name + v->namelen + IN_ADDR_SIZE,
+                                        neighbor);
                        return vl_data;
                }
        }
@@ -2104,8 +2082,7 @@ static struct ospf_neighbor *ospfNbrLookup(struct variable *v, oid *name,
 
                if (nbr) {
                        *length = v->namelen + IN_ADDR_SIZE + 1;
-                       oid_copy_addr(name + v->namelen, nbr_addr,
-                                     IN_ADDR_SIZE);
+                       oid_copy_in_addr(name + v->namelen, nbr_addr);
                        name[v->namelen + IN_ADDR_SIZE] = *ifindex;
                        return nbr;
                }
@@ -2328,10 +2305,9 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
 
                        *offset = OSPF_AS_EXTERNAL_LSA;
                        offset++;
-                       oid_copy_addr(offset, &lsa->data->id, IN_ADDR_SIZE);
+                       oid_copy_in_addr(offset, &lsa->data->id);
                        offset += IN_ADDR_SIZE;
-                       oid_copy_addr(offset, &lsa->data->adv_router,
-                                     IN_ADDR_SIZE);
+                       oid_copy_in_addr(offset, &lsa->data->adv_router);
 
                        return lsa;
                }
@@ -2461,7 +2437,7 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)
                zlog_info("%s: trap sent: %pI4 now %s", __func__,
                          &on->address.u.prefix4, msgbuf);
 
-       oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
+       oid_copy_in_addr(index, &(on->address.u.prefix4));
        index[IN_ADDR_SIZE] = 0;
 
        smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
@@ -2476,7 +2452,7 @@ static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
 
        zlog_info("ospfTrapVirtNbrStateChange trap sent");
 
-       oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
+       oid_copy_in_addr(index, &(on->address.u.prefix4));
        index[IN_ADDR_SIZE] = 0;
 
        smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
@@ -2520,7 +2496,7 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi)
                          &oi->address->u.prefix4,
                          lookup_msg(ospf_ism_state_msg, oi->state, NULL));
 
-       oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
+       oid_copy_in_addr(index, &(oi->address->u.prefix4));
        index[IN_ADDR_SIZE] = 0;
 
        smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
@@ -2535,7 +2511,7 @@ static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
 
        zlog_info("ospfTrapVirtIfStateChange trap sent");
 
-       oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
+       oid_copy_in_addr(index, &(oi->address->u.prefix4));
        index[IN_ADDR_SIZE] = 0;
 
        smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
@@ -2586,4 +2562,5 @@ static int ospf_snmp_module_init(void)
 
 FRR_MODULE_SETUP(.name = "ospfd_snmp", .version = FRR_VERSION,
                 .description = "ospfd AgentX SNMP module",
-                .init = ospf_snmp_module_init, )
+                .init = ospf_snmp_module_init,
+);