version 1.1.1.1, 2012/02/21 17:26:12
|
version 1.1.1.3, 2013/07/21 23:54:40
|
Line 25
|
Line 25
|
#include <zebra.h> |
#include <zebra.h> |
|
|
#ifdef HAVE_SNMP |
#ifdef HAVE_SNMP |
#ifdef HAVE_NETSNMP |
|
#include <net-snmp/net-snmp-config.h> |
#include <net-snmp/net-snmp-config.h> |
#include <net-snmp/net-snmp-includes.h> |
#include <net-snmp/net-snmp-includes.h> |
#else |
|
#include <asn1.h> |
|
#include <snmp.h> |
|
#include <snmp_impl.h> |
|
#endif |
|
|
|
#include "if.h" |
#include "if.h" |
#include "log.h" |
#include "log.h" |
Line 216 SNMP_LOCAL_VARIABLES
|
Line 210 SNMP_LOCAL_VARIABLES
|
|
|
/* OSPF-MIB instances. */ |
/* OSPF-MIB instances. */ |
oid ospf_oid [] = { OSPF2MIB }; |
oid ospf_oid [] = { OSPF2MIB }; |
|
oid ospf_trap_oid [] = { OSPF2MIB, 16, 2 }; /* Not reverse mappable! */ |
|
|
/* IP address 0.0.0.0. */ |
/* IP address 0.0.0.0. */ |
static struct in_addr ospf_empty_addr = {0}; |
static struct in_addr ospf_empty_addr = {0}; |
Line 709 ospfAreaEntry (struct variable *v, oid *name, size_t *
|
Line 704 ospfAreaEntry (struct variable *v, oid *name, size_t *
|
struct ospf_area *area; |
struct ospf_area *area; |
struct in_addr addr; |
struct in_addr addr; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
memset (&addr, 0, sizeof (struct in_addr)); |
memset (&addr, 0, sizeof (struct in_addr)); |
|
|
area = ospfAreaLookup (v, name, length, &addr, exact); |
area = ospfAreaLookup (v, name, length, &addr, exact); |
Line 852 ospfStubAreaEntry (struct variable *v, oid *name, size
|
Line 851 ospfStubAreaEntry (struct variable *v, oid *name, size
|
struct ospf_area *area; |
struct ospf_area *area; |
struct in_addr addr; |
struct in_addr addr; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
memset (&addr, 0, sizeof (struct in_addr)); |
memset (&addr, 0, sizeof (struct in_addr)); |
|
|
area = ospfStubAreaLookup (v, name, length, &addr, exact); |
area = ospfStubAreaLookup (v, name, length, &addr, exact); |
Line 934 ospfLsdbLookup (struct variable *v, oid *name, size_t
|
Line 937 ospfLsdbLookup (struct variable *v, oid *name, size_t
|
struct ospf *ospf; |
struct ospf *ospf; |
struct ospf_area *area; |
struct ospf_area *area; |
struct ospf_lsa *lsa; |
struct ospf_lsa *lsa; |
unsigned int len; | int len; |
int type_next; |
int type_next; |
int ls_id_next; |
int ls_id_next; |
int router_id_next; |
int router_id_next; |
Line 992 ospfLsdbLookup (struct variable *v, oid *name, size_t
|
Line 995 ospfLsdbLookup (struct variable *v, oid *name, size_t
|
if (len == IN_ADDR_SIZE) |
if (len == IN_ADDR_SIZE) |
area = ospf_area_lookup_by_area_id (ospf, *area_id); |
area = ospf_area_lookup_by_area_id (ospf, *area_id); |
else |
else |
area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0); | area = ospf_area_lookup_next (ospf, area_id, 1); |
|
|
if (area == NULL) |
if (area == NULL) |
return NULL; |
return NULL; |
Line 1000 ospfLsdbLookup (struct variable *v, oid *name, size_t
|
Line 1003 ospfLsdbLookup (struct variable *v, oid *name, size_t
|
do |
do |
{ |
{ |
/* Next we lookup type. */ |
/* Next we lookup type. */ |
offset += IN_ADDR_SIZE; | offset += len; |
offsetlen -= IN_ADDR_SIZE; | offsetlen -= len; |
len = offsetlen; |
len = offsetlen; |
|
|
if (len <= 0) |
if (len <= 0) |
Line 1083 ospfLsdbEntry (struct variable *v, oid *name, size_t *
|
Line 1086 ospfLsdbEntry (struct variable *v, oid *name, size_t *
|
struct in_addr router_id; |
struct in_addr router_id; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
/* INDEX { ospfLsdbAreaId, ospfLsdbType, |
/* INDEX { ospfLsdbAreaId, ospfLsdbType, |
ospfLsdbLsid, ospfLsdbRouterId } */ |
ospfLsdbLsid, ospfLsdbRouterId } */ |
|
|
Line 1245 ospfAreaRangeEntry (struct variable *v, oid *name, siz
|
Line 1252 ospfAreaRangeEntry (struct variable *v, oid *name, siz
|
struct in_addr mask; |
struct in_addr mask; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
/* Check OSPF instance. */ |
/* Check OSPF instance. */ |
ospf = ospf_lookup (); |
ospf = ospf_lookup (); |
if (ospf == NULL) |
if (ospf == NULL) |
Line 1349 ospfHostEntry (struct variable *v, oid *name, size_t *
|
Line 1360 ospfHostEntry (struct variable *v, oid *name, size_t *
|
struct in_addr addr; |
struct in_addr addr; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
/* Check OSPF instance. */ |
/* Check OSPF instance. */ |
ospf = ospf_lookup (); |
ospf = ospf_lookup (); |
if (ospf == NULL) |
if (ospf == NULL) |
Line 1684 ospfIfEntry (struct variable *v, oid *name, size_t *le
|
Line 1699 ospfIfEntry (struct variable *v, oid *name, size_t *le
|
struct ospf_interface *oi; |
struct ospf_interface *oi; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
ifindex = 0; |
ifindex = 0; |
memset (&ifaddr, 0, sizeof (struct in_addr)); |
memset (&ifaddr, 0, sizeof (struct in_addr)); |
|
|
Line 1852 ospfIfMetricEntry (struct variable *v, oid *name, size
|
Line 1871 ospfIfMetricEntry (struct variable *v, oid *name, size
|
struct ospf_interface *oi; |
struct ospf_interface *oi; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
ifindex = 0; |
ifindex = 0; |
memset (&ifaddr, 0, sizeof (struct in_addr)); |
memset (&ifaddr, 0, sizeof (struct in_addr)); |
|
|
Line 2044 ospfVirtIfEntry (struct variable *v, oid *name, size_t
|
Line 2067 ospfVirtIfEntry (struct variable *v, oid *name, size_t
|
struct in_addr area_id; |
struct in_addr area_id; |
struct in_addr neighbor; |
struct in_addr neighbor; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
memset (&area_id, 0, sizeof (struct in_addr)); |
memset (&area_id, 0, sizeof (struct in_addr)); |
memset (&neighbor, 0, sizeof (struct in_addr)); |
memset (&neighbor, 0, sizeof (struct in_addr)); |
|
|
Line 2277 ospfNbrEntry (struct variable *v, oid *name, size_t *l
|
Line 2304 ospfNbrEntry (struct variable *v, oid *name, size_t *l
|
struct ospf_neighbor *nbr; |
struct ospf_neighbor *nbr; |
struct ospf_interface *oi; |
struct ospf_interface *oi; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
memset (&nbr_addr, 0, sizeof (struct in_addr)); |
memset (&nbr_addr, 0, sizeof (struct in_addr)); |
ifindex = 0; |
ifindex = 0; |
|
|
Line 2339 ospfVirtNbrEntry (struct variable *v, oid *name, size_
|
Line 2370 ospfVirtNbrEntry (struct variable *v, oid *name, size_
|
struct in_addr neighbor; |
struct in_addr neighbor; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
memset (&area_id, 0, sizeof (struct in_addr)); |
memset (&area_id, 0, sizeof (struct in_addr)); |
memset (&neighbor, 0, sizeof (struct in_addr)); |
memset (&neighbor, 0, sizeof (struct in_addr)); |
|
|
Line 2487 ospfExtLsdbEntry (struct variable *v, oid *name, size_
|
Line 2522 ospfExtLsdbEntry (struct variable *v, oid *name, size_
|
struct in_addr router_id; |
struct in_addr router_id; |
struct ospf *ospf; |
struct ospf *ospf; |
|
|
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
type = OSPF_AS_EXTERNAL_LSA; |
type = OSPF_AS_EXTERNAL_LSA; |
memset (&ls_id, 0, sizeof (struct in_addr)); |
memset (&ls_id, 0, sizeof (struct in_addr)); |
memset (&router_id, 0, sizeof (struct in_addr)); |
memset (&router_id, 0, sizeof (struct in_addr)); |
Line 2538 static u_char *
|
Line 2577 static u_char *
|
ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length, |
ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length, |
int exact, size_t *var_len, WriteMethod **write_method) |
int exact, size_t *var_len, WriteMethod **write_method) |
{ |
{ |
|
if (smux_header_table(v, name, length, exact, var_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
/* Return the current value of the variable */ |
/* Return the current value of the variable */ |
switch (v->magic) |
switch (v->magic) |
{ |
{ |
Line 2574 ospfAreaAggregateEntry (struct variable *v, oid *name,
|
Line 2617 ospfAreaAggregateEntry (struct variable *v, oid *name,
|
|
|
struct trap_object ospfNbrTrapList[] = |
struct trap_object ospfNbrTrapList[] = |
{ |
{ |
{ospfGeneralGroup, -2, {1, OSPFROUTERID}}, | {-2, {1, OSPFROUTERID}}, |
{ospfNbrEntry, 3, {10, 1, OSPFNBRIPADDR}}, | {3, {10, 1, OSPFNBRIPADDR}}, |
{ospfNbrEntry, 3, {10, 1, OSPFNBRRTRID}}, | {3, {10, 1, OSPFNBRRTRID}}, |
{ospfNbrEntry, 3, {10, 1, OSPFNBRSTATE}} | {3, {10, 1, OSPFNBRSTATE}} |
}; |
}; |
|
|
|
|
struct trap_object ospfVirtNbrTrapList[] = |
struct trap_object ospfVirtNbrTrapList[] = |
{ |
{ |
{ospfGeneralGroup, -2, {1, 1}}, | {-2, {1, 1}}, |
{ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRAREA}}, | {3, {11, 1, OSPFVIRTNBRAREA}}, |
{ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRRTRID}}, | {3, {11, 1, OSPFVIRTNBRRTRID}}, |
{ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRSTATE}} | {3, {11, 1, OSPFVIRTNBRSTATE}} |
}; |
}; |
|
|
struct trap_object ospfIfTrapList[] = |
struct trap_object ospfIfTrapList[] = |
{ |
{ |
{ospfGeneralGroup, -2, {1, OSPFROUTERID}}, | {-2, {1, OSPFROUTERID}}, |
{ospfIfEntry, 3, {7, 1, OSPFIFIPADDRESS}}, | {3, {7, 1, OSPFIFIPADDRESS}}, |
{ospfIfEntry, 3, {7, 1, OSPFADDRESSLESSIF}}, | {3, {7, 1, OSPFADDRESSLESSIF}}, |
{ospfIfEntry, 3, {7, 1, OSPFIFSTATE}} | {3, {7, 1, OSPFIFSTATE}} |
}; |
}; |
|
|
struct trap_object ospfVirtIfTrapList[] = |
struct trap_object ospfVirtIfTrapList[] = |
{ |
{ |
{ospfGeneralGroup, -2, {1, OSPFROUTERID}}, | {-2, {1, OSPFROUTERID}}, |
{ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFAREAID}}, | {3, {9, 1, OSPFVIRTIFAREAID}}, |
{ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFNEIGHBOR}}, | {3, {9, 1, OSPFVIRTIFNEIGHBOR}}, |
{ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFSTATE}} | {3, {9, 1, OSPFVIRTIFSTATE}} |
}; |
}; |
|
|
void |
void |
Line 2618 ospfTrapNbrStateChange (struct ospf_neighbor *on)
|
Line 2661 ospfTrapNbrStateChange (struct ospf_neighbor *on)
|
oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); |
oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); |
index[IN_ADDR_SIZE] = 0; |
index[IN_ADDR_SIZE] = 0; |
|
|
smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), |
| ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), |
| ospf_oid, sizeof ospf_oid / sizeof (oid), |
index, IN_ADDR_SIZE + 1, |
index, IN_ADDR_SIZE + 1, |
ospfNbrTrapList, |
ospfNbrTrapList, |
sizeof ospfNbrTrapList / sizeof (struct trap_object), |
sizeof ospfNbrTrapList / sizeof (struct trap_object), |
time (NULL), NBRSTATECHANGE); | NBRSTATECHANGE); |
} |
} |
|
|
void |
void |
Line 2635 ospfTrapVirtNbrStateChange (struct ospf_neighbor *on)
|
Line 2680 ospfTrapVirtNbrStateChange (struct ospf_neighbor *on)
|
oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); |
oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); |
index[IN_ADDR_SIZE] = 0; |
index[IN_ADDR_SIZE] = 0; |
|
|
smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), |
| ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), |
| ospf_oid, sizeof ospf_oid / sizeof (oid), |
index, IN_ADDR_SIZE + 1, |
index, IN_ADDR_SIZE + 1, |
ospfVirtNbrTrapList, |
ospfVirtNbrTrapList, |
sizeof ospfVirtNbrTrapList / sizeof (struct trap_object), |
sizeof ospfVirtNbrTrapList / sizeof (struct trap_object), |
time (NULL), VIRTNBRSTATECHANGE); | VIRTNBRSTATECHANGE); |
} |
} |
|
|
void |
void |
Line 2654 ospfTrapIfStateChange (struct ospf_interface *oi)
|
Line 2701 ospfTrapIfStateChange (struct ospf_interface *oi)
|
oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); |
oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); |
index[IN_ADDR_SIZE] = 0; |
index[IN_ADDR_SIZE] = 0; |
|
|
smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), |
| ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), |
| ospf_oid, sizeof ospf_oid / sizeof (oid), |
index, IN_ADDR_SIZE + 1, |
index, IN_ADDR_SIZE + 1, |
ospfIfTrapList, |
ospfIfTrapList, |
sizeof ospfIfTrapList / sizeof (struct trap_object), |
sizeof ospfIfTrapList / sizeof (struct trap_object), |
time (NULL), IFSTATECHANGE); | IFSTATECHANGE); |
} |
} |
|
|
void |
void |
Line 2671 ospfTrapVirtIfStateChange (struct ospf_interface *oi)
|
Line 2720 ospfTrapVirtIfStateChange (struct ospf_interface *oi)
|
oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); |
oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); |
index[IN_ADDR_SIZE] = 0; |
index[IN_ADDR_SIZE] = 0; |
|
|
smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable), |
| ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid), |
| ospf_oid, sizeof ospf_oid / sizeof (oid), |
index, IN_ADDR_SIZE + 1, |
index, IN_ADDR_SIZE + 1, |
ospfVirtIfTrapList, |
ospfVirtIfTrapList, |
sizeof ospfVirtIfTrapList / sizeof (struct trap_object), |
sizeof ospfVirtIfTrapList / sizeof (struct trap_object), |
time (NULL), VIRTIFSTATECHANGE); | VIRTIFSTATECHANGE); |
} |
} |
/* Register OSPF2-MIB. */ |
/* Register OSPF2-MIB. */ |
void |
void |