]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/ldp_snmp.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ldpd / ldp_snmp.c
index 3f59d18aa8e76da640eacc1c620ea635fefaa4b5..9a26a8d17be6d9ff9524a48bbd81fbd380043eee 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * LDP SNMP support
  * Copyright (C) 2020 Volta Networks, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -36,7 +23,7 @@
 #include "memory.h"
 #include "smux.h"
 #include "libfrr.h"
-#include "version.h"
+#include "lib/version.h"
 #include "ldpd.h"
 #include "ldpe.h"
 
@@ -301,8 +288,7 @@ static uint8_t *ldpEntityTable(struct variable *v, oid name[], size_t *length,
 
                /* Append index */
                *length = LDP_ENTITY_TOTAL_LEN;
-               oid_copy_addr(name + v->namelen, &entityLdpId,
-                             IN_ADDR_SIZE);
+               oid_copy_in_addr(name + v->namelen, &entityLdpId);
                name[v->namelen + 4] = 0;
                name[v->namelen + 5] = 0;
                name[v->namelen + 6] = LDP_DEFAULT_ENTITY_INDEX;
@@ -402,8 +388,7 @@ static uint8_t *ldpEntityStatsTable(struct variable *v, oid name[],
 
                /* Append index */
                *length = LDP_ENTITY_TOTAL_LEN;
-               oid_copy_addr(name + v->namelen, &entityLdpId,
-                             IN_ADDR_SIZE);
+               oid_copy_in_addr(name + v->namelen, &entityLdpId);
                name[v->namelen + 4] = 0;
                name[v->namelen + 5] = 0;
                name[v->namelen + 6] = LDP_DEFAULT_ENTITY_INDEX;
@@ -640,13 +625,11 @@ static uint8_t *ldpHelloAdjacencyTable(struct variable *v, oid name[], size_t *l
 
                struct in_addr peerLdpId = ctl_adj->id;
 
-               oid_copy_addr(name + v->namelen, &entityLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen, &entityLdpId);
                name[v->namelen + 4] = 0;
                name[v->namelen + 5] = 0;
                name[v->namelen + 6] = LDP_DEFAULT_ENTITY_INDEX;
-               oid_copy_addr(name + v->namelen + 7, &peerLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen + 7, &peerLdpId);
                name[v->namelen + 11] = 0;
                name[v->namelen + 12] = 0;
                name[v->namelen + 13] = adjacencyIndex;
@@ -804,14 +787,12 @@ static uint8_t *ldpPeerTable(struct variable *v, oid name[], size_t *length,
                memcpy(name, v->name, v->namelen * sizeof(oid));
 
                /* Append index */
-               oid_copy_addr(name + v->namelen, &entityLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen, &entityLdpId);
 
                name[v->namelen + 4] = 0;
                name[v->namelen + 5] = 0;
                name[v->namelen + 6] = entityIndex;
-               oid_copy_addr(name + v->namelen + 7, &peerLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen + 7, &peerLdpId);
                name[v->namelen + 11] = 0;
                name[v->namelen + 12] = 0;
 
@@ -875,14 +856,12 @@ static uint8_t *ldpSessionTable(struct variable *v, oid name[], size_t *length,
                memcpy(name, v->name, v->namelen * sizeof(oid));
 
                /* Append index */
-               oid_copy_addr(name + v->namelen, &entityLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen, &entityLdpId);
 
                name[v->namelen + 4] = 0;
                name[v->namelen + 5] = 0;
                name[v->namelen + 6] = entityIndex;
-               oid_copy_addr(name + v->namelen + 7, &peerLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen + 7, &peerLdpId);
                name[v->namelen + 11] = 0;
                name[v->namelen + 12] = 0;
 
@@ -961,13 +940,11 @@ static uint8_t *ldpSessionStatsTable(struct variable *v, oid name[],
                memcpy(name, v->name, v->namelen * sizeof(oid));
 
                /* Append index */
-               oid_copy_addr(name + v->namelen, &entityLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen, &entityLdpId);
                name[v->namelen + 4] = 0;
                name[v->namelen + 5] = 0;
                name[v->namelen + 6] = entityIndex;
-               oid_copy_addr(name + v->namelen + 7, &peerLdpId,
-                       sizeof(struct in_addr));
+               oid_copy_in_addr(name + v->namelen + 7, &peerLdpId);
                name[v->namelen + 11] = 0;
                name[v->namelen + 12] = 0;
 
@@ -1147,15 +1124,15 @@ ldpTrapSession(struct nbr * nbr, unsigned int sptrap)
        entityIndex = LDP_DEFAULT_ENTITY_INDEX;
        peerLdpId = ctl_nbr->id;
 
-        oid_copy_addr(index, &entityLdpId, sizeof(struct in_addr));
-        index[4] = 0;
-        index[5] = 0;
-        index[6] = entityIndex;
-        oid_copy_addr(&index[7], &peerLdpId, sizeof(struct in_addr));
-        index[11] = 0;
-        index[12] = 0;
+       oid_copy_in_addr(index, &entityLdpId);
+       index[4] = 0;
+       index[5] = 0;
+       index[6] = entityIndex;
+       oid_copy_in_addr(&index[7], &peerLdpId);
+       index[11] = 0;
+       index[12] = 0;
 
-        index[LDP_PEER_ENTRY_MAX_IDX_LEN] = 0;
+       index[LDP_PEER_ENTRY_MAX_IDX_LEN] = 0;
 
         smux_trap(ldpe_variables, array_size(ldpe_variables), ldp_trap_oid,
                   array_size(ldp_trap_oid), ldp_oid,
@@ -1176,7 +1153,7 @@ ldpTrapSessionDown(struct nbr * nbr)
        ldpTrapSession(nbr, LDPSESSIONDOWN);
 }
 
-static int ldp_snmp_agentx_enabled()
+static int ldp_snmp_agentx_enabled(void)
 {
        main_imsg_compose_both(IMSG_AGENTX_ENABLED, NULL, 0);