Diff for /embedaddon/quagga/bgpd/bgp_snmp.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/21 23:54:38 version 1.1.1.3, 2016/11/02 10:09:10
Line 30  Software Foundation, Inc., 59 Temple Place - Suite 330 Line 30  Software Foundation, Inc., 59 Temple Place - Suite 330
 #include "command.h"  #include "command.h"
 #include "thread.h"  #include "thread.h"
 #include "smux.h"  #include "smux.h"
   #include "filter.h"
   
 #include "bgpd/bgpd.h"  #include "bgpd/bgpd.h"
 #include "bgpd/bgp_table.h"  #include "bgpd/bgp_table.h"
Line 38  Software Foundation, Inc., 59 Temple Place - Suite 330 Line 39  Software Foundation, Inc., 59 Temple Place - Suite 330
 #include "bgpd/bgp_route.h"  #include "bgpd/bgp_route.h"
 #include "bgpd/bgp_fsm.h"  #include "bgpd/bgp_fsm.h"
 #include "bgpd/bgp_snmp.h"  #include "bgpd/bgp_snmp.h"
 /* BGP4-MIB described in RFC1657. */  /* BGP4-MIB described in RFC1657. */
 #define BGP4MIB 1,3,6,1,2,1,15  #define BGP4MIB 1,3,6,1,2,1,15
   
Line 74  Software Foundation, Inc., 59 Temple Place - Suite 330 Line 75  Software Foundation, Inc., 59 Temple Place - Suite 330
 #define BGPPEERKEEPALIVE                     19  #define BGPPEERKEEPALIVE                     19
 #define BGPPEERHOLDTIMECONFIGURED            20  #define BGPPEERHOLDTIMECONFIGURED            20
 #define BGPPEERKEEPALIVECONFIGURED           21  #define BGPPEERKEEPALIVECONFIGURED           21
#define BGPPEERMINASORIGINATIONINTERVAL      22#define BGPPEERMINROUTEADVERTISEMENTINTERVAL 22
#define BGPPEERMINROUTEADVERTISEMENTINTERVAL 23#define BGPPEERINUPDATEELAPSEDTIME           23
#define BGPPEERINUPDATEELAPSEDTIME           24 
   
 /* BGP MIB bgpIdentifier. */  /* BGP MIB bgpIdentifier. */
 #define BGPIDENTIFIER                         0  #define BGPIDENTIFIER                         0
Line 112  Software Foundation, Inc., 59 Temple Place - Suite 330 Line 112  Software Foundation, Inc., 59 Temple Place - Suite 330
 #define OCTET_STRING ASN_OCTET_STR  #define OCTET_STRING ASN_OCTET_STR
 #define IPADDRESS ASN_IPADDRESS  #define IPADDRESS ASN_IPADDRESS
 #define GAUGE32 ASN_UNSIGNED  #define GAUGE32 ASN_UNSIGNED
 /* Declare static local variables for convenience. */  /* Declare static local variables for convenience. */
 SNMP_LOCAL_VARIABLES  SNMP_LOCAL_VARIABLES
   
Line 121  oid bgp_oid [] = { BGP4MIB }; Line 121  oid bgp_oid [] = { BGP4MIB };
 oid bgp_trap_oid [] = { BGP4MIB, 0 };  oid bgp_trap_oid [] = { BGP4MIB, 0 };
   
 /* IP address 0.0.0.0. */  /* IP address 0.0.0.0. */
