summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_snmp.c
diff options
context:
space:
mode:
authorpaul <paul>2003-03-25 02:37:13 +0000
committerpaul <paul>2003-03-25 02:37:13 +0000
commitf7ccadc4a079d585770cb5fc6add832d4384facc (patch)
treec2c96f7405c46112eb3d8f6efcc693e040bc222b /ospfd/ospf_snmp.c
parent139c7c96b474a90aa3685b7efb8f23b550be1ff1 (diff)
downloadquagga-zebra.org.20030325.tar.bz2
quagga-zebra.org.20030325.tar.xz
Import of Zebra CVS 20030325-02:30zebra.org.20030325
Diffstat (limited to 'ospfd/ospf_snmp.c')
-rw-r--r--ospfd/ospf_snmp.c113
1 files changed, 65 insertions, 48 deletions
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 6187977e..389fd73c 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -493,15 +493,15 @@ struct variable ospf_variables[] =
/* The administrative status of OSPF. When OSPF is enbled on at least
one interface return 1. */
int
-ospf_admin_stat ()
+ospf_admin_stat (struct ospf *ospf)
{
listnode node;
struct ospf_interface *oi;
- if (! ospf_top)
+ if (ospf == NULL)
return 0;
- for (node = listhead (ospf_top->oiflist); node; nextnode (node))
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
{
oi = getdata (node);
@@ -515,6 +515,8 @@ static u_char *
ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
+ struct ospf *ospf = ospf_top;
+
/* Check whether the instance identifier is valid */
if (smux_header_generic (v, name, length, exact, var_len, write_method)
== MATCH_FAILED)
@@ -525,14 +527,14 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
{
case OSPFROUTERID: /* 1 */
/* Router-ID of this OSPF instance. */
- if (ospf_top)
- return SNMP_IPADDRESS (ospf_top->router_id);
+ if (ospf)
+ return SNMP_IPADDRESS (ospf->router_id);
else
return SNMP_IPADDRESS (ospf_empty_addr);
break;
case OSPFADMINSTAT: /* 2 */
/* The administrative status of OSPF in the router. */
- if (ospf_admin_stat ())
+ if (ospf_admin_stat (ospf))
return SNMP_INTEGER (OSPF_STATUS_ENABLED);
else
return SNMP_INTEGER (OSPF_STATUS_DISABLED);
@@ -543,22 +545,22 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
break;
case OSPFAREABDRRTRSTATUS: /* 4 */
/* Area Border router status. */
- if (ospf_top && CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ABR))
+ if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
return SNMP_INTEGER (SNMP_TRUE);
else
return SNMP_INTEGER (SNMP_FALSE);
break;
case OSPFASBDRRTRSTATUS: /* 5 */
/* AS Border router status. */
- if (ospf_top && CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ASBR))
+ if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
return SNMP_INTEGER (SNMP_TRUE);
else
return SNMP_INTEGER (SNMP_FALSE);
break;
case OSPFEXTERNLSACOUNT: /* 6 */
/* External LSA counts. */
- if (ospf_top)
- return SNMP_INTEGER (ospf_lsdb_count_all (ospf_top->lsdb));
+ if (ospf)
+ return SNMP_INTEGER (ospf_lsdb_count_all (ospf->lsdb));
else
return SNMP_INTEGER (0);
break;
@@ -572,16 +574,16 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
break;
case OSPFORIGINATENEWLSAS: /* 9 */
/* The number of new link-state advertisements. */
- if (ospf_top)
- return SNMP_INTEGER (ospf_top->lsa_originate_count);
+ if (ospf)
+ return SNMP_INTEGER (ospf->lsa_originate_count);
else
return SNMP_INTEGER (0);
break;
case OSPFRXNEWLSAS: /* 10 */
/* The number of link-state advertisements received determined
to be new instantiations. */
- if (ospf_top)
- return SNMP_INTEGER (ospf_top->rx_lsa_count);
+ if (ospf)
+ return SNMP_INTEGER (ospf->rx_lsa_count);
else
return SNMP_INTEGER (0);
break;
@@ -609,7 +611,7 @@ ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
}
struct ospf_area *
-ospf_area_lookup_next (struct in_addr *area_id, int first)
+ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first)
{
struct ospf_area *area;
listnode node;
@@ -619,7 +621,7 @@ ospf_area_lookup_next (struct in_addr *area_id, int first)
if (first)
{
- node = listhead (ospf_top->areas);
+ node = listhead (ospf->areas);
if (node)
{
area = getdata (node);
@@ -628,7 +630,7 @@ ospf_area_lookup_next (struct in_addr *area_id, int first)
}
return NULL;
}
- for (node = listhead (ospf_top->areas); node; nextnode (node))
+ for (node = listhead (ospf->areas); node; nextnode (node))
{
area = getdata (node);
@@ -645,10 +647,11 @@ struct ospf_area *
ospfAreaLookup (struct variable *v, oid name[], size_t *length,
struct in_addr *addr, int exact)
{
- int len;
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
+ int len;
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
if (exact)
@@ -659,7 +662,7 @@ ospfAreaLookup (struct variable *v, oid name[], size_t *length,
oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr);
- area = ospf_area_lookup_by_area_id (*addr);
+ area = ospf_area_lookup_by_area_id (ospf, *addr);
return area;
}
@@ -671,7 +674,7 @@ ospfAreaLookup (struct variable *v, oid name[], size_t *length,
oid2in_addr (name + v->namelen, len, addr);
- area = ospf_area_lookup_next (addr, len == 0 ? 1 : 0);
+ area = ospf_area_lookup_next (ospf, addr, len == 0 ? 1 : 0);
if (area == NULL)
return NULL;
@@ -776,8 +779,9 @@ struct ospf_area *
ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
struct in_addr *addr, int exact)
{
- int len;
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
+ int len;
if (! ospf_top)
return NULL;
@@ -795,7 +799,7 @@ ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr);
- area = ospf_area_lookup_by_area_id (*addr);
+ area = ospf_area_lookup_by_area_id (ospf, *addr);
if (area->external_routing == OSPF_AREA_STUB)
return area;
@@ -903,6 +907,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
struct in_addr *area_id, u_char *type,
struct in_addr *ls_id, struct in_addr *router_id, int exact)
{
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
struct ospf_lsa *lsa;
int len;
@@ -926,7 +931,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
/* Lookup area first. */
oid2in_addr (offset, IN_ADDR_SIZE, area_id);
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf, *area_id);
if (! area)
return NULL;
offset += IN_ADDR_SIZE;
@@ -959,9 +964,9 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
/* First we search area. */
if (len == IN_ADDR_SIZE)
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf, *area_id);
else
- area = ospf_area_lookup_next (area_id, len == 0 ? 1 : 0);
+ area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0);
if (area == NULL)
return NULL;
@@ -1035,7 +1040,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
return lsa;
}
}
- while ((area = ospf_area_lookup_next (area_id, 0)) != NULL);
+ while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL);
}
return NULL;
}
@@ -1113,6 +1118,7 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
oid *offset;
int offsetlen;
int len;
+ struct ospf *ospf = ospf_top;
struct ospf_area *area;
struct ospf_area_range *range;
struct prefix_ipv4 p;
@@ -1131,7 +1137,7 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
/* Lookup area first. */
oid2in_addr (offset, IN_ADDR_SIZE, area_id);
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf, *area_id);
if (! area)
return NULL;
@@ -1157,9 +1163,9 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
/* First we search area. */
if (len == IN_ADDR_SIZE)
- area = ospf_area_lookup_by_area_id (*area_id);
+ area = ospf_area_lookup_by_area_id (ospf,*area_id);
else
- area = ospf_area_lookup_next (area_id, len == 0 ? 1 : 0);
+ area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0);
if (area == NULL)
return NULL;
@@ -1194,7 +1200,7 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
return range;
}
}
- while ((area = ospf_area_lookup_next (area_id, 0)) != NULL);
+ while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL);
}
return NULL;
}
@@ -1207,9 +1213,10 @@ ospfAreaRangeEntry (struct variable *v, oid *name, size_t *length, int exact,
struct in_addr area_id;
struct in_addr range_net;
struct in_addr mask;
+ struct ospf *ospf = ospf_top;
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
memset (&area_id, 0, IN_ADDR_SIZE);
@@ -1255,8 +1262,9 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
{
int len;
struct ospf_nbr_nbma *nbr_nbma;
+ struct ospf *ospf = ospf_top;
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
if (exact)
@@ -1271,7 +1279,7 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
oid2in_addr (name + v->namelen, IN_ADDR_SIZE, addr);
- nbr_nbma = ospf_nbr_nbma_lookup (ospf_top, *addr);
+ nbr_nbma = ospf_nbr_nbma_lookup (ospf, *addr);
return nbr_nbma;
}
@@ -1283,7 +1291,7 @@ ospfHostLookup (struct variable *v, oid *name, size_t *length,
oid2in_addr (name + v->namelen, len, addr);
- nbr_nbma = ospf_nbr_nbma_lookup_next (addr, len == 0 ? 1 : 0);
+ nbr_nbma = ospf_nbr_nbma_lookup_next (ospf, addr, len == 0 ? 1 : 0);
if (nbr_nbma == NULL)
return NULL;
@@ -1307,9 +1315,10 @@ ospfHostEntry (struct variable *v, oid *name, size_t *length, int exact,
struct ospf_nbr_nbma *nbr_nbma;
struct ospf_interface *oi;
struct in_addr addr;
+ struct ospf *ospf = ospf_top;
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
memset (&addr, 0, sizeof (struct in_addr));
@@ -1597,19 +1606,20 @@ ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact,
unsigned int ifindex;
struct in_addr ifaddr;
struct ospf_interface *oi;
+ struct ospf *ospf = ospf_top;
ifindex = 0;
memset (&ifaddr, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
ifp = ospfIfLookup (v, name, length, &ifaddr, &ifindex, exact);
if (ifp == NULL)
return NULL;
- oi = ospf_if_lookup_by_local_addr (ifp, ifaddr);
+ oi = ospf_if_lookup_by_local_addr (ospf, ifp, ifaddr);
if (oi == NULL)
return NULL;
@@ -1768,19 +1778,20 @@ ospfIfMetricEntry (struct variable *v, oid *name, size_t *length, int exact,
unsigned int ifindex;
struct in_addr ifaddr;
struct ospf_interface *oi;
+ struct ospf *ospf = ospf_top;
ifindex = 0;
memset (&ifaddr, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
ifp = ospfIfMetricLookup (v, name, length, &ifaddr, &ifindex, exact);
if (ifp == NULL)
return NULL;
- oi = ospf_if_lookup_by_local_addr (ifp, ifaddr);
+ oi = ospf_if_lookup_by_local_addr (ospf, ifp, ifaddr);
if (oi == NULL)
return NULL;
@@ -2022,14 +2033,15 @@ ospfVirtIfEntry (struct variable *v, oid *name, size_t *length, int exact,
}
struct ospf_neighbor *
-ospf_snmp_nbr_lookup (struct in_addr *nbr_addr, unsigned int *ifindex)
+ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
+ unsigned int *ifindex)
{
struct listnode *nn;
struct ospf_interface *oi;
struct ospf_neighbor *nbr;
struct route_node *rn;
- LIST_LOOP (ospf_top->oiflist, oi, nn)
+ LIST_LOOP (ospf->oiflist, oi, nn)
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
@@ -2056,8 +2068,9 @@ ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, unsigned int *ifindex,
struct ospf_neighbor *nbr;
struct route_node *rn;
struct ospf_neighbor *min = NULL;
+ struct ospf *ospf = ospf_top;
- LIST_LOOP (ospf_top->oiflist, oi, nn)
+ LIST_LOOP (ospf->oiflist, oi, nn)
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
@@ -2097,6 +2110,7 @@ ospfNbrLookup (struct variable *v, oid *name, size_t *length,
int len;
int first;
struct ospf_neighbor *nbr;
+ struct ospf *ospf = ospf_top;
if (exact)
{
@@ -2106,7 +2120,7 @@ ospfNbrLookup (struct variable *v, oid *name, size_t *length,
oid2in_addr (name + v->namelen, IN_ADDR_SIZE, nbr_addr);
*ifindex = name[v->namelen + IN_ADDR_SIZE];
- return ospf_snmp_nbr_lookup (nbr_addr, ifindex);
+ return ospf_snmp_nbr_lookup (ospf, nbr_addr, ifindex);
}
else
{
@@ -2207,12 +2221,13 @@ ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
struct ospf_vl_data *vl_data;
struct in_addr area_id;
struct in_addr neighbor;
+ struct ospf *ospf = ospf_top;
memset (&area_id, 0, sizeof (struct in_addr));
memset (&neighbor, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
vl_data = ospfVirtIfLookup (v, name, length, &area_id, &neighbor, exact);
@@ -2263,6 +2278,7 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
u_char lsa_type;
int len;
struct ospf_lsa *lsa;
+ struct ospf *ospf = ospf_top;
if (exact)
{
@@ -2285,7 +2301,7 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
/* Router ID. */
oid2in_addr (offset, IN_ADDR_SIZE, router_id);
- return ospf_lsdb_lookup_by_id (ospf_top->lsdb, *type, *ls_id, *router_id);
+ return ospf_lsdb_lookup_by_id (ospf->lsdb, *type, *ls_id, *router_id);
}
else
{
@@ -2319,7 +2335,7 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
oid2in_addr (offset, len, router_id);
- lsa = ospf_lsdb_lookup_by_id_next (ospf_top->lsdb, *type, *ls_id,
+ lsa = ospf_lsdb_lookup_by_id_next (ospf->lsdb, *type, *ls_id,
*router_id, first);
if (lsa)
@@ -2351,13 +2367,14 @@ ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
u_char type;
struct in_addr ls_id;
struct in_addr router_id;
+ struct ospf *ospf = ospf_top;
type = OSPF_AS_EXTERNAL_LSA;
memset (&ls_id, 0, sizeof (struct in_addr));
memset (&router_id, 0, sizeof (struct in_addr));
/* Check OSPF instance. */
- if (! ospf_top)
+ if (ospf == NULL)
return NULL;
lsa = ospfExtLsdbLookup (v, name, length, &type, &ls_id, &router_id, exact);