summaryrefslogtreecommitdiff
path: root/agent/mibgroup/tcp-mib
diff options
context:
space:
mode:
Diffstat (limited to 'agent/mibgroup/tcp-mib')
-rw-r--r--agent/mibgroup/tcp-mib/data_access/Makefile26
-rw-r--r--agent/mibgroup/tcp-mib/data_access/tcpConn.h28
-rw-r--r--agent/mibgroup/tcp-mib/data_access/tcpConn_common.c267
-rw-r--r--agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c395
-rw-r--r--agent/mibgroup/tcp-mib/data_access/tcpConn_private.h6
-rw-r--r--agent/mibgroup/tcp-mib/data_access/tcpConn_solaris2.c182
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnTable.h8
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable.h6
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.c1137
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.h620
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h138
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.c321
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.h105
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c1790
-rw-r--r--agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.h176
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable.h5
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.c445
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.h271
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_constants.h78
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.c320
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.h73
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c981
-rw-r--r--agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.h98
23 files changed, 7476 insertions, 0 deletions
diff --git a/agent/mibgroup/tcp-mib/data_access/Makefile b/agent/mibgroup/tcp-mib/data_access/Makefile
new file mode 100644
index 0000000..3067611
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/data_access/Makefile
@@ -0,0 +1,26 @@
+top_srcdir := ../../../..
+
+CC := gcc
+CFLAGS := -g -DNETSNMP_TCPCONN_TEST \
+ -I$(top_srcdir)/agent/mibgroup/ip-mib/data_access \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/agent/mibgroup
+
+OBJS = tcpConn_common.o tcpConn_linux.o
+
+NETSNMPDIR=$(top_srcdir)
+NETSNMPCONFIG=$(NETSNMPDIR)/net-snmp-config
+NETSNMPBASELIBS := $(shell $(NETSNMPCONFIG) --base-agent-libs)
+NETSNMPEXTLIBS := $(shell $(NETSNMPCONFIG) --external-agent-libs)
+NETSNMPLIBDIRS := $(shell $(NETSNMPCONFIG) --build-lib-dirs $(NETSNMPDIR))
+NETSNMPLIBDEPS := $(shell $(NETSNMPCONFIG) --build-lib-deps $(NETSNMPDIR))
+LIB_DEPS=$(NETSNMPLIBDEPS)
+LIBS=$(NETSNMPLIBDIRS) -Wl,-Bstatic $(NETSNMPBASELIBS) -Wl,-Bdynamic $(NETSNMPEXTLIBS)
+
+TARGET := tcpConn_test
+
+test: $(OBJS)
+ $(CC) $(CFLAGS) $(OBJS) -o $(TARGET) $(LIBS)
+
+clean:
+ rm $(OBJS) $(TARGET)
diff --git a/agent/mibgroup/tcp-mib/data_access/tcpConn.h b/agent/mibgroup/tcp-mib/data_access/tcpConn.h
new file mode 100644
index 0000000..43f5293
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/data_access/tcpConn.h
@@ -0,0 +1,28 @@
+/*
+ * tcpConn data access header
+ *
+ * $Id: tcpConn.h 15387 2006-10-10 21:13:36Z tanders $
+ */
+/**---------------------------------------------------------------------*/
+/*
+ * 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(tcp-mib/data_access/tcpConn_common)
+#if defined( linux )
+config_require(tcp-mib/data_access/tcpConn_linux)
+#elif defined( solaris2 )
+config_require(tcp-mib/data_access/tcpConn_solaris2)
+#else
+# define NETSNMP_TCPCONN_COMMON_ONLY
+#endif
+
diff --git a/agent/mibgroup/tcp-mib/data_access/tcpConn_common.c b/agent/mibgroup/tcp-mib/data_access/tcpConn_common.c
new file mode 100644
index 0000000..5d4e8c0
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/data_access/tcpConn_common.c
@@ -0,0 +1,267 @@
+/*
+ * TcpConn MIB architecture support
+ *
+ * $Id: tcpConn_common.c 16724 2007-10-14 22:10:09Z magfr $
+ */
+#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/tcpConn.h>
+
+#include "tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h"
+#include "tcp-mib/data_access/tcpConn_private.h"
+
+/**---------------------------------------------------------------------*/
+/*
+ * local static prototypes
+ */
+static void _access_tcpconn_entry_release(netsnmp_tcpconn_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_tcpconn_container_load(netsnmp_container* container,
+ u_int load_flags);
+extern int
+netsnmp_arch_tcpconn_entry_init(netsnmp_tcpconn_entry *entry);
+extern int
+netsnmp_arch_tcpconn_entry_copy(netsnmp_tcpconn_entry *lhs,
+ netsnmp_tcpconn_entry *rhs);
+extern void
+netsnmp_arch_tcpconn_entry_cleanup(netsnmp_tcpconn_entry *entry);
+
+
+
+/**---------------------------------------------------------------------*/
+/*
+ * container functions
+ */
+/**
+ */
+netsnmp_container *
+netsnmp_access_tcpconn_container_init(u_int flags)
+{
+ netsnmp_container *container1;
+
+ DEBUGMSGTL(("access:tcpconn:container", "init\n"));
+
+ /*
+ * create the container
+ */
+ container1 = netsnmp_container_find("access:tcpconn:table_container");
+ if (NULL == container1) {
+ snmp_log(LOG_ERR, "tcpconn primary container not found\n");
+ return NULL;
+ }
+ container1->container_name = strdup("tcpConnTable");
+
+ return container1;
+}
+
+/**
+ * @retval NULL error
+ * @retval !NULL pointer to container
+ */
+netsnmp_container*
+netsnmp_access_tcpconn_container_load(netsnmp_container* container, u_int load_flags)
+{
+ int rc;
+
+ DEBUGMSGTL(("access:tcpconn:container", "load\n"));
+
+ if (NULL == container)
+ container = netsnmp_access_tcpconn_container_init(load_flags);
+ if (NULL == container) {
+ snmp_log(LOG_ERR, "no container specified/found for access_tcpconn\n");
+ return NULL;
+ }
+
+ rc = netsnmp_arch_tcpconn_container_load(container, load_flags);
+ if (0 != rc) {
+ netsnmp_access_tcpconn_container_free(container,
+ NETSNMP_ACCESS_TCPCONN_FREE_NOFLAGS);
+ container = NULL;
+ }
+
+ return container;
+}
+
+void
+netsnmp_access_tcpconn_container_free(netsnmp_container *container, u_int free_flags)
+{
+ DEBUGMSGTL(("access:tcpconn:container", "free\n"));
+
+ if (NULL == container) {
+ snmp_log(LOG_ERR, "invalid container for netsnmp_access_tcpconn_free\n");
+ return;
+ }
+
+ if(! (free_flags & NETSNMP_ACCESS_TCPCONN_FREE_DONT_CLEAR)) {
+ /*
+ * free all items.
+ */
+ CONTAINER_CLEAR(container,
+ (netsnmp_container_obj_func*)_access_tcpconn_entry_release,
+ NULL);
+ }
+
+ if(! (free_flags & NETSNMP_ACCESS_TCPCONN_FREE_KEEP_CONTAINER))
+ CONTAINER_FREE(container);
+}
+
+/**---------------------------------------------------------------------*/
+/*
+ * tcpconn_entry functions
+ */
+/**
+ */
+/**
+ */
+netsnmp_tcpconn_entry *
+netsnmp_access_tcpconn_entry_create(void)
+{
+ netsnmp_tcpconn_entry *entry =
+ SNMP_MALLOC_TYPEDEF(netsnmp_tcpconn_entry);
+ int rc = 0;
+
+ DEBUGMSGTL(("verbose:access:tcpconn:entry", "create\n"));
+
+ entry->oid_index.len = 1;
+ entry->oid_index.oids = &entry->arbitrary_index;
+
+ /*
+ * init arch data
+ */
+ rc = netsnmp_arch_tcpconn_entry_init(entry);
+ if (SNMP_ERR_NOERROR != rc) {
+ DEBUGMSGT(("access:tcpconn:create","error %d in arch init\n", rc));
+ netsnmp_access_tcpconn_entry_free(entry);
+ }
+
+ return entry;
+}
+
+/**
+ */
+void
+netsnmp_access_tcpconn_entry_free(netsnmp_tcpconn_entry * entry)
+{
+ if (NULL == entry)
+ return;
+
+ DEBUGMSGTL(("verbose:access:tcpconn:entry", "free\n"));
+
+ if (NULL != entry->arch_data)
+ netsnmp_arch_tcpconn_entry_cleanup(entry);
+
+ free(entry);
+}
+
+/**
+ * update underlying data store (kernel) for entry
+ *
+ * @retval 0 : success
+ * @retval -1 : error
+ */
+int
+netsnmp_access_tcpconn_entry_set(netsnmp_tcpconn_entry * entry)
+{
+ int rc = SNMP_ERR_NOERROR;
+
+ if (NULL == entry) {
+ netsnmp_assert(NULL != entry);
+ return -1;
+ }
+
+ DEBUGMSGTL(("access:tcpconn:entry", "set\n"));
+
+
+ /*
+ * only option is delete
+ */
+ if (! (entry->flags & NETSNMP_ACCESS_TCPCONN_DELETE))
+ return -1;
+
+ rc = netsnmp_arch_tcpconn_delete(entry);
+
+ return rc;
+}
+
+/**
+ * update an old tcpconn_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 fileds updated
+ */
+int
+netsnmp_access_tcpconn_entry_update(netsnmp_tcpconn_entry *lhs,
+ netsnmp_tcpconn_entry *rhs)
+{
+ int rc, changed = 0;
+
+ DEBUGMSGTL(("access:tcpconn:entry", "update\n"));
+
+ if (lhs->tcpConnState != rhs->tcpConnState) {
+ ++changed;
+ lhs->tcpConnState = rhs->tcpConnState;
+ }
+
+ if (lhs->pid != rhs->pid) {
+ ++changed;
+ lhs->pid = rhs->pid;
+ }
+
+ /*
+ * copy arch stuff. we don't care if it changed
+ */
+ rc = netsnmp_arch_tcpconn_entry_copy(lhs,rhs);
+ if (0 != rc) {
+ snmp_log(LOG_ERR,"arch tcpconn copy failed\n");
+ return -1;
+ }
+
+ return changed;
+}
+
+/**---------------------------------------------------------------------*/
+/*
+ * Utility routines
+ */
+
+/**
+ */
+void
+_access_tcpconn_entry_release(netsnmp_tcpconn_entry * entry, void *context)
+{
+ netsnmp_access_tcpconn_entry_free(entry);
+}
+
+
+#ifdef NETSNMP_TCPCONN_TEST
+
+int
+main(int argc, char** argv)
+{
+ netsnmp_container *container;
+
+ netsnmp_config("debugTokens access:tcp,verbose:access:tcp,tcp,verbose:tcp");
+
+ netsnmp_container_init_list();
+
+ dodebug = 1;
+
+ container = netsnmp_access_tcpconn_container_load(NULL, 0);
+
+ netsnmp_access_tcpconn_container_free(container, 0);
+}
+#endif
diff --git a/agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c b/agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c
new file mode 100644
index 0000000..7ffebe6
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c
@@ -0,0 +1,395 @@
+/*
+ * tcpConnTable MIB architecture support
+ *
+ * $Id: tcpConn_linux.c 15654 2006-12-08 14:30:56Z rstory $
+ */
+#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/tcpConn.h>
+
+#include "tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h"
+#include "tcp-mib/data_access/tcpConn_private.h"
+
+static int
+linux_states[12] = { 1, 5, 3, 4, 6, 7, 11, 1, 8, 9, 2, 10 };
+
+static int _load4(netsnmp_container *container, u_int flags);
+#if defined (NETSNMP_ENABLE_IPV6)
+static int _load6(netsnmp_container *container, u_int flags);
+#endif
+
+/*
+ * initialize arch specific storage
+ *
+ * @retval 0: success
+ * @retval <0: error
+ */
+int
+netsnmp_arch_tcpconn_entry_init(netsnmp_tcpconn_entry *entry)
+{
+ /*
+ * init
+ */
+ return 0;
+}
+
+/*
+ * cleanup arch specific storage
+ */
+void
+netsnmp_arch_tcpconn_entry_cleanup(netsnmp_tcpconn_entry *entry)
+{
+ /*
+ * cleanup
+ */
+}
+
+/*
+ * copy arch specific storage
+ */
+int
+netsnmp_arch_tcpconn_entry_copy(netsnmp_tcpconn_entry *lhs,
+ netsnmp_tcpconn_entry *rhs)
+{
+ return 0;
+}
+
+/*
+ * delete an entry
+ */
+int
+netsnmp_arch_tcpconn_delete(netsnmp_tcpconn_entry *entry)
+{
+ if (NULL == entry)
+ return -1;
+ /** xxx-rks:9 tcpConn delete not implemented */
+ return -1;
+}
+
+
+/**
+ *
+ * @retval 0 no errors
+ * @retval !0 errors
+ */
+int
+netsnmp_arch_tcpconn_container_load(netsnmp_container *container,
+ u_int load_flags )
+{
+ int rc = 0;
+
+ DEBUGMSGTL(("access:tcpconn:container",
+ "tcpconn_container_arch_load (flags %p)\n", load_flags));
+
+ if (NULL == container) {
+ snmp_log(LOG_ERR, "no container specified/found for access_tcpconn\n");
+ return -1;
+ }
+
+ rc = _load4(container, load_flags);
+
+#if defined (NETSNMP_ENABLE_IPV6)
+ if((0 != rc) || (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_IPV4_ONLY))
+ return rc;
+
+ /*
+ * load ipv6. ipv6 module might not be loaded,
+ * so ignore -2 err (file not found)
+ */
+ rc = _load6(container, load_flags);
+ if (-2 == rc)
+ rc = 0;
+#endif
+
+ return rc;
+}
+
+/**
+ *
+ * @retval 0 no errors
+ * @retval !0 errors
+ */
+static int
+_load4(netsnmp_container *container, u_int load_flags)
+{
+ int rc = 0;
+ FILE *in;
+ char line[160];
+
+ netsnmp_assert(NULL != container);
+
+#define PROCFILE "/proc/net/tcp"
+ if (!(in = fopen(PROCFILE, "r"))) {
+ snmp_log(LOG_ERR,"could not open " PROCFILE "\n");
+ return -2;
+ }
+
+ fgets(line, sizeof(line), in); /* skip header */
+
+ /*
+ * sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
+ * 0: 00000000:8000 00000000:0000 0A 00000000:00000000 00:00000000 00000000 29 0 1028 1 df7b1b80 300 0 0 2 -1
+ */
+ while (fgets(line, sizeof(line), in)) {
+ netsnmp_tcpconn_entry *entry;
+ int state, rc, local_port, remote_port, tmp_state;
+ size_t buf_len, offset;
+ u_char local_addr[10], remote_addr[10];
+ u_char *tmp_ptr;
+
+ if (5 != (rc = sscanf(line, "%*d: %8[0-9A-Z]:%x %8[0-9A-Z]:%x %x",
+ local_addr, &local_port,
+ remote_addr, &remote_port, &tmp_state))) {
+ DEBUGMSGT(("access:tcpconn:container",
+ "error parsing line (%d != 5)\n", rc));
+ DEBUGMSGT(("access:tcpconn:container"," line '%s'\n", line));
+ continue;
+ }
+ DEBUGMSGT(("verbose:access:tcpconn:container"," line '%s'\n", line));
+
+ /*
+ * check if we care about listen state
+ */
+ state = (tmp_state & 0xf) < 12 ? linux_states[tmp_state & 0xf] : 2;
+ if (load_flags) {
+ if (TCPCONNECTIONSTATE_LISTEN == state) {
+ if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " skipping listen\n"));
+ continue;
+ }
+ }
+ else if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " skipping non-listen\n"));
+ continue;
+ }
+ }
+
+ /*
+ */
+ entry = netsnmp_access_tcpconn_entry_create();
+ if(NULL == entry) {
+ rc = -3;
+ break;
+ }
+
+ /** oddly enough, these appear to already be in network order */
+ entry->loc_port = (unsigned short) local_port;
+ entry->rmt_port = (unsigned short) remote_port;
+ entry->tcpConnState = state;
+
+ /** the addr string may need work */
+ buf_len = strlen(local_addr);
+ if ((8 != buf_len) ||
+ (-1 == netsnmp_addrstr_hton(local_addr, 8))) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " error processing local address\n"));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+ offset = 0;
+ tmp_ptr = entry->loc_addr;
+ rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
+ &offset, 0, local_addr, NULL);
+ entry->loc_addr_len = offset;
+ if ( 4 != entry->loc_addr_len ) {
+ DEBUGMSGT(("access:tcpconn:container",
+ "error parsing local addr (%d != 4)\n",
+ entry->loc_addr_len));
+ DEBUGMSGT(("access:tcpconn:container"," line '%s'\n", line));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+
+ /** the addr string may need work */
+ buf_len = strlen((char*)remote_addr);
+ if ((8 != buf_len) ||
+ (-1 == netsnmp_addrstr_hton(remote_addr, 8))) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " error processing remote address\n"));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+ offset = 0;
+ tmp_ptr = entry->rmt_addr;
+ rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
+ &offset, 0, remote_addr, NULL);
+ entry->rmt_addr_len = offset;
+ if ( 4 != entry->rmt_addr_len ) {
+ DEBUGMSGT(("access:tcpconn:container",
+ "error parsing remote addr (%d != 4)\n",
+ entry->rmt_addr_len));
+ DEBUGMSGT(("access:tcpconn:container"," line '%s'\n", line));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+
+ /*
+ * add entry to container
+ */
+ entry->arbitrary_index = CONTAINER_SIZE(container) + 1;
+ CONTAINER_INSERT(container, entry);
+ }
+
+ fclose(in);
+
+ if(rc<0)
+ return rc;
+
+ return 0;
+}
+
+#if defined (NETSNMP_ENABLE_IPV6)
+/**
+ *
+ * @retval 0 no errors
+ * @retval !0 errors
+ */
+static int
+_load6(netsnmp_container *container, u_int load_flags)
+{
+ int rc = 0;
+ FILE *in;
+ char line[180];
+ static int log_open_err = 1;
+
+ netsnmp_assert(NULL != container);
+
+#undef PROCFILE
+#define PROCFILE "/proc/net/tcp6"
+ if (!(in = fopen(PROCFILE, "r"))) {
+ snmp_log(LOG_ERR,"could not open " PROCFILE "\n");
+ if (1 == log_open_err) {
+ snmp_log(LOG_ERR,"could not open " PROCFILE "\n");
+ log_open_err = 0;
+ }
+ return -2;
+ }
+ /*
+ * if we turned off logging of open errors, turn it back on now that
+ * we have been able to open the file.
+ */
+ if (0 == log_open_err)
+ log_open_err = 1;
+
+ fgets(line, sizeof(line), in); /* skip header */
+
+ /*
+ * Note: PPC (big endian)
+ *
+ * sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
+ * 0: 00000000000000000000000000000001:1466 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 500 0 326699 1 efb81580 3000 0 0 2 -1
+ */
+ while (fgets(line, sizeof(line), in)) {
+ netsnmp_tcpconn_entry *entry;
+ int state, rc, local_port, remote_port, tmp_state;
+ size_t buf_len, offset;
+ u_char local_addr[48], remote_addr[48];
+ u_char *tmp_ptr;
+
+ if (5 != (rc = sscanf(line, "%*d: %47[0-9A-Z]:%x %47[0-9A-Z]:%x %x",
+ local_addr, &local_port,
+ remote_addr, &remote_port, &tmp_state))) {
+ DEBUGMSGT(("access:tcpconn:container",
+ "error parsing line (%d != 5)\n", rc));
+ DEBUGMSGT(("access:tcpconn:container"," line '%s'\n", line));
+ continue;
+ }
+ DEBUGMSGT(("verbose:access:tcpconn:container"," line '%s'\n", line));
+
+ /*
+ * check if we care about listen state
+ */
+ state = (tmp_state & 0xf) < 12 ? linux_states[tmp_state & 0xf] : 2;
+ if (load_flags) {
+ if (TCPCONNECTIONSTATE_LISTEN == state) {
+ if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " skipping listen\n"));
+ continue;
+ }
+ }
+ else if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " skipping non-listen\n"));
+ continue;
+ }
+ }
+
+ /*
+ */
+ entry = netsnmp_access_tcpconn_entry_create();
+ if(NULL == entry) {
+ rc = -3;
+ break;
+ }
+
+ /** oddly enough, these appear to already be in network order */
+ entry->loc_port = (unsigned short) local_port;
+ entry->rmt_port = (unsigned short) remote_port;
+ entry->tcpConnState = state;
+
+ /** the addr string may need work */
+ buf_len = strlen((char*)local_addr);
+ if ((32 != buf_len) ||
+ (-1 == netsnmp_addrstr_hton(local_addr, 32))) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " error processing local address\n"));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+ offset = 0;
+ tmp_ptr = entry->loc_addr;
+ rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
+ &offset, 0, local_addr, NULL);
+ entry->loc_addr_len = offset;
+ if (( 16 != entry->loc_addr_len ) && ( 20 != entry->loc_addr_len )) {
+ DEBUGMSGT(("access:tcpconn:container",
+ "error parsing local addr (%d != 16|20)\n",
+ entry->loc_addr_len));
+ DEBUGMSGT(("access:tcpconn:container"," line '%s'\n", line));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+
+ buf_len = strlen((char*)remote_addr);
+ if ((32 != buf_len) ||
+ (-1 == netsnmp_addrstr_hton(remote_addr, 32))) {
+ DEBUGMSGT(("verbose:access:tcpconn:container",
+ " error processing remote address\n"));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+ offset = 0;
+ tmp_ptr = entry->rmt_addr;
+ rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
+ &offset, 0, remote_addr, NULL);
+ entry->rmt_addr_len = offset;
+ if (( 16 != entry->rmt_addr_len ) && ( 20 != entry->rmt_addr_len )) {
+ DEBUGMSGT(("access:tcpconn:container",
+ "error parsing remote addr (%d != 16|20)\n",
+ entry->rmt_addr_len));
+ DEBUGMSGT(("access:tcpconn:container"," line '%s'\n", line));
+ netsnmp_access_tcpconn_entry_free(entry);
+ continue;
+ }
+
+
+ /*
+ * add entry to container
+ */
+ entry->arbitrary_index = CONTAINER_SIZE(container) + 1;
+ CONTAINER_INSERT(container, entry);
+ }
+
+ fclose(in);
+
+ if(rc<0)
+ return rc;
+
+ return 0;
+}
+#endif /* NETSNMP_ENABLE_IPV6 */
diff --git a/agent/mibgroup/tcp-mib/data_access/tcpConn_private.h b/agent/mibgroup/tcp-mib/data_access/tcpConn_private.h
new file mode 100644
index 0000000..c758f0e
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/data_access/tcpConn_private.h
@@ -0,0 +1,6 @@
+int netsnmp_arch_tcpconn_container_load(netsnmp_container *, u_int);
+int netsnmp_arch_tcpconn_entry_init(netsnmp_tcpconn_entry *);
+void netsnmp_arch_tcpconn_entry_cleanup(netsnmp_tcpconn_entry *);
+int netsnmp_arch_tcpconn_entry_delete(netsnmp_tcpconn_entry *);
+int netsnmp_arch_tcpconn_entry_copy(netsnmp_tcpconn_entry *,
+ netsnmp_tcpconn_entry *);
diff --git a/agent/mibgroup/tcp-mib/data_access/tcpConn_solaris2.c b/agent/mibgroup/tcp-mib/data_access/tcpConn_solaris2.c
new file mode 100644
index 0000000..7c2c6ae
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/data_access/tcpConn_solaris2.c
@@ -0,0 +1,182 @@
+#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/tcpConn.h>
+
+#include "tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h"
+#include "tcp-mib/data_access/tcpConn_private.h"
+
+#include "kernel_sunos5.h"
+
+static int _load_tcpconn_table_v4(netsnmp_container *, int);
+#if defined(NETSNMP_ENABLE_IPV6) && defined(SOLARIS_HAVE_IPV6_MIB_SUPPORT)
+static int _load_tcpconn_table_v6(netsnmp_container *, int);
+#endif
+
+int
+netsnmp_arch_tcpconn_entry_init(netsnmp_tcpconn_entry *ep)
+{
+ init_kernel_sunos5();
+ return 0;
+}
+
+void
+netsnmp_arch_tcpconn_entry_cleanup(netsnmp_tcpconn_entry *ep)
+{
+ /*
+ * Do nothing
+ */
+}
+
+int
+netsnmp_arch_tcpconn_entry_copy(netsnmp_tcpconn_entry *ep1,
+ netsnmp_tcpconn_entry *ep2)
+{
+ /*
+ * Do nothing
+ */
+ return 0;
+}
+
+int
+netsnmp_arch_tcpconn_delete(netsnmp_tcpconn_entry *ep)
+{
+ /*
+ * Not implemented
+ */
+ return (-1);
+}
+
+int
+netsnmp_arch_tcpconn_container_load(netsnmp_container * container,
+ u_int load_flag)
+{
+ int rc;
+
+ if ((rc = _load_tcpconn_table_v4(container, load_flag)) != 0) {
+ u_int flag = NETSNMP_ACCESS_TCPCONN_FREE_KEEP_CONTAINER;
+ netsnmp_access_tcpconn_container_free(container, flag);
+ return (rc);
+ }
+#if defined(NETSNMP_ENABLE_IPV6) && defined(SOLARIS_HAVE_IPV6_MIB_SUPPORT)
+ if ((rc = _load_tcpconn_table_v6(container, load_flag)) != 0) {
+ u_int flag = NETSNMP_ACCESS_TCPCONN_FREE_KEEP_CONTAINER;
+ netsnmp_access_tcpconn_container_free(container, flag);
+ return (rc);
+ }
+#endif
+ return (0);
+}
+
+static int
+_load_tcpconn_table_v4(netsnmp_container *container, int flag)
+{
+ mib2_tcpConnEntry_t tc;
+ netsnmp_tcpconn_entry *ep;
+ req_e req = GET_FIRST;
+
+ DEBUGMSGT(("access:tcpconn:container", "load v4\n"));
+
+ while (getMibstat(MIB_TCP_CONN, &tc, sizeof(tc), req,
+ &Get_everything, 0)==0) {
+ req = GET_NEXT;
+ if ((flag & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN &&
+ tc.tcpConnState != MIB2_TCP_listen) ||
+ (flag & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN &&
+ tc.tcpConnState == MIB2_TCP_listen)) {
+ continue;
+ }
+ ep = netsnmp_access_tcpconn_entry_create();
+ if (ep == NULL)
+ return (-1);
+ DEBUGMSGT(("access:tcpconn:container", "add entry\n"));
+
+ /*
+ * local address/port.
+ */
+ ep->loc_addr_len = sizeof(tc.tcpConnLocalAddress);
+ if (sizeof(ep->loc_addr) < ep->loc_addr_len) {
+ netsnmp_access_tcpconn_entry_free(ep);
+ return (-1);
+ }
+ (void)memcpy(&ep->loc_addr, &tc.tcpConnLocalAddress, ep->loc_addr_len);
+
+ ep->loc_port = tc.tcpConnLocalPort;
+
+ /*
+ * remote address/port. The address length is the same as the
+ * local address, so no check needed.
+ */
+ ep->rmt_addr_len = sizeof(tc.tcpConnRemAddress);
+ (void)memcpy(&ep->rmt_addr, &tc.tcpConnRemAddress, ep->rmt_addr_len);
+
+ ep->rmt_port = tc.tcpConnRemPort;
+
+ /* state/pid */
+ ep->tcpConnState = tc.tcpConnState;
+ ep->pid = 0;
+ ep->arch_data = NULL;
+
+ /* index */
+ ep->arbitrary_index = CONTAINER_SIZE(container) + 1;
+ CONTAINER_INSERT(container, (void *)ep);
+ }
+ return (0);
+}
+
+#if defined(NETSNMP_ENABLE_IPV6) && defined(SOLARIS_HAVE_IPV6_MIB_SUPPORT)
+static int
+_load_tcpconn_table_v6(netsnmp_container *container, int flag)
+{
+ mib2_tcp6ConnEntry_t tc6;
+ netsnmp_tcpconn_entry *ep;
+ req_e req = GET_FIRST;
+
+ DEBUGMSGT(("access:tcpconn:container", "load v6\n"));
+
+ while (getMibstat(MIB_TCP6_CONN, &tc6, sizeof(tc6), req,
+ &Get_everything, 0)==0) {
+ req = GET_NEXT;
+ if ((flag & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN &&
+ tc6.tcp6ConnState != MIB2_TCP_listen) ||
+ (flag & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN &&
+ tc6.tcp6ConnState == MIB2_TCP_listen)) {
+ continue;
+ }
+ ep = netsnmp_access_tcpconn_entry_create();
+ if (ep == NULL)
+ return (-1);
+ DEBUGMSGT(("access:tcpconn:container", "add entry\n"));
+
+ /*
+ * local address/port.
+ */
+ ep->loc_addr_len = sizeof(tc6.tcp6ConnLocalAddress);
+ if (sizeof(ep->loc_addr) < ep->loc_addr_len) {
+ netsnmp_access_tcpconn_entry_free(ep);
+ return (-1);
+ }
+ (void)memcpy(&ep->loc_addr, &tc6.tcp6ConnLocalAddress,
+ ep->loc_addr_len);
+
+ ep->loc_port = tc6.tcp6ConnLocalPort;
+
+ /* remote address/port */
+ ep->rmt_addr_len = sizeof(tc6.tcp6ConnRemAddress);
+ (void)memcpy(&ep->rmt_addr, &tc6.tcp6ConnRemAddress, ep->rmt_addr_len);
+
+ ep->rmt_port = tc6.tcp6ConnRemPort;
+
+ /* state/pid */
+ ep->tcpConnState = tc6.tcp6ConnState;
+ ep->pid = 0;
+ ep->arch_data = NULL;
+
+ /* index */
+ ep->arbitrary_index = CONTAINER_SIZE(container) + 1;
+ CONTAINER_INSERT(container, (void *)ep);
+ }
+ return (0);
+}
+#endif /*defined(NETSNMP_ENABLE_IPV6)&&defined(SOLARIS_HAVE_IPV6_MIB_SUPPORT)*/
diff --git a/agent/mibgroup/tcp-mib/tcpConnTable.h b/agent/mibgroup/tcp-mib/tcpConnTable.h
new file mode 100644
index 0000000..f588c1c
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnTable.h
@@ -0,0 +1,8 @@
+/*
+ * module to include the modules
+ */
+
+config_require(tcp-mib/data_access/tcpConn)
+config_require(tcp-mib/tcpConnTable/tcpConnTable)
+config_require(tcp-mib/tcpConnTable/tcpConnTable_interface)
+config_require(tcp-mib/tcpConnTable/tcpConnTable_data_access)
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable.h b/agent/mibgroup/tcp-mib/tcpConnectionTable.h
new file mode 100644
index 0000000..c697aaa
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable.h
@@ -0,0 +1,6 @@
+/*
+ * module to include the modules
+ */
+
+config_require(tcp-mib/data_access/tcpConn)
+config_require(tcp-mib/tcpConnectionTable/tcpConnectionTable)
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.c b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.c
new file mode 100644
index 0000000..4c61fe2
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.c
@@ -0,0 +1,1137 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.48 $ of : mfd-top.m2c,v $
+ *
+ * $Id: tcpConnectionTable.c 17861 2009-12-02 15:39:04Z jsafranek $
+ */
+/** \page MFD helper for tcpConnectionTable
+ *
+ * \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 "tcpConnectionTable.h"
+
+#include <net-snmp/agent/mib_modules.h>
+
+#include "tcpConnectionTable_interface.h"
+
+oid tcpConnectionTable_oid[] = { TCPCONNECTIONTABLE_OID };
+int tcpConnectionTable_oid_size =
+OID_LENGTH(tcpConnectionTable_oid);
+
+tcpConnectionTable_registration tcpConnectionTable_user_context;
+
+void initialize_table_tcpConnectionTable(void);
+void shutdown_table_tcpConnectionTable(void);
+
+
+/**
+ * Initializes the tcpConnectionTable module
+ */
+void
+init_tcpConnectionTable(void)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:init_tcpConnectionTable",
+ "called\n"));
+
+ /*
+ * TODO:300:o: Perform tcpConnectionTable one-time module initialization.
+ */
+
+ /*
+ * here we initialize all the tables we're planning on supporting
+ */
+ if (should_init("tcpConnectionTable"))
+ initialize_table_tcpConnectionTable();
+
+} /* init_tcpConnectionTable */
+
+/**
+ * Shut-down the tcpConnectionTable module (agent is exiting)
+ */
+void
+shutdown_tcpConnectionTable(void)
+{
+ if (should_init("tcpConnectionTable"))
+ shutdown_table_tcpConnectionTable();
+
+}
+
+/**
+ * Initialize the table tcpConnectionTable
+ * (Define its contents and how it's structured)
+ */
+void
+initialize_table_tcpConnectionTable(void)
+{
+ tcpConnectionTable_registration *user_context;
+ u_long flags;
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:initialize_table_tcpConnectionTable", "called\n"));
+
+ /*
+ * TODO:301:o: Perform tcpConnectionTable one-time table initialization.
+ */
+
+ /*
+ * TODO:302:o: |->Initialize tcpConnectionTable user context
+ * if you'd like to pass in a pointer to some data for this
+ * table, allocate or set it up here.
+ */
+ user_context = &tcpConnectionTable_user_context;
+
+ /*
+ * No support for any flags yet, but in the future you would
+ * set any flags here.
+ */
+ flags = 0;
+
+ /*
+ * call interface initialization code
+ */
+ _tcpConnectionTable_initialize_interface(user_context, flags);
+} /* initialize_table_tcpConnectionTable */
+
+/**
+ * Shutdown the table tcpConnectionTable
+ */
+void
+shutdown_table_tcpConnectionTable(void)
+{
+ /*
+ * call interface shutdown code
+ */
+ _tcpConnectionTable_shutdown_interface
+ (&tcpConnectionTable_user_context);
+}
+
+/**
+ * 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
+tcpConnectionTable_rowreq_ctx_init(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx, void *user_init_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_rowreq_ctx_init", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:210:o: |-> Perform extra tcpConnectionTable rowreq initialization. (eg DEFVALS)
+ */
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_rowreq_ctx_init */
+
+/**
+ * extra context cleanup
+ *
+ */
+void
+tcpConnectionTable_rowreq_ctx_cleanup(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_rowreq_ctx_cleanup", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:211:o: |-> Perform extra tcpConnectionTable rowreq cleanup.
+ */
+ netsnmp_access_tcpconn_entry_free(rowreq_ctx->data);
+ rowreq_ctx->data = NULL;
+} /* tcpConnectionTable_rowreq_ctx_cleanup */
+
+/**
+ * pre-request callback
+ *
+ * @param user_context
+ * @retval MFD_SUCCESS : success.
+ * @retval MFD_ERROR : other error
+ */
+int
+tcpConnectionTable_pre_request(tcpConnectionTable_registration *
+ user_context)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_pre_request", "called\n"));
+
+ /*
+ * TODO:510:o: Perform tcpConnectionTable pre-request actions.
+ */
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_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
+tcpConnectionTable_post_request(tcpConnectionTable_registration *
+ user_context, int rc)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_post_request", "called\n"));
+
+ /*
+ * TODO:511:o: Perform tcpConnectionTable post-request actions.
+ */
+
+ /*
+ * check to set if any rows were changed.
+ */
+ if (tcpConnectionTable_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
+ */
+ }
+
+ tcpConnectionTable_dirty_set(0); /* clear table dirty flag */
+ }
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_post_request */
+
+
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, length: 8
+ */
+
+/*
+ * ---------------------------------------------------------------------
+ * * TODO:200:r: Implement tcpConnectionTable data context functions.
+ */
+/*
+ * tcpConnectionTable_allocate_data
+ *
+ * Purpose: create new tcpConnectionTable_data.
+ */
+tcpConnectionTable_data *
+tcpConnectionTable_allocate_data(void)
+{
+ /*
+ * TODO:201:r: |-> allocate memory for the tcpConnectionTable data context.
+ */
+ tcpConnectionTable_data *rtn =
+ SNMP_MALLOC_TYPEDEF(tcpConnectionTable_data);
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_allocate_data", "called\n"));
+
+ if (NULL == rtn) {
+ snmp_log(LOG_ERR, "unable to malloc memory for new "
+ "tcpConnectionTable_data.\n");
+ }
+
+ return rtn;
+} /* tcpConnectionTable_allocate_data */
+
+/*
+ * tcpConnectionTable_release_data
+ *
+ * Purpose: release tcpConnectionTable data.
+ */
+void
+tcpConnectionTable_release_data(tcpConnectionTable_data * data)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_release_data", "called\n"));
+
+ /*
+ * TODO:202:r: |-> release memory for the tcpConnectionTable data context.
+ */
+ free(data);
+} /* tcpConnectionTable_release_data */
+
+
+
+/**
+ * set mib index(es)
+ *
+ * @param tbl_idx mib index structure
+ * @param tcpConnectionLocalAddressType_val
+ * @param tcpConnectionLocalAddress_val_ptr
+ * @param tcpConnectionLocalAddress_val_ptr_len
+ * @param tcpConnectionLocalPort_val
+ * @param tcpConnectionRemAddressType_val
+ * @param tcpConnectionRemAddress_val_ptr
+ * @param tcpConnectionRemAddress_val_ptr_len
+ * @param tcpConnectionRemPort_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
+tcpConnectionTable_indexes_set_tbl_idx(tcpConnectionTable_mib_index *
+ tbl_idx,
+ u_long
+ tcpConnectionLocalAddressType_val,
+ char
+ *tcpConnectionLocalAddress_val_ptr,
+ size_t
+ tcpConnectionLocalAddress_val_ptr_len,
+ u_long tcpConnectionLocalPort_val,
+ u_long
+ tcpConnectionRemAddressType_val,
+ char
+ *tcpConnectionRemAddress_val_ptr,
+ size_t
+ tcpConnectionRemAddress_val_ptr_len,
+ u_long tcpConnectionRemPort_val)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_indexes_set_tbl_idx", "called\n"));
+
+ /*
+ * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ /** are cross protocol connections allowed? */
+ netsnmp_assert(tbl_idx->tcpConnectionRemAddressType ==
+ tbl_idx->tcpConnectionLocalAddressType);
+ if (4 == tcpConnectionLocalAddressType_val)
+ tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_IPV4;
+ else if (16 == tcpConnectionLocalAddressType_val)
+ tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_IPV6;
+ else
+ tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_UNKNOWN;
+
+ /*
+ * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ tbl_idx->tcpConnectionLocalAddress_len = sizeof(tbl_idx->tcpConnectionLocalAddress) / sizeof(tbl_idx->tcpConnectionLocalAddress[0]); /* max length */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ /*
+ * make sure there is enough space for tcpConnectionLocalAddress data
+ */
+ if ((NULL == tbl_idx->tcpConnectionLocalAddress) ||
+ (tbl_idx->tcpConnectionLocalAddress_len <
+ (tcpConnectionLocalAddress_val_ptr_len))) {
+ snmp_log(LOG_ERR, "not enough space for value\n");
+ return MFD_ERROR;
+ }
+ tbl_idx->tcpConnectionLocalAddress_len =
+ tcpConnectionLocalAddress_val_ptr_len;
+ memcpy(tbl_idx->tcpConnectionLocalAddress,
+ tcpConnectionLocalAddress_val_ptr,
+ tcpConnectionLocalAddress_val_ptr_len *
+ sizeof(tcpConnectionLocalAddress_val_ptr[0]));
+
+ /*
+ * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ tbl_idx->tcpConnectionLocalPort = tcpConnectionLocalPort_val;
+
+ /*
+ * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ tbl_idx->tcpConnectionRemAddressType =
+ tbl_idx->tcpConnectionLocalAddressType;
+
+ /*
+ * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ tbl_idx->tcpConnectionRemAddress_len = sizeof(tbl_idx->tcpConnectionRemAddress) / sizeof(tbl_idx->tcpConnectionRemAddress[0]); /* max length */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ /*
+ * make sure there is enough space for tcpConnectionRemAddress data
+ */
+ if ((NULL == tbl_idx->tcpConnectionRemAddress) ||
+ (tbl_idx->tcpConnectionRemAddress_len <
+ (tcpConnectionRemAddress_val_ptr_len))) {
+ snmp_log(LOG_ERR, "not enough space for value\n");
+ return MFD_ERROR;
+ }
+ tbl_idx->tcpConnectionRemAddress_len =
+ tcpConnectionRemAddress_val_ptr_len;
+ memcpy(tbl_idx->tcpConnectionRemAddress,
+ tcpConnectionRemAddress_val_ptr,
+ tcpConnectionRemAddress_val_ptr_len *
+ sizeof(tcpConnectionRemAddress_val_ptr[0]));
+
+ /*
+ * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ tbl_idx->tcpConnectionRemPort = tcpConnectionRemPort_val;
+
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_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
+tcpConnectionTable_indexes_set(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ u_long tcpConnectionLocalAddressType_val,
+ char *tcpConnectionLocalAddress_val_ptr,
+ size_t
+ tcpConnectionLocalAddress_val_ptr_len,
+ u_long tcpConnectionLocalPort_val,
+ u_long tcpConnectionRemAddressType_val,
+ char *tcpConnectionRemAddress_val_ptr,
+ size_t tcpConnectionRemAddress_val_ptr_len,
+ u_long tcpConnectionRemPort_val)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_indexes_set", "called\n"));
+
+ if (MFD_SUCCESS !=
+ tcpConnectionTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
+ tcpConnectionLocalAddressType_val,
+ tcpConnectionLocalAddress_val_ptr,
+ tcpConnectionLocalAddress_val_ptr_len,
+ tcpConnectionLocalPort_val,
+ tcpConnectionRemAddressType_val,
+ tcpConnectionRemAddress_val_ptr,
+ tcpConnectionRemAddress_val_ptr_len,
+ tcpConnectionRemPort_val))
+ return MFD_ERROR;
+
+ /*
+ * convert mib index to oid index
+ */
+ rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);
+ if (0 != tcpConnectionTable_index_to_oid(&rowreq_ctx->oid_idx,
+ &rowreq_ctx->tbl_idx)) {
+ return MFD_ERROR;
+ }
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_indexes_set */
+
+
+/*---------------------------------------------------------------------
+ * TCP-MIB::tcpConnectionEntry.tcpConnectionState
+ * tcpConnectionState is subid 7 of tcpConnectionEntry.
+ * Its status is Current, and its access level is ReadWrite.
+ * OID: .1.3.6.1.2.1.6.19.1.7
+ * Description:
+The state of this TCP connection.
+
+ The value listen(2) is included only for parallelism to the
+ old tcpConnTable, and should not be used. A connection in
+ LISTEN state should be present in the tcpListenerTable.
+
+ The only value which may be set by a management station is
+ deleteTCB(12). Accordingly, it is appropriate for an agent
+ to return a `badValue' response if a management station
+ attempts to set this object to any other value.
+
+ If a management station sets this object to the value
+ deleteTCB(12), then this has the effect of deleting the TCB
+ (as defined in RFC 793) of the corresponding connection on
+ the managed node, resulting in immediate termination of the
+ connection.
+
+ As an implementation-specific option, a RST segment may be
+ sent from the managed node to the other TCP endpoint (note
+ however that RST segments are not sent reliably).
+ *
+ * Attributes:
+ * accessible 1 isscalar 0 enums 1 hasdefval 0
+ * readable 1 iscolumn 1 ranges 0 hashint 0
+ * settable 1
+ *
+ * Enum range: 9/16. Values: closed(1), listen(2), synSent(3), synReceived(4), established(5), finWait1(6), finWait2(7), closeWait(8), lastAck(9), closing(10), timeWait(11), deleteTCB(12)
+ *
+ * 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 tcpConnectionState data.
+ *
+ * Set a value using the data context for the row.
+ *
+ * @param rowreq_ctx
+ * Pointer to the row request context.
+ * @param tcpConnectionState_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
+tcpConnectionState_get(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ u_long * tcpConnectionState_val_ptr)
+{
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != tcpConnectionState_val_ptr);
+
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_get",
+ "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:231:o: |-> Extract the current value of the tcpConnectionState data.
+ * copy (* tcpConnectionState_val_ptr ) from rowreq_ctx->data
+ */
+ (*tcpConnectionState_val_ptr) = rowreq_ctx->data->tcpConnState;
+
+ return MFD_SUCCESS;
+} /* tcpConnectionState_get */
+
+/*---------------------------------------------------------------------
+ * TCP-MIB::tcpConnectionEntry.tcpConnectionProcess
+ * tcpConnectionProcess is subid 8 of tcpConnectionEntry.
+ * Its status is Current, and its access level is ReadOnly.
+ * OID: .1.3.6.1.2.1.6.19.1.8
+ * Description:
+The system's process ID for the process associated with
+ this connection, or zero if there is no such process. This
+ value is expected to be the same as HOST-RESOURCES-MIB::
+ hrSWRunIndex or SYSAPPL-MIB::sysApplElmtRunIndex for some
+ row in the appropriate tables.
+ *
+ * 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 tcpConnectionProcess data.
+ *
+ * Set a value using the data context for the row.
+ *
+ * @param rowreq_ctx
+ * Pointer to the row request context.
+ * @param tcpConnectionProcess_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
+tcpConnectionProcess_get(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ u_long * tcpConnectionProcess_val_ptr)
+{
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != tcpConnectionProcess_val_ptr);
+
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionProcess_get",
+ "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:231:o: |-> Extract the current value of the tcpConnectionProcess data.
+ * copy (* tcpConnectionProcess_val_ptr ) from rowreq_ctx->data
+ */
+ (*tcpConnectionProcess_val_ptr) = rowreq_ctx->data->pid;
+
+ return MFD_SUCCESS;
+} /* tcpConnectionProcess_get */
+
+
+
+/** @} */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, 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
+ * tcpConnectionTable_allocate_data(), but may need extra
+ * initialization similar to what you may have done in
+ * tcpConnectionTable_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 (tcpConnectionTable_rowreq_ctx)
+ *
+ * @retval MFD_SUCCESS : success
+ * @retval MFD_ERROR : error. set will fail.
+ */
+int
+tcpConnectionTable_undo_setup(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo_setup",
+ "called\n"));
+
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:451:M: |-> Setup tcpConnectionTable undo.
+ * set up tcpConnectionTable undo information, in preparation for a set.
+ * Undo storage is in (* tcpConnectionProcess_val_ptr )*
+ */
+
+ return rc;
+} /* tcpConnectionTable_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 (tcpConnectionTable_rowreq_ctx)
+ *
+ * @retval MFD_SUCCESS : success
+ * @retval MFD_ERROR : error. set will fail.
+ */
+int
+tcpConnectionTable_undo(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo",
+ "called\n"));
+
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:451:M: |-> tcpConnectionTable undo.
+ * tcpConnectionTable undo information, in response to a failed set.
+ * Undo storage is in (* tcpConnectionProcess_val_ptr )*
+ */
+
+ return rc;
+} /* tcpConnectionTable_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 (tcpConnectionTable_rowreq_ctx)
+ *
+ * @retval MFD_SUCCESS : success
+ * @retval MFD_ERROR : error
+ */
+int
+tcpConnectionTable_undo_cleanup(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo_cleanup", "called\n"));
+
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:452:M: |-> Cleanup tcpConnectionTable undo.
+ * Undo storage is in (* tcpConnectionProcess_val_ptr )*
+ */
+
+ return rc;
+} /* tcpConnectionTable_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
+ * tcpConnectionTable.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
+tcpConnectionTable_commit(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+ int save_flags;
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_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 tcpConnectionTable 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_TCPCONNECTIONSTATE_FLAG) {
+ save_flags &= ~COLUMN_TCPCONNECTIONSTATE_FLAG; /* clear tcpConnectionState */
+ /*
+ * TODO:482:o: |-> commit column tcpConnectionState.
+ */
+ rc = -1;
+ if (-1 == rc) {
+ snmp_log(LOG_ERR,
+ "tcpConnectionTable column tcpConnectionState commit failed\n");
+ } else {
+ /*
+ * set flag, in case we need to undo tcpConnectionState
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_TCPCONNECTIONSTATE_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;
+} /* tcpConnectionTable_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
+ * tcpConnectionTable.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
+tcpConnectionTable_undo_commit(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo_commit", "called\n"));
+
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:485:M: |-> Undo tcpConnectionTable 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;
+} /* tcpConnectionTable_undo_commit */
+
+/*
+ * TODO:440:M: Implement tcpConnectionTable node value checks.
+ * TODO:450:M: Implement tcpConnectionTable undo functions.
+ * TODO:460:M: Implement tcpConnectionTable set functions.
+ * TODO:480:M: Implement tcpConnectionTable commit functions.
+ */
+/*---------------------------------------------------------------------
+ * TCP-MIB::tcpConnectionEntry.tcpConnectionState
+ * tcpConnectionState is subid 7 of tcpConnectionEntry.
+ * Its status is Current, and its access level is ReadWrite.
+ * OID: .1.3.6.1.2.1.6.19.1.7
+ * Description:
+The state of this TCP connection.
+
+ The value listen(2) is included only for parallelism to the
+ old tcpConnTable, and should not be used. A connection in
+ LISTEN state should be present in the tcpListenerTable.
+
+ The only value which may be set by a management station is
+ deleteTCB(12). Accordingly, it is appropriate for an agent
+ to return a `badValue' response if a management station
+ attempts to set this object to any other value.
+
+ If a management station sets this object to the value
+ deleteTCB(12), then this has the effect of deleting the TCB
+ (as defined in RFC 793) of the corresponding connection on
+ the managed node, resulting in immediate termination of the
+ connection.
+
+ As an implementation-specific option, a RST segment may be
+ sent from the managed node to the other TCP endpoint (note
+ however that RST segments are not sent reliably).
+ *
+ * Attributes:
+ * accessible 1 isscalar 0 enums 1 hasdefval 0
+ * readable 1 iscolumn 1 ranges 0 hashint 0
+ * settable 1
+ *
+ * Enum range: 9/16. Values: closed(1), listen(2), synSent(3), synReceived(4), established(5), finWait1(6), finWait2(7), closeWait(8), lastAck(9), closing(10), timeWait(11), deleteTCB(12)
+ *
+ * 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 tcpConnectionState_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
+ * tcpConnectionTable_check_dependencies() function.
+ *
+ * The following checks have already been done for you:
+ * The syntax is ASN_INTEGER
+ * The value is one of closed(1), listen(2), synSent(3), synReceived(4), established(5), finWait1(6), finWait2(7), closeWait(8), lastAck(9), closing(10), timeWait(11), deleteTCB(12)
+ *
+ * If there a no other checks you need to do, simply return MFD_SUCCESS.
+ *
+ */
+int
+tcpConnectionState_check_value(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ u_long tcpConnectionState_val)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_check_value", "called\n"));
+
+ /** should never get a NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:441:o: |-> Check for valid tcpConnectionState value.
+ */
+
+ return MFD_SUCCESS; /* tcpConnectionState value not illegal */
+} /* tcpConnectionState_check_value */
+
+/**
+ * Save old value information
+ *
+ * @param rowreq_ctx
+ * Pointer to the table context (tcpConnectionTable_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
+ * tcpConnectionTable_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
+tcpConnectionState_undo_setup(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_undo_setup",
+ "called\n"));
+
+ /** should never get a NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:455:o: |-> Setup tcpConnectionState undo.
+ */
+ /*
+ * copy tcpConnectionState data
+ * set rowreq_ctx->undo->tcpConnectionState from rowreq_ctx->data->tcpConnectionState
+ */
+
+
+ return MFD_SUCCESS;
+} /* tcpConnectionState_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 tcpConnectionState_val
+ * A long containing the new value.
+ */
+int
+tcpConnectionState_set(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ u_long tcpConnectionState_val)
+{
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_set",
+ "called\n"));
+
+ /** should never get a NULL pointer */
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:461:M: |-> Set tcpConnectionState value.
+ * set tcpConnectionState value in rowreq_ctx->data
+ */
+
+ return MFD_SUCCESS;
+} /* tcpConnectionState_set */
+
+/**
+ * undo the previous set.
+ *
+ * @param rowreq_ctx
+ * Pointer to the users context.
+ */
+int
+tcpConnectionState_undo(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_undo",
+ "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:456:o: |-> Clean up tcpConnectionState undo.
+ */
+ /*
+ * copy tcpConnectionState data
+ * set rowreq_ctx->data->tcpConnectionState from rowreq_ctx->undo->tcpConnectionState
+ */
+
+
+ return MFD_SUCCESS;
+} /* tcpConnectionState_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
+ * tcpConnectionTable.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-tcpConnectionTable if you don't have dependencies)
+ */
+int
+tcpConnectionTable_check_dependencies(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:tcpConnectionTable_check_dependencies", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:470:o: Check tcpConnectionTable row dependencies.
+ * check that all new value are legal and consistent with each other
+ */
+ return rc;
+} /* tcpConnectionTable_check_dependencies */
+
+/** @} */
+/** @{ */
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.h b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.h
new file mode 100644
index 0000000..06bdb3c
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable.h
@@ -0,0 +1,620 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.48 $ of : mfd-top.m2c,v $
+ *
+ * $Id: tcpConnectionTable.h 14169 2006-01-25 16:28:12Z dts12 $
+ */
+#ifndef TCPCONNECTIONTABLE_H
+#define TCPCONNECTIONTABLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** @addtogroup misc misc: Miscellaneous routines
+ *
+ * @{
+ */
+#include <net-snmp/library/asn1.h>
+#include <net-snmp/data_access/tcpConn.h>
+
+ /*
+ * other required module components
+ */
+ /* *INDENT-OFF* */
+config_require(tcp-mib/data_access/tcpConn)
+config_require(tcp-mib/tcpConnectionTable/tcpConnectionTable_interface)
+config_require(tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access)
+ /* *INDENT-ON* */
+
+ /*
+ * OID, column number and enum definions for tcpConnectionTable
+ */
+#include "tcpConnectionTable_constants.h"
+
+ /*
+ *********************************************************************
+ * function declarations
+ */
+ void init_tcpConnectionTable(void);
+ void shutdown_tcpConnectionTable(void);
+
+ /*
+ *********************************************************************
+ * Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, 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 tcpConnectionTable registration context.
+ */
+ typedef struct tConnectionT_user_ctx {
+
+ void *dummy;
+
+ } tcpConnectionTable_registration;
+
+/**********************************************************************/
+ /*
+ * TODO:110:r: |-> Review tcpConnectionTable data context structure.
+ * This structure is used to represent the data for tcpConnectionTable.
+ */
+ typedef netsnmp_tcpconn_entry tcpConnectionTable_data;
+
+
+ /*
+ *********************************************************************
+ * TODO:115:o: |-> Review tcpConnectionTable 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 tcpConnectionTable_data tcpConnectionTable_undo_data;
+
+ /*
+ * TODO:120:r: |-> Review tcpConnectionTable mib index.
+ * This structure is used to represent the index for tcpConnectionTable.
+ */
+ typedef struct tcpConnectionTable_mib_index_s {
+
+ /*
+ * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ u_long tcpConnectionLocalAddressType;
+
+ /*
+ * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ /** 128 - 5(other indexes) - oid length(10) = 112 */
+ /** but 20 = size of ipv6z address, longest supported type */
+ char tcpConnectionLocalAddress[20];
+ size_t tcpConnectionLocalAddress_len;
+
+ /*
+ * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ u_long tcpConnectionLocalPort;
+
+ /*
+ * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ u_long tcpConnectionRemAddressType;
+
+ /*
+ * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ /** 128 - 5(other indexes) - oid length(10) = 112 */
+ /** but 20 = size of ipv6z address, longest supported type */
+ char tcpConnectionRemAddress[20];
+ size_t tcpConnectionRemAddress_len;
+
+ /*
+ * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ u_long tcpConnectionRemPort;
+
+
+ } tcpConnectionTable_mib_index;
+
+ /*
+ * TODO:121:r: | |-> Review tcpConnectionTable 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_tcpConnectionTable_IDX_LEN 44
+
+
+ /*
+ *********************************************************************
+ * TODO:130:o: |-> Review tcpConnectionTable Row request (rowreq) context.
+ * When your functions are called, you will be passed a
+ * tcpConnectionTable_rowreq_ctx pointer.
+ */
+ typedef struct tcpConnectionTable_rowreq_ctx_s {
+
+ /** this must be first for container compare to work */
+ netsnmp_index oid_idx;
+ oid oid_tmp[MAX_tcpConnectionTable_IDX_LEN];
+
+ tcpConnectionTable_mib_index tbl_idx;
+
+ tcpConnectionTable_data *data;
+ tcpConnectionTable_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 tcpConnectionTable rowreq context.
+ */
+
+ /*
+ * storage for future expansion
+ */
+ netsnmp_data_list *tcpConnectionTable_data_list;
+
+ } tcpConnectionTable_rowreq_ctx;
+
+ typedef struct tcpConnectionTable_ref_rowreq_ctx_s {
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx;
+ } tcpConnectionTable_ref_rowreq_ctx;
+
+ /*
+ *********************************************************************
+ * function prototypes
+ */
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_pre_request(tcpConnectionTable_registration *
+ user_context);
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_post_request(tcpConnectionTable_registration *
+ user_context, int rc);
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_rowreq_ctx_init(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx,
+ void *user_init_ctx);
+ void
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_rowreq_ctx_cleanup(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx);
+
+ tcpConnectionTable_data *tcpConnectionTable_allocate_data(void);
+ void tcpConnectionTable_release_data(tcpConnectionTable_data
+ * data);
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_check_dependencies(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx);
+ int tcpConnectionTable_commit(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx);
+
+
+
+
+
+
+
+ tcpConnectionTable_rowreq_ctx
+ * tcpConnectionTable_row_find_by_mib_index
+ (tcpConnectionTable_mib_index * mib_idx);
+
+ extern oid tcpConnectionTable_oid[];
+ extern int tcpConnectionTable_oid_size;
+
+
+#include "tcpConnectionTable_interface.h"
+#include "tcpConnectionTable_data_access.h"
+ /*
+ *********************************************************************
+ * GET function declarations
+ */
+
+ /*
+ *********************************************************************
+ * GET Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, length: 8
+ */
+ /*
+ * indexes
+ */
+
+ int tcpConnectionState_get(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ tcpConnectionState_val_ptr);
+ int tcpConnectionProcess_get(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx,
+ u_long *
+ tcpConnectionProcess_val_ptr);
+
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_indexes_set_tbl_idx(tcpConnectionTable_mib_index
+ * tbl_idx,
+ u_long
+ tcpConnectionLocalAddressType_val,
+ char
+ *tcpConnectionLocalAddress_val_ptr,
+ size_t
+ tcpConnectionLocalAddress_val_ptr_len,
+ u_long
+ tcpConnectionLocalPort_val,
+ u_long
+ tcpConnectionRemAddressType_val,
+ char
+ *tcpConnectionRemAddress_val_ptr,
+ size_t
+ tcpConnectionRemAddress_val_ptr_len,
+ u_long
+ tcpConnectionRemPort_val);
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_indexes_set(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long
+ tcpConnectionLocalAddressType_val,
+ char
+ *tcpConnectionLocalAddress_val_ptr,
+ size_t
+ tcpConnectionLocalAddress_val_ptr_len,
+ u_long tcpConnectionLocalPort_val,
+ u_long
+ tcpConnectionRemAddressType_val,
+ char
+ *tcpConnectionRemAddress_val_ptr,
+ size_t
+ tcpConnectionRemAddress_val_ptr_len,
+ u_long tcpConnectionRemPort_val);
+
+
+
+ /*
+ *********************************************************************
+ * SET function declarations
+ */
+
+ /*
+ *********************************************************************
+ * SET Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, length: 8
+ */
+
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_undo_setup(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_undo_cleanup(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+ int tcpConnectionTable_undo(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+ int tcpConnectionTable_commit(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx);
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_undo_commit(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionState_check_value(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long tcpConnectionState_val);
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionState_undo_setup(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+ int tcpConnectionState_set(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long tcpConnectionState_val);
+ int tcpConnectionState_undo(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionProcess_check_value(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long tcpConnectionProcess_val);
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionProcess_undo_setup(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+ int tcpConnectionProcess_set(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx,
+ u_long
+ tcpConnectionProcess_val);
+ int tcpConnectionProcess_undo(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx);
+
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_check_dependencies(tcpConnectionTable_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 /* TCPCONNECTIONTABLE_H */
+/** @} */
+
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h
new file mode 100644
index 0000000..01f7215
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_constants.h
@@ -0,0 +1,138 @@
+/*
+ * 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: tcpConnectionTable_constants.h 13776 2005-12-01 21:42:04Z rstory $
+ */
+#ifndef TCPCONNECTIONTABLE_CONSTANTS_H
+#define TCPCONNECTIONTABLE_CONSTANTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /*
+ * column number definitions for table tcpConnectionTable
+ */
+#define TCPCONNECTIONTABLE_OID 1,3,6,1,2,1,6,19
+
+#define COLUMN_TCPCONNECTIONLOCALADDRESSTYPE 1
+
+#define COLUMN_TCPCONNECTIONLOCALADDRESS 2
+
+#define COLUMN_TCPCONNECTIONLOCALPORT 3
+
+#define COLUMN_TCPCONNECTIONREMADDRESSTYPE 4
+
+#define COLUMN_TCPCONNECTIONREMADDRESS 5
+
+#define COLUMN_TCPCONNECTIONREMPORT 6
+
+#define COLUMN_TCPCONNECTIONSTATE 7
+#define COLUMN_TCPCONNECTIONSTATE_FLAG (0x1 << 6)
+
+#define COLUMN_TCPCONNECTIONPROCESS 8
+
+
+#define TCPCONNECTIONTABLE_MIN_COL COLUMN_TCPCONNECTIONSTATE
+#define TCPCONNECTIONTABLE_MAX_COL COLUMN_TCPCONNECTIONPROCESS
+
+
+ /*
+ * TODO:405:r: Review TCPCONNECTIONTABLE_SETTABLE_COLS macro.
+ * OR together all the writable cols.
+ */
+#define TCPCONNECTIONTABLE_SETTABLE_COLS (COLUMN_TCPCONNECTIONSTATE_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 tcpConnectionTable
+ *
+ *************************************************************************
+ *************************************************************************/
+
+/*************************************************************
+ * constants for enums for the MIB node
+ * tcpConnectionLocalAddressType (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
+ * tcpConnectionRemAddressType (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
+ * tcpConnectionState (INTEGER / ASN_INTEGER)
+ *
+ * since a Textual Convention may be referenced more than once in a
+ * MIB, protect againt redefinitions of the enum values.
+ */
+#ifndef TCPCONNECTIONSTATE_ENUMS
+#define TCPCONNECTIONSTATE_ENUMS
+
+#define TCPCONNECTIONSTATE_CLOSED 1
+#define TCPCONNECTIONSTATE_LISTEN 2
+#define TCPCONNECTIONSTATE_SYNSENT 3
+#define TCPCONNECTIONSTATE_SYNRECEIVED 4
+#define TCPCONNECTIONSTATE_ESTABLISHED 5
+#define TCPCONNECTIONSTATE_FINWAIT1 6
+#define TCPCONNECTIONSTATE_FINWAIT2 7
+#define TCPCONNECTIONSTATE_CLOSEWAIT 8
+#define TCPCONNECTIONSTATE_LASTACK 9
+#define TCPCONNECTIONSTATE_CLOSING 10
+#define TCPCONNECTIONSTATE_TIMEWAIT 11
+#define TCPCONNECTIONSTATE_DELETETCB 12
+
+#endif /* TCPCONNECTIONSTATE_ENUMS */
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TCPCONNECTIONTABLE_OIDS_H */
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.c b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.c
new file mode 100644
index 0000000..2c2c095
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.c
@@ -0,0 +1,321 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.17 $ of : mfd-data-access.m2c,v $
+ *
+ * $Id: tcpConnectionTable_data_access.c 17861 2009-12-02 15:39:04Z jsafranek $
+ */
+/*
+ * 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 "tcpConnectionTable.h"
+
+
+#include "tcpConnectionTable_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 tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, length: 8
+ */
+
+/**
+ * initialization for tcpConnectionTable data access
+ *
+ * This function is called during startup to allow you to
+ * allocate any resources you need for the data table.
+ *
+ * @param tcpConnectionTable_reg
+ * Pointer to tcpConnectionTable_registration
+ *
+ * @retval MFD_SUCCESS : success.
+ * @retval MFD_ERROR : unrecoverable error.
+ */
+int
+tcpConnectionTable_init_data(tcpConnectionTable_registration *
+ tcpConnectionTable_reg)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_init_data",
+ "called\n"));
+
+ /*
+ * TODO:303:o: Initialize tcpConnectionTable data.
+ */
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_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
+tcpConnectionTable_container_init(netsnmp_container **container_ptr_ptr,
+ netsnmp_cache * cache)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_container_init", "called\n"));
+
+ if (NULL == container_ptr_ptr) {
+ snmp_log(LOG_ERR,
+ "bad container param to tcpConnectionTable_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 tcpConnectionTable_container_init\n");
+ return;
+ }
+
+ /*
+ * TODO:345:A: Set up tcpConnectionTable 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 = TCPCONNECTIONTABLE_CACHE_TIMEOUT; /* seconds */
+ cache->flags |= NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
+} /* tcpConnectionTable_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 tcpConnectionTable_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
+tcpConnectionTable_container_shutdown(netsnmp_container *container_ptr)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_container_shutdown", "called\n"));
+
+ if (NULL == container_ptr) {
+ snmp_log(LOG_ERR,
+ "bad params to tcpConnectionTable_container_shutdown\n");
+ return;
+ }
+
+} /* tcpConnectionTable_container_shutdown */
+
+/**
+ * add new entry
+ */
+static void
+_add_connection(netsnmp_tcpconn_entry *entry, netsnmp_container *container)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx;
+
+ DEBUGMSGTL(("tcpConnectionTable:access", "creating new entry\n"));
+
+ /*
+ * allocate an row context and set the index(es), then add it to
+ * the container
+ */
+ rowreq_ctx = tcpConnectionTable_allocate_rowreq_ctx(entry, NULL);
+ if ((NULL != rowreq_ctx) &&
+ (MFD_SUCCESS == tcpConnectionTable_indexes_set(rowreq_ctx,
+ entry->loc_addr_len,
+ entry->loc_addr,
+ entry->loc_addr_len,
+ entry->loc_port,
+ entry->rmt_addr_len,
+ entry->rmt_addr,
+ entry->rmt_addr_len,
+ entry->rmt_port))) {
+ CONTAINER_INSERT(container, rowreq_ctx);
+ } else {
+ if (rowreq_ctx) {
+ snmp_log(LOG_ERR, "error setting index while loading "
+ "tcpConnectionTable cache.\n");
+ tcpConnectionTable_release_rowreq_ctx(rowreq_ctx);
+ } else {
+ snmp_log(LOG_ERR, "memory allocation failed while loading "
+ "tcpConnectionTable cache.\n");
+ netsnmp_access_tcpconn_entry_free(entry);
+ }
+ }
+}
+
+/**
+ * load initial data
+ *
+ * TODO:350:M: Implement tcpConnectionTable 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
+ * tcpConnectionTable_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
+tcpConnectionTable_container_load(netsnmp_container *container)
+{
+ netsnmp_container *raw_data =
+ netsnmp_access_tcpconn_container_load(NULL,
+ NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN);
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_container_load", "called\n"));
+
+ if (NULL == raw_data)
+ return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */
+
+ /*
+ * got all the connections. pull out the active ones.
+ */
+ CONTAINER_FOR_EACH(raw_data, (netsnmp_container_obj_func *)
+ _add_connection, container);
+
+ /*
+ * free the container. we've either claimed each entry, or released it,
+ * so the dal function doesn't need to clear the container.
+ */
+ netsnmp_access_tcpconn_container_free(raw_data,
+ NETSNMP_ACCESS_TCPCONN_FREE_DONT_CLEAR);
+
+ DEBUGMSGT(("verbose:tcpConnectionTable:tcpConnectionTable_cache_load",
+ "%d records\n", CONTAINER_SIZE(container)));
+
+ return MFD_SUCCESS;
+} /* tcpConnectionTable_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
+tcpConnectionTable_container_free(netsnmp_container *container)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_container_free", "called\n"));
+
+ /*
+ * TODO:380:M: Free tcpConnectionTable container data.
+ */
+} /* tcpConnectionTable_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
+tcpConnectionTable_row_prep(tcpConnectionTable_rowreq_ctx * rowreq_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_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;
+} /* tcpConnectionTable_row_prep */
+
+/** @} */
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.h b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_data_access.h
new file mode 100644
index 0000000..350165a
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_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: tcpConnectionTable_data_access.h 13776 2005-12-01 21:42:04Z rstory $
+ */
+#ifndef TCPCONNECTIONTABLE_DATA_ACCESS_H
+#define TCPCONNECTIONTABLE_DATA_ACCESS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /*
+ *********************************************************************
+ * function declarations
+ */
+
+ /*
+ *********************************************************************
+ * Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, length: 8
+ */
+
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_init_data(tcpConnectionTable_registration *
+ tcpConnectionTable_reg);
+
+
+ /*
+ * TODO:180:o: Review tcpConnectionTable cache timeout.
+ * The number of seconds before the cache times out
+ */
+#define TCPCONNECTIONTABLE_CACHE_TIMEOUT 60
+
+ void tcpConnectionTable_container_init(netsnmp_container
+ **container_ptr_ptr,
+ netsnmp_cache *
+ cache);
+ void tcpConnectionTable_container_shutdown(netsnmp_container
+ *container_ptr);
+
+ int tcpConnectionTable_container_load(netsnmp_container
+ *container);
+ void tcpConnectionTable_container_free(netsnmp_container
+ *container);
+
+ int tcpConnectionTable_cache_load(netsnmp_container
+ *container);
+ void tcpConnectionTable_cache_free(netsnmp_container
+ *container);
+
+ int
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_row_prep(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TCPCONNECTIONTABLE_DATA_ACCESS_H */
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c
new file mode 100644
index 0000000..9bd5606
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c
@@ -0,0 +1,1790 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.67 $ of : mfd-interface.m2c,v $
+ *
+ * $Id: tcpConnectionTable_interface.c 15015 2006-08-17 15:06:43Z rstory $
+ */
+/*
+ * *********************************************************************
+ * *********************************************************************
+ * *********************************************************************
+ * *** ***
+ * *** 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-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+
+/*
+ * include our parent header
+ */
+#include "tcpConnectionTable.h"
+
+
+#include <net-snmp/agent/table_container.h>
+#include <net-snmp/library/container.h>
+
+#include "tcpConnectionTable_interface.h"
+
+#include <ctype.h>
+
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpConnectionTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpConnectionTable is subid 19 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.19, length: 8
+ */
+typedef struct tcpConnectionTable_interface_ctx_s {
+
+ netsnmp_container *container;
+ netsnmp_cache *cache;
+
+ tcpConnectionTable_registration *user_ctx;
+
+ netsnmp_table_registration_info tbl_info;
+
+ netsnmp_baby_steps_access_methods access_multiplexer;
+
+ u_int table_dirty;
+
+} tcpConnectionTable_interface_ctx;
+
+static tcpConnectionTable_interface_ctx tcpConnectionTable_if_ctx;
+
+static void
+ _tcpConnectionTable_container_init(tcpConnectionTable_interface_ctx *
+ if_ctx);
+static void
+ _tcpConnectionTable_container_shutdown(tcpConnectionTable_interface_ctx *
+ if_ctx);
+
+
+netsnmp_container *
+tcpConnectionTable_container_get(void)
+{
+ return tcpConnectionTable_if_ctx.container;
+}
+
+tcpConnectionTable_registration *
+tcpConnectionTable_registration_get(void)
+{
+ return tcpConnectionTable_if_ctx.user_ctx;
+}
+
+tcpConnectionTable_registration *
+tcpConnectionTable_registration_set(tcpConnectionTable_registration *
+ newreg)
+{
+ tcpConnectionTable_registration *old =
+ tcpConnectionTable_if_ctx.user_ctx;
+ tcpConnectionTable_if_ctx.user_ctx = newreg;
+ return old;
+}
+
+int
+tcpConnectionTable_container_size(void)
+{
+ return CONTAINER_SIZE(tcpConnectionTable_if_ctx.container);
+}
+
+u_int
+tcpConnectionTable_dirty_get(void)
+{
+ return tcpConnectionTable_if_ctx.table_dirty;
+}
+
+void
+tcpConnectionTable_dirty_set(u_int status)
+{
+ DEBUGMSGTL(("tcpConnectionTable:tcpConnectionTable_dirty_set",
+ "called. was %d, now %d\n",
+ tcpConnectionTable_if_ctx.table_dirty, status));
+ tcpConnectionTable_if_ctx.table_dirty = status;
+}
+
+/*
+ * mfd multiplexer modes
+ */
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_pre_request;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_post_request;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_object_lookup;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_get_values;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_check_objects;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_undo_setup;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_set_values;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_undo_cleanup;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_undo_values;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_commit;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_undo_commit;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_irreversible_commit;
+static Netsnmp_Node_Handler _mfd_tcpConnectionTable_check_dependencies;
+
+NETSNMP_STATIC_INLINE int
+ _tcpConnectionTable_undo_column(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ netsnmp_variable_list *
+ var, int column);
+
+/**
+ * @internal
+ * Initialize the table tcpConnectionTable
+ * (Define its contents and how it's structured)
+ */
+void
+_tcpConnectionTable_initialize_interface(tcpConnectionTable_registration *
+ reg_ptr, u_long flags)
+{
+ netsnmp_baby_steps_access_methods *access_multiplexer =
+ &tcpConnectionTable_if_ctx.access_multiplexer;
+ netsnmp_table_registration_info *tbl_info =
+ &tcpConnectionTable_if_ctx.tbl_info;
+ netsnmp_handler_registration *reginfo;
+ netsnmp_mib_handler *handler;
+ int mfd_modes = 0;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_initialize_interface", "called\n"));
+
+
+ /*************************************************
+ *
+ * save interface context for tcpConnectionTable
+ */
+ /*
+ * Setting up the table's definition
+ */
+ netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
+ /** index: tcpConnectionLocalAddressType */
+ ASN_OCTET_STR,
+ /** index: tcpConnectionLocalAddress */
+ ASN_UNSIGNED,
+ /** index: tcpConnectionLocalPort */
+ ASN_INTEGER,
+ /** index: tcpConnectionRemAddressType */
+ ASN_OCTET_STR,
+ /** index: tcpConnectionRemAddress */
+ ASN_UNSIGNED,
+ /** index: tcpConnectionRemPort */
+ 0);
+
+ /*
+ * Define the minimum and maximum accessible columns. This
+ * optimizes retrival.
+ */
+ tbl_info->min_column = TCPCONNECTIONTABLE_MIN_COL;
+ tbl_info->max_column = TCPCONNECTIONTABLE_MAX_COL;
+
+ /*
+ * save users context
+ */
+ tcpConnectionTable_if_ctx.user_ctx = reg_ptr;
+
+ /*
+ * call data access initialization code
+ */
+ tcpConnectionTable_init_data(reg_ptr);
+
+ /*
+ * set up the container
+ */
+ _tcpConnectionTable_container_init(&tcpConnectionTable_if_ctx);
+ if (NULL == tcpConnectionTable_if_ctx.container) {
+ snmp_log(LOG_ERR,
+ "could not initialize container for tcpConnectionTable\n");
+ return;
+ }
+
+ /*
+ * access_multiplexer: REQUIRED wrapper for get request handling
+ */
+ access_multiplexer->object_lookup =
+ _mfd_tcpConnectionTable_object_lookup;
+ access_multiplexer->get_values = _mfd_tcpConnectionTable_get_values;
+
+ /*
+ * no wrappers yet
+ */
+ access_multiplexer->pre_request = _mfd_tcpConnectionTable_pre_request;
+ access_multiplexer->post_request =
+ _mfd_tcpConnectionTable_post_request;
+
+
+ /*
+ * REQUIRED wrappers for set request handling
+ */
+ access_multiplexer->object_syntax_checks =
+ _mfd_tcpConnectionTable_check_objects;
+ access_multiplexer->undo_setup = _mfd_tcpConnectionTable_undo_setup;
+ access_multiplexer->undo_cleanup =
+ _mfd_tcpConnectionTable_undo_cleanup;
+ access_multiplexer->set_values = _mfd_tcpConnectionTable_set_values;
+ access_multiplexer->undo_sets = _mfd_tcpConnectionTable_undo_values;
+
+ /*
+ * no wrappers yet
+ */
+ access_multiplexer->commit = _mfd_tcpConnectionTable_commit;
+ access_multiplexer->undo_commit = _mfd_tcpConnectionTable_undo_commit;
+ access_multiplexer->irreversible_commit =
+ _mfd_tcpConnectionTable_irreversible_commit;
+
+ /*
+ * REQUIRED for tables with dependencies
+ */
+ access_multiplexer->consistency_checks =
+ _mfd_tcpConnectionTable_check_dependencies;
+
+ /*************************************************
+ *
+ * Create a registration, save our reg data, register table.
+ */
+ DEBUGMSGTL(("tcpConnectionTable:init_tcpConnectionTable",
+ "Registering tcpConnectionTable as a mibs-for-dummies table.\n"));
+ handler =
+ netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
+ reginfo =
+ netsnmp_handler_registration_create("tcpConnectionTable", handler,
+ tcpConnectionTable_oid,
+ tcpConnectionTable_oid_size,
+ HANDLER_CAN_BABY_STEP |
+ HANDLER_CAN_RWRITE);
+ if (NULL == reginfo) {
+ snmp_log(LOG_ERR, "error registering table tcpConnectionTable\n");
+ return;
+ }
+ reginfo->my_reg_void = &tcpConnectionTable_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->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->pre_request)
+ mfd_modes |= BABY_STEP_PRE_REQUEST;
+ if (access_multiplexer->post_request)
+ mfd_modes |= BABY_STEP_POST_REQUEST;
+
+ 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;
+
+ 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,
+ tcpConnectionTable_if_ctx.
+ container,
+ TABLE_CONTAINER_KEY_NETSNMP_INDEX);
+ netsnmp_inject_handler(reginfo, handler);
+
+ /*************************************************
+ *
+ * inject cache helper
+ */
+ if (NULL != tcpConnectionTable_if_ctx.cache) {
+ handler =
+ netsnmp_cache_handler_get(tcpConnectionTable_if_ctx.cache);
+ netsnmp_inject_handler(reginfo, handler);
+ }
+
+ /*
+ * register table
+ */
+ netsnmp_register_table(reginfo, tbl_info);
+
+} /* _tcpConnectionTable_initialize_interface */
+
+/**
+ * @internal
+ * Shutdown the table tcpConnectionTable
+ */
+void
+_tcpConnectionTable_shutdown_interface(tcpConnectionTable_registration *
+ reg_ptr)
+{
+ /*
+ * shutdown the container
+ */
+ _tcpConnectionTable_container_shutdown(&tcpConnectionTable_if_ctx);
+}
+
+void
+tcpConnectionTable_valid_columns_set(netsnmp_column_info *vc)
+{
+ tcpConnectionTable_if_ctx.tbl_info.valid_columns = vc;
+} /* tcpConnectionTable_valid_columns_set */
+
+/**
+ * @internal
+ * convert the index component stored in the context to an oid
+ */
+int
+tcpConnectionTable_index_to_oid(netsnmp_index * oid_idx,
+ tcpConnectionTable_mib_index * mib_idx)
+{
+ int err = SNMP_ERR_NOERROR;
+
+ /*
+ * temp storage for parsing indexes
+ */
+ /*
+ * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionLocalAddressType;
+ /*
+ * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionLocalAddress;
+ /*
+ * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ netsnmp_variable_list var_tcpConnectionLocalPort;
+ /*
+ * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionRemAddressType;
+ /*
+ * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionRemAddress;
+ /*
+ * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ netsnmp_variable_list var_tcpConnectionRemPort;
+
+ /*
+ * set up varbinds
+ */
+ memset(&var_tcpConnectionLocalAddressType, 0x00,
+ sizeof(var_tcpConnectionLocalAddressType));
+ var_tcpConnectionLocalAddressType.type = ASN_INTEGER;
+ memset(&var_tcpConnectionLocalAddress, 0x00,
+ sizeof(var_tcpConnectionLocalAddress));
+ var_tcpConnectionLocalAddress.type = ASN_OCTET_STR;
+ memset(&var_tcpConnectionLocalPort, 0x00,
+ sizeof(var_tcpConnectionLocalPort));
+ var_tcpConnectionLocalPort.type = ASN_UNSIGNED;
+ memset(&var_tcpConnectionRemAddressType, 0x00,
+ sizeof(var_tcpConnectionRemAddressType));
+ var_tcpConnectionRemAddressType.type = ASN_INTEGER;
+ memset(&var_tcpConnectionRemAddress, 0x00,
+ sizeof(var_tcpConnectionRemAddress));
+ var_tcpConnectionRemAddress.type = ASN_OCTET_STR;
+ memset(&var_tcpConnectionRemPort, 0x00,
+ sizeof(var_tcpConnectionRemPort));
+ var_tcpConnectionRemPort.type = ASN_UNSIGNED;
+
+ /*
+ * chain temp index varbinds together
+ */
+ var_tcpConnectionLocalAddressType.next_variable =
+ &var_tcpConnectionLocalAddress;
+ var_tcpConnectionLocalAddress.next_variable =
+ &var_tcpConnectionLocalPort;
+ var_tcpConnectionLocalPort.next_variable =
+ &var_tcpConnectionRemAddressType;
+ var_tcpConnectionRemAddressType.next_variable =
+ &var_tcpConnectionRemAddress;
+ var_tcpConnectionRemAddress.next_variable = &var_tcpConnectionRemPort;
+ var_tcpConnectionRemPort.next_variable = NULL;
+
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_index_to_oid", "called\n"));
+
+ /*
+ * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ snmp_set_var_value(&var_tcpConnectionLocalAddressType,
+ (u_char *) & mib_idx->tcpConnectionLocalAddressType,
+ sizeof(mib_idx->tcpConnectionLocalAddressType));
+
+ /*
+ * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ snmp_set_var_value(&var_tcpConnectionLocalAddress,
+ (u_char *) & mib_idx->tcpConnectionLocalAddress,
+ mib_idx->tcpConnectionLocalAddress_len *
+ sizeof(mib_idx->tcpConnectionLocalAddress[0]));
+
+ /*
+ * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ snmp_set_var_value(&var_tcpConnectionLocalPort,
+ (u_char *) & mib_idx->tcpConnectionLocalPort,
+ sizeof(mib_idx->tcpConnectionLocalPort));
+
+ /*
+ * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ snmp_set_var_value(&var_tcpConnectionRemAddressType,
+ (u_char *) & mib_idx->tcpConnectionRemAddressType,
+ sizeof(mib_idx->tcpConnectionRemAddressType));
+
+ /*
+ * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ snmp_set_var_value(&var_tcpConnectionRemAddress,
+ (u_char *) & mib_idx->tcpConnectionRemAddress,
+ mib_idx->tcpConnectionRemAddress_len *
+ sizeof(mib_idx->tcpConnectionRemAddress[0]));
+
+ /*
+ * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ snmp_set_var_value(&var_tcpConnectionRemPort,
+ (u_char *) & mib_idx->tcpConnectionRemPort,
+ sizeof(mib_idx->tcpConnectionRemPort));
+
+
+ err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
+ NULL, 0, &var_tcpConnectionLocalAddressType);
+ 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_tcpConnectionLocalAddressType);
+
+ return err;
+} /* tcpConnectionTable_index_to_oid */
+
+/**
+ * extract tcpConnectionTable indexes from a netsnmp_index
+ *
+ * @retval SNMP_ERR_NOERROR : no error
+ * @retval SNMP_ERR_GENERR : error
+ */
+int
+tcpConnectionTable_index_from_oid(netsnmp_index * oid_idx,
+ tcpConnectionTable_mib_index * mib_idx)
+{
+ int err = SNMP_ERR_NOERROR;
+
+ /*
+ * temp storage for parsing indexes
+ */
+ /*
+ * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionLocalAddressType;
+ /*
+ * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionLocalAddress;
+ /*
+ * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ netsnmp_variable_list var_tcpConnectionLocalPort;
+ /*
+ * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionRemAddressType;
+ /*
+ * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ netsnmp_variable_list var_tcpConnectionRemAddress;
+ /*
+ * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ netsnmp_variable_list var_tcpConnectionRemPort;
+
+ /*
+ * set up varbinds
+ */
+ memset(&var_tcpConnectionLocalAddressType, 0x00,
+ sizeof(var_tcpConnectionLocalAddressType));
+ var_tcpConnectionLocalAddressType.type = ASN_INTEGER;
+ memset(&var_tcpConnectionLocalAddress, 0x00,
+ sizeof(var_tcpConnectionLocalAddress));
+ var_tcpConnectionLocalAddress.type = ASN_OCTET_STR;
+ memset(&var_tcpConnectionLocalPort, 0x00,
+ sizeof(var_tcpConnectionLocalPort));
+ var_tcpConnectionLocalPort.type = ASN_UNSIGNED;
+ memset(&var_tcpConnectionRemAddressType, 0x00,
+ sizeof(var_tcpConnectionRemAddressType));
+ var_tcpConnectionRemAddressType.type = ASN_INTEGER;
+ memset(&var_tcpConnectionRemAddress, 0x00,
+ sizeof(var_tcpConnectionRemAddress));
+ var_tcpConnectionRemAddress.type = ASN_OCTET_STR;
+ memset(&var_tcpConnectionRemPort, 0x00,
+ sizeof(var_tcpConnectionRemPort));
+ var_tcpConnectionRemPort.type = ASN_UNSIGNED;
+
+ /*
+ * chain temp index varbinds together
+ */
+ var_tcpConnectionLocalAddressType.next_variable =
+ &var_tcpConnectionLocalAddress;
+ var_tcpConnectionLocalAddress.next_variable =
+ &var_tcpConnectionLocalPort;
+ var_tcpConnectionLocalPort.next_variable =
+ &var_tcpConnectionRemAddressType;
+ var_tcpConnectionRemAddressType.next_variable =
+ &var_tcpConnectionRemAddress;
+ var_tcpConnectionRemAddress.next_variable = &var_tcpConnectionRemPort;
+ var_tcpConnectionRemPort.next_variable = NULL;
+
+
+ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_index_from_oid", "called\n"));
+
+ /*
+ * parse the oid into the individual index components
+ */
+ err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
+ &var_tcpConnectionLocalAddressType);
+ if (err == SNMP_ERR_NOERROR) {
+ /*
+ * copy out values
+ */
+ mib_idx->tcpConnectionLocalAddressType =
+ *((u_long *) var_tcpConnectionLocalAddressType.val.string);
+ /*
+ * NOTE: val_len is in bytes, tcpConnectionLocalAddress_len might not be
+ */
+ if (var_tcpConnectionLocalAddress.val_len >
+ sizeof(mib_idx->tcpConnectionLocalAddress))
+ err = SNMP_ERR_GENERR;
+ else {
+ memcpy(mib_idx->tcpConnectionLocalAddress,
+ var_tcpConnectionLocalAddress.val.string,
+ var_tcpConnectionLocalAddress.val_len);
+ mib_idx->tcpConnectionLocalAddress_len =
+ var_tcpConnectionLocalAddress.val_len /
+ sizeof(mib_idx->tcpConnectionLocalAddress[0]);
+ }
+ mib_idx->tcpConnectionLocalPort =
+ *((u_long *) var_tcpConnectionLocalPort.val.string);
+ mib_idx->tcpConnectionRemAddressType =
+ *((u_long *) var_tcpConnectionRemAddressType.val.string);
+ /*
+ * NOTE: val_len is in bytes, tcpConnectionRemAddress_len might not be
+ */
+ if (var_tcpConnectionRemAddress.val_len >
+ sizeof(mib_idx->tcpConnectionRemAddress))
+ err = SNMP_ERR_GENERR;
+ else {
+ memcpy(mib_idx->tcpConnectionRemAddress,
+ var_tcpConnectionRemAddress.val.string,
+ var_tcpConnectionRemAddress.val_len);
+ mib_idx->tcpConnectionRemAddress_len =
+ var_tcpConnectionRemAddress.val_len /
+ sizeof(mib_idx->tcpConnectionRemAddress[0]);
+ }
+ mib_idx->tcpConnectionRemPort =
+ *((u_long *) var_tcpConnectionRemPort.val.string);
+
+
+ }
+
+ /*
+ * parsing may have allocated memory. free it.
+ */
+ snmp_reset_var_buffers(&var_tcpConnectionLocalAddressType);
+
+ return err;
+} /* tcpConnectionTable_index_from_oid */
+
+
+/*
+ *********************************************************************
+ * @internal
+ * allocate resources for a tcpConnectionTable_rowreq_ctx
+ */
+tcpConnectionTable_rowreq_ctx *
+tcpConnectionTable_allocate_rowreq_ctx(tcpConnectionTable_data * data,
+ void *user_init_ctx)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ SNMP_MALLOC_TYPEDEF(tcpConnectionTable_rowreq_ctx);
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:tcpConnectionTable_allocate_rowreq_ctx", "called\n"));
+
+ if (NULL == rowreq_ctx) {
+ snmp_log(LOG_ERR, "Couldn't allocate memory for a "
+ "tcpConnectionTable_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 =
+ tcpConnectionTable_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->tcpConnectionTable_data_list = NULL;
+
+ /*
+ * if we allocated data, call init routine
+ */
+ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
+ if (SNMPERR_SUCCESS !=
+ tcpConnectionTable_rowreq_ctx_init(rowreq_ctx,
+ user_init_ctx)) {
+ tcpConnectionTable_release_rowreq_ctx(rowreq_ctx);
+ rowreq_ctx = NULL;
+ }
+ }
+
+ return rowreq_ctx;
+} /* tcpConnectionTable_allocate_rowreq_ctx */
+
+/*
+ * @internal
+ * release resources for a tcpConnectionTable_rowreq_ctx
+ */
+void
+tcpConnectionTable_release_rowreq_ctx(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx)
+{
+ DEBUGMSGTL(("internal:tcpConnectionTable:tcpConnectionTable_release_rowreq_ctx", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ tcpConnectionTable_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))
+ tcpConnectionTable_release_data(rowreq_ctx->data);
+
+ if (rowreq_ctx->undo)
+ tcpConnectionTable_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);
+} /* tcpConnectionTable_release_rowreq_ctx */
+
+/**
+ * @internal
+ * wrapper
+ */
+static int
+_mfd_tcpConnectionTable_pre_request(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_pre_request", "called\n"));
+
+ if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
+ DEBUGMSGTL(("internal:tcpConnectionTable",
+ "skipping additional pre_request\n"));
+ return SNMP_ERR_NOERROR;
+ }
+
+ rc = tcpConnectionTable_pre_request(tcpConnectionTable_if_ctx.
+ user_ctx);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpConnectionTable", "error %d from "
+ "tcpConnectionTable_pre_request\n", rc));
+ netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_pre_request */
+
+/**
+ * @internal
+ * wrapper
+ */
+static int
+_mfd_tcpConnectionTable_post_request(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ int rc, packet_rc;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_post_request", "called\n"));
+
+ /*
+ * release row context, if deleted
+ */
+ if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
+ tcpConnectionTable_release_rowreq_ctx(rowreq_ctx);
+
+ /*
+ * wait for last call before calling user
+ */
+ if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
+ DEBUGMSGTL(("internal:tcpConnectionTable",
+ "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) && tcpConnectionTable_dirty_get()) {
+ /*
+ * we shouldn't get here. the undo steps should also clear
+ * the dirty flags.
+ */
+ snmp_log(LOG_WARNING,
+ "tcpConnectionTable dirty flag set in post_request "
+ "but status != SUCCESS.\n");
+ }
+
+ rc = tcpConnectionTable_post_request(tcpConnectionTable_if_ctx.
+ user_ctx, packet_rc);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpConnectionTable", "error %d from "
+ "tcpConnectionTable_post_request\n", rc));
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_post_request */
+
+/**
+ * @internal
+ * wrapper
+ */
+static int
+_mfd_tcpConnectionTable_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;
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_object_lookup", "called\n"));
+
+ /*
+ * get our context from mfd
+ * tcpConnectionTable_interface_ctx *if_ctx =
+ * (tcpConnectionTable_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
+ tcpConnectionTable_row_prep(rowreq_ctx);
+
+ return SNMP_VALIDATE_ERR(rc);
+} /* _mfd_tcpConnectionTable_object_lookup */
+
+/***********************************************************************
+ *
+ * GET processing
+ *
+ ***********************************************************************/
+/*
+ * @internal
+ * Retrieve the value for a particular column
+ */
+NETSNMP_STATIC_INLINE int
+_tcpConnectionTable_get_column(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ netsnmp_variable_list * var, int column)
+{
+ int rc = SNMPERR_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_get_column", "called for %d\n", column));
+
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ switch (column) {
+
+ /*
+ * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONSTATE:
+ var->val_len = sizeof(u_long);
+ var->type = ASN_INTEGER;
+ rc = tcpConnectionState_get(rowreq_ctx,
+ (u_long *) var->val.string);
+ break;
+
+ /*
+ * tcpConnectionProcess(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONPROCESS:
+ var->val_len = sizeof(u_long);
+ var->type = ASN_UNSIGNED;
+ rc = tcpConnectionProcess_get(rowreq_ctx,
+ (u_long *) var->val.string);
+ break;
+
+ default:
+ snmp_log(LOG_ERR,
+ "unknown column %d in _tcpConnectionTable_get_column\n",
+ column);
+ break;
+ }
+
+ return rc;
+} /* _tcpConnectionTable_get_column */
+
+int
+_mfd_tcpConnectionTable_get_values(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpConnectionTable_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:tcpConnectionTable:_mfd_tcpConnectionTable_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 = _tcpConnectionTable_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_tcpConnectionTable_get_values */
+
+
+/***********************************************************************
+ *
+ * SET processing
+ *
+ ***********************************************************************/
+
+/*----------------------------------------------------------------------
+ *
+ * SET: Syntax checks
+ *
+ *---------------------------------------------------------------------*/
+/*
+ * @internal
+ * Check the syntax for a particular column
+ */
+NETSNMP_STATIC_INLINE int
+_tcpConnectionTable_check_column(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx, netsnmp_variable_list * var,
+ int column)
+{
+ int rc = SNMPERR_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_check_column", "called for %d\n", column));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ switch (column) {
+ /*
+ * (INDEX) tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONLOCALADDRESSTYPE:
+ rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
+ break;
+ /*
+ * (INDEX) tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ case COLUMN_TCPCONNECTIONLOCALADDRESS:
+ rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
+ break;
+ /*
+ * (INDEX) tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ case COLUMN_TCPCONNECTIONLOCALPORT:
+ rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
+ break;
+ /*
+ * (INDEX) tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONREMADDRESSTYPE:
+ rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
+ break;
+ /*
+ * (INDEX) tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ case COLUMN_TCPCONNECTIONREMADDRESS:
+ rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
+ break;
+ /*
+ * (INDEX) tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ case COLUMN_TCPCONNECTIONREMPORT:
+ rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
+ break;
+
+ /*
+ * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONSTATE:
+ rc = netsnmp_check_vb_type(var, ASN_INTEGER);
+ /*
+ * check that the value is one of defined enums
+ */
+ if ((SNMPERR_SUCCESS == rc)
+ && (*var->val.integer != TCPCONNECTIONSTATE_CLOSED)
+ && (*var->val.integer != TCPCONNECTIONSTATE_LISTEN)
+ && (*var->val.integer != TCPCONNECTIONSTATE_SYNSENT)
+ && (*var->val.integer != TCPCONNECTIONSTATE_SYNRECEIVED)
+ && (*var->val.integer != TCPCONNECTIONSTATE_ESTABLISHED)
+ && (*var->val.integer != TCPCONNECTIONSTATE_FINWAIT1)
+ && (*var->val.integer != TCPCONNECTIONSTATE_FINWAIT2)
+ && (*var->val.integer != TCPCONNECTIONSTATE_CLOSEWAIT)
+ && (*var->val.integer != TCPCONNECTIONSTATE_LASTACK)
+ && (*var->val.integer != TCPCONNECTIONSTATE_CLOSING)
+ && (*var->val.integer != TCPCONNECTIONSTATE_TIMEWAIT)
+ && (*var->val.integer != TCPCONNECTIONSTATE_DELETETCB)
+ ) {
+ rc = SNMP_ERR_WRONGVALUE;
+ }
+ if (SNMPERR_SUCCESS != rc) {
+ DEBUGMSGTL(("tcpConnectionTable:_tcpConnectionTable_check_column:tcpConnectionState", "varbind validation failed (eg bad type or size)\n"));
+ } else {
+ rc = tcpConnectionState_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 tcpConnectionState_check_value\n",
+ rc);
+ rc = SNMP_ERR_GENERR;
+ }
+ }
+ break;
+
+ /*
+ * tcpConnectionProcess(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONPROCESS:
+ rc = SNMP_ERR_NOTWRITABLE;
+ break;
+
+ default: /** We shouldn't get here */
+ rc = SNMP_ERR_GENERR;
+ snmp_log(LOG_ERR,
+ "unknown column %d in _tcpConnectionTable_check_column\n",
+ column);
+ }
+
+ return rc;
+} /* _tcpConnectionTable_check_column */
+
+int
+_mfd_tcpConnectionTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration
+ *reginfo, netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ netsnmp_table_request_info *tri;
+ int rc;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_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 = _tcpConnectionTable_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_tcpConnectionTable_check_objects */
+
+
+/*----------------------------------------------------------------------
+ *
+ * SET: check dependencies
+ *
+ *---------------------------------------------------------------------*/
+/*
+ * @internal
+ * Check dependencies wrapper
+ */
+static int
+_mfd_tcpConnectionTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration
+ *reginfo, netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_check_dependencies", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ rc = tcpConnectionTable_check_dependencies(rowreq_ctx);
+ if (rc) {
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_check_dependencies\n", rc));
+ netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_check_dependencies */
+
+/*----------------------------------------------------------------------
+ *
+ * SET: Undo setup
+ *
+ *---------------------------------------------------------------------*/
+/*
+ * @internal
+ * Set the value for a particular column
+ */
+NETSNMP_STATIC_INLINE int
+_tcpConnectionTable_undo_setup_column(tcpConnectionTable_rowreq_ctx *
+ rowreq_ctx, int column)
+{
+ int rc = SNMPERR_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_undo_setup_column", "called for %d\n", column));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ switch (column) {
+
+ /*
+ * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONSTATE:
+ rowreq_ctx->column_set_flags |= COLUMN_TCPCONNECTIONSTATE_FLAG;
+ rc = tcpConnectionState_undo_setup(rowreq_ctx);
+ break;
+
+ default:
+ snmp_log(LOG_ERR,
+ "unknown column %d in _tcpConnectionTable_undo_setup_column\n",
+ column);
+ break;
+ }
+
+ return rc;
+} /* _tcpConnectionTable_undo_setup_column */
+
+
+/**
+ * @internal
+ * undo setup
+ */
+int
+_mfd_tcpConnectionTable_undo_setup(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_undo_setup", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * allocate undo context
+ */
+ rowreq_ctx->undo = tcpConnectionTable_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 = tcpConnectionTable_undo_setup(rowreq_ctx);
+ if (MFD_SUCCESS != rc) {
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_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 = _tcpConnectionTable_undo_setup_column(rowreq_ctx,
+ tri->colnum);
+ if (MFD_SUCCESS != rc) {
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_undo_setup_column\n", rc));
+ netsnmp_set_request_error(agtreq_info, requests,
+ SNMP_VALIDATE_ERR(rc));
+ }
+ } /* for results */
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_undo_setup */
+
+/**
+ * @internal
+ * undo setup
+ */
+int
+_mfd_tcpConnectionTable_undo_cleanup(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ int rc;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_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 = tcpConnectionTable_undo_cleanup(rowreq_ctx);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_undo_cleanup\n", rc));
+ }
+
+ /*
+ * release undo context, if needed
+ */
+ if (rowreq_ctx->undo) {
+ tcpConnectionTable_release_data(rowreq_ctx->undo);
+ rowreq_ctx->undo = NULL;
+ }
+
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_undo_cleanup */
+
+/*----------------------------------------------------------------------
+ *
+ * SET: Set values
+ *
+ *---------------------------------------------------------------------*/
+/*
+ * @internal
+ * Set the value for a particular column
+ */
+NETSNMP_STATIC_INLINE int
+_tcpConnectionTable_set_column(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ netsnmp_variable_list * var, int column)
+{
+ int rc = SNMPERR_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_set_column", "called for %d\n", column));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ switch (column) {
+
+ /*
+ * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONSTATE:
+ rowreq_ctx->column_set_flags |= COLUMN_TCPCONNECTIONSTATE_FLAG;
+ rc = tcpConnectionState_set(rowreq_ctx,
+ *((u_long *) var->val.string));
+ break;
+
+ default:
+ snmp_log(LOG_ERR,
+ "unknown column %d in _tcpConnectionTable_set_column\n",
+ column);
+ rc = SNMP_ERR_GENERR;
+ break;
+ }
+
+ return rc;
+} /* _tcpConnectionTable_set_column */
+
+int
+_mfd_tcpConnectionTable_set_values(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ netsnmp_table_request_info *tri;
+ int rc = SNMP_ERR_NOERROR;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_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 = _tcpConnectionTable_set_column(rowreq_ctx,
+ requests->requestvb,
+ tri->colnum);
+ if (MFD_SUCCESS != rc) {
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_set_column\n", rc));
+ netsnmp_set_request_error(agtreq_info, requests,
+ SNMP_VALIDATE_ERR(rc));
+ }
+ } /* for results */
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_set_values */
+
+/*----------------------------------------------------------------------
+ *
+ * SET: commit
+ *
+ *---------------------------------------------------------------------*/
+/**
+ * @internal
+ * commit the values
+ */
+int
+_mfd_tcpConnectionTable_commit(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_commit", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ rc = tcpConnectionTable_commit(rowreq_ctx);
+ if (MFD_SUCCESS != rc) {
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_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...
+ */
+ tcpConnectionTable_dirty_set(tcpConnectionTable_dirty_get() + 1); /* set table dirty flag */
+ }
+
+ return SNMP_ERR_NOERROR;
+}
+
+int
+_mfd_tcpConnectionTable_undo_commit(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_undo_commit", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
+ u_int d = tcpConnectionTable_dirty_get();
+
+ netsnmp_assert(d != 0);
+ if (d)
+ tcpConnectionTable_dirty_set(d - 1);
+ }
+
+ rc = tcpConnectionTable_undo_commit(rowreq_ctx);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_undo_commit\n", rc));
+ }
+
+ if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
+ snmp_log(LOG_WARNING,
+ "tcpConnectionTable row dirty flag still set after undo_commit\n");
+ rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_commit */
+
+/*----------------------------------------------------------------------
+ *
+ * SET: Undo
+ *
+ *---------------------------------------------------------------------*/
+/**
+ * @internal
+ * undo the value for a particular column
+ */
+NETSNMP_STATIC_INLINE int
+_tcpConnectionTable_undo_column(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ netsnmp_variable_list * var, int column)
+{
+ int rc = SNMPERR_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_undo_column", "called for %d\n", column));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ switch (column) {
+
+ /*
+ * tcpConnectionState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ */
+ case COLUMN_TCPCONNECTIONSTATE:
+ rc = tcpConnectionState_undo(rowreq_ctx);
+ break;
+
+ default:
+ snmp_log(LOG_ERR,
+ "unknown column %d in _tcpConnectionTable_undo_column\n",
+ column);
+ break;
+ }
+
+ return rc;
+} /* _tcpConnectionTable_undo_column */
+
+int
+_mfd_tcpConnectionTable_undo_values(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ netsnmp_table_request_info *tri;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_undo_values", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ rc = tcpConnectionTable_undo(rowreq_ctx);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_undo\n", rc));
+ }
+
+ for (; requests; requests = requests->next) {
+ /*
+ * set column data
+ */
+ tri = netsnmp_extract_table_info(requests);
+ if (NULL == tri)
+ continue;
+
+ rc = _tcpConnectionTable_undo_column(rowreq_ctx,
+ requests->requestvb,
+ tri->colnum);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpConnectionTable:mfd", "error %d from "
+ "tcpConnectionTable_undo_column\n", rc));
+ }
+ } /* for results */
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_undo_values */
+
+/*----------------------------------------------------------------------
+ *
+ * SET: irreversible commit
+ *
+ *---------------------------------------------------------------------*/
+/**
+ * @internal
+ * commit irreversible actions
+ */
+int
+_mfd_tcpConnectionTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration
+ *reginfo, netsnmp_agent_request_info
+ *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpConnectionTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_mfd_tcpConnectionTable_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(tcpConnectionTable_if_ctx.container, rowreq_ctx);
+ } else {
+ if (rowreq_ctx->column_set_flags) {
+ rowreq_ctx->column_set_flags = 0;
+ }
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpConnectionTable_irreversible_commit */
+
+/***********************************************************************
+ *
+ * DATA ACCESS
+ *
+ ***********************************************************************/
+static void _container_free(netsnmp_container *container);
+
+/**
+ * @internal
+ */
+static int
+_cache_load(netsnmp_cache * cache, void *vmagic)
+{
+ DEBUGMSGTL(("internal:tcpConnectionTable:_cache_load", "called\n"));
+
+ if ((NULL == cache) || (NULL == cache->magic)) {
+ snmp_log(LOG_ERR,
+ "invalid cache for tcpConnectionTable_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 tcpConnectionTable_container_load((netsnmp_container *) cache->
+ magic);
+} /* _cache_load */
+
+/**
+ * @internal
+ */
+static void
+_cache_free(netsnmp_cache * cache, void *magic)
+{
+ netsnmp_container *container;
+
+ DEBUGMSGTL(("internal:tcpConnectionTable:_cache_free", "called\n"));
+
+ if ((NULL == cache) || (NULL == cache->magic)) {
+ snmp_log(LOG_ERR,
+ "invalid cache in tcpConnectionTable_cache_free\n");
+ return;
+ }
+
+ container = (netsnmp_container *) cache->magic;
+
+ _container_free(container);
+} /* _cache_free */
+
+/**
+ * @internal
+ */
+static void
+_container_item_free(tcpConnectionTable_rowreq_ctx * rowreq_ctx,
+ void *context)
+{
+ DEBUGMSGTL(("internal:tcpConnectionTable:_container_item_free",
+ "called\n"));
+
+ if (NULL == rowreq_ctx)
+ return;
+
+ tcpConnectionTable_release_rowreq_ctx(rowreq_ctx);
+} /* _container_item_free */
+
+/**
+ * @internal
+ */
+static void
+_container_free(netsnmp_container *container)
+{
+ DEBUGMSGTL(("internal:tcpConnectionTable:_container_free",
+ "called\n"));
+
+ if (NULL == container) {
+ snmp_log(LOG_ERR,
+ "invalid container in tcpConnectionTable_container_free\n");
+ return;
+ }
+
+ /*
+ * call user code
+ */
+ tcpConnectionTable_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
+_tcpConnectionTable_container_init(tcpConnectionTable_interface_ctx *
+ if_ctx)
+{
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_container_init", "called\n"));
+
+ /*
+ * cache init
+ */
+ if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */
+ _cache_load, _cache_free,
+ tcpConnectionTable_oid,
+ tcpConnectionTable_oid_size);
+
+ if (NULL == if_ctx->cache) {
+ snmp_log(LOG_ERR, "error creating cache for tcpConnectionTable\n");
+ return;
+ }
+
+ if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
+
+ tcpConnectionTable_container_init(&if_ctx->container, if_ctx->cache);
+ if (NULL == if_ctx->container)
+ if_ctx->container =
+ netsnmp_container_find("tcpConnectionTable:table_container");
+ if (NULL == if_ctx->container) {
+ snmp_log(LOG_ERR, "error creating container in "
+ "tcpConnectionTable_container_init\n");
+ return;
+ }
+
+ if (NULL != if_ctx->cache)
+ if_ctx->cache->magic = (void *) if_ctx->container;
+} /* _tcpConnectionTable_container_init */
+
+/**
+ * @internal
+ * shutdown the container with functions or wrappers
+ */
+void
+_tcpConnectionTable_container_shutdown(tcpConnectionTable_interface_ctx *
+ if_ctx)
+{
+ DEBUGMSGTL(("internal:tcpConnectionTable:_tcpConnectionTable_container_shutdown", "called\n"));
+
+ tcpConnectionTable_container_shutdown(if_ctx->container);
+
+ _container_free(if_ctx->container);
+
+} /* _tcpConnectionTable_container_shutdown */
+
+
+tcpConnectionTable_rowreq_ctx *
+tcpConnectionTable_row_find_by_mib_index(tcpConnectionTable_mib_index *
+ mib_idx)
+{
+ tcpConnectionTable_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 = tcpConnectionTable_index_to_oid(&oid_idx, mib_idx);
+ if (MFD_SUCCESS != rc)
+ return NULL;
+
+ rowreq_ctx =
+ CONTAINER_FIND(tcpConnectionTable_if_ctx.container, &oid_idx);
+
+ return rowreq_ctx;
+}
diff --git a/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.h b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.h
new file mode 100644
index 0000000..02500d1
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.h
@@ -0,0 +1,176 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.67 $ of : mfd-interface.m2c,v $
+ *
+ * $Id: tcpConnectionTable_interface.h 14169 2006-01-25 16:28:12Z dts12 $
+ */
+/** @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 TCPCONNECTIONTABLE_INTERFACE_H
+#define TCPCONNECTIONTABLE_INTERFACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "tcpConnectionTable.h"
+
+
+ /*
+ ********************************************************************
+ * Table declarations
+ */
+
+ /*
+ * PUBLIC interface initialization routine
+ */
+ void
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ _tcpConnectionTable_initialize_interface
+ (tcpConnectionTable_registration * user_ctx, u_long flags);
+ void
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ _tcpConnectionTable_shutdown_interface
+ (tcpConnectionTable_registration * user_ctx);
+
+
+
+
+
+
+
+ tcpConnectionTable_registration
+ * tcpConnectionTable_registration_get(void);
+
+
+
+
+
+
+
+ tcpConnectionTable_registration
+ * tcpConnectionTable_registration_set
+ (tcpConnectionTable_registration * newreg);
+
+ netsnmp_container *tcpConnectionTable_container_get(void);
+ int tcpConnectionTable_container_size(void);
+
+ u_int tcpConnectionTable_dirty_get(void);
+ void tcpConnectionTable_dirty_set(u_int status);
+
+
+
+
+
+
+
+ tcpConnectionTable_rowreq_ctx
+ * tcpConnectionTable_allocate_rowreq_ctx(tcpConnectionTable_data *,
+ void *);
+ void
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_release_rowreq_ctx(tcpConnectionTable_rowreq_ctx
+ * rowreq_ctx);
+
+ int tcpConnectionTable_index_to_oid(netsnmp_index *
+ oid_idx,
+ tcpConnectionTable_mib_index
+ * mib_idx);
+ int tcpConnectionTable_index_from_oid(netsnmp_index *
+ oid_idx,
+ tcpConnectionTable_mib_index
+ * mib_idx);
+
+ /*
+ * access to certain internals. use with caution!
+ */
+ void
+
+
+
+
+
+
+
+
+
+
+ tcpConnectionTable_valid_columns_set(netsnmp_column_info *vc);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TCPCONNECTIONTABLE_INTERFACE_H */
+/** @} */
+
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable.h b/agent/mibgroup/tcp-mib/tcpListenerTable.h
new file mode 100644
index 0000000..7024f79
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable.h
@@ -0,0 +1,5 @@
+/*
+ * module to include the modules
+ */
+
+config_require(tcp-mib/tcpListenerTable/tcpListenerTable)
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.c b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.c
new file mode 100644
index 0000000..3c1be1f
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.c
@@ -0,0 +1,445 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.48 $ of : mfd-top.m2c,v $
+ *
+ * $Id: tcpListenerTable.c 17861 2009-12-02 15:39:04Z jsafranek $
+ */
+/** \page MFD helper for tcpListenerTable
+ *
+ * \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 "tcpListenerTable.h"
+
+#include <net-snmp/agent/mib_modules.h>
+
+#include "tcpListenerTable_interface.h"
+
+oid tcpListenerTable_oid[] = { TCPLISTENERTABLE_OID };
+int tcpListenerTable_oid_size =
+OID_LENGTH(tcpListenerTable_oid);
+
+tcpListenerTable_registration tcpListenerTable_user_context;
+
+void initialize_table_tcpListenerTable(void);
+void shutdown_table_tcpListenerTable(void);
+
+
+/**
+ * Initializes the tcpListenerTable module
+ */
+void
+init_tcpListenerTable(void)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:init_tcpListenerTable",
+ "called\n"));
+
+ /*
+ * TODO:300:o: Perform tcpListenerTable one-time module initialization.
+ */
+
+ /*
+ * here we initialize all the tables we're planning on supporting
+ */
+ if (should_init("tcpListenerTable"))
+ initialize_table_tcpListenerTable();
+
+} /* init_tcpListenerTable */
+
+/**
+ * Shut-down the tcpListenerTable module (agent is exiting)
+ */
+void
+shutdown_tcpListenerTable(void)
+{
+ if (should_init("tcpListenerTable"))
+ shutdown_table_tcpListenerTable();
+
+}
+
+/**
+ * Initialize the table tcpListenerTable
+ * (Define its contents and how it's structured)
+ */
+void
+initialize_table_tcpListenerTable(void)
+{
+ tcpListenerTable_registration *user_context;
+ u_long flags;
+
+ DEBUGMSGTL(("verbose:tcpListenerTable:initialize_table_tcpListenerTable", "called\n"));
+
+ /*
+ * TODO:301:o: Perform tcpListenerTable one-time table initialization.
+ */
+
+ /*
+ * TODO:302:o: |->Initialize tcpListenerTable user context
+ * if you'd like to pass in a pointer to some data for this
+ * table, allocate or set it up here.
+ */
+ user_context = &tcpListenerTable_user_context;
+
+ /*
+ * No support for any flags yet, but in the future you would
+ * set any flags here.
+ */
+ flags = 0;
+
+ /*
+ * call interface initialization code
+ */
+ _tcpListenerTable_initialize_interface(user_context, flags);
+} /* initialize_table_tcpListenerTable */
+
+/**
+ * Shutdown the table tcpListenerTable
+ */
+void
+shutdown_table_tcpListenerTable(void)
+{
+ /*
+ * call interface shutdown code
+ */
+ _tcpListenerTable_shutdown_interface(&tcpListenerTable_user_context);
+}
+
+/**
+ * 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
+tcpListenerTable_rowreq_ctx_init(tcpListenerTable_rowreq_ctx * rowreq_ctx,
+ void *user_init_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_rowreq_ctx_init", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:210:o: |-> Perform extra tcpListenerTable rowreq initialization. (eg DEFVALS)
+ */
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_rowreq_ctx_init */
+
+/**
+ * extra context cleanup
+ *
+ */
+void
+tcpListenerTable_rowreq_ctx_cleanup(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_rowreq_ctx_cleanup", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:211:o: |-> Perform extra tcpListenerTable rowreq cleanup.
+ */
+ netsnmp_access_tcpconn_entry_free(rowreq_ctx->data);
+ rowreq_ctx->data = NULL;
+} /* tcpListenerTable_rowreq_ctx_cleanup */
+
+/**
+ * pre-request callback
+ *
+ *
+ * @retval MFD_SUCCESS : success.
+ * @retval MFD_ERROR : other error
+ */
+int
+tcpListenerTable_pre_request(tcpListenerTable_registration * user_context)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_pre_request",
+ "called\n"));
+
+ /*
+ * TODO:510:o: Perform tcpListenerTable pre-request actions.
+ */
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_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
+tcpListenerTable_post_request(tcpListenerTable_registration * user_context,
+ int rc)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_post_request",
+ "called\n"));
+
+ /*
+ * TODO:511:o: Perform tcpListenerTable post-request actions.
+ */
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_post_request */
+
+
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpListenerTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpListenerTable is subid 20 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.20, length: 8
+ */
+
+/*
+ * ---------------------------------------------------------------------
+ * * TODO:200:r: Implement tcpListenerTable data context functions.
+ */
+/*
+ * tcpListenerTable_allocate_data
+ *
+ * Purpose: create new tcpListenerTable_data.
+ */
+tcpListenerTable_data *
+tcpListenerTable_allocate_data(void)
+{
+ /*
+ * TODO:201:r: |-> allocate memory for the tcpListenerTable data context.
+ */
+ tcpListenerTable_data *rtn =
+ SNMP_MALLOC_TYPEDEF(tcpListenerTable_data);
+
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_allocate_data",
+ "called\n"));
+
+ if (NULL == rtn) {
+ snmp_log(LOG_ERR, "unable to malloc memory for new "
+ "tcpListenerTable_data.\n");
+ }
+
+ return rtn;
+} /* tcpListenerTable_allocate_data */
+
+/*
+ * tcpListenerTable_release_data
+ *
+ * Purpose: release tcpListenerTable data.
+ */
+void
+tcpListenerTable_release_data(tcpListenerTable_data * data)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_release_data",
+ "called\n"));
+
+ /*
+ * TODO:202:r: |-> release memory for the tcpListenerTable data context.
+ */
+ free(data);
+} /* tcpListenerTable_release_data */
+
+
+
+/**
+ * set mib index(es)
+ *
+ * @param tbl_idx mib index structure
+ * @param tcpListenerLocalAddressType_val
+ * @param tcpListenerLocalAddress_val_ptr
+ * @param tcpListenerLocalAddress_val_ptr_len
+ * @param tcpListenerLocalPort_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
+tcpListenerTable_indexes_set_tbl_idx(tcpListenerTable_mib_index * tbl_idx,
+ u_long
+ tcpListenerLocalAddressType_val,
+ char *tcpListenerLocalAddress_val_ptr,
+ size_t
+ tcpListenerLocalAddress_val_ptr_len,
+ u_long tcpListenerLocalPort_val)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_indexes_set_tbl_idx", "called\n"));
+
+ /*
+ * tcpListenerLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ if (4 == tcpListenerLocalAddressType_val)
+ tbl_idx->tcpListenerLocalAddressType = INETADDRESSTYPE_IPV4;
+ else if (16 == tcpListenerLocalAddressType_val)
+ tbl_idx->tcpListenerLocalAddressType = INETADDRESSTYPE_IPV6;
+ else
+ tbl_idx->tcpListenerLocalAddressType = INETADDRESSTYPE_UNKNOWN;
+
+ /*
+ * tcpListenerLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ tbl_idx->tcpListenerLocalAddress_len = sizeof(tbl_idx->tcpListenerLocalAddress) / sizeof(tbl_idx->tcpListenerLocalAddress[0]); /* max length */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ /*
+ * make sure there is enough space for tcpListenerLocalAddress data
+ */
+ if ((NULL == tbl_idx->tcpListenerLocalAddress) ||
+ (tbl_idx->tcpListenerLocalAddress_len <
+ (tcpListenerLocalAddress_val_ptr_len))) {
+ snmp_log(LOG_ERR, "not enough space for value\n");
+ return MFD_ERROR;
+ }
+ tbl_idx->tcpListenerLocalAddress_len =
+ tcpListenerLocalAddress_val_ptr_len;
+ memcpy(tbl_idx->tcpListenerLocalAddress,
+ tcpListenerLocalAddress_val_ptr,
+ tcpListenerLocalAddress_val_ptr_len *
+ sizeof(tcpListenerLocalAddress_val_ptr[0]));
+
+ /*
+ * tcpListenerLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ /** WARNING: this code might not work for netsnmp_tcpconn_entry */
+ tbl_idx->tcpListenerLocalPort = tcpListenerLocalPort_val;
+
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_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
+tcpListenerTable_indexes_set(tcpListenerTable_rowreq_ctx * rowreq_ctx,
+ u_long tcpListenerLocalAddressType_val,
+ char *tcpListenerLocalAddress_val_ptr,
+ size_t tcpListenerLocalAddress_val_ptr_len,
+ u_long tcpListenerLocalPort_val)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_indexes_set",
+ "called\n"));
+
+ if (MFD_SUCCESS !=
+ tcpListenerTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
+ tcpListenerLocalAddressType_val,
+ tcpListenerLocalAddress_val_ptr,
+ tcpListenerLocalAddress_val_ptr_len,
+ tcpListenerLocalPort_val))
+ return MFD_ERROR;
+
+ /*
+ * convert mib index to oid index
+ */
+ rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);
+ if (0 != tcpListenerTable_index_to_oid(&rowreq_ctx->oid_idx,
+ &rowreq_ctx->tbl_idx)) {
+ return MFD_ERROR;
+ }
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_indexes_set */
+
+
+/*---------------------------------------------------------------------
+ * TCP-MIB::tcpListenerEntry.tcpListenerProcess
+ * tcpListenerProcess is subid 4 of tcpListenerEntry.
+ * Its status is Current, and its access level is ReadOnly.
+ * OID: .1.3.6.1.2.1.6.20.1.4
+ * Description:
+The system's process ID for the process associated with
+ this listener, or zero if there is no such process. This
+ value is expected to be the same as HOST-RESOURCES-MIB::
+ hrSWRunIndex or SYSAPPL-MIB::sysApplElmtRunIndex for some
+ row in the appropriate tables.
+ *
+ * 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 tcpListenerProcess data.
+ *
+ * Set a value using the data context for the row.
+ *
+ * @param rowreq_ctx
+ * Pointer to the row request context.
+ * @param tcpListenerProcess_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
+tcpListenerProcess_get(tcpListenerTable_rowreq_ctx * rowreq_ctx,
+ u_long * tcpListenerProcess_val_ptr)
+{
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != tcpListenerProcess_val_ptr);
+
+
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerProcess_get",
+ "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ /*
+ * TODO:231:o: |-> Extract the current value of the tcpListenerProcess data.
+ * copy (* tcpListenerProcess_val_ptr ) from rowreq_ctx->data
+ */
+ (*tcpListenerProcess_val_ptr) = rowreq_ctx->data->pid;
+
+ return MFD_SUCCESS;
+} /* tcpListenerProcess_get */
+
+
+
+/** @} */
+/** @} */
+/** @{ */
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.h b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.h
new file mode 100644
index 0000000..9a96a8e
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable.h
@@ -0,0 +1,271 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.48 $ of : mfd-top.m2c,v $
+ *
+ * $Id: tcpListenerTable.h 14169 2006-01-25 16:28:12Z dts12 $
+ */
+#ifndef TCPLISTENERTABLE_H
+#define TCPLISTENERTABLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** @addtogroup misc misc: Miscellaneous routines
+ *
+ * @{
+ */
+#include <net-snmp/library/asn1.h>
+#include <net-snmp/data_access/tcpConn.h>
+
+ /*
+ * other required module components
+ */
+ /* *INDENT-OFF* */
+config_require(tcp-mib/data_access/tcpConn)
+config_require(tcp-mib/tcpListenerTable/tcpListenerTable_interface)
+config_require(tcp-mib/tcpListenerTable/tcpListenerTable_data_access)
+ /* *INDENT-ON* */
+
+ /*
+ * OID, column number and enum definions for tcpListenerTable
+ */
+#include "tcpListenerTable_constants.h"
+
+ /*
+ *********************************************************************
+ * function declarations
+ */
+ void init_tcpListenerTable(void);
+ void shutdown_tcpListenerTable(void);
+
+ /*
+ *********************************************************************
+ * Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpListenerTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpListenerTable is subid 20 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.20, 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 tcpListenerTable registration context.
+ */
+ typedef struct tListenerT_user_ctx {
+
+ void *dummy;
+
+ } tcpListenerTable_registration;
+
+/**********************************************************************/
+ /*
+ * TODO:110:r: |-> Review tcpListenerTable data context structure.
+ * This structure is used to represent the data for tcpListenerTable.
+ */
+ typedef netsnmp_tcpconn_entry tcpListenerTable_data;
+
+
+ /*
+ * TODO:120:r: |-> Review tcpListenerTable mib index.
+ * This structure is used to represent the index for tcpListenerTable.
+ */
+ typedef struct tcpListenerTable_mib_index_s {
+
+ /*
+ * tcpListenerLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ u_long tcpListenerLocalAddressType;
+
+ /*
+ * tcpListenerLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ /** 128 - 2(other indexes) - oid length(10) = 115 */
+ char tcpListenerLocalAddress[20];
+ size_t tcpListenerLocalAddress_len;
+
+ /*
+ * tcpListenerLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ u_long tcpListenerLocalPort;
+
+
+ } tcpListenerTable_mib_index;
+
+ /*
+ * TODO:121:r: | |-> Review tcpListenerTable 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_tcpListenerTable_IDX_LEN 22
+
+
+ /*
+ *********************************************************************
+ * TODO:130:o: |-> Review tcpListenerTable Row request (rowreq) context.
+ * When your functions are called, you will be passed a
+ * tcpListenerTable_rowreq_ctx pointer.
+ */
+ typedef struct tcpListenerTable_rowreq_ctx_s {
+
+ /** this must be first for container compare to work */
+ netsnmp_index oid_idx;
+ oid oid_tmp[MAX_tcpListenerTable_IDX_LEN];
+
+ tcpListenerTable_mib_index tbl_idx;
+
+ tcpListenerTable_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 tcpListenerTable rowreq context.
+ */
+
+ /*
+ * storage for future expansion
+ */
+ netsnmp_data_list *tcpListenerTable_data_list;
+
+ } tcpListenerTable_rowreq_ctx;
+
+ typedef struct tcpListenerTable_ref_rowreq_ctx_s {
+ tcpListenerTable_rowreq_ctx *rowreq_ctx;
+ } tcpListenerTable_ref_rowreq_ctx;
+
+ /*
+ *********************************************************************
+ * function prototypes
+ */
+ int
+ tcpListenerTable_pre_request(tcpListenerTable_registration *
+ user_context);
+ int
+ tcpListenerTable_post_request(tcpListenerTable_registration *
+ user_context, int rc);
+
+ int
+ tcpListenerTable_rowreq_ctx_init(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx, void *user_init_ctx);
+ void
+ tcpListenerTable_rowreq_ctx_cleanup(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx);
+
+ tcpListenerTable_data *tcpListenerTable_allocate_data(void);
+ void tcpListenerTable_release_data(tcpListenerTable_data *
+ data);
+
+ tcpListenerTable_rowreq_ctx
+ * tcpListenerTable_row_find_by_mib_index(tcpListenerTable_mib_index
+ * mib_idx);
+
+ extern oid tcpListenerTable_oid[];
+ extern int tcpListenerTable_oid_size;
+
+
+#include "tcpListenerTable_interface.h"
+#include "tcpListenerTable_data_access.h"
+ /*
+ *********************************************************************
+ * GET function declarations
+ */
+
+ /*
+ *********************************************************************
+ * GET Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpListenerTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpListenerTable is subid 20 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.20, length: 8
+ */
+ /*
+ * indexes
+ */
+
+ int tcpListenerProcess_get(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ tcpListenerProcess_val_ptr);
+
+
+ int
+ tcpListenerTable_indexes_set_tbl_idx(tcpListenerTable_mib_index *
+ tbl_idx,
+ u_long
+ tcpListenerLocalAddressType_val,
+ char
+ *tcpListenerLocalAddress_val_ptr,
+ size_t
+ tcpListenerLocalAddress_val_ptr_len,
+ u_long
+ tcpListenerLocalPort_val);
+ int
+ tcpListenerTable_indexes_set(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long
+ tcpListenerLocalAddressType_val,
+ char *tcpListenerLocalAddress_val_ptr,
+ size_t
+ tcpListenerLocalAddress_val_ptr_len,
+ u_long tcpListenerLocalPort_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 /* TCPLISTENERTABLE_H */
+/** @} */
+
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_constants.h b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_constants.h
new file mode 100644
index 0000000..fd9939e
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_constants.h
@@ -0,0 +1,78 @@
+/*
+ * 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: tcpListenerTable_constants.h 13787 2005-12-02 18:05:59Z rstory $
+ */
+#ifndef TCPLISTENERTABLE_CONSTANTS_H
+#define TCPLISTENERTABLE_CONSTANTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /*
+ * column number definitions for table tcpListenerTable
+ */
+#define TCPLISTENERTABLE_OID 1,3,6,1,2,1,6,20
+
+#define COLUMN_TCPLISTENERLOCALADDRESSTYPE 1
+
+#define COLUMN_TCPLISTENERLOCALADDRESS 2
+
+#define COLUMN_TCPLISTENERLOCALPORT 3
+
+#define COLUMN_TCPLISTENERPROCESS 4
+
+
+#define TCPLISTENERTABLE_MIN_COL COLUMN_TCPLISTENERPROCESS
+#define TCPLISTENERTABLE_MAX_COL COLUMN_TCPLISTENERPROCESS
+
+
+ /*
+ * 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 tcpListenerTable
+ *
+ *************************************************************************
+ *************************************************************************/
+
+/*************************************************************
+ * constants for enums for the MIB node
+ * tcpListenerLocalAddressType (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 */
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TCPLISTENERTABLE_OIDS_H */
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.c b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.c
new file mode 100644
index 0000000..d41c0d7
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.c
@@ -0,0 +1,320 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.17 $ of : mfd-data-access.m2c,v $
+ *
+ * $Id: tcpListenerTable_data_access.c 17861 2009-12-02 15:39:04Z jsafranek $
+ */
+/*
+ * 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 "tcpListenerTable.h"
+
+
+#include "tcpListenerTable_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 tcpListenerTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpListenerTable is subid 20 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.20, length: 8
+ */
+
+/**
+ * initialization for tcpListenerTable data access
+ *
+ * This function is called during startup to allow you to
+ * allocate any resources you need for the data table.
+ *
+ * @param tcpListenerTable_reg
+ * Pointer to tcpListenerTable_registration
+ *
+ * @retval MFD_SUCCESS : success.
+ * @retval MFD_ERROR : unrecoverable error.
+ */
+int
+tcpListenerTable_init_data(tcpListenerTable_registration *
+ tcpListenerTable_reg)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_init_data",
+ "called\n"));
+
+ /*
+ * TODO:303:o: Initialize tcpListenerTable data.
+ */
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_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
+tcpListenerTable_container_init(netsnmp_container **container_ptr_ptr,
+ netsnmp_cache * cache)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_container_init",
+ "called\n"));
+
+ if (NULL == container_ptr_ptr) {
+ snmp_log(LOG_ERR,
+ "bad container param to tcpListenerTable_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 tcpListenerTable_container_init\n");
+ return;
+ }
+
+ /*
+ * TODO:345:A: Set up tcpListenerTable 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 = TCPLISTENERTABLE_CACHE_TIMEOUT; /* seconds */
+ cache->flags |= NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
+} /* tcpListenerTable_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 tcpListenerTable_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
+tcpListenerTable_container_shutdown(netsnmp_container *container_ptr)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_container_shutdown", "called\n"));
+
+ if (NULL == container_ptr) {
+ snmp_log(LOG_ERR,
+ "bad params to tcpListenerTable_container_shutdown\n");
+ return;
+ }
+
+} /* tcpListenerTable_container_shutdown */
+
+/**
+ * add new entry
+ */
+static void
+_add_connection(netsnmp_tcpconn_entry *entry, netsnmp_container *container)
+{
+ tcpListenerTable_rowreq_ctx *rowreq_ctx;
+
+ DEBUGMSGTL(("tcpListenerTable:access", "creating new entry\n"));
+
+ /*
+ * allocate an row context and set the index(es), then add it to
+ * the container
+ */
+ rowreq_ctx = tcpListenerTable_allocate_rowreq_ctx(entry, NULL);
+ if ((NULL != rowreq_ctx) &&
+ (MFD_SUCCESS == tcpListenerTable_indexes_set(rowreq_ctx,
+ entry->loc_addr_len,
+ entry->loc_addr,
+ entry->loc_addr_len,
+ entry->loc_port))) {
+ CONTAINER_INSERT(container, rowreq_ctx);
+ } else {
+ if (rowreq_ctx) {
+ snmp_log(LOG_ERR, "error setting index while loading "
+ "tcpListenerTable cache.\n");
+ tcpListenerTable_release_rowreq_ctx(rowreq_ctx);
+ } else {
+ snmp_log(LOG_ERR, "memory allocation failed while loading "
+ "tcpListenerTable cache.\n");
+ netsnmp_access_tcpconn_entry_free(entry);
+ }
+ }
+}
+
+/**
+ * load initial data
+ *
+ * TODO:350:M: Implement tcpListenerTable 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
+ * tcpListenerTable_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
+tcpListenerTable_container_load(netsnmp_container *container)
+{
+ netsnmp_container *raw_data =
+ netsnmp_access_tcpconn_container_load(NULL,
+ NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN);
+
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_container_load",
+ "called\n"));
+
+ if (NULL == raw_data)
+ return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */
+
+ /*
+ * got all the connections. pull out the active ones.
+ */
+ CONTAINER_FOR_EACH(raw_data, (netsnmp_container_obj_func *)
+ _add_connection, container);
+
+ /*
+ * free the container. we've either claimed each entry, or released it,
+ * so the dal function doesn't need to clear the container.
+ */
+ netsnmp_access_tcpconn_container_free(raw_data,
+ NETSNMP_ACCESS_TCPCONN_FREE_DONT_CLEAR);
+
+ DEBUGMSGT(("verbose:tcpListenerTable:tcpListenerTable_cache_load",
+ "%d records\n", CONTAINER_SIZE(container)));
+
+ return MFD_SUCCESS;
+} /* tcpListenerTable_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
+tcpListenerTable_container_free(netsnmp_container *container)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_container_free",
+ "called\n"));
+
+ /*
+ * TODO:380:M: Free tcpListenerTable container data.
+ */
+} /* tcpListenerTable_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
+tcpListenerTable_row_prep(tcpListenerTable_rowreq_ctx * rowreq_ctx)
+{
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_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;
+} /* tcpListenerTable_row_prep */
+
+/** @} */
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.h b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.h
new file mode 100644
index 0000000..3ec2e4c
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.h
@@ -0,0 +1,73 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.17 $ of : mfd-data-access.m2c,v $
+ *
+ * $Id: tcpListenerTable_data_access.h 13787 2005-12-02 18:05:59Z rstory $
+ */
+#ifndef TCPLISTENERTABLE_DATA_ACCESS_H
+#define TCPLISTENERTABLE_DATA_ACCESS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /*
+ *********************************************************************
+ * function declarations
+ */
+
+ /*
+ *********************************************************************
+ * Table declarations
+ */
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpListenerTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+ /*
+ * TCP-MIB::tcpListenerTable is subid 20 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.20, length: 8
+ */
+
+
+ int
+ tcpListenerTable_init_data(tcpListenerTable_registration *
+ tcpListenerTable_reg);
+
+
+ /*
+ * TODO:180:o: Review tcpListenerTable cache timeout.
+ * The number of seconds before the cache times out
+ */
+#define TCPLISTENERTABLE_CACHE_TIMEOUT 60
+
+ void tcpListenerTable_container_init(netsnmp_container
+ **container_ptr_ptr,
+ netsnmp_cache * cache);
+ void tcpListenerTable_container_shutdown(netsnmp_container
+ *container_ptr);
+
+ int tcpListenerTable_container_load(netsnmp_container
+ *container);
+ void tcpListenerTable_container_free(netsnmp_container
+ *container);
+
+ int tcpListenerTable_cache_load(netsnmp_container
+ *container);
+ void tcpListenerTable_cache_free(netsnmp_container
+ *container);
+
+ int tcpListenerTable_row_prep(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TCPLISTENERTABLE_DATA_ACCESS_H */
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c
new file mode 100644
index 0000000..78c4b6a
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c
@@ -0,0 +1,981 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.67 $ of : mfd-interface.m2c,v $
+ *
+ * $Id: tcpListenerTable_interface.c 15015 2006-08-17 15:06:43Z rstory $
+ */
+/*
+ * *********************************************************************
+ * *********************************************************************
+ * *********************************************************************
+ * *** ***
+ * *** 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-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+
+/*
+ * include our parent header
+ */
+#include "tcpListenerTable.h"
+
+
+#include <net-snmp/agent/table_container.h>
+#include <net-snmp/library/container.h>
+
+#include "tcpListenerTable_interface.h"
+
+#include <ctype.h>
+
+/**********************************************************************
+ **********************************************************************
+ ***
+ *** Table tcpListenerTable
+ ***
+ **********************************************************************
+ **********************************************************************/
+/*
+ * TCP-MIB::tcpListenerTable is subid 20 of tcp.
+ * Its status is Current.
+ * OID: .1.3.6.1.2.1.6.20, length: 8
+ */
+typedef struct tcpListenerTable_interface_ctx_s {
+
+ netsnmp_container *container;
+ netsnmp_cache *cache;
+
+ tcpListenerTable_registration *user_ctx;
+
+ netsnmp_table_registration_info tbl_info;
+
+ netsnmp_baby_steps_access_methods access_multiplexer;
+
+} tcpListenerTable_interface_ctx;
+
+static tcpListenerTable_interface_ctx tcpListenerTable_if_ctx;
+
+static void
+ _tcpListenerTable_container_init(tcpListenerTable_interface_ctx * if_ctx);
+static void
+ _tcpListenerTable_container_shutdown(tcpListenerTable_interface_ctx *
+ if_ctx);
+
+
+netsnmp_container *
+tcpListenerTable_container_get(void)
+{
+ return tcpListenerTable_if_ctx.container;
+}
+
+tcpListenerTable_registration *
+tcpListenerTable_registration_get(void)
+{
+ return tcpListenerTable_if_ctx.user_ctx;
+}
+
+tcpListenerTable_registration *
+tcpListenerTable_registration_set(tcpListenerTable_registration * newreg)
+{
+ tcpListenerTable_registration *old = tcpListenerTable_if_ctx.user_ctx;
+ tcpListenerTable_if_ctx.user_ctx = newreg;
+ return old;
+}
+
+int
+tcpListenerTable_container_size(void)
+{
+ return CONTAINER_SIZE(tcpListenerTable_if_ctx.container);
+}
+
+/*
+ * mfd multiplexer modes
+ */
+static Netsnmp_Node_Handler _mfd_tcpListenerTable_pre_request;
+static Netsnmp_Node_Handler _mfd_tcpListenerTable_post_request;
+static Netsnmp_Node_Handler _mfd_tcpListenerTable_object_lookup;
+static Netsnmp_Node_Handler _mfd_tcpListenerTable_get_values;
+/**
+ * @internal
+ * Initialize the table tcpListenerTable
+ * (Define its contents and how it's structured)
+ */
+void
+_tcpListenerTable_initialize_interface(tcpListenerTable_registration *
+ reg_ptr, u_long flags)
+{
+ netsnmp_baby_steps_access_methods *access_multiplexer =
+ &tcpListenerTable_if_ctx.access_multiplexer;
+ netsnmp_table_registration_info *tbl_info =
+ &tcpListenerTable_if_ctx.tbl_info;
+ netsnmp_handler_registration *reginfo;
+ netsnmp_mib_handler *handler;
+ int mfd_modes = 0;
+
+ DEBUGMSGTL(("internal:tcpListenerTable:_tcpListenerTable_initialize_interface", "called\n"));
+
+
+ /*************************************************
+ *
+ * save interface context for tcpListenerTable
+ */
+ /*
+ * Setting up the table's definition
+ */
+ netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
+ /** index: tcpListenerLocalAddressType */
+ ASN_OCTET_STR,
+ /** index: tcpListenerLocalAddress */
+ ASN_UNSIGNED,
+ /** index: tcpListenerLocalPort */
+ 0);
+
+ /*
+ * Define the minimum and maximum accessible columns. This
+ * optimizes retrival.
+ */
+ tbl_info->min_column = TCPLISTENERTABLE_MIN_COL;
+ tbl_info->max_column = TCPLISTENERTABLE_MAX_COL;
+
+ /*
+ * save users context
+ */
+ tcpListenerTable_if_ctx.user_ctx = reg_ptr;
+
+ /*
+ * call data access initialization code
+ */
+ tcpListenerTable_init_data(reg_ptr);
+
+ /*
+ * set up the container
+ */
+ _tcpListenerTable_container_init(&tcpListenerTable_if_ctx);
+ if (NULL == tcpListenerTable_if_ctx.container) {
+ snmp_log(LOG_ERR,
+ "could not initialize container for tcpListenerTable\n");
+ return;
+ }
+
+ /*
+ * access_multiplexer: REQUIRED wrapper for get request handling
+ */
+ access_multiplexer->object_lookup =
+ _mfd_tcpListenerTable_object_lookup;
+ access_multiplexer->get_values = _mfd_tcpListenerTable_get_values;
+
+ /*
+ * no wrappers yet
+ */
+ access_multiplexer->pre_request = _mfd_tcpListenerTable_pre_request;
+ access_multiplexer->post_request = _mfd_tcpListenerTable_post_request;
+
+
+ /*************************************************
+ *
+ * Create a registration, save our reg data, register table.
+ */
+ DEBUGMSGTL(("tcpListenerTable:init_tcpListenerTable",
+ "Registering tcpListenerTable as a mibs-for-dummies table.\n"));
+ handler =
+ netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
+ reginfo =
+ netsnmp_handler_registration_create("tcpListenerTable", handler,
+ tcpListenerTable_oid,
+ tcpListenerTable_oid_size,
+ HANDLER_CAN_BABY_STEP |
+ HANDLER_CAN_RONLY);
+ if (NULL == reginfo) {
+ snmp_log(LOG_ERR, "error registering table tcpListenerTable\n");
+ return;
+ }
+ reginfo->my_reg_void = &tcpListenerTable_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->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->pre_request)
+ mfd_modes |= BABY_STEP_PRE_REQUEST;
+ if (access_multiplexer->post_request)
+ mfd_modes |= BABY_STEP_POST_REQUEST;
+
+ 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;
+
+ 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,
+ tcpListenerTable_if_ctx.
+ container,
+ TABLE_CONTAINER_KEY_NETSNMP_INDEX);
+ netsnmp_inject_handler(reginfo, handler);
+
+ /*************************************************
+ *
+ * inject cache helper
+ */
+ if (NULL != tcpListenerTable_if_ctx.cache) {
+ handler = netsnmp_cache_handler_get(tcpListenerTable_if_ctx.cache);
+ netsnmp_inject_handler(reginfo, handler);
+ }
+
+ /*
+ * register table
+ */
+ netsnmp_register_table(reginfo, tbl_info);
+
+} /* _tcpListenerTable_initialize_interface */
+
+/**
+ * @internal
+ * Shutdown the table tcpListenerTable
+ */
+void
+_tcpListenerTable_shutdown_interface(tcpListenerTable_registration *
+ reg_ptr)
+{
+ /*
+ * shutdown the container
+ */
+ _tcpListenerTable_container_shutdown(&tcpListenerTable_if_ctx);
+}
+
+void
+tcpListenerTable_valid_columns_set(netsnmp_column_info *vc)
+{
+ tcpListenerTable_if_ctx.tbl_info.valid_columns = vc;
+} /* tcpListenerTable_valid_columns_set */
+
+/**
+ * @internal
+ * convert the index component stored in the context to an oid
+ */
+int
+tcpListenerTable_index_to_oid(netsnmp_index * oid_idx,
+ tcpListenerTable_mib_index * mib_idx)
+{
+ int err = SNMP_ERR_NOERROR;
+
+ /*
+ * temp storage for parsing indexes
+ */
+ /*
+ * tcpListenerLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ netsnmp_variable_list var_tcpListenerLocalAddressType;
+ /*
+ * tcpListenerLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ netsnmp_variable_list var_tcpListenerLocalAddress;
+ /*
+ * tcpListenerLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ netsnmp_variable_list var_tcpListenerLocalPort;
+
+ /*
+ * set up varbinds
+ */
+ memset(&var_tcpListenerLocalAddressType, 0x00,
+ sizeof(var_tcpListenerLocalAddressType));
+ var_tcpListenerLocalAddressType.type = ASN_INTEGER;
+ memset(&var_tcpListenerLocalAddress, 0x00,
+ sizeof(var_tcpListenerLocalAddress));
+ var_tcpListenerLocalAddress.type = ASN_OCTET_STR;
+ memset(&var_tcpListenerLocalPort, 0x00,
+ sizeof(var_tcpListenerLocalPort));
+ var_tcpListenerLocalPort.type = ASN_UNSIGNED;
+
+ /*
+ * chain temp index varbinds together
+ */
+ var_tcpListenerLocalAddressType.next_variable =
+ &var_tcpListenerLocalAddress;
+ var_tcpListenerLocalAddress.next_variable = &var_tcpListenerLocalPort;
+ var_tcpListenerLocalPort.next_variable = NULL;
+
+
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_index_to_oid",
+ "called\n"));
+
+ /*
+ * tcpListenerLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ snmp_set_var_value(&var_tcpListenerLocalAddressType,
+ (u_char *) & mib_idx->tcpListenerLocalAddressType,
+ sizeof(mib_idx->tcpListenerLocalAddressType));
+
+ /*
+ * tcpListenerLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ snmp_set_var_value(&var_tcpListenerLocalAddress,
+ (u_char *) & mib_idx->tcpListenerLocalAddress,
+ mib_idx->tcpListenerLocalAddress_len *
+ sizeof(mib_idx->tcpListenerLocalAddress[0]));
+
+ /*
+ * tcpListenerLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ snmp_set_var_value(&var_tcpListenerLocalPort,
+ (u_char *) & mib_idx->tcpListenerLocalPort,
+ sizeof(mib_idx->tcpListenerLocalPort));
+
+
+ err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
+ NULL, 0, &var_tcpListenerLocalAddressType);
+ 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_tcpListenerLocalAddressType);
+
+ return err;
+} /* tcpListenerTable_index_to_oid */
+
+/**
+ * extract tcpListenerTable indexes from a netsnmp_index
+ *
+ * @retval SNMP_ERR_NOERROR : no error
+ * @retval SNMP_ERR_GENERR : error
+ */
+int
+tcpListenerTable_index_from_oid(netsnmp_index * oid_idx,
+ tcpListenerTable_mib_index * mib_idx)
+{
+ int err = SNMP_ERR_NOERROR;
+
+ /*
+ * temp storage for parsing indexes
+ */
+ /*
+ * tcpListenerLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
+ */
+ netsnmp_variable_list var_tcpListenerLocalAddressType;
+ /*
+ * tcpListenerLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
+ */
+ netsnmp_variable_list var_tcpListenerLocalAddress;
+ /*
+ * tcpListenerLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
+ */
+ netsnmp_variable_list var_tcpListenerLocalPort;
+
+ /*
+ * set up varbinds
+ */
+ memset(&var_tcpListenerLocalAddressType, 0x00,
+ sizeof(var_tcpListenerLocalAddressType));
+ var_tcpListenerLocalAddressType.type = ASN_INTEGER;
+ memset(&var_tcpListenerLocalAddress, 0x00,
+ sizeof(var_tcpListenerLocalAddress));
+ var_tcpListenerLocalAddress.type = ASN_OCTET_STR;
+ memset(&var_tcpListenerLocalPort, 0x00,
+ sizeof(var_tcpListenerLocalPort));
+ var_tcpListenerLocalPort.type = ASN_UNSIGNED;
+
+ /*
+ * chain temp index varbinds together
+ */
+ var_tcpListenerLocalAddressType.next_variable =
+ &var_tcpListenerLocalAddress;
+ var_tcpListenerLocalAddress.next_variable = &var_tcpListenerLocalPort;
+ var_tcpListenerLocalPort.next_variable = NULL;
+
+
+ DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_index_from_oid",
+ "called\n"));
+
+ /*
+ * parse the oid into the individual index components
+ */
+ err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
+ &var_tcpListenerLocalAddressType);
+ if (err == SNMP_ERR_NOERROR) {
+ /*
+ * copy out values
+ */
+ mib_idx->tcpListenerLocalAddressType =
+ *((u_long *) var_tcpListenerLocalAddressType.val.string);
+ /*
+ * NOTE: val_len is in bytes, tcpListenerLocalAddress_len might not be
+ */
+ if (var_tcpListenerLocalAddress.val_len >
+ sizeof(mib_idx->tcpListenerLocalAddress))
+ err = SNMP_ERR_GENERR;
+ else {
+ memcpy(mib_idx->tcpListenerLocalAddress,
+ var_tcpListenerLocalAddress.val.string,
+ var_tcpListenerLocalAddress.val_len);
+ mib_idx->tcpListenerLocalAddress_len =
+ var_tcpListenerLocalAddress.val_len /
+ sizeof(mib_idx->tcpListenerLocalAddress[0]);
+ }
+ mib_idx->tcpListenerLocalPort =
+ *((u_long *) var_tcpListenerLocalPort.val.string);
+
+
+ }
+
+ /*
+ * parsing may have allocated memory. free it.
+ */
+ snmp_reset_var_buffers(&var_tcpListenerLocalAddressType);
+
+ return err;
+} /* tcpListenerTable_index_from_oid */
+
+
+/*
+ *********************************************************************
+ * @internal
+ * allocate resources for a tcpListenerTable_rowreq_ctx
+ */
+tcpListenerTable_rowreq_ctx *
+tcpListenerTable_allocate_rowreq_ctx(tcpListenerTable_data * data,
+ void *user_init_ctx)
+{
+ tcpListenerTable_rowreq_ctx *rowreq_ctx =
+ SNMP_MALLOC_TYPEDEF(tcpListenerTable_rowreq_ctx);
+
+ DEBUGMSGTL(("internal:tcpListenerTable:tcpListenerTable_allocate_rowreq_ctx", "called\n"));
+
+ if (NULL == rowreq_ctx) {
+ snmp_log(LOG_ERR, "Couldn't allocate memory for a "
+ "tcpListenerTable_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 = tcpListenerTable_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->tcpListenerTable_data_list = NULL;
+
+ /*
+ * if we allocated data, call init routine
+ */
+ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
+ if (SNMPERR_SUCCESS !=
+ tcpListenerTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
+ tcpListenerTable_release_rowreq_ctx(rowreq_ctx);
+ rowreq_ctx = NULL;
+ }
+ }
+
+ return rowreq_ctx;
+} /* tcpListenerTable_allocate_rowreq_ctx */
+
+/*
+ * @internal
+ * release resources for a tcpListenerTable_rowreq_ctx
+ */
+void
+tcpListenerTable_release_rowreq_ctx(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx)
+{
+ DEBUGMSGTL(("internal:tcpListenerTable:tcpListenerTable_release_rowreq_ctx", "called\n"));
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ tcpListenerTable_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))
+ tcpListenerTable_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);
+} /* tcpListenerTable_release_rowreq_ctx */
+
+/**
+ * @internal
+ * wrapper
+ */
+static int
+_mfd_tcpListenerTable_pre_request(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ int rc;
+
+ DEBUGMSGTL(("internal:tcpListenerTable:_mfd_tcpListenerTable_pre_request", "called\n"));
+
+ if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
+ DEBUGMSGTL(("internal:tcpListenerTable",
+ "skipping additional pre_request\n"));
+ return SNMP_ERR_NOERROR;
+ }
+
+ rc = tcpListenerTable_pre_request(tcpListenerTable_if_ctx.user_ctx);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpListenerTable", "error %d from "
+ "tcpListenerTable_pre_request\n", rc));
+ netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpListenerTable_pre_request */
+
+/**
+ * @internal
+ * wrapper
+ */
+static int
+_mfd_tcpListenerTable_post_request(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpListenerTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+ int rc, packet_rc;
+
+ DEBUGMSGTL(("internal:tcpListenerTable:_mfd_tcpListenerTable_post_request", "called\n"));
+
+ /*
+ * release row context, if deleted
+ */
+ if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
+ tcpListenerTable_release_rowreq_ctx(rowreq_ctx);
+
+ /*
+ * wait for last call before calling user
+ */
+ if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
+ DEBUGMSGTL(("internal:tcpListenerTable",
+ "waiting for last post_request\n"));
+ return SNMP_ERR_NOERROR;
+ }
+
+ packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
+ rc = tcpListenerTable_post_request(tcpListenerTable_if_ctx.user_ctx,
+ packet_rc);
+ if (MFD_SUCCESS != rc) {
+ /*
+ * nothing we can do about it but log it
+ */
+ DEBUGMSGTL(("tcpListenerTable", "error %d from "
+ "tcpListenerTable_post_request\n", rc));
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_tcpListenerTable_post_request */
+
+/**
+ * @internal
+ * wrapper
+ */
+static int
+_mfd_tcpListenerTable_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;
+ tcpListenerTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract(requests);
+
+ DEBUGMSGTL(("internal:tcpListenerTable:_mfd_tcpListenerTable_object_lookup", "called\n"));
+
+ /*
+ * get our context from mfd
+ * tcpListenerTable_interface_ctx *if_ctx =
+ * (tcpListenerTable_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
+ tcpListenerTable_row_prep(rowreq_ctx);
+
+ return SNMP_VALIDATE_ERR(rc);
+} /* _mfd_tcpListenerTable_object_lookup */
+
+/***********************************************************************
+ *
+ * GET processing
+ *
+ ***********************************************************************/
+/*
+ * @internal
+ * Retrieve the value for a particular column
+ */
+NETSNMP_STATIC_INLINE int
+_tcpListenerTable_get_column(tcpListenerTable_rowreq_ctx * rowreq_ctx,
+ netsnmp_variable_list * var, int column)
+{
+ int rc = SNMPERR_SUCCESS;
+
+ DEBUGMSGTL(("internal:tcpListenerTable:_mfd_tcpListenerTable_get_column", "called for %d\n", column));
+
+
+ netsnmp_assert(NULL != rowreq_ctx);
+
+ switch (column) {
+
+ /*
+ * tcpListenerProcess(4)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h
+ */
+ case COLUMN_TCPLISTENERPROCESS:
+ var->val_len = sizeof(u_long);
+ var->type = ASN_UNSIGNED;
+ rc = tcpListenerProcess_get(rowreq_ctx,
+ (u_long *) var->val.string);
+ break;
+
+ default:
+ snmp_log(LOG_ERR,
+ "unknown column %d in _tcpListenerTable_get_column\n",
+ column);
+ break;
+ }
+
+ return rc;
+} /* _tcpListenerTable_get_column */
+
+int
+_mfd_tcpListenerTable_get_values(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *agtreq_info,
+ netsnmp_request_info *requests)
+{
+ tcpListenerTable_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:tcpListenerTable:_mfd_tcpListenerTable_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 = _tcpListenerTable_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_tcpListenerTable_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:tcpListenerTable:_cache_load", "called\n"));
+
+ if ((NULL == cache) || (NULL == cache->magic)) {
+ snmp_log(LOG_ERR,
+ "invalid cache for tcpListenerTable_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 tcpListenerTable_container_load((netsnmp_container *) cache->
+ magic);
+} /* _cache_load */
+
+/**
+ * @internal
+ */
+static void
+_cache_free(netsnmp_cache * cache, void *magic)
+{
+ netsnmp_container *container;
+
+ DEBUGMSGTL(("internal:tcpListenerTable:_cache_free", "called\n"));
+
+ if ((NULL == cache) || (NULL == cache->magic)) {
+ snmp_log(LOG_ERR,
+ "invalid cache in tcpListenerTable_cache_free\n");
+ return;
+ }
+
+ container = (netsnmp_container *) cache->magic;
+
+ _container_free(container);
+} /* _cache_free */
+
+/**
+ * @internal
+ */
+static void
+_container_item_free(tcpListenerTable_rowreq_ctx * rowreq_ctx,
+ void *context)
+{
+ DEBUGMSGTL(("internal:tcpListenerTable:_container_item_free",
+ "called\n"));
+
+ if (NULL == rowreq_ctx)
+ return;
+
+ tcpListenerTable_release_rowreq_ctx(rowreq_ctx);
+} /* _container_item_free */
+
+/**
+ * @internal
+ */
+static void
+_container_free(netsnmp_container *container)
+{
+ DEBUGMSGTL(("internal:tcpListenerTable:_container_free", "called\n"));
+
+ if (NULL == container) {
+ snmp_log(LOG_ERR,
+ "invalid container in tcpListenerTable_container_free\n");
+ return;
+ }
+
+ /*
+ * call user code
+ */
+ tcpListenerTable_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
+_tcpListenerTable_container_init(tcpListenerTable_interface_ctx * if_ctx)
+{
+ DEBUGMSGTL(("internal:tcpListenerTable:_tcpListenerTable_container_init", "called\n"));
+
+ /*
+ * cache init
+ */
+ if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */
+ _cache_load, _cache_free,
+ tcpListenerTable_oid,
+ tcpListenerTable_oid_size);
+
+ if (NULL == if_ctx->cache) {
+ snmp_log(LOG_ERR, "error creating cache for tcpListenerTable\n");
+ return;
+ }
+
+ if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
+
+ tcpListenerTable_container_init(&if_ctx->container, if_ctx->cache);
+ if (NULL == if_ctx->container)
+ if_ctx->container =
+ netsnmp_container_find("tcpListenerTable:table_container");
+ if (NULL == if_ctx->container) {
+ snmp_log(LOG_ERR, "error creating container in "
+ "tcpListenerTable_container_init\n");
+ return;
+ }
+
+ if (NULL != if_ctx->cache)
+ if_ctx->cache->magic = (void *) if_ctx->container;
+} /* _tcpListenerTable_container_init */
+
+/**
+ * @internal
+ * shutdown the container with functions or wrappers
+ */
+void
+_tcpListenerTable_container_shutdown(tcpListenerTable_interface_ctx *
+ if_ctx)
+{
+ DEBUGMSGTL(("internal:tcpListenerTable:_tcpListenerTable_container_shutdown", "called\n"));
+
+ tcpListenerTable_container_shutdown(if_ctx->container);
+
+ _container_free(if_ctx->container);
+
+} /* _tcpListenerTable_container_shutdown */
+
+
+tcpListenerTable_rowreq_ctx *
+tcpListenerTable_row_find_by_mib_index(tcpListenerTable_mib_index *
+ mib_idx)
+{
+ tcpListenerTable_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 = tcpListenerTable_index_to_oid(&oid_idx, mib_idx);
+ if (MFD_SUCCESS != rc)
+ return NULL;
+
+ rowreq_ctx =
+ CONTAINER_FIND(tcpListenerTable_if_ctx.container, &oid_idx);
+
+ return rowreq_ctx;
+}
diff --git a/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.h b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.h
new file mode 100644
index 0000000..dca6996
--- /dev/null
+++ b/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.h
@@ -0,0 +1,98 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * version : 1.67 $ of : mfd-interface.m2c,v $
+ *
+ * $Id: tcpListenerTable_interface.h 14169 2006-01-25 16:28:12Z dts12 $
+ */
+/** @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 TCPLISTENERTABLE_INTERFACE_H
+#define TCPLISTENERTABLE_INTERFACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "tcpListenerTable.h"
+
+
+ /*
+ ********************************************************************
+ * Table declarations
+ */
+
+ /*
+ * PUBLIC interface initialization routine
+ */
+ void
+ _tcpListenerTable_initialize_interface
+ (tcpListenerTable_registration * user_ctx, u_long flags);
+ void
+ _tcpListenerTable_shutdown_interface(tcpListenerTable_registration
+ * user_ctx);
+
+ tcpListenerTable_registration *tcpListenerTable_registration_get(void);
+
+ tcpListenerTable_registration
+ * tcpListenerTable_registration_set(tcpListenerTable_registration *
+ newreg);
+
+ netsnmp_container *tcpListenerTable_container_get(void);
+ int tcpListenerTable_container_size(void);
+
+ tcpListenerTable_rowreq_ctx
+ * tcpListenerTable_allocate_rowreq_ctx(tcpListenerTable_data *,
+ void *);
+ void
+ tcpListenerTable_release_rowreq_ctx(tcpListenerTable_rowreq_ctx *
+ rowreq_ctx);
+
+ int tcpListenerTable_index_to_oid(netsnmp_index * oid_idx,
+ tcpListenerTable_mib_index
+ * mib_idx);
+ int tcpListenerTable_index_from_oid(netsnmp_index *
+ oid_idx,
+ tcpListenerTable_mib_index
+ * mib_idx);
+
+ /*
+ * access to certain internals. use with caution!
+ */
+ void tcpListenerTable_valid_columns_set(netsnmp_column_info
+ *vc);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TCPLISTENERTABLE_INTERFACE_H */
+/** @} */
+