diff options
Diffstat (limited to 'agent/mibgroup/ip-forward-mib')
22 files changed, 15142 insertions, 0 deletions
diff --git a/agent/mibgroup/ip-forward-mib/data_access/route.h b/agent/mibgroup/ip-forward-mib/data_access/route.h new file mode 100644 index 0000000..a2b4ee4 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/data_access/route.h @@ -0,0 +1,31 @@ +/* + * route data access header + * + * $Id$ + */ +/**---------------------------------------------------------------------*/ +/* + * configure required files + * + * Notes: + * + * 1) prefer functionality over platform, where possible. If a method + * is available for multiple platforms, test that first. That way + * when a new platform is ported, it won't need a new test here. + * + * 2) don't do detail requirements here. If, for example, + * HPUX11 had different reuirements than other HPUX, that should + * be handled in the *_hpux.h header file. + */ +config_require(ip-forward-mib/data_access/route_common) + +#if defined( linux ) +config_require(ip-forward-mib/data_access/route_linux) +config_require(ip-forward-mib/data_access/route_ioctl) +#else +config_error(the route data access library is not available in this environment.) +#endif + +/** need interface for ifIndex */ +config_require(if-mib/data_access/interface) + diff --git a/agent/mibgroup/ip-forward-mib/data_access/route_common.c b/agent/mibgroup/ip-forward-mib/data_access/route_common.c new file mode 100644 index 0000000..84c1810 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/data_access/route_common.c @@ -0,0 +1,281 @@ +/* + * Interface MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include "mibII/mibII_common.h" + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/route.h> + +/**---------------------------------------------------------------------*/ +/* + * local static prototypes + */ +static void _access_route_entry_release(netsnmp_route_entry * entry, void *unused); + +/**---------------------------------------------------------------------*/ +/* + * external per-architecture functions prototypes + * + * These shouldn't be called by the general public, so they aren't in + * the header file. + */ +extern int netsnmp_access_route_container_arch_load(netsnmp_container* container, + u_int load_flags); +extern int +netsnmp_arch_route_create(netsnmp_route_entry *entry); +extern int +netsnmp_arch_route_delete(netsnmp_route_entry *entry); + + +/**---------------------------------------------------------------------*/ +/* + * container functions + */ + +/** + * @retval NULL error + * @retval !NULL pointer to container + */ +netsnmp_container* +netsnmp_access_route_container_load(netsnmp_container* container, u_int load_flags) +{ + int rc; + + DEBUGMSGTL(("access:route:container", "load\n")); + + if (NULL == container) { + container = netsnmp_container_find("access:_route:fifo"); + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_route\n"); + return NULL; + } + } + + container->container_name = strdup("_route"); + + rc = netsnmp_access_route_container_arch_load(container, load_flags); + if (0 != rc) { + netsnmp_access_route_container_free(container, NETSNMP_ACCESS_ROUTE_FREE_NOFLAGS); + container = NULL; + } + + return container; +} + +void +netsnmp_access_route_container_free(netsnmp_container *container, u_int free_flags) +{ + DEBUGMSGTL(("access:route:container", "free\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, "invalid container for netsnmp_access_route_free\n"); + return; + } + + if(! (free_flags & NETSNMP_ACCESS_ROUTE_FREE_DONT_CLEAR)) { + /* + * free all items. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func*)_access_route_entry_release, + NULL); + } + + if(! (free_flags & NETSNMP_ACCESS_ROUTE_FREE_KEEP_CONTAINER)) + CONTAINER_FREE(container); +} + +/**---------------------------------------------------------------------*/ +/* + * ifentry functions + */ +/** create route entry + * + * @note: + * if you create a route for entry into a container of your own, you + * must set ns_rt_index to a unique index for your container. + */ +netsnmp_route_entry * +netsnmp_access_route_entry_create(void) +{ + netsnmp_route_entry *entry = SNMP_MALLOC_TYPEDEF(netsnmp_route_entry); + if(NULL == entry) { + snmp_log(LOG_ERR, "could not allocate route entry\n"); + return NULL; + } + + entry->oid_index.oids = &entry->ns_rt_index; + entry->oid_index.len = 1; + + entry->rt_metric1 = -1; + entry->rt_metric2 = -1; + entry->rt_metric3 = -1; + entry->rt_metric4 = -1; + entry->rt_metric5 = -1; + + /** entry->row_status? */ + + return entry; +} + +/** + */ +void +netsnmp_access_route_entry_free(netsnmp_route_entry * entry) +{ + if (NULL == entry) + return; + +#ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE + if ((NULL != entry->rt_policy) && + !(entry->flags & NETSNMP_ACCESS_ROUTE_POLICY_STATIC)) + free(entry->rt_policy); +#endif +#ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE + if (NULL != entry->rt_info) + free(entry->rt_info); +#endif + + free(entry); +} + + +/** + * update underlying data store (kernel) for entry + * + * @retval 0 : success + * @retval -1 : error + */ +int +netsnmp_access_route_entry_set(netsnmp_route_entry * entry) +{ + int rc = SNMP_ERR_NOERROR; + + if (NULL == entry) { + netsnmp_assert(NULL != entry); + return -1; + } + + /* + * + */ + if (entry->flags & NETSNMP_ACCESS_ROUTE_CREATE) { + rc = netsnmp_arch_route_create(entry); + } + else if (entry->flags & NETSNMP_ACCESS_ROUTE_CHANGE) { + /** xxx-rks:9 route change not implemented */ + snmp_log(LOG_ERR,"netsnmp_access_route_entry_set change not supported yet\n"); + rc = -1; + } + else if (entry->flags & NETSNMP_ACCESS_ROUTE_DELETE) { + rc = netsnmp_arch_route_delete(entry); + } + else { + snmp_log(LOG_ERR,"netsnmp_access_route_entry_set with no mode\n"); + netsnmp_assert(!"route_entry_set == unknown mode"); /* always false */ + rc = -1; + } + + return rc; +} + +/** + * copy an route_entry + * + * @retval -1 : error + * @retval 0 : no error + */ +int +netsnmp_access_route_entry_copy(netsnmp_route_entry *lhs, + netsnmp_route_entry *rhs) +{ +#if 0 /* no arch stuff in route (yet) */ + int rc; + + /* + * copy arch stuff. we don't care if it changed + */ + rc = netsnmp_arch_route_entry_copy(lhs,rhs); + if (0 != rc) { + snmp_log(LOG_ERR,"arch route copy failed\n"); + return -1; + } +#endif + + lhs->if_index = rhs->if_index; + + lhs->rt_dest_len = rhs->rt_dest_len; + memcpy(lhs->rt_dest, rhs->rt_dest, rhs->rt_dest_len); + lhs->rt_dest_type = rhs->rt_dest_type; + + lhs->rt_nexthop_len = rhs->rt_nexthop_len; + memcpy(lhs->rt_nexthop, rhs->rt_nexthop, rhs->rt_nexthop_len); + lhs->rt_nexthop_type = rhs->rt_nexthop_type; + +#ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE + if (NULL != lhs->rt_policy) { + if (NETSNMP_ACCESS_ROUTE_POLICY_STATIC & lhs->flags) + lhs->rt_policy = NULL; + else { + SNMP_FREE(lhs->rt_policy); + } + } + if (NULL != rhs->rt_policy) { + if ((NETSNMP_ACCESS_ROUTE_POLICY_STATIC & rhs->flags) && + ! (NETSNMP_ACCESS_ROUTE_POLICY_DEEP_COPY & rhs->flags)) { + lhs->rt_policy = rhs->rt_policy; + } + else { + snmp_clone_mem((void **) &lhs->rt_policy, rhs->rt_policy, + rhs->rt_policy_len * sizeof(oid)); + } + } + lhs->rt_policy_len = rhs->rt_policy_len; +#endif + + lhs->rt_pfx_len = rhs->rt_pfx_len; + lhs->rt_type = rhs->rt_type; + lhs->rt_proto = rhs->rt_proto; + +#ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE + SNMP_FREE(lhs->rt_info); + if (NULL != rhs->rt_info) + snmp_clone_mem((void **) &lhs->rt_info, rhs->rt_info, + rhs->rt_info_len * sizeof(oid)); + lhs->rt_info_len = rhs->rt_info_len; + + lhs->rt_mask = rhs->rt_mask; + lhs->rt_tos = rhs->rt_tos; +#endif + + lhs->rt_age = rhs->rt_age; + lhs->rt_nexthop_as = rhs->rt_nexthop_as; + + lhs->rt_metric1 = rhs->rt_metric1; + lhs->rt_metric2 = rhs->rt_metric2; + lhs->rt_metric3 = rhs->rt_metric3; + lhs->rt_metric4 = rhs->rt_metric4; + lhs->rt_metric5 = rhs->rt_metric5; + + lhs->flags = rhs->flags; + + return 0; +} + + +/**---------------------------------------------------------------------*/ +/* + * Utility routines + */ + +/** + */ +void +_access_route_entry_release(netsnmp_route_entry * entry, void *context) +{ + netsnmp_access_route_entry_free(entry); +} diff --git a/agent/mibgroup/ip-forward-mib/data_access/route_ioctl.c b/agent/mibgroup/ip-forward-mib/data_access/route_ioctl.c new file mode 100644 index 0000000..815c415 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/data_access/route_ioctl.c @@ -0,0 +1,193 @@ +/* + * Portions of this file are subject to copyright(s). See the Net-SNMP's + * COPYING file for more details and other copyrights that may apply. + */ +#include <net-snmp/net-snmp-config.h> + +#include <sys/types.h> +#if HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif +#if HAVE_SYS_FILE_H +#include <sys/file.h> +#endif +#if HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#if HAVE_SYS_SOCKIO_H +#include <sys/sockio.h> +#endif +#if HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif +#if HAVE_SYS_MBUF_H +#include <sys/mbuf.h> +#endif + + +#if HAVE_SYS_STREAM_H +#include <sys/stream.h> +#endif +#if HAVE_NET_ROUTE_H +#include <net/route.h> +#endif +#if HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#if HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#if HAVE_NETDB_H +#include <netdb.h> +#endif + +#include <errno.h> +#if HAVE_UNISTD_H +#include <unistd.h> +#endif +#include <stdio.h> +#include <ctype.h> +#if HAVE_STRING_H +#include <string.h> +#endif +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/route.h> + +#include "ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.h" +#include "route_ioctl.h" + +#ifdef cygwin +#include <windows.h> +#endif + +#ifndef HAVE_STRUCT_RTENTRY_RT_DST +# define rt_dst rt_nodes->rn_key +#endif +#ifndef HAVE_STRUCT_RTENTRY_RT_HASH +# define rt_hash rt_pad1 +#endif + + +#ifdef linux +# define NETSNMP_ROUTE_WRITE_PROTOCOL PF_ROUTE +#else +# define NETSNMP_ROUTE_WRITE_PROTOCOL 0 +#endif + +#ifdef irix6 +#define SIOCADDRT SIOCADDMULTI +#define SIOCDELRT SIOCDELMULTI +#endif + +#if defined SIOCADDRT && !defined(irix6) +int _netsnmp_ioctl_route_set_v4(netsnmp_route_entry * entry) +{ + struct sockaddr_in dst, gateway, mask; + int s, rc; + RTENTRY route; + char * DEBUGSTR; + + netsnmp_assert(NULL != entry); /* checked in netsnmp_arch_route_create */ + netsnmp_assert((4 == entry->rt_dest_len) && (4 == entry->rt_nexthop_len)); + + s = socket(AF_INET, SOCK_RAW, NETSNMP_ROUTE_WRITE_PROTOCOL); + if (s < 0) { + snmp_log_perror("socket"); + return -3; + } + + memset(&route, 0, sizeof(route)); + + dst.sin_family = AF_INET; + memcpy(&dst.sin_addr.s_addr, entry->rt_dest, 4); + DEBUGSTR = inet_ntoa(dst.sin_addr); + DEBUGMSGTL(("access:route","*** route to %s\n", DEBUGSTR)); + + gateway.sin_family = AF_INET; + memcpy(&gateway.sin_addr.s_addr, entry->rt_nexthop, 4); + DEBUGSTR = inet_ntoa(gateway.sin_addr); + DEBUGMSGTL(("access:route"," via %s\n", DEBUGSTR)); + + mask.sin_family = AF_INET; + mask.sin_addr.s_addr = htonl(0); + DEBUGSTR = inet_ntoa(mask.sin_addr); + DEBUGMSGTL(("access:route"," mask %s\n", DEBUGSTR)); + + memcpy(&route.rt_dst, &dst, sizeof(struct sockaddr_in)); + memcpy(&route.rt_gateway, &gateway, sizeof(struct sockaddr_in)); + memcpy(&route.rt_genmask, &mask, sizeof(struct sockaddr_in)); + + if (32 == entry->rt_pfx_len) + route.rt_flags |= RTF_HOST; + if (INETCIDRROUTETYPE_REMOTE == entry->rt_type) + route.rt_flags |= RTF_GATEWAY; + route.rt_flags |= RTF_UP; + +#ifndef RTENTRY_4_4 + route.rt_hash = entry->if_index; +#endif + + rc = ioctl(s, SIOCADDRT, (caddr_t) & route); + close(s); + if (rc < 0) { + snmp_log_perror("ioctl"); + return -4; + } + + return 0; +} +#endif + +#if defined SIOCDELRT && !defined(irix6) +int _netsnmp_ioctl_route_delete_v4(netsnmp_route_entry * entry) +{ + struct sockaddr_in dst; + struct sockaddr_in gateway; + int s, rc; + RTENTRY route; + + netsnmp_assert(NULL != entry); /* checked in netsnmp_arch_route_delete */ + netsnmp_assert((4 == entry->rt_dest_len) && (4 == entry->rt_nexthop_len)); + + s = socket(AF_INET, SOCK_RAW, NETSNMP_ROUTE_WRITE_PROTOCOL); + if (s < 0) { + snmp_log_perror("socket"); + return -3; + } + + memset(&route, 0, sizeof(route)); + + dst.sin_family = AF_INET; + memcpy(&dst.sin_addr.s_addr, entry->rt_dest, 4); + + gateway.sin_family = AF_INET; + memcpy(&gateway.sin_addr.s_addr, entry->rt_nexthop, 4); + + memcpy(&route.rt_dst, &dst, sizeof(struct sockaddr_in)); + memcpy(&route.rt_gateway, &gateway, sizeof(struct sockaddr_in)); + + if (32 == entry->rt_pfx_len) + route.rt_flags |= RTF_HOST; + if (INETCIDRROUTETYPE_REMOTE == entry->rt_type) + route.rt_flags |= RTF_GATEWAY; + route.rt_flags |= RTF_UP; + +#ifndef RTENTRY_4_4 + route.rt_hash = entry->if_index; +#endif + + rc = ioctl(s, SIOCDELRT, (caddr_t) & route); + close(s); + if (rc < 0) { + snmp_log_perror("ioctl"); + rc = -4; + } + + return rc; +} +#endif /* SIOCDELRT */ diff --git a/agent/mibgroup/ip-forward-mib/data_access/route_ioctl.h b/agent/mibgroup/ip-forward-mib/data_access/route_ioctl.h new file mode 100644 index 0000000..18c24af --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/data_access/route_ioctl.h @@ -0,0 +1,8 @@ +/* + * internal header, not for distribution + */ + +int _netsnmp_ioctl_route_set_v4(netsnmp_route_entry * entry); +int _netsnmp_ioctl_route_remove_v4(netsnmp_route_entry * entry); +int _netsnmp_ioctl_route_delete_v4(netsnmp_route_entry * entry); + diff --git a/agent/mibgroup/ip-forward-mib/data_access/route_linux.c b/agent/mibgroup/ip-forward-mib/data_access/route_linux.c new file mode 100644 index 0000000..7228e38 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/data_access/route_linux.c @@ -0,0 +1,415 @@ +/* + * Interface MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include "mibII/mibII_common.h" + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/interface.h> +#include <net-snmp/data_access/route.h> +#include <net-snmp/data_access/ipaddress.h> + +#include "ip-forward-mib/data_access/route_ioctl.h" +#include "ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_constants.h" +#include "if-mib/data_access/interface_ioctl.h" + +static int +_type_from_flags(unsigned int flags) +{ + /* + * RTF_GATEWAY RTF_UP RTF_DYNAMIC RTF_CACHE + * RTF_MODIFIED RTF_EXPIRES RTF_NONEXTHOP + * RTF_DYNAMIC RTF_LOCAL RTF_PREFIX_RT + * + * xxx: can we distinguish between reject & blackhole? + */ + if (flags & RTF_UP) { + if (flags & RTF_GATEWAY) + return INETCIDRROUTETYPE_REMOTE; + else /*if (flags & RTF_LOCAL) */ + return INETCIDRROUTETYPE_LOCAL; + } else + return 0; /* route not up */ + +} +static int +_load_ipv4(netsnmp_container* container, u_long *index ) +{ + FILE *in; + char line[256]; + netsnmp_route_entry *entry = NULL; + char name[16]; + int fd; + + DEBUGMSGTL(("access:route:container", + "route_container_arch_load ipv4\n")); + + netsnmp_assert(NULL != container); + + /* + * fetch routes from the proc file-system: + */ + if (!(in = fopen("/proc/net/route", "r"))) { + NETSNMP_LOGONCE((LOG_ERR, "cannot open /proc/net/route\n")); + return -2; + } + + /* + * create socket for ioctls (see NOTE[1], below) + */ + fd = socket(AF_INET, SOCK_DGRAM, 0); + if(fd < 0) { + snmp_log(LOG_ERR, "could not create socket\n"); + fclose(in); + return -2; + } + + fgets(line, sizeof(line), in); /* skip header */ + + while (fgets(line, sizeof(line), in)) { + char rtent_name[32]; + int refcnt, rc; + uint32_t dest, nexthop, mask; + unsigned flags, use; + + entry = netsnmp_access_route_entry_create(); + + /* + * as with 1.99.14: + * Iface Dest GW Flags RefCnt Use Met Mask MTU Win IRTT + * BE eth0 00000000 C0A80101 0003 0 0 0 FFFFFFFF 1500 0 0 + * LE eth0 00000000 0101A8C0 0003 0 0 0 00FFFFFF 0 0 0 + */ + rc = sscanf(line, "%s %x %x %x %d %u %d %x %*d %*d %*d\n", + rtent_name, &dest, &nexthop, + /* + * XXX: fix type of the args + */ + &flags, &refcnt, &use, &entry->rt_metric1, + &mask); + DEBUGMSGTL(("9:access:route:container", "line |%s|\n", line)); + if (8 != rc) { + snmp_log(LOG_ERR, + "/proc/net/route data format error (%d!=8), line ==|%s|", + rc, line); + + netsnmp_access_route_entry_free(entry); + continue; + } + + /* + * temporary null terminated name + */ + strlcpy(name, rtent_name, sizeof(name)); + + /* + * don't bother to try and get the ifindex for routes with + * no interface name. + * NOTE[1]: normally we'd use netsnmp_access_interface_index_find, + * but since that will open/close a socket, and we might + * have a lot of routes, call the ioctl routine directly. + */ + if ('*' != name[0]) + entry->if_index = + netsnmp_access_interface_ioctl_ifindex_get(fd,name); + + /* + * arbitrary index + */ + entry->ns_rt_index = ++(*index); + +#ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE + memcpy(&entry->rt_mask, &mask, 4); + /** entry->rt_tos = XXX; */ + /** rt info ?? */ +#endif + /* + * copy dest & next hop + */ + entry->rt_dest_type = INETADDRESSTYPE_IPV4; + entry->rt_dest_len = 4; + memcpy(entry->rt_dest, &dest, 4); + + entry->rt_nexthop_type = INETADDRESSTYPE_IPV4; + entry->rt_nexthop_len = 4; + memcpy(entry->rt_nexthop, &nexthop, 4); + + /* + * count bits in mask + */ + mask = htonl(mask); + entry->rt_pfx_len = netsnmp_ipaddress_ipv4_prefix_len(mask); + +#ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE + /* + inetCidrRoutePolicy OBJECT-TYPE + SYNTAX OBJECT IDENTIFIER + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This object is an opaque object without any defined + semantics. Its purpose is to serve as an additional + index which may delineate between multiple entries to + the same destination. The value { 0 0 } shall be used + as the default value for this object." + */ + /* + * on linux, default routes all look alike, and would have the same + * indexed based on dest and next hop. So we use the if index + * as the policy, to distinguise between them. Hopefully this is + * unique. + * xxx-rks: It should really only be for the duplicate case, but that + * would be more complicated than I want to get into now. Fix later. + */ + if (0 == nexthop) { + entry->rt_policy = calloc(3, sizeof(oid)); + entry->rt_policy[2] = entry->if_index; + entry->rt_policy_len = sizeof(oid)*3; + } +#endif + + /* + * get protocol and type from flags + */ + entry->rt_type = _type_from_flags(flags); + + entry->rt_proto = (flags & RTF_DYNAMIC) + ? IANAIPROUTEPROTOCOL_ICMP : IANAIPROUTEPROTOCOL_LOCAL; + + /* + * insert into container + */ + if (CONTAINER_INSERT(container, entry) < 0) + { + DEBUGMSGTL(("access:route:container", "error with route_entry: insert into container failed.\n")); + netsnmp_access_route_entry_free(entry); + continue; + } + } + + fclose(in); + close(fd); + return 0; +} + +#ifdef NETSNMP_ENABLE_IPV6 +static int +_load_ipv6(netsnmp_container* container, u_long *index ) +{ + FILE *in; + char line[256]; + netsnmp_route_entry *entry = NULL; + + DEBUGMSGTL(("access:route:container", + "route_container_arch_load ipv6\n")); + + netsnmp_assert(NULL != container); + + /* + * fetch routes from the proc file-system: + */ + if (!(in = fopen("/proc/net/ipv6_route", "r"))) { + DEBUGMSGTL(("9:access:route:container", "cannot open /proc/net/ipv6_route\n")); + return -2; + } + + fgets(line,sizeof(line),in); /* skip header */ + while (fgets(line, sizeof(line), in)) { + char c_name[IFNAMSIZ+1]; + char c_dest[33], c_src[33], c_next[33]; + int rc; + unsigned int dest_pfx, flags; + size_t buf_len, buf_offset; + u_char *temp_uchar_ptr; + + entry = netsnmp_access_route_entry_create(); + + /* + * based on /usr/src/linux/net/ipv6/route.c, kernel 2.6.7: + * + * [ Dest addr / plen ] + * fe80000000000000025056fffec00008 80 \ + * + * [ (?subtree) : src addr/plen : 0/0] + * 00000000000000000000000000000000 00 \ + * + * [ next hop ][ metric ][ref ctn][ use ] + * 00000000000000000000000000000000 00000000 00000000 00000000 \ + * + * [ flags ][dev name] + * 80200001 lo + */ + rc = sscanf(line, "%32s %2x %32s %*x %32s %x %*x %*x %x %" + SNMP_MACRO_VAL_TO_STR(IFNAMSIZ) "s\n", + c_dest, &dest_pfx, c_src, /*src_pfx,*/ c_next, + &entry->rt_metric1, /** ref,*/ /* use, */ &flags, c_name); + DEBUGMSGTL(("9:access:route:container", "line |%s|\n", line)); + if (7 != rc) { + snmp_log(LOG_ERR, + "/proc/net/ipv6_route data format error (%d!=8), " + "line ==|%s|", rc, line); + continue; + } + + /* + * temporary null terminated name + */ + c_name[ sizeof(c_name)-1 ] = 0; + entry->if_index = se_find_value_in_slist("interfaces", c_name); + if(SE_DNE == entry->if_index) { + snmp_log(LOG_ERR,"unknown interface in /proc/net/ipv6_route " + "('%s')\n", c_name); + netsnmp_access_route_entry_free(entry); + continue; + } + /* + * arbitrary index + */ + entry->ns_rt_index = ++(*index); + +#ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE + /** entry->rt_mask = mask; */ /* IPv4 only */ + /** entry->rt_tos = XXX; */ + /** rt info ?? */ +#endif + /* + * convert hex addresses to binary + */ + entry->rt_dest_type = INETADDRESSTYPE_IPV6; + entry->rt_dest_len = 16; + buf_len = sizeof(entry->rt_dest); + buf_offset = 0; + temp_uchar_ptr = entry->rt_dest; + netsnmp_hex_to_binary(&temp_uchar_ptr, &buf_len, &buf_offset, 0, + c_dest, NULL); + + entry->rt_nexthop_type = INETADDRESSTYPE_IPV6; + entry->rt_nexthop_len = 16; + buf_len = sizeof(entry->rt_nexthop); + buf_offset = 0; + temp_uchar_ptr = entry->rt_nexthop; + netsnmp_hex_to_binary(&temp_uchar_ptr, &buf_len, &buf_offset, 0, + c_next, NULL); + + entry->rt_pfx_len = dest_pfx; + +#ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE + /* + inetCidrRoutePolicy OBJECT-TYPE + SYNTAX OBJECT IDENTIFIER + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This object is an opaque object without any defined + semantics. Its purpose is to serve as an additional + index which may delineate between multiple entries to + the same destination. The value { 0 0 } shall be used + as the default value for this object." + */ + /* + * on linux, default routes all look alike, and would have the same + * indexed based on dest and next hop. So we use our arbitrary index + * as the policy, to distinguish between them. + */ + entry->rt_policy = calloc(3, sizeof(oid)); + entry->rt_policy[2] = entry->ns_rt_index; + entry->rt_policy_len = sizeof(oid)*3; +#endif + + /* + * get protocol and type from flags + */ + entry->rt_type = _type_from_flags(flags); + + entry->rt_proto = (flags & RTF_DYNAMIC) + ? IANAIPROUTEPROTOCOL_ICMP : IANAIPROUTEPROTOCOL_LOCAL; + + /* + * insert into container + */ + CONTAINER_INSERT(container, entry); + } + + fclose(in); + return 0; +} +#endif + +/** arch specific load + * @internal + * + * @retval 0 success + * @retval -1 no container specified + * @retval -2 could not open data file + */ +int +netsnmp_access_route_container_arch_load(netsnmp_container* container, + u_int load_flags) +{ + u_long count = 0; + int rc; + + DEBUGMSGTL(("access:route:container", + "route_container_arch_load (flags %x)\n", load_flags)); + + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_route\n"); + return -1; + } + + rc = _load_ipv4(container, &count); + +#ifdef NETSNMP_ENABLE_IPV6 + if((0 != rc) || (load_flags & NETSNMP_ACCESS_ROUTE_LOAD_IPV4_ONLY)) + return rc; + + /* + * load ipv6. ipv6 module might not be loaded, + * so ignore -2 err (file not found) + */ + rc = _load_ipv6(container, &count); + if (-2 == rc) + rc = 0; +#endif + + return rc; +} + +/* + * create a new entry + */ +int +netsnmp_arch_route_create(netsnmp_route_entry *entry) +{ + if (NULL == entry) + return -1; + + if (4 != entry->rt_dest_len) { + DEBUGMSGT(("access:route:create", "only ipv4 supported\n")); + return -2; + } + + return _netsnmp_ioctl_route_set_v4(entry); +} + +/* + * create a new entry + */ +int +netsnmp_arch_route_delete(netsnmp_route_entry *entry) +{ + if (NULL == entry) + return -1; + + if (4 != entry->rt_dest_len) { + DEBUGMSGT(("access:route:create", "only ipv4 supported\n")); + return -2; + } + + return _netsnmp_ioctl_route_delete_v4(entry); +} + + diff --git a/agent/mibgroup/ip-forward-mib/data_access/route_linux.h b/agent/mibgroup/ip-forward-mib/data_access/route_linux.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/data_access/route_linux.h diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable.h b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable.h new file mode 100644 index 0000000..542d516 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable) diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.c b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.c new file mode 100644 index 0000000..0f013ea --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.c @@ -0,0 +1,2688 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for inetCidrRouteTable + * + * \section intro Introduction + * Introductory text. + * + */ +/* + * standard Net-SNMP includes + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "inetCidrRouteTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "inetCidrRouteTable_interface.h" + +netsnmp_feature_require(inetCidrRouteTable_container_get) +netsnmp_feature_require(inetCidrRouteTable_container_size) + +const oid inetCidrRouteTable_oid[] = { INETCIDRROUTETABLE_OID }; +const int inetCidrRouteTable_oid_size = +OID_LENGTH(inetCidrRouteTable_oid); + +inetCidrRouteTable_registration inetCidrRouteTable_user_context; +static inetCidrRouteTable_registration *inetCidrRouteTable_user_context_p; + +void initialize_table_inetCidrRouteTable(void); +void shutdown_table_inetCidrRouteTable(void); + +int +_route_number_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + + +/** + * Initializes the inetCidrRouteTable module + */ +void +init_inetCidrRouteTable(void) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:init_inetCidrRouteTable", + "called\n")); + + /* + * TODO:300:o: Perform inetCidrRouteTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("inetCidrRouteTable")) + initialize_table_inetCidrRouteTable(); + +} /* init_inetCidrRouteTable */ + +/** + * Shut-down the inetCidrRouteTable module (agent is exiting) + */ +void +shutdown_inetCidrRouteTable(void) +{ + if (should_init("inetCidrRouteTable")) + shutdown_table_inetCidrRouteTable(); + +} + +/** + * Initialize the table inetCidrRouteTable + * (Define its contents and how it's structured) + */ +void +initialize_table_inetCidrRouteTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:initialize_table_inetCidrRouteTable", "called\n")); + + /* + * TODO:301:o: Perform inetCidrRouteTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize inetCidrRouteTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + inetCidrRouteTable_user_context_p = + netsnmp_create_data_list("inetCidrRouteTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _inetCidrRouteTable_initialize_interface + (inetCidrRouteTable_user_context_p, flags); + + /* + * regester scalar for route number + */ + { + oid reg_oid[] = + { INETCIDRROUTENUMBER_OID }; + netsnmp_handler_registration *myreg; + netsnmp_mib_handler *handler; + + myreg = + netsnmp_create_handler_registration("route number", + _route_number_handler, + reg_oid, + OID_LENGTH(reg_oid), + HANDLER_CAN_RONLY); + /* + * snarf cache to use w/cache handler to make sure the + * container is loaded w/up to date data. + */ + netsnmp_assert(NULL != inetCidrRouteTable_get_cache()); + handler = + netsnmp_cache_handler_get(inetCidrRouteTable_get_cache()); + netsnmp_inject_handler(myreg, handler); + + netsnmp_register_instance(myreg); + } +} /* initialize_table_inetCidrRouteTable */ + +/** + * Shutdown the table inetCidrRouteTable + */ +void +shutdown_table_inetCidrRouteTable(void) +{ + /* + * call interface shutdown code + */ + _inetCidrRouteTable_shutdown_interface + (inetCidrRouteTable_user_context_p); + netsnmp_free_all_list_data(inetCidrRouteTable_user_context_p); + inetCidrRouteTable_user_context_p = NULL; +} + +/** + * extra context initialization (eg default values) + * + * @param rowreq_ctx : row request context + * @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) + * + * @retval MFD_SUCCESS : no errors + * @retval MFD_ERROR : error (context allocate will fail) + */ +int +inetCidrRouteTable_rowreq_ctx_init(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra inetCidrRouteTable rowreq initialization. (eg DEFVALS) + */ + rowreq_ctx->data->rt_nexthop_type = 0; + + rowreq_ctx->data->rt_metric1 = -1; + + rowreq_ctx->data->rt_metric2 = -1; + + rowreq_ctx->data->rt_metric3 = -1; + + rowreq_ctx->data->rt_metric4 = -1; + + rowreq_ctx->data->rt_metric5 = -1; + + + return MFD_SUCCESS; +} /* inetCidrRouteTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +inetCidrRouteTable_rowreq_ctx_cleanup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra inetCidrRouteTable rowreq cleanup. + */ + if (NULL != rowreq_ctx->data) { + inetCidrRouteTable_release_data(rowreq_ctx->data); + rowreq_ctx->data = NULL; + } +} /* inetCidrRouteTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +inetCidrRouteTable_pre_request(inetCidrRouteTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform inetCidrRouteTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* inetCidrRouteTable_pre_request */ + +/** + * post-request callback + * + * Note: + * New rows have been inserted into the container, and + * deleted rows have been removed from the container and + * released. + * + * @param user_context + * @param rc : MFD_SUCCESS if all requests succeeded + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +inetCidrRouteTable_post_request(inetCidrRouteTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform inetCidrRouteTable post-request actions. + */ + + /* + * check to set if any rows were changed. + */ + if (inetCidrRouteTable_dirty_get()) { + /* + * check if request was successful. If so, this would be + * a good place to save data to its persistent store. + */ + if (MFD_SUCCESS == rc) { + /* + * save changed rows, if you haven't already + */ + } + + inetCidrRouteTable_dirty_set(0); /* clear table dirty flag */ + } + + return MFD_SUCCESS; +} /* inetCidrRouteTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement inetCidrRouteTable data context functions. + */ +/* + * inetCidrRouteTable_allocate_data + * + * Purpose: create new inetCidrRouteTable_data-> + */ +inetCidrRouteTable_data * +inetCidrRouteTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the inetCidrRouteTable data context. + */ + inetCidrRouteTable_data *rtn = netsnmp_access_route_entry_create(); + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_allocate_data", "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "inetCidrRouteTable_data->\n"); + } + + return rtn; +} /* inetCidrRouteTable_allocate_data */ + +/* + * inetCidrRouteTable_release_data + * + * Purpose: release inetCidrRouteTable data-> + */ +void +inetCidrRouteTable_release_data(inetCidrRouteTable_data * data) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_release_data", "called\n")); + + /* + * TODO:202:r: |-> release memory for the inetCidrRouteTable data context. + */ + netsnmp_access_route_entry_free(data); +} /* inetCidrRouteTable_release_data */ + + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param inetCidrRouteDestType_val + * @param inetCidrRouteDest_val_ptr + * @param inetCidrRouteDest_val_ptr_len + * @param inetCidrRoutePfxLen_val + * @param inetCidrRoutePolicy_val_ptr + * @param inetCidrRoutePolicy_val_ptr_len + * @param inetCidrRouteNextHopType_val + * @param inetCidrRouteNextHop_val_ptr + * @param inetCidrRouteNextHop_val_ptr_len + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +inetCidrRouteTable_indexes_set_tbl_idx(inetCidrRouteTable_mib_index * + tbl_idx, + u_long inetCidrRouteDestType_val, + char *inetCidrRouteDest_val_ptr, + size_t + inetCidrRouteDest_val_ptr_len, + u_long inetCidrRoutePfxLen_val, + oid * inetCidrRoutePolicy_val_ptr, + size_t + inetCidrRoutePolicy_val_ptr_len, + u_long inetCidrRouteNextHopType_val, + char *inetCidrRouteNextHop_val_ptr, + size_t + inetCidrRouteNextHop_val_ptr_len) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_indexes_set_tbl_idx", "called\n")); + + /* + * inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_route_entry */ + tbl_idx->inetCidrRouteDestType = inetCidrRouteDestType_val; + + /* + * inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + tbl_idx->inetCidrRouteDest_len = sizeof(tbl_idx->inetCidrRouteDest) / sizeof(tbl_idx->inetCidrRouteDest[0]); /* max length */ + /** WARNING: this code might not work for netsnmp_route_entry */ + /* + * make sure there is enough space for inetCidrRouteDest data + */ + if ((NULL == tbl_idx->inetCidrRouteDest) || + (tbl_idx->inetCidrRouteDest_len < + (inetCidrRouteDest_val_ptr_len))) { + snmp_log(LOG_ERR, "not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->inetCidrRouteDest_len = inetCidrRouteDest_val_ptr_len; + memcpy(tbl_idx->inetCidrRouteDest, inetCidrRouteDest_val_ptr, + inetCidrRouteDest_val_ptr_len * + sizeof(inetCidrRouteDest_val_ptr[0])); + + /* + * inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + /** WARNING: this code might not work for netsnmp_route_entry */ + tbl_idx->inetCidrRoutePfxLen = inetCidrRoutePfxLen_val; + + /* + * inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + tbl_idx->inetCidrRoutePolicy_len = sizeof(tbl_idx->inetCidrRoutePolicy) / sizeof(tbl_idx->inetCidrRoutePolicy[0]); + /** WARNING: this code might not work for netsnmp_route_entry */ + /* + * make sure there is enough space for inetCidrRoutePolicy data + */ + if ((NULL == tbl_idx->inetCidrRoutePolicy) || + (tbl_idx->inetCidrRoutePolicy_len < + (inetCidrRoutePolicy_val_ptr_len / sizeof(inetCidrRoutePolicy_val_ptr[0])))) { + snmp_log(LOG_ERR, + "inetCidrRoutePolicy: Not enough space for value (%d < %d)\n", + (int)tbl_idx->inetCidrRoutePolicy_len, + (int)(inetCidrRoutePolicy_val_ptr_len / sizeof(inetCidrRoutePolicy_val_ptr[0]))); + return MFD_ERROR; + } + if (0 == inetCidrRoutePolicy_val_ptr_len) { + inetCidrRoutePolicy_val_ptr_len = nullOidLen; + inetCidrRoutePolicy_val_ptr = nullOid; + } + tbl_idx->inetCidrRoutePolicy_len = inetCidrRoutePolicy_val_ptr_len / sizeof(oid); + memcpy(tbl_idx->inetCidrRoutePolicy, inetCidrRoutePolicy_val_ptr, + inetCidrRoutePolicy_val_ptr_len); + + /* + * inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_route_entry */ + tbl_idx->inetCidrRouteNextHopType = inetCidrRouteNextHopType_val; + + /* + * inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + tbl_idx->inetCidrRouteNextHop_len = sizeof(tbl_idx->inetCidrRouteNextHop) / sizeof(tbl_idx->inetCidrRouteNextHop[0]); /* max length */ + /** WARNING: this code might not work for netsnmp_route_entry */ + /* + * make sure there is enough space for inetCidrRouteNextHop data + */ + if ((NULL == tbl_idx->inetCidrRouteNextHop) || + (tbl_idx->inetCidrRouteNextHop_len < + (inetCidrRouteNextHop_val_ptr_len / sizeof(inetCidrRouteNextHop_val_ptr[0])))) { + snmp_log(LOG_ERR, + "inetCidrRouteNexthop: Not enough space for value (%d < %d)\n", + (int)tbl_idx->inetCidrRouteNextHop_len, + (int)(inetCidrRouteNextHop_val_ptr_len / sizeof(inetCidrRouteNextHop_val_ptr[0]))); + return MFD_ERROR; + } + tbl_idx->inetCidrRouteNextHop_len = inetCidrRouteNextHop_val_ptr_len / sizeof(inetCidrRouteNextHop_val_ptr[0]); + memcpy(tbl_idx->inetCidrRouteNextHop, inetCidrRouteNextHop_val_ptr, + inetCidrRouteNextHop_val_ptr_len * + sizeof(inetCidrRouteNextHop_val_ptr[0])); + + + return MFD_SUCCESS; +} /* inetCidrRouteTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param rowreq_ctx the row context that needs updated indexes + * @param inetCidrRouteDestType_val + * @param inetCidrRouteDest_val_ptr + * @param inetCidrRouteDest_val_ptr_len + * @param inetCidrRoutePfxLen_val + * @param inetCidrRoutePolicy_val_ptr + * @param inetCidrRoutePolicy_val_ptr_len + * @param inetCidrRouteNextHopType_val + * @param inetCidrRouteNextHop_val_ptr + * @param inetCidrRouteNextHop_val_ptr_len + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +inetCidrRouteTable_indexes_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long inetCidrRouteDestType_val, + char *inetCidrRouteDest_val_ptr, + size_t inetCidrRouteDest_val_ptr_len, + u_long inetCidrRoutePfxLen_val, + oid * inetCidrRoutePolicy_val_ptr, + size_t inetCidrRoutePolicy_val_ptr_len, + u_long inetCidrRouteNextHopType_val, + char *inetCidrRouteNextHop_val_ptr, + size_t inetCidrRouteNextHop_val_ptr_len) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_indexes_set", "called\n")); + + if (MFD_SUCCESS != + inetCidrRouteTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + inetCidrRouteDestType_val, + inetCidrRouteDest_val_ptr, + inetCidrRouteDest_val_ptr_len, + inetCidrRoutePfxLen_val, + inetCidrRoutePolicy_val_ptr, + inetCidrRoutePolicy_val_ptr_len, + inetCidrRouteNextHopType_val, + inetCidrRouteNextHop_val_ptr, + inetCidrRouteNextHop_val_ptr_len)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != inetCidrRouteTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* inetCidrRouteTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteIfIndex + * inetCidrRouteIfIndex is subid 7 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.7 + * Description: +The ifIndex value which identifies the local interface + through which the next hop of this route should be + reached. A value of 0 is valid and represents the + scenario where no interface is specified. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: d + * + * Ranges: 0 - 2147483647; + * + * Its syntax is InterfaceIndexOrZero (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the inetCidrRouteIfIndex data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteIfIndex_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteIfIndex_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *inetCidrRouteIfIndex_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteIfIndex_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteIfIndex_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteIfIndex data-> + * copy (* inetCidrRouteIfIndex_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteIfIndex data + */ + (*inetCidrRouteIfIndex_val_ptr) = rowreq_ctx->data->if_index; + + return MFD_SUCCESS; +} /* inetCidrRouteIfIndex_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteType + * inetCidrRouteType is subid 8 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.8 + * Description: +The type of route. Note that local(3) refers to a + route for which the next hop is the final destination; + remote(4)refers to a route for which the next hop is + not the final destination. + + Routes which do not result in traffic forwarding or + rejection should not be displayed even if the + implementation keeps them stored internally. + + reject(2) refers to a route which, if matched, discards + the message as unreachable and returns a notification + (e.g. ICMP error) to the message sender. This is used + in some protocols as a means of correctly aggregating + routes. + + blackhole(5) refers to a route which, if matched, + discards the message silently. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: other(1), reject(2), local(3), remote(4), blackhole(5) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Extract the current value of the inetCidrRouteType data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteType_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteType_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * inetCidrRouteType_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteType_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteType_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteType data-> + * copy (* inetCidrRouteType_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteType data + */ + (*inetCidrRouteType_val_ptr) = rowreq_ctx->data->rt_type; + + return MFD_SUCCESS; +} /* inetCidrRouteType_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteProto + * inetCidrRouteProto is subid 9 of inetCidrRouteEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.7.1.9 + * Description: +The routing mechanism via which this route was learned. + Inclusion of values for gateway routing protocols is + not intended to imply that hosts should support those + protocols. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 13/32. Values: other(1), local(2), netmgmt(3), icmp(4), egp(5), ggp(6), hello(7), rip(8), isIs(9), esIs(10), ciscoIgrp(11), bbnSpfIgp(12), ospf(13), bgp(14), idpr(15), ciscoEigrp(16), dvmrp(17) + * + * Its syntax is IANAipRouteProtocol (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Extract the current value of the inetCidrRouteProto data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteProto_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteProto_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * inetCidrRouteProto_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteProto_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteProto_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteProto data-> + * copy (* inetCidrRouteProto_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteProto data + */ + (*inetCidrRouteProto_val_ptr) = rowreq_ctx->data->rt_proto; + + return MFD_SUCCESS; +} /* inetCidrRouteProto_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteAge + * inetCidrRouteAge is subid 10 of inetCidrRouteEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.7.1.10 + * Description: +The number of seconds since this route was last updated + or otherwise determined to be correct. Note that no + semantics of 'too old' can be implied except through + knowledge of the routing protocol by which the route + was learned. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is GAUGE (based on perltype GAUGE) + * The net-snmp type is ASN_GAUGE. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the inetCidrRouteAge data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteAge_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteAge_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * inetCidrRouteAge_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteAge_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteAge_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteAge data-> + * copy (* inetCidrRouteAge_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteAge data + */ + (*inetCidrRouteAge_val_ptr) = rowreq_ctx->data->rt_age; + + return MFD_SUCCESS; +} /* inetCidrRouteAge_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteNextHopAS + * inetCidrRouteNextHopAS is subid 11 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.11 + * Description: +The Autonomous System Number of the Next Hop. The + semantics of this object are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. When this object is unknown or not relevant its + value should be set to zero. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 1 + * defval: 0 + * hint: d + * + * + * Its syntax is InetAutonomousSystemNumber (based on perltype UNSIGNED32) + * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the inetCidrRouteNextHopAS data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteNextHopAS_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteNextHopAS_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * inetCidrRouteNextHopAS_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteNextHopAS_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHopAS_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteNextHopAS data-> + * copy (* inetCidrRouteNextHopAS_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteNextHopAS data + */ + (*inetCidrRouteNextHopAS_val_ptr) = rowreq_ctx->data->rt_nexthop_as; + + return MFD_SUCCESS; +} /* inetCidrRouteNextHopAS_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric1 + * inetCidrRouteMetric1 is subid 12 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.12 + * Description: +The primary routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the inetCidrRouteMetric1 data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric1_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteMetric1_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *inetCidrRouteMetric1_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteMetric1_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric1_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteMetric1 data-> + * copy (* inetCidrRouteMetric1_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteMetric1 data + */ + (*inetCidrRouteMetric1_val_ptr) = rowreq_ctx->data->rt_metric1; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric1_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric2 + * inetCidrRouteMetric2 is subid 13 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.13 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the inetCidrRouteMetric2 data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric2_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteMetric2_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *inetCidrRouteMetric2_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteMetric2_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric2_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteMetric2 data-> + * copy (* inetCidrRouteMetric2_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteMetric2 data + */ + (*inetCidrRouteMetric2_val_ptr) = rowreq_ctx->data->rt_metric2; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric2_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric3 + * inetCidrRouteMetric3 is subid 14 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.14 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the inetCidrRouteMetric3 data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric3_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteMetric3_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *inetCidrRouteMetric3_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteMetric3_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric3_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteMetric3 data-> + * copy (* inetCidrRouteMetric3_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteMetric3 data + */ + (*inetCidrRouteMetric3_val_ptr) = rowreq_ctx->data->rt_metric3; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric3_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric4 + * inetCidrRouteMetric4 is subid 15 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.15 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the inetCidrRouteMetric4 data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric4_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteMetric4_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *inetCidrRouteMetric4_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteMetric4_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric4_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteMetric4 data-> + * copy (* inetCidrRouteMetric4_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteMetric4 data + */ + (*inetCidrRouteMetric4_val_ptr) = rowreq_ctx->data->rt_metric4; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric4_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric5 + * inetCidrRouteMetric5 is subid 16 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.16 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the inetCidrRouteMetric5 data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric5_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteMetric5_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *inetCidrRouteMetric5_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteMetric5_val_ptr); + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric5_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetCidrRouteMetric5 data-> + * copy (* inetCidrRouteMetric5_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteMetric5 data + */ + (*inetCidrRouteMetric5_val_ptr) = rowreq_ctx->data->rt_metric5; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric5_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteStatus + * inetCidrRouteStatus is subid 17 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.17 + * Description: +The row status variable, used according to row + installation and removal conventions. + + A row entry cannot be modified when the status is + marked as active(1). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) + * + * Its syntax is RowStatus (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Extract the current value of the inetCidrRouteStatus data-> + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteStatus_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +inetCidrRouteStatus_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * inetCidrRouteStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetCidrRouteStatus_val_ptr); + + /** WARNING: this code might not work for netsnmp_route_entry */ + (*inetCidrRouteStatus_val_ptr) = rowreq_ctx->row_status; + + return MFD_SUCCESS; +} /* inetCidrRouteStatus_get */ + + + +/** @} */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + /* + * NOTE: if you update this chart, please update the versions in + * local/mib2c-conf.d/parent-set.m2i + * agent/mibgroup/helpers/baby_steps.c + * while you're at it. + */ + /* + *********************************************************************** + * Baby Steps Flow Chart (2004.06.05) * + * * + * +--------------+ +================+ U = unconditional path * + * |optional state| ||required state|| S = path for success * + * +--------------+ +================+ E = path for error * + *********************************************************************** + * + * +--------------+ + * | pre | + * | request | + * +--------------+ + * | U + * +-------------+ +==============+ + * | row |f|<-------|| object || + * | create |1| E || lookup || + * +-------------+ +==============+ + * E | | S | S + * | +------------------>| + * | +==============+ + * | E || check || + * |<---------------|| values || + * | +==============+ + * | | S + * | +==============+ + * | +<-------|| undo || + * | | E || setup || + * | | +==============+ + * | | | S + * | | +==============+ + * | | || set ||-------------------------->+ + * | | || value || E | + * | | +==============+ | + * | | | S | + * | | +--------------+ | + * | | | check |-------------------------->| + * | | | consistency | E | + * | | +--------------+ | + * | | | S | + * | | +==============+ +==============+ | + * | | || commit ||-------->|| undo || | + * | | || || E || commit || | + * | | +==============+ +==============+ | + * | | | S U |<--------+ + * | | +--------------+ +==============+ + * | | | irreversible | || undo || + * | | | commit | || set || + * | | +--------------+ +==============+ + * | | | U U | + * | +-------------->|<------------------------+ + * | +==============+ + * | || undo || + * | || cleanup || + * | +==============+ + * +---------------------->| U + * | + * (err && f1)------------------->+ + * | | + * +--------------+ +--------------+ + * | post |<--------| row | + * | request | U | release | + * +--------------+ +--------------+ + * + */ + +/** + * Setup up context with information needed to undo a set request. + * + * This function will be called before the individual node undo setup + * functions are called. If you need to do any undo setup that is not + * related to a specific column, you can do it here. + * + * Note that the undo context has been allocated with + * inetCidrRouteTable_allocate_data(), but may need extra + * initialization similar to what you may have done in + * inetCidrRouteTable_rowreq_ctx_init(). + * Note that an individual node's undo_setup function will only be called + * if that node is being set to a new value. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in the node's undo_setup + * function, so it won't be done unless it is necessary. + * + * @param rowreq_ctx + * Pointer to the table context (inetCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +inetCidrRouteTable_undo_setup(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo_setup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> Setup inetCidrRouteTable undo. + * set up inetCidrRouteTable undo information, in preparation for a set. + * Undo storage is in (* inetCidrRouteStatus_val_ptr )* + */ + rowreq_ctx->row_status_undo = rowreq_ctx->row_status; + + rc = netsnmp_access_route_entry_copy(rowreq_ctx->undo, + rowreq_ctx->data); + + return rc; +} /* inetCidrRouteTable_undo_setup */ + +/** + * Undo a set request. + * + * This function will be called before the individual node undo + * functions are called. If you need to do any undo that is not + * related to a specific column, you can do it here. + * + * Note that an individual node's undo function will only be called + * if that node is being set to a new value. + * + * If there is anything specific to a particular column (e.g. releasing + * memory for a string), you should do that setup in the node's undo + * function, so it won't be done unless it is necessary. + * + * @param rowreq_ctx + * Pointer to the table context (inetCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +inetCidrRouteTable_undo(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> inetCidrRouteTable undo. + * inetCidrRouteTable undo information, in response to a failed set. + * Undo storage is in (* inetCidrRouteStatus_val_ptr )* + */ + rowreq_ctx->row_status = rowreq_ctx->row_status_undo; + + rc = netsnmp_access_route_entry_copy(rowreq_ctx->data, + rowreq_ctx->undo); + + return rc; +} /* inetCidrRouteTable_undo_setup */ + +/** + * Cleanup up context undo information. + * + * This function will be called after set/commit processing. If you + * allocated any resources in undo_setup, this is the place to release + * those resources. + * + * This function is called regardless of the success or failure of the set + * request. If you need to perform different steps for cleanup depending + * on success or failure, you can add a flag to the rowreq_ctx. + * + * @param rowreq_ctx + * Pointer to the table context (inetCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +inetCidrRouteTable_undo_cleanup(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo_cleanup", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:452:M: |-> Cleanup inetCidrRouteTable undo. + * Undo storage is in (* inetCidrRouteStatus_val_ptr )* + */ + + return rc; +} /* inetCidrRouteTable_undo_cleanup */ + +/** + * commit new values. + * + * At this point, you should have done everything you can to ensure that + * this commit will not fail. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the COLUMN_*_FLAG bits can be found in + * inetCidrRouteTable.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rowreq_ctx + * Pointer to the users context. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +inetCidrRouteTable_commit(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + int save_flags; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_commit", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * save flags, then clear until we actually do something + */ + save_flags = rowreq_ctx->column_set_flags; + rowreq_ctx->column_set_flags = 0; + + /* + * commit inetCidrRouteTable data + * 1) check the column's flag in save_flags to see if it was set. + * 2) clear the flag when you handle that column + * 3) set the column's flag in column_set_flags if it needs undo + * processing in case of a failure. + */ + /* + * did anything change? + */ + if (0 == save_flags) { + DEBUGMSGTL(("ipAddressTable:ipAddressTable_commit", + "no change\n")); + return MFD_SUCCESS; + } + + /* + * pass everything to data access + */ + if (save_flags & COLUMN_INETCIDRROUTESTATUS_FLAG) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + if (ROWSTATUS_DESTROY == rowreq_ctx->row_status) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; + return MFD_SUCCESS; + } + netsnmp_assert(ROWSTATUS_ACTIVE == rowreq_ctx->row_status); + rowreq_ctx->data->flags |= NETSNMP_ACCESS_ROUTE_CREATE; + } else if (ROWSTATUS_DESTROY == rowreq_ctx->row_status) { + rowreq_ctx->data->flags |= NETSNMP_ACCESS_ROUTE_DELETE; + } else + rowreq_ctx->data->flags |= NETSNMP_ACCESS_ROUTE_CHANGE; + } else + rowreq_ctx->data->flags |= NETSNMP_ACCESS_ROUTE_CHANGE; + + /* + * do it + * let data access know what columns are set + */ + rowreq_ctx->data->flags |= + (save_flags & NETSNMP_ACCESS_ROUTE_RESERVED_BITS); + rc = netsnmp_access_route_entry_set(rowreq_ctx->data); + if (rc) { + snmp_log(LOG_ERR, + "inetCidrRouteTable column inetCidrRouteStatus commit failed\n"); + rc = MFD_ERROR; + } else { + /* + * set flag, in case we need to undo + */ + rowreq_ctx->column_set_flags |= save_flags; + } + + /* + * if we successfully commited this row, set the dirty flag. + */ + if (MFD_SUCCESS == rc) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; + } + + return rc; +} /* inetCidrRouteTable_commit */ + +/** + * undo commit new values. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the COLUMN_*_FLAG bits can be found in + * inetCidrRouteTable.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rowreq_ctx + * Pointer to the users context. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +inetCidrRouteTable_undo_commit(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo_commit", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:485:M: |-> Undo inetCidrRouteTable commit. + * check the column's flag in rowreq_ctx->column_set_flags to see + * if it was set during commit, then undo it. + * + * eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {} + */ + if (rowreq_ctx->column_set_flags & COLUMN_INETCIDRROUTESTATUS_FLAG) { + /* + * if we created an addr, delete it. if we deleted it, + * re-create it. If we changed it, change it back. + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_ROUTE_DELETE; + } else if (ROWSTATUS_DESTROY == rowreq_ctx->row_status) { + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_ROUTE_CREATE; + } else + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_ROUTE_CHANGE; + } else + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_ROUTE_CHANGE; + + /* + * do it + */ + rc = netsnmp_access_route_entry_set(rowreq_ctx->undo); + if (rc) { + DEBUGMSGTL(("ipAddressTable", + "bad rc %d from IP address data access\n", rc)); + rc = MFD_ERROR; + } + + /* + * if we successfully un-commited this row, clear the dirty flag. + */ + if (MFD_SUCCESS == rc) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return rc; +} /* inetCidrRouteTable_undo_commit */ + +/* + * TODO:440:M: Implement inetCidrRouteTable node value checks. + * TODO:450:M: Implement inetCidrRouteTable undo functions. + * TODO:460:M: Implement inetCidrRouteTable set functions. + * TODO:480:M: Implement inetCidrRouteTable commit functions. + */ +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteIfIndex + * inetCidrRouteIfIndex is subid 7 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.7 + * Description: +The ifIndex value which identifies the local interface + through which the next hop of this route should be + reached. A value of 0 is valid and represents the + scenario where no interface is specified. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: d + * + * Ranges: 0 - 2147483647; + * + * Its syntax is InterfaceIndexOrZero (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteIfIndex_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is in (one of) the range set(s): 0 - 2147483647 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteIfIndex_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, long inetCidrRouteIfIndex_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteIfIndex_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteIfIndex value. + */ + + return MFD_SUCCESS; /* inetCidrRouteIfIndex value not illegal */ +} /* inetCidrRouteIfIndex_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteIfIndex_val + * A long containing the new value. + */ +int +inetCidrRouteIfIndex_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long inetCidrRouteIfIndex_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteIfIndex_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteIfIndex value. + * set inetCidrRouteIfIndex value in rowreq_ctx->data + */ + rowreq_ctx->data->if_index = inetCidrRouteIfIndex_val; + + return MFD_SUCCESS; +} /* inetCidrRouteIfIndex_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteType + * inetCidrRouteType is subid 8 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.8 + * Description: +The type of route. Note that local(3) refers to a + route for which the next hop is the final destination; + remote(4)refers to a route for which the next hop is + not the final destination. + + Routes which do not result in traffic forwarding or + rejection should not be displayed even if the + implementation keeps them stored internally. + + reject(2) refers to a route which, if matched, discards + the message as unreachable and returns a notification + (e.g. ICMP error) to the message sender. This is used + in some protocols as a means of correctly aggregating + routes. + + blackhole(5) refers to a route which, if matched, + discards the message silently. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: other(1), reject(2), local(3), remote(4), blackhole(5) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteType_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of other(1), reject(2), local(3), remote(4), blackhole(5) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteType_check_value(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long inetCidrRouteType_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteType_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteType value. + */ + + return MFD_SUCCESS; /* inetCidrRouteType value not illegal */ +} /* inetCidrRouteType_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteType_val + * A long containing the new value. + */ +int +inetCidrRouteType_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long inetCidrRouteType_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteType_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteType value. + * set inetCidrRouteType value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_type = inetCidrRouteType_val; + + return MFD_SUCCESS; +} /* inetCidrRouteType_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteNextHopAS + * inetCidrRouteNextHopAS is subid 11 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.11 + * Description: +The Autonomous System Number of the Next Hop. The + semantics of this object are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. When this object is unknown or not relevant its + value should be set to zero. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 1 + * defval: 0 + * hint: d + * + * + * Its syntax is InetAutonomousSystemNumber (based on perltype UNSIGNED32) + * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteNextHopAS_val + * A u_long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_UNSIGNED + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteNextHopAS_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteNextHopAS_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHopAS_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteNextHopAS value. + */ + + return MFD_SUCCESS; /* inetCidrRouteNextHopAS value not illegal */ +} /* inetCidrRouteNextHopAS_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteNextHopAS_val + * A u_long containing the new value. + */ +int +inetCidrRouteNextHopAS_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long inetCidrRouteNextHopAS_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHopAS_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteNextHopAS value. + * set inetCidrRouteNextHopAS value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_nexthop_type = inetCidrRouteNextHopAS_val; + + return MFD_SUCCESS; +} /* inetCidrRouteNextHopAS_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric1 + * inetCidrRouteMetric1 is subid 12 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.12 + * Description: +The primary routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric1_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteMetric1_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, long inetCidrRouteMetric1_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric1_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteMetric1 value. + */ + + return MFD_SUCCESS; /* inetCidrRouteMetric1 value not illegal */ +} /* inetCidrRouteMetric1_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteMetric1_val + * A long containing the new value. + */ +int +inetCidrRouteMetric1_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long inetCidrRouteMetric1_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric1_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteMetric1 value. + * set inetCidrRouteMetric1 value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_metric1 = inetCidrRouteMetric1_val; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric1_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric2 + * inetCidrRouteMetric2 is subid 13 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.13 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric2_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteMetric2_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, long inetCidrRouteMetric2_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric2_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteMetric2 value. + */ + /* + * does any os use metrics 2-5? If so, update this to deal with it. + */ + + return MFD_NOT_VALID_EVER; +} /* inetCidrRouteMetric2_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteMetric2_val + * A long containing the new value. + */ +int +inetCidrRouteMetric2_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long inetCidrRouteMetric2_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric2_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteMetric2 value. + * set inetCidrRouteMetric2 value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_metric2 = inetCidrRouteMetric2_val; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric2_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric3 + * inetCidrRouteMetric3 is subid 14 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.14 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric3_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteMetric3_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, long inetCidrRouteMetric3_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric3_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteMetric3 value. + */ + /* + * does any os use metrics 2-5? If so, update this to deal with it. + */ + + return MFD_NOT_VALID_NOW; +} /* inetCidrRouteMetric3_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteMetric3_val + * A long containing the new value. + */ +int +inetCidrRouteMetric3_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long inetCidrRouteMetric3_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric3_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteMetric3 value. + * set inetCidrRouteMetric3 value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_metric3 = inetCidrRouteMetric3_val; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric3_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric4 + * inetCidrRouteMetric4 is subid 15 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.15 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric4_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteMetric4_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, long inetCidrRouteMetric4_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric4_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteMetric4 value. + */ + /* + * does any os use metrics 2-5? If so, update this to deal with it. + */ + + return MFD_NOT_VALID_NOW; +} /* inetCidrRouteMetric4_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteMetric4_val + * A long containing the new value. + */ +int +inetCidrRouteMetric4_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long inetCidrRouteMetric4_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric4_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteMetric4 value. + * set inetCidrRouteMetric4 value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_metric4 = inetCidrRouteMetric4_val; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric4_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteMetric5 + * inetCidrRouteMetric5 is subid 16 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.16 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's inetCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteMetric5_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteMetric5_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, long inetCidrRouteMetric5_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric5_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteMetric5 value. + */ + /* + * does any os use metrics 2-5? If so, update this to deal with it. + */ + return MFD_NOT_VALID_NOW; +} /* inetCidrRouteMetric5_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteMetric5_val + * A long containing the new value. + */ +int +inetCidrRouteMetric5_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + long inetCidrRouteMetric5_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteMetric5_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteMetric5 value. + * set inetCidrRouteMetric5 value in rowreq_ctx->data + */ + rowreq_ctx->data->rt_metric5 = inetCidrRouteMetric5_val; + + return MFD_SUCCESS; +} /* inetCidrRouteMetric5_set */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteStatus + * inetCidrRouteStatus is subid 17 of inetCidrRouteEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.7.1.17 + * Description: +The row status variable, used according to row + installation and removal conventions. + + A row entry cannot be modified when the status is + marked as active(1). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) + * + * Its syntax is RowStatus (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetCidrRouteStatus_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * inetCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetCidrRouteStatus_check_value(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long inetCidrRouteStatus_val) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteStatus_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetCidrRouteStatus value. + */ + + return MFD_SUCCESS; /* inetCidrRouteStatus value not illegal */ +} /* inetCidrRouteStatus_check_value */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param inetCidrRouteStatus_val + * A long containing the new value. + */ +int +inetCidrRouteStatus_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long inetCidrRouteStatus_val) +{ + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteStatus_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetCidrRouteStatus value. + * set inetCidrRouteStatus value in rowreq_ctx->data + */ + rowreq_ctx->row_status = inetCidrRouteStatus_val; + + return MFD_SUCCESS; +} /* inetCidrRouteStatus_set */ + +/** + * check dependencies + * + * This is useful for for tables which have dependencies between columns + * (or rows, or tables). For example, two columns allocating a percentage + * of something add up 100%. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the COLUMN_*_FLAG bits can be found in + * inetCidrRouteTable.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @retval MFD_SUCCESS all the changes to the row are legal + * @retval MFD_ERROR one or more changes are not legal + * + * (see README-table-inetCidrRouteTable if you don't have dependencies) + */ +int +inetCidrRouteTable_check_dependencies(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("internal:inetCidrRouteTable:inetCidrRouteTable_check_dependencies", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:470:o: Check inetCidrRouteTable row dependencies. + * check that all new value are legal and consistent with each other + */ + /* + * can't modify an active row + */ + if ((ROWSTATUS_ACTIVE == rowreq_ctx->row_status) && + (ROWSTATUS_ACTIVE == rowreq_ctx->row_status_undo)) { + DEBUGMSGTL(("inetCidrRouteTable", + "can't change active row (yet)\n")); + return MFD_ERROR; + } + + /* + * check RowStatus dependencies + */ + if (rowreq_ctx->column_set_flags & COLUMN_INETCIDRROUTESTATUS_FLAG) { + /* + * check for valid RowStatus transition (old, new) + * (Note: move transition check to + * to catch errors earlier) + */ + rc = check_rowstatus_transition(rowreq_ctx->row_status_undo, + rowreq_ctx->row_status); + if (MFD_SUCCESS != rc) + return rc; + + /* + * row creation requirements + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + if (ROWSTATUS_DESTROY == rowreq_ctx->row_status) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; + } else if (ROWSTATUS_CREATEANDGO == rowreq_ctx->row_status) { + if ((rowreq_ctx-> + column_set_flags & INETCIDRROUTETABLE_REQUIRED_COLS) + != INETCIDRROUTETABLE_REQUIRED_COLS) { + DEBUGMSGTL(("inetCidrRouteTable", + "required columns missing (0x%0x != 0x%0x)\n", + rowreq_ctx->column_set_flags, + INETCIDRROUTETABLE_REQUIRED_COLS)); + return MFD_CANNOT_CREATE_NOW; + } + rowreq_ctx->row_status = ROWSTATUS_ACTIVE; + } + } /* row creation */ + else { + /* + * row change requirements + */ + /* + * don't allow a destroy if any other value was changed, since + * that might call data access routines with bad info. + * + * you may or may not require the row be notInService before it + * can be destroyed. + */ + if (ROWSTATUS_DESTROY == rowreq_ctx->row_status) { + if (rowreq_ctx-> + column_set_flags & ~COLUMN_INETCIDRROUTESTATUS_FLAG) { + DEBUGMSGTL(("inetCidrRouteTable", + "destroy must be only varbind for row\n")); + return MFD_NOT_VALID_NOW; + } + rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; + + } /* row destroy */ + } /* row change */ + } else { + /* + * must have row status to create a row + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + DEBUGMSGTL(("inetCidrRouteTable", + "must use RowStatus to create rows\n")); + return MFD_CANNOT_CREATE_NOW; + } + } /* row status not set */ + + if (MFD_SUCCESS != rc) + return rc; + + return rc; +} /* inetCidrRouteTable_check_dependencies */ + + +int +_route_number_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + if (MODE_GET == reqinfo->mode) { + int val = inetCidrRouteTable_container_size(); + snmp_set_var_typed_value(requests->requestvb, ASN_UNSIGNED, + (u_char *) &val, sizeof(val)); + } else + netsnmp_assert("bad mode in RO handler"); + + if (handler->next && handler->next->access_method) + return netsnmp_call_next_handler(handler, reginfo, reqinfo, + requests); + + return SNMP_ERR_NOERROR; +} + +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.h b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.h new file mode 100644 index 0000000..b8132e1 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable.h @@ -0,0 +1,537 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef INETCIDRROUTETABLE_H +#define INETCIDRROUTETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/route.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-forward-mib/data_access/route) +config_require(ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface) +config_require(ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for inetCidrRouteTable + */ +#include "inetCidrRouteTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void init_inetCidrRouteTable(void); + void shutdown_inetCidrRouteTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + /* + ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review inetCidrRouteTable registration context. + */ + typedef netsnmp_data_list inetCidrRouteTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review inetCidrRouteTable data context structure. + * This structure is used to represent the data for inetCidrRouteTable. + */ + typedef netsnmp_route_entry inetCidrRouteTable_data; + + + /* + ********************************************************************* + * TODO:115:o: |-> Review inetCidrRouteTable undo context. + * We're just going to use the same data structure for our + * undo_context. If you want to do something more efficent, + * define your typedef here. + */ + typedef inetCidrRouteTable_data inetCidrRouteTable_undo_data; + + /* + * TODO:120:r: |-> Review inetCidrRouteTable mib index. + * This structure is used to represent the index for inetCidrRouteTable. + */ + typedef struct inetCidrRouteTable_mib_index_s { + + /* + * inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long inetCidrRouteDestType; + + /* + * inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + char + inetCidrRouteDest[NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE]; + size_t inetCidrRouteDest_len; + + /* + * inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + u_long inetCidrRoutePfxLen; + + /* + * inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + oid inetCidrRoutePolicy[NETSNMP_POLICY_OID_MAX_LEN]; + size_t inetCidrRoutePolicy_len; + + /* + * inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long inetCidrRouteNextHopType; + + /* + * inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + char + inetCidrRouteNextHop[NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE]; + size_t inetCidrRouteNextHop_len; + + + } inetCidrRouteTable_mib_index; + + /* + * TODO:121:r: | |-> Review inetCidrRouteTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + */ +#define MAX_inetCidrRouteTable_IDX_LEN (((NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE+1)*2)+ 3 + (NETSNMP_POLICY_OID_MAX_LEN + 1)) + + + /* + ********************************************************************* + * TODO:130:o: |-> Review inetCidrRouteTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * inetCidrRouteTable_rowreq_ctx pointer. + */ + typedef struct inetCidrRouteTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_inetCidrRouteTable_IDX_LEN]; + + inetCidrRouteTable_mib_index tbl_idx; + + inetCidrRouteTable_data *data; + inetCidrRouteTable_undo_data *undo; + unsigned int column_set_flags; /* flags for set columns */ + + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * TODO:131:o: | |-> Add useful data to inetCidrRouteTable rowreq context. + */ + u_char row_status; + u_char row_status_undo; + + /* + * storage for future expansion + */ + netsnmp_data_list *inetCidrRouteTable_data_list; + + } inetCidrRouteTable_rowreq_ctx; + + typedef struct inetCidrRouteTable_ref_rowreq_ctx_s { + inetCidrRouteTable_rowreq_ctx *rowreq_ctx; + } inetCidrRouteTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + inetCidrRouteTable_pre_request(inetCidrRouteTable_registration * + user_context); + int + inetCidrRouteTable_post_request(inetCidrRouteTable_registration * + user_context, int rc); + + int + inetCidrRouteTable_rowreq_ctx_init(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + void *user_init_ctx); + void + inetCidrRouteTable_rowreq_ctx_cleanup(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + inetCidrRouteTable_data *inetCidrRouteTable_allocate_data(void); + void inetCidrRouteTable_release_data(inetCidrRouteTable_data + * data); + + int + inetCidrRouteTable_check_dependencies(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + int inetCidrRouteTable_commit(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + + inetCidrRouteTable_rowreq_ctx + * inetCidrRouteTable_row_find_by_mib_index + (inetCidrRouteTable_mib_index * mib_idx); + + extern const oid inetCidrRouteTable_oid[]; + extern const int inetCidrRouteTable_oid_size; + + +#include "inetCidrRouteTable_interface.h" +#include "inetCidrRouteTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + /* + * indexes + */ + + int inetCidrRouteIfIndex_get(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + *inetCidrRouteIfIndex_val_ptr); + int inetCidrRouteType_get(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetCidrRouteType_val_ptr); + int inetCidrRouteProto_get(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetCidrRouteProto_val_ptr); + int inetCidrRouteAge_get(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetCidrRouteAge_val_ptr); + int + inetCidrRouteNextHopAS_get(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetCidrRouteNextHopAS_val_ptr); + int inetCidrRouteMetric1_get(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + *inetCidrRouteMetric1_val_ptr); + int inetCidrRouteMetric2_get(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + *inetCidrRouteMetric2_val_ptr); + int inetCidrRouteMetric3_get(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + *inetCidrRouteMetric3_val_ptr); + int inetCidrRouteMetric4_get(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + *inetCidrRouteMetric4_val_ptr); + int inetCidrRouteMetric5_get(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + *inetCidrRouteMetric5_val_ptr); + int inetCidrRouteStatus_get(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetCidrRouteStatus_val_ptr); + + + int + inetCidrRouteTable_indexes_set_tbl_idx(inetCidrRouteTable_mib_index + * tbl_idx, + u_long + inetCidrRouteDestType_val, + char + *inetCidrRouteDest_val_ptr, + size_t + inetCidrRouteDest_val_ptr_len, + u_long + inetCidrRoutePfxLen_val, + oid * + inetCidrRoutePolicy_val_ptr, + size_t + inetCidrRoutePolicy_val_ptr_len, + u_long + inetCidrRouteNextHopType_val, + char + *inetCidrRouteNextHop_val_ptr, + size_t + inetCidrRouteNextHop_val_ptr_len); + int + inetCidrRouteTable_indexes_set(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteDestType_val, + char *inetCidrRouteDest_val_ptr, + size_t + inetCidrRouteDest_val_ptr_len, + u_long inetCidrRoutePfxLen_val, + oid * inetCidrRoutePolicy_val_ptr, + size_t + inetCidrRoutePolicy_val_ptr_len, + u_long inetCidrRouteNextHopType_val, + char *inetCidrRouteNextHop_val_ptr, + size_t + inetCidrRouteNextHop_val_ptr_len); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + + + int + inetCidrRouteTable_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int + inetCidrRouteTable_undo_cleanup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteTable_undo(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteTable_commit(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + int + inetCidrRouteTable_undo_commit(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + + int + inetCidrRouteIfIndex_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long inetCidrRouteIfIndex_val); + int + inetCidrRouteIfIndex_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteIfIndex_set(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + inetCidrRouteIfIndex_val); + int inetCidrRouteIfIndex_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int + inetCidrRouteType_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteType_val); + int + inetCidrRouteType_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteType_set(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteType_val); + int inetCidrRouteType_undo(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + inetCidrRouteProto_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteProto_val); + int + inetCidrRouteProto_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteProto_set(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteProto_val); + int inetCidrRouteProto_undo(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + inetCidrRouteAge_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteAge_val); + int + inetCidrRouteAge_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteAge_set(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteAge_val); + int inetCidrRouteAge_undo(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + inetCidrRouteNextHopAS_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long + inetCidrRouteNextHopAS_val); + int + inetCidrRouteNextHopAS_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int + inetCidrRouteNextHopAS_set(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteNextHopAS_val); + int + inetCidrRouteNextHopAS_undo(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + inetCidrRouteMetric1_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long inetCidrRouteMetric1_val); + int + inetCidrRouteMetric1_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteMetric1_set(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + inetCidrRouteMetric1_val); + int inetCidrRouteMetric1_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int + inetCidrRouteMetric2_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long inetCidrRouteMetric2_val); + int + inetCidrRouteMetric2_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteMetric2_set(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + inetCidrRouteMetric2_val); + int inetCidrRouteMetric2_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int + inetCidrRouteMetric3_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long inetCidrRouteMetric3_val); + int + inetCidrRouteMetric3_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteMetric3_set(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + inetCidrRouteMetric3_val); + int inetCidrRouteMetric3_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int + inetCidrRouteMetric4_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long inetCidrRouteMetric4_val); + int + inetCidrRouteMetric4_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteMetric4_set(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + inetCidrRouteMetric4_val); + int inetCidrRouteMetric4_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int + inetCidrRouteMetric5_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long inetCidrRouteMetric5_val); + int + inetCidrRouteMetric5_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteMetric5_set(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx, long + inetCidrRouteMetric5_val); + int inetCidrRouteMetric5_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int + inetCidrRouteStatus_check_value(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long inetCidrRouteStatus_val); + int + inetCidrRouteStatus_undo_setup(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteStatus_set(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long + inetCidrRouteStatus_val); + int inetCidrRouteStatus_undo(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + + int + inetCidrRouteTable_check_dependencies(inetCidrRouteTable_rowreq_ctx + * ctx); + + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* INETCIDRROUTETABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_constants.h b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_constants.h new file mode 100644 index 0000000..0fe26b8 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_constants.h @@ -0,0 +1,216 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-constants.m2c,v 1.5 2005/07/15 22:41:16 rstory Exp $ + * + * $Id$ + */ +#ifndef INETCIDRROUTETABLE_CONSTANTS_H +#define INETCIDRROUTETABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table inetCidrRouteTable + */ +#define INETCIDRROUTENUMBER_OID 1,3,6,1,2,1,4,24,6,0 +#define INETCIDRROUTETABLE_OID 1,3,6,1,2,1,4,24,7 + +#define COLUMN_INETCIDRROUTEDESTTYPE 1 + +#define COLUMN_INETCIDRROUTEDEST 2 + +#define COLUMN_INETCIDRROUTEPFXLEN 3 + +#define COLUMN_INETCIDRROUTEPOLICY 4 + +#define COLUMN_INETCIDRROUTENEXTHOPTYPE 5 + +#define COLUMN_INETCIDRROUTENEXTHOP 6 + +#define COLUMN_INETCIDRROUTEIFINDEX 7 +#define COLUMN_INETCIDRROUTEIFINDEX_FLAG (0x1 << 6) + +#define COLUMN_INETCIDRROUTETYPE 8 +#define COLUMN_INETCIDRROUTETYPE_FLAG (0x1 << 7) + +#define COLUMN_INETCIDRROUTEPROTO 9 + +#define COLUMN_INETCIDRROUTEAGE 10 + +#define COLUMN_INETCIDRROUTENEXTHOPAS 11 +#define COLUMN_INETCIDRROUTENEXTHOPAS_FLAG (0x1 << 10) + +#define COLUMN_INETCIDRROUTEMETRIC1 12 +#define COLUMN_INETCIDRROUTEMETRIC1_FLAG (0x1 << 11) + +#define COLUMN_INETCIDRROUTEMETRIC2 13 +#define COLUMN_INETCIDRROUTEMETRIC2_FLAG (0x1 << 12) + +#define COLUMN_INETCIDRROUTEMETRIC3 14 +#define COLUMN_INETCIDRROUTEMETRIC3_FLAG (0x1 << 13) + +#define COLUMN_INETCIDRROUTEMETRIC4 15 +#define COLUMN_INETCIDRROUTEMETRIC4_FLAG (0x1 << 14) + +#define COLUMN_INETCIDRROUTEMETRIC5 16 +#define COLUMN_INETCIDRROUTEMETRIC5_FLAG (0x1 << 15) + +#define COLUMN_INETCIDRROUTESTATUS 17 +#define COLUMN_INETCIDRROUTESTATUS_FLAG (0x1 << 16) + + +#define INETCIDRROUTETABLE_MIN_COL COLUMN_INETCIDRROUTEIFINDEX +#define INETCIDRROUTETABLE_MAX_COL COLUMN_INETCIDRROUTESTATUS + + + /* + * TODO:405:r: Review INETCIDRROUTETABLE_SETTABLE_COLS macro. + * OR together all the writable cols. + */ +#define INETCIDRROUTETABLE_SETTABLE_COLS (COLUMN_INETCIDRROUTEIFINDEX_FLAG | COLUMN_INETCIDRROUTETYPE_FLAG | COLUMN_INETCIDRROUTENEXTHOPAS_FLAG | COLUMN_INETCIDRROUTEMETRIC1_FLAG | COLUMN_INETCIDRROUTEMETRIC2_FLAG | COLUMN_INETCIDRROUTEMETRIC3_FLAG | COLUMN_INETCIDRROUTEMETRIC4_FLAG | COLUMN_INETCIDRROUTEMETRIC5_FLAG | COLUMN_INETCIDRROUTESTATUS_FLAG) + /* + * TODO:405:r: Review INETCIDRROUTETABLE_REQUIRED_COLS macro. + * OR together all the required rows for row creation. + * default is writable cols w/out defaults. + */ +#define INETCIDRROUTETABLE_REQUIRED_COLS (COLUMN_INETCIDRROUTEIFINDEX_FLAG | COLUMN_INETCIDRROUTETYPE_FLAG | COLUMN_INETCIDRROUTESTATUS_FLAG) + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table inetCidrRouteTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * inetCidrRouteDestType (InetAddressType / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETADDRESSTYPE_ENUMS +#define INETADDRESSTYPE_ENUMS + +#define INETADDRESSTYPE_UNKNOWN 0 +#define INETADDRESSTYPE_IPV4 1 +#define INETADDRESSTYPE_IPV6 2 +#define INETADDRESSTYPE_IPV4Z 3 +#define INETADDRESSTYPE_IPV6Z 4 +#define INETADDRESSTYPE_DNS 16 + +#endif /* INETADDRESSTYPE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * inetCidrRouteNextHopType (InetAddressType / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETADDRESSTYPE_ENUMS +#define INETADDRESSTYPE_ENUMS + +#define INETADDRESSTYPE_UNKNOWN 0 +#define INETADDRESSTYPE_IPV4 1 +#define INETADDRESSTYPE_IPV6 2 +#define INETADDRESSTYPE_IPV4Z 3 +#define INETADDRESSTYPE_IPV6Z 4 +#define INETADDRESSTYPE_DNS 16 + +#endif /* INETADDRESSTYPE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * inetCidrRouteType (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETCIDRROUTETYPE_ENUMS +#define INETCIDRROUTETYPE_ENUMS + +#define INETCIDRROUTETYPE_OTHER 1 +#define INETCIDRROUTETYPE_REJECT 2 +#define INETCIDRROUTETYPE_LOCAL 3 +#define INETCIDRROUTETYPE_REMOTE 4 +#define INETCIDRROUTETYPE_BLACKHOLE 5 + +#endif /* INETCIDRROUTETYPE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * inetCidrRouteProto (IANAipRouteProtocol / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IANAIPROUTEPROTOCOL_ENUMS +#define IANAIPROUTEPROTOCOL_ENUMS + +#define IANAIPROUTEPROTOCOL_OTHER 1 +#define IANAIPROUTEPROTOCOL_LOCAL 2 +#define IANAIPROUTEPROTOCOL_NETMGMT 3 +#define IANAIPROUTEPROTOCOL_ICMP 4 +#define IANAIPROUTEPROTOCOL_EGP 5 +#define IANAIPROUTEPROTOCOL_GGP 6 +#define IANAIPROUTEPROTOCOL_HELLO 7 +#define IANAIPROUTEPROTOCOL_RIP 8 +#define IANAIPROUTEPROTOCOL_ISIS 9 +#define IANAIPROUTEPROTOCOL_ESIS 10 +#define IANAIPROUTEPROTOCOL_CISCOIGRP 11 +#define IANAIPROUTEPROTOCOL_BBNSPFIGP 12 +#define IANAIPROUTEPROTOCOL_OSPF 13 +#define IANAIPROUTEPROTOCOL_BGP 14 +#define IANAIPROUTEPROTOCOL_IDPR 15 +#define IANAIPROUTEPROTOCOL_CISCOEIGRP 16 +#define IANAIPROUTEPROTOCOL_DVMRP 17 + +#endif /* IANAIPROUTEPROTOCOL_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * inetCidrRouteStatus (RowStatus / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef ROWSTATUS_ENUMS +#define ROWSTATUS_ENUMS + +#define ROWSTATUS_ACTIVE 1 +#define ROWSTATUS_NOTINSERVICE 2 +#define ROWSTATUS_NOTREADY 3 +#define ROWSTATUS_CREATEANDGO 4 +#define ROWSTATUS_CREATEANDWAIT 5 +#define ROWSTATUS_DESTROY 6 + +#endif /* ROWSTATUS_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* INETCIDRROUTETABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.c b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.c new file mode 100644 index 0000000..beebb2c --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.c @@ -0,0 +1,932 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +/* + * standard Net-SNMP includes + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "inetCidrRouteTable.h" + + +#include "inetCidrRouteTable_data_access.h" + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + +/** + * initialization for inetCidrRouteTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param inetCidrRouteTable_reg + * Pointer to inetCidrRouteTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +inetCidrRouteTable_init_data(inetCidrRouteTable_registration * + inetCidrRouteTable_reg) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize inetCidrRouteTable data. + */ + + return MFD_SUCCESS; +} /* inetCidrRouteTable_init_data */ + +/** + * container overview + * + */ + +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +inetCidrRouteTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to inetCidrRouteTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + if (NULL == cache) { + snmp_log(LOG_ERR, + "bad cache param to inetCidrRouteTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up inetCidrRouteTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = INETCIDRROUTETABLE_CACHE_TIMEOUT; /* seconds */ +} /* inetCidrRouteTable_container_init */ + +/** + * check entry for update + */ +static void +_snarf_route_entry(netsnmp_route_entry *route_entry, + netsnmp_container *container) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx; + + netsnmp_assert(NULL != route_entry); + netsnmp_assert(NULL != container); + + /* + * per inetCidrRouteType: + * + * Routes which do not result in traffic forwarding or + * rejection should not be displayed even if the + * implementation keeps them stored internally. + */ + if (route_entry->rt_type == 0) { /* set when route not up */ + DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load", "skipping route\n")); + netsnmp_access_route_entry_free(route_entry); + return; + } + + /* + * allocate an row context and set the index(es), then add it to + * the container + */ + rowreq_ctx = inetCidrRouteTable_allocate_rowreq_ctx(route_entry, NULL); + if ((NULL != rowreq_ctx) && + (MFD_SUCCESS == inetCidrRouteTable_indexes_set + (rowreq_ctx, route_entry->rt_dest_type, + (char *) route_entry->rt_dest, route_entry->rt_dest_len, + route_entry->rt_pfx_len, + route_entry->rt_policy, route_entry->rt_policy_len, + route_entry->rt_nexthop_type, + (char *) route_entry->rt_nexthop, route_entry->rt_nexthop_len))) { + CONTAINER_INSERT(container, rowreq_ctx); + rowreq_ctx->row_status = ROWSTATUS_ACTIVE; + } else { + if (rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "inetCidrRoute cache.\n"); + inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + } else + netsnmp_access_route_entry_free(route_entry); + } +} + +/** + * container shutdown + * + * @param container_ptr A pointer to the container. + * + * This function is called at shutdown to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. + * + * This function is called before inetCidrRouteTable_container_free(). + * + * @remark + * This would also be a good place to do any cleanup needed + * for you data source. For example, closing a connection to another + * process that supplied the data, closing a database, etc. + */ +void +inetCidrRouteTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to inetCidrRouteTable_container_shutdown\n"); + return; + } + +} /* inetCidrRouteTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement inetCidrRouteTable data load + * This function will also be called by the cache helper to load + * the container again (after the container free function has been + * called to free the previous contents). + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to load the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the data, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * inetCidrRouteTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +inetCidrRouteTable_container_load(netsnmp_container *container) +{ + netsnmp_container *route_container; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_load", "called\n")); + + /* + * TODO:351:M: |-> Load/update data in the inetCidrRouteTable container. + * loop over your inetCidrRouteTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + * + * we use the netsnmp data access api to get the data + */ + route_container = + netsnmp_access_route_container_load(NULL, + NETSNMP_ACCESS_ROUTE_LOAD_NOFLAGS); + DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load", + "%d records\n", (int)CONTAINER_SIZE(route_container))); + + if (NULL == route_container) + return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */ + + /* + * we just got a fresh copy of route data. snarf data + */ + CONTAINER_FOR_EACH(route_container, + (netsnmp_container_obj_func *) _snarf_route_entry, + container); + + /* + * free the container. we've either claimed each ifentry, or released it, + * so the dal function doesn't need to clear the container. + */ + netsnmp_access_route_container_free(route_container, + NETSNMP_ACCESS_ROUTE_FREE_DONT_CLEAR); + + DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load", + "%d records\n", (int)CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} /* inetCidrRouteTable_container_load */ + +/** + * container clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +inetCidrRouteTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_free", "called\n")); + + /* + * TODO:380:M: Free inetCidrRouteTable container data. + */ +} /* inetCidrRouteTable_container_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +inetCidrRouteTable_row_prep(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_row_prep", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + if (MFD_ROW_CREATED & rowreq_ctx->rowreq_flags) { + memcpy(rowreq_ctx->data->rt_dest, + rowreq_ctx->tbl_idx.inetCidrRouteDest, + rowreq_ctx->tbl_idx.inetCidrRouteDest_len); + rowreq_ctx->data->rt_dest_len = + rowreq_ctx->tbl_idx.inetCidrRouteDest_len; + rowreq_ctx->data->rt_dest_type = + rowreq_ctx->tbl_idx.inetCidrRouteDestType; + + memcpy(rowreq_ctx->data->rt_nexthop, + rowreq_ctx->tbl_idx.inetCidrRouteNextHop, + rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len); + rowreq_ctx->data->rt_nexthop_len = + rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len; + rowreq_ctx->data->rt_nexthop_type = + rowreq_ctx->tbl_idx.inetCidrRouteNextHopType; + + rowreq_ctx->data->rt_pfx_len = + rowreq_ctx->tbl_idx.inetCidrRoutePfxLen; + + rowreq_ctx->data->rt_policy_len = + rowreq_ctx->tbl_idx.inetCidrRoutePolicy_len; + rowreq_ctx->data->rt_policy = + rowreq_ctx->tbl_idx.inetCidrRoutePolicy; + /* + * policy pointing to rowreq array, set flag so + * it won't be freed + */ + rowreq_ctx->data->flags |= NETSNMP_ACCESS_ROUTE_POLICY_STATIC; + } + + + return MFD_SUCCESS; +} /* inetCidrRouteTable_row_prep */ + +/* + * TODO:420:r: Implement inetCidrRouteTable index validation. + */ +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteDestType + * inetCidrRouteDestType is subid 1 of inetCidrRouteEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.24.7.1.1 + * Description: +The type of the inetCidrRouteDest address, as defined + in the InetAddress MIB. + + Only those address types that may appear in an actual + routing table are allowed as values of this object. + * + * Attributes: + * accessible 0 isscalar 0 enums 1 hasdefval 0 + * readable 0 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 5/8. Values: unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) + * + * Its syntax is InetAddressType (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + * + * + * + * NOTE: NODE inetCidrRouteDestType IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetCidrRouteDestType index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * inetCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * The value is one of unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetCidrRouteDestType_check_index(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteDestType_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteDestType. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetCidrRouteDestType) + */ + /* + * we don't support all types + */ + switch (rowreq_ctx->tbl_idx.inetCidrRouteDestType) { + + case INETADDRESSTYPE_IPV4: + case INETADDRESSTYPE_IPV6: + break; + + case INETADDRESSTYPE_UNKNOWN: + case INETADDRESSTYPE_IPV4Z: + case INETADDRESSTYPE_IPV6Z: + case INETADDRESSTYPE_DNS: + /* + * fall through + */ + + default: + return MFD_ERROR; + } + + return MFD_SUCCESS; /* inetCidrRouteDestType index ok */ +} /* inetCidrRouteDestType_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteDest + * inetCidrRouteDest is subid 2 of inetCidrRouteEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.24.7.1.2 + * Description: +The destination IP address of this route. + + The type of this address is determined by the value of + the inetCidrRouteDestType object. + + The values for the index objects inetCidrRouteDest and + inetCidrRoutePfxLen must be consistent. When the value + of inetCidrRouteDest (excluding the zone index, if one + is present) is x, then the bitwise logical-AND + of x with the value of the mask formed from the + corresponding index object inetCidrRoutePfxLen MUST be + equal to x. If not, then the index pair is not + consistent and an inconsistentName error must be + returned on SET or CREATE requests. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 0 - 255; + * + * Its syntax is InetAddress (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE inetCidrRouteDest IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetCidrRouteDest index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * inetCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * The length is in (one of) the range set(s): 0 - 255 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetCidrRouteDest_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteDest_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteDest. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetCidrRouteDest) + */ + + return MFD_SUCCESS; /* inetCidrRouteDest index ok */ +} /* inetCidrRouteDest_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRoutePfxLen + * inetCidrRoutePfxLen is subid 3 of inetCidrRouteEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.24.7.1.3 + * Description: +Indicates the number of leading one bits which form the + mask to be logical-ANDed with the destination address + before being compared to the value in the + inetCidrRouteDest field. + + The values for the index objects inetCidrRouteDest and + inetCidrRoutePfxLen must be consistent. When the value + of inetCidrRouteDest (excluding the zone index, if one + is present) is x, then the bitwise logical-AND + of x with the value of the mask formed from the + corresponding index object inetCidrRoutePfxLen MUST be + equal to x. If not, then the index pair is not + consistent and an inconsistentName error must be + returned on SET or CREATE requests. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: d + * + * Ranges: 0 - 2040; + * + * Its syntax is InetAddressPrefixLength (based on perltype UNSIGNED32) + * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long) + * + * + * + * NOTE: NODE inetCidrRoutePfxLen IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetCidrRoutePfxLen index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * inetCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * The value is in (one of) the range set(s): 0 - 2040 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetCidrRoutePfxLen_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRoutePfxLen_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRoutePfxLen. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetCidrRoutePfxLen) + */ + + return MFD_SUCCESS; /* inetCidrRoutePfxLen index ok */ +} /* inetCidrRoutePfxLen_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRoutePolicy + * inetCidrRoutePolicy is subid 4 of inetCidrRouteEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.24.7.1.4 + * Description: +This object is an opaque object without any defined + semantics. Its purpose is to serve as an additional + index which may delineate between multiple entries to + the same destination. The value { 0 0 } shall be used + as the default value for this object. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is OBJECTID (based on perltype OBJECTID) + * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) + * This data type requires a length. (Max 2040) + * + * + * + * NOTE: NODE inetCidrRoutePolicy IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetCidrRoutePolicy index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * inetCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetCidrRoutePolicy_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRoutePolicy_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRoutePolicy. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetCidrRoutePolicy) + */ + + return MFD_SUCCESS; /* inetCidrRoutePolicy index ok */ +} /* inetCidrRoutePolicy_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteNextHopType + * inetCidrRouteNextHopType is subid 5 of inetCidrRouteEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.24.7.1.5 + * Description: +The type of the inetCidrRouteNextHop address, as + defined in the InetAddress MIB. + + Value should be set to unknown(0) for non-remote + routes. + + Only those address types that may appear in an actual + routing table are allowed as values of this object. + * + * Attributes: + * accessible 0 isscalar 0 enums 1 hasdefval 0 + * readable 0 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 5/8. Values: unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) + * + * Its syntax is InetAddressType (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + * + * + * + * NOTE: NODE inetCidrRouteNextHopType IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetCidrRouteNextHopType index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * inetCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * The value is one of unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetCidrRouteNextHopType_check_index(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHopType_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteNextHopType. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetCidrRouteNextHopType) + */ + /* + * we don't support all types + */ + switch (rowreq_ctx->tbl_idx.inetCidrRouteDestType) { + + case INETADDRESSTYPE_IPV4: + case INETADDRESSTYPE_IPV6: + break; + + case INETADDRESSTYPE_UNKNOWN: + case INETADDRESSTYPE_IPV4Z: + case INETADDRESSTYPE_IPV6Z: + case INETADDRESSTYPE_DNS: + /* + * fall through + */ + + default: + return MFD_ERROR; + } + + return MFD_SUCCESS; /* inetCidrRouteNextHopType index ok */ +} /* inetCidrRouteNextHopType_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteNextHop + * inetCidrRouteNextHop is subid 6 of inetCidrRouteEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.24.7.1.6 + * Description: +On remote routes, the address of the next system en + route. For non-remote routes, a zero length string. + + The type of this address is determined by the value of + the inetCidrRouteNextHopType object. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 0 - 255; + * + * Its syntax is InetAddress (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE inetCidrRouteNextHop IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetCidrRouteNextHop index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * inetCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * The length is in (one of) the range set(s): 0 - 255 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetCidrRouteNextHop_check_index(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHop_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteNextHop. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetCidrRouteNextHop) + */ + + return MFD_SUCCESS; /* inetCidrRouteNextHop index ok */ +} /* inetCidrRouteNextHop_check_index */ + +/** + * verify specified index is valid. + * + * This check is independent of whether or not the values specified for + * the columns of the new row are valid. Column values and row consistency + * will be checked later. At this point, only the index values should be + * checked. + * + * All of the individual index validation functions have been called, so this + * is the place to make sure they are valid as a whole when combined. If + * you only have one index, then you probably don't need to do anything else + * here. + * + * @note Keep in mind that if the indexes refer to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * + * @param inetCidrRouteTable_reg + * Pointer to the user registration data + * @param rowreq_ctx + * Pointer to the users context. + * @retval MFD_SUCCESS : success + * @retval MFD_CANNOT_CREATE_NOW : index not valid right now + * @retval MFD_CANNOT_CREATE_EVER : index never valid + */ +int +inetCidrRouteTable_validate_index(inetCidrRouteTable_registration * + inetCidrRouteTable_reg, + inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_validate_index", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:430:M: |-> Validate potential inetCidrRouteTable index. + */ + if (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + rowreq_ctx->tbl_idx.inetCidrRouteNextHopType) { + DEBUGMSGTL(("inetCidrRouteTable:validate_index", + "ipv4/v6 cross routing not supported\n")); + return MFD_CANNOT_CREATE_EVER; + } + + /* + * InetAddress + */ + if (((INETADDRESSTYPE_IPV4 == + rowreq_ctx->tbl_idx.inetCidrRouteDestType) + && (4 != rowreq_ctx->tbl_idx.inetCidrRouteDest_len)) + || + ((INETADDRESSTYPE_IPV6 == + rowreq_ctx->tbl_idx.inetCidrRouteDestType) + && (16 != rowreq_ctx->tbl_idx.inetCidrRouteDest_len))) { + DEBUGMSGTL(("inetCidrRouteTable:validate_index", + "dest addr type/size mismatch\n")); + return MFD_CANNOT_CREATE_EVER; + } + /* + * InetAddress + */ + if (((INETADDRESSTYPE_IPV4 == + rowreq_ctx->tbl_idx.inetCidrRouteNextHopType) + && (4 != rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len)) + || + ((INETADDRESSTYPE_IPV6 == + rowreq_ctx->tbl_idx.inetCidrRouteNextHopType) + && (16 != rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len))) { + DEBUGMSGTL(("inetCidrRouteTable:validate_index", + "next hop addr type/size mismatch\n")); + return MFD_CANNOT_CREATE_EVER; + } + + return rc; +} /* inetCidrRouteTable_validate_index */ + +/** @} */ diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.h b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.h new file mode 100644 index 0000000..9ad9067 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.h @@ -0,0 +1,86 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef INETCIDRROUTETABLE_DATA_ACCESS_H +#define INETCIDRROUTETABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ + + + int + inetCidrRouteTable_init_data(inetCidrRouteTable_registration * + inetCidrRouteTable_reg); + + + /* + * TODO:180:o: Review inetCidrRouteTable cache timeout. + * The number of seconds before the cache times out + */ +#define INETCIDRROUTETABLE_CACHE_TIMEOUT 60 + + void inetCidrRouteTable_container_init(netsnmp_container + **container_ptr_ptr, + netsnmp_cache * + cache); + void inetCidrRouteTable_container_shutdown(netsnmp_container + *container_ptr); + + int inetCidrRouteTable_container_load(netsnmp_container + *container); + void inetCidrRouteTable_container_free(netsnmp_container + *container); + + int inetCidrRouteTable_cache_load(netsnmp_container + *container); + void inetCidrRouteTable_cache_free(netsnmp_container + *container); + + int + inetCidrRouteTable_row_prep(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + inetCidrRouteTable_validate_index(inetCidrRouteTable_registration * + inetCidrRouteTable_reg, + inetCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int inetCidrRouteDestType_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetCidrRouteDest_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetCidrRoutePfxLen_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetCidrRoutePolicy_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetCidrRouteNextHopType_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetCidrRouteNextHop_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + + +#ifdef __cplusplus +} +#endif +#endif /* INETCIDRROUTETABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c new file mode 100644 index 0000000..0dba9d2 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c @@ -0,0 +1,2402 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.67 $ of : mfd-interface.m2c,v $ + * + * $Id$ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ + +/* + * standard Net-SNMP includes + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "inetCidrRouteTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "inetCidrRouteTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(inetCidrRouteTable_external_access, libnetsnmpmibs) +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(table_container_row_insert) +netsnmp_feature_require(check_all_requests_error) + +netsnmp_feature_child_of(inetCidrRouteTable_container_size, inetCidrRouteTable_external_access) +netsnmp_feature_child_of(inetCidrRouteTable_registration_set, inetCidrRouteTable_external_access) +netsnmp_feature_child_of(inetCidrRouteTable_registration_get, inetCidrRouteTable_external_access) +netsnmp_feature_child_of(inetCidrRouteTable_container_get, inetCidrRouteTable_external_access) +/********************************************************************** + ********************************************************************** + *** + *** Table inetCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.24.7, length: 9 + */ +typedef struct inetCidrRouteTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + inetCidrRouteTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_int table_dirty; + +} inetCidrRouteTable_interface_ctx; + +static inetCidrRouteTable_interface_ctx inetCidrRouteTable_if_ctx; + +static void + _inetCidrRouteTable_container_init(inetCidrRouteTable_interface_ctx * + if_ctx); +static void + _inetCidrRouteTable_container_shutdown(inetCidrRouteTable_interface_ctx * + if_ctx); + +#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_GET +netsnmp_container * +inetCidrRouteTable_container_get(void) +{ + return inetCidrRouteTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_GET +inetCidrRouteTable_registration * +inetCidrRouteTable_registration_get(void) +{ + return inetCidrRouteTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_SET +inetCidrRouteTable_registration * +inetCidrRouteTable_registration_set(inetCidrRouteTable_registration * + newreg) +{ + inetCidrRouteTable_registration *old = + inetCidrRouteTable_if_ctx.user_ctx; + inetCidrRouteTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_SIZE +int +inetCidrRouteTable_container_size(void) +{ + return CONTAINER_SIZE(inetCidrRouteTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_SIZE */ + +u_int +inetCidrRouteTable_dirty_get(void) +{ + return inetCidrRouteTable_if_ctx.table_dirty; +} + +void +inetCidrRouteTable_dirty_set(u_int status) +{ + DEBUGMSGTL(("inetCidrRouteTable:inetCidrRouteTable_dirty_set", + "called. was %d, now %d\n", + inetCidrRouteTable_if_ctx.table_dirty, status)); + inetCidrRouteTable_if_ctx.table_dirty = status; +} + +netsnmp_cache * +inetCidrRouteTable_get_cache(void) +{ + return inetCidrRouteTable_if_ctx.cache; +} + + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_pre_request; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_post_request; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_object_lookup; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_get_values; +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_check_objects; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_setup; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_set_values; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_values; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_commit; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_commit; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_irreversible_commit; +static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_check_dependencies; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + +NETSNMP_STATIC_INLINE int + _inetCidrRouteTable_check_indexes(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); +/** + * @internal + * Initialize the table inetCidrRouteTable + * (Define its contents and how it's structured) + */ +void +_inetCidrRouteTable_initialize_interface(inetCidrRouteTable_registration * + reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &inetCidrRouteTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &inetCidrRouteTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for inetCidrRouteTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: inetCidrRouteDestType */ + ASN_OCTET_STR, + /** index: inetCidrRouteDest */ + ASN_UNSIGNED, + /** index: inetCidrRoutePfxLen */ + ASN_OBJECT_ID, + /** index: inetCidrRoutePolicy */ + ASN_INTEGER, + /** index: inetCidrRouteNextHopType */ + ASN_OCTET_STR, + /** index: inetCidrRouteNextHop */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = INETCIDRROUTETABLE_MIN_COL; + tbl_info->max_column = INETCIDRROUTETABLE_MAX_COL; + + /* + * save users context + */ + inetCidrRouteTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + inetCidrRouteTable_init_data(reg_ptr); + + /* + * set up the container + */ + _inetCidrRouteTable_container_init(&inetCidrRouteTable_if_ctx); + if (NULL == inetCidrRouteTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for inetCidrRouteTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_inetCidrRouteTable_object_lookup; + access_multiplexer->get_values = _mfd_inetCidrRouteTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_inetCidrRouteTable_pre_request; + access_multiplexer->post_request = + _mfd_inetCidrRouteTable_post_request; + + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) + /* + * REQUIRED wrappers for set request handling + */ + access_multiplexer->object_syntax_checks = + _mfd_inetCidrRouteTable_check_objects; + access_multiplexer->undo_setup = _mfd_inetCidrRouteTable_undo_setup; + access_multiplexer->undo_cleanup = + _mfd_inetCidrRouteTable_undo_cleanup; + access_multiplexer->set_values = _mfd_inetCidrRouteTable_set_values; + access_multiplexer->undo_sets = _mfd_inetCidrRouteTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_inetCidrRouteTable_commit; + access_multiplexer->undo_commit = _mfd_inetCidrRouteTable_undo_commit; + access_multiplexer->irreversible_commit = + _mfd_inetCidrRouteTable_irreversible_commit; + + /* + * REQUIRED for tables with dependencies + */ + access_multiplexer->consistency_checks = + _mfd_inetCidrRouteTable_check_dependencies; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("inetCidrRouteTable:init_inetCidrRouteTable", + "Registering inetCidrRouteTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("inetCidrRouteTable", handler, + inetCidrRouteTable_oid, + inetCidrRouteTable_oid_size, + HANDLER_CAN_BABY_STEP +#ifndef NETSNMP_DISABLE_SET_SUPPORT + | HANDLER_CAN_RWRITE +#endif + ); + if (NULL == reginfo) { + snmp_log(LOG_ERR, "error registering table inetCidrRouteTable\n"); + return; + } + reginfo->my_reg_void = &inetCidrRouteTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if (access_multiplexer->object_lookup) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if (access_multiplexer->pre_request) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if (access_multiplexer->post_request) + mfd_modes |= BABY_STEP_POST_REQUEST; + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) + if (access_multiplexer->set_values) + mfd_modes |= BABY_STEP_SET_VALUES; + if (access_multiplexer->irreversible_commit) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if (access_multiplexer->object_syntax_checks) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if (access_multiplexer->undo_setup) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if (access_multiplexer->undo_cleanup) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if (access_multiplexer->undo_sets) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if (access_multiplexer->row_creation) + mfd_modes |= BABY_STEP_ROW_CREATE; + if (access_multiplexer->consistency_checks) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if (access_multiplexer->commit) + mfd_modes |= BABY_STEP_COMMIT; + if (access_multiplexer->undo_commit) + mfd_modes |= BABY_STEP_UNDO_COMMIT; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + inetCidrRouteTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != inetCidrRouteTable_if_ctx.cache) { + handler = + netsnmp_cache_handler_get(inetCidrRouteTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _inetCidrRouteTable_initialize_interface */ + +/** + * @internal + * Shutdown the table inetCidrRouteTable + */ +void +_inetCidrRouteTable_shutdown_interface(inetCidrRouteTable_registration * + reg_ptr) +{ + /* + * shutdown the container + */ + _inetCidrRouteTable_container_shutdown(&inetCidrRouteTable_if_ctx); +} + +void +inetCidrRouteTable_valid_columns_set(netsnmp_column_info *vc) +{ + inetCidrRouteTable_if_ctx.tbl_info.valid_columns = vc; +} /* inetCidrRouteTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +inetCidrRouteTable_index_to_oid(netsnmp_index * oid_idx, + inetCidrRouteTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_inetCidrRouteDestType; + /* + * inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_inetCidrRouteDest; + /* + * inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_inetCidrRoutePfxLen; + /* + * inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + netsnmp_variable_list var_inetCidrRoutePolicy; + /* + * inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_inetCidrRouteNextHopType; + /* + * inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_inetCidrRouteNextHop; + + /* + * set up varbinds + */ + memset(&var_inetCidrRouteDestType, 0x00, + sizeof(var_inetCidrRouteDestType)); + var_inetCidrRouteDestType.type = ASN_INTEGER; + memset(&var_inetCidrRouteDest, 0x00, sizeof(var_inetCidrRouteDest)); + var_inetCidrRouteDest.type = ASN_OCTET_STR; + memset(&var_inetCidrRoutePfxLen, 0x00, + sizeof(var_inetCidrRoutePfxLen)); + var_inetCidrRoutePfxLen.type = ASN_UNSIGNED; + memset(&var_inetCidrRoutePolicy, 0x00, + sizeof(var_inetCidrRoutePolicy)); + var_inetCidrRoutePolicy.type = ASN_OBJECT_ID; + memset(&var_inetCidrRouteNextHopType, 0x00, + sizeof(var_inetCidrRouteNextHopType)); + var_inetCidrRouteNextHopType.type = ASN_INTEGER; + memset(&var_inetCidrRouteNextHop, 0x00, + sizeof(var_inetCidrRouteNextHop)); + var_inetCidrRouteNextHop.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_inetCidrRouteDestType.next_variable = &var_inetCidrRouteDest; + var_inetCidrRouteDest.next_variable = &var_inetCidrRoutePfxLen; + var_inetCidrRoutePfxLen.next_variable = &var_inetCidrRoutePolicy; + var_inetCidrRoutePolicy.next_variable = &var_inetCidrRouteNextHopType; + var_inetCidrRouteNextHopType.next_variable = &var_inetCidrRouteNextHop; + var_inetCidrRouteNextHop.next_variable = NULL; + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_index_to_oid", "called\n")); + + /* + * inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_inetCidrRouteDestType, + (u_char *) & mib_idx->inetCidrRouteDestType, + sizeof(mib_idx->inetCidrRouteDestType)); + + /* + * inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + snmp_set_var_value(&var_inetCidrRouteDest, + (u_char *) & mib_idx->inetCidrRouteDest, + mib_idx->inetCidrRouteDest_len * + sizeof(mib_idx->inetCidrRouteDest[0])); + + /* + * inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_inetCidrRoutePfxLen, + (u_char *) & mib_idx->inetCidrRoutePfxLen, + sizeof(mib_idx->inetCidrRoutePfxLen)); + + /* + * inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + snmp_set_var_value(&var_inetCidrRoutePolicy, + (u_char *) & mib_idx->inetCidrRoutePolicy, + mib_idx->inetCidrRoutePolicy_len * + sizeof(mib_idx->inetCidrRoutePolicy[0])); + + /* + * inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_inetCidrRouteNextHopType, + (u_char *) & mib_idx->inetCidrRouteNextHopType, + sizeof(mib_idx->inetCidrRouteNextHopType)); + + /* + * inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + snmp_set_var_value(&var_inetCidrRouteNextHop, + (u_char *) & mib_idx->inetCidrRouteNextHop, + mib_idx->inetCidrRouteNextHop_len * + sizeof(mib_idx->inetCidrRouteNextHop[0])); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_inetCidrRouteDestType); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_inetCidrRouteDestType); + + return err; +} /* inetCidrRouteTable_index_to_oid */ + +/** + * extract inetCidrRouteTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +inetCidrRouteTable_index_from_oid(netsnmp_index * oid_idx, + inetCidrRouteTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_inetCidrRouteDestType; + /* + * inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_inetCidrRouteDest; + /* + * inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_inetCidrRoutePfxLen; + /* + * inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + netsnmp_variable_list var_inetCidrRoutePolicy; + /* + * inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_inetCidrRouteNextHopType; + /* + * inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_inetCidrRouteNextHop; + + /* + * set up varbinds + */ + memset(&var_inetCidrRouteDestType, 0x00, + sizeof(var_inetCidrRouteDestType)); + var_inetCidrRouteDestType.type = ASN_INTEGER; + memset(&var_inetCidrRouteDest, 0x00, sizeof(var_inetCidrRouteDest)); + var_inetCidrRouteDest.type = ASN_OCTET_STR; + memset(&var_inetCidrRoutePfxLen, 0x00, + sizeof(var_inetCidrRoutePfxLen)); + var_inetCidrRoutePfxLen.type = ASN_UNSIGNED; + memset(&var_inetCidrRoutePolicy, 0x00, + sizeof(var_inetCidrRoutePolicy)); + var_inetCidrRoutePolicy.type = ASN_OBJECT_ID; + memset(&var_inetCidrRouteNextHopType, 0x00, + sizeof(var_inetCidrRouteNextHopType)); + var_inetCidrRouteNextHopType.type = ASN_INTEGER; + memset(&var_inetCidrRouteNextHop, 0x00, + sizeof(var_inetCidrRouteNextHop)); + var_inetCidrRouteNextHop.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_inetCidrRouteDestType.next_variable = &var_inetCidrRouteDest; + var_inetCidrRouteDest.next_variable = &var_inetCidrRoutePfxLen; + var_inetCidrRoutePfxLen.next_variable = &var_inetCidrRoutePolicy; + var_inetCidrRoutePolicy.next_variable = &var_inetCidrRouteNextHopType; + var_inetCidrRouteNextHopType.next_variable = &var_inetCidrRouteNextHop; + var_inetCidrRouteNextHop.next_variable = NULL; + + + DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_index_from_oid", "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_inetCidrRouteDestType); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->inetCidrRouteDestType = + *((u_long *) var_inetCidrRouteDestType.val.string); + /* + * NOTE: val_len is in bytes, inetCidrRouteDest_len might not be + */ + if (var_inetCidrRouteDest.val_len > + sizeof(mib_idx->inetCidrRouteDest)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->inetCidrRouteDest, + var_inetCidrRouteDest.val.string, + var_inetCidrRouteDest.val_len); + mib_idx->inetCidrRouteDest_len = + var_inetCidrRouteDest.val_len / + sizeof(mib_idx->inetCidrRouteDest[0]); + } + mib_idx->inetCidrRoutePfxLen = + *((u_long *) var_inetCidrRoutePfxLen.val.string); + /* + * NOTE: val_len is in bytes, inetCidrRoutePolicy_len might not be + */ + if (var_inetCidrRoutePolicy.val_len > + sizeof(mib_idx->inetCidrRoutePolicy)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->inetCidrRoutePolicy, + var_inetCidrRoutePolicy.val.string, + var_inetCidrRoutePolicy.val_len); + mib_idx->inetCidrRoutePolicy_len = + var_inetCidrRoutePolicy.val_len / + sizeof(mib_idx->inetCidrRoutePolicy[0]); + } + mib_idx->inetCidrRouteNextHopType = + *((u_long *) var_inetCidrRouteNextHopType.val.string); + /* + * NOTE: val_len is in bytes, inetCidrRouteNextHop_len might not be + */ + if (var_inetCidrRouteNextHop.val_len > + sizeof(mib_idx->inetCidrRouteNextHop)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->inetCidrRouteNextHop, + var_inetCidrRouteNextHop.val.string, + var_inetCidrRouteNextHop.val_len); + mib_idx->inetCidrRouteNextHop_len = + var_inetCidrRouteNextHop.val_len / + sizeof(mib_idx->inetCidrRouteNextHop[0]); + } + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_inetCidrRouteDestType); + + return err; +} /* inetCidrRouteTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a inetCidrRouteTable_rowreq_ctx + */ +inetCidrRouteTable_rowreq_ctx * +inetCidrRouteTable_allocate_rowreq_ctx(inetCidrRouteTable_data * data, + void *user_init_ctx) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(inetCidrRouteTable_rowreq_ctx); + + DEBUGMSGTL(("internal:inetCidrRouteTable:inetCidrRouteTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "inetCidrRouteTable_rowreq_ctx.\n"); + return NULL; + } else { + if (NULL != data) { + /* + * track if we got data from user + */ + rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; + rowreq_ctx->data = data; + } else if (NULL == + (rowreq_ctx->data = + inetCidrRouteTable_allocate_data())) { + SNMP_FREE(rowreq_ctx); + return NULL; + } + } + + /* + * undo context will be allocated when needed (in *_undo_setup) + */ + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->inetCidrRouteTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + inetCidrRouteTable_rowreq_ctx_init(rowreq_ctx, + user_init_ctx)) { + inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* inetCidrRouteTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a inetCidrRouteTable_rowreq_ctx + */ +void +inetCidrRouteTable_release_rowreq_ctx(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("internal:inetCidrRouteTable:inetCidrRouteTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + inetCidrRouteTable_rowreq_ctx_cleanup(rowreq_ctx); + + /* + * for non-transient data, don't free data we got from the user + */ + if ((rowreq_ctx->data) && + !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) + inetCidrRouteTable_release_data(rowreq_ctx->data); + + if (rowreq_ctx->undo) + inetCidrRouteTable_release_data(rowreq_ctx->undo); + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* inetCidrRouteTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_inetCidrRouteTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:inetCidrRouteTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = inetCidrRouteTable_pre_request(inetCidrRouteTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetCidrRouteTable", "error %d from " + "inetCidrRouteTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_inetCidrRouteTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:inetCidrRouteTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + if ((MFD_SUCCESS != packet_rc) && inetCidrRouteTable_dirty_get()) { + /* + * we shouldn't get here. the undo steps should also clear + * the dirty flags. + */ + snmp_log(LOG_WARNING, + "inetCidrRouteTable dirty flag set in post_request " + "but status != SUCCESS.\n"); + } + + rc = inetCidrRouteTable_post_request(inetCidrRouteTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetCidrRouteTable", "error %d from " + "inetCidrRouteTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_post_request */ + +/** + * @internal + * wrapper + */ +static inetCidrRouteTable_rowreq_ctx * +_mfd_inetCidrRouteTable_rowreq_from_index(netsnmp_index * oid_idx, + int *rc_ptr) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx; + inetCidrRouteTable_mib_index mib_idx; + int rc; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_rowreq_from_index", "called\n")); + + if (NULL == rc_ptr) + rc_ptr = &rc; + *rc_ptr = MFD_SUCCESS; + + memset(&mib_idx, 0x0, sizeof(mib_idx)); + + /* + * try to parse oid + */ + *rc_ptr = inetCidrRouteTable_index_from_oid(oid_idx, &mib_idx); + if (MFD_SUCCESS != *rc_ptr) { + DEBUGMSGT(("inetCidrRouteTable", "error parsing index\n")); + return NULL; + } + + /* + * allocate new context + */ + rowreq_ctx = inetCidrRouteTable_allocate_rowreq_ctx(NULL, NULL); + if (NULL == rowreq_ctx) { + *rc_ptr = MFD_ERROR; + return NULL; /* msg already logged */ + } + + memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx)); + + /* + * check indexes + */ + *rc_ptr = _inetCidrRouteTable_check_indexes(rowreq_ctx); + if (MFD_SUCCESS != *rc_ptr) { + netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) || + (*rc_ptr == SNMP_ERR_INCONSISTENTNAME)); + inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + return NULL; + } + + /* + * copy indexes + */ + rowreq_ctx->oid_idx.len = oid_idx->len; + memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids, + oid_idx->len * sizeof(oid)); + + return rowreq_ctx; +} /* _mfd_inetCidrRouteTable_rowreq_from_index */ + + +/** + * @internal + * wrapper + */ +static int +_mfd_inetCidrRouteTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = SNMP_ERR_NOERROR; + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * inetCidrRouteTable_interface_ctx *if_ctx = + * (inetCidrRouteTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + netsnmp_table_request_info *tblreq_info; + netsnmp_index oid_idx; + + tblreq_info = netsnmp_extract_table_info(requests); + if (NULL == tblreq_info) { + snmp_log(LOG_ERR, "request had no table info\n"); + return MFD_ERROR; + } + + /* + * try create rowreq + */ + oid_idx.oids = tblreq_info->index_oid; + oid_idx.len = tblreq_info->index_oid_len; + + rowreq_ctx = + _mfd_inetCidrRouteTable_rowreq_from_index(&oid_idx, &rc); + if (MFD_SUCCESS == rc) { + netsnmp_assert(NULL != rowreq_ctx); + rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED; + /* + * add rowreq_ctx to request data lists + */ + netsnmp_container_table_row_insert(requests, (netsnmp_index *) + rowreq_ctx); + } + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + inetCidrRouteTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_inetCidrRouteTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetCidrRouteTable_get_column(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_INETCIDRROUTEIFINDEX: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = inetCidrRouteIfIndex_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTETYPE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = inetCidrRouteType_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * inetCidrRouteProto(9)/IANAipRouteProtocol/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_INETCIDRROUTEPROTO: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = inetCidrRouteProto_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * inetCidrRouteAge(10)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_INETCIDRROUTEAGE: + var->val_len = sizeof(u_long); + var->type = ASN_GAUGE; + rc = inetCidrRouteAge_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H + */ + case COLUMN_INETCIDRROUTENEXTHOPAS: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = inetCidrRouteNextHopAS_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC1: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = inetCidrRouteMetric1_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC2: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = inetCidrRouteMetric2_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC3: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = inetCidrRouteMetric3_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC4: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = inetCidrRouteMetric4_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC5: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = inetCidrRouteMetric5_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTESTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = inetCidrRouteStatus_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetCidrRouteTable_get_column\n", + column); + break; + } + + return rc; +} /* _inetCidrRouteTable_get_column */ + +int +_mfd_inetCidrRouteTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_get_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for (; requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if (NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = + sizeof(requests->requestvb->buf); + } else if (requests->requestvb->buf == + requests->requestvb->val.string) { + if (requests->requestvb->val_len != + sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = + sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _inetCidrRouteTable_get_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (rc) { + if (MFD_SKIP == rc) { + requests->requestvb->type = SNMP_NOSUCHINSTANCE; + rc = SNMP_ERR_NOERROR; + } + } else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if (rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if (old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if (dataFreeHook) + (*dataFreeHook) (old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_get_values */ + +NETSNMP_STATIC_INLINE int +_inetCidrRouteTable_check_indexes(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_check_indexes", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * (INDEX) inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + INETADDRESSTYPE_UNKNOWN) + && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + INETADDRESSTYPE_IPV4) + && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + INETADDRESSTYPE_IPV6) + && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + INETADDRESSTYPE_IPV4Z) + && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + INETADDRESSTYPE_IPV6Z) + && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != + INETADDRESSTYPE_DNS) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetCidrRouteDestType_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((rowreq_ctx->tbl_idx.inetCidrRouteDest_len < 0) + || (rowreq_ctx->tbl_idx.inetCidrRouteDest_len > 255)) + ) { + rc = SNMP_ERR_WRONGLENGTH; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetCidrRouteDest_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((rowreq_ctx->tbl_idx.inetCidrRoutePfxLen < 0) + || (rowreq_ctx->tbl_idx.inetCidrRoutePfxLen > 2040)) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetCidrRoutePfxLen_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + if (MFD_SUCCESS != rc) + return rc; + rc = inetCidrRoutePolicy_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != + INETADDRESSTYPE_UNKNOWN) + && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != + INETADDRESSTYPE_IPV4) + && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != + INETADDRESSTYPE_IPV6) + && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != + INETADDRESSTYPE_IPV4Z) + && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != + INETADDRESSTYPE_IPV6Z) + && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != + INETADDRESSTYPE_DNS) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetCidrRouteNextHopType_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len < 0) + || (rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len > 255)) + ) { + rc = SNMP_ERR_WRONGLENGTH; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetCidrRouteNextHop_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * if individual parts look ok, check them as a whole + */ + return inetCidrRouteTable_validate_index(inetCidrRouteTable_if_ctx. + user_ctx, rowreq_ctx); +} /* _inetCidrRouteTable_check_indexes */ + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/*---------------------------------------------------------------------- + * + * SET: Syntax checks + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check the syntax for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetCidrRouteTable_check_column(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_check_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + /* + * (INDEX) inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + case COLUMN_INETCIDRROUTEDESTTYPE: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + case COLUMN_INETCIDRROUTEDEST: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + case COLUMN_INETCIDRROUTEPFXLEN: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h + */ + case COLUMN_INETCIDRROUTEPOLICY: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + case COLUMN_INETCIDRROUTENEXTHOPTYPE: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + case COLUMN_INETCIDRROUTENEXTHOP: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + + /* + * inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_INETCIDRROUTEIFINDEX: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((*var->val.integer < 0) + || (*var->val.integer > 2147483647)) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteIfIndex", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteIfIndex_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteIfIndex_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTETYPE: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != INETCIDRROUTETYPE_OTHER) + && (*var->val.integer != INETCIDRROUTETYPE_REJECT) + && (*var->val.integer != INETCIDRROUTETYPE_LOCAL) + && (*var->val.integer != INETCIDRROUTETYPE_REMOTE) + && (*var->val.integer != INETCIDRROUTETYPE_BLACKHOLE) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteType", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteType_check_value(rowreq_ctx, + *((u_long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteType_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteProto(9)/IANAipRouteProtocol/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_INETCIDRROUTEPROTO: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * inetCidrRouteAge(10)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_INETCIDRROUTEAGE: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H + */ + case COLUMN_INETCIDRROUTENEXTHOPAS: + rc = netsnmp_check_vb_type(var, ASN_UNSIGNED); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteNextHopAS", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteNextHopAS_check_value(rowreq_ctx, + *((u_long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteNextHopAS_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC1: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric1", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteMetric1_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteMetric1_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC2: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric2", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteMetric2_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteMetric2_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC3: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric3", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteMetric3_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteMetric3_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC4: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric4", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteMetric4_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteMetric4_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC5: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric5", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteMetric5_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteMetric5_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTESTATUS: + rc = netsnmp_check_vb_rowstatus_value(var); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetCidrRouteStatus_check_value(rowreq_ctx, + *((u_long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from inetCidrRouteStatus_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + default: /** We shouldn't get here */ + rc = SNMP_ERR_GENERR; + snmp_log(LOG_ERR, + "unknown column %d in _inetCidrRouteTable_check_column\n", + column); + } + + return rc; +} /* _inetCidrRouteTable_check_column */ + +int +_mfd_inetCidrRouteTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_check_objects", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for (; requests; requests = requests->next) { + + /* + * get column number from table request info, and check that column + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _inetCidrRouteTable_check_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (rc) { + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + break; + } + + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_check_objects */ + + +/*---------------------------------------------------------------------- + * + * SET: check dependencies + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check dependencies wrapper + */ +static int +_mfd_inetCidrRouteTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_check_dependencies", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = inetCidrRouteTable_check_dependencies(rowreq_ctx); + if (rc) { + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_check_dependencies\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_check_dependencies */ + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetCidrRouteTable_undo_setup_column(inetCidrRouteTable_rowreq_ctx * + rowreq_ctx, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_undo_setup_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_INETCIDRROUTEIFINDEX: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEIFINDEX_FLAG; + break; + + /* + * inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTETYPE: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTETYPE_FLAG; + break; + + /* + * inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H + */ + case COLUMN_INETCIDRROUTENEXTHOPAS: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTENEXTHOPAS_FLAG; + break; + + /* + * inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC1: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC1_FLAG; + break; + + /* + * inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC2: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC2_FLAG; + break; + + /* + * inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC3: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC3_FLAG; + break; + + /* + * inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC4: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC4_FLAG; + break; + + /* + * inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC5: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC5_FLAG; + break; + + /* + * inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTESTATUS: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTESTATUS_FLAG; + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetCidrRouteTable_undo_setup_column\n", + column); + break; + } + + return rc; +} /* _inetCidrRouteTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_inetCidrRouteTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_setup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rowreq_ctx->undo = inetCidrRouteTable_allocate_data(); + if (NULL == rowreq_ctx->undo) { + /** msg already logged */ + netsnmp_request_set_error_all(requests, + SNMP_ERR_RESOURCEUNAVAILABLE); + return SNMP_ERR_NOERROR; + } + + /* + * row undo setup + */ + rowreq_ctx->column_set_flags = 0; + rc = inetCidrRouteTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_undo_setup\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } else { + /* + * column undo setup + */ + netsnmp_table_request_info *tri; + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _inetCidrRouteTable_undo_setup_column(rowreq_ctx, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_undo_setup_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_inetCidrRouteTable_undo_cleanup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_cleanup", "called\n")); + + /* + * failed row create in early stages has no rowreq_ctx + */ + if (NULL == rowreq_ctx) + return MFD_SUCCESS; + + /* + * call user cleanup + */ + rc = inetCidrRouteTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + if (rowreq_ctx->undo) { + inetCidrRouteTable_release_data(rowreq_ctx->undo); + rowreq_ctx->undo = NULL; + } + + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetCidrRouteTable_set_column(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_set_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_INETCIDRROUTEIFINDEX: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEIFINDEX_FLAG; + rc = inetCidrRouteIfIndex_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTETYPE: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTETYPE_FLAG; + rc = inetCidrRouteType_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H + */ + case COLUMN_INETCIDRROUTENEXTHOPAS: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTENEXTHOPAS_FLAG; + rc = inetCidrRouteNextHopAS_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC1: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC1_FLAG; + rc = inetCidrRouteMetric1_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC2: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC2_FLAG; + rc = inetCidrRouteMetric2_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC3: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC3_FLAG; + rc = inetCidrRouteMetric3_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC4: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC4_FLAG; + rc = inetCidrRouteMetric4_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_INETCIDRROUTEMETRIC5: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC5_FLAG; + rc = inetCidrRouteMetric5_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETCIDRROUTESTATUS: + rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTESTATUS_FLAG; + rc = inetCidrRouteStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetCidrRouteTable_set_column\n", + column); + rc = SNMP_ERR_GENERR; + break; + } + + return rc; +} /* _inetCidrRouteTable_set_column */ + +int +_mfd_inetCidrRouteTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_set_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rowreq_ctx->column_set_flags = 0; + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _inetCidrRouteTable_set_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_inetCidrRouteTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = inetCidrRouteTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_commit\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + /* + * if we successfully commited this row, set the dirty flag. Use the + * current value + 1 (i.e. dirty = # rows changed). + * this is checked in post_request... + */ + inetCidrRouteTable_dirty_set(inetCidrRouteTable_dirty_get() + 1); /* set table dirty flag */ + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_inetCidrRouteTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + u_int d = inetCidrRouteTable_dirty_get(); + + netsnmp_assert(d != 0); + if (d) + inetCidrRouteTable_dirty_set(d - 1); + } + + rc = inetCidrRouteTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_undo_commit\n", rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + snmp_log(LOG_WARNING, + "inetCidrRouteTable row dirty flag still set after undo_commit\n"); + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +int +_mfd_inetCidrRouteTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = inetCidrRouteTable_undo(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " + "inetCidrRouteTable_undo\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_undo_values */ + +/*---------------------------------------------------------------------- + * + * SET: irreversible commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit irreversible actions + */ +int +_mfd_inetCidrRouteTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_irreversible:commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * check for and handle row creation/deletion + * and update column exist flags... + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)) + CONTAINER_REMOVE(inetCidrRouteTable_if_ctx.container, rowreq_ctx); + } else { + if (rowreq_ctx->column_set_flags) { + rowreq_ctx->column_set_flags = 0; + } + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(inetCidrRouteTable_if_ctx.container, + rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetCidrRouteTable_irreversible_commit */ +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +static void _container_free(netsnmp_container *container); + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:inetCidrRouteTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for inetCidrRouteTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return inetCidrRouteTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:inetCidrRouteTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in inetCidrRouteTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:inetCidrRouteTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:inetCidrRouteTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in inetCidrRouteTable_container_free\n"); + return; + } + + /* + * call user code + */ + inetCidrRouteTable_container_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *) _container_item_free, + NULL); +} /* _container_free */ + +/** + * @internal + * initialize the container with functions or wrappers + */ +void +_inetCidrRouteTable_container_init(inetCidrRouteTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_container_init", "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(INETCIDRROUTETABLE_CACHE_TIMEOUT, + _cache_load, _cache_free, + inetCidrRouteTable_oid, + inetCidrRouteTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for ipCidrRouteTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + inetCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("inetCidrRouteTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "inetCidrRouteTable_container_init\n"); + return; + } + } + + if_ctx->container->container_name = strdup("inetCidrRouteTable"); + + /* set allow duplicates this makes insert O(1) */ + netsnmp_binary_array_options_set(if_ctx->container, 1, + CONTAINER_KEY_ALLOW_DUPLICATES); + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _inetCidrRouteTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_inetCidrRouteTable_container_shutdown(inetCidrRouteTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_container_shutdown", "called\n")); + + inetCidrRouteTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _inetCidrRouteTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_EXTERNAL_ACCESS +inetCidrRouteTable_rowreq_ctx * +inetCidrRouteTable_row_find_by_mib_index(inetCidrRouteTable_mib_index * + mib_idx) +{ + inetCidrRouteTable_rowreq_ctx *rowreq_ctx; + oid oid_tmp[MAX_OID_LEN]; + netsnmp_index oid_idx; + int rc; + + /* + * set up storage for OID + */ + oid_idx.oids = oid_tmp; + oid_idx.len = sizeof(oid_tmp) / sizeof(oid); + + /* + * convert + */ + rc = inetCidrRouteTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) + CONTAINER_FIND(inetCidrRouteTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_EXTERNAL_ACCESS */ diff --git a/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.h b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.h new file mode 100644 index 0000000..bda0757 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.h @@ -0,0 +1,102 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.67 $ of : mfd-interface.m2c,v $ + * + * $Id$ + */ +/** @ingroup interface Routines to interface to Net-SNMP + * + * \warning This code should not be modified, called directly, + * or used to interpret functionality. It is subject to + * change at any time. + * + * @{ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ +#ifndef INETCIDRROUTETABLE_INTERFACE_H +#define INETCIDRROUTETABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "inetCidrRouteTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _inetCidrRouteTable_initialize_interface + (inetCidrRouteTable_registration * user_ctx, u_long flags); + void + _inetCidrRouteTable_shutdown_interface + (inetCidrRouteTable_registration * user_ctx); + + inetCidrRouteTable_registration + * inetCidrRouteTable_registration_set + (inetCidrRouteTable_registration * newreg); + + netsnmp_container *inetCidrRouteTable_container_get(void); + int inetCidrRouteTable_container_size(void); + + u_int inetCidrRouteTable_dirty_get(void); + void inetCidrRouteTable_dirty_set(u_int status); + + netsnmp_cache *inetCidrRouteTable_get_cache(void); + + inetCidrRouteTable_rowreq_ctx + * inetCidrRouteTable_allocate_rowreq_ctx(inetCidrRouteTable_data *, + void *); + void + inetCidrRouteTable_release_rowreq_ctx(inetCidrRouteTable_rowreq_ctx + * rowreq_ctx); + + int inetCidrRouteTable_index_to_oid(netsnmp_index * + oid_idx, + inetCidrRouteTable_mib_index + * mib_idx); + int inetCidrRouteTable_index_from_oid(netsnmp_index * + oid_idx, + inetCidrRouteTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + inetCidrRouteTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* INETCIDRROUTETABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable.h b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable.h new file mode 100644 index 0000000..0214caf --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable) diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.c b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.c new file mode 100644 index 0000000..323c1bc --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.c @@ -0,0 +1,3361 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for ipCidrRouteTable + * + * \section intro Introduction + * Introductory text. + * + */ +/* + * standard Net-SNMP includes + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "ipCidrRouteTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipCidrRouteTable_interface.h" + +const oid ipCidrRouteTable_oid[] = { IPCIDRROUTETABLE_OID }; +const int ipCidrRouteTable_oid_size = +OID_LENGTH(ipCidrRouteTable_oid); + +ipCidrRouteTable_registration ipCidrRouteTable_user_context; +static ipCidrRouteTable_registration *ipCidrRouteTable_user_context_p; + +void initialize_table_ipCidrRouteTable(void); +void shutdown_table_ipCidrRouteTable(void); + + +/** + * Initializes the ipCidrRouteTable module + */ +void +init_ipCidrRouteTable(void) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:init_ipCidrRouteTable", + "called\n")); + + /* + * TODO:300:o: Perform ipCidrRouteTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipCidrRouteTable")) + initialize_table_ipCidrRouteTable(); + +} /* init_ipCidrRouteTable */ + +/** + * Shut-down the ipCidrRouteTable module (agent is exiting) + */ +void +shutdown_ipCidrRouteTable(void) +{ + if (should_init("ipCidrRouteTable")) + shutdown_table_ipCidrRouteTable(); + +} + +/** + * Initialize the table ipCidrRouteTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipCidrRouteTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:initialize_table_ipCidrRouteTable", "called\n")); + + /* + * TODO:301:o: Perform ipCidrRouteTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipCidrRouteTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + ipCidrRouteTable_user_context_p + = netsnmp_create_data_list("ipCidrRouteTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipCidrRouteTable_initialize_interface + (ipCidrRouteTable_user_context_p, flags); +} /* initialize_table_ipCidrRouteTable */ + +/** + * Shutdown the table ipCidrRouteTable + */ +void +shutdown_table_ipCidrRouteTable(void) +{ + /* + * call interface shutdown code + */ + _ipCidrRouteTable_shutdown_interface(ipCidrRouteTable_user_context_p); + netsnmp_free_all_list_data(ipCidrRouteTable_user_context_p); + ipCidrRouteTable_user_context_p = NULL; +} + +/** + * extra context initialization (eg default values) + * + * @param rowreq_ctx : row request context + * @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) + * + * @retval MFD_SUCCESS : no errors + * @retval MFD_ERROR : error (context allocate will fail) + */ +int +ipCidrRouteTable_rowreq_ctx_init(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipCidrRouteTable rowreq initialization. (eg DEFVALS) + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipCidrRouteTable_rowreq_ctx_cleanup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipCidrRouteTable rowreq cleanup. + */ + if (NULL != rowreq_ctx->data) { + ipCidrRouteTable_release_data(rowreq_ctx->data); + rowreq_ctx->data = NULL; + } +} /* ipCidrRouteTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * @param user_context + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipCidrRouteTable_pre_request(ipCidrRouteTable_registration * user_context) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_pre_request", + "called\n")); + + /* + * TODO:510:o: Perform ipCidrRouteTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipCidrRouteTable_pre_request */ + +/** + * post-request callback + * + * Note: + * New rows have been inserted into the container, and + * deleted rows have been removed from the container and + * released. + * @param user_context + * @param rc : MFD_SUCCESS if all requests succeeded + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +ipCidrRouteTable_post_request(ipCidrRouteTable_registration * user_context, + int rc) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_post_request", + "called\n")); + + /* + * TODO:511:o: Perform ipCidrRouteTable post-request actions. + */ + + /* + * check to set if any rows were changed. + */ + if (ipCidrRouteTable_dirty_get()) { + /* + * check if request was successful. If so, this would be + * a good place to save data to its persistent store. + */ + if (MFD_SUCCESS == rc) { + /* + * save changed rows, if you haven't already + */ + } + + ipCidrRouteTable_dirty_set(0); /* clear table dirty flag */ + } + + return MFD_SUCCESS; +} /* ipCidrRouteTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipCidrRouteTable data context functions. + */ +/* + * ipCidrRouteTable_allocate_data + * + * Purpose: create new ipCidrRouteTable_data. + */ +ipCidrRouteTable_data * +ipCidrRouteTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the ipCidrRouteTable data context. + */ + ipCidrRouteTable_data *rtn = netsnmp_access_route_entry_create(); + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_allocate_data", + "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipCidrRouteTable_data.\n"); + } + + return rtn; +} /* ipCidrRouteTable_allocate_data */ + +/* + * ipCidrRouteTable_release_data + * + * Purpose: release ipCidrRouteTable data. + */ +void +ipCidrRouteTable_release_data(ipCidrRouteTable_data * data) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_release_data", + "called\n")); + + /* + * TODO:202:r: |-> release memory for the ipCidrRouteTable data context. + */ + netsnmp_access_route_entry_free(data); +} /* ipCidrRouteTable_release_data */ + + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipCidrRouteDest_val + * @param ipCidrRouteMask_val + * @param ipCidrRouteTos_val + * @param ipCidrRouteNextHop_val + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +ipCidrRouteTable_indexes_set_tbl_idx(ipCidrRouteTable_mib_index * tbl_idx, + u_long ipCidrRouteDest_val, + u_long ipCidrRouteMask_val, + long ipCidrRouteTos_val, + u_long ipCidrRouteNextHop_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + tbl_idx->ipCidrRouteDest = ipCidrRouteDest_val; + + /* + * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + tbl_idx->ipCidrRouteMask = ipCidrRouteMask_val; + + /* + * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + tbl_idx->ipCidrRouteTos = ipCidrRouteTos_val; + + /* + * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + tbl_idx->ipCidrRouteNextHop = ipCidrRouteNextHop_val; + + + return MFD_SUCCESS; +} /* ipCidrRouteTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +ipCidrRouteTable_indexes_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long ipCidrRouteDest_val, + u_long ipCidrRouteMask_val, + long ipCidrRouteTos_val, + u_long ipCidrRouteNextHop_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_indexes_set", + "called\n")); + + if (MFD_SUCCESS != + ipCidrRouteTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipCidrRouteDest_val, + ipCidrRouteMask_val, + ipCidrRouteTos_val, + ipCidrRouteNextHop_val)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != ipCidrRouteTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipCidrRouteTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteIfIndex + * ipCidrRouteIfIndex is subid 5 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.5 + * Description: +The ifIndex value which identifies the local interface + + + through which the next hop of this route should be + reached. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: 0 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteIfIndex data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteIfIndex_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteIfIndex_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteIfIndex_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteIfIndex_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteIfIndex_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteIfIndex data. + * copy (* ipCidrRouteIfIndex_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteIfIndex_val_ptr) = rowreq_ctx->data->if_index; + + return MFD_SUCCESS; +} /* ipCidrRouteIfIndex_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteType + * ipCidrRouteType is subid 6 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.6 + * Description: +The type of route. Note that local(3) refers to a + route for which the next hop is the final destination; + remote(4) refers to a route for which the next hop is + not the final destination. + + Routes which do not result in traffic forwarding or + rejection should not be displayed even if the + implementation keeps them stored internally. + + reject (2) refers to a route which, if matched, + discards the message as unreachable. This is used in + some protocols as a means of correctly aggregating + routes. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: other(1), reject(2), local(3), remote(4) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Extract the current value of the ipCidrRouteType data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteType_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteType_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * ipCidrRouteType_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteType_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteType_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteType data. + * copy (* ipCidrRouteType_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteType_val_ptr) = rowreq_ctx->data->rt_type; + + return MFD_SUCCESS; +} /* ipCidrRouteType_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteProto + * ipCidrRouteProto is subid 7 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.4.1.7 + * Description: +The routing mechanism via which this route was learned. + Inclusion of values for gateway routing protocols is + not intended to imply that hosts should support those + protocols. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 11/16. Values: other(1), local(2), netmgmt(3), icmp(4), egp(5), ggp(6), hello(7), rip(8), isIs(9), esIs(10), ciscoIgrp(11), bbnSpfIgp(12), ospf(13), bgp(14), idpr(15), ciscoEigrp(16) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Extract the current value of the ipCidrRouteProto data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteProto_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteProto_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * ipCidrRouteProto_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteProto_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteProto_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteProto data. + * copy (* ipCidrRouteProto_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteProto_val_ptr) = rowreq_ctx->data->rt_proto; + + return MFD_SUCCESS; +} /* ipCidrRouteProto_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteAge + * ipCidrRouteAge is subid 8 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.4.1.8 + * Description: +The number of seconds since this route was last updated + or otherwise determined to be correct. Note that no + semantics of `too old' can be implied except through + knowledge of the routing protocol by which the route + was learned. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * defval: 0 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteAge data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteAge_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteAge_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteAge_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteAge_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteAge_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteAge data. + * copy (* ipCidrRouteAge_val_ptr ) from rowreq_ctx->data + */ + /* + * TODO:235:M: |-> Remove log message/SKIP once you've set ipCidrRouteAge data + */ + return MFD_SKIP; + + return MFD_SUCCESS; +} /* ipCidrRouteAge_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteInfo + * ipCidrRouteInfo is subid 9 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.9 + * Description: +A reference to MIB definitions specific to the + particular routing protocol which is responsible for + this route, as determined by the value specified in the + route's ipCidrRouteProto value. If this information is + not present, its value should be set to the OBJECT + IDENTIFIER { 0 0 }, which is a syntactically valid + object identifier, and any implementation conforming to + ASN.1 and the Basic Encoding Rules must be able to + generate and recognize this value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * + * Its syntax is OBJECTID (based on perltype OBJECTID) + * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) + * This data type requires a length. (Max ) + */ +/** + * Extract the current value of the ipCidrRouteInfo data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteInfo_val_ptr_ptr + * Pointer to storage for a oid variable + * @param ipCidrRouteInfo_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by ipCidrRouteInfo. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*ipCidrRouteInfo_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update ipCidrRouteInfo_val_ptr_ptr. + * <b>DO NOT</b> free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +ipCidrRouteInfo_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + oid ** ipCidrRouteInfo_val_ptr_ptr, + size_t * ipCidrRouteInfo_val_ptr_len_ptr) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert((NULL != ipCidrRouteInfo_val_ptr_ptr) + && (NULL != *ipCidrRouteInfo_val_ptr_ptr)); + netsnmp_assert(NULL != ipCidrRouteInfo_val_ptr_len_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteInfo_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteInfo data. + * copy (* ipCidrRouteInfo_val_ptr_ptr ) data and (* ipCidrRouteInfo_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /** nullOidLen is in bytes, so not sizeof(oid) needed */ + if ((*ipCidrRouteInfo_val_ptr_len_ptr) < (size_t)nullOidLen) { + (*ipCidrRouteInfo_val_ptr_ptr) = (oid*)malloc(nullOidLen); + if (NULL == (*ipCidrRouteInfo_val_ptr_ptr)) + return MFD_ERROR; + } + (*ipCidrRouteInfo_val_ptr_len_ptr) = (size_t)nullOidLen; + memcpy((*ipCidrRouteInfo_val_ptr_ptr), nullOid, (size_t)nullOidLen); + + return MFD_SUCCESS; +} /* ipCidrRouteInfo_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteNextHopAS + * ipCidrRouteNextHopAS is subid 10 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.10 + * Description: +The Autonomous System Number of the Next Hop. The + semantics of this object are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. When this object is unknown or not relevant its + value should be set to zero. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: 0 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteNextHopAS data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteNextHopAS_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteNextHopAS_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteNextHopAS_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteNextHopAS_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteNextHopAS_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteNextHopAS data. + * copy (* ipCidrRouteNextHopAS_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteNextHopAS_val_ptr) = rowreq_ctx->data->rt_nexthop_as; + + return MFD_SUCCESS; +} /* ipCidrRouteNextHopAS_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric1 + * ipCidrRouteMetric1 is subid 11 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.11 + * Description: +The primary routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteMetric1 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric1_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteMetric1_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteMetric1_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteMetric1_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric1_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteMetric1 data. + * copy (* ipCidrRouteMetric1_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteMetric1_val_ptr) = rowreq_ctx->data->rt_metric1; + + return MFD_SUCCESS; +} /* ipCidrRouteMetric1_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric2 + * ipCidrRouteMetric2 is subid 12 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.12 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteMetric2 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric2_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteMetric2_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteMetric2_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteMetric2_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric2_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteMetric2 data. + * copy (* ipCidrRouteMetric2_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteMetric2_val_ptr) = rowreq_ctx->data->rt_metric2; + + return MFD_SUCCESS; +} /* ipCidrRouteMetric2_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric3 + * ipCidrRouteMetric3 is subid 13 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.13 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteMetric3 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric3_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteMetric3_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteMetric3_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteMetric3_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric3_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteMetric3 data. + * copy (* ipCidrRouteMetric3_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteMetric3_val_ptr) = rowreq_ctx->data->rt_metric3; + + return MFD_SUCCESS; +} /* ipCidrRouteMetric3_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric4 + * ipCidrRouteMetric4 is subid 14 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.14 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteMetric4 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric4_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteMetric4_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteMetric4_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteMetric4_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric4_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteMetric4 data. + * copy (* ipCidrRouteMetric4_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteMetric4_val_ptr) = rowreq_ctx->data->rt_metric4; + + return MFD_SUCCESS; +} /* ipCidrRouteMetric4_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric5 + * ipCidrRouteMetric5 is subid 15 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.15 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + + + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipCidrRouteMetric5 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric5_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteMetric5_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long *ipCidrRouteMetric5_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteMetric5_val_ptr); + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric5_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipCidrRouteMetric5 data. + * copy (* ipCidrRouteMetric5_val_ptr ) from rowreq_ctx->data + */ + (*ipCidrRouteMetric5_val_ptr) = rowreq_ctx->data->rt_metric5; + + return MFD_SUCCESS; +} /* ipCidrRouteMetric5_get */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteStatus + * ipCidrRouteStatus is subid 16 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.16 + * Description: +The row status variable, used according to row + installation and removal conventions. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) + * + * Its syntax is RowStatus (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Extract the current value of the ipCidrRouteStatus data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteStatus_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipCidrRouteStatus_get(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long * ipCidrRouteStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipCidrRouteStatus_val_ptr); + + (*ipCidrRouteStatus_val_ptr) = rowreq_ctx->ipCidrRouteStatus; + + return MFD_SUCCESS; +} /* ipCidrRouteStatus_get */ + + + +/** @} */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + /* + * NOTE: if you update this chart, please update the versions in + * local/mib2c-conf.d/parent-set.m2i + * agent/mibgroup/helpers/baby_steps.c + * while you're at it. + */ + /* + *********************************************************************** + * Baby Steps Flow Chart (2004.06.05) * + * * + * +--------------+ +================+ U = unconditional path * + * |optional state| ||required state|| S = path for success * + * +--------------+ +================+ E = path for error * + *********************************************************************** + * + * +--------------+ + * | pre | + * | request | + * +--------------+ + * | U + * +-------------+ +==============+ + * | row |f|<-------|| object || + * | create |1| E || lookup || + * +-------------+ +==============+ + * E | | S | S + * | +------------------>| + * | +==============+ + * | E || check || + * |<---------------|| values || + * | +==============+ + * | | S + * | +==============+ + * | +<-------|| undo || + * | | E || setup || + * | | +==============+ + * | | | S + * | | +==============+ + * | | || set ||-------------------------->+ + * | | || value || E | + * | | +==============+ | + * | | | S | + * | | +--------------+ | + * | | | check |-------------------------->| + * | | | consistency | E | + * | | +--------------+ | + * | | | S | + * | | +==============+ +==============+ | + * | | || commit ||-------->|| undo || | + * | | || || E || commit || | + * | | +==============+ +==============+ | + * | | | S U |<--------+ + * | | +--------------+ +==============+ + * | | | irreversible | || undo || + * | | | commit | || set || + * | | +--------------+ +==============+ + * | | | U U | + * | +-------------->|<------------------------+ + * | +==============+ + * | || undo || + * | || cleanup || + * | +==============+ + * +---------------------->| U + * | + * (err && f1)------------------->+ + * | | + * +--------------+ +--------------+ + * | post |<--------| row | + * | request | U | release | + * +--------------+ +--------------+ + * + */ + +/** + * Setup up context with information needed to undo a set request. + * + * This function will be called before the individual node undo setup + * functions are called. If you need to do any undo setup that is not + * related to a specific column, you can do it here. + * + * Note that the undo context has been allocated with + * ipCidrRouteTable_allocate_data(), but may need extra + * initialization similar to what you may have done in + * ipCidrRouteTable_rowreq_ctx_init(). + * Note that an individual node's undo_setup function will only be called + * if that node is being set to a new value. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in the node's undo_setup + * function, so it won't be done unless it is necessary. + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipCidrRouteTable_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo_setup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> Setup ipCidrRouteTable undo. + * set up ipCidrRouteTable undo information, in preparation for a set. + * Undo storage is in (* ipCidrRouteStatus_val_ptr )* + */ + + return rc; +} /* ipCidrRouteTable_undo_setup */ + +/** + * Undo a set request. + * + * This function will be called before the individual node undo + * functions are called. If you need to do any undo that is not + * related to a specific column, you can do it here. + * + * Note that an individual node's undo function will only be called + * if that node is being set to a new value. + * + * If there is anything specific to a particular column (e.g. releasing + * memory for a string), you should do that setup in the node's undo + * function, so it won't be done unless it is necessary. + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipCidrRouteTable_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> ipCidrRouteTable undo. + * ipCidrRouteTable undo information, in response to a failed set. + * Undo storage is in (* ipCidrRouteStatus_val_ptr )* + */ + + return rc; +} /* ipCidrRouteTable_undo_setup */ + +/** + * Cleanup up context undo information. + * + * This function will be called after set/commit processing. If you + * allocated any resources in undo_setup, this is the place to release + * those resources. + * + * This function is called regardless of the success or failure of the set + * request. If you need to perform different steps for cleanup depending + * on success or failure, you can add a flag to the rowreq_ctx. + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +ipCidrRouteTable_undo_cleanup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo_cleanup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:452:M: |-> Cleanup ipCidrRouteTable undo. + * Undo storage is in (* ipCidrRouteStatus_val_ptr )* + */ + + return rc; +} /* ipCidrRouteTable_undo_cleanup */ + +/** + * commit new values. + * + * At this point, you should have done everything you can to ensure that + * this commit will not fail. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the COLUMN_*_FLAG bits can be found in + * ipCidrRouteTable.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rowreq_ctx + * Pointer to the users context. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +ipCidrRouteTable_commit(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + int save_flags; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_commit", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * save flags, then clear until we actually do something + */ + save_flags = rowreq_ctx->column_set_flags; + rowreq_ctx->column_set_flags = 0; + + /* + * commit ipCidrRouteTable data + * 1) check the column's flag in save_flags to see if it was set. + * 2) clear the flag when you handle that column + * 3) set the column's flag in column_set_flags if it needs undo + * processing in case of a failure. + */ + if (save_flags & COLUMN_IPCIDRROUTEIFINDEX_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEIFINDEX_FLAG; /* clear ipCidrRouteIfIndex */ + /* + * TODO:482:o: |-> commit column ipCidrRouteIfIndex. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteIfIndex commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteIfIndex + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEIFINDEX_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTETYPE_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTETYPE_FLAG; /* clear ipCidrRouteType */ + /* + * TODO:482:o: |-> commit column ipCidrRouteType. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteType commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteType + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTETYPE_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTEINFO_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEINFO_FLAG; /* clear ipCidrRouteInfo */ + /* + * TODO:482:o: |-> commit column ipCidrRouteInfo. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteInfo commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteInfo + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEINFO_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTENEXTHOPAS_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTENEXTHOPAS_FLAG; /* clear ipCidrRouteNextHopAS */ + /* + * TODO:482:o: |-> commit column ipCidrRouteNextHopAS. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteNextHopAS commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteNextHopAS + */ + rowreq_ctx->column_set_flags |= + COLUMN_IPCIDRROUTENEXTHOPAS_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTEMETRIC1_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEMETRIC1_FLAG; /* clear ipCidrRouteMetric1 */ + /* + * TODO:482:o: |-> commit column ipCidrRouteMetric1. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteMetric1 commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteMetric1 + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC1_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTEMETRIC2_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEMETRIC2_FLAG; /* clear ipCidrRouteMetric2 */ + /* + * TODO:482:o: |-> commit column ipCidrRouteMetric2. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteMetric2 commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteMetric2 + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC2_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTEMETRIC3_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEMETRIC3_FLAG; /* clear ipCidrRouteMetric3 */ + /* + * TODO:482:o: |-> commit column ipCidrRouteMetric3. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteMetric3 commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteMetric3 + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC3_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTEMETRIC4_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEMETRIC4_FLAG; /* clear ipCidrRouteMetric4 */ + /* + * TODO:482:o: |-> commit column ipCidrRouteMetric4. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteMetric4 commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteMetric4 + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC4_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTEMETRIC5_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTEMETRIC5_FLAG; /* clear ipCidrRouteMetric5 */ + /* + * TODO:482:o: |-> commit column ipCidrRouteMetric5. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteMetric5 commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteMetric5 + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC5_FLAG; + } + } + + if (save_flags & COLUMN_IPCIDRROUTESTATUS_FLAG) { + save_flags &= ~COLUMN_IPCIDRROUTESTATUS_FLAG; /* clear ipCidrRouteStatus */ + /* + * TODO:482:o: |-> commit column ipCidrRouteStatus. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipCidrRouteTable column ipCidrRouteStatus commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipCidrRouteStatus + */ + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTESTATUS_FLAG; + } + } + + /* + * if we successfully commited this row, set the dirty flag. + */ + if (MFD_SUCCESS == rc) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; + } + + if (save_flags) { + snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", + save_flags); + return MFD_ERROR; + } + + return rc; +} /* ipCidrRouteTable_commit */ + +/** + * undo commit new values. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the COLUMN_*_FLAG bits can be found in + * ipCidrRouteTable.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rowreq_ctx + * Pointer to the users context. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +ipCidrRouteTable_undo_commit(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo_commit", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:485:M: |-> Undo ipCidrRouteTable commit. + * check the column's flag in rowreq_ctx->column_set_flags to see + * if it was set during commit, then undo it. + * + * eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {} + */ + + + /* + * if we successfully un-commited this row, clear the dirty flag. + */ + if (MFD_SUCCESS == rc) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return rc; +} /* ipCidrRouteTable_undo_commit */ + +/* + * TODO:440:M: Implement ipCidrRouteTable node value checks. + * TODO:450:M: Implement ipCidrRouteTable undo functions. + * TODO:460:M: Implement ipCidrRouteTable set functions. + * TODO:480:M: Implement ipCidrRouteTable commit functions. + */ +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteIfIndex + * ipCidrRouteIfIndex is subid 5 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.5 + * Description: +The ifIndex value which identifies the local interface + + + through which the next hop of this route should be + reached. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: 0 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteIfIndex_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteIfIndex_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteIfIndex_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteIfIndex value. + */ + + return MFD_SUCCESS; /* ipCidrRouteIfIndex value not illegal */ +} /* ipCidrRouteIfIndex_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteIfIndex_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteIfIndex_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteIfIndex undo. + */ + /* + * copy ipCidrRouteIfIndex data + * set rowreq_ctx->undo->ipCidrRouteIfIndex from rowreq_ctx->data->ipCidrRouteIfIndex + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteIfIndex_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteIfIndex_val + * A long containing the new value. + */ +int +ipCidrRouteIfIndex_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteIfIndex_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteIfIndex_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteIfIndex value. + * set ipCidrRouteIfIndex value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteIfIndex_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteIfIndex_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteIfIndex_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteIfIndex undo. + */ + /* + * copy ipCidrRouteIfIndex data + * set rowreq_ctx->data->ipCidrRouteIfIndex from rowreq_ctx->undo->ipCidrRouteIfIndex + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteIfIndex_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteType + * ipCidrRouteType is subid 6 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.6 + * Description: +The type of route. Note that local(3) refers to a + route for which the next hop is the final destination; + remote(4) refers to a route for which the next hop is + not the final destination. + + Routes which do not result in traffic forwarding or + rejection should not be displayed even if the + implementation keeps them stored internally. + + reject (2) refers to a route which, if matched, + discards the message as unreachable. This is used in + some protocols as a means of correctly aggregating + routes. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: other(1), reject(2), local(3), remote(4) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteType_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of other(1), reject(2), local(3), remote(4) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteType_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long ipCidrRouteType_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteType_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteType value. + */ + + return MFD_SUCCESS; /* ipCidrRouteType value not illegal */ +} /* ipCidrRouteType_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteType_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteType_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteType undo. + */ + /* + * copy ipCidrRouteType data + * set rowreq_ctx->undo->ipCidrRouteType from rowreq_ctx->data->ipCidrRouteType + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteType_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteType_val + * A long containing the new value. + */ +int +ipCidrRouteType_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long ipCidrRouteType_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteType_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteType value. + * set ipCidrRouteType value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteType_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteType_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteType_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteType undo. + */ + /* + * copy ipCidrRouteType data + * set rowreq_ctx->data->ipCidrRouteType from rowreq_ctx->undo->ipCidrRouteType + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteType_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteInfo + * ipCidrRouteInfo is subid 9 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.9 + * Description: +A reference to MIB definitions specific to the + particular routing protocol which is responsible for + this route, as determined by the value specified in the + route's ipCidrRouteProto value. If this information is + not present, its value should be set to the OBJECT + IDENTIFIER { 0 0 }, which is a syntactically valid + object identifier, and any implementation conforming to + ASN.1 and the Basic Encoding Rules must be able to + generate and recognize this value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * + * Its syntax is OBJECTID (based on perltype OBJECTID) + * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) + * This data type requires a length. (Max ) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteInfo_val_ptr + * A oid containing the new value. + * @param ipCidrRouteInfo_val_ptr_len + * The size (in bytes) of the data pointed to by ipCidrRouteInfo_val_ptr + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * Since you aren't using a generated data context, you also need to + * check the length, to make sure you don't overflow your storage space. + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_OBJECT_ID + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteInfo_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + oid * ipCidrRouteInfo_val_ptr, + size_t ipCidrRouteInfo_val_ptr_len) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteInfo_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + netsnmp_assert(NULL != ipCidrRouteInfo_val_ptr); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteInfo value. + */ + + return MFD_SUCCESS; /* ipCidrRouteInfo value not illegal */ +} /* ipCidrRouteInfo_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteInfo_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteInfo_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteInfo undo. + */ + /* + * copy ipCidrRouteInfo and ipCidrRouteInfo_len data + * set rowreq_ctx->undo->ipCidrRouteInfo from rowreq_ctx->data->ipCidrRouteInfo + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteInfo_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteInfo_val_ptr + * A oid containing the new value. + * @param ipCidrRouteInfo_val_ptr_len + * The size (in bytes) of the data pointed to by ipCidrRouteInfo_val_ptr + */ +int +ipCidrRouteInfo_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + oid * ipCidrRouteInfo_val_ptr, + size_t ipCidrRouteInfo_val_ptr_len) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteInfo_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + netsnmp_assert(NULL != ipCidrRouteInfo_val_ptr); + + /* + * TODO:461:M: |-> Set ipCidrRouteInfo value. + * set ipCidrRouteInfo value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteInfo_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteInfo_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteInfo_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteInfo undo. + */ + /* + * copy ipCidrRouteInfo and ipCidrRouteInfo_len data + * set rowreq_ctx->data->ipCidrRouteInfo from rowreq_ctx->undo->ipCidrRouteInfo + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteInfo_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteNextHopAS + * ipCidrRouteNextHopAS is subid 10 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.10 + * Description: +The Autonomous System Number of the Next Hop. The + semantics of this object are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. When this object is unknown or not relevant its + value should be set to zero. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: 0 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteNextHopAS_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteNextHopAS_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteNextHopAS_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteNextHopAS_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteNextHopAS value. + */ + + return MFD_SUCCESS; /* ipCidrRouteNextHopAS value not illegal */ +} /* ipCidrRouteNextHopAS_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteNextHopAS_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteNextHopAS_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteNextHopAS undo. + */ + /* + * copy ipCidrRouteNextHopAS data + * set rowreq_ctx->undo->ipCidrRouteNextHopAS from rowreq_ctx->data->ipCidrRouteNextHopAS + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteNextHopAS_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteNextHopAS_val + * A long containing the new value. + */ +int +ipCidrRouteNextHopAS_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteNextHopAS_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteNextHopAS_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteNextHopAS value. + * set ipCidrRouteNextHopAS value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteNextHopAS_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteNextHopAS_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteNextHopAS_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteNextHopAS undo. + */ + /* + * copy ipCidrRouteNextHopAS data + * set rowreq_ctx->data->ipCidrRouteNextHopAS from rowreq_ctx->undo->ipCidrRouteNextHopAS + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteNextHopAS_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric1 + * ipCidrRouteMetric1 is subid 11 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.11 + * Description: +The primary routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric1_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteMetric1_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric1_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric1_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteMetric1 value. + */ + + return MFD_SUCCESS; /* ipCidrRouteMetric1 value not illegal */ +} /* ipCidrRouteMetric1_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteMetric1_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric1_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteMetric1 undo. + */ + /* + * copy ipCidrRouteMetric1 data + * set rowreq_ctx->undo->ipCidrRouteMetric1 from rowreq_ctx->data->ipCidrRouteMetric1 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric1_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteMetric1_val + * A long containing the new value. + */ +int +ipCidrRouteMetric1_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric1_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric1_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteMetric1 value. + * set ipCidrRouteMetric1 value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteMetric1_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteMetric1_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric1_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteMetric1 undo. + */ + /* + * copy ipCidrRouteMetric1 data + * set rowreq_ctx->data->ipCidrRouteMetric1 from rowreq_ctx->undo->ipCidrRouteMetric1 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric1_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric2 + * ipCidrRouteMetric2 is subid 12 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.12 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric2_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteMetric2_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric2_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric2_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteMetric2 value. + */ + /* + * does any os use metric 2-5? if so, update to deal with it. + * otherwise, only accept same value we have. + */ + if (ipCidrRouteMetric2_val != rowreq_ctx->data->rt_metric2) + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipCidrRouteMetric2 value not illegal */ +} /* ipCidrRouteMetric2_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteMetric2_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric2_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteMetric2 undo. + */ + /* + * copy ipCidrRouteMetric2 data + * set rowreq_ctx->undo->ipCidrRouteMetric2 from rowreq_ctx->data->ipCidrRouteMetric2 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric2_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteMetric2_val + * A long containing the new value. + */ +int +ipCidrRouteMetric2_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric2_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric2_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteMetric2 value. + * set ipCidrRouteMetric2 value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteMetric2_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteMetric2_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric2_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteMetric2 undo. + */ + /* + * copy ipCidrRouteMetric2 data + * set rowreq_ctx->data->ipCidrRouteMetric2 from rowreq_ctx->undo->ipCidrRouteMetric2 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric2_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric3 + * ipCidrRouteMetric3 is subid 13 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.13 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric3_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteMetric3_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric3_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric3_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteMetric3 value. + */ + /* + * does any os use metric 2-5? if so, update to deal with it. + * otherwise, only accept same value we have. + */ + if (ipCidrRouteMetric3_val != rowreq_ctx->data->rt_metric3) + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipCidrRouteMetric3 value not illegal */ +} /* ipCidrRouteMetric3_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteMetric3_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric3_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteMetric3 undo. + */ + /* + * copy ipCidrRouteMetric3 data + * set rowreq_ctx->undo->ipCidrRouteMetric3 from rowreq_ctx->data->ipCidrRouteMetric3 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric3_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteMetric3_val + * A long containing the new value. + */ +int +ipCidrRouteMetric3_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric3_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric3_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteMetric3 value. + * set ipCidrRouteMetric3 value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteMetric3_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteMetric3_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric3_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteMetric3 undo. + */ + /* + * copy ipCidrRouteMetric3 data + * set rowreq_ctx->data->ipCidrRouteMetric3 from rowreq_ctx->undo->ipCidrRouteMetric3 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric3_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric4 + * ipCidrRouteMetric4 is subid 14 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.14 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric4_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteMetric4_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric4_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric4_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteMetric4 value. + */ + /* + * does any os use metric 2-5? if so, update to deal with it. + * otherwise, only accept same value we have. + */ + if (ipCidrRouteMetric4_val != rowreq_ctx->data->rt_metric4) + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipCidrRouteMetric4 value not illegal */ +} /* ipCidrRouteMetric4_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteMetric4_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric4_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteMetric4 undo. + */ + /* + * copy ipCidrRouteMetric4 data + * set rowreq_ctx->undo->ipCidrRouteMetric4 from rowreq_ctx->data->ipCidrRouteMetric4 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric4_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteMetric4_val + * A long containing the new value. + */ +int +ipCidrRouteMetric4_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric4_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric4_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteMetric4 value. + * set ipCidrRouteMetric4 value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteMetric4_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteMetric4_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric4_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteMetric4 undo. + */ + /* + * copy ipCidrRouteMetric4 data + * set rowreq_ctx->data->ipCidrRouteMetric4 from rowreq_ctx->undo->ipCidrRouteMetric4 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric4_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMetric5 + * ipCidrRouteMetric5 is subid 15 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.15 + * Description: +An alternate routing metric for this route. The + semantics of this metric are determined by the routing- + + + protocol specified in the route's ipCidrRouteProto + value. If this metric is not used, its value should be + set to -1. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: -1 + * + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteMetric5_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteMetric5_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric5_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric5_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteMetric5 value. + */ + /* + * does any os use metric 2-5? if so, update to deal with it. + * otherwise, only accept same value we have. + */ + if (ipCidrRouteMetric5_val != rowreq_ctx->data->rt_metric5) + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipCidrRouteMetric5 value not illegal */ +} /* ipCidrRouteMetric5_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteMetric5_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric5_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteMetric5 undo. + */ + /* + * copy ipCidrRouteMetric5 data + * set rowreq_ctx->undo->ipCidrRouteMetric5 from rowreq_ctx->data->ipCidrRouteMetric5 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric5_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteMetric5_val + * A long containing the new value. + */ +int +ipCidrRouteMetric5_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + long ipCidrRouteMetric5_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric5_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteMetric5 value. + * set ipCidrRouteMetric5 value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteMetric5_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteMetric5_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMetric5_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteMetric5 undo. + */ + /* + * copy ipCidrRouteMetric5 data + * set rowreq_ctx->data->ipCidrRouteMetric5 from rowreq_ctx->undo->ipCidrRouteMetric5 + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteMetric5_undo */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteStatus + * ipCidrRouteStatus is subid 16 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is Create. + * OID: .1.3.6.1.2.1.4.24.4.1.16 + * Description: +The row status variable, used according to row + installation and removal conventions. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 3/8. Values: active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) + * + * Its syntax is RowStatus (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipCidrRouteStatus_val + * A long containing the new value. + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * ipCidrRouteTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipCidrRouteStatus_check_value(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long ipCidrRouteStatus_val) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteStatus_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipCidrRouteStatus value. + */ + + return MFD_SUCCESS; /* ipCidrRouteStatus value not illegal */ +} /* ipCidrRouteStatus_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * ipCidrRouteTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +ipCidrRouteStatus_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteStatus_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipCidrRouteStatus undo. + */ + /* + * copy ipCidrRouteStatus data + * set rowreq_ctx->undo->ipCidrRouteStatus from rowreq_ctx->data->ipCidrRouteStatus + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteStatus_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param ipCidrRouteStatus_val + * A long containing the new value. + */ +int +ipCidrRouteStatus_set(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + u_long ipCidrRouteStatus_val) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteStatus_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipCidrRouteStatus value. + * set ipCidrRouteStatus value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* ipCidrRouteStatus_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipCidrRouteStatus_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteStatus_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipCidrRouteStatus undo. + */ + /* + * copy ipCidrRouteStatus data + * set rowreq_ctx->data->ipCidrRouteStatus from rowreq_ctx->undo->ipCidrRouteStatus + */ + + + return MFD_SUCCESS; +} /* ipCidrRouteStatus_undo */ + +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.h b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.h new file mode 100644 index 0000000..95767e0 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable.h @@ -0,0 +1,501 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef IPCIDRROUTETABLE_H +#define IPCIDRROUTETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/route.h> + +#include "mibII/route_headers.h" + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-forward-mib/data_access/route) +config_require(ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface) +config_require(ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for ipCidrRouteTable + */ +#include "ipCidrRouteTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipCidrRouteTable(void); + void shutdown_ipCidrRouteTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + /* + ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review ipCidrRouteTable registration context. + */ + typedef netsnmp_data_list ipCidrRouteTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipCidrRouteTable data context structure. + * This structure is used to represent the data for ipCidrRouteTable. + */ + typedef netsnmp_route_entry ipCidrRouteTable_data; + + + /* + ********************************************************************* + * TODO:115:o: |-> Review ipCidrRouteTable undo context. + * We're just going to use the same data structure for our + * undo_context. If you want to do something more efficent, + * define your typedef here. + */ + typedef ipCidrRouteTable_data ipCidrRouteTable_undo_data; + + /* + * TODO:120:r: |-> Review ipCidrRouteTable mib index. + * This structure is used to represent the index for ipCidrRouteTable. + */ + typedef struct ipCidrRouteTable_mib_index_s { + + /* + * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + uint32_t ipCidrRouteDest; + + /* + * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + uint32_t ipCidrRouteMask; + + /* + * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + long ipCidrRouteTos; + + /* + * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + uint32_t ipCidrRouteNextHop; + + + } ipCidrRouteTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipCidrRouteTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + */ +#define MAX_ipCidrRouteTable_IDX_LEN 13 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipCidrRouteTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipCidrRouteTable_rowreq_ctx pointer. + */ + typedef struct ipCidrRouteTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipCidrRouteTable_IDX_LEN]; + + ipCidrRouteTable_mib_index tbl_idx; + + ipCidrRouteTable_data *data; + ipCidrRouteTable_undo_data *undo; + unsigned int column_set_flags; /* flags for set columns */ + + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * TODO:131:o: | |-> Add useful data to ipCidrRouteTable rowreq context. + */ + u_char ipCidrRouteStatus; + + /* + * storage for future expansion + */ + netsnmp_data_list *ipCidrRouteTable_data_list; + + } ipCidrRouteTable_rowreq_ctx; + + typedef struct ipCidrRouteTable_ref_rowreq_ctx_s { + ipCidrRouteTable_rowreq_ctx *rowreq_ctx; + } ipCidrRouteTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + ipCidrRouteTable_pre_request(ipCidrRouteTable_registration * + user_context); + int + ipCidrRouteTable_post_request(ipCidrRouteTable_registration * + user_context, int rc); + + int + ipCidrRouteTable_rowreq_ctx_init(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx); + void + ipCidrRouteTable_rowreq_ctx_cleanup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + ipCidrRouteTable_data *ipCidrRouteTable_allocate_data(void); + void ipCidrRouteTable_release_data(ipCidrRouteTable_data * + data); + + int ipCidrRouteTable_commit(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + ipCidrRouteTable_rowreq_ctx + * ipCidrRouteTable_row_find_by_mib_index(ipCidrRouteTable_mib_index + * mib_idx); + + extern const oid ipCidrRouteTable_oid[]; + extern const int ipCidrRouteTable_oid_size; + + +#include "ipCidrRouteTable_interface.h" +#include "ipCidrRouteTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + /* + * indexes + */ + + int ipCidrRouteIfIndex_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteIfIndex_val_ptr); + int ipCidrRouteType_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * ipCidrRouteType_val_ptr); + int ipCidrRouteProto_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipCidrRouteProto_val_ptr); + int ipCidrRouteAge_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long *ipCidrRouteAge_val_ptr); + int ipCidrRouteInfo_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + oid ** ipCidrRouteInfo_val_ptr_ptr, + size_t + * ipCidrRouteInfo_val_ptr_len_ptr); + int ipCidrRouteNextHopAS_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteNextHopAS_val_ptr); + int ipCidrRouteMetric1_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteMetric1_val_ptr); + int ipCidrRouteMetric2_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteMetric2_val_ptr); + int ipCidrRouteMetric3_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteMetric3_val_ptr); + int ipCidrRouteMetric4_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteMetric4_val_ptr); + int ipCidrRouteMetric5_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + *ipCidrRouteMetric5_val_ptr); + int ipCidrRouteStatus_get(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipCidrRouteStatus_val_ptr); + + + int + ipCidrRouteTable_indexes_set_tbl_idx(ipCidrRouteTable_mib_index * + tbl_idx, + u_long ipCidrRouteDest_val, + u_long ipCidrRouteMask_val, + long ipCidrRouteTos_val, + u_long + ipCidrRouteNextHop_val); + int + ipCidrRouteTable_indexes_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long ipCidrRouteDest_val, + u_long ipCidrRouteMask_val, + long ipCidrRouteTos_val, + u_long ipCidrRouteNextHop_val); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + + + int ipCidrRouteTable_undo_setup(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx); + int + ipCidrRouteTable_undo_cleanup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteTable_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteTable_commit(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int + ipCidrRouteTable_undo_commit(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + + int + ipCidrRouteIfIndex_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteIfIndex_val); + int + ipCidrRouteIfIndex_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteIfIndex_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteIfIndex_val); + int ipCidrRouteIfIndex_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int ipCidrRouteType_check_value(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx, + u_long + ipCidrRouteType_val); + int ipCidrRouteType_undo_setup(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx); + int ipCidrRouteType_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long ipCidrRouteType_val); + int ipCidrRouteType_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteProto_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long ipCidrRouteProto_val); + int ipCidrRouteProto_undo_setup(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx); + int ipCidrRouteProto_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long ipCidrRouteProto_val); + int ipCidrRouteProto_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int ipCidrRouteAge_check_value(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx, + long ipCidrRouteAge_val); + int ipCidrRouteAge_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteAge_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteAge_val); + int ipCidrRouteAge_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int ipCidrRouteInfo_check_value(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx, + oid * + ipCidrRouteInfo_val_ptr, + size_t + ipCidrRouteInfo_val_ptr_len); + int ipCidrRouteInfo_undo_setup(ipCidrRouteTable_rowreq_ctx + * rowreq_ctx); + int ipCidrRouteInfo_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + oid * ipCidrRouteInfo_val_ptr, + size_t + ipCidrRouteInfo_val_ptr_len); + int ipCidrRouteInfo_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteNextHopAS_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteNextHopAS_val); + int + ipCidrRouteNextHopAS_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteNextHopAS_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, long + ipCidrRouteNextHopAS_val); + int ipCidrRouteNextHopAS_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteMetric1_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric1_val); + int + ipCidrRouteMetric1_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteMetric1_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric1_val); + int ipCidrRouteMetric1_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteMetric2_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric2_val); + int + ipCidrRouteMetric2_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteMetric2_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric2_val); + int ipCidrRouteMetric2_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteMetric3_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric3_val); + int + ipCidrRouteMetric3_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteMetric3_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric3_val); + int ipCidrRouteMetric3_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteMetric4_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric4_val); + int + ipCidrRouteMetric4_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteMetric4_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric4_val); + int ipCidrRouteMetric4_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteMetric5_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric5_val); + int + ipCidrRouteMetric5_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteMetric5_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + long ipCidrRouteMetric5_val); + int ipCidrRouteMetric5_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteStatus_check_value(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long ipCidrRouteStatus_val); + int + ipCidrRouteStatus_undo_setup(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteStatus_set(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, + u_long ipCidrRouteStatus_val); + int ipCidrRouteStatus_undo(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + + int + ipCidrRouteTable_check_dependencies(ipCidrRouteTable_rowreq_ctx * + ctx); + + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* IPCIDRROUTETABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_constants.h b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_constants.h new file mode 100644 index 0000000..ae7a3d3 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_constants.h @@ -0,0 +1,172 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-constants.m2c,v 1.5 2005/07/15 22:41:16 rstory Exp $ + * + * $Id$ + */ +#ifndef IPCIDRROUTETABLE_CONSTANTS_H +#define IPCIDRROUTETABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipCidrRouteTable + */ +#define IPCIDRROUTETABLE_OID 1,3,6,1,2,1,4,24,4 + +#define COLUMN_IPCIDRROUTEDEST 1 + +#define COLUMN_IPCIDRROUTEMASK 2 + +#define COLUMN_IPCIDRROUTETOS 3 + +#define COLUMN_IPCIDRROUTENEXTHOP 4 + +#define COLUMN_IPCIDRROUTEIFINDEX 5 +#define COLUMN_IPCIDRROUTEIFINDEX_FLAG (0x1 << 4) + +#define COLUMN_IPCIDRROUTETYPE 6 +#define COLUMN_IPCIDRROUTETYPE_FLAG (0x1 << 5) + +#define COLUMN_IPCIDRROUTEPROTO 7 + +#define COLUMN_IPCIDRROUTEAGE 8 + +#define COLUMN_IPCIDRROUTEINFO 9 +#define COLUMN_IPCIDRROUTEINFO_FLAG (0x1 << 8) + +#define COLUMN_IPCIDRROUTENEXTHOPAS 10 +#define COLUMN_IPCIDRROUTENEXTHOPAS_FLAG (0x1 << 9) + +#define COLUMN_IPCIDRROUTEMETRIC1 11 +#define COLUMN_IPCIDRROUTEMETRIC1_FLAG (0x1 << 10) + +#define COLUMN_IPCIDRROUTEMETRIC2 12 +#define COLUMN_IPCIDRROUTEMETRIC2_FLAG (0x1 << 11) + +#define COLUMN_IPCIDRROUTEMETRIC3 13 +#define COLUMN_IPCIDRROUTEMETRIC3_FLAG (0x1 << 12) + +#define COLUMN_IPCIDRROUTEMETRIC4 14 +#define COLUMN_IPCIDRROUTEMETRIC4_FLAG (0x1 << 13) + +#define COLUMN_IPCIDRROUTEMETRIC5 15 +#define COLUMN_IPCIDRROUTEMETRIC5_FLAG (0x1 << 14) + +#define COLUMN_IPCIDRROUTESTATUS 16 +#define COLUMN_IPCIDRROUTESTATUS_FLAG (0x1 << 15) + + +#define IPCIDRROUTETABLE_MIN_COL COLUMN_IPCIDRROUTEDEST +#define IPCIDRROUTETABLE_MAX_COL COLUMN_IPCIDRROUTESTATUS + + + /* + * TODO:405:r: Review IPCIDRROUTETABLE_SETTABLE_COLS macro. + * OR together all the writable cols. + */ +#define IPCIDRROUTETABLE_SETTABLE_COLS (COLUMN_IPCIDRROUTEIFINDEX_FLAG | COLUMN_IPCIDRROUTETYPE_FLAG | COLUMN_IPCIDRROUTEINFO_FLAG | COLUMN_IPCIDRROUTENEXTHOPAS_FLAG | COLUMN_IPCIDRROUTEMETRIC1_FLAG | COLUMN_IPCIDRROUTEMETRIC2_FLAG | COLUMN_IPCIDRROUTEMETRIC3_FLAG | COLUMN_IPCIDRROUTEMETRIC4_FLAG | COLUMN_IPCIDRROUTEMETRIC5_FLAG | COLUMN_IPCIDRROUTESTATUS_FLAG) + /* + * TODO:405:r: Review IPCIDRROUTETABLE_REQUIRED_COLS macro. + * OR together all the required rows for row creation. + * default is writable cols w/out defaults. + */ +#define IPCIDRROUTETABLE_REQUIRED_COLS (COLUMN_IPCIDRROUTETYPE_FLAG | COLUMN_IPCIDRROUTEINFO_FLAG | COLUMN_IPCIDRROUTESTATUS_FLAG) + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table ipCidrRouteTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipCidrRouteType (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPCIDRROUTETYPE_ENUMS +#define IPCIDRROUTETYPE_ENUMS + +#define IPCIDRROUTETYPE_OTHER 1 +#define IPCIDRROUTETYPE_REJECT 2 +#define IPCIDRROUTETYPE_LOCAL 3 +#define IPCIDRROUTETYPE_REMOTE 4 + +#endif /* IPCIDRROUTETYPE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipCidrRouteProto (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPCIDRROUTEPROTO_ENUMS +#define IPCIDRROUTEPROTO_ENUMS + +#define IPCIDRROUTEPROTO_OTHER 1 +#define IPCIDRROUTEPROTO_LOCAL 2 +#define IPCIDRROUTEPROTO_NETMGMT 3 +#define IPCIDRROUTEPROTO_ICMP 4 +#define IPCIDRROUTEPROTO_EGP 5 +#define IPCIDRROUTEPROTO_GGP 6 +#define IPCIDRROUTEPROTO_HELLO 7 +#define IPCIDRROUTEPROTO_RIP 8 +#define IPCIDRROUTEPROTO_ISIS 9 +#define IPCIDRROUTEPROTO_ESIS 10 +#define IPCIDRROUTEPROTO_CISCOIGRP 11 +#define IPCIDRROUTEPROTO_BBNSPFIGP 12 +#define IPCIDRROUTEPROTO_OSPF 13 +#define IPCIDRROUTEPROTO_BGP 14 +#define IPCIDRROUTEPROTO_IDPR 15 +#define IPCIDRROUTEPROTO_CISCOEIGRP 16 + +#endif /* IPCIDRROUTEPROTO_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipCidrRouteStatus (RowStatus / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef ROWSTATUS_ENUMS +#define ROWSTATUS_ENUMS + +#define ROWSTATUS_ACTIVE 1 +#define ROWSTATUS_NOTINSERVICE 2 +#define ROWSTATUS_NOTREADY 3 +#define ROWSTATUS_CREATEANDGO 4 +#define ROWSTATUS_CREATEANDWAIT 5 +#define ROWSTATUS_DESTROY 6 + +#endif /* ROWSTATUS_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPCIDRROUTETABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.c b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.c new file mode 100644 index 0000000..3955519 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.c @@ -0,0 +1,671 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +/* + * standard Net-SNMP includes + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "ipCidrRouteTable.h" + + +#include "ipCidrRouteTable_data_access.h" + + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + +/** + * initialization for ipCidrRouteTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipCidrRouteTable_reg + * Pointer to ipCidrRouteTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipCidrRouteTable_init_data(ipCidrRouteTable_registration * + ipCidrRouteTable_reg) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize ipCidrRouteTable data. + */ + + return MFD_SUCCESS; +} /* ipCidrRouteTable_init_data */ + +/** + * container overview + * + */ + +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +ipCidrRouteTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_container_init", + "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipCidrRouteTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + if (NULL == cache) { + snmp_log(LOG_ERR, + "bad cache param to ipCidrRouteTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipCidrRouteTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = IPCIDRROUTETABLE_CACHE_TIMEOUT; /* seconds */ +} /* ipCidrRouteTable_container_init */ + +/** + * check entry for update + * + */ +static void +_snarf_route_entry(netsnmp_route_entry *route_entry, + netsnmp_container *container) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx; + + DEBUGTRACE; + + netsnmp_assert(NULL != route_entry); + netsnmp_assert(NULL != container); + + /* + * allocate an row context and set the index(es), then add it to + * the container + */ + rowreq_ctx = ipCidrRouteTable_allocate_rowreq_ctx(route_entry, NULL); + if ((NULL != rowreq_ctx) && + (MFD_SUCCESS == ipCidrRouteTable_indexes_set + (rowreq_ctx, *((u_long *) route_entry->rt_dest), + route_entry->rt_mask, route_entry->rt_tos, + *((u_long *) route_entry->rt_nexthop)))) { + CONTAINER_INSERT(container, rowreq_ctx); + rowreq_ctx->ipCidrRouteStatus = ROWSTATUS_ACTIVE; + } else { + if (rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "ipCidrRoute cache.\n"); + ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + } else + netsnmp_access_route_entry_free(route_entry); + } +} + +/** + * container shutdown + * + * @param container_ptr A pointer to the container. + * + * This function is called at shutdown to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. + * + * This function is called before ipCidrRouteTable_container_free(). + * + * @remark + * This would also be a good place to do any cleanup needed + * for you data source. For example, closing a connection to another + * process that supplied the data, closing a database, etc. + */ +void +ipCidrRouteTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipCidrRouteTable_container_shutdown\n"); + return; + } + +} /* ipCidrRouteTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement ipCidrRouteTable data load + * This function will also be called by the cache helper to load + * the container again (after the container free function has been + * called to free the previous contents). + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to load the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the data, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * ipCidrRouteTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +ipCidrRouteTable_container_load(netsnmp_container *container) +{ + netsnmp_container *route_container; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_cache_load", + "called\n")); + + /* + * TODO:351:M: |-> Load/update data in the ipCidrRouteTable container. + * loop over your ipCidrRouteTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + route_container = + netsnmp_access_route_container_load(NULL, + NETSNMP_ACCESS_ROUTE_LOAD_IPV4_ONLY); + + if (NULL == route_container) + return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */ + + /* + * we just got a fresh copy of route data. snarf data + */ + CONTAINER_FOR_EACH(route_container, + (netsnmp_container_obj_func *) _snarf_route_entry, + container); + + /* + * free the container. we've either claimed each ifentry, or released it, + * so the dal function doesn't need to clear the container. + */ + netsnmp_access_route_container_free(route_container, + NETSNMP_ACCESS_ROUTE_FREE_DONT_CLEAR); + + DEBUGMSGT(("verbose:ipCidrRouteTable:ipCidrRouteTable_cache_load", + "%d records\n", (int)CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} /* ipCidrRouteTable_container_load */ + +/** + * container clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +ipCidrRouteTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_container_free", + "called\n")); + + /* + * TODO:380:M: Free ipCidrRouteTable container data. + */ +} /* ipCidrRouteTable_container_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +ipCidrRouteTable_row_prep(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_row_prep", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* ipCidrRouteTable_row_prep */ + +/* + * TODO:420:r: Implement ipCidrRouteTable index validation. + */ +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteDest + * ipCidrRouteDest is subid 1 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.4.1.1 + * Description: +The destination IP address of this route. + + This object may not take a Multicast (Class D) address + value. + + Any assignment (implicit or otherwise) of an instance + of this object to a value x must be rejected if the + bitwise logical-AND of x with the value of the + corresponding instance of the ipCidrRouteMask object is + not equal to x. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is IPADDR (based on perltype IPADDR) + * The net-snmp type is ASN_IPADDRESS. The C type decl is u_long (u_long) + */ +/** + * check validity of ipCidrRouteDest index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * ipCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +ipCidrRouteDest_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteDest_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check ipCidrRouteTable index ipCidrRouteDest. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.ipCidrRouteDest) + */ + + return MFD_SUCCESS; /* ipCidrRouteDest index ok */ +} /* ipCidrRouteDest_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteMask + * ipCidrRouteMask is subid 2 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.4.1.2 + * Description: +Indicate the mask to be logical-ANDed with the + destination address before being compared to the value + in the ipCidrRouteDest field. For those systems that + do not support arbitrary subnet masks, an agent + constructs the value of the ipCidrRouteMask by + reference to the IP Address Class. + + Any assignment (implicit or otherwise) of an instance + of this object to a value x must be rejected if the + bitwise logical-AND of x with the value of the + corresponding instance of the ipCidrRouteDest object is + + + not equal to ipCidrRouteDest. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is IPADDR (based on perltype IPADDR) + * The net-snmp type is ASN_IPADDRESS. The C type decl is u_long (u_long) + */ +/** + * check validity of ipCidrRouteMask index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * ipCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +ipCidrRouteMask_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteMask_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check ipCidrRouteTable index ipCidrRouteMask. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.ipCidrRouteMask) + */ + + return MFD_SUCCESS; /* ipCidrRouteMask index ok */ +} /* ipCidrRouteMask_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteTos + * ipCidrRouteTos is subid 3 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.4.1.3 + * Description: +The policy specifier is the IP TOS Field. The encoding + of IP TOS is as specified by the following convention. + Zero indicates the default path if no more specific + policy applies. + + +-----+-----+-----+-----+-----+-----+-----+-----+ + | | | | + | PRECEDENCE | TYPE OF SERVICE | 0 | + | | | | + +-----+-----+-----+-----+-----+-----+-----+-----+ + + IP TOS IP TOS + Field Policy Field Policy + Contents Code Contents Code + 0 0 0 0 ==> 0 0 0 0 1 ==> 2 + 0 0 1 0 ==> 4 0 0 1 1 ==> 6 + 0 1 0 0 ==> 8 0 1 0 1 ==> 10 + 0 1 1 0 ==> 12 0 1 1 1 ==> 14 + 1 0 0 0 ==> 16 1 0 0 1 ==> 18 + 1 0 1 0 ==> 20 1 0 1 1 ==> 22 + 1 1 0 0 ==> 24 1 1 0 1 ==> 26 + 1 1 1 0 ==> 28 1 1 1 1 ==> 30 + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 0 - 2147483647; + * + * Its syntax is INTEGER32 (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * check validity of ipCidrRouteTos index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * ipCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * The value is in (one of) the range set(s): 0 - 2147483647 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +ipCidrRouteTos_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTos_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check ipCidrRouteTable index ipCidrRouteTos. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.ipCidrRouteTos) + */ + + return MFD_SUCCESS; /* ipCidrRouteTos index ok */ +} /* ipCidrRouteTos_check_index */ + +/*--------------------------------------------------------------------- + * IP-FORWARD-MIB::ipCidrRouteEntry.ipCidrRouteNextHop + * ipCidrRouteNextHop is subid 4 of ipCidrRouteEntry. + * Its status is Deprecated, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.24.4.1.4 + * Description: +On remote routes, the address of the next system en + route; Otherwise, 0.0.0.0. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is IPADDR (based on perltype IPADDR) + * The net-snmp type is ASN_IPADDRESS. The C type decl is u_long (u_long) + */ +/** + * check validity of ipCidrRouteNextHop index portion + * + * @retval MFD_SUCCESS : the incoming value is legal + * @retval MFD_ERROR : the incoming value is NOT legal + * + * @note this is not the place to do any checks for the sanity + * of multiple indexes. Those types of checks should be done in the + * ipCidrRouteTable_validate_index() function. + * + * @note Also keep in mind that if the index refers to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * The following checks have already been done for you: + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +ipCidrRouteNextHop_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteNextHop_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check ipCidrRouteTable index ipCidrRouteNextHop. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.ipCidrRouteNextHop) + */ + + return MFD_SUCCESS; /* ipCidrRouteNextHop index ok */ +} /* ipCidrRouteNextHop_check_index */ + +/** + * verify specified index is valid. + * + * This check is independent of whether or not the values specified for + * the columns of the new row are valid. Column values and row consistency + * will be checked later. At this point, only the index values should be + * checked. + * + * All of the individual index validation functions have been called, so this + * is the place to make sure they are valid as a whole when combined. If + * you only have one index, then you probably don't need to do anything else + * here. + * + * @note Keep in mind that if the indexes refer to a row in this or + * some other table, you can't check for that row here to make + * decisions, since that row might not be created yet, but may + * be created during the processing this request. If you have + * such checks, they should be done in the check_dependencies + * function, because any new/deleted/changed rows should be + * available then. + * + * + * @param ipCidrRouteTable_reg + * Pointer to the user registration data + * @param rowreq_ctx + * Pointer to the users context. + * @retval MFD_SUCCESS : success + * @retval MFD_CANNOT_CREATE_NOW : index not valid right now + * @retval MFD_CANNOT_CREATE_EVER : index never valid + */ +int +ipCidrRouteTable_validate_index(ipCidrRouteTable_registration * + ipCidrRouteTable_reg, + ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_validate_index", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:430:M: |-> Validate potential ipCidrRouteTable index. + */ + if (1) { + snmp_log(LOG_WARNING, "invalid index for a new row in the " + "ipCidrRouteTable table.\n"); + /* + * determine failure type. + * + * If the index could not ever be created, return MFD_NOT_EVER + * If the index can not be created under the present circumstances + * (even though it could be created under other circumstances), + * return MFD_NOT_NOW. + */ + if (0) { + return MFD_CANNOT_CREATE_EVER; + } else { + return MFD_CANNOT_CREATE_NOW; + } + } + + return rc; +} /* ipCidrRouteTable_validate_index */ + +/** @} */ diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.h b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.h new file mode 100644 index 0000000..c62cf39 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_data_access.h @@ -0,0 +1,82 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef IPCIDRROUTETABLE_DATA_ACCESS_H +#define IPCIDRROUTETABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ + + + int + ipCidrRouteTable_init_data(ipCidrRouteTable_registration * + ipCidrRouteTable_reg); + + + /* + * TODO:180:o: Review ipCidrRouteTable cache timeout. + * The number of seconds before the cache times out + */ +#define IPCIDRROUTETABLE_CACHE_TIMEOUT 60 + + void ipCidrRouteTable_container_init(netsnmp_container + **container_ptr_ptr, + netsnmp_cache * cache); + void ipCidrRouteTable_container_shutdown(netsnmp_container + *container_ptr); + + int ipCidrRouteTable_container_load(netsnmp_container + *container); + void ipCidrRouteTable_container_free(netsnmp_container + *container); + + int ipCidrRouteTable_cache_load(netsnmp_container + *container); + void ipCidrRouteTable_cache_free(netsnmp_container + *container); + + int ipCidrRouteTable_row_prep(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int + ipCidrRouteTable_validate_index(ipCidrRouteTable_registration * + ipCidrRouteTable_reg, + ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + int ipCidrRouteDest_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int ipCidrRouteMask_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int ipCidrRouteTos_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + int ipCidrRouteNextHop_check_index(ipCidrRouteTable_rowreq_ctx * rowreq_ctx); /* internal */ + + +#ifdef __cplusplus +} +#endif +#endif /* IPCIDRROUTETABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c new file mode 100644 index 0000000..5e855d4 --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c @@ -0,0 +1,2354 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.67 $ of : mfd-interface.m2c,v $ + * + * $Id$ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ + +/* + * standard Net-SNMP includes + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "ipCidrRouteTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipCidrRouteTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(ipCidrRouteTable_external_access, libnetsnmpmibs) +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(table_container_row_insert) +netsnmp_feature_require(check_all_requests_error) + + +netsnmp_feature_child_of(ipCidrRouteTable_container_size, ipCidrRouteTable_external_access) +netsnmp_feature_child_of(ipCidrRouteTable_registration_set, ipCidrRouteTable_external_access) +netsnmp_feature_child_of(ipCidrRouteTable_registration_get, ipCidrRouteTable_external_access) +netsnmp_feature_child_of(ipCidrRouteTable_container_get, ipCidrRouteTable_external_access) +/********************************************************************** + ********************************************************************** + *** + *** Table ipCidrRouteTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward. + * Its status is Deprecated. + * OID: .1.3.6.1.2.1.4.24.4, length: 9 + */ +typedef struct ipCidrRouteTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + ipCidrRouteTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_int table_dirty; + +} ipCidrRouteTable_interface_ctx; + +static ipCidrRouteTable_interface_ctx ipCidrRouteTable_if_ctx; + +static void + _ipCidrRouteTable_container_init(ipCidrRouteTable_interface_ctx * if_ctx); +static void + _ipCidrRouteTable_container_shutdown(ipCidrRouteTable_interface_ctx * + if_ctx); + +#ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_GET +netsnmp_container * +ipCidrRouteTable_container_get(void) +{ + return ipCidrRouteTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_GET +ipCidrRouteTable_registration * +ipCidrRouteTable_registration_get(void) +{ + return ipCidrRouteTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_SET +ipCidrRouteTable_registration * +ipCidrRouteTable_registration_set(ipCidrRouteTable_registration * newreg) +{ + ipCidrRouteTable_registration *old = ipCidrRouteTable_if_ctx.user_ctx; + ipCidrRouteTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_SIZE +int +ipCidrRouteTable_container_size(void) +{ + return CONTAINER_SIZE(ipCidrRouteTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_SIZE */ + +u_int +ipCidrRouteTable_dirty_get(void) +{ + return ipCidrRouteTable_if_ctx.table_dirty; +} + +void +ipCidrRouteTable_dirty_set(u_int status) +{ + DEBUGMSGTL(("ipCidrRouteTable:ipCidrRouteTable_dirty_set", + "called. was %d, now %d\n", + ipCidrRouteTable_if_ctx.table_dirty, status)); + ipCidrRouteTable_if_ctx.table_dirty = status; +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_post_request; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_get_values; +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_check_objects; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_setup; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_set_values; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_values; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_commit; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_commit; +static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_irreversible_commit; + +NETSNMP_STATIC_INLINE int + _ipCidrRouteTable_undo_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, + int column); +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + +NETSNMP_STATIC_INLINE int + _ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx); + +/** + * @internal + * Initialize the table ipCidrRouteTable + * (Define its contents and how it's structured) + */ +void +_ipCidrRouteTable_initialize_interface(ipCidrRouteTable_registration * + reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipCidrRouteTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipCidrRouteTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipCidrRouteTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_IPADDRESS, + /** index: ipCidrRouteDest */ + ASN_IPADDRESS, + /** index: ipCidrRouteMask */ + ASN_INTEGER, + /** index: ipCidrRouteTos */ + ASN_IPADDRESS, + /** index: ipCidrRouteNextHop */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPCIDRROUTETABLE_MIN_COL; + tbl_info->max_column = IPCIDRROUTETABLE_MAX_COL; + + /* + * save users context + */ + ipCidrRouteTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipCidrRouteTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipCidrRouteTable_container_init(&ipCidrRouteTable_if_ctx); + if (NULL == ipCidrRouteTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipCidrRouteTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipCidrRouteTable_object_lookup; + access_multiplexer->get_values = _mfd_ipCidrRouteTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_ipCidrRouteTable_pre_request; + access_multiplexer->post_request = _mfd_ipCidrRouteTable_post_request; + + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) + /* + * REQUIRED wrappers for set request handling + */ + access_multiplexer->object_syntax_checks = + _mfd_ipCidrRouteTable_check_objects; + access_multiplexer->undo_setup = _mfd_ipCidrRouteTable_undo_setup; + access_multiplexer->undo_cleanup = _mfd_ipCidrRouteTable_undo_cleanup; + access_multiplexer->set_values = _mfd_ipCidrRouteTable_set_values; + access_multiplexer->undo_sets = _mfd_ipCidrRouteTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_ipCidrRouteTable_commit; + access_multiplexer->undo_commit = _mfd_ipCidrRouteTable_undo_commit; + access_multiplexer->irreversible_commit = + _mfd_ipCidrRouteTable_irreversible_commit; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipCidrRouteTable:init_ipCidrRouteTable", + "Registering ipCidrRouteTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipCidrRouteTable", handler, + ipCidrRouteTable_oid, + ipCidrRouteTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY); + if (NULL == reginfo) { + snmp_log(LOG_ERR, "error registering table ipCidrRouteTable\n"); + return; + } + reginfo->my_reg_void = &ipCidrRouteTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if (access_multiplexer->object_lookup) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if (access_multiplexer->pre_request) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if (access_multiplexer->post_request) + mfd_modes |= BABY_STEP_POST_REQUEST; + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) + if (access_multiplexer->set_values) + mfd_modes |= BABY_STEP_SET_VALUES; + if (access_multiplexer->irreversible_commit) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if (access_multiplexer->object_syntax_checks) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if (access_multiplexer->undo_setup) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if (access_multiplexer->undo_cleanup) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if (access_multiplexer->undo_sets) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if (access_multiplexer->row_creation) + mfd_modes |= BABY_STEP_ROW_CREATE; + if (access_multiplexer->consistency_checks) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if (access_multiplexer->commit) + mfd_modes |= BABY_STEP_COMMIT; + if (access_multiplexer->undo_commit) + mfd_modes |= BABY_STEP_UNDO_COMMIT; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + ipCidrRouteTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != ipCidrRouteTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(ipCidrRouteTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _ipCidrRouteTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipCidrRouteTable + */ +void +_ipCidrRouteTable_shutdown_interface(ipCidrRouteTable_registration * + reg_ptr) +{ + /* + * shutdown the container + */ + _ipCidrRouteTable_container_shutdown(&ipCidrRouteTable_if_ctx); +} + +void +ipCidrRouteTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipCidrRouteTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipCidrRouteTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipCidrRouteTable_index_to_oid(netsnmp_index * oid_idx, + ipCidrRouteTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + netsnmp_variable_list var_ipCidrRouteDest; + /* + * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + netsnmp_variable_list var_ipCidrRouteMask; + /* + * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + netsnmp_variable_list var_ipCidrRouteTos; + /* + * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + netsnmp_variable_list var_ipCidrRouteNextHop; + + /* + * set up varbinds + */ + memset(&var_ipCidrRouteDest, 0x00, sizeof(var_ipCidrRouteDest)); + var_ipCidrRouteDest.type = ASN_PRIV_IMPLIED_OCTET_STR; + memset(&var_ipCidrRouteMask, 0x00, sizeof(var_ipCidrRouteMask)); + var_ipCidrRouteMask.type = ASN_PRIV_IMPLIED_OCTET_STR; + memset(&var_ipCidrRouteTos, 0x00, sizeof(var_ipCidrRouteTos)); + var_ipCidrRouteTos.type = ASN_INTEGER; + memset(&var_ipCidrRouteNextHop, 0x00, sizeof(var_ipCidrRouteNextHop)); + var_ipCidrRouteNextHop.type = ASN_PRIV_IMPLIED_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_ipCidrRouteDest.next_variable = &var_ipCidrRouteMask; + var_ipCidrRouteMask.next_variable = &var_ipCidrRouteTos; + var_ipCidrRouteTos.next_variable = &var_ipCidrRouteNextHop; + var_ipCidrRouteNextHop.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_index_to_oid", + "called\n")); + + /* + * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + snmp_set_var_value(&var_ipCidrRouteDest, + (u_char *) & mib_idx->ipCidrRouteDest, + sizeof(mib_idx->ipCidrRouteDest)); + + /* + * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + snmp_set_var_value(&var_ipCidrRouteMask, + (u_char *) & mib_idx->ipCidrRouteMask, + sizeof(mib_idx->ipCidrRouteMask)); + + /* + * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + snmp_set_var_value(&var_ipCidrRouteTos, + (u_char *) & mib_idx->ipCidrRouteTos, + sizeof(mib_idx->ipCidrRouteTos)); + + /* + * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + snmp_set_var_value(&var_ipCidrRouteNextHop, + (u_char *) & mib_idx->ipCidrRouteNextHop, + sizeof(mib_idx->ipCidrRouteNextHop)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipCidrRouteDest); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipCidrRouteDest); + + return err; +} /* ipCidrRouteTable_index_to_oid */ + +/** + * extract ipCidrRouteTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipCidrRouteTable_index_from_oid(netsnmp_index * oid_idx, + ipCidrRouteTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + netsnmp_variable_list var_ipCidrRouteDest; + /* + * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + netsnmp_variable_list var_ipCidrRouteMask; + /* + * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + netsnmp_variable_list var_ipCidrRouteTos; + /* + * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + netsnmp_variable_list var_ipCidrRouteNextHop; + + /* + * set up varbinds + */ + memset(&var_ipCidrRouteDest, 0x00, sizeof(var_ipCidrRouteDest)); + var_ipCidrRouteDest.type = ASN_IPADDRESS; + memset(&var_ipCidrRouteMask, 0x00, sizeof(var_ipCidrRouteMask)); + var_ipCidrRouteMask.type = ASN_IPADDRESS; + memset(&var_ipCidrRouteTos, 0x00, sizeof(var_ipCidrRouteTos)); + var_ipCidrRouteTos.type = ASN_INTEGER; + memset(&var_ipCidrRouteNextHop, 0x00, sizeof(var_ipCidrRouteNextHop)); + var_ipCidrRouteNextHop.type = ASN_IPADDRESS; + + /* + * chain temp index varbinds together + */ + var_ipCidrRouteDest.next_variable = &var_ipCidrRouteMask; + var_ipCidrRouteMask.next_variable = &var_ipCidrRouteTos; + var_ipCidrRouteTos.next_variable = &var_ipCidrRouteNextHop; + var_ipCidrRouteNextHop.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_index_from_oid", + "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipCidrRouteDest); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipCidrRouteDest = + *((u_long *) var_ipCidrRouteDest.val.string); + mib_idx->ipCidrRouteMask = + *((u_long *) var_ipCidrRouteMask.val.string); + mib_idx->ipCidrRouteTos = + *((long *) var_ipCidrRouteTos.val.string); + mib_idx->ipCidrRouteNextHop = + *((u_long *) var_ipCidrRouteNextHop.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipCidrRouteDest); + + return err; +} /* ipCidrRouteTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipCidrRouteTable_rowreq_ctx + */ +ipCidrRouteTable_rowreq_ctx * +ipCidrRouteTable_allocate_rowreq_ctx(ipCidrRouteTable_data * data, + void *user_init_ctx) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipCidrRouteTable_rowreq_ctx); + + DEBUGMSGTL(("internal:ipCidrRouteTable:ipCidrRouteTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipCidrRouteTable_rowreq_ctx.\n"); + return NULL; + } else { + if (NULL != data) { + /* + * track if we got data from user + */ + rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; + rowreq_ctx->data = data; + } else if (NULL == + (rowreq_ctx->data = ipCidrRouteTable_allocate_data())) { + SNMP_FREE(rowreq_ctx); + return NULL; + } + } + + /* + * undo context will be allocated when needed (in *_undo_setup) + */ + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->ipCidrRouteTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipCidrRouteTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { + ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipCidrRouteTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipCidrRouteTable_rowreq_ctx + */ +void +ipCidrRouteTable_release_rowreq_ctx(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipCidrRouteTable:ipCidrRouteTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipCidrRouteTable_rowreq_ctx_cleanup(rowreq_ctx); + + /* + * for non-transient data, don't free data we got from the user + */ + if ((rowreq_ctx->data) && + !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) + ipCidrRouteTable_release_data(rowreq_ctx->data); + + if (rowreq_ctx->undo) + ipCidrRouteTable_release_data(rowreq_ctx->undo); + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* ipCidrRouteTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipCidrRouteTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipCidrRouteTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipCidrRouteTable_pre_request(ipCidrRouteTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipCidrRouteTable", "error %d from " + "ipCidrRouteTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipCidrRouteTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipCidrRouteTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + if ((MFD_SUCCESS != packet_rc) && ipCidrRouteTable_dirty_get()) { + /* + * we shouldn't get here. the undo steps should also clear + * the dirty flags. + */ + snmp_log(LOG_WARNING, + "ipCidrRouteTable dirty flag set in post_request " + "but status != SUCCESS.\n"); + } + + rc = ipCidrRouteTable_post_request(ipCidrRouteTable_if_ctx.user_ctx, + packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipCidrRouteTable", "error %d from " + "ipCidrRouteTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_post_request */ + +/** + * @internal + * wrapper + */ +static ipCidrRouteTable_rowreq_ctx * +_mfd_ipCidrRouteTable_rowreq_from_index(netsnmp_index * oid_idx, + int *rc_ptr) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx; + ipCidrRouteTable_mib_index mib_idx; + int rc; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_rowreq_from_index", "called\n")); + + if (NULL == rc_ptr) + rc_ptr = &rc; + *rc_ptr = MFD_SUCCESS; + + memset(&mib_idx, 0x0, sizeof(mib_idx)); + + /* + * try to parse oid + */ + *rc_ptr = ipCidrRouteTable_index_from_oid(oid_idx, &mib_idx); + if (MFD_SUCCESS != *rc_ptr) { + DEBUGMSGT(("ipCidrRouteTable", "error parsing index\n")); + return NULL; + } + + /* + * allocate new context + */ + rowreq_ctx = ipCidrRouteTable_allocate_rowreq_ctx(NULL, NULL); + if (NULL == rowreq_ctx) { + *rc_ptr = MFD_ERROR; + return NULL; /* msg already logged */ + } + + memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx)); + + /* + * check indexes + */ + *rc_ptr = _ipCidrRouteTable_check_indexes(rowreq_ctx); + if (MFD_SUCCESS != *rc_ptr) { + netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) || + (*rc_ptr == SNMP_ERR_INCONSISTENTNAME)); + ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx); + return NULL; + } + + /* + * copy indexes + */ + rowreq_ctx->oid_idx.len = oid_idx->len; + memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids, + oid_idx->len * sizeof(oid)); + + return rowreq_ctx; +} /* _mfd_ipCidrRouteTable_rowreq_from_index */ + + +/** + * @internal + * wrapper + */ +static int +_mfd_ipCidrRouteTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = SNMP_ERR_NOERROR; + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipCidrRouteTable_interface_ctx *if_ctx = + * (ipCidrRouteTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + netsnmp_table_request_info *tblreq_info; + netsnmp_index oid_idx; + + tblreq_info = netsnmp_extract_table_info(requests); + if (NULL == tblreq_info) { + snmp_log(LOG_ERR, "request had no table info\n"); + return MFD_ERROR; + } + + /* + * try create rowreq + */ + oid_idx.oids = tblreq_info->index_oid; + oid_idx.len = tblreq_info->index_oid_len; + + rowreq_ctx = + _mfd_ipCidrRouteTable_rowreq_from_index(&oid_idx, &rc); + if (MFD_SUCCESS == rc) { + netsnmp_assert(NULL != rowreq_ctx); + rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED; + /* + * add rowreq_ctx to request data lists + */ + netsnmp_container_table_row_insert(requests, (netsnmp_index *) + rowreq_ctx); + } + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipCidrRouteTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipCidrRouteTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipCidrRouteTable_get_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPCIDRROUTEDEST: + var->type = ASN_IPADDRESS; + var->val_len = sizeof(in_addr_t); + (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteDest; + break; + + /* + * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPCIDRROUTEMASK: + var->type = ASN_IPADDRESS; + var->val_len = sizeof(in_addr_t); + (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteMask; + break; + + /* + * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + case COLUMN_IPCIDRROUTETOS: + var->type = ASN_INTEGER; + var->val_len = sizeof(long); + (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteTos; + break; + + /* + * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPCIDRROUTENEXTHOP: + var->type = ASN_IPADDRESS; + var->val_len = sizeof(in_addr_t); + (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteNextHop; + break; + + /* + * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEIFINDEX: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteIfIndex_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTETYPE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipCidrRouteType_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipCidrRouteProto(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPCIDRROUTEPROTO: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipCidrRouteProto_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipCidrRouteAge(8)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/D/h + */ + case COLUMN_IPCIDRROUTEAGE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteAge_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h + */ + case COLUMN_IPCIDRROUTEINFO: + var->type = ASN_OBJECT_ID; + rc = ipCidrRouteInfo_get(rowreq_ctx, (oid **) & var->val.string, + &var->val_len); + break; + + /* + * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTENEXTHOPAS: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteNextHopAS_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC1: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteMetric1_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC2: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteMetric2_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC3: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteMetric3_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC4: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteMetric4_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC5: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipCidrRouteMetric5_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTESTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipCidrRouteStatus_get(rowreq_ctx, (u_long *) var->val.string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipCidrRouteTable_get_column\n", + column); + break; + } + + return rc; +} /* _ipCidrRouteTable_get_column */ + +int +_mfd_ipCidrRouteTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for (; requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if (NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = + sizeof(requests->requestvb->buf); + } else if (requests->requestvb->buf == + requests->requestvb->val.string) { + if (requests->requestvb->val_len != + sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = + sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipCidrRouteTable_get_column(rowreq_ctx, requests->requestvb, + tri->colnum); + if (rc) { + if (MFD_SKIP == rc) { + requests->requestvb->type = SNMP_NOSUCHINSTANCE; + rc = SNMP_ERR_NOERROR; + } + } else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if (rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if (old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if (dataFreeHook) + (*dataFreeHook) (old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_get_values */ + +NETSNMP_STATIC_INLINE int +_ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_indexes", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + if (MFD_SUCCESS != rc) + return rc; + rc = ipCidrRouteDest_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + if (MFD_SUCCESS != rc) + return rc; + rc = ipCidrRouteMask_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((rowreq_ctx->tbl_idx.ipCidrRouteTos < 0) + || (rowreq_ctx->tbl_idx.ipCidrRouteTos > 2147483647)) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = ipCidrRouteTos_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + if (MFD_SUCCESS != rc) + return rc; + rc = ipCidrRouteNextHop_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * if individual parts look ok, check them as a whole + */ + return ipCidrRouteTable_validate_index(ipCidrRouteTable_if_ctx. + user_ctx, rowreq_ctx); +} /* _ipCidrRouteTable_check_indexes */ + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/*---------------------------------------------------------------------- + * + * SET: Syntax checks + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check the syntax for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipCidrRouteTable_check_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_column", + "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + /* + * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPCIDRROUTEDEST: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPCIDRROUTEMASK: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + case COLUMN_IPCIDRROUTETOS: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPCIDRROUTENEXTHOP: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + + /* + * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEIFINDEX: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteIfIndex", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteIfIndex_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteIfIndex_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTETYPE: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != IPCIDRROUTETYPE_OTHER) + && (*var->val.integer != IPCIDRROUTETYPE_REJECT) + && (*var->val.integer != IPCIDRROUTETYPE_LOCAL) + && (*var->val.integer != IPCIDRROUTETYPE_REMOTE) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteType", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteType_check_value(rowreq_ctx, + *((u_long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteType_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteProto(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPCIDRROUTEPROTO: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipCidrRouteAge(8)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/D/h + */ + case COLUMN_IPCIDRROUTEAGE: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h + */ + case COLUMN_IPCIDRROUTEINFO: + rc = netsnmp_check_vb_type(var, ASN_OBJECT_ID); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteInfo", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteInfo_check_value(rowreq_ctx, + (oid *) var->val.string, + var->val_len); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteInfo_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTENEXTHOPAS: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteNextHopAS", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteNextHopAS_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteNextHopAS_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC1: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric1", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteMetric1_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteMetric1_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC2: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric2", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteMetric2_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteMetric2_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC3: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric3", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteMetric3_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteMetric3_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC4: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric4", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteMetric4_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteMetric4_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC5: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric5", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteMetric5_check_value(rowreq_ctx, + *((long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteMetric5_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTESTATUS: + rc = netsnmp_check_vb_rowstatus_value(var); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipCidrRouteStatus_check_value(rowreq_ctx, + *((u_long *) var->val. + string)); + if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) + && (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, + "bad rc %d from ipCidrRouteStatus_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + default: /** We shouldn't get here */ + rc = SNMP_ERR_GENERR; + snmp_log(LOG_ERR, + "unknown column %d in _ipCidrRouteTable_check_column\n", + column); + } + + return rc; +} /* _ipCidrRouteTable_check_column */ + +int +_mfd_ipCidrRouteTable_check_objects(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_check_objects", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for (; requests; requests = requests->next) { + + /* + * get column number from table request info, and check that column + */ + netsnmp_table_request_info *tri; + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipCidrRouteTable_check_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (rc) { + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + break; + } + + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_check_objects */ + + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipCidrRouteTable_undo_setup_column(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_setup_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEIFINDEX: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEIFINDEX_FLAG; + rc = ipCidrRouteIfIndex_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTETYPE: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTETYPE_FLAG; + rc = ipCidrRouteType_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h + */ + case COLUMN_IPCIDRROUTEINFO: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEINFO_FLAG; + rc = ipCidrRouteInfo_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTENEXTHOPAS: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTENEXTHOPAS_FLAG; + rc = ipCidrRouteNextHopAS_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC1: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC1_FLAG; + rc = ipCidrRouteMetric1_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC2: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC2_FLAG; + rc = ipCidrRouteMetric2_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC3: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC3_FLAG; + rc = ipCidrRouteMetric3_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC4: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC4_FLAG; + rc = ipCidrRouteMetric4_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC5: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC5_FLAG; + rc = ipCidrRouteMetric5_undo_setup(rowreq_ctx); + break; + + /* + * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTESTATUS: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTESTATUS_FLAG; + rc = ipCidrRouteStatus_undo_setup(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipCidrRouteTable_undo_setup_column\n", + column); + break; + } + + return rc; +} /* _ipCidrRouteTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_ipCidrRouteTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_setup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rowreq_ctx->undo = ipCidrRouteTable_allocate_data(); + if (NULL == rowreq_ctx->undo) { + /** msg already logged */ + netsnmp_request_set_error_all(requests, + SNMP_ERR_RESOURCEUNAVAILABLE); + return SNMP_ERR_NOERROR; + } + + /* + * row undo setup + */ + rowreq_ctx->column_set_flags = 0; + rc = ipCidrRouteTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_undo_setup\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } else { + /* + * column undo setup + */ + netsnmp_table_request_info *tri; + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipCidrRouteTable_undo_setup_column(rowreq_ctx, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_undo_setup_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_ipCidrRouteTable_undo_cleanup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_cleanup", "called\n")); + + /* + * failed row create in early stages has no rowreq_ctx + */ + if (NULL == rowreq_ctx) + return MFD_SUCCESS; + + /* + * call user cleanup + */ + rc = ipCidrRouteTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + if (rowreq_ctx->undo) { + ipCidrRouteTable_release_data(rowreq_ctx->undo); + rowreq_ctx->undo = NULL; + } + + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipCidrRouteTable_set_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_set_column", + "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEIFINDEX: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEIFINDEX_FLAG; + rc = ipCidrRouteIfIndex_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTETYPE: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTETYPE_FLAG; + rc = ipCidrRouteType_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h + */ + case COLUMN_IPCIDRROUTEINFO: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEINFO_FLAG; + rc = ipCidrRouteInfo_set(rowreq_ctx, (oid *) var->val.string, + var->val_len); + break; + + /* + * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTENEXTHOPAS: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTENEXTHOPAS_FLAG; + rc = ipCidrRouteNextHopAS_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC1: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC1_FLAG; + rc = ipCidrRouteMetric1_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC2: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC2_FLAG; + rc = ipCidrRouteMetric2_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC3: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC3_FLAG; + rc = ipCidrRouteMetric3_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC4: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC4_FLAG; + rc = ipCidrRouteMetric4_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC5: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC5_FLAG; + rc = ipCidrRouteMetric5_set(rowreq_ctx, + *((long *) var->val.string)); + break; + + /* + * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTESTATUS: + rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTESTATUS_FLAG; + rc = ipCidrRouteStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipCidrRouteTable_set_column\n", + column); + rc = SNMP_ERR_GENERR; + break; + } + + return rc; +} /* _ipCidrRouteTable_set_column */ + +int +_mfd_ipCidrRouteTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_set_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rowreq_ctx->column_set_flags = 0; + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipCidrRouteTable_set_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_ipCidrRouteTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_commit", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipCidrRouteTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_commit\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + /* + * if we successfully commited this row, set the dirty flag. Use the + * current value + 1 (i.e. dirty = # rows changed). + * this is checked in post_request... + */ + ipCidrRouteTable_dirty_set(ipCidrRouteTable_dirty_get() + 1); /* set table dirty flag */ + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_ipCidrRouteTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + u_int d = ipCidrRouteTable_dirty_get(); + + netsnmp_assert(d != 0); + if (d) + ipCidrRouteTable_dirty_set(d - 1); + } + + rc = ipCidrRouteTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_undo_commit\n", rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + snmp_log(LOG_WARNING, + "ipCidrRouteTable row dirty flag still set after undo_commit\n"); + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +/** + * @internal + * undo the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipCidrRouteTable_undo_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_column", + "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEIFINDEX: + rc = ipCidrRouteIfIndex_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTETYPE: + rc = ipCidrRouteType_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h + */ + case COLUMN_IPCIDRROUTEINFO: + rc = ipCidrRouteInfo_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTENEXTHOPAS: + rc = ipCidrRouteNextHopAS_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC1: + rc = ipCidrRouteMetric1_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC2: + rc = ipCidrRouteMetric2_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC3: + rc = ipCidrRouteMetric3_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC4: + rc = ipCidrRouteMetric4_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h + */ + case COLUMN_IPCIDRROUTEMETRIC5: + rc = ipCidrRouteMetric5_undo(rowreq_ctx); + break; + + /* + * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPCIDRROUTESTATUS: + rc = ipCidrRouteStatus_undo(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipCidrRouteTable_undo_column\n", + column); + break; + } + + return rc; +} /* _ipCidrRouteTable_undo_column */ + +int +_mfd_ipCidrRouteTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipCidrRouteTable_undo(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_undo\n", rc)); + } + + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipCidrRouteTable_undo_column(rowreq_ctx, requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from " + "ipCidrRouteTable_undo_column\n", rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_undo_values */ + +/*---------------------------------------------------------------------- + * + * SET: irreversible commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit irreversible actions + */ +int +_mfd_ipCidrRouteTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_irreversible:commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * check for and handle row creation/deletion + * and update column exist flags... + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)) + CONTAINER_REMOVE(ipCidrRouteTable_if_ctx.container, rowreq_ctx); + } else { + if (rowreq_ctx->column_set_flags) { + rowreq_ctx->column_set_flags = 0; + } + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(ipCidrRouteTable_if_ctx.container, + rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipCidrRouteTable_irreversible_commit */ +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +static void _container_free(netsnmp_container *container); + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for ipCidrRouteTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return ipCidrRouteTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in ipCidrRouteTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:ipCidrRouteTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:ipCidrRouteTable:_container_free", "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipCidrRouteTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipCidrRouteTable_container_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *) _container_item_free, + NULL); +} /* _container_free */ + +/** + * @internal + * initialize the container with functions or wrappers + */ +void +_ipCidrRouteTable_container_init(ipCidrRouteTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_container_init", "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(IPCIDRROUTETABLE_CACHE_TIMEOUT, + _cache_load, _cache_free, + ipCidrRouteTable_oid, + ipCidrRouteTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for ipCidrRouteTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("ipCidrRouteTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipCidrRouteTable_container_init\n"); + return; + } + } + + if_ctx->container->container_name = strdup("ipCidrRouteTable"); + + /* set allow duplicates this makes insert O(1) */ + netsnmp_binary_array_options_set(if_ctx->container, 1, + CONTAINER_KEY_ALLOW_DUPLICATES); + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _ipCidrRouteTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipCidrRouteTable_container_shutdown(ipCidrRouteTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_container_shutdown", "called\n")); + + ipCidrRouteTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipCidrRouteTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_EXTERNAL_ACCESS +ipCidrRouteTable_rowreq_ctx * +ipCidrRouteTable_row_find_by_mib_index(ipCidrRouteTable_mib_index * + mib_idx) +{ + ipCidrRouteTable_rowreq_ctx *rowreq_ctx; + oid oid_tmp[MAX_OID_LEN]; + netsnmp_index oid_idx; + int rc; + + /* + * set up storage for OID + */ + oid_idx.oids = oid_tmp; + oid_idx.len = sizeof(oid_tmp) / sizeof(oid); + + /* + * convert + */ + rc = ipCidrRouteTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*) + CONTAINER_FIND(ipCidrRouteTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_EXTERNAL_ACCESS */ diff --git a/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.h b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.h new file mode 100644 index 0000000..596a46e --- /dev/null +++ b/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.h @@ -0,0 +1,100 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.67 $ of : mfd-interface.m2c,v $ + * + * $Id$ + */ +/** @ingroup interface Routines to interface to Net-SNMP + * + * \warning This code should not be modified, called directly, + * or used to interpret functionality. It is subject to + * change at any time. + * + * @{ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ +#ifndef IPCIDRROUTETABLE_INTERFACE_H +#define IPCIDRROUTETABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipCidrRouteTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipCidrRouteTable_initialize_interface + (ipCidrRouteTable_registration * user_ctx, u_long flags); + void + _ipCidrRouteTable_shutdown_interface(ipCidrRouteTable_registration + * user_ctx); + ipCidrRouteTable_registration *ipCidrRouteTable_registration_get(void); + + ipCidrRouteTable_registration + * ipCidrRouteTable_registration_set(ipCidrRouteTable_registration * + newreg); + + netsnmp_container *ipCidrRouteTable_container_get(void); + int ipCidrRouteTable_container_size(void); + + u_int ipCidrRouteTable_dirty_get(void); + void ipCidrRouteTable_dirty_set(u_int status); + + ipCidrRouteTable_rowreq_ctx + * ipCidrRouteTable_allocate_rowreq_ctx(ipCidrRouteTable_data *, + void *); + void + ipCidrRouteTable_release_rowreq_ctx(ipCidrRouteTable_rowreq_ctx * + rowreq_ctx); + + int ipCidrRouteTable_index_to_oid(netsnmp_index * oid_idx, + ipCidrRouteTable_mib_index + * mib_idx); + int ipCidrRouteTable_index_from_oid(netsnmp_index * + oid_idx, + ipCidrRouteTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void ipCidrRouteTable_valid_columns_set(netsnmp_column_info + *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* IPCIDRROUTETABLE_INTERFACE_H */ +/** @} */ + |