static struct in_addr bgp_empty_addr = {0};static struct in_addr bgp_empty_addr = { .s_addr = 0 };
   
 /* Hook functions. */  /* Hook functions. */
 static u_char *bgpVersion (struct variable *, oid [], size_t *, int,  static u_char *bgpVersion (struct variable *, oid [], size_t *, int,
Line 189  struct variable bgp_variables[] =  Line 189  struct variable bgp_variables[] = 
    3, {3, 1, 20}},     3, {3, 1, 20}},
   {BGPPEERKEEPALIVECONFIGURED, INTEGER, RWRITE, bgpPeerTable,    {BGPPEERKEEPALIVECONFIGURED, INTEGER, RWRITE, bgpPeerTable,
    3, {3, 1, 21}},     3, {3, 1, 21}},
   {BGPPEERMINASORIGINATIONINTERVAL, INTEGER, RWRITE, bgpPeerTable,  
    3, {3, 1, 22}},  
   {BGPPEERMINROUTEADVERTISEMENTINTERVAL, INTEGER, RWRITE, bgpPeerTable,    {BGPPEERMINROUTEADVERTISEMENTINTERVAL, INTEGER, RWRITE, bgpPeerTable,
    3, {3, 1, 23}},     3, {3, 1, 23}},
   {BGPPEERINUPDATEELAPSEDTIME, GAUGE32, RONLY, bgpPeerTable,    {BGPPEERINUPDATEELAPSEDTIME, GAUGE32, RONLY, bgpPeerTable,
Line 242  struct variable bgp_variables[] =  Line 240  struct variable bgp_variables[] = 
    3, {6, 1, 14}},     3, {6, 1, 14}},
 };  };
   
 static u_char *  static u_char *
 bgpVersion (struct variable *v, oid name[], size_t *length, int exact,  bgpVersion (struct variable *v, oid name[], size_t *length, int exact,
             size_t *var_len, WriteMethod **write_method)              size_t *var_len, WriteMethod **write_method)
