diff options
Diffstat (limited to 'agent/mibgroup/ip-mib')
105 files changed, 46206 insertions, 0 deletions
diff --git a/agent/mibgroup/ip-mib/data_access/arp.h b/agent/mibgroup/ip-mib/data_access/arp.h new file mode 100644 index 0000000..0f536c3 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/arp.h @@ -0,0 +1,31 @@ +/* + * arp 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-mib/data_access/arp_common) +#if defined( HAVE_LINUX_RTNETLINK_H ) +config_require(ip-mib/data_access/arp_netlink) +#elif defined( linux ) +config_require(ip-mib/data_access/arp_linux) +#else +/* + * couldn't determine the correct file! + */ +config_error(the arp data access library is not available in this environment.) +#endif + diff --git a/agent/mibgroup/ip-mib/data_access/arp_common.c b/agent/mibgroup/ip-mib/data_access/arp_common.c new file mode 100644 index 0000000..2958719 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/arp_common.c @@ -0,0 +1,83 @@ +/* + * Arp MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/arp.h> + +/**---------------------------------------------------------------------*/ +/* + * arp_entry functions + */ +/** + */ +netsnmp_arp_entry * +netsnmp_access_arp_entry_create(void) +{ + netsnmp_arp_entry *entry = + SNMP_MALLOC_TYPEDEF(netsnmp_arp_entry); + + if (NULL == entry) + return NULL; + + entry->oid_index.len = 1; + entry->oid_index.oids = &entry->ns_arp_index; + + return entry; +} + +/** + */ +void +netsnmp_access_arp_entry_free(netsnmp_arp_entry * entry) +{ + free(entry); +} + +/**---------------------------------------------------------------------*/ +/* + * Utility routines + */ + +/** + * Update given entry with new data. Calculate new arp_last_updated, if any + * field is changed. + */ +void netsnmp_access_arp_entry_update(netsnmp_arp_entry *entry, + netsnmp_arp_entry *new_data) +{ + int modified = 0; + + entry->generation = new_data->generation; + if (entry->arp_ipaddress_len != new_data->arp_ipaddress_len + || memcmp(entry->arp_ipaddress, new_data->arp_ipaddress, entry->arp_ipaddress_len) != 0 ) { + modified = 1; + entry->arp_ipaddress_len = new_data->arp_ipaddress_len; + memcpy(entry->arp_ipaddress, new_data->arp_ipaddress, sizeof(entry->arp_ipaddress)); + } + if (entry->arp_physaddress_len != new_data->arp_physaddress_len || + memcmp(entry->arp_physaddress, new_data->arp_physaddress, entry->arp_physaddress_len) != 0) { + modified = 1; + entry->arp_physaddress_len = new_data->arp_physaddress_len; + memcpy(entry->arp_physaddress, new_data->arp_physaddress, sizeof(entry->arp_physaddress_len)); + } + if (entry->arp_state != new_data->arp_state) { + modified = 1; + entry->arp_state = new_data->arp_state; + } + if (entry->arp_type != new_data->arp_type) { + modified = 1; + entry->arp_type = new_data->arp_type; + } + if (entry->flags != new_data->flags) { + modified = 1; + entry->flags = new_data->flags; + } + + if (modified) + entry->arp_last_updated = netsnmp_get_agent_uptime(); +} diff --git a/agent/mibgroup/ip-mib/data_access/arp_linux.c b/agent/mibgroup/ip-mib/data_access/arp_linux.c new file mode 100644 index 0000000..a2fa49a --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/arp_linux.c @@ -0,0 +1,214 @@ +/* + * Interface MIB architecture support + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/arp.h> +#include <net-snmp/data_access/interface.h> + +#include <sys/socket.h> +#include <netinet/in.h> +#include <net/if_arp.h> +#include <arpa/inet.h> +#include <linux/types.h> +#include <asm/types.h> + +static int _load_v4(netsnmp_arp_access *access); + +netsnmp_arp_access * +netsnmp_access_arp_create(u_int init_flags, + NetsnmpAccessArpUpdate *update_hook, + NetsnmpAccessArpGC *gc_hook, + int *cache_timeout, int *cache_flags, + char *cache_expired) +{ + netsnmp_arp_access *access; + + access = SNMP_MALLOC_TYPEDEF(netsnmp_arp_access); + if (NULL == access) { + snmp_log(LOG_ERR,"malloc error in netsnmp_access_arp_create\n"); + return NULL; + } + + access->arch_magic = NULL; + access->magic = NULL; + access->update_hook = update_hook; + access->gc_hook = gc_hook; + access->synchronized = 0; + + if (cache_timeout != NULL) + *cache_timeout = 5; + if (cache_flags != NULL) + *cache_flags |= NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD + | NETSNMP_CACHE_AUTO_RELOAD; + access->cache_expired = cache_expired; + + return access; +} + +int netsnmp_access_arp_delete(netsnmp_arp_access *access) +{ + if (NULL == access) + return 0; + + netsnmp_access_arp_unload(access); + free(access); + + return 0; +} + +int netsnmp_access_arp_load(netsnmp_arp_access *access) +{ + int rc = 0; + + access->generation++; + rc =_load_v4(access); + access->gc_hook(access); + access->synchronized = (rc == 0); + + return rc; +} + +int netsnmp_access_arp_unload(netsnmp_arp_access *access) +{ + access->synchronized = 0; + + return 0; +} + +/** + */ +static int +_load_v4(netsnmp_arp_access *access) +{ + FILE *in; + char line[128]; + int rc = 0; + netsnmp_arp_entry *entry; + char arp[3*NETSNMP_ACCESS_ARP_PHYSADDR_BUF_SIZE+1]; + char *arp_token; + int i; + + netsnmp_assert(NULL != access); + +#define PROCFILE "/proc/net/arp" + if (!(in = fopen(PROCFILE, "r"))) { + snmp_log(LOG_DEBUG,"could not open " PROCFILE "\n"); + return -2; + } + + /* + * Get rid of the header line + */ + fgets(line, sizeof(line), in); + + /* + * IP address | HW | Flag | HW address | Mask | Device + * 192.168.1.4 0x1 0x2 00:40:63:CC:1C:8C * eth0 + */ + while (fgets(line, sizeof(line), in)) { + + int za, zb, zc, zd; + unsigned int tmp_flags; + char ifname[21]; + + rc = sscanf(line, + "%d.%d.%d.%d 0x%*x 0x%x %96s %*[^ ] %20s\n", + &za, &zb, &zc, &zd, &tmp_flags, arp, ifname); + if (7 != rc) { + snmp_log(LOG_ERR, PROCFILE " data format error (%d!=12)\n", rc); + snmp_log(LOG_ERR, " line ==|%s|\n", line); + continue; + } + DEBUGMSGTL(("access:arp:container", + "ip addr %d.%d.%d.%d, flags 0x%X, hw addr " + "%s, name %s\n", + za,zb,zc,zd, tmp_flags, arp, ifname )); + + /* + */ + entry = netsnmp_access_arp_entry_create(); + if(NULL == entry) { + rc = -3; + break; + } + + /* + * look up ifIndex + */ + entry->generation = access->generation; + entry->if_index = netsnmp_access_interface_index_find(ifname); + if(0 == entry->if_index) { + snmp_log(LOG_ERR,"couldn't find ifIndex for '%s', skipping\n", + ifname); + netsnmp_access_arp_entry_free(entry); + continue; + } + + /* + * now that we've passed all the possible 'continue', assign + * index offset. + */ + /* entry->ns_arp_index = ++idx_offset; */ + + /* + * parse ip addr + */ + entry->arp_ipaddress[0] = za; + entry->arp_ipaddress[1] = zb; + entry->arp_ipaddress[2] = zc; + entry->arp_ipaddress[3] = zd; + entry->arp_ipaddress_len = 4; + + /* + * parse hw addr + */ + for (arp_token = strtok(arp, ":"), i=0; arp_token != NULL; arp_token = strtok(NULL, ":"), i++) { + entry->arp_physaddress[i] = strtol(arp_token, NULL, 16); + } + entry->arp_physaddress_len = i; + + /* + * what can we do with hw? from arp manpage: + + default value of this parameter is ether (i.e. hardware code + 0x01 for IEEE 802.3 10Mbps Ethernet). Other values might + include network technologies such as ARCnet (arcnet) , PROnet + (pronet) , AX.25 (ax25) and NET/ROM (netrom). + */ + + /* + * parse mask + */ + /* xxx-rks: what is mask? how to interpret '*'? */ + + + /* + * process type + */ + if(tmp_flags & ATF_PERM) + entry->arp_type = INETNETTOMEDIATYPE_STATIC; + else + entry->arp_type = INETNETTOMEDIATYPE_DYNAMIC; + + /* + * process status + * if flags are 0, we can't tell the difference between + * stale or incomplete. + */ + if(tmp_flags & ATF_COM) + entry->arp_state = INETNETTOMEDIASTATE_REACHABLE; + else + entry->arp_state = INETNETTOMEDIASTATE_UNKNOWN; + + /* + * add entry to container + */ + access->update_hook(access, entry); + } + + fclose(in); + return 0; +} diff --git a/agent/mibgroup/ip-mib/data_access/arp_netlink.c b/agent/mibgroup/ip-mib/data_access/arp_netlink.c new file mode 100644 index 0000000..2059c23 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/arp_netlink.c @@ -0,0 +1,304 @@ +/* + * Interface MIB architecture support + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/arp.h> +#include <net-snmp/data_access/interface.h> + +#include <errno.h> +#include <sys/types.h> +#include <linux/types.h> +#include <linux/rtnetlink.h> + + +static int fillup_entry_info(netsnmp_arp_entry *entry, struct nlmsghdr *h); +static void netsnmp_access_arp_read_netlink(int fd, void *data); + +/** + */ +netsnmp_arp_access * +netsnmp_access_arp_create(u_int init_flags, + NetsnmpAccessArpUpdate *update_hook, + NetsnmpAccessArpGC *gc_hook, + int *cache_timeout, int *cache_flags, + char *cache_expired) +{ + netsnmp_arp_access *access; + + access = SNMP_MALLOC_TYPEDEF(netsnmp_arp_access); + if (NULL == access) { + snmp_log(LOG_ERR,"malloc error in netsnmp_access_arp_create\n"); + return NULL; + } + + access->arch_magic = NULL; + access->magic = NULL; + access->update_hook = update_hook; + access->gc_hook = gc_hook; + access->synchronized = 0; + + if (cache_timeout != NULL) + *cache_timeout = 5; + if (cache_flags != NULL) + *cache_flags |= NETSNMP_CACHE_RESET_TIMER_ON_USE | NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD; + access->cache_expired = cache_expired; + + DEBUGMSGTL(("access:netlink:arp", "create arp cache\n")); + + return access; +} + +int netsnmp_access_arp_delete(netsnmp_arp_access *access) +{ + if (NULL == access) + return 0; + + netsnmp_access_arp_unload(access); + free(access); + + return 0; +} + +int netsnmp_access_arp_load(netsnmp_arp_access *access) +{ + int r, fd = (uintptr_t) access->arch_magic; + struct { + struct nlmsghdr n; + struct ndmsg r; + } req; + + if (access->synchronized) + return 0; + + if (fd == 0) { + struct sockaddr_nl sa; + + fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); + if (fd < 0) { + snmp_log(LOG_ERR,"netsnmp_access_arp_load: netlink socket create error\n"); + return -1; + } + access->arch_magic = (void *)(uintptr_t)fd; + + memset(&sa, 0, sizeof(sa)); + sa.nl_family = AF_NETLINK; + sa.nl_groups = RTMGRP_NEIGH; + if (bind(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) { + snmp_log(LOG_ERR,"netsnmp_access_arp_load: netlink bind failed\n"); + return -1; + } + + if (register_readfd(fd, netsnmp_access_arp_read_netlink, access) != 0) { + snmp_log(LOG_ERR,"netsnmp_access_arp_load: error registering netlink socket\n"); + return -1; + } + } + + DEBUGMSGTL(("access:netlink:arp", "synchronizing arp table\n")); + + access->generation++; + + memset(&req, 0, sizeof(req)); + req.n.nlmsg_len = sizeof(req); + req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; + req.n.nlmsg_type = RTM_GETNEIGH; + req.r.ndm_family = AF_UNSPEC; + + r = send(fd, &req, req.n.nlmsg_len, 0); + if (r < 0) { + snmp_log(LOG_ERR,"netsnmp_access_arp_refresh: send failed\n"); + return -1; + } + + while (!access->synchronized) + netsnmp_access_arp_read_netlink(fd, access); + access->gc_hook(access); + + return 0; +} + +int netsnmp_access_arp_unload(netsnmp_arp_access *access) +{ + int fd; + + DEBUGMSGTL(("access:netlink:arp", "unload arp cache\n")); + + fd = (uintptr_t) access->arch_magic; + if (fd > 0) { + unregister_readfd(fd); + close(fd); + access->arch_magic = NULL; + access->synchronized = 0; + } + return 0; +} + +static void netsnmp_access_arp_read_netlink(int fd, void *data) +{ + netsnmp_arp_access *access = (netsnmp_arp_access *) data; + netsnmp_arp_entry *entry; + char buf[16384]; + struct nlmsghdr *h; + int r, len; + + do { + r = recv(fd, buf, sizeof(buf), MSG_DONTWAIT); + if (r < 0) { + if (errno == EINTR) + continue; + if (errno == EAGAIN) + return; + snmp_log(LOG_WARNING, "netlink buffer overrun\n"); + access->synchronized = 0; + if (access->cache_expired != NULL) + *access->cache_expired = 1; + return; + } + } while (0); + len = r; + + for (h = (struct nlmsghdr *) buf; NLMSG_OK(h, len); h = NLMSG_NEXT(h, len)) { + if (h->nlmsg_type == NLMSG_DONE) { + access->synchronized = 1; + continue; + } + + entry = netsnmp_access_arp_entry_create(); + if (NULL == entry) + break; + + DEBUGMSGTL(("access:netlink:arp", "arp netlink notification\n")); + + entry->generation = access->generation; + r = fillup_entry_info (entry, h); + if (r > 0) { + access->update_hook(access, entry); + } else { + if (r < 0) { + NETSNMP_LOGONCE((LOG_ERR, "filling entry info failed\n")); + DEBUGMSGTL(("access:netlink:arp", "filling entry info failed\n")); + } + netsnmp_access_arp_entry_free(entry); + } + } +} + +static int +fillup_entry_info(netsnmp_arp_entry *entry, struct nlmsghdr *nlmp) +{ + struct ndmsg *rtmp; + struct rtattr *tb[NDA_MAX + 1], *rta; + int length; + + rtmp = (struct ndmsg *) NLMSG_DATA(nlmp); + switch (nlmp->nlmsg_type) { + case RTM_NEWNEIGH: + if (rtmp->ndm_state == NUD_FAILED) + entry->flags = NETSNMP_ACCESS_ARP_ENTRY_FLAG_DELETE; + else + entry->flags = 0; + break; + case RTM_DELNEIGH: + entry->flags = NETSNMP_ACCESS_ARP_ENTRY_FLAG_DELETE; + break; + case RTM_GETNEIGH: + return 0; + default: + DEBUGMSGTL(("access:netlink:arp", + "Wrong Netlink message type %d\n", nlmp->nlmsg_type)); + return -1; + } + + if (rtmp->ndm_state == NUD_NOARP) { + /* NUD_NOARP is for broadcast addresses and similar, + * drop them silently */ + return 0; + } + + memset(tb, 0, sizeof(struct rtattr *) * (NDA_MAX + 1)); + length = nlmp->nlmsg_len - NLMSG_LENGTH(sizeof(*rtmp)); + rta = ((struct rtattr *) (((char *) (rtmp)) + NLMSG_ALIGN(sizeof(struct ndmsg)))); + while (RTA_OK(rta, length)) { + if (rta->rta_type <= NDA_MAX) + tb[rta->rta_type] = rta; + rta = RTA_NEXT(rta, length); + } + + /* + * Fill up the index and addresses + */ + entry->if_index = rtmp->ndm_ifindex; + if (tb[NDA_DST]) { + entry->arp_ipaddress_len = RTA_PAYLOAD(tb[NDA_DST]); + if (entry->arp_ipaddress_len > sizeof(entry->arp_ipaddress)) { + snmp_log(LOG_ERR, "netlink ip address length %d is too long\n", + entry->arp_ipaddress_len); + return -1; + } + memcpy(entry->arp_ipaddress, RTA_DATA(tb[NDA_DST]), + entry->arp_ipaddress_len); + } + if (tb[NDA_LLADDR]) { + entry->arp_physaddress_len = RTA_PAYLOAD(tb[NDA_LLADDR]); + if (entry->arp_physaddress_len > sizeof(entry->arp_physaddress)) { + snmp_log(LOG_ERR, "netlink hw address length %d is too long\n", + entry->arp_physaddress_len); + return -1; + } + memcpy(entry->arp_physaddress, RTA_DATA(tb[NDA_LLADDR]), + entry->arp_physaddress_len); + } + + switch (rtmp->ndm_state) { + case NUD_INCOMPLETE: + entry->arp_state = INETNETTOMEDIASTATE_INCOMPLETE; + break; + case NUD_REACHABLE: + case NUD_PERMANENT: + entry->arp_state = INETNETTOMEDIASTATE_REACHABLE; + break; + case NUD_STALE: + entry->arp_state = INETNETTOMEDIASTATE_STALE; + break; + case NUD_DELAY: + entry->arp_state = INETNETTOMEDIASTATE_DELAY; + break; + case NUD_PROBE: + entry->arp_state = INETNETTOMEDIASTATE_PROBE; + break; + case NUD_FAILED: + entry->arp_state = INETNETTOMEDIASTATE_INVALID; + break; + case NUD_NONE: + entry->arp_state = INETNETTOMEDIASTATE_UNKNOWN; + break; + default: + snmp_log(LOG_ERR, "Unrecognized ARP entry state %d", rtmp->ndm_state); + break; + } + + switch (rtmp->ndm_state) { + case NUD_INCOMPLETE: + case NUD_FAILED: + case NUD_NONE: + entry->arp_type = INETNETTOMEDIATYPE_INVALID; + break; + case NUD_REACHABLE: + case NUD_STALE: + case NUD_DELAY: + case NUD_PROBE: + entry->arp_type = INETNETTOMEDIATYPE_DYNAMIC; + break; + case NUD_PERMANENT: + entry->arp_type = INETNETTOMEDIATYPE_STATIC; + break; + default: + entry->arp_type = INETNETTOMEDIATYPE_LOCAL; + break; + } + + return 1; +} diff --git a/agent/mibgroup/ip-mib/data_access/defaultrouter.h b/agent/mibgroup/ip-mib/data_access/defaultrouter.h new file mode 100644 index 0000000..a4dfbb1 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/defaultrouter.h @@ -0,0 +1,28 @@ +/* + * defaultrouter 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-mib/data_access/defaultrouter_common) +#if defined( linux ) +config_require(ip-mib/data_access/defaultrouter_linux) +#else +/* + * couldn't determine the correct file! + */ +config_error(the defaultrouter data access library is not available in this environment.) +#endif diff --git a/agent/mibgroup/ip-mib/data_access/defaultrouter_common.c b/agent/mibgroup/ip-mib/data_access/defaultrouter_common.c new file mode 100644 index 0000000..ae85bfa --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/defaultrouter_common.c @@ -0,0 +1,291 @@ +/* + * defaultrouter MIB architecture support + * + * $Id:$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/defaultrouter.h> + +#include "ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h" + +/**---------------------------------------------------------------------*/ +/* + * local static prototypes + */ +static int _access_defaultrouter_entry_compare_addr(const void *lhs, + const void *rhs); +static void _access_defaultrouter_entry_release(netsnmp_defaultrouter_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_arch_defaultrouter_entry_init(netsnmp_defaultrouter_entry *entry); + +extern int +netsnmp_arch_defaultrouter_container_load(netsnmp_container* container, + u_int load_flags); + +/**---------------------------------------------------------------------*/ +/* + * container functions + */ +/** + */ +netsnmp_container * +netsnmp_access_defaultrouter_container_init(u_int flags) +{ + netsnmp_container *container1; + + DEBUGMSGTL(("access:defaultrouter:container", "init\n")); + + /* + * create the containers. one indexed by ifIndex, the other + * indexed by ifName. + */ + container1 = netsnmp_container_find("access_defaultrouter:table_container"); + if (NULL == container1) { + snmp_log(LOG_ERR, "defaultrouter primary container is not found\n"); + return NULL; + } + container1->container_name = strdup("dr_index"); + + if (flags & NETSNMP_ACCESS_DEFAULTROUTER_INIT_ADDL_IDX_BY_ADDR) { + netsnmp_container *container2 = + netsnmp_container_find("defaultrouter_addr:access_defaultrouter:table_container"); + if (NULL == container2) { + snmp_log(LOG_ERR, "defaultrouter secondary container not found\n"); + CONTAINER_FREE(container1); + return NULL; + } + + container2->compare = _access_defaultrouter_entry_compare_addr; + container2->container_name = strdup("dr_addr"); + + netsnmp_container_add_index(container1, container2); + } + + return container1; +} + +/** + * @retval NULL error + * @retval !NULL pointer to container + */ +netsnmp_container* +netsnmp_access_defaultrouter_container_load(netsnmp_container* container, + u_int load_flags) +{ + int rc; + u_int container_flags = 0; + + DEBUGMSGTL(("access:defaultrouter:container", "load\n")); + + if (NULL == container) { + if (load_flags & NETSNMP_ACCESS_DEFAULTROUTER_LOAD_ADDL_IDX_BY_ADDR) { + container_flags |= + NETSNMP_ACCESS_DEFAULTROUTER_INIT_ADDL_IDX_BY_ADDR; + } + container = + netsnmp_access_defaultrouter_container_init(container_flags); + } + + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_defaultrouter\n"); + return NULL; + } + + rc = netsnmp_arch_defaultrouter_container_load(container, load_flags); + if (0 != rc) { + netsnmp_access_defaultrouter_container_free(container, + NETSNMP_ACCESS_DEFAULTROUTER_FREE_NOFLAGS); + container = NULL; + } + + return container; +} + +void +netsnmp_access_defaultrouter_container_free(netsnmp_container *container, + u_int free_flags) +{ + DEBUGMSGTL(("access:defaultrouter:container", "free\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container for netsnmp_access_defaultrouter_free\n"); + return; + } + + if(! (free_flags & NETSNMP_ACCESS_DEFAULTROUTER_FREE_DONT_CLEAR)) { + /* + * free all items. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func*)_access_defaultrouter_entry_release, + NULL); + } + + if(! (free_flags & NETSNMP_ACCESS_DEFAULTROUTER_FREE_KEEP_CONTAINER)) + CONTAINER_FREE(container); +} + +/**---------------------------------------------------------------------*/ +/* + * defaultrouter_entry functions + */ +/** + */ +/** + */ +netsnmp_defaultrouter_entry * +netsnmp_access_defaultrouter_entry_create(void) +{ + int rc = 0; + netsnmp_defaultrouter_entry *entry = + SNMP_MALLOC_TYPEDEF(netsnmp_defaultrouter_entry); + + DEBUGMSGTL(("access:defaultrouter:entry", "create\n")); + + if(NULL == entry) + return NULL; + + entry->oid_index.len = 1; + entry->oid_index.oids = &entry->ns_dr_index; + + /* + * set up defaults + */ + entry->dr_lifetime = IPDEFAULTROUTERLIFETIME_MAX; + entry->dr_preference = IPDEFAULTROUTERPREFERENCE_MEDIUM; + + rc = netsnmp_arch_defaultrouter_entry_init(entry); + if (SNMP_ERR_NOERROR != rc) { + DEBUGMSGT(("access:defaultrouter:create","error %d in arch init\n", rc)); + netsnmp_access_defaultrouter_entry_free(entry); + entry = NULL; + } + + return entry; +} + +void +netsnmp_access_defaultrouter_entry_free(netsnmp_defaultrouter_entry * entry) +{ + if (NULL == entry) + return; + + free(entry); +} + +/** + * update an old defaultrouter_entry from a new one + * + * @note: only mib related items are compared. Internal objects + * such as oid_index, ns_dr_index and flags are not compared. + * + * @retval -1 : error + * @retval >=0 : number of fields updated + */ +int +netsnmp_access_defaultrouter_entry_update(netsnmp_defaultrouter_entry *lhs, + netsnmp_defaultrouter_entry *rhs) +{ + int changed = 0; + + if (lhs->dr_addresstype != rhs->dr_addresstype) { + ++changed; + lhs->dr_addresstype = rhs->dr_addresstype; + } + + if (lhs->dr_address_len != rhs->dr_address_len) { + changed += 2; + lhs->dr_address_len = rhs->dr_address_len; + memcpy(lhs->dr_address, rhs->dr_address, rhs->dr_address_len); + } + else if (memcmp(lhs->dr_address, rhs->dr_address, rhs->dr_address_len) != 0) { + ++changed; + memcpy(lhs->dr_address, rhs->dr_address, rhs->dr_address_len); + } + + if (lhs->dr_if_index != rhs->dr_if_index) { + ++changed; + lhs->dr_if_index = rhs->dr_if_index; + } + + if (lhs->dr_lifetime != rhs->dr_lifetime) { + ++changed; + lhs->dr_lifetime = rhs->dr_lifetime; + } + + if (lhs->dr_preference != rhs->dr_preference) { + ++changed; + lhs->dr_preference = rhs->dr_preference; + } + + return changed; +} + +/** + * copy an defaultrouter_entry + * + * @retval -1 : error + * @retval 0 : no error + */ +int +netsnmp_access_defaultrouter_entry_copy(netsnmp_defaultrouter_entry *lhs, + netsnmp_defaultrouter_entry *rhs) +{ + lhs->dr_addresstype = rhs->dr_addresstype; + lhs->dr_address_len = rhs->dr_address_len; + memcpy(lhs->dr_address, rhs->dr_address, rhs->dr_address_len); + lhs->dr_if_index = rhs->dr_if_index; + lhs->dr_lifetime = rhs->dr_lifetime; + lhs->dr_preference = rhs->dr_preference; + + return 0; +} + +/**---------------------------------------------------------------------*/ +/* + * Utility routines + */ + +/** + */ +void +_access_defaultrouter_entry_release(netsnmp_defaultrouter_entry * entry, void *context) +{ + netsnmp_access_defaultrouter_entry_free(entry); +} + +static int _access_defaultrouter_entry_compare_addr(const void *lhs, + const void *rhs) +{ + const netsnmp_defaultrouter_entry *lh = (const netsnmp_defaultrouter_entry *)lhs; + const netsnmp_defaultrouter_entry *rh = (const netsnmp_defaultrouter_entry *)rhs; + + netsnmp_assert(NULL != lhs); + netsnmp_assert(NULL != rhs); + + /* + * compare address length + */ + if (lh->dr_address_len < rh->dr_address_len) + return -1; + else if (lh->dr_address_len > rh->dr_address_len) + return 1; + + /* + * length equal, compare address + */ + return memcmp(lh->dr_address, rh->dr_address, lh->dr_address_len); +} diff --git a/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c b/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c new file mode 100644 index 0000000..5a1fa46 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c @@ -0,0 +1,328 @@ +/* + * Interface MIB architecture support + * + * $Id:$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/defaultrouter.h> + +#include "ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h" + +#include <asm/types.h> +#ifdef HAVE_LINUX_RTNETLINK_H +#include <linux/netlink.h> +#include <linux/rtnetlink.h> +#endif +#include <sys/socket.h> +#include <arpa/inet.h> +#include <errno.h> +#include <unistd.h> + +#define RCVBUF_SIZE 32768 +#define SNDBUF_SIZE 512 + +#ifdef NETSNMP_ENABLE_IPV6 +#define DR_ADDRSTRLEN INET6_ADDRSTRLEN +#else +#define DR_ADDRSTRLEN INET_ADDRSTRLEN +#endif + +/**---------------------------------------------------------------------*/ +/* + * local static prototypes + */ +static int _load(netsnmp_container *container); + + +/* + * initialize arch specific storage + * + * @retval 0: success + * @retval <0: error + */ +int +netsnmp_arch_defaultrouter_entry_init(netsnmp_defaultrouter_entry *entry) +{ + /* + * init + */ + return 0; +} + +/** + * + * @retval 0 no errors + * @retval !0 errors + */ +int +netsnmp_arch_defaultrouter_container_load(netsnmp_container *container, + u_int load_flags) +{ + int rc = 0; + + DEBUGMSGTL(("access:defaultrouter:entry:arch", "load (linux)\n")); + + rc = _load(container); + if (rc < 0) { + u_int flags = NETSNMP_ACCESS_DEFAULTROUTER_FREE_KEEP_CONTAINER; + netsnmp_access_defaultrouter_container_free(container, flags); + } + + return rc; +} + +/** + * + * @retval 0 no errors + * @retval !0 errors + */ +static int +_load(netsnmp_container *container) +{ +#ifndef HAVE_LINUX_RTNETLINK_H + DEBUGMSGTL(("access:defaultrouter", + "cannot get default router information" + "as netlink socket is not available\n")); + return -1; +#else + int rc = 0; + int idx_offset = 0; + netsnmp_defaultrouter_entry *entry; + int nlsk; + struct sockaddr_nl addr; + int rcvbuf_size = RCVBUF_SIZE; + unsigned char rcvbufmem[RCVBUF_SIZE + sizeof(intmax_t)]; + unsigned char sndbufmem[SNDBUF_SIZE + sizeof(intmax_t)]; + /* + * Buffers must be memory aligned. + * Message structure internal alignment is maintained by the netlink API. + */ + unsigned char *rcvbuf = rcvbufmem + + sizeof(intmax_t) - (((intptr_t)rcvbufmem) % sizeof(intmax_t)); + unsigned char *sndbuf = sndbufmem + + sizeof(intmax_t) - (((intptr_t)sndbufmem) % sizeof(intmax_t)); + struct nlmsghdr *hdr; + struct rtmsg *rthdr; + int count; + int end_of_message = 0; + long hz = sysconf(_SC_CLK_TCK); + + netsnmp_assert(NULL != container); + + /* + * Open a netlink socket + */ + nlsk = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); + if (nlsk < 0) { + snmp_log(LOG_ERR, "Could not open netlink socket : %s\n", + strerror(errno)); + return -1; + } + + if (setsockopt(nlsk, SOL_SOCKET, SO_RCVBUF, + &rcvbuf_size, sizeof(rcvbuf_size)) < 0) { + snmp_log(LOG_ERR, "Could not open netlink socket : %s\n", + strerror(errno)); + close(nlsk); + return -1; + } + + memset(&addr, '\0', sizeof(struct sockaddr_nl)); + addr.nl_family = AF_NETLINK; + + memset(sndbuf, '\0', SNDBUF_SIZE); + hdr = (struct nlmsghdr *)sndbuf; + hdr->nlmsg_type = RTM_GETROUTE; + hdr->nlmsg_pid = getpid(); + hdr->nlmsg_seq = 0; + hdr->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST; + hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); + rthdr = (struct rtmsg *)NLMSG_DATA(hdr); + rthdr->rtm_table = RT_TABLE_MAIN; + + /* + * Send a request to the kernel to dump the routing table to us + */ + count = sendto(nlsk, sndbuf, hdr->nlmsg_len, 0, + (struct sockaddr *)&addr, sizeof(struct sockaddr_nl)); + if (count < 0) { + snmp_log(LOG_ERR, "unable to send netlink message to kernel : %s\n", + strerror(errno)); + close(nlsk); + return -2; + } + + /* + * Now listen for response + */ + do { + struct nlmsghdr *nlmhp; + struct rtmsg *rtmp; + struct rtattr *rtap; + struct rta_cacheinfo *rtci; + socklen_t sock_len; + int rtcount; + + memset(rcvbuf, '\0', RCVBUF_SIZE); + sock_len = sizeof(struct sockaddr_nl); + + /* + * Get the message + */ + count = recvfrom(nlsk, rcvbuf, RCVBUF_SIZE, 0, + (struct sockaddr *)&addr, &sock_len); + if (count < 0) { + snmp_log(LOG_ERR, "unable to receive netlink messages: %s\n", + strerror(errno)); + rc = -1; + break; + } + + /* + * Walk all of the returned messages + */ + nlmhp = (struct nlmsghdr *)rcvbuf; + while (NLMSG_OK(nlmhp, count)) { + u_char addresstype; + char address[NETSNMP_ACCESS_DEFAULTROUTER_BUF_SIZE + 1]; + size_t address_len = 0; + int if_index = -1; + u_long lifetime = 0; + int preference = -3; + + /* + * Make sure the message is ok + */ + if (nlmhp->nlmsg_type == NLMSG_ERROR) { + snmp_log(LOG_ERR, "kernel produced nlmsg err\n"); + rc = -1; + break; + } + + /* + * End of message, we're done + */ + if (nlmhp->nlmsg_type & NLMSG_DONE) { + end_of_message = 1; + break; + } + + /* + * Get the pointer to the rtmsg struct + */ + rtmp = NLMSG_DATA(nlmhp); + + /* + * zero length destination is a default route + */ + if (rtmp->rtm_dst_len != 0) + goto next_nlmsghdr; + + /* + * Start scanning the attributes for needed info + */ + if (rtmp->rtm_family == AF_INET) { + addresstype = INETADDRESSTYPE_IPV4; + lifetime = IPDEFAULTROUTERLIFETIME_MAX; /* infinity */ + } +#ifdef NETSNMP_ENABLE_IPV6 + else if (rtmp->rtm_family == AF_INET6) { + addresstype = INETADDRESSTYPE_IPV6; + /* router lifetime for IPv6 is retrieved by RTA_CACHEINFO */ + lifetime = 0; + } +#endif + else + goto next_nlmsghdr; /* skip, we don't care about this route */ + + preference = 0; /* preference is medium(0) for now */ + + rtap = RTM_RTA(rtmp); + rtcount = RTM_PAYLOAD(nlmhp); + while (RTA_OK(rtap, rtcount)) { + switch (rtap->rta_type) { + case RTA_OIF: + if_index = *(int *)(RTA_DATA(rtap)); + break; + + case RTA_GATEWAY: + address_len = RTA_PAYLOAD(rtap); + memset(address, '\0', sizeof(address)); + memcpy(address, RTA_DATA(rtap), address_len); + break; + +#ifdef NETSNMP_ENABLE_IPV6 + case RTA_CACHEINFO: + rtci = RTA_DATA(rtap); + if ((rtmp->rtm_flags & RTM_F_CLONED) || + (rtci && rtci->rta_expires)) { + lifetime = rtci->rta_expires / hz; + } + break; +#endif + + default: + break; + } /* switch */ + + rtap = RTA_NEXT(rtap, rtcount); + } /* while RTA_OK(rtap) */ + + if (address_len != 0 && if_index != -1 && + lifetime != 0 && preference != -3 ) { + DEBUGIF("access:defaultrouter") { + char addr_str[DR_ADDRSTRLEN]; + memset(addr_str, '\0', DR_ADDRSTRLEN); + + if (rtmp->rtm_family == AF_INET) + inet_ntop(AF_INET, address, addr_str, DR_ADDRSTRLEN); +#ifdef NETSNMP_ENABLE_IPV6 + else + inet_ntop(AF_INET6, address, addr_str, DR_ADDRSTRLEN); +#endif + DEBUGMSGTL(("access:defaultrouter", + "found default route: %s if_index %d " + "lifetime %lu preference %d\n", + addr_str, if_index, lifetime, preference)); + } + + entry = netsnmp_access_defaultrouter_entry_create(); + if (NULL == entry) { + rc = -3; + break; + } + + entry->ns_dr_index = ++idx_offset; + entry->dr_addresstype = addresstype; + entry->dr_address_len = address_len; + memcpy(entry->dr_address, address, + NETSNMP_ACCESS_DEFAULTROUTER_BUF_SIZE); + entry->dr_if_index = if_index; + entry->dr_lifetime = lifetime; + entry->dr_preference = preference; + + if (CONTAINER_INSERT(container, entry) < 0) + { + DEBUGMSGTL(("access:arp:container", + "error with defaultrouter_entry: " + "insert into container failed.\n")); + netsnmp_access_defaultrouter_entry_free(entry); + } + } + +next_nlmsghdr: + nlmhp = NLMSG_NEXT(nlmhp, count); + } /* while NLMSG_OK(nlmhp) */ + + if (rc < 0) + break; + + } while (!end_of_message); + + close(nlsk); + return rc; +#endif /* HAVE_LINUX_RTNETLINK_H */ +} diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress.h b/agent/mibgroup/ip-mib/data_access/ipaddress.h new file mode 100644 index 0000000..9cf8181 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress.h @@ -0,0 +1,28 @@ +/* + * ipaddress 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-mib/data_access/ipaddress_common) +#if defined( linux ) +config_require(ip-mib/data_access/ipaddress_linux) +#elif defined( solaris2 ) +config_require(ip-mib/data_access/ipaddress_solaris2) +#else +config_error(the ipaddress data access library is not available in this environment.) +#endif + diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_common.c b/agent/mibgroup/ip-mib/data_access/ipaddress_common.c new file mode 100644 index 0000000..e305c9f --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress_common.c @@ -0,0 +1,519 @@ +/* + * Ipaddress MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/ipaddress.h> +#include <net-snmp/data_access/interface.h> + +#include "ip-mib/ipAddressTable/ipAddressTable_constants.h" + +#include <net-snmp/net-snmp-features.h> + +netsnmp_feature_child_of(ipaddress_common, libnetsnmpmibs) + +netsnmp_feature_child_of(ipaddress_common_copy_utilities, ipaddress_common) +netsnmp_feature_child_of(ipaddress_entry_copy, ipaddress_common) +netsnmp_feature_child_of(ipaddress_entry_update, ipaddress_common) +netsnmp_feature_child_of(ipaddress_prefix_copy, ipaddress_common_copy_utilities) + +#ifdef NETSNMP_FEATURE_REQUIRE_IPADDRESS_ENTRY_COPY +netsnmp_feature_require(ipaddress_arch_entry_copy) +#endif /* NETSNMP_FEATURE_REQUIRE_IPADDRESS_ENTRY_COPY */ + +/**---------------------------------------------------------------------*/ +/* + * local static prototypes + */ +static int _access_ipaddress_entry_compare_addr(const void *lhs, + const void *rhs); +static void _access_ipaddress_entry_release(netsnmp_ipaddress_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_arch_ipaddress_container_load(netsnmp_container* container, + u_int load_flags); +extern int +netsnmp_arch_ipaddress_entry_init(netsnmp_ipaddress_entry *entry); +extern int +netsnmp_arch_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs); +extern void +netsnmp_arch_ipaddress_entry_cleanup(netsnmp_ipaddress_entry *entry); +extern int +netsnmp_arch_ipaddress_create(netsnmp_ipaddress_entry *entry); +extern int +netsnmp_arch_ipaddress_delete(netsnmp_ipaddress_entry *entry); + + +/**---------------------------------------------------------------------*/ +/* + * container functions + */ +/** + */ +netsnmp_container * +netsnmp_access_ipaddress_container_init(u_int flags) +{ + netsnmp_container *container1; + + DEBUGMSGTL(("access:ipaddress:container", "init\n")); + + /* + * create the containers. one indexed by ifIndex, the other + * indexed by ifName. + */ + container1 = netsnmp_container_find("access_ipaddress:table_container"); + if (NULL == container1) { + snmp_log(LOG_ERR, "ipaddress primary container not found\n"); + return NULL; + } + container1->container_name = strdup("ia_index"); + + if (flags & NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR) { + netsnmp_container *container2 = + netsnmp_container_find("ipaddress_addr:access_ipaddress:table_container"); + if (NULL == container2) { + snmp_log(LOG_ERR, "ipaddress secondary container not found\n"); + CONTAINER_FREE(container1); + return NULL; + } + + container2->compare = _access_ipaddress_entry_compare_addr; + container2->container_name = strdup("ia_addr"); + + netsnmp_container_add_index(container1, container2); + } + + return container1; +} + +/** + * @retval NULL error + * @retval !NULL pointer to container + */ +netsnmp_container* +netsnmp_access_ipaddress_container_load(netsnmp_container* container, + u_int load_flags) +{ + int rc; + u_int container_flags = 0; + + DEBUGMSGTL(("access:ipaddress:container", "load\n")); + + if (NULL == container) { + if (load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_ADDL_IDX_BY_ADDR) + container_flags |= NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR; + container = netsnmp_access_ipaddress_container_init(container_flags); + } + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_ipaddress\n"); + return NULL; + } + + rc = netsnmp_arch_ipaddress_container_load(container, load_flags); + if (0 != rc) { + netsnmp_access_ipaddress_container_free(container, + NETSNMP_ACCESS_IPADDRESS_FREE_NOFLAGS); + container = NULL; + } + + return container; +} + +void +netsnmp_access_ipaddress_container_free(netsnmp_container *container, u_int free_flags) +{ + DEBUGMSGTL(("access:ipaddress:container", "free\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, "invalid container for netsnmp_access_ipaddress_free\n"); + return; + } + + if(! (free_flags & NETSNMP_ACCESS_IPADDRESS_FREE_DONT_CLEAR)) { + /* + * free all items. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func*)_access_ipaddress_entry_release, + NULL); + } + + if(! (free_flags & NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER)) + CONTAINER_FREE(container); +} + +/**---------------------------------------------------------------------*/ +/* + * ipaddress_entry functions + */ +/** + */ +/** + */ +netsnmp_ipaddress_entry * +netsnmp_access_ipaddress_entry_create(void) +{ + netsnmp_ipaddress_entry *entry = + SNMP_MALLOC_TYPEDEF(netsnmp_ipaddress_entry); + int rc = 0; + + entry->oid_index.len = 1; + entry->oid_index.oids = &entry->ns_ia_index; + + /* + * set up defaults + */ + entry->ia_type = IPADDRESSTYPE_UNICAST; + entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; + entry->ia_storagetype = STORAGETYPE_VOLATILE; + + rc = netsnmp_arch_ipaddress_entry_init(entry); + if (SNMP_ERR_NOERROR != rc) { + DEBUGMSGT(("access:ipaddress:create","error %d in arch init\n", rc)); + netsnmp_access_ipaddress_entry_free(entry); + entry = NULL; + } + + return entry; +} + +/** + */ +void +netsnmp_access_ipaddress_entry_free(netsnmp_ipaddress_entry * entry) +{ + if (NULL == entry) + return; + + if (NULL != entry->arch_data) + netsnmp_arch_ipaddress_entry_cleanup(entry); + + free(entry); +} + +/** + * update underlying data store (kernel) for entry + * + * @retval 0 : success + * @retval -1 : error + */ +int +netsnmp_access_ipaddress_entry_set(netsnmp_ipaddress_entry * entry) +{ + int rc = SNMP_ERR_NOERROR; + + if (NULL == entry) { + netsnmp_assert(NULL != entry); + return -1; + } + + /* + * make sure interface and ifIndex match up + */ + if (NULL == netsnmp_access_interface_name_find(entry->if_index)) { + DEBUGMSGT(("access:ipaddress:set", + "cant find name for index %" NETSNMP_PRIo "d\n", + entry->if_index)); + return -1; + } + + /* + * don't support non-volatile yet + */ + if (STORAGETYPE_VOLATILE != entry->ia_storagetype) { + DEBUGMSGT(("access:ipaddress:set", + "non-volatile storagetypes unsupported\n")); + return -1; + } + + /* + * + */ + rc = -1; + if (entry->flags & NETSNMP_ACCESS_IPADDRESS_CREATE) { + rc = netsnmp_arch_ipaddress_create(entry); + } + else if (entry->flags & NETSNMP_ACCESS_IPADDRESS_CHANGE) { + } + else if (entry->flags & NETSNMP_ACCESS_IPADDRESS_DELETE) { + rc = netsnmp_arch_ipaddress_delete(entry); + } + else { + snmp_log(LOG_ERR,"netsnmp_access_ipaddress_entry_set with no mode\n"); + netsnmp_assert(!"ipaddress_entry_set == unknown mode"); /* always false */ + rc = -1; + } + + return rc; +} + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_ENTRY_UPDATE +/** + * update an old ipaddress_entry from a new one + * + * @note: only mib related items are compared. Internal objects + * such as oid_index, ns_ia_index and flags are not compared. + * + * @retval -1 : error + * @retval >=0 : number of fields updated + */ +int +netsnmp_access_ipaddress_entry_update(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs) +{ + int rc, changed = 0; + + /* + * copy arch stuff. we don't care if it changed + */ + rc = netsnmp_arch_ipaddress_entry_copy(lhs,rhs); + if (0 != rc) { + snmp_log(LOG_ERR,"arch ipaddress copy failed\n"); + return -1; + } + + if (lhs->if_index != rhs->if_index) { + ++changed; + lhs->if_index = rhs->if_index; + } + + if (lhs->ia_storagetype != rhs->ia_storagetype) { + ++changed; + lhs->ia_storagetype = rhs->ia_storagetype; + } + + if (lhs->ia_address_len != rhs->ia_address_len) { + changed += 2; + lhs->ia_address_len = rhs->ia_address_len; + memcpy(lhs->ia_address, rhs->ia_address, rhs->ia_address_len); + } + else if (memcmp(lhs->ia_address, rhs->ia_address, rhs->ia_address_len) != 0) { + ++changed; + memcpy(lhs->ia_address, rhs->ia_address, rhs->ia_address_len); + } + + if (lhs->ia_type != rhs->ia_type) { + ++changed; + lhs->ia_type = rhs->ia_type; + } + + if (lhs->ia_status != rhs->ia_status) { + ++changed; + lhs->ia_status = rhs->ia_status; + } + + if (lhs->ia_origin != rhs->ia_origin) { + ++changed; + lhs->ia_origin = rhs->ia_origin; + } + + if (lhs->ia_onlink_flag != rhs->ia_onlink_flag) { + ++changed; + lhs->ia_onlink_flag = rhs->ia_onlink_flag; + } + + if (lhs->ia_autonomous_flag != rhs->ia_autonomous_flag) { + ++changed; + lhs->ia_autonomous_flag = rhs->ia_autonomous_flag; + } + + if (lhs->ia_prefered_lifetime != rhs->ia_prefered_lifetime) { + ++changed; + lhs->ia_prefered_lifetime = rhs->ia_prefered_lifetime; + } + + if (lhs->ia_valid_lifetime != rhs->ia_valid_lifetime) { + ++changed; + lhs->ia_valid_lifetime = rhs->ia_valid_lifetime; + } + + + return changed; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_ENTRY_UPDATE */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_ENTRY_COPY +/** + * copy an ipaddress_entry + * + * @retval -1 : error + * @retval 0 : no error + */ +int +netsnmp_access_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs) +{ + int rc; + + /* + * copy arch stuff. we don't care if it changed + */ + rc = netsnmp_arch_ipaddress_entry_copy(lhs,rhs); + if (0 != rc) { + snmp_log(LOG_ERR,"arch ipaddress copy failed\n"); + return -1; + } + + lhs->if_index = rhs->if_index; + lhs->ia_storagetype = rhs->ia_storagetype; + lhs->ia_address_len = rhs->ia_address_len; + memcpy(lhs->ia_address, rhs->ia_address, rhs->ia_address_len); + lhs->ia_type = rhs->ia_type; + lhs->ia_status = rhs->ia_status; + lhs->ia_origin = rhs->ia_origin; + + return 0; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_ENTRY_COPY */ + +/**---------------------------------------------------------------------*/ +/* + * Utility routines + */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_PREFIX_COPY +/** + * copy the prefix portion of an ip address + */ +int +netsnmp_ipaddress_prefix_copy(u_char *dst, u_char *src, int addr_len, int pfx_len) +{ + int bytes = pfx_len / 8; + int bits = pfx_len % 8; + + if ((NULL == dst) || (NULL == src) || (0 == pfx_len)) + return 0; + + memcpy(dst, src, bytes); + + if (bytes < addr_len) + memset(&dst[bytes],0x0, addr_len - bytes); + + if (bits) { + u_char mask = (0xff << (8-bits)); + + dst[bytes] = (src[bytes] & mask); + } + + return pfx_len; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_PREFIX_COPY */ + + +/** + * copy the prefix portion of an ip address + * + * @param mask network byte order make + * + * @returns number of prefix bits + */ +int +netsnmp_ipaddress_ipv4_prefix_len(in_addr_t mask) +{ + int len = 0; + + while((0xff000000 & mask) == 0xff000000) { + len += 8; + mask = mask << 8; + } + + while(0x80000000 & mask) { + ++len; + mask = mask << 1; + } + + return len; +} + + +/** + */ +void +_access_ipaddress_entry_release(netsnmp_ipaddress_entry * entry, void *context) +{ + netsnmp_access_ipaddress_entry_free(entry); +} + +static int _access_ipaddress_entry_compare_addr(const void *lhs, + const void *rhs) +{ + const netsnmp_ipaddress_entry *lh = (const netsnmp_ipaddress_entry *)lhs; + const netsnmp_ipaddress_entry *rh = (const netsnmp_ipaddress_entry *)rhs; + + netsnmp_assert(NULL != lhs); + netsnmp_assert(NULL != rhs); + + /* + * compare address length + */ + if (lh->ia_address_len < rh->ia_address_len) + return -1; + else if (lh->ia_address_len > rh->ia_address_len) + return 1; + + /* + * length equal, compare address + */ + return memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len); +} + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_COMMON_COPY_UTILITIES +int +netsnmp_ipaddress_flags_copy(u_long *ipAddressPrefixAdvPreferredLifetime, + u_long *ipAddressPrefixAdvValidLifetime, + u_long *ipAddressPrefixOnLinkFlag, + u_long *ipAddressPrefixAutonomousFlag, + u_long *ia_prefered_lifetime, + u_long *ia_valid_lifetime, + u_char *ia_onlink_flag, + u_char *ia_autonomous_flag) +{ + + /*Copy all the flags*/ + *ipAddressPrefixAdvPreferredLifetime = *ia_prefered_lifetime; + *ipAddressPrefixAdvValidLifetime = *ia_valid_lifetime; + *ipAddressPrefixOnLinkFlag = *ia_onlink_flag; + *ipAddressPrefixAutonomousFlag = *ia_autonomous_flag; + return 0; +} + +int +netsnmp_ipaddress_prefix_origin_copy(u_long *ipAddressPrefixOrigin, + u_char ia_origin, + int flags, + u_long ipAddressAddrType) +{ + if(ipAddressAddrType == INETADDRESSTYPE_IPV4){ + if(ia_origin == 6) /*Random*/ + (*ipAddressPrefixOrigin) = 3 /*IPADDRESSPREFIXORIGINTC_WELLKNOWN*/; + else + (*ipAddressPrefixOrigin) = ia_origin; + } else { + if(ia_origin == 5) { /*Link Layer*/ + if(!flags) /*Global address assigned by router adv*/ + (*ipAddressPrefixOrigin) = 5 /*IPADDRESSPREFIXORIGINTC_ROUTERADV*/; + else + (*ipAddressPrefixOrigin) = 3 /*IPADDRESSPREFIXORIGINTC_WELLKNOWN*/; + } + else if(ia_origin == 6) /*Random*/ + (*ipAddressPrefixOrigin) = 5 /*IPADDRESSPREFIXORIGINTC_ROUTERADV*/; + else + (*ipAddressPrefixOrigin) = ia_origin; + } + return 0; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_COMMON_COPY_UTILITIES */ + diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c b/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c new file mode 100644 index 0000000..cf65013 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c @@ -0,0 +1,746 @@ +/* + * Interface MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.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/ipaddress.h> +#include <net-snmp/data_access/interface.h> + +#include "ip-mib/ipAddressTable/ipAddressTable_constants.h" +#include "if-mib/data_access/interface_ioctl.h" + +#include <errno.h> +#include <net/if.h> +#include <sys/ioctl.h> + +#include "ipaddress_ioctl.h" + +netsnmp_feature_child_of(ipadress_ioctl_entry_copy, ipaddress_common) + +static void _print_flags(short flags); + +#define LIST_TOKEN "ioctl_extras" + +/* + * get extra structure + * + * @returns the extras structure from the entry + */ +_ioctl_extras * +netsnmp_ioctl_ipaddress_extras_get(netsnmp_ipaddress_entry *entry) +{ + if ((NULL == entry) || (NULL == entry->arch_data)) + return NULL; + + return (_ioctl_extras*)netsnmp_get_list_data(entry->arch_data, LIST_TOKEN); +} + +/** + * initialize ioctl extras + * + * @returns _ioctl_extras pointer, or NULL on error + */ +_ioctl_extras * +netsnmp_ioctl_ipaddress_entry_init(netsnmp_ipaddress_entry *entry) +{ + netsnmp_data_list *node; + _ioctl_extras *extras; + + if (NULL == entry) + return NULL; + + extras = SNMP_MALLOC_TYPEDEF(_ioctl_extras); + if (NULL == extras) + return NULL; + + node = netsnmp_create_data_list(LIST_TOKEN, extras, free); + if (NULL == node) { + free(extras); + return NULL; + } + + netsnmp_data_list_add_node( &entry->arch_data, node ); + + return extras; +} + +/** + * cleanup ioctl extras + */ +void +netsnmp_ioctl_ipaddress_entry_cleanup(netsnmp_ipaddress_entry *entry) +{ + if (NULL == entry) { + netsnmp_assert(NULL != entry); + return; + } + + if (NULL == entry->arch_data) { + netsnmp_assert(NULL != entry->arch_data); + return; + } + + netsnmp_remove_list_node(&entry->arch_data, LIST_TOKEN); +} + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_IOCTL_ENTRY_COPY +/** + * copy ioctl extras + * + * @retval 0: success + * @retval <0: error + */ +int +netsnmp_ioctl_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs) +{ + _ioctl_extras *lhs_extras, *rhs_extras; + int rc = SNMP_ERR_NOERROR; + + if ((NULL == lhs) || (NULL == rhs)) { + netsnmp_assert((NULL != lhs) && (NULL != rhs)); + return -1; + } + + rhs_extras = netsnmp_ioctl_ipaddress_extras_get(rhs); + lhs_extras = netsnmp_ioctl_ipaddress_extras_get(lhs); + if (NULL == rhs_extras) { + if (NULL != lhs_extras) + netsnmp_ioctl_ipaddress_entry_cleanup(lhs); + } + else { + if (NULL == lhs_extras) + lhs_extras = netsnmp_ioctl_ipaddress_entry_init(lhs); + + if (NULL != lhs_extras) + memcpy(lhs_extras, rhs_extras, sizeof(_ioctl_extras)); + else + rc = -1; + } + + return rc; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_IOCTL_ENTRY_COPY */ + +/** + * load ipv4 address via ioctl + */ +int +_netsnmp_ioctl_ipaddress_container_load_v4(netsnmp_container *container, + int idx_offset) +{ + int i, sd, rc = 0, interfaces = 0; + struct ifconf ifc; + struct ifreq *ifrp; + struct sockaddr save_addr; + struct sockaddr_in * si; + struct address_flag_info addr_info; + in_addr_t ipval; + _ioctl_extras *extras; + + if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + snmp_log(LOG_ERR, "could not create socket\n"); + return -1; + } + + interfaces = + netsnmp_access_ipaddress_ioctl_get_interface_count(sd, &ifc); + if(interfaces < 0) { + close(sd); + return -2; + } + netsnmp_assert(NULL != ifc.ifc_buf); + DEBUGMSGTL(("access:ipaddress:container", "processing %d interfaces\n", interfaces)); + + ifrp = ifc.ifc_req; + for(i=0; i < interfaces; ++i, ++ifrp) { + netsnmp_ipaddress_entry *entry, *bcastentry = NULL; + + DEBUGMSGTL(("access:ipaddress:container", + " interface %d, %s\n", i, ifrp->ifr_name)); + + if (AF_INET != ifrp->ifr_addr.sa_family) { + DEBUGMSGTL(("access:ipaddress:container", + " skipping %s; non AF_INET family %d\n", + ifrp->ifr_name, ifrp->ifr_addr.sa_family)); + continue; + } + + /* + */ + entry = netsnmp_access_ipaddress_entry_create(); + if(NULL == entry) { + rc = -3; + break; + } + entry->ns_ia_index = ++idx_offset; + + /* + * save if name + */ + extras = netsnmp_ioctl_ipaddress_extras_get(entry); + memcpy(extras->name, ifrp->ifr_name, sizeof(extras->name)); + + /* + * each time we make an ioctl, we need to specify the address, but + * it will be overwritten in the call. so we save address here. + */ + save_addr = ifrp->ifr_addr; + + /* + * set indexes + */ + si = (struct sockaddr_in *) &ifrp->ifr_addr; + entry->ia_address_len = sizeof(si->sin_addr.s_addr); + ipval = si->sin_addr.s_addr; + memcpy(entry->ia_address, &si->sin_addr.s_addr, + entry->ia_address_len); + + /* + * get ifindex + */ + { + /* + * I think that Linux and Solaris both use ':' in the + * interface name for aliases. When a new arch is added + * that uses some other indicator, a new function, maybe + * netsnmp_access_ipaddress_entry_name_alias_check(), will + * need to be written. + */ + char *ptr = strchr(ifrp->ifr_name, ':'); + if (NULL != ptr) { + entry->flags |= NETSNMP_ACCESS_IPADDRESS_ISALIAS; + *ptr = 0; + } + } + entry->if_index = + netsnmp_access_interface_ioctl_ifindex_get(sd, ifrp->ifr_name); + if (0 == entry->if_index) { + snmp_log(LOG_ERR,"no ifindex found for interface\n"); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + + /* restore the interface name if we modifed it due to unaliasing + * above + */ + if (entry->flags & NETSNMP_ACCESS_IPADDRESS_ISALIAS) { + memcpy(ifrp->ifr_name, extras->name, sizeof(extras->name)); + } + + /* + * get broadcast + */ + memset(&addr_info, 0, sizeof(struct address_flag_info)); +#if defined (NETSNMP_ENABLE_IPV6) + addr_info = netsnmp_access_other_info_get(entry->if_index, AF_INET); + if(addr_info.bcastflg) { + bcastentry = netsnmp_access_ipaddress_entry_create(); + if(NULL == bcastentry) { + rc = -3; + break; + } + bcastentry->if_index = entry->if_index; + bcastentry->ns_ia_index = ++idx_offset; + bcastentry->ia_address_len = sizeof(addr_info.addr); + memcpy(bcastentry->ia_address, &addr_info.addr, + bcastentry->ia_address_len); + } +#endif + + /* + * get netmask + */ + ifrp->ifr_addr = save_addr; + if (ioctl(sd, SIOCGIFNETMASK, ifrp) < 0) { + snmp_log(LOG_ERR, + "error getting netmask for interface %d\n", i); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + netsnmp_assert(AF_INET == ifrp->ifr_addr.sa_family); + si = (struct sockaddr_in *) &ifrp->ifr_addr; + entry->ia_prefix_len = + netsnmp_ipaddress_ipv4_prefix_len(ntohl(si->sin_addr.s_addr)); + if(bcastentry) + bcastentry->ia_prefix_len = entry->ia_prefix_len; + + + /* + * get flags + */ + ifrp->ifr_addr = save_addr; + if (ioctl(sd, SIOCGIFFLAGS, ifrp) < 0) { + snmp_log(LOG_ERR, + "error getting if_flags for interface %d\n", i); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + extras->flags = ifrp->ifr_flags; + + if(bcastentry) + bcastentry->ia_type = IPADDRESSTYPE_BROADCAST; + if(addr_info.anycastflg) + entry->ia_type = IPADDRESSTYPE_ANYCAST; + else + entry->ia_type = IPADDRESSTYPE_UNICAST; + + /** entry->ia_prefix_oid ? */ + + /* + * per the MIB: + * In the absence of other information, an IPv4 address is + * always preferred(1). + */ + entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; + if(bcastentry) + bcastentry->ia_status = IPADDRESSSTATUSTC_PREFERRED; + + /* + * can we figure out if an address is from DHCP? + * use manual until then... + */ + if(IS_APIPA(ipval)) { + entry->ia_origin = IPADDRESSORIGINTC_RANDOM; + if(bcastentry) + bcastentry->ia_origin = IPADDRESSORIGINTC_RANDOM; + } + else { + entry->ia_origin = IPADDRESSORIGINTC_MANUAL; + if(bcastentry) + bcastentry->ia_origin = IPADDRESSORIGINTC_MANUAL; + } + + DEBUGIF("access:ipaddress:container") { + DEBUGMSGT_NC(("access:ipaddress:container", + " if %d: addr len %d, index 0x%" NETSNMP_PRIo "x\n", + i, entry->ia_address_len, entry->if_index)); + if (4 == entry->ia_address_len) + DEBUGMSGT_NC(("access:ipaddress:container", " address %p\n", + *((void**)entry->ia_address))); + DEBUGMSGT_NC(("access:ipaddress:container", "flags 0x%x\n", + extras->flags)); + _print_flags(extras->flags); + + } + + /* + * add entry to container + */ + if(bcastentry){ + if (CONTAINER_INSERT(container, bcastentry) < 0) { + DEBUGMSGTL(("access:ipaddress:container","error with ipaddress_entry: insert broadcast entry into container failed.\n")); + netsnmp_access_ipaddress_entry_free(bcastentry); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + bcastentry = NULL; + } + + if (CONTAINER_INSERT(container, entry) < 0) { + DEBUGMSGTL(("access:ipaddress:container","error with ipaddress_entry: insert into container failed.\n")); + NETSNMP_LOGONCE((LOG_ERR, "Duplicate IPv4 address detected, some interfaces may not be visible in IP-MIB\n")); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + } + + /* + * clean up + */ + free(ifc.ifc_buf); + close(sd); + + /* + * return number of interfaces seen + */ + if(rc < 0) + return rc; + + return idx_offset; +} + +/** + * find unused alias number + */ +static int +_next_alias(const char *if_name) +{ + int i, j, k, sd, interfaces = 0, len; + struct ifconf ifc; + struct ifreq *ifrp; + char *alias; + int *alias_list; + + if (NULL == if_name) + return -1; + len = strlen(if_name); + + if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + snmp_log(LOG_ERR, "could not create socket\n"); + return -1; + } + + interfaces = + netsnmp_access_ipaddress_ioctl_get_interface_count(sd, &ifc); + if(interfaces < 0) { + close(sd); + return -2; + } + netsnmp_assert(NULL != ifc.ifc_buf); + DEBUGMSGTL(("access:ipaddress:container", "processing %d interfaces\n", interfaces)); + + alias_list = (int*)malloc(interfaces * sizeof(int)); + if (NULL == alias_list) { + close(sd); + return -2; + } + + ifrp = ifc.ifc_req; + for(i=0,j=0; i < interfaces; ++i, ++ifrp) { + + if (strncmp(ifrp->ifr_name, if_name, len) != 0) + continue; + + DEBUGMSGTL(("access:ipaddress:container", + " interface %d, %s\n", i, ifrp->ifr_name)); + + alias = strchr(ifrp->ifr_name, ':'); + if (NULL == alias) + continue; + + ++alias; /* skip ':' */ + alias_list[j++] = atoi(alias); + } + + /* + * clean up + */ + free(ifc.ifc_buf); + close(sd); + + /* + * return first unused alias + */ + for(i=1; i<=interfaces; ++i) { + for(k=0;k<j;++k) + if (alias_list[k] == i) + break; + if (k == j) { + free(alias_list); + return i; + } + } + + free(alias_list); + return interfaces + 1; +} + + +/** + * + * @retval 0 : no error + * @retval -1 : bad parameter + * @retval -2 : couldn't create socket + * @retval -3 : ioctl failed + */ +int +_netsnmp_ioctl_ipaddress_set_v4(netsnmp_ipaddress_entry * entry) +{ + struct ifreq ifrq; + struct sockaddr_in *sin; + int rc, fd = -1; + _ioctl_extras *extras; + + if (NULL == entry) + return -1; + + netsnmp_assert(4 == entry->ia_address_len); + + extras = netsnmp_ioctl_ipaddress_extras_get(entry); + if (NULL == extras) + return -1; + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if(fd < 0) { + snmp_log(LOG_ERR,"couldn't create socket\n"); + return -2; + } + memset(&ifrq, 0, sizeof(ifrq)); + + if ('\0' == extras->name[0]) { + const char *name = netsnmp_access_interface_name_find(entry->if_index); + int alias_idx; + + if (NULL == name) { + DEBUGMSGT(("access:ipaddress:set", + "cant find name for index %" NETSNMP_PRIo "d\n", + entry->if_index)); + close(fd); + return -1; + } + + /* + * search for unused alias + */ + alias_idx = _next_alias(name); + snprintf(ifrq.ifr_name,sizeof(ifrq.ifr_name), "%s:%d", + name, alias_idx); + ifrq.ifr_name[sizeof(ifrq.ifr_name) - 1] = 0; + } + else + strlcpy(ifrq.ifr_name, (char *) extras->name, sizeof(ifrq.ifr_name)); + + sin = (struct sockaddr_in*)&ifrq.ifr_addr; + sin->sin_family = AF_INET; + memcpy(&sin->sin_addr.s_addr, entry->ia_address, + entry->ia_address_len); + + rc = ioctl(fd, SIOCSIFADDR, &ifrq); + close(fd); + if(rc < 0) { + snmp_log(LOG_ERR,"error setting address\n"); + return -3; + } + + return 0; +} + +/** + * + * @retval 0 : no error + * @retval -1 : bad parameter + * @retval -2 : couldn't create socket + * @retval -3 : ioctl failed + */ +int +_netsnmp_ioctl_ipaddress_delete_v4(netsnmp_ipaddress_entry * entry) +{ + struct ifreq ifrq; + int rc, fd = -1; + _ioctl_extras *extras; + + if (NULL == entry) + return -1; + + netsnmp_assert(4 == entry->ia_address_len); + + extras = netsnmp_ioctl_ipaddress_extras_get(entry); + if (NULL == extras) + return -1; + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if(fd < 0) { + snmp_log(LOG_ERR,"couldn't create socket\n"); + return -2; + } + + memset(&ifrq, 0, sizeof(ifrq)); + + strlcpy(ifrq.ifr_name, (char *) extras->name, sizeof(ifrq.ifr_name)); + + ifrq.ifr_flags = 0; + + rc = ioctl(fd, SIOCSIFFLAGS, &ifrq); + close(fd); + if(rc < 0) { + snmp_log(LOG_ERR,"error deleting address\n"); + return -3; + } + + return 0; +} + + +/** + * Add/remove IPv6 address using ioctl. + * @retval 0 : no error + * @retval -1 : bad parameter + * @retval -2 : couldn't create socket + * @retval -3 : ioctl failed + */ +int +_netsnmp_ioctl_ipaddress_v6(netsnmp_ipaddress_entry * entry, int operation) +{ +#ifdef linux + /* + * From linux/ipv6.h. It cannot be included because it collides + * with netinet/in.h + */ + struct in6_ifreq { + struct in6_addr ifr6_addr; + uint32_t ifr6_prefixlen; + int ifr6_ifindex; + }; + + struct in6_ifreq ifrq; + int rc, fd = -1; + + DEBUGMSGT(("access:ipaddress:set", "_netsnmp_ioctl_ipaddress_set_v6 started\n")); + + if (NULL == entry) + return -1; + + netsnmp_assert(16 == entry->ia_address_len); + + fd = socket(AF_INET6, SOCK_DGRAM, 0); + if(fd < 0) { + snmp_log(LOG_ERR,"couldn't create socket\n"); + return -2; + } + memset(&ifrq, 0, sizeof(ifrq)); + ifrq.ifr6_ifindex = entry->if_index; + ifrq.ifr6_prefixlen = 64; + + memcpy(&ifrq.ifr6_addr, entry->ia_address, + entry->ia_address_len); + + rc = ioctl(fd, operation, &ifrq); + close(fd); + if(rc < 0) { + snmp_log(LOG_ERR,"error setting address: %s(%d)\n", strerror(errno), errno); + return -3; + } + DEBUGMSGT(("access:ipaddress:set", "_netsnmp_ioctl_ipaddress_set_v6 finished\n")); + return 0; +#else + /* we don't support ipv6 on this platform (yet) */ + return -3; +#endif + +} + +/** + * + * @retval 0 : no error + * @retval -1 : bad parameter + * @retval -2 : couldn't create socket + * @retval -3 : ioctl failed + */ +int +_netsnmp_ioctl_ipaddress_set_v6(netsnmp_ipaddress_entry * entry) +{ + return _netsnmp_ioctl_ipaddress_v6(entry, SIOCSIFADDR); +} + +/** + * + * @retval 0 : no error + * @retval -1 : bad parameter + * @retval -2 : couldn't create socket + * @retval -3 : ioctl failed + */ +int +_netsnmp_ioctl_ipaddress_delete_v6(netsnmp_ipaddress_entry * entry) +{ + return _netsnmp_ioctl_ipaddress_v6(entry, SIOCDIFADDR); +} + +/** + * get the interface count and populate the ifc_buf + * + * Note: the caller assumes responsbility for the ifc->ifc_buf + * memory, and should free() it when done. + * + * @retval -1 : malloc error + */ +int +netsnmp_access_ipaddress_ioctl_get_interface_count(int sd, struct ifconf * ifc) +{ + int lastlen = 0, i; + struct ifconf ifc_tmp; + + if (NULL == ifc) { + memset(&ifc_tmp, 0x0, sizeof(ifc_tmp)); + ifc = &ifc_tmp; + } + + /* + * Cope with lots of interfaces and brokenness of ioctl SIOCGIFCONF + * on some platforms; see W. R. Stevens, ``Unix Network Programming + * Volume I'', p.435. + */ + + for (i = 8;; i *= 2) { + ifc->ifc_buf = (caddr_t)calloc(i, sizeof(struct ifreq)); + if (NULL == ifc->ifc_buf) { + snmp_log(LOG_ERR, "could not allocate memory for %d interfaces\n", + i); + return -1; + } + ifc->ifc_len = i * sizeof(struct ifreq); + + if (ioctl(sd, SIOCGIFCONF, (char *) ifc) < 0) { + if (errno != EINVAL || lastlen != 0) { + /* + * Something has gone genuinely wrong. + */ + snmp_log(LOG_ERR, "bad rc from ioctl, errno %d", errno); + SNMP_FREE(ifc->ifc_buf); + return -1; + } + /* + * Otherwise, it could just be that the buffer is too small. + */ + } else { + if (ifc->ifc_len == lastlen) { + /* + * The length is the same as the last time; we're done. + */ + break; + } + lastlen = ifc->ifc_len; + } + free(ifc->ifc_buf); /* no SNMP_FREE, getting ready to reassign */ + } + + if (ifc == &ifc_tmp) + free(ifc_tmp.ifc_buf); + + return ifc->ifc_len / sizeof(struct ifreq); +} + +/** + */ +static void +_print_flags(short flags) +{ +/** Standard interface flags. */ + struct { + short flag; + const char *name; + } map[] = { + { IFF_UP, "interface is up"}, + { IFF_BROADCAST, "broadcast address valid"}, + { IFF_DEBUG, "turn on debugging"}, + { IFF_LOOPBACK, "is a loopback net"}, + { IFF_POINTOPOINT, "interface is has p-p link"}, + { IFF_NOTRAILERS, "avoid use of trailers"}, + { IFF_RUNNING, "resources allocated"}, + { IFF_NOARP, "no ARP protocol"}, + { IFF_PROMISC, "receive all packets"}, + { IFF_ALLMULTI, "receive all multicast packets"}, + { IFF_MASTER, "master of a load balancer"}, + { IFF_SLAVE, "slave of a load balancer"}, + { IFF_MULTICAST, "Supports multicast"}, + { IFF_PORTSEL, "can set media type"}, + { IFF_AUTOMEDIA, "auto media select active"}, + }; + short unknown = flags; + size_t i; + + for(i = 0; i < sizeof(map)/sizeof(map[0]); ++i) + if(flags & map[i].flag) { + DEBUGMSGT_NC(("access:ipaddress:container"," %s\n", map[i].name)); + unknown &= ~map[i].flag; + } + + if(unknown) + DEBUGMSGT_NC(("access:ipaddress:container"," unknown 0x%x\n", unknown)); +} diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.h b/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.h new file mode 100644 index 0000000..f2b7847 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.h @@ -0,0 +1,64 @@ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * struct for netlink extras + */ +struct address_flag_info { + int bcastflg; + int anycastflg; + in_addr_t addr; +}; + +#define IS_APIPA(a) (((in_addr_t)(a << 16)) == 0xFEA90000) + +int +_netsnmp_ioctl_ipaddress_container_load_v4(netsnmp_container *container, + int idx_offset); +int +_netsnmp_ioctl_ipaddress_set_v4(netsnmp_ipaddress_entry * entry); +int +_netsnmp_ioctl_ipaddress_remove_v4(netsnmp_ipaddress_entry * entry); + +int +_netsnmp_ioctl_ipaddress_set_v6(netsnmp_ipaddress_entry * entry); +int +_netsnmp_ioctl_ipaddress_remove_v6(netsnmp_ipaddress_entry * entry); + +int +netsnmp_access_ipaddress_ioctl_get_interface_count(int sd, struct ifconf * ifc); + +struct address_flag_info +netsnmp_access_other_info_get(int index, int family); + +/* + * struct ioctl for arch_data + */ +typedef struct _ioctl_extras { + u_int flags; + u_char name[IFNAMSIZ]; +} _ioctl_extras; + + + +_ioctl_extras * +netsnmp_ioctl_ipaddress_entry_init(netsnmp_ipaddress_entry *entry); +void +netsnmp_ioctl_ipaddress_entry_cleanup(netsnmp_ipaddress_entry *entry); +int +netsnmp_ioctl_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs); + +_ioctl_extras * +netsnmp_ioctl_ipaddress_extras_get(netsnmp_ipaddress_entry *entry); + +int +_netsnmp_ioctl_ipaddress_delete_v4(netsnmp_ipaddress_entry * entry); +int +_netsnmp_ioctl_ipaddress_delete_v6(netsnmp_ipaddress_entry * entry); + +#ifdef __cplusplus +} +#endif + diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c new file mode 100644 index 0000000..f1cef0a --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c @@ -0,0 +1,600 @@ +/* + * Interface MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-features.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/ipaddress.h> +#include <net-snmp/data_access/interface.h> + +#include "ip-mib/ipAddressTable/ipAddressTable_constants.h" +#include "ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_constants.h" +#include "mibgroup/util_funcs.h" + +#include <errno.h> +#include <sys/ioctl.h> + +netsnmp_feature_require(prefix_info) +netsnmp_feature_require(find_prefix_info) + +netsnmp_feature_child_of(ipaddress_arch_entry_copy, ipaddress_common) + +#ifdef NETSNMP_FEATURE_REQUIRE_IPADDRESS_ARCH_ENTRY_COPY +netsnmp_feature_require(ipaddress_ioctl_entry_copy) +#endif /* NETSNMP_FEATURE_REQUIRE_IPADDRESS_ARCH_ENTRY_COPY */ + +#if defined (NETSNMP_ENABLE_IPV6) +#include <linux/types.h> +#include <asm/types.h> +#if defined(HAVE_LINUX_RTNETLINK_H) +#include <linux/netlink.h> +#include <linux/rtnetlink.h> +#ifdef RTMGRP_IPV6_PREFIX +#define SUPPORT_PREFIX_FLAGS 1 +#endif /* RTMGRP_IPV6_PREFIX */ +#endif /* HAVE_LINUX_RTNETLINK_H */ +#endif + +#include "ipaddress_ioctl.h" +#ifdef SUPPORT_PREFIX_FLAGS +extern prefix_cbx *prefix_head_list; +#endif +int _load_v6(netsnmp_container *container, int idx_offset); +#ifdef HAVE_LINUX_RTNETLINK_H +int +netsnmp_access_ipaddress_extra_prefix_info(int index, + u_long *preferedlt, + ulong *validlt, + char *addr); +#endif + +/* + * initialize arch specific storage + * + * @retval 0: success + * @retval <0: error + */ +int +netsnmp_arch_ipaddress_entry_init(netsnmp_ipaddress_entry *entry) +{ + /* + * init ipv4 stuff + */ + if (NULL == netsnmp_ioctl_ipaddress_entry_init(entry)) + return -1; + + /* + * init ipv6 stuff + * so far, we can just share the ipv4 stuff, so nothing to do + */ + + return 0; +} + +/* + * cleanup arch specific storage + */ +void +netsnmp_arch_ipaddress_entry_cleanup(netsnmp_ipaddress_entry *entry) +{ + /* + * cleanup ipv4 stuff + */ + netsnmp_ioctl_ipaddress_entry_cleanup(entry); + + /* + * cleanup ipv6 stuff + * so far, we can just share the ipv4 stuff, so nothing to do + */ +} + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_ARCH_ENTRY_COPY +/* + * copy arch specific storage + */ +int +netsnmp_arch_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs) +{ + int rc; + + /* + * copy ipv4 stuff + */ + rc = netsnmp_ioctl_ipaddress_entry_copy(lhs, rhs); + if (rc) + return rc; + + /* + * copy ipv6 stuff + * so far, we can just share the ipv4 stuff, so nothing to do + */ + + return rc; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_ARCH_ENTRY_COPY */ + +/* + * create a new entry + */ +int +netsnmp_arch_ipaddress_create(netsnmp_ipaddress_entry *entry) +{ + if (NULL == entry) + return -1; + + if (4 == entry->ia_address_len) { + return _netsnmp_ioctl_ipaddress_set_v4(entry); + } else if (16 == entry->ia_address_len) { + return _netsnmp_ioctl_ipaddress_set_v6(entry); + } else { + DEBUGMSGT(("access:ipaddress:create", "wrong length of IP address\n")); + return -2; + } +} + +/* + * create a new entry + */ +int +netsnmp_arch_ipaddress_delete(netsnmp_ipaddress_entry *entry) +{ + if (NULL == entry) + return -1; + + if (4 == entry->ia_address_len) { + return _netsnmp_ioctl_ipaddress_delete_v4(entry); + } else if (16 == entry->ia_address_len) { + return _netsnmp_ioctl_ipaddress_delete_v6(entry); + } else { + DEBUGMSGT(("access:ipaddress:create", "only ipv4 supported\n")); + return -2; + } +} + +/** + * + * @retval 0 no errors + * @retval !0 errors + */ +int +netsnmp_arch_ipaddress_container_load(netsnmp_container *container, + u_int load_flags) +{ + int rc = 0, idx_offset = 0; + + if (0 == (load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV6_ONLY)) { + rc = _netsnmp_ioctl_ipaddress_container_load_v4(container, idx_offset); + if(rc < 0) { + u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER; + netsnmp_access_ipaddress_container_free(container, flags); + } + } + +#if defined (NETSNMP_ENABLE_IPV6) + + if (0 == (load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV4_ONLY)) { + if (rc < 0) + rc = 0; + + idx_offset = rc; + + /* + * load ipv6, ignoring errors if file not found + */ + rc = _load_v6(container, idx_offset); + if (-2 == rc) + rc = 0; + else if(rc < 0) { + u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER; + netsnmp_access_ipaddress_container_free(container, flags); + } + } +#endif + + /* + * return no errors (0) if we found any interfaces + */ + if(rc > 0) + rc = 0; + + return rc; +} + +#if defined (NETSNMP_ENABLE_IPV6) +/** + */ +int +_load_v6(netsnmp_container *container, int idx_offset) +{ +#ifndef HAVE_LINUX_RTNETLINK_H + DEBUGMSGTL(("access:ipaddress:container", + "cannot get ip address information" + "as netlink socket is not available\n")); + return -1; +#else + FILE *in; + char line[80], addr[40]; + char if_name[IFNAMSIZ+1];/* +1 for '\0' because of the ugly sscanf below */ + u_char *buf; + int if_index, pfx_len, scope, flags, rc = 0; + size_t in_len, out_len; + netsnmp_ipaddress_entry *entry; + _ioctl_extras *extras; + struct address_flag_info addr_info; + + netsnmp_assert(NULL != container); + +#define PROCFILE "/proc/net/if_inet6" + if (!(in = fopen(PROCFILE, "r"))) { + DEBUGMSGTL(("access:ipaddress:container","could not open " PROCFILE "\n")); + return -2; + } + + /* + * address index prefix_len scope status if_name + */ + while (fgets(line, sizeof(line), in)) { + /* + * fe800000000000000200e8fffe5b5c93 05 40 20 80 eth0 + * A D P S F I + * A: address + * D: device number + * P: prefix len + * S: scope (see include/net/ipv6.h, net/ipv6/addrconf.c) + * F: flags (see include/linux/rtnetlink.h, net/ipv6/addrconf.c) + * I: interface + */ + rc = sscanf(line, "%39s %08x %08x %04x %02x %" SNMP_MACRO_VAL_TO_STR(IFNAMSIZ) "s\n", + addr, &if_index, &pfx_len, &scope, &flags, if_name); + if( 6 != rc ) { + snmp_log(LOG_ERR, PROCFILE " data format error (%d!=6), line ==|%s|\n", + rc, line); + continue; + } + DEBUGMSGTL(("access:ipaddress:container", + "addr %s, index %d, pfx %d, scope %d, flags 0x%X, name %s\n", + addr, if_index, pfx_len, scope, flags, if_name)); + /* + */ + entry = netsnmp_access_ipaddress_entry_create(); + if(NULL == entry) { + rc = -3; + break; + } + + in_len = entry->ia_address_len = sizeof(entry->ia_address); + netsnmp_assert(16 == in_len); + out_len = 0; + entry->flags = flags; + buf = entry->ia_address; + if(1 != netsnmp_hex_to_binary(&buf, &in_len, + &out_len, 0, addr, ":")) { + snmp_log(LOG_ERR,"error parsing '%s', skipping\n", + entry->ia_address); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + netsnmp_assert(16 == out_len); + entry->ia_address_len = out_len; + + entry->ns_ia_index = ++idx_offset; + + /* + * save if name + */ + extras = netsnmp_ioctl_ipaddress_extras_get(entry); + memcpy(extras->name, if_name, sizeof(extras->name)); + extras->flags = flags; + + /* + * yyy-rks: optimization: create a socket outside the loop and use + * netsnmp_access_interface_ioctl_ifindex_get() here, since + * netsnmp_access_interface_index_find will open/close a socket + * every time it is called. + */ + entry->if_index = netsnmp_access_interface_index_find(if_name); + memset(&addr_info, 0, sizeof(struct address_flag_info)); + addr_info = netsnmp_access_other_info_get(entry->if_index, AF_INET6); + + /* + #define IPADDRESSSTATUSTC_PREFERRED 1 + #define IPADDRESSSTATUSTC_DEPRECATED 2 + #define IPADDRESSSTATUSTC_INVALID 3 + #define IPADDRESSSTATUSTC_INACCESSIBLE 4 + #define IPADDRESSSTATUSTC_UNKNOWN 5 + #define IPADDRESSSTATUSTC_TENTATIVE 6 + #define IPADDRESSSTATUSTC_DUPLICATE 7 + */ + if((flags & IFA_F_PERMANENT) || (!flags)) + entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; /* ?? */ +#ifdef IFA_F_TEMPORARY + else if(flags & IFA_F_TEMPORARY) + entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; /* ?? */ +#endif + else if(flags & IFA_F_DEPRECATED) + entry->ia_status = IPADDRESSSTATUSTC_DEPRECATED; + else if(flags & IFA_F_TENTATIVE) + entry->ia_status = IPADDRESSSTATUSTC_TENTATIVE; + else { + entry->ia_status = IPADDRESSSTATUSTC_UNKNOWN; + DEBUGMSGTL(("access:ipaddress:ipv6", + "unknown flags 0x%x\n", flags)); + } + + /* + * if it's not multi, it must be uni. + * (an ipv6 address is never broadcast) + */ + if(addr_info.anycastflg) + entry->ia_type = IPADDRESSTYPE_ANYCAST; + else + entry->ia_type = IPADDRESSTYPE_UNICAST; + + + entry->ia_prefix_len = pfx_len; + + /* + * can we figure out if an address is from DHCP? + * use manual until then... + * + *#define IPADDRESSORIGINTC_OTHER 1 + *#define IPADDRESSORIGINTC_MANUAL 2 + *#define IPADDRESSORIGINTC_DHCP 4 + *#define IPADDRESSORIGINTC_LINKLAYER 5 + *#define IPADDRESSORIGINTC_RANDOM 6 + * + * are 'local' address assigned by link layer?? + */ + if (!flags) + entry->ia_origin = IPADDRESSORIGINTC_LINKLAYER; +#ifdef IFA_F_TEMPORARY + else if (flags & IFA_F_TEMPORARY) + entry->ia_origin = IPADDRESSORIGINTC_RANDOM; +#endif + else if (IN6_IS_ADDR_LINKLOCAL(entry->ia_address)) + entry->ia_origin = IPADDRESSORIGINTC_LINKLAYER; + else + entry->ia_origin = IPADDRESSORIGINTC_MANUAL; + + if(entry->ia_origin == IPADDRESSORIGINTC_LINKLAYER) + entry->ia_storagetype = STORAGETYPE_PERMANENT; + + /* xxx-rks: what can we do with scope? */ +#ifdef HAVE_LINUX_RTNETLINK_H + if(netsnmp_access_ipaddress_extra_prefix_info(entry->if_index, &entry->ia_prefered_lifetime + ,&entry->ia_valid_lifetime, addr) < 0){ + DEBUGMSGTL(("access:ipaddress:container", "unable to fetch extra prefix info\n")); + } +#else + entry->ia_prefered_lifetime = 0; + entry->ia_valid_lifetime = 0; +#endif +#ifdef SUPPORT_PREFIX_FLAGS + { + prefix_cbx prefix_val; + memset(&prefix_val, 0, sizeof(prefix_cbx)); + if(net_snmp_find_prefix_info(&prefix_head_list, addr, &prefix_val) < 0) { + DEBUGMSGTL(("access:ipaddress:container", "unable to find info\n")); + entry->ia_onlink_flag = 1; /*Set by default as true*/ + entry->ia_autonomous_flag = 2; /*Set by default as false*/ + + } else { + entry->ia_onlink_flag = prefix_val.ipAddressPrefixOnLinkFlag; + entry->ia_autonomous_flag = prefix_val.ipAddressPrefixAutonomousFlag; + } + } +#else + entry->ia_onlink_flag = 1; /*Set by default as true*/ + entry->ia_autonomous_flag = 2; /*Set by default as false*/ +#endif + + /* + * add entry to container + */ + if (CONTAINER_INSERT(container, entry) < 0) { + DEBUGMSGTL(("access:ipaddress:container","error with ipaddress_entry: insert into container failed.\n")); + netsnmp_access_ipaddress_entry_free(entry); + continue; + } + } + + fclose(in); + + if(rc<0) + return rc; + + return idx_offset; +} + +struct address_flag_info +netsnmp_access_other_info_get(int index, int family) +{ + struct { + struct nlmsghdr n; + struct ifaddrmsg r; + char buf[1024]; + } req; + struct address_flag_info addr; + struct rtattr *rta; + int status; + char buf[16384]; + struct nlmsghdr *nlmp; + struct ifaddrmsg *rtmp; + struct rtattr *rtatp; + int rtattrlen; + int sd; + + memset(&addr, 0, sizeof(struct address_flag_info)); + sd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); + if(sd < 0) { + snmp_log(LOG_ERR, "could not open netlink socket\n"); + return addr; + } + + memset(&req, 0, sizeof(req)); + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; + req.n.nlmsg_type = RTM_GETADDR; + req.r.ifa_family = family; + rta = (struct rtattr *)(((char *)&req) + NLMSG_ALIGN(req.n.nlmsg_len)); + if(family == AF_INET) + rta->rta_len = RTA_LENGTH(4); + else + rta->rta_len = RTA_LENGTH(16); + + status = send(sd, &req, req.n.nlmsg_len, 0); + if (status < 0) { + snmp_log(LOG_ERR, "could not send netlink request\n"); + return addr; + } + + status = recv(sd, buf, sizeof(buf), 0); + if (status < 0) { + snmp_log (LOG_ERR, "could not recieve netlink request\n"); + return addr; + } + + if(status == 0) { + snmp_log (LOG_ERR, "nothing to read\n"); + return addr; + } + + for(nlmp = (struct nlmsghdr *)buf; status > sizeof(*nlmp);) { + int len = nlmp->nlmsg_len; + int req_len = len - sizeof(*nlmp); + + if (req_len < 0 || len > status) { + snmp_log (LOG_ERR, "invalid netlink message\n"); + return addr; + } + + if (!NLMSG_OK(nlmp, status)) { + snmp_log (LOG_ERR, "invalid NLMSG message\n"); + return addr; + } + rtmp = (struct ifaddrmsg *)NLMSG_DATA(nlmp); + rtatp = (struct rtattr *)IFA_RTA(rtmp); + rtattrlen = IFA_PAYLOAD(nlmp); + if(index == rtmp->ifa_index){ + for (; RTA_OK(rtatp, rtattrlen); rtatp = RTA_NEXT(rtatp, rtattrlen)) { + if(rtatp->rta_type == IFA_BROADCAST){ + addr.addr = ((struct in_addr *)RTA_DATA(rtatp))->s_addr; + addr.bcastflg = 1; + } + if(rtatp->rta_type == IFA_ANYCAST){ + addr.addr = ((struct in_addr *)RTA_DATA(rtatp))->s_addr; + addr.anycastflg = 1; + } + } + } + status -= NLMSG_ALIGN(len); + nlmp = (struct nlmsghdr*)((char*)nlmp + NLMSG_ALIGN(len)); + } + close(sd); + return addr; +#endif +} + +#ifdef HAVE_LINUX_RTNETLINK_H +int +netsnmp_access_ipaddress_extra_prefix_info(int index, u_long *preferedlt, + ulong *validlt, char *addr) +{ + + struct { + struct nlmsghdr nlhdr; + struct ifaddrmsg ifaceinfo; + char buf[1024]; + } req; + + struct rtattr *rta; + int status; + char buf[16384]; + char tmpaddr[40]; + struct nlmsghdr *nlmp; + struct ifaddrmsg *rtmp; + struct rtattr *rtatp; + struct ifa_cacheinfo *cache_info; + struct in6_addr *in6p; + int rtattrlen; + int sd; + int reqaddr = 0; + sd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); + if(sd < 0) { + snmp_log(LOG_ERR, "could not open netlink socket\n"); + return -1; + } + memset(&req, 0, sizeof(req)); + req.nlhdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); + req.nlhdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; + req.nlhdr.nlmsg_type = RTM_GETADDR; + req.ifaceinfo.ifa_family = AF_INET6; + rta = (struct rtattr *)(((char *)&req) + NLMSG_ALIGN(req.nlhdr.nlmsg_len)); + rta->rta_len = RTA_LENGTH(16); /*For ipv6*/ + + status = send (sd, &req, req.nlhdr.nlmsg_len, 0); + if (status < 0) { + snmp_log(LOG_ERR, "could not send netlink request\n"); + return -1; + } + status = recv (sd, buf, sizeof(buf), 0); + if (status < 0) { + snmp_log (LOG_ERR, "could not recieve netlink request\n"); + return -1; + } + if (status == 0) { + snmp_log (LOG_ERR, "nothing to read\n"); + return -1; + } + for (nlmp = (struct nlmsghdr *)buf; status > sizeof(*nlmp); ){ + + int len = nlmp->nlmsg_len; + int req_len = len - sizeof(*nlmp); + + if (req_len < 0 || len > status) { + snmp_log (LOG_ERR, "invalid netlink message\n"); + return -1; + } + + if (!NLMSG_OK (nlmp, status)) { + snmp_log (LOG_ERR, "invalid NLMSG message\n"); + return -1; + } + rtmp = (struct ifaddrmsg *)NLMSG_DATA(nlmp); + rtatp = (struct rtattr *)IFA_RTA(rtmp); + rtattrlen = IFA_PAYLOAD(nlmp); + if(index == rtmp->ifa_index) { + for (; RTA_OK(rtatp, rtattrlen); rtatp = RTA_NEXT(rtatp, rtattrlen)) { + if(rtatp->rta_type == IFA_ADDRESS) { + in6p = (struct in6_addr *)RTA_DATA(rtatp); + sprintf(tmpaddr, "%04x%04x%04x%04x%04x%04x%04x%04x", NIP6(*in6p)); + if(!strcmp(tmpaddr ,addr)) + reqaddr = 1; + } + if(rtatp->rta_type == IFA_CACHEINFO) { + cache_info = (struct ifa_cacheinfo *)RTA_DATA(rtatp); + if(reqaddr) { + reqaddr = 0; + *validlt = cache_info->ifa_valid; + *preferedlt = cache_info->ifa_prefered; + } + + } + + } + } + status -= NLMSG_ALIGN(len); + nlmp = (struct nlmsghdr*)((char*)nlmp + NLMSG_ALIGN(len)); + } + close(sd); + return 0; +} +#endif +#endif + diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_linux.h b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.h new file mode 100644 index 0000000..600ceaf --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.h @@ -0,0 +1,21 @@ +/* + * ipaddress 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-mib/data_access/ipaddress_ioctl) +config_require(util_funcs) diff --git a/agent/mibgroup/ip-mib/data_access/ipaddress_solaris2.c b/agent/mibgroup/ip-mib/data_access/ipaddress_solaris2.c new file mode 100644 index 0000000..e2485e3 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipaddress_solaris2.c @@ -0,0 +1,291 @@ +/* + * IP-MIB architecture support + * + */ +#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 <net-snmp/data_access/ipaddress.h> +#include <net-snmp/data_access/interface.h> + +#include "ip-mib/ipAddressTable/ipAddressTable_constants.h" + +#include "kernel_sunos5.h" +#include "mibII/mibII_common.h" + +netsnmp_feature_child_of(ipaddress_arch_entry_copy, ipaddress_common) + +static int _load_v4(netsnmp_container *container, int idx_offset); +#if defined( NETSNMP_ENABLE_IPV6 ) +static int _load_v6(netsnmp_container *container, int idx_offset); +#endif + +/* + * initialize arch specific storage + * + * @retval 0: success + * @retval <0: error + */ +int +netsnmp_arch_ipaddress_entry_init(netsnmp_ipaddress_entry *entry) +{ + init_kernel_sunos5(); + return 0; +} + +/* + * cleanup arch specific storage + */ +void +netsnmp_arch_ipaddress_entry_cleanup(netsnmp_ipaddress_entry *entry) +{ + /* + * Nothing to do. + */ +} + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_ARCH_ENTRY_COPY +/* + * copy arch specific storage + */ +int +netsnmp_arch_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, + netsnmp_ipaddress_entry *rhs) +{ + /* + * Nothing to do. + */ + return 0; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESS_ARCH_ENTRY_COPY */ + +/* + * create a new entry + */ +int +netsnmp_arch_ipaddress_create(netsnmp_ipaddress_entry *entry) +{ + if (NULL == entry) + return -1; + + DEBUGMSGT(("access:ipaddress:create", "not applicable\n")); + return 0; +} + +/* + * delete an entry + */ +int +netsnmp_arch_ipaddress_delete(netsnmp_ipaddress_entry *entry) +{ + if (NULL == entry) + return -1; + + DEBUGMSGT(("access:ipaddress:create", "not applicable\n")); + return 0; +} + +/** + * + * @retval 0 no errors + * @retval !0 errors + */ +int +netsnmp_arch_ipaddress_container_load(netsnmp_container *container, + u_int load_flags) +{ + int rc = 0, idx_offset = 0; + + if (!(load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV6_ONLY)) { + rc = _load_v4(container, idx_offset); + if(rc < 0) { + u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER; + netsnmp_access_ipaddress_container_free(container, flags); + } + } + +#if defined( NETSNMP_ENABLE_IPV6 ) + + if (!(load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV4_ONLY)) { + if (rc < 0) + rc = 0; + + idx_offset = rc; + + rc = _load_v6(container, idx_offset); + if(rc < 0) { + u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER; + netsnmp_access_ipaddress_container_free(container, flags); + } + } +#endif + + /* + * return no errors (0) if we found any interfaces + */ + if(rc > 0) + rc = 0; + return rc; +} + +/* + * @retval >=idx_offset ok + * @retval -1 memory allocation error + * @retval -2 interface lookup error + * @retval -3 container error + */ +static int +_load_v4(netsnmp_container *container, int idx_offset) +{ + mib2_ipAddrEntry_t ipae; + netsnmp_ipaddress_entry *entry; + req_e req = GET_FIRST; + int rc = 0; + + DEBUGMSGTL(("access:ipaddress:container", "loading v4\n")); + while ((rc = getMibstat(MIB_IP_ADDR, &ipae, sizeof(ipae), req, + &Get_everything, NULL)) == 0) { + req = GET_NEXT; + entry = netsnmp_access_ipaddress_entry_create(); + if (entry == NULL) + return (-1); + if (ipae.ipAdEntAddr == INADDR_ANY) + continue; + + ipae.ipAdEntIfIndex.o_bytes[ipae.ipAdEntIfIndex.o_length] = '\0'; + DEBUGMSGTL(("access:ipaddress:container", "found if %s\n", + ipae.ipAdEntIfIndex.o_bytes)); + /* Obtain interface index */ + entry->if_index = + netsnmp_access_interface_index_find(ipae.ipAdEntIfIndex.o_bytes); + if (entry->if_index == 0) { + DEBUGMSGTL(("access:ipaddress:container", "cannot find if %s\n", + ipae.ipAdEntIfIndex.o_bytes)); + netsnmp_access_ipaddress_entry_free(entry); + return (-2); + } + + if (strchr((const char *)&ipae.ipAdEntIfIndex.o_bytes, ':') != 0) + entry->flags |= NETSNMP_ACCESS_IPADDRESS_ISALIAS; + + /* Get the address */ + entry->ia_address_len = sizeof(ipae.ipAdEntAddr); + netsnmp_assert(entry->ia_address_len == 4 && + entry->ia_address_len <= sizeof(entry->ia_address)); + memcpy(&entry->ia_address, &ipae.ipAdEntAddr, entry->ia_address_len); + + /* prefix */ + entry->ia_prefix_len = ipae.ipAdEntInfo.ae_subnet_len; + + /* set the Origin */ + if (ipae.ipAdEntInfo.ae_flags & IFF_DHCPRUNNING) + entry->ia_origin = IPADDRESSORIGINTC_DHCP; + else + entry->ia_origin = IPADDRESSORIGINTC_MANUAL; + + /* set ipv4 constants */ + entry->ia_type = IPADDRESSTYPE_UNICAST; + entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; + + entry->ns_ia_index = ++idx_offset; + + DEBUGMSGTL(("access:ipaddress:container", "insert if %" NETSNMP_PRIo "u, addrlen %d\n", + entry->if_index, entry->ia_address_len)); + + if (CONTAINER_INSERT(container, entry) < 0) { + DEBUGMSGTL(("access:ipaddress:container", "unable to insert %s\n", + ipae.ipAdEntIfIndex.o_bytes)); + netsnmp_access_ipaddress_entry_free(entry); + return (-3); + } + } + return (idx_offset); +} + +/* + * @retval >=idx_offset ok + * @retval -1 memory allocation error + * @retval -2 interface lookup error + * @retval -3 container error + */ +#if defined( NETSNMP_ENABLE_IPV6 ) +static int +_load_v6(netsnmp_container *container, int idx_offset) +{ + mib2_ipv6AddrEntry_t ip6ae; + netsnmp_ipaddress_entry *entry; + req_e req = GET_FIRST; + int rc = 0; + + DEBUGMSGTL(("access:ipaddress:container", "loading v6... cache %d\n", + MIB_IP6_ADDR)); + while ((rc = getMibstat(MIB_IP6_ADDR, &ip6ae, sizeof(ip6ae), req, + &Get_everything, NULL)) == 0) { + req = GET_NEXT; + entry = netsnmp_access_ipaddress_entry_create(); + if (entry == NULL) + return (-1); + if (memcmp((const void *)&ip6ae.ipv6AddrAddress, + (const void *)&in6addr_any, + sizeof (ip6ae.ipv6AddrAddress)) == 0) + continue; + + ip6ae.ipv6AddrIfIndex.o_bytes[ip6ae.ipv6AddrIfIndex.o_length] = '\0'; + DEBUGMSGTL(("access:ipaddress:container", "found if %s\n", + ip6ae.ipv6AddrIfIndex.o_bytes)); + + /* Obtain interface index */ + entry->if_index = + netsnmp_access_interface_index_find( + ip6ae.ipv6AddrIfIndex.o_bytes); + if (entry->if_index == 0) { + DEBUGMSGTL(("access:ipaddress:container", "cannot find if %s\n", + ip6ae.ipv6AddrIfIndex.o_bytes)); + netsnmp_access_ipaddress_entry_free(entry); + return (-2); + } + + /* Get the address */ + entry->ia_address_len = sizeof(ip6ae.ipv6AddrAddress); + netsnmp_assert(entry->ia_address_len == 16 && + entry->ia_address_len <= sizeof(entry->ia_address)); + memcpy(&entry->ia_address, &ip6ae.ipv6AddrAddress, + entry->ia_address_len); + + /* prefix */ + entry->ia_prefix_len = ip6ae.ipv6AddrPfxLength; + + /* type is anycast? (mib2.h: 1 = yes, 2 = no) */ + entry->ia_type = (ip6ae.ipv6AddrAnycastFlag == 1) ? + IPADDRESSTYPE_ANYCAST : IPADDRESSTYPE_UNICAST; + + /* origin (mib2.h: 1 = stateless, 2 = stateful, 3 = unknown) */ + DEBUGMSGTL(("access:ipaddress:container", "origin %d\n", + ip6ae.ipv6AddrType)); + if (ip6ae.ipv6AddrType == 1) + entry->ia_origin = IPADDRESSORIGINTC_LINKLAYER; + else if (ip6ae.ipv6AddrInfo.ae_flags & IFF_DHCPRUNNING) + entry->ia_origin = IPADDRESSORIGINTC_DHCP; + else + entry->ia_origin = IPADDRESSORIGINTC_MANUAL; + + /* status */ + entry->ia_status = ip6ae.ipv6AddrStatus; + + entry->ns_ia_index = ++idx_offset; + + DEBUGMSGTL(("access:ipaddress:container", "insert if %" NETSNMP_PRIo "u, addrlen %d\n", + entry->if_index, entry->ia_address_len)); + + if (CONTAINER_INSERT(container, entry) < 0) { + DEBUGMSGTL(("access:ipaddress:container", "unable to insert %s\n", + ip6ae.ipv6AddrIfIndex.o_bytes)); + netsnmp_access_ipaddress_entry_free(entry); + return (-3); + } + } + return (idx_offset); +} +#endif /* defined( NETSNMP_ENABLE_IPV6 ) */ diff --git a/agent/mibgroup/ip-mib/data_access/ipv6scopezone.h b/agent/mibgroup/ip-mib/data_access/ipv6scopezone.h new file mode 100644 index 0000000..8d81b3f --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipv6scopezone.h @@ -0,0 +1,30 @@ +/* + * scopezone data access header + * + * $Id: ipv6scopezone.h 14170 2007-04-29 02:22:12Z varun_c $ + */ +/**---------------------------------------------------------------------*/ +/* + * 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-mib/data_access/ipv6scopezone_common) +#if defined( linux ) +config_require(ip-mib/data_access/ipv6scopezone_linux) +#else +/* + * couldn't determine the correct file! + * require a bogus file to generate an error. + */ +config_require(ip-mib/data_access/ipv6scopezone-unknown-arch); +#endif + diff --git a/agent/mibgroup/ip-mib/data_access/ipv6scopezone_common.c b/agent/mibgroup/ip-mib/data_access/ipv6scopezone_common.c new file mode 100644 index 0000000..7462ebe --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipv6scopezone_common.c @@ -0,0 +1,155 @@ +/* + * ipv6ScopeIndexTable MIB architecture support + * + * $Id: ipv6scopezone_common.c 14170 2007-04-29 02:22:12Z varun_c $ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/scopezone.h> +/* + * local static prototypes + */ +static void _entry_release(netsnmp_v6scopezone_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_scopezone_container_arch_load(netsnmp_container* container, + u_int load_flags); +extern void +netsnmp_access_scopezone_arch_init(void); + +/** + * initialize systemstats container + */ +netsnmp_container * +netsnmp_access_scopezone_container_init(u_int flags) +{ + netsnmp_container *container; + + DEBUGMSGTL(("access:scopezone:container", "init\n")); + /* + * create the containers. one indexed by ifIndex, the other + * indexed by ifName. + */ + container = netsnmp_container_find("access_scopezone:table_container"); + if (NULL == container) + return NULL; + + return container; +} + +/** + * load scopezone information in specified container + * + * @param container empty container, or NULL to have one created for you + * @param load_flags flags to modify behaviour. + * + * @retval NULL error + * @retval !NULL pointer to container + */ +netsnmp_container* +netsnmp_access_scopezone_container_load(netsnmp_container* container, u_int load_flags) +{ + int rc; + + DEBUGMSGTL(("access:scopezone:container", "load\n")); + + if (NULL == container) { + container = netsnmp_access_scopezone_container_init(load_flags); + if (container) + container->container_name = strdup("scopezone"); + } + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_scopezone\n"); + return NULL; + } + + rc = netsnmp_access_scopezone_container_arch_load(container, load_flags); + if (0 != rc) { + netsnmp_access_scopezone_container_free(container, + NETSNMP_ACCESS_SCOPEZONE_FREE_NOFLAGS); + container = NULL; + } + + return container; +} + +void +netsnmp_access_scopezone_container_free(netsnmp_container *container, u_int free_flags) +{ + DEBUGMSGTL(("access:scopezone:container", "free\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, "invalid container for netsnmp_access_scopezone_free\n"); + return; + } + + if(! (free_flags & NETSNMP_ACCESS_SCOPEZONE_FREE_DONT_CLEAR)) { + /* + * free all items. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func*)_entry_release, + NULL); + } + + CONTAINER_FREE(container); +} + +/** + */ +netsnmp_v6scopezone_entry * +netsnmp_access_scopezone_entry_create(void) +{ + netsnmp_v6scopezone_entry *entry = + SNMP_MALLOC_TYPEDEF(netsnmp_v6scopezone_entry); + + DEBUGMSGTL(("access:scopezone:entry", "create\n")); + + if(NULL == entry) + return NULL; + + + entry->oid_index.len = 1; + entry->oid_index.oids = &entry->ns_scopezone_index; + + return entry; +} + +/** + */ +void +netsnmp_access_scopezone_entry_free(netsnmp_v6scopezone_entry * entry) +{ + DEBUGMSGTL(("access:scopezone:entry", "free\n")); + + if (NULL == entry) + return; + + + free(entry); +} + +/**---------------------------------------------------------------------*/ +/* + * Utility routines + */ + +/** + * \internal + */ +static void +_entry_release(netsnmp_v6scopezone_entry * entry, void *context) +{ + netsnmp_access_scopezone_entry_free(entry); +} + diff --git a/agent/mibgroup/ip-mib/data_access/ipv6scopezone_linux.c b/agent/mibgroup/ip-mib/data_access/ipv6scopezone_linux.c new file mode 100644 index 0000000..7d60641 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/ipv6scopezone_linux.c @@ -0,0 +1,132 @@ +/* + * Interface MIB architecture support + * + * $Id: ipv6scopezone_linux.c 14170 2007-04-29 02:22:12Z varun_c $ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/scopezone.h> + +#if defined (NETSNMP_ENABLE_IPV6) +static int _scopezone_v6(netsnmp_container* container, int idx_offset); +#endif + +/* + * + * @retval 0 success + * @retval -1 no container specified + * @retval -2 could not open file + * @retval -3 could not create entry (probably malloc) + * @retval -4 file format error + */ +int +netsnmp_access_scopezone_container_arch_load(netsnmp_container* container, + u_int load_flags) +{ + int rc1 = 0; +#if defined (NETSNMP_ENABLE_IPV6) + int idx_offset = 0; + + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_scopezone_\n"); + return -1; + } + + rc1 = _scopezone_v6(container, idx_offset); +#endif + if(rc1 > 0) + rc1 = 0; + return rc1; +} + +#if defined (NETSNMP_ENABLE_IPV6) + +/* scope identifiers, from kernel - include/net/ipv6.h */ +#define IPV6_ADDR_LOOPBACK 0x0010U +#define IPV6_ADDR_LINKLOCAL 0x0020U +#define IPV6_ADDR_SITELOCAL 0x0040U + +static int +_scopezone_v6(netsnmp_container* container, int idx_offset) +{ + + /* + * On Linux, we support only link-local scope zones. + * Each interface, which has link-local address, gets unique scope + * zone index. + */ + FILE *in; + char line[80], addr[40]; + int if_index, pfx_len, scope, flags, rc = 0; + int last_if_index = -1; + netsnmp_v6scopezone_entry *entry; + + netsnmp_assert(NULL != container); + +#define PROCFILE "/proc/net/if_inet6" + if (!(in = fopen(PROCFILE, "r"))) { + DEBUGMSGTL(("access:scopezone:container","could not open " PROCFILE "\n")); + return -2; + } + + /* + * address index prefix_len scope status if_name + */ + while (fgets(line, sizeof(line), in)) { + /* + * fe800000000000000200e8fffe5b5c93 05 40 20 80 eth0 + * A D P S F I + * A: address + * D: device number + * P: prefix len + * S: scope (see include/net/ipv6.h, net/ipv6/addrconf.c) + * F: flags (see include/linux/rtnetlink.h, net/ipv6/addrconf.c) + * I: interface + */ + rc = sscanf(line, "%39s %04x %02x %02x %02x\n", + addr, &if_index, &pfx_len, &scope, &flags); + if( 5 != rc ) { + snmp_log(LOG_ERR, PROCFILE " data format error (%d!=5), line ==|%s|\n", + rc, line); + continue; + } + DEBUGMSGTL(("access:scopezone:container", + "addr %s, index %d, pfx %d, scope %d, flags 0x%X\n", + addr, if_index, pfx_len, scope, flags)); + + if (! (scope & IPV6_ADDR_LINKLOCAL)) { + DEBUGMSGTL(("access:scopezone:container", + "The address is not link-local, skipping\n")); + continue; + } + /* + * Check that the interface was not inserted before, just in case + * one interface has two or more link-local addresses. + */ + if (last_if_index == if_index) { + DEBUGMSGTL(("access:scopezone:container", + "The interface was already inserted, skipping\n")); + continue; + } + + last_if_index = if_index; + entry = netsnmp_access_scopezone_entry_create(); + if(NULL == entry) { + rc = -3; + break; + } + entry->ns_scopezone_index = ++idx_offset; + entry->index = if_index; + entry->scopezone_linklocal = if_index; + + CONTAINER_INSERT(container, entry); + } + fclose(in); + if(rc<0) + return rc; + + return idx_offset; +} +#endif diff --git a/agent/mibgroup/ip-mib/data_access/scalars_common.h b/agent/mibgroup/ip-mib/data_access/scalars_common.h new file mode 100644 index 0000000..2f0a63a --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/scalars_common.h @@ -0,0 +1,29 @@ +/* + * ip scalar 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. + */ +#if defined( linux ) +config_require(ip-mib/data_access/scalars_linux) +#else +/* + * couldn't determine the correct file! + * require a bogus file to generate an error. + */ +config_require(ip-mib/data_access/scalars-unknown-arch) +#endif + diff --git a/agent/mibgroup/ip-mib/data_access/scalars_linux.c b/agent/mibgroup/ip-mib/data_access/scalars_linux.c new file mode 100644 index 0000000..6ba356b --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/scalars_linux.c @@ -0,0 +1,148 @@ +/* + * Arp MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/data_access/ip_scalars.h> + +static const char ipfw_name[] = "/proc/sys/net/ipv4/conf/all/forwarding"; +static const char ipfw6_name[] = "/proc/sys/net/ipv6/conf/all/forwarding"; + +int +netsnmp_arch_ip_scalars_ipForwarding_get(u_long *value) +{ + FILE *filep; + int rc; + + if (NULL == value) + return -1; + + + filep = fopen(ipfw_name, "r"); + if (NULL == filep) { + DEBUGMSGTL(("access:ipForwarding", "could not open %s\n", + ipfw_name)); + return -2; + } + + rc = fscanf(filep, "%lu", value); + fclose(filep); + if (1 != rc) { + DEBUGMSGTL(("access:ipForwarding", "could not read %s\n", + ipfw_name)); + return -3; + } + + if ((0 != *value) && (1 != *value)) { + DEBUGMSGTL(("access:ipForwarding", "unexpected value %ld in %s\n", + *value, ipfw_name)); + return -4; + } + + return 0; +} + +int +netsnmp_arch_ip_scalars_ipForwarding_set(u_long value) +{ + FILE *filep; + int rc; + + if (1 == value) + ; + else if (2 == value) + value = 0; + else { + DEBUGMSGTL(("access:ipForwarding", "bad value %ld for %s\n", + value, ipfw_name)); + return SNMP_ERR_WRONGVALUE; + } + + filep = fopen(ipfw_name, "w"); + if (NULL == filep) { + DEBUGMSGTL(("access:ipForwarding", "could not open %s\n", + ipfw_name)); + return SNMP_ERR_RESOURCEUNAVAILABLE; + } + + rc = fprintf(filep, "%ld", value); + fclose(filep); + if (1 != rc) { + DEBUGMSGTL(("access:ipForwarding", "could not write %s\n", + ipfw_name)); + return SNMP_ERR_GENERR; + } + + return 0; +} + +int +netsnmp_arch_ip_scalars_ipv6IpForwarding_get(u_long *value) +{ + FILE *filep; + int rc; + + if (NULL == value) + return -1; + + + filep = fopen(ipfw6_name, "r"); + if (NULL == filep) { + DEBUGMSGTL(("access:ipv6IpForwarding", "could not open %s\n", + ipfw6_name)); + return -2; + } + + rc = fscanf(filep, "%lu", value); + fclose(filep); + if (1 != rc) { + DEBUGMSGTL(("access:ipv6IpForwarding", "could not read %s\n", + ipfw6_name)); + return -3; + } + + if ((0 != *value) && (1 != *value)) { + DEBUGMSGTL(("access:ipv6IpForwarding", "unexpected value %ld in %s\n", + *value, ipfw6_name)); + return -4; + } + + return 0; +} + +int +netsnmp_arch_ip_scalars_ipv6IpForwarding_set(u_long value) +{ + FILE *filep; + int rc; + + if (1 == value) + ; + else if (2 == value) + value = 0; + else { + DEBUGMSGTL(("access:ipv6IpForwarding", + "bad value %ld for ipv6IpForwarding\n", value)); + return SNMP_ERR_WRONGVALUE; + } + + filep = fopen(ipfw6_name, "w"); + if (NULL == filep) { + DEBUGMSGTL(("access:ipv6IpForwarding", "could not open %s\n", + ipfw6_name)); + return SNMP_ERR_RESOURCEUNAVAILABLE; + } + + rc = fprintf(filep, "%ld", value); + fclose(filep); + if (1 != rc) { + DEBUGMSGTL(("access:ipv6IpForwarding", "could not write %s\n", + ipfw6_name)); + return SNMP_ERR_GENERR; + } + + return 0; +} diff --git a/agent/mibgroup/ip-mib/data_access/systemstats.h b/agent/mibgroup/ip-mib/data_access/systemstats.h new file mode 100644 index 0000000..28810e3 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/systemstats.h @@ -0,0 +1,27 @@ +/* + * systemstats 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-mib/data_access/systemstats_common) +#if defined( linux ) +config_require(ip-mib/data_access/systemstats_linux) +#elif defined( solaris2 ) +config_require(ip-mib/data_access/systemstats_solaris2) +#else +config_error(the systemstats data access library is not available in this environment.) +#endif diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_common.c b/agent/mibgroup/ip-mib/data_access/systemstats_common.c new file mode 100644 index 0000000..f60caab --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/systemstats_common.c @@ -0,0 +1,602 @@ +/* + * ipSystemStatsTable and ipIfStatsTable MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include "ip-mib/ipSystemStatsTable/ipSystemStatsTable_constants.h" + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/ipstats.h> +#include <net-snmp/data_access/systemstats.h> + +/**---------------------------------------------------------------------*/ +/* + * local static vars + */ +static int need_wrap_check = -1; + +/* + * local static prototypes + */ +static void _entry_release(netsnmp_systemstats_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_systemstats_container_arch_load(netsnmp_container* container, + u_int load_flags); +extern void +netsnmp_access_systemstats_arch_init(void); + +/**---------------------------------------------------------------------*/ +/* + * initialization + */ +void +netsnmp_access_systemstats_init(void) +{ + netsnmp_container * ifcontainer; + + netsnmp_access_systemstats_arch_init(); + + /* + * load once to set up ifIndexes + */ + ifcontainer = netsnmp_access_systemstats_container_load(NULL, 0); + if(NULL != ifcontainer) + netsnmp_access_systemstats_container_free(ifcontainer, 0); + +} + +/**---------------------------------------------------------------------*/ +/* + * container functions + */ +/** + * initialize systemstats container + */ +netsnmp_container * +netsnmp_access_systemstats_container_init(u_int flags) +{ + netsnmp_container *container; + + DEBUGMSGTL(("access:systemstats:container", "init\n")); + + /* + * create the containers. one indexed by ifIndex, the other + * indexed by ifName. + */ + container = netsnmp_container_find("access_systemstats:table_container"); + if (NULL == container) + return NULL; + + return container; +} + +/** + * load systemstats information in specified container + * + * @param container empty container, or NULL to have one created for you + * @param load_flags flags to modify behaviour. + * + * @retval NULL error + * @retval !NULL pointer to container + */ +netsnmp_container* +netsnmp_access_systemstats_container_load(netsnmp_container* container, u_int load_flags) +{ + int rc; + + DEBUGMSGTL(("access:systemstats:container", "load\n")); + + if (NULL == container) { + container = netsnmp_access_systemstats_container_init(load_flags); + if (NULL != container) + container->container_name = strdup("systemstats_autocreate"); + } + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_systemstats\n"); + return NULL; + } + + rc = netsnmp_access_systemstats_container_arch_load(container, load_flags); + if (0 != rc) { + netsnmp_access_systemstats_container_free(container, + NETSNMP_ACCESS_SYSTEMSTATS_FREE_NOFLAGS); + container = NULL; + } + + return container; +} + +void +netsnmp_access_systemstats_container_free(netsnmp_container *container, u_int free_flags) +{ + DEBUGMSGTL(("access:systemstats:container", "free\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, "invalid container for netsnmp_access_systemstats_free\n"); + return; + } + + if(! (free_flags & NETSNMP_ACCESS_SYSTEMSTATS_FREE_DONT_CLEAR)) { + /* + * free all items. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func*)_entry_release, + NULL); + } + + CONTAINER_FREE(container); +} + +/**---------------------------------------------------------------------*/ +/* + * entry functions + */ +/** + */ +netsnmp_systemstats_entry * +netsnmp_access_systemstats_entry_get_by_index(netsnmp_container *container, oid index) +{ + netsnmp_index tmp; + + DEBUGMSGTL(("access:systemstats:entry", "by_index\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container for netsnmp_access_systemstats_entry_get_by_index\n"); + return NULL; + } + + tmp.len = 1; + tmp.oids = &index; + + return (netsnmp_systemstats_entry *) CONTAINER_FIND(container, &tmp); +} + +/** + */ +netsnmp_systemstats_entry * +netsnmp_access_systemstats_entry_create(int version, int if_index, + const char *tableName) +{ + netsnmp_systemstats_entry *entry = + SNMP_MALLOC_TYPEDEF(netsnmp_systemstats_entry); + + DEBUGMSGTL(("access:systemstats:entry", "create\n")); + + if(NULL == entry) + return NULL; + + entry->oid_index.len = 2; + entry->oid_index.oids = entry->index; + entry->index[0] = version; + entry->index[1] = if_index; + entry->tableName = tableName; + return entry; +} + +/** + */ +void +netsnmp_access_systemstats_entry_free(netsnmp_systemstats_entry * entry) +{ + DEBUGMSGTL(("access:systemstats:entry", "free\n")); + + if (NULL == entry) + return; + + /* + * SNMP_FREE not needed, for any of these, + * since the whole entry is about to be freed + */ + + if (NULL != entry->old_stats) + free(entry->old_stats); + + free(entry); +} + + +/**---------------------------------------------------------------------*/ +/* + * Utility routines + */ + +/** + * \internal + */ +static void +_entry_release(netsnmp_systemstats_entry * entry, void *context) +{ + netsnmp_access_systemstats_entry_free(entry); +} + +/* + * Calculates the entries, which are not provided by OS, but can be + * computed from the others. + */ +static void +_calculate_entries(netsnmp_systemstats_entry * entry) +{ + /* + * HCInForwDatagrams = HCInNoRoutes + HCOutForwDatagrams + */ + if (!entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINNOROUTES]) { + + entry->stats.HCInForwDatagrams = entry->stats.HCInNoRoutes; + u64Incr(&entry->stats.HCInForwDatagrams, &entry->stats.HCOutForwDatagrams); + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS] = 1; + } + + /* + * HCOutFragReqds = HCOutFragOKs + HCOutFragFails + */ + if (!entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGREQDS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGOKS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGFAILS]) { + + entry->stats.HCOutFragReqds = entry->stats.HCOutFragOKs; + u64Incr(&entry->stats.HCOutFragReqds, &entry->stats.HCOutFragFails); + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGREQDS] = 1; + } + + /* + * HCOutTransmits = HCOutRequests + HCOutForwDatagrams + HCOutFragCreates + * - HCOutFragReqds - HCOutNoRoutes - HCOutDiscards + */ + if (!entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGREQDS] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTNOROUTES] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES] + && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS]) { + + U64 tmp, tmp2, tmp3; + tmp = entry->stats.HCOutRequests; + u64Incr(&tmp, &entry->stats.HCOutForwDatagrams); + u64Incr(&tmp, &entry->stats.HCOutFragCreates); + + u64Subtract(&tmp, &entry->stats.HCOutFragReqds, &tmp2); + u64Subtract(&tmp2, &entry->stats.HCOutNoRoutes, &tmp3); + u64Subtract(&tmp3, &entry->stats.HCOutDiscards, &entry->stats.HCOutTransmits); + + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS] = 1; + } +} + +/** + * update entry stats (checking for counter wrap) + * + * @retval 0 : success + * @retval <0 : error + */ +int +netsnmp_access_systemstats_entry_update_stats(netsnmp_systemstats_entry * prev_vals, + netsnmp_systemstats_entry * new_vals) +{ + DEBUGMSGTL(("access:systemstats", "check_wrap\n")); + + /* + * sanity checks + */ + if ((NULL == prev_vals) || (NULL == new_vals) || + (prev_vals->index[0] != new_vals->index[0]) + || (prev_vals->index[1] != new_vals->index[1])) + return -1; + + /* + * if we've determined that we have 64 bit counters, just copy them. + */ + if (0 == need_wrap_check) { + memcpy(&prev_vals->stats, &new_vals->stats, sizeof(new_vals->stats)); + _calculate_entries(prev_vals); + return 0; + } + + if (NULL == prev_vals->old_stats) { + /* + * if we don't have old stats, they can't have wrapped, so just copy + */ + prev_vals->old_stats = SNMP_MALLOC_TYPEDEF(netsnmp_ipstats); + if (NULL == prev_vals->old_stats) { + return -2; + } + memcpy(&prev_vals->stats, &new_vals->stats, sizeof(new_vals->stats)); + } + else { + /* + * update straight 32 bit counters + */ + memcpy(&prev_vals->stats.columnAvail[0], &new_vals->stats.columnAvail[0], sizeof(new_vals->stats.columnAvail)); + prev_vals->stats.InHdrErrors = new_vals->stats.InHdrErrors; + prev_vals->stats.InAddrErrors = new_vals->stats.InAddrErrors; + prev_vals->stats.InUnknownProtos = new_vals->stats.InUnknownProtos; + prev_vals->stats.InTruncatedPkts = new_vals->stats.InTruncatedPkts; + prev_vals->stats.ReasmReqds = new_vals->stats.ReasmReqds; + prev_vals->stats.ReasmOKs = new_vals->stats.ReasmOKs; + prev_vals->stats.ReasmFails = new_vals->stats.ReasmFails; + prev_vals->stats.InDiscards = new_vals->stats.InDiscards; + + /* + * update 64bit counters + */ + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINNOROUTES]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInNoRoutes, + &new_vals->stats.HCInNoRoutes, + &prev_vals->old_stats->HCInNoRoutes, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInNoRoutes to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTNOROUTES]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutNoRoutes, + &new_vals->stats.HCOutNoRoutes, + &prev_vals->old_stats->HCOutNoRoutes, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutNoRoutes to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutDiscards, + &new_vals->stats.HCOutDiscards, + &prev_vals->old_stats->HCOutDiscards, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutDiscards to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGREQDS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutFragReqds, + &new_vals->stats.HCOutFragReqds, + &prev_vals->old_stats->HCOutFragReqds, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutFragReqds to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGOKS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutFragOKs, + &new_vals->stats.HCOutFragOKs, + &prev_vals->old_stats->HCOutFragOKs, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutFragOKs to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGFAILS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutFragFails, + &new_vals->stats.HCOutFragFails, + &prev_vals->old_stats->HCOutFragFails, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutFragFails to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutFragCreates, + &new_vals->stats.HCOutFragCreates, + &prev_vals->old_stats->HCOutFragCreates, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutFragCreates to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInReceives, + &new_vals->stats.HCInReceives, + &prev_vals->old_stats->HCInReceives, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInReceives to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInOctets, + &new_vals->stats.HCInOctets, + &prev_vals->old_stats->HCInOctets, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInOctets to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInForwDatagrams, + &new_vals->stats.HCInForwDatagrams, + &prev_vals->old_stats->HCInForwDatagrams, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInForwDatagrams to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInDelivers, + &new_vals->stats.HCInDelivers, + &prev_vals->old_stats->HCInDelivers, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInDelivers to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutRequests, + &new_vals->stats.HCOutRequests, + &prev_vals->old_stats->HCOutRequests, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutRequests to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutForwDatagrams, + &new_vals->stats.HCOutForwDatagrams, + &prev_vals->old_stats->HCOutForwDatagrams, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutForwDatagrams to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutTransmits, + &new_vals->stats.HCOutTransmits, + &prev_vals->old_stats->HCOutTransmits, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutTransmits to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutOctets, + &new_vals->stats.HCOutOctets, + &prev_vals->old_stats->HCOutOctets, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutOctets to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInMcastPkts, + &new_vals->stats.HCInMcastPkts, + &prev_vals->old_stats->HCInMcastPkts, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInMcastPkts to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInMcastOctets, + &new_vals->stats.HCInMcastOctets, + &prev_vals->old_stats->HCInMcastOctets, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInMcastOctets to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutMcastPkts, + &new_vals->stats.HCOutMcastPkts, + &prev_vals->old_stats->HCOutMcastPkts, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutMcastPkts to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutMcastOctets, + &new_vals->stats.HCOutMcastOctets, + &prev_vals->old_stats->HCOutMcastOctets, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutMcastOctets to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCInBcastPkts, + &new_vals->stats.HCInBcastPkts, + &prev_vals->old_stats->HCInBcastPkts, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCInBcastPkts to 64bits in %s\n", + prev_vals->tableName)); + + if (new_vals->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS]) + if (0 != netsnmp_c64_check32_and_update( + &prev_vals->stats.HCOutBcastPkts, + &new_vals->stats.HCOutBcastPkts, + &prev_vals->old_stats->HCOutBcastPkts, + &need_wrap_check)) + DEBUGMSGTL(("access:systemstats", + "Error expanding HCOutBcastPkts to 64bits in %s\n", + prev_vals->tableName)); + } + + /* + * if we've decided we no longer need to check wraps, free old stats + */ + if (0 == need_wrap_check) { + SNMP_FREE(prev_vals->old_stats); + } else { + /* + * update old stats from new stats. + * careful - old_stats is a pointer to stats... + */ + memcpy(prev_vals->old_stats, &new_vals->stats, sizeof(new_vals->stats)); + } + + _calculate_entries(prev_vals); + + return 0; +} + +/** + * update systemstats entry data (checking for counter wraps) + * + * Given an existing entry, update it with the new values from another + * entry. + * + * @retval -2 : malloc failed + * @retval -1 : systemstatss not the same + * @retval 0 : no error + */ +int +netsnmp_access_systemstats_entry_update(netsnmp_systemstats_entry * lhs, + netsnmp_systemstats_entry * rhs) +{ + DEBUGMSGTL(("access:systemstats", "copy\n")); + + if ((NULL == lhs) || (NULL == rhs) || + (lhs->index[0] != rhs->index[0]) + || (lhs->index[1] != rhs->index[1])) + return -1; + + /* + * update stats + */ + netsnmp_access_systemstats_entry_update_stats(lhs, rhs); + + /* + * update other data + */ + lhs->flags = rhs->flags; + + return 0; +} + +/**---------------------------------------------------------------------*/ +/* + * + */ diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c new file mode 100644 index 0000000..275b0bd --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c @@ -0,0 +1,685 @@ +/* + * ipSystemStatsTable and ipIfStatsTable interface MIB architecture support + * + * $Id$ + */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/ipstats.h> +#include <net-snmp/data_access/systemstats.h> + +#include "../ipSystemStatsTable/ipSystemStatsTable.h" + +#include <sys/types.h> +#include <dirent.h> +#include <ctype.h> + +static int _systemstats_v4(netsnmp_container* container, u_int load_flags); +static int _additional_systemstats_v4(netsnmp_systemstats_entry* entry, + u_int load_flags); + +#if defined (NETSNMP_ENABLE_IPV6) +static int _systemstats_v6(netsnmp_container* container, u_int load_flags); +#endif + +void +netsnmp_access_systemstats_arch_init(void) +{ + /* + * nothing to do + */ +} + +/* + /proc/net/snmp + + Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates + Ip: 2 64 7083534 0 0 0 0 0 6860233 6548963 0 0 1 286623 63322 1 259920 0 0 + + Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps + Icmp: 335 36 254 72 0 0 0 0 9 0 0 0 0 257 0 257 0 0 0 0 0 0 0 0 0 0 + + Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts + Tcp: 1 200 120000 -1 5985 55 27 434 10 5365077 5098096 10902 2 4413 + + Udp: InDatagrams NoPorts InErrors OutDatagrams + Udp: 1491094 122 0 1466178 +*/ + + +/* + * + * @retval 0 success + * @retval -1 no container specified + * @retval -2 could not open file + * @retval -3 could not create entry (probably malloc) + * @retval -4 file format error + */ +int +netsnmp_access_systemstats_container_arch_load(netsnmp_container* container, + u_int load_flags) +{ + int rc1; +#if defined (NETSNMP_ENABLE_IPV6) + int rc2; +#endif + + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_systemstats_\n"); + return -1; + } + + /* + * load v4 and v6 stats. Even if one fails, try the other. + * If they have the same rc, return it. if the differ, return + * the smaller one. No log messages, since each individual function + * would have logged its own message. + */ + rc1 = _systemstats_v4(container, load_flags); +#if defined (NETSNMP_ENABLE_IPV6) + rc2 = _systemstats_v6(container, load_flags); + if ((rc1 == rc2) || (rc1 < rc2)) + return rc1; + + return rc2; +#else + return rc1; +#endif +} + +/* + * Based on load_flags, load ipSystemStatsTable or ipIfStatsTable for ipv4 entries. + */ +static int +_systemstats_v4(netsnmp_container* container, u_int load_flags) +{ + FILE *devin; + char line[1024]; + netsnmp_systemstats_entry *entry = NULL; + int scan_count; + char *stats, *start = line; + int len; + unsigned long long scan_vals[19]; + + DEBUGMSGTL(("access:systemstats:container:arch", "load v4 (flags %x)\n", + load_flags)); + + netsnmp_assert(container != NULL); /* load function shoulda checked this */ + + if (load_flags & NETSNMP_ACCESS_SYSTEMSTATS_LOAD_IFTABLE) { + /* we do not support ipIfStatsTable for ipv4 */ + return 0; + } + + if (!(devin = fopen("/proc/net/snmp", "r"))) { + DEBUGMSGTL(("access:systemstats", + "Failed to load Systemstats Table (linux1)\n")); + NETSNMP_LOGONCE((LOG_ERR, "cannot open /proc/net/snmp ...\n")); + return -2; + } + + /* + * skip header, but make sure it's the length we expect... + */ + fgets(line, sizeof(line), devin); + len = strlen(line); + if (224 != len) { + fclose(devin); + snmp_log(LOG_ERR, "unexpected header length in /proc/net/snmp." + " %d != 224\n", len); + return -4; + } + + /* + * This file provides the statistics for each systemstats. + * Read in each line in turn, isolate the systemstats name + * and retrieve (or create) the corresponding data structure. + */ + start = fgets(line, sizeof(line), devin); + fclose(devin); + if (start) { + + len = strlen(line); + if (line[len - 1] == '\n') + line[len - 1] = '\0'; + + while (*start && *start == ' ') + start++; + + if ((!*start) || ((stats = strrchr(start, ':')) == NULL)) { + snmp_log(LOG_ERR, + "systemstats data format error 1, line ==|%s|\n", line); + return -4; + } + + DEBUGMSGTL(("access:systemstats", "processing '%s'\n", start)); + + *stats++ = 0; /* null terminate name */ + while (*stats == ' ') /* skip spaces before stats */ + stats++; + + entry = netsnmp_access_systemstats_entry_create(1, 0, + "ipSystemStatsTable.ipv4"); + if(NULL == entry) { + netsnmp_access_systemstats_container_free(container, + NETSNMP_ACCESS_SYSTEMSTATS_FREE_NOFLAGS); + return -3; + } + + /* + * OK - we've now got (or created) the data structure for + * this systemstats, including any "static" information. + * Now parse the rest of the line (i.e. starting from 'stats') + * to extract the relevant statistics, and populate + * data structure accordingly. + */ + + memset(scan_vals, 0x0, sizeof(scan_vals)); + scan_count = sscanf(stats, + "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" + "%llu %llu %llu %llu %llu %llu %llu %llu %llu", + &scan_vals[0],&scan_vals[1],&scan_vals[2], + &scan_vals[3],&scan_vals[4],&scan_vals[5], + &scan_vals[6],&scan_vals[7],&scan_vals[8], + &scan_vals[9],&scan_vals[10],&scan_vals[11], + &scan_vals[12],&scan_vals[13],&scan_vals[14], + &scan_vals[15],&scan_vals[16],&scan_vals[17], + &scan_vals[18]); + DEBUGMSGTL(("access:systemstats", " read %d values\n", scan_count)); + + if(scan_count != 19) { + snmp_log(LOG_ERR, + "error scanning systemstats data (expected %d, got %d)\n", + 19, scan_count); + netsnmp_access_systemstats_entry_free(entry); + return -4; + } + /* entry->stats. = scan_vals[0]; / * Forwarding */ + /* entry->stats. = scan_vals[1]; / * DefaultTTL */ + entry->stats.HCInReceives.low = scan_vals[2] & 0xffffffff; + entry->stats.HCInReceives.high = scan_vals[2] >> 32; + entry->stats.InHdrErrors = scan_vals[3]; + entry->stats.InAddrErrors = scan_vals[4]; + entry->stats.HCOutForwDatagrams.low = scan_vals[5] & 0xffffffff; + entry->stats.HCOutForwDatagrams.high = scan_vals[5] >> 32; + entry->stats.InUnknownProtos = scan_vals[6]; + entry->stats.InDiscards = scan_vals[7]; + entry->stats.HCInDelivers.low = scan_vals[8] & 0xffffffff; + entry->stats.HCInDelivers.high = scan_vals[8] >> 32; + entry->stats.HCOutRequests.low = scan_vals[9] & 0xffffffff; + entry->stats.HCOutRequests.high = scan_vals[9] >> 32; + entry->stats.HCOutDiscards.low = scan_vals[10] & 0xffffffff;; + entry->stats.HCOutDiscards.high = scan_vals[10] >> 32; + entry->stats.HCOutNoRoutes.low = scan_vals[11] & 0xffffffff;; + entry->stats.HCOutNoRoutes.high = scan_vals[11] >> 32; + /* entry->stats. = scan_vals[12]; / * ReasmTimeout */ + entry->stats.ReasmReqds = scan_vals[13]; + entry->stats.ReasmOKs = scan_vals[14]; + entry->stats.ReasmFails = scan_vals[15]; + entry->stats.HCOutFragOKs.low = scan_vals[16] & 0xffffffff;; + entry->stats.HCOutFragOKs.high = scan_vals[16] >> 32; + entry->stats.HCOutFragFails.low = scan_vals[17] & 0xffffffff;; + entry->stats.HCOutFragFails.high = scan_vals[17] >> 32; + entry->stats.HCOutFragCreates.low = scan_vals[18] & 0xffffffff;; + entry->stats.HCOutFragCreates.high = scan_vals[18] >> 32; + + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INADDRERRORS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INUNKNOWNPROTOS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INDISCARDS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTNOROUTES] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMREQDS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMOKS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMFAILS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGOKS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGFAILS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_DISCONTINUITYTIME] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REFRESHRATE] = 1; + + /* + * load addtional statistics defined by RFC 4293 + * As these are supported linux 2.6.22 or later, it is no problem + * if loading them are failed. + */ + _additional_systemstats_v4(entry, load_flags); + + /* + * add to container + */ + if (CONTAINER_INSERT(container, entry) < 0) + { + DEBUGMSGTL(("access:systemstats:container","error with systemstats_entry: insert into container failed.\n")); + netsnmp_access_systemstats_entry_free(entry); + } + } + + return 0; +} + +#define IP_EXT_HEAD "IpExt:" +static int +_additional_systemstats_v4(netsnmp_systemstats_entry* entry, + u_int load_flags) +{ + FILE *devin; + char line[1024]; + int scan_count; + unsigned long long scan_vals[6]; + int retval = 0; + + DEBUGMSGTL(("access:systemstats:container:arch", + "load addtional v4 (flags %u)\n", load_flags)); + + if (!(devin = fopen("/proc/net/netstat", "r"))) { + DEBUGMSGTL(("access:systemstats", + "cannot open /proc/net/netstat\n")); + NETSNMP_LOGONCE((LOG_ERR,"cannot open /proc/net/netstat\n")); + return -2; + } + + /* + * Get header and stat lines + */ + while (fgets(line, sizeof(line), devin)) { + if (strncmp(IP_EXT_HEAD, line, sizeof(IP_EXT_HEAD) - 1) == 0) { + /* next line should includes IPv4 addtional statistics */ + if ((fgets(line, sizeof(line), devin)) == NULL) { + retval = -4; + break; + } + if (strncmp(IP_EXT_HEAD, line, sizeof(IP_EXT_HEAD) - 1) != 0) { + retval = -4; + break; + } + + memset(scan_vals, 0x0, sizeof(scan_vals)); + scan_count = sscanf(line, + "%*s" /* ignore `IpExt:' */ + "%llu %llu %llu %llu %llu %llu", + &scan_vals[0], &scan_vals[1], &scan_vals[2], + &scan_vals[3], &scan_vals[4], &scan_vals[5]); + if (scan_count < 6) { + snmp_log(LOG_ERR, + "error scanning addtional systemstats data" + "(minimum expected %d, got %d)\n", + 6, scan_count); + retval = -4; + break; + } + + entry->stats.HCInNoRoutes.low = scan_vals[0] & 0xffffffff; + entry->stats.HCInNoRoutes.high = scan_vals[0] >> 32; + entry->stats.InTruncatedPkts = scan_vals[1]; + entry->stats.HCInMcastPkts.low = scan_vals[2] & 0xffffffff; + entry->stats.HCInMcastPkts.high = scan_vals[2] >> 32; + entry->stats.HCOutMcastPkts.low = scan_vals[3] & 0xffffffff; + entry->stats.HCOutMcastPkts.high = scan_vals[3] >> 32; + entry->stats.HCInBcastPkts.low = scan_vals[4] & 0xffffffff; + entry->stats.HCInBcastPkts.high = scan_vals[4] >> 32; + entry->stats.HCOutBcastPkts.low = scan_vals[5] & 0xffffffff; + entry->stats.HCOutBcastPkts.high = scan_vals[5] >> 32; + + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINNOROUTES] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INTRUNCATEDPKTS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS] = 1; + } + } + + fclose(devin); + + if (retval < 0) + DEBUGMSGTL(("access:systemstats", + "/proc/net/netstat does not include addtional stats\n")); + + return retval; +} + +#if defined (NETSNMP_ENABLE_IPV6) + +/* + * Load one /proc/net/snmp6 - like file (e.g. /proc/net/dev_snmp6) + */ +static int +_systemstats_v6_load_file(netsnmp_systemstats_entry *entry, FILE *devin) +{ + char line[1024]; + char *stats, *start = line; + int len, rc; + uintmax_t scan_val; + + /* + * Read in each line in turn, isolate the systemstats name + * and retrieve (or create) the corresponding data structure. + */ + rc = 0; + while (1) { + start = fgets(line, sizeof(line), devin); + if (NULL == start) + break; + + len = strlen(line); + if (line[len - 1] == '\n') + line[len - 1] = '\0'; + + if (('I' != line[0]) || ('6' != line[2])) + continue; + + stats = strrchr(line, ' '); + if (NULL == stats) { + snmp_log(LOG_ERR, + "systemstats data format error 1, line ==|%s|\n", line); + continue; + } + + DEBUGMSGTL(("access:systemstats", "processing '%s'\n", line)); + + /* + * OK - we've now got (or created) the data structure for + * this systemstats, including any "static" information. + * Now parse the rest of the line (i.e. starting from 'stats') + * to extract the relevant statistics, and populate + * data structure accordingly. + */ + scan_val = atoll(stats); + + rc = 0; + if ('I' == line[3]) { /* In */ + if ('A' == line[5]) { + entry->stats.InAddrErrors = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INADDRERRORS] = 1; + } else if ('D' == line[5]) { + if ('e' == line[6]) { + entry->stats.HCInDelivers.low = scan_val & 0xffffffff; + entry->stats.HCInDelivers.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS] = 1; + } else if ('i' == line[6]) { + entry->stats.InDiscards = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INDISCARDS] = 1; + } else + rc = 1; + } else if ('H' == line[5]) { + entry->stats.InHdrErrors = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1; + } else if ('M' == line[5]) { + if ('P' == line[10]) { + entry->stats.HCInMcastPkts.low = scan_val & 0xffffffff; + entry->stats.HCInMcastPkts.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS] = 1; + } else if ('O' == line[10]) { + entry->stats.HCInMcastOctets.low = scan_val & 0xffffffff; + entry->stats.HCInMcastOctets.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS] = 1; + } else + rc = 1; + } else if ('N' == line[5]) { + entry->stats.HCInNoRoutes.low = scan_val & 0xffffffff; + entry->stats.HCInNoRoutes.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINNOROUTES] = 1; + } else if ('R' == line[5]) { + entry->stats.HCInReceives.low = scan_val & 0xffffffff; + entry->stats.HCInReceives.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1; + } else if ('T' == line[5]) { + if ('r' == line[6]) { + entry->stats.InTruncatedPkts = scan_val & 0xffffffff; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INTRUNCATEDPKTS] = 1; + } else if ('o' == line[6]) + ; /* TooBig isn't in the MIB, so ignore it */ + else + rc = 1; + } else if ('U' == line[5]) { + entry->stats.InUnknownProtos = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INUNKNOWNPROTOS] = 1; + } else if ('O' == line[5]) { + entry->stats.HCInOctets.low = scan_val & 0xffffffff; + entry->stats.HCInOctets.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS] = 1; + } else + rc = 1; + } else if ('O' == line[3]) { /* Out */ + if ('D' == line[6]) { + entry->stats.HCOutDiscards.low = scan_val & 0xffffffff; + entry->stats.HCOutDiscards.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS] = 1; + } else if ('F' == line[6]) { + entry->stats.HCOutForwDatagrams.low = scan_val & 0xffffffff; + entry->stats.HCOutForwDatagrams.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS] = 1; + } else if ('M' == line[6]) { + if ('P' == line[11]) { + entry->stats.HCOutMcastPkts.low = scan_val & 0xffffffff; + entry->stats.HCOutMcastPkts.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS] = 1; + } else if ('O' == line[11]) { + entry->stats.HCOutMcastOctets.low = scan_val & 0xffffffff; + entry->stats.HCOutMcastOctets.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS] = 1; + } else + rc = -1; + } else if ('N' == line[6]) { + entry->stats.HCOutNoRoutes.low = scan_val & 0xffffffff; + entry->stats.HCOutNoRoutes.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTNOROUTES] = 1; + } else if ('R' == line[6]) { + entry->stats.HCOutRequests.low = scan_val & 0xffffffff; + entry->stats.HCOutRequests.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS] = 1; + } else if ('O' == line[6]) { + entry->stats.HCOutOctets.low = scan_val & 0xffffffff; + entry->stats.HCOutOctets.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS] = 1; + } else + rc = 1; + } else if ('R' == line[3]) { /* Reasm */ + if ('F' == line[8]) { + entry->stats.ReasmFails = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMFAILS] = 1; + } else if ('O' == line[8]) { + entry->stats.ReasmOKs = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMOKS] = 1; + } else if ('R' == line[8]) { + entry->stats.ReasmReqds = scan_val; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMREQDS] = 1; + } else if ('T' == line[8]) { + ; /* no mib entry for reasm timeout */ + } else + rc = 1; + } else if ('F' == line[3]) { /* Frag */ + if ('C' == line[7]) { + entry->stats.HCOutFragCreates.low = scan_val & 0xffffffff; + entry->stats.HCOutFragCreates.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES] = 1; + } else if ('O' == line[7]) { + entry->stats.HCOutFragOKs.low = scan_val & 0xffffffff; + entry->stats.HCOutFragOKs.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGOKS] = 1; + } else if ('F' == line[7]) { + entry->stats.HCOutFragFails.low = scan_val & 0xffffffff; + entry->stats.HCOutFragFails.high = scan_val >> 32; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGFAILS] = 1; + } else + rc = 1; + } else + rc = 1; + + if (rc) + DEBUGMSGTL(("access:systemstats", "unknown stat %s\n", line)); + } + /* + * Let DiscontinuityTime and RefreshRate active + */ + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_DISCONTINUITYTIME] = 1; + entry->stats.columnAvail[IPSYSTEMSTATSTABLE_REFRESHRATE] = 1; + + return rc; +} + +/* + * load ipSystemStatsTable for ipv6 entries + */ +static int +_systemstats_v6_load_systemstats(netsnmp_container* container, u_int load_flags) +{ + FILE *devin; + netsnmp_systemstats_entry *entry = NULL; + const char *filename = "/proc/net/snmp6"; + int rc = 0; + + entry = netsnmp_access_systemstats_entry_create(2, 0, + "ipSystemStatsTable.ipv6"); + if(NULL == entry) + return -3; + + /* + * try to open file. If we can't, that's ok - maybe the module hasn't + * been loaded yet. + */ + if (!(devin = fopen(filename, "r"))) { + DEBUGMSGTL(("access:systemstats", + "Failed to load Systemstats Table (linux1), cannot open %s\n", + filename)); + return 0; + } + + rc = _systemstats_v6_load_file(entry, devin); + + fclose(devin); + + /* + * add to container + */ + if (CONTAINER_INSERT(container, entry) < 0) + { + DEBUGMSGTL(("access:systemstats:container","error with systemstats_entry: insert into container failed.\n")); + netsnmp_access_systemstats_entry_free(entry); + } + + + return rc; +} + +#define DEV_SNMP6_DIRNAME "/proc/net/dev_snmp6" +#define IFINDEX_LINE "ifIndex" +#define DEV_FILENAME_LEN 64 + +/* + * load ipIfStatsTable for ipv6 entries + */ +static int +_systemstats_v6_load_ifstats(netsnmp_container* container, u_int load_flags) +{ + DIR *dev_snmp6_dir; + struct dirent *dev_snmp6_entry; + char dev_filename[DEV_FILENAME_LEN]; + FILE *devin; + char line[1024]; + char *start = line; + char *scan_str; + uintmax_t scan_val; + netsnmp_systemstats_entry *entry = NULL; + + /* + * try to open /proc/net/dev_snmp6 directory. If we can't, that' ok - + * maybe it is not supported by the current running kernel. + */ + if ((dev_snmp6_dir = opendir(DEV_SNMP6_DIRNAME)) == NULL) { + DEBUGMSGTL(("access:ifstats", + "Failed to load IPv6 IfStats Table (linux)\n")); + return 0; + } + + /* + * Read each per interface statistics proc file + */ + while ((dev_snmp6_entry = readdir(dev_snmp6_dir)) != NULL) { + if (dev_snmp6_entry->d_name[0] == '.') + continue; + + if (snprintf(dev_filename, DEV_FILENAME_LEN, "%s/%s", DEV_SNMP6_DIRNAME, + dev_snmp6_entry->d_name) > DEV_FILENAME_LEN) { + snmp_log(LOG_ERR, "Interface name %s is too long\n", + dev_snmp6_entry->d_name); + continue; + } + if (NULL == (devin = fopen(dev_filename, "r"))) { + snmp_log(LOG_ERR, "Failed to open %s\n", dev_filename); + continue; + } + + /* + * If a stat file name is made of digits, the name is interface index. + * If it is an interface name, the file includes a line labeled ifIndex. + */ + if (isdigit(dev_snmp6_entry->d_name[0])) { + scan_val = strtoull(dev_snmp6_entry->d_name, NULL, 0); + } else { + if (NULL == (start = fgets(line, sizeof(line), devin))) { + snmp_log(LOG_ERR, "%s doesn't include any lines\n", + dev_filename); + fclose(devin); + continue; + } + + if (0 != strncmp(start, IFINDEX_LINE, 7)) { + snmp_log(LOG_ERR, "%s doesn't include ifIndex line", + dev_filename); + fclose(devin); + continue; + } + + scan_str = strrchr(line, ' '); + if (NULL == scan_str) { + snmp_log(LOG_ERR, "%s is wrong format", dev_filename); + fclose(devin); + continue; + } + scan_val = strtoull(scan_str, NULL, 0); + } + + entry = netsnmp_access_systemstats_entry_create(2, scan_val, + "ipIfStatsTable.ipv6"); + if(NULL == entry) { + fclose(devin); + closedir(dev_snmp6_dir); + return -3; + } + + _systemstats_v6_load_file(entry, devin); + CONTAINER_INSERT(container, entry); + fclose(devin); + } + closedir(dev_snmp6_dir); + return 0; +} + +/* + * Based on load_flags, load ipSystemStatsTable or ipIfStatsTable for ipv6 entries. + */ +static int +_systemstats_v6(netsnmp_container* container, u_int load_flags) +{ + DEBUGMSGTL(("access:systemstats:container:arch", "load v6 (flags %u)\n", + load_flags)); + + netsnmp_assert(container != NULL); /* load function shoulda checked this */ + + if (load_flags & NETSNMP_ACCESS_SYSTEMSTATS_LOAD_IFTABLE) { + /* load ipIfStatsTable */ + return _systemstats_v6_load_ifstats(container, load_flags); + } else { + /* load ipSystemStatsTable */ + return _systemstats_v6_load_systemstats(container, load_flags); + } +} +#endif /* NETSNMP_ENABLE_IPV6 */ diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_solaris2.c b/agent/mibgroup/ip-mib/data_access/systemstats_solaris2.c new file mode 100644 index 0000000..f2ec497 --- /dev/null +++ b/agent/mibgroup/ip-mib/data_access/systemstats_solaris2.c @@ -0,0 +1,213 @@ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> + +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/data_access/ipstats.h> +#include <net-snmp/data_access/systemstats.h> + +#include "kernel_sunos5.h" + +static int _systemstats(mibgroup_e, netsnmp_container *, u_int); +static void _add_ipstats(mib2_ipIfStatsEntry_t *, mib2_ipIfStatsEntry_t *); +static int _insert_entry(netsnmp_container *, mib2_ipIfStatsEntry_t *); + +void +netsnmp_access_systemstats_arch_init(void) +{ + init_kernel_sunos5(); +} + +/* + * @retval 0 success + * @retval -1 container error + * @retval -2 could not create entry (probably malloc) + */ +int +netsnmp_access_systemstats_container_arch_load(netsnmp_container* container, + u_int load_flags) +{ + int rc; + + if (container == NULL) + return (-1); + + if (load_flags & NETSNMP_ACCESS_SYSTEMSTATS_LOAD_IFTABLE) + return 0; /* we do not support ipIfStatsTable yet */ + + if ((rc = _systemstats(MIB_IP_TRAFFIC_STATS, container, load_flags)) < 0) + return (rc); +#if defined(NETSNMP_ENABLE_IPV6) + if ((rc = _systemstats(MIB_IP6, container, load_flags)) < 0) { + netsnmp_access_systemstats_container_free(container, + NETSNMP_ACCESS_SYSTEMSTATS_FREE_NOFLAGS); + return (rc); + } +#endif + return (0); +} + +/* + * @retval 0 success + * @retval <0 error + */ +static int +_systemstats(mibgroup_e mib, netsnmp_container *container, u_int load_flags) +{ + mib2_ipIfStatsEntry_t ipe, iptot; + req_e req = GET_FIRST; + int ipversion = (mib == MIB_IP6) ? MIB2_INETADDRESSTYPE_ipv6 : + MIB2_INETADDRESSTYPE_ipv4; + memset(&iptot, '\0', sizeof(iptot)); + + while (getMibstat(mib, &ipe, sizeof(ipe), req, + &Get_everything, NULL) == 0) { + req = GET_NEXT; + netsnmp_assert(ipe.ipIfStatsIPVersion == ipversion); + _add_ipstats(&iptot, &ipe); + } + iptot.ipIfStatsIPVersion = ipversion; + return _insert_entry(container, &iptot); +} + +static void +_add_ipstats(mib2_ipIfStatsEntry_t *o1, mib2_ipIfStatsEntry_t *o2) +{ + o1->ipIfStatsInHdrErrors += o2->ipIfStatsInHdrErrors; + o1->ipIfStatsInTooBigErrors += o2->ipIfStatsInTooBigErrors; + o1->ipIfStatsInNoRoutes += o2->ipIfStatsInNoRoutes; + o1->ipIfStatsInAddrErrors += o2->ipIfStatsInAddrErrors; + o1->ipIfStatsInUnknownProtos += o2->ipIfStatsInUnknownProtos; + o1->ipIfStatsInTruncatedPkts += o2->ipIfStatsInTruncatedPkts; + o1->ipIfStatsInDiscards += o2->ipIfStatsInDiscards; + o1->ipIfStatsOutDiscards += o2->ipIfStatsOutDiscards; + o1->ipIfStatsOutFragOKs += o2->ipIfStatsOutFragOKs; + o1->ipIfStatsOutFragFails += o2->ipIfStatsOutFragFails; + o1->ipIfStatsOutFragCreates += o2->ipIfStatsOutFragCreates; + o1->ipIfStatsReasmReqds += o2->ipIfStatsReasmReqds; + o1->ipIfStatsReasmOKs += o2->ipIfStatsReasmOKs; + o1->ipIfStatsReasmFails += o2->ipIfStatsReasmFails; + o1->ipIfStatsOutNoRoutes += o2->ipIfStatsOutNoRoutes; + o1->ipIfStatsReasmDuplicates += o2->ipIfStatsReasmDuplicates; + o1->ipIfStatsReasmPartDups += o2->ipIfStatsReasmPartDups; + o1->ipIfStatsForwProhibits += o2->ipIfStatsForwProhibits; + o1->udpInCksumErrs += o2->udpInCksumErrs; + o1->udpInOverflows += o2->udpInOverflows; + o1->rawipInOverflows += o2->rawipInOverflows; + o1->ipIfStatsInWrongIPVersion += o2->ipIfStatsInWrongIPVersion; + o1->ipIfStatsOutWrongIPVersion += o2->ipIfStatsOutWrongIPVersion; + o1->ipIfStatsOutSwitchIPVersion += o2->ipIfStatsOutSwitchIPVersion; + o1->ipIfStatsHCInReceives += o2->ipIfStatsHCInReceives; + o1->ipIfStatsHCInOctets += o2->ipIfStatsHCInOctets; + o1->ipIfStatsHCInForwDatagrams += o2->ipIfStatsHCInForwDatagrams; + o1->ipIfStatsHCInDelivers += o2->ipIfStatsHCInDelivers; + o1->ipIfStatsHCOutRequests += o2->ipIfStatsHCOutRequests; + o1->ipIfStatsHCOutForwDatagrams += o2->ipIfStatsHCOutForwDatagrams; + o1->ipIfStatsOutFragReqds += o2->ipIfStatsOutFragReqds; + o1->ipIfStatsHCOutTransmits += o2->ipIfStatsHCOutTransmits; + o1->ipIfStatsHCOutOctets += o2->ipIfStatsHCOutOctets; + o1->ipIfStatsHCInMcastPkts += o2->ipIfStatsHCInMcastPkts; + o1->ipIfStatsHCInMcastOctets += o2->ipIfStatsHCInMcastOctets; + o1->ipIfStatsHCOutMcastPkts += o2->ipIfStatsHCOutMcastPkts; + o1->ipIfStatsHCOutMcastOctets += o2->ipIfStatsHCOutMcastOctets; + o1->ipIfStatsHCInBcastPkts += o2->ipIfStatsHCInBcastPkts; + o1->ipIfStatsHCOutBcastPkts += o2->ipIfStatsHCOutBcastPkts; + o1->ipsecInSucceeded += o2->ipsecInSucceeded; + o1->ipsecInFailed += o2->ipsecInFailed; + o1->ipInCksumErrs += o2->ipInCksumErrs; + o1->tcpInErrs += o2->tcpInErrs; + o1->udpNoPorts += o2->udpNoPorts; +} + +/* + * @retval 0 entry was successfully inserted in the container + * @retval -1 container error + * @retval -2 memory allocation error + */ +static int +_insert_entry(netsnmp_container *container, mib2_ipIfStatsEntry_t *ipe) +{ + int i; + + netsnmp_systemstats_entry *ep = + netsnmp_access_systemstats_entry_create(ipe->ipIfStatsIPVersion, 0, + "ipSystemStatsTable"); + + DEBUGMSGTL(("access:systemstats:arch", "insert entry for v%d\n", + ipe->ipIfStatsIPVersion)); + if (ep == NULL) { + DEBUGMSGT(("access:systemstats:arch", "insert failed (alloc)")); + return (-2); + } + + ep->stats.HCInReceives.low = + ipe->ipIfStatsHCInReceives & 0xffffffff; + ep->stats.HCInReceives.high = ipe->ipIfStatsHCInReceives >> 32; + ep->stats.HCInOctets.low = + ipe->ipIfStatsHCInOctets & 0xffffffff; + ep->stats.HCInOctets.high = ipe->ipIfStatsHCInOctets >> 32; + ep->stats.InHdrErrors = ipe->ipIfStatsInHdrErrors; + ep->stats.InAddrErrors = ipe->ipIfStatsInAddrErrors; + ep->stats.InUnknownProtos = ipe->ipIfStatsInUnknownProtos; + ep->stats.InTruncatedPkts = ipe->ipIfStatsInTruncatedPkts; + ep->stats.HCInForwDatagrams.low = + ipe->ipIfStatsHCInForwDatagrams & 0xffffffff; + ep->stats.HCInForwDatagrams.high = + ipe->ipIfStatsHCInForwDatagrams >> 32; + ep->stats.ReasmReqds = ipe->ipIfStatsReasmReqds; + ep->stats.ReasmOKs = ipe->ipIfStatsReasmOKs; + ep->stats.ReasmFails = ipe->ipIfStatsReasmFails; + ep->stats.InDiscards = ipe->ipIfStatsInDiscards; + ep->stats.HCInDelivers.low = + ipe->ipIfStatsHCInDelivers & 0xffffffff; + ep->stats.HCInDelivers.high = + ipe->ipIfStatsHCInDelivers >> 32; + ep->stats.HCOutRequests.low = + ipe->ipIfStatsHCOutRequests & 0xffffffff; + ep->stats.HCOutRequests.high = + ipe->ipIfStatsHCOutRequests >> 32; + ep->stats.HCOutNoRoutes.low = ipe->ipIfStatsOutNoRoutes & 0xffffffff; + ep->stats.HCOutNoRoutes.high = 0; + ep->stats.HCOutForwDatagrams.low = + ipe->ipIfStatsHCOutForwDatagrams & 0xffffffff; + ep->stats.HCOutForwDatagrams.high = + ipe->ipIfStatsHCOutForwDatagrams >> 32; + ep->stats.HCOutDiscards.low = ipe->ipIfStatsOutDiscards & 0xffffffff; + ep->stats.HCOutDiscards.high = 0; + ep->stats.HCOutFragOKs.low = ipe->ipIfStatsOutFragOKs & 0xffffffff; + ep->stats.HCOutFragOKs.high = 0; + ep->stats.HCOutFragFails.low = ipe->ipIfStatsOutFragFails & 0xffffffff; + ep->stats.HCOutFragFails.high = 0; + ep->stats.HCOutFragCreates.low = ipe->ipIfStatsOutFragCreates & 0xffffffff; + ep->stats.HCOutFragCreates.high = 0; + ep->stats.HCOutTransmits.low = + ipe->ipIfStatsHCOutTransmits & 0xffffffff; + ep->stats.HCOutTransmits.high = ipe->ipIfStatsHCOutTransmits >> 32; + ep->stats.HCOutOctets.low = ipe->ipIfStatsHCOutOctets & 0xffffffff; + ep->stats.HCOutOctets.high = ipe->ipIfStatsHCOutOctets >> 32; + ep->stats.HCInMcastPkts.low = ipe->ipIfStatsHCInMcastPkts & 0xffffffff; + ep->stats.HCInMcastPkts.high = ipe->ipIfStatsHCInMcastPkts >> 32; + ep->stats.HCInMcastOctets.low = + ipe->ipIfStatsHCInMcastOctets & 0xffffffff; + ep->stats.HCInMcastOctets.high = ipe->ipIfStatsHCInMcastOctets >> 32; + ep->stats.HCOutMcastPkts.low = + ipe->ipIfStatsHCOutMcastPkts & 0xffffffff; + ep->stats.HCOutMcastPkts.high = ipe->ipIfStatsHCOutMcastPkts >> 32; + ep->stats.HCOutMcastOctets.low = + ipe->ipIfStatsHCOutMcastOctets & 0xffffffff; + ep->stats.HCOutMcastOctets.high = ipe->ipIfStatsHCOutMcastOctets >> 32; + ep->stats.HCInBcastPkts.low = ipe->ipIfStatsHCInBcastPkts & 0xffffffff; + ep->stats.HCInBcastPkts.high = ipe->ipIfStatsHCInBcastPkts >> 32; + ep->stats.HCOutBcastPkts.low = + ipe->ipIfStatsHCOutBcastPkts & 0xffffffff; + ep->stats.HCOutBcastPkts.high = ipe->ipIfStatsHCOutBcastPkts >> 32; + + for (i=0; i<=IPSYSTEMSTATSTABLE_LAST; i++) + ep->stats.columnAvail[i] = 1; + + if (CONTAINER_INSERT(container, ep) < 0) { + DEBUGMSGT(("access:systemstats:arch", "unable to insert entry")); + netsnmp_access_systemstats_entry_free(ep); + return (-1); + } + return (0); +} diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable.h b/agent/mibgroup/ip-mib/inetNetToMediaTable.h new file mode 100644 index 0000000..c2faab8 --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable.h @@ -0,0 +1,8 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/data_access/arp) +config_require(ip-mib/inetNetToMediaTable/inetNetToMediaTable) +config_require(ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface) +config_require(ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access) diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable.c b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable.c new file mode 100644 index 0000000..aaae2e3 --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable.c @@ -0,0 +1,1817 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for inetNetToMediaTable + * + * \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 "inetNetToMediaTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "inetNetToMediaTable_interface.h" + +const oid inetNetToMediaTable_oid[] = { INETNETTOMEDIATABLE_OID }; +const int inetNetToMediaTable_oid_size = +OID_LENGTH(inetNetToMediaTable_oid); + +inetNetToMediaTable_registration inetNetToMediaTable_user_context; +static inetNetToMediaTable_registration *inetNetToMediaTable_user_context_p; + +void initialize_table_inetNetToMediaTable(void); +void shutdown_table_inetNetToMediaTable(void); + + +/** + * Initializes the inetNetToMediaTable module + */ +void +init_inetNetToMediaTable(void) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:init_inetNetToMediaTable", + "called\n")); + + /* + * TODO:300:o: Perform inetNetToMediaTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("inetNetToMediaTable")) + initialize_table_inetNetToMediaTable(); + +} /* init_inetNetToMediaTable */ + +/** + * Shut-down the inetNetToMediaTable module (agent is exiting) + */ +void +shutdown_inetNetToMediaTable(void) +{ + if (should_init("inetNetToMediaTable")) + shutdown_table_inetNetToMediaTable(); + +} + +/** + * Initialize the table inetNetToMediaTable + * (Define its contents and how it's structured) + */ +void +initialize_table_inetNetToMediaTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:initialize_table_inetNetToMediaTable", "called\n")); + + /* + * TODO:301:o: Perform inetNetToMediaTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize inetNetToMediaTable 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. + */ + inetNetToMediaTable_user_context_p = + netsnmp_create_data_list("inetNetToMediaTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _inetNetToMediaTable_initialize_interface + (inetNetToMediaTable_user_context_p, flags); +} /* initialize_table_inetNetToMediaTable */ + +/** + * Shutdown the table inetNetToMediaTable + */ +void +shutdown_table_inetNetToMediaTable(void) +{ + /* + * call interface shutdown code + */ + _inetNetToMediaTable_shutdown_interface + (inetNetToMediaTable_user_context_p); + netsnmp_free_all_list_data(inetNetToMediaTable_user_context_p); + inetNetToMediaTable_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 +inetNetToMediaTable_rowreq_ctx_init(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra inetNetToMediaTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* inetNetToMediaTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +inetNetToMediaTable_rowreq_ctx_cleanup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + /* + * TODO:211:o: |-> Perform extra inetNetToMediaTable rowreq cleanup. + */ + SNMP_FREE(rowreq_ctx->data); +} /* inetNetToMediaTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +inetNetToMediaTable_pre_request(inetNetToMediaTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform inetNetToMediaTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* inetNetToMediaTable_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 +inetNetToMediaTable_post_request(inetNetToMediaTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform inetNetToMediaTable post-request actions. + */ + + /* + * check to set if any rows were changed. + */ + if (inetNetToMediaTable_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 + */ + } + + inetNetToMediaTable_dirty_set(0); /* clear table dirty flag */ + } + + return MFD_SUCCESS; +} /* inetNetToMediaTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement inetNetToMediaTable data context functions. + */ +/* + * inetNetToMediaTable_allocate_data + * + * Purpose: create new inetNetToMediaTable_data. + */ +inetNetToMediaTable_data * +inetNetToMediaTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the inetNetToMediaTable data context. + */ + /** this might not be right for netsnmp_inetmedia_entry */ + inetNetToMediaTable_data *rtn = netsnmp_access_arp_entry_create(); + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_allocate_data", "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "inetNetToMediaTable_data.\n"); + } + + return rtn; +} /* inetNetToMediaTable_allocate_data */ + +/* + * inetNetToMediaTable_release_data + * + * Purpose: release inetNetToMediaTable data. + */ +void +inetNetToMediaTable_release_data(inetNetToMediaTable_data * data) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_release_data", "called\n")); + + /* + * TODO:202:r: |-> release memory for the inetNetToMediaTable data context. + */ + netsnmp_access_arp_entry_free(data); +} /* inetNetToMediaTable_release_data */ + + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param inetNetToMediaIfIndex_val + * @param inetNetToMediaNetAddressType_val + * @param inetNetToMediaNetAddress_val_ptr + * @param inetNetToMediaNetAddress_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 +inetNetToMediaTable_indexes_set_tbl_idx(inetNetToMediaTable_mib_index * + tbl_idx, + long inetNetToMediaIfIndex_val, + u_long + inetNetToMediaNetAddressType_val, + char + *inetNetToMediaNetAddress_val_ptr, + size_t + inetNetToMediaNetAddress_val_ptr_len) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_indexes_set_tbl_idx", "called\n")); + + /* + * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + /** WARNING: this code might not work for netsnmp_arp_entry */ + tbl_idx->inetNetToMediaIfIndex = inetNetToMediaIfIndex_val; + + /* + * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_arp_entry */ + tbl_idx->inetNetToMediaNetAddressType = + inetNetToMediaNetAddressType_val; + + /* + * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + tbl_idx->inetNetToMediaNetAddress_len = sizeof(tbl_idx->inetNetToMediaNetAddress) / sizeof(tbl_idx->inetNetToMediaNetAddress[0]); /* max length */ + /** WARNING: this code might not work for netsnmp_arp_entry */ + /* + * make sure there is enough space for inetNetToMediaNetAddress data + */ + if (tbl_idx->inetNetToMediaNetAddress_len < + inetNetToMediaNetAddress_val_ptr_len) { + snmp_log(LOG_ERR, "not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->inetNetToMediaNetAddress_len = + inetNetToMediaNetAddress_val_ptr_len; + memcpy(tbl_idx->inetNetToMediaNetAddress, + inetNetToMediaNetAddress_val_ptr, + inetNetToMediaNetAddress_val_ptr_len * + sizeof(inetNetToMediaNetAddress_val_ptr[0])); + + + return MFD_SUCCESS; +} /* inetNetToMediaTable_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 +inetNetToMediaTable_indexes_set(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, long inetNetToMediaIfIndex_val, + u_long inetNetToMediaNetAddressType_val, + char *inetNetToMediaNetAddress_val_ptr, + size_t + inetNetToMediaNetAddress_val_ptr_len) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_indexes_set", "called\n")); + + if (MFD_SUCCESS != + inetNetToMediaTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + inetNetToMediaIfIndex_val, + inetNetToMediaNetAddressType_val, + inetNetToMediaNetAddress_val_ptr, + inetNetToMediaNetAddress_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 != inetNetToMediaTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* inetNetToMediaTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaPhysAddress + * inetNetToMediaPhysAddress is subid 4 of inetNetToMediaEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.35.1.4 + * Description: +The media-dependent `physical' address. + + + As the entries in this table are typically not persistent + when this object is written the entity SHOULD NOT save the + change to non-volatile storage. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 1x: + * + * Ranges: 0 - 65535; + * + * Its syntax is PhysAddress (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 65535) + */ +/** + * Extract the current value of the inetNetToMediaPhysAddress data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetNetToMediaPhysAddress_val_ptr_ptr + * Pointer to storage for a char variable + * @param inetNetToMediaPhysAddress_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by inetNetToMediaPhysAddress. + * 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 (*inetNetToMediaPhysAddress_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update inetNetToMediaPhysAddress_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 +inetNetToMediaPhysAddress_get(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + char **inetNetToMediaPhysAddress_val_ptr_ptr, + size_t + * inetNetToMediaPhysAddress_val_ptr_len_ptr) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert((NULL != inetNetToMediaPhysAddress_val_ptr_ptr) + && (NULL != *inetNetToMediaPhysAddress_val_ptr_ptr)); + netsnmp_assert(NULL != inetNetToMediaPhysAddress_val_ptr_len_ptr); + + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaPhysAddress_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetNetToMediaPhysAddress data. + * copy (* inetNetToMediaPhysAddress_val_ptr_ptr ) data and (* inetNetToMediaPhysAddress_val_ptr_len_ptr ) from rowreq_ctx->data + */ + if ((*inetNetToMediaPhysAddress_val_ptr_len_ptr) < + rowreq_ctx->data->arp_physaddress_len) + return MFD_SKIP; + + memcpy((*inetNetToMediaPhysAddress_val_ptr_ptr), + rowreq_ctx->data->arp_physaddress, + rowreq_ctx->data->arp_physaddress_len); + (*inetNetToMediaPhysAddress_val_ptr_len_ptr) = + rowreq_ctx->data->arp_physaddress_len; + + return MFD_SUCCESS; +} /* inetNetToMediaPhysAddress_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaLastUpdated + * inetNetToMediaLastUpdated is subid 5 of inetNetToMediaEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.35.1.5 + * Description: +The value of sysUpTime at the time this entry was last + updated. If this entry was updated prior to the last re- + initialization of the local network management subsystem, + then this object contains a zero value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is TimeStamp (based on perltype TICKS) + * The net-snmp type is ASN_TIMETICKS. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the inetNetToMediaLastUpdated data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetNetToMediaLastUpdated_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 +inetNetToMediaLastUpdated_get(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long * inetNetToMediaLastUpdated_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetNetToMediaLastUpdated_val_ptr); + + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaLastUpdated_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetNetToMediaLastUpdated data. + * copy (* inetNetToMediaLastUpdated_val_ptr ) from rowreq_ctx->data + */ + *inetNetToMediaLastUpdated_val_ptr = rowreq_ctx->data->arp_last_updated; + return MFD_SUCCESS; +} /* inetNetToMediaLastUpdated_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaType + * inetNetToMediaType is subid 6 of inetNetToMediaEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.35.1.6 + * Description: +The type of mapping. + + + Setting this object to the value invalid(2) has the effect + of invalidating the corresponding entry in the + inetNetToMediaTable. That is, it effectively dis- + associates the interface identified with said entry from the + mapping identified with said entry. It is an + implementation- specific matter as to whether the agent + removes an invalidated entry from the table. Accordingly, + management stations must be prepared to receive tabular + information from agents that corresponds to entries not + currently in use. Proper interpretation of such entries + requires examination of the relevant inetNetToMediaType + object. + + + The 'dynamic(3)' type indicates that the IP address to + physical addresses mapping has been dynamically resolved + using e.g. IPv4 ARP or the IPv6 Neighbor Discovery protocol. + + + The 'static(4)' type indicates that the mapping has been + statically configured. Both of these refer to entries that + provide mappings for other entities addresses. + + + The 'local(5)' type indicates that the mapping is provided + for an entity's own interface address. + + + As the entries in this table are typically not persistent + when this object is written the entity SHOULD NOT save the + + + + + change to non-volatile storage. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: static + * + * Enum range: 5/8. Values: other(1), invalid(2), dynamic(3), static(4), local(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 inetNetToMediaType data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetNetToMediaType_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 +inetNetToMediaType_get(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long * inetNetToMediaType_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetNetToMediaType_val_ptr); + + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaType_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetNetToMediaType data. + * copy (* inetNetToMediaType_val_ptr ) from rowreq_ctx->data + */ + (*inetNetToMediaType_val_ptr) = rowreq_ctx->data->arp_type; + + return MFD_SUCCESS; +} /* inetNetToMediaType_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaState + * inetNetToMediaState is subid 7 of inetNetToMediaEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.35.1.7 + * Description: +The Neighbor Unreachability Detection [4] state for the + interface when the address mapping in this entry is used. + If Neighbor Unreachability Detection is not in use (e.g. for + IPv4), this object is always unknown(6). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 6/8. Values: reachable(1), stale(2), delay(3), probe(4), invalid(5), unknown(6), incomplete(7) + * + * 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 inetNetToMediaState data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetNetToMediaState_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 +inetNetToMediaState_get(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long * inetNetToMediaState_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetNetToMediaState_val_ptr); + + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaState_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the inetNetToMediaState data. + * copy (* inetNetToMediaState_val_ptr ) from rowreq_ctx->data + */ + (*inetNetToMediaState_val_ptr) = rowreq_ctx->data->arp_state; + + return MFD_SUCCESS; +} /* inetNetToMediaState_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaRowStatus + * inetNetToMediaRowStatus is subid 8 of inetNetToMediaEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.35.1.8 + * Description: +The status of this conceptual row. + + + The RowStatus TC requires that this DESCRIPTION clause + states under which circumstances other objects in this row + can be modified. The value of this object has no effect on + whether other objects in this conceptual row can be + modified. + + + A conceptual row can not be made active until the + inetNetToMediaPhysAddress object has been set. + + + + + Note that if the inetNetToMediaType is set to 'invalid' the + managed node may delete the entry independent of the state + of this object. + * + * 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 inetNetToMediaRowStatus data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetNetToMediaRowStatus_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 +inetNetToMediaRowStatus_get(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long * inetNetToMediaRowStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != inetNetToMediaRowStatus_val_ptr); + + (*inetNetToMediaRowStatus_val_ptr) = + rowreq_ctx->inetNetToMediaRowStatus; + + return MFD_SUCCESS; +} /* inetNetToMediaRowStatus_get */ + + + +/** @} */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + /* + * 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 + * inetNetToMediaTable_allocate_data(), but may need extra + * initialization similar to what you may have done in + * inetNetToMediaTable_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 (inetNetToMediaTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +inetNetToMediaTable_undo_setup(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_undo_setup", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> Setup inetNetToMediaTable undo. + * set up inetNetToMediaTable undo information, in preparation for a set. + * Undo storage is in (* inetNetToMediaRowStatus_val_ptr )* + */ + + return rc; +} /* inetNetToMediaTable_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 (inetNetToMediaTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +inetNetToMediaTable_undo(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_undo", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> inetNetToMediaTable undo. + * inetNetToMediaTable undo information, in response to a failed set. + * Undo storage is in (* inetNetToMediaRowStatus_val_ptr )* + */ + + return rc; +} /* inetNetToMediaTable_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 (inetNetToMediaTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +inetNetToMediaTable_undo_cleanup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_undo_cleanup", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:452:M: |-> Cleanup inetNetToMediaTable undo. + * Undo storage is in (* inetNetToMediaRowStatus_val_ptr )* + */ + + return rc; +} /* inetNetToMediaTable_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 + * inetNetToMediaTable.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 +inetNetToMediaTable_commit(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + int save_flags; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_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 inetNetToMediaTable 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 1 + /** xxx-rks:9 nettomedia commit */ +#else + if (save_flags & COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG) { + save_flags &= ~COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG; /* clear inetNetToMediaPhysAddress */ + /* + * TODO:482:o: |-> commit column inetNetToMediaPhysAddress. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "inetNetToMediaTable column inetNetToMediaPhysAddress commit failed\n"); + } else { + /* + * set flag, in case we need to undo inetNetToMediaPhysAddress + */ + rowreq_ctx->column_set_flags |= + COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG; + } + } + + if (save_flags & COLUMN_INETNETTOMEDIATYPE_FLAG) { + save_flags &= ~COLUMN_INETNETTOMEDIATYPE_FLAG; /* clear inetNetToMediaType */ + /* + * TODO:482:o: |-> commit column inetNetToMediaType. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "inetNetToMediaTable column inetNetToMediaType commit failed\n"); + } else { + /* + * set flag, in case we need to undo inetNetToMediaType + */ + rowreq_ctx->column_set_flags |= COLUMN_INETNETTOMEDIATYPE_FLAG; + } + } + + if (save_flags & COLUMN_INETNETTOMEDIAROWSTATUS_FLAG) { + save_flags &= ~COLUMN_INETNETTOMEDIAROWSTATUS_FLAG; /* clear inetNetToMediaRowStatus */ + /* + * TODO:482:o: |-> commit column inetNetToMediaRowStatus. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "inetNetToMediaTable column inetNetToMediaRowStatus commit failed\n"); + } else { + /* + * set flag, in case we need to undo inetNetToMediaRowStatus + */ + rowreq_ctx->column_set_flags |= + COLUMN_INETNETTOMEDIAROWSTATUS_FLAG; + } + } + + /* + * if we successfully commited this row, set the dirty flag. + */ + if (MFD_SUCCESS == rc) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; + } +#endif + + if (save_flags) { + snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", + save_flags); + return MFD_ERROR; + } + + return rc; +} /* inetNetToMediaTable_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 + * inetNetToMediaTable.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 +inetNetToMediaTable_undo_commit(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_undo_commit", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:485:M: |-> Undo inetNetToMediaTable 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; +} /* inetNetToMediaTable_undo_commit */ + +/* + * TODO:440:M: Implement inetNetToMediaTable node value checks. + * TODO:450:M: Implement inetNetToMediaTable undo functions. + * TODO:460:M: Implement inetNetToMediaTable set functions. + * TODO:480:M: Implement inetNetToMediaTable commit functions. + */ +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaPhysAddress + * inetNetToMediaPhysAddress is subid 4 of inetNetToMediaEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.35.1.4 + * Description: +The media-dependent `physical' address. + + + As the entries in this table are typically not persistent + when this object is written the entity SHOULD NOT save the + change to non-volatile storage. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 1x: + * + * Ranges: 0 - 65535; + * + * Its syntax is PhysAddress (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 65535) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param inetNetToMediaPhysAddress_val_ptr + * A char containing the new value. + * @param inetNetToMediaPhysAddress_val_ptr_len + * The size (in bytes) of the data pointed to by inetNetToMediaPhysAddress_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 + * inetNetToMediaTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_OCTET_STR + * The length is in (one of) the range set(s): 0 - 65535 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetNetToMediaPhysAddress_check_value(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, char + *inetNetToMediaPhysAddress_val_ptr, + size_t + inetNetToMediaPhysAddress_val_ptr_len) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaPhysAddress_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + netsnmp_assert(NULL != inetNetToMediaPhysAddress_val_ptr); + + /* + * TODO:441:o: |-> Check for valid inetNetToMediaPhysAddress value. + */ + + return MFD_SUCCESS; /* inetNetToMediaPhysAddress value not illegal */ +} /* inetNetToMediaPhysAddress_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (inetNetToMediaTable_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 + * inetNetToMediaTable_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 +inetNetToMediaPhysAddress_undo_setup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaPhysAddress_undo_setup", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup inetNetToMediaPhysAddress undo. + */ + /* + * copy inetNetToMediaPhysAddress and inetNetToMediaPhysAddress_len data + * set rowreq_ctx->undo->inetNetToMediaPhysAddress from rowreq_ctx->data->inetNetToMediaPhysAddress + */ + + + return MFD_SUCCESS; +} /* inetNetToMediaPhysAddress_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 inetNetToMediaPhysAddress_val_ptr + * A char containing the new value. + * @param inetNetToMediaPhysAddress_val_ptr_len + * The size (in bytes) of the data pointed to by inetNetToMediaPhysAddress_val_ptr + */ +int +inetNetToMediaPhysAddress_set(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + char *inetNetToMediaPhysAddress_val_ptr, + size_t inetNetToMediaPhysAddress_val_ptr_len) +{ + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaPhysAddress_set", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + netsnmp_assert(NULL != inetNetToMediaPhysAddress_val_ptr); + + /* + * TODO:461:M: |-> Set inetNetToMediaPhysAddress value. + * set inetNetToMediaPhysAddress value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* inetNetToMediaPhysAddress_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +inetNetToMediaPhysAddress_undo(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaPhysAddress_undo", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up inetNetToMediaPhysAddress undo. + */ + /* + * copy inetNetToMediaPhysAddress and inetNetToMediaPhysAddress_len data + * set rowreq_ctx->data->inetNetToMediaPhysAddress from rowreq_ctx->undo->inetNetToMediaPhysAddress + */ + + + return MFD_SUCCESS; +} /* inetNetToMediaPhysAddress_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaType + * inetNetToMediaType is subid 6 of inetNetToMediaEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.35.1.6 + * Description: +The type of mapping. + + + Setting this object to the value invalid(2) has the effect + of invalidating the corresponding entry in the + inetNetToMediaTable. That is, it effectively dis- + associates the interface identified with said entry from the + mapping identified with said entry. It is an + implementation- specific matter as to whether the agent + removes an invalidated entry from the table. Accordingly, + management stations must be prepared to receive tabular + information from agents that corresponds to entries not + currently in use. Proper interpretation of such entries + requires examination of the relevant inetNetToMediaType + object. + + + The 'dynamic(3)' type indicates that the IP address to + physical addresses mapping has been dynamically resolved + using e.g. IPv4 ARP or the IPv6 Neighbor Discovery protocol. + + + The 'static(4)' type indicates that the mapping has been + statically configured. Both of these refer to entries that + provide mappings for other entities addresses. + + + The 'local(5)' type indicates that the mapping is provided + for an entity's own interface address. + + + As the entries in this table are typically not persistent + when this object is written the entity SHOULD NOT save the + + + + + change to non-volatile storage. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: static + * + * Enum range: 5/8. Values: other(1), invalid(2), dynamic(3), static(4), local(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 inetNetToMediaType_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 + * inetNetToMediaTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of other(1), invalid(2), dynamic(3), static(4), local(5) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +inetNetToMediaType_check_value(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long inetNetToMediaType_val) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaType_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetNetToMediaType value. + */ + + return MFD_SUCCESS; /* inetNetToMediaType value not illegal */ +} /* inetNetToMediaType_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (inetNetToMediaTable_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 + * inetNetToMediaTable_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 +inetNetToMediaType_undo_setup(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaType_undo_setup", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup inetNetToMediaType undo. + */ + /* + * copy inetNetToMediaType data + * set rowreq_ctx->undo->inetNetToMediaType from rowreq_ctx->data->inetNetToMediaType + */ + + + return MFD_SUCCESS; +} /* inetNetToMediaType_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 inetNetToMediaType_val + * A long containing the new value. + */ +int +inetNetToMediaType_set(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long inetNetToMediaType_val) +{ + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaType_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetNetToMediaType value. + * set inetNetToMediaType value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* inetNetToMediaType_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +inetNetToMediaType_undo(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaType_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up inetNetToMediaType undo. + */ + /* + * copy inetNetToMediaType data + * set rowreq_ctx->data->inetNetToMediaType from rowreq_ctx->undo->inetNetToMediaType + */ + + + return MFD_SUCCESS; +} /* inetNetToMediaType_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaRowStatus + * inetNetToMediaRowStatus is subid 8 of inetNetToMediaEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.35.1.8 + * Description: +The status of this conceptual row. + + + The RowStatus TC requires that this DESCRIPTION clause + states under which circumstances other objects in this row + can be modified. The value of this object has no effect on + whether other objects in this conceptual row can be + modified. + + + A conceptual row can not be made active until the + inetNetToMediaPhysAddress object has been set. + + + + + Note that if the inetNetToMediaType is set to 'invalid' the + managed node may delete the entry independent of the state + of this object. + * + * 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 inetNetToMediaRowStatus_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 + * inetNetToMediaTable_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 +inetNetToMediaRowStatus_check_value(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long inetNetToMediaRowStatus_val) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaRowStatus_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid inetNetToMediaRowStatus value. + */ + + return MFD_SUCCESS; /* inetNetToMediaRowStatus value not illegal */ +} /* inetNetToMediaRowStatus_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (inetNetToMediaTable_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 + * inetNetToMediaTable_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 +inetNetToMediaRowStatus_undo_setup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaRowStatus_undo_setup", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup inetNetToMediaRowStatus undo. + */ + /* + * copy inetNetToMediaRowStatus data + * set rowreq_ctx->undo->inetNetToMediaRowStatus from rowreq_ctx->data->inetNetToMediaRowStatus + */ + rowreq_ctx->inetNetToMediaRowStatus_undo = + rowreq_ctx->inetNetToMediaRowStatus; + + return MFD_SUCCESS; +} /* inetNetToMediaRowStatus_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 inetNetToMediaRowStatus_val + * A long containing the new value. + */ +int +inetNetToMediaRowStatus_set(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long inetNetToMediaRowStatus_val) +{ + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaRowStatus_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set inetNetToMediaRowStatus value. + * set inetNetToMediaRowStatus value in rowreq_ctx->data + */ + + return MFD_SUCCESS; +} /* inetNetToMediaRowStatus_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +inetNetToMediaRowStatus_undo(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaRowStatus_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up inetNetToMediaRowStatus undo. + */ + /* + * copy inetNetToMediaRowStatus data + * set rowreq_ctx->data->inetNetToMediaRowStatus from rowreq_ctx->undo->inetNetToMediaRowStatus + */ + rowreq_ctx->inetNetToMediaRowStatus = + rowreq_ctx->inetNetToMediaRowStatus_undo; + + + return MFD_SUCCESS; +} /* inetNetToMediaRowStatus_undo */ + +/** + * 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 + * inetNetToMediaTable.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rowreq_ctx + * + * @retval MFD_SUCCESS all the changes to the row are legal + * @retval MFD_ERROR one or more changes are not legal + * + * (see README-table-inetNetToMediaTable if you don't have dependencies) + */ +int +inetNetToMediaTable_check_dependencies(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:inetNetToMediaTable_check_dependencies", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:470:o: Check inetNetToMediaTable row dependencies. + * check that all new value are legal and consistent with each other + */ + /* + * check RowStatus dependencies + */ + if (rowreq_ctx->column_set_flags & COLUMN_INETNETTOMEDIAROWSTATUS_FLAG) { + /* + * check for valid RowStatus transition (old, new) + * (Note: move transition check to + * to catch errors earlier) + */ + rc = check_rowstatus_transition(rowreq_ctx-> + inetNetToMediaRowStatus_undo, + rowreq_ctx-> + inetNetToMediaRowStatus); + if (MFD_SUCCESS != rc) + return rc; + + /* + * row creation requirements + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + if (ROWSTATUS_DESTROY == rowreq_ctx->inetNetToMediaRowStatus) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; + } else if (ROWSTATUS_CREATEANDGO == + rowreq_ctx->inetNetToMediaRowStatus) { + if ((rowreq_ctx-> + column_set_flags & INETNETTOMEDIATABLE_REQUIRED_COLS) + != INETNETTOMEDIATABLE_REQUIRED_COLS) { + DEBUGMSGTL(("inetNetToMediaTable", + "required columns missing (0x%0x != 0x%0x)\n", + rowreq_ctx->column_set_flags, + INETNETTOMEDIATABLE_REQUIRED_COLS)); + return MFD_CANNOT_CREATE_NOW; + } + rowreq_ctx->inetNetToMediaRowStatus = 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->inetNetToMediaRowStatus) { + if (rowreq_ctx-> + column_set_flags & + ~COLUMN_INETNETTOMEDIAROWSTATUS_FLAG) { + DEBUGMSGTL(("inetNetToMediaTable", + "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(("inetNetToMediaTable", + "must use RowStatus to create rows\n")); + return MFD_CANNOT_CREATE_NOW; + } + } /* row status not set */ + + if (MFD_SUCCESS != rc) + return rc; + + return rc; +} /* inetNetToMediaTable_check_dependencies */ + +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable.h b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable.h new file mode 100644 index 0000000..73afae6 --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable.h @@ -0,0 +1,420 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef INETNETTOMEDIATABLE_H +#define INETNETTOMEDIATABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/arp.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-mib/data_access/arp) +config_require(ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface) +config_require(ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for inetNetToMediaTable + */ +#include "inetNetToMediaTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void init_inetNetToMediaTable(void); + void shutdown_inetNetToMediaTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + /* + ********************************************************************* + * 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 inetNetToMediaTable registration context. + */ + typedef netsnmp_data_list inetNetToMediaTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review inetNetToMediaTable data context structure. + * This structure is used to represent the data for inetNetToMediaTable. + */ + typedef netsnmp_arp_entry inetNetToMediaTable_data; + + + /* + ********************************************************************* + * TODO:115:o: |-> Review inetNetToMediaTable 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 inetNetToMediaTable_data inetNetToMediaTable_undo_data; + + /* + * TODO:120:r: |-> Review inetNetToMediaTable mib index. + * This structure is used to represent the index for inetNetToMediaTable. + */ + typedef struct inetNetToMediaTable_mib_index_s { + + /* + * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + long inetNetToMediaIfIndex; + + /* + * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long inetNetToMediaNetAddressType; + + /* + * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + /** 128 - 2(other indexes) - oid length(10) = 115 */ + char inetNetToMediaNetAddress[115]; + size_t inetNetToMediaNetAddress_len; + + + } inetNetToMediaTable_mib_index; + + /* + * TODO:121:r: | |-> Review inetNetToMediaTable 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! + * Guessing 128 - col/entry(2) - oid len(8) + */ +#define MAX_inetNetToMediaTable_IDX_LEN 118 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review inetNetToMediaTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * inetNetToMediaTable_rowreq_ctx pointer. + */ + typedef struct inetNetToMediaTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_inetNetToMediaTable_IDX_LEN]; + + inetNetToMediaTable_mib_index tbl_idx; + + inetNetToMediaTable_data *data; + inetNetToMediaTable_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 inetNetToMediaTable rowreq context. + */ + int inetNetToMediaRowStatus, + inetNetToMediaRowStatus_undo; + + /* + * storage for future expansion + */ + netsnmp_data_list *inetNetToMediaTable_data_list; + + } inetNetToMediaTable_rowreq_ctx; + + typedef struct inetNetToMediaTable_ref_rowreq_ctx_s { + inetNetToMediaTable_rowreq_ctx *rowreq_ctx; + } inetNetToMediaTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + inetNetToMediaTable_pre_request(inetNetToMediaTable_registration * + user_context); + int + inetNetToMediaTable_post_request(inetNetToMediaTable_registration * + user_context, int rc); + + int + inetNetToMediaTable_rowreq_ctx_init(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx, + void *user_init_ctx); + void + inetNetToMediaTable_rowreq_ctx_cleanup + (inetNetToMediaTable_rowreq_ctx * rowreq_ctx); + + inetNetToMediaTable_data *inetNetToMediaTable_allocate_data(void); + void + inetNetToMediaTable_release_data(inetNetToMediaTable_data * data); + + int + inetNetToMediaTable_check_dependencies + (inetNetToMediaTable_rowreq_ctx * rowreq_ctx); + int + inetNetToMediaTable_commit(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + + inetNetToMediaTable_rowreq_ctx + * inetNetToMediaTable_row_find_by_mib_index + (inetNetToMediaTable_mib_index * mib_idx); + + extern const oid inetNetToMediaTable_oid[]; + extern const int inetNetToMediaTable_oid_size; + + +#include "inetNetToMediaTable_interface.h" +#include "inetNetToMediaTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + /* + * indexes + */ + + int + inetNetToMediaPhysAddress_get(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, char + **inetNetToMediaPhysAddress_val_ptr_ptr, + size_t * + inetNetToMediaPhysAddress_val_ptr_len_ptr); + int + inetNetToMediaLastUpdated_get(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetNetToMediaLastUpdated_val_ptr); + int inetNetToMediaType_get(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetNetToMediaType_val_ptr); + int inetNetToMediaState_get(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx, + u_long * + inetNetToMediaState_val_ptr); + + int + inetNetToMediaRowStatus_get(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long * + inetNetToMediaRowStatus_val_ptr); + + int + inetNetToMediaRowStatus_set(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long + inetNetToMediaRowStatus_val); + + + int + inetNetToMediaTable_indexes_set_tbl_idx + (inetNetToMediaTable_mib_index * tbl_idx, + long inetNetToMediaIfIndex_val, + u_long inetNetToMediaNetAddressType_val, + char *inetNetToMediaNetAddress_val_ptr, + size_t inetNetToMediaNetAddress_val_ptr_len); + int + inetNetToMediaTable_indexes_set(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + long inetNetToMediaIfIndex_val, + u_long + inetNetToMediaNetAddressType_val, + char + *inetNetToMediaNetAddress_val_ptr, + size_t + inetNetToMediaNetAddress_val_ptr_len); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + + + int + inetNetToMediaTable_undo_setup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int + inetNetToMediaTable_undo_cleanup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int inetNetToMediaTable_undo(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx); + int + inetNetToMediaTable_commit(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int + inetNetToMediaTable_undo_commit(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + + + int + inetNetToMediaPhysAddress_check_value + (inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + char *inetNetToMediaPhysAddress_val_ptr, + size_t inetNetToMediaPhysAddress_val_ptr_len); + int + inetNetToMediaPhysAddress_undo_setup(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx); + int + inetNetToMediaPhysAddress_set(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, char + *inetNetToMediaPhysAddress_val_ptr, + size_t + inetNetToMediaPhysAddress_val_ptr_len); + int + inetNetToMediaPhysAddress_undo(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + + int + inetNetToMediaLastUpdated_check_value + (inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + u_long inetNetToMediaLastUpdated_val); + int + inetNetToMediaLastUpdated_undo_setup(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx); + int + inetNetToMediaLastUpdated_set(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long + inetNetToMediaLastUpdated_val); + int + inetNetToMediaLastUpdated_undo(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + + int + inetNetToMediaType_check_value(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long inetNetToMediaType_val); + int + inetNetToMediaType_undo_setup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int inetNetToMediaType_set(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long inetNetToMediaType_val); + int inetNetToMediaType_undo(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx); + + int + inetNetToMediaState_check_value(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + u_long inetNetToMediaState_val); + int + inetNetToMediaState_undo_setup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int inetNetToMediaState_set(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx, + u_long + inetNetToMediaState_val); + int inetNetToMediaState_undo(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx); + + int + inetNetToMediaRowStatus_check_value(inetNetToMediaTable_rowreq_ctx + * rowreq_ctx, + u_long + inetNetToMediaRowStatus_val); + int + inetNetToMediaRowStatus_undo_setup(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int + inetNetToMediaRowStatus_undo(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + + + int + inetNetToMediaTable_check_dependencies + (inetNetToMediaTable_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 /* INETNETTOMEDIATABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_constants.h b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_constants.h new file mode 100644 index 0000000..0b23b9f --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_constants.h @@ -0,0 +1,161 @@ +/* + * 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 INETNETTOMEDIATABLE_CONSTANTS_H +#define INETNETTOMEDIATABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table inetNetToMediaTable + */ +#define INETNETTOMEDIATABLE_OID 1,3,6,1,2,1,4,35 + +#define COLUMN_INETNETTOMEDIAIFINDEX 1 + +#define COLUMN_INETNETTOMEDIANETADDRESSTYPE 2 + +#define COLUMN_INETNETTOMEDIANETADDRESS 3 + +#define COLUMN_INETNETTOMEDIAPHYSADDRESS 4 +#define COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG (0x1 << 3) + +#define COLUMN_INETNETTOMEDIALASTUPDATED 5 + +#define COLUMN_INETNETTOMEDIATYPE 6 +#define COLUMN_INETNETTOMEDIATYPE_FLAG (0x1 << 5) + +#define COLUMN_INETNETTOMEDIASTATE 7 + +#define COLUMN_INETNETTOMEDIAROWSTATUS 8 +#define COLUMN_INETNETTOMEDIAROWSTATUS_FLAG (0x1 << 7) + + +#define INETNETTOMEDIATABLE_MIN_COL COLUMN_INETNETTOMEDIAPHYSADDRESS +#define INETNETTOMEDIATABLE_MAX_COL COLUMN_INETNETTOMEDIAROWSTATUS + + + /* + * TODO:405:r: Review INETNETTOMEDIATABLE_SETTABLE_COLS macro. + * OR together all the writable cols. + */ +#define INETNETTOMEDIATABLE_SETTABLE_COLS (COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG | COLUMN_INETNETTOMEDIATYPE_FLAG | COLUMN_INETNETTOMEDIAROWSTATUS_FLAG) + /* + * TODO:405:r: Review INETNETTOMEDIATABLE_REQUIRED_COLS macro. + * OR together all the required rows for row creation. + * default is writable cols w/out defaults. + */ +#define INETNETTOMEDIATABLE_REQUIRED_COLS (COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG | COLUMN_INETNETTOMEDIAROWSTATUS_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 inetNetToMediaTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * inetNetToMediaNetAddressType (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 + * inetNetToMediaType (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETNETTOMEDIATYPE_ENUMS +#define INETNETTOMEDIATYPE_ENUMS + +#define INETNETTOMEDIATYPE_OTHER 1 +#define INETNETTOMEDIATYPE_INVALID 2 +#define INETNETTOMEDIATYPE_DYNAMIC 3 +#define INETNETTOMEDIATYPE_STATIC 4 +#define INETNETTOMEDIATYPE_LOCAL 5 + +#endif /* INETNETTOMEDIATYPE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * inetNetToMediaState (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETNETTOMEDIASTATE_ENUMS +#define INETNETTOMEDIASTATE_ENUMS + +#define INETNETTOMEDIASTATE_REACHABLE 1 +#define INETNETTOMEDIASTATE_STALE 2 +#define INETNETTOMEDIASTATE_DELAY 3 +#define INETNETTOMEDIASTATE_PROBE 4 +#define INETNETTOMEDIASTATE_INVALID 5 +#define INETNETTOMEDIASTATE_UNKNOWN 6 +#define INETNETTOMEDIASTATE_INCOMPLETE 7 + +#endif /* INETNETTOMEDIASTATE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * inetNetToMediaRowStatus (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 /* INETNETTOMEDIATABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access.c b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access.c new file mode 100644 index 0000000..d877f8b --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access.c @@ -0,0 +1,670 @@ +/* + * 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-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "inetNetToMediaTable.h" + + +#include "inetNetToMediaTable_data_access.h" + +netsnmp_feature_require(container_lifo) +static netsnmp_arp_access * arp_access = NULL; + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + +/** + * initialization for inetNetToMediaTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param inetNetToMediaTable_reg + * Pointer to inetNetToMediaTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +inetNetToMediaTable_init_data(inetNetToMediaTable_registration * + inetNetToMediaTable_reg) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_init_data", "called\n")); + + /* + * TODO:303:o: Initialize inetNetToMediaTable data. + */ + + return MFD_SUCCESS; +} /* inetNetToMediaTable_init_data */ + +/** + * container overview + * + */ + +/** + * check entry for update + */ +static void +_add_or_update_arp_entry(netsnmp_arp_entry *arp_entry, + netsnmp_container *container) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx, *old; + int inetAddressType; + + DEBUGTRACE; + + netsnmp_assert(NULL != arp_entry); + netsnmp_assert(NULL != container); + + /* + * convert the addr len to an inetAddressType + */ + switch (arp_entry->arp_ipaddress_len) { + case 4: + inetAddressType = INETADDRESSTYPE_IPV4; + break; + + case 16: + inetAddressType = INETADDRESSTYPE_IPV6; + break; + + default: + netsnmp_access_arp_entry_free(arp_entry); + snmp_log(LOG_ERR, "unsupported address type\n"); + return; + } + + /* + * allocate an row context and set the index(es), then try to find it in + * the cache. + */ + rowreq_ctx = inetNetToMediaTable_allocate_rowreq_ctx(arp_entry, NULL); + if ((NULL != rowreq_ctx) && + (MFD_SUCCESS == inetNetToMediaTable_indexes_set + (rowreq_ctx, rowreq_ctx->data->if_index, inetAddressType, + (char *) rowreq_ctx->data->arp_ipaddress, + rowreq_ctx->data->arp_ipaddress_len))) { + + /* try to find old entry */ + old = (inetNetToMediaTable_rowreq_ctx*)CONTAINER_FIND(container, rowreq_ctx); + if (arp_entry->flags & NETSNMP_ACCESS_ARP_ENTRY_FLAG_DELETE) { + /* delete existing entry */ + if (old != NULL) { + CONTAINER_REMOVE(container, old); + inetNetToMediaTable_release_rowreq_ctx(old); + } + inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx); + } else if (old != NULL) { + /* the entry is already there, update it */ + netsnmp_access_arp_entry_update(old->data, arp_entry); + /* delete the auxiliary context we used to find the entry + * (this deletes also arp_entry) */ + inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx); + } else { + /* create new entry and add it to the cache*/ + rowreq_ctx->inetNetToMediaRowStatus = ROWSTATUS_ACTIVE; + rowreq_ctx->data->arp_last_updated = netsnmp_get_agent_uptime(); + CONTAINER_INSERT(container, rowreq_ctx); + } + } else { + if (rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "inetNetToMediaTable cache.\n"); + inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx); + } else + netsnmp_access_arp_entry_free(arp_entry); + } +} + +static void _arp_hook_update(netsnmp_arp_access *access, netsnmp_arp_entry *entry) +{ + _add_or_update_arp_entry(entry, access->magic); +} + +typedef struct { + unsigned generation; + netsnmp_container *to_delete; +} _collect_ctx; + +/** + * Put all entries with outdated generation to deletion list. + */ +static void +_collect_invalid_arp_ctx(inetNetToMediaTable_rowreq_ctx *ctx, + _collect_ctx *cctx) +{ + if (ctx->data->generation != cctx->generation) + CONTAINER_INSERT(cctx->to_delete, ctx); +} + +static void _arp_hook_gc(netsnmp_arp_access *access) +{ + netsnmp_container *container = access->magic; + _collect_ctx cctx; + + cctx.to_delete = netsnmp_container_find("lifo"); + cctx.generation = access->generation; + + CONTAINER_FOR_EACH(container, + (netsnmp_container_obj_func *) _collect_invalid_arp_ctx, + &cctx); + + while (CONTAINER_SIZE(cctx.to_delete)) { + inetNetToMediaTable_rowreq_ctx *ctx = (inetNetToMediaTable_rowreq_ctx*)CONTAINER_FIRST(cctx.to_delete); + CONTAINER_REMOVE(container, ctx); + inetNetToMediaTable_release_rowreq_ctx(ctx); + CONTAINER_REMOVE(cctx.to_delete, NULL); + } + CONTAINER_FREE(cctx.to_delete); +} + +/** + * 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 +inetNetToMediaTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to inetNetToMediaTable_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 inetNetToMediaTable_container_init\n"); + return; + } + + arp_access = netsnmp_access_arp_create( + NETSNMP_ACCESS_ARP_CREATE_NOFLAGS, + _arp_hook_update, + _arp_hook_gc, + &cache->timeout, + &cache->flags, + &cache->expired); + if (arp_access == NULL) { + snmp_log(LOG_ERR, + "unable to create arp access in inetNetToMediaTable_container_init\n"); + return; + } +} /* inetNetToMediaTable_container_init */ + +/** + * 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 inetNetToMediaTable_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 +inetNetToMediaTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_container_shutdown", "called\n")); + + if (NULL != arp_access) { + netsnmp_access_arp_delete(arp_access); + arp_access = NULL; + } + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to inetNetToMediaTable_container_shutdown\n"); + return; + } +} /* inetNetToMediaTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement inetNetToMediaTable 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 + * inetNetToMediaTable_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 +inetNetToMediaTable_container_load(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_cache_load", "called\n")); + + arp_access->magic = container; + if (netsnmp_access_arp_load(arp_access) < 0) + return MFD_ERROR; + + return MFD_SUCCESS; +} /* inetNetToMediaTable_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 +inetNetToMediaTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_container_free", "called\n")); + + if (NULL != arp_access) { + netsnmp_access_arp_unload(arp_access); + arp_access->magic = NULL; + } + + /* + * TODO:380:M: Free inetNetToMediaTable container data. + */ +} /* inetNetToMediaTable_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 +inetNetToMediaTable_row_prep(inetNetToMediaTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_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; +} /* inetNetToMediaTable_row_prep */ + +/* + * TODO:420:r: Implement inetNetToMediaTable index validation. + */ +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaIfIndex + * inetNetToMediaIfIndex is subid 1 of inetNetToMediaEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.35.1.1 + * Description: +The index value which uniquely identifies the interface to + which this entry is applicable. The interface identified by + a particular value of this index is the same interface as + identified by the same value of the IF-MIB's ifIndex. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: d + * + * Ranges: 1 - 2147483647; + * + * Its syntax is InterfaceIndex (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + * + * + * + * NOTE: NODE inetNetToMediaIfIndex IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetNetToMediaIfIndex 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 + * inetNetToMediaTable_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): 1 - 2147483647 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + */ +int +inetNetToMediaIfIndex_check_index(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaIfIndex_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetNetToMediaTable index inetNetToMediaIfIndex. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetNetToMediaIfIndex) + */ + + return MFD_SUCCESS; /* inetNetToMediaIfIndex index ok */ +} /* inetNetToMediaIfIndex_check_index */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaNetAddressType + * inetNetToMediaNetAddressType is subid 2 of inetNetToMediaEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.35.1.2 + * Description: +The type of inetNetToMediaNetAddress. + * + * 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 inetNetToMediaNetAddressType IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetNetToMediaNetAddressType 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 + * inetNetToMediaTable_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 +inetNetToMediaNetAddressType_check_index(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaNetAddressType_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetNetToMediaTable index inetNetToMediaNetAddressType. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetNetToMediaNetAddressType) + */ + + return MFD_SUCCESS; /* inetNetToMediaNetAddressType index ok */ +} /* inetNetToMediaNetAddressType_check_index */ + +/*--------------------------------------------------------------------- + * IP-MIB::inetNetToMediaEntry.inetNetToMediaNetAddress + * inetNetToMediaNetAddress is subid 3 of inetNetToMediaEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.35.1.3 + * Description: +The IP Address corresponding to the media-dependent + `physical' address. The address type of this object is + specified in inetNetToMediaAddressType. + + + Implementors need to be aware that if the size of + inetNetToMediaNetAddress exceeds 115 octets then OIDS of + instances of columns in this row will have more than 128 + sub-identifiers and cannot be accessed using SNMPv1, SNMPv2c + or SNMPv3. + * + * 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 inetNetToMediaNetAddress IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of inetNetToMediaNetAddress 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 + * inetNetToMediaTable_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 +inetNetToMediaNetAddress_check_index(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaNetAddress_check_index", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check inetNetToMediaTable index inetNetToMediaNetAddress. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.inetNetToMediaNetAddress) + */ + + return MFD_SUCCESS; /* inetNetToMediaNetAddress index ok */ +} /* inetNetToMediaNetAddress_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 inetNetToMediaTable_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 +inetNetToMediaTable_validate_index(inetNetToMediaTable_registration * + inetNetToMediaTable_reg, + inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_validate_index", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:430:M: |-> Validate potential inetNetToMediaTable index. + */ + if (1) { + snmp_log(LOG_WARNING, "invalid index for a new row in the " + "inetNetToMediaTable 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; +} /* inetNetToMediaTable_validate_index */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access.h b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access.h new file mode 100644 index 0000000..cc0434b --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_data_access.h @@ -0,0 +1,84 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef INETNETTOMEDIATABLE_DATA_ACCESS_H +#define INETNETTOMEDIATABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ + + + int + inetNetToMediaTable_init_data(inetNetToMediaTable_registration * + inetNetToMediaTable_reg); + + + /* + * TODO:180:o: Review inetNetToMediaTable cache timeout. + * The number of seconds before the cache times out + */ +#define INETNETTOMEDIATABLE_CACHE_TIMEOUT 60 + + void inetNetToMediaTable_container_init(netsnmp_container + **container_ptr_ptr, + netsnmp_cache * + cache); + void + inetNetToMediaTable_container_shutdown(netsnmp_container + *container_ptr); + + int inetNetToMediaTable_container_load(netsnmp_container + *container); + void inetNetToMediaTable_container_free(netsnmp_container + *container); + + int inetNetToMediaTable_cache_load(netsnmp_container + *container); + void inetNetToMediaTable_cache_free(netsnmp_container + *container); + + int + inetNetToMediaTable_row_prep(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + + int + inetNetToMediaTable_validate_index(inetNetToMediaTable_registration + * inetNetToMediaTable_reg, + inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + int inetNetToMediaIfIndex_check_index(inetNetToMediaTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetNetToMediaNetAddressType_check_index(inetNetToMediaTable_rowreq_ctx * rowreq_ctx); /* internal */ + int inetNetToMediaNetAddress_check_index(inetNetToMediaTable_rowreq_ctx * rowreq_ctx); /* internal */ + + +#ifdef __cplusplus +} +#endif +#endif /* INETNETTOMEDIATABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c new file mode 100644 index 0000000..c18689a --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c @@ -0,0 +1,2032 @@ +/* + * 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 "inetNetToMediaTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "inetNetToMediaTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(inetNetToMediaTable_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(inetNetToMediaTable_container_size, inetNetToMediaTable_external_access) +netsnmp_feature_child_of(inetNetToMediaTable_registration_set, inetNetToMediaTable_external_access) +netsnmp_feature_child_of(inetNetToMediaTable_registration_get, inetNetToMediaTable_external_access) +netsnmp_feature_child_of(inetNetToMediaTable_container_get, inetNetToMediaTable_external_access) + +/********************************************************************** + ********************************************************************** + *** + *** Table inetNetToMediaTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::inetNetToMediaTable is subid 35 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.35, length: 8 + */ +typedef struct inetNetToMediaTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + inetNetToMediaTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_int table_dirty; + +} inetNetToMediaTable_interface_ctx; + +static inetNetToMediaTable_interface_ctx inetNetToMediaTable_if_ctx; + +static void + _inetNetToMediaTable_container_init(inetNetToMediaTable_interface_ctx * + if_ctx); +static void + _inetNetToMediaTable_container_shutdown(inetNetToMediaTable_interface_ctx * + if_ctx); + +#ifndef NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_CONTAINER_GET +netsnmp_container * +inetNetToMediaTable_container_get(void) +{ + return inetNetToMediaTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_REGISTRATION_GET +inetNetToMediaTable_registration * +inetNetToMediaTable_registration_get(void) +{ + return inetNetToMediaTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_REGISTRATION_SET +inetNetToMediaTable_registration * +inetNetToMediaTable_registration_set(inetNetToMediaTable_registration * + newreg) +{ + inetNetToMediaTable_registration *old = + inetNetToMediaTable_if_ctx.user_ctx; + inetNetToMediaTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_CONTAINER_SIZE +int +inetNetToMediaTable_container_size(void) +{ + return CONTAINER_SIZE(inetNetToMediaTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_CONTAINER_SIZE */ + +u_int +inetNetToMediaTable_dirty_get(void) +{ + return inetNetToMediaTable_if_ctx.table_dirty; +} + +void +inetNetToMediaTable_dirty_set(u_int status) +{ + DEBUGMSGTL(("inetNetToMediaTable:inetNetToMediaTable_dirty_set", + "called. was %d, now %d\n", + inetNetToMediaTable_if_ctx.table_dirty, status)); + inetNetToMediaTable_if_ctx.table_dirty = status; +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_pre_request; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_post_request; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_object_lookup; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_get_values; +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_check_objects; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_setup; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_set_values; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_values; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_commit; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_commit; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_irreversible_commit; +static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_check_dependencies; + +NETSNMP_STATIC_INLINE int + _inetNetToMediaTable_undo_column(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, + netsnmp_variable_list * + var, int column); +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + +NETSNMP_STATIC_INLINE int + _inetNetToMediaTable_check_indexes(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx); + +/** + * @internal + * Initialize the table inetNetToMediaTable + * (Define its contents and how it's structured) + */ +void +_inetNetToMediaTable_initialize_interface(inetNetToMediaTable_registration + * reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &inetNetToMediaTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &inetNetToMediaTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for inetNetToMediaTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: inetNetToMediaIfIndex */ + ASN_INTEGER, + /** index: inetNetToMediaNetAddressType */ + ASN_OCTET_STR, + /** index: inetNetToMediaNetAddress */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = INETNETTOMEDIATABLE_MIN_COL; + tbl_info->max_column = INETNETTOMEDIATABLE_MAX_COL; + + /* + * save users context + */ + inetNetToMediaTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + inetNetToMediaTable_init_data(reg_ptr); + + /* + * set up the container + */ + _inetNetToMediaTable_container_init(&inetNetToMediaTable_if_ctx); + if (NULL == inetNetToMediaTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for inetNetToMediaTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_inetNetToMediaTable_object_lookup; + access_multiplexer->get_values = _mfd_inetNetToMediaTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_inetNetToMediaTable_pre_request; + access_multiplexer->post_request = + _mfd_inetNetToMediaTable_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_inetNetToMediaTable_check_objects; + access_multiplexer->undo_setup = _mfd_inetNetToMediaTable_undo_setup; + access_multiplexer->undo_cleanup = + _mfd_inetNetToMediaTable_undo_cleanup; + access_multiplexer->set_values = _mfd_inetNetToMediaTable_set_values; + access_multiplexer->undo_sets = _mfd_inetNetToMediaTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_inetNetToMediaTable_commit; + access_multiplexer->undo_commit = _mfd_inetNetToMediaTable_undo_commit; + access_multiplexer->irreversible_commit = + _mfd_inetNetToMediaTable_irreversible_commit; + + /* + * REQUIRED for tables with dependencies + */ + access_multiplexer->consistency_checks = + _mfd_inetNetToMediaTable_check_dependencies; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("inetNetToMediaTable:init_inetNetToMediaTable", + "Registering inetNetToMediaTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("inetNetToMediaTable", handler, + inetNetToMediaTable_oid, + inetNetToMediaTable_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 inetNetToMediaTable\n"); + return; + } + reginfo->my_reg_void = &inetNetToMediaTable_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, + inetNetToMediaTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != inetNetToMediaTable_if_ctx.cache) { + handler = + netsnmp_cache_handler_get(inetNetToMediaTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _inetNetToMediaTable_initialize_interface */ + +/** + * @internal + * Shutdown the table inetNetToMediaTable + */ +void +_inetNetToMediaTable_shutdown_interface(inetNetToMediaTable_registration * + reg_ptr) +{ + /* + * shutdown the container + */ + _inetNetToMediaTable_container_shutdown(&inetNetToMediaTable_if_ctx); +} + +void +inetNetToMediaTable_valid_columns_set(netsnmp_column_info *vc) +{ + inetNetToMediaTable_if_ctx.tbl_info.valid_columns = vc; +} /* inetNetToMediaTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +inetNetToMediaTable_index_to_oid(netsnmp_index * oid_idx, + inetNetToMediaTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_inetNetToMediaIfIndex; + /* + * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_inetNetToMediaNetAddressType; + /* + * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_inetNetToMediaNetAddress; + + /* + * set up varbinds + */ + memset(&var_inetNetToMediaIfIndex, 0x00, + sizeof(var_inetNetToMediaIfIndex)); + var_inetNetToMediaIfIndex.type = ASN_INTEGER; + memset(&var_inetNetToMediaNetAddressType, 0x00, + sizeof(var_inetNetToMediaNetAddressType)); + var_inetNetToMediaNetAddressType.type = ASN_INTEGER; + memset(&var_inetNetToMediaNetAddress, 0x00, + sizeof(var_inetNetToMediaNetAddress)); + var_inetNetToMediaNetAddress.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_inetNetToMediaIfIndex.next_variable = + &var_inetNetToMediaNetAddressType; + var_inetNetToMediaNetAddressType.next_variable = + &var_inetNetToMediaNetAddress; + var_inetNetToMediaNetAddress.next_variable = NULL; + + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_index_to_oid", "called\n")); + + /* + * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_inetNetToMediaIfIndex, + (u_char *) & mib_idx->inetNetToMediaIfIndex, + sizeof(mib_idx->inetNetToMediaIfIndex)); + + /* + * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_inetNetToMediaNetAddressType, + (u_char *) & mib_idx->inetNetToMediaNetAddressType, + sizeof(mib_idx->inetNetToMediaNetAddressType)); + + /* + * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + snmp_set_var_value(&var_inetNetToMediaNetAddress, + (u_char *) & mib_idx->inetNetToMediaNetAddress, + mib_idx->inetNetToMediaNetAddress_len * + sizeof(mib_idx->inetNetToMediaNetAddress[0])); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_inetNetToMediaIfIndex); + 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_inetNetToMediaIfIndex); + + return err; +} /* inetNetToMediaTable_index_to_oid */ + +/** + * extract inetNetToMediaTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +inetNetToMediaTable_index_from_oid(netsnmp_index * oid_idx, + inetNetToMediaTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_inetNetToMediaIfIndex; + /* + * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_inetNetToMediaNetAddressType; + /* + * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_inetNetToMediaNetAddress; + + /* + * set up varbinds + */ + memset(&var_inetNetToMediaIfIndex, 0x00, + sizeof(var_inetNetToMediaIfIndex)); + var_inetNetToMediaIfIndex.type = ASN_INTEGER; + memset(&var_inetNetToMediaNetAddressType, 0x00, + sizeof(var_inetNetToMediaNetAddressType)); + var_inetNetToMediaNetAddressType.type = ASN_INTEGER; + memset(&var_inetNetToMediaNetAddress, 0x00, + sizeof(var_inetNetToMediaNetAddress)); + var_inetNetToMediaNetAddress.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_inetNetToMediaIfIndex.next_variable = + &var_inetNetToMediaNetAddressType; + var_inetNetToMediaNetAddressType.next_variable = + &var_inetNetToMediaNetAddress; + var_inetNetToMediaNetAddress.next_variable = NULL; + + + DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_index_from_oid", "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_inetNetToMediaIfIndex); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->inetNetToMediaIfIndex = + *((long *) var_inetNetToMediaIfIndex.val.string); + mib_idx->inetNetToMediaNetAddressType = + *((u_long *) var_inetNetToMediaNetAddressType.val.string); + /* + * NOTE: val_len is in bytes, inetNetToMediaNetAddress_len might not be + */ + if (var_inetNetToMediaNetAddress.val_len > + sizeof(mib_idx->inetNetToMediaNetAddress)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->inetNetToMediaNetAddress, + var_inetNetToMediaNetAddress.val.string, + var_inetNetToMediaNetAddress.val_len); + mib_idx->inetNetToMediaNetAddress_len = + var_inetNetToMediaNetAddress.val_len / + sizeof(mib_idx->inetNetToMediaNetAddress[0]); + } + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_inetNetToMediaIfIndex); + + return err; +} /* inetNetToMediaTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a inetNetToMediaTable_rowreq_ctx + */ +inetNetToMediaTable_rowreq_ctx * +inetNetToMediaTable_allocate_rowreq_ctx(inetNetToMediaTable_data * data, + void *user_init_ctx) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(inetNetToMediaTable_rowreq_ctx); + + DEBUGMSGTL(("internal:inetNetToMediaTable:inetNetToMediaTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "inetNetToMediaTable_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 = + inetNetToMediaTable_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->inetNetToMediaTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + inetNetToMediaTable_rowreq_ctx_init(rowreq_ctx, + user_init_ctx)) { + inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* inetNetToMediaTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a inetNetToMediaTable_rowreq_ctx + */ +void +inetNetToMediaTable_release_rowreq_ctx(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("internal:inetNetToMediaTable:inetNetToMediaTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + inetNetToMediaTable_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)) + inetNetToMediaTable_release_data(rowreq_ctx->data); + + if (rowreq_ctx->undo) + inetNetToMediaTable_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); +} /* inetNetToMediaTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_inetNetToMediaTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:inetNetToMediaTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = inetNetToMediaTable_pre_request(inetNetToMediaTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetNetToMediaTable", "error %d from " + "inetNetToMediaTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_inetNetToMediaTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:inetNetToMediaTable", + "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) && inetNetToMediaTable_dirty_get()) { + /* + * we shouldn't get here. the undo steps should also clear + * the dirty flags. + */ + snmp_log(LOG_WARNING, + "inetNetToMediaTable dirty flag set in post_request " + "but status != SUCCESS.\n"); + } + + rc = inetNetToMediaTable_post_request(inetNetToMediaTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetNetToMediaTable", "error %d from " + "inetNetToMediaTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_post_request */ + + +/** + * @internal + * wrapper + */ +static inetNetToMediaTable_rowreq_ctx * +_mfd_inetNetToMediaTable_rowreq_from_index(netsnmp_index * oid_idx, + int *rc_ptr) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx; + inetNetToMediaTable_mib_index mib_idx; + int rc; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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 = inetNetToMediaTable_index_from_oid(oid_idx, &mib_idx); + if (MFD_SUCCESS != *rc_ptr) { + DEBUGMSGT(("inetNetToMediaTable", "error parsing index\n")); + return NULL; + } + + /* + * allocate new context + */ + rowreq_ctx = inetNetToMediaTable_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 = _inetNetToMediaTable_check_indexes(rowreq_ctx); + if (MFD_SUCCESS != *rc_ptr) { + netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) || + (*rc_ptr == SNMP_ERR_INCONSISTENTNAME)); + inetNetToMediaTable_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_inetNetToMediaTable_rowreq_from_index */ + + +/** + * @internal + * wrapper + */ +static int +_mfd_inetNetToMediaTable_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; + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * inetNetToMediaTable_interface_ctx *if_ctx = + * (inetNetToMediaTable_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_inetNetToMediaTable_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 + inetNetToMediaTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_inetNetToMediaTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetNetToMediaTable_get_column(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + case COLUMN_INETNETTOMEDIAPHYSADDRESS: + var->type = ASN_OCTET_STR; + rc = inetNetToMediaPhysAddress_get(rowreq_ctx, + (char **) &var->val.string, + &var->val_len); + break; + + /* + * inetNetToMediaLastUpdated(5)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_INETNETTOMEDIALASTUPDATED: + var->val_len = sizeof(u_long); + var->type = ASN_TIMETICKS; + rc = inetNetToMediaLastUpdated_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_INETNETTOMEDIATYPE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = inetNetToMediaType_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * inetNetToMediaState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_INETNETTOMEDIASTATE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = inetNetToMediaState_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETNETTOMEDIAROWSTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = inetNetToMediaRowStatus_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetNetToMediaTable_get_column\n", + column); + break; + } + + return rc; +} /* _inetNetToMediaTable_get_column */ + +int +_mfd_inetNetToMediaTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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 = _inetNetToMediaTable_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_inetNetToMediaTable_get_values */ + +NETSNMP_STATIC_INLINE int +_inetNetToMediaTable_check_indexes(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_check_indexes", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * (INDEX) inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((rowreq_ctx->tbl_idx.inetNetToMediaIfIndex < 1) + || (rowreq_ctx->tbl_idx.inetNetToMediaIfIndex > 2147483647)) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetNetToMediaIfIndex_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetNetToMediaNetAddressType(2)/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.inetNetToMediaNetAddressType != + INETADDRESSTYPE_UNKNOWN) + && (rowreq_ctx->tbl_idx.inetNetToMediaNetAddressType != + INETADDRESSTYPE_IPV4) + && (rowreq_ctx->tbl_idx.inetNetToMediaNetAddressType != + INETADDRESSTYPE_IPV6) + && (rowreq_ctx->tbl_idx.inetNetToMediaNetAddressType != + INETADDRESSTYPE_IPV4Z) + && (rowreq_ctx->tbl_idx.inetNetToMediaNetAddressType != + INETADDRESSTYPE_IPV6Z) + && (rowreq_ctx->tbl_idx.inetNetToMediaNetAddressType != + INETADDRESSTYPE_DNS) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetNetToMediaNetAddressType_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) inetNetToMediaNetAddress(3)/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.inetNetToMediaNetAddress_len < 0) + || (rowreq_ctx->tbl_idx.inetNetToMediaNetAddress_len > 255)) + ) { + rc = SNMP_ERR_WRONGLENGTH; + } + if (MFD_SUCCESS != rc) + return rc; + rc = inetNetToMediaNetAddress_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * if individual parts look ok, check them as a whole + */ + return inetNetToMediaTable_validate_index(inetNetToMediaTable_if_ctx. + user_ctx, rowreq_ctx); +} /* _inetNetToMediaTable_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 +_inetNetToMediaTable_check_column(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_check_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + /* + * (INDEX) inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + case COLUMN_INETNETTOMEDIAIFINDEX: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + case COLUMN_INETNETTOMEDIANETADDRESSTYPE: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + case COLUMN_INETNETTOMEDIANETADDRESS: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + + /* + * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + case COLUMN_INETNETTOMEDIAPHYSADDRESS: + rc = netsnmp_check_vb_type(var, ASN_OCTET_STR); + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((var->val_len < 0) || (var->val_len > 65535)) + ) { + rc = SNMP_ERR_WRONGLENGTH; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:_inetNetToMediaTable_check_column:inetNetToMediaPhysAddress", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetNetToMediaPhysAddress_check_value(rowreq_ctx, + (char *) 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 inetNetToMediaPhysAddress_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetNetToMediaLastUpdated(5)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_INETNETTOMEDIALASTUPDATED: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_INETNETTOMEDIATYPE: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != INETNETTOMEDIATYPE_OTHER) + && (*var->val.integer != INETNETTOMEDIATYPE_INVALID) + && (*var->val.integer != INETNETTOMEDIATYPE_DYNAMIC) + && (*var->val.integer != INETNETTOMEDIATYPE_STATIC) + && (*var->val.integer != INETNETTOMEDIATYPE_LOCAL) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:_inetNetToMediaTable_check_column:inetNetToMediaType", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetNetToMediaType_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 inetNetToMediaType_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * inetNetToMediaState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_INETNETTOMEDIASTATE: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETNETTOMEDIAROWSTATUS: + rc = netsnmp_check_vb_rowstatus_value(var); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:_inetNetToMediaTable_check_column:inetNetToMediaRowStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = inetNetToMediaRowStatus_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 inetNetToMediaRowStatus_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 _inetNetToMediaTable_check_column\n", + column); + } + + return rc; +} /* _inetNetToMediaTable_check_column */ + +int +_mfd_inetNetToMediaTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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 = _inetNetToMediaTable_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_inetNetToMediaTable_check_objects */ + + +/*---------------------------------------------------------------------- + * + * SET: check dependencies + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check dependencies wrapper + */ +static int +_mfd_inetNetToMediaTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_check_dependencies", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = inetNetToMediaTable_check_dependencies(rowreq_ctx); + if (rc) { + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_check_dependencies\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_check_dependencies */ + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetNetToMediaTable_undo_setup_column(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_undo_setup_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + case COLUMN_INETNETTOMEDIAPHYSADDRESS: + rowreq_ctx->column_set_flags |= + COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG; + rc = inetNetToMediaPhysAddress_undo_setup(rowreq_ctx); + break; + + /* + * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_INETNETTOMEDIATYPE: + rowreq_ctx->column_set_flags |= COLUMN_INETNETTOMEDIATYPE_FLAG; + rc = inetNetToMediaType_undo_setup(rowreq_ctx); + break; + + /* + * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETNETTOMEDIAROWSTATUS: + rowreq_ctx->column_set_flags |= + COLUMN_INETNETTOMEDIAROWSTATUS_FLAG; + rc = inetNetToMediaRowStatus_undo_setup(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetNetToMediaTable_undo_setup_column\n", + column); + break; + } + + return rc; +} /* _inetNetToMediaTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_inetNetToMediaTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_setup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rowreq_ctx->undo = inetNetToMediaTable_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 = inetNetToMediaTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_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 = _inetNetToMediaTable_undo_setup_column(rowreq_ctx, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_undo_setup_column\n", + rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_inetNetToMediaTable_undo_cleanup(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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 = inetNetToMediaTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + if (rowreq_ctx->undo) { + inetNetToMediaTable_release_data(rowreq_ctx->undo); + rowreq_ctx->undo = NULL; + } + + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetNetToMediaTable_set_column(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_set_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + case COLUMN_INETNETTOMEDIAPHYSADDRESS: + rowreq_ctx->column_set_flags |= + COLUMN_INETNETTOMEDIAPHYSADDRESS_FLAG; + rc = inetNetToMediaPhysAddress_set(rowreq_ctx, + (char *) var->val.string, + var->val_len); + break; + + /* + * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_INETNETTOMEDIATYPE: + rowreq_ctx->column_set_flags |= COLUMN_INETNETTOMEDIATYPE_FLAG; + rc = inetNetToMediaType_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETNETTOMEDIAROWSTATUS: + rowreq_ctx->column_set_flags |= + COLUMN_INETNETTOMEDIAROWSTATUS_FLAG; + rc = inetNetToMediaRowStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetNetToMediaTable_set_column\n", + column); + rc = SNMP_ERR_GENERR; + break; + } + + return rc; +} /* _inetNetToMediaTable_set_column */ + +int +_mfd_inetNetToMediaTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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 = _inetNetToMediaTable_set_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_inetNetToMediaTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = inetNetToMediaTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_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... + */ + inetNetToMediaTable_dirty_set(inetNetToMediaTable_dirty_get() + 1); /* set table dirty flag */ + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_inetNetToMediaTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + u_int d = inetNetToMediaTable_dirty_get(); + + netsnmp_assert(d != 0); + if (d) + inetNetToMediaTable_dirty_set(d - 1); + } + + rc = inetNetToMediaTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_undo_commit\n", rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + snmp_log(LOG_WARNING, + "inetNetToMediaTable row dirty flag still set after undo_commit\n"); + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +/** + * @internal + * undo the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_inetNetToMediaTable_undo_column(inetNetToMediaTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_undo_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + case COLUMN_INETNETTOMEDIAPHYSADDRESS: + rc = inetNetToMediaPhysAddress_undo(rowreq_ctx); + break; + + /* + * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_INETNETTOMEDIATYPE: + rc = inetNetToMediaType_undo(rowreq_ctx); + break; + + /* + * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_INETNETTOMEDIAROWSTATUS: + rc = inetNetToMediaRowStatus_undo(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _inetNetToMediaTable_undo_column\n", + column); + break; + } + + return rc; +} /* _inetNetToMediaTable_undo_column */ + +int +_mfd_inetNetToMediaTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = inetNetToMediaTable_undo(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_undo\n", rc)); + } + + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _inetNetToMediaTable_undo_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from " + "inetNetToMediaTable_undo_column\n", rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_undo_values */ + +/*---------------------------------------------------------------------- + * + * SET: irreversible commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit irreversible actions + */ +int +_mfd_inetNetToMediaTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, netsnmp_request_info + *requests) +{ + inetNetToMediaTable_rowreq_ctx *rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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(inetNetToMediaTable_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(inetNetToMediaTable_if_ctx.container, + rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_inetNetToMediaTable_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) +{ + DEBUGTRACE; + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for inetNetToMediaTable_cache_load\n"); + return -1; + } + DEBUGMSGTL(("inetNetToMediaTable/cache", "inetNetToMedia_load %p/%p\n", + cache, cache->magic)); + + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return inetNetToMediaTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:inetNetToMediaTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in inetNetToMediaTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:inetNetToMediaTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:inetNetToMediaTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in inetNetToMediaTable_container_free\n"); + return; + } + + /* + * call user code + */ + inetNetToMediaTable_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 +_inetNetToMediaTable_container_init(inetNetToMediaTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_container_init", "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + inetNetToMediaTable_oid, + inetNetToMediaTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, + "error creating cache for inetNetToMediaTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + inetNetToMediaTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("inetNetToMediaTable:table_container"); + if (if_ctx->container) + if_ctx->container->container_name = strdup("inetNetToMediaTable"); + } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "inetNetToMediaTable_container_init\n"); + return; + } + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _inetNetToMediaTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_inetNetToMediaTable_container_shutdown(inetNetToMediaTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_container_shutdown", "called\n")); + + inetNetToMediaTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _inetNetToMediaTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_EXTERNAL_ACCESS +inetNetToMediaTable_rowreq_ctx * +inetNetToMediaTable_row_find_by_mib_index(inetNetToMediaTable_mib_index * + mib_idx) +{ + inetNetToMediaTable_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 = inetNetToMediaTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (inetNetToMediaTable_rowreq_ctx*) + CONTAINER_FIND(inetNetToMediaTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_INETNETTOMEDIATABLE_EXTERNAL_ACCESS */ diff --git a/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.h b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.h new file mode 100644 index 0000000..8cbb36f --- /dev/null +++ b/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.h @@ -0,0 +1,103 @@ +/* + * 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 INETNETTOMEDIATABLE_INTERFACE_H +#define INETNETTOMEDIATABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "inetNetToMediaTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _inetNetToMediaTable_initialize_interface + (inetNetToMediaTable_registration * user_ctx, u_long flags); + void + _inetNetToMediaTable_shutdown_interface + (inetNetToMediaTable_registration * user_ctx); + + inetNetToMediaTable_registration + * inetNetToMediaTable_registration_get(void); + + inetNetToMediaTable_registration + * inetNetToMediaTable_registration_set + (inetNetToMediaTable_registration * newreg); + + netsnmp_container *inetNetToMediaTable_container_get(void); + int inetNetToMediaTable_container_size(void); + + u_int inetNetToMediaTable_dirty_get(void); + void inetNetToMediaTable_dirty_set(u_int status); + + inetNetToMediaTable_rowreq_ctx + * inetNetToMediaTable_allocate_rowreq_ctx(inetNetToMediaTable_data + *, void *); + void + inetNetToMediaTable_release_rowreq_ctx + (inetNetToMediaTable_rowreq_ctx * rowreq_ctx); + + int inetNetToMediaTable_index_to_oid(netsnmp_index * + oid_idx, + inetNetToMediaTable_mib_index + * mib_idx); + int inetNetToMediaTable_index_from_oid(netsnmp_index * + oid_idx, + inetNetToMediaTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + inetNetToMediaTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* INETNETTOMEDIATABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable.h b/agent/mibgroup/ip-mib/ipAddressPrefixTable.h new file mode 100644 index 0000000..abfa100 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/ipAddressPrefixTable/ipAddressPrefixTable) diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.c b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.c new file mode 100644 index 0000000..f4bb085 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.c @@ -0,0 +1,675 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for ipAddressPrefixTable + * + * \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 "ipAddressPrefixTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipAddressPrefixTable_interface.h" + +const oid ipAddressPrefixTable_oid[] = { IPADDRESSPREFIXTABLE_OID }; +const int ipAddressPrefixTable_oid_size = +OID_LENGTH(ipAddressPrefixTable_oid); + +ipAddressPrefixTable_registration ipAddressPrefixTable_user_context; +static ipAddressPrefixTable_registration *ipAddressPrefixTable_user_context_p; + +void initialize_table_ipAddressPrefixTable(void); +void shutdown_table_ipAddressPrefixTable(void); + + +/** + * Initializes the ipAddressPrefixTable module + */ +void +init_ipAddressPrefixTable(void) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:init_ipAddressPrefixTable", + "called\n")); + + /* + * TODO:300:o: Perform ipAddressPrefixTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipAddressPrefixTable")) + initialize_table_ipAddressPrefixTable(); + +} /* init_ipAddressPrefixTable */ + +/** + * Shut-down the ipAddressPrefixTable module (agent is exiting) + */ +void +shutdown_ipAddressPrefixTable(void) +{ + if (should_init("ipAddressPrefixTable")) + shutdown_table_ipAddressPrefixTable(); + +} + +/** + * Initialize the table ipAddressPrefixTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipAddressPrefixTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:initialize_table_ipAddressPrefixTable", "called\n")); + + /* + * TODO:301:o: Perform ipAddressPrefixTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipAddressPrefixTable 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. + */ + ipAddressPrefixTable_user_context_p + = netsnmp_create_data_list("ipAddressPrefixTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipAddressPrefixTable_initialize_interface + (ipAddressPrefixTable_user_context_p, flags); +} /* initialize_table_ipAddressPrefixTable */ + +/** + * Shutdown the table ipAddressPrefixTable + */ +void +shutdown_table_ipAddressPrefixTable(void) +{ + /* + * call interface shutdown code + */ + _ipAddressPrefixTable_shutdown_interface + (ipAddressPrefixTable_user_context_p); + netsnmp_free_all_list_data(ipAddressPrefixTable_user_context_p); + ipAddressPrefixTable_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 +ipAddressPrefixTable_rowreq_ctx_init(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipAddressPrefixTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipAddressPrefixTable_rowreq_ctx_cleanup(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipAddressPrefixTable rowreq cleanup. + */ +} /* ipAddressPrefixTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipAddressPrefixTable_pre_request(ipAddressPrefixTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform ipAddressPrefixTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_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 +ipAddressPrefixTable_post_request(ipAddressPrefixTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform ipAddressPrefixTable post-request actions. + */ + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressPrefixTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressPrefixTable is subid 32 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.32, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipAddressPrefixTable data context functions. + */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipAddressPrefixIfIndex_val + * @param ipAddressPrefixType_val + * @param ipAddressPrefixPrefix_val_ptr + * @param ipAddressPrefixPrefix_val_ptr_len + * @param ipAddressPrefixLength_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 +ipAddressPrefixTable_indexes_set_tbl_idx(ipAddressPrefixTable_mib_index * + tbl_idx, + long ipAddressPrefixIfIndex_val, + u_long ipAddressPrefixType_val, + u_char + *ipAddressPrefixPrefix_val_ptr, + size_t + ipAddressPrefixPrefix_val_ptr_len, + u_long ipAddressPrefixLength_val) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipAddressPrefixIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + tbl_idx->ipAddressPrefixIfIndex = ipAddressPrefixIfIndex_val; + + /* + * ipAddressPrefixType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + tbl_idx->ipAddressPrefixType = ipAddressPrefixType_val; + + /* + * ipAddressPrefixPrefix(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + tbl_idx->ipAddressPrefixPrefix_len = sizeof(tbl_idx->ipAddressPrefixPrefix) / sizeof(tbl_idx->ipAddressPrefixPrefix[0]); /* max length */ + /* + * make sure there is enough space for ipAddressPrefixPrefix data + */ + if ((NULL == tbl_idx->ipAddressPrefixPrefix) || + (tbl_idx->ipAddressPrefixPrefix_len < + (ipAddressPrefixPrefix_val_ptr_len))) { + snmp_log(LOG_ERR, "not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->ipAddressPrefixPrefix_len = ipAddressPrefixPrefix_val_ptr_len; + memcpy(tbl_idx->ipAddressPrefixPrefix, ipAddressPrefixPrefix_val_ptr, + ipAddressPrefixPrefix_val_ptr_len * + sizeof(ipAddressPrefixPrefix_val_ptr[0])); + + /* + * ipAddressPrefixLength(4)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + tbl_idx->ipAddressPrefixLength = ipAddressPrefixLength_val; + + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_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 +ipAddressPrefixTable_indexes_set(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + long ipAddressPrefixIfIndex_val, + u_long ipAddressPrefixType_val, + u_char *ipAddressPrefixPrefix_val_ptr, + size_t ipAddressPrefixPrefix_val_ptr_len, + u_long ipAddressPrefixLength_val) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_indexes_set", "called\n")); + + if (MFD_SUCCESS != + ipAddressPrefixTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipAddressPrefixIfIndex_val, + ipAddressPrefixType_val, + ipAddressPrefixPrefix_val_ptr, + ipAddressPrefixPrefix_val_ptr_len, + ipAddressPrefixLength_val)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != ipAddressPrefixTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressPrefixEntry.ipAddressPrefixOrigin + * ipAddressPrefixOrigin is subid 5 of ipAddressPrefixEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.32.1.5 + * Description: +The origin of this prefix. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 4/8. Values: other(1), manual(2), wellknown(3), dhcp(4), routeradv(5) + * + * Its syntax is IpAddressPrefixOriginTC (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 ipAddressPrefixOrigin data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressPrefixOrigin_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 +ipAddressPrefixOrigin_get(ipAddressPrefixTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressPrefixOrigin_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressPrefixOrigin_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixOrigin_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressPrefixOrigin data. + * copy (* ipAddressPrefixOrigin_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressPrefixOrigin_val_ptr) = rowreq_ctx->data.ipAddressPrefixOrigin; + + return MFD_SUCCESS; +} /* ipAddressPrefixOrigin_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressPrefixEntry.ipAddressPrefixOnLinkFlag + * ipAddressPrefixOnLinkFlag is subid 6 of ipAddressPrefixEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.32.1.6 + * Description: +This object has the value 'true(1)', if this prefix can be + used for on-link determination and the value 'false(2)' + otherwise. + + + The default for IPv4 prefixes is 'true(1)'. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (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 ipAddressPrefixOnLinkFlag data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressPrefixOnLinkFlag_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 +ipAddressPrefixOnLinkFlag_get(ipAddressPrefixTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressPrefixOnLinkFlag_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressPrefixOnLinkFlag_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixOnLinkFlag_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressPrefixOnLinkFlag data. + * copy (* ipAddressPrefixOnLinkFlag_val_ptr ) from rowreq_ctx->data + */ + if (INETADDRESSTYPE_IPV4 == rowreq_ctx->tbl_idx.ipAddressPrefixType) { + (*ipAddressPrefixOnLinkFlag_val_ptr) = 1; /* per MIB */ + } else + (*ipAddressPrefixOnLinkFlag_val_ptr) = + rowreq_ctx->data.ipAddressPrefixOnLinkFlag; + + return MFD_SUCCESS; +} /* ipAddressPrefixOnLinkFlag_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressPrefixEntry.ipAddressPrefixAutonomousFlag + * ipAddressPrefixAutonomousFlag is subid 7 of ipAddressPrefixEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.32.1.7 + * Description: +Autonomous address configuration flag. When true(1), + indicates that this prefix can be used for autonomous + address configuration (i.e. can be used to form a local + interface address). If false(2), it is not used to auto- + configure a local interface address. + + + The default for IPv4 prefixes is 'false(2)'. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (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 ipAddressPrefixAutonomousFlag data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressPrefixAutonomousFlag_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 +ipAddressPrefixAutonomousFlag_get(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressPrefixAutonomousFlag_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressPrefixAutonomousFlag_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixAutonomousFlag_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressPrefixAutonomousFlag data. + * copy (* ipAddressPrefixAutonomousFlag_val_ptr ) from rowreq_ctx->data + */ + if (INETADDRESSTYPE_IPV4 == rowreq_ctx->tbl_idx.ipAddressPrefixType) + (*ipAddressPrefixAutonomousFlag_val_ptr) = 2; /* per MIB */ + else + (*ipAddressPrefixAutonomousFlag_val_ptr) = + rowreq_ctx->data.ipAddressPrefixAutonomousFlag; + + return MFD_SUCCESS; +} /* ipAddressPrefixAutonomousFlag_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressPrefixEntry.ipAddressPrefixAdvPreferredLifetime + * ipAddressPrefixAdvPreferredLifetime is subid 8 of ipAddressPrefixEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.32.1.8 + * Description: +The remaining length of time in seconds that this prefix + will continue to be preferred, i.e. time until deprecation. + + + + + A value of 4,294,967,295 represents infinity. + + + The address generated from a deprecated prefix should no + longer be used as a source address in new communications, + but packets received on such an interface are processed as + expected. + + + The default for IPv4 prefixes is 4,294,967,295 (infinity). + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is UNSIGNED32 (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 ipAddressPrefixAdvPreferredLifetime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressPrefixAdvPreferredLifetime_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 +ipAddressPrefixAdvPreferredLifetime_get(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressPrefixAdvPreferredLifetime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressPrefixAdvPreferredLifetime_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixAdvPreferredLifetime_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressPrefixAdvPreferredLifetime data. + * copy (* ipAddressPrefixAdvPreferredLifetime_val_ptr ) from rowreq_ctx->data + */ + if (INETADDRESSTYPE_IPV4 == rowreq_ctx->tbl_idx.ipAddressPrefixType) + (*ipAddressPrefixAdvPreferredLifetime_val_ptr) = 4294967295U; /* per MIB */ + else + (*ipAddressPrefixAdvPreferredLifetime_val_ptr) = + rowreq_ctx->data.ipAddressPrefixAdvPreferredLifetime; + + return MFD_SUCCESS; +} /* ipAddressPrefixAdvPreferredLifetime_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressPrefixEntry.ipAddressPrefixAdvValidLifetime + * ipAddressPrefixAdvValidLifetime is subid 9 of ipAddressPrefixEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.32.1.9 + * Description: +The remaining length of time, in seconds, that this prefix + will continue to be valid, i.e. time until invalidation. A + value of 4,294,967,295 represents infinity. + + + The address generated from an invalidated prefix should not + appear as the destination or source address of a packet. + + + The default for IPv4 prefixes is 4,294,967,295 (infinity). + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is UNSIGNED32 (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 ipAddressPrefixAdvValidLifetime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressPrefixAdvValidLifetime_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 +ipAddressPrefixAdvValidLifetime_get(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressPrefixAdvValidLifetime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressPrefixAdvValidLifetime_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixAdvValidLifetime_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressPrefixAdvValidLifetime data. + * copy (* ipAddressPrefixAdvValidLifetime_val_ptr ) from rowreq_ctx->data + */ + if (INETADDRESSTYPE_IPV4 == rowreq_ctx->tbl_idx.ipAddressPrefixType) + (*ipAddressPrefixAdvValidLifetime_val_ptr) = 4294967295U; /* per MIB */ + else + (*ipAddressPrefixAdvValidLifetime_val_ptr) = + rowreq_ctx->data.ipAddressPrefixAdvValidLifetime; + + return MFD_SUCCESS; +} /* ipAddressPrefixAdvValidLifetime_get */ + + + +/** @} */ +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.h b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.h new file mode 100644 index 0000000..24b22a2 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable.h @@ -0,0 +1,316 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef IPADDRESSPREFIXTABLE_H +#define IPADDRESSPREFIXTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-mib/ipAddressTable/ipAddressTable) +config_require(ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface) +config_require(ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for ipAddressPrefixTable + */ +#include "ipAddressPrefixTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipAddressPrefixTable(void); + void shutdown_ipAddressPrefixTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressPrefixTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressPrefixTable is subid 32 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.32, length: 8 + */ + /* + ********************************************************************* + * 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 ipAddressPrefixTable registration context. + */ + typedef netsnmp_data_list ipAddressPrefixTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipAddressPrefixTable data context structure. + * This structure is used to represent the data for ipAddressPrefixTable. + */ + /* + * This structure contains storage for all the columns defined in the + * ipAddressPrefixTable. + */ + typedef struct ipAddressPrefixTable_data_s { + + /* + * ipAddressPrefixOrigin(5)/IpAddressPrefixOriginTC/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long ipAddressPrefixOrigin; + + /* + * ipAddressPrefixOnLinkFlag(6)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long ipAddressPrefixOnLinkFlag; + + /* + * ipAddressPrefixAutonomousFlag(7)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long ipAddressPrefixAutonomousFlag; + + /* + * ipAddressPrefixAdvPreferredLifetime(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long ipAddressPrefixAdvPreferredLifetime; + + /* + * ipAddressPrefixAdvValidLifetime(9)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long ipAddressPrefixAdvValidLifetime; + + } ipAddressPrefixTable_data; + + + /* + * TODO:120:r: |-> Review ipAddressPrefixTable mib index. + * This structure is used to represent the index for ipAddressPrefixTable. + */ + typedef struct ipAddressPrefixTable_mib_index_s { + + /* + * ipAddressPrefixIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + long ipAddressPrefixIfIndex; + + /* + * ipAddressPrefixType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long ipAddressPrefixType; + + /* + * ipAddressPrefixPrefix(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + /** 128 - 3(other indexes) - oid length(10) = 114 */ + char ipAddressPrefixPrefix[114]; + size_t ipAddressPrefixPrefix_len; + + /* + * ipAddressPrefixLength(4)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + u_long ipAddressPrefixLength; + + + } ipAddressPrefixTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipAddressPrefixTable 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! + * Guessing 128 - col/entry(2) - oid len(8) + */ +#define MAX_ipAddressPrefixTable_IDX_LEN 118 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipAddressPrefixTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipAddressPrefixTable_rowreq_ctx pointer. + */ + typedef struct ipAddressPrefixTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipAddressPrefixTable_IDX_LEN]; + + ipAddressPrefixTable_mib_index tbl_idx; + + ipAddressPrefixTable_data data; + + /* + * 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 ipAddressPrefixTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *ipAddressPrefixTable_data_list; + + } ipAddressPrefixTable_rowreq_ctx; + + typedef struct ipAddressPrefixTable_ref_rowreq_ctx_s { + ipAddressPrefixTable_rowreq_ctx *rowreq_ctx; + } ipAddressPrefixTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + ipAddressPrefixTable_pre_request(ipAddressPrefixTable_registration + * user_context); + int + ipAddressPrefixTable_post_request(ipAddressPrefixTable_registration + * user_context, int rc); + + int + ipAddressPrefixTable_rowreq_ctx_init + (ipAddressPrefixTable_rowreq_ctx * rowreq_ctx, + void *user_init_ctx); + void + ipAddressPrefixTable_rowreq_ctx_cleanup + (ipAddressPrefixTable_rowreq_ctx * rowreq_ctx); + + + ipAddressPrefixTable_rowreq_ctx + * ipAddressPrefixTable_row_find_by_mib_index + (ipAddressPrefixTable_mib_index * mib_idx); + + extern const oid ipAddressPrefixTable_oid[]; + extern const int ipAddressPrefixTable_oid_size; + + +#include "ipAddressPrefixTable_interface.h" +#include "ipAddressPrefixTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressPrefixTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressPrefixTable is subid 32 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.32, length: 8 + */ + /* + * indexes + */ + + int + ipAddressPrefixOrigin_get(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + u_long * ipAddressPrefixOrigin_val_ptr); + int + ipAddressPrefixOnLinkFlag_get(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressPrefixOnLinkFlag_val_ptr); + int + ipAddressPrefixAutonomousFlag_get(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressPrefixAutonomousFlag_val_ptr); + int + ipAddressPrefixAdvPreferredLifetime_get + (ipAddressPrefixTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressPrefixAdvPreferredLifetime_val_ptr); + int + ipAddressPrefixAdvValidLifetime_get(ipAddressPrefixTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipAddressPrefixAdvValidLifetime_val_ptr); + + + int + ipAddressPrefixTable_indexes_set_tbl_idx + (ipAddressPrefixTable_mib_index * tbl_idx, + long ipAddressPrefixIfIndex_val, u_long ipAddressPrefixType_val, + u_char *ipAddressPrefixPrefix_val_ptr, + size_t ipAddressPrefixPrefix_val_ptr_len, + u_long ipAddressPrefixLength_val); + int + ipAddressPrefixTable_indexes_set(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, + long ipAddressPrefixIfIndex_val, + u_long ipAddressPrefixType_val, + u_char + *ipAddressPrefixPrefix_val_ptr, + size_t + ipAddressPrefixPrefix_val_ptr_len, + u_long ipAddressPrefixLength_val); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ + + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSPREFIXTABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_constants.h b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_constants.h new file mode 100644 index 0000000..5ecade4 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_constants.h @@ -0,0 +1,153 @@ +/* + * 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 IPADDRESSPREFIXTABLE_CONSTANTS_H +#define IPADDRESSPREFIXTABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipAddressPrefixTable + */ +#define IPADDRESSPREFIXTABLE_OID 1,3,6,1,2,1,4,32 + +#define COLUMN_IPADDRESSPREFIXIFINDEX 1 + +#define COLUMN_IPADDRESSPREFIXTYPE 2 + +#define COLUMN_IPADDRESSPREFIXPREFIX 3 + +#define COLUMN_IPADDRESSPREFIXLENGTH 4 + +#define COLUMN_IPADDRESSPREFIXORIGIN 5 + +#define COLUMN_IPADDRESSPREFIXONLINKFLAG 6 + +#define COLUMN_IPADDRESSPREFIXAUTONOMOUSFLAG 7 + +#define COLUMN_IPADDRESSPREFIXADVPREFERREDLIFETIME 8 + +#define COLUMN_IPADDRESSPREFIXADVVALIDLIFETIME 9 + + +#define IPADDRESSPREFIXTABLE_MIN_COL COLUMN_IPADDRESSPREFIXORIGIN +#define IPADDRESSPREFIXTABLE_MAX_COL COLUMN_IPADDRESSPREFIXADVVALIDLIFETIME + + + /* + * 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 ipAddressPrefixTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipAddressPrefixType (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 + * ipAddressPrefixOrigin (IpAddressPrefixOriginTC / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPADDRESSPREFIXORIGINTC_ENUMS +#define IPADDRESSPREFIXORIGINTC_ENUMS + +#define IPADDRESSPREFIXORIGINTC_OTHER 1 +#define IPADDRESSPREFIXORIGINTC_MANUAL 2 +#define IPADDRESSPREFIXORIGINTC_WELLKNOWN 3 +#define IPADDRESSPREFIXORIGINTC_DHCP 4 +#define IPADDRESSPREFIXORIGINTC_ROUTERADV 5 + +#endif /* IPADDRESSPREFIXORIGINTC_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressPrefixOnLinkFlag (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + +#endif /* TRUTHVALUE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressPrefixAutonomousFlag (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + +#endif /* TRUTHVALUE_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSPREFIXTABLE_OIDS_H */ +/**************************************************************** +* Additional constants and definitions for common implementation +*/ +#define INFINITY_LIFE_TIME 0xFFFFFFFFU +#define NIP6(addr) \ + ntohs((addr).s6_addr16[0]), \ + ntohs((addr).s6_addr16[1]), \ + ntohs((addr).s6_addr16[2]), \ + ntohs((addr).s6_addr16[3]), \ + ntohs((addr).s6_addr16[4]), \ + ntohs((addr).s6_addr16[5]), \ + ntohs((addr).s6_addr16[6]), \ + ntohs((addr).s6_addr16[7]) + diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.c b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.c new file mode 100644 index 0000000..4437829 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.c @@ -0,0 +1,383 @@ +/* + * 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-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "ipAddressPrefixTable.h" + + +#include "ipAddressPrefixTable_data_access.h" + +#include "ip-mib/ipAddressTable/ipAddressTable.h" + +netsnmp_feature_require(ipAddressTable_container_get) +netsnmp_feature_require(ipaddress_common_copy_utilities) +netsnmp_feature_require(ipaddress_prefix_copy) + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressPrefixTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressPrefixTable is subid 32 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.32, length: 8 + */ + +/** + * initialization for ipAddressPrefixTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipAddressPrefixTable_reg + * Pointer to ipAddressPrefixTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipAddressPrefixTable_init_data(ipAddressPrefixTable_registration * + ipAddressPrefixTable_reg) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_init_data", "called\n")); + + /* + * TODO:303:o: Initialize ipAddressPrefixTable data. + */ + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_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 +ipAddressPrefixTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipAddressPrefixTable_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 ipAddressPrefixTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipAddressPrefixTable 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 = IPADDRESSPREFIXTABLE_CACHE_TIMEOUT; /* seconds */ +} /* ipAddressPrefixTable_container_init */ + +/** + * 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 ipAddressPrefixTable_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 +ipAddressPrefixTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipAddressPrefixTable_container_shutdown\n"); + return; + } + +} /* ipAddressPrefixTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement ipAddressPrefixTable 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 + * ipAddressPrefixTable_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 +ipAddressPrefixTable_container_load(netsnmp_container *container) +{ + ipAddressPrefixTable_rowreq_ctx *rowreq_ctx = NULL, *tmp_rowreq_ctx; + ipAddressTable_rowreq_ctx *addr_rowreq_ctx; + netsnmp_container *addr_container; + netsnmp_iterator *addr_it; + int count = 0; + u_char tmp_pfx[NETSNMP_ACCESS_IPADDRESS_BUF_SIZE]; + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_container_load", "called\n")); + + addr_container = ipAddressTable_container_get(); + if (NULL == addr_container) { + DEBUGMSGTL(("ipAddressPrefixTable:container_load", + "couldn't get ipAddress container\n")); + return MFD_RESOURCE_UNAVAILABLE; + } + + addr_it = CONTAINER_ITERATOR(addr_container); + if (NULL == addr_container) { + DEBUGMSGTL(("ipAddressPrefixTable:container_load", + "couldn't get ipAddress iterator\n")); + return MFD_RESOURCE_UNAVAILABLE; + } + + /* + * TODO:351:M: |-> Load/update data in the ipAddressPrefixTable container. + * loop over your ipAddressPrefixTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (addr_rowreq_ctx = ITERATOR_FIRST(addr_it); + addr_rowreq_ctx; addr_rowreq_ctx = ITERATOR_NEXT(addr_it)) { + + + + /* + * TODO:352:M: | |-> set indexes in new ipAddressPrefixTable rowreq context. + * data context will be set from the param (unless NULL, + * in which case a new data context will be allocated) + */ + if (NULL == rowreq_ctx) { + rowreq_ctx = ipAddressPrefixTable_allocate_rowreq_ctx(NULL); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + } + netsnmp_ipaddress_prefix_copy(tmp_pfx, + addr_rowreq_ctx->tbl_idx. + ipAddressAddr, + addr_rowreq_ctx->data-> + ia_address_len, + addr_rowreq_ctx->data-> + ia_prefix_len); + netsnmp_ipaddress_flags_copy(&rowreq_ctx->data. + ipAddressPrefixAdvPreferredLifetime, + &rowreq_ctx->data. + ipAddressPrefixAdvValidLifetime, + &rowreq_ctx->data. + ipAddressPrefixOnLinkFlag, + &rowreq_ctx->data. + ipAddressPrefixAutonomousFlag, + &addr_rowreq_ctx->data-> + ia_prefered_lifetime, + &addr_rowreq_ctx->data-> + ia_valid_lifetime, + &addr_rowreq_ctx->data-> + ia_onlink_flag, + &addr_rowreq_ctx->data-> + ia_autonomous_flag); + + if (MFD_SUCCESS != + ipAddressPrefixTable_indexes_set(rowreq_ctx, + addr_rowreq_ctx->data-> + if_index, + addr_rowreq_ctx->tbl_idx. + ipAddressAddrType, tmp_pfx, + addr_rowreq_ctx->data-> + ia_address_len, + addr_rowreq_ctx->data-> + ia_prefix_len)) { + snmp_log(LOG_ERR, + "error setting index while loading " + "ipAddressPrefixTable data.\n"); + ipAddressPrefixTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + continue; + } + + /** do we already have this prefix? */ + tmp_rowreq_ctx = CONTAINER_FIND(container, rowreq_ctx); + if (NULL != tmp_rowreq_ctx) + continue; + + /* + * TODO:352:r: | |-> populate ipAddressPrefixTable data context. + * Populate data context here. (optionally, delay until row prep) + */ + netsnmp_ipaddress_prefix_origin_copy(&rowreq_ctx->data. + ipAddressPrefixOrigin, + addr_rowreq_ctx->data-> + ia_origin, + addr_rowreq_ctx->data-> + flags, + addr_rowreq_ctx->tbl_idx. + ipAddressAddrType); + + /** defer the rest til row prep */ + + /* + * insert into table container, clear ptr so we reallocate + */ + CONTAINER_INSERT(container, rowreq_ctx); + rowreq_ctx = NULL; + ++count; + } + ITERATOR_RELEASE(addr_it); + + DEBUGMSGT(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_container_load", "inserted %d records\n", count)); + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_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 +ipAddressPrefixTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_container_free", "called\n")); + + /* + * TODO:380:M: Free ipAddressPrefixTable container data. + */ +} /* ipAddressPrefixTable_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 +ipAddressPrefixTable_row_prep(ipAddressPrefixTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_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 (INETADDRESSTYPE_IPV6 == rowreq_ctx->tbl_idx.ipAddressPrefixType) { + + } + + return MFD_SUCCESS; +} /* ipAddressPrefixTable_row_prep */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.h b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.h new file mode 100644 index 0000000..e50d7d0 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_data_access.h @@ -0,0 +1,76 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef IPADDRESSPREFIXTABLE_DATA_ACCESS_H +#define IPADDRESSPREFIXTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressPrefixTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressPrefixTable is subid 32 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.32, length: 8 + */ + + + int + ipAddressPrefixTable_init_data(ipAddressPrefixTable_registration * + ipAddressPrefixTable_reg); + + + /* + * TODO:180:o: Review ipAddressPrefixTable cache timeout. + * The number of seconds before the cache times out + */ +#define IPADDRESSPREFIXTABLE_CACHE_TIMEOUT 60 + + void ipAddressPrefixTable_container_init(netsnmp_container + **container_ptr_ptr, + netsnmp_cache * + cache); + void + ipAddressPrefixTable_container_shutdown(netsnmp_container + *container_ptr); + + int ipAddressPrefixTable_container_load(netsnmp_container + *container); + void ipAddressPrefixTable_container_free(netsnmp_container + *container); + + int ipAddressPrefixTable_cache_load(netsnmp_container + *container); + void ipAddressPrefixTable_cache_free(netsnmp_container + *container); + + int + ipAddressPrefixTable_row_prep(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx); + + + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSPREFIXTABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.c b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.c new file mode 100644 index 0000000..e14a337 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.c @@ -0,0 +1,1065 @@ +/* + * 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 "ipAddressPrefixTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipAddressPrefixTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(check_all_requests_error) + +netsnmp_feature_child_of(ipaddressprefixtable_row_find_by_mib_index, ipaddressprefixtable_all) +netsnmp_feature_child_of(ipaddressprefixtable_container_get, ipaddressprefixtable_all) +netsnmp_feature_child_of(ipAddressPrefixTable_registration_get, ipaddressprefixtable_all) +netsnmp_feature_child_of(ipAddressPrefixTable_registration_set, ipaddressprefixtable_all) +netsnmp_feature_child_of(ipAddressPrefixTable_container_size, ipaddressprefixtable_all) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressPrefixTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressPrefixTable is subid 32 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.32, length: 8 + */ +typedef struct ipAddressPrefixTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + ipAddressPrefixTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} ipAddressPrefixTable_interface_ctx; + +static ipAddressPrefixTable_interface_ctx ipAddressPrefixTable_if_ctx; + +static void + _ipAddressPrefixTable_container_init(ipAddressPrefixTable_interface_ctx * + if_ctx); +static void + _ipAddressPrefixTable_container_shutdown(ipAddressPrefixTable_interface_ctx + * if_ctx); + + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_CONTAINER_GET +netsnmp_container * +ipAddressPrefixTable_container_get(void) +{ + return ipAddressPrefixTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_REGISTRATION_GET +ipAddressPrefixTable_registration * +ipAddressPrefixTable_registration_get(void) +{ + return ipAddressPrefixTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_REGISTRATION_SET +ipAddressPrefixTable_registration * +ipAddressPrefixTable_registration_set(ipAddressPrefixTable_registration * + newreg) +{ + ipAddressPrefixTable_registration *old = + ipAddressPrefixTable_if_ctx.user_ctx; + ipAddressPrefixTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_CONTAINER_SIZE +int +ipAddressPrefixTable_container_size(void) +{ + return CONTAINER_SIZE(ipAddressPrefixTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_CONTAINER_SIZE */ + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipAddressPrefixTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipAddressPrefixTable_post_request; +static Netsnmp_Node_Handler _mfd_ipAddressPrefixTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipAddressPrefixTable_get_values; +/** + * @internal + * Initialize the table ipAddressPrefixTable + * (Define its contents and how it's structured) + */ +void + _ipAddressPrefixTable_initialize_interface + (ipAddressPrefixTable_registration * reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipAddressPrefixTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipAddressPrefixTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_ipAddressPrefixTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipAddressPrefixTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipAddressPrefixIfIndex */ + ASN_INTEGER, + /** index: ipAddressPrefixType */ + ASN_OCTET_STR, + /** index: ipAddressPrefixPrefix */ + ASN_UNSIGNED, + /** index: ipAddressPrefixLength */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPADDRESSPREFIXTABLE_MIN_COL; + tbl_info->max_column = IPADDRESSPREFIXTABLE_MAX_COL; + + /* + * save users context + */ + ipAddressPrefixTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipAddressPrefixTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipAddressPrefixTable_container_init(&ipAddressPrefixTable_if_ctx); + if (NULL == ipAddressPrefixTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipAddressPrefixTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipAddressPrefixTable_object_lookup; + access_multiplexer->get_values = _mfd_ipAddressPrefixTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = + _mfd_ipAddressPrefixTable_pre_request; + access_multiplexer->post_request = + _mfd_ipAddressPrefixTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipAddressPrefixTable:init_ipAddressPrefixTable", + "Registering ipAddressPrefixTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipAddressPrefixTable", + handler, + ipAddressPrefixTable_oid, + ipAddressPrefixTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY); + if (NULL == reginfo) { + snmp_log(LOG_ERR, + "error registering table ipAddressPrefixTable\n"); + return; + } + reginfo->my_reg_void = &ipAddressPrefixTable_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)) + /* XXX - are these actually necessary? */ + 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, + ipAddressPrefixTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != ipAddressPrefixTable_if_ctx.cache) { + handler = + netsnmp_cache_handler_get(ipAddressPrefixTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _ipAddressPrefixTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipAddressPrefixTable + */ +void +_ipAddressPrefixTable_shutdown_interface(ipAddressPrefixTable_registration + * reg_ptr) +{ + /* + * shutdown the container + */ + _ipAddressPrefixTable_container_shutdown(&ipAddressPrefixTable_if_ctx); +} + +void +ipAddressPrefixTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipAddressPrefixTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipAddressPrefixTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipAddressPrefixTable_index_to_oid(netsnmp_index * oid_idx, + ipAddressPrefixTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipAddressPrefixIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipAddressPrefixIfIndex; + /* + * ipAddressPrefixType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipAddressPrefixType; + /* + * ipAddressPrefixPrefix(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_ipAddressPrefixPrefix; + /* + * ipAddressPrefixLength(4)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipAddressPrefixLength; + + /* + * set up varbinds + */ + memset(&var_ipAddressPrefixIfIndex, 0x00, + sizeof(var_ipAddressPrefixIfIndex)); + var_ipAddressPrefixIfIndex.type = ASN_INTEGER; + memset(&var_ipAddressPrefixType, 0x00, + sizeof(var_ipAddressPrefixType)); + var_ipAddressPrefixType.type = ASN_INTEGER; + memset(&var_ipAddressPrefixPrefix, 0x00, + sizeof(var_ipAddressPrefixPrefix)); + var_ipAddressPrefixPrefix.type = ASN_OCTET_STR; + memset(&var_ipAddressPrefixLength, 0x00, + sizeof(var_ipAddressPrefixLength)); + var_ipAddressPrefixLength.type = ASN_UNSIGNED; + + /* + * chain temp index varbinds together + */ + var_ipAddressPrefixIfIndex.next_variable = &var_ipAddressPrefixType; + var_ipAddressPrefixType.next_variable = &var_ipAddressPrefixPrefix; + var_ipAddressPrefixPrefix.next_variable = &var_ipAddressPrefixLength; + var_ipAddressPrefixLength.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_index_to_oid", "called\n")); + + /* + * ipAddressPrefixIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_ipAddressPrefixIfIndex, + (u_char *) & mib_idx->ipAddressPrefixIfIndex, + sizeof(mib_idx->ipAddressPrefixIfIndex)); + + /* + * ipAddressPrefixType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_ipAddressPrefixType, + (u_char *) & mib_idx->ipAddressPrefixType, + sizeof(mib_idx->ipAddressPrefixType)); + + /* + * ipAddressPrefixPrefix(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + snmp_set_var_value(&var_ipAddressPrefixPrefix, + (u_char *) & mib_idx->ipAddressPrefixPrefix, + mib_idx->ipAddressPrefixPrefix_len * + sizeof(mib_idx->ipAddressPrefixPrefix[0])); + + /* + * ipAddressPrefixLength(4)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_ipAddressPrefixLength, + (u_char *) & mib_idx->ipAddressPrefixLength, + sizeof(mib_idx->ipAddressPrefixLength)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipAddressPrefixIfIndex); + 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_ipAddressPrefixIfIndex); + + return err; +} /* ipAddressPrefixTable_index_to_oid */ + +/** + * extract ipAddressPrefixTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipAddressPrefixTable_index_from_oid(netsnmp_index * oid_idx, + ipAddressPrefixTable_mib_index * + mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipAddressPrefixIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipAddressPrefixIfIndex; + /* + * ipAddressPrefixType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipAddressPrefixType; + /* + * ipAddressPrefixPrefix(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_ipAddressPrefixPrefix; + /* + * ipAddressPrefixLength(4)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipAddressPrefixLength; + + /* + * set up varbinds + */ + memset(&var_ipAddressPrefixIfIndex, 0x00, + sizeof(var_ipAddressPrefixIfIndex)); + var_ipAddressPrefixIfIndex.type = ASN_INTEGER; + memset(&var_ipAddressPrefixType, 0x00, + sizeof(var_ipAddressPrefixType)); + var_ipAddressPrefixType.type = ASN_INTEGER; + memset(&var_ipAddressPrefixPrefix, 0x00, + sizeof(var_ipAddressPrefixPrefix)); + var_ipAddressPrefixPrefix.type = ASN_OCTET_STR; + memset(&var_ipAddressPrefixLength, 0x00, + sizeof(var_ipAddressPrefixLength)); + var_ipAddressPrefixLength.type = ASN_UNSIGNED; + + /* + * chain temp index varbinds together + */ + var_ipAddressPrefixIfIndex.next_variable = &var_ipAddressPrefixType; + var_ipAddressPrefixType.next_variable = &var_ipAddressPrefixPrefix; + var_ipAddressPrefixPrefix.next_variable = &var_ipAddressPrefixLength; + var_ipAddressPrefixLength.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipAddressPrefixTable:ipAddressPrefixTable_index_from_oid", "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipAddressPrefixIfIndex); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipAddressPrefixIfIndex = + *((long *) var_ipAddressPrefixIfIndex.val.string); + mib_idx->ipAddressPrefixType = + *((u_long *) var_ipAddressPrefixType.val.string); + /* + * NOTE: val_len is in bytes, ipAddressPrefixPrefix_len might not be + */ + if (var_ipAddressPrefixPrefix.val_len > + sizeof(mib_idx->ipAddressPrefixPrefix)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->ipAddressPrefixPrefix, + var_ipAddressPrefixPrefix.val.string, + var_ipAddressPrefixPrefix.val_len); + mib_idx->ipAddressPrefixPrefix_len = + var_ipAddressPrefixPrefix.val_len / + sizeof(mib_idx->ipAddressPrefixPrefix[0]); + } + mib_idx->ipAddressPrefixLength = + *((u_long *) var_ipAddressPrefixLength.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipAddressPrefixIfIndex); + + return err; +} /* ipAddressPrefixTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipAddressPrefixTable_rowreq_ctx + */ +ipAddressPrefixTable_rowreq_ctx * +ipAddressPrefixTable_allocate_rowreq_ctx(void *user_init_ctx) +{ + ipAddressPrefixTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipAddressPrefixTable_rowreq_ctx); + + DEBUGMSGTL(("internal:ipAddressPrefixTable:ipAddressPrefixTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipAddressPrefixTable_rowreq_ctx.\n"); + return NULL; + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->ipAddressPrefixTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipAddressPrefixTable_rowreq_ctx_init(rowreq_ctx, + user_init_ctx)) { + ipAddressPrefixTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipAddressPrefixTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipAddressPrefixTable_rowreq_ctx + */ +void +ipAddressPrefixTable_release_rowreq_ctx(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipAddressPrefixTable:ipAddressPrefixTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipAddressPrefixTable_rowreq_ctx_cleanup(rowreq_ctx); + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* ipAddressPrefixTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipAddressPrefixTable_pre_request(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_mfd_ipAddressPrefixTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipAddressPrefixTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipAddressPrefixTable_pre_request(ipAddressPrefixTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressPrefixTable", "error %d from " + "ipAddressPrefixTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressPrefixTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipAddressPrefixTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressPrefixTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_mfd_ipAddressPrefixTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipAddressPrefixTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipAddressPrefixTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + rc = ipAddressPrefixTable_post_request(ipAddressPrefixTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressPrefixTable", "error %d from " + "ipAddressPrefixTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressPrefixTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipAddressPrefixTable_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; + ipAddressPrefixTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_mfd_ipAddressPrefixTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipAddressPrefixTable_interface_ctx *if_ctx = + * (ipAddressPrefixTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + rc = SNMP_ERR_NOCREATION; + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipAddressPrefixTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipAddressPrefixTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipAddressPrefixTable_get_column(ipAddressPrefixTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_mfd_ipAddressPrefixTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipAddressPrefixOrigin(5)/IpAddressPrefixOriginTC/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPADDRESSPREFIXORIGIN: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressPrefixOrigin_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipAddressPrefixOnLinkFlag(6)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPADDRESSPREFIXONLINKFLAG: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressPrefixOnLinkFlag_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipAddressPrefixAutonomousFlag(7)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPADDRESSPREFIXAUTONOMOUSFLAG: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressPrefixAutonomousFlag_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipAddressPrefixAdvPreferredLifetime(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPADDRESSPREFIXADVPREFERREDLIFETIME: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipAddressPrefixAdvPreferredLifetime_get(rowreq_ctx, + (u_long *) var->val. + string); + break; + + /* + * ipAddressPrefixAdvValidLifetime(9)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPADDRESSPREFIXADVVALIDLIFETIME: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipAddressPrefixAdvValidLifetime_get(rowreq_ctx, + (u_long *) var->val. + string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipAddressPrefixTable_get_column\n", + column); + break; + } + + return rc; +} /* _ipAddressPrefixTable_get_column */ + +int +_mfd_ipAddressPrefixTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressPrefixTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_mfd_ipAddressPrefixTable_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 = _ipAddressPrefixTable_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_ipAddressPrefixTable_get_values */ + + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * SET PROCESSING NOT APPLICABLE (per MIB or user setting) + */ +#endif + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +static void _container_free(netsnmp_container *container); + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:ipAddressPrefixTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for ipAddressPrefixTable_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 ipAddressPrefixTable_container_load((netsnmp_container *) + cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipAddressPrefixTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in ipAddressPrefixTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(ipAddressPrefixTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:ipAddressPrefixTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipAddressPrefixTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:ipAddressPrefixTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipAddressPrefixTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipAddressPrefixTable_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 +_ipAddressPrefixTable_container_init(ipAddressPrefixTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipAddressPrefixTable:_ipAddressPrefixTable_container_init", "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + ipAddressPrefixTable_oid, + ipAddressPrefixTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, + "error creating cache for ipAddressPrefixTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipAddressPrefixTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipAddressPrefixTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipAddressPrefixTable_container_init\n"); + return; + } + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _ipAddressPrefixTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipAddressPrefixTable_container_shutdown(ipAddressPrefixTable_interface_ctx + * if_ctx) +{ + DEBUGMSGTL(("internal:ipAddressPrefixTable:_ipAddressPrefixTable_container_shutdown", "called\n")); + + ipAddressPrefixTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipAddressPrefixTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_ROW_FIND_BY_MIB_INDEX +ipAddressPrefixTable_rowreq_ctx * +ipAddressPrefixTable_row_find_by_mib_index(ipAddressPrefixTable_mib_index * + mib_idx) +{ + ipAddressPrefixTable_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 = ipAddressPrefixTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = + CONTAINER_FIND(ipAddressPrefixTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSPREFIXTABLE_ROW_FIND_BY_MIB_INDEX */ diff --git a/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.h b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.h new file mode 100644 index 0000000..28308b5 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressPrefixTable/ipAddressPrefixTable_interface.h @@ -0,0 +1,98 @@ +/* + * 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 IPADDRESSPREFIXTABLE_INTERFACE_H +#define IPADDRESSPREFIXTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipAddressPrefixTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipAddressPrefixTable_initialize_interface + (ipAddressPrefixTable_registration * user_ctx, u_long flags); + void + _ipAddressPrefixTable_shutdown_interface + (ipAddressPrefixTable_registration * user_ctx); + + ipAddressPrefixTable_registration + * ipAddressPrefixTable_registration_get(void); + + ipAddressPrefixTable_registration + * ipAddressPrefixTable_registration_set + (ipAddressPrefixTable_registration * newreg); + + netsnmp_container *ipAddressPrefixTable_container_get(void); + int ipAddressPrefixTable_container_size(void); + ipAddressPrefixTable_rowreq_ctx + * ipAddressPrefixTable_allocate_rowreq_ctx(void *); + void + ipAddressPrefixTable_release_rowreq_ctx + (ipAddressPrefixTable_rowreq_ctx * rowreq_ctx); + + int ipAddressPrefixTable_index_to_oid(netsnmp_index * + oid_idx, + ipAddressPrefixTable_mib_index + * mib_idx); + int ipAddressPrefixTable_index_from_oid(netsnmp_index * + oid_idx, + ipAddressPrefixTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + ipAddressPrefixTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSPREFIXTABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipAddressTable.h b/agent/mibgroup/ip-mib/ipAddressTable.h new file mode 100644 index 0000000..8d4d274 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/ipAddressTable/ipAddressTable) diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c new file mode 100644 index 0000000..deff4e9 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c @@ -0,0 +1,2436 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for ipAddressTable + * + * \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 <net-snmp/data_access/interface.h> + +/* + * include our parent header + */ +#include "ipAddressTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipAddressTable_interface.h" + +netsnmp_feature_require(check_storage_transition) +netsnmp_feature_require(ipaddress_entry_copy) +netsnmp_feature_require(ipaddress_prefix_copy) + +const oid ipAddressTable_oid[] = { IPADDRESSTABLE_OID }; +const int ipAddressTable_oid_size = OID_LENGTH(ipAddressTable_oid); + +ipAddressTable_registration ipAddressTable_user_context; +static ipAddressTable_registration *ipAddressTable_user_context_p; + +void initialize_table_ipAddressTable(void); +void shutdown_table_ipAddressTable(void); + + +/** + * Initializes the ipAddressTable module + */ +void +init_ipAddressTable(void) +{ + DEBUGMSGTL(("verbose:ipAddressTable:init_ipAddressTable", "called\n")); + + /* + * TODO:300:o: Perform ipAddressTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipAddressTable")) + initialize_table_ipAddressTable(); + +} /* init_ipAddressTable */ + +/** + * Shut-down the ipAddressTable module (agent is exiting) + */ +void +shutdown_ipAddressTable(void) +{ + if (should_init("ipAddressTable")) + shutdown_table_ipAddressTable(); + +} + +/** + * Initialize the table ipAddressTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipAddressTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipAddressTable:initialize_table_ipAddressTable", + "called\n")); + + /* + * TODO:301:o: Perform ipAddressTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipAddressTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + ipAddressTable_user_context_p = NULL; + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipAddressTable_initialize_interface(ipAddressTable_user_context_p, flags); +} /* initialize_table_ipAddressTable */ + +/** + * Shutdown the table ipAddressTable + */ +void +shutdown_table_ipAddressTable(void) +{ + /* + * call interface shutdown code + */ + _ipAddressTable_shutdown_interface(ipAddressTable_user_context_p); + netsnmp_free_all_list_data(ipAddressTable_user_context_p); + ipAddressTable_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 +ipAddressTable_rowreq_ctx_init(ipAddressTable_rowreq_ctx * rowreq_ctx, + void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_rowreq_ctx_init", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipAddressTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* ipAddressTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipAddressTable_rowreq_ctx_cleanup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_rowreq_ctx_cleanup", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipAddressTable rowreq cleanup. + */ + if (NULL != rowreq_ctx->data) { + ipAddressTable_release_data(rowreq_ctx->data); + rowreq_ctx->data = NULL; + } +} /* ipAddressTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * @param user_context + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipAddressTable_pre_request(ipAddressTable_registration * user_context) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_pre_request", + "called\n")); + + /* + * TODO:510:o: Perform ipAddressTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipAddressTable_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 +ipAddressTable_post_request(ipAddressTable_registration * user_context, + int rc) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_post_request", + "called\n")); + + /* + * TODO:511:o: Perform ipAddressTable post-request actions. + */ + + /* + * check to set if any rows were changed. + */ + if (ipAddressTable_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 + */ + } + + ipAddressTable_dirty_set(0); /* clear table dirty flag */ + } + + return MFD_SUCCESS; +} /* ipAddressTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipAddressTable data context functions. + */ +/* + * ipAddressTable_allocate_data + * + * Purpose: create new ipAddressTable_data. + */ +ipAddressTable_data * +ipAddressTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the ipAddressTable data context. + */ + ipAddressTable_data *rtn = netsnmp_access_ipaddress_entry_create(); + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_allocate_data", + "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipAddressTable_data.\n"); + } + + return rtn; +} /* ipAddressTable_allocate_data */ + +/* + * ipAddressTable_release_data + * + * Purpose: release ipAddressTable data. + */ +void +ipAddressTable_release_data(ipAddressTable_data * data) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_release_data", + "called\n")); + + /* + * TODO:202:r: |-> release memory for the ipAddressTable data context. + */ + netsnmp_access_ipaddress_entry_free(data); +} /* ipAddressTable_release_data */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressAddrType + * ipAddressAddrType is subid 1 of ipAddressEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.34.1.1 + * Description: +The address type of ipAddressAddr. + * + * 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 ipAddressAddrType IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-ipAddressAddrType.m2d : + * @verbatim $m2c_node_skip_mapping = 1@endverbatim + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +ipAddressAddrType_map(long * mib_ipAddressAddrType_val_ptr, + long raw_ipAddressAddrType_val) +{ + netsnmp_assert(NULL != mib_ipAddressAddrType_val_ptr); + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressAddrType_map", + "called\n")); + + /* + * TODO:241:o: |-> Implement ipAddressAddrType enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch (raw_ipAddressAddrType_val) { + case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4: + *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4; + break; + + case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6: + *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for ipAddressAddrType\n", + raw_ipAddressAddrType_val); + *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_UNKNOWN; + } + + return MFD_SUCCESS; +} /* ipAddressAddrType_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipAddressAddrType_val + * @param ipAddressAddr_val_ptr + * @param ipAddressAddr_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 +ipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * tbl_idx, + long ipAddressAddrType_val, + u_char *ipAddressAddr_val_ptr, + size_t ipAddressAddr_val_ptr_len) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_ipaddress_entry */ + ipAddressAddrType_map(&tbl_idx->ipAddressAddrType, + ipAddressAddrType_val); + + /* + * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + tbl_idx->ipAddressAddr_len = sizeof(tbl_idx->ipAddressAddr) / sizeof(tbl_idx->ipAddressAddr[0]); /* max length */ + /** WARNING: this code might not work for netsnmp_ipaddress_entry */ + /* + * make sure there is enough space for ipAddressAddr data + */ + if (tbl_idx->ipAddressAddr_len < ipAddressAddr_val_ptr_len) { + snmp_log(LOG_ERR, "not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->ipAddressAddr_len = ipAddressAddr_val_ptr_len; + memcpy(tbl_idx->ipAddressAddr, ipAddressAddr_val_ptr, + ipAddressAddr_val_ptr_len * sizeof(ipAddressAddr_val_ptr[0])); + + + return MFD_SUCCESS; +} /* ipAddressTable_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 +ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressAddrType_val, + u_char *ipAddressAddr_val_ptr, + size_t ipAddressAddr_val_ptr_len) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set", + "called\n")); + + if (MFD_SUCCESS != + ipAddressTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipAddressAddrType_val, + ipAddressAddr_val_ptr, + ipAddressAddr_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 != ipAddressTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipAddressTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressIfIndex + * ipAddressIfIndex is subid 3 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.3 + * Description: +The index value which uniquely identifies the interface to + which this entry is applicable. The interface identified by + a particular value of this index is the same interface as + identified by the same value of the IF-MIB's ifIndex. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: d + * + * Ranges: 1 - 2147483647; + * + * Its syntax is InterfaceIndex (based on perltype INTEGER32) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the ipAddressIfIndex data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressIfIndex_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 +ipAddressIfIndex_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + long *ipAddressIfIndex_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressIfIndex_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressIfIndex_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressIfIndex data. + * copy (* ipAddressIfIndex_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressIfIndex_val_ptr) = rowreq_ctx->data->if_index; + + return MFD_SUCCESS; +} /* ipAddressIfIndex_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressType + * ipAddressType is subid 4 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.4 + * Description: +The type of address. broadcast(3) is not a valid value for + IPv6 addresses (RFC3513). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: unicast + * + * Enum range: 2/8. Values: unicast(1), anycast(2), broadcast(3) + * + * 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 ipAddressType data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressType_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 +ipAddressType_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressType_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressType_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressType_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressType data. + * copy (* ipAddressType_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressType_val_ptr) = rowreq_ctx->data->ia_type; + + return MFD_SUCCESS; +} /* ipAddressType_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressPrefix + * ipAddressPrefix is subid 5 of ipAddressEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.34.1.5 + * Description: +A pointer to the row in the prefix table to which this + address belongs. May be { 0 0 } if there is no such row. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * defval: zeroDotZero + * + * + * Its syntax is RowPointer (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. + */ +/** + * Extract the current value of the ipAddressPrefix data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressPrefix_val_ptr_ptr + * Pointer to storage for a oid variable + * @param ipAddressPrefix_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by ipAddressPrefix. + * 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 (*ipAddressPrefix_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update ipAddressPrefix_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 +ipAddressPrefix_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + oid ** ipAddressPrefix_val_ptr_ptr, + size_t * ipAddressPrefix_val_ptr_len_ptr) +{ + oid *dst, tmp_oid[MAX_OID_LEN] = + { 1, 3, 6, 1, 2, 1, 4, 32, 1, 5 }; + u_char tmp_buf[NETSNMP_ACCESS_IPADDRESS_BUF_SIZE]; + size_t len; + + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert((NULL != ipAddressPrefix_val_ptr_ptr) + && (NULL != *ipAddressPrefix_val_ptr_ptr)); + netsnmp_assert(NULL != ipAddressPrefix_val_ptr_len_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressPrefix_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressPrefix data. + * copy (* ipAddressPrefix_val_ptr_ptr ) data and (* ipAddressPrefix_val_ptr_len_ptr ) from rowreq_ctx->data + */ + dst = &tmp_oid[10]; + *(dst++) = rowreq_ctx->data->if_index; + *(dst++) = rowreq_ctx->tbl_idx.ipAddressAddrType; + *(dst++) = rowreq_ctx->data->ia_address_len; + netsnmp_ipaddress_prefix_copy(tmp_buf, + (u_char *) rowreq_ctx->tbl_idx.ipAddressAddr, + rowreq_ctx->data->ia_address_len, + rowreq_ctx->data->ia_prefix_len); + for (len = 0; len < rowreq_ctx->data->ia_address_len; ++len) + *(dst++) = tmp_buf[len]; + *(dst++) = rowreq_ctx->data->ia_prefix_len; + len = dst - tmp_oid; + + len *= sizeof((*ipAddressPrefix_val_ptr_ptr)[0]); + if ((*ipAddressPrefix_val_ptr_len_ptr) < len) { + (*ipAddressPrefix_val_ptr_ptr) = (oid*)malloc(len); + if (NULL == (*ipAddressPrefix_val_ptr_ptr)) { + snmp_log(LOG_ERR, "could not allocate memory\n"); + return MFD_ERROR; + } + } + (*ipAddressPrefix_val_ptr_len_ptr) = len; + memcpy((*ipAddressPrefix_val_ptr_ptr), tmp_oid, len); + + return MFD_SUCCESS; +} /* ipAddressPrefix_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressOrigin + * ipAddressOrigin is subid 6 of ipAddressEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.34.1.6 + * Description: +The origin of the address. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 4/8. Values: other(1), manual(2), dhcp(4), linklayer(5), random(6) + * + * Its syntax is IpAddressOriginTC (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 ipAddressOrigin data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressOrigin_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 +ipAddressOrigin_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressOrigin_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressOrigin_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressOrigin_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressOrigin data. + * copy (* ipAddressOrigin_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressOrigin_val_ptr) = rowreq_ctx->data->ia_origin; + + return MFD_SUCCESS; +} /* ipAddressOrigin_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressStatus + * ipAddressStatus is subid 7 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.7 + * Description: +The status of the address, describing if the address can be + used for communication. + + + In the absence of other information, an IPv4 address is + always preferred(1). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: preferred + * + * Enum range: 5/8. Values: preferred(1), invalid(3), inaccessible(4), unknown(5), tentative(6), duplicate(7) + * + * Its syntax is IpAddressStatusTC (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 ipAddressStatus data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressStatus_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 +ipAddressStatus_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressStatus_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStatus_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressStatus data. + * copy (* ipAddressStatus_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressStatus_val_ptr) = rowreq_ctx->data->ia_status; + + return MFD_SUCCESS; +} /* ipAddressStatus_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressCreated + * ipAddressCreated is subid 8 of ipAddressEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.34.1.8 + * Description: +The value of sysUpTime at the time this entry was created. + If this entry was created prior to the last re- + initialization of the local network management subsystem, + then this object contains a zero value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is TimeStamp (based on perltype TICKS) + * The net-snmp type is ASN_TIMETICKS. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipAddressCreated data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressCreated_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 +ipAddressCreated_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressCreated_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressCreated_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressCreated_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressCreated data. + * copy (* ipAddressCreated_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressCreated_val_ptr) = rowreq_ctx->ipAddressCreated; + + return MFD_SUCCESS; +} /* ipAddressCreated_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressLastChanged + * ipAddressLastChanged is subid 9 of ipAddressEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.34.1.9 + * Description: +The value of sysUpTime at the time this entry was last + updated. If this entry was updated prior to the last re- + initialization of the local network management subsystem, + then this object contains a zero value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is TimeStamp (based on perltype TICKS) + * The net-snmp type is ASN_TIMETICKS. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipAddressLastChanged data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressLastChanged_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 +ipAddressLastChanged_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressLastChanged_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressLastChanged_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressLastChanged_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressLastChanged data. + * copy (* ipAddressLastChanged_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressLastChanged_val_ptr) = rowreq_ctx->ipAddressLastChanged; + + return MFD_SUCCESS; +} /* ipAddressLastChanged_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressRowStatus + * ipAddressRowStatus is subid 10 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.10 + * Description: +The status of this conceptual row. + + + The RowStatus TC requires that this DESCRIPTION clause + states under which circumstances other objects in this row + can be modified. The value of this object has no effect on + whether other objects in this conceptual row can be + modified. + + + A conceptual row can not be made active until the + ipAddressIfIndex has been set to a valid index. + * + * 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 ipAddressRowStatus data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressRowStatus_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 +ipAddressRowStatus_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressRowStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressRowStatus_val_ptr); + + /** WARNING: this code might not work for netsnmp_ipaddress_entry */ + if(rowreq_ctx->data->if_index) + (*ipAddressRowStatus_val_ptr) = rowreq_ctx->ipAddressRowStatus; + else + (*ipAddressRowStatus_val_ptr) = ROWSTATUS_NOTREADY; + + return MFD_SUCCESS; +} /* ipAddressRowStatus_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressStorageType + * ipAddressStorageType is subid 11 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.11 + * Description: +The storage type for this conceptual row. If this object + has a value of 'permanent' then no other objects are + required to be able to be modified. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: volatile + * + * Enum range: 4/8. Values: other(1), volatile(2), nonVolatile(3), permanent(4), readOnly(5) + * + * Its syntax is StorageType (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 ipAddressStorageType data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipAddressStorageType_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 +ipAddressStorageType_get(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long * ipAddressStorageType_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipAddressStorageType_val_ptr); + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStorageType_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipAddressStorageType data. + * copy (* ipAddressStorageType_val_ptr ) from rowreq_ctx->data + */ + (*ipAddressStorageType_val_ptr) = rowreq_ctx->data->ia_storagetype; + + return MFD_SUCCESS; +} /* ipAddressStorageType_get */ + + + +/** @} */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + /* + * 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 + * ipAddressTable_allocate_data(), but may need extra + * initialization similar to what you may have done in + * ipAddressTable_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 (ipAddressTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipAddressTable_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_undo_setup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> Setup ipAddressTable undo. + * set up ipAddressTable undo information, in preparation for a set. + * Undo storage is in (* ipAddressStorageType_val_ptr )* + */ + /* + * check for storage types that don't allow modification. + * probably should try and do this earlier (and we could, by + * adding code to the interface file), but this ought to suffice. + */ + if (STORAGETYPE_READONLY == rowreq_ctx->data->ia_storagetype) { + DEBUGMSGTL(("ipAddressTable", "can't change readonly row\n")); + return MFD_NOT_VALID_EVER; + } + + /* + * save last changed + */ + rowreq_ctx->ipAddressLastChanged_undo = + rowreq_ctx->ipAddressLastChanged; + + + /* + * just copy everything + */ + rc = netsnmp_access_ipaddress_entry_copy(rowreq_ctx->undo, + rowreq_ctx->data); + + return rc; +} /* ipAddressTable_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 (ipAddressTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipAddressTable_undo(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_undo", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> ipAddressTable undo. + * ipAddressTable undo information, in response to a failed set. + * Undo storage is in (* ipAddressStorageType_val_ptr )* + */ + + return rc; +} /* ipAddressTable_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 (ipAddressTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +ipAddressTable_undo_cleanup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_undo_cleanup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:452:M: |-> Cleanup ipAddressTable undo. + * Undo storage is in (* ipAddressStorageType_val_ptr )* + */ + rowreq_ctx->ipAddressLastChanged = + rowreq_ctx->ipAddressLastChanged_undo; + + return rc; +} /* ipAddressTable_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 + * ipAddressTable.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 +ipAddressTable_commit(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_commit", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * commit ipAddressTable data + * 1) check the column's flag 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 == rowreq_ctx->column_set_flags) { + DEBUGMSGTL(("ipAddressTable:ipAddressTable_commit", + "no change\n")); + return MFD_SUCCESS; + } + + /* + * pass everything to data access + * let data access know what columns are set + */ + rowreq_ctx->data->flags = rowreq_ctx->column_set_flags; + + if (rowreq_ctx->column_set_flags & COLUMN_IPADDRESSROWSTATUS_FLAG) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->data->flags |= NETSNMP_ACCESS_IPADDRESS_CREATE; + rowreq_ctx->ipAddressCreated = netsnmp_get_agent_uptime(); + } else if (ROWSTATUS_DESTROY == rowreq_ctx->ipAddressRowStatus) { + rowreq_ctx->data->flags |= NETSNMP_ACCESS_IPADDRESS_DELETE; + } else + rowreq_ctx->data->flags |= NETSNMP_ACCESS_IPADDRESS_CHANGE; + } else + rowreq_ctx->data->flags |= NETSNMP_ACCESS_IPADDRESS_CHANGE; + + /* + * do it + */ + rc = netsnmp_access_ipaddress_entry_set(rowreq_ctx->data); + if (rc) { + DEBUGMSGTL(("ipAddressTable", + "bad rc %d from IP address data access\n", rc)); + rc = MFD_ERROR; + } else { + rowreq_ctx->ipAddressLastChanged = netsnmp_get_agent_uptime(); + } + + /* + * if we successfully commited this row, set the dirty flag. + */ + if (MFD_SUCCESS == rc) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; + } + + return rc; +} /* ipAddressTable_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 + * ipAddressTable.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 +ipAddressTable_undo_commit(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_undo_commit", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:485:M: |-> Undo ipAddressTable 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_IPADDRESSROWSTATUS_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_IPADDRESS_DELETE; + } else if (ROWSTATUS_DESTROY == rowreq_ctx->ipAddressRowStatus) { + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_IPADDRESS_CREATE; + } else + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_IPADDRESS_CHANGE; + } else + rowreq_ctx->undo->flags |= NETSNMP_ACCESS_IPADDRESS_CHANGE; + + /* + * do it + */ + rc = netsnmp_access_ipaddress_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; +} /* ipAddressTable_undo_commit */ + +/* + * TODO:440:M: Implement ipAddressTable node value checks. + * TODO:450:M: Implement ipAddressTable undo functions. + * TODO:460:M: Implement ipAddressTable set functions. + * TODO:480:M: Implement ipAddressTable commit functions. + */ +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressIfIndex + * ipAddressIfIndex is subid 3 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.3 + * Description: +The index value which uniquely identifies the interface to + which this entry is applicable. The interface identified by + a particular value of this index is the same interface as + identified by the same value of the IF-MIB's ifIndex. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: d + * + * Ranges: 1 - 2147483647; + * + * Its syntax is InterfaceIndex (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 ipAddressIfIndex_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 + * ipAddressTable_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): 1 - 2147483647 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipAddressIfIndex_check_value(ipAddressTable_rowreq_ctx * rowreq_ctx, + long ipAddressIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressIfIndex_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipAddressIfIndex value. + */ + /* + * if the new value is the same as the old, accept it. + */ + if (ipAddressIfIndex_val == (long)rowreq_ctx->data->if_index) + return MFD_SUCCESS; + + /* + * currently don't support moving addresses between interfaces, so + * if this isn't a new row, return error. + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)) { + DEBUGMSGT(("ipAddressTable", + "changing ifIndex value not supported\n")); + return MFD_NOT_VALID_EVER; + } + + /* + * find name for ifIndex + */ + if (NULL == netsnmp_access_interface_name_find(ipAddressIfIndex_val)) { + DEBUGMSGT(("ipAddressTable", "cant find name for index %ld\n", + ipAddressIfIndex_val)); + return MFD_NOT_VALID_NOW; + } + + return MFD_SUCCESS; /* ipAddressIfIndex value not illegal */ +} /* ipAddressIfIndex_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipAddressTable_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 + * ipAddressTable_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 +ipAddressIfIndex_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressIfIndex_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipAddressIfIndex undo. + */ + /* + * handled in ipAddressTable_undo_setup + */ + + return MFD_SUCCESS; +} /* ipAddressIfIndex_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 ipAddressIfIndex_val + * A long containing the new value. + */ +int +ipAddressIfIndex_set(ipAddressTable_rowreq_ctx * rowreq_ctx, + long ipAddressIfIndex_val) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressIfIndex_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipAddressIfIndex value. + * set ipAddressIfIndex value in rowreq_ctx->data + */ + if (rowreq_ctx->data->if_index != (oid)ipAddressIfIndex_val) + rowreq_ctx->data->if_index = (oid)ipAddressIfIndex_val; + else + rowreq_ctx->column_set_flags &= ~COLUMN_IPADDRESSIFINDEX_FLAG; + + return MFD_SUCCESS; +} /* ipAddressIfIndex_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipAddressIfIndex_undo(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressIfIndex_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipAddressIfIndex undo. + */ + /* + * copy ipAddressIfIndex data + * set rowreq_ctx->data->ipAddressIfIndex from rowreq_ctx->undo->ipAddressIfIndex + */ + rowreq_ctx->data->if_index = rowreq_ctx->undo->if_index; + + return MFD_SUCCESS; +} /* ipAddressIfIndex_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressType + * ipAddressType is subid 4 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.4 + * Description: +The type of address. broadcast(3) is not a valid value for + IPv6 addresses (RFC3513). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: unicast + * + * Enum range: 2/8. Values: unicast(1), anycast(2), broadcast(3) + * + * 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 ipAddressType_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 + * ipAddressTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of unicast(1), anycast(2), broadcast(3) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipAddressType_check_value(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressType_val) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressType_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipAddressType value. + * + * no support for anything but unicast yet + */ + if (ipAddressType_val != IPADDRESSTYPE_UNICAST) + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipAddressType value not illegal */ +} /* ipAddressType_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipAddressTable_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 + * ipAddressTable_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 +ipAddressType_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressType_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipAddressType undo. + */ + /* + * handled in ipAddressTable_undo_setup + */ + + return MFD_SUCCESS; +} /* ipAddressType_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 ipAddressType_val + * A long containing the new value. + */ +int +ipAddressType_set(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressType_val) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressType_set", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipAddressType value. + * set ipAddressType value in rowreq_ctx->data + */ + rowreq_ctx->data->ia_type = ipAddressType_val; + + return MFD_SUCCESS; +} /* ipAddressType_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipAddressType_undo(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressType_undo", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipAddressType undo. + */ + /* + * copy ipAddressType data + * set rowreq_ctx->data->ipAddressType from rowreq_ctx->undo->ipAddressType + */ + rowreq_ctx->data->ia_type = rowreq_ctx->undo->ia_type; + + return MFD_SUCCESS; +} /* ipAddressType_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressStatus + * ipAddressStatus is subid 7 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.7 + * Description: +The status of the address, describing if the address can be + used for communication. + + + In the absence of other information, an IPv4 address is + always preferred(1). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: preferred + * + * Enum range: 5/8. Values: preferred(1), invalid(3), inaccessible(4), unknown(5), tentative(6), duplicate(7) + * + * Its syntax is IpAddressStatusTC (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 ipAddressStatus_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 + * ipAddressTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of preferred(1), invalid(3), inaccessible(4), unknown(5), tentative(6), duplicate(7) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipAddressStatus_check_value(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressStatus_val) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStatus_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipAddressStatus value. + * + * nothing but preferred supported yet + */ + if (IPADDRESSSTATUSTC_PREFERRED != ipAddressStatus_val) + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipAddressStatus value not illegal */ +} /* ipAddressStatus_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipAddressTable_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 + * ipAddressTable_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 +ipAddressStatus_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStatus_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipAddressStatus undo. + */ + /* + * handled in ipAddressTable_undo_setup + */ + + return MFD_SUCCESS; +} /* ipAddressStatus_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 ipAddressStatus_val + * A long containing the new value. + */ +int +ipAddressStatus_set(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressStatus_val) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStatus_set", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipAddressStatus value. + * set ipAddressStatus value in rowreq_ctx->data + */ + rowreq_ctx->data->ia_status = ipAddressStatus_val; + + return MFD_SUCCESS; +} /* ipAddressStatus_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipAddressStatus_undo(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStatus_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipAddressStatus undo. + */ + /* + * copy ipAddressStatus data + * set rowreq_ctx->data->ipAddressStatus from rowreq_ctx->undo->ipAddressStatus + */ + rowreq_ctx->data->ia_status = rowreq_ctx->undo->ia_status; + + return MFD_SUCCESS; +} /* ipAddressStatus_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressRowStatus + * ipAddressRowStatus is subid 10 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.10 + * Description: +The status of this conceptual row. + + + The RowStatus TC requires that this DESCRIPTION clause + states under which circumstances other objects in this row + can be modified. The value of this object has no effect on + whether other objects in this conceptual row can be + modified. + + + A conceptual row can not be made active until the + ipAddressIfIndex has been set to a valid index. + * + * 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 ipAddressRowStatus_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 + * ipAddressTable_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 +ipAddressRowStatus_check_value(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressRowStatus_val) +{ + int rc; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressRowStatus_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipAddressRowStatus value. + * + * don't support createAndWait + * check for valid RowStatus transition (old, new) + */ + if (ROWSTATUS_CREATEANDWAIT == ipAddressRowStatus_val) { + DEBUGMSGTL(("ipAddressTable", "createAndWait not supported\n")); + return MFD_NOT_VALID_EVER; + } + + rc = check_rowstatus_transition(rowreq_ctx->ipAddressRowStatus, + ipAddressRowStatus_val); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable", + "row status transition from %d to %lu\n", + rowreq_ctx->ipAddressRowStatus, + ipAddressRowStatus_val)); + return rc; + } + + return MFD_SUCCESS; /* ipAddressRowStatus value not illegal */ +} /* ipAddressRowStatus_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipAddressTable_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 + * ipAddressTable_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 +ipAddressRowStatus_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressRowStatus_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipAddressRowStatus undo. + */ + /* + * handled in ipAddressTable_undo_setup + */ + + return MFD_SUCCESS; +} /* ipAddressRowStatus_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 ipAddressRowStatus_val + * A long containing the new value. + */ +int +ipAddressRowStatus_set(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressRowStatus_val) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressRowStatus_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipAddressRowStatus value. + * set ipAddressRowStatus value in rowreq_ctx->data + */ + rowreq_ctx->ipAddressRowStatus = ipAddressRowStatus_val; + + return MFD_SUCCESS; +} /* ipAddressRowStatus_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipAddressRowStatus_undo(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressRowStatus_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipAddressRowStatus undo. + */ + /* + * copy ipAddressRowStatus data + * set rowreq_ctx->data->ipAddressRowStatus from rowreq_ctx->undo->ipAddressRowStatus + */ + rowreq_ctx->ipAddressRowStatus = rowreq_ctx->ipAddressRowStatus_undo; + + return MFD_SUCCESS; +} /* ipAddressRowStatus_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressStorageType + * ipAddressStorageType is subid 11 of ipAddressEntry. + * Its status is Current, and its access level is Create. + * OID: .1.3.6.1.2.1.4.34.1.11 + * Description: +The storage type for this conceptual row. If this object + has a value of 'permanent' then no other objects are + required to be able to be modified. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * defval: volatile + * + * Enum range: 4/8. Values: other(1), volatile(2), nonVolatile(3), permanent(4), readOnly(5) + * + * Its syntax is StorageType (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 ipAddressStorageType_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 + * ipAddressTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of other(1), volatile(2), nonVolatile(3), permanent(4), readOnly(5) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipAddressStorageType_check_value(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressStorageType_val) +{ + int rc; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStorageType_check_value", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipAddressStorageType value. + */ + /* + * since I don't know how the various operating systems + * deal with ip addresses, and whether or not changes will + * be saved on reboot, so don't allow rows to be set to anything + * but volatile. I'd prefer other, but since the default for + * new rows, per the mib, is volatile... + * + * If some industrious soul would like + * non-volaltile support, the first would need to + * add it in the data access code for their os + * define a flag bit for volatile/permanent/readonly + * set the bit in data access + * copy the bit to a new var in the rowreq_ctx (see _add_new_entry) + * with a default of volatile (for os' w/out nonvolatile support) + * update this code to use new flag + */ + if (STORAGETYPE_VOLATILE != ipAddressStorageType_val) + return MFD_NOT_VALID_EVER; + + /* + * check for valid StorageType transition (old, new) + */ + rc = check_storage_transition(rowreq_ctx->data->ia_storagetype, + ipAddressStorageType_val); + if (MFD_SUCCESS != rc) + return rc; + + return MFD_SUCCESS; /* ipAddressStorageType value not illegal */ +} /* ipAddressStorageType_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipAddressTable_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 + * ipAddressTable_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 +ipAddressStorageType_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStorageType_undo_setup", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipAddressStorageType undo. + */ + /* + * handled in ipAddressTable_undo_setup + */ + + return MFD_SUCCESS; +} /* ipAddressStorageType_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 ipAddressStorageType_val + * A long containing the new value. + */ +int +ipAddressStorageType_set(ipAddressTable_rowreq_ctx * rowreq_ctx, + u_long ipAddressStorageType_val) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStorageType_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipAddressStorageType value. + * set ipAddressStorageType value in rowreq_ctx->data + */ + rowreq_ctx->data->ia_storagetype = ipAddressStorageType_val; + + return MFD_SUCCESS; +} /* ipAddressStorageType_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipAddressStorageType_undo(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStorageType_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipAddressStorageType undo. + */ + /* + * copy ipAddressStorageType data + * set rowreq_ctx->data->ipAddressStorageType from rowreq_ctx->undo->ipAddressStorageType + */ + rowreq_ctx->data->ia_storagetype = rowreq_ctx->undo->ia_storagetype; + + return MFD_SUCCESS; +} /* ipAddressStorageType_undo */ + +/** + * 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 + * ipAddressTable.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-ipAddressTable if you don't have dependencies) + */ +int +ipAddressTable_check_dependencies(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:ipAddressTable_check_dependencies", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:470:o: Check ipAddressTable row dependencies. + * check that all new value are legal and consistent with each other + */ + /* + * check RowStatus dependencies + */ + if (rowreq_ctx->column_set_flags & COLUMN_IPADDRESSROWSTATUS_FLAG) { + /* + * row creation requirements + */ + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + if (ROWSTATUS_DESTROY == rowreq_ctx->ipAddressRowStatus) { + rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; + } else if (ROWSTATUS_CREATEANDGO == + rowreq_ctx->ipAddressRowStatus) { + if ((rowreq_ctx-> + column_set_flags & IPADDRESSTABLE_REQUIRED_COLS) + != IPADDRESSTABLE_REQUIRED_COLS) { + DEBUGMSGTL(("ipAddressTable", + "required columns missing (0x%0x != 0x%0x)\n", + rowreq_ctx->column_set_flags, + IPADDRESSTABLE_REQUIRED_COLS)); + return MFD_CANNOT_CREATE_NOW; + } + rowreq_ctx->ipAddressRowStatus = 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->ipAddressRowStatus) { + if (rowreq_ctx-> + column_set_flags & ~COLUMN_IPADDRESSROWSTATUS_FLAG) { + DEBUGMSGTL(("ipAddressTable", + "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(("ipAddressTable", + "must use RowStatus to create rows\n")); + return MFD_CANNOT_CREATE_NOW; + } + } /* row status not set */ + + return rc; +} /* ipAddressTable_check_dependencies */ + +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h new file mode 100644 index 0000000..fe8f04a --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h @@ -0,0 +1,457 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef IPADDRESSTABLE_H +#define IPADDRESSTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/ipaddress.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(if-mib/data_access/interface) +config_require(ip-mib/data_access/ipaddress) +config_require(ip-mib/ipAddressTable/ipAddressTable_interface) +config_require(ip-mib/ipAddressTable/ipAddressTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for ipAddressTable + */ +#include "ipAddressTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipAddressTable(void); + void shutdown_ipAddressTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + /* + ********************************************************************* + * 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 ipAddressTable registration context. + */ + typedef netsnmp_data_list ipAddressTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipAddressTable data context structure. + * This structure is used to represent the data for ipAddressTable. + */ + typedef netsnmp_ipaddress_entry ipAddressTable_data; + + + /* + ********************************************************************* + * TODO:115:o: |-> Review ipAddressTable 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 ipAddressTable_data ipAddressTable_undo_data; + + /* + * TODO:120:r: |-> Review ipAddressTable mib index. + * This structure is used to represent the index for ipAddressTable. + */ + typedef struct ipAddressTable_mib_index_s { + + /* + * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + long ipAddressAddrType; + + /* + * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + /** 128 - 1(other indexes) - oid length(10) = 116 */ + u_char ipAddressAddr[116]; + size_t ipAddressAddr_len; + + + } ipAddressTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipAddressTable 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! + * Guessing 128 - col/entry(2) - oid len(8) + */ +#define MAX_ipAddressTable_IDX_LEN 118 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipAddressTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipAddressTable_rowreq_ctx pointer. + */ + typedef struct ipAddressTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipAddressTable_IDX_LEN]; + + ipAddressTable_mib_index tbl_idx; + + ipAddressTable_data *data; + ipAddressTable_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 ipAddressTable rowreq context. + */ + + /* + * not available from net-snmp ipaddress data_access + */ + uint32_t ipAddressCreated; /* sysUpTime */ + uint32_t ipAddressLastChanged, ipAddressLastChanged_undo; /* sysUpTime */ + int ipAddressRowStatus, ipAddressRowStatus_undo; + + /* + * storage for future expansion + */ + netsnmp_data_list *ipAddressTable_data_list; + + } ipAddressTable_rowreq_ctx; + + typedef struct ipAddressTable_ref_rowreq_ctx_s { + ipAddressTable_rowreq_ctx *rowreq_ctx; + } ipAddressTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int ipAddressTable_pre_request(ipAddressTable_registration + * user_context); + int ipAddressTable_post_request(ipAddressTable_registration + * user_context, int rc); + + int + ipAddressTable_rowreq_ctx_init(ipAddressTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx); + void + ipAddressTable_rowreq_ctx_cleanup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + ipAddressTable_data *ipAddressTable_allocate_data(void); + void ipAddressTable_release_data(ipAddressTable_data * + data); + + int + ipAddressTable_check_dependencies(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressTable_commit(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + ipAddressTable_rowreq_ctx + * ipAddressTable_row_find_by_mib_index(ipAddressTable_mib_index * + mib_idx); + + extern const oid ipAddressTable_oid[]; + extern const int ipAddressTable_oid_size; + + +#include "ipAddressTable_interface.h" +#include "ipAddressTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + /* + * indexes + */ + int ipAddressAddrType_map(long * + mib_ipAddressAddrType_val_ptr, + long + raw_ipAddressAddrType_val); + + int ipAddressIfIndex_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + long *ipAddressIfIndex_val_ptr); + int ipAddressType_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * ipAddressType_val_ptr); + int ipAddressPrefix_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + oid ** ipAddressPrefix_val_ptr_ptr, + size_t + * ipAddressPrefix_val_ptr_len_ptr); + int ipAddressOrigin_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * ipAddressOrigin_val_ptr); + int ipAddressStatus_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * ipAddressStatus_val_ptr); + int ipAddressCreated_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressCreated_val_ptr); + int ipAddressLastChanged_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressLastChanged_val_ptr); + int ipAddressRowStatus_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressRowStatus_val_ptr); + int ipAddressStorageType_get(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipAddressStorageType_val_ptr); + + + int + ipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * + tbl_idx, + long ipAddressAddrType_val, + u_char *ipAddressAddr_val_ptr, + size_t + ipAddressAddr_val_ptr_len); + int ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long + ipAddressAddrType_val, + u_char *ipAddressAddr_val_ptr, + size_t + ipAddressAddr_val_ptr_len); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + + + int ipAddressTable_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressTable_undo_cleanup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressTable_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressTable_commit(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressTable_undo_commit(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + + int ipAddressIfIndex_check_value(ipAddressTable_rowreq_ctx + * rowreq_ctx, long + ipAddressIfIndex_val); + + int ipAddressIfIndex_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressIfIndex_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + long ipAddressIfIndex_val); + int ipAddressIfIndex_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int ipAddressType_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressType_val); + int ipAddressType_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressType_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressType_val); + int ipAddressType_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int ipAddressPrefix_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + oid * + ipAddressPrefix_val_ptr, + size_t + ipAddressPrefix_val_ptr_len); + int ipAddressPrefix_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressPrefix_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + oid * ipAddressPrefix_val_ptr, + size_t + ipAddressPrefix_val_ptr_len); + int ipAddressPrefix_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int ipAddressOrigin_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long + ipAddressOrigin_val); + int ipAddressOrigin_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressOrigin_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressOrigin_val); + int ipAddressOrigin_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int ipAddressStatus_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long + ipAddressStatus_val); + int ipAddressStatus_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressStatus_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressStatus_val); + int ipAddressStatus_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int ipAddressCreated_check_value(ipAddressTable_rowreq_ctx + * rowreq_ctx, + u_long + ipAddressCreated_val); + int ipAddressCreated_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressCreated_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressCreated_val); + int ipAddressCreated_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int + ipAddressLastChanged_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressLastChanged_val); + int + ipAddressLastChanged_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressLastChanged_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long + ipAddressLastChanged_val); + int ipAddressLastChanged_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int + ipAddressRowStatus_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressRowStatus_val); + int ipAddressRowStatus_undo_setup(ipAddressTable_rowreq_ctx + * rowreq_ctx); + int ipAddressRowStatus_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressRowStatus_val); + int ipAddressRowStatus_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int + ipAddressStorageType_check_value(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long ipAddressStorageType_val); + int + ipAddressStorageType_undo_setup(ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressStorageType_set(ipAddressTable_rowreq_ctx * + rowreq_ctx, + u_long + ipAddressStorageType_val); + int ipAddressStorageType_undo(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + + int + ipAddressTable_check_dependencies(ipAddressTable_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 /* IPADDRESSTABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h new file mode 100644 index 0000000..7e88550 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h @@ -0,0 +1,213 @@ +/* + * 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 IPADDRESSTABLE_CONSTANTS_H +#define IPADDRESSTABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipAddressTable + */ +#define IPADDRESSTABLE_OID 1,3,6,1,2,1,4,34 + +#define COLUMN_IPADDRESSADDRTYPE 1 + +#define COLUMN_IPADDRESSADDR 2 + +#define COLUMN_IPADDRESSIFINDEX 3 +#define COLUMN_IPADDRESSIFINDEX_FLAG (0x1 << 2) + +#define COLUMN_IPADDRESSTYPE 4 +#define COLUMN_IPADDRESSTYPE_FLAG (0x1 << 3) + +#define COLUMN_IPADDRESSPREFIX 5 + +#define COLUMN_IPADDRESSORIGIN 6 + +#define COLUMN_IPADDRESSSTATUS 7 +#define COLUMN_IPADDRESSSTATUS_FLAG (0x1 << 6) + +#define COLUMN_IPADDRESSCREATED 8 + +#define COLUMN_IPADDRESSLASTCHANGED 9 + +#define COLUMN_IPADDRESSROWSTATUS 10 +#define COLUMN_IPADDRESSROWSTATUS_FLAG (0x1 << 9) + +#define COLUMN_IPADDRESSSTORAGETYPE 11 +#define COLUMN_IPADDRESSSTORAGETYPE_FLAG (0x1 << 10) + + +#define IPADDRESSTABLE_MIN_COL COLUMN_IPADDRESSIFINDEX +#define IPADDRESSTABLE_MAX_COL COLUMN_IPADDRESSSTORAGETYPE + + /* + * TODO:405:r: Review IPADDRESSTABLE_SETTABLE_COLS macro. + * OR together all the writable cols. + */ +#define IPADDRESSTABLE_SETTABLE_COLS (COLUMN_IPADDRESSIFINDEX_FLAG | COLUMN_IPADDRESSTYPE_FLAG | COLUMN_IPADDRESSSTATUS_FLAG | COLUMN_IPADDRESSROWSTATUS_FLAG | COLUMN_IPADDRESSSTORAGETYPE_FLAG) + /* + * TODO:405:r: Review IPADDRESSTABLE_REQUIRED_COLS macro. + * OR together all the required rows for row creation. + * default is writable cols w/out defaults. + */ +#define IPADDRESSTABLE_REQUIRED_COLS (COLUMN_IPADDRESSIFINDEX_FLAG | COLUMN_IPADDRESSROWSTATUS_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 ipAddressTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipAddressAddrType (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 */ + + /* + * TODO:140:o: Define your interal representation of ipAddressAddrType enums. + * (used for value mapping; see notes at top of file) + * + * simplistic map of address length to type + */ +#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4 4 +#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6 16 + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressType (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPADDRESSTYPE_ENUMS +#define IPADDRESSTYPE_ENUMS + +#define IPADDRESSTYPE_UNICAST 1 +#define IPADDRESSTYPE_ANYCAST 2 +#define IPADDRESSTYPE_BROADCAST 3 + +#endif /* IPADDRESSTYPE_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressOrigin (IpAddressOriginTC / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPADDRESSORIGINTC_ENUMS +#define IPADDRESSORIGINTC_ENUMS + +#define IPADDRESSORIGINTC_OTHER 1 +#define IPADDRESSORIGINTC_MANUAL 2 +#define IPADDRESSORIGINTC_DHCP 4 +#define IPADDRESSORIGINTC_LINKLAYER 5 +#define IPADDRESSORIGINTC_RANDOM 6 + +#endif /* IPADDRESSORIGINTC_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressStatus (IpAddressStatusTC / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPADDRESSSTATUSTC_ENUMS +#define IPADDRESSSTATUSTC_ENUMS + +#define IPADDRESSSTATUSTC_PREFERRED 1 +#define IPADDRESSSTATUSTC_DEPRECATED 2 +#define IPADDRESSSTATUSTC_INVALID 3 +#define IPADDRESSSTATUSTC_INACCESSIBLE 4 +#define IPADDRESSSTATUSTC_UNKNOWN 5 +#define IPADDRESSSTATUSTC_TENTATIVE 6 +#define IPADDRESSSTATUSTC_DUPLICATE 7 + +#endif /* IPADDRESSSTATUSTC_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressRowStatus (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 */ + + +/************************************************************* + * constants for enums for the MIB node + * ipAddressStorageType (StorageType / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef STORAGETYPE_ENUMS +#define STORAGETYPE_ENUMS + +#define STORAGETYPE_OTHER 1 +#define STORAGETYPE_VOLATILE 2 +#define STORAGETYPE_NONVOLATILE 3 +#define STORAGETYPE_PERMANENT 4 +#define STORAGETYPE_READONLY 5 + +#endif /* STORAGETYPE_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSTABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c new file mode 100644 index 0000000..d80b3e7 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c @@ -0,0 +1,706 @@ +/* + * 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-features.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* + * include our parent header + */ +#include "ipAddressTable.h" + + +#include "ipAddressTable_data_access.h" + +#include <sys/ioctl.h> +#include <errno.h> + +netsnmp_feature_require(container_lifo) +netsnmp_feature_require(ipaddress_entry_update) + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + +/** + * initialization for ipAddressTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipAddressTable_reg + * Pointer to ipAddressTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipAddressTable_init_data(ipAddressTable_registration * ipAddressTable_reg) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize ipAddressTable data. + */ + + return MFD_SUCCESS; +} /* ipAddressTable_init_data */ + +/** + * container overview + * + */ +/** + * check entry for update + */ +static void +_clear_times(ipAddressTable_rowreq_ctx * rowreq_ctx, void *magic) +{ + rowreq_ctx->ipAddressLastChanged = rowreq_ctx->ipAddressCreated = 0; +} + +/** + * 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 +ipAddressTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_container_init", + "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipAddressTable_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. + */ + /* + * We create a custom container here so we can pre-load it, which + * will result in all new entries with last changed values. we need + * to clear those... We also need to make sure ifIndexes have been + * assigned... + */ + *container_ptr_ptr = + netsnmp_container_find("ipAddressTable:table_container"); + if (NULL != *container_ptr_ptr) { + (*container_ptr_ptr)->container_name = strdup("ipAddressTable"); + ipAddressTable_container_load(*container_ptr_ptr); + CONTAINER_FOR_EACH(*container_ptr_ptr, + (netsnmp_container_obj_func *) _clear_times, + NULL); + } + + if (NULL == cache) { + snmp_log(LOG_ERR, + "bad cache param to ipAddressTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipAddressTable 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. + */ + + /* + * basically, turn off all automatic cache handling except autoload. + */ + cache->flags |= + (NETSNMP_CACHE_DONT_AUTO_RELEASE | NETSNMP_CACHE_DONT_FREE_EXPIRED + | NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD | NETSNMP_CACHE_AUTO_RELOAD + | NETSNMP_CACHE_DONT_INVALIDATE_ON_SET); +} /* ipAddressTable_container_init */ + +/** + * 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 ipAddressTable_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 +ipAddressTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_container_shutdown", + "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipAddressTable_container_shutdown\n"); + return; + } + +} /* ipAddressTable_container_shutdown */ + +/** + * check entry for update + */ +static void +_check_entry_for_updates(ipAddressTable_rowreq_ctx * rowreq_ctx, + void **magic) +{ + netsnmp_container *ipaddress_container = (netsnmp_container*)magic[0]; + netsnmp_container *to_delete = (netsnmp_container*)magic[1]; + + /* + * check for matching entry using secondary index. + */ + netsnmp_ipaddress_entry *ipaddress_entry = (netsnmp_ipaddress_entry*) + CONTAINER_FIND(ipaddress_container, rowreq_ctx->data); + if (NULL == ipaddress_entry) { + DEBUGMSGTL(("ipAddressTable:access", "removing missing entry\n")); + + if (NULL == to_delete) { + magic[1] = to_delete = netsnmp_container_find("lifo"); + if (NULL == to_delete) + snmp_log(LOG_ERR, "couldn't create delete container\n"); + } + if (NULL != to_delete) + CONTAINER_INSERT(to_delete, rowreq_ctx); + } else { + DEBUGMSGTL(("ipAddressTable:access", "updating existing entry\n")); + + /* + * Check for changes & update + */ + if (netsnmp_access_ipaddress_entry_update(rowreq_ctx->data, + ipaddress_entry) > 0) + rowreq_ctx->ipAddressLastChanged = netsnmp_get_agent_uptime(); + + /* + * remove entry from ifcontainer + */ + CONTAINER_REMOVE(ipaddress_container, ipaddress_entry); + netsnmp_access_ipaddress_entry_free(ipaddress_entry); + } +} + +/** + * add new entry + */ +static void +_add_new_entry(netsnmp_ipaddress_entry *ipaddress_entry, + netsnmp_container *container) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx; + + DEBUGMSGTL(("ipAddressTable:access", "creating new entry\n")); + + netsnmp_assert(NULL != ipaddress_entry); + netsnmp_assert(NULL != container); + + /* + * allocate an row context and set the index(es) + */ + rowreq_ctx = ipAddressTable_allocate_rowreq_ctx(ipaddress_entry, NULL); + if ((NULL != rowreq_ctx) && + (MFD_SUCCESS == + ipAddressTable_indexes_set(rowreq_ctx, + ipaddress_entry->ia_address_len, + ipaddress_entry->ia_address, + ipaddress_entry->ia_address_len))) { + if (CONTAINER_INSERT(container, rowreq_ctx) < 0) { + DEBUGMSGTL (("ipAddressTable:access","container insert failed for new entry\n")); + ipAddressTable_release_rowreq_ctx(rowreq_ctx); + return; + } + rowreq_ctx->ipAddressLastChanged = + rowreq_ctx->ipAddressCreated = netsnmp_get_agent_uptime(); + } else { + if (NULL != rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "ipAddressTable cache.\n"); + ipAddressTable_release_rowreq_ctx(rowreq_ctx); + } else { + snmp_log(LOG_ERR, "memory allocation failed while loading " + "ipAddressTable cache.\n"); + netsnmp_access_ipaddress_entry_free(ipaddress_entry); + } + + return; + } + + /*------------------------------------------------------------------- + * handle data that isn't part of the data_access ipaddress structure + */ + rowreq_ctx->ipAddressRowStatus = ROWSTATUS_ACTIVE; +} + +/** + * load initial data + * + * TODO:350:M: Implement ipAddressTable 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 + * ipAddressTable_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 +ipAddressTable_container_load(netsnmp_container *container) +{ + netsnmp_container *ipaddress_container; + void *tmp_ptr[2]; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_cache_load", + "called\n")); + + /* + * TODO:351:M: |-> Load/update data in the ipAddressTable container. + * loop over your ipAddressTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + ipaddress_container = + netsnmp_access_ipaddress_container_load(NULL, + NETSNMP_ACCESS_IPADDRESS_LOAD_ADDL_IDX_BY_ADDR); + /* + * we just got a fresh copy of interface data. compare it to + * what we've already got, and make any adjustments, saving + * missing addresses to be deleted. + */ + tmp_ptr[0] = ipaddress_container->next; + tmp_ptr[1] = NULL; + CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *) + _check_entry_for_updates, tmp_ptr); + + /* + * now add any new interfaces + */ + CONTAINER_FOR_EACH(ipaddress_container, + (netsnmp_container_obj_func *) _add_new_entry, + container); + + /* + * free the container. we've either claimed each entry, or released it, + * so the access function doesn't need to clear the container. + */ + netsnmp_access_ipaddress_container_free(ipaddress_container, + NETSNMP_ACCESS_IPADDRESS_FREE_DONT_CLEAR); + + /* + * remove deleted addresses from table container + */ + if (NULL != tmp_ptr[1]) { + netsnmp_container *tmp_container = + (netsnmp_container *) tmp_ptr[1]; + ipAddressTable_rowreq_ctx *tmp_ctx; + + /* + * this works because the tmp_container is a linked list, + * which can be used like a stack... + */ + while (CONTAINER_SIZE(tmp_container)) { + /* + * get from delete list + */ + tmp_ctx = (ipAddressTable_rowreq_ctx*)CONTAINER_FIRST(tmp_container); + + /* + * release context, delete from table container + */ + CONTAINER_REMOVE(container, tmp_ctx); + ipAddressTable_release_rowreq_ctx(tmp_ctx); + + /* + * pop off delete list + */ + CONTAINER_REMOVE(tmp_container, NULL); + } + } + + DEBUGMSGT(("verbose:ipAddressTable:ipAddressTable_cache_load", + "%lu records\n", (unsigned long)CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} + +/** + * 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 +ipAddressTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_container_free", + "called\n")); + + /* + * TODO:380:M: Free ipAddressTable container data. + */ +} /* ipAddressTable_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 +ipAddressTable_row_prep(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_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; +} /* ipAddressTable_row_prep */ + +/* + * TODO:420:r: Implement ipAddressTable index validation. + */ +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressAddrType + * ipAddressAddrType is subid 1 of ipAddressEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.34.1.1 + * Description: +The address type of ipAddressAddr. + * + * 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 ipAddressAddrType IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of ipAddressAddrType 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 + * ipAddressTable_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 +ipAddressAddrType_check_index(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressAddrType_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check ipAddressTable index ipAddressAddrType. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.ipAddressAddrType) + */ + switch (rowreq_ctx->tbl_idx.ipAddressAddrType) { + + case INETADDRESSTYPE_IPV4: + case INETADDRESSTYPE_IPV6: + break; + + default: + DEBUGMSGT(("ipAddressTable", "illegal addr type\n")); + return MFD_ERROR; + } + + + return MFD_SUCCESS; /* ipAddressAddrType index ok */ +} /* ipAddressAddrType_check_index */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipAddressEntry.ipAddressAddr + * ipAddressAddr is subid 2 of ipAddressEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.4.34.1.2 + * Description: +The IP address to which this entry's addressing information + pertains. The address type of this object is specified in + ipAddressAddrType. + + + Implementors need to be aware that if the size of + ipAddressAddr exceeds 116 octets then OIDS of instances of + columns in this row will have more than 128 sub-identifiers + and cannot be accessed using SNMPv1, SNMPv2c or SNMPv3. + * + * 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 ipAddressAddr IS NOT ACCESSIBLE + * + * + */ +/** + * check validity of ipAddressAddr 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 + * ipAddressTable_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 +ipAddressAddr_check_index(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressAddr_check_index", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:426:M: |-> Check ipAddressTable index ipAddressAddr. + * check that index value in the table context is legal. + * (rowreq_ctx->tbl_index.ipAddressAddr) + */ + switch (rowreq_ctx->tbl_idx.ipAddressAddrType) { + + case INETADDRESSTYPE_IPV4: + if (4 != rowreq_ctx->tbl_idx.ipAddressAddr_len) { + DEBUGMSGT(("ipAddressTable", "bad addr len\n")); + return MFD_ERROR; + } + break; + + case INETADDRESSTYPE_IPV6: + /** xxx-rks: allow 20? */ + if (16 != rowreq_ctx->tbl_idx.ipAddressAddr_len) { + DEBUGMSGT(("ipAddressTable", "bad addr len\n")); + return MFD_ERROR; + } + break; + + default: + return MFD_ERROR; + } + + return MFD_SUCCESS; /* ipAddressAddr index ok */ +} /* ipAddressAddr_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 ipAddressTable_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 +ipAddressTable_validate_index(ipAddressTable_registration * + ipAddressTable_reg, + ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_validate_index", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:430:M: |-> Validate potential ipAddressTable index. + * + * + */ + if ((4 != rowreq_ctx->tbl_idx.ipAddressAddr_len) + && (16 != rowreq_ctx->tbl_idx.ipAddressAddr_len)) { + snmp_log(LOG_WARNING, "invalid index for a new row in the " + "ipAddressTable 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; + } + } else { + memcpy(rowreq_ctx->data->ia_address, rowreq_ctx->tbl_idx.ipAddressAddr, + rowreq_ctx->tbl_idx.ipAddressAddr_len); + rowreq_ctx->data->ia_address_len = rowreq_ctx->tbl_idx.ipAddressAddr_len; + } + + return rc; +} /* ipAddressTable_validate_index */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.h b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.h new file mode 100644 index 0000000..7bcd435 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.h @@ -0,0 +1,79 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef IPADDRESSTABLE_DATA_ACCESS_H +#define IPADDRESSTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ + + + int ipAddressTable_init_data(ipAddressTable_registration * + ipAddressTable_reg); + + + /* + * TODO:180:o: Review ipAddressTable cache timeout. + * The number of seconds before the cache times out + */ +#define IPADDRESSTABLE_CACHE_TIMEOUT 60 + + void ipAddressTable_container_init(netsnmp_container + **container_ptr_ptr, + netsnmp_cache * cache); + void ipAddressTable_container_shutdown(netsnmp_container + *container_ptr); + + int ipAddressTable_container_load(netsnmp_container + *container); + void ipAddressTable_container_free(netsnmp_container + *container); + + int ipAddressTable_cache_load(netsnmp_container + *container); + void ipAddressTable_cache_free(netsnmp_container + *container); + + int ipAddressTable_row_prep(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int + ipAddressTable_validate_index(ipAddressTable_registration * + ipAddressTable_reg, + ipAddressTable_rowreq_ctx * + rowreq_ctx); + int ipAddressAddrType_check_index(ipAddressTable_rowreq_ctx * rowreq_ctx); /* internal */ + int ipAddressAddr_check_index(ipAddressTable_rowreq_ctx * rowreq_ctx); /* internal */ + + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSTABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_interface.c b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_interface.c new file mode 100644 index 0000000..48770b0 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_interface.c @@ -0,0 +1,2092 @@ +/* + * 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 "ipAddressTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipAddressTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(ipAddressTable_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(ipAddressTable_container_size, ipAddressTable_external_access) +netsnmp_feature_child_of(ipAddressTable_registration_set, ipAddressTable_external_access) +netsnmp_feature_child_of(ipAddressTable_registration_get, ipAddressTable_external_access) +netsnmp_feature_child_of(ipAddressTable_container_get, ipAddressTable_external_access) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipAddressTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipAddressTable is subid 34 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.34, length: 8 + */ +typedef struct ipAddressTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + ipAddressTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_int table_dirty; + +} ipAddressTable_interface_ctx; + +static ipAddressTable_interface_ctx ipAddressTable_if_ctx; + +static void _ipAddressTable_container_init(ipAddressTable_interface_ctx + * if_ctx); +static void + _ipAddressTable_container_shutdown(ipAddressTable_interface_ctx * if_ctx); + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_CONTAINER_GET +netsnmp_container * +ipAddressTable_container_get(void) +{ + return ipAddressTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_REGISTRATION_GET +ipAddressTable_registration * +ipAddressTable_registration_get(void) +{ + return ipAddressTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_REGISTRATION_SET +ipAddressTable_registration * +ipAddressTable_registration_set(ipAddressTable_registration * newreg) +{ + ipAddressTable_registration *old = ipAddressTable_if_ctx.user_ctx; + ipAddressTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_CONTAINER_SIZE +int +ipAddressTable_container_size(void) +{ + return CONTAINER_SIZE(ipAddressTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_CONTAINER_SIZE */ + +u_int +ipAddressTable_dirty_get(void) +{ + return ipAddressTable_if_ctx.table_dirty; +} + +void +ipAddressTable_dirty_set(u_int status) +{ + DEBUGMSGTL(("ipAddressTable:ipAddressTable_dirty_set", + "called. was %d, now %d\n", + ipAddressTable_if_ctx.table_dirty, status)); + ipAddressTable_if_ctx.table_dirty = status; +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipAddressTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipAddressTable_post_request; +static Netsnmp_Node_Handler _mfd_ipAddressTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipAddressTable_get_values; +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +static Netsnmp_Node_Handler _mfd_ipAddressTable_check_objects; +static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_setup; +static Netsnmp_Node_Handler _mfd_ipAddressTable_set_values; +static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_values; +static Netsnmp_Node_Handler _mfd_ipAddressTable_commit; +static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_commit; +static Netsnmp_Node_Handler _mfd_ipAddressTable_irreversible_commit; +static Netsnmp_Node_Handler _mfd_ipAddressTable_check_dependencies; + +NETSNMP_STATIC_INLINE int + _ipAddressTable_undo_column(ipAddressTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, + int column); +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + +NETSNMP_STATIC_INLINE int + _ipAddressTable_check_indexes(ipAddressTable_rowreq_ctx * rowreq_ctx); + +/** + * @internal + * Initialize the table ipAddressTable + * (Define its contents and how it's structured) + */ +void +_ipAddressTable_initialize_interface(ipAddressTable_registration * reg_ptr, + u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipAddressTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipAddressTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipAddressTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipAddressAddrType */ + ASN_OCTET_STR, + /** index: ipAddressAddr */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPADDRESSTABLE_MIN_COL; + tbl_info->max_column = IPADDRESSTABLE_MAX_COL; + + /* + * save users context + */ + ipAddressTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipAddressTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipAddressTable_container_init(&ipAddressTable_if_ctx); + if (NULL == ipAddressTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipAddressTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_ipAddressTable_object_lookup; + access_multiplexer->get_values = _mfd_ipAddressTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_ipAddressTable_pre_request; + access_multiplexer->post_request = _mfd_ipAddressTable_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_ipAddressTable_check_objects; + access_multiplexer->undo_setup = _mfd_ipAddressTable_undo_setup; + access_multiplexer->undo_cleanup = _mfd_ipAddressTable_undo_cleanup; + access_multiplexer->set_values = _mfd_ipAddressTable_set_values; + access_multiplexer->undo_sets = _mfd_ipAddressTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_ipAddressTable_commit; + access_multiplexer->undo_commit = _mfd_ipAddressTable_undo_commit; + access_multiplexer->irreversible_commit = + _mfd_ipAddressTable_irreversible_commit; + + /* + * REQUIRED for tables with dependencies + */ + access_multiplexer->consistency_checks = + _mfd_ipAddressTable_check_dependencies; +#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipAddressTable:init_ipAddressTable", + "Registering ipAddressTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipAddressTable", handler, + ipAddressTable_oid, + ipAddressTable_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 ipAddressTable\n"); + return; + } + reginfo->my_reg_void = &ipAddressTable_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, + ipAddressTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != ipAddressTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(ipAddressTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _ipAddressTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipAddressTable + */ +void +_ipAddressTable_shutdown_interface(ipAddressTable_registration * reg_ptr) +{ + /* + * shutdown the container + */ + _ipAddressTable_container_shutdown(&ipAddressTable_if_ctx); +} + +void +ipAddressTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipAddressTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipAddressTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipAddressTable_index_to_oid(netsnmp_index * oid_idx, + ipAddressTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipAddressAddrType; + /* + * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_ipAddressAddr; + + /* + * set up varbinds + */ + memset(&var_ipAddressAddrType, 0x00, sizeof(var_ipAddressAddrType)); + var_ipAddressAddrType.type = ASN_INTEGER; + memset(&var_ipAddressAddr, 0x00, sizeof(var_ipAddressAddr)); + var_ipAddressAddr.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_ipAddressAddrType.next_variable = &var_ipAddressAddr; + var_ipAddressAddr.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_index_to_oid", + "called\n")); + + /* + * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_ipAddressAddrType, + (u_char *) & mib_idx->ipAddressAddrType, + sizeof(mib_idx->ipAddressAddrType)); + + /* + * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + snmp_set_var_value(&var_ipAddressAddr, + (u_char *) & mib_idx->ipAddressAddr, + mib_idx->ipAddressAddr_len * + sizeof(mib_idx->ipAddressAddr[0])); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipAddressAddrType); + 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_ipAddressAddrType); + + return err; +} /* ipAddressTable_index_to_oid */ + +/** + * extract ipAddressTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipAddressTable_index_from_oid(netsnmp_index * oid_idx, + ipAddressTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipAddressAddrType; + /* + * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_ipAddressAddr; + + /* + * set up varbinds + */ + memset(&var_ipAddressAddrType, 0x00, sizeof(var_ipAddressAddrType)); + var_ipAddressAddrType.type = ASN_INTEGER; + memset(&var_ipAddressAddr, 0x00, sizeof(var_ipAddressAddr)); + var_ipAddressAddr.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_ipAddressAddrType.next_variable = &var_ipAddressAddr; + var_ipAddressAddr.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_index_from_oid", + "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipAddressAddrType); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipAddressAddrType = + *((u_long *) var_ipAddressAddrType.val.string); + /* + * NOTE: val_len is in bytes, ipAddressAddr_len might not be + */ + if (var_ipAddressAddr.val_len > sizeof(mib_idx->ipAddressAddr)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->ipAddressAddr, var_ipAddressAddr.val.string, + var_ipAddressAddr.val_len); + mib_idx->ipAddressAddr_len = + var_ipAddressAddr.val_len / + sizeof(mib_idx->ipAddressAddr[0]); + } + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipAddressAddrType); + + return err; +} /* ipAddressTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipAddressTable_rowreq_ctx + */ +ipAddressTable_rowreq_ctx * +ipAddressTable_allocate_rowreq_ctx(ipAddressTable_data * data, + void *user_init_ctx) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipAddressTable_rowreq_ctx); + + DEBUGMSGTL(("internal:ipAddressTable:ipAddressTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipAddressTable_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 = ipAddressTable_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->ipAddressTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipAddressTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { + ipAddressTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipAddressTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipAddressTable_rowreq_ctx + */ +void +ipAddressTable_release_rowreq_ctx(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipAddressTable:ipAddressTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipAddressTable_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)) + ipAddressTable_release_data(rowreq_ctx->data); + + if (rowreq_ctx->undo) + ipAddressTable_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); +} /* ipAddressTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipAddressTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_pre_request", + "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipAddressTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipAddressTable_pre_request(ipAddressTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressTable", "error %d from " + "ipAddressTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipAddressTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_post_request", + "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipAddressTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipAddressTable", + "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) && ipAddressTable_dirty_get()) { + /* + * we shouldn't get here. the undo steps should also clear + * the dirty flags. + */ + snmp_log(LOG_WARNING, + "ipAddressTable dirty flag set in post_request " + "but status != SUCCESS.\n"); + } + + rc = ipAddressTable_post_request(ipAddressTable_if_ctx.user_ctx, + packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressTable", "error %d from " + "ipAddressTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_post_request */ + + +/** + * @internal + * wrapper + */ +static ipAddressTable_rowreq_ctx * +_mfd_ipAddressTable_rowreq_from_index(netsnmp_index * oid_idx, int *rc_ptr) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx; + ipAddressTable_mib_index mib_idx; + int rc; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = ipAddressTable_index_from_oid(oid_idx, &mib_idx); + if (MFD_SUCCESS != *rc_ptr) { + DEBUGMSGT(("ipAddressTable", "error parsing index\n")); + return NULL; + } + + /* + * allocate new context + */ + rowreq_ctx = ipAddressTable_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 = _ipAddressTable_check_indexes(rowreq_ctx); + if (MFD_SUCCESS != *rc_ptr) { + netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) || + (*rc_ptr == SNMP_ERR_INCONSISTENTNAME)); + ipAddressTable_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_ipAddressTable_rowreq_from_index */ + + +/** + * @internal + * wrapper + */ +static int +_mfd_ipAddressTable_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; + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipAddressTable_interface_ctx *if_ctx = + * (ipAddressTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { +#define NETSNMP_IPADDRESSTABLE_CREATE_SUPPORT 1 +#ifndef NETSNMP_IPADDRESSTABLE_CREATE_SUPPORT + rc = SNMP_ERR_NOCREATION; +#else + 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_ipAddressTable_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); + } +#endif + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipAddressTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipAddressTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipAddressTable_get_column(ipAddressTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_get_column", + "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_IPADDRESSIFINDEX: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipAddressIfIndex_get(rowreq_ctx, (long *) var->val.string); + break; + + /* + * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSTYPE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressType_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipAddressPrefix(5)/RowPointer/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/D/h + */ + case COLUMN_IPADDRESSPREFIX: + var->type = ASN_OBJECT_ID; + rc = ipAddressPrefix_get(rowreq_ctx, (oid **) & var->val.string, + &var->val_len); + break; + + /* + * ipAddressOrigin(6)/IpAddressOriginTC/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPADDRESSORIGIN: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressOrigin_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressStatus_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipAddressCreated(8)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPADDRESSCREATED: + var->val_len = sizeof(u_long); + var->type = ASN_TIMETICKS; + rc = ipAddressCreated_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipAddressLastChanged(9)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPADDRESSLASTCHANGED: + var->val_len = sizeof(u_long); + var->type = ASN_TIMETICKS; + rc = ipAddressLastChanged_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPADDRESSROWSTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressRowStatus_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTORAGETYPE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipAddressStorageType_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipAddressTable_get_column\n", + column); + break; + } + + return rc; +} /* _ipAddressTable_get_column */ + +int +_mfd_ipAddressTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = _ipAddressTable_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_ipAddressTable_get_values */ + +NETSNMP_STATIC_INLINE int +_ipAddressTable_check_indexes(ipAddressTable_rowreq_ctx * rowreq_ctx) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_check_indexes", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * (INDEX) ipAddressAddrType(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.ipAddressAddrType != + INETADDRESSTYPE_UNKNOWN) + && (rowreq_ctx->tbl_idx.ipAddressAddrType != INETADDRESSTYPE_IPV4) + && (rowreq_ctx->tbl_idx.ipAddressAddrType != INETADDRESSTYPE_IPV6) + && (rowreq_ctx->tbl_idx.ipAddressAddrType != INETADDRESSTYPE_IPV4Z) + && (rowreq_ctx->tbl_idx.ipAddressAddrType != INETADDRESSTYPE_IPV6Z) + && (rowreq_ctx->tbl_idx.ipAddressAddrType != INETADDRESSTYPE_DNS) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (MFD_SUCCESS != rc) + return rc; + rc = ipAddressAddrType_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * (INDEX) ipAddressAddr(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.ipAddressAddr_len < 0) + || (rowreq_ctx->tbl_idx.ipAddressAddr_len > 255)) + ) { + rc = SNMP_ERR_WRONGLENGTH; + } + if (MFD_SUCCESS != rc) + return rc; + rc = ipAddressAddr_check_index(rowreq_ctx); + if (MFD_SUCCESS != rc) + return SNMP_ERR_NOCREATION; + + /* + * if individual parts look ok, check them as a whole + */ + return ipAddressTable_validate_index(ipAddressTable_if_ctx.user_ctx, + rowreq_ctx); +} /* _ipAddressTable_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 +_ipAddressTable_check_column(ipAddressTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_check_column", + "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + /* + * (INDEX) ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + case COLUMN_IPADDRESSADDRTYPE: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + /* + * (INDEX) ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + case COLUMN_IPADDRESSADDR: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + + /* + * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_IPADDRESSIFINDEX: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check defined range(s). + */ + if ((SNMPERR_SUCCESS == rc) + && ((*var->val.integer < 1) + || (*var->val.integer > 2147483647)) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:_ipAddressTable_check_column:ipAddressIfIndex", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipAddressIfIndex_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 ipAddressIfIndex_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSTYPE: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != IPADDRESSTYPE_UNICAST) + && (*var->val.integer != IPADDRESSTYPE_ANYCAST) + && (*var->val.integer != IPADDRESSTYPE_BROADCAST) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:_ipAddressTable_check_column:ipAddressType", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipAddressType_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 ipAddressType_check_value\n", rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipAddressPrefix(5)/RowPointer/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/D/h + */ + case COLUMN_IPADDRESSPREFIX: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipAddressOrigin(6)/IpAddressOriginTC/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPADDRESSORIGIN: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTATUS: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != IPADDRESSSTATUSTC_PREFERRED) + && (*var->val.integer != IPADDRESSSTATUSTC_INVALID) + && (*var->val.integer != IPADDRESSSTATUSTC_INACCESSIBLE) + && (*var->val.integer != IPADDRESSSTATUSTC_UNKNOWN) + && (*var->val.integer != IPADDRESSSTATUSTC_TENTATIVE) + && (*var->val.integer != IPADDRESSSTATUSTC_DUPLICATE) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:_ipAddressTable_check_column:ipAddressStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipAddressStatus_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 ipAddressStatus_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipAddressCreated(8)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPADDRESSCREATED: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipAddressLastChanged(9)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPADDRESSLASTCHANGED: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPADDRESSROWSTATUS: + rc = netsnmp_check_vb_rowstatus_value(var); + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:_ipAddressTable_check_column:ipAddressRowStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipAddressRowStatus_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 ipAddressRowStatus_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTORAGETYPE: + rc = netsnmp_check_vb_type(var, ASN_INTEGER); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != STORAGETYPE_OTHER) + && (*var->val.integer != STORAGETYPE_VOLATILE) + && (*var->val.integer != STORAGETYPE_NONVOLATILE) + && (*var->val.integer != STORAGETYPE_PERMANENT) + && (*var->val.integer != STORAGETYPE_READONLY) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:_ipAddressTable_check_column:ipAddressStorageType", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipAddressStorageType_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 ipAddressStorageType_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 _ipAddressTable_check_column\n", + column); + } + + return rc; +} /* _ipAddressTable_check_column */ + +int +_mfd_ipAddressTable_check_objects(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = _ipAddressTable_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_ipAddressTable_check_objects */ + + +/*---------------------------------------------------------------------- + * + * SET: check dependencies + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check dependencies wrapper + */ +static int +_mfd_ipAddressTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_check_dependencies", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipAddressTable_check_dependencies(rowreq_ctx); + if (rc) { + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_check_dependencies\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_check_dependencies */ + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipAddressTable_undo_setup_column(ipAddressTable_rowreq_ctx * rowreq_ctx, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_undo_setup_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_IPADDRESSIFINDEX: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSIFINDEX_FLAG; + rc = ipAddressIfIndex_undo_setup(rowreq_ctx); + break; + + /* + * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSTYPE: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSTYPE_FLAG; + rc = ipAddressType_undo_setup(rowreq_ctx); + break; + + /* + * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTATUS: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSSTATUS_FLAG; + rc = ipAddressStatus_undo_setup(rowreq_ctx); + break; + + /* + * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPADDRESSROWSTATUS: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSROWSTATUS_FLAG; + rc = ipAddressRowStatus_undo_setup(rowreq_ctx); + break; + + /* + * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTORAGETYPE: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSSTORAGETYPE_FLAG; + rc = ipAddressStorageType_undo_setup(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipAddressTable_undo_setup_column\n", + column); + break; + } + + return rc; +} /* _ipAddressTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_ipAddressTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_undo_setup", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rowreq_ctx->undo = ipAddressTable_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 = ipAddressTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_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 = _ipAddressTable_undo_setup_column(rowreq_ctx, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_undo_setup_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_ipAddressTable_undo_cleanup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = ipAddressTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + if (rowreq_ctx->undo) { + ipAddressTable_release_data(rowreq_ctx->undo); + rowreq_ctx->undo = NULL; + } + + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipAddressTable_set_column(ipAddressTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_set_column", + "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_IPADDRESSIFINDEX: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSIFINDEX_FLAG; + rc = ipAddressIfIndex_set(rowreq_ctx, *((long *) var->val.string)); + break; + + /* + * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSTYPE: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSTYPE_FLAG; + rc = ipAddressType_set(rowreq_ctx, *((u_long *) var->val.string)); + break; + + /* + * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTATUS: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSSTATUS_FLAG; + rc = ipAddressStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPADDRESSROWSTATUS: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSROWSTATUS_FLAG; + rc = ipAddressRowStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTORAGETYPE: + rowreq_ctx->column_set_flags |= COLUMN_IPADDRESSSTORAGETYPE_FLAG; + rc = ipAddressStorageType_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipAddressTable_set_column\n", + column); + rc = SNMP_ERR_GENERR; + break; + } + + return rc; +} /* _ipAddressTable_set_column */ + +int +_mfd_ipAddressTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = _ipAddressTable_set_column(rowreq_ctx, + requests->requestvb, tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_ipAddressTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_commit", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipAddressTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_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... + */ + ipAddressTable_dirty_set(ipAddressTable_dirty_get() + 1); /* set table dirty flag */ + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_ipAddressTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_undo_commit", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + u_int d = ipAddressTable_dirty_get(); + + netsnmp_assert(d != 0); + if (d) + ipAddressTable_dirty_set(d - 1); + } + + rc = ipAddressTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_undo_commit\n", rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + snmp_log(LOG_WARNING, + "ipAddressTable row dirty flag still set after undo_commit\n"); + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +/** + * @internal + * undo the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipAddressTable_undo_column(ipAddressTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_undo_column", + "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H + */ + case COLUMN_IPADDRESSIFINDEX: + rc = ipAddressIfIndex_undo(rowreq_ctx); + break; + + /* + * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSTYPE: + rc = ipAddressType_undo(rowreq_ctx); + break; + + /* + * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTATUS: + rc = ipAddressStatus_undo(rowreq_ctx); + break; + + /* + * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPADDRESSROWSTATUS: + rc = ipAddressRowStatus_undo(rowreq_ctx); + break; + + /* + * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h + */ + case COLUMN_IPADDRESSSTORAGETYPE: + rc = ipAddressStorageType_undo(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipAddressTable_undo_column\n", + column); + break; + } + + return rc; +} /* _ipAddressTable_undo_column */ + +int +_mfd_ipAddressTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_undo_values", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipAddressTable_undo(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_undo\n", rc)); + } + + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipAddressTable_undo_column(rowreq_ctx, requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipAddressTable:mfd", "error %d from " + "ipAddressTable_undo_column\n", rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_undo_values */ + +/*---------------------------------------------------------------------- + * + * SET: irreversible commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit irreversible actions + */ +int +_mfd_ipAddressTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipAddressTable_rowreq_ctx *rowreq_ctx = (ipAddressTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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(ipAddressTable_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(ipAddressTable_if_ctx.container, rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipAddressTable_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:ipAddressTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for ipAddressTable_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 ipAddressTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipAddressTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in ipAddressTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(ipAddressTable_rowreq_ctx * rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:ipAddressTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipAddressTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:ipAddressTable:_container_free", "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipAddressTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipAddressTable_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 +_ipAddressTable_container_init(ipAddressTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_container_init", + "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + ipAddressTable_oid, + ipAddressTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for ipAddressTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipAddressTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipAddressTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipAddressTable_container_init\n"); + return; + } + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _ipAddressTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipAddressTable_container_shutdown(ipAddressTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_container_shutdown", "called\n")); + + ipAddressTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipAddressTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_EXTERNAL_ACCESS +ipAddressTable_rowreq_ctx * +ipAddressTable_row_find_by_mib_index(ipAddressTable_mib_index * mib_idx) +{ + ipAddressTable_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 = ipAddressTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (ipAddressTable_rowreq_ctx*)CONTAINER_FIND(ipAddressTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPADDRESSTABLE_EXTERNAL_ACCESS */ diff --git a/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_interface.h b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_interface.h new file mode 100644 index 0000000..ac54477 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_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 IPADDRESSTABLE_INTERFACE_H +#define IPADDRESSTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipAddressTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipAddressTable_initialize_interface(ipAddressTable_registration * + user_ctx, u_long flags); + void + _ipAddressTable_shutdown_interface(ipAddressTable_registration * + user_ctx); + + ipAddressTable_registration *ipAddressTable_registration_get(void); + + ipAddressTable_registration + * ipAddressTable_registration_set(ipAddressTable_registration * + newreg); + + netsnmp_container *ipAddressTable_container_get(void); + int ipAddressTable_container_size(void); + + u_int ipAddressTable_dirty_get(void); + void ipAddressTable_dirty_set(u_int status); + + ipAddressTable_rowreq_ctx + * ipAddressTable_allocate_rowreq_ctx(ipAddressTable_data *, + void *); + void + ipAddressTable_release_rowreq_ctx(ipAddressTable_rowreq_ctx * + rowreq_ctx); + + int ipAddressTable_index_to_oid(netsnmp_index * oid_idx, + ipAddressTable_mib_index * + mib_idx); + int ipAddressTable_index_from_oid(netsnmp_index * oid_idx, + ipAddressTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void ipAddressTable_valid_columns_set(netsnmp_column_info + *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* IPADDRESSTABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable.h new file mode 100644 index 0000000..28ed84b --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/ipDefaultRouterTable/ipDefaultRouterTable) diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.c b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.c new file mode 100644 index 0000000..180e317 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.c @@ -0,0 +1,218 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +/** \page MFD helper for ipDefaultRouterTable + * + * \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 "ipDefaultRouterTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipDefaultRouterTable_interface.h" + +const oid ipDefaultRouterTable_oid[] = { IPDEFAULTROUTERTABLE_OID }; +const int ipDefaultRouterTable_oid_size = +OID_LENGTH(ipDefaultRouterTable_oid); + +ipDefaultRouterTable_registration ipDefaultRouterTable_user_context; +static ipDefaultRouterTable_registration *ipDefaultRouterTable_user_context_p; + +void initialize_table_ipDefaultRouterTable(void); +void shutdown_table_ipDefaultRouterTable(void); + + +/** + * Initializes the ipDefaultRouterTable module + */ +void +init_ipDefaultRouterTable(void) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:init_ipDefaultRouterTable", + "called\n")); + + /* + * TODO:300:o: Perform ipDefaultRouterTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipDefaultRouterTable")) + initialize_table_ipDefaultRouterTable(); + +} /* init_ipDefaultRouterTable */ + +/** + * Shut-down the ipDefaultRouterTable module (agent is exiting) + */ +void +shutdown_ipDefaultRouterTable(void) +{ + if (should_init("ipDefaultRouterTable")) + shutdown_table_ipDefaultRouterTable(); + +} + +/** + * Initialize the table ipDefaultRouterTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipDefaultRouterTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:initialize_table_ipDefaultRouterTable", "called\n")); + + /* + * TODO:301:o: Perform ipDefaultRouterTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipDefaultRouterTable 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. + */ + ipDefaultRouterTable_user_context_p = + netsnmp_create_data_list("ipDefaultRouterTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipDefaultRouterTable_initialize_interface + (ipDefaultRouterTable_user_context_p, flags); +} /* initialize_table_ipDefaultRouterTable */ + +/** + * Shutdown the table ipDefaultRouterTable + */ +void +shutdown_table_ipDefaultRouterTable(void) +{ + /* + * call interface shutdown code + */ + _ipDefaultRouterTable_shutdown_interface + (ipDefaultRouterTable_user_context_p); + netsnmp_free_all_list_data(ipDefaultRouterTable_user_context_p); + ipDefaultRouterTable_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 +ipDefaultRouterTable_rowreq_ctx_init(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipDefaultRouterTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* ipDefaultRouterTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipDefaultRouterTable_rowreq_ctx_cleanup(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipDefaultRouterTable rowreq cleanup. + */ + netsnmp_access_defaultrouter_entry_free(rowreq_ctx->data); + rowreq_ctx->data = NULL; +} /* ipDefaultRouterTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipDefaultRouterTable_pre_request(ipDefaultRouterTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform ipDefaultRouterTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipDefaultRouterTable_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 +ipDefaultRouterTable_post_request(ipDefaultRouterTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform ipDefaultRouterTable post-request actions. + */ + + return MFD_SUCCESS; +} /* ipDefaultRouterTable_post_request */ + + +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h new file mode 100644 index 0000000..f2ef29a --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h @@ -0,0 +1,212 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +#ifndef IPDEFAULTROUTERTABLE_H +#define IPDEFAULTROUTERTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/defaultrouter.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-mib/data_access/defaultrouter) +config_require(ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface) +config_require(ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access) +config_require(ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get) + /* *INDENT-ON* */ + + /* + * OID and column number definitions for ipDefaultRouterTable + */ +#include "ipDefaultRouterTable_oids.h" + + /* + * enum definions + */ +#include "ipDefaultRouterTable_enums.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipDefaultRouterTable(void); + void shutdown_ipDefaultRouterTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipDefaultRouterTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipDefaultRouterTable is subid 37 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.37, length: 8 + */ + /* + ********************************************************************* + * 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 ipDefaultRouterTable registration context. + */ + typedef netsnmp_data_list ipDefaultRouterTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipDefaultRouterTable data context structure. + * This structure is used to represent the data for ipDefaultRouterTable. + */ + typedef netsnmp_defaultrouter_entry ipDefaultRouterTable_data; + + + /* + * TODO:120:r: |-> Review ipDefaultRouterTable mib index. + * This structure is used to represent the index for ipDefaultRouterTable. + */ + typedef struct ipDefaultRouterTable_mib_index_s { + + /* + * ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long ipDefaultRouterAddressType; + + /* + * ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + /** 128 - 2(other indexes) - oid length(10) = 115 */ + char ipDefaultRouterAddress[115]; + size_t ipDefaultRouterAddress_len; + + /* + * ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + long ipDefaultRouterIfIndex; + + + } ipDefaultRouterTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipDefaultRouterTable 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! + * Guessing 128 - col/entry(2) - oid len(8) + */ +#define MAX_ipDefaultRouterTable_IDX_LEN 118 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipDefaultRouterTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipDefaultRouterTable_rowreq_ctx pointer. + */ + typedef struct ipDefaultRouterTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipDefaultRouterTable_IDX_LEN]; + + ipDefaultRouterTable_mib_index tbl_idx; + + ipDefaultRouterTable_data *data; + + /* + * 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 ipDefaultRouterTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *ipDefaultRouterTable_data_list; + + } ipDefaultRouterTable_rowreq_ctx; + + typedef struct ipDefaultRouterTable_ref_rowreq_ctx_s { + ipDefaultRouterTable_rowreq_ctx *rowreq_ctx; + } ipDefaultRouterTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + ipDefaultRouterTable_pre_request(ipDefaultRouterTable_registration + * user_context); + int + ipDefaultRouterTable_post_request(ipDefaultRouterTable_registration + * user_context, int rc); + + int + ipDefaultRouterTable_rowreq_ctx_init + (ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, + void *user_init_ctx); + void + ipDefaultRouterTable_rowreq_ctx_cleanup + (ipDefaultRouterTable_rowreq_ctx * rowreq_ctx); + + ipDefaultRouterTable_data *ipDefaultRouterTable_allocate_data(void); + void + ipDefaultRouterTable_release_data(ipDefaultRouterTable_data * + data); + + + ipDefaultRouterTable_rowreq_ctx + *ipDefaultRouterTable_row_find_by_mib_index + (ipDefaultRouterTable_mib_index * mib_idx); + + extern const oid ipDefaultRouterTable_oid[]; + extern const int ipDefaultRouterTable_oid_size; + + +#include "ipDefaultRouterTable_interface.h" +#include "ipDefaultRouterTable_data_access.h" +#include "ipDefaultRouterTable_data_get.h" + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* IPDEFAULTROUTERTABLE_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.c b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.c new file mode 100644 index 0000000..7d7dcfe --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.c @@ -0,0 +1,423 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +/* + * 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 "ipDefaultRouterTable.h" + + +#include "ipDefaultRouterTable_data_access.h" + +netsnmp_feature_require(container_lifo) + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipDefaultRouterTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipDefaultRouterTable is subid 37 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.37, length: 8 + */ + +/** + * initialization for ipDefaultRouterTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipDefaultRouterTable_reg + * Pointer to ipDefaultRouterTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipDefaultRouterTable_init_data(ipDefaultRouterTable_registration * + ipDefaultRouterTable_reg) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_init_data", "called\n")); + + /* + * TODO:303:o: Initialize ipDefaultRouterTable data. + */ + + return MFD_SUCCESS; +} /* ipDefaultRouterTable_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 +ipDefaultRouterTable_container_init(netsnmp_container ** container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipDefaultRouterTable_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 ipDefaultRouterTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipDefaultRouterTable 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 = IPDEFAULTROUTERTABLE_CACHE_TIMEOUT; /* seconds */ +} /* ipDefaultRouterTable_container_init */ + +/** + * 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 ipDefaultRouterTable_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 +ipDefaultRouterTable_container_shutdown(netsnmp_container * container_ptr) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipDefaultRouterTable_container_shutdown\n"); + return; + } + +} /* ipDefaultRouterTable_container_shutdown */ + +/** + * check entry for update + */ +static void +_check_entry_for_updates(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, + void **magic) +{ + netsnmp_container *defaultrouter_container = magic[0]; + netsnmp_container *to_delete = (netsnmp_container *) magic[1]; + + /* + * check for matching entry using secondary index. + */ + netsnmp_defaultrouter_entry *defaultrouter_entry = + CONTAINER_FIND(defaultrouter_container, rowreq_ctx->data); + if (NULL == defaultrouter_entry) { + DEBUGMSGTL(("ipDefaultRouterTable:access", "removing missing entry\n")); + + if (NULL == to_delete) { + magic[1] = to_delete = netsnmp_container_find("lifo"); + if (NULL == to_delete) + snmp_log(LOG_ERR, "couldn't create delete container\n"); + } + if (NULL != to_delete) + CONTAINER_INSERT(to_delete, rowreq_ctx); + } else { + DEBUGMSGTL(("ipDefaultRouterTable:access", "updating existing entry\n")); + + /* + * Check for changes & update + */ + netsnmp_access_defaultrouter_entry_update(rowreq_ctx->data, + defaultrouter_entry); + + /* + * remove entry from ifcontainer + */ + CONTAINER_REMOVE(defaultrouter_container, defaultrouter_entry); + netsnmp_access_defaultrouter_entry_free(defaultrouter_entry); + } +} + +/** + * add new entry + */ +static void +_add_new_entry(netsnmp_defaultrouter_entry *defaultrouter_entry, + netsnmp_container *container) +{ + ipDefaultRouterTable_rowreq_ctx *rowreq_ctx; + + DEBUGMSGTL(("ipDefaultRouterTable:access", "creating new entry\n")); + + netsnmp_assert(NULL != defaultrouter_entry); + netsnmp_assert(NULL != container); + + /* + * allocate an row context and set the index(es) + */ + rowreq_ctx = ipDefaultRouterTable_allocate_rowreq_ctx(defaultrouter_entry, + NULL); + if ((NULL != rowreq_ctx) && + (MFD_SUCCESS == + ipDefaultRouterTable_indexes_set(rowreq_ctx, + defaultrouter_entry->dr_addresstype, + defaultrouter_entry->dr_address, + defaultrouter_entry->dr_address_len, + defaultrouter_entry->dr_if_index))) { + if (CONTAINER_INSERT(container, rowreq_ctx) < 0) { + DEBUGMSGTL(("ipAddressTable:access", + "container insert failed for new entry\n")); + ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx); + return; + } + } else { + if (NULL != rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "ipDefaultRouterTable cache.\n"); + ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx); + } else { + snmp_log(LOG_ERR, "memory allocation failed while loading " + "ipDefaultRouterTable cache.\n"); + netsnmp_access_defaultrouter_entry_free(defaultrouter_entry); + } + + return; + } +} + +/** + * load initial data + * + * TODO:350:M: Implement ipDefaultRouterTable 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 + * ipDefaultRouterTable_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 +ipDefaultRouterTable_container_load(netsnmp_container * container) +{ + netsnmp_container *defaultrouter_container; + void *tmp_ptr[2]; + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_container_load", "called\n")); + + /* + * TODO:351:M: |-> Load/update data in the ipDefaultRouterTable container. + * loop over your ipDefaultRouterTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + defaultrouter_container = + netsnmp_access_defaultrouter_container_load(NULL, + NETSNMP_ACCESS_DEFAULTROUTER_LOAD_ADDL_IDX_BY_ADDR); + + if (NULL == defaultrouter_container) + return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */ + + /* + * we just got a fresh copy of interface data. compare it to + * what we've already got, and make any adjustments, saving + * missing addresses to be deleted. + */ + tmp_ptr[0] = defaultrouter_container->next; + tmp_ptr[1] = NULL; + CONTAINER_FOR_EACH(container, + (netsnmp_container_obj_func *) _check_entry_for_updates, + tmp_ptr); + + /* + * now add any new interfaces + */ + CONTAINER_FOR_EACH(defaultrouter_container, + (netsnmp_container_obj_func *) _add_new_entry, + container); + + /* + * free the container. we've either claimed each entry, or released it, + * so the access function doesn't need to clear the container. + */ + netsnmp_access_defaultrouter_container_free(defaultrouter_container, + NETSNMP_ACCESS_DEFAULTROUTER_FREE_DONT_CLEAR); + + /* + * remove deleted addresses from table container + */ + if (NULL != tmp_ptr[1]) { + netsnmp_container *tmp_container = + (netsnmp_container *) tmp_ptr[1]; + ipDefaultRouterTable_rowreq_ctx *tmp_ctx; + + /* + * this works because the tmp_container is a linked list, + * which can be used like a stack... + */ + while (CONTAINER_SIZE(tmp_container)) { + /* + * get from delete list + */ + tmp_ctx = CONTAINER_FIRST(tmp_container); + + /* + * release context, delete from table container + */ + CONTAINER_REMOVE(container, tmp_ctx); + ipDefaultRouterTable_release_rowreq_ctx(tmp_ctx); + + /* + * pop off delete list + */ + CONTAINER_REMOVE(tmp_container, NULL); + } + } + + DEBUGMSGT(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_container_load", + "%" NETSNMP_PRIz "d records\n", CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} + +/** + * 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 +ipDefaultRouterTable_container_free(netsnmp_container * container) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_container_free", "called\n")); + + /* + * TODO:380:M: Free ipDefaultRouterTable container data. + */ +} /* ipDefaultRouterTable_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 +ipDefaultRouterTable_row_prep(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_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; +} /* ipDefaultRouterTable_row_prep */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.h new file mode 100644 index 0000000..ed033f0 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_access.h @@ -0,0 +1,76 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +#ifndef IPDEFAULTROUTERTABLE_DATA_ACCESS_H +#define IPDEFAULTROUTERTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipDefaultRouterTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipDefaultRouterTable is subid 37 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.37, length: 8 + */ + + + int + ipDefaultRouterTable_init_data(ipDefaultRouterTable_registration * + ipDefaultRouterTable_reg); + + + /* + * TODO:180:o: Review ipDefaultRouterTable cache timeout. + * The number of seconds before the cache times out + */ +#define IPDEFAULTROUTERTABLE_CACHE_TIMEOUT 60 + + void ipDefaultRouterTable_container_init(netsnmp_container + ** + container_ptr_ptr, + netsnmp_cache * + cache); + void + ipDefaultRouterTable_container_shutdown(netsnmp_container * + container_ptr); + + int ipDefaultRouterTable_container_load(netsnmp_container * + container); + void ipDefaultRouterTable_container_free(netsnmp_container * + container); + + int ipDefaultRouterTable_cache_load(netsnmp_container * + container); + void ipDefaultRouterTable_cache_free(netsnmp_container * + container); + int + ipDefaultRouterTable_row_prep(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx); + + + +#ifdef __cplusplus +} +#endif +#endif /* IPDEFAULTROUTERTABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.c b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.c new file mode 100644 index 0000000..1177897 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.c @@ -0,0 +1,325 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 12088 $ of $ + * + * $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 "ipDefaultRouterTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement ipDefaultRouterTable get routines. + * TODO:240:M: Implement ipDefaultRouterTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipDefaultRouterTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipDefaultRouterTable is subid 37 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.37, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipDefaultRouterTable data context functions. + */ +/* + * ipDefaultRouterTable_allocate_data + * + * Purpose: create new ipDefaultRouterTable_data. + */ +ipDefaultRouterTable_data * +ipDefaultRouterTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the ipDefaultRouterTable data context. + */ + ipDefaultRouterTable_data *rtn = + netsnmp_access_defaultrouter_entry_create(); + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_allocate_data", "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipDefaultRouterTable_data.\n"); + } + + return rtn; +} /* ipDefaultRouterTable_allocate_data */ + +/* + * ipDefaultRouterTable_release_data + * + * Purpose: release ipDefaultRouterTable data. + */ +void +ipDefaultRouterTable_release_data(ipDefaultRouterTable_data * data) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_release_data", "called\n")); + + /* + * TODO:202:r: |-> release memory for the ipDefaultRouterTable data context. + */ + netsnmp_access_defaultrouter_entry_free(data); +} /* ipDefaultRouterTable_release_data */ + + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipDefaultRouterAddressType_val + * @param ipDefaultRouterAddress_ptr + * @param ipDefaultRouterAddress_ptr_len + * @param ipDefaultRouterIfIndex_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 +ipDefaultRouterTable_indexes_set_tbl_idx(ipDefaultRouterTable_mib_index * + tbl_idx, + u_long + ipDefaultRouterAddressType_val, + char + *ipDefaultRouterAddress_val_ptr, + size_t + ipDefaultRouterAddress_val_ptr_len, + long ipDefaultRouterIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_defaultrouter_entry */ + tbl_idx->ipDefaultRouterAddressType = ipDefaultRouterAddressType_val; + + /* + * ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + tbl_idx->ipDefaultRouterAddress_len = sizeof(tbl_idx->ipDefaultRouterAddress) / sizeof(tbl_idx->ipDefaultRouterAddress[0]); /* max length */ + /** WARNING: this code might not work for netsnmp_defaultrouter_entry */ + /* + * make sure there is enough space for ipDefaultRouterAddress data + */ + if ((NULL == tbl_idx->ipDefaultRouterAddress) || + (tbl_idx->ipDefaultRouterAddress_len < + (ipDefaultRouterAddress_val_ptr_len))) { + snmp_log(LOG_ERR, "not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->ipDefaultRouterAddress_len = + ipDefaultRouterAddress_val_ptr_len; + memcpy(tbl_idx->ipDefaultRouterAddress, ipDefaultRouterAddress_val_ptr, + ipDefaultRouterAddress_val_ptr_len * + sizeof(ipDefaultRouterAddress_val_ptr[0])); + + /* + * ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + /** WARNING: this code might not work for netsnmp_defaultrouter_entry */ + tbl_idx->ipDefaultRouterIfIndex = ipDefaultRouterIfIndex_val; + + + return MFD_SUCCESS; +} /* ipDefaultRouterTable_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 +ipDefaultRouterTable_indexes_set(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx, + u_long ipDefaultRouterAddressType_val, + char *ipDefaultRouterAddress_val_ptr, + size_t ipDefaultRouterAddress_val_ptr_len, + long ipDefaultRouterIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_indexes_set", "called\n")); + + if (MFD_SUCCESS != + ipDefaultRouterTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipDefaultRouterAddressType_val, + ipDefaultRouterAddress_val_ptr, + ipDefaultRouterAddress_val_ptr_len, + ipDefaultRouterIfIndex_val)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != ipDefaultRouterTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipDefaultRouterTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipDefaultRouterEntry.ipDefaultRouterLifetime + * ipDefaultRouterLifetime is subid 4 of ipDefaultRouterEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.37.1.4 + * Description: +The remaining length of time, in seconds, that this router + will continue to be useful as a default router. A value of + zero indicates that it is no longer useful as a default + router. It is left to the implementer of the MIB as to + whether a router with a lifetime of zero is removed from the + list. + + For IPv6, this value should be extracted from the router + advertisement messages. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 0 - 65535; + * + * Its syntax is UNSIGNED32 (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 ipDefaultRouterLifetime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipDefaultRouterLifetime_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 +ipDefaultRouterLifetime_get(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, + u_long * ipDefaultRouterLifetime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipDefaultRouterLifetime_val_ptr); + + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterLifetime_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipDefaultRouterLifetime data. + * copy (* ipDefaultRouterLifetime_val_ptr ) from rowreq_ctx->data + */ + (*ipDefaultRouterLifetime_val_ptr) = rowreq_ctx->data->dr_lifetime; + + return MFD_SUCCESS; +} /* ipDefaultRouterLifetime_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipDefaultRouterEntry.ipDefaultRouterPreference + * ipDefaultRouterPreference is subid 5 of ipDefaultRouterEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.37.1.5 + * Description: +An indication of preference given to this router as a + default router as described in he Default Router + Preferences document. Treating the value as a + 2 bit signed integer allows for simple arithmetic + comparisons. + + For IPv4 routers or IPv6 routers that are not using the + updated router advertisement format, this object is set to + medium (0). + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 3/8. Values: reserved(-2), low(-1), medium(0), high(1) + * + * 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 ipDefaultRouterPreference data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipDefaultRouterPreference_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 +ipDefaultRouterPreference_get(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, + u_long * ipDefaultRouterPreference_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipDefaultRouterPreference_val_ptr); + + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterPreference_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipDefaultRouterPreference data. + * copy (* ipDefaultRouterPreference_val_ptr ) from rowreq_ctx->data + */ + (*ipDefaultRouterPreference_val_ptr) = rowreq_ctx->data->dr_preference; + + return MFD_SUCCESS; +} /* ipDefaultRouterPreference_get */ + + + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.h new file mode 100644 index 0000000..8698675 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_data_get.h @@ -0,0 +1,84 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 12088 $ of $ + * + * $Id:$ + * + * @file ipDefaultRouterTable_data_get.h + * + * @addtogroup get + * + * Prototypes for get functions + * + * @{ + */ +#ifndef IPDEFAULTROUTERTABLE_DATA_GET_H +#define IPDEFAULTROUTERTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipDefaultRouterTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipDefaultRouterTable is subid 37 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.37, length: 8 + */ + /* + * indexes + */ + + int + ipDefaultRouterLifetime_get(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipDefaultRouterLifetime_val_ptr); + int + ipDefaultRouterPreference_get(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipDefaultRouterPreference_val_ptr); + + + int + ipDefaultRouterTable_indexes_set_tbl_idx + (ipDefaultRouterTable_mib_index * tbl_idx, + u_long ipDefaultRouterAddressType_val, + char *ipDefaultRouterAddress_val_ptr, + size_t ipDefaultRouterAddress_val_ptr_len, + long ipDefaultRouterIfIndex_val); + int + ipDefaultRouterTable_indexes_set(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx, + u_long + ipDefaultRouterAddressType_val, + char + *ipDefaultRouterAddress_val_ptr, + size_t + ipDefaultRouterAddress_val_ptr_len, + long ipDefaultRouterIfIndex_val); + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPDEFAULTROUTERTABLE_DATA_GET_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_enums.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_enums.h new file mode 100644 index 0000000..bb46d10 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_enums.h @@ -0,0 +1,93 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c 12526 2005-07-15 22:41:16Z rstory $ + * + * $Id:$ + */ +#ifndef IPDEFAULTROUTERTABLE_ENUMS_H +#define IPDEFAULTROUTERTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * 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 ipDefaultRouterTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipDefaultRouterLifetime (UNSIGNED32 / ASN_UNSIGNED) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPDEFAULTROUTERLIFETIME_ENUMS +#define IPDEFAULTROUTERLIFETIME_ENUMS + +#define IPDEFAULTROUTERLIFETIME_MIN 0 +#define IPDEFAULTROUTERLIFETIME_MAX 0xFFFFFFFFUL + +#endif /* IPDEFAULTROUTERLIFETIME_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipDefaultRouterAddressType (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 + * ipDefaultRouterPreference (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPDEFAULTROUTERPREFERENCE_ENUMS +#define IPDEFAULTROUTERPREFERENCE_ENUMS + +#define IPDEFAULTROUTERPREFERENCE_RESERVED -2 +#define IPDEFAULTROUTERPREFERENCE_LOW -1 +#define IPDEFAULTROUTERPREFERENCE_MEDIUM 0 +#define IPDEFAULTROUTERPREFERENCE_HIGH 1 + +#endif /* IPDEFAULTROUTERPREFERENCE_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPDEFAULTROUTERTABLE_ENUMS_H */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.c b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.c new file mode 100644 index 0000000..40ad72b --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.c @@ -0,0 +1,1026 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 15899 $ of $ + * + * $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 "ipDefaultRouterTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipDefaultRouterTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(check_all_requests_error) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipDefaultRouterTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipDefaultRouterTable is subid 37 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.37, length: 8 + */ +typedef struct ipDefaultRouterTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + ipDefaultRouterTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} ipDefaultRouterTable_interface_ctx; + +static ipDefaultRouterTable_interface_ctx ipDefaultRouterTable_if_ctx; + +static void +_ipDefaultRouterTable_container_init(ipDefaultRouterTable_interface_ctx * + if_ctx); +static void +_ipDefaultRouterTable_container_shutdown(ipDefaultRouterTable_interface_ctx + * if_ctx); + + +netsnmp_container * +ipDefaultRouterTable_container_get(void) +{ + return ipDefaultRouterTable_if_ctx.container; +} + +ipDefaultRouterTable_registration * +ipDefaultRouterTable_registration_get(void) +{ + return ipDefaultRouterTable_if_ctx.user_ctx; +} + +ipDefaultRouterTable_registration * +ipDefaultRouterTable_registration_set(ipDefaultRouterTable_registration * + newreg) +{ + ipDefaultRouterTable_registration *old = + ipDefaultRouterTable_if_ctx.user_ctx; + ipDefaultRouterTable_if_ctx.user_ctx = newreg; + return old; +} + +int +ipDefaultRouterTable_container_size(void) +{ + return CONTAINER_SIZE(ipDefaultRouterTable_if_ctx.container); +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipDefaultRouterTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipDefaultRouterTable_post_request; +static Netsnmp_Node_Handler _mfd_ipDefaultRouterTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipDefaultRouterTable_get_values; +/** + * @internal + * Initialize the table ipDefaultRouterTable + * (Define its contents and how it's structured) + */ +void +_ipDefaultRouterTable_initialize_interface + (ipDefaultRouterTable_registration * reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipDefaultRouterTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipDefaultRouterTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_ipDefaultRouterTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipDefaultRouterTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipDefaultRouterAddressType */ + ASN_OCTET_STR, + /** index: ipDefaultRouterAddress */ + ASN_INTEGER, + /** index: ipDefaultRouterIfIndex */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPDEFAULTROUTERTABLE_MIN_COL; + tbl_info->max_column = IPDEFAULTROUTERTABLE_MAX_COL; + + /* + * save users context + */ + ipDefaultRouterTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipDefaultRouterTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipDefaultRouterTable_container_init(&ipDefaultRouterTable_if_ctx); + if (NULL == ipDefaultRouterTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipDefaultRouterTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipDefaultRouterTable_object_lookup; + access_multiplexer->get_values = _mfd_ipDefaultRouterTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = + _mfd_ipDefaultRouterTable_pre_request; + access_multiplexer->post_request = + _mfd_ipDefaultRouterTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipDefaultRouterTable:init_ipDefaultRouterTable", + "Registering ipDefaultRouterTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipDefaultRouterTable", + handler, + ipDefaultRouterTable_oid, + ipDefaultRouterTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY); + if (NULL == reginfo) { + snmp_log(LOG_ERR, + "error registering table ipDefaultRouterTable\n"); + return; + } + reginfo->my_reg_void = &ipDefaultRouterTable_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)) + /* XXX - are these actually necessary? */ + 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, + ipDefaultRouterTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != ipDefaultRouterTable_if_ctx.cache) { + handler = + netsnmp_cache_handler_get(ipDefaultRouterTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _ipDefaultRouterTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipDefaultRouterTable + */ +void +_ipDefaultRouterTable_shutdown_interface(ipDefaultRouterTable_registration + * reg_ptr) +{ + /* + * shutdown the container + */ + _ipDefaultRouterTable_container_shutdown(&ipDefaultRouterTable_if_ctx); +} + +void +ipDefaultRouterTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipDefaultRouterTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipDefaultRouterTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipDefaultRouterTable_index_to_oid(netsnmp_index * oid_idx, + ipDefaultRouterTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipDefaultRouterAddressType; + /* + * ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_ipDefaultRouterAddress; + /* + * ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipDefaultRouterIfIndex; + + /* + * set up varbinds + */ + memset(&var_ipDefaultRouterAddressType, 0x00, + sizeof(var_ipDefaultRouterAddressType)); + var_ipDefaultRouterAddressType.type = ASN_INTEGER; + memset(&var_ipDefaultRouterAddress, 0x00, + sizeof(var_ipDefaultRouterAddress)); + var_ipDefaultRouterAddress.type = ASN_OCTET_STR; + memset(&var_ipDefaultRouterIfIndex, 0x00, + sizeof(var_ipDefaultRouterIfIndex)); + var_ipDefaultRouterIfIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipDefaultRouterAddressType.next_variable = + &var_ipDefaultRouterAddress; + var_ipDefaultRouterAddress.next_variable = &var_ipDefaultRouterIfIndex; + var_ipDefaultRouterIfIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_index_to_oid", "called\n")); + + /* + * ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_ipDefaultRouterAddressType, + (u_char *) & mib_idx->ipDefaultRouterAddressType, + sizeof(mib_idx->ipDefaultRouterAddressType)); + + /* + * ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + snmp_set_var_value(&var_ipDefaultRouterAddress, + (u_char *) & mib_idx->ipDefaultRouterAddress, + mib_idx->ipDefaultRouterAddress_len * + sizeof(mib_idx->ipDefaultRouterAddress[0])); + + /* + * ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_ipDefaultRouterIfIndex, + (u_char *) & mib_idx->ipDefaultRouterIfIndex, + sizeof(mib_idx->ipDefaultRouterIfIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipDefaultRouterAddressType); + 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_ipDefaultRouterAddressType); + + return err; +} /* ipDefaultRouterTable_index_to_oid */ + +/** + * extract ipDefaultRouterTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipDefaultRouterTable_index_from_oid(netsnmp_index * oid_idx, + ipDefaultRouterTable_mib_index * + mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipDefaultRouterAddressType; + /* + * ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h + */ + netsnmp_variable_list var_ipDefaultRouterAddress; + /* + * ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipDefaultRouterIfIndex; + + /* + * set up varbinds + */ + memset(&var_ipDefaultRouterAddressType, 0x00, + sizeof(var_ipDefaultRouterAddressType)); + var_ipDefaultRouterAddressType.type = ASN_INTEGER; + memset(&var_ipDefaultRouterAddress, 0x00, + sizeof(var_ipDefaultRouterAddress)); + var_ipDefaultRouterAddress.type = ASN_OCTET_STR; + memset(&var_ipDefaultRouterIfIndex, 0x00, + sizeof(var_ipDefaultRouterIfIndex)); + var_ipDefaultRouterIfIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipDefaultRouterAddressType.next_variable = + &var_ipDefaultRouterAddress; + var_ipDefaultRouterAddress.next_variable = &var_ipDefaultRouterIfIndex; + var_ipDefaultRouterIfIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_index_from_oid", "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipDefaultRouterAddressType); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipDefaultRouterAddressType = + *((u_long *) var_ipDefaultRouterAddressType.val.string); + /* + * NOTE: val_len is in bytes, ipDefaultRouterAddress_len might not be + */ + if (var_ipDefaultRouterAddress.val_len > + sizeof(mib_idx->ipDefaultRouterAddress)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->ipDefaultRouterAddress, + var_ipDefaultRouterAddress.val.string, + var_ipDefaultRouterAddress.val_len); + mib_idx->ipDefaultRouterAddress_len = + var_ipDefaultRouterAddress.val_len / + sizeof(mib_idx->ipDefaultRouterAddress[0]); + } + mib_idx->ipDefaultRouterIfIndex = + *((long *) var_ipDefaultRouterIfIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipDefaultRouterAddressType); + + return err; +} /* ipDefaultRouterTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipDefaultRouterTable_rowreq_ctx + */ +ipDefaultRouterTable_rowreq_ctx * +ipDefaultRouterTable_allocate_rowreq_ctx(ipDefaultRouterTable_data * data, + void *user_init_ctx) +{ + ipDefaultRouterTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipDefaultRouterTable_rowreq_ctx); + + DEBUGMSGTL(("internal:ipDefaultRouterTable:ipDefaultRouterTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipDefaultRouterTable_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 = + ipDefaultRouterTable_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->ipDefaultRouterTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipDefaultRouterTable_rowreq_ctx_init(rowreq_ctx, + user_init_ctx)) { + ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipDefaultRouterTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipDefaultRouterTable_rowreq_ctx + */ +void +ipDefaultRouterTable_release_rowreq_ctx(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipDefaultRouterTable:ipDefaultRouterTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipDefaultRouterTable_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)) + ipDefaultRouterTable_release_data(rowreq_ctx->data); + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* ipDefaultRouterTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipDefaultRouterTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_mfd_ipDefaultRouterTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipDefaultRouterTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipDefaultRouterTable_pre_request(ipDefaultRouterTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipDefaultRouterTable", "error %d from " + "ipDefaultRouterTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipDefaultRouterTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipDefaultRouterTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipDefaultRouterTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_mfd_ipDefaultRouterTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipDefaultRouterTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + rc = ipDefaultRouterTable_post_request(ipDefaultRouterTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipDefaultRouterTable", "error %d from " + "ipDefaultRouterTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipDefaultRouterTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipDefaultRouterTable_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; + ipDefaultRouterTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_mfd_ipDefaultRouterTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipDefaultRouterTable_interface_ctx *if_ctx = + * (ipDefaultRouterTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + rc = SNMP_ERR_NOCREATION; + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipDefaultRouterTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipDefaultRouterTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipDefaultRouterTable_get_column(ipDefaultRouterTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_mfd_ipDefaultRouterTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipDefaultRouterLifetime(4)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/R/d/h + */ + case COLUMN_IPDEFAULTROUTERLIFETIME: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipDefaultRouterLifetime_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipDefaultRouterPreference(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + case COLUMN_IPDEFAULTROUTERPREFERENCE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipDefaultRouterPreference_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + if (IPDEFAULTROUTERTABLE_MIN_COL <= column + && column <= IPDEFAULTROUTERTABLE_MAX_COL) { + DEBUGMSGTL(("internal:ipDefaultRouterTable:_mfd_ipDefaultRouterTable_get_column", "assume column %d is reserved\n", column)); + rc = MFD_SKIP; + } else { + snmp_log(LOG_ERR, + "unknown column %d in _ipDefaultRouterTable_get_column\n", + column); + } + break; + } + + return rc; +} /* _ipDefaultRouterTable_get_column */ + +int +_mfd_ipDefaultRouterTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipDefaultRouterTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_mfd_ipDefaultRouterTable_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 = _ipDefaultRouterTable_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_ipDefaultRouterTable_get_values */ + + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * SET PROCESSING NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +static void _container_free(netsnmp_container * container); + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:ipDefaultRouterTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for ipDefaultRouterTable_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 ipDefaultRouterTable_container_load((netsnmp_container *) + cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipDefaultRouterTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in ipDefaultRouterTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:ipDefaultRouterTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container * container) +{ + DEBUGMSGTL(("internal:ipDefaultRouterTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipDefaultRouterTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipDefaultRouterTable_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 +_ipDefaultRouterTable_container_init(ipDefaultRouterTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipDefaultRouterTable:_ipDefaultRouterTable_container_init", "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + ipDefaultRouterTable_oid, + ipDefaultRouterTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, + "error creating cache for ipDefaultRouterTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipDefaultRouterTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipDefaultRouterTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipDefaultRouterTable_container_init\n"); + return; + } + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _ipDefaultRouterTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipDefaultRouterTable_container_shutdown(ipDefaultRouterTable_interface_ctx + * if_ctx) +{ + DEBUGMSGTL(("internal:ipDefaultRouterTable:_ipDefaultRouterTable_container_shutdown", "called\n")); + + ipDefaultRouterTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipDefaultRouterTable_container_shutdown */ + + +ipDefaultRouterTable_rowreq_ctx * +ipDefaultRouterTable_row_find_by_mib_index(ipDefaultRouterTable_mib_index * + mib_idx) +{ + ipDefaultRouterTable_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 = ipDefaultRouterTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = + CONTAINER_FIND(ipDefaultRouterTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.h new file mode 100644 index 0000000..a780491 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_interface.h @@ -0,0 +1,99 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 15899 $ of $ + * + * $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 IPDEFAULTROUTERTABLE_INTERFACE_H +#define IPDEFAULTROUTERTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipDefaultRouterTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipDefaultRouterTable_initialize_interface + (ipDefaultRouterTable_registration * user_ctx, u_long flags); + void + _ipDefaultRouterTable_shutdown_interface + (ipDefaultRouterTable_registration * user_ctx); + + ipDefaultRouterTable_registration + *ipDefaultRouterTable_registration_get(void); + + ipDefaultRouterTable_registration + *ipDefaultRouterTable_registration_set + (ipDefaultRouterTable_registration * newreg); + + netsnmp_container *ipDefaultRouterTable_container_get(void); + int ipDefaultRouterTable_container_size(void); + + ipDefaultRouterTable_rowreq_ctx + *ipDefaultRouterTable_allocate_rowreq_ctx(ipDefaultRouterTable_data + *, void *); + void + ipDefaultRouterTable_release_rowreq_ctx + (ipDefaultRouterTable_rowreq_ctx * rowreq_ctx); + + int ipDefaultRouterTable_index_to_oid(netsnmp_index * + oid_idx, + ipDefaultRouterTable_mib_index + * mib_idx); + int ipDefaultRouterTable_index_from_oid(netsnmp_index * + oid_idx, + ipDefaultRouterTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + ipDefaultRouterTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* IPDEFAULTROUTERTABLE_INTERFACE_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_oids.h b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_oids.h new file mode 100644 index 0000000..6914e71 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipDefaultRouterTable/ipDefaultRouterTable_oids.h @@ -0,0 +1,39 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c 12855 2005-09-27 15:56:08Z rstory $ + * + * $Id:$ + */ +#ifndef IPDEFAULTROUTERTABLE_OIDS_H +#define IPDEFAULTROUTERTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipDefaultRouterTable + */ +#define IPDEFAULTROUTERTABLE_OID 1,3,6,1,2,1,4,37 + +#define COLUMN_IPDEFAULTROUTERADDRESSTYPE 1 + +#define COLUMN_IPDEFAULTROUTERADDRESS 2 + +#define COLUMN_IPDEFAULTROUTERIFINDEX 3 + +#define COLUMN_IPDEFAULTROUTERLIFETIME 4 + +#define COLUMN_IPDEFAULTROUTERPREFERENCE 5 + + +#define IPDEFAULTROUTERTABLE_MIN_COL COLUMN_IPDEFAULTROUTERLIFETIME +#define IPDEFAULTROUTERTABLE_MAX_COL COLUMN_IPDEFAULTROUTERPREFERENCE + + + +#ifdef __cplusplus +} +#endif +#endif /* IPDEFAULTROUTERTABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable.h b/agent/mibgroup/ip-mib/ipIfStatsTable.h new file mode 100644 index 0000000..da1d85c --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable.h @@ -0,0 +1,8 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/data_access/systemstats) +config_require(ip-mib/ipIfStatsTable/ipIfStatsTable) +config_require(ip-mib/ipIfStatsTable/ipIfStatsTable_interface) +config_require(ip-mib/ipIfStatsTable/ipIfStatsTable_data_access) diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.c b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.c new file mode 100644 index 0000000..43d807e --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.c @@ -0,0 +1,222 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +/** \page MFD helper for ipIfStatsTable + * + * \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 "ipIfStatsTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipIfStatsTable_interface.h" + +const oid ipIfStatsTable_oid[] = { IPIFSTATSTABLE_OID }; +const int ipIfStatsTable_oid_size = OID_LENGTH(ipIfStatsTable_oid); + +ipIfStatsTable_registration ipIfStatsTable_user_context; +static ipIfStatsTable_registration *ipIfStatsTable_user_context_p; + +void initialize_table_ipIfStatsTable(void); +void shutdown_table_ipIfStatsTable(void); + + +/** + * Initializes the ipIfStatsTable module + */ +void +init_ipIfStatsTable(void) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:init_ipIfStatsTable", "called\n")); + + /* + * TODO:300:o: Perform ipIfStatsTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipIfStatsTable")) + initialize_table_ipIfStatsTable(); + + /* + * last changed should be 0 at startup + */ + ipIfStatsTable_lastChange_set(0); +} /* init_ipIfStatsTable */ + +/** + * Shut-down the ipIfStatsTable module (agent is exiting) + */ +void +shutdown_ipIfStatsTable(void) +{ + if (should_init("ipIfStatsTable")) + shutdown_table_ipIfStatsTable(); + +} + +/** + * Initialize the table ipIfStatsTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipIfStatsTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipIfStatsTable:initialize_table_ipIfStatsTable", + "called\n")); + + /* + * TODO:301:o: Perform ipIfStatsTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipIfStatsTable 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. + */ + ipIfStatsTable_user_context_p + = netsnmp_create_data_list("ipIfStatsTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipIfStatsTable_initialize_interface + (ipIfStatsTable_user_context_p, flags); +} /* initialize_table_ipIfStatsTable */ + +/** + * Shutdown the table ipIfStatsTable + */ +void +shutdown_table_ipIfStatsTable(void) +{ + /* + * call interface shutdown code + */ + _ipIfStatsTable_shutdown_interface(ipIfStatsTable_user_context_p); + netsnmp_free_all_list_data(ipIfStatsTable_user_context_p); + ipIfStatsTable_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 +ipIfStatsTable_rowreq_ctx_init(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_rowreq_ctx_init", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipIfStatsTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* ipIfStatsTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipIfStatsTable_rowreq_ctx_cleanup(ipIfStatsTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_rowreq_ctx_cleanup", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipIfStatsTable rowreq cleanup. + */ + netsnmp_access_systemstats_entry_free(rowreq_ctx->data); + rowreq_ctx->data = NULL; +} /* ipIfStatsTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipIfStatsTable_pre_request(ipIfStatsTable_registration * user_context) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_pre_request", + "called\n")); + + /* + * TODO:510:o: Perform ipIfStatsTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipIfStatsTable_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 +ipIfStatsTable_post_request(ipIfStatsTable_registration * user_context, + int rc) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_post_request", + "called\n")); + + /* + * TODO:511:o: Perform ipIfStatsTable post-request actions. + */ + + return MFD_SUCCESS; +} /* ipIfStatsTable_post_request */ + + +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.h b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.h new file mode 100644 index 0000000..bda956f --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable.h @@ -0,0 +1,200 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +#ifndef IPIFSTATSTABLE_H +#define IPIFSTATSTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/ipstats.h> +#include <net-snmp/data_access/systemstats.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-mib/ipIfStatsTable/ipIfStatsTable_interface) +config_require(ip-mib/ipIfStatsTable/ipIfStatsTable_data_access) +config_require(ip-mib/ipIfStatsTable/ipIfStatsTable_data_get) + /* *INDENT-ON* */ + + /* + * OID and column number definitions for ipIfStatsTable + */ +#include "ipIfStatsTable_oids.h" + + /* + * enum definions + */ +#include "ipIfStatsTable_enums.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipIfStatsTable(void); + void shutdown_ipIfStatsTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipIfStatsTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.3, 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 ipIfStatsTable registration context. + */ + typedef netsnmp_data_list ipIfStatsTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipIfStatsTable data context structure. + * This structure is used to represent the data for ipIfStatsTable. + */ + typedef netsnmp_systemstats_entry ipIfStatsTable_data; + + + /* + * TODO:120:r: |-> Review ipIfStatsTable mib index. + * This structure is used to represent the index for ipIfStatsTable. + */ + typedef struct ipIfStatsTable_mib_index_s { + + /* + * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long ipIfStatsIPVersion; + + /* + * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + long ipIfStatsIfIndex; + + + } ipIfStatsTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipIfStatsTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + */ +#define MAX_ipIfStatsTable_IDX_LEN 2 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipIfStatsTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipIfStatsTable_rowreq_ctx pointer. + */ + typedef struct ipIfStatsTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipIfStatsTable_IDX_LEN]; + + ipIfStatsTable_mib_index tbl_idx; + + ipIfStatsTable_data *data; + + /* + * 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 ipIfStatsTable rowreq context. + */ + char known_missing; + uint32_t ipIfStatsDiscontinuityTime; + uint32_t ipIfStatsRefreshRate; + + /* + * storage for future expansion + */ + netsnmp_data_list *ipIfStatsTable_data_list; + + } ipIfStatsTable_rowreq_ctx; + + typedef struct ipIfStatsTable_ref_rowreq_ctx_s { + ipIfStatsTable_rowreq_ctx *rowreq_ctx; + } ipIfStatsTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int ipIfStatsTable_pre_request(ipIfStatsTable_registration + * user_context); + int ipIfStatsTable_post_request(ipIfStatsTable_registration + * user_context, int rc); + + int + ipIfStatsTable_rowreq_ctx_init(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx); + void + ipIfStatsTable_rowreq_ctx_cleanup(ipIfStatsTable_rowreq_ctx * + rowreq_ctx); + + ipIfStatsTable_data *ipIfStatsTable_allocate_data(void); + void ipIfStatsTable_release_data(ipIfStatsTable_data * + data); + + + ipIfStatsTable_rowreq_ctx + *ipIfStatsTable_row_find_by_mib_index(ipIfStatsTable_mib_index * + mib_idx); + + extern const oid ipIfStatsTable_oid[]; + extern const int ipIfStatsTable_oid_size; + + +#include "ipIfStatsTable_interface.h" +#include "ipIfStatsTable_data_access.h" +#include "ipIfStatsTable_data_get.h" + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* IPIFSTATSTABLE_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.c b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.c new file mode 100644 index 0000000..7919dea --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.c @@ -0,0 +1,410 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $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 "ipIfStatsTable.h" + + +#include "ipIfStatsTable_data_access.h" + +static int ipis_cache_refresh = IPIFSTATSTABLE_CACHE_TIMEOUT; + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipIfStatsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.3, length: 9 + */ + +/** + * initialization for ipIfStatsTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipIfStatsTable_reg + * Pointer to ipIfStatsTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipIfStatsTable_init_data(ipIfStatsTable_registration * ipIfStatsTable_reg) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize ipIfStatsTable data. + */ + netsnmp_access_systemstats_init(); + + return MFD_SUCCESS; +} /* ipIfStatsTable_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 +ipIfStatsTable_container_init(netsnmp_container ** container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_container_init", + "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipIfStatsTable_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. + */ + /* + * We create a custom container here so we can pre-load it, which + * will result in all new entries with last changed values. we need + * to clear those... We also need to make sure ifIndexes have been + * assigned... + */ + *container_ptr_ptr = + netsnmp_container_find("ipIfStatsTable:table_container"); + if (NULL != *container_ptr_ptr) { + (*container_ptr_ptr)->container_name = strdup("ipIfStatsTable"); + ipIfStatsTable_container_load(*container_ptr_ptr); + } + if (NULL == cache) { + snmp_log(LOG_ERR, + "bad cache param to ipIfStatsTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipIfStatsTable 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 = IPIFSTATSTABLE_CACHE_TIMEOUT; /* seconds */ + + cache->flags |= + (NETSNMP_CACHE_DONT_AUTO_RELEASE | NETSNMP_CACHE_DONT_FREE_EXPIRED + | NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD | + NETSNMP_CACHE_AUTO_RELOAD); +} /* ipIfStatsTable_container_init */ + +/** + * check entry for update + */ +static void +_check_for_updates(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + netsnmp_container *stats) +{ + netsnmp_systemstats_entry *ifstats_entry; + + /* + * check for matching entry. works because indexes are the same. + */ + ifstats_entry = (netsnmp_systemstats_entry*)CONTAINER_FIND(stats, rowreq_ctx->data); + if (NULL == ifstats_entry) { + DEBUGMSGTL(("ipIfStatsTable:access", + "updating missing entry\n")); + + /* + * mark row as missing, so we can set discontinuity + * when it comes back. + * + * what else should we do? set refresh to 0? that's not quite right... + */ + rowreq_ctx->known_missing = 1; + } else { + DEBUGMSGTL(("ipIfStatsTable:access", + "updating existing entry\n")); + + /* + * Check for changes & update + */ + netsnmp_access_systemstats_entry_update(rowreq_ctx->data, + ifstats_entry); + + /* + * set discontinuity if previously missing. + */ + if (1 == rowreq_ctx->known_missing) { + rowreq_ctx->known_missing = 0; + rowreq_ctx->ipIfStatsDiscontinuityTime = + netsnmp_get_agent_uptime(); + ipIfStatsTable_lastChange_set(netsnmp_get_agent_uptime()); + } + + /* + * remove entry from container + */ + CONTAINER_REMOVE(stats, ifstats_entry); + netsnmp_access_systemstats_entry_free(ifstats_entry); + } +} + +/** + * add new entry + */ +static void +_add_new(netsnmp_systemstats_entry *ifstats_entry, + netsnmp_container *container) +{ + ipIfStatsTable_rowreq_ctx *rowreq_ctx; + + DEBUGMSGTL(("ipIfStatsTable:access", "creating new entry\n")); + + netsnmp_assert(NULL != ifstats_entry); + netsnmp_assert(NULL != container); + + /* + * allocate an row context and set the index(es) + */ + rowreq_ctx = + ipIfStatsTable_allocate_rowreq_ctx(ifstats_entry, NULL); + if ((NULL != rowreq_ctx) + && (MFD_SUCCESS == + ipIfStatsTable_indexes_set(rowreq_ctx, + ifstats_entry->index[0], + ifstats_entry->index[1]))) { + rowreq_ctx->ipIfStatsRefreshRate = ipis_cache_refresh * 1000; /* milli-seconds */ + CONTAINER_INSERT(container, rowreq_ctx); + ipIfStatsTable_lastChange_set(netsnmp_get_agent_uptime()); + } else { + if (NULL != rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "ipIfStatsTable cache.\n"); + ipIfStatsTable_release_rowreq_ctx(rowreq_ctx); + } else { + snmp_log(LOG_ERR, "memory allocation failed while loading " + "ipIfStatsTable cache.\n"); + netsnmp_access_systemstats_entry_free(ifstats_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 ipIfStatsTable_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 +ipIfStatsTable_container_shutdown(netsnmp_container * container_ptr) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_container_shutdown", + "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipIfStatsTable_container_shutdown\n"); + return; + } + +} /* ipIfStatsTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement ipIfStatsTable 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 + * ipIfStatsTable_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 +ipIfStatsTable_container_load(netsnmp_container * container) +{ + netsnmp_container *stats; + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_container_load", + "called\n")); + + netsnmp_assert(NULL != container); + + stats = netsnmp_access_systemstats_container_load(NULL, NETSNMP_ACCESS_SYSTEMSTATS_LOAD_IFTABLE); + if (NULL == stats) + return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */ + + /* + * TODO:351:M: |-> Load/update data in the ipIfStatsTable container. + * loop over your ipIfStatsTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + + /* + * we just got a fresh copy of data. compare it to + * what we've already got, and make any adjustements... + */ + CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *) + _check_for_updates, stats); + + /* + * now add any new entries + */ + CONTAINER_FOR_EACH(stats, (netsnmp_container_obj_func *) + _add_new, 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_systemstats_container_free(stats, + NETSNMP_ACCESS_SYSTEMSTATS_FREE_DONT_CLEAR); + + DEBUGMSGT(("verbose:ipIfStatsTable:ipIfStatsTable_container_load", + "%lu records\n", (unsigned long)CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} /* ipIfStatsTable_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 +ipIfStatsTable_container_free(netsnmp_container * container) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_container_free", + "called\n")); + + /* + * TODO:380:M: Free ipIfStatsTable container data. + */ +} /* ipIfStatsTable_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 +ipIfStatsTable_row_prep(ipIfStatsTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_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; +} /* ipIfStatsTable_row_prep */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.h b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.h new file mode 100644 index 0000000..5ef7682 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_access.h @@ -0,0 +1,70 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:$ + */ +#ifndef IPIFSTATSTABLE_DATA_ACCESS_H +#define IPIFSTATSTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipIfStatsTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.3, length: 9 + */ + + + int ipIfStatsTable_init_data(ipIfStatsTable_registration * + ipIfStatsTable_reg); + + + /* + * TODO:180:o: Review ipIfStatsTable cache timeout. + * The number of seconds before the cache times out + */ +#define IPIFSTATSTABLE_CACHE_TIMEOUT 60 + + void ipIfStatsTable_container_init(netsnmp_container ** + container_ptr_ptr, + netsnmp_cache * cache); + void ipIfStatsTable_container_shutdown(netsnmp_container * + container_ptr); + + int ipIfStatsTable_container_load(netsnmp_container * + container); + void ipIfStatsTable_container_free(netsnmp_container * + container); + + int ipIfStatsTable_cache_load(netsnmp_container * + container); + void ipIfStatsTable_cache_free(netsnmp_container * + container); + + int ipIfStatsTable_row_prep(ipIfStatsTable_rowreq_ctx * + rowreq_ctx); + +#ifdef __cplusplus +} +#endif +#endif /* IPIFSTATSTABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.c b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.c new file mode 100644 index 0000000..db673dc --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.c @@ -0,0 +1,3015 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 12088 $ of $ + * + * $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 "ipIfStatsTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement ipIfStatsTable get routines. + * TODO:240:M: Implement ipIfStatsTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipIfStatsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.3, length: 9 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipIfStatsTable data context functions. + */ +/* + * ipIfStatsTable_allocate_data + * + * Purpose: create new ipIfStatsTable_data. + */ +ipIfStatsTable_data * +ipIfStatsTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the ipIfStatsTable data context. + */ + ipIfStatsTable_data *rtn = SNMP_MALLOC_TYPEDEF(ipIfStatsTable_data); + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_allocate_data", + "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipIfStatsTable_data.\n"); + } + + return rtn; +} /* ipIfStatsTable_allocate_data */ + +/* + * ipIfStatsTable_release_data + * + * Purpose: release ipIfStatsTable data. + */ +void +ipIfStatsTable_release_data(ipIfStatsTable_data * data) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_release_data", + "called\n")); + + /* + * TODO:202:r: |-> release memory for the ipIfStatsTable data context. + */ + free(data); +} /* ipIfStatsTable_release_data */ + + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipIfStatsIPVersion_val + * @param ipIfStatsIfIndex_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 +ipIfStatsTable_indexes_set_tbl_idx(ipIfStatsTable_mib_index * tbl_idx, + u_long ipIfStatsIPVersion_val, + long ipIfStatsIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_ifstats_entry */ + tbl_idx->ipIfStatsIPVersion = ipIfStatsIPVersion_val; + + /* + * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + /** WARNING: this code might not work for netsnmp_ifstats_entry */ + tbl_idx->ipIfStatsIfIndex = ipIfStatsIfIndex_val; + + + return MFD_SUCCESS; +} /* ipIfStatsTable_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 +ipIfStatsTable_indexes_set(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long ipIfStatsIPVersion_val, + long ipIfStatsIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_indexes_set", + "called\n")); + + if (MFD_SUCCESS != + ipIfStatsTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipIfStatsIPVersion_val, + ipIfStatsIfIndex_val)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != ipIfStatsTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipIfStatsTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInReceives + * ipIfStatsInReceives is subid 3 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.3 + * Description: +The total number of input IP datagrams received, including + those received in error. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInReceives data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInReceives_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 +ipIfStatsInReceives_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInReceives_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInReceives_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInReceives_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInReceives data. + * copy (* ipIfStatsInReceives_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES]) + return MFD_SKIP; + + (*ipIfStatsInReceives_val_ptr) = + rowreq_ctx->data->stats.HCInReceives.low; + + return MFD_SUCCESS; +} /* ipIfStatsInReceives_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInReceives + * ipIfStatsHCInReceives is subid 4 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.4 + * Description: +The total number of input IP datagrams received, including + those received in error. This object counts the same + datagrams as ipIfStatsInReceives, but allows for larger + values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInReceives data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInReceives_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInReceives_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInReceives_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInReceives_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInReceives data. + * get (* ipIfStatsHCInReceives_val_ptr ).low and (* ipIfStatsHCInReceives_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES]) + return MFD_SKIP; + + (*ipIfStatsHCInReceives_val_ptr).low = + rowreq_ctx->data->stats.HCInReceives.low; + (*ipIfStatsHCInReceives_val_ptr).high = + rowreq_ctx->data->stats.HCInReceives.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInReceives_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInOctets + * ipIfStatsInOctets is subid 5 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.5 + * Description: +The total number of octets received in input IP datagrams, + including those received in error. Octets from datagrams + counted in ipIfStatsInReceives MUST be counted here. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInOctets_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 +ipIfStatsInOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInOctets_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInOctets data. + * copy (* ipIfStatsInOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS]) + return MFD_SKIP; + + (*ipIfStatsInOctets_val_ptr) = + rowreq_ctx->data->stats.HCInOctets.low; + + return MFD_SUCCESS; +} /* ipIfStatsInOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInOctets + * ipIfStatsHCInOctets is subid 6 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.6 + * Description: +The total number of octets received in input IP datagrams, + including those received in error. This object counts the + same octets as ipIfStatsInOctets, but allows for larger + values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInOctets data. + * get (* ipIfStatsHCInOctets_val_ptr ).low and (* ipIfStatsHCInOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS]) + return MFD_SKIP; + + (*ipIfStatsHCInOctets_val_ptr).low = + rowreq_ctx->data->stats.HCInOctets.low; + (*ipIfStatsHCInOctets_val_ptr).high = + rowreq_ctx->data->stats.HCInOctets.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInHdrErrors + * ipIfStatsInHdrErrors is subid 7 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.7 + * Description: +The number of input IP datagrams discarded due to errors in + their IP headers, including version number mismatch, other + format errors, hop count exceeded, errors discovered in + processing their IP options, etc. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInHdrErrors data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInHdrErrors_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 +ipIfStatsInHdrErrors_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInHdrErrors_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInHdrErrors_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInHdrErrors_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInHdrErrors data. + * copy (* ipIfStatsInHdrErrors_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS]) + return MFD_SKIP; + + (*ipIfStatsInHdrErrors_val_ptr) = + rowreq_ctx->data->stats.InHdrErrors; + + return MFD_SUCCESS; +} /* ipIfStatsInHdrErrors_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInNoRoutes + * ipIfStatsInNoRoutes is subid 8 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.8 + * Description: +The number of input IP datagrams discarded because no route + could be found to transmit them to their destination. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInNoRoutes data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInNoRoutes_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 +ipIfStatsInNoRoutes_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInNoRoutes_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInNoRoutes_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInNoRoutes_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInNoRoutes data. + * copy (* ipIfStatsInNoRoutes_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINNOROUTES]) + return MFD_SKIP; + + (*ipIfStatsInNoRoutes_val_ptr) = + rowreq_ctx->data->stats.HCInNoRoutes.low; + + return MFD_SUCCESS; +} /* ipIfStatsInNoRoutes_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInAddrErrors + * ipIfStatsInAddrErrors is subid 9 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.9 + * Description: +The number of input IP datagrams discarded because the IP + address in their IP header's destination field was not a + valid address to be received at this entity. This count + includes invalid addresses (e.g., ::0). For entities that + are not IP routers and therefore do not forward datagrams, + this counter includes datagrams discarded because the + destination address was not a local address. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInAddrErrors data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInAddrErrors_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 +ipIfStatsInAddrErrors_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInAddrErrors_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInAddrErrors_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInAddrErrors_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInAddrErrors data. + * copy (* ipIfStatsInAddrErrors_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INADDRERRORS]) + return MFD_SKIP; + + (*ipIfStatsInAddrErrors_val_ptr) = + rowreq_ctx->data->stats.InAddrErrors; + + return MFD_SUCCESS; +} /* ipIfStatsInAddrErrors_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInUnknownProtos + * ipIfStatsInUnknownProtos is subid 10 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.10 + * Description: +The number of locally-addressed IP datagrams received + successfully but discarded because of an unknown or + unsupported protocol. + + When tracking interface statistics, the counter of the + interface to which these datagrams were addressed is + incremented. This interface might not be the same as the + input interface for some of the datagrams. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + + + + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInUnknownProtos data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInUnknownProtos_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 +ipIfStatsInUnknownProtos_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInUnknownProtos_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInUnknownProtos_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInUnknownProtos_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInUnknownProtos data. + * copy (* ipIfStatsInUnknownProtos_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INUNKNOWNPROTOS]) + return MFD_SKIP; + + (*ipIfStatsInUnknownProtos_val_ptr) = + rowreq_ctx->data->stats.InUnknownProtos; + + return MFD_SUCCESS; +} /* ipIfStatsInUnknownProtos_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInTruncatedPkts + * ipIfStatsInTruncatedPkts is subid 11 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.11 + * Description: +The number of input IP datagrams discarded because the + datagram frame didn't carry enough data. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInTruncatedPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInTruncatedPkts_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 +ipIfStatsInTruncatedPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInTruncatedPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInTruncatedPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInTruncatedPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInTruncatedPkts data. + * copy (* ipIfStatsInTruncatedPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INTRUNCATEDPKTS]) + return MFD_SKIP; + + (*ipIfStatsInTruncatedPkts_val_ptr) = + rowreq_ctx->data->stats.InTruncatedPkts; + + return MFD_SUCCESS; +} /* ipIfStatsInTruncatedPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInForwDatagrams + * ipIfStatsInForwDatagrams is subid 12 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.12 + * Description: +The number of input datagrams for which this entity was not + their final IP destination and for which this entity + attempted to find a route to forward them to that final + destination. In entities that do not act as IP routers, + this counter will include only those datagrams that were + Source-Routed via this entity, and the Source-Route + processing was successful. + + When tracking interface statistics, the counter of the + incoming interface is incremented for each datagram. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInForwDatagrams_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 +ipIfStatsInForwDatagrams_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInForwDatagrams_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInForwDatagrams_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInForwDatagrams data. + * copy (* ipIfStatsInForwDatagrams_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipIfStatsInForwDatagrams_val_ptr) = + rowreq_ctx->data->stats.HCInForwDatagrams.low; + + return MFD_SUCCESS; +} /* ipIfStatsInForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInForwDatagrams + * ipIfStatsHCInForwDatagrams is subid 13 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.13 + * Description: +The number of input datagrams for which this entity was not + their final IP destination and for which this entity + attempted to find a route to forward them to that final + destination. This object counts the same packets as + + + + ipIfStatsInForwDatagrams, but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInForwDatagrams_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInForwDatagrams_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInForwDatagrams_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInForwDatagrams data. + * get (* ipIfStatsHCInForwDatagrams_val_ptr ).low and (* ipIfStatsHCInForwDatagrams_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipIfStatsHCInForwDatagrams_val_ptr).low = + rowreq_ctx->data->stats.HCInForwDatagrams.low; + (*ipIfStatsHCInForwDatagrams_val_ptr).high = + rowreq_ctx->data->stats.HCInForwDatagrams.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsReasmReqds + * ipIfStatsReasmReqds is subid 14 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.14 + * Description: +The number of IP fragments received that needed to be + reassembled at this interface. + + When tracking interface statistics, the counter of the + interface to which these fragments were addressed is + incremented. This interface might not be the same as the + input interface for some of the fragments. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsReasmReqds data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsReasmReqds_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 +ipIfStatsReasmReqds_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsReasmReqds_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsReasmReqds_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsReasmReqds_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsReasmReqds data. + * copy (* ipIfStatsReasmReqds_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMREQDS]) + return MFD_SKIP; + + (*ipIfStatsReasmReqds_val_ptr) = + rowreq_ctx->data->stats.ReasmReqds; + + return MFD_SUCCESS; +} /* ipIfStatsReasmReqds_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsReasmOKs + * ipIfStatsReasmOKs is subid 15 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.15 + * Description: +The number of IP datagrams successfully reassembled. + + When tracking interface statistics, the counter of the + interface to which these datagrams were addressed is + incremented. This interface might not be the same as the + input interface for some of the datagrams. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsReasmOKs data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsReasmOKs_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 +ipIfStatsReasmOKs_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsReasmOKs_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsReasmOKs_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsReasmOKs_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsReasmOKs data. + * copy (* ipIfStatsReasmOKs_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMOKS]) + return MFD_SKIP; + + (*ipIfStatsReasmOKs_val_ptr) = + rowreq_ctx->data->stats.ReasmOKs; + + return MFD_SUCCESS; +} /* ipIfStatsReasmOKs_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsReasmFails + * ipIfStatsReasmFails is subid 16 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.16 + * Description: +The number of failures detected by the IP re-assembly + algorithm (for whatever reason: timed out, errors, etc.). + Note that this is not necessarily a count of discarded IP + fragments since some algorithms (notably the algorithm in + RFC 815) can lose track of the number of fragments by + combining them as they are received. + + When tracking interface statistics, the counter of the + interface to which these fragments were addressed is + incremented. This interface might not be the same as the + input interface for some of the fragments. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsReasmFails data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsReasmFails_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 +ipIfStatsReasmFails_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsReasmFails_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsReasmFails_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsReasmFails_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsReasmFails data. + * copy (* ipIfStatsReasmFails_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMFAILS]) + return MFD_SKIP; + + (*ipIfStatsReasmFails_val_ptr) = + rowreq_ctx->data->stats.ReasmFails; + + return MFD_SUCCESS; +} /* ipIfStatsReasmFails_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInDiscards + * ipIfStatsInDiscards is subid 17 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.17 + * Description: +The number of input IP datagrams for which no problems were + encountered to prevent their continued processing, but + were discarded (e.g., for lack of buffer space). Note that + this counter does not include any datagrams discarded while + awaiting re-assembly. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInDiscards data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInDiscards_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 +ipIfStatsInDiscards_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInDiscards_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInDiscards_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInDiscards_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInDiscards data. + * copy (* ipIfStatsInDiscards_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INDISCARDS]) + return MFD_SKIP; + + (*ipIfStatsInDiscards_val_ptr) = + rowreq_ctx->data->stats.InDiscards; + + return MFD_SUCCESS; +} /* ipIfStatsInDiscards_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInDelivers + * ipIfStatsInDelivers is subid 18 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.18 + * Description: +The total number of datagrams successfully delivered to IP + user-protocols (including ICMP). + + When tracking interface statistics, the counter of the + interface to which these datagrams were addressed is + incremented. This interface might not be the same as the + + + + input interface for some of the datagrams. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInDelivers data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInDelivers_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 +ipIfStatsInDelivers_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInDelivers_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInDelivers_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInDelivers_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInDelivers data. + * copy (* ipIfStatsInDelivers_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS]) + return MFD_SKIP; + + (*ipIfStatsInDelivers_val_ptr) = + rowreq_ctx->data->stats.HCInDelivers.low; + + return MFD_SUCCESS; +} /* ipIfStatsInDelivers_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInDelivers + * ipIfStatsHCInDelivers is subid 19 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.19 + * Description: +The total number of datagrams successfully delivered to IP + user-protocols (including ICMP). This object counts the + same packets as ipIfStatsInDelivers, but allows for larger + values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInDelivers data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInDelivers_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInDelivers_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInDelivers_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInDelivers_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInDelivers data. + * get (* ipIfStatsHCInDelivers_val_ptr ).low and (* ipIfStatsHCInDelivers_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS]) + return MFD_SKIP; + + (*ipIfStatsHCInDelivers_val_ptr).low = + rowreq_ctx->data->stats.HCInDelivers.low; + (*ipIfStatsHCInDelivers_val_ptr).high = + rowreq_ctx->data->stats.HCInDelivers.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInDelivers_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutRequests + * ipIfStatsOutRequests is subid 20 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.20 + * Description: +The total number of IP datagrams that local IP user- + protocols (including ICMP) supplied to IP in requests for + transmission. Note that this counter does not include any + datagrams counted in ipIfStatsOutForwDatagrams. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutRequests data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutRequests_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 +ipIfStatsOutRequests_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutRequests_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutRequests_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutRequests_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutRequests data. + * copy (* ipIfStatsOutRequests_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS]) + return MFD_SKIP; + + (*ipIfStatsOutRequests_val_ptr) = + rowreq_ctx->data->stats.HCOutRequests.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutRequests_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutRequests + * ipIfStatsHCOutRequests is subid 21 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.21 + * Description: +The total number of IP datagrams that local IP user- + protocols (including ICMP) supplied to IP in requests for + transmission. This object counts the same packets as + + + + ipIfStatsOutRequests, but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutRequests data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutRequests_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutRequests_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutRequests_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutRequests_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutRequests data. + * get (* ipIfStatsHCOutRequests_val_ptr ).low and (* ipIfStatsHCOutRequests_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS]) + return MFD_SKIP; + + (*ipIfStatsHCOutRequests_val_ptr).low = + rowreq_ctx->data->stats.HCOutRequests.low; + (*ipIfStatsHCOutRequests_val_ptr).high = + rowreq_ctx->data->stats.HCOutRequests.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutRequests_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutForwDatagrams + * ipIfStatsOutForwDatagrams is subid 23 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.23 + * Description: +The number of datagrams for which this entity was not their + final IP destination and for which it was successful in + finding a path to their final destination. In entities + that do not act as IP routers, this counter will include + only those datagrams that were Source-Routed via this + entity, and the Source-Route processing was successful. + + When tracking interface statistics, the counter of the + outgoing interface is incremented for a successfully + forwarded datagram. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutForwDatagrams_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 +ipIfStatsOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutForwDatagrams_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutForwDatagrams_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutForwDatagrams data. + * copy (* ipIfStatsOutForwDatagrams_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipIfStatsOutForwDatagrams_val_ptr) = + rowreq_ctx->data->stats.HCOutForwDatagrams.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutForwDatagrams + * ipIfStatsHCOutForwDatagrams is subid 24 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.24 + * Description: +The number of datagrams for which this entity was not their + final IP destination and for which it was successful in + finding a path to their final destination. This object + counts the same packets as ipIfStatsOutForwDatagrams, but + allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + + + + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutForwDatagrams_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutForwDatagrams_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutForwDatagrams data. + * get (* ipIfStatsHCOutForwDatagrams_val_ptr ).low and (* ipIfStatsHCOutForwDatagrams_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipIfStatsHCOutForwDatagrams_val_ptr).low = + rowreq_ctx->data->stats.HCOutForwDatagrams.low; + (*ipIfStatsHCOutForwDatagrams_val_ptr).high = + rowreq_ctx->data->stats.HCOutForwDatagrams.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutDiscards + * ipIfStatsOutDiscards is subid 25 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.25 + * Description: +The number of output IP datagrams for which no problem was + encountered to prevent their transmission to their + destination, but were discarded (e.g., for lack of + buffer space). Note that this counter would include + datagrams counted in ipIfStatsOutForwDatagrams if any such + datagrams met this (discretionary) discard criterion. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutDiscards data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutDiscards_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 +ipIfStatsOutDiscards_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutDiscards_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutDiscards_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutDiscards_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutDiscards data. + * copy (* ipIfStatsOutDiscards_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS]) + return MFD_SKIP; + + (*ipIfStatsOutDiscards_val_ptr) = + rowreq_ctx->data->stats.HCOutDiscards.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutDiscards_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutFragReqds + * ipIfStatsOutFragReqds is subid 26 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.26 + * Description: +The number of IP datagrams that would require fragmentation + in order to be transmitted. + + When tracking interface statistics, the counter of the + outgoing interface is incremented for a successfully + fragmented datagram. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutFragReqds data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutFragReqds_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 +ipIfStatsOutFragReqds_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutFragReqds_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutFragReqds_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutFragReqds_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutFragReqds data. + * copy (* ipIfStatsOutFragReqds_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGREQDS]) + return MFD_SKIP; + + (*ipIfStatsOutFragReqds_val_ptr) = + rowreq_ctx->data->stats.HCOutFragReqds.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutFragReqds_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutFragOKs + * ipIfStatsOutFragOKs is subid 27 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.27 + * Description: +The number of IP datagrams that have been successfully + fragmented. + + When tracking interface statistics, the counter of the + + + + outgoing interface is incremented for a successfully + fragmented datagram. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutFragOKs data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutFragOKs_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 +ipIfStatsOutFragOKs_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutFragOKs_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutFragOKs_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutFragOKs_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutFragOKs data. + * copy (* ipIfStatsOutFragOKs_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGOKS]) + return MFD_SKIP; + + (*ipIfStatsOutFragOKs_val_ptr) = + rowreq_ctx->data->stats.HCOutFragOKs.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutFragOKs_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutFragFails + * ipIfStatsOutFragFails is subid 28 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.28 + * Description: +The number of IP datagrams that have been discarded because + they needed to be fragmented but could not be. This + includes IPv4 packets that have the DF bit set and IPv6 + packets that are being forwarded and exceed the outgoing + link MTU. + + When tracking interface statistics, the counter of the + outgoing interface is incremented for an unsuccessfully + fragmented datagram. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutFragFails data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutFragFails_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 +ipIfStatsOutFragFails_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutFragFails_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutFragFails_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutFragFails_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutFragFails data. + * copy (* ipIfStatsOutFragFails_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGFAILS]) + return MFD_SKIP; + + (*ipIfStatsOutFragFails_val_ptr) = + rowreq_ctx->data->stats.HCOutFragFails.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutFragFails_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutFragCreates + * ipIfStatsOutFragCreates is subid 29 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.29 + * Description: +The number of output datagram fragments that have been + generated as a result of IP fragmentation. + + When tracking interface statistics, the counter of the + outgoing interface is incremented for a successfully + fragmented datagram. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutFragCreates data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutFragCreates_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 +ipIfStatsOutFragCreates_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutFragCreates_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutFragCreates_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutFragCreates_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutFragCreates data. + * copy (* ipIfStatsOutFragCreates_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES]) + return MFD_SKIP; + + (*ipIfStatsOutFragCreates_val_ptr) = + rowreq_ctx->data->stats.HCOutFragCreates.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutFragCreates_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutTransmits + * ipIfStatsOutTransmits is subid 30 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.30 + * Description: +The total number of IP datagrams that this entity supplied + to the lower layers for transmission. This includes + datagrams generated locally and those forwarded by this + entity. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutTransmits data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutTransmits_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 +ipIfStatsOutTransmits_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutTransmits_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutTransmits_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutTransmits_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutTransmits data. + * copy (* ipIfStatsOutTransmits_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS]) + return MFD_SKIP; + + (*ipIfStatsOutTransmits_val_ptr) = + rowreq_ctx->data->stats.HCOutTransmits.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutTransmits_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutTransmits + * ipIfStatsHCOutTransmits is subid 31 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.31 + * Description: +The total number of IP datagrams that this entity supplied + to the lower layers for transmission. This object counts + the same datagrams as ipIfStatsOutTransmits, but allows for + larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutTransmits data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutTransmits_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutTransmits_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutTransmits_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutTransmits_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutTransmits data. + * get (* ipIfStatsHCOutTransmits_val_ptr ).low and (* ipIfStatsHCOutTransmits_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS]) + return MFD_SKIP; + + (*ipIfStatsHCOutTransmits_val_ptr).low = + rowreq_ctx->data->stats.HCOutTransmits.low; + (*ipIfStatsHCOutTransmits_val_ptr).high = + rowreq_ctx->data->stats.HCOutTransmits.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutTransmits_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutOctets + * ipIfStatsOutOctets is subid 32 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.32 + * Description: +The total number of octets in IP datagrams delivered to the + lower layers for transmission. Octets from datagrams + counted in ipIfStatsOutTransmits MUST be counted here. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutOctets_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 +ipIfStatsOutOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutOctets_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutOctets data. + * copy (* ipIfStatsOutOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS]) + return MFD_SKIP; + + (*ipIfStatsOutOctets_val_ptr) = + rowreq_ctx->data->stats.HCOutOctets.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutOctets + * ipIfStatsHCOutOctets is subid 33 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.33 + * Description: +The total number of octets in IP datagrams delivered to the + lower layers for transmission. This objects counts the same + octets as ipIfStatsOutOctets, but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutOctets data. + * get (* ipIfStatsHCOutOctets_val_ptr ).low and (* ipIfStatsHCOutOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS]) + return MFD_SKIP; + + (*ipIfStatsHCOutOctets_val_ptr).low = + rowreq_ctx->data->stats.HCOutOctets.low; + (*ipIfStatsHCOutOctets_val_ptr).high = + rowreq_ctx->data->stats.HCOutOctets.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInMcastPkts + * ipIfStatsInMcastPkts is subid 34 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.34 + * Description: +The number of IP multicast datagrams received. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInMcastPkts_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 +ipIfStatsInMcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInMcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInMcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInMcastPkts data. + * copy (* ipIfStatsInMcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsInMcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCInMcastPkts.low; + + return MFD_SUCCESS; +} /* ipIfStatsInMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInMcastPkts + * ipIfStatsHCInMcastPkts is subid 35 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.35 + * Description: +The number of IP multicast datagrams received. This object + counts the same datagrams as ipIfStatsInMcastPkts, but + allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInMcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInMcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInMcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInMcastPkts data. + * get (* ipIfStatsHCInMcastPkts_val_ptr ).low and (* ipIfStatsHCInMcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsHCInMcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCInMcastPkts.low; + (*ipIfStatsHCInMcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCInMcastPkts.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInMcastOctets + * ipIfStatsInMcastOctets is subid 36 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.36 + * Description: +The total number of octets received in IP multicast + + + + datagrams. Octets from datagrams counted in + ipIfStatsInMcastPkts MUST be counted here. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInMcastOctets_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 +ipIfStatsInMcastOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInMcastOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInMcastOctets_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInMcastOctets data. + * copy (* ipIfStatsInMcastOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS]) + return MFD_SKIP; + + (*ipIfStatsInMcastOctets_val_ptr) = + rowreq_ctx->data->stats.HCInMcastOctets.low; + + return MFD_SUCCESS; +} /* ipIfStatsInMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInMcastOctets + * ipIfStatsHCInMcastOctets is subid 37 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.37 + * Description: +The total number of octets received in IP multicast + datagrams. This object counts the same octets as + ipIfStatsInMcastOctets, but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInMcastOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInMcastOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInMcastOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInMcastOctets data. + * get (* ipIfStatsHCInMcastOctets_val_ptr ).low and (* ipIfStatsHCInMcastOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS]) + return MFD_SKIP; + + (*ipIfStatsHCInMcastOctets_val_ptr).low = + rowreq_ctx->data->stats.HCInMcastOctets.low; + (*ipIfStatsHCInMcastOctets_val_ptr).high = + rowreq_ctx->data->stats.HCInMcastOctets.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutMcastPkts + * ipIfStatsOutMcastPkts is subid 38 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.38 + * Description: +The number of IP multicast datagrams transmitted. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutMcastPkts_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 +ipIfStatsOutMcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutMcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutMcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutMcastPkts data. + * copy (* ipIfStatsOutMcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsOutMcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCOutMcastPkts.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutMcastPkts + * ipIfStatsHCOutMcastPkts is subid 39 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.39 + * Description: +The number of IP multicast datagrams transmitted. This + object counts the same datagrams as ipIfStatsOutMcastPkts, + but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + + + + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutMcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutMcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutMcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutMcastPkts data. + * get (* ipIfStatsHCOutMcastPkts_val_ptr ).low and (* ipIfStatsHCOutMcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsHCOutMcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCOutMcastPkts.low; + (*ipIfStatsHCOutMcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCOutMcastPkts.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutMcastOctets + * ipIfStatsOutMcastOctets is subid 40 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.40 + * Description: +The total number of octets transmitted in IP multicast + datagrams. Octets from datagrams counted in + ipIfStatsOutMcastPkts MUST be counted here. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutMcastOctets_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 +ipIfStatsOutMcastOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutMcastOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutMcastOctets_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutMcastOctets data. + * copy (* ipIfStatsOutMcastOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS]) + return MFD_SKIP; + + (*ipIfStatsOutMcastOctets_val_ptr) = + rowreq_ctx->data->stats.HCOutMcastOctets.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutMcastOctets + * ipIfStatsHCOutMcastOctets is subid 41 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.41 + * Description: +The total number of octets transmitted in IP multicast + datagrams. This object counts the same octets as + ipIfStatsOutMcastOctets, but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutMcastOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutMcastOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutMcastOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutMcastOctets data. + * get (* ipIfStatsHCOutMcastOctets_val_ptr ).low and (* ipIfStatsHCOutMcastOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS]) + return MFD_SKIP; + + (*ipIfStatsHCOutMcastOctets_val_ptr).low = + rowreq_ctx->data->stats.HCOutMcastOctets.low; + (*ipIfStatsHCOutMcastOctets_val_ptr).high = + rowreq_ctx->data->stats.HCOutMcastOctets.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsInBcastPkts + * ipIfStatsInBcastPkts is subid 42 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.42 + * Description: +The number of IP broadcast datagrams received. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsInBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsInBcastPkts_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 +ipIfStatsInBcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsInBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsInBcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsInBcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsInBcastPkts data. + * copy (* ipIfStatsInBcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsInBcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCInBcastPkts.low; + + return MFD_SUCCESS; +} /* ipIfStatsInBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCInBcastPkts + * ipIfStatsHCInBcastPkts is subid 43 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.43 + * Description: +The number of IP broadcast datagrams received. This object + counts the same datagrams as ipIfStatsInBcastPkts, but + allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCInBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCInBcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCInBcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCInBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCInBcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCInBcastPkts data. + * get (* ipIfStatsHCInBcastPkts_val_ptr ).low and (* ipIfStatsHCInBcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsHCInBcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCInBcastPkts.low; + (*ipIfStatsHCInBcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCInBcastPkts.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCInBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsOutBcastPkts + * ipIfStatsOutBcastPkts is subid 44 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.44 + * Description: +The number of IP broadcast datagrams transmitted. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsOutBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsOutBcastPkts_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 +ipIfStatsOutBcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsOutBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsOutBcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsOutBcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsOutBcastPkts data. + * copy (* ipIfStatsOutBcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsOutBcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCOutBcastPkts.low; + + return MFD_SUCCESS; +} /* ipIfStatsOutBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsHCOutBcastPkts + * ipIfStatsHCOutBcastPkts is subid 45 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.45 + * Description: +The number of IP broadcast datagrams transmitted. This + object counts the same datagrams as ipIfStatsOutBcastPkts, + but allows for larger values. + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipIfStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipIfStatsHCOutBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsHCOutBcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipIfStatsHCOutBcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipIfStatsHCOutBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsHCOutBcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipIfStatsHCOutBcastPkts data. + * get (* ipIfStatsHCOutBcastPkts_val_ptr ).low and (* ipIfStatsHCOutBcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS]) + return MFD_SKIP; + + (*ipIfStatsHCOutBcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCOutBcastPkts.low; + (*ipIfStatsHCOutBcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCOutBcastPkts.high; + + return MFD_SUCCESS; +} /* ipIfStatsHCOutBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsDiscontinuityTime + * ipIfStatsDiscontinuityTime is subid 46 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.46 + * Description: +The value of sysUpTime on the most recent occasion at which + + + + any one or more of this entry's counters suffered a + discontinuity. + + If no such discontinuities have occurred since the last re- + initialization of the local management subsystem, then this + object contains a zero value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is TimeStamp (based on perltype TICKS) + * The net-snmp type is ASN_TIMETICKS. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipIfStatsDiscontinuityTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsDiscontinuityTime_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 +ipIfStatsDiscontinuityTime_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsDiscontinuityTime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsDiscontinuityTime_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsDiscontinuityTime_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsDiscontinuityTime data. + * copy (* ipIfStatsDiscontinuityTime_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_DISCONTINUITYTIME]) + return MFD_SKIP; + + (*ipIfStatsDiscontinuityTime_val_ptr) = + rowreq_ctx->ipIfStatsDiscontinuityTime; + + return MFD_SUCCESS; +} /* ipIfStatsDiscontinuityTime_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipIfStatsEntry.ipIfStatsRefreshRate + * ipIfStatsRefreshRate is subid 47 of ipIfStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.3.1.47 + * Description: +The minimum reasonable polling interval for this entry. + This object provides an indication of the minimum amount of + time required to update the counters in this entry. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is UNSIGNED32 (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 ipIfStatsRefreshRate data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipIfStatsRefreshRate_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 +ipIfStatsRefreshRate_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipIfStatsRefreshRate_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipIfStatsRefreshRate_val_ptr); + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsRefreshRate_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipIfStatsRefreshRate data. + * copy (* ipIfStatsRefreshRate_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REFRESHRATE]) + return MFD_SKIP; + + (*ipIfStatsRefreshRate_val_ptr) = + rowreq_ctx->ipIfStatsRefreshRate; + + return MFD_SUCCESS; +} /* ipIfStatsRefreshRate_get */ + + + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h new file mode 100644 index 0000000..0cc7e47 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h @@ -0,0 +1,246 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 12088 $ of $ + * + * $Id:$ + * + * @file ipIfStatsTable_data_get.h + * + * @addtogroup get + * + * Prototypes for get functions + * + * @{ + */ +#ifndef IPIFSTATSTABLE_DATA_GET_H +#define IPIFSTATSTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipIfStatsTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.3, length: 9 + */ + /* + * indexes + */ + + int ipIfStatsInReceives_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInReceives_val_ptr); + int ipIfStatsHCInReceives_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCInReceives_val_ptr); + int ipIfStatsInOctets_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInOctets_val_ptr); + int ipIfStatsHCInOctets_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCInOctets_val_ptr); + int ipIfStatsInHdrErrors_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInHdrErrors_val_ptr); + int ipIfStatsInNoRoutes_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInNoRoutes_val_ptr); + int ipIfStatsInAddrErrors_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInAddrErrors_val_ptr); + int ipIfStatsInUnknownProtos_get(ipIfStatsTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipIfStatsInUnknownProtos_val_ptr); + int ipIfStatsInTruncatedPkts_get(ipIfStatsTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipIfStatsInTruncatedPkts_val_ptr); + int ipIfStatsInForwDatagrams_get(ipIfStatsTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipIfStatsInForwDatagrams_val_ptr); + int + ipIfStatsHCInForwDatagrams_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCInForwDatagrams_val_ptr); + int ipIfStatsReasmReqds_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsReasmReqds_val_ptr); + int ipIfStatsReasmOKs_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsReasmOKs_val_ptr); + int ipIfStatsReasmFails_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsReasmFails_val_ptr); + int ipIfStatsInDiscards_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInDiscards_val_ptr); + int ipIfStatsInDelivers_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInDelivers_val_ptr); + int ipIfStatsHCInDelivers_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCInDelivers_val_ptr); + int ipIfStatsOutRequests_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutRequests_val_ptr); + int ipIfStatsHCOutRequests_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCOutRequests_val_ptr); + int ipIfStatsOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipIfStatsOutForwDatagrams_val_ptr); + int + ipIfStatsHCOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCOutForwDatagrams_val_ptr); + int ipIfStatsOutDiscards_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutDiscards_val_ptr); + int ipIfStatsOutFragReqds_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutFragReqds_val_ptr); + int ipIfStatsOutFragOKs_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutFragOKs_val_ptr); + int ipIfStatsOutFragFails_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutFragFails_val_ptr); + int ipIfStatsOutFragCreates_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutFragCreates_val_ptr); + int ipIfStatsOutTransmits_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutTransmits_val_ptr); + int ipIfStatsHCOutTransmits_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCOutTransmits_val_ptr); + int ipIfStatsOutOctets_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutOctets_val_ptr); + int ipIfStatsHCOutOctets_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCOutOctets_val_ptr); + int ipIfStatsInMcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInMcastPkts_val_ptr); + int ipIfStatsHCInMcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCInMcastPkts_val_ptr); + int ipIfStatsInMcastOctets_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInMcastOctets_val_ptr); + int ipIfStatsHCInMcastOctets_get(ipIfStatsTable_rowreq_ctx + * rowreq_ctx, + U64 * + ipIfStatsHCInMcastOctets_val_ptr); + int ipIfStatsOutMcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutMcastPkts_val_ptr); + int ipIfStatsHCOutMcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCOutMcastPkts_val_ptr); + int ipIfStatsOutMcastOctets_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutMcastOctets_val_ptr); + int ipIfStatsHCOutMcastOctets_get(ipIfStatsTable_rowreq_ctx + * rowreq_ctx, + U64 * + ipIfStatsHCOutMcastOctets_val_ptr); + int ipIfStatsInBcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsInBcastPkts_val_ptr); + int ipIfStatsHCInBcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCInBcastPkts_val_ptr); + int ipIfStatsOutBcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsOutBcastPkts_val_ptr); + int ipIfStatsHCOutBcastPkts_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipIfStatsHCOutBcastPkts_val_ptr); + int + ipIfStatsDiscontinuityTime_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsDiscontinuityTime_val_ptr); + int ipIfStatsRefreshRate_get(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipIfStatsRefreshRate_val_ptr); + + + int + ipIfStatsTable_indexes_set_tbl_idx(ipIfStatsTable_mib_index * + tbl_idx, + u_long ipIfStatsIPVersion_val, + long ipIfStatsIfIndex_val); + int ipIfStatsTable_indexes_set(ipIfStatsTable_rowreq_ctx * + rowreq_ctx, + u_long + ipIfStatsIPVersion_val, + long ipIfStatsIfIndex_val); + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPIFSTATSTABLE_DATA_GET_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_enums.h b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_enums.h new file mode 100644 index 0000000..c3657d5 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_enums.h @@ -0,0 +1,56 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c 12526 2005-07-15 22:41:16Z rstory $ + * + * $Id:$ + */ +#ifndef IPIFSTATSTABLE_ENUMS_H +#define IPIFSTATSTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * 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 ipIfStatsTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipIfStatsIPVersion (InetVersion / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETVERSION_ENUMS +#define INETVERSION_ENUMS + +#define INETVERSION_UNKNOWN 0 +#define INETVERSION_IPV4 1 +#define INETVERSION_IPV6 2 + +#endif /* INETVERSION_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPIFSTATSTABLE_ENUMS_H */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c new file mode 100644 index 0000000..559d1c1 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c @@ -0,0 +1,1420 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 15899 $ of $ + * + * $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 "ipIfStatsTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipIfStatsTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(ipIfStatsTable_external_access, libnetsnmpmibs) + +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(check_all_requests_error) + + +netsnmp_feature_child_of(ipIfStatsTable_container_size, ipIfStatsTable_external_access) +netsnmp_feature_child_of(ipIfStatsTable_registration_set, ipIfStatsTable_external_access) +netsnmp_feature_child_of(ipIfStatsTable_registration_get, ipIfStatsTable_external_access) +netsnmp_feature_child_of(ipIfStatsTable_container_get, ipIfStatsTable_external_access) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipIfStatsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.3, length: 9 + */ +typedef struct ipIfStatsTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + ipIfStatsTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_long last_changed; + +} ipIfStatsTable_interface_ctx; + +static ipIfStatsTable_interface_ctx ipIfStatsTable_if_ctx; + +static void _ipIfStatsTable_container_init(ipIfStatsTable_interface_ctx + * if_ctx); +static void +_ipIfStatsTable_container_shutdown(ipIfStatsTable_interface_ctx * if_ctx); + +#ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_GET +netsnmp_container * +ipIfStatsTable_container_get(void) +{ + return ipIfStatsTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_GET +ipIfStatsTable_registration * +ipIfStatsTable_registration_get(void) +{ + return ipIfStatsTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_SET +ipIfStatsTable_registration * +ipIfStatsTable_registration_set(ipIfStatsTable_registration * newreg) +{ + ipIfStatsTable_registration *old = ipIfStatsTable_if_ctx.user_ctx; + ipIfStatsTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_SIZE +int +ipIfStatsTable_container_size(void) +{ + return CONTAINER_SIZE(ipIfStatsTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_SIZE */ + +/* + * ipIfStatsTableLastChanged, which is the last time that a row in + * the table was changed or the last time a row was added/deleted from the + * table. + */ +void +ipIfStatsTable_lastChange_set(u_long table_changed) +{ + DEBUGMSGTL(("ipIfStatsTable:lastChanged_set", + "called. was %ld, now %ld\n", + ipIfStatsTable_if_ctx.last_changed, table_changed)); + ipIfStatsTable_if_ctx.last_changed = table_changed; +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipIfStatsTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipIfStatsTable_post_request; +static Netsnmp_Node_Handler _mfd_ipIfStatsTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipIfStatsTable_get_values; +/** + * @internal + * Initialize the table ipIfStatsTable + * (Define its contents and how it's structured) + */ +void +_ipIfStatsTable_initialize_interface(ipIfStatsTable_registration * reg_ptr, + u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipIfStatsTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipIfStatsTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipIfStatsTable:_ipIfStatsTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipIfStatsTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipIfStatsIPVersion */ + ASN_INTEGER, + /** index: ipIfStatsIfIndex */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPIFSTATSTABLE_MIN_COL; + tbl_info->max_column = IPIFSTATSTABLE_MAX_COL; + + /* + * save users context + */ + ipIfStatsTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipIfStatsTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipIfStatsTable_container_init(&ipIfStatsTable_if_ctx); + if (NULL == ipIfStatsTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipIfStatsTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_ipIfStatsTable_object_lookup; + access_multiplexer->get_values = _mfd_ipIfStatsTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_ipIfStatsTable_pre_request; + access_multiplexer->post_request = _mfd_ipIfStatsTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipIfStatsTable:init_ipIfStatsTable", + "Registering ipIfStatsTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipIfStatsTable", handler, + ipIfStatsTable_oid, + ipIfStatsTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY); + if (NULL == reginfo) { + snmp_log(LOG_ERR, "error registering table ipIfStatsTable\n"); + return; + } + reginfo->my_reg_void = &ipIfStatsTable_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; + +#ifndef NETSNMP_NO_WRITE_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 */ + + 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, + ipIfStatsTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != ipIfStatsTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(ipIfStatsTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + + /* + * register LastChanged + */ + { + oid lc_oid[] = { IPIFSTATSTABLELASTCHANGE_OID }; + netsnmp_register_watched_scalar2(netsnmp_create_handler_registration + ("ipIfStatsTableLastChanged", NULL, + lc_oid, OID_LENGTH(lc_oid), + HANDLER_CAN_RONLY), + netsnmp_create_watcher_info((void + *) + &ipIfStatsTable_if_ctx. + last_changed, + sizeof + (u_long), + ASN_TIMETICKS, + WATCHER_FIXED_SIZE)); + } +} /* _ipIfStatsTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipIfStatsTable + */ +void +_ipIfStatsTable_shutdown_interface(ipIfStatsTable_registration * reg_ptr) +{ + /* + * shutdown the container + */ + _ipIfStatsTable_container_shutdown(&ipIfStatsTable_if_ctx); +} + +void +ipIfStatsTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipIfStatsTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipIfStatsTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipIfStatsTable_index_to_oid(netsnmp_index * oid_idx, + ipIfStatsTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipIfStatsIPVersion; + /* + * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipIfStatsIfIndex; + + /* + * set up varbinds + */ + memset(&var_ipIfStatsIPVersion, 0x00, sizeof(var_ipIfStatsIPVersion)); + var_ipIfStatsIPVersion.type = ASN_INTEGER; + memset(&var_ipIfStatsIfIndex, 0x00, sizeof(var_ipIfStatsIfIndex)); + var_ipIfStatsIfIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipIfStatsIPVersion.next_variable = &var_ipIfStatsIfIndex; + var_ipIfStatsIfIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_index_to_oid", + "called\n")); + + /* + * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_ipIfStatsIPVersion, + (u_char *) & mib_idx->ipIfStatsIPVersion, + sizeof(mib_idx->ipIfStatsIPVersion)); + + /* + * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_ipIfStatsIfIndex, + (u_char *) & mib_idx->ipIfStatsIfIndex, + sizeof(mib_idx->ipIfStatsIfIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipIfStatsIPVersion); + 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_ipIfStatsIPVersion); + + return err; +} /* ipIfStatsTable_index_to_oid */ + +/** + * extract ipIfStatsTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipIfStatsTable_index_from_oid(netsnmp_index * oid_idx, + ipIfStatsTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipIfStatsIPVersion; + /* + * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipIfStatsIfIndex; + + /* + * set up varbinds + */ + memset(&var_ipIfStatsIPVersion, 0x00, sizeof(var_ipIfStatsIPVersion)); + var_ipIfStatsIPVersion.type = ASN_INTEGER; + memset(&var_ipIfStatsIfIndex, 0x00, sizeof(var_ipIfStatsIfIndex)); + var_ipIfStatsIfIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipIfStatsIPVersion.next_variable = &var_ipIfStatsIfIndex; + var_ipIfStatsIfIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_index_from_oid", + "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipIfStatsIPVersion); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipIfStatsIPVersion = + *((u_long *) var_ipIfStatsIPVersion.val.string); + mib_idx->ipIfStatsIfIndex = + *((long *) var_ipIfStatsIfIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipIfStatsIPVersion); + + return err; +} /* ipIfStatsTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipIfStatsTable_rowreq_ctx + */ +ipIfStatsTable_rowreq_ctx * +ipIfStatsTable_allocate_rowreq_ctx(ipIfStatsTable_data * data, + void *user_init_ctx) +{ + ipIfStatsTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipIfStatsTable_rowreq_ctx); + + DEBUGMSGTL(("internal:ipIfStatsTable:ipIfStatsTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipIfStatsTable_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 = ipIfStatsTable_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->ipIfStatsTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipIfStatsTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { + ipIfStatsTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipIfStatsTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipIfStatsTable_rowreq_ctx + */ +void +ipIfStatsTable_release_rowreq_ctx(ipIfStatsTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipIfStatsTable:ipIfStatsTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipIfStatsTable_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)) + ipIfStatsTable_release_data(rowreq_ctx->data); + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* ipIfStatsTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipIfStatsTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_pre_request", + "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipIfStatsTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipIfStatsTable_pre_request(ipIfStatsTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipIfStatsTable", "error %d from " + "ipIfStatsTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipIfStatsTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipIfStatsTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipIfStatsTable_rowreq_ctx *rowreq_ctx = (ipIfStatsTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_post_request", + "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipIfStatsTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipIfStatsTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + rc = ipIfStatsTable_post_request(ipIfStatsTable_if_ctx.user_ctx, + packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipIfStatsTable", "error %d from " + "ipIfStatsTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipIfStatsTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipIfStatsTable_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; + ipIfStatsTable_rowreq_ctx *rowreq_ctx = (ipIfStatsTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipIfStatsTable_interface_ctx *if_ctx = + * (ipIfStatsTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + rc = SNMP_ERR_NOCREATION; + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipIfStatsTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipIfStatsTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipIfStatsTable_get_column(ipIfStatsTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_get_column", + "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipIfStatsInReceives(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINRECEIVES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInReceives_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINRECEIVES: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInReceives_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsInOctets(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInOctets_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInOctets_get(rowreq_ctx, (U64 *) var->val.string); + break; + + /* + * ipIfStatsInHdrErrors(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINHDRERRORS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInHdrErrors_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInNoRoutes(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINNOROUTES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInNoRoutes_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInAddrErrors(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINADDRERRORS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInAddrErrors_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInUnknownProtos(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINUNKNOWNPROTOS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInUnknownProtos_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInTruncatedPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINTRUNCATEDPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInTruncatedPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInForwDatagrams(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINFORWDATAGRAMS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInForwDatagrams_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINFORWDATAGRAMS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInForwDatagrams_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsReasmReqds(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSREASMREQDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsReasmReqds_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsReasmOKs(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSREASMOKS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsReasmOKs_get(rowreq_ctx, (u_long *) var->val.string); + break; + + /* + * ipIfStatsReasmFails(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSREASMFAILS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsReasmFails_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInDiscards(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINDISCARDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInDiscards_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsInDelivers(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINDELIVERS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInDelivers_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINDELIVERS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInDelivers_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutRequests(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTREQUESTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutRequests_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTREQUESTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutRequests_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutForwDatagrams(23)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTFORWDATAGRAMS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutForwDatagrams_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTFORWDATAGRAMS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutForwDatagrams_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutDiscards(25)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTDISCARDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutDiscards_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsOutFragReqds(26)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTFRAGREQDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutFragReqds_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsOutFragOKs(27)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTFRAGOKS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutFragOKs_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsOutFragFails(28)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTFRAGFAILS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutFragFails_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsOutFragCreates(29)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTFRAGCREATES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutFragCreates_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsOutTransmits(30)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTTRANSMITS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutTransmits_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTTRANSMITS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutTransmits_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutOctets(32)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutOctets_get(rowreq_ctx, (U64 *) var->val.string); + break; + + /* + * ipIfStatsInMcastPkts(34)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINMCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInMcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINMCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInMcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsInMcastOctets(36)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINMCASTOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInMcastOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINMCASTOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInMcastOctets_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutMcastPkts(38)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTMCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutMcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTMCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutMcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutMcastOctets(40)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTMCASTOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutMcastOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTMCASTOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutMcastOctets_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsInBcastPkts(42)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSINBCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsInBcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCINBCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCInBcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsOutBcastPkts(44)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSOUTBCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipIfStatsOutBcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSHCOUTBCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipIfStatsHCOutBcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipIfStatsDiscontinuityTime(46)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSDISCONTINUITYTIME: + var->val_len = sizeof(u_long); + var->type = ASN_TIMETICKS; + rc = ipIfStatsDiscontinuityTime_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipIfStatsRefreshRate(47)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPIFSTATSREFRESHRATE: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipIfStatsRefreshRate_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + if (IPIFSTATSTABLE_MIN_COL <= column + && column <= IPIFSTATSTABLE_MAX_COL) { + DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_get_column", "assume column %d is reserved\n", column)); + rc = MFD_SKIP; + } else { + snmp_log(LOG_ERR, + "unknown column %d in _ipIfStatsTable_get_column\n", + column); + } + break; + } + + return rc; +} /* _ipIfStatsTable_get_column */ + +int +_mfd_ipIfStatsTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipIfStatsTable_rowreq_ctx *rowreq_ctx = (ipIfStatsTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_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 = _ipIfStatsTable_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_ipIfStatsTable_get_values */ + + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * SET PROCESSING NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +static void _container_free(netsnmp_container * container); + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:ipIfStatsTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for ipIfStatsTable_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 ipIfStatsTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipIfStatsTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in ipIfStatsTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(ipIfStatsTable_rowreq_ctx * rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:ipIfStatsTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipIfStatsTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container * container) +{ + DEBUGMSGTL(("internal:ipIfStatsTable:_container_free", "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipIfStatsTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipIfStatsTable_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 +_ipIfStatsTable_container_init(ipIfStatsTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipIfStatsTable:_ipIfStatsTable_container_init", + "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + ipIfStatsTable_oid, + ipIfStatsTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for ipIfStatsTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipIfStatsTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipIfStatsTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipIfStatsTable_container_init\n"); + return; + } + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _ipIfStatsTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipIfStatsTable_container_shutdown(ipIfStatsTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipIfStatsTable:_ipIfStatsTable_container_shutdown", "called\n")); + + ipIfStatsTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipIfStatsTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_EXTERNAL_ACCESS +ipIfStatsTable_rowreq_ctx * +ipIfStatsTable_row_find_by_mib_index(ipIfStatsTable_mib_index * mib_idx) +{ + ipIfStatsTable_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 = ipIfStatsTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (ipIfStatsTable_rowreq_ctx*)CONTAINER_FIND(ipIfStatsTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_EXTERNAL_ACCESS */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.h b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.h new file mode 100644 index 0000000..c43de84 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.h @@ -0,0 +1,99 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 15899 $ of $ + * + * $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 IPIFSTATSTABLE_INTERFACE_H +#define IPIFSTATSTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipIfStatsTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipIfStatsTable_initialize_interface(ipIfStatsTable_registration * + user_ctx, u_long flags); + void + _ipIfStatsTable_shutdown_interface(ipIfStatsTable_registration * + user_ctx); + + ipIfStatsTable_registration *ipIfStatsTable_registration_get(void); + + ipIfStatsTable_registration + *ipIfStatsTable_registration_set(ipIfStatsTable_registration * + newreg); + + netsnmp_container *ipIfStatsTable_container_get(void); + int ipIfStatsTable_container_size(void); + + ipIfStatsTable_rowreq_ctx + *ipIfStatsTable_allocate_rowreq_ctx(ipIfStatsTable_data *, void *); + void + ipIfStatsTable_release_rowreq_ctx(ipIfStatsTable_rowreq_ctx * + rowreq_ctx); + + int ipIfStatsTable_index_to_oid(netsnmp_index * oid_idx, + ipIfStatsTable_mib_index * + mib_idx); + int ipIfStatsTable_index_from_oid(netsnmp_index * oid_idx, + ipIfStatsTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void ipIfStatsTable_valid_columns_set(netsnmp_column_info + *vc); + + /* + */ + void ipIfStatsTable_lastChange_set(u_long uptime); + + +#ifdef __cplusplus +} +#endif +#endif /* IPIFSTATSTABLE_INTERFACE_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_oids.h b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_oids.h new file mode 100644 index 0000000..76607a9 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_oids.h @@ -0,0 +1,122 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c 12855 2005-09-27 15:56:08Z rstory $ + * + * $Id:$ + */ +#ifndef IPIFSTATSTABLE_OIDS_H +#define IPIFSTATSTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipIfStatsTable + */ +#define IPIFSTATSTABLE_OID 1,3,6,1,2,1,4,31,3 +#define IPIFSTATSTABLELASTCHANGE_OID 1,3,6,1,2,1,4,31,2 + +#define COLUMN_IPIFSTATSIPVERSION 1 + +#define COLUMN_IPIFSTATSIFINDEX 2 + +#define COLUMN_IPIFSTATSINRECEIVES 3 + +#define COLUMN_IPIFSTATSHCINRECEIVES 4 + +#define COLUMN_IPIFSTATSINOCTETS 5 + +#define COLUMN_IPIFSTATSHCINOCTETS 6 + +#define COLUMN_IPIFSTATSINHDRERRORS 7 + +#define COLUMN_IPIFSTATSINNOROUTES 8 + +#define COLUMN_IPIFSTATSINADDRERRORS 9 + +#define COLUMN_IPIFSTATSINUNKNOWNPROTOS 10 + +#define COLUMN_IPIFSTATSINTRUNCATEDPKTS 11 + +#define COLUMN_IPIFSTATSINFORWDATAGRAMS 12 + +#define COLUMN_IPIFSTATSHCINFORWDATAGRAMS 13 + +#define COLUMN_IPIFSTATSREASMREQDS 14 + +#define COLUMN_IPIFSTATSREASMOKS 15 + +#define COLUMN_IPIFSTATSREASMFAILS 16 + +#define COLUMN_IPIFSTATSINDISCARDS 17 + +#define COLUMN_IPIFSTATSINDELIVERS 18 + +#define COLUMN_IPIFSTATSHCINDELIVERS 19 + +#define COLUMN_IPIFSTATSOUTREQUESTS 20 + +#define COLUMN_IPIFSTATSHCOUTREQUESTS 21 + +#define COLUMN_IPIFSTATSOUTFORWDATAGRAMS 23 + +#define COLUMN_IPIFSTATSHCOUTFORWDATAGRAMS 24 + +#define COLUMN_IPIFSTATSOUTDISCARDS 25 + +#define COLUMN_IPIFSTATSOUTFRAGREQDS 26 + +#define COLUMN_IPIFSTATSOUTFRAGOKS 27 + +#define COLUMN_IPIFSTATSOUTFRAGFAILS 28 + +#define COLUMN_IPIFSTATSOUTFRAGCREATES 29 + +#define COLUMN_IPIFSTATSOUTTRANSMITS 30 + +#define COLUMN_IPIFSTATSHCOUTTRANSMITS 31 + +#define COLUMN_IPIFSTATSOUTOCTETS 32 + +#define COLUMN_IPIFSTATSHCOUTOCTETS 33 + +#define COLUMN_IPIFSTATSINMCASTPKTS 34 + +#define COLUMN_IPIFSTATSHCINMCASTPKTS 35 + +#define COLUMN_IPIFSTATSINMCASTOCTETS 36 + +#define COLUMN_IPIFSTATSHCINMCASTOCTETS 37 + +#define COLUMN_IPIFSTATSOUTMCASTPKTS 38 + +#define COLUMN_IPIFSTATSHCOUTMCASTPKTS 39 + +#define COLUMN_IPIFSTATSOUTMCASTOCTETS 40 + +#define COLUMN_IPIFSTATSHCOUTMCASTOCTETS 41 + +#define COLUMN_IPIFSTATSINBCASTPKTS 42 + +#define COLUMN_IPIFSTATSHCINBCASTPKTS 43 + +#define COLUMN_IPIFSTATSOUTBCASTPKTS 44 + +#define COLUMN_IPIFSTATSHCOUTBCASTPKTS 45 + +#define COLUMN_IPIFSTATSDISCONTINUITYTIME 46 + +#define COLUMN_IPIFSTATSREFRESHRATE 47 + + +#define IPIFSTATSTABLE_MIN_COL COLUMN_IPIFSTATSINRECEIVES +#define IPIFSTATSTABLE_MAX_COL COLUMN_IPIFSTATSREFRESHRATE + + + +#ifdef __cplusplus +} +#endif +#endif /* IPIFSTATSTABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable.h b/agent/mibgroup/ip-mib/ipSystemStatsTable.h new file mode 100644 index 0000000..047db74 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable.h @@ -0,0 +1,8 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/data_access/systemstats) +config_require(ip-mib/ipSystemStatsTable/ipSystemStatsTable) +config_require(ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface) +config_require(ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access) diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.c b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.c new file mode 100644 index 0000000..10587e2 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.c @@ -0,0 +1,3321 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for ipSystemStatsTable + * + * \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 "ipSystemStatsTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipSystemStatsTable_interface.h" + +const oid ipSystemStatsTable_oid[] = { IPSYSTEMSTATSTABLE_OID }; +const int ipSystemStatsTable_oid_size = +OID_LENGTH(ipSystemStatsTable_oid); + +ipSystemStatsTable_registration ipSystemStatsTable_user_context; +static ipSystemStatsTable_registration *ipSystemStatsTable_user_context_p; + +void initialize_table_ipSystemStatsTable(void); +void shutdown_table_ipSystemStatsTable(void); + + +/** + * Initializes the ipSystemStatsTable module + */ +void +init_ipSystemStatsTable(void) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:init_ipSystemStatsTable", + "called\n")); + + /* + * TODO:300:o: Perform ipSystemStatsTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipSystemStatsTable")) + initialize_table_ipSystemStatsTable(); + +} /* init_ipSystemStatsTable */ + +/** + * Shut-down the ipSystemStatsTable module (agent is exiting) + */ +void +shutdown_ipSystemStatsTable(void) +{ + if (should_init("ipSystemStatsTable")) + shutdown_table_ipSystemStatsTable(); + +} + +/** + * Initialize the table ipSystemStatsTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipSystemStatsTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipSystemStatsTable:initialize_table_ipSystemStatsTable", "called\n")); + + /* + * TODO:301:o: Perform ipSystemStatsTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipSystemStatsTable 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. + */ + ipSystemStatsTable_user_context_p = + netsnmp_create_data_list("ipSystemStatsTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipSystemStatsTable_initialize_interface + (ipSystemStatsTable_user_context_p, flags); +} /* initialize_table_ipSystemStatsTable */ + +/** + * Shutdown the table ipSystemStatsTable + */ +void +shutdown_table_ipSystemStatsTable(void) +{ + /* + * call interface shutdown code + */ + _ipSystemStatsTable_shutdown_interface + (ipSystemStatsTable_user_context_p); + netsnmp_free_all_list_data(ipSystemStatsTable_user_context_p); + ipSystemStatsTable_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 +ipSystemStatsTable_rowreq_ctx_init(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipSystemStatsTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* ipSystemStatsTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipSystemStatsTable_rowreq_ctx_cleanup(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipSystemStatsTable rowreq cleanup. + */ + netsnmp_access_systemstats_entry_free(rowreq_ctx->data); + rowreq_ctx->data = NULL; +} /* ipSystemStatsTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * @param user_context + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipSystemStatsTable_pre_request(ipSystemStatsTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform ipSystemStatsTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipSystemStatsTable_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 +ipSystemStatsTable_post_request(ipSystemStatsTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform ipSystemStatsTable post-request actions. + */ + + return MFD_SUCCESS; +} /* ipSystemStatsTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table ipSystemStatsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.1, length: 9 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipSystemStatsTable data context functions. + */ +/* + * ipSystemStatsTable_allocate_data + * + * Purpose: create new ipSystemStatsTable_data. + */ +ipSystemStatsTable_data * +ipSystemStatsTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the ipSystemStatsTable data context. + */ + ipSystemStatsTable_data *rtn = + SNMP_MALLOC_TYPEDEF(ipSystemStatsTable_data); + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_allocate_data", "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipSystemStatsTable_data.\n"); + } + + return rtn; +} /* ipSystemStatsTable_allocate_data */ + +/* + * ipSystemStatsTable_release_data + * + * Purpose: release ipSystemStatsTable data. + */ +void +ipSystemStatsTable_release_data(ipSystemStatsTable_data * data) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_release_data", "called\n")); + + /* + * TODO:202:r: |-> release memory for the ipSystemStatsTable data context. + */ + free(data); +} /* ipSystemStatsTable_release_data */ + + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipSystemStatsIPVersion_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 +ipSystemStatsTable_indexes_set_tbl_idx(ipSystemStatsTable_mib_index * + tbl_idx, + u_long ipSystemStatsIPVersion_val) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + /** WARNING: this code might not work for netsnmp_systemstats_entry */ + tbl_idx->ipSystemStatsIPVersion = ipSystemStatsIPVersion_val; + + + return MFD_SUCCESS; +} /* ipSystemStatsTable_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 +ipSystemStatsTable_indexes_set(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long ipSystemStatsIPVersion_val) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_indexes_set", "called\n")); + + if (MFD_SUCCESS != + ipSystemStatsTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipSystemStatsIPVersion_val)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != ipSystemStatsTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipSystemStatsTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInReceives + * ipSystemStatsInReceives is subid 3 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.3 + * Description: +The total number of input IP datagrams received, including + those received in error. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInReceives data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInReceives_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 +ipSystemStatsInReceives_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInReceives_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInReceives_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInReceives_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInReceives data. + * copy (* ipSystemStatsInReceives_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES]) + return MFD_SKIP; + + (*ipSystemStatsInReceives_val_ptr) = + rowreq_ctx->data->stats.HCInReceives.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInReceives_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInReceives + * ipSystemStatsHCInReceives is subid 4 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.4 + * Description: +The total number of input IP datagrams received, including + those received in error. This object counts the same + datagrams as ipSystemStatsInReceives but allows for larger + + + + + values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInReceives data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInReceives_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInReceives_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCInReceives_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInReceives_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInReceives data. + * get (* ipSystemStatsHCInReceives_val_ptr ).low and (* ipSystemStatsHCInReceives_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES]) + return MFD_SKIP; + + (*ipSystemStatsHCInReceives_val_ptr).low = + rowreq_ctx->data->stats.HCInReceives.low; + (*ipSystemStatsHCInReceives_val_ptr).high = + rowreq_ctx->data->stats.HCInReceives.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInReceives_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInOctets + * ipSystemStatsInOctets is subid 5 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.5 + * Description: +The total number of octets received in input IP datagrams, + including those received in error. Octets from datagrams + counted in ipSystemStatsInReceives MUST be counted here. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInOctets_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 +ipSystemStatsInOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInOctets_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInOctets data. + * copy (* ipSystemStatsInOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsInOctets_val_ptr) = + rowreq_ctx->data->stats.HCInOctets.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInOctets + * ipSystemStatsHCInOctets is subid 6 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.6 + * Description: +The total number of octets received in input IP datagrams, + including those received in error. This object counts the + same octets as ipSystemStatsInOctets but allows for larger + values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCInOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInOctets data. + * get (* ipSystemStatsHCInOctets_val_ptr ).low and (* ipSystemStatsHCInOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsHCInOctets_val_ptr).low = + rowreq_ctx->data->stats.HCInOctets.low; + (*ipSystemStatsHCInOctets_val_ptr).high = + rowreq_ctx->data->stats.HCInOctets.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInHdrErrors + * ipSystemStatsInHdrErrors is subid 7 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.7 + * Description: +The number of input IP datagrams discarded due to errors in + their IP headers, including version number mismatch, other + format errors, hop count exceeded, errors discovered in + processing their IP options, etc. + + + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInHdrErrors data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInHdrErrors_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 +ipSystemStatsInHdrErrors_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInHdrErrors_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInHdrErrors_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInHdrErrors_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInHdrErrors data. + * copy (* ipSystemStatsInHdrErrors_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS]) + return MFD_SKIP; + + (*ipSystemStatsInHdrErrors_val_ptr) = + rowreq_ctx->data->stats.InHdrErrors; + + return MFD_SUCCESS; +} /* ipSystemStatsInHdrErrors_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInNoRoutes + * ipSystemStatsInNoRoutes is subid 8 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.8 + * Description: +The number of input IP datagrams discarded because no route + could be found to transmit them to their destination. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInNoRoutes data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInNoRoutes_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 +ipSystemStatsInNoRoutes_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInNoRoutes_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInNoRoutes_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInNoRoutes_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInNoRoutes data. + * copy (* ipSystemStatsInNoRoutes_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINNOROUTES]) + return MFD_SKIP; + + (*ipSystemStatsInNoRoutes_val_ptr) = + rowreq_ctx->data->stats.HCInNoRoutes.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInNoRoutes_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInAddrErrors + * ipSystemStatsInAddrErrors is subid 9 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.9 + * Description: +The number of input IP datagrams discarded because the IP + address in their IP header's destination field was not a + valid address to be received at this entity. This count + includes invalid addresses (e.g., ::0) and unsupported + addresses (e.g., addresses with unallocated prefixes). For + entities which are not IP routers and therefore do not + forward datagrams, this counter includes datagrams discarded + because the destination address was not a local address. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInAddrErrors data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInAddrErrors_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 +ipSystemStatsInAddrErrors_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInAddrErrors_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInAddrErrors_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInAddrErrors_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInAddrErrors data. + * copy (* ipSystemStatsInAddrErrors_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INADDRERRORS]) + return MFD_SKIP; + + (*ipSystemStatsInAddrErrors_val_ptr) = + rowreq_ctx->data->stats.InAddrErrors; + + return MFD_SUCCESS; +} /* ipSystemStatsInAddrErrors_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInUnknownProtos + * ipSystemStatsInUnknownProtos is subid 10 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.10 + * Description: +The number of locally-addressed IP datagrams received + successfully but discarded because of an unknown or + unsupported protocol. + + + + + When tracking interface statistics the counter of the + interface to which these datagrams were addressed is + incremented. This interface might not be the same as the + input interface for some of the datagrams. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInUnknownProtos data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInUnknownProtos_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 +ipSystemStatsInUnknownProtos_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInUnknownProtos_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInUnknownProtos_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInUnknownProtos_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInUnknownProtos data. + * copy (* ipSystemStatsInUnknownProtos_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INUNKNOWNPROTOS]) + return MFD_SKIP; + + (*ipSystemStatsInUnknownProtos_val_ptr) = + rowreq_ctx->data->stats.InUnknownProtos; + + return MFD_SUCCESS; +} /* ipSystemStatsInUnknownProtos_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInTruncatedPkts + * ipSystemStatsInTruncatedPkts is subid 11 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.11 + * Description: +The number of input IP datagrams discarded because the + datagram frame didn't carry enough data. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInTruncatedPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInTruncatedPkts_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 +ipSystemStatsInTruncatedPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInTruncatedPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInTruncatedPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInTruncatedPkts_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInTruncatedPkts data. + * copy (* ipSystemStatsInTruncatedPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INTRUNCATEDPKTS]) + return MFD_SKIP; + + (*ipSystemStatsInTruncatedPkts_val_ptr) = + rowreq_ctx->data->stats.InTruncatedPkts; + + return MFD_SUCCESS; +} /* ipSystemStatsInTruncatedPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInForwDatagrams + * ipSystemStatsInForwDatagrams is subid 12 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.12 + * Description: +The number of input datagrams for which this entity was not + their final IP destination and for which this entity + attempted to find a route to forward them to that final + destination. In entities which do not act as IP routers, + this counter will include only those datagrams which were + Source-Routed via this entity, and the Source-Route + processing was successful. + + + When tracking interface statistics the counter of the + incoming interface is incremented for each datagram. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInForwDatagrams_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 +ipSystemStatsInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInForwDatagrams_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInForwDatagrams_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInForwDatagrams data. + * copy (* ipSystemStatsInForwDatagrams_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipSystemStatsInForwDatagrams_val_ptr) = + rowreq_ctx->data->stats.HCInForwDatagrams.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInForwDatagrams + * ipSystemStatsHCInForwDatagrams is subid 13 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.13 + * Description: +The number of input datagrams for which this entity was not + their final IP destination and for which this entity + attempted to find a route to forward them to that final + destination. This object counts the same packets as + ipSystemStatsInForwDatagrams but allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInForwDatagrams_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInForwDatagrams_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInForwDatagrams data. + * get (* ipSystemStatsHCInForwDatagrams_val_ptr ).low and (* ipSystemStatsHCInForwDatagrams_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipSystemStatsHCInForwDatagrams_val_ptr).low = + rowreq_ctx->data->stats.HCInForwDatagrams.low; + (*ipSystemStatsHCInForwDatagrams_val_ptr).high = + rowreq_ctx->data->stats.HCInForwDatagrams.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsReasmReqds + * ipSystemStatsReasmReqds is subid 14 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.14 + * Description: +The number of IP fragments received which needed to be + reassembled at this interface. + + + When tracking interface statistics the counter of the + interface to which these fragments were addressed is + incremented. This interface might not be the same as the + input interface for some of the fragments. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsReasmReqds data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsReasmReqds_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 +ipSystemStatsReasmReqds_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsReasmReqds_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsReasmReqds_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsReasmReqds_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsReasmReqds data. + * copy (* ipSystemStatsReasmReqds_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMREQDS]) + return MFD_SKIP; + + (*ipSystemStatsReasmReqds_val_ptr) = + rowreq_ctx->data->stats.ReasmReqds; + + return MFD_SUCCESS; +} /* ipSystemStatsReasmReqds_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsReasmOKs + * ipSystemStatsReasmOKs is subid 15 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.15 + * Description: +The number of IP datagrams successfully reassembled. + + + When tracking interface statistics the counter of the + interface to which these datagrams were addressed is + incremented. This interface might not be the same as the + input interface for some of the datagrams. + + + Discontinuities in the value of this counter can occur at + + + + + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsReasmOKs data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsReasmOKs_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 +ipSystemStatsReasmOKs_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsReasmOKs_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsReasmOKs_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsReasmOKs_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsReasmOKs data. + * copy (* ipSystemStatsReasmOKs_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMOKS]) + return MFD_SKIP; + + (*ipSystemStatsReasmOKs_val_ptr) = rowreq_ctx->data->stats.ReasmOKs; + + return MFD_SUCCESS; +} /* ipSystemStatsReasmOKs_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsReasmFails + * ipSystemStatsReasmFails is subid 16 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.16 + * Description: +The number of failures detected by the IP re-assembly + algorithm (for whatever reason: timed out, errors, etc.). + Note that this is not necessarily a count of discarded IP + fragments since some algorithms (notably the algorithm in + RFC 815) can lose track of the number of fragments by + combining them as they are received. + + + When tracking interface statistics the counter of the + interface to which these fragments were addressed is + incremented. This interface might not be the same as the + input interface for some of the fragments. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsReasmFails data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsReasmFails_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 +ipSystemStatsReasmFails_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsReasmFails_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsReasmFails_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsReasmFails_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsReasmFails data. + * copy (* ipSystemStatsReasmFails_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REASMFAILS]) + return MFD_SKIP; + + (*ipSystemStatsReasmFails_val_ptr) = + rowreq_ctx->data->stats.ReasmFails; + + return MFD_SUCCESS; +} /* ipSystemStatsReasmFails_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInDiscards + * ipSystemStatsInDiscards is subid 17 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.17 + * Description: +The number of input IP datagrams for which no problems were + encountered to prevent their continued processing, but which + were discarded (e.g., for lack of buffer space). Note that + this counter does not include any datagrams discarded while + awaiting re-assembly. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInDiscards data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInDiscards_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 +ipSystemStatsInDiscards_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInDiscards_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInDiscards_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInDiscards_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInDiscards data. + * copy (* ipSystemStatsInDiscards_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_INDISCARDS]) + return MFD_SKIP; + + (*ipSystemStatsInDiscards_val_ptr) = + rowreq_ctx->data->stats.InDiscards; + + return MFD_SUCCESS; +} /* ipSystemStatsInDiscards_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInDelivers + * ipSystemStatsInDelivers is subid 18 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.18 + * Description: +The total number of datagrams successfully delivered to IP + user-protocols (including ICMP). + + + When tracking interface statistics the counter of the + interface to which these datagrams were addressed is + incremented. This interface might not be the same as the + input interface for some of the datagrams. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInDelivers data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInDelivers_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 +ipSystemStatsInDelivers_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInDelivers_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInDelivers_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInDelivers_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInDelivers data. + * copy (* ipSystemStatsInDelivers_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS]) + return MFD_SKIP; + + (*ipSystemStatsInDelivers_val_ptr) = + rowreq_ctx->data->stats.HCInDelivers.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInDelivers_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInDelivers + * ipSystemStatsHCInDelivers is subid 19 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.19 + * Description: +The total number of datagrams successfully delivered to IP + user-protocols (including ICMP). This object counts the + same packets as ipSystemStatsInDelivers but allows for + larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInDelivers data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInDelivers_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInDelivers_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCInDelivers_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInDelivers_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInDelivers data. + * get (* ipSystemStatsHCInDelivers_val_ptr ).low and (* ipSystemStatsHCInDelivers_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINDELIVERS]) + return MFD_SKIP; + + (*ipSystemStatsHCInDelivers_val_ptr).low = + rowreq_ctx->data->stats.HCInDelivers.low; + (*ipSystemStatsHCInDelivers_val_ptr).high = + rowreq_ctx->data->stats.HCInDelivers.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInDelivers_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutRequests + * ipSystemStatsOutRequests is subid 20 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.20 + * Description: +The total number of IP datagrams which local IP user- + protocols (including ICMP) supplied to IP in requests for + transmission. Note that this counter does not include any + datagrams counted in ipSystemStatsOutForwDatagrams. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutRequests data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutRequests_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 +ipSystemStatsOutRequests_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutRequests_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutRequests_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutRequests_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutRequests data. + * copy (* ipSystemStatsOutRequests_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS]) + return MFD_SKIP; + + (*ipSystemStatsOutRequests_val_ptr) = + rowreq_ctx->data->stats.HCOutRequests.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutRequests_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutRequests + * ipSystemStatsHCOutRequests is subid 21 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.21 + * Description: +The total number of IP datagrams which local IP user- + protocols (including ICMP) supplied to IP in requests for + transmission. This object counts the same packets as + ipSystemStatsHCOutRequests but allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutRequests data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutRequests_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutRequests_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCOutRequests_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutRequests_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutRequests data. + * get (* ipSystemStatsHCOutRequests_val_ptr ).low and (* ipSystemStatsHCOutRequests_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTREQUESTS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutRequests_val_ptr).low = + rowreq_ctx->data->stats.HCOutRequests.low; + (*ipSystemStatsHCOutRequests_val_ptr).high = + rowreq_ctx->data->stats.HCOutRequests.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutRequests_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutNoRoutes + * ipSystemStatsOutNoRoutes is subid 22 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.22 + * Description: +The number of locally generated IP datagrams discarded + because no route could be found to transmit them to their + destination. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutNoRoutes data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutNoRoutes_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 +ipSystemStatsOutNoRoutes_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutNoRoutes_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutNoRoutes_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutNoRoutes_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutNoRoutes data. + * copy (* ipSystemStatsOutNoRoutes_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTNOROUTES]) + return MFD_SKIP; + + (*ipSystemStatsOutNoRoutes_val_ptr) = + rowreq_ctx->data->stats.HCOutNoRoutes.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutNoRoutes_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutForwDatagrams + * ipSystemStatsOutForwDatagrams is subid 23 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.23 + * Description: +The number of datagrams for which this entity was not their + final IP destination and for which it was successful in + finding a path to their final destination. In entities + which do not act as IP routers, this counter will include + only those datagrams which were Source-Routed via this + entity, and the Source-Route processing was successful. + + + When tracking interface statistics the counter of the + outgoing interface is incremented for a successfully + forwarded datagram. + + + Discontinuities in the value of this counter can occur at + + + + + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutForwDatagrams_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 +ipSystemStatsOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutForwDatagrams_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutForwDatagrams_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutForwDatagrams data. + * copy (* ipSystemStatsOutForwDatagrams_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipSystemStatsOutForwDatagrams_val_ptr) = + rowreq_ctx->data->stats.HCOutForwDatagrams.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutForwDatagrams + * ipSystemStatsHCOutForwDatagrams is subid 24 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.24 + * Description: +The number of datagrams for which this entity was not their + final IP destination and for which it was successful in + finding a path to their final destination. This object + counts the same packets as ipSystemStatsOutForwDatagrams but + allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutForwDatagrams data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutForwDatagrams_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutForwDatagrams_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutForwDatagrams_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutForwDatagrams data. + * get (* ipSystemStatsHCOutForwDatagrams_val_ptr ).low and (* ipSystemStatsHCOutForwDatagrams_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFORWDATAGRAMS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutForwDatagrams_val_ptr).low = + rowreq_ctx->data->stats.HCOutForwDatagrams.low; + (*ipSystemStatsHCOutForwDatagrams_val_ptr).high = + rowreq_ctx->data->stats.HCOutForwDatagrams.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutForwDatagrams_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutDiscards + * ipSystemStatsOutDiscards is subid 25 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.25 + * Description: +The number of output IP datagrams for which no problem was + encountered to prevent their transmission to their + destination, but which were discarded (e.g., for lack of + buffer space). Note that this counter would include + datagrams counted in ipSystemStatsOutForwDatagrams if any + such datagrams met this (discretionary) discard criterion. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutDiscards data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutDiscards_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 +ipSystemStatsOutDiscards_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutDiscards_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutDiscards_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutDiscards_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutDiscards data. + * copy (* ipSystemStatsOutDiscards_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS]) + return MFD_SKIP; + + (*ipSystemStatsOutDiscards_val_ptr) = + rowreq_ctx->data->stats.HCOutDiscards.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutDiscards_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutFragReqds + * ipSystemStatsOutFragReqds is subid 26 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.26 + * Description: +The number of IP datagrams that would require fragmentation + in order to be transmitted. + + + + + + When tracking interface statistics the counter of the + outgoing interface is incremented for a successfully + fragmented datagram. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutFragReqds data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutFragReqds_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 +ipSystemStatsOutFragReqds_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutFragReqds_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutFragReqds_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutFragReqds_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutFragReqds data. + * copy (* ipSystemStatsOutFragReqds_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGREQDS]) + return MFD_SKIP; + + (*ipSystemStatsOutFragReqds_val_ptr) = + rowreq_ctx->data->stats.HCOutFragReqds.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutFragReqds_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutFragOKs + * ipSystemStatsOutFragOKs is subid 27 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.27 + * Description: +The number of IP datagrams that have been successfully + fragmented. + + + When tracking interface statistics the counter of the + outgoing interface is incremented for a successfully + fragmented datagram. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutFragOKs data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutFragOKs_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 +ipSystemStatsOutFragOKs_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutFragOKs_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutFragOKs_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutFragOKs_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutFragOKs data. + * copy (* ipSystemStatsOutFragOKs_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGOKS]) + return MFD_SKIP; + + (*ipSystemStatsOutFragOKs_val_ptr) = + rowreq_ctx->data->stats.HCOutFragOKs.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutFragOKs_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutFragFails + * ipSystemStatsOutFragFails is subid 28 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.28 + * Description: +The number of IP datagrams that have been discarded because + they needed to be fragmented but could not be. This + includes IPv4 packets that have the DF bit set and IPv6 + packets that are being forwarded and exceed the outgoing + link MTU. + + + When tracking interface statistics the counter of the + outgoing interface is incremented for an unsuccessfully + fragmented datagram. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutFragFails data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutFragFails_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 +ipSystemStatsOutFragFails_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutFragFails_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutFragFails_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutFragFails_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutFragFails data. + * copy (* ipSystemStatsOutFragFails_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGFAILS]) + return MFD_SKIP; + + (*ipSystemStatsOutFragFails_val_ptr) = + rowreq_ctx->data->stats.HCOutFragFails.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutFragFails_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutFragCreates + * ipSystemStatsOutFragCreates is subid 29 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.29 + * Description: +The number of output datagram fragments that have been + generated as a result of IP fragmentation. + + + When tracking interface statistics the counter of the + outgoing interface is incremented for a successfully + fragmented datagram. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutFragCreates data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutFragCreates_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 +ipSystemStatsOutFragCreates_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * + ipSystemStatsOutFragCreates_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutFragCreates_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutFragCreates_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutFragCreates data. + * copy (* ipSystemStatsOutFragCreates_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES]) + return MFD_SKIP; + + (*ipSystemStatsOutFragCreates_val_ptr) = + rowreq_ctx->data->stats.HCOutFragCreates.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutFragCreates_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutTransmits + * ipSystemStatsOutTransmits is subid 30 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.30 + * Description: +The total number of IP datagrams that this entity supplied + to the lower layers for transmission. This includes + datagrams generated local and those forwarded by this + entity. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutTransmits data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutTransmits_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 +ipSystemStatsOutTransmits_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutTransmits_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutTransmits_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutTransmits_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutTransmits data. + * copy (* ipSystemStatsOutTransmits_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS]) + return MFD_SKIP; + + (*ipSystemStatsOutTransmits_val_ptr) = + rowreq_ctx->data->stats.HCOutTransmits.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutTransmits_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutTransmits + * ipSystemStatsHCOutTransmits is subid 31 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.31 + * Description: +The total number of IP datagrams that this entity supplied + to the lower layers for transmission. This object counts + the same datagrams as ipSystemStatsOutTransmits but allows + for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutTransmits data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutTransmits_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutTransmits_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCOutTransmits_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutTransmits_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutTransmits data. + * get (* ipSystemStatsHCOutTransmits_val_ptr ).low and (* ipSystemStatsHCOutTransmits_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTTRANSMITS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutTransmits_val_ptr).low = + rowreq_ctx->data->stats.HCOutTransmits.low; + (*ipSystemStatsHCOutTransmits_val_ptr).high = + rowreq_ctx->data->stats.HCOutTransmits.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutTransmits_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutOctets + * ipSystemStatsOutOctets is subid 32 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.32 + * Description: +The total number of octets in IP datagrams delivered to the + lower layers for transmission. Octets from datagrams + counted in ipSystemStatsOutTransmits MUST be counted here. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutOctets_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 +ipSystemStatsOutOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutOctets_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutOctets data. + * copy (* ipSystemStatsOutOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsOutOctets_val_ptr) = + rowreq_ctx->data->stats.HCOutOctets.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutOctets + * ipSystemStatsHCOutOctets is subid 33 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.33 + * Description: +The total number of octets in IP datagrams delivered to the + lower layers for transmission. This objects counts the same + octets as ipSystemStatsOutOctets but allows for larger + values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCOutOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutOctets data. + * get (* ipSystemStatsHCOutOctets_val_ptr ).low and (* ipSystemStatsHCOutOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutOctets_val_ptr).low = + rowreq_ctx->data->stats.HCOutOctets.low; + (*ipSystemStatsHCOutOctets_val_ptr).high = + rowreq_ctx->data->stats.HCOutOctets.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInMcastPkts + * ipSystemStatsInMcastPkts is subid 34 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.34 + * Description: +The number of IP multicast datagrams received. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInMcastPkts_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 +ipSystemStatsInMcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInMcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInMcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInMcastPkts data. + * copy (* ipSystemStatsInMcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsInMcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCInMcastPkts.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInMcastPkts + * ipSystemStatsHCInMcastPkts is subid 35 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.35 + * Description: +The number of IP multicast datagrams received. This object + counts the same datagrams as ipSystemStatsInMcastPkts but + allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInMcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInMcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCInMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInMcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInMcastPkts data. + * get (* ipSystemStatsHCInMcastPkts_val_ptr ).low and (* ipSystemStatsHCInMcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsHCInMcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCInMcastPkts.low; + (*ipSystemStatsHCInMcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCInMcastPkts.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInMcastOctets + * ipSystemStatsInMcastOctets is subid 36 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.36 + * Description: +The total number of octets received in IP multicast + datagrams. Octets from datagrams counted in + ipSystemStatsOutMcastPkts MUST be counted here. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInMcastOctets_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 +ipSystemStatsInMcastOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInMcastOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInMcastOctets_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInMcastOctets data. + * copy (* ipSystemStatsInMcastOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsInMcastOctets_val_ptr) = + rowreq_ctx->data->stats.HCInMcastOctets.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInMcastOctets + * ipSystemStatsHCInMcastOctets is subid 37 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.37 + * Description: +The total number of octets received in IP multicast + datagrams. This object counts the same octets as + ipSystemStatsInMcastOctets but allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInMcastOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInMcastOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInMcastOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInMcastOctets data. + * get (* ipSystemStatsHCInMcastOctets_val_ptr ).low and (* ipSystemStatsHCInMcastOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsHCInMcastOctets_val_ptr).low = + rowreq_ctx->data->stats.HCInMcastOctets.low; + (*ipSystemStatsHCInMcastOctets_val_ptr).high = + rowreq_ctx->data->stats.HCInMcastOctets.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutMcastPkts + * ipSystemStatsOutMcastPkts is subid 38 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.38 + * Description: +The number of IP multicast datagrams transmitted. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutMcastPkts_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 +ipSystemStatsOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutMcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutMcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutMcastPkts data. + * copy (* ipSystemStatsOutMcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsOutMcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCOutMcastPkts.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutMcastPkts + * ipSystemStatsHCOutMcastPkts is subid 39 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.39 + * Description: +The number of IP multicast datagrams transmitted. This + object counts the same datagrams as + ipSystemStatsOutMcastPkts but allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutMcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutMcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCOutMcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutMcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutMcastPkts data. + * get (* ipSystemStatsHCOutMcastPkts_val_ptr ).low and (* ipSystemStatsHCOutMcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutMcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCOutMcastPkts.low; + (*ipSystemStatsHCOutMcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCOutMcastPkts.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutMcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutMcastOctets + * ipSystemStatsOutMcastOctets is subid 40 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.40 + * Description: +The total number of octets transmitted in IP multicast + datagrams. Octets from datagrams counted in + ipSystemStatsInMcastPkts MUST be counted here. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutMcastOctets_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 +ipSystemStatsOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * + ipSystemStatsOutMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutMcastOctets_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutMcastOctets_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutMcastOctets data. + * copy (* ipSystemStatsOutMcastOctets_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsOutMcastOctets_val_ptr) = + rowreq_ctx->data->stats.HCOutMcastOctets.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutMcastOctets + * ipSystemStatsHCOutMcastOctets is subid 41 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.41 + * Description: +The total number of octets transmitted in IP multicast + datagrams. This object counts the same octets as + ipSystemStatsOutMcastOctets but allows for larger values. + + + Discontinuities in the value of this counter can occur at + + + + + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutMcastOctets data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutMcastOctets_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutMcastOctets_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutMcastOctets_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutMcastOctets data. + * get (* ipSystemStatsHCOutMcastOctets_val_ptr ).low and (* ipSystemStatsHCOutMcastOctets_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutMcastOctets_val_ptr).low = + rowreq_ctx->data->stats.HCOutMcastOctets.low; + (*ipSystemStatsHCOutMcastOctets_val_ptr).high = + rowreq_ctx->data->stats.HCOutMcastOctets.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutMcastOctets_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsInBcastPkts + * ipSystemStatsInBcastPkts is subid 42 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.42 + * Description: +The number of IP broadcast datagrams received. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsInBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsInBcastPkts_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 +ipSystemStatsInBcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsInBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsInBcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsInBcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsInBcastPkts data. + * copy (* ipSystemStatsInBcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsInBcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCInBcastPkts.low; + + return MFD_SUCCESS; +} /* ipSystemStatsInBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCInBcastPkts + * ipSystemStatsHCInBcastPkts is subid 43 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.43 + * Description: +The number of IP broadcast datagrams received. This object + counts the same datagrams as ipSystemStatsInBcastPkts but + allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCInBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCInBcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCInBcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCInBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCInBcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCInBcastPkts data. + * get (* ipSystemStatsHCInBcastPkts_val_ptr ).low and (* ipSystemStatsHCInBcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsHCInBcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCInBcastPkts.low; + (*ipSystemStatsHCInBcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCInBcastPkts.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCInBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsOutBcastPkts + * ipSystemStatsOutBcastPkts is subid 44 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.44 + * Description: +The number of IP broadcast datagrams transmitted. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsOutBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsOutBcastPkts_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 +ipSystemStatsOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsOutBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsOutBcastPkts_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsOutBcastPkts_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsOutBcastPkts data. + * copy (* ipSystemStatsOutBcastPkts_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsOutBcastPkts_val_ptr) = + rowreq_ctx->data->stats.HCOutBcastPkts.low; + + return MFD_SUCCESS; +} /* ipSystemStatsOutBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsHCOutBcastPkts + * ipSystemStatsHCOutBcastPkts is subid 45 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.45 + * Description: +The number of IP broadcast datagrams transmitted. This + object counts the same datagrams as + ipSystemStatsOutBcastPkts but allows for larger values. + + + Discontinuities in the value of this counter can occur at + re-initialization of the management system, and at other + times as indicated by the value of + ipSystemStatsDiscontinuityTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER64 (based on perltype COUNTER64) + * The net-snmp type is ASN_COUNTER64. The C type decl is U64 (U64) + */ +/** + * Extract the current value of the ipSystemStatsHCOutBcastPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsHCOutBcastPkts_val_ptr + * Pointer to storage for a U64 variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +ipSystemStatsHCOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + U64 * ipSystemStatsHCOutBcastPkts_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsHCOutBcastPkts_val_ptr); + + /* + * TODO:231:o: |-> copy ipSystemStatsHCOutBcastPkts data. + * get (* ipSystemStatsHCOutBcastPkts_val_ptr ).low and (* ipSystemStatsHCOutBcastPkts_val_ptr ).high from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS]) + return MFD_SKIP; + + (*ipSystemStatsHCOutBcastPkts_val_ptr).low = + rowreq_ctx->data->stats.HCOutBcastPkts.low; + (*ipSystemStatsHCOutBcastPkts_val_ptr).high = + rowreq_ctx->data->stats.HCOutBcastPkts.high; + + return MFD_SUCCESS; +} /* ipSystemStatsHCOutBcastPkts_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsDiscontinuityTime + * ipSystemStatsDiscontinuityTime is subid 46 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.46 + * Description: +The value of sysUpTime on the most recent occasion at which + any one or more of this entry's counters suffered a + discontinuity. + + + If no such discontinuities have occurred since the last re- + initialization of the local management subsystem, then this + object contains a zero value. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is TimeStamp (based on perltype TICKS) + * The net-snmp type is ASN_TIMETICKS. The C type decl is u_long (u_long) + */ +/** + * Extract the current value of the ipSystemStatsDiscontinuityTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsDiscontinuityTime_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 +ipSystemStatsDiscontinuityTime_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsDiscontinuityTime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsDiscontinuityTime_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsDiscontinuityTime_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsDiscontinuityTime data. + * copy (* ipSystemStatsDiscontinuityTime_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_DISCONTINUITYTIME]) + return MFD_SKIP; + + (*ipSystemStatsDiscontinuityTime_val_ptr) = + rowreq_ctx->ipSystemStatsDiscontinuityTime; + + return MFD_SUCCESS; +} /* ipSystemStatsDiscontinuityTime_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipSystemStatsEntry.ipSystemStatsRefreshRate + * ipSystemStatsRefreshRate is subid 47 of ipSystemStatsEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.31.1.1.47 + * Description: +The minimum reasonable polling interval for this entry. + This object provides an indication of the minimum amount of + time required to update the counters in this entry. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is UNSIGNED32 (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 ipSystemStatsRefreshRate data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipSystemStatsRefreshRate_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 +ipSystemStatsRefreshRate_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + u_long * ipSystemStatsRefreshRate_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipSystemStatsRefreshRate_val_ptr); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsRefreshRate_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipSystemStatsRefreshRate data. + * copy (* ipSystemStatsRefreshRate_val_ptr ) from rowreq_ctx->data + */ + if (!rowreq_ctx->data->stats.columnAvail[IPSYSTEMSTATSTABLE_REFRESHRATE]) + return MFD_SKIP; + + (*ipSystemStatsRefreshRate_val_ptr) = + rowreq_ctx->ipSystemStatsRefreshRate; + + return MFD_SUCCESS; +} /* ipSystemStatsRefreshRate_get */ + + + +/** @} */ +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h new file mode 100644 index 0000000..ca1e1f3 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h @@ -0,0 +1,1205 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef IPSYSTEMSTATSTABLE_H +#define IPSYSTEMSTATSTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/ipstats.h> +#include <net-snmp/data_access/systemstats.h> + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-mib/data_access/systemstats) +config_require(ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface) +config_require(ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for ipSystemStatsTable + */ +#include "ipSystemStatsTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipSystemStatsTable(void); + void shutdown_ipSystemStatsTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipSystemStatsTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.1, 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 ipSystemStatsTable registration context. + */ + typedef netsnmp_data_list ipSystemStatsTable_registration; + +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipSystemStatsTable data context structure. + * This structure is used to represent the data for ipSystemStatsTable. + */ + typedef netsnmp_systemstats_entry ipSystemStatsTable_data; + + + /* + * TODO:120:r: |-> Review ipSystemStatsTable mib index. + * This structure is used to represent the index for ipSystemStatsTable. + */ + typedef struct ipSystemStatsTable_mib_index_s { + + /* + * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + u_long ipSystemStatsIPVersion; + + + } ipSystemStatsTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipSystemStatsTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + */ +#define MAX_ipSystemStatsTable_IDX_LEN 1 + + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipSystemStatsTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipSystemStatsTable_rowreq_ctx pointer. + */ + typedef struct ipSystemStatsTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipSystemStatsTable_IDX_LEN]; + + ipSystemStatsTable_mib_index tbl_idx; + + ipSystemStatsTable_data *data; + + /* + * 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 ipSystemStatsTable rowreq context. + */ + char known_missing; + uint32_t ipSystemStatsDiscontinuityTime; + uint32_t ipSystemStatsRefreshRate; + + /* + * storage for future expansion + */ + netsnmp_data_list *ipSystemStatsTable_data_list; + + } ipSystemStatsTable_rowreq_ctx; + + typedef struct ipSystemStatsTable_ref_rowreq_ctx_s { + ipSystemStatsTable_rowreq_ctx *rowreq_ctx; + } ipSystemStatsTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + + + + + + + + + + + + + + + + ipSystemStatsTable_pre_request(ipSystemStatsTable_registration * + user_context); + int + + + + + + + + + + + + + + + + ipSystemStatsTable_post_request(ipSystemStatsTable_registration * + user_context, int rc); + + int + + + + + + + + + + + + + + + + ipSystemStatsTable_rowreq_ctx_init(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + void *user_init_ctx); + void + + + + + + + + + + + + + + + + ipSystemStatsTable_rowreq_ctx_cleanup(ipSystemStatsTable_rowreq_ctx + * rowreq_ctx); + + ipSystemStatsTable_data *ipSystemStatsTable_allocate_data(void); + void ipSystemStatsTable_release_data(ipSystemStatsTable_data + * data); + + + + + + + + + ipSystemStatsTable_rowreq_ctx + * ipSystemStatsTable_row_find_by_mib_index + (ipSystemStatsTable_mib_index * mib_idx); + + extern const oid ipSystemStatsTable_oid[]; + extern const int ipSystemStatsTable_oid_size; + + +#include "ipSystemStatsTable_interface.h" +#include "ipSystemStatsTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipSystemStatsTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.1, length: 9 + */ + /* + * indexes + */ + + int + + + + + + + + + + + + + + + + ipSystemStatsInReceives_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInReceives_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInReceives_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInReceives_val_ptr); + int ipSystemStatsInOctets_get(ipSystemStatsTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipSystemStatsInOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * ipSystemStatsHCInOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInHdrErrors_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInHdrErrors_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInNoRoutes_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInNoRoutes_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInAddrErrors_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInAddrErrors_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInUnknownProtos_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInUnknownProtos_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInTruncatedPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInTruncatedPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInForwDatagrams_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInForwDatagrams_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsReasmReqds_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsReasmReqds_val_ptr); + int ipSystemStatsReasmOKs_get(ipSystemStatsTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipSystemStatsReasmOKs_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsReasmFails_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsReasmFails_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInDiscards_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInDiscards_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInDelivers_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInDelivers_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInDelivers_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInDelivers_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutRequests_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutRequests_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutRequests_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutRequests_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutNoRoutes_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutNoRoutes_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutForwDatagrams_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutForwDatagrams_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutDiscards_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutDiscards_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutFragReqds_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutFragReqds_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutFragOKs_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutFragOKs_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutFragFails_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutFragFails_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutFragCreates_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutFragCreates_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutTransmits_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutTransmits_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutTransmits_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutTransmits_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInMcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInMcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInMcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInMcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInMcastOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInMcastOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInMcastOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInMcastOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutMcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutMcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutMcastOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutMcastOctets_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsInBcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsInBcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCInBcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCInBcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsOutBcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsHCOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + U64 * + ipSystemStatsHCOutBcastPkts_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsDiscontinuityTime_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsDiscontinuityTime_val_ptr); + int + + + + + + + + + + + + + + + + ipSystemStatsRefreshRate_get(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipSystemStatsRefreshRate_val_ptr); + + + int + + + + + + + + + + + + + + + + ipSystemStatsTable_indexes_set_tbl_idx(ipSystemStatsTable_mib_index + * tbl_idx, + u_long + ipSystemStatsIPVersion_val); + int + + + + + + + + + + + + + + + + ipSystemStatsTable_indexes_set(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx, + u_long ipSystemStatsIPVersion_val); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ + + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* IPSYSTEMSTATSTABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_constants.h b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_constants.h new file mode 100644 index 0000000..e9294c4 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_constants.h @@ -0,0 +1,159 @@ +/* + * 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 IPSYSTEMSTATSTABLE_CONSTANTS_H +#define IPSYSTEMSTATSTABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipSystemStatsTable + */ +#define IPSYSTEMSTATSTABLE_OID 1,3,6,1,2,1,4,31,1 + +#define COLUMN_IPSYSTEMSTATSIPVERSION 1 + +#define COLUMN_IPSYSTEMSTATSINRECEIVES 3 + +#define COLUMN_IPSYSTEMSTATSHCINRECEIVES 4 + +#define COLUMN_IPSYSTEMSTATSINOCTETS 5 + +#define COLUMN_IPSYSTEMSTATSHCINOCTETS 6 + +#define COLUMN_IPSYSTEMSTATSINHDRERRORS 7 + +#define COLUMN_IPSYSTEMSTATSINNOROUTES 8 + +#define COLUMN_IPSYSTEMSTATSINADDRERRORS 9 + +#define COLUMN_IPSYSTEMSTATSINUNKNOWNPROTOS 10 + +#define COLUMN_IPSYSTEMSTATSINTRUNCATEDPKTS 11 + +#define COLUMN_IPSYSTEMSTATSINFORWDATAGRAMS 12 + +#define COLUMN_IPSYSTEMSTATSHCINFORWDATAGRAMS 13 + +#define COLUMN_IPSYSTEMSTATSREASMREQDS 14 + +#define COLUMN_IPSYSTEMSTATSREASMOKS 15 + +#define COLUMN_IPSYSTEMSTATSREASMFAILS 16 + +#define COLUMN_IPSYSTEMSTATSINDISCARDS 17 + +#define COLUMN_IPSYSTEMSTATSINDELIVERS 18 + +#define COLUMN_IPSYSTEMSTATSHCINDELIVERS 19 + +#define COLUMN_IPSYSTEMSTATSOUTREQUESTS 20 + +#define COLUMN_IPSYSTEMSTATSHCOUTREQUESTS 21 + +#define COLUMN_IPSYSTEMSTATSOUTNOROUTES 22 + +#define COLUMN_IPSYSTEMSTATSOUTFORWDATAGRAMS 23 + +#define COLUMN_IPSYSTEMSTATSHCOUTFORWDATAGRAMS 24 + +#define COLUMN_IPSYSTEMSTATSOUTDISCARDS 25 + +#define COLUMN_IPSYSTEMSTATSOUTFRAGREQDS 26 + +#define COLUMN_IPSYSTEMSTATSOUTFRAGOKS 27 + +#define COLUMN_IPSYSTEMSTATSOUTFRAGFAILS 28 + +#define COLUMN_IPSYSTEMSTATSOUTFRAGCREATES 29 + +#define COLUMN_IPSYSTEMSTATSOUTTRANSMITS 30 + +#define COLUMN_IPSYSTEMSTATSHCOUTTRANSMITS 31 + +#define COLUMN_IPSYSTEMSTATSOUTOCTETS 32 + +#define COLUMN_IPSYSTEMSTATSHCOUTOCTETS 33 + +#define COLUMN_IPSYSTEMSTATSINMCASTPKTS 34 + +#define COLUMN_IPSYSTEMSTATSHCINMCASTPKTS 35 + +#define COLUMN_IPSYSTEMSTATSINMCASTOCTETS 36 + +#define COLUMN_IPSYSTEMSTATSHCINMCASTOCTETS 37 + +#define COLUMN_IPSYSTEMSTATSOUTMCASTPKTS 38 + +#define COLUMN_IPSYSTEMSTATSHCOUTMCASTPKTS 39 + +#define COLUMN_IPSYSTEMSTATSOUTMCASTOCTETS 40 + +#define COLUMN_IPSYSTEMSTATSHCOUTMCASTOCTETS 41 + +#define COLUMN_IPSYSTEMSTATSINBCASTPKTS 42 + +#define COLUMN_IPSYSTEMSTATSHCINBCASTPKTS 43 + +#define COLUMN_IPSYSTEMSTATSOUTBCASTPKTS 44 + +#define COLUMN_IPSYSTEMSTATSHCOUTBCASTPKTS 45 + +#define COLUMN_IPSYSTEMSTATSDISCONTINUITYTIME 46 + +#define COLUMN_IPSYSTEMSTATSREFRESHRATE 47 + + +#define IPSYSTEMSTATSTABLE_MIN_COL COLUMN_IPSYSTEMSTATSINRECEIVES +#define IPSYSTEMSTATSTABLE_MAX_COL COLUMN_IPSYSTEMSTATSREFRESHRATE + + + /* + * 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 ipSystemStatsTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipSystemStatsIPVersion (InetVersion / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef INETVERSION_ENUMS +#define INETVERSION_ENUMS + +#define INETVERSION_UNKNOWN 0 +#define INETVERSION_IPV4 1 +#define INETVERSION_IPV6 2 + +#endif /* INETVERSION_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPSYSTEMSTATSTABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.c b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.c new file mode 100644 index 0000000..d41bb25 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.c @@ -0,0 +1,400 @@ +/* + * 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 "ipSystemStatsTable.h" + + +#include "ipSystemStatsTable_data_access.h" + +static int ipss_cache_refresh = IPSYSTEMSTATSTABLE_CACHE_TIMEOUT; + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipSystemStatsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.1, length: 9 + */ + +/** + * initialization for ipSystemStatsTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipSystemStatsTable_reg + * Pointer to ipSystemStatsTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipSystemStatsTable_init_data(ipSystemStatsTable_registration * + ipSystemStatsTable_reg) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize ipSystemStatsTable data. + */ + + return MFD_SUCCESS; +} /* ipSystemStatsTable_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 +ipSystemStatsTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipSystemStatsTable_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 = netsnmp_container_find("ipSystemStatsTable:table_container"); + if (NULL != *container_ptr_ptr) + (*container_ptr_ptr)->container_name = strdup("ipSystemStatsTable"); + + if (NULL == cache) { + snmp_log(LOG_ERR, + "bad cache param to ipSystemStatsTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipSystemStatsTable 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 = IPSYSTEMSTATSTABLE_CACHE_TIMEOUT; /* seconds */ + + /* + * don't release resources + */ + cache->flags |= + (NETSNMP_CACHE_DONT_AUTO_RELEASE | NETSNMP_CACHE_DONT_FREE_EXPIRED + | NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD | + NETSNMP_CACHE_AUTO_RELOAD); + ipSystemStatsTable_container_load(*container_ptr_ptr); +} /* ipSystemStatsTable_container_init */ + +/** + * check entry for update + */ +static void +_check_for_updates(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + netsnmp_container *stats) +{ + /* + * check for matching entry. works because indexes are the same. + */ + netsnmp_systemstats_entry *systemstats_entry = (netsnmp_systemstats_entry*) + CONTAINER_FIND(stats, rowreq_ctx->data); + if (NULL == systemstats_entry) { + DEBUGMSGTL(("ipSystemStatsTable:access", + "updating missing entry\n")); + + /* + * mark row as missing, so we can set discontinuity + * when it comes back. + * + * what else should we do? set refresh to 0? that's not quite right... + */ + rowreq_ctx->known_missing = 1; + } else { + DEBUGMSGTL(("ipSystemStatsTable:access", + "updating existing entry\n")); + + /* + * Check for changes & update + */ + netsnmp_access_systemstats_entry_update(rowreq_ctx->data, + systemstats_entry); + + /* + * set discontinuity if previously missing. + */ + if (1 == rowreq_ctx->known_missing) { + rowreq_ctx->known_missing = 0; + rowreq_ctx->ipSystemStatsDiscontinuityTime = + netsnmp_get_agent_uptime(); + } + + /* + * remove entry from container + */ + CONTAINER_REMOVE(stats, systemstats_entry); + netsnmp_access_systemstats_entry_free(systemstats_entry); + } +} + +/** + * add new entry + */ +static void +_add_new(netsnmp_systemstats_entry *systemstats_entry, + netsnmp_container *container) +{ + ipSystemStatsTable_rowreq_ctx *rowreq_ctx; + + DEBUGMSGTL(("ipSystemStatsTable:access", "creating new entry\n")); + + netsnmp_assert(NULL != systemstats_entry); + netsnmp_assert(NULL != container); + + /* + * allocate an row context and set the index(es) + */ + rowreq_ctx = + ipSystemStatsTable_allocate_rowreq_ctx(systemstats_entry, NULL); + if ((NULL != rowreq_ctx) + && (MFD_SUCCESS == + ipSystemStatsTable_indexes_set(rowreq_ctx, + systemstats_entry-> + index[0]))) { + rowreq_ctx->ipSystemStatsRefreshRate = ipss_cache_refresh * 1000; /* milli-seconds */ + CONTAINER_INSERT(container, rowreq_ctx); + } else { + if (NULL != rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "ipSystemStatsTable cache.\n"); + ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx); + } else { + snmp_log(LOG_ERR, "memory allocation failed while loading " + "ipSystemStatsTable cache.\n"); + netsnmp_access_systemstats_entry_free(systemstats_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 ipSystemStatsTable_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 +ipSystemStatsTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipSystemStatsTable_container_shutdown\n"); + return; + } + +} /* ipSystemStatsTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement ipSystemStatsTable 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 + * ipSystemStatsTable_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 +ipSystemStatsTable_container_load(netsnmp_container *container) +{ + netsnmp_container *stats = + netsnmp_access_systemstats_container_load(NULL, 0); + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_cache_load", + "called\n")); + + netsnmp_assert(NULL != container); + + if (NULL == stats) + return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */ + /* + * TODO:351:M: |-> Load/update data in the ipSystemStatsTable container. + * loop over your ipSystemStatsTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + /* + * we just got a fresh copy of data. compare it to + * what we've already got, and make any adjustements... + */ + CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *) + _check_for_updates, stats); + + /* + * now add any new entries + */ + CONTAINER_FOR_EACH(stats, (netsnmp_container_obj_func *) + _add_new, 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_systemstats_container_free(stats, + NETSNMP_ACCESS_SYSTEMSTATS_FREE_DONT_CLEAR); + + DEBUGMSGT(("verbose:ipSystemStatsTable:ipSystemStatsTable_cache_load", + "%" NETSNMP_PRIz "u records\n", CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} /* ipSystemStatsTable_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 +ipSystemStatsTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_container_free", "called\n")); + + /* + * TODO:380:M: Free ipSystemStatsTable container data. + */ +} /* ipSystemStatsTable_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 +ipSystemStatsTable_row_prep(ipSystemStatsTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_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; +} /* ipSystemStatsTable_row_prep */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.h b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.h new file mode 100644 index 0000000..56cdb72 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_data_access.h @@ -0,0 +1,105 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef IPSYSTEMSTATSTABLE_DATA_ACCESS_H +#define IPSYSTEMSTATSTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipSystemStatsTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.1, length: 9 + */ + + + int + + + + + + + + + + + + + + + + ipSystemStatsTable_init_data(ipSystemStatsTable_registration * + ipSystemStatsTable_reg); + + + /* + * TODO:180:o: Review ipSystemStatsTable cache timeout. + * The number of seconds before the cache times out + */ +#define IPSYSTEMSTATSTABLE_CACHE_TIMEOUT 60 + + void ipSystemStatsTable_container_init(netsnmp_container + **container_ptr_ptr, + netsnmp_cache * + cache); + void ipSystemStatsTable_container_shutdown(netsnmp_container + *container_ptr); + + int ipSystemStatsTable_container_load(netsnmp_container + *container); + void ipSystemStatsTable_container_free(netsnmp_container + *container); + + int ipSystemStatsTable_cache_load(netsnmp_container + *container); + void ipSystemStatsTable_cache_free(netsnmp_container + *container); + + int + + + + + + + + + + + + + + + + ipSystemStatsTable_row_prep(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx); + + + +#ifdef __cplusplus +} +#endif +#endif /* IPSYSTEMSTATSTABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c new file mode 100644 index 0000000..e1ca2cb --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c @@ -0,0 +1,1391 @@ +/* + * 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 "ipSystemStatsTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipSystemStatsTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(ipSystemStatsTable_external_access, libnetsnmpmibs) + +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(check_all_requests_error) + + +netsnmp_feature_child_of(ipSystemStatsTable_container_size, ipSystemStatsTable_external_access) +netsnmp_feature_child_of(ipSystemStatsTable_registration_set, ipSystemStatsTable_external_access) +netsnmp_feature_child_of(ipSystemStatsTable_registration_get, ipSystemStatsTable_external_access) +netsnmp_feature_child_of(ipSystemStatsTable_container_get, ipSystemStatsTable_external_access) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipSystemStatsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.31.1, length: 9 + */ +typedef struct ipSystemStatsTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + + ipSystemStatsTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} ipSystemStatsTable_interface_ctx; + +static ipSystemStatsTable_interface_ctx ipSystemStatsTable_if_ctx; + +static void + _ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx * + if_ctx); +static void + _ipSystemStatsTable_container_shutdown(ipSystemStatsTable_interface_ctx * + if_ctx); + +#ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_GET +netsnmp_container * +ipSystemStatsTable_container_get(void) +{ + return ipSystemStatsTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_GET +ipSystemStatsTable_registration * +ipSystemStatsTable_registration_get(void) +{ + return ipSystemStatsTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_SET +ipSystemStatsTable_registration * +ipSystemStatsTable_registration_set(ipSystemStatsTable_registration * + newreg) +{ + ipSystemStatsTable_registration *old = + ipSystemStatsTable_if_ctx.user_ctx; + ipSystemStatsTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_SIZE +int +ipSystemStatsTable_container_size(void) +{ + return CONTAINER_SIZE(ipSystemStatsTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_SIZE */ + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_post_request; +static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_get_values; +/** + * @internal + * Initialize the table ipSystemStatsTable + * (Define its contents and how it's structured) + */ +void +_ipSystemStatsTable_initialize_interface(ipSystemStatsTable_registration * + reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipSystemStatsTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipSystemStatsTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipSystemStatsTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipSystemStatsIPVersion */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPSYSTEMSTATSTABLE_MIN_COL; + tbl_info->max_column = IPSYSTEMSTATSTABLE_MAX_COL; + + /* + * save users context + */ + ipSystemStatsTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipSystemStatsTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipSystemStatsTable_container_init(&ipSystemStatsTable_if_ctx); + if (NULL == ipSystemStatsTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipSystemStatsTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipSystemStatsTable_object_lookup; + access_multiplexer->get_values = _mfd_ipSystemStatsTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_ipSystemStatsTable_pre_request; + access_multiplexer->post_request = + _mfd_ipSystemStatsTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipSystemStatsTable:init_ipSystemStatsTable", + "Registering ipSystemStatsTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipSystemStatsTable", handler, + ipSystemStatsTable_oid, + ipSystemStatsTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY); + if (NULL == reginfo) { + snmp_log(LOG_ERR, "error registering table ipSystemStatsTable\n"); + return; + } + reginfo->my_reg_void = &ipSystemStatsTable_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)) + /* XXX - are these actually necessary? */ + 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, + ipSystemStatsTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject cache helper + */ + if (NULL != ipSystemStatsTable_if_ctx.cache) { + handler = + netsnmp_cache_handler_get(ipSystemStatsTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _ipSystemStatsTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipSystemStatsTable + */ +void +_ipSystemStatsTable_shutdown_interface(ipSystemStatsTable_registration * + reg_ptr) +{ + /* + * shutdown the container + */ + _ipSystemStatsTable_container_shutdown(&ipSystemStatsTable_if_ctx); +} + +void +ipSystemStatsTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipSystemStatsTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipSystemStatsTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipSystemStatsTable_index_to_oid(netsnmp_index * oid_idx, + ipSystemStatsTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipSystemStatsIPVersion; + + /* + * set up varbinds + */ + memset(&var_ipSystemStatsIPVersion, 0x00, + sizeof(var_ipSystemStatsIPVersion)); + var_ipSystemStatsIPVersion.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipSystemStatsIPVersion.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_index_to_oid", "called\n")); + + /* + * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + snmp_set_var_value(&var_ipSystemStatsIPVersion, + (u_char *) & mib_idx->ipSystemStatsIPVersion, + sizeof(mib_idx->ipSystemStatsIPVersion)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipSystemStatsIPVersion); + 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_ipSystemStatsIPVersion); + + return err; +} /* ipSystemStatsTable_index_to_oid */ + +/** + * extract ipSystemStatsTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipSystemStatsTable_index_from_oid(netsnmp_index * oid_idx, + ipSystemStatsTable_mib_index * mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h + */ + netsnmp_variable_list var_ipSystemStatsIPVersion; + + /* + * set up varbinds + */ + memset(&var_ipSystemStatsIPVersion, 0x00, + sizeof(var_ipSystemStatsIPVersion)); + var_ipSystemStatsIPVersion.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipSystemStatsIPVersion.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_index_from_oid", "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipSystemStatsIPVersion); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipSystemStatsIPVersion = + *((u_long *) var_ipSystemStatsIPVersion.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipSystemStatsIPVersion); + + return err; +} /* ipSystemStatsTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipSystemStatsTable_rowreq_ctx + */ +ipSystemStatsTable_rowreq_ctx * +ipSystemStatsTable_allocate_rowreq_ctx(ipSystemStatsTable_data * data, + void *user_init_ctx) +{ + ipSystemStatsTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipSystemStatsTable_rowreq_ctx); + + DEBUGMSGTL(("internal:ipSystemStatsTable:ipSystemStatsTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipSystemStatsTable_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 = + ipSystemStatsTable_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->ipSystemStatsTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipSystemStatsTable_rowreq_ctx_init(rowreq_ctx, + user_init_ctx)) { + ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipSystemStatsTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipSystemStatsTable_rowreq_ctx + */ +void +ipSystemStatsTable_release_rowreq_ctx(ipSystemStatsTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipSystemStatsTable:ipSystemStatsTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipSystemStatsTable_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)) + ipSystemStatsTable_release_data(rowreq_ctx->data); + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* ipSystemStatsTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipSystemStatsTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipSystemStatsTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipSystemStatsTable_pre_request(ipSystemStatsTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipSystemStatsTable", "error %d from " + "ipSystemStatsTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipSystemStatsTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipSystemStatsTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipSystemStatsTable_rowreq_ctx *rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipSystemStatsTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + rc = ipSystemStatsTable_post_request(ipSystemStatsTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipSystemStatsTable", "error %d from " + "ipSystemStatsTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipSystemStatsTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipSystemStatsTable_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; + ipSystemStatsTable_rowreq_ctx *rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipSystemStatsTable_interface_ctx *if_ctx = + * (ipSystemStatsTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + rc = SNMP_ERR_NOCREATION; + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipSystemStatsTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipSystemStatsTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipSystemStatsTable_get_column(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipSystemStatsInReceives(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINRECEIVES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInReceives_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINRECEIVES: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInReceives_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsInOctets(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInOctets_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsInHdrErrors(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINHDRERRORS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInHdrErrors_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInNoRoutes(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINNOROUTES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInNoRoutes_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInAddrErrors(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINADDRERRORS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInAddrErrors_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInUnknownProtos(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINUNKNOWNPROTOS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInUnknownProtos_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInTruncatedPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINTRUNCATEDPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInTruncatedPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInForwDatagrams(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINFORWDATAGRAMS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInForwDatagrams_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINFORWDATAGRAMS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInForwDatagrams_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsReasmReqds(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSREASMREQDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsReasmReqds_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsReasmOKs(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSREASMOKS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsReasmOKs_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsReasmFails(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSREASMFAILS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsReasmFails_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInDiscards(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINDISCARDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInDiscards_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsInDelivers(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINDELIVERS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInDelivers_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINDELIVERS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInDelivers_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutRequests(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTREQUESTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutRequests_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTREQUESTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutRequests_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutNoRoutes(22)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTNOROUTES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutNoRoutes_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsOutForwDatagrams(23)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTFORWDATAGRAMS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutForwDatagrams_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTFORWDATAGRAMS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutForwDatagrams_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutDiscards(25)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTDISCARDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutDiscards_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsOutFragReqds(26)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTFRAGREQDS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutFragReqds_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsOutFragOKs(27)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTFRAGOKS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutFragOKs_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsOutFragFails(28)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTFRAGFAILS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutFragFails_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsOutFragCreates(29)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTFRAGCREATES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutFragCreates_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsOutTransmits(30)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTTRANSMITS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutTransmits_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTTRANSMITS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutTransmits_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutOctets(32)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutOctets_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsInMcastPkts(34)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINMCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInMcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINMCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInMcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsInMcastOctets(36)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINMCASTOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInMcastOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINMCASTOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInMcastOctets_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutMcastPkts(38)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTMCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutMcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTMCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutMcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutMcastOctets(40)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTMCASTOCTETS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutMcastOctets_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTMCASTOCTETS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutMcastOctets_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsInBcastPkts(42)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSINBCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsInBcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCINBCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCInBcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsOutBcastPkts(44)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSOUTBCASTPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; + rc = ipSystemStatsOutBcastPkts_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipSystemStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSHCOUTBCASTPKTS: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; + rc = ipSystemStatsHCOutBcastPkts_get(rowreq_ctx, + (U64 *) var->val.string); + break; + + /* + * ipSystemStatsDiscontinuityTime(46)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSDISCONTINUITYTIME: + var->val_len = sizeof(u_long); + var->type = ASN_TIMETICKS; + rc = ipSystemStatsDiscontinuityTime_get(rowreq_ctx, + (u_long *) var->val. + string); + break; + + /* + * ipSystemStatsRefreshRate(47)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPSYSTEMSTATSREFRESHRATE: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipSystemStatsRefreshRate_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipSystemStatsTable_get_column\n", + column); + break; + } + + return rc; +} /* _ipSystemStatsTable_get_column */ + +int +_mfd_ipSystemStatsTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipSystemStatsTable_rowreq_ctx *rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_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 = _ipSystemStatsTable_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_ipSystemStatsTable_get_values */ + + +#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * SET PROCESSING NOT APPLICABLE (per MIB or user setting) + */ +#endif + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +static void _container_free(netsnmp_container *container); + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for ipSystemStatsTable_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 ipSystemStatsTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in ipSystemStatsTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + +/** + * @internal + */ +static void +_container_item_free(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:ipSystemStatsTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:ipSystemStatsTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipSystemStatsTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipSystemStatsTable_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 +_ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_init", "called\n")); + + /* + * cache init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + ipSystemStatsTable_oid, + ipSystemStatsTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for ipSystemStatsTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipSystemStatsTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipSystemStatsTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipSystemStatsTable_container_init\n"); + return; + } + + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; +} /* _ipSystemStatsTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipSystemStatsTable_container_shutdown(ipSystemStatsTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_shutdown", "called\n")); + + ipSystemStatsTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipSystemStatsTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_EXTERNAL_ACCESS +ipSystemStatsTable_rowreq_ctx * +ipSystemStatsTable_row_find_by_mib_index(ipSystemStatsTable_mib_index * + mib_idx) +{ + ipSystemStatsTable_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 = ipSystemStatsTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*) + CONTAINER_FIND(ipSystemStatsTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_EXTERNAL_ACCESS */ diff --git a/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.h b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.h new file mode 100644 index 0000000..89f6ae0 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.h @@ -0,0 +1,173 @@ +/* + * 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 IPSYSTEMSTATSTABLE_INTERFACE_H +#define IPSYSTEMSTATSTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipSystemStatsTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + + + + + + + + + + + + + + + + _ipSystemStatsTable_initialize_interface + (ipSystemStatsTable_registration * user_ctx, u_long flags); + void + + + + + + + + + + + + + + + + _ipSystemStatsTable_shutdown_interface + (ipSystemStatsTable_registration * user_ctx); + + + + + + + + ipSystemStatsTable_registration + * ipSystemStatsTable_registration_get(void); + + + + + + + + ipSystemStatsTable_registration + * ipSystemStatsTable_registration_set + (ipSystemStatsTable_registration * newreg); + + netsnmp_container *ipSystemStatsTable_container_get(void); + int ipSystemStatsTable_container_size(void); + + + + + + + + ipSystemStatsTable_rowreq_ctx + * ipSystemStatsTable_allocate_rowreq_ctx(ipSystemStatsTable_data *, + void *); + void + + + + + + + + + + + + + + + + ipSystemStatsTable_release_rowreq_ctx(ipSystemStatsTable_rowreq_ctx + * rowreq_ctx); + + int ipSystemStatsTable_index_to_oid(netsnmp_index * + oid_idx, + ipSystemStatsTable_mib_index + * mib_idx); + int ipSystemStatsTable_index_from_oid(netsnmp_index * + oid_idx, + ipSystemStatsTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + + + + + + + + + + + ipSystemStatsTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* IPSYSTEMSTATSTABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ip_scalars.c b/agent/mibgroup/ip-mib/ip_scalars.c new file mode 100644 index 0000000..b697a75 --- /dev/null +++ b/agent/mibgroup/ip-mib/ip_scalars.c @@ -0,0 +1,372 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.scalar.conf,v 1.8 2004/10/14 12:57:34 dts12 Exp $ + */ + +#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 <net-snmp/data_access/ip_scalars.h> + +netsnmp_feature_require(register_num_file_instance) + +#include "ip_scalars.h" + +int +handle_ipForwarding(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + +int +handle_ipDefaultTTL(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + +int +handle_ipv6IpForwarding(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + +int ipAddressSpinLockValue; + +int +handle_ipAddressSpinLock(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests); + +/** Initializes the ip module */ +void +init_ip_scalars(void) +{ + static oid ipForwarding_oid[] = { 1, 3, 6, 1, 2, 1, 4, 1 }; + static oid ipDefaultTTL_oid[] = { 1, 3, 6, 1, 2, 1, 4, 2, 0 }; + static oid ipReasmTimeout_oid[] = { 1, 3, 6, 1, 2, 1, 4, 13, 0 }; + static oid ipv6IpForwarding_oid[] = { 1, 3, 6, 1, 2, 1, 4, 25 }; + static oid ipv6IpDefaultHopLimit_oid[] = + { 1, 3, 6, 1, 2, 1, 4, 26, 0 }; + static oid ipAddressSpinLock_oid[] = { 1, 3, 6, 1, 2, 1, 4, 33 }; + + DEBUGMSGTL(("ip_scalar", "Initializing\n")); + + netsnmp_register_num_file_instance + ("ipReasmTimeout", + ipReasmTimeout_oid, OID_LENGTH(ipReasmTimeout_oid), + "/proc/sys/net/ipv4/ipfrag_time", ASN_INTEGER, + HANDLER_CAN_RONLY, NULL, NULL); + + netsnmp_register_scalar(netsnmp_create_handler_registration + ("ipForwarding", handle_ipForwarding, + ipForwarding_oid, + OID_LENGTH(ipForwarding_oid), + HANDLER_CAN_RWRITE)); + + netsnmp_register_scalar(netsnmp_create_handler_registration + ("ipv6IpForwarding", handle_ipv6IpForwarding, + ipv6IpForwarding_oid, + OID_LENGTH(ipv6IpForwarding_oid), + HANDLER_CAN_RWRITE)); + + netsnmp_register_scalar(netsnmp_create_handler_registration + ("ipAddressSpinLock", handle_ipAddressSpinLock, + ipAddressSpinLock_oid, + OID_LENGTH(ipAddressSpinLock_oid), + HANDLER_CAN_RWRITE)); + + /* Initialize spin lock with random value */ + ipAddressSpinLockValue = (int) random(); + + netsnmp_register_num_file_instance + ("ipv6IpDefaultHopLimit", + ipv6IpDefaultHopLimit_oid, OID_LENGTH(ipv6IpDefaultHopLimit_oid), + "/proc/sys/net/ipv6/conf/default/hop_limit", ASN_INTEGER, + HANDLER_CAN_RWRITE, NULL, NULL); + + netsnmp_register_num_file_instance + ("ipDefaultTTL", + ipDefaultTTL_oid, OID_LENGTH(ipDefaultTTL_oid), + "/proc/sys/net/ipv4/ip_default_ttl", ASN_INTEGER, + HANDLER_CAN_RWRITE, NULL, NULL); + +} + +int +handle_ipForwarding(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + int rc; + u_long value; + + /* We are never called for a GETNEXT if it's registered as a + "instance", as it's "magically" handled for us. */ + + /* a instance handler also only hands us one request at a time, so + we don't need to loop over a list of requests; we'll only get one. */ + + switch(reqinfo->mode) { + + case MODE_GET: + rc = netsnmp_arch_ip_scalars_ipForwarding_get(&value); + if (rc != 0) { + netsnmp_set_request_error(reqinfo, requests, + SNMP_NOSUCHINSTANCE); + } + else { + value = value ? 1 : 2; + snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, + (u_char *)&value, sizeof(value)); + } + break; + +#ifndef NETSNMP_NO_WRITE_SUPPORT + /* + * SET REQUEST + * + * multiple states in the transaction. See: + * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg + */ + case MODE_SET_RESERVE1: + break; + + case MODE_SET_RESERVE2: + /* + * store old info for undo later + */ + rc = netsnmp_arch_ip_scalars_ipForwarding_get(&value); + if (rc < 0) { + netsnmp_set_request_error(reqinfo, requests, + SNMP_ERR_NOCREATION); + } else { + u_long *value_save; + memdup((u_char **) & value_save, (u_char *) &value, + sizeof(value)); + if ( NULL == value_save ) + netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE); + else + netsnmp_request_add_list_data(requests, + netsnmp_create_data_list + ("ipfw", value_save, + free)); + } + break; + + case MODE_SET_FREE: + /* XXX: free resources allocated in RESERVE1 and/or + RESERVE2. Something failed somewhere, and the states + below won't be called. */ + break; + + case MODE_SET_ACTION: + /* XXX: perform the value change here */ + value = *(requests->requestvb->val.integer); + rc = netsnmp_arch_ip_scalars_ipForwarding_set(value); + if ( 0 != rc ) { + netsnmp_set_request_error(reqinfo, requests, rc); + } + break; + + case MODE_SET_COMMIT: + break; + + case MODE_SET_UNDO: + value = + *((u_long *) netsnmp_request_get_list_data(requests, + "ipfw")); + rc = netsnmp_arch_ip_scalars_ipForwarding_set(value); + if ( 0 != rc ) { + netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED); + } + break; +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + + default: + /* we should never get here, so this is a really bad error */ + snmp_log(LOG_ERR, "unknown mode (%d) in handle_ipForwarding\n", reqinfo->mode ); + return SNMP_ERR_GENERR; + } + + return SNMP_ERR_NOERROR; +} + + +int +handle_ipv6IpForwarding(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + int rc; + u_long value; + + /* + * We are never called for a GETNEXT if it's registered as a + * "instance", as it's "magically" handled for us. + */ + + /* + * a instance handler also only hands us one request at a time, so + * we don't need to loop over a list of requests; we'll only get one. + */ + switch (reqinfo->mode) { + + case MODE_GET: + rc = netsnmp_arch_ip_scalars_ipv6IpForwarding_get(&value); + if (rc != 0) { + netsnmp_set_request_error(reqinfo, requests, + SNMP_NOSUCHINSTANCE); + } + else { + value = value ? 1 : 2; + snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, + (u_char *)&value, sizeof(value)); + } + break; + +#ifndef NETSNMP_NO_WRITE_SUPPORT + /* + * SET REQUEST + * + * multiple states in the transaction. See: + * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg + */ + case MODE_SET_RESERVE1: + break; + + case MODE_SET_RESERVE2: + /* + * store old info for undo later + */ + rc = netsnmp_arch_ip_scalars_ipv6IpForwarding_get(&value); + if (rc < 0) { + netsnmp_set_request_error(reqinfo, requests, + SNMP_ERR_NOCREATION); + } + else { + u_long *value_save; + memdup((u_char **) & value_save, (u_char *) &value, + sizeof(value)); + if ( NULL == value_save ) { + netsnmp_set_request_error(reqinfo, requests, + SNMP_ERR_RESOURCEUNAVAILABLE); + } + else { + netsnmp_request_add_list_data(requests, + netsnmp_create_data_list + ("ipfw", value_save, + free)); + } + } + break; + + case MODE_SET_FREE: + break; + + case MODE_SET_ACTION: + value = *(requests->requestvb->val.integer); + rc = netsnmp_arch_ip_scalars_ipv6IpForwarding_set(value); + if ( 0 != rc ) { + netsnmp_set_request_error(reqinfo, requests, rc ); + } + break; + + case MODE_SET_COMMIT: + break; + + case MODE_SET_UNDO: + value = + *((u_long *) netsnmp_request_get_list_data(requests, + "ipfw")); + rc = netsnmp_arch_ip_scalars_ipv6IpForwarding_set(value); + if ( 0 != rc ) { + netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED); + } + break; +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + + default: + /* + * we should never get here, so this is a really bad error + */ + snmp_log(LOG_ERR, "unknown mode (%d) in handle_ipv6IpForwarding\n", + reqinfo->mode); + return SNMP_ERR_GENERR; + } + + return SNMP_ERR_NOERROR; +} + +int +handle_ipAddressSpinLock(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + long value; + + /* We are never called for a GETNEXT if it's registered as a + "instance", as it's "magically" handled for us. */ + + /* a instance handler also only hands us one request at a time, so + we don't need to loop over a list of requests; we'll only get one. */ + + switch(reqinfo->mode) { + + case MODE_GET: + snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, + (u_char *)&ipAddressSpinLockValue, + sizeof(ipAddressSpinLockValue)); + break; + +#ifndef NETSNMP_NO_WRITE_SUPPORT + /* + * SET REQUEST + * + * multiple states in the transaction. See: + * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg + */ + case MODE_SET_RESERVE1: + case MODE_SET_RESERVE2: + /* just check the value */ + value = *(requests->requestvb->val.integer); + if (value != ipAddressSpinLockValue) + netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_INCONSISTENTVALUE); + break; + + case MODE_SET_FREE: + break; + + case MODE_SET_ACTION: + /* perform the final spinlock check and increase its value */ + value = *(requests->requestvb->val.integer); + if (value != ipAddressSpinLockValue) { + netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_INCONSISTENTVALUE); + } else { + ipAddressSpinLockValue++; + /* and check it for overflow */ + if (ipAddressSpinLockValue > 2147483647 || ipAddressSpinLockValue < 0) + ipAddressSpinLockValue = 0; + } + break; + + case MODE_SET_COMMIT: + break; + + case MODE_SET_UNDO: + break; +#endif /* !NETSNMP_NO_WRITE_SUPPORT */ + + default: + /* we should never get here, so this is a really bad error */ + snmp_log(LOG_ERR, "unknown mode (%d) in handle_ipAddressSpinLock\n", reqinfo->mode ); + return SNMP_ERR_GENERR; + } + + return SNMP_ERR_NOERROR; +} diff --git a/agent/mibgroup/ip-mib/ip_scalars.h b/agent/mibgroup/ip-mib/ip_scalars.h new file mode 100644 index 0000000..7670a49 --- /dev/null +++ b/agent/mibgroup/ip-mib/ip_scalars.h @@ -0,0 +1,7 @@ +/* + * module to include the modules + */ + +void init_ip_scalars(void); + +config_require(ip-mib/data_access/scalars_common) diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable.h b/agent/mibgroup/ip-mib/ipv4InterfaceTable.h new file mode 100644 index 0000000..2ebd768 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/ipv4InterfaceTable/ipv4InterfaceTable) diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable.c b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable.c new file mode 100644 index 0000000..351ddd1 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable.c @@ -0,0 +1,959 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for ipv4InterfaceTable + * + * \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 "ipv4InterfaceTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipv4InterfaceTable_interface.h" + +const oid ipv4InterfaceTable_oid[] = { IPV4INTERFACETABLE_OID }; +const int ipv4InterfaceTable_oid_size = +OID_LENGTH(ipv4InterfaceTable_oid); + +ipv4InterfaceTable_registration ipv4InterfaceTable_user_context; +static ipv4InterfaceTable_registration *ipv4InterfaceTable_user_context_p; + +void initialize_table_ipv4InterfaceTable(void); +void shutdown_table_ipv4InterfaceTable(void); + + +/** + * Initializes the ipv4InterfaceTable module + */ +void +init_ipv4InterfaceTable(void) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:init_ipv4InterfaceTable", + "called\n")); + + /* + * TODO:300:o: Perform ipv4InterfaceTable one-time module initialization. + */ + + /* + * we depend on the ifTable, so we put our init in with it + * to guarantee order of execution. + */ + init_ifTable(); + + /* + * last changed should be 0 at startup + */ + ipv4InterfaceTable_lastChange_set(0); + +} /* init_ipv4InterfaceTable */ + +/** + * Shut-down the ipv4InterfaceTable module (agent is exiting) + */ +void +shutdown_ipv4InterfaceTable(void) +{ + if (should_init("ipv4InterfaceTable")) + shutdown_table_ipv4InterfaceTable(); + +} + +/** + * Initialize the table ipv4InterfaceTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipv4InterfaceTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:initialize_table_ipv4InterfaceTable", "called\n")); + + /* + * TODO:301:o: Perform ipv4InterfaceTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipv4InterfaceTable 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. + */ + ipv4InterfaceTable_user_context_p = + netsnmp_create_data_list("ipv4InterfaceTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipv4InterfaceTable_initialize_interface + (ipv4InterfaceTable_user_context_p, flags); +} /* initialize_table_ipv4InterfaceTable */ + +/** + * Shutdown the table ipv4InterfaceTable + */ +void +shutdown_table_ipv4InterfaceTable(void) +{ + /* + * call interface shutdown code + */ + _ipv4InterfaceTable_shutdown_interface + (ipv4InterfaceTable_user_context_p); + netsnmp_free_all_list_data(ipv4InterfaceTable_user_context_p); + ipv4InterfaceTable_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 +ipv4InterfaceTable_rowreq_ctx_init(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipv4InterfaceTable rowreq initialization. (eg DEFVALS) + */ + rowreq_ctx->data.ipv4InterfaceRetransmitTime = 1000; + + + return MFD_SUCCESS; +} /* ipv4InterfaceTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * @param rowreq_ctx + * + */ +void +ipv4InterfaceTable_rowreq_ctx_cleanup(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipv4InterfaceTable rowreq cleanup. + */ +} /* ipv4InterfaceTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * @param user_context + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipv4InterfaceTable_pre_request(ipv4InterfaceTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform ipv4InterfaceTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipv4InterfaceTable_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 +ipv4InterfaceTable_post_request(ipv4InterfaceTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform ipv4InterfaceTable post-request actions. + */ + + /* + * check to set if any rows were changed. + */ + if (ipv4InterfaceTable_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 + */ + } + + ipv4InterfaceTable_dirty_set(0); /* clear table dirty flag */ + } + + return MFD_SUCCESS; +} /* ipv4InterfaceTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipv4InterfaceTable data context functions. + */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipv4InterfaceEntry.ipv4InterfaceReasmMaxSize + * ipv4InterfaceReasmMaxSize is subid 2 of ipv4InterfaceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.28.1.2 + * Description: +The size of the largest IPv4 datagram which this entity can + re-assemble from incoming IPv4 fragmented datagrams received + on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 0 - 65535; + * + * 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 ipv4InterfaceReasmMaxSize data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv4InterfaceReasmMaxSize_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 +ipv4InterfaceReasmMaxSize_get(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + long *ipv4InterfaceReasmMaxSize_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv4InterfaceReasmMaxSize_val_ptr); + + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceReasmMaxSize_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V4_REASMMAX)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv4InterfaceReasmMaxSize data. + * copy (* ipv4InterfaceReasmMaxSize_val_ptr ) from rowreq_ctx->data + */ + (*ipv4InterfaceReasmMaxSize_val_ptr) = + rowreq_ctx->data.ipv4InterfaceReasmMaxSize; + + return MFD_SUCCESS; +} /* ipv4InterfaceReasmMaxSize_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv4InterfaceEntry.ipv4InterfaceEnableStatus + * ipv4InterfaceEnableStatus is subid 3 of ipv4InterfaceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.4.28.1.3 + * Description: +The indication of whether IPv4 is enabled (up) or disabled + (down) on this interface. This object does not affect the + state of the interface itself, only its connection to an + IPv4 stack. The IF-MIB should be used to control the state + of the interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 1/8. Values: up(1), down(2) + * + * 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 ipv4InterfaceEnableStatus data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv4InterfaceEnableStatus_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 +ipv4InterfaceEnableStatus_get(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * ipv4InterfaceEnableStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv4InterfaceEnableStatus_val_ptr); + + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv4InterfaceEnableStatus data. + * copy (* ipv4InterfaceEnableStatus_val_ptr ) from rowreq_ctx->data + */ + (*ipv4InterfaceEnableStatus_val_ptr) = + rowreq_ctx->data.ipv4InterfaceEnableStatus; + + return MFD_SUCCESS; +} /* ipv4InterfaceEnableStatus_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv4InterfaceEntry.ipv4InterfaceRetransmitTime + * ipv4InterfaceRetransmitTime is subid 4 of ipv4InterfaceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.28.1.4 + * Description: +The time between retransmissions of ARP requests to a + neighbor when resolving the address or when probing the + reachability of a neighbor. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 1 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * defval: 1000 + * + * + * Its syntax is UNSIGNED32 (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 ipv4InterfaceRetransmitTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv4InterfaceRetransmitTime_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 +ipv4InterfaceRetransmitTime_get(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * + ipv4InterfaceRetransmitTime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv4InterfaceRetransmitTime_val_ptr); + + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceRetransmitTime_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V4_RETRANSMIT)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv4InterfaceRetransmitTime data. + * copy (* ipv4InterfaceRetransmitTime_val_ptr ) from rowreq_ctx->data + */ + (*ipv4InterfaceRetransmitTime_val_ptr) = + rowreq_ctx->data.ipv4InterfaceRetransmitTime; + + return MFD_SUCCESS; +} /* ipv4InterfaceRetransmitTime_get */ + + + +/** @} */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ + /* + * 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 + * +==============+ + * +----------------|| object || + * | E || lookup || + * | +==============+ + * | | 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 + * +--------------+ + * | post | + * | request | + * +--------------+ + * + */ + +/** + * 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 + * ipv4InterfaceTable_allocate_data(), but may need extra + * initialization similar to what you may have done in + * ipv4InterfaceTable_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 (ipv4InterfaceTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipv4InterfaceTable_undo_setup(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_setup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> Setup ipv4InterfaceTable undo. + * set up ipv4InterfaceTable undo information, in preparation for a set. + * Undo storage is in (* ipv4InterfaceRetransmitTime_val_ptr )* + */ + + return rc; +} /* ipv4InterfaceTable_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 (ipv4InterfaceTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipv4InterfaceTable_undo(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> ipv4InterfaceTable undo. + * ipv4InterfaceTable undo information, in response to a failed set. + * Undo storage is in (* ipv4InterfaceRetransmitTime_val_ptr )* + */ + + return rc; +} /* ipv4InterfaceTable_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 (ipv4InterfaceTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +ipv4InterfaceTable_undo_cleanup(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_cleanup", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:452:M: |-> Cleanup ipv4InterfaceTable undo. + * Undo storage is in (* ipv4InterfaceRetransmitTime_val_ptr )* + */ + + return rc; +} /* ipv4InterfaceTable_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 + * ipv4InterfaceTable.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 +ipv4InterfaceTable_commit(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + int save_flags; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_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 ipv4InterfaceTable 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_IPV4INTERFACEENABLESTATUS_FLAG) { + save_flags &= ~COLUMN_IPV4INTERFACEENABLESTATUS_FLAG; /* clear ipv4InterfaceEnableStatus */ + /* + * TODO:482:o: |-> commit column ipv4InterfaceEnableStatus. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipv4InterfaceTable column ipv4InterfaceEnableStatus commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipv4InterfaceEnableStatus + */ + rowreq_ctx->column_set_flags |= + COLUMN_IPV4INTERFACEENABLESTATUS_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; +} /* ipv4InterfaceTable_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 + * ipv4InterfaceTable.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 +ipv4InterfaceTable_undo_commit(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_commit", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:485:M: |-> Undo ipv4InterfaceTable 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; +} /* ipv4InterfaceTable_undo_commit */ + +/* + * TODO:440:M: Implement ipv4InterfaceTable node value checks. + * TODO:450:M: Implement ipv4InterfaceTable undo functions. + * TODO:460:M: Implement ipv4InterfaceTable set functions. + * TODO:480:M: Implement ipv4InterfaceTable commit functions. + */ +/*--------------------------------------------------------------------- + * IP-MIB::ipv4InterfaceEntry.ipv4InterfaceEnableStatus + * ipv4InterfaceEnableStatus is subid 3 of ipv4InterfaceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.4.28.1.3 + * Description: +The indication of whether IPv4 is enabled (up) or disabled + (down) on this interface. This object does not affect the + state of the interface itself, only its connection to an + IPv4 stack. The IF-MIB should be used to control the state + of the interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 1/8. Values: up(1), down(2) + * + * 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 ipv4InterfaceEnableStatus_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 + * ipv4InterfaceTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of up(1), down(2) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipv4InterfaceEnableStatus_check_value(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long ipv4InterfaceEnableStatus_val) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipv4InterfaceEnableStatus value. + */ + /* + * did the access code set the flag indicating that we can control + * individual protocols on this interface? + */ + if (rowreq_ctx->data.ifentry->ns_flags & + NETSNMP_INTERFACE_FLAGS_CAN_DOWN_PROTOCOL); + else + return MFD_NOT_VALID_EVER; + + return MFD_SUCCESS; /* ipv4InterfaceEnableStatus value not illegal */ +} /* ipv4InterfaceEnableStatus_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipv4InterfaceTable_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 + * ipv4InterfaceTable_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 +ipv4InterfaceEnableStatus_undo_setup(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_undo_setup", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipv4InterfaceEnableStatus undo. + */ + /* + * copy ipv4InterfaceEnableStatus data + * set rowreq_ctx->undo->ipv4InterfaceEnableStatus from rowreq_ctx->data.ipv4InterfaceEnableStatus + */ + rowreq_ctx->undo->ipv4InterfaceEnableStatus = + rowreq_ctx->data.ipv4InterfaceEnableStatus; + + + return MFD_SUCCESS; +} /* ipv4InterfaceEnableStatus_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 ipv4InterfaceEnableStatus_val + * A long containing the new value. + */ +int +ipv4InterfaceEnableStatus_set(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long ipv4InterfaceEnableStatus_val) +{ + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipv4InterfaceEnableStatus value. + * set ipv4InterfaceEnableStatus value in rowreq_ctx->data + */ + rowreq_ctx->data.ipv4InterfaceEnableStatus = + ipv4InterfaceEnableStatus_val; + + return MFD_SUCCESS; +} /* ipv4InterfaceEnableStatus_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipv4InterfaceEnableStatus_undo(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_undo", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipv4InterfaceEnableStatus undo. + */ + /* + * copy ipv4InterfaceEnableStatus data + * set rowreq_ctx->data.ipv4InterfaceEnableStatus from rowreq_ctx->undo->ipv4InterfaceEnableStatus + */ + rowreq_ctx->data.ipv4InterfaceEnableStatus = + rowreq_ctx->undo->ipv4InterfaceEnableStatus; + + + return MFD_SUCCESS; +} /* ipv4InterfaceEnableStatus_undo */ + +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable.h b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable.h new file mode 100644 index 0000000..8123908 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable.h @@ -0,0 +1,276 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef IPV4INTERFACETABLE_H +#define IPV4INTERFACETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/interface.h> + +#include "if-mib/ifTable/ifTable.h" + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(if-mib/ifTable/ifTable) +config_require(ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface) +config_require(ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for ipv4InterfaceTable + */ +#include "ipv4InterfaceTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void initialize_table_ipv4InterfaceTable(void); + void init_ipv4InterfaceTable(void); + void shutdown_ipv4InterfaceTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + * + * we share data structures (data too, in fact) with ifTable + */ + typedef ifTable_registration ipv4InterfaceTable_registration; + typedef ifTable_data ipv4InterfaceTable_data; + typedef ifTable_undo_data ipv4InterfaceTable_undo_data; + typedef ifTable_mib_index ipv4InterfaceTable_mib_index; + typedef ifTable_rowreq_ctx ipv4InterfaceTable_rowreq_ctx; + + /* + * ipv4InterfaceReasmMaxSize(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ +#define ipv4InterfaceReasmMaxSize ifentry->reasm_max_v4 + + /* + * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ +#define ipv4InterfaceEnableStatus ifentry->admin_status + + /* + * ipv4InterfaceRetransmitTime(4)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/D/h + */ +#define ipv4InterfaceRetransmitTime ifentry->retransmit_v4 + + + /* + ********************************************************************* + * function prototypes + */ + int + ipv4InterfaceTable_pre_request(ipv4InterfaceTable_registration * + user_context); + int + ipv4InterfaceTable_post_request(ipv4InterfaceTable_registration * + user_context, int rc); + + int + ipv4InterfaceTable_rowreq_ctx_init(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + void *user_init_ctx); + void + ipv4InterfaceTable_rowreq_ctx_cleanup(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx); + + int ipv4InterfaceTable_commit(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx); + ipv4InterfaceTable_rowreq_ctx + * ipv4InterfaceTable_row_find_by_mib_index + (ipv4InterfaceTable_mib_index * mib_idx); + + extern const oid ipv4InterfaceTable_oid[]; + extern const int ipv4InterfaceTable_oid_size; + + +#include "ipv4InterfaceTable_interface.h" +#include "ipv4InterfaceTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ + /* + * indexes + */ + + int + ipv4InterfaceReasmMaxSize_get(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, long + *ipv4InterfaceReasmMaxSize_val_ptr); + int + ipv4InterfaceEnableStatus_get(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv4InterfaceEnableStatus_val_ptr); + int + ipv4InterfaceRetransmitTime_get(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv4InterfaceRetransmitTime_val_ptr); + + + int + ipv4InterfaceTable_indexes_set_tbl_idx(ipv4InterfaceTable_mib_index + * tbl_idx, long + ipv4InterfaceIfIndex_val); + int + ipv4InterfaceTable_indexes_set(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + long ipv4InterfaceIfIndex_val); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ + + + int + ipv4InterfaceTable_undo_setup(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + int + ipv4InterfaceTable_undo_cleanup(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + int ipv4InterfaceTable_undo(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + int ipv4InterfaceTable_commit(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + ipv4InterfaceTable_undo_commit(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + + + int + ipv4InterfaceReasmMaxSize_check_value(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx, long + ipv4InterfaceReasmMaxSize_val); + int + ipv4InterfaceReasmMaxSize_undo_setup(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + ipv4InterfaceReasmMaxSize_set(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + long ipv4InterfaceReasmMaxSize_val); + int + ipv4InterfaceReasmMaxSize_undo(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + ipv4InterfaceEnableStatus_check_value(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx, + u_long + ipv4InterfaceEnableStatus_val); + int + ipv4InterfaceEnableStatus_undo_setup(ipv4InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + ipv4InterfaceEnableStatus_set(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv4InterfaceEnableStatus_val); + int + ipv4InterfaceEnableStatus_undo(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + ipv4InterfaceRetransmitTime_check_value + (ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long ipv4InterfaceRetransmitTime_val); + int + ipv4InterfaceRetransmitTime_undo_setup + (ipv4InterfaceTable_rowreq_ctx * rowreq_ctx); + int + ipv4InterfaceRetransmitTime_set(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv4InterfaceRetransmitTime_val); + int + ipv4InterfaceRetransmitTime_undo(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + + + int + ipv4InterfaceTable_check_dependencies(ipv4InterfaceTable_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 /* IPV4INTERFACETABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_constants.h b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_constants.h new file mode 100644 index 0000000..eb391ae --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_constants.h @@ -0,0 +1,81 @@ +/* + * 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 IPV4INTERFACETABLE_CONSTANTS_H +#define IPV4INTERFACETABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipv4InterfaceTable + */ +#define IPV4INTERFACETABLE_OID 1,3,6,1,2,1,4,28 +#define IPV4INTERFACETABLELASTCHANGE_OID 1,3,6,1,2,1,4,27 + +#define COLUMN_IPV4INTERFACEIFINDEX 1 + +#define COLUMN_IPV4INTERFACEREASMMAXSIZE 2 + +#define COLUMN_IPV4INTERFACEENABLESTATUS 3 +#define COLUMN_IPV4INTERFACEENABLESTATUS_FLAG (0x1 << 2) + +#define COLUMN_IPV4INTERFACERETRANSMITTIME 4 + + +#define IPV4INTERFACETABLE_MIN_COL COLUMN_IPV4INTERFACEREASMMAXSIZE +#define IPV4INTERFACETABLE_MAX_COL COLUMN_IPV4INTERFACERETRANSMITTIME + + + /* + * TODO:405:r: Review IPV4INTERFACETABLE_SETTABLE_COLS macro. + * OR together all the writable cols. + */ +#define IPV4INTERFACETABLE_SETTABLE_COLS (COLUMN_IPV4INTERFACEENABLESTATUS_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 ipv4InterfaceTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipv4InterfaceEnableStatus (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPV4INTERFACEENABLESTATUS_ENUMS +#define IPV4INTERFACEENABLESTATUS_ENUMS + +#define IPV4INTERFACEENABLESTATUS_UP 1 +#define IPV4INTERFACEENABLESTATUS_DOWN 2 + +#endif /* IPV4INTERFACEENABLESTATUS_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPV4INTERFACETABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access.c b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access.c new file mode 100644 index 0000000..c9e14ff --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access.c @@ -0,0 +1,302 @@ +/* + * 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 "ipv4InterfaceTable.h" + + +#include "ipv4InterfaceTable_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 ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ + +/** + * initialization for ipv4InterfaceTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipv4InterfaceTable_reg + * Pointer to ipv4InterfaceTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipv4InterfaceTable_init_data(ipv4InterfaceTable_registration * + ipv4InterfaceTable_reg) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize ipv4InterfaceTable data. + */ + + return MFD_SUCCESS; +} /* ipv4InterfaceTable_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. + * + * 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. + * + * @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 +ipv4InterfaceTable_container_init(netsnmp_container **container_ptr_ptr) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipv4InterfaceTable_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. + */ +} /* ipv4InterfaceTable_container_init */ + + +/** + * @internal + * determine if we want a ifTable row in our container + */ +void +ipv4InterfaceTable_check_entry_for_updates(const ifTable_rowreq_ctx * + ift_rrc, + netsnmp_interface_entry *entry) +{ + netsnmp_container *c = ipv4InterfaceTable_container_get(); + ifTable_rowreq_ctx *ip4if_rrc; + int changed = 0; + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:check_entry_for_updates", + "called\n")); + + /* + * do we have a corresponding row? + */ + ip4if_rrc = CONTAINER_FIND(c, ift_rrc); + if (NULL == ip4if_rrc) { + /* + * no corresponding row. should we have one? + */ + if ((NULL != entry) && + (entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_IPV4)) { + /* + * yes. + */ + DEBUGMSGTL(("ipv4InterfaceTable:check_entry_for_updates", + "inserted row for %" NETSNMP_PRIo "d\n", entry->index)); + CONTAINER_INSERT(c, ift_rrc); + changed = 1; + } + } else { + /* + * found corresponding row. is it still applicable? + */ + if ((NULL == entry) || + (0 == (entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_IPV4))) { + /* + * no + */ + DEBUGMSGTL(("ipv4InterfaceTable:check_entry_for_updates", + "removed row for %" NETSNMP_PRIo "d\n", + ift_rrc->data.ifentry->index)); + CONTAINER_REMOVE(c, ift_rrc); + changed = 1; + } else { + /* + * still applicable. anything changed? + */ + if ((entry->retransmit_v4 != + ift_rrc->data.ifentry->retransmit_v4) || + (entry->reasm_max_v4 != ift_rrc->data.ifentry->reasm_max_v4)) { + DEBUGMSGTL(("ipv4InterfaceTable:check_entry_for_updates", + "row changed for %" NETSNMP_PRIo "d\n", + ift_rrc->data.ifentry->index)); + changed = 1; + } + } + } + + /* + * if something changed, update table last changed + */ + if (changed) + ipv4InterfaceTable_lastChange_set(netsnmp_get_agent_uptime()); +} + + +/** + * 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 ipv4InterfaceTable_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 +ipv4InterfaceTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipv4InterfaceTable_container_shutdown\n"); + return; + } + +} /* ipv4InterfaceTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement ipv4InterfaceTable data load + * + * @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 + * ipv4InterfaceTable_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 +ipv4InterfaceTable_container_load(netsnmp_container *container) +{ + DEBUGMSGT(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_load", "illegal call!\n")); + + return MFD_ERROR; +} /* ipv4InterfaceTable_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 +ipv4InterfaceTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_free", "called\n")); + + /* + * TODO:380:M: Free ipv4InterfaceTable container data. + */ +} /* ipv4InterfaceTable_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 +ipv4InterfaceTable_row_prep(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_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; +} /* ipv4InterfaceTable_row_prep */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access.h b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access.h new file mode 100644 index 0000000..4fb5db3 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_data_access.h @@ -0,0 +1,71 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef IPV4INTERFACETABLE_DATA_ACCESS_H +#define IPV4INTERFACETABLE_DATA_ACCESS_H + +#ifdef __cplusplus + extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ + + + int + ipv4InterfaceTable_init_data(ipv4InterfaceTable_registration * + ipv4InterfaceTable_reg); + + + void + ipv4InterfaceTable_container_init(netsnmp_container + **container_ptr_ptr); + void ipv4InterfaceTable_container_shutdown(netsnmp_container + *container_ptr); + + int + ipv4InterfaceTable_container_load(netsnmp_container + *container); + void + ipv4InterfaceTable_container_free(netsnmp_container + *container); + + int + ipv4InterfaceTable_row_prep(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx); + + void + ipv4InterfaceTable_check_entry_for_updates(const + ifTable_rowreq_ctx + * ift_rrc, + netsnmp_interface_entry + *entry); + + +#ifdef __cplusplus + } +#endif +#endif /* IPV4INTERFACETABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c new file mode 100644 index 0000000..a851a30 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c @@ -0,0 +1,1325 @@ +/* + * 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 "ipv4InterfaceTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipv4InterfaceTable_interface.h" + +#include "if-mib/ifTable/ifTable.h" + +#include <ctype.h> + +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(check_all_requests_error) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipv4InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv4InterfaceTable is subid 28 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.28, length: 8 + */ +typedef struct ipv4InterfaceTable_interface_ctx_s { + + netsnmp_container *container; + + ipv4InterfaceTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_long last_changed; + +} ipv4InterfaceTable_interface_ctx; + +static ipv4InterfaceTable_interface_ctx ipv4InterfaceTable_if_ctx; + +static void + _ipv4InterfaceTable_container_init(ipv4InterfaceTable_interface_ctx * + if_ctx); +static void + _ipv4InterfaceTable_container_shutdown(ipv4InterfaceTable_interface_ctx * + if_ctx); + + +netsnmp_container * +ipv4InterfaceTable_container_get(void) +{ + return ipv4InterfaceTable_if_ctx.container; +} + +ipv4InterfaceTable_registration * +ipv4InterfaceTable_registration_get(void) +{ + return ipv4InterfaceTable_if_ctx.user_ctx; +} + +ipv4InterfaceTable_registration * +ipv4InterfaceTable_registration_set(ipv4InterfaceTable_registration * + newreg) +{ + ipv4InterfaceTable_registration *old = + ipv4InterfaceTable_if_ctx.user_ctx; + ipv4InterfaceTable_if_ctx.user_ctx = newreg; + return old; +} + +int +ipv4InterfaceTable_container_size(void) +{ + return CONTAINER_SIZE(ipv4InterfaceTable_if_ctx.container); +} + +u_int +ipv4InterfaceTable_dirty_get(void) +{ + return ifTable_dirty_get(); +} + +void +ipv4InterfaceTable_dirty_set(u_int status) +{ + ifTable_dirty_set(status); +} + +/* + * ipv4InterfaceTableLastChanged, which is the last time that a row in + * the table was changed or the last time a row was added/deleted from the + * table. + */ +void +ipv4InterfaceTable_lastChange_set(u_long table_changed) +{ + DEBUGMSGTL(("ipv4InterfaceTable:lastChanged_set", + "called. was %ld, now %ld\n", + ipv4InterfaceTable_if_ctx.last_changed, table_changed)); + ipv4InterfaceTable_if_ctx.last_changed = table_changed; +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_post_request; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_get_values; +#ifndef NETSNMP_DISABLE_SET_SUPPORT +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_check_objects; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_undo_setup; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_set_values; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_undo_values; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_commit; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_undo_commit; +static Netsnmp_Node_Handler _mfd_ipv4InterfaceTable_irreversible_commit; + +NETSNMP_STATIC_INLINE int + _ipv4InterfaceTable_undo_column(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * + var, int column); +#endif + +ipv4InterfaceTable_data *ipv4InterfaceTable_allocate_data(void); + +/** + * @internal + * Initialize the table ipv4InterfaceTable + * (Define its contents and how it's structured) + */ +void +_ipv4InterfaceTable_initialize_interface(ipv4InterfaceTable_registration * + reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipv4InterfaceTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipv4InterfaceTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipv4InterfaceTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipv4InterfaceIfIndex */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPV4INTERFACETABLE_MIN_COL; + tbl_info->max_column = IPV4INTERFACETABLE_MAX_COL; + + /* + * save users context + */ + ipv4InterfaceTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipv4InterfaceTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipv4InterfaceTable_container_init(&ipv4InterfaceTable_if_ctx); + if (NULL == ipv4InterfaceTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipv4InterfaceTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipv4InterfaceTable_object_lookup; + access_multiplexer->get_values = _mfd_ipv4InterfaceTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_ipv4InterfaceTable_pre_request; + access_multiplexer->post_request = + _mfd_ipv4InterfaceTable_post_request; + + +#ifndef NETSNMP_DISABLE_SET_SUPPORT + /* + * REQUIRED wrappers for set request handling + */ + access_multiplexer->object_syntax_checks = + _mfd_ipv4InterfaceTable_check_objects; + access_multiplexer->undo_setup = _mfd_ipv4InterfaceTable_undo_setup; + access_multiplexer->undo_cleanup = + _mfd_ipv4InterfaceTable_undo_cleanup; + access_multiplexer->set_values = _mfd_ipv4InterfaceTable_set_values; + access_multiplexer->undo_sets = _mfd_ipv4InterfaceTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_ipv4InterfaceTable_commit; + access_multiplexer->undo_commit = _mfd_ipv4InterfaceTable_undo_commit; + access_multiplexer->irreversible_commit = + _mfd_ipv4InterfaceTable_irreversible_commit; +#endif + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipv4InterfaceTable:init_ipv4InterfaceTable", + "Registering ipv4InterfaceTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipv4InterfaceTable", handler, + ipv4InterfaceTable_oid, + ipv4InterfaceTable_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 ipv4InterfaceTable\n"); + return; + } + reginfo->my_reg_void = &ipv4InterfaceTable_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; + +#ifndef 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 + + 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, + ipv4InterfaceTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + + /* + * register LastChanged + */ + { + oid lc_oid[] = { IPV4INTERFACETABLELASTCHANGE_OID }; + netsnmp_register_watched_scalar2(netsnmp_create_handler_registration + ("ipv4TableLastChanged", NULL, + lc_oid, OID_LENGTH(lc_oid), + HANDLER_CAN_RONLY), + netsnmp_create_watcher_info((void + *) + &ipv4InterfaceTable_if_ctx. + last_changed, + sizeof + (u_long), + ASN_TIMETICKS, + WATCHER_FIXED_SIZE)); + } +} /* _ipv4InterfaceTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipv4InterfaceTable + */ +void +_ipv4InterfaceTable_shutdown_interface(ipv4InterfaceTable_registration * + reg_ptr) +{ + /* + * shutdown the container + */ + _ipv4InterfaceTable_container_shutdown(&ipv4InterfaceTable_if_ctx); +} + +void +ipv4InterfaceTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipv4InterfaceTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipv4InterfaceTable_valid_columns_set */ + +/* + * ipv4InterfaceTable_allocate_data + * + * Purpose: create new ipv4InterfaceTable_data. + */ +ipv4InterfaceTable_data * +ipv4InterfaceTable_allocate_data(void) +{ + ipv4InterfaceTable_data *rtn = + SNMP_MALLOC_TYPEDEF(ipv4InterfaceTable_data); + + DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_allocate_data", "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipv4InterfaceTable_data.\n"); + } + + return rtn; +} /* ipv4InterfaceTable_allocate_data */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv4InterfaceTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipv4InterfaceTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipv4InterfaceTable_pre_request(ipv4InterfaceTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv4InterfaceTable", "error %d from " + "ipv4InterfaceTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv4InterfaceTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_post_request", "called\n")); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipv4InterfaceTable", + "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) && ipv4InterfaceTable_dirty_get()) { + /* + * we shouldn't get here. the undo steps should also clear + * the dirty flags. + */ + snmp_log(LOG_WARNING, + "ipv4InterfaceTable dirty flag set in post_request " + "but status != SUCCESS.\n"); + } + + rc = ipv4InterfaceTable_post_request(ipv4InterfaceTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv4InterfaceTable", "error %d from " + "ipv4InterfaceTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv4InterfaceTable_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; + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipv4InterfaceTable_interface_ctx *if_ctx = + * (ipv4InterfaceTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + rc = SNMP_ERR_NOCREATION; + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipv4InterfaceTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipv4InterfaceTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv4InterfaceTable_get_column(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv4InterfaceReasmMaxSize(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + case COLUMN_IPV4INTERFACEREASMMAXSIZE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; + rc = ipv4InterfaceReasmMaxSize_get(rowreq_ctx, + (long *) var->val.string); + break; + + /* + * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV4INTERFACEENABLESTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipv4InterfaceEnableStatus_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv4InterfaceRetransmitTime(4)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/D/h + */ + case COLUMN_IPV4INTERFACERETRANSMITTIME: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv4InterfaceRetransmitTime_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv4InterfaceTable_get_column\n", + column); + break; + } + + return rc; +} /* _ipv4InterfaceTable_get_column */ + +int +_mfd_ipv4InterfaceTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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 = _ipv4InterfaceTable_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_ipv4InterfaceTable_get_values */ + + +#ifndef NETSNMP_DISABLE_SET_SUPPORT +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/*---------------------------------------------------------------------- + * + * SET: Syntax checks + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check the syntax for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv4InterfaceTable_check_column(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_check_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + /* + * (INDEX) ipv4InterfaceIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + case COLUMN_IPV4INTERFACEIFINDEX: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + + /* + * ipv4InterfaceReasmMaxSize(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + case COLUMN_IPV4INTERFACEREASMMAXSIZE: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV4INTERFACEENABLESTATUS: + rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, + sizeof(rowreq_ctx->data. + ipv4InterfaceEnableStatus)); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != IPV4INTERFACEENABLESTATUS_UP) + && (*var->val.integer != IPV4INTERFACEENABLESTATUS_DOWN) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipv4InterfaceTable:_ipv4InterfaceTable_check_column:ipv4InterfaceEnableStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipv4InterfaceEnableStatus_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 ipv4InterfaceEnableStatus_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipv4InterfaceRetransmitTime(4)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/D/h + */ + case COLUMN_IPV4INTERFACERETRANSMITTIME: + rc = SNMP_ERR_NOTWRITABLE; + break; + + default: /** We shouldn't get here */ + rc = SNMP_ERR_GENERR; + snmp_log(LOG_ERR, + "unknown column %d in _ipv4InterfaceTable_check_column\n", + column); + } + + return rc; +} /* _ipv4InterfaceTable_check_column */ + +int +_mfd_ipv4InterfaceTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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 = _ipv4InterfaceTable_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_ipv4InterfaceTable_check_objects */ + + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv4InterfaceTable_undo_setup_column(ipv4InterfaceTable_rowreq_ctx * + rowreq_ctx, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_undo_setup_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV4INTERFACEENABLESTATUS: + rowreq_ctx->column_set_flags |= + COLUMN_IPV4INTERFACEENABLESTATUS_FLAG; + rc = ipv4InterfaceEnableStatus_undo_setup(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv4InterfaceTable_undo_setup_column\n", + column); + break; + } + + return rc; +} /* _ipv4InterfaceTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_ipv4InterfaceTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_setup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rc = _mfd_ifTable_undo_setup_allocate(rowreq_ctx); + if (MFD_SUCCESS != rc) { + netsnmp_request_set_error_all(requests, rc); + return SNMP_ERR_NOERROR; + } + + /* + * row undo setup + */ + rc = ipv4InterfaceTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_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 = _ipv4InterfaceTable_undo_setup_column(rowreq_ctx, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_undo_setup_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_ipv4InterfaceTable_undo_cleanup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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 = ipv4InterfaceTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + _mfd_ifTable_undo_setup_release(rowreq_ctx); + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv4InterfaceTable_set_column(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_set_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV4INTERFACEENABLESTATUS: + rowreq_ctx->column_set_flags |= + COLUMN_IPV4INTERFACEENABLESTATUS_FLAG; + rc = ipv4InterfaceEnableStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv4InterfaceTable_set_column\n", + column); + rc = SNMP_ERR_GENERR; + break; + } + + return rc; +} /* _ipv4InterfaceTable_set_column */ + +int +_mfd_ipv4InterfaceTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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 = _ipv4InterfaceTable_set_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_ipv4InterfaceTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipv4InterfaceTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_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... + */ + ipv4InterfaceTable_dirty_set(ipv4InterfaceTable_dirty_get() + 1); /* set table dirty flag */ + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_ipv4InterfaceTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + u_int d = ipv4InterfaceTable_dirty_get(); + + netsnmp_assert(d != 0); + if (d) + ipv4InterfaceTable_dirty_set(d - 1); + } + + rc = ipv4InterfaceTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_undo_commit\n", rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + snmp_log(LOG_WARNING, + "ipv4InterfaceTable row dirty flag still set after undo_commit\n"); + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +/** + * @internal + * undo the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv4InterfaceTable_undo_column(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_undo_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV4INTERFACEENABLESTATUS: + rc = ipv4InterfaceEnableStatus_undo(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv4InterfaceTable_undo_column\n", + column); + break; + } + + return rc; +} /* _ipv4InterfaceTable_undo_column */ + +int +_mfd_ipv4InterfaceTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipv4InterfaceTable_undo(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_undo\n", rc)); + } + + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipv4InterfaceTable_undo_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " + "ipv4InterfaceTable_undo_column\n", rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_undo_values */ + +/*---------------------------------------------------------------------- + * + * SET: irreversible commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit irreversible actions + */ +int +_mfd_ipv4InterfaceTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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) { + CONTAINER_REMOVE(ipv4InterfaceTable_if_ctx.container, rowreq_ctx); + } else { + if (rowreq_ctx->column_set_flags) { + rowreq_ctx->column_set_flags = 0; + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv4InterfaceTable_irreversible_commit */ +#endif + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:ipv4InterfaceTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipv4InterfaceTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipv4InterfaceTable_container_free(container); +} /* _container_free */ + +/** + * @internal + * initialize the container with functions or wrappers + */ +void +_ipv4InterfaceTable_container_init(ipv4InterfaceTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_container_init", "called\n")); + + /* + * container init + */ + ipv4InterfaceTable_container_init(&if_ctx->container); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipv4InterfaceTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipv4InterfaceTable_container_init\n"); + return; + } + if_ctx->container->container_name = strdup("ipv4InterfaceTable"); + +} /* _ipv4InterfaceTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipv4InterfaceTable_container_shutdown(ipv4InterfaceTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_container_shutdown", "called\n")); + + ipv4InterfaceTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipv4InterfaceTable_container_shutdown */ + + +ipv4InterfaceTable_rowreq_ctx * +ipv4InterfaceTable_row_find_by_mib_index(ipv4InterfaceTable_mib_index * + mib_idx) +{ + ipv4InterfaceTable_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 = ifTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = + CONTAINER_FIND(ipv4InterfaceTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.h b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.h new file mode 100644 index 0000000..46b3049 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.h @@ -0,0 +1,106 @@ +/* + * 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 IPV4INTERFACETABLE_INTERFACE_H +#define IPV4INTERFACETABLE_INTERFACE_H + +#ifdef __cplusplus + extern "C" { +#endif + + +#include "ipv4InterfaceTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipv4InterfaceTable_initialize_interface + (ipv4InterfaceTable_registration * user_ctx, u_long flags); + void + _ipv4InterfaceTable_shutdown_interface + (ipv4InterfaceTable_registration * user_ctx); + + ipv4InterfaceTable_registration + * ipv4InterfaceTable_registration_get(void); + + ipv4InterfaceTable_registration + * ipv4InterfaceTable_registration_set + (ipv4InterfaceTable_registration * newreg); + + netsnmp_container *ipv4InterfaceTable_container_get(void); + int ipv4InterfaceTable_container_size(void); + + u_int ipv4InterfaceTable_dirty_get(void); + void ipv4InterfaceTable_dirty_set(u_int status); + + ipv4InterfaceTable_rowreq_ctx + * ipv4InterfaceTable_allocate_rowreq_ctx(void *); + void + ipv4InterfaceTable_release_rowreq_ctx + (ipv4InterfaceTable_rowreq_ctx * rowreq_ctx); + + int ipv4InterfaceTable_index_to_oid(netsnmp_index * + oid_idx, + ipv4InterfaceTable_mib_index + * mib_idx); + int ipv4InterfaceTable_index_from_oid(netsnmp_index * + oid_idx, + ipv4InterfaceTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + ipv4InterfaceTable_valid_columns_set(netsnmp_column_info *vc); + + /* + */ + void ipv4InterfaceTable_lastChange_set(u_long uptime); + + +#ifdef __cplusplus + } +#endif +#endif /* IPV4INTERFACETABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_subagent.c b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_subagent.c new file mode 100644 index 0000000..35b2e96 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_subagent.c @@ -0,0 +1,207 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.7 $ of : subagent.m2c,v $ + */ +/* + * 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> + +netsnmp_feature_require(agentx_enable_subagent) +netsnmp_feature_require(agent_check_and_process) +netsnmp_feature_require(enable_stderrlog) + +/* + * include our parent header + */ +#include "ipv4InterfaceTable.h" + +#include <signal.h> + +static int keep_running; + +static RETSIGTYPE +stop_server(int a) +{ + keep_running = 0; +} + +static void +usage(void) +{ + printf + ("usage: ipv4InterfaceTable [-D<tokens>] [-f] [-L] [-M] [-H] [LISTENING ADDRESSES]\n" + "\t-f Do not fork() from the calling shell.\n" + "\t-DTOKEN[,TOKEN,...]\n" + "\t\tTurn on debugging output for the given TOKEN(s).\n" + "\t\tWithout any tokens specified, it defaults to printing\n" + "\t\tall the tokens (which is equivalent to the keyword 'ALL').\n" + "\t\tYou might want to try ALL for extremely verbose output.\n" + "\t\tNote: You can't put a space between the -D and the TOKENs.\n" + "\t-H\tDisplay a list of configuration file directives\n" + "\t\tunderstood by the agent and then exit.\n" + "\t-M\tRun as a normal SNMP Agent instead of an AgentX sub-agent.\n" + "\t-x ADDRESS\tconnect to master agent at ADDRESS (default NETSNMP_AGENTX_SOCKET).\n" + "\t-L\tDo not open a log file; print all messages to stderr.\n"); + exit(0); +} + +int +main(int argc, char **argv) +{ + int agentx_subagent = 1; /* change this if you want to be a SNMP master agent */ + /* + * Defs for arg-handling code: handles setting of policy-related variables + */ + int ch; + extern char *optarg; + int dont_fork = 0, use_syslog = 0; + char *agentx_socket = NULL; + + while ((ch = getopt(argc, argv, "D:fHLMx:")) != EOF) + switch (ch) { + case 'D': + debug_register_tokens(optarg); + snmp_set_do_debugging(1); + break; + case 'f': + dont_fork = 1; + break; + case 'H': + netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1); + init_agent("ipv4InterfaceTable"); /* register our .conf handlers */ + init_ipv4InterfaceTable(); + init_snmp("ipv4InterfaceTable"); + fprintf(stderr, "Configuration directives understood:\n"); + read_config_print_usage(" "); + exit(0); + case 'M': + agentx_subagent = 0; + break; + case 'L': + use_syslog = 0; /* use stderr */ + break; + case 'x': + agentx_socket = optarg; + break; + default: + fprintf(stderr, "unknown option %c\n", ch); + usage(); + } + + if (optind < argc) { + int i; + /* + * There are optional transport addresses on the command line. + */ + DEBUGMSGTL(("snmpd/main", "optind %d, argc %d\n", optind, argc)); + for (i = optind; i < argc; i++) { + char *c, *astring; + if ((c = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS))) { + astring = malloc(strlen(c) + 2 + strlen(argv[i])); + if (astring == NULL) { + fprintf(stderr, "malloc failure processing argv[%d]\n", + i); + exit(1); + } + sprintf(astring, "%s,%s", c, argv[i]); + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS, astring); + SNMP_FREE(astring); + } else { + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS, argv[i]); + } + } + DEBUGMSGTL(("snmpd/main", "port spec: %s\n", + netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_PORTS))); + } + + /* + * we're an agentx subagent? + */ + if (agentx_subagent) { + /* + * make us a agentx client. + */ + netsnmp_enable_subagent(); + if (NULL != agentx_socket) + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_X_SOCKET, + agentx_socket); + } + + snmp_disable_log(); + if (use_syslog) + snmp_enable_calllog(); + else + snmp_enable_stderrlog(); + + /* + * daemonize + */ + if (!dont_fork) { + int rc = netsnmp_daemonize(1, !use_syslog); + if (rc) + exit(-1); + } + + /* + * initialize tcp/ip if necessary + */ + SOCK_STARTUP; + + /* + * initialize the agent library + */ + init_agent("ipv4InterfaceTable"); + + /* + * init ipv4InterfaceTable mib code + */ + init_ipv4InterfaceTable(); + + /* + * read ipv4InterfaceTable.conf files. + */ + init_snmp("ipv4InterfaceTable"); + + /* + * If we're going to be a snmp master agent, initial the ports + */ + if (!agentx_subagent) + init_master_agent(); /* open the port to listen on (defaults to udp:161) */ + + /* + * In case we recevie a request to stop (kill -TERM or kill -INT) + */ + keep_running = 1; + signal(SIGTERM, stop_server); + signal(SIGINT, stop_server); + + /* + * you're main loop here... + */ + while (keep_running) { + /* + * if you use select(), see snmp_select_info() in snmp_api(3) + */ + /* + * --- OR --- + */ + agent_check_and_process(1); /* 0 == don't block */ + } + + /* + * at shutdown time + */ + snmp_shutdown("ipv4InterfaceTable"); + SOCK_CLEANUP; + exit(0); +} diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable.h b/agent/mibgroup/ip-mib/ipv6InterfaceTable.h new file mode 100644 index 0000000..471eaa0 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/ipv6InterfaceTable/ipv6InterfaceTable) diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable.c b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable.c new file mode 100644 index 0000000..92f0a5b --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable.c @@ -0,0 +1,1421 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +/** \page MFD helper for ipv6InterfaceTable + * + * \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 "ipv6InterfaceTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipv6InterfaceTable_interface.h" + +const oid ipv6InterfaceTable_oid[] = { IPV6INTERFACETABLE_OID }; +const int ipv6InterfaceTable_oid_size = +OID_LENGTH(ipv6InterfaceTable_oid); + +ipv6InterfaceTable_registration ipv6InterfaceTable_user_context; +static ipv6InterfaceTable_registration *ipv6InterfaceTable_user_context_p; + +void initialize_table_ipv6InterfaceTable(void); +void shutdown_table_ipv6InterfaceTable(void); + + +/** + * Initializes the ipv6InterfaceTable module + */ +void +init_ipv6InterfaceTable(void) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:init_ipv6InterfaceTable", + "called\n")); + + /* + * TODO:300:o: Perform ipv6InterfaceTable one-time module initialization. + */ + + /* + * we depend on the ifTable, so we put our init in with it + * to guarantee order of execution. + */ + init_ifTable(); + + /* + * last changed should be 0 at startup + */ + ipv6InterfaceTable_lastChange_set(0); + +} /* init_ipv6InterfaceTable */ + +/** + * Shut-down the ipv6InterfaceTable module (agent is exiting) + */ +void +shutdown_ipv6InterfaceTable(void) +{ + if (should_init("ipv6InterfaceTable")) + shutdown_table_ipv6InterfaceTable(); + +} + +/** + * Initialize the table ipv6InterfaceTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipv6InterfaceTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:initialize_table_ipv6InterfaceTable", "called\n")); + + /* + * TODO:301:o: Perform ipv6InterfaceTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipv6InterfaceTable 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. + */ + ipv6InterfaceTable_user_context_p = + netsnmp_create_data_list("ipv6InterfaceTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipv6InterfaceTable_initialize_interface + (ipv6InterfaceTable_user_context_p, flags); +} /* initialize_table_ipv6InterfaceTable */ + +/** + * Shutdown the table ipv6InterfaceTable + */ +void +shutdown_table_ipv6InterfaceTable(void) +{ + /* + * call interface shutdown code + */ + _ipv6InterfaceTable_shutdown_interface + (ipv6InterfaceTable_user_context_p); + netsnmp_free_all_list_data(ipv6InterfaceTable_user_context_p); + ipv6InterfaceTable_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 +ipv6InterfaceTable_rowreq_ctx_init(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipv6InterfaceTable rowreq initialization. (eg DEFVALS) + */ + + return MFD_SUCCESS; +} /* ipv6InterfaceTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * @param rowreq_ctx + */ +void +ipv6InterfaceTable_rowreq_ctx_cleanup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipv6InterfaceTable rowreq cleanup. + */ +} /* ipv6InterfaceTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * @param user_context + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipv6InterfaceTable_pre_request(ipv6InterfaceTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform ipv6InterfaceTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipv6InterfaceTable_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 +ipv6InterfaceTable_post_request(ipv6InterfaceTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform ipv6InterfaceTable post-request actions. + */ + + /* + * check to set if any rows were changed. + */ + if (ipv6InterfaceTable_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 + */ + } + + ipv6InterfaceTable_dirty_set(0); /* clear table dirty flag */ + } + + return MFD_SUCCESS; +} /* ipv6InterfaceTable_post_request */ + + +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipv6InterfaceTable data context functions. + */ + + + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceReasmMaxSize + * ipv6InterfaceReasmMaxSize is subid 2 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.30.1.2 + * Description: +The size of the largest IPv6 datagram which this entity can + re-assemble from incoming IPv6 fragmented datagrams received + on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 1500 - 65535; + * + * Its syntax is UNSIGNED32 (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 ipv6InterfaceReasmMaxSize data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6InterfaceReasmMaxSize_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 +ipv6InterfaceReasmMaxSize_get(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6InterfaceReasmMaxSize_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6InterfaceReasmMaxSize_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceReasmMaxSize_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_REASMMAX)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv6InterfaceReasmMaxSize data. + * copy (* ipv6InterfaceReasmMaxSize_val_ptr ) from rowreq_ctx->data + */ + (*ipv6InterfaceReasmMaxSize_val_ptr) = + rowreq_ctx->data.ipv6InterfaceReasmMaxSize; + + return MFD_SUCCESS; +} /* ipv6InterfaceReasmMaxSize_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceIdentifier + * ipv6InterfaceIdentifier is subid 3 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.30.1.3 + * Description: +The Interface Identifier for this interface. The Interface + Identifier is combined with an address prefix to form an + interface address. + + + By default, the Interface Identifier is auto-configured + according to the rules of the link type this interface is + attached to. + + + A zero length identifier may be used where appropriate. One + possible example is a loopback interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 2x: + * + * Ranges: 0 - 8; + * + * Its syntax is Ipv6AddressIfIdentifierTC (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 8) + */ +/** + * Extract the current value of the ipv6InterfaceIdentifier data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6InterfaceIdentifier_val_ptr_ptr + * Pointer to storage for a char variable + * @param ipv6InterfaceIdentifier_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by ipv6InterfaceIdentifier. + * 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 (*ipv6InterfaceIdentifier_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update ipv6InterfaceIdentifier_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 +ipv6InterfaceIdentifier_get(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + char **ipv6InterfaceIdentifier_val_ptr_ptr, + size_t + * ipv6InterfaceIdentifier_val_ptr_len_ptr) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert((NULL != ipv6InterfaceIdentifier_val_ptr_ptr) + && (NULL != *ipv6InterfaceIdentifier_val_ptr_ptr)); + netsnmp_assert(NULL != ipv6InterfaceIdentifier_val_ptr_len_ptr); + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceIdentifier_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_IFID)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv6InterfaceIdentifier data. + * copy (* ipv6InterfaceIdentifier_val_ptr_ptr ) data and (* ipv6InterfaceIdentifier_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for ipv6InterfaceIdentifier data + */ + if ((NULL == (*ipv6InterfaceIdentifier_val_ptr_ptr)) || + ((*ipv6InterfaceIdentifier_val_ptr_len_ptr) < + (rowreq_ctx->data.ipv6InterfaceIdentifier_len * + sizeof(rowreq_ctx->data.ipv6InterfaceIdentifier[0])))) { + /* + * allocate space for ipv6InterfaceIdentifier data + */ + (*ipv6InterfaceIdentifier_val_ptr_ptr) = + malloc(rowreq_ctx->data.ipv6InterfaceIdentifier_len * + sizeof(rowreq_ctx->data.ipv6InterfaceIdentifier[0])); + if (NULL == (*ipv6InterfaceIdentifier_val_ptr_ptr)) { + snmp_log(LOG_ERR, "could not allocate memory\n"); + return MFD_ERROR; + } + } + (*ipv6InterfaceIdentifier_val_ptr_len_ptr) = + rowreq_ctx->data.ipv6InterfaceIdentifier_len * + sizeof(rowreq_ctx->data.ipv6InterfaceIdentifier[0]); + memcpy((*ipv6InterfaceIdentifier_val_ptr_ptr), + rowreq_ctx->data.ipv6InterfaceIdentifier, + rowreq_ctx->data.ipv6InterfaceIdentifier_len * + sizeof(rowreq_ctx->data.ipv6InterfaceIdentifier[0])); + + return MFD_SUCCESS; +} /* ipv6InterfaceIdentifier_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceEnableStatus + * ipv6InterfaceEnableStatus is subid 5 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.4.30.1.5 + * Description: +The indication of whether IPv6 is enabled (up) or disabled + (down) on this interface. This object does not affect the + state of the interface itself, only its connection to an + IPv6 stack. The IF-MIB should be used to control the state + of the interface. + + + When this object is written the entity SHOULD save the + change to non-volatile storage and restore the object from + non-volatile storage upon re-initialization of the system. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 1/8. Values: up(1), down(2) + * + * 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 ipv6InterfaceEnableStatus data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6InterfaceEnableStatus_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 +ipv6InterfaceEnableStatus_get(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6InterfaceEnableStatus_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6InterfaceEnableStatus_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceEnableStatus_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6InterfaceEnableStatus data. + * copy (* ipv6InterfaceEnableStatus_val_ptr ) from rowreq_ctx->data + */ + (*ipv6InterfaceEnableStatus_val_ptr) = + rowreq_ctx->data.ipv6InterfaceEnableStatus; + + return MFD_SUCCESS; +} /* ipv6InterfaceEnableStatus_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceReachableTime + * ipv6InterfaceReachableTime is subid 6 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.30.1.6 + * Description: +The time a neighbor is considered reachable after receiving + a reachability confirmation. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is UNSIGNED32 (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 ipv6InterfaceReachableTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6InterfaceReachableTime_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 +ipv6InterfaceReachableTime_get(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6InterfaceReachableTime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6InterfaceReachableTime_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceReachableTime_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_REACHABLE)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv6InterfaceReachableTime data. + * copy (* ipv6InterfaceReachableTime_val_ptr ) from rowreq_ctx->data + */ + (*ipv6InterfaceReachableTime_val_ptr) = + rowreq_ctx->data.ipv6InterfaceReachableTime; + + return MFD_SUCCESS; +} /* ipv6InterfaceReachableTime_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceRetransmitTime + * ipv6InterfaceRetransmitTime is subid 7 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.30.1.7 + * Description: +The time between retransmissions of Neighbor Solicitation + messages to a neighbor when resolving the address or when + probing the reachability of a neighbor. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is UNSIGNED32 (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 ipv6InterfaceRetransmitTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6InterfaceRetransmitTime_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 +ipv6InterfaceRetransmitTime_get(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * + ipv6InterfaceRetransmitTime_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6InterfaceRetransmitTime_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceRetransmitTime_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_RETRANSMIT)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv6InterfaceRetransmitTime data. + * copy (* ipv6InterfaceRetransmitTime_val_ptr ) from rowreq_ctx->data + */ + (*ipv6InterfaceRetransmitTime_val_ptr) = + rowreq_ctx->data.ipv6InterfaceRetransmitTime; + + return MFD_SUCCESS; +} /* ipv6InterfaceRetransmitTime_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceForwarding + * ipv6InterfaceForwarding is subid 8 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.4.30.1.8 + * Description: +The indication of whether this entity is acting as an IPv6 + router on this interface with respect to the forwarding of + datagrams received by, but not addressed to, this entity. + IPv6 routers forward datagrams. IPv6 hosts do not (except + those source-routed via the host). + + + + + + This object is constrained by ipv6IpForwarding and is + ignored if ipv6IpForwarding is set to notForwarding. Those + systems that do not provide per-interface control of the + forwarding function should set this object to forwarding for + all interfaces and allow the ipv6IpForwarding object to + control the forwarding capability. + + + When this object is written the entity SHOULD save the + change to non-volatile storage and restore the object from + non-volatile storage upon re-initialization of the system. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 2/8. Values: forwarding(1), notForwarding(2) + * + * 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 ipv6InterfaceForwarding data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6InterfaceForwarding_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 +ipv6InterfaceForwarding_get(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6InterfaceForwarding_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6InterfaceForwarding_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceForwarding_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (! + (rowreq_ctx->data.ifentry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_FORWARDING)) + return MFD_SKIP; + + /* + * TODO:231:o: |-> Extract the current value of the ipv6InterfaceForwarding data. + * copy (* ipv6InterfaceForwarding_val_ptr ) from rowreq_ctx->data + */ + (*ipv6InterfaceForwarding_val_ptr) = + (rowreq_ctx->data.ipv6InterfaceForwarding) ? 1 : 2; + + return MFD_SUCCESS; +} /* ipv6InterfaceForwarding_get */ + + + +/** @} */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ + /* + * 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 + * +==============+ + * +----------------|| object || + * | E || lookup || + * | +==============+ + * | | 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 + * +--------------+ + * | post | + * | request | + * +--------------+ + * + */ + +/** + * 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 + * ipv6InterfaceTable_allocate_data(), but may need extra + * initialization similar to what you may have done in + * ipv6InterfaceTable_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 (ipv6InterfaceTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipv6InterfaceTable_undo_setup(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_undo_setup", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> Setup ipv6InterfaceTable undo. + * set up ipv6InterfaceTable undo information, in preparation for a set. + * Undo storage is in (* ipv6InterfaceForwarding_val_ptr )* + */ + + return rc; +} /* ipv6InterfaceTable_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 (ipv6InterfaceTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +ipv6InterfaceTable_undo(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_undo", + "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:451:M: |-> ipv6InterfaceTable undo. + * ipv6InterfaceTable undo information, in response to a failed set. + * Undo storage is in (* ipv6InterfaceForwarding_val_ptr )* + */ + + return rc; +} /* ipv6InterfaceTable_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 (ipv6InterfaceTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +ipv6InterfaceTable_undo_cleanup(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_undo_cleanup", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:452:M: |-> Cleanup ipv6InterfaceTable undo. + * Undo storage is in (* ipv6InterfaceForwarding_val_ptr )* + */ + + return rc; +} /* ipv6InterfaceTable_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 + * ipv6InterfaceTable.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 +ipv6InterfaceTable_commit(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + int save_flags; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_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 ipv6InterfaceTable 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_IPV6INTERFACEENABLESTATUS_FLAG) { + save_flags &= ~COLUMN_IPV6INTERFACEENABLESTATUS_FLAG; /* clear ipv6InterfaceEnableStatus */ + /* + * TODO:482:o: |-> commit column ipv6InterfaceEnableStatus. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipv6InterfaceTable column ipv6InterfaceEnableStatus commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipv6InterfaceEnableStatus + */ + rowreq_ctx->column_set_flags |= + COLUMN_IPV6INTERFACEENABLESTATUS_FLAG; + } + } + + if (save_flags & COLUMN_IPV6INTERFACEFORWARDING_FLAG) { + save_flags &= ~COLUMN_IPV6INTERFACEFORWARDING_FLAG; /* clear ipv6InterfaceForwarding */ + /* + * TODO:482:o: |-> commit column ipv6InterfaceForwarding. + */ + rc = -1; + if (-1 == rc) { + snmp_log(LOG_ERR, + "ipv6InterfaceTable column ipv6InterfaceForwarding commit failed\n"); + } else { + /* + * set flag, in case we need to undo ipv6InterfaceForwarding + */ + rowreq_ctx->column_set_flags |= + COLUMN_IPV6INTERFACEFORWARDING_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; +} /* ipv6InterfaceTable_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 + * ipv6InterfaceTable.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 +ipv6InterfaceTable_undo_commit(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_undo_commit", "called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:485:M: |-> Undo ipv6InterfaceTable 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; +} /* ipv6InterfaceTable_undo_commit */ + +/* + * TODO:440:M: Implement ipv6InterfaceTable node value checks. + * TODO:450:M: Implement ipv6InterfaceTable undo functions. + * TODO:460:M: Implement ipv6InterfaceTable set functions. + * TODO:480:M: Implement ipv6InterfaceTable commit functions. + */ +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceEnableStatus + * ipv6InterfaceEnableStatus is subid 5 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.4.30.1.5 + * Description: +The indication of whether IPv6 is enabled (up) or disabled + (down) on this interface. This object does not affect the + state of the interface itself, only its connection to an + IPv6 stack. The IF-MIB should be used to control the state + of the interface. + + + When this object is written the entity SHOULD save the + change to non-volatile storage and restore the object from + non-volatile storage upon re-initialization of the system. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 1/8. Values: up(1), down(2) + * + * 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 ipv6InterfaceEnableStatus_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 + * ipv6InterfaceTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of up(1), down(2) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipv6InterfaceEnableStatus_check_value(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long ipv6InterfaceEnableStatus_val) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceEnableStatus_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipv6InterfaceEnableStatus value. + */ + + return MFD_SUCCESS; /* ipv6InterfaceEnableStatus value not illegal */ +} /* ipv6InterfaceEnableStatus_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipv6InterfaceTable_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 + * ipv6InterfaceTable_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 +ipv6InterfaceEnableStatus_undo_setup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceEnableStatus_undo_setup", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipv6InterfaceEnableStatus undo. + */ + /* + * copy ipv6InterfaceEnableStatus data + * set rowreq_ctx->undo->ipv6InterfaceEnableStatus from rowreq_ctx->data.ipv6InterfaceEnableStatus + */ + rowreq_ctx->undo->ipv6InterfaceEnableStatus = + rowreq_ctx->data.ipv6InterfaceEnableStatus; + + + return MFD_SUCCESS; +} /* ipv6InterfaceEnableStatus_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 ipv6InterfaceEnableStatus_val + * A long containing the new value. + */ +int +ipv6InterfaceEnableStatus_set(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long ipv6InterfaceEnableStatus_val) +{ + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceEnableStatus_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipv6InterfaceEnableStatus value. + * set ipv6InterfaceEnableStatus value in rowreq_ctx->data + */ + rowreq_ctx->data.ipv6InterfaceEnableStatus = + ipv6InterfaceEnableStatus_val; + + return MFD_SUCCESS; +} /* ipv6InterfaceEnableStatus_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipv6InterfaceEnableStatus_undo(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceEnableStatus_undo", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipv6InterfaceEnableStatus undo. + */ + /* + * copy ipv6InterfaceEnableStatus data + * set rowreq_ctx->data.ipv6InterfaceEnableStatus from rowreq_ctx->undo->ipv6InterfaceEnableStatus + */ + rowreq_ctx->data.ipv6InterfaceEnableStatus = + rowreq_ctx->undo->ipv6InterfaceEnableStatus; + + + return MFD_SUCCESS; +} /* ipv6InterfaceEnableStatus_undo */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6InterfaceEntry.ipv6InterfaceForwarding + * ipv6InterfaceForwarding is subid 8 of ipv6InterfaceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.4.30.1.8 + * Description: +The indication of whether this entity is acting as an IPv6 + router on this interface with respect to the forwarding of + datagrams received by, but not addressed to, this entity. + IPv6 routers forward datagrams. IPv6 hosts do not (except + those source-routed via the host). + + + + + + This object is constrained by ipv6IpForwarding and is + ignored if ipv6IpForwarding is set to notForwarding. Those + systems that do not provide per-interface control of the + forwarding function should set this object to forwarding for + all interfaces and allow the ipv6IpForwarding object to + control the forwarding capability. + + + When this object is written the entity SHOULD save the + change to non-volatile storage and restore the object from + non-volatile storage upon re-initialization of the system. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 1 + * + * Enum range: 2/8. Values: forwarding(1), notForwarding(2) + * + * 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 ipv6InterfaceForwarding_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 + * ipv6InterfaceTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_INTEGER + * The value is one of forwarding(1), notForwarding(2) + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +ipv6InterfaceForwarding_check_value(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long ipv6InterfaceForwarding_val) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceForwarding_check_value", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:441:o: |-> Check for valid ipv6InterfaceForwarding value. + */ + + return MFD_SUCCESS; /* ipv6InterfaceForwarding value not illegal */ +} /* ipv6InterfaceForwarding_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (ipv6InterfaceTable_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 + * ipv6InterfaceTable_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 +ipv6InterfaceForwarding_undo_setup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceForwarding_undo_setup", "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup ipv6InterfaceForwarding undo. + */ + /* + * copy ipv6InterfaceForwarding data + * set rowreq_ctx->undo->ipv6InterfaceForwarding from rowreq_ctx->data.ipv6InterfaceForwarding + */ + rowreq_ctx->undo->ipv6InterfaceForwarding = + rowreq_ctx->data.ipv6InterfaceForwarding; + + + return MFD_SUCCESS; +} /* ipv6InterfaceForwarding_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 ipv6InterfaceForwarding_val + * A long containing the new value. + */ +int +ipv6InterfaceForwarding_set(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long ipv6InterfaceForwarding_val) +{ + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceForwarding_set", + "called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:461:M: |-> Set ipv6InterfaceForwarding value. + * set ipv6InterfaceForwarding value in rowreq_ctx->data + */ + rowreq_ctx->data.ipv6InterfaceForwarding = ipv6InterfaceForwarding_val; + + return MFD_SUCCESS; +} /* ipv6InterfaceForwarding_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +ipv6InterfaceForwarding_undo(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceForwarding_undo", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up ipv6InterfaceForwarding undo. + */ + /* + * copy ipv6InterfaceForwarding data + * set rowreq_ctx->data.ipv6InterfaceForwarding from rowreq_ctx->undo->ipv6InterfaceForwarding + */ + rowreq_ctx->data.ipv6InterfaceForwarding = + rowreq_ctx->undo->ipv6InterfaceForwarding; + + + return MFD_SUCCESS; +} /* ipv6InterfaceForwarding_undo */ + +/** @} */ +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable.h b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable.h new file mode 100644 index 0000000..e2a87a1 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable.h @@ -0,0 +1,971 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.48 $ of : mfd-top.m2c,v $ + * + * $Id$ + */ +#ifndef IPV6INTERFACETABLE_H +#define IPV6INTERFACETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/interface.h> + +#include "if-mib/ifTable/ifTable.h" + + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(if-mib/ifTable/ifTable) +config_require(ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface) +config_require(ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access) + /* *INDENT-ON* */ + + /* + * OID, column number and enum definions for ipv6InterfaceTable + */ +#include "ipv6InterfaceTable_constants.h" + + /* + ********************************************************************* + * function declarations + */ + void initialize_table_ipv6InterfaceTable(void); + void init_ipv6InterfaceTable(void); + void shutdown_ipv6InterfaceTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + * + * we share data structures (data too, in fact) with ifTable + */ + typedef ifTable_registration ipv6InterfaceTable_registration; + typedef ifTable_data ipv6InterfaceTable_data; + typedef ifTable_undo_data ipv6InterfaceTable_undo_data; + typedef ifTable_mib_index ipv6InterfaceTable_mib_index; + typedef ifTable_rowreq_ctx ipv6InterfaceTable_rowreq_ctx; + + /* + * ipv6InterfaceReasmMaxSize(2)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/R/d/h + */ +#define ipv6InterfaceReasmMaxSize ifentry->reasm_max_v6 + + /* + * ipv6InterfaceIdentifier(3)/Ipv6AddressIfIdentifierTC/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + +#define ipv6InterfaceIdentifier ifentry->v6_if_id +#define ipv6InterfaceIdentifier_len ifentry->v6_if_id_len + + /* + * ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ +#define ipv6InterfaceEnableStatus ifentry->admin_status + + /* + * ipv6InterfaceReachableTime(6)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ +#define ipv6InterfaceReachableTime ifentry->reachable_time + + /* + * ipv6InterfaceRetransmitTime(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ +#define ipv6InterfaceRetransmitTime ifentry->retransmit_v6 + + /* + * ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ +#define ipv6InterfaceForwarding ifentry->forwarding_v6 + + + /* + ********************************************************************* + * function prototypes + */ + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_pre_request(ipv6InterfaceTable_registration * + user_context); + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_post_request(ipv6InterfaceTable_registration * + user_context, int rc); + + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_rowreq_ctx_init(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + void *user_init_ctx); + void + + + + + + + + + + + + + + + + ipv6InterfaceTable_rowreq_ctx_cleanup(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + + int ipv6InterfaceTable_commit(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + + + + + + + + ipv6InterfaceTable_rowreq_ctx + * ipv6InterfaceTable_row_find_by_mib_index + (ipv6InterfaceTable_mib_index * mib_idx); + + extern const oid ipv6InterfaceTable_oid[]; + extern const int ipv6InterfaceTable_oid_size; + + +#include "ipv6InterfaceTable_interface.h" +#include "ipv6InterfaceTable_data_access.h" + /* + ********************************************************************* + * GET function declarations + */ + + /* + ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ + /* + * indexes + */ + + int + + + + + + + + + + + + + + + + ipv6InterfaceReasmMaxSize_get(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6InterfaceReasmMaxSize_val_ptr); + int + + + + + + + + + + + + + + + + ipv6InterfaceIdentifier_get(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, char + **ipv6InterfaceIdentifier_val_ptr_ptr, + size_t + * + ipv6InterfaceIdentifier_val_ptr_len_ptr); + int + + + + + + + + + + + + + + + + ipv6InterfaceEnableStatus_get(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6InterfaceEnableStatus_val_ptr); + int + + + + + + + + + + + + + + + + ipv6InterfaceReachableTime_get(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6InterfaceReachableTime_val_ptr); + int + + + + + + + + + + + + + + + + ipv6InterfaceRetransmitTime_get(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6InterfaceRetransmitTime_val_ptr); + int + + + + + + + + + + + + + + + + ipv6InterfaceForwarding_get(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6InterfaceForwarding_val_ptr); + + + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_indexes_set_tbl_idx(ipv6InterfaceTable_mib_index + * tbl_idx, long + ipv6InterfaceIfIndex_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_indexes_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + long ipv6InterfaceIfIndex_val); + + + + /* + ********************************************************************* + * SET function declarations + */ + + /* + ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ + + + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_undo_setup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_undo_cleanup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + int ipv6InterfaceTable_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + int ipv6InterfaceTable_commit(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_undo_commit(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + + int + + + + + + + + + + + + + + + + ipv6InterfaceReasmMaxSize_check_value(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx, + u_long + ipv6InterfaceReasmMaxSize_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceReasmMaxSize_undo_setup(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceReasmMaxSize_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv6InterfaceReasmMaxSize_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceReasmMaxSize_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + + + + + + + + + + + + + + + + ipv6InterfaceIdentifier_check_value(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, char + *ipv6InterfaceIdentifier_val_ptr, + size_t + ipv6InterfaceIdentifier_val_ptr_len); + int + + + + + + + + + + + + + + + + ipv6InterfaceIdentifier_undo_setup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceIdentifier_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + char *ipv6InterfaceIdentifier_val_ptr, + size_t + ipv6InterfaceIdentifier_val_ptr_len); + int + + + + + + + + + + + + + + + + ipv6InterfaceIdentifier_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + + + + + + + + + + + + + + + + ipv6InterfaceEnableStatus_check_value(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx, + u_long + ipv6InterfaceEnableStatus_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceEnableStatus_undo_setup(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceEnableStatus_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv6InterfaceEnableStatus_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceEnableStatus_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + + + + + + + + + + + + + + + + ipv6InterfaceReachableTime_check_value + (ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long ipv6InterfaceReachableTime_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceReachableTime_undo_setup(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceReachableTime_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv6InterfaceReachableTime_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceReachableTime_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + + + + + + + + + + + + + + + + ipv6InterfaceRetransmitTime_check_value + (ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + u_long ipv6InterfaceRetransmitTime_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceRetransmitTime_undo_setup + (ipv6InterfaceTable_rowreq_ctx * rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceRetransmitTime_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv6InterfaceRetransmitTime_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceRetransmitTime_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + int + + + + + + + + + + + + + + + + ipv6InterfaceForwarding_check_value(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long + ipv6InterfaceForwarding_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceForwarding_undo_setup(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + int + + + + + + + + + + + + + + + + ipv6InterfaceForwarding_set(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, + u_long ipv6InterfaceForwarding_val); + int + + + + + + + + + + + + + + + + ipv6InterfaceForwarding_undo(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + + int + + + + + + + + + + + + + + + + ipv6InterfaceTable_check_dependencies(ipv6InterfaceTable_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 /* IPV6INTERFACETABLE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_constants.h b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_constants.h new file mode 100644 index 0000000..a8f371b --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_constants.h @@ -0,0 +1,104 @@ +/* + * 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 IPV6INTERFACETABLE_CONSTANTS_H +#define IPV6INTERFACETABLE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipv6InterfaceTable + */ +#define IPV6INTERFACETABLELASTCHANGE_OID 1,3,6,1,2,1,4,29 +#define IPV6INTERFACETABLE_OID 1,3,6,1,2,1,4,30 + +#define COLUMN_IPV6INTERFACEIFINDEX 1 + +#define COLUMN_IPV6INTERFACEREASMMAXSIZE 2 + +#define COLUMN_IPV6INTERFACEIDENTIFIER 3 + +#define COLUMN_IPV6INTERFACEENABLESTATUS 5 +#define COLUMN_IPV6INTERFACEENABLESTATUS_FLAG (0x1 << 4) + +#define COLUMN_IPV6INTERFACEREACHABLETIME 6 + +#define COLUMN_IPV6INTERFACERETRANSMITTIME 7 + +#define COLUMN_IPV6INTERFACEFORWARDING 8 +#define COLUMN_IPV6INTERFACEFORWARDING_FLAG (0x1 << 7) + + +#define IPV6INTERFACETABLE_MIN_COL COLUMN_IPV6INTERFACEREASMMAXSIZE +#define IPV6INTERFACETABLE_MAX_COL COLUMN_IPV6INTERFACEFORWARDING + + + /* + * TODO:405:r: Review IPV6INTERFACETABLE_SETTABLE_COLS macro. + * OR together all the writable cols. + */ +#define IPV6INTERFACETABLE_SETTABLE_COLS (COLUMN_IPV6INTERFACEENABLESTATUS_FLAG | COLUMN_IPV6INTERFACEFORWARDING_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 ipv6InterfaceTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * ipv6InterfaceEnableStatus (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPV6INTERFACEENABLESTATUS_ENUMS +#define IPV6INTERFACEENABLESTATUS_ENUMS + +#define IPV6INTERFACEENABLESTATUS_UP 1 +#define IPV6INTERFACEENABLESTATUS_DOWN 2 + +#endif /* IPV6INTERFACEENABLESTATUS_ENUMS */ + + +/************************************************************* + * constants for enums for the MIB node + * ipv6InterfaceForwarding (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef IPV6INTERFACEFORWARDING_ENUMS +#define IPV6INTERFACEFORWARDING_ENUMS + +#define IPV6INTERFACEFORWARDING_FORWARDING 1 +#define IPV6INTERFACEFORWARDING_NOTFORWARDING 2 + +#endif /* IPV6INTERFACEFORWARDING_ENUMS */ + + + + +#ifdef __cplusplus +} +#endif +#endif /* IPV6INTERFACETABLE_OIDS_H */ diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access.c b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access.c new file mode 100644 index 0000000..33c65a9 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access.c @@ -0,0 +1,390 @@ +/* + * 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 "ipv6InterfaceTable.h" + + +#include "ipv6InterfaceTable_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 ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ + +/** + * initialization for ipv6InterfaceTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipv6InterfaceTable_reg + * Pointer to ipv6InterfaceTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipv6InterfaceTable_init_data(ipv6InterfaceTable_registration * + ipv6InterfaceTable_reg) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_init_data", + "called\n")); + + /* + * TODO:303:o: Initialize ipv6InterfaceTable data. + */ + + return MFD_SUCCESS; +} /* ipv6InterfaceTable_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. + * + * 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. + * + * @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 +ipv6InterfaceTable_container_init(netsnmp_container **container_ptr_ptr) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipv6InterfaceTable_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; + +} /* ipv6InterfaceTable_container_init */ + +/** + * @internal + * determine if we want a ifTable row in our container + */ +void +ipv6InterfaceTable_check_entry_for_updates(const ifTable_rowreq_ctx * + ift_rrc, + netsnmp_interface_entry *entry) +{ + netsnmp_container *c = ipv6InterfaceTable_container_get(); + ifTable_rowreq_ctx *ip6if_rrc; + int changed = 0; + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:check_entry_for_updates", + "called\n")); + + /* + * do we have a corresponding row? + */ + ip6if_rrc = CONTAINER_FIND(c, ift_rrc); + if (NULL == ip6if_rrc) { + /* + * no corresponding row. should we have one? + */ + if ((NULL != entry) && + (entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_IPV6)) { + /* + * yes. + */ + DEBUGMSGTL(("ipv6InterfaceTable:check_entry_for_updates", + "inserted row for index %" NETSNMP_PRIo "d\n", entry->index)); + CONTAINER_INSERT(c, ift_rrc); + changed = 1; + } + } else { + /* + * found corresponding row. is it still applicable? + */ + if ((NULL == entry) || + (0 == (entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_IPV6))) { + /* + * no + */ + DEBUGMSGTL(("ipv6InterfaceTable:check_entry_for_updates", + "removed row for index %" NETSNMP_PRIo "d\n", + ift_rrc->data.ifentry->index)); + CONTAINER_REMOVE(c, ift_rrc); + changed = 1; + } else { + /* + * still applicable. anything changed? + */ + if (/** retransmit */ + ((entry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_RETRANSMIT) + && (entry->retransmit_v6 != + ift_rrc->data.ifentry->retransmit_v6)) || + /** reasm */ + ((entry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_REASMMAX) + && (entry->reasm_max_v6 != + ift_rrc->data.ifentry->reasm_max_v6)) || + /** reachable time */ + ((entry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_REACHABLE) + && (entry->reachable_time != + ift_rrc->data.ifentry->reachable_time)) || + /** if id */ + ((entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_IFID) + && + ((entry->v6_if_id_len != + ift_rrc->data.ifentry->v6_if_id_len) + || (0 != + memcmp(entry->v6_if_id, + ift_rrc->data.ifentry->v6_if_id, + entry->v6_if_id_len)))) || + /** forwarding */ + ((entry-> + ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V6_FORWARDING) + && (entry->forwarding_v6 != + ift_rrc->data.ifentry->forwarding_v6))) { + DEBUGMSGTL(("ipv6InterfaceTable:check_entry_for_updates", + "row changed for index %" NETSNMP_PRIo "d\n", + ift_rrc->data.ifentry->index)); + changed = 1; + } + } + } + + /* + * if something changed, update table last changed + */ + if (changed) + ipv6InterfaceTable_lastChange_set(netsnmp_get_agent_uptime()); +} + + +/** + * 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 ipv6InterfaceTable_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 +ipv6InterfaceTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipv6InterfaceTable_container_shutdown\n"); + return; + } + +} /* ipv6InterfaceTable_container_shutdown */ + +/** + * load initial data + * + * TODO:350:M: Implement ipv6InterfaceTable data load + * + * @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 + * ipv6InterfaceTable_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 +ipv6InterfaceTable_container_load(netsnmp_container *container) +{ + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + + /* + * temporary storage for index values + */ + /* + * ipv6InterfaceIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + long ipv6InterfaceIfIndex; + + + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_container_load", "called\n")); + + /* + * TODO:351:M: |-> Load/update data in the ipv6InterfaceTable container. + * loop over your ipv6InterfaceTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + while (1) { + /* + * check for end of data; bail out if there is no more data + */ + if (1) + break; + + /* + * TODO:352:M: | |-> set indexes in new ipv6InterfaceTable rowreq context. + * data context will be set from the param (unless NULL, + * in which case a new data context will be allocated) + */ + rowreq_ctx = ipv6InterfaceTable_allocate_rowreq_ctx(NULL); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + if (MFD_SUCCESS != + ipv6InterfaceTable_indexes_set(rowreq_ctx, + ipv6InterfaceIfIndex)) { + snmp_log(LOG_ERR, + "error setting index while loading " + "ipv6InterfaceTable data.\n"); + ipv6InterfaceTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + + /* + * TODO:352:r: | |-> populate ipv6InterfaceTable data context. + * Populate data context here. (optionally, delay until row prep) + */ + /* + * non-TRANSIENT data: no need to copy. set pointer to data + */ + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + DEBUGMSGT(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_container_load", "inserted %d records\n", (int)count)); + + return MFD_SUCCESS; +} /* ipv6InterfaceTable_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 +ipv6InterfaceTable_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_container_free", "called\n")); + + /* + * TODO:380:M: Free ipv6InterfaceTable container data. + */ +} /* ipv6InterfaceTable_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 +ipv6InterfaceTable_row_prep(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv6InterfaceTable:ipv6InterfaceTable_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; +} /* ipv6InterfaceTable_row_prep */ + +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access.h b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access.h new file mode 100644 index 0000000..664c3d7 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_data_access.h @@ -0,0 +1,64 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.17 $ of : mfd-data-access.m2c,v $ + * + * $Id$ + */ +#ifndef IPV6INTERFACETABLE_DATA_ACCESS_H +#define IPV6INTERFACETABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ + + + int ipv6InterfaceTable_init_data(ipv6InterfaceTable_registration * + ipv6InterfaceTable_reg); + + + void ipv6InterfaceTable_check_entry_for_updates( + const ifTable_rowreq_ctx * ift_rrc, + netsnmp_interface_entry *entry); + + void ipv6InterfaceTable_container_init(netsnmp_container + **container_ptr_ptr); + void ipv6InterfaceTable_container_shutdown(netsnmp_container + *container_ptr); + + int ipv6InterfaceTable_container_load(netsnmp_container + *container); + void ipv6InterfaceTable_container_free(netsnmp_container + *container); + + int ipv6InterfaceTable_row_prep(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx); + + + +#ifdef __cplusplus +} +#endif +#endif /* IPV6INTERFACETABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c new file mode 100644 index 0000000..cbd533c --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c @@ -0,0 +1,1406 @@ +/* + * 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 "ipv6InterfaceTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipv6InterfaceTable_interface.h" + +#include "if-mib/ifTable/ifTable.h" + +#include <ctype.h> + +netsnmp_feature_require(row_merge) +netsnmp_feature_require(baby_steps) +netsnmp_feature_require(check_all_requests_error) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6InterfaceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6InterfaceTable is subid 30 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.30, length: 8 + */ +typedef struct ipv6InterfaceTable_interface_ctx_s { + + netsnmp_container *container; + + ipv6InterfaceTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + + u_long last_changed; + +} ipv6InterfaceTable_interface_ctx; + +static ipv6InterfaceTable_interface_ctx ipv6InterfaceTable_if_ctx; + +static void + _ipv6InterfaceTable_container_init(ipv6InterfaceTable_interface_ctx * + if_ctx); +static void + _ipv6InterfaceTable_container_shutdown(ipv6InterfaceTable_interface_ctx * + if_ctx); + + +netsnmp_container * +ipv6InterfaceTable_container_get(void) +{ + return ipv6InterfaceTable_if_ctx.container; +} + +ipv6InterfaceTable_registration * +ipv6InterfaceTable_registration_get(void) +{ + return ipv6InterfaceTable_if_ctx.user_ctx; +} + +ipv6InterfaceTable_registration * +ipv6InterfaceTable_registration_set(ipv6InterfaceTable_registration * + newreg) +{ + ipv6InterfaceTable_registration *old = + ipv6InterfaceTable_if_ctx.user_ctx; + ipv6InterfaceTable_if_ctx.user_ctx = newreg; + return old; +} + +int +ipv6InterfaceTable_container_size(void) +{ + return CONTAINER_SIZE(ipv6InterfaceTable_if_ctx.container); +} + +u_int +ipv6InterfaceTable_dirty_get(void) +{ + return ifTable_dirty_get(); +} + +void +ipv6InterfaceTable_dirty_set(u_int status) +{ + ifTable_dirty_set(status); +} + +/* + * ipv6InterfaceTableLastChanged, which is the last time that a row in + * the table was changed or the last time a row was added/deleted from the + * table. + */ +void +ipv6InterfaceTable_lastChange_set(u_long table_changed) +{ + DEBUGMSGTL(("ipv6InterfaceTable:lastChanged_set", + "called. was %ld, now %ld\n", + ipv6InterfaceTable_if_ctx.last_changed, table_changed)); + ipv6InterfaceTable_if_ctx.last_changed = table_changed; +} + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_post_request; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_get_values; +#ifndef NETSNMP_DISABLE_SET_SUPPORT +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_check_objects; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_setup; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_set_values; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_values; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_commit; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_commit; +static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_irreversible_commit; + +NETSNMP_STATIC_INLINE int + _ipv6InterfaceTable_undo_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * + var, int column); +#endif + +/** + * @internal + * Initialize the table ipv6InterfaceTable + * (Define its contents and how it's structured) + */ +void +_ipv6InterfaceTable_initialize_interface(ipv6InterfaceTable_registration * + reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipv6InterfaceTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipv6InterfaceTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipv6InterfaceTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipv6InterfaceIfIndex */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPV6INTERFACETABLE_MIN_COL; + tbl_info->max_column = IPV6INTERFACETABLE_MAX_COL; + + /* + * save users context + */ + ipv6InterfaceTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipv6InterfaceTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipv6InterfaceTable_container_init(&ipv6InterfaceTable_if_ctx); + if (NULL == ipv6InterfaceTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipv6InterfaceTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipv6InterfaceTable_object_lookup; + access_multiplexer->get_values = _mfd_ipv6InterfaceTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_ipv6InterfaceTable_pre_request; + access_multiplexer->post_request = + _mfd_ipv6InterfaceTable_post_request; + + +#ifndef NETSNMP_DISABLE_SET_SUPPORT + /* + * REQUIRED wrappers for set request handling + */ + access_multiplexer->object_syntax_checks = + _mfd_ipv6InterfaceTable_check_objects; + access_multiplexer->undo_setup = _mfd_ipv6InterfaceTable_undo_setup; + access_multiplexer->undo_cleanup = + _mfd_ipv6InterfaceTable_undo_cleanup; + access_multiplexer->set_values = _mfd_ipv6InterfaceTable_set_values; + access_multiplexer->undo_sets = _mfd_ipv6InterfaceTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_ipv6InterfaceTable_commit; + access_multiplexer->undo_commit = _mfd_ipv6InterfaceTable_undo_commit; + access_multiplexer->irreversible_commit = + _mfd_ipv6InterfaceTable_irreversible_commit; +#endif + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipv6InterfaceTable:init_ipv6InterfaceTable", + "Registering ipv6InterfaceTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipv6InterfaceTable", handler, + ipv6InterfaceTable_oid, + ipv6InterfaceTable_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 ipv6InterfaceTable\n"); + return; + } + reginfo->my_reg_void = &ipv6InterfaceTable_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; + +#ifndef 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 + + 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, + ipv6InterfaceTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + + /* + * register LastChanged + */ + { + oid lc_oid[] = { IPV6INTERFACETABLELASTCHANGE_OID }; + netsnmp_register_watched_scalar2(netsnmp_create_handler_registration + ("ipv6TableLastChanged", NULL, + lc_oid, OID_LENGTH(lc_oid), + HANDLER_CAN_RONLY), + netsnmp_create_watcher_info((void + *) + &ipv6InterfaceTable_if_ctx. + last_changed, + sizeof + (u_long), + ASN_TIMETICKS, + WATCHER_FIXED_SIZE)); + } +} /* _ipv6InterfaceTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipv6InterfaceTable + */ +void +_ipv6InterfaceTable_shutdown_interface(ipv6InterfaceTable_registration * + reg_ptr) +{ + /* + * shutdown the container + */ + _ipv6InterfaceTable_container_shutdown(&ipv6InterfaceTable_if_ctx); +} + +void +ipv6InterfaceTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipv6InterfaceTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipv6InterfaceTable_valid_columns_set */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv6InterfaceTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipv6InterfaceTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipv6InterfaceTable_pre_request(ipv6InterfaceTable_if_ctx. + user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6InterfaceTable", "error %d from " + "ipv6InterfaceTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv6InterfaceTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_post_request", "called\n")); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipv6InterfaceTable", + "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) && ipv6InterfaceTable_dirty_get()) { + /* + * we shouldn't get here. the undo steps should also clear + * the dirty flags. + */ + snmp_log(LOG_WARNING, + "ipv6InterfaceTable dirty flag set in post_request " + "but status != SUCCESS.\n"); + } + + rc = ipv6InterfaceTable_post_request(ipv6InterfaceTable_if_ctx. + user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6InterfaceTable", "error %d from " + "ipv6InterfaceTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv6InterfaceTable_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; + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipv6InterfaceTable_interface_ctx *if_ctx = + * (ipv6InterfaceTable_interface_ctx *)reginfo->my_reg_void; + */ + + if (NULL == rowreq_ctx) { + rc = SNMP_ERR_NOCREATION; + } + + if (MFD_SUCCESS != rc) + netsnmp_request_set_error_all(requests, rc); + else + ipv6InterfaceTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipv6InterfaceTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv6InterfaceTable_get_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv6InterfaceReasmMaxSize(2)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/R/d/h + */ + case COLUMN_IPV6INTERFACEREASMMAXSIZE: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6InterfaceReasmMaxSize_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6InterfaceIdentifier(3)/Ipv6AddressIfIdentifierTC/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + case COLUMN_IPV6INTERFACEIDENTIFIER: + var->type = ASN_OCTET_STR; + rc = ipv6InterfaceIdentifier_get(rowreq_ctx, + (char **) &var->val.string, + &var->val_len); + break; + + /* + * ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEENABLESTATUS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipv6InterfaceEnableStatus_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6InterfaceReachableTime(6)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPV6INTERFACEREACHABLETIME: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6InterfaceReachableTime_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6InterfaceRetransmitTime(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPV6INTERFACERETRANSMITTIME: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6InterfaceRetransmitTime_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEFORWARDING: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; + rc = ipv6InterfaceForwarding_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + if (COLUMN_IPV6INTERFACEREASMMAXSIZE <= column && column <= COLUMN_IPV6INTERFACEFORWARDING) { + DEBUGMSGTL(("internal:${context}:_ipv6InterfaceTable_get_column", + "assume column %d is reserved\n", column)); + rc = MFD_SKIP; + } else { + snmp_log(LOG_ERR, + "unknown column %d in _ipv6InterfaceTable_get_column\n", + column); + } + break; + } + + return rc; +} /* _ipv6InterfaceTable_get_column */ + +int +_mfd_ipv6InterfaceTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_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 = _ipv6InterfaceTable_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_ipv6InterfaceTable_get_values */ + + +#ifndef NETSNMP_DISABLE_SET_SUPPORT +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/*---------------------------------------------------------------------- + * + * SET: Syntax checks + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check the syntax for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv6InterfaceTable_check_column(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_check_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + /* + * (INDEX) ipv6InterfaceIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + case COLUMN_IPV6INTERFACEIFINDEX: + rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ + break; + + /* + * ipv6InterfaceReasmMaxSize(2)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/R/d/h + */ + case COLUMN_IPV6INTERFACEREASMMAXSIZE: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipv6InterfaceIdentifier(3)/Ipv6AddressIfIdentifierTC/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + case COLUMN_IPV6INTERFACEIDENTIFIER: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEENABLESTATUS: + rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, + sizeof(rowreq_ctx->data. + ipv6InterfaceEnableStatus)); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != IPV6INTERFACEENABLESTATUS_UP) + && (*var->val.integer != IPV6INTERFACEENABLESTATUS_DOWN) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipv6InterfaceTable:_ipv6InterfaceTable_check_column:ipv6InterfaceEnableStatus", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipv6InterfaceEnableStatus_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 ipv6InterfaceEnableStatus_check_value\n", + rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + /* + * ipv6InterfaceReachableTime(6)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPV6INTERFACEREACHABLETIME: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipv6InterfaceRetransmitTime(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h + */ + case COLUMN_IPV6INTERFACERETRANSMITTIME: + rc = SNMP_ERR_NOTWRITABLE; + break; + + /* + * ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEFORWARDING: + rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, + sizeof(rowreq_ctx->data. + ipv6InterfaceForwarding)); + /* + * check that the value is one of defined enums + */ + if ((SNMPERR_SUCCESS == rc) + && (*var->val.integer != IPV6INTERFACEFORWARDING_FORWARDING) + && (*var->val.integer != IPV6INTERFACEFORWARDING_NOTFORWARDING) + ) { + rc = SNMP_ERR_WRONGVALUE; + } + if (SNMPERR_SUCCESS != rc) { + DEBUGMSGTL(("ipv6InterfaceTable:_ipv6InterfaceTable_check_column:ipv6InterfaceForwarding", "varbind validation failed (eg bad type or size)\n")); + } else { + rc = ipv6InterfaceForwarding_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 ipv6InterfaceForwarding_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 _ipv6InterfaceTable_check_column\n", + column); + } + + return rc; +} /* _ipv6InterfaceTable_check_column */ + +int +_mfd_ipv6InterfaceTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_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 = _ipv6InterfaceTable_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_ipv6InterfaceTable_check_objects */ + + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv6InterfaceTable_undo_setup_column(ipv6InterfaceTable_rowreq_ctx * + rowreq_ctx, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_undo_setup_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEENABLESTATUS: + rowreq_ctx->column_set_flags |= + COLUMN_IPV6INTERFACEENABLESTATUS_FLAG; + rc = ipv6InterfaceEnableStatus_undo_setup(rowreq_ctx); + break; + + /* + * ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEFORWARDING: + rowreq_ctx->column_set_flags |= + COLUMN_IPV6INTERFACEFORWARDING_FLAG; + rc = ipv6InterfaceForwarding_undo_setup(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv6InterfaceTable_undo_setup_column\n", + column); + break; + } + + return rc; +} /* _ipv6InterfaceTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_ipv6InterfaceTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_setup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rc = _mfd_ifTable_undo_setup_allocate(rowreq_ctx); + if (MFD_SUCCESS != rc) { + netsnmp_request_set_error_all(requests,rc); + return SNMP_ERR_NOERROR; + } + + /* + * row undo setup + */ + rc = ipv6InterfaceTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_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 = _ipv6InterfaceTable_undo_setup_column(rowreq_ctx, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_undo_setup_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_ipv6InterfaceTable_undo_cleanup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_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 = ipv6InterfaceTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + _mfd_ifTable_undo_setup_release(rowreq_ctx); + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv6InterfaceTable_set_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_set_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEENABLESTATUS: + rowreq_ctx->column_set_flags |= + COLUMN_IPV6INTERFACEENABLESTATUS_FLAG; + rc = ipv6InterfaceEnableStatus_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + /* + * ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEFORWARDING: + rowreq_ctx->column_set_flags |= + COLUMN_IPV6INTERFACEFORWARDING_FLAG; + rc = ipv6InterfaceForwarding_set(rowreq_ctx, + *((u_long *) var->val.string)); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv6InterfaceTable_set_column\n", + column); + rc = SNMP_ERR_GENERR; + break; + } + + return rc; +} /* _ipv6InterfaceTable_set_column */ + +int +_mfd_ipv6InterfaceTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_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 = _ipv6InterfaceTable_set_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, + SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_ipv6InterfaceTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipv6InterfaceTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_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... + */ + ipv6InterfaceTable_dirty_set(ipv6InterfaceTable_dirty_get() + 1); /* set table dirty flag */ + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_ipv6InterfaceTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_commit", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + u_int d = ipv6InterfaceTable_dirty_get(); + + netsnmp_assert(d != 0); + if (d) + ipv6InterfaceTable_dirty_set(d - 1); + } + + rc = ipv6InterfaceTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_undo_commit\n", rc)); + } + + if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { + snmp_log(LOG_WARNING, + "ipv6InterfaceTable row dirty flag still set after undo_commit\n"); + rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +/** + * @internal + * undo the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv6InterfaceTable_undo_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, + netsnmp_variable_list * var, int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_undo_column", "called for %d\n", column)); + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEENABLESTATUS: + rc = ipv6InterfaceEnableStatus_undo(rowreq_ctx); + break; + + /* + * ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h + */ + case COLUMN_IPV6INTERFACEFORWARDING: + rc = ipv6InterfaceForwarding_undo(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR, + "unknown column %d in _ipv6InterfaceTable_undo_column\n", + column); + break; + } + + return rc; +} /* _ipv6InterfaceTable_undo_column */ + +int +_mfd_ipv6InterfaceTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_values", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = ipv6InterfaceTable_undo(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_undo\n", rc)); + } + + for (; requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if (NULL == tri) + continue; + + rc = _ipv6InterfaceTable_undo_column(rowreq_ctx, + requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " + "ipv6InterfaceTable_undo_column\n", rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_undo_values */ + +/*---------------------------------------------------------------------- + * + * SET: irreversible commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit irreversible actions + */ +int +_mfd_ipv6InterfaceTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration + *reginfo, netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_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) { + CONTAINER_REMOVE(ipv6InterfaceTable_if_ctx.container, rowreq_ctx); + } else { + if (rowreq_ctx->column_set_flags) { + rowreq_ctx->column_set_flags = 0; + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6InterfaceTable_irreversible_commit */ +#endif + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static void +_container_free(netsnmp_container *container) +{ + DEBUGMSGTL(("internal:ipv6InterfaceTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipv6InterfaceTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipv6InterfaceTable_container_free(container); +} /* _container_free */ + +/** + * @internal + * initialize the container with functions or wrappers + */ +void +_ipv6InterfaceTable_container_init(ipv6InterfaceTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_container_init", "called\n")); + + /* + * container init + */ + ipv6InterfaceTable_container_init(&if_ctx->container); + if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipv6InterfaceTable:table_container"); + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipv6InterfaceTable_container_init\n"); + return; + } + if_ctx->container->container_name = strdup("ipv6InterfaceTable"); +} /* _ipv6InterfaceTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipv6InterfaceTable_container_shutdown(ipv6InterfaceTable_interface_ctx * + if_ctx) +{ + DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_container_shutdown", "called\n")); + + ipv6InterfaceTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipv6InterfaceTable_container_shutdown */ + + +ipv6InterfaceTable_rowreq_ctx * +ipv6InterfaceTable_row_find_by_mib_index(ipv6InterfaceTable_mib_index * + mib_idx) +{ + ipv6InterfaceTable_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 = ifTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = + CONTAINER_FIND(ipv6InterfaceTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} diff --git a/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.h b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.h new file mode 100644 index 0000000..4cb8ff5 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.h @@ -0,0 +1,178 @@ +/* + * 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 IPV6INTERFACETABLE_INTERFACE_H +#define IPV6INTERFACETABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipv6InterfaceTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + + + + + + + + + + + + + + + + _ipv6InterfaceTable_initialize_interface + (ipv6InterfaceTable_registration * user_ctx, u_long flags); + void + + + + + + + + + + + + + + + + _ipv6InterfaceTable_shutdown_interface + (ipv6InterfaceTable_registration * user_ctx); + + + + + + + + ipv6InterfaceTable_registration + * ipv6InterfaceTable_registration_get(void); + + + + + + + + ipv6InterfaceTable_registration + * ipv6InterfaceTable_registration_set + (ipv6InterfaceTable_registration * newreg); + + netsnmp_container *ipv6InterfaceTable_container_get(void); + int ipv6InterfaceTable_container_size(void); + + u_int ipv6InterfaceTable_dirty_get(void); + void ipv6InterfaceTable_dirty_set(u_int status); + + + + + + + + ipv6InterfaceTable_rowreq_ctx + * ipv6InterfaceTable_allocate_rowreq_ctx(void *); + void + + + + + + + + + + + + + + + + ipv6InterfaceTable_release_rowreq_ctx(ipv6InterfaceTable_rowreq_ctx + * rowreq_ctx); + + int ipv6InterfaceTable_index_to_oid(netsnmp_index * + oid_idx, + ipv6InterfaceTable_mib_index + * mib_idx); + int ipv6InterfaceTable_index_from_oid(netsnmp_index * + oid_idx, + ipv6InterfaceTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + + + + + + + + + + + ipv6InterfaceTable_valid_columns_set(netsnmp_column_info *vc); + + /* + */ + void ipv6InterfaceTable_lastChange_set(u_long uptime); + +#ifdef __cplusplus +} +#endif +#endif /* IPV6INTERFACETABLE_INTERFACE_H */ +/** @} */ + diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable.h b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable.h new file mode 100644 index 0000000..779bd75 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable.h @@ -0,0 +1,5 @@ +/* + * module to include the modules + */ + +config_require(ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable) diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable.c b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable.c new file mode 100644 index 0000000..f794093 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable.c @@ -0,0 +1,1009 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:ipv6ScopeZoneIndexTable.c 14170 2007-04-29 00:12:32Z varun_c$ + */ +/** \page MFD helper for ipv6ScopeZoneIndexTable + * + * \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 "ipv6ScopeZoneIndexTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "ipv6ScopeZoneIndexTable_interface.h" + +const oid ipv6ScopeZoneIndexTable_oid[] = + { IPV6SCOPEZONEINDEXTABLE_OID }; +const int ipv6ScopeZoneIndexTable_oid_size = +OID_LENGTH(ipv6ScopeZoneIndexTable_oid); + +ipv6ScopeZoneIndexTable_registration ipv6ScopeZoneIndexTable_user_context; +static ipv6ScopeZoneIndexTable_registration *ipv6ScopeZoneIndexTable_user_context_p; + +void initialize_table_ipv6ScopeZoneIndexTable(void); +void shutdown_table_ipv6ScopeZoneIndexTable(void); + + +/** + * Initializes the ipv6ScopeZoneIndexTable module + */ +void +init_ipv6ScopeZoneIndexTable(void) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:init_ipv6ScopeZoneIndexTable", "called\n")); + + /* + * TODO:300:o: Perform ipv6ScopeZoneIndexTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("ipv6ScopeZoneIndexTable")) + initialize_table_ipv6ScopeZoneIndexTable(); + +} /* init_ipv6ScopeZoneIndexTable */ + +/** + * Shut-down the ipv6ScopeZoneIndexTable module (agent is exiting) + */ +void +shutdown_ipv6ScopeZoneIndexTable(void) +{ + if (should_init("ipv6ScopeZoneIndexTable")) + shutdown_table_ipv6ScopeZoneIndexTable(); + +} + +/** + * Initialize the table ipv6ScopeZoneIndexTable + * (Define its contents and how it's structured) + */ +void +initialize_table_ipv6ScopeZoneIndexTable(void) +{ + u_long flags; + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:initialize_table_ipv6ScopeZoneIndexTable", "called\n")); + + /* + * TODO:301:o: Perform ipv6ScopeZoneIndexTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize ipv6ScopeZoneIndexTable 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. + */ + ipv6ScopeZoneIndexTable_user_context_p = + netsnmp_create_data_list("ipv6ScopeZoneIndexTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _ipv6ScopeZoneIndexTable_initialize_interface + (ipv6ScopeZoneIndexTable_user_context_p, flags); +} /* initialize_table_ipv6ScopeZoneIndexTable */ + +/** + * Shutdown the table ipv6ScopeZoneIndexTable + */ +void +shutdown_table_ipv6ScopeZoneIndexTable(void) +{ + /* + * call interface shutdown code + */ + _ipv6ScopeZoneIndexTable_shutdown_interface + (ipv6ScopeZoneIndexTable_user_context_p); + netsnmp_free_all_list_data(ipv6ScopeZoneIndexTable_user_context_p); + ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_rowreq_ctx_init(ipv6ScopeZoneIndexTable_rowreq_ctx + * rowreq_ctx, void *user_init_ctx) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_rowreq_ctx_init", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:210:o: |-> Perform extra ipv6ScopeZoneIndexTable rowreq initialization. (eg DEFVALS) + */ + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_rowreq_ctx_init */ + +/** + * extra context cleanup + * + */ +void +ipv6ScopeZoneIndexTable_rowreq_ctx_cleanup + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_rowreq_ctx_cleanup", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:211:o: |-> Perform extra ipv6ScopeZoneIndexTable rowreq cleanup. + */ + netsnmp_access_scopezone_entry_free(rowreq_ctx->data); + rowreq_ctx->data = NULL; +} /* ipv6ScopeZoneIndexTable_rowreq_ctx_cleanup */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +ipv6ScopeZoneIndexTable_pre_request(ipv6ScopeZoneIndexTable_registration * + user_context) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_pre_request", "called\n")); + + /* + * TODO:510:o: Perform ipv6ScopeZoneIndexTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_post_request(ipv6ScopeZoneIndexTable_registration * + user_context, int rc) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_post_request", "called\n")); + + /* + * TODO:511:o: Perform ipv6ScopeZoneIndexTable post-request actions. + */ + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_post_request */ + +/* + * ipv6ScopeZoneIndexTable_allocate_data + * + * Purpose: create new ipv6ScopeZoneIndexTable_data. + */ +ipv6ScopeZoneIndexTable_data * +ipv6ScopeZoneIndexTable_allocate_data(void) +{ + /* + * TODO:201:r: |-> allocate memory for the ipv6ScopeZoneIndexTable data context. + */ + ipv6ScopeZoneIndexTable_data *rtn = netsnmp_access_scopezone_entry_create(); + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_allocate_data", "called\n")); + + if (NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "ipv6ScopeZoneIndexTable_data.\n"); + } + + return rtn; +} /* ipv6ScopeZoneIndexTable_allocate_data */ + +/* + * ipv6ScopeZoneIndexTable_release_data + * + * Purpose: release ipv6ScopeZoneIndexTable data. + */ +void +ipv6ScopeZoneIndexTable_release_data(ipv6ScopeZoneIndexTable_data * data) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_release_data", "called\n")); + + /* + * TODO:202:r: |-> release memory for the ipv6ScopeZoneIndexTable data context. + */ + netsnmp_access_scopezone_entry_free(data); +} /* ipv6ScopeZoneIndexTable_release_data */ + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement ipv6ScopeZoneIndexTable get routines. + * TODO:240:M: Implement ipv6ScopeZoneIndexTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6ScopeZoneIndexTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.36, length: 8 + */ + +/* + * --------------------------------------------------------------------- + * * TODO:200:r: Implement ipv6ScopeZoneIndexTable data context functions. + */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * @param ipv6ScopeZoneIndexIfIndex_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 +ipv6ScopeZoneIndexTable_indexes_set_tbl_idx + (ipv6ScopeZoneIndexTable_mib_index * tbl_idx, + long ipv6ScopeZoneIndexIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_indexes_set_tbl_idx", "called\n")); + + /* + * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + tbl_idx->ipv6ScopeZoneIndexIfIndex = ipv6ScopeZoneIndexIfIndex_val; + + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_indexes_set(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + long ipv6ScopeZoneIndexIfIndex_val) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_indexes_set", "called\n")); + + if (MFD_SUCCESS != + ipv6ScopeZoneIndexTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, + ipv6ScopeZoneIndexIfIndex_val)) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if (0 != ipv6ScopeZoneIndexTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexLinkLocal + * ipv6ScopeZoneIndexLinkLocal is subid 2 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.2 + * Description: +The zone index for the link-local scope on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexLinkLocal data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexLinkLocal_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 +ipv6ScopeZoneIndexLinkLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6ScopeZoneIndexLinkLocal_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexLinkLocal_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexLinkLocal_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexLinkLocal data. + * copy (* ipv6ScopeZoneIndexLinkLocal_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexLinkLocal_val_ptr) = + rowreq_ctx->data->scopezone_linklocal; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexLinkLocal_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndex3 + * ipv6ScopeZoneIndex3 is subid 3 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.3 + * Description: +The zone index for scope 3 on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndex3 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndex3_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 +ipv6ScopeZoneIndex3_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndex3_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndex3_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndex3_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndex3 data. + * copy (* ipv6ScopeZoneIndex3_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndex3_val_ptr) = 0; + + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndex3_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexAdminLocal + * ipv6ScopeZoneIndexAdminLocal is subid 4 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.4 + * Description: +The zone index for the admin-local scope on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexAdminLocal data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexAdminLocal_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 +ipv6ScopeZoneIndexAdminLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6ScopeZoneIndexAdminLocal_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexAdminLocal_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexAdminLocal_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexAdminLocal data. + * copy (* ipv6ScopeZoneIndexAdminLocal_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexAdminLocal_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexAdminLocal_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexSiteLocal + * ipv6ScopeZoneIndexSiteLocal is subid 5 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.5 + * Description: +The zone index for the site-local scope on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexSiteLocal data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexSiteLocal_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 +ipv6ScopeZoneIndexSiteLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * + ipv6ScopeZoneIndexSiteLocal_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexSiteLocal_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexSiteLocal_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexSiteLocal data. + * copy (* ipv6ScopeZoneIndexSiteLocal_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexSiteLocal_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexSiteLocal_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndex6 + * ipv6ScopeZoneIndex6 is subid 6 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.6 + * Description: +The zone index for scope 6 on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndex6 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndex6_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 +ipv6ScopeZoneIndex6_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndex6_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndex6_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndex6_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndex6 data. + * copy (* ipv6ScopeZoneIndex6_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndex6_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndex6_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndex7 + * ipv6ScopeZoneIndex7 is subid 7 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.7 + * Description: +The zone index for scope 7 on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndex7 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndex7_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 +ipv6ScopeZoneIndex7_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndex7_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndex7_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndex7_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndex7 data. + * copy (* ipv6ScopeZoneIndex7_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndex7_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndex7_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexOrganizationLocal + * ipv6ScopeZoneIndexOrganizationLocal is subid 8 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.8 + * Description: +The zone index for the organization-local scope on this + interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexOrganizationLocal data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexOrganizationLocal_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 +ipv6ScopeZoneIndexOrganizationLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipv6ScopeZoneIndexOrganizationLocal_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexOrganizationLocal_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexOrganizationLocal_get", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexOrganizationLocal data. + * copy (* ipv6ScopeZoneIndexOrganizationLocal_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexOrganizationLocal_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexOrganizationLocal_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndex9 + * ipv6ScopeZoneIndex9 is subid 9 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.9 + * Description: +The zone index for scope 9 on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndex9 data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndex9_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 +ipv6ScopeZoneIndex9_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndex9_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndex9_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndex9_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndex9 data. + * copy (* ipv6ScopeZoneIndex9_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndex9_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndex9_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexA + * ipv6ScopeZoneIndexA is subid 10 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.10 + * Description: +The zone index for scope A on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexA data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexA_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 +ipv6ScopeZoneIndexA_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndexA_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexA_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexA_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexA data. + * copy (* ipv6ScopeZoneIndexA_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexA_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexA_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexB + * ipv6ScopeZoneIndexB is subid 11 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.11 + * Description: +The zone index for scope B on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexB data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexB_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 +ipv6ScopeZoneIndexB_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndexB_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexB_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexB_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexB data. + * copy (* ipv6ScopeZoneIndexB_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexB_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexB_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexC + * ipv6ScopeZoneIndexC is subid 12 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.12 + * Description: +The zone index for scope C on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexC data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexC_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 +ipv6ScopeZoneIndexC_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndexC_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexC_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexC_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexC data. + * copy (* ipv6ScopeZoneIndexC_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexC_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexC_get */ + +/*--------------------------------------------------------------------- + * IP-MIB::ipv6ScopeZoneIndexEntry.ipv6ScopeZoneIndexD + * ipv6ScopeZoneIndexD is subid 13 of ipv6ScopeZoneIndexEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.4.36.1.13 + * Description: +The zone index for scope D on this interface. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 1 + * settable 0 + * hint: d + * + * + * Its syntax is InetZoneIndex (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 ipv6ScopeZoneIndexD data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param ipv6ScopeZoneIndexD_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 +ipv6ScopeZoneIndexD_get(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndexD_val_ptr) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert(NULL != ipv6ScopeZoneIndexD_val_ptr); + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexD_get", + "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:231:o: |-> Extract the current value of the ipv6ScopeZoneIndexD data. + * copy (* ipv6ScopeZoneIndexD_val_ptr ) from rowreq_ctx->data + */ + (*ipv6ScopeZoneIndexD_val_ptr) = 0; + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexD_get */ + + +/** @{ */ diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable.h b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable.h new file mode 100644 index 0000000..2974fee --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable.h @@ -0,0 +1,269 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:ipv6ScopeZoneIndexTable.h 14170 2007-04-29 00:12:32Z varun_c$ + */ +#ifndef IPV6SCOPEZONEINDEXTABLE_H +#define IPV6SCOPEZONEINDEXTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @addtogroup misc misc: Miscellaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> +#include <net-snmp/data_access/scopezone.h> + /* + * other required module components + */ + /* *INDENT-OFF* */ +config_require(ip-mib/data_access/ipv6scopezone) +config_require(ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface) +config_require(ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access) + /* *INDENT-ON* */ + + /* + * OID and column number definitions for ipv6ScopeZoneIndexTable + */ +#include "ipv6ScopeZoneIndexTable_oids.h" + + /* + * enum definions + */ +#include "ipv6ScopeZoneIndexTable_enums.h" + + /* + ********************************************************************* + * function declarations + */ + void init_ipv6ScopeZoneIndexTable(void); + void shutdown_ipv6ScopeZoneIndexTable(void); + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6ScopeZoneIndexTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.36, length: 8 + */ + /* + ********************************************************************* + * 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 ipv6ScopeZoneIndexTable registration context. + */ + typedef netsnmp_data_list ipv6ScopeZoneIndexTable_registration; +/**********************************************************************/ + /* + * TODO:110:r: |-> Review ipv6ScopeZoneTable data context structure. + * This structure is used to represent the data for ipv6ScopeZoneTable. + */ + typedef netsnmp_v6scopezone_entry ipv6ScopeZoneIndexTable_data; + + + /* + * TODO:120:r: |-> Review ipv6ScopeZoneIndexTable mib index. + * This structure is used to represent the index for ipv6ScopeZoneIndexTable. + */ + typedef struct ipv6ScopeZoneIndexTable_mib_index_s { + + /* + * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + long ipv6ScopeZoneIndexIfIndex; + + + } ipv6ScopeZoneIndexTable_mib_index; + + /* + * TODO:121:r: | |-> Review ipv6ScopeZoneIndexTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + */ +#define MAX_ipv6ScopeZoneIndexTable_IDX_LEN 1 + + /* + ********************************************************************* + * TODO:130:o: |-> Review ipv6ScopeZoneIndexTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * ipv6ScopeZoneIndexTable_rowreq_ctx pointer. + */ + typedef struct ipv6ScopeZoneIndexTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_ipv6ScopeZoneIndexTable_IDX_LEN]; + + ipv6ScopeZoneIndexTable_mib_index tbl_idx; + + ipv6ScopeZoneIndexTable_data *data; + + /* + * 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 ipv6ScopeZoneIndexTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *ipv6ScopeZoneIndexTable_data_list; + + } ipv6ScopeZoneIndexTable_rowreq_ctx; + + typedef struct ipv6ScopeZoneIndexTable_ref_rowreq_ctx_s { + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx; + } ipv6ScopeZoneIndexTable_ref_rowreq_ctx; + + /* + ********************************************************************* + * function prototypes + */ + int + ipv6ScopeZoneIndexTable_pre_request + (ipv6ScopeZoneIndexTable_registration * user_context); + int + ipv6ScopeZoneIndexTable_post_request + (ipv6ScopeZoneIndexTable_registration * user_context, int rc); + + int + ipv6ScopeZoneIndexTable_rowreq_ctx_init + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + void *user_init_ctx); + void + ipv6ScopeZoneIndexTable_rowreq_ctx_cleanup + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx); + + + ipv6ScopeZoneIndexTable_rowreq_ctx + *ipv6ScopeZoneIndexTable_row_find_by_mib_index + (ipv6ScopeZoneIndexTable_mib_index * mib_idx); + + ipv6ScopeZoneIndexTable_data * + ipv6ScopeZoneIndexTable_allocate_data(void); + + void + ipv6ScopeZoneIndexTable_release_data(ipv6ScopeZoneIndexTable_data * data); + + extern const oid ipv6ScopeZoneIndexTable_oid[]; + extern const int ipv6ScopeZoneIndexTable_oid_size; + + +#include "ipv6ScopeZoneIndexTable_interface.h" +#include "ipv6ScopeZoneIndexTable_data_access.h" +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6ScopeZoneIndexTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.36, length: 8 + */ + /* + * indexes + */ + + int + ipv6ScopeZoneIndexLinkLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipv6ScopeZoneIndexLinkLocal_val_ptr); + int + ipv6ScopeZoneIndex3_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndex3_val_ptr); + int + ipv6ScopeZoneIndexAdminLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipv6ScopeZoneIndexAdminLocal_val_ptr); + int + ipv6ScopeZoneIndexSiteLocal_get(ipv6ScopeZoneIndexTable_rowreq_ctx + * rowreq_ctx, + u_long * + ipv6ScopeZoneIndexSiteLocal_val_ptr); + int + ipv6ScopeZoneIndex6_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndex6_val_ptr); + int + ipv6ScopeZoneIndex7_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndex7_val_ptr); + int + ipv6ScopeZoneIndexOrganizationLocal_get + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + u_long * ipv6ScopeZoneIndexOrganizationLocal_val_ptr); + int + ipv6ScopeZoneIndex9_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndex9_val_ptr); + int + ipv6ScopeZoneIndexA_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndexA_val_ptr); + int + ipv6ScopeZoneIndexB_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndexB_val_ptr); + int + ipv6ScopeZoneIndexC_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndexC_val_ptr); + int + ipv6ScopeZoneIndexD_get(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + u_long * ipv6ScopeZoneIndexD_val_ptr); + + + int + ipv6ScopeZoneIndexTable_indexes_set_tbl_idx + (ipv6ScopeZoneIndexTable_mib_index * tbl_idx, + long ipv6ScopeZoneIndexIfIndex_val); + int + ipv6ScopeZoneIndexTable_indexes_set + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + long ipv6ScopeZoneIndexIfIndex_val); + + /* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif +#endif /* IPV6SCOPEZONEINDEXTABLE_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access.c b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access.c new file mode 100644 index 0000000..0025dd3 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access.c @@ -0,0 +1,304 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:ipv6ScopeZoneIndexTable_data_access.c 14170 2007-04-29 00:12:32Z varun_c$ + */ +/* + * 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 "ipv6ScopeZoneIndexTable.h" + + +#include "ipv6ScopeZoneIndexTable_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 ipv6ScopeZoneIndexTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.36, length: 8 + */ + +/** + * initialization for ipv6ScopeZoneIndexTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param ipv6ScopeZoneIndexTable_reg + * Pointer to ipv6ScopeZoneIndexTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +ipv6ScopeZoneIndexTable_init_data(ipv6ScopeZoneIndexTable_registration * + ipv6ScopeZoneIndexTable_reg) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_init_data", "called\n")); + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_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. + * + * 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. + * + * @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 +ipv6ScopeZoneIndexTable_container_init(netsnmp_container ** + container_ptr_ptr, + netsnmp_cache * cache) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_container_init", "called\n")); + + if (NULL == container_ptr_ptr) { + snmp_log(LOG_ERR, + "bad container param to ipv6ScopeZoneIndexTable_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 ipv6ScopeZoneIndexTable_container_init\n"); + return; + } + + /* + * TODO:345:A: Set up ipv6ScopeZoneIndexTable 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 = 60; /* seconds */ + + +} /* ipv6ScopeZoneIndexTable_container_init */ + +/** + * 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 ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_container_shutdown(netsnmp_container *container_ptr) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_container_shutdown", "called\n")); + + if (NULL == container_ptr) { + snmp_log(LOG_ERR, + "bad params to ipv6ScopeZoneIndexTable_container_shutdown\n"); + return; + } + +} /* ipv6ScopeZoneIndexTable_container_shutdown */ + +/** + * check entry for update + * + */ +static void +_snarf_zoneindex_entry(netsnmp_v6scopezone_entry *scopezone_entry, + netsnmp_container *container) +{ + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx; + + DEBUGTRACE; + netsnmp_assert(NULL != scopezone_entry); + netsnmp_assert(NULL != container); + rowreq_ctx = ipv6ScopeZoneIndexTable_allocate_rowreq_ctx(scopezone_entry,NULL); + if ((NULL != rowreq_ctx) && + (MFD_SUCCESS == ipv6ScopeZoneIndexTable_indexes_set + (rowreq_ctx, rowreq_ctx->data->index))) { + CONTAINER_INSERT(container, rowreq_ctx); + } else { + if (rowreq_ctx) { + snmp_log(LOG_ERR, "error setting index while loading " + "ipv6ScopeZoneIndexTable cache.\n"); + ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); + } else + netsnmp_access_scopezone_entry_free(scopezone_entry); + } + +} + +/** + * load initial data + * + * TODO:350:M: Implement ipv6ScopeZoneIndexTable data load + * + * @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 + * ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_container_load(netsnmp_container * container) +{ + + /* + * temporary storage for index values + */ + /* + * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_container *zoneindex = netsnmp_access_scopezone_container_load(NULL, 0); + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_container_load", "called\n")); + + if (NULL == zoneindex) { + DEBUGMSGTL(("ipv6ScopeZoneIndexTable:container_load", + "couldn't get scopezone iterator\n")); + return MFD_RESOURCE_UNAVAILABLE; + } + /* + * TODO:351:M: |-> Load/update data in the ipv6ScopeZoneIndexTable container. + * loop over your ipv6ScopeZoneIndexTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + + CONTAINER_FOR_EACH(zoneindex, + (netsnmp_container_obj_func *) _snarf_zoneindex_entry, + container); + /* + * free the container. we've either claimed each entry, or released it, + * so the access function doesn't need to clear the container. + */ + netsnmp_access_scopezone_container_free(zoneindex, + 0x0001); + + DEBUGMSGT(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_container_load", "inserted %lu records\n", (unsigned long)CONTAINER_SIZE(container))); + + return MFD_SUCCESS; +} /* ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_container_free(netsnmp_container * container) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_container_free", "called\n")); + + /* + * TODO:380:M: Free ipv6ScopeZoneIndexTable container data. + */ +} /* ipv6ScopeZoneIndexTable_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 +ipv6ScopeZoneIndexTable_row_prep(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx) +{ + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_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; +} /* ipv6ScopeZoneIndexTable_row_prep */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access.h b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access.h new file mode 100644 index 0000000..8f98e91 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_data_access.h @@ -0,0 +1,70 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ + * + * $Id:ipv6ScopeZoneIndexTable_data_access.h 14170 2007-04-29 00:12:32Z varun_c$ + */ +#ifndef IPV6SCOPEZONEINDEXTABLE_DATA_ACCESS_H +#define IPV6SCOPEZONEINDEXTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + ********************************************************************* + * function declarations + */ + + /* + ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6ScopeZoneIndexTable + *** + ********************************************************************** + **********************************************************************/ + /* + * IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.36, length: 8 + */ + + + int + ipv6ScopeZoneIndexTable_init_data + (ipv6ScopeZoneIndexTable_registration * + ipv6ScopeZoneIndexTable_reg); + + + void + ipv6ScopeZoneIndexTable_container_init(netsnmp_container ** + container_ptr_ptr, + netsnmp_cache * + cache); + void + ipv6ScopeZoneIndexTable_container_shutdown(netsnmp_container * + container_ptr); + + int + ipv6ScopeZoneIndexTable_container_load(netsnmp_container * + container); + void + ipv6ScopeZoneIndexTable_container_free(netsnmp_container * + container); + +#define MAX_LINE_SIZE 256 + int + ipv6ScopeZoneIndexTable_row_prep(ipv6ScopeZoneIndexTable_rowreq_ctx + * rowreq_ctx); + + + +#ifdef __cplusplus +} +#endif +#endif /* IPV6SCOPEZONEINDEXTABLE_DATA_ACCESS_H */ diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_enums.h b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_enums.h new file mode 100644 index 0000000..a79ec88 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_enums.h @@ -0,0 +1,39 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c 12526 2005-07-15 22:41:16Z rstory $ + * + * $Id:ipv6ScopeZoneIndexTable_enums.h 14170 2007-04-29 00:12:32Z varun_c$ + */ +#ifndef IPV6SCOPEZONEINDEXTABLE_ENUMS_H +#define IPV6SCOPEZONEINDEXTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * 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 ipv6ScopeZoneIndexTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif +#endif /* IPV6SCOPEZONEINDEXTABLE_ENUMS_H */ diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface.c b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface.c new file mode 100644 index 0000000..ef2088b --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface.c @@ -0,0 +1,1154 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 15899 $ of $ + * + * $Id:ipv6ScopeZoneIndexTable_interface.c 14170 2007-04-29 00:12:32Z varun_c$ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** 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 "ipv6ScopeZoneIndexTable.h" + + +#include <net-snmp/agent/table_container.h> +#include <net-snmp/library/container.h> + +#include "ipv6ScopeZoneIndexTable_interface.h" + +#include <ctype.h> + +netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_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(ipv6ScopeZoneIndexTable_container_size, ipv6ScopeZoneIndexTable_external_access) +netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_registration_set, ipv6ScopeZoneIndexTable_external_access) +netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_registration_get, ipv6ScopeZoneIndexTable_external_access) +netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_container_get, ipv6ScopeZoneIndexTable_external_access) + +/********************************************************************** + ********************************************************************** + *** + *** Table ipv6ScopeZoneIndexTable + *** + ********************************************************************** + **********************************************************************/ +/* + * IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. + * Its status is Current. + * OID: .1.3.6.1.2.1.4.36, length: 8 + */ +typedef struct ipv6ScopeZoneIndexTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; + ipv6ScopeZoneIndexTable_registration *user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} ipv6ScopeZoneIndexTable_interface_ctx; + +static ipv6ScopeZoneIndexTable_interface_ctx + ipv6ScopeZoneIndexTable_if_ctx; + +static void +_ipv6ScopeZoneIndexTable_container_init +(ipv6ScopeZoneIndexTable_interface_ctx * if_ctx); +static void +_ipv6ScopeZoneIndexTable_container_shutdown +(ipv6ScopeZoneIndexTable_interface_ctx * if_ctx); +static int +_cache_load(netsnmp_cache * cache, void *vmagic); +static void +_cache_free(netsnmp_cache * cache, void *magic); + +#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_GET +netsnmp_container * +ipv6ScopeZoneIndexTable_container_get(void) +{ + return ipv6ScopeZoneIndexTable_if_ctx.container; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_GET +ipv6ScopeZoneIndexTable_registration * +ipv6ScopeZoneIndexTable_registration_get(void) +{ + return ipv6ScopeZoneIndexTable_if_ctx.user_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_GET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_SET +ipv6ScopeZoneIndexTable_registration * +ipv6ScopeZoneIndexTable_registration_set + (ipv6ScopeZoneIndexTable_registration * newreg) +{ + ipv6ScopeZoneIndexTable_registration *old = + ipv6ScopeZoneIndexTable_if_ctx.user_ctx; + ipv6ScopeZoneIndexTable_if_ctx.user_ctx = newreg; + return old; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_SET */ + +#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_SIZE +int +ipv6ScopeZoneIndexTable_container_size(void) +{ + return CONTAINER_SIZE(ipv6ScopeZoneIndexTable_if_ctx.container); +} +#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_SIZE */ + +/* + * mfd multiplexer modes + */ +static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_pre_request; +static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_post_request; +static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_object_lookup; +static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_get_values; +/** + * @internal + * Initialize the table ipv6ScopeZoneIndexTable + * (Define its contents and how it's structured) + */ +void +_ipv6ScopeZoneIndexTable_initialize_interface + (ipv6ScopeZoneIndexTable_registration * reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &ipv6ScopeZoneIndexTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = + &ipv6ScopeZoneIndexTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_ipv6ScopeZoneIndexTable_initialize_interface", "called\n")); + + + /************************************************* + * + * save interface context for ipv6ScopeZoneIndexTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, + /** index: ipv6ScopeZoneIndexIfIndex */ + 0); + + /* + * Define the minimum and maximum accessible columns. This + * optimizes retrieval. + */ + tbl_info->min_column = IPV6SCOPEZONEINDEXTABLE_MIN_COL; + tbl_info->max_column = IPV6SCOPEZONEINDEXTABLE_MAX_COL; + + /* + * save users context + */ + ipv6ScopeZoneIndexTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + ipv6ScopeZoneIndexTable_init_data(reg_ptr); + + /* + * set up the container + */ + _ipv6ScopeZoneIndexTable_container_init + (&ipv6ScopeZoneIndexTable_if_ctx); + if (NULL == ipv6ScopeZoneIndexTable_if_ctx.container) { + snmp_log(LOG_ERR, + "could not initialize container for ipv6ScopeZoneIndexTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = + _mfd_ipv6ScopeZoneIndexTable_object_lookup; + access_multiplexer->get_values = + _mfd_ipv6ScopeZoneIndexTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = + _mfd_ipv6ScopeZoneIndexTable_pre_request; + access_multiplexer->post_request = + _mfd_ipv6ScopeZoneIndexTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("ipv6ScopeZoneIndexTable:init_ipv6ScopeZoneIndexTable", + "Registering ipv6ScopeZoneIndexTable as a mibs-for-dummies table.\n")); + handler = + netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = + netsnmp_handler_registration_create("ipv6ScopeZoneIndexTable", + handler, + ipv6ScopeZoneIndexTable_oid, + ipv6ScopeZoneIndexTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY); + if (NULL == reginfo) { + snmp_log(LOG_ERR, + "error registering table ipv6ScopeZoneIndexTable\n"); + return; + } + reginfo->my_reg_void = &ipv6ScopeZoneIndexTable_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; + +#ifndef NETSNMP_NO_WRITE_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 */ + + 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, + ipv6ScopeZoneIndexTable_if_ctx. + container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler(reginfo, handler); + + if (NULL != ipv6ScopeZoneIndexTable_if_ctx.cache) { + handler = + netsnmp_cache_handler_get(ipv6ScopeZoneIndexTable_if_ctx.cache); + netsnmp_inject_handler(reginfo, handler); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); + +} /* _ipv6ScopeZoneIndexTable_initialize_interface */ + +/** + * @internal + * Shutdown the table ipv6ScopeZoneIndexTable + */ +void +_ipv6ScopeZoneIndexTable_shutdown_interface + (ipv6ScopeZoneIndexTable_registration * reg_ptr) +{ + /* + * shutdown the container + */ + _ipv6ScopeZoneIndexTable_container_shutdown + (&ipv6ScopeZoneIndexTable_if_ctx); +} + +void +ipv6ScopeZoneIndexTable_valid_columns_set(netsnmp_column_info *vc) +{ + ipv6ScopeZoneIndexTable_if_ctx.tbl_info.valid_columns = vc; +} /* ipv6ScopeZoneIndexTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +ipv6ScopeZoneIndexTable_index_to_oid(netsnmp_index * oid_idx, + ipv6ScopeZoneIndexTable_mib_index * + mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipv6ScopeZoneIndexIfIndex; + + /* + * set up varbinds + */ + memset(&var_ipv6ScopeZoneIndexIfIndex, 0x00, + sizeof(var_ipv6ScopeZoneIndexIfIndex)); + var_ipv6ScopeZoneIndexIfIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipv6ScopeZoneIndexIfIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_index_to_oid", "called\n")); + + /* + * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + snmp_set_var_value(&var_ipv6ScopeZoneIndexIfIndex, + (u_char *) & mib_idx->ipv6ScopeZoneIndexIfIndex, + sizeof(mib_idx->ipv6ScopeZoneIndexIfIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_ipv6ScopeZoneIndexIfIndex); + 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_ipv6ScopeZoneIndexIfIndex); + + return err; +} /* ipv6ScopeZoneIndexTable_index_to_oid */ + +/** + * extract ipv6ScopeZoneIndexTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +ipv6ScopeZoneIndexTable_index_from_oid(netsnmp_index * oid_idx, + ipv6ScopeZoneIndexTable_mib_index * + mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H + */ + netsnmp_variable_list var_ipv6ScopeZoneIndexIfIndex; + + /* + * set up varbinds + */ + memset(&var_ipv6ScopeZoneIndexIfIndex, 0x00, + sizeof(var_ipv6ScopeZoneIndexIfIndex)); + var_ipv6ScopeZoneIndexIfIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_ipv6ScopeZoneIndexIfIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_index_from_oid", "called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes(oid_idx->oids, oid_idx->len, + &var_ipv6ScopeZoneIndexIfIndex); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->ipv6ScopeZoneIndexIfIndex = + *((long *) var_ipv6ScopeZoneIndexIfIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers(&var_ipv6ScopeZoneIndexIfIndex); + + return err; +} /* ipv6ScopeZoneIndexTable_index_from_oid */ + + +/* + ********************************************************************* + * @internal + * allocate resources for a ipv6ScopeZoneIndexTable_rowreq_ctx + */ +ipv6ScopeZoneIndexTable_rowreq_ctx * +ipv6ScopeZoneIndexTable_allocate_rowreq_ctx(ipv6ScopeZoneIndexTable_data *data, + void *user_init_ctx) +{ + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(ipv6ScopeZoneIndexTable_rowreq_ctx); + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_allocate_rowreq_ctx", "called\n")); + + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "Couldn't allocate memory for a " + "ipv6ScopeZoneIndexTable_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 = + ipv6ScopeZoneIndexTable_allocate_data())) { + SNMP_FREE(rowreq_ctx); + return NULL; + } + } + + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->ipv6ScopeZoneIndexTable_data_list = NULL; + + /* + * if we allocated data, call init routine + */ + if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { + if (SNMPERR_SUCCESS != + ipv6ScopeZoneIndexTable_rowreq_ctx_init(rowreq_ctx, + user_init_ctx)) { + ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); + rowreq_ctx = NULL; + } + } + + return rowreq_ctx; +} /* ipv6ScopeZoneIndexTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a ipv6ScopeZoneIndexTable_rowreq_ctx + */ +void +ipv6ScopeZoneIndexTable_release_rowreq_ctx + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx) +{ + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_release_rowreq_ctx", "called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + ipv6ScopeZoneIndexTable_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)) + ipv6ScopeZoneIndexTable_release_data(rowreq_ctx->data); + + + /* + * free index oid pointer + */ + if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* ipv6ScopeZoneIndexTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv6ScopeZoneIndexTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_pre_request", "called\n")); + + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable", + "skipping additional pre_request\n")); + return SNMP_ERR_NOERROR; + } + + rc = ipv6ScopeZoneIndexTable_pre_request + (ipv6ScopeZoneIndexTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6ScopeZoneIndexTable", "error %d from " + "ipv6ScopeZoneIndexTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6ScopeZoneIndexTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv6ScopeZoneIndexTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + int rc, packet_rc; + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_post_request", "called\n")); + + /* + * release row context, if deleted + */ + if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) + ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); + + /* + * wait for last call before calling user + */ + if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable", + "waiting for last post_request\n")); + return SNMP_ERR_NOERROR; + } + + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); + rc = ipv6ScopeZoneIndexTable_post_request + (ipv6ScopeZoneIndexTable_if_ctx.user_ctx, packet_rc); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("ipv6ScopeZoneIndexTable", "error %d from " + "ipv6ScopeZoneIndexTable_post_request\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_ipv6ScopeZoneIndexTable_post_request */ + +/** + * @internal + * wrapper + */ +static ipv6ScopeZoneIndexTable_rowreq_ctx * +_mfd_ipv6ScopeZoneIndexTable_rowreq_from_index(netsnmp_index * oid_idx, + int *rc_ptr) +{ + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx; + ipv6ScopeZoneIndexTable_mib_index mib_idx; + int rc; + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_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 = ipv6ScopeZoneIndexTable_index_from_oid(oid_idx, &mib_idx); + if (MFD_SUCCESS != *rc_ptr) { + DEBUGMSGT(("ipv6ScopeZoneIndexTable", "error parsing index\n")); + return NULL; + } + + /* + * allocate new context + */ + rowreq_ctx = ipv6ScopeZoneIndexTable_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)); + + + /* + * 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_ipv6ScopeZoneIndexTable_rowreq_from_index */ + +/** + * @internal + * wrapper + */ +static int +_mfd_ipv6ScopeZoneIndexTable_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; + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_object_lookup", "called\n")); + + /* + * get our context from mfd + * ipv6ScopeZoneIndexTable_interface_ctx *if_ctx = + * (ipv6ScopeZoneIndexTable_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_ipv6ScopeZoneIndexTable_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 + ipv6ScopeZoneIndexTable_row_prep(rowreq_ctx); + + return SNMP_VALIDATE_ERR(rc); +} /* _mfd_ipv6ScopeZoneIndexTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_ipv6ScopeZoneIndexTable_get_column(ipv6ScopeZoneIndexTable_rowreq_ctx * + rowreq_ctx, + netsnmp_variable_list * var, + int column) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_column", "called for %d\n", column)); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch (column) { + + /* + * ipv6ScopeZoneIndexLinkLocal(2)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXLINKLOCAL: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexLinkLocal_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndex3(3)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEX3: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndex3_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexAdminLocal(4)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXADMINLOCAL: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexAdminLocal_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexSiteLocal(5)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXSITELOCAL: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexSiteLocal_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndex6(6)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEX6: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndex6_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndex7(7)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEX7: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndex7_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexOrganizationLocal(8)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXORGANIZATIONLOCAL: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexOrganizationLocal_get(rowreq_ctx, + (u_long *) var->val. + string); + break; + + /* + * ipv6ScopeZoneIndex9(9)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEX9: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndex9_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexA(10)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXA: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexA_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexB(11)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXB: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexB_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexC(12)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXC: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexC_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + /* + * ipv6ScopeZoneIndexD(13)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H + */ + case COLUMN_IPV6SCOPEZONEINDEXD: + var->val_len = sizeof(u_long); + var->type = ASN_UNSIGNED; + rc = ipv6ScopeZoneIndexD_get(rowreq_ctx, + (u_long *) var->val.string); + break; + + default: + if (IPV6SCOPEZONEINDEXTABLE_MIN_COL <= column + && column <= IPV6SCOPEZONEINDEXTABLE_MAX_COL) { + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_column", "assume column %d is reserved\n", column)); + rc = MFD_SKIP; + } else { + snmp_log(LOG_ERR, + "unknown column %d in _ipv6ScopeZoneIndexTable_get_column\n", + column); + } + break; + } + + return rc; +} /* _ipv6ScopeZoneIndexTable_get_column */ + +int +_mfd_ipv6ScopeZoneIndexTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration + *reginfo, + netsnmp_agent_request_info + *agtreq_info, + netsnmp_request_info *requests) +{ + ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info *tri; + u_char *old_string; + void (*dataFreeHook) (void *); + int rc; + + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_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 = _ipv6ScopeZoneIndexTable_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_ipv6ScopeZoneIndexTable_get_values */ + + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * SET PROCESSING NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static void +_container_item_free(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx, + void *context) +{ + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_container_item_free", + "called\n")); + + if (NULL == rowreq_ctx) + return; + + ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); +} /* _container_item_free */ + +/** + * @internal + */ +static void +_container_free(netsnmp_container * container) +{ + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_container_free", + "called\n")); + + if (NULL == container) { + snmp_log(LOG_ERR, + "invalid container in ipv6ScopeZoneIndexTable_container_free\n"); + return; + } + + /* + * call user code + */ + ipv6ScopeZoneIndexTable_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 +_ipv6ScopeZoneIndexTable_container_init + (ipv6ScopeZoneIndexTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_ipv6ScopeZoneIndexTable_container_init", "called\n")); + + /* + * container init + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + ipv6ScopeZoneIndexTable_oid, + ipv6ScopeZoneIndexTable_oid_size); + + if (NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for ipScopeZoneIndexTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipv6ScopeZoneIndexTable_container_init(&if_ctx->container, if_ctx->cache); + if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find + ("ipv6ScopeZoneIndexTable:table_container"); + if (if_ctx->container) + if_ctx->container->container_name = + strdup("ipv6ScopeZoneIndexTable"); + } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipv6ScopeZoneIndexTable_container_init\n"); + return; + } + if (NULL != if_ctx->cache) + if_ctx->cache->magic = (void *) if_ctx->container; + + +} /* _ipv6ScopeZoneIndexTable_container_init */ + +/** + * @internal + * shutdown the container with functions or wrappers + */ +void +_ipv6ScopeZoneIndexTable_container_shutdown + (ipv6ScopeZoneIndexTable_interface_ctx * if_ctx) +{ + DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_ipv6ScopeZoneIndexTable_container_shutdown", "called\n")); + + ipv6ScopeZoneIndexTable_container_shutdown(if_ctx->container); + + _container_free(if_ctx->container); + +} /* _ipv6ScopeZoneIndexTable_container_shutdown */ + + +#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_EXTERNAL_ACCESS +ipv6ScopeZoneIndexTable_rowreq_ctx * +ipv6ScopeZoneIndexTable_row_find_by_mib_index + (ipv6ScopeZoneIndexTable_mib_index * mib_idx) +{ + ipv6ScopeZoneIndexTable_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 = ipv6ScopeZoneIndexTable_index_to_oid(&oid_idx, mib_idx); + if (MFD_SUCCESS != rc) + return NULL; + + rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) + CONTAINER_FIND(ipv6ScopeZoneIndexTable_if_ctx.container, &oid_idx); + + return rowreq_ctx; +} +#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_EXTERNAL_ACCESS */ + +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:ipScopeZoneIndexTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache for ipScopeZoneIndexTable_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 ipv6ScopeZoneIndexTable_container_load((netsnmp_container *) cache-> + magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:ipScopeZoneIndexTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, + "invalid cache in ipScopeZoneIndexTable_cache_free\n"); + return; + } + + container = (netsnmp_container *) cache->magic; + + _container_free(container); +} /* _cache_free */ + diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface.h b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface.h new file mode 100644 index 0000000..7fc3109 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_interface.h @@ -0,0 +1,98 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 15899 $ of $ + * + * $Id:ipv6ScopeZoneIndexTable_interface.h 14170 2007-04-29 00:12:32Z varun_c$ + */ +/** @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 IPV6SCOPEZONEINDEXTABLE_INTERFACE_H +#define IPV6SCOPEZONEINDEXTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "ipv6ScopeZoneIndexTable.h" + + + /* + ******************************************************************** + * Table declarations + */ + + /* + * PUBLIC interface initialization routine + */ + void + _ipv6ScopeZoneIndexTable_initialize_interface + (ipv6ScopeZoneIndexTable_registration * user_ctx, u_long flags); + void + _ipv6ScopeZoneIndexTable_shutdown_interface + (ipv6ScopeZoneIndexTable_registration * user_ctx); + + ipv6ScopeZoneIndexTable_registration + *ipv6ScopeZoneIndexTable_registration_get(void); + + ipv6ScopeZoneIndexTable_registration + *ipv6ScopeZoneIndexTable_registration_set + (ipv6ScopeZoneIndexTable_registration * newreg); + + netsnmp_container *ipv6ScopeZoneIndexTable_container_get(void); + int ipv6ScopeZoneIndexTable_container_size(void); + + ipv6ScopeZoneIndexTable_rowreq_ctx + *ipv6ScopeZoneIndexTable_allocate_rowreq_ctx(ipv6ScopeZoneIndexTable_data *, void *); + void + ipv6ScopeZoneIndexTable_release_rowreq_ctx + (ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx); + + int ipv6ScopeZoneIndexTable_index_to_oid(netsnmp_index * + oid_idx, + ipv6ScopeZoneIndexTable_mib_index + * mib_idx); + int ipv6ScopeZoneIndexTable_index_from_oid(netsnmp_index * + oid_idx, + ipv6ScopeZoneIndexTable_mib_index + * mib_idx); + + /* + * access to certain internals. use with caution! + */ + void + ipv6ScopeZoneIndexTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif +#endif /* IPV6SCOPEZONEINDEXTABLE_INTERFACE_H */ +/** @} */ diff --git a/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_oids.h b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_oids.h new file mode 100644 index 0000000..134daa2 --- /dev/null +++ b/agent/mibgroup/ip-mib/ipv6ScopeZoneIndexTable/ipv6ScopeZoneIndexTable_oids.h @@ -0,0 +1,55 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c 12855 2005-09-27 15:56:08Z rstory $ + * + * $Id:ipv6ScopeZoneIndexTable_oids.h 14170 2007-04-29 00:12:32Z varun_c$ + */ +#ifndef IPV6SCOPEZONEINDEXTABLE_OIDS_H +#define IPV6SCOPEZONEINDEXTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * column number definitions for table ipv6ScopeZoneIndexTable + */ +#define IPV6SCOPEZONEINDEXTABLE_OID 1,3,6,1,2,1,4,36 + +#define COLUMN_IPV6SCOPEZONEINDEXIFINDEX 1 + +#define COLUMN_IPV6SCOPEZONEINDEXLINKLOCAL 2 + +#define COLUMN_IPV6SCOPEZONEINDEX3 3 + +#define COLUMN_IPV6SCOPEZONEINDEXADMINLOCAL 4 + +#define COLUMN_IPV6SCOPEZONEINDEXSITELOCAL 5 + +#define COLUMN_IPV6SCOPEZONEINDEX6 6 + +#define COLUMN_IPV6SCOPEZONEINDEX7 7 + +#define COLUMN_IPV6SCOPEZONEINDEXORGANIZATIONLOCAL 8 + +#define COLUMN_IPV6SCOPEZONEINDEX9 9 + +#define COLUMN_IPV6SCOPEZONEINDEXA 10 + +#define COLUMN_IPV6SCOPEZONEINDEXB 11 + +#define COLUMN_IPV6SCOPEZONEINDEXC 12 + +#define COLUMN_IPV6SCOPEZONEINDEXD 13 + + +#define IPV6SCOPEZONEINDEXTABLE_MIN_COL COLUMN_IPV6SCOPEZONEINDEXLINKLOCAL +#define IPV6SCOPEZONEINDEXTABLE_MAX_COL COLUMN_IPV6SCOPEZONEINDEXD + + + +#ifdef __cplusplus +} +#endif +#endif /* IPV6SCOPEZONEINDEXTABLE_OIDS_H */ |