version 1.1, 2012/02/21 17:26:11
|
version 1.1.1.3, 2016/11/02 10:09:10
|
Line 19
|
Line 19
|
* 02111-1307, USA. |
* 02111-1307, USA. |
*/ |
*/ |
|
|
|
/* |
|
* Currently SNMP is only running properly for MIBs in the default VRF. |
|
*/ |
|
|
#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 37
|
Line 35
|
#include "command.h" |
#include "command.h" |
#include "smux.h" |
#include "smux.h" |
#include "table.h" |
#include "table.h" |
|
#include "vrf.h" |
|
|
#include "zebra/rib.h" |
#include "zebra/rib.h" |
#include "zebra/zserv.h" |
#include "zebra/zserv.h" |
| |
#define IPFWMIB 1,3,6,1,2,1,4,24 |
#define IPFWMIB 1,3,6,1,2,1,4,24 |
|
|
/* ipForwardTable */ |
/* ipForwardTable */ |
Line 84
|
Line 83
|
#define ROWSTATUS ASN_INTEGER |
#define ROWSTATUS ASN_INTEGER |
#define IPADDRESS ASN_IPADDRESS |
#define IPADDRESS ASN_IPADDRESS |
#define OBJECTIDENTIFIER ASN_OBJECT_ID |
#define OBJECTIDENTIFIER ASN_OBJECT_ID |
| |
extern struct zebra_t zebrad; |
extern struct zebra_t zebrad; |
|
|
oid ipfw_oid [] = { IPFWMIB }; |
oid ipfw_oid [] = { IPFWMIB }; |
Line 136 struct variable zebra_variables[] =
|
Line 135 struct variable zebra_variables[] =
|
{IPCIDRROUTESTATUS, ROWSTATUS, RONLY, ipCidrTable, 3, {4, 1, 16}} |
{IPCIDRROUTESTATUS, ROWSTATUS, RONLY, ipCidrTable, 3, {4, 1, 16}} |
}; |
}; |
|
|
| |
static u_char * |
static u_char * |
ipFwNumber (struct variable *v, oid objid[], size_t *objid_len, |
ipFwNumber (struct variable *v, oid objid[], size_t *objid_len, |
int exact, size_t *val_len, WriteMethod **write_method) |
int exact, size_t *val_len, WriteMethod **write_method) |
Line 149 ipFwNumber (struct variable *v, oid objid[], size_t *o
|
Line 148 ipFwNumber (struct variable *v, oid objid[], size_t *o
|
if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED) |
if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED) |
return NULL; |
return NULL; |
|
|
table = vrf_table (AFI_IP, SAFI_UNICAST, 0); | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); |
if (! table) |
if (! table) |
return NULL; |
return NULL; |
|
|
/* Return number of routing entries. */ |
/* Return number of routing entries. */ |
result = 0; |
result = 0; |
for (rn = route_top (table); rn; rn = route_next (rn)) |
for (rn = route_top (table); rn; rn = route_next (rn)) |
for (rib = rn->info; rib; rib = rib->next) | RNODE_FOREACH_RIB (rn, rib) |
result++; |
result++; |
|
|
return (u_char *)&result; |
return (u_char *)&result; |
Line 174 ipCidrNumber (struct variable *v, oid objid[], size_t
|
Line 173 ipCidrNumber (struct variable *v, oid objid[], size_t
|
if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED) |
if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED) |
return NULL; |
return NULL; |
|
|
table = vrf_table (AFI_IP, SAFI_UNICAST, 0); | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); |
if (! table) |
if (! table) |
return 0; |
return 0; |
|
|
/* Return number of routing entries. */ |
/* Return number of routing entries. */ |
result = 0; |
result = 0; |
for (rn = route_top (table); rn; rn = route_next (rn)) |
for (rn = route_top (table); rn; rn = route_next (rn)) |
for (rib = rn->info; rib; rib = rib->next) | RNODE_FOREACH_RIB (rn, rib) |
result++; |
result++; |
|
|
return (u_char *)&result; |
return (u_char *)&result; |
Line 336 get_fwtable_route_node(struct variable *v, oid objid[]
|
Line 335 get_fwtable_route_node(struct variable *v, oid objid[]
|
if (exact && (*objid_len != (unsigned) v->namelen + 10)) |
if (exact && (*objid_len != (unsigned) v->namelen + 10)) |
return; |
return; |
|
|
table = vrf_table (AFI_IP, SAFI_UNICAST, 0); | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); |
if (! table) |
if (! table) |
return; |
return; |
|
|
Line 375 get_fwtable_route_node(struct variable *v, oid objid[]
|
Line 374 get_fwtable_route_node(struct variable *v, oid objid[]
|
{ |
{ |
if (!in_addr_cmp(&(*np)->p.u.prefix, (u_char *)&dest)) |
if (!in_addr_cmp(&(*np)->p.u.prefix, (u_char *)&dest)) |
{ |
{ |
for (*rib = (*np)->info; *rib; *rib = (*rib)->next) | RNODE_FOREACH_RIB (*np, *rib) |
{ |
{ |
if (!in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4, |
if (!in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4, |
(u_char *)&nexthop)) |
(u_char *)&nexthop)) |
Line 394 get_fwtable_route_node(struct variable *v, oid objid[]
|
Line 393 get_fwtable_route_node(struct variable *v, oid objid[]
|
|
|
/* Check destination first */ |
/* Check destination first */ |
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) > 0) |
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) > 0) |
for (rib2 = np2->info; rib2; rib2 = rib2->next) | RNODE_FOREACH_RIB (np2, rib2) |
check_replace(np2, rib2, np, rib); |
check_replace(np2, rib2, np, rib); |
|
|
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) == 0) |
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) == 0) |
{ /* have to look at each rib individually */ |
{ /* have to look at each rib individually */ |
for (rib2 = np2->info; rib2; rib2 = rib2->next) | RNODE_FOREACH_RIB (np2, rib2) |
{ |
{ |
int proto2, policy2; |
int proto2, policy2; |
|
|
Line 457 ipFwTable (struct variable *v, oid objid[], size_t *ob
|
Line 456 ipFwTable (struct variable *v, oid objid[], size_t *ob
|
static struct in_addr netmask; |
static struct in_addr netmask; |
struct nexthop *nexthop; |
struct nexthop *nexthop; |
|
|
|
if (smux_header_table(v, objid, objid_len, exact, val_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
get_fwtable_route_node(v, objid, objid_len, exact, &np, &rib); |
get_fwtable_route_node(v, objid, objid_len, exact, &np, &rib); |
if (!np) |
if (!np) |
return NULL; |
return NULL; |
Line 555 static u_char *
|
Line 558 static u_char *
|
ipCidrTable (struct variable *v, oid objid[], size_t *objid_len, |
ipCidrTable (struct variable *v, oid objid[], size_t *objid_len, |
int exact, size_t *val_len, WriteMethod **write_method) |
int exact, size_t *val_len, WriteMethod **write_method) |
{ |
{ |
|
if (smux_header_table(v, objid, objid_len, exact, val_len, write_method) |
|
== MATCH_FAILED) |
|
return NULL; |
|
|
switch (v->magic) |
switch (v->magic) |
{ |
{ |
case IPCIDRROUTEDEST: |
case IPCIDRROUTEDEST: |