Line 337  bgp_peer_lookup_next (struct in_addr *src) Line 335  bgp_peer_lookup_next (struct in_addr *src)
   return NULL;    return NULL;
 }  }
   
   /* 1.3.6.1.2.1.15.3.1.x  = 10 */
   #define PEERTAB_NAMELEN 10
   
 static struct peer *  static struct peer *
 bgpPeerTable_lookup (struct variable *v, oid name[], size_t *length,   bgpPeerTable_lookup (struct variable *v, oid name[], size_t *length, 
                      struct in_addr *addr, int exact)                       struct in_addr *addr, int exact)
 {  {
   struct peer *peer = NULL;    struct peer *peer = NULL;
     size_t namelen = v ? v->namelen : PEERTAB_NAMELEN;
   int len;    int len;
   
   if (exact)    if (exact)
     {      {
       /* Check the length. */        /* Check the length. */
      if (*length - v->namelen != sizeof (struct in_addr))      if (*length - namelen != sizeof (struct in_addr))
         return NULL;          return NULL;
   
      oid2in_addr (name + v->namelen, IN_ADDR_SIZE, addr);      oid2in_addr (name + namelen, IN_ADDR_SIZE, addr);
   
       peer = peer_lookup_addr_ipv4 (addr);        peer = peer_lookup_addr_ipv4 (addr);
       return peer;        return peer;
     }      }
   else    else
     {      {
      len = *length - v->namelen;      len = *length - namelen;
       if (len > 4) len = 4;        if (len > 4) len = 4;
               
      oid2in_addr (name + v->namelen, len, addr);      oid2in_addr (name + namelen, len, addr);
               
       peer = bgp_peer_lookup_next (addr);        peer = bgp_peer_lookup_next (addr);
   
       if (peer == NULL)        if (peer == NULL)
         return NULL;          return NULL;
   
      oid_copy_addr (name + v->namelen, addr, sizeof (struct in_addr));      oid_copy_addr (name + namelen, addr, sizeof (struct in_addr));
      *length = sizeof (struct in_addr) + v->namelen;      *length = sizeof (struct in_addr) + namelen;
   
       return peer;        return peer;
     }      }
Line 379  bgpPeerTable_lookup (struct variable *v, oid name[], s Line 381  bgpPeerTable_lookup (struct variable *v, oid name[], s
 static int  static int
 write_bgpPeerTable (int action, u_char *var_val,  write_bgpPeerTable (int action, u_char *var_val,
                     u_char var_val_type, size_t var_val_len,                      u_char var_val_type, size_t var_val_len,
                    u_char *statP, oid *name, size_t length,                    u_char *statP, oid *name, size_t length)
                    struct variable *v) 
 {  {
   struct in_addr addr;    struct in_addr addr;
   struct peer *peer;    struct peer *peer;
   long intval;    long intval;
  size_t bigsize = SNMP_MAX_LEN;
   
   if (var_val_type != ASN_INTEGER)     if (var_val_type != ASN_INTEGER) 
     {      {
       return SNMP_ERR_WRONGTYPE;        return SNMP_ERR_WRONGTYPE;
Line 396  write_bgpPeerTable (int action, u_char *var_val, Line 396  write_bgpPeerTable (int action, u_char *var_val,
       return SNMP_ERR_WRONGLENGTH;        return SNMP_ERR_WRONGLENGTH;
     }      }
   
  if (! asn_parse_int(var_val, &bigsize, &var_val_type,  intval = *(long *)var_val;
                      &intval, sizeof(long))) 
    { 
      return SNMP_ERR_WRONGENCODING; 
    } 
   
   memset (&addr, 0, sizeof (struct in_addr));    memset (&addr, 0, sizeof (struct in_addr));
   
  peer = bgpPeerTable_lookup (v, name, &length, &addr, 1);  peer = bgpPeerTable_lookup (NULL, name, &length, &addr, 1);
   if (! peer)    if (! peer)
     return SNMP_ERR_NOSUCHNAME;      return SNMP_ERR_NOSUCHNAME;
   
  printf ("val: %ld\n", intval);  if (action != SNMP_MSG_INTERNAL_SET_COMMIT)
     return SNMP_ERR_NOERROR;
   
  switch (v->magic)  zlog_info ("%s: SNMP write .%ld = %ld",
              peer->host, (long)name[PEERTAB_NAMELEN - 1], intval);
 
   switch (name[PEERTAB_NAMELEN - 1])
     {      {
     case BGPPEERADMINSTATUS:      case BGPPEERADMINSTATUS:
 #define BGP_PeerAdmin_stop  1  #define BGP_PeerAdmin_stop  1
Line 438  write_bgpPeerTable (int action, u_char *var_val, Line 438  write_bgpPeerTable (int action, u_char *var_val,
       peer->keepalive = intval;        peer->keepalive = intval;
       peer->v_keepalive = intval;        peer->v_keepalive = intval;
       break;        break;
     case BGPPEERMINASORIGINATIONINTERVAL:  
       peer->v_asorig = intval;  
       break;  
     case BGPPEERMINROUTEADVERTISEMENTINTERVAL:      case BGPPEERMINROUTEADVERTISEMENTINTERVAL:
       peer->v_routeadv = intval;        peer->v_routeadv = intval;
       break;        break;
Line 569  bgpPeerTable (struct variable *v, oid name[], size_t * Line 566  bgpPeerTable (struct variable *v, oid name[], size_t *
       else        else
         return SNMP_INTEGER (peer->v_keepalive);          return SNMP_INTEGER (peer->v_keepalive);
       break;        break;
     case BGPPEERMINASORIGINATIONINTERVAL:  
       *write_method = write_bgpPeerTable;  
       return SNMP_INTEGER (peer->v_asorig);  
       break;  
     case BGPPEERMINROUTEADVERTISEMENTINTERVAL:      case BGPPEERMINROUTEADVERTISEMENTINTERVAL:
       *write_method = write_bgpPeerTable;        *write_method = write_bgpPeerTable;
       return SNMP_INTEGER (peer->v_routeadv);        return SNMP_INTEGER (peer->v_routeadv);
Line 835  bgp4PathAttrTable (struct variable *v, oid name[], siz Line 828  bgp4PathAttrTable (struct variable *v, oid name[], siz
     }      }
   return NULL;    return NULL;
 }  }
 /* BGP Traps. */  /* BGP Traps. */
 struct trap_object bgpTrapList[] =  struct trap_object bgpTrapList[] =
 {  {

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>