2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPFv2 SNMP support
|
2005-09-29 15:52:57 +02:00
|
|
|
* Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
|
2002-12-13 21:15:29 +01:00
|
|
|
* Copyright (C) 2000 IP Infusion Inc.
|
|
|
|
*
|
|
|
|
* Written by Kunihiro Ishiguro <kunihiro@zebra.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
2003-03-18 01:03:05 +01:00
|
|
|
#include <net-snmp/net-snmp-config.h>
|
2008-05-13 20:03:32 +02:00
|
|
|
#include <net-snmp/net-snmp-includes.h>
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#include "if.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "table.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "smux.h"
|
2016-06-12 17:52:50 +02:00
|
|
|
#include "libfrr.h"
|
2021-04-21 11:19:39 +02:00
|
|
|
#include "lib/version.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#include "ospfd/ospfd.h"
|
|
|
|
#include "ospfd/ospf_interface.h"
|
|
|
|
#include "ospfd/ospf_asbr.h"
|
|
|
|
#include "ospfd/ospf_lsa.h"
|
|
|
|
#include "ospfd/ospf_lsdb.h"
|
|
|
|
#include "ospfd/ospf_abr.h"
|
|
|
|
#include "ospfd/ospf_neighbor.h"
|
|
|
|
#include "ospfd/ospf_nsm.h"
|
|
|
|
#include "ospfd/ospf_flood.h"
|
2005-09-29 15:56:14 +02:00
|
|
|
#include "ospfd/ospf_ism.h"
|
2006-06-24 22:05:02 +02:00
|
|
|
#include "ospfd/ospf_dump.h"
|
2018-08-21 14:40:51 +02:00
|
|
|
#include "ospfd/ospf_route.h"
|
2016-06-12 17:32:23 +02:00
|
|
|
#include "ospfd/ospf_zebra.h"
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2022-12-05 17:43:57 +01:00
|
|
|
DEFINE_MTYPE_STATIC(OSPFD, SNMP, "OSPF SNMP");
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF2-MIB. */
|
|
|
|
#define OSPF2MIB 1,3,6,1,2,1,14
|
|
|
|
|
|
|
|
/* OSPF MIB General Group values. */
|
|
|
|
#define OSPFROUTERID 1
|
|
|
|
#define OSPFADMINSTAT 2
|
|
|
|
#define OSPFVERSIONNUMBER 3
|
|
|
|
#define OSPFAREABDRRTRSTATUS 4
|
|
|
|
#define OSPFASBDRRTRSTATUS 5
|
|
|
|
#define OSPFEXTERNLSACOUNT 6
|
|
|
|
#define OSPFEXTERNLSACKSUMSUM 7
|
|
|
|
#define OSPFTOSSUPPORT 8
|
|
|
|
#define OSPFORIGINATENEWLSAS 9
|
|
|
|
#define OSPFRXNEWLSAS 10
|
|
|
|
#define OSPFEXTLSDBLIMIT 11
|
|
|
|
#define OSPFMULTICASTEXTENSIONS 12
|
|
|
|
#define OSPFEXITOVERFLOWINTERVAL 13
|
|
|
|
#define OSPFDEMANDEXTENSIONS 14
|
|
|
|
|
|
|
|
/* OSPF MIB ospfAreaTable. */
|
|
|
|
#define OSPFAREAID 1
|
|
|
|
#define OSPFAUTHTYPE 2
|
|
|
|
#define OSPFIMPORTASEXTERN 3
|
|
|
|
#define OSPFSPFRUNS 4
|
|
|
|
#define OSPFAREABDRRTRCOUNT 5
|
|
|
|
#define OSPFASBDRRTRCOUNT 6
|
|
|
|
#define OSPFAREALSACOUNT 7
|
|
|
|
#define OSPFAREALSACKSUMSUM 8
|
|
|
|
#define OSPFAREASUMMARY 9
|
|
|
|
#define OSPFAREASTATUS 10
|
|
|
|
|
|
|
|
/* OSPF MIB ospfStubAreaTable. */
|
|
|
|
#define OSPFSTUBAREAID 1
|
|
|
|
#define OSPFSTUBTOS 2
|
|
|
|
#define OSPFSTUBMETRIC 3
|
|
|
|
#define OSPFSTUBSTATUS 4
|
|
|
|
#define OSPFSTUBMETRICTYPE 5
|
|
|
|
|
|
|
|
/* OSPF MIB ospfLsdbTable. */
|
|
|
|
#define OSPFLSDBAREAID 1
|
|
|
|
#define OSPFLSDBTYPE 2
|
|
|
|
#define OSPFLSDBLSID 3
|
|
|
|
#define OSPFLSDBROUTERID 4
|
|
|
|
#define OSPFLSDBSEQUENCE 5
|
|
|
|
#define OSPFLSDBAGE 6
|
|
|
|
#define OSPFLSDBCHECKSUM 7
|
|
|
|
#define OSPFLSDBADVERTISEMENT 8
|
|
|
|
|
|
|
|
/* OSPF MIB ospfAreaRangeTable. */
|
|
|
|
#define OSPFAREARANGEAREAID 1
|
|
|
|
#define OSPFAREARANGENET 2
|
|
|
|
#define OSPFAREARANGEMASK 3
|
|
|
|
#define OSPFAREARANGESTATUS 4
|
|
|
|
#define OSPFAREARANGEEFFECT 5
|
|
|
|
|
|
|
|
/* OSPF MIB ospfHostTable. */
|
|
|
|
#define OSPFHOSTIPADDRESS 1
|
|
|
|
#define OSPFHOSTTOS 2
|
|
|
|
#define OSPFHOSTMETRIC 3
|
|
|
|
#define OSPFHOSTSTATUS 4
|
|
|
|
#define OSPFHOSTAREAID 5
|
|
|
|
|
|
|
|
/* OSPF MIB ospfIfTable. */
|
|
|
|
#define OSPFIFIPADDRESS 1
|
|
|
|
#define OSPFADDRESSLESSIF 2
|
|
|
|
#define OSPFIFAREAID 3
|
|
|
|
#define OSPFIFTYPE 4
|
|
|
|
#define OSPFIFADMINSTAT 5
|
|
|
|
#define OSPFIFRTRPRIORITY 6
|
|
|
|
#define OSPFIFTRANSITDELAY 7
|
|
|
|
#define OSPFIFRETRANSINTERVAL 8
|
|
|
|
#define OSPFIFHELLOINTERVAL 9
|
|
|
|
#define OSPFIFRTRDEADINTERVAL 10
|
|
|
|
#define OSPFIFPOLLINTERVAL 11
|
|
|
|
#define OSPFIFSTATE 12
|
|
|
|
#define OSPFIFDESIGNATEDROUTER 13
|
|
|
|
#define OSPFIFBACKUPDESIGNATEDROUTER 14
|
|
|
|
#define OSPFIFEVENTS 15
|
|
|
|
#define OSPFIFAUTHKEY 16
|
|
|
|
#define OSPFIFSTATUS 17
|
|
|
|
#define OSPFIFMULTICASTFORWARDING 18
|
|
|
|
#define OSPFIFDEMAND 19
|
|
|
|
#define OSPFIFAUTHTYPE 20
|
|
|
|
|
|
|
|
/* OSPF MIB ospfIfMetricTable. */
|
|
|
|
#define OSPFIFMETRICIPADDRESS 1
|
|
|
|
#define OSPFIFMETRICADDRESSLESSIF 2
|
|
|
|
#define OSPFIFMETRICTOS 3
|
|
|
|
#define OSPFIFMETRICVALUE 4
|
|
|
|
#define OSPFIFMETRICSTATUS 5
|
|
|
|
|
|
|
|
/* OSPF MIB ospfVirtIfTable. */
|
|
|
|
#define OSPFVIRTIFAREAID 1
|
|
|
|
#define OSPFVIRTIFNEIGHBOR 2
|
|
|
|
#define OSPFVIRTIFTRANSITDELAY 3
|
|
|
|
#define OSPFVIRTIFRETRANSINTERVAL 4
|
|
|
|
#define OSPFVIRTIFHELLOINTERVAL 5
|
|
|
|
#define OSPFVIRTIFRTRDEADINTERVAL 6
|
|
|
|
#define OSPFVIRTIFSTATE 7
|
|
|
|
#define OSPFVIRTIFEVENTS 8
|
|
|
|
#define OSPFVIRTIFAUTHKEY 9
|
|
|
|
#define OSPFVIRTIFSTATUS 10
|
|
|
|
#define OSPFVIRTIFAUTHTYPE 11
|
|
|
|
|
|
|
|
/* OSPF MIB ospfNbrTable. */
|
|
|
|
#define OSPFNBRIPADDR 1
|
|
|
|
#define OSPFNBRADDRESSLESSINDEX 2
|
|
|
|
#define OSPFNBRRTRID 3
|
|
|
|
#define OSPFNBROPTIONS 4
|
|
|
|
#define OSPFNBRPRIORITY 5
|
|
|
|
#define OSPFNBRSTATE 6
|
|
|
|
#define OSPFNBREVENTS 7
|
|
|
|
#define OSPFNBRLSRETRANSQLEN 8
|
|
|
|
#define OSPFNBMANBRSTATUS 9
|
|
|
|
#define OSPFNBMANBRPERMANENCE 10
|
|
|
|
#define OSPFNBRHELLOSUPPRESSED 11
|
|
|
|
|
|
|
|
/* OSPF MIB ospfVirtNbrTable. */
|
|
|
|
#define OSPFVIRTNBRAREA 1
|
|
|
|
#define OSPFVIRTNBRRTRID 2
|
|
|
|
#define OSPFVIRTNBRIPADDR 3
|
|
|
|
#define OSPFVIRTNBROPTIONS 4
|
|
|
|
#define OSPFVIRTNBRSTATE 5
|
|
|
|
#define OSPFVIRTNBREVENTS 6
|
|
|
|
#define OSPFVIRTNBRLSRETRANSQLEN 7
|
|
|
|
#define OSPFVIRTNBRHELLOSUPPRESSED 8
|
|
|
|
|
|
|
|
/* OSPF MIB ospfExtLsdbTable. */
|
|
|
|
#define OSPFEXTLSDBTYPE 1
|
|
|
|
#define OSPFEXTLSDBLSID 2
|
|
|
|
#define OSPFEXTLSDBROUTERID 3
|
|
|
|
#define OSPFEXTLSDBSEQUENCE 4
|
|
|
|
#define OSPFEXTLSDBAGE 5
|
|
|
|
#define OSPFEXTLSDBCHECKSUM 6
|
|
|
|
#define OSPFEXTLSDBADVERTISEMENT 7
|
|
|
|
|
|
|
|
/* OSPF MIB ospfAreaAggregateTable. */
|
|
|
|
#define OSPFAREAAGGREGATEAREAID 1
|
|
|
|
#define OSPFAREAAGGREGATELSDBTYPE 2
|
|
|
|
#define OSPFAREAAGGREGATENET 3
|
|
|
|
#define OSPFAREAAGGREGATEMASK 4
|
|
|
|
#define OSPFAREAAGGREGATESTATUS 5
|
|
|
|
#define OSPFAREAAGGREGATEEFFECT 6
|
|
|
|
|
|
|
|
/* SYNTAX Status from OSPF-MIB. */
|
|
|
|
#define OSPF_STATUS_ENABLED 1
|
|
|
|
#define OSPF_STATUS_DISABLED 2
|
|
|
|
|
|
|
|
/* SNMP value hack. */
|
|
|
|
#define COUNTER ASN_COUNTER
|
|
|
|
#define INTEGER ASN_INTEGER
|
|
|
|
#define GAUGE ASN_GAUGE
|
|
|
|
#define TIMETICKS ASN_TIMETICKS
|
|
|
|
#define IPADDRESS ASN_IPADDRESS
|
|
|
|
#define STRING ASN_OCTET_STR
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
/* Because DR/DROther values are exhanged wrt RFC */
|
|
|
|
#define ISM_SNMP(x) \
|
|
|
|
(((x) == ISM_DROther) ? ISM_DR : ((x) == ISM_DR) ? ISM_DROther : (x))
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Declare static local variables for convenience. */
|
|
|
|
SNMP_LOCAL_VARIABLES
|
|
|
|
|
|
|
|
/* OSPF-MIB instances. */
|
2016-07-28 17:23:45 +02:00
|
|
|
static oid ospf_oid[] = {OSPF2MIB};
|
|
|
|
static oid ospf_trap_oid[] = {OSPF2MIB, 16, 2}; /* Not reverse mappable! */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* IP address 0.0.0.0. */
|
2015-09-15 12:00:09 +02:00
|
|
|
static struct in_addr ospf_empty_addr = {.s_addr = 0};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Hook functions. */
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfGeneralGroup(struct variable *, oid *, size_t *, int,
|
2009-06-02 19:40:07 +02:00
|
|
|
size_t *, WriteMethod **);
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfAreaEntry(struct variable *, oid *, size_t *, int, size_t *,
|
|
|
|
WriteMethod **);
|
|
|
|
static uint8_t *ospfStubAreaEntry(struct variable *, oid *, size_t *, int,
|
2009-06-02 19:40:07 +02:00
|
|
|
size_t *, WriteMethod **);
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfLsdbEntry(struct variable *, oid *, size_t *, int, size_t *,
|
|
|
|
WriteMethod **);
|
|
|
|
static uint8_t *ospfAreaRangeEntry(struct variable *, oid *, size_t *, int,
|
|
|
|
size_t *, WriteMethod **);
|
|
|
|
static uint8_t *ospfHostEntry(struct variable *, oid *, size_t *, int, size_t *,
|
|
|
|
WriteMethod **);
|
|
|
|
static uint8_t *ospfIfEntry(struct variable *, oid *, size_t *, int, size_t *,
|
2009-06-02 19:40:07 +02:00
|
|
|
WriteMethod **);
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfIfMetricEntry(struct variable *, oid *, size_t *, int,
|
|
|
|
size_t *, WriteMethod **);
|
|
|
|
static uint8_t *ospfVirtIfEntry(struct variable *, oid *, size_t *, int,
|
2009-06-02 19:40:07 +02:00
|
|
|
size_t *, WriteMethod **);
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfNbrEntry(struct variable *, oid *, size_t *, int, size_t *,
|
|
|
|
WriteMethod **);
|
|
|
|
static uint8_t *ospfVirtNbrEntry(struct variable *, oid *, size_t *, int,
|
|
|
|
size_t *, WriteMethod **);
|
|
|
|
static uint8_t *ospfExtLsdbEntry(struct variable *, oid *, size_t *, int,
|
|
|
|
size_t *, WriteMethod **);
|
|
|
|
static uint8_t *ospfAreaAggregateEntry(struct variable *, oid *, size_t *, int,
|
|
|
|
size_t *, WriteMethod **);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct variable ospf_variables[] = {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF general variables */
|
|
|
|
{OSPFROUTERID, IPADDRESS, RWRITE, ospfGeneralGroup, 2, {1, 1}},
|
|
|
|
{OSPFADMINSTAT, INTEGER, RWRITE, ospfGeneralGroup, 2, {1, 2}},
|
|
|
|
{OSPFVERSIONNUMBER, INTEGER, RONLY, ospfGeneralGroup, 2, {1, 3}},
|
|
|
|
{OSPFAREABDRRTRSTATUS, INTEGER, RONLY, ospfGeneralGroup, 2, {1, 4}},
|
|
|
|
{OSPFASBDRRTRSTATUS, INTEGER, RWRITE, ospfGeneralGroup, 2, {1, 5}},
|
|
|
|
{OSPFEXTERNLSACOUNT, GAUGE, RONLY, ospfGeneralGroup, 2, {1, 6}},
|
|
|
|
{OSPFEXTERNLSACKSUMSUM, INTEGER, RONLY, ospfGeneralGroup, 2, {1, 7}},
|
|
|
|
{OSPFTOSSUPPORT, INTEGER, RWRITE, ospfGeneralGroup, 2, {1, 8}},
|
|
|
|
{OSPFORIGINATENEWLSAS, COUNTER, RONLY, ospfGeneralGroup, 2, {1, 9}},
|
|
|
|
{OSPFRXNEWLSAS, COUNTER, RONLY, ospfGeneralGroup, 2, {1, 10}},
|
|
|
|
{OSPFEXTLSDBLIMIT, INTEGER, RWRITE, ospfGeneralGroup, 2, {1, 11}},
|
|
|
|
{OSPFMULTICASTEXTENSIONS,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfGeneralGroup,
|
|
|
|
2,
|
|
|
|
{1, 12}},
|
|
|
|
{OSPFEXITOVERFLOWINTERVAL,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfGeneralGroup,
|
|
|
|
2,
|
|
|
|
{1, 13}},
|
|
|
|
{OSPFDEMANDEXTENSIONS, INTEGER, RWRITE, ospfGeneralGroup, 2, {1, 14}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF area data structure. */
|
|
|
|
{OSPFAREAID, IPADDRESS, RONLY, ospfAreaEntry, 3, {2, 1, 1}},
|
|
|
|
{OSPFAUTHTYPE, INTEGER, RWRITE, ospfAreaEntry, 3, {2, 1, 2}},
|
|
|
|
{OSPFIMPORTASEXTERN, INTEGER, RWRITE, ospfAreaEntry, 3, {2, 1, 3}},
|
|
|
|
{OSPFSPFRUNS, COUNTER, RONLY, ospfAreaEntry, 3, {2, 1, 4}},
|
|
|
|
{OSPFAREABDRRTRCOUNT, GAUGE, RONLY, ospfAreaEntry, 3, {2, 1, 5}},
|
|
|
|
{OSPFASBDRRTRCOUNT, GAUGE, RONLY, ospfAreaEntry, 3, {2, 1, 6}},
|
|
|
|
{OSPFAREALSACOUNT, GAUGE, RONLY, ospfAreaEntry, 3, {2, 1, 7}},
|
|
|
|
{OSPFAREALSACKSUMSUM, INTEGER, RONLY, ospfAreaEntry, 3, {2, 1, 8}},
|
|
|
|
{OSPFAREASUMMARY, INTEGER, RWRITE, ospfAreaEntry, 3, {2, 1, 9}},
|
|
|
|
{OSPFAREASTATUS, INTEGER, RWRITE, ospfAreaEntry, 3, {2, 1, 10}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF stub area information. */
|
|
|
|
{OSPFSTUBAREAID, IPADDRESS, RONLY, ospfStubAreaEntry, 3, {3, 1, 1}},
|
|
|
|
{OSPFSTUBTOS, INTEGER, RONLY, ospfStubAreaEntry, 3, {3, 1, 2}},
|
|
|
|
{OSPFSTUBMETRIC, INTEGER, RWRITE, ospfStubAreaEntry, 3, {3, 1, 3}},
|
|
|
|
{OSPFSTUBSTATUS, INTEGER, RWRITE, ospfStubAreaEntry, 3, {3, 1, 4}},
|
|
|
|
{OSPFSTUBMETRICTYPE, INTEGER, RWRITE, ospfStubAreaEntry, 3, {3, 1, 5}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF link state database. */
|
|
|
|
{OSPFLSDBAREAID, IPADDRESS, RONLY, ospfLsdbEntry, 3, {4, 1, 1}},
|
|
|
|
{OSPFLSDBTYPE, INTEGER, RONLY, ospfLsdbEntry, 3, {4, 1, 2}},
|
|
|
|
{OSPFLSDBLSID, IPADDRESS, RONLY, ospfLsdbEntry, 3, {4, 1, 3}},
|
|
|
|
{OSPFLSDBROUTERID, IPADDRESS, RONLY, ospfLsdbEntry, 3, {4, 1, 4}},
|
|
|
|
{OSPFLSDBSEQUENCE, INTEGER, RONLY, ospfLsdbEntry, 3, {4, 1, 5}},
|
|
|
|
{OSPFLSDBAGE, INTEGER, RONLY, ospfLsdbEntry, 3, {4, 1, 6}},
|
|
|
|
{OSPFLSDBCHECKSUM, INTEGER, RONLY, ospfLsdbEntry, 3, {4, 1, 7}},
|
|
|
|
{OSPFLSDBADVERTISEMENT, STRING, RONLY, ospfLsdbEntry, 3, {4, 1, 8}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Area range table. */
|
|
|
|
{OSPFAREARANGEAREAID,
|
|
|
|
IPADDRESS,
|
2017-07-17 14:03:14 +02:00
|
|
|
RONLY,
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfAreaRangeEntry,
|
|
|
|
3,
|
|
|
|
{5, 1, 1}},
|
|
|
|
{OSPFAREARANGENET, IPADDRESS, RONLY, ospfAreaRangeEntry, 3, {5, 1, 2}},
|
|
|
|
{OSPFAREARANGEMASK,
|
|
|
|
IPADDRESS,
|
|
|
|
RWRITE,
|
|
|
|
ospfAreaRangeEntry,
|
|
|
|
3,
|
|
|
|
{5, 1, 3}},
|
|
|
|
{OSPFAREARANGESTATUS,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfAreaRangeEntry,
|
2017-07-17 14:03:14 +02:00
|
|
|
3,
|
2002-12-13 21:15:29 +01:00
|
|
|
{5, 1, 4}},
|
|
|
|
{OSPFAREARANGEEFFECT,
|
2017-07-17 14:03:14 +02:00
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfAreaRangeEntry,
|
|
|
|
3,
|
|
|
|
{5, 1, 5}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF host table. */
|
|
|
|
{OSPFHOSTIPADDRESS, IPADDRESS, RONLY, ospfHostEntry, 3, {6, 1, 1}},
|
|
|
|
{OSPFHOSTTOS, INTEGER, RONLY, ospfHostEntry, 3, {6, 1, 2}},
|
|
|
|
{OSPFHOSTMETRIC, INTEGER, RWRITE, ospfHostEntry, 3, {6, 1, 3}},
|
|
|
|
{OSPFHOSTSTATUS, INTEGER, RWRITE, ospfHostEntry, 3, {6, 1, 4}},
|
|
|
|
{OSPFHOSTAREAID, IPADDRESS, RONLY, ospfHostEntry, 3, {6, 1, 5}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF interface table. */
|
|
|
|
{OSPFIFIPADDRESS, IPADDRESS, RONLY, ospfIfEntry, 3, {7, 1, 1}},
|
|
|
|
{OSPFADDRESSLESSIF, INTEGER, RONLY, ospfIfEntry, 3, {7, 1, 2}},
|
|
|
|
{OSPFIFAREAID, IPADDRESS, RWRITE, ospfIfEntry, 3, {7, 1, 3}},
|
|
|
|
{OSPFIFTYPE, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 4}},
|
|
|
|
{OSPFIFADMINSTAT, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 5}},
|
|
|
|
{OSPFIFRTRPRIORITY, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 6}},
|
|
|
|
{OSPFIFTRANSITDELAY, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 7}},
|
|
|
|
{OSPFIFRETRANSINTERVAL, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 8}},
|
|
|
|
{OSPFIFHELLOINTERVAL, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 9}},
|
|
|
|
{OSPFIFRTRDEADINTERVAL, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 10}},
|
|
|
|
{OSPFIFPOLLINTERVAL, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 11}},
|
|
|
|
{OSPFIFSTATE, INTEGER, RONLY, ospfIfEntry, 3, {7, 1, 12}},
|
|
|
|
{OSPFIFDESIGNATEDROUTER, IPADDRESS, RONLY, ospfIfEntry, 3, {7, 1, 13}},
|
|
|
|
{OSPFIFBACKUPDESIGNATEDROUTER,
|
|
|
|
IPADDRESS,
|
2017-07-17 14:03:14 +02:00
|
|
|
RONLY,
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfIfEntry,
|
|
|
|
3,
|
|
|
|
{7, 1, 14}},
|
|
|
|
{OSPFIFEVENTS, COUNTER, RONLY, ospfIfEntry, 3, {7, 1, 15}},
|
|
|
|
{OSPFIFAUTHKEY, STRING, RWRITE, ospfIfEntry, 3, {7, 1, 16}},
|
|
|
|
{OSPFIFSTATUS, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 17}},
|
|
|
|
{OSPFIFMULTICASTFORWARDING,
|
2017-07-17 14:03:14 +02:00
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfIfEntry,
|
2017-07-17 14:03:14 +02:00
|
|
|
3,
|
2002-12-13 21:15:29 +01:00
|
|
|
{7, 1, 18}},
|
|
|
|
{OSPFIFDEMAND, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 19}},
|
|
|
|
{OSPFIFAUTHTYPE, INTEGER, RWRITE, ospfIfEntry, 3, {7, 1, 20}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF interface metric table. */
|
|
|
|
{OSPFIFMETRICIPADDRESS,
|
|
|
|
IPADDRESS,
|
|
|
|
RONLY,
|
|
|
|
ospfIfMetricEntry,
|
|
|
|
3,
|
|
|
|
{8, 1, 1}},
|
|
|
|
{OSPFIFMETRICADDRESSLESSIF,
|
|
|
|
INTEGER,
|
|
|
|
RONLY,
|
|
|
|
ospfIfMetricEntry,
|
|
|
|
3,
|
|
|
|
{8, 1, 2}},
|
|
|
|
{OSPFIFMETRICTOS, INTEGER, RONLY, ospfIfMetricEntry, 3, {8, 1, 3}},
|
|
|
|
{OSPFIFMETRICVALUE, INTEGER, RWRITE, ospfIfMetricEntry, 3, {8, 1, 4}},
|
|
|
|
{OSPFIFMETRICSTATUS, INTEGER, RWRITE, ospfIfMetricEntry, 3, {8, 1, 5}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF virtual interface table. */
|
|
|
|
{OSPFVIRTIFAREAID, IPADDRESS, RONLY, ospfVirtIfEntry, 3, {9, 1, 1}},
|
|
|
|
{OSPFVIRTIFNEIGHBOR, IPADDRESS, RONLY, ospfVirtIfEntry, 3, {9, 1, 2}},
|
|
|
|
{OSPFVIRTIFTRANSITDELAY,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfVirtIfEntry,
|
|
|
|
3,
|
|
|
|
{9, 1, 3}},
|
|
|
|
{OSPFVIRTIFRETRANSINTERVAL,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfVirtIfEntry,
|
|
|
|
3,
|
|
|
|
{9, 1, 4}},
|
|
|
|
{OSPFVIRTIFHELLOINTERVAL,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfVirtIfEntry,
|
|
|
|
3,
|
|
|
|
{9, 1, 5}},
|
|
|
|
{OSPFVIRTIFRTRDEADINTERVAL,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfVirtIfEntry,
|
|
|
|
3,
|
|
|
|
{9, 1, 6}},
|
|
|
|
{OSPFVIRTIFSTATE, INTEGER, RONLY, ospfVirtIfEntry, 3, {9, 1, 7}},
|
|
|
|
{OSPFVIRTIFEVENTS, COUNTER, RONLY, ospfVirtIfEntry, 3, {9, 1, 8}},
|
|
|
|
{OSPFVIRTIFAUTHKEY, STRING, RWRITE, ospfVirtIfEntry, 3, {9, 1, 9}},
|
|
|
|
{OSPFVIRTIFSTATUS, INTEGER, RWRITE, ospfVirtIfEntry, 3, {9, 1, 10}},
|
|
|
|
{OSPFVIRTIFAUTHTYPE, INTEGER, RWRITE, ospfVirtIfEntry, 3, {9, 1, 11}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF neighbor table. */
|
|
|
|
{OSPFNBRIPADDR, IPADDRESS, RONLY, ospfNbrEntry, 3, {10, 1, 1}},
|
|
|
|
{OSPFNBRADDRESSLESSINDEX, INTEGER, RONLY, ospfNbrEntry, 3, {10, 1, 2}},
|
|
|
|
{OSPFNBRRTRID, IPADDRESS, RONLY, ospfNbrEntry, 3, {10, 1, 3}},
|
|
|
|
{OSPFNBROPTIONS, INTEGER, RONLY, ospfNbrEntry, 3, {10, 1, 4}},
|
|
|
|
{OSPFNBRPRIORITY, INTEGER, RWRITE, ospfNbrEntry, 3, {10, 1, 5}},
|
|
|
|
{OSPFNBRSTATE, INTEGER, RONLY, ospfNbrEntry, 3, {10, 1, 6}},
|
|
|
|
{OSPFNBREVENTS, COUNTER, RONLY, ospfNbrEntry, 3, {10, 1, 7}},
|
|
|
|
{OSPFNBRLSRETRANSQLEN, GAUGE, RONLY, ospfNbrEntry, 3, {10, 1, 8}},
|
|
|
|
{OSPFNBMANBRSTATUS, INTEGER, RWRITE, ospfNbrEntry, 3, {10, 1, 9}},
|
|
|
|
{OSPFNBMANBRPERMANENCE, INTEGER, RONLY, ospfNbrEntry, 3, {10, 1, 10}},
|
|
|
|
{OSPFNBRHELLOSUPPRESSED, INTEGER, RONLY, ospfNbrEntry, 3, {10, 1, 11}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF virtual neighbor table. */
|
|
|
|
{OSPFVIRTNBRAREA, IPADDRESS, RONLY, ospfVirtNbrEntry, 3, {11, 1, 1}},
|
|
|
|
{OSPFVIRTNBRRTRID, IPADDRESS, RONLY, ospfVirtNbrEntry, 3, {11, 1, 2}},
|
|
|
|
{OSPFVIRTNBRIPADDR, IPADDRESS, RONLY, ospfVirtNbrEntry, 3, {11, 1, 3}},
|
|
|
|
{OSPFVIRTNBROPTIONS, INTEGER, RONLY, ospfVirtNbrEntry, 3, {11, 1, 4}},
|
|
|
|
{OSPFVIRTNBRSTATE, INTEGER, RONLY, ospfVirtNbrEntry, 3, {11, 1, 5}},
|
|
|
|
{OSPFVIRTNBREVENTS, COUNTER, RONLY, ospfVirtNbrEntry, 3, {11, 1, 6}},
|
|
|
|
{OSPFVIRTNBRLSRETRANSQLEN,
|
2017-07-17 14:03:14 +02:00
|
|
|
INTEGER,
|
|
|
|
RONLY,
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfVirtNbrEntry,
|
2017-07-17 14:03:14 +02:00
|
|
|
3,
|
2002-12-13 21:15:29 +01:00
|
|
|
{11, 1, 7}},
|
|
|
|
{OSPFVIRTNBRHELLOSUPPRESSED,
|
|
|
|
INTEGER,
|
|
|
|
RONLY,
|
|
|
|
ospfVirtNbrEntry,
|
|
|
|
3,
|
|
|
|
{11, 1, 8}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF link state database, external. */
|
|
|
|
{OSPFEXTLSDBTYPE, INTEGER, RONLY, ospfExtLsdbEntry, 3, {12, 1, 1}},
|
|
|
|
{OSPFEXTLSDBLSID, IPADDRESS, RONLY, ospfExtLsdbEntry, 3, {12, 1, 2}},
|
|
|
|
{OSPFEXTLSDBROUTERID,
|
|
|
|
IPADDRESS,
|
2017-07-17 14:03:14 +02:00
|
|
|
RONLY,
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfExtLsdbEntry,
|
2017-07-17 14:03:14 +02:00
|
|
|
3,
|
2002-12-13 21:15:29 +01:00
|
|
|
{12, 1, 3}},
|
|
|
|
{OSPFEXTLSDBSEQUENCE, INTEGER, RONLY, ospfExtLsdbEntry, 3, {12, 1, 4}},
|
|
|
|
{OSPFEXTLSDBAGE, INTEGER, RONLY, ospfExtLsdbEntry, 3, {12, 1, 5}},
|
|
|
|
{OSPFEXTLSDBCHECKSUM, INTEGER, RONLY, ospfExtLsdbEntry, 3, {12, 1, 6}},
|
|
|
|
{OSPFEXTLSDBADVERTISEMENT,
|
|
|
|
STRING,
|
|
|
|
RONLY,
|
|
|
|
ospfExtLsdbEntry,
|
|
|
|
3,
|
|
|
|
{12, 1, 7}},
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF area aggregate table. */
|
|
|
|
{OSPFAREAAGGREGATEAREAID,
|
|
|
|
IPADDRESS,
|
|
|
|
RONLY,
|
|
|
|
ospfAreaAggregateEntry,
|
2017-07-17 14:03:14 +02:00
|
|
|
3,
|
2002-12-13 21:15:29 +01:00
|
|
|
{14, 1, 1}},
|
|
|
|
{OSPFAREAAGGREGATELSDBTYPE,
|
|
|
|
INTEGER,
|
|
|
|
RONLY,
|
|
|
|
ospfAreaAggregateEntry,
|
|
|
|
3,
|
|
|
|
{14, 1, 2}},
|
|
|
|
{OSPFAREAAGGREGATENET,
|
|
|
|
IPADDRESS,
|
|
|
|
RONLY,
|
|
|
|
ospfAreaAggregateEntry,
|
|
|
|
3,
|
|
|
|
{14, 1, 3}},
|
|
|
|
{OSPFAREAAGGREGATEMASK,
|
|
|
|
IPADDRESS,
|
|
|
|
RONLY,
|
|
|
|
ospfAreaAggregateEntry,
|
|
|
|
3,
|
|
|
|
{14, 1, 4}},
|
|
|
|
{OSPFAREAAGGREGATESTATUS,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfAreaAggregateEntry,
|
|
|
|
3,
|
|
|
|
{14, 1, 5}},
|
|
|
|
{OSPFAREAAGGREGATEEFFECT,
|
|
|
|
INTEGER,
|
|
|
|
RWRITE,
|
|
|
|
ospfAreaAggregateEntry,
|
|
|
|
3,
|
|
|
|
{14, 1, 6}}};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* The administrative status of OSPF. When OSPF is enbled on at least
|
|
|
|
one interface return 1. */
|
2003-03-25 06:07:42 +01:00
|
|
|
static int ospf_admin_stat(struct ospf *ospf)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-07 16:19:36 +02:00
|
|
|
struct listnode *node;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_interface *oi;
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi))
|
|
|
|
if (oi && oi->address)
|
|
|
|
return 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfGeneralGroup(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check whether the instance identifier is valid */
|
|
|
|
if (smux_header_generic(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFROUTERID: /* 1 */
|
|
|
|
/* Router-ID of this OSPF instance. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf)
|
|
|
|
return SNMP_IPADDRESS(ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
return SNMP_IPADDRESS(ospf_empty_addr);
|
|
|
|
case OSPFADMINSTAT: /* 2 */
|
|
|
|
/* The administrative status of OSPF in the router. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf_admin_stat(ospf))
|
2002-12-13 21:15:29 +01:00
|
|
|
return SNMP_INTEGER(OSPF_STATUS_ENABLED);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(OSPF_STATUS_DISABLED);
|
|
|
|
case OSPFVERSIONNUMBER: /* 3 */
|
|
|
|
/* OSPF version 2. */
|
|
|
|
return SNMP_INTEGER(OSPF_VERSION);
|
|
|
|
case OSPFAREABDRRTRSTATUS: /* 4 */
|
|
|
|
/* Area Border router status. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf && CHECK_FLAG(ospf->flags, OSPF_FLAG_ABR))
|
2002-12-13 21:15:29 +01:00
|
|
|
return SNMP_INTEGER(SNMP_TRUE);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(SNMP_FALSE);
|
|
|
|
case OSPFASBDRRTRSTATUS: /* 5 */
|
|
|
|
/* AS Border router status. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf && CHECK_FLAG(ospf->flags, OSPF_FLAG_ASBR))
|
2002-12-13 21:15:29 +01:00
|
|
|
return SNMP_INTEGER(SNMP_TRUE);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(SNMP_FALSE);
|
|
|
|
case OSPFEXTERNLSACOUNT: /* 6 */
|
|
|
|
/* External LSA counts. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf)
|
|
|
|
return SNMP_INTEGER(ospf_lsdb_count_all(ospf->lsdb));
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFEXTERNLSACKSUMSUM: /* 7 */
|
|
|
|
/* External LSA checksum. */
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFTOSSUPPORT: /* 8 */
|
|
|
|
/* TOS is not supported. */
|
|
|
|
return SNMP_INTEGER(SNMP_FALSE);
|
|
|
|
case OSPFORIGINATENEWLSAS: /* 9 */
|
|
|
|
/* The number of new link-state advertisements. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf)
|
|
|
|
return SNMP_INTEGER(ospf->lsa_originate_count);
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFRXNEWLSAS: /* 10 */
|
|
|
|
/* The number of link-state advertisements received determined
|
|
|
|
to be new instantiations. */
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf)
|
|
|
|
return SNMP_INTEGER(ospf->rx_lsa_count);
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFEXTLSDBLIMIT: /* 11 */
|
|
|
|
/* There is no limit for the number of non-default
|
|
|
|
AS-external-LSAs. */
|
|
|
|
return SNMP_INTEGER(-1);
|
|
|
|
case OSPFMULTICASTEXTENSIONS: /* 12 */
|
|
|
|
/* Multicast Extensions to OSPF is not supported. */
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFEXITOVERFLOWINTERVAL: /* 13 */
|
|
|
|
/* Overflow is not supported. */
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFDEMANDEXTENSIONS: /* 14 */
|
|
|
|
/* Demand routing is not supported. */
|
|
|
|
return SNMP_INTEGER(SNMP_FALSE);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:40:07 +02:00
|
|
|
static struct ospf_area *
|
2003-03-25 06:07:42 +01:00
|
|
|
ospf_area_lookup_next(struct ospf *ospf, struct in_addr *area_id, int first)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_area *area;
|
2004-10-07 16:19:36 +02:00
|
|
|
struct listnode *node;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-04-04 04:44:16 +02:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (first) {
|
2003-03-25 06:07:42 +01:00
|
|
|
node = listhead(ospf->areas);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (node) {
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
area = listgetdata(node);
|
2002-12-13 21:15:29 +01:00
|
|
|
*area_id = area->area_id;
|
|
|
|
return area;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ntohl(area->area_id.s_addr) > ntohl(area_id->s_addr)) {
|
|
|
|
*area_id = area->area_id;
|
|
|
|
return area;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_area *ospfAreaLookup(struct variable *v, oid name[],
|
|
|
|
size_t *length, struct in_addr *addr,
|
|
|
|
int exact)
|
|
|
|
{
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_area *area;
|
2003-03-25 06:07:42 +01:00
|
|
|
int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ospf == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
if (exact) {
|
|
|
|
/* Length is insufficient to lookup OSPF area. */
|
|
|
|
if (*length - v->namelen != sizeof(struct in_addr))
|
|
|
|
return NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, sizeof(struct in_addr), addr);
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_by_area_id(ospf, *addr);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return area;
|
|
|
|
} else {
|
|
|
|
len = *length - v->namelen;
|
|
|
|
if (len > 4)
|
2017-07-17 14:03:14 +02:00
|
|
|
len = 4;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, len, addr);
|
|
|
|
|
|
|
|
area = ospf_area_lookup_next(ospf, addr, len == 0 ? 1 : 0);
|
|
|
|
|
|
|
|
if (area == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(name + v->namelen, addr);
|
2003-04-04 04:44:16 +02:00
|
|
|
*length = sizeof(struct in_addr) + v->namelen;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfAreaEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_area *area;
|
2003-03-25 06:07:42 +01:00
|
|
|
struct in_addr addr;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-04-04 04:44:16 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&addr, 0, sizeof(addr));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
area = ospfAreaLookup(v, name, length, &addr, exact);
|
|
|
|
if (!area)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFAREAID: /* 1 */
|
2003-03-25 06:07:42 +01:00
|
|
|
return SNMP_IPADDRESS(area->area_id);
|
|
|
|
case OSPFAUTHTYPE: /* 2 */
|
2002-12-13 21:15:29 +01:00
|
|
|
return SNMP_INTEGER(area->auth_type);
|
|
|
|
case OSPFIMPORTASEXTERN: /* 3 */
|
|
|
|
return SNMP_INTEGER(area->external_routing + 1);
|
|
|
|
case OSPFSPFRUNS: /* 4 */
|
|
|
|
return SNMP_INTEGER(area->spf_calculation);
|
|
|
|
case OSPFAREABDRRTRCOUNT: /* 5 */
|
|
|
|
return SNMP_INTEGER(area->abr_count);
|
|
|
|
case OSPFASBDRRTRCOUNT: /* 6 */
|
|
|
|
return SNMP_INTEGER(area->asbr_count);
|
|
|
|
case OSPFAREALSACOUNT: /* 7 */
|
|
|
|
return SNMP_INTEGER(area->lsdb->total);
|
|
|
|
case OSPFAREALSACKSUMSUM: /* 8 */
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFAREASUMMARY: /* 9 */
|
|
|
|
#define OSPF_noAreaSummary 1
|
|
|
|
#define OSPF_sendAreaSummary 2
|
|
|
|
if (area->no_summary)
|
|
|
|
return SNMP_INTEGER(OSPF_noAreaSummary);
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2002-12-13 21:15:29 +01:00
|
|
|
return SNMP_INTEGER(OSPF_sendAreaSummary);
|
|
|
|
case OSPFAREASTATUS: /* 10 */
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
2017-07-17 14:03:14 +02:00
|
|
|
default:
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_area *ospf_stub_area_lookup_next(struct in_addr *area_id,
|
|
|
|
int first)
|
|
|
|
{
|
|
|
|
struct ospf_area *area;
|
2004-10-07 16:19:36 +02:00
|
|
|
struct listnode *node;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2012-05-31 13:30:28 +02:00
|
|
|
if (ospf == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
|
|
|
|
if (area->external_routing == OSPF_AREA_STUB) {
|
|
|
|
if (first) {
|
|
|
|
*area_id = area->area_id;
|
|
|
|
return area;
|
|
|
|
} else if (ntohl(area->area_id.s_addr)
|
|
|
|
> ntohl(area_id->s_addr)) {
|
|
|
|
*area_id = area->area_id;
|
|
|
|
return area;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_area *ospfStubAreaLookup(struct variable *v, oid name[],
|
|
|
|
size_t *length,
|
|
|
|
struct in_addr *addr, int exact)
|
|
|
|
{
|
|
|
|
struct ospf *ospf;
|
|
|
|
struct ospf_area *area;
|
|
|
|
int len;
|
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ospf == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Exact lookup. */
|
|
|
|
if (exact) {
|
|
|
|
/* ospfStubAreaID + ospfStubTOS. */
|
|
|
|
if (*length != v->namelen + sizeof(struct in_addr) + 1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Check ospfStubTOS is zero. */
|
|
|
|
if (name[*length - 1] != 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, sizeof(struct in_addr), addr);
|
|
|
|
|
|
|
|
area = ospf_area_lookup_by_area_id(ospf, *addr);
|
|
|
|
|
2020-04-17 02:16:02 +02:00
|
|
|
if (area && area->external_routing == OSPF_AREA_STUB)
|
2002-12-13 21:15:29 +01:00
|
|
|
return area;
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2002-12-13 21:15:29 +01:00
|
|
|
len = *length - v->namelen;
|
2015-03-04 06:44:57 +01:00
|
|
|
if (len > 4)
|
2002-12-13 21:15:29 +01:00
|
|
|
len = 4;
|
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, len, addr);
|
|
|
|
|
2012-04-09 18:03:57 +02:00
|
|
|
area = ospf_stub_area_lookup_next(addr, len == 0 ? 1 : 0);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (area == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(name + v->namelen, addr);
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set TOS 0. */
|
|
|
|
name[v->namelen + sizeof(struct in_addr)] = 0;
|
|
|
|
*length = v->namelen + sizeof(struct in_addr) + 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return area;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfStubAreaEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_area *area;
|
|
|
|
struct in_addr addr;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&addr, 0, sizeof(addr));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-04-04 04:44:16 +02:00
|
|
|
area = ospfStubAreaLookup(v, name, length, &addr, exact);
|
|
|
|
if (!area)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFSTUBAREAID: /* 1 */
|
|
|
|
/* OSPF stub area id. */
|
|
|
|
return SNMP_IPADDRESS(area->area_id);
|
|
|
|
case OSPFSTUBTOS: /* 2 */
|
|
|
|
/* TOS value is not supported. */
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFSTUBMETRIC: /* 3 */
|
|
|
|
/* Default cost to stub area. */
|
|
|
|
return SNMP_INTEGER(area->default_cost);
|
|
|
|
case OSPFSTUBSTATUS: /* 4 */
|
|
|
|
/* Status of the stub area. */
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
|
|
|
case OSPFSTUBMETRICTYPE: /* 5 */
|
2017-07-22 14:52:33 +02:00
|
|
|
/* OSPF Metric type. */
|
2002-12-13 21:15:29 +01:00
|
|
|
#define OSPF_ospfMetric 1
|
|
|
|
#define OSPF_comparableCost 2
|
|
|
|
#define OSPF_nonComparable 3
|
|
|
|
return SNMP_INTEGER(OSPF_ospfMetric);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static struct ospf_lsa *lsdb_lookup_next(struct ospf_area *area, uint8_t *type,
|
2002-12-13 21:15:29 +01:00
|
|
|
int type_next, struct in_addr *ls_id,
|
|
|
|
int ls_id_next,
|
|
|
|
struct in_addr *router_id,
|
|
|
|
int router_id_next)
|
|
|
|
{
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
int i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (type_next)
|
|
|
|
i = OSPF_MIN_LSA;
|
|
|
|
else
|
|
|
|
i = *type;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Sanity check, if LSA type unknwon
|
|
|
|
merley skip any LSA */
|
2003-04-04 04:44:16 +02:00
|
|
|
if ((i < OSPF_MIN_LSA) || (i >= OSPF_MAX_LSA)) {
|
2019-03-14 19:41:15 +01:00
|
|
|
zlog_debug("Strange request with LSA type %d", i);
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
for (; i < OSPF_MAX_LSA; i++) {
|
|
|
|
*type = i;
|
|
|
|
|
|
|
|
lsa = ospf_lsdb_lookup_by_id_next(area->lsdb, *type, *ls_id,
|
|
|
|
*router_id, ls_id_next);
|
|
|
|
if (lsa)
|
|
|
|
return lsa;
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
ls_id_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
|
|
|
|
size_t *length, struct in_addr *area_id,
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t *type, struct in_addr *ls_id,
|
2002-12-13 21:15:29 +01:00
|
|
|
struct in_addr *router_id, int exact)
|
2017-07-17 14:03:14 +02:00
|
|
|
{
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_area *area;
|
|
|
|
struct ospf_lsa *lsa;
|
2017-07-17 14:03:14 +02:00
|
|
|
int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
int type_next;
|
|
|
|
int ls_id_next;
|
|
|
|
int router_id_next;
|
|
|
|
oid *offset;
|
|
|
|
int offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#define OSPF_LSDB_ENTRY_OFFSET (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
/* Area ID + Type + LS ID + Router ID. */
|
|
|
|
if (*length - v->namelen != OSPF_LSDB_ENTRY_OFFSET)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set OID offset for Area ID. */
|
|
|
|
offset = name + v->namelen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup area first. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, area_id);
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_by_area_id(ospf, *area_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (!area)
|
|
|
|
return NULL;
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Type. */
|
|
|
|
*type = *offset;
|
|
|
|
offset++;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* LS ID. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, ls_id);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Router ID. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, router_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup LSDB. */
|
2003-03-25 06:07:42 +01:00
|
|
|
return ospf_lsdb_lookup_by_id(area->lsdb, *type, *ls_id,
|
|
|
|
*router_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Get variable length. */
|
|
|
|
offset = name + v->namelen;
|
|
|
|
offsetlen = *length - v->namelen;
|
|
|
|
len = offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-03-04 06:44:57 +01:00
|
|
|
if (len > (int)IN_ADDR_SIZE)
|
2002-12-13 21:15:29 +01:00
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, area_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* First we search area. */
|
|
|
|
if (len == IN_ADDR_SIZE)
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_by_area_id(ospf, *area_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_next(ospf, area_id, 1);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (area == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
do {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Next we lookup type. */
|
|
|
|
offset += len;
|
2012-04-09 18:03:57 +02:00
|
|
|
offsetlen -= len;
|
2002-12-13 21:15:29 +01:00
|
|
|
len = offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
if (len <= 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
type_next = 1;
|
|
|
|
else {
|
|
|
|
type_next = 0;
|
|
|
|
*type = *offset;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* LS ID. */
|
|
|
|
offset++;
|
|
|
|
offsetlen--;
|
|
|
|
len = offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (len <= 0)
|
|
|
|
ls_id_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
else {
|
2002-12-13 21:15:29 +01:00
|
|
|
ls_id_next = 0;
|
2015-03-04 06:44:57 +01:00
|
|
|
if (len > (int)IN_ADDR_SIZE)
|
2002-12-13 21:15:29 +01:00
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, ls_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Router ID. */
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2002-12-13 21:15:29 +01:00
|
|
|
offsetlen -= IN_ADDR_SIZE;
|
|
|
|
len = offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (len <= 0)
|
|
|
|
router_id_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
else {
|
2003-03-25 06:07:42 +01:00
|
|
|
router_id_next = 0;
|
2015-03-04 06:44:57 +01:00
|
|
|
if (len > (int)IN_ADDR_SIZE)
|
2002-12-13 21:15:29 +01:00
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, router_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
lsa = lsdb_lookup_next(area, type, type_next, ls_id,
|
|
|
|
ls_id_next, router_id,
|
|
|
|
router_id_next);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (lsa) {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Fill in length. */
|
|
|
|
*length = v->namelen + OSPF_LSDB_ENTRY_OFFSET;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Fill in value. */
|
|
|
|
offset = name + v->namelen;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, area_id);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2002-12-13 21:15:29 +01:00
|
|
|
*offset = lsa->data->type;
|
|
|
|
offset++;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, &lsa->data->id);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset,
|
|
|
|
&lsa->data->adv_router);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return lsa;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2003-03-25 06:07:42 +01:00
|
|
|
} while ((area = ospf_area_lookup_next(ospf, area_id, 0))
|
2002-12-13 21:15:29 +01:00
|
|
|
!= NULL);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfLsdbEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
struct in_addr area_id;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t type;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct in_addr ls_id;
|
|
|
|
struct in_addr router_id;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* INDEX { ospfLsdbAreaId, ospfLsdbType,
|
|
|
|
ospfLsdbLsid, ospfLsdbRouterId } */
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&area_id, 0, sizeof(area_id));
|
2002-12-13 21:15:29 +01:00
|
|
|
type = 0;
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&ls_id, 0, sizeof(ls_id));
|
|
|
|
memset(&router_id, 0, sizeof(router_id));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2015-03-04 06:44:57 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
lsa = ospfLsdbLookup(v, name, length, &area_id, &type, &ls_id,
|
|
|
|
&router_id, exact);
|
|
|
|
if (!lsa)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
lsah = lsa->data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFLSDBAREAID: /* 1 */
|
|
|
|
return SNMP_IPADDRESS(lsa->area->area_id);
|
|
|
|
case OSPFLSDBTYPE: /* 2 */
|
|
|
|
return SNMP_INTEGER(lsah->type);
|
|
|
|
case OSPFLSDBLSID: /* 3 */
|
|
|
|
return SNMP_IPADDRESS(lsah->id);
|
|
|
|
case OSPFLSDBROUTERID: /* 4 */
|
|
|
|
return SNMP_IPADDRESS(lsah->adv_router);
|
|
|
|
case OSPFLSDBSEQUENCE: /* 5 */
|
|
|
|
return SNMP_INTEGER(lsah->ls_seqnum);
|
|
|
|
case OSPFLSDBAGE: /* 6 */
|
|
|
|
return SNMP_INTEGER(lsah->ls_age);
|
|
|
|
case OSPFLSDBCHECKSUM: /* 7 */
|
|
|
|
return SNMP_INTEGER(lsah->checksum);
|
|
|
|
case OSPFLSDBADVERTISEMENT: /* 8 */
|
|
|
|
*var_len = ntohs(lsah->length);
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)lsah;
|
2017-07-17 14:03:14 +02:00
|
|
|
default:
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2009-06-02 19:40:07 +02:00
|
|
|
static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
|
2002-12-13 21:15:29 +01:00
|
|
|
oid *name, size_t *length,
|
|
|
|
struct in_addr *area_id,
|
|
|
|
struct in_addr *range_net,
|
|
|
|
int exact)
|
2017-07-17 14:03:14 +02:00
|
|
|
{
|
2002-12-13 21:15:29 +01:00
|
|
|
oid *offset;
|
|
|
|
int offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
int len;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_area *area;
|
|
|
|
struct ospf_area_range *range;
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
p.family = AF_INET;
|
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
/* Area ID + Range Network. */
|
|
|
|
if (v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE != *length)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set OID offset for Area ID. */
|
|
|
|
offset = name + v->namelen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup area first. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, area_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_by_area_id(ospf, *area_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (!area)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup area range. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, range_net);
|
|
|
|
p.prefix = *range_net;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-03-08 01:13:53 +01:00
|
|
|
return ospf_area_range_lookup(area, area->ranges, &p);
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set OID offset for Area ID. */
|
|
|
|
offset = name + v->namelen;
|
|
|
|
offsetlen = *length - v->namelen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
len = offsetlen;
|
2015-03-04 06:44:57 +01:00
|
|
|
if (len > (int)IN_ADDR_SIZE)
|
2002-12-13 21:15:29 +01:00
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, area_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* First we search area. */
|
|
|
|
if (len == IN_ADDR_SIZE)
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_by_area_id(ospf, *area_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2003-03-25 06:07:42 +01:00
|
|
|
area = ospf_area_lookup_next(ospf, area_id,
|
|
|
|
len == 0 ? 1 : 0);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (area == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
do {
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2002-12-13 21:15:29 +01:00
|
|
|
offsetlen -= IN_ADDR_SIZE;
|
|
|
|
len = offsetlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (len < 0)
|
2017-07-17 14:03:14 +02:00
|
|
|
len = 0;
|
2015-03-04 06:44:57 +01:00
|
|
|
if (len > (int)IN_ADDR_SIZE)
|
2002-12-13 21:15:29 +01:00
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, range_net);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
range = ospf_area_range_lookup_next(area, range_net,
|
2003-03-25 06:07:42 +01:00
|
|
|
len == 0 ? 1 : 0);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (range) {
|
|
|
|
/* Fill in length. */
|
|
|
|
*length = v->namelen + IN_ADDR_SIZE
|
|
|
|
+ IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Fill in value. */
|
|
|
|
offset = name + v->namelen;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, area_id);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, range_net);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return range;
|
|
|
|
}
|
2003-03-25 06:07:42 +01:00
|
|
|
} while ((area = ospf_area_lookup_next(ospf, area_id, 0))
|
|
|
|
!= NULL);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfAreaRangeEntry(struct variable *v, oid *name,
|
|
|
|
size_t *length, int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_area_range *range;
|
|
|
|
struct in_addr area_id;
|
|
|
|
struct in_addr range_net;
|
|
|
|
struct in_addr mask;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
memset(&area_id, 0, IN_ADDR_SIZE);
|
|
|
|
memset(&range_net, 0, IN_ADDR_SIZE);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
range = ospfAreaRangeLookup(v, name, length, &area_id, &range_net,
|
|
|
|
exact);
|
|
|
|
if (!range)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Convert prefixlen to network mask format. */
|
|
|
|
masklen2ip(range->subst_masklen, &mask);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFAREARANGEAREAID: /* 1 */
|
|
|
|
return SNMP_IPADDRESS(area_id);
|
|
|
|
case OSPFAREARANGENET: /* 2 */
|
|
|
|
return SNMP_IPADDRESS(range_net);
|
|
|
|
case OSPFAREARANGEMASK: /* 3 */
|
|
|
|
return SNMP_IPADDRESS(mask);
|
|
|
|
case OSPFAREARANGESTATUS: /* 4 */
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
|
|
|
case OSPFAREARANGEEFFECT: /* 5 */
|
|
|
|
#define OSPF_advertiseMatching 1
|
|
|
|
#define OSPF_doNotAdvertiseMatching 2
|
|
|
|
return SNMP_INTEGER(OSPF_advertiseMatching);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_nbr_nbma *ospfHostLookup(struct variable *v, oid *name,
|
|
|
|
size_t *length,
|
|
|
|
struct in_addr *addr, int exact)
|
|
|
|
{
|
|
|
|
struct ospf_nbr_nbma *nbr_nbma;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ospf == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (exact) {
|
|
|
|
/* INDEX { ospfHostIpAddress, ospfHostTOS } */
|
|
|
|
if (*length != v->namelen + IN_ADDR_SIZE + 1)
|
|
|
|
return NULL;
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
/* Check ospfHostTOS. */
|
|
|
|
if (name[*length - 1] != 0)
|
|
|
|
return NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, addr);
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
nbr_nbma = ospf_nbr_nbma_lookup(ospf, *addr);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return nbr_nbma;
|
|
|
|
}
|
2021-01-28 20:56:11 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfHostEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_nbr_nbma *nbr_nbma;
|
|
|
|
struct ospf_interface *oi;
|
|
|
|
struct in_addr addr;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&addr, 0, sizeof(addr));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
nbr_nbma = ospfHostLookup(v, name, length, &addr, exact);
|
|
|
|
if (nbr_nbma == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oi = nbr_nbma->oi;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFHOSTIPADDRESS: /* 1 */
|
|
|
|
return SNMP_IPADDRESS(nbr_nbma->addr);
|
|
|
|
case OSPFHOSTTOS: /* 2 */
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFHOSTMETRIC: /* 3 */
|
|
|
|
if (oi)
|
|
|
|
return SNMP_INTEGER(oi->output_cost);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(1);
|
|
|
|
case OSPFHOSTSTATUS: /* 4 */
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
|
|
|
case OSPFHOSTAREAID: /* 5 */
|
|
|
|
if (oi && oi->area)
|
|
|
|
return SNMP_IPADDRESS(oi->area->area_id);
|
|
|
|
else
|
|
|
|
return SNMP_IPADDRESS(ospf_empty_addr);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct list *ospf_snmp_iflist;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
struct ospf_snmp_if {
|
|
|
|
struct in_addr addr;
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct interface *ifp;
|
|
|
|
};
|
|
|
|
|
2009-06-02 19:40:07 +02:00
|
|
|
static struct ospf_snmp_if *ospf_snmp_if_new(void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2022-12-05 17:43:57 +01:00
|
|
|
return XCALLOC(MTYPE_SNMP, sizeof(struct ospf_snmp_if));
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf_snmp_if_free(struct ospf_snmp_if *osif)
|
|
|
|
{
|
2022-12-05 17:43:57 +01:00
|
|
|
XFREE(MTYPE_SNMP, osif);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf_snmp_if_delete(struct interface *ifp)
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
struct listnode *node, *nnode;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_snmp_if *osif;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS(ospf_snmp_iflist, node, nnode, osif)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
if (osif->ifp == ifp) {
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
list_delete_node(ospf_snmp_iflist, node);
|
2002-12-13 21:15:29 +01:00
|
|
|
ospf_snmp_if_free(osif);
|
2016-06-12 17:32:23 +02:00
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2016-06-12 17:32:23 +02:00
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf_snmp_if_update(struct interface *ifp)
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
struct listnode *node;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct listnode *pn;
|
|
|
|
struct connected *ifc;
|
|
|
|
struct prefix *p;
|
|
|
|
struct ospf_snmp_if *osif;
|
|
|
|
struct in_addr *addr;
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
ospf_snmp_if_delete(ifp);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
p = NULL;
|
|
|
|
addr = NULL;
|
|
|
|
ifindex = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup first IPv4 address entry. */
|
2023-11-22 19:05:41 +01:00
|
|
|
frr_each (if_connected, ifp->connected, ifc) {
|
[PtP over ethernet] New peer flag allows much more addressing flexibility
2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating
whether a peer address has been configured. Comment now shows
the new interpretation of the destination addr: if ZEBRA_IFA_PEER
is set, then it must contain the destination address, otherwise
it may contain the broadcast address or be NULL.
(CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete
macros that were specific to IPv4 and not fully general.
(CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag.
(CONNECTED_PREFIX) New macro giving the prefix to insert into
the RIB: if CONNECTED_PEER, then use the destination (peer) address,
else use the address field.
(CONNECTED_ID) New macro to come up with an identifying address
for the struct connected.
* if.c: (if_lookup_address, connected_lookup_address) Streamline
logic with new CONNECTED_PREFIX macro.
* prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros
for better performance than the general prefix_copy function.
* zclient.c: (zebra_interface_address_read) For non-null destination
addresses, set prefixlen to equal the address prefixlen. This
is needed to get the new CONNECTED_PREFIX macro to work properly.
* connected.c: (connected_up_ipv4, connected_down_ipv4,
connected_up_ipv6, connected_down_ipv6) Simplify logic using the
new CONNECTED_PREFIX macro.
(connected_add_ipv4) Set prefixlen in destination addresses (required
by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead
of testing for IFF_POINTOPOINT. Delete invalid warning message.
Warn about cases where the ZEBRA_IFA_PEER is set but no
destination address has been supplied (and turn off the flag).
(connected_add_ipv6) Add new flags argument so callers may set
the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies
IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning.
Set prefixlen in destination address so CONNECTED_PREFIX will work.
* connected.h: (connected_add_ipv6) Add new flags argument so
callers may set the ZEBRA_IFA_PEER flag.
* interface.c: (connected_dump_vty) Use CONNECTED_PEER macro
to decide whether the destination address is a peer or broadcast
address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT).
* if_ioctl.c: (if_getaddrs) Instead of setting a peer address
only when the IFF_POINTOPOINT is set, we now accept a peer
address whenever it is available and not the same as the local
address. Otherwise (no peer address assigned), we check
for a broadcast address (regardless of the IFF_BROADCAST flag).
And must now pass a flags value of ZEBRA_IFA_PEER to
connected_add_ipv4 when a peer address is assigned.
The same new logic is used with the IPv6 code as well (and we
pass the new flags argument to connected_add_ipv6).
(if_get_addr) Do not bother to check IFF_POINTOPOINT: just
issue the SIOCGIFDSTADDR ioctl and see if we get back
a peer address not matching the local address (and set
the ZEBRA_IFA_PEER in that case). If there's no peer address,
try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set.
* if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl
without bothering to check the IFF_POINTOPOINT flag. And if
no peer address was found, just try the SIOCGLIFBRDADDR ioctl
without checking the IFF_BROADCAST flag. Call connected_add_ipv4
and connected_add_ipv6 with appropriate flags.
* if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to
connected_add_ipv6.
* kernel_socket.c: (ifam_read) Must pass new flags argument to
connected_add_ipv6.
* rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2
to determine local and possible peer address (so there's no longer
a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately.
Pass new flags argument to connected_add_ipv6.
(netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast
to determine whether the connected destination address is a
broadcast address.
* bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete)
Simplify logic by using new CONNECTED_PREFIX macro.
* ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix,
ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX
macro, both options collapse into the same code.
* ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new
CONNECTED_ID macro.
(ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro
instead of testing the IFF_POINTOPOINT flag.
* ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro
instead of testing with if_is_pointopoint. And add commented-out
code to implement alternative (in my opinion) more elegant behavior
that has no special-case treatment for PtP addresses.
(ospf_network_run) Use new CONNECTED_ID macro to simplify logic.
* rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID
macro to simplify logic.
(rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does
not give a useful result if prefixlen is 32 (we require a peer
address in such cases).
* ripd.c: (rip_update_interface) Fix same bug as above.
2006-12-12 20:18:21 +01:00
|
|
|
p = CONNECTED_ID(ifc);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (p->family == AF_INET) {
|
|
|
|
addr = &p->u.prefix4;
|
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
if (!addr)
|
|
|
|
ifindex = ifp->ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Add interface to the list. */
|
|
|
|
pn = NULL;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf_snmp_iflist, node, osif)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
if (addr) {
|
2005-10-06 09:46:22 +02:00
|
|
|
/* Usual interfaces --> Sort them based on interface
|
|
|
|
* IPv4 addresses */
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ntohl(osif->addr.s_addr) > ntohl(addr->s_addr))
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
} else {
|
2005-10-06 09:46:22 +02:00
|
|
|
/* Unnumbered interfaces --> Sort them based on
|
|
|
|
* interface indexes */
|
2020-12-14 20:01:31 +01:00
|
|
|
if (osif->addr.s_addr != INADDR_ANY
|
|
|
|
|| osif->ifindex > ifindex)
|
2002-12-13 21:15:29 +01:00
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
pn = node;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
osif = ospf_snmp_if_new();
|
|
|
|
if (addr) /* Usual interface */
|
|
|
|
{
|
|
|
|
osif->addr = *addr;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
/* This field is used for storing ospfAddressLessIf OID value,
|
|
|
|
* conform to RFC1850 OSPF-MIB specification, it must be 0 for
|
|
|
|
* usual interface */
|
|
|
|
osif->ifindex = 0;
|
|
|
|
} else /* Unnumbered interface */
|
2002-12-13 21:15:29 +01:00
|
|
|
osif->ifindex = ifindex;
|
|
|
|
osif->ifp = ifp;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
listnode_add_after(ospf_snmp_iflist, pn, osif);
|
2016-06-12 17:32:23 +02:00
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
static int ospf_snmp_is_if_have_addr(struct interface *ifp)
|
|
|
|
{
|
|
|
|
struct connected *ifc;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
/* Is this interface having any connected IPv4 address ? */
|
2023-11-22 19:05:41 +01:00
|
|
|
frr_each (if_connected, ifp->connected, ifc) {
|
[PtP over ethernet] New peer flag allows much more addressing flexibility
2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating
whether a peer address has been configured. Comment now shows
the new interpretation of the destination addr: if ZEBRA_IFA_PEER
is set, then it must contain the destination address, otherwise
it may contain the broadcast address or be NULL.
(CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete
macros that were specific to IPv4 and not fully general.
(CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag.
(CONNECTED_PREFIX) New macro giving the prefix to insert into
the RIB: if CONNECTED_PEER, then use the destination (peer) address,
else use the address field.
(CONNECTED_ID) New macro to come up with an identifying address
for the struct connected.
* if.c: (if_lookup_address, connected_lookup_address) Streamline
logic with new CONNECTED_PREFIX macro.
* prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros
for better performance than the general prefix_copy function.
* zclient.c: (zebra_interface_address_read) For non-null destination
addresses, set prefixlen to equal the address prefixlen. This
is needed to get the new CONNECTED_PREFIX macro to work properly.
* connected.c: (connected_up_ipv4, connected_down_ipv4,
connected_up_ipv6, connected_down_ipv6) Simplify logic using the
new CONNECTED_PREFIX macro.
(connected_add_ipv4) Set prefixlen in destination addresses (required
by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead
of testing for IFF_POINTOPOINT. Delete invalid warning message.
Warn about cases where the ZEBRA_IFA_PEER is set but no
destination address has been supplied (and turn off the flag).
(connected_add_ipv6) Add new flags argument so callers may set
the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies
IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning.
Set prefixlen in destination address so CONNECTED_PREFIX will work.
* connected.h: (connected_add_ipv6) Add new flags argument so
callers may set the ZEBRA_IFA_PEER flag.
* interface.c: (connected_dump_vty) Use CONNECTED_PEER macro
to decide whether the destination address is a peer or broadcast
address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT).
* if_ioctl.c: (if_getaddrs) Instead of setting a peer address
only when the IFF_POINTOPOINT is set, we now accept a peer
address whenever it is available and not the same as the local
address. Otherwise (no peer address assigned), we check
for a broadcast address (regardless of the IFF_BROADCAST flag).
And must now pass a flags value of ZEBRA_IFA_PEER to
connected_add_ipv4 when a peer address is assigned.
The same new logic is used with the IPv6 code as well (and we
pass the new flags argument to connected_add_ipv6).
(if_get_addr) Do not bother to check IFF_POINTOPOINT: just
issue the SIOCGIFDSTADDR ioctl and see if we get back
a peer address not matching the local address (and set
the ZEBRA_IFA_PEER in that case). If there's no peer address,
try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set.
* if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl
without bothering to check the IFF_POINTOPOINT flag. And if
no peer address was found, just try the SIOCGLIFBRDADDR ioctl
without checking the IFF_BROADCAST flag. Call connected_add_ipv4
and connected_add_ipv6 with appropriate flags.
* if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to
connected_add_ipv6.
* kernel_socket.c: (ifam_read) Must pass new flags argument to
connected_add_ipv6.
* rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2
to determine local and possible peer address (so there's no longer
a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately.
Pass new flags argument to connected_add_ipv6.
(netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast
to determine whether the connected destination address is a
broadcast address.
* bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete)
Simplify logic by using new CONNECTED_PREFIX macro.
* ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix,
ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX
macro, both options collapse into the same code.
* ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new
CONNECTED_ID macro.
(ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro
instead of testing the IFF_POINTOPOINT flag.
* ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro
instead of testing with if_is_pointopoint. And add commented-out
code to implement alternative (in my opinion) more elegant behavior
that has no special-case treatment for PtP addresses.
(ospf_network_run) Use new CONNECTED_ID macro to simplify logic.
* rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID
macro to simplify logic.
(rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does
not give a useful result if prefixlen is 32 (we require a peer
address in such cases).
* ripd.c: (rip_update_interface) Fix same bug as above.
2006-12-12 20:18:21 +01:00
|
|
|
if (CONNECTED_PREFIX(ifc)->family == AF_INET)
|
2005-10-06 09:46:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-18 11:12:10 +01:00
|
|
|
static struct ospf_interface *ospf_snmp_if_lookup(struct in_addr *ifaddr,
|
|
|
|
ifindex_t *ifindex)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
struct listnode *node;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_snmp_if *osif;
|
2005-10-06 09:46:22 +02:00
|
|
|
struct ospf_interface *oi = NULL;
|
2017-08-25 22:51:12 +02:00
|
|
|
struct ospf *ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf_snmp_iflist, node, osif)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ifaddr->s_addr) {
|
2005-10-06 09:46:22 +02:00
|
|
|
if (IPV4_ADDR_SAME(&osif->addr, ifaddr))
|
|
|
|
oi = ospf_if_lookup_by_local_addr(
|
|
|
|
ospf, osif->ifp, *ifaddr);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else {
|
2005-10-06 09:46:22 +02:00
|
|
|
if (osif->ifindex == *ifindex)
|
|
|
|
oi = ospf_if_lookup_by_local_addr(
|
|
|
|
ospf, osif->ifp, *ifaddr);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2005-10-06 09:46:22 +02:00
|
|
|
return oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2016-01-18 11:12:10 +01:00
|
|
|
static struct ospf_interface *ospf_snmp_if_lookup_next(struct in_addr *ifaddr,
|
|
|
|
ifindex_t *ifindex,
|
|
|
|
int ifaddr_next,
|
|
|
|
ifindex_t ifindex_next)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_snmp_if *osif;
|
|
|
|
struct listnode *nn;
|
2017-08-25 22:51:12 +02:00
|
|
|
struct ospf *ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2005-10-06 09:46:22 +02:00
|
|
|
struct ospf_interface *oi = NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
if (ospf == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
/* No instance is specified --> Return the first OSPF interface */
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ifaddr_next) {
|
2005-10-06 09:46:22 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf_snmp_iflist, nn, osif)) {
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
osif = listgetdata(nn);
|
2002-12-13 21:15:29 +01:00
|
|
|
*ifaddr = osif->addr;
|
|
|
|
*ifindex = osif->ifindex;
|
2005-10-06 09:46:22 +02:00
|
|
|
/* Because no instance is specified, we don't care about
|
|
|
|
* the kind of
|
|
|
|
* interface (usual or unnumbered), just returning the
|
|
|
|
* first valid
|
|
|
|
* OSPF interface */
|
|
|
|
oi = ospf_if_lookup_by_local_addr(ospf, osif->ifp,
|
|
|
|
*ifaddr);
|
|
|
|
if (oi)
|
|
|
|
return (oi);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
/* An instance is specified --> Return the next OSPF interface */
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf_snmp_iflist, nn, osif)) {
|
2005-10-06 09:46:22 +02:00
|
|
|
/* Usual interface */
|
|
|
|
if (ifaddr->s_addr) {
|
2009-06-02 19:40:07 +02:00
|
|
|
/* The interface must have valid AF_INET connected
|
|
|
|
* address */
|
|
|
|
/* it must have lager IPv4 address value than the lookup
|
|
|
|
* entry */
|
|
|
|
if ((ospf_snmp_is_if_have_addr(osif->ifp))
|
|
|
|
&& (ntohl(osif->addr.s_addr)
|
|
|
|
> ntohl(ifaddr->s_addr))) {
|
2005-10-06 09:46:22 +02:00
|
|
|
*ifaddr = osif->addr;
|
|
|
|
*ifindex = osif->ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
/* and it must be an OSPF interface */
|
|
|
|
oi = ospf_if_lookup_by_local_addr(
|
|
|
|
ospf, osif->ifp, *ifaddr);
|
2009-06-02 19:40:07 +02:00
|
|
|
if (oi)
|
2005-10-06 09:46:22 +02:00
|
|
|
return oi;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
}
|
2005-10-06 09:46:22 +02:00
|
|
|
/* Unnumbered interface */
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2005-10-06 09:46:22 +02:00
|
|
|
/* The interface must NOT have valid AF_INET connected
|
|
|
|
address */
|
|
|
|
/* it must have lager interface index than the lookup
|
2017-07-17 14:03:14 +02:00
|
|
|
entry */
|
2009-06-02 19:40:07 +02:00
|
|
|
if ((!ospf_snmp_is_if_have_addr(osif->ifp))
|
|
|
|
&& (osif->ifindex > *ifindex)) {
|
|
|
|
*ifaddr = osif->addr;
|
|
|
|
*ifindex = osif->ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2009-06-02 19:40:07 +02:00
|
|
|
/* and it must be an OSPF interface */
|
|
|
|
oi = ospf_if_lookup_by_local_addr(ospf, osif->ifp,
|
|
|
|
*ifaddr);
|
|
|
|
if (oi)
|
|
|
|
return oi;
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf_snmp_iftype(struct interface *ifp)
|
|
|
|
{
|
|
|
|
#define ospf_snmp_iftype_broadcast 1
|
|
|
|
#define ospf_snmp_iftype_nbma 2
|
|
|
|
#define ospf_snmp_iftype_pointToPoint 3
|
|
|
|
#define ospf_snmp_iftype_pointToMultipoint 5
|
|
|
|
if (if_is_broadcast(ifp))
|
|
|
|
return ospf_snmp_iftype_broadcast;
|
|
|
|
if (if_is_pointopoint(ifp))
|
|
|
|
return ospf_snmp_iftype_pointToPoint;
|
|
|
|
return ospf_snmp_iftype_broadcast;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
|
|
|
|
size_t *length,
|
2016-01-18 11:12:10 +01:00
|
|
|
struct in_addr *ifaddr,
|
|
|
|
ifindex_t *ifindex, int exact)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-11 13:00:30 +02:00
|
|
|
unsigned int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
int ifaddr_next = 0;
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex_next = 0;
|
2005-10-06 09:46:22 +02:00
|
|
|
struct ospf_interface *oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
oid *offset;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
if (*length != v->namelen + IN_ADDR_SIZE + 1)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, ifaddr);
|
|
|
|
*ifindex = name[v->namelen + IN_ADDR_SIZE];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return ospf_snmp_if_lookup(ifaddr, ifindex);
|
|
|
|
} else {
|
|
|
|
len = *length - v->namelen;
|
|
|
|
if (len >= IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
2018-06-18 19:07:24 +02:00
|
|
|
if (len == 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
ifaddr_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(name + v->namelen, len, ifaddr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
len = *length - v->namelen - IN_ADDR_SIZE;
|
|
|
|
if (len >= 1)
|
|
|
|
len = 1;
|
|
|
|
else
|
|
|
|
ifindex_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (len == 1)
|
|
|
|
*ifindex = name[v->namelen + IN_ADDR_SIZE];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
oi = ospf_snmp_if_lookup_next(ifaddr, ifindex, ifaddr_next,
|
2002-12-13 21:15:29 +01:00
|
|
|
ifindex_next);
|
2005-10-06 09:46:22 +02:00
|
|
|
if (oi) {
|
2002-12-13 21:15:29 +01:00
|
|
|
*length = v->namelen + IN_ADDR_SIZE + 1;
|
|
|
|
offset = name + v->namelen;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, ifaddr);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2002-12-13 21:15:29 +01:00
|
|
|
*offset = *ifindex;
|
2005-10-06 09:46:22 +02:00
|
|
|
return oi;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfIfEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct in_addr ifaddr;
|
|
|
|
struct ospf_interface *oi;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
ifindex = 0;
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&ifaddr, 0, sizeof(ifaddr));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
oi = ospfIfLookup(v, name, length, &ifaddr, &ifindex, exact);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (oi == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFIFIPADDRESS: /* 1 */
|
|
|
|
return SNMP_IPADDRESS(ifaddr);
|
|
|
|
case OSPFADDRESSLESSIF: /* 2 */
|
|
|
|
return SNMP_INTEGER(ifindex);
|
|
|
|
case OSPFIFAREAID: /* 3 */
|
|
|
|
if (oi->area)
|
|
|
|
return SNMP_IPADDRESS(oi->area->area_id);
|
|
|
|
else
|
|
|
|
return SNMP_IPADDRESS(ospf_empty_addr);
|
|
|
|
case OSPFIFTYPE: /* 4 */
|
2005-10-06 09:46:22 +02:00
|
|
|
return SNMP_INTEGER(ospf_snmp_iftype(oi->ifp));
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFIFADMINSTAT: /* 5 */
|
|
|
|
if (oi)
|
|
|
|
return SNMP_INTEGER(OSPF_STATUS_ENABLED);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(OSPF_STATUS_DISABLED);
|
|
|
|
case OSPFIFRTRPRIORITY: /* 6 */
|
|
|
|
return SNMP_INTEGER(PRIORITY(oi));
|
|
|
|
case OSPFIFTRANSITDELAY: /* 7 */
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, transmit_delay));
|
|
|
|
case OSPFIFRETRANSINTERVAL: /* 8 */
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, retransmit_interval));
|
|
|
|
case OSPFIFHELLOINTERVAL: /* 9 */
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, v_hello));
|
|
|
|
case OSPFIFRTRDEADINTERVAL: /* 10 */
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, v_wait));
|
|
|
|
case OSPFIFPOLLINTERVAL: /* 11 */
|
|
|
|
return SNMP_INTEGER(OSPF_POLL_INTERVAL_DEFAULT);
|
|
|
|
case OSPFIFSTATE: /* 12 */
|
2005-09-29 15:52:57 +02:00
|
|
|
return SNMP_INTEGER(ISM_SNMP(oi->state));
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFIFDESIGNATEDROUTER: /* 13 */
|
|
|
|
return SNMP_IPADDRESS(DR(oi));
|
|
|
|
case OSPFIFBACKUPDESIGNATEDROUTER: /* 14 */
|
|
|
|
return SNMP_IPADDRESS(BDR(oi));
|
|
|
|
case OSPFIFEVENTS: /* 15 */
|
|
|
|
return SNMP_INTEGER(oi->state_change);
|
|
|
|
case OSPFIFAUTHKEY: /* 16 */
|
|
|
|
*var_len = 0;
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)OSPF_IF_PARAM(oi, auth_simple);
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFIFSTATUS: /* 17 */
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
|
|
|
case OSPFIFMULTICASTFORWARDING: /* 18 */
|
|
|
|
#define ospf_snmp_multiforward_blocked 1
|
|
|
|
#define ospf_snmp_multiforward_multicast 2
|
|
|
|
#define ospf_snmp_multiforward_unicast 3
|
|
|
|
return SNMP_INTEGER(ospf_snmp_multiforward_blocked);
|
|
|
|
case OSPFIFDEMAND: /* 19 */
|
|
|
|
return SNMP_INTEGER(SNMP_FALSE);
|
|
|
|
case OSPFIFAUTHTYPE: /* 20 */
|
|
|
|
if (oi->area)
|
|
|
|
return SNMP_INTEGER(oi->area->auth_type);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OSPF_SNMP_METRIC_VALUE 1
|
|
|
|
|
|
|
|
static struct ospf_interface *ospfIfMetricLookup(struct variable *v, oid *name,
|
|
|
|
size_t *length,
|
2016-01-18 11:12:10 +01:00
|
|
|
struct in_addr *ifaddr,
|
|
|
|
ifindex_t *ifindex, int exact)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-11 13:00:30 +02:00
|
|
|
unsigned int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
int ifaddr_next = 0;
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex_next = 0;
|
2005-10-06 09:46:22 +02:00
|
|
|
struct ospf_interface *oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
oid *offset;
|
|
|
|
int metric;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
if (*length != v->namelen + IN_ADDR_SIZE + 1 + 1)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, ifaddr);
|
|
|
|
*ifindex = name[v->namelen + IN_ADDR_SIZE];
|
|
|
|
metric = name[v->namelen + IN_ADDR_SIZE + 1];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (metric != OSPF_SNMP_METRIC_VALUE)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return ospf_snmp_if_lookup(ifaddr, ifindex);
|
|
|
|
} else {
|
|
|
|
len = *length - v->namelen;
|
|
|
|
if (len >= IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
|
|
|
else
|
|
|
|
ifaddr_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(name + v->namelen, len, ifaddr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
len = *length - v->namelen - IN_ADDR_SIZE;
|
|
|
|
if (len >= 1)
|
|
|
|
len = 1;
|
|
|
|
else
|
|
|
|
ifindex_next = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (len == 1)
|
|
|
|
*ifindex = name[v->namelen + IN_ADDR_SIZE];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
oi = ospf_snmp_if_lookup_next(ifaddr, ifindex, ifaddr_next,
|
2002-12-13 21:15:29 +01:00
|
|
|
ifindex_next);
|
2005-10-06 09:46:22 +02:00
|
|
|
if (oi) {
|
2002-12-13 21:15:29 +01:00
|
|
|
*length = v->namelen + IN_ADDR_SIZE + 1 + 1;
|
|
|
|
offset = name + v->namelen;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, ifaddr);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2002-12-13 21:15:29 +01:00
|
|
|
*offset = *ifindex;
|
|
|
|
offset++;
|
|
|
|
*offset = OSPF_SNMP_METRIC_VALUE;
|
2005-10-06 09:46:22 +02:00
|
|
|
return oi;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfIfMetricEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
/* Currently we support metric 1 only. */
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct in_addr ifaddr;
|
|
|
|
struct ospf_interface *oi;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
ifindex = 0;
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&ifaddr, 0, sizeof(ifaddr));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-10-06 09:46:22 +02:00
|
|
|
oi = ospfIfMetricLookup(v, name, length, &ifaddr, &ifindex, exact);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (oi == NULL)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFIFMETRICIPADDRESS:
|
|
|
|
return SNMP_IPADDRESS(ifaddr);
|
|
|
|
case OSPFIFMETRICADDRESSLESSIF:
|
|
|
|
return SNMP_INTEGER(ifindex);
|
|
|
|
case OSPFIFMETRICTOS:
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
case OSPFIFMETRICVALUE:
|
|
|
|
return SNMP_INTEGER(OSPF_SNMP_METRIC_VALUE);
|
|
|
|
case OSPFIFMETRICSTATUS:
|
|
|
|
return SNMP_INTEGER(1);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct route_table *ospf_snmp_vl_table;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
static int ospf_snmp_vl_add(struct ospf_vl_data *vl_data)
|
|
|
|
{
|
|
|
|
struct prefix_ls lp;
|
|
|
|
struct route_node *rn;
|
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&lp, 0, sizeof(lp));
|
2022-02-07 19:20:43 +01:00
|
|
|
lp.family = AF_UNSPEC;
|
2002-12-13 21:15:29 +01:00
|
|
|
lp.prefixlen = 64;
|
|
|
|
lp.id = vl_data->vl_area_id;
|
|
|
|
lp.adv_router = vl_data->vl_peer;
|
|
|
|
|
|
|
|
rn = route_node_get(ospf_snmp_vl_table, (struct prefix *)&lp);
|
2010-03-08 13:58:14 +01:00
|
|
|
if (rn->info)
|
|
|
|
route_unlock_node(rn);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
rn->info = vl_data;
|
2016-06-12 17:32:23 +02:00
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf_snmp_vl_delete(struct ospf_vl_data *vl_data)
|
|
|
|
{
|
|
|
|
struct prefix_ls lp;
|
|
|
|
struct route_node *rn;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&lp, 0, sizeof(lp));
|
2022-02-07 19:20:43 +01:00
|
|
|
lp.family = AF_UNSPEC;
|
2002-12-13 21:15:29 +01:00
|
|
|
lp.prefixlen = 64;
|
|
|
|
lp.id = vl_data->vl_area_id;
|
|
|
|
lp.adv_router = vl_data->vl_peer;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
rn = route_node_lookup(ospf_snmp_vl_table, (struct prefix *)&lp);
|
|
|
|
if (!rn)
|
2016-06-12 17:32:23 +02:00
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
rn->info = NULL;
|
|
|
|
route_unlock_node(rn);
|
|
|
|
route_unlock_node(rn);
|
2016-06-12 17:32:23 +02:00
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_vl_data *ospf_snmp_vl_lookup(struct in_addr *area_id,
|
|
|
|
struct in_addr *neighbor)
|
|
|
|
{
|
|
|
|
struct prefix_ls lp;
|
|
|
|
struct route_node *rn;
|
|
|
|
struct ospf_vl_data *vl_data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&lp, 0, sizeof(lp));
|
2022-02-07 19:20:43 +01:00
|
|
|
lp.family = AF_UNSPEC;
|
2002-12-13 21:15:29 +01:00
|
|
|
lp.prefixlen = 64;
|
|
|
|
lp.id = *area_id;
|
|
|
|
lp.adv_router = *neighbor;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
rn = route_node_lookup(ospf_snmp_vl_table, (struct prefix *)&lp);
|
|
|
|
if (rn) {
|
|
|
|
vl_data = rn->info;
|
|
|
|
route_unlock_node(rn);
|
|
|
|
return vl_data;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_vl_data *ospf_snmp_vl_lookup_next(struct in_addr *area_id,
|
|
|
|
struct in_addr *neighbor,
|
|
|
|
int first)
|
|
|
|
{
|
|
|
|
struct prefix_ls lp;
|
|
|
|
struct route_node *rn;
|
|
|
|
struct ospf_vl_data *vl_data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&lp, 0, sizeof(lp));
|
2022-02-07 19:20:43 +01:00
|
|
|
lp.family = AF_UNSPEC;
|
2002-12-13 21:15:29 +01:00
|
|
|
lp.prefixlen = 64;
|
|
|
|
lp.id = *area_id;
|
|
|
|
lp.adv_router = *neighbor;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (first)
|
|
|
|
rn = route_top(ospf_snmp_vl_table);
|
2017-07-17 14:03:14 +02:00
|
|
|
else {
|
2002-12-13 21:15:29 +01:00
|
|
|
rn = route_node_get(ospf_snmp_vl_table, (struct prefix *)&lp);
|
|
|
|
rn = route_next(rn);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; rn; rn = route_next(rn))
|
|
|
|
if (rn->info)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (rn && rn->info) {
|
|
|
|
vl_data = rn->info;
|
|
|
|
*area_id = vl_data->vl_area_id;
|
|
|
|
*neighbor = vl_data->vl_peer;
|
|
|
|
route_unlock_node(rn);
|
|
|
|
return vl_data;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2009-06-02 19:40:07 +02:00
|
|
|
static struct ospf_vl_data *
|
2002-12-13 21:15:29 +01:00
|
|
|
ospfVirtIfLookup(struct variable *v, oid *name, size_t *length,
|
|
|
|
struct in_addr *area_id, struct in_addr *neighbor, int exact)
|
2017-07-17 14:03:14 +02:00
|
|
|
{
|
2002-12-13 21:15:29 +01:00
|
|
|
int first;
|
2004-10-11 13:00:30 +02:00
|
|
|
unsigned int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_vl_data *vl_data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
if (*length != v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, area_id);
|
|
|
|
oid2in_addr(name + v->namelen + IN_ADDR_SIZE, IN_ADDR_SIZE,
|
|
|
|
neighbor);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return ospf_snmp_vl_lookup(area_id, neighbor);
|
|
|
|
} else {
|
|
|
|
first = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
len = *length - v->namelen;
|
2018-06-18 19:07:24 +02:00
|
|
|
if (len == 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
first = 1;
|
|
|
|
if (len > IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
|
|
|
oid2in_addr(name + v->namelen, len, area_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
len = *length - v->namelen - IN_ADDR_SIZE;
|
|
|
|
if (len > IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
|
|
|
oid2in_addr(name + v->namelen + IN_ADDR_SIZE, len, neighbor);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
vl_data = ospf_snmp_vl_lookup_next(area_id, neighbor, first);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (vl_data) {
|
|
|
|
*length = v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(name + v->namelen, area_id);
|
|
|
|
oid_copy_in_addr(name + v->namelen + IN_ADDR_SIZE,
|
|
|
|
neighbor);
|
2002-12-13 21:15:29 +01:00
|
|
|
return vl_data;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfVirtIfEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_vl_data *vl_data;
|
|
|
|
struct ospf_interface *oi;
|
|
|
|
struct in_addr area_id;
|
|
|
|
struct in_addr neighbor;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&area_id, 0, sizeof(area_id));
|
|
|
|
memset(&neighbor, 0, sizeof(neighbor));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
vl_data = ospfVirtIfLookup(v, name, length, &area_id, &neighbor, exact);
|
|
|
|
if (!vl_data)
|
|
|
|
return NULL;
|
|
|
|
oi = vl_data->vl_oi;
|
|
|
|
if (!oi)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFVIRTIFAREAID:
|
|
|
|
return SNMP_IPADDRESS(area_id);
|
|
|
|
case OSPFVIRTIFNEIGHBOR:
|
|
|
|
return SNMP_IPADDRESS(neighbor);
|
|
|
|
case OSPFVIRTIFTRANSITDELAY:
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, transmit_delay));
|
|
|
|
case OSPFVIRTIFRETRANSINTERVAL:
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, retransmit_interval));
|
|
|
|
case OSPFVIRTIFHELLOINTERVAL:
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, v_hello));
|
|
|
|
case OSPFVIRTIFRTRDEADINTERVAL:
|
|
|
|
return SNMP_INTEGER(OSPF_IF_PARAM(oi, v_wait));
|
|
|
|
case OSPFVIRTIFSTATE:
|
|
|
|
return SNMP_INTEGER(oi->state);
|
|
|
|
case OSPFVIRTIFEVENTS:
|
|
|
|
return SNMP_INTEGER(oi->state_change);
|
|
|
|
case OSPFVIRTIFAUTHKEY:
|
|
|
|
*var_len = 0;
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)OSPF_IF_PARAM(oi, auth_simple);
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTIFSTATUS:
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
|
|
|
case OSPFVIRTIFAUTHTYPE:
|
|
|
|
if (oi->area)
|
|
|
|
return SNMP_INTEGER(oi->area->auth_type);
|
|
|
|
else
|
|
|
|
return SNMP_INTEGER(0);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
static struct ospf_neighbor *ospf_snmp_nbr_lookup(struct ospf *ospf,
|
|
|
|
struct in_addr *nbr_addr,
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t *ifindex)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
struct listnode *node, *nnode;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_interface *oi;
|
|
|
|
struct ospf_neighbor *nbr;
|
|
|
|
struct route_node *rn;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
|
2020-12-14 20:01:31 +01:00
|
|
|
if ((nbr = rn->info) != NULL
|
|
|
|
&& nbr != oi->nbr_self
|
2005-09-29 18:34:30 +02:00
|
|
|
/* If EXACT match is needed, provide ALL entry found
|
2002-12-13 21:15:29 +01:00
|
|
|
&& nbr->state != NSM_Down
|
2005-09-29 18:34:30 +02:00
|
|
|
*/
|
2020-12-14 20:01:31 +01:00
|
|
|
&& nbr->src.s_addr != INADDR_ANY) {
|
2002-12-13 21:15:29 +01:00
|
|
|
if (IPV4_ADDR_SAME(&nbr->src, nbr_addr)) {
|
|
|
|
route_unlock_node(rn);
|
|
|
|
return nbr;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-01-18 11:12:10 +01:00
|
|
|
static struct ospf_neighbor *ospf_snmp_nbr_lookup_next(struct in_addr *nbr_addr,
|
|
|
|
ifindex_t *ifindex,
|
2002-12-13 21:15:29 +01:00
|
|
|
int first)
|
|
|
|
{
|
|
|
|
struct listnode *nn;
|
|
|
|
struct ospf_interface *oi;
|
|
|
|
struct ospf_neighbor *nbr;
|
|
|
|
struct route_node *rn;
|
|
|
|
struct ospf_neighbor *min = NULL;
|
2018-04-16 20:47:57 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, nn, oi)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
|
|
|
|
if ((nbr = rn->info) != NULL && nbr != oi->nbr_self
|
2020-12-14 20:01:31 +01:00
|
|
|
&& nbr->state != NSM_Down
|
|
|
|
&& nbr->src.s_addr != INADDR_ANY) {
|
2002-12-13 21:15:29 +01:00
|
|
|
if (first) {
|
|
|
|
if (!min)
|
|
|
|
min = nbr;
|
|
|
|
else if (ntohl(nbr->src.s_addr)
|
|
|
|
< ntohl(min->src.s_addr))
|
|
|
|
min = nbr;
|
|
|
|
} else if (ntohl(nbr->src.s_addr)
|
|
|
|
> ntohl(nbr_addr->s_addr)) {
|
|
|
|
if (!min)
|
|
|
|
min = nbr;
|
|
|
|
else if (ntohl(nbr->src.s_addr)
|
|
|
|
< ntohl(min->src.s_addr))
|
|
|
|
min = nbr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (min) {
|
|
|
|
*nbr_addr = min->src;
|
|
|
|
*ifindex = 0;
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf_neighbor *ospfNbrLookup(struct variable *v, oid *name,
|
|
|
|
size_t *length,
|
2016-01-18 11:12:10 +01:00
|
|
|
struct in_addr *nbr_addr,
|
|
|
|
ifindex_t *ifindex, int exact)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-11 13:00:30 +02:00
|
|
|
unsigned int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
int first;
|
|
|
|
struct ospf_neighbor *nbr;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2005-03-27 15:32:25 +02:00
|
|
|
if (!ospf)
|
|
|
|
return NULL;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
if (*length != v->namelen + IN_ADDR_SIZE + 1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, nbr_addr);
|
|
|
|
*ifindex = name[v->namelen + IN_ADDR_SIZE];
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
return ospf_snmp_nbr_lookup(ospf, nbr_addr, ifindex);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else {
|
|
|
|
first = 0;
|
|
|
|
len = *length - v->namelen;
|
|
|
|
|
2018-06-18 19:07:24 +02:00
|
|
|
if (len == 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
first = 1;
|
|
|
|
|
|
|
|
if (len > IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
|
|
|
|
|
|
|
oid2in_addr(name + v->namelen, len, nbr_addr);
|
|
|
|
|
|
|
|
len = *length - v->namelen - IN_ADDR_SIZE;
|
|
|
|
if (len >= 1)
|
|
|
|
*ifindex = name[v->namelen + IN_ADDR_SIZE];
|
|
|
|
|
|
|
|
nbr = ospf_snmp_nbr_lookup_next(nbr_addr, ifindex, first);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (nbr) {
|
|
|
|
*length = v->namelen + IN_ADDR_SIZE + 1;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(name + v->namelen, nbr_addr);
|
2002-12-13 21:15:29 +01:00
|
|
|
name[v->namelen + IN_ADDR_SIZE] = *ifindex;
|
|
|
|
return nbr;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-11-11 20:40:17 +01:00
|
|
|
/* map internal frr neighbor states to official MIB values:
|
2007-03-14 23:05:18 +01:00
|
|
|
|
|
|
|
ospfNbrState OBJECT-TYPE
|
|
|
|
SYNTAX INTEGER {
|
|
|
|
down (1),
|
|
|
|
attempt (2),
|
|
|
|
init (3),
|
|
|
|
twoWay (4),
|
|
|
|
exchangeStart (5),
|
|
|
|
exchange (6),
|
|
|
|
loading (7),
|
|
|
|
full (8)
|
|
|
|
}
|
|
|
|
*/
|
2018-03-27 21:13:34 +02:00
|
|
|
static int32_t ospf_snmp_neighbor_state(uint8_t nst)
|
2007-03-14 23:05:18 +01:00
|
|
|
{
|
|
|
|
switch (nst) {
|
|
|
|
case NSM_Attempt:
|
|
|
|
return 2;
|
|
|
|
case NSM_Init:
|
|
|
|
return 3;
|
|
|
|
case NSM_TwoWay:
|
|
|
|
return 4;
|
|
|
|
case NSM_ExStart:
|
|
|
|
return 5;
|
|
|
|
case NSM_Exchange:
|
|
|
|
return 6;
|
|
|
|
case NSM_Loading:
|
|
|
|
return 7;
|
|
|
|
case NSM_Full:
|
|
|
|
return 8;
|
|
|
|
default:
|
|
|
|
return 1; /* down */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfNbrEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct in_addr nbr_addr;
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_neighbor *nbr;
|
|
|
|
struct ospf_interface *oi;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&nbr_addr, 0, sizeof(nbr_addr));
|
2002-12-13 21:15:29 +01:00
|
|
|
ifindex = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
nbr = ospfNbrLookup(v, name, length, &nbr_addr, &ifindex, exact);
|
|
|
|
if (!nbr)
|
|
|
|
return NULL;
|
|
|
|
oi = nbr->oi;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFNBRIPADDR:
|
|
|
|
return SNMP_IPADDRESS(nbr_addr);
|
|
|
|
case OSPFNBRADDRESSLESSINDEX:
|
|
|
|
return SNMP_INTEGER(ifindex);
|
|
|
|
case OSPFNBRRTRID:
|
|
|
|
return SNMP_IPADDRESS(nbr->router_id);
|
|
|
|
case OSPFNBROPTIONS:
|
|
|
|
return SNMP_INTEGER(oi->nbr_self->options);
|
|
|
|
case OSPFNBRPRIORITY:
|
|
|
|
return SNMP_INTEGER(nbr->priority);
|
|
|
|
case OSPFNBRSTATE:
|
2007-03-14 23:05:18 +01:00
|
|
|
return SNMP_INTEGER(ospf_snmp_neighbor_state(nbr->state));
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFNBREVENTS:
|
|
|
|
return SNMP_INTEGER(nbr->state_change);
|
|
|
|
case OSPFNBRLSRETRANSQLEN:
|
|
|
|
return SNMP_INTEGER(ospf_ls_retransmit_count(nbr));
|
|
|
|
case OSPFNBMANBRSTATUS:
|
|
|
|
return SNMP_INTEGER(SNMP_VALID);
|
|
|
|
case OSPFNBMANBRPERMANENCE:
|
|
|
|
return SNMP_INTEGER(2);
|
|
|
|
case OSPFNBRHELLOSUPPRESSED:
|
|
|
|
return SNMP_INTEGER(SNMP_FALSE);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfVirtNbrEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_vl_data *vl_data;
|
|
|
|
struct in_addr area_id;
|
|
|
|
struct in_addr neighbor;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&area_id, 0, sizeof(area_id));
|
|
|
|
memset(&neighbor, 0, sizeof(neighbor));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
vl_data = ospfVirtIfLookup(v, name, length, &area_id, &neighbor, exact);
|
|
|
|
if (!vl_data)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFVIRTNBRAREA:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBRRTRID:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBRIPADDR:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBROPTIONS:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBRSTATE:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBREVENTS:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBRLSRETRANSQLEN:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFVIRTNBRHELLOSUPPRESSED:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
|
2018-03-27 21:13:34 +02:00
|
|
|
size_t *length, uint8_t *type,
|
2002-12-13 21:15:29 +01:00
|
|
|
struct in_addr *ls_id,
|
|
|
|
struct in_addr *router_id, int exact)
|
|
|
|
{
|
|
|
|
int first;
|
|
|
|
oid *offset;
|
|
|
|
int offsetlen;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t lsa_type;
|
2004-10-11 13:00:30 +02:00
|
|
|
unsigned int len;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf_lsa *lsa;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (exact) {
|
|
|
|
if (*length != v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
offset = name + v->namelen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Make it sure given value match to type. */
|
|
|
|
lsa_type = *offset;
|
|
|
|
offset++;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (lsa_type != *type)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* LS ID. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, ls_id);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Router ID. */
|
|
|
|
oid2in_addr(offset, IN_ADDR_SIZE, router_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
return ospf_lsdb_lookup_by_id(ospf->lsdb, *type, *ls_id,
|
|
|
|
*router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else {
|
|
|
|
/* Get variable length. */
|
|
|
|
first = 0;
|
|
|
|
offset = name + v->namelen;
|
|
|
|
offsetlen = *length - v->namelen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* LSA type value. */
|
|
|
|
lsa_type = *offset;
|
|
|
|
offset++;
|
|
|
|
offsetlen--;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (offsetlen <= 0 || lsa_type < OSPF_AS_EXTERNAL_LSA)
|
|
|
|
first = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* LS ID. */
|
|
|
|
len = offsetlen;
|
|
|
|
if (len > IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, ls_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2002-12-13 21:15:29 +01:00
|
|
|
offsetlen -= IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Router ID. */
|
|
|
|
len = offsetlen;
|
|
|
|
if (len > IN_ADDR_SIZE)
|
|
|
|
len = IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
oid2in_addr(offset, len, router_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
lsa = ospf_lsdb_lookup_by_id_next(ospf->lsdb, *type, *ls_id,
|
2002-12-13 21:15:29 +01:00
|
|
|
*router_id, first);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (lsa) {
|
|
|
|
/* Fill in length. */
|
|
|
|
*length = v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Fill in value. */
|
|
|
|
offset = name + v->namelen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
*offset = OSPF_AS_EXTERNAL_LSA;
|
|
|
|
offset++;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, &lsa->data->id);
|
2024-04-23 11:36:14 +02:00
|
|
|
offset += IN_ADDR_SIZE;
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(offset, &lsa->data->adv_router);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return lsa;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfExtLsdbEntry(struct variable *v, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
struct lsa_header *lsah;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t type;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct in_addr ls_id;
|
|
|
|
struct in_addr router_id;
|
2003-04-04 04:44:16 +02:00
|
|
|
struct ospf *ospf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
type = OSPF_AS_EXTERNAL_LSA;
|
2022-05-11 12:16:44 +02:00
|
|
|
memset(&ls_id, 0, sizeof(ls_id));
|
|
|
|
memset(&router_id, 0, sizeof(router_id));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Check OSPF instance. */
|
2017-08-25 22:51:12 +02:00
|
|
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
2003-03-25 06:07:42 +01:00
|
|
|
if (ospf == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
lsa = ospfExtLsdbLookup(v, name, length, &type, &ls_id, &router_id,
|
|
|
|
exact);
|
|
|
|
if (!lsa)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
lsah = lsa->data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFEXTLSDBTYPE:
|
|
|
|
return SNMP_INTEGER(OSPF_AS_EXTERNAL_LSA);
|
|
|
|
case OSPFEXTLSDBLSID:
|
|
|
|
return SNMP_IPADDRESS(lsah->id);
|
|
|
|
case OSPFEXTLSDBROUTERID:
|
|
|
|
return SNMP_IPADDRESS(lsah->adv_router);
|
|
|
|
case OSPFEXTLSDBSEQUENCE:
|
|
|
|
return SNMP_INTEGER(lsah->ls_seqnum);
|
|
|
|
case OSPFEXTLSDBAGE:
|
|
|
|
return SNMP_INTEGER(lsah->ls_age);
|
|
|
|
case OSPFEXTLSDBCHECKSUM:
|
|
|
|
return SNMP_INTEGER(lsah->checksum);
|
|
|
|
case OSPFEXTLSDBADVERTISEMENT:
|
|
|
|
*var_len = ntohs(lsah->length);
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)lsah;
|
2002-12-13 21:15:29 +01:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint8_t *ospfAreaAggregateEntry(struct variable *v, oid *name,
|
|
|
|
size_t *length, int exact,
|
|
|
|
size_t *var_len,
|
|
|
|
WriteMethod **write_method)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2012-05-31 13:30:28 +02:00
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method)
|
|
|
|
== MATCH_FAILED)
|
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return the current value of the variable */
|
|
|
|
switch (v->magic) {
|
|
|
|
case OSPFAREAAGGREGATEAREAID:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFAREAAGGREGATELSDBTYPE:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFAREAAGGREGATENET:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFAREAAGGREGATEMASK:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFAREAAGGREGATESTATUS:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
case OSPFAREAAGGREGATEEFFECT:
|
2018-03-27 21:13:34 +02:00
|
|
|
return (uint8_t *)NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2005-09-29 18:34:30 +02:00
|
|
|
/* OSPF Traps. */
|
|
|
|
#define IFSTATECHANGE 16
|
|
|
|
#define VIRTIFSTATECHANGE 1
|
|
|
|
#define NBRSTATECHANGE 2
|
|
|
|
#define VIRTNBRSTATECHANGE 3
|
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct trap_object ospfNbrTrapList[] = {{-2, {1, OSPFROUTERID}},
|
2012-05-25 08:56:44 +02:00
|
|
|
{3, {10, 1, OSPFNBRIPADDR}},
|
|
|
|
{3, {10, 1, OSPFNBRRTRID}},
|
|
|
|
{3, {10, 1, OSPFNBRSTATE}}};
|
2005-09-29 18:34:30 +02:00
|
|
|
|
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct trap_object ospfVirtNbrTrapList[] = {
|
2012-05-25 08:56:44 +02:00
|
|
|
{-2, {1, 1}},
|
|
|
|
{3, {11, 1, OSPFVIRTNBRAREA}},
|
|
|
|
{3, {11, 1, OSPFVIRTNBRRTRID}},
|
|
|
|
{3, {11, 1, OSPFVIRTNBRSTATE}}};
|
2005-09-29 18:34:30 +02:00
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct trap_object ospfIfTrapList[] = {{-2, {1, OSPFROUTERID}},
|
2012-05-25 08:56:44 +02:00
|
|
|
{3, {7, 1, OSPFIFIPADDRESS}},
|
|
|
|
{3, {7, 1, OSPFADDRESSLESSIF}},
|
|
|
|
{3, {7, 1, OSPFIFSTATE}}};
|
2005-09-29 18:34:30 +02:00
|
|
|
|
2016-07-28 17:23:45 +02:00
|
|
|
static struct trap_object ospfVirtIfTrapList[] = {
|
2012-05-25 08:56:44 +02:00
|
|
|
{-2, {1, OSPFROUTERID}},
|
|
|
|
{3, {9, 1, OSPFVIRTIFAREAID}},
|
|
|
|
{3, {9, 1, OSPFVIRTIFNEIGHBOR}},
|
|
|
|
{3, {9, 1, OSPFVIRTIFSTATE}}};
|
2005-09-29 18:34:30 +02:00
|
|
|
|
|
|
|
static void ospfTrapNbrStateChange(struct ospf_neighbor *on)
|
|
|
|
{
|
|
|
|
oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)];
|
2006-06-24 22:05:02 +02:00
|
|
|
char msgbuf[16];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-10-08 09:15:48 +02:00
|
|
|
ospf_nbr_ism_state_message(on, msgbuf, sizeof(msgbuf));
|
2017-12-26 18:45:25 +01:00
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2020-10-21 19:56:26 +02:00
|
|
|
zlog_info("%s: trap sent: %pI4 now %s", __func__,
|
|
|
|
&on->address.u.prefix4, msgbuf);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(index, &(on->address.u.prefix4));
|
2005-09-29 18:34:30 +02:00
|
|
|
index[IN_ADDR_SIZE] = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-02-25 20:23:41 +01:00
|
|
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
|
|
|
array_size(ospf_trap_oid), ospf_oid,
|
2020-03-08 20:43:26 +01:00
|
|
|
sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
2019-02-25 20:23:41 +01:00
|
|
|
ospfNbrTrapList, array_size(ospfNbrTrapList), NBRSTATECHANGE);
|
2005-09-29 18:34:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
|
|
|
|
{
|
|
|
|
oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
*: get rid of zlog(*, LOG_LEVEL, ...)
Result of running the following Coccinelle patch + fixups:
<<EOF
/* long-forms: zlog(NULL, <level>, ...)
* => zlog_level(...)
*/
@@
expression list args;
@@
- zlog(NULL, LOG_DEBUG, args)
+ zlog_debug(args)
@@
expression list args;
@@
- zlog(NULL, LOG_NOTICE, args)
+ zlog_notice(args)
@@
expression list args;
@@
- zlog(NULL, LOG_INFO, args)
+ zlog_info(args)
@@
expression list args;
@@
- zlog(NULL, LOG_WARNING, args)
+ zlog_warn(args)
@@
expression list args;
@@
- zlog(NULL, LOG_ERR, args)
+ zlog_err(args)
/* long-forms: zlog(base->log, <level>, ...)
* => zlog_level(...)
*/
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_DEBUG, args)
+ zlog_debug(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_NOTICE, args)
+ zlog_notice(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_INFO, args)
+ zlog_info(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_WARNING, args)
+ zlog_warn(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_ERR, args)
+ zlog_err(args)
EOF
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-13 04:19:14 +01:00
|
|
|
zlog_info("ospfTrapVirtNbrStateChange trap sent");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(index, &(on->address.u.prefix4));
|
2005-09-29 18:34:30 +02:00
|
|
|
index[IN_ADDR_SIZE] = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-02-25 20:23:41 +01:00
|
|
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
|
|
|
array_size(ospf_trap_oid), ospf_oid,
|
2020-03-08 20:43:26 +01:00
|
|
|
sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
2019-02-25 20:23:41 +01:00
|
|
|
ospfVirtNbrTrapList, array_size(ospfVirtNbrTrapList),
|
2012-05-24 21:22:01 +02:00
|
|
|
VIRTNBRSTATECHANGE);
|
2005-09-29 18:34:30 +02:00
|
|
|
}
|
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
static int ospf_snmp_nsm_change(struct ospf_neighbor *nbr, int next_state,
|
|
|
|
int old_state)
|
|
|
|
{
|
2020-10-01 11:07:54 +02:00
|
|
|
/* Transition to/from state Full should be handled only by
|
|
|
|
* DR when in Broadcast or Non-Brodcast Multi-Access networks
|
|
|
|
*/
|
|
|
|
if ((next_state == NSM_Full || old_state == NSM_Full)
|
|
|
|
&& (nbr->oi->state != ISM_DR)
|
|
|
|
&& (nbr->oi->type == OSPF_IFTYPE_BROADCAST
|
|
|
|
|| nbr->oi->type == OSPF_IFTYPE_NBMA))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* State progression to non-terminal state */
|
|
|
|
if (next_state > old_state && next_state != NSM_Full
|
|
|
|
&& next_state != NSM_TwoWay)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (nbr->oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
|
|
|
ospfTrapVirtNbrStateChange(nbr);
|
|
|
|
else
|
|
|
|
ospfTrapNbrStateChange(nbr);
|
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-29 18:34:30 +02:00
|
|
|
static void ospfTrapIfStateChange(struct ospf_interface *oi)
|
|
|
|
{
|
|
|
|
oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-12-26 18:45:25 +01:00
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2020-10-21 19:56:26 +02:00
|
|
|
zlog_info("%s: trap sent: %pI4 now %s", __func__,
|
|
|
|
&oi->address->u.prefix4,
|
2017-12-26 18:45:25 +01:00
|
|
|
lookup_msg(ospf_ism_state_msg, oi->state, NULL));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(index, &(oi->address->u.prefix4));
|
2005-09-29 18:34:30 +02:00
|
|
|
index[IN_ADDR_SIZE] = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-02-25 20:23:41 +01:00
|
|
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
|
|
|
array_size(ospf_trap_oid), ospf_oid,
|
2020-03-08 20:43:26 +01:00
|
|
|
sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
2019-02-25 20:23:41 +01:00
|
|
|
ospfIfTrapList, array_size(ospfIfTrapList), IFSTATECHANGE);
|
2005-09-29 18:34:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
|
|
|
|
{
|
|
|
|
oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
*: get rid of zlog(*, LOG_LEVEL, ...)
Result of running the following Coccinelle patch + fixups:
<<EOF
/* long-forms: zlog(NULL, <level>, ...)
* => zlog_level(...)
*/
@@
expression list args;
@@
- zlog(NULL, LOG_DEBUG, args)
+ zlog_debug(args)
@@
expression list args;
@@
- zlog(NULL, LOG_NOTICE, args)
+ zlog_notice(args)
@@
expression list args;
@@
- zlog(NULL, LOG_INFO, args)
+ zlog_info(args)
@@
expression list args;
@@
- zlog(NULL, LOG_WARNING, args)
+ zlog_warn(args)
@@
expression list args;
@@
- zlog(NULL, LOG_ERR, args)
+ zlog_err(args)
/* long-forms: zlog(base->log, <level>, ...)
* => zlog_level(...)
*/
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_DEBUG, args)
+ zlog_debug(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_NOTICE, args)
+ zlog_notice(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_INFO, args)
+ zlog_info(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_WARNING, args)
+ zlog_warn(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_ERR, args)
+ zlog_err(args)
EOF
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-13 04:19:14 +01:00
|
|
|
zlog_info("ospfTrapVirtIfStateChange trap sent");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 15:39:07 +01:00
|
|
|
oid_copy_in_addr(index, &(oi->address->u.prefix4));
|
2005-09-29 18:34:30 +02:00
|
|
|
index[IN_ADDR_SIZE] = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-02-25 20:23:41 +01:00
|
|
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
|
|
|
array_size(ospf_trap_oid), ospf_oid,
|
2020-03-08 20:43:26 +01:00
|
|
|
sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
2019-02-25 20:23:41 +01:00
|
|
|
ospfVirtIfTrapList, array_size(ospfVirtIfTrapList),
|
2012-05-24 21:22:01 +02:00
|
|
|
VIRTIFSTATECHANGE);
|
2005-09-29 18:34:30 +02:00
|
|
|
}
|
2016-06-12 17:32:23 +02:00
|
|
|
|
|
|
|
static int ospf_snmp_ism_change(struct ospf_interface *oi, int state,
|
|
|
|
int old_state)
|
|
|
|
{
|
|
|
|
/* Terminal state or regression */
|
|
|
|
if ((state == ISM_DR) || (state == ISM_Backup) || (state == ISM_DROther)
|
|
|
|
|| (state == ISM_PointToPoint) || (state < old_state)) {
|
|
|
|
/* ospfVirtIfStateChange */
|
|
|
|
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
|
|
|
ospfTrapVirtIfStateChange(oi);
|
|
|
|
/* ospfIfStateChange */
|
|
|
|
else
|
|
|
|
ospfTrapIfStateChange(oi);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Register OSPF2-MIB. */
|
2023-03-07 20:14:41 +01:00
|
|
|
static int ospf_snmp_init(struct event_loop *tm)
|
2016-06-12 17:52:50 +02:00
|
|
|
{
|
|
|
|
ospf_snmp_iflist = list_new();
|
|
|
|
ospf_snmp_vl_table = route_table_init();
|
|
|
|
smux_init(tm);
|
|
|
|
REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf_snmp_module_init(void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2016-06-12 17:32:23 +02:00
|
|
|
hook_register(ospf_if_update, ospf_snmp_if_update);
|
|
|
|
hook_register(ospf_if_delete, ospf_snmp_if_delete);
|
|
|
|
hook_register(ospf_vl_add, ospf_snmp_vl_add);
|
|
|
|
hook_register(ospf_vl_delete, ospf_snmp_vl_delete);
|
|
|
|
hook_register(ospf_ism_change, ospf_snmp_ism_change);
|
|
|
|
hook_register(ospf_nsm_change, ospf_snmp_nsm_change);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-06-12 17:52:50 +02:00
|
|
|
hook_register(frr_late_init, ospf_snmp_init);
|
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2016-06-12 17:52:50 +02:00
|
|
|
|
|
|
|
FRR_MODULE_SETUP(.name = "ospfd_snmp", .version = FRR_VERSION,
|
|
|
|
.description = "ospfd AgentX SNMP module",
|
|
|
|
.init = ospf_snmp_module_init,
|
|
|
|
);
|