diff --git a/README.SuSE b/README.SuSE index d896d37..307f9bf 100644 --- a/README.SuSE +++ b/README.SuSE @@ -7,39 +7,41 @@ SNMP access (161/udp,162/udp) be blocked at your firewall. There are also some important changes that have been made in this release of our package: - o the daemon now sets a PID file in /var/run/ - o logging is now done directly to /var/log/net-snmp.log instead - of sending stderr/stdout through syslog. If you don't want logging, - remove the '-l /var/log/net-snmp.log' from /etc/init.d/snmpd. + o the daemon now sets a PID file in /var/run/ - o the daemon is now started with the '-r'. This option prevents - snmpd from exiting if it doesn't have permission to read something. - This only occurs if you start snmpd on a high port as a non-root - root user. + o logging is now done directly to /var/log/net-snmp.log instead + of sending stderr/stdout through syslog. If you don't want logging, + remove the '-l /var/log/net-snmp.log' from /etc/init.d/snmpd. - o If you need to run snmptrapd, we've provided an example init - script in /usr/share/doc/packages/net-snmp/rc.snmptrapd. SNMP - traps should be avoided whenever possible because they are - unreliable (you should poll with snmpget instead) and snmptrapd - has been the source of many of the security problems with snmp - so please don't run this unless you are sure of what you are doing. - To install the script, - cp rc.snmptrapd /etc/init.d/snmptrapd - innserv /etc/init.d/snmptrapd - cd /usr/sbin && ln -s ../../etc/init.d/snmptrapd . - and create a configuration file named /etc/snmptrapd.conf. Then, - start the daemon with - rcsnmptrapd start - Logging is done to /var/log/net-snmptrapd.log. + o the daemon is now started with the '-r'. This option prevents + snmpd from exiting if it doesn't have permission to read something. + This only occurs if you start snmpd on a high port as a non-root + root user. - o Master agentx support is enabled if you have modules in - /usr/lib/net-snmp/--the domain socket is created as - /var/run/agentx/master. You can change this to a network - interface if needed (see snmpd(1)). The snmpd init script - automatically detects and starts any sub-agents in placed into - /var/lib/net-snmp. + o If you need to run snmptrapd, we've provided an example init + script in /usr/share/doc/packages/net-snmp/rc.snmptrapd. SNMP + traps should be avoided whenever possible because they are + unreliable (you should poll with snmpget instead) and snmptrapd + has been the source of many of the security problems with snmp + so please don't run this unless you are sure of what you are doing. + To install the script, + install rc.snmptrapd /etc/init.d/snmptrapd + chkconfig snmptrapd on + ln -s ../../etc/init.d/snmptrapd /usr/sbin/rcsnmptrapd. + and create a configuration file named /etc/snmp/snmptrapd.conf. Then, + start the daemon with + rcsnmptrapd start + Logging is done to /var/log/net-snmptrapd.log. + + For more informations see the manpages for snmptrapd and snmptrapd.conf. + + o Master agentx support is enabled if you have modules in + /usr/lib/net-snmp/--the domain socket is created as + /var/run/agentx/master. You can change this to a network + interface if needed (see snmpd(1)). The snmpd init script + automatically detects and starts any sub-agents in placed into + /var/lib/net-snmp. More documentation on the net-snmp package can be found in this directory -as well as the project's homepage: http://net-snmp.sourceforge.net/ - +as well as the project's homepage: http://www.net-snmp.org/ diff --git a/net-snmp-5.4.1.2-etherlike-mib-revised_2.patch b/net-snmp-5.4.1.2-etherlike-mib-revised_4.patch similarity index 93% rename from net-snmp-5.4.1.2-etherlike-mib-revised_2.patch rename to net-snmp-5.4.1.2-etherlike-mib-revised_4.patch index 383b264..e2b7e6d 100644 --- a/net-snmp-5.4.1.2-etherlike-mib-revised_2.patch +++ b/net-snmp-5.4.1.2-etherlike-mib-revised_4.patch @@ -1,231 +1,18 @@ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable.c 2008-11-21 14:49:15.697017950 +0100 -@@ -0,0 +1,212 @@ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/data_access/dot3stats.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/data_access/dot3stats.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/data_access/dot3stats.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/data_access/dot3stats.h 2008-12-21 05:19:52.000000000 -0500 +@@ -0,0 +1,7 @@ +/* -+ * Note: this file originally auto-generated by mib2c using -+ * version : 14170 $ of $ -+ * -+ * $Id:$ ++ * module to include the modules + */ -+/** \page MFD helper for dot3StatsTable -+ * -+ * \section intro Introduction -+ * Introductory text. -+ * -+ */ -+/* -+ * standard Net-SNMP includes -+ */ -+#include -+#include -+#include + -+/* -+ * include our parent header -+ */ -+#include "dot3StatsTable.h" -+ -+#include -+ -+#include "dot3StatsTable_interface.h" -+ -+oid dot3StatsTable_oid[] = { DOT3STATSTABLE_OID }; -+int dot3StatsTable_oid_size = OID_LENGTH(dot3StatsTable_oid); -+ -+dot3StatsTable_registration dot3StatsTable_user_context; -+ -+void initialize_table_dot3StatsTable(void); -+void shutdown_table_dot3StatsTable(void); -+ -+ -+/** -+ * Initializes the dot3StatsTable module -+ */ -+void -+init_dot3StatsTable(void) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:init_dot3StatsTable", "called\n")); -+ -+ /* -+ * TODO:300:o: Perform dot3StatsTable one-time module initialization. -+ */ -+ -+ /* -+ * here we initialize all the tables we're planning on supporting -+ */ -+ if (should_init("dot3StatsTable")) -+ initialize_table_dot3StatsTable(); -+ -+} /* init_dot3StatsTable */ -+ -+/** -+ * Shut-down the dot3StatsTable module (agent is exiting) -+ */ -+void -+shutdown_dot3StatsTable(void) -+{ -+ if (should_init("dot3StatsTable")) -+ shutdown_table_dot3StatsTable(); -+ -+} -+ -+/** -+ * Initialize the table dot3StatsTable -+ * (Define its contents and how it's structured) -+ */ -+void -+initialize_table_dot3StatsTable(void) -+{ -+ dot3StatsTable_registration *user_context; -+ u_long flags; -+ -+ DEBUGMSGTL(("verbose:dot3StatsTable:initialize_table_dot3StatsTable", -+ "called\n")); -+ -+ /* -+ * TODO:301:o: Perform dot3StatsTable one-time table initialization. -+ */ -+ -+ /* -+ * TODO:302:o: |->Initialize dot3StatsTable user context -+ * if you'd like to pass in a pointer to some data for this -+ * table, allocate or set it up here. -+ */ -+ /* -+ * a netsnmp_data_list is a simple way to store void pointers. A simple -+ * string token is used to add, find or remove pointers. -+ */ -+ user_context = netsnmp_create_data_list("dot3StatsTable", NULL, NULL); -+ -+ /* -+ * No support for any flags yet, but in the future you would -+ * set any flags here. -+ */ -+ flags = 0; -+ -+ /* -+ * call interface initialization code -+ */ -+ _dot3StatsTable_initialize_interface(user_context, flags); -+} /* initialize_table_dot3StatsTable */ -+ -+/** -+ * Shutdown the table dot3StatsTable -+ */ -+void -+shutdown_table_dot3StatsTable(void) -+{ -+ /* -+ * call interface shutdown code -+ */ -+ _dot3StatsTable_shutdown_interface(&dot3StatsTable_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 -+dot3StatsTable_rowreq_ctx_init(dot3StatsTable_rowreq_ctx * rowreq_ctx, -+ void *user_init_ctx) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_rowreq_ctx_init", -+ "called\n")); -+ -+ netsnmp_assert(NULL != rowreq_ctx); -+ -+ /* -+ * TODO:210:o: |-> Perform extra dot3StatsTable rowreq initialization. (eg DEFVALS) -+ */ -+ -+ return MFD_SUCCESS; -+} /* dot3StatsTable_rowreq_ctx_init */ -+ -+/** -+ * extra context cleanup -+ * -+ */ -+void -+dot3StatsTable_rowreq_ctx_cleanup(dot3StatsTable_rowreq_ctx * rowreq_ctx) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_rowreq_ctx_cleanup", -+ "called\n")); -+ -+ netsnmp_assert(NULL != rowreq_ctx); -+ -+ /* -+ * TODO:211:o: |-> Perform extra dot3StatsTable rowreq cleanup. -+ */ -+} /* dot3StatsTable_rowreq_ctx_cleanup */ -+ -+/** -+ * pre-request callback -+ * -+ * -+ * @retval MFD_SUCCESS : success. -+ * @retval MFD_ERROR : other error -+ */ -+int -+dot3StatsTable_pre_request(dot3StatsTable_registration * user_context) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_pre_request", -+ "called\n")); -+ -+ /* -+ * TODO:510:o: Perform dot3StatsTable pre-request actions. -+ */ -+ -+ return MFD_SUCCESS; -+} /* dot3StatsTable_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 -+dot3StatsTable_post_request(dot3StatsTable_registration * user_context, -+ int rc) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_post_request", -+ "called\n")); -+ -+ /* -+ * TODO:511:o: Perform dot3StatsTable post-request actions. -+ */ -+ -+ return MFD_SUCCESS; -+} /* dot3StatsTable_post_request */ -+ -+ -+/** @{ */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c 2008-11-21 14:49:15.713015508 +0100 -@@ -0,0 +1,793 @@ -+/* -+ * Note: this file originally auto-generated by mib2c using -+ * version : 14170 $ of $ -+ * -+ * $Id:$ -+ */ ++#if defined(linux) ++config_require(etherlike-mib/data_access/dot3stats_linux) ++#endif +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c 2008-12-21 05:35:33.000000000 -0500 +@@ -0,0 +1,397 @@ +/* + * standard Net-SNMP includes + */ @@ -237,344 +24,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c +/* + * include our parent header + */ -+#include "dot3StatsTable.h" -+ -+ -+#include "dot3StatsTable_data_access.h" -+#include "ioctl_imp_common.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 dot3StatsTable -+ *** -+ ********************************************************************** -+ **********************************************************************/ -+/* -+ * EtherLike-MIB::dot3StatsTable is subid 2 of dot3. -+ * Its status is Current. -+ * OID: .1.3.6.1.2.1.10.7.2, length: 9 -+ */ -+ -+/** -+ * initialization for dot3StatsTable data access -+ * -+ * This function is called during startup to allow you to -+ * allocate any resources you need for the data table. -+ * -+ * @param dot3StatsTable_reg -+ * Pointer to dot3StatsTable_registration -+ * -+ * @retval MFD_SUCCESS : success. -+ * @retval MFD_ERROR : unrecoverable error. -+ */ -+int -+dot3StatsTable_init_data(dot3StatsTable_registration * dot3StatsTable_reg) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_init_data", -+ "called\n")); -+ -+ /* -+ * TODO:303:o: Initialize dot3StatsTable data. -+ */ -+ -+ return MFD_SUCCESS; -+} /* dot3StatsTable_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 -+dot3StatsTable_container_init(netsnmp_container ** container_ptr_ptr, -+ netsnmp_cache * cache) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_init", -+ "called\n")); -+ -+ if (NULL == container_ptr_ptr) { -+ snmp_log(LOG_ERR, -+ "bad container param to dot3StatsTable_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 dot3StatsTable_container_init\n"); -+ return; -+ } -+ -+ /* -+ * TODO:345:A: Set up dot3StatsTable 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 = DOT3STATSTABLE_CACHE_TIMEOUT; /* seconds */ -+} /* dot3StatsTable_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 dot3StatsTable_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 -+dot3StatsTable_container_shutdown(netsnmp_container * container_ptr) -+{ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_shutdown", -+ "called\n")); -+ -+ if (NULL == container_ptr) { -+ snmp_log(LOG_ERR, -+ "bad params to dot3StatsTable_container_shutdown\n"); -+ return; -+ } -+ -+} /* dot3StatsTable_container_shutdown */ -+ -+/** -+ * load initial data -+ * -+ * TODO:350:M: Implement dot3StatsTable 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 -+ * dot3StatsTable_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. -+ * -+ */ -+ -+/* -+ * -+ * @retval MFD_SUCCESS success -+ * @retval MFD_ERROR could not get the interface names -+ * @retval MFD_RESOURCE_UNAVAILABLE failed to allocate memory -+ * @retval -2 could not open a socket -+ */ -+ -+ -+int -+dot3StatsTable_container_load(netsnmp_container * container) -+{ -+ dot3StatsTable_rowreq_ctx *rowreq_ctx; -+ size_t count = 0; -+ -+ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_load", -+ "called\n")); -+ -+ /* -+ * TODO:352:M: | |-> set indexes in new dot3StatsTable rowreq context. -+ * data context will be set from the param (unless NULL, -+ * in which case a new data context will be allocated) -+ */ -+ -+ /* -+ * temporary storage for index values -+ */ -+ -+ /* -+ * dot3StatsIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H -+ */ -+ -+ long dot3StatsIndex; -+ int fd; -+ int rc = 0, retval = 0; -+ struct ifname *list_head = NULL, *p = NULL; -+ -+ -+ /* -+ * create socket for ioctls -+ */ -+ -+ fd = socket(AF_INET, SOCK_DGRAM, 0); -+ if(fd < 0) { -+ snmp_log(LOG_ERR, "could not create socket\n"); -+ return -2; -+ } -+ -+ /* -+ * get the interface names of the devices present in the system, in case of failure retval suggests the reson for failure -+ * and list_head contains null -+ */ -+ -+ list_head = interface_name_list_get (list_head, &retval); -+ -+ if (!list_head) { -+ snmp_log (LOG_ERR, "access:dot3StatsTable, error getting the interface names present in the system\n"); -+ DEBUGMSGTL(("access:dot3StatsTable", "error getting the interface names present in the system")); -+ return MFD_ERROR; -+ } -+ -+ /* -+ * Walk over the list of interface names present in the system and retreive the statistics -+ */ -+ -+ for (p = list_head; p; p = p->ifn_next) { -+ u_int flags; -+ -+ flags = 0; -+ -+ DEBUGMSGTL(("access:dot3StatsTable", "processing '%s'\n", p->name)); -+ -+ /* -+ * get index via ioctl. -+ */ -+ -+ dot3StatsIndex = (long) interface_ioctl_ifindex_get(-1, p->name); -+ -+ /* -+ * get the dot3stats contents populated, if the device is not an ethernet device -+ * the operation will not be supported and an error message will be logged -+ */ -+ -+ rowreq_ctx = dot3StatsTable_allocate_rowreq_ctx(NULL); -+ if (NULL == rowreq_ctx) { -+ snmp_log(LOG_ERR, "memory allocation for dot3StatsTable failed\n"); -+ return MFD_RESOURCE_UNAVAILABLE; -+ } -+ -+ if (MFD_SUCCESS != -+ dot3StatsTable_indexes_set(rowreq_ctx, dot3StatsIndex)) { -+ snmp_log(LOG_ERR, -+ "error setting index while loading " -+ "dot3StatsTable data.\n"); -+ dot3StatsTable_release_rowreq_ctx(rowreq_ctx); -+ continue; -+ } -+ -+ /* -+ * TODO:352:r: | |-> populate dot3StatsTable data context. -+ * Populate data context here. (optionally, delay until row prep) -+ */ -+ /* -+ * non-TRANSIENT data: no need to copy. set pointer to data -+ */ -+ -+ memset (&rowreq_ctx->data, 0, sizeof (rowreq_ctx->data)); -+ rc = interface_ioctl_dot3stats_get (rowreq_ctx, fd, p->name); -+ -+ if (rc < 0) { -+ snmp_log(LOG_ERR, -+ "error getting the statistics for interface |%s| " -+ "dot3StatsTable data, operation might not be supported\n", p->name); -+ DEBUGMSGTL(("access:dot3StatsTable", "error getting the statistics for interface |%s| " -+ "dot3StatsTable data, operation might not be supported\n", p->name)); -+ dot3StatsTable_release_rowreq_ctx(rowreq_ctx); -+ continue; -+ } -+ -+ rc = interface_ioctl_dot3stats_duplex_get(rowreq_ctx, fd, p->name); -+ if (rc < 0) { -+ snmp_log(LOG_ERR, -+ "error getting the duplex status for |%s| " -+ "dot3StatsTable data, operation might not be supported\n", p->name); -+ DEBUGMSGTL(("access:dot3StatsTable", "error getting the duplex status for |%s| " -+ "dot3StatsTable data, operation might not be supported\n", p->name)); -+ dot3StatsTable_release_rowreq_ctx(rowreq_ctx); -+ continue; -+ } -+ -+ /* -+ * insert into table container -+ */ -+ CONTAINER_INSERT(container, rowreq_ctx); -+ ++count; -+ } -+ -+ -+ /* -+ * free the interface names list -+ */ -+ -+ if ( (interface_name_list_free(list_head)) < 0) { -+ snmp_log(LOG_ERR, "access:dot3StatsTable, error freeing the interface name list \n"); -+ DEBUGMSGTL(("access:dot3StatsTable", "error freeing the interface name list\n")); -+ return MFD_ERROR; -+ } -+ -+ -+ DEBUGMSGT(("verbose:dot3StatsTable:dot3StatsTable_container_load", -+ "inserted %d records\n", count)); -+ -+ return MFD_SUCCESS; -+} ++#include "etherlike-mib/dot3StatsTable/dot3StatsTable.h" ++#include "etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.h" ++#include "etherlike-mib/dot3StatsTable/ioctl_imp_common.h" + +/* + * @retval 0 success @@ -582,8 +34,8 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c + * @retval -2 memory allocation failed + */ + -+static struct ifname * -+interface_name_list_get (struct ifname *list_head, int *retval) ++struct ifname * ++dot3stats_interface_name_list_get (struct ifname *list_head, int *retval) +{ + struct ifaddrs *addrs = NULL, *p = NULL; + struct ifname *nameptr1=NULL, *nameptr2 = NULL; @@ -647,8 +99,8 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c + * @retval -1 invalid pointer + */ + -+static int -+interface_name_list_free (struct ifname *list_head) ++int ++dot3stats_interface_name_list_free (struct ifname *list_head) +{ + struct ifname *nameptr1 = NULL, *nameptr2 = NULL; + @@ -675,8 +127,8 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c + * @retval !0 : ifIndex + */ + -+static int -+interface_ioctl_ifindex_get (int fd, const char *name) { ++int ++dot3stats_interface_ioctl_ifindex_get (int fd, const char *name) { +#ifndef SIOCGIFINDEX + return 0; +#else @@ -911,7 +363,7 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c + * @retval -2 : couldn't create socket + * @retval -3 : ioctl call failed + */ -+static int ++int +_dot3Stats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name) +{ + int ourfd = -1, rc = 0; @@ -956,7 +408,585 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c + + return rc; +} -+ /* dot3StatsTable_container_load */ ++ ++ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.c net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.c +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.c 2008-08-08 05:58:09.000000000 -0400 +@@ -0,0 +1,212 @@ ++/* ++ * Note: this file originally auto-generated by mib2c using ++ * version : 14170 $ of $ ++ * ++ * $Id:$ ++ */ ++/** \page MFD helper for dot3StatsTable ++ * ++ * \section intro Introduction ++ * Introductory text. ++ * ++ */ ++/* ++ * standard Net-SNMP includes ++ */ ++#include ++#include ++#include ++ ++/* ++ * include our parent header ++ */ ++#include "dot3StatsTable.h" ++ ++#include ++ ++#include "dot3StatsTable_interface.h" ++ ++oid dot3StatsTable_oid[] = { DOT3STATSTABLE_OID }; ++int dot3StatsTable_oid_size = OID_LENGTH(dot3StatsTable_oid); ++ ++dot3StatsTable_registration dot3StatsTable_user_context; ++ ++void initialize_table_dot3StatsTable(void); ++void shutdown_table_dot3StatsTable(void); ++ ++ ++/** ++ * Initializes the dot3StatsTable module ++ */ ++void ++init_dot3StatsTable(void) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:init_dot3StatsTable", "called\n")); ++ ++ /* ++ * TODO:300:o: Perform dot3StatsTable one-time module initialization. ++ */ ++ ++ /* ++ * here we initialize all the tables we're planning on supporting ++ */ ++ if (should_init("dot3StatsTable")) ++ initialize_table_dot3StatsTable(); ++ ++} /* init_dot3StatsTable */ ++ ++/** ++ * Shut-down the dot3StatsTable module (agent is exiting) ++ */ ++void ++shutdown_dot3StatsTable(void) ++{ ++ if (should_init("dot3StatsTable")) ++ shutdown_table_dot3StatsTable(); ++ ++} ++ ++/** ++ * Initialize the table dot3StatsTable ++ * (Define its contents and how it's structured) ++ */ ++void ++initialize_table_dot3StatsTable(void) ++{ ++ dot3StatsTable_registration *user_context; ++ u_long flags; ++ ++ DEBUGMSGTL(("verbose:dot3StatsTable:initialize_table_dot3StatsTable", ++ "called\n")); ++ ++ /* ++ * TODO:301:o: Perform dot3StatsTable one-time table initialization. ++ */ ++ ++ /* ++ * TODO:302:o: |->Initialize dot3StatsTable user context ++ * if you'd like to pass in a pointer to some data for this ++ * table, allocate or set it up here. ++ */ ++ /* ++ * a netsnmp_data_list is a simple way to store void pointers. A simple ++ * string token is used to add, find or remove pointers. ++ */ ++ user_context = netsnmp_create_data_list("dot3StatsTable", NULL, NULL); ++ ++ /* ++ * No support for any flags yet, but in the future you would ++ * set any flags here. ++ */ ++ flags = 0; ++ ++ /* ++ * call interface initialization code ++ */ ++ _dot3StatsTable_initialize_interface(user_context, flags); ++} /* initialize_table_dot3StatsTable */ ++ ++/** ++ * Shutdown the table dot3StatsTable ++ */ ++void ++shutdown_table_dot3StatsTable(void) ++{ ++ /* ++ * call interface shutdown code ++ */ ++ _dot3StatsTable_shutdown_interface(&dot3StatsTable_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 ++dot3StatsTable_rowreq_ctx_init(dot3StatsTable_rowreq_ctx * rowreq_ctx, ++ void *user_init_ctx) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_rowreq_ctx_init", ++ "called\n")); ++ ++ netsnmp_assert(NULL != rowreq_ctx); ++ ++ /* ++ * TODO:210:o: |-> Perform extra dot3StatsTable rowreq initialization. (eg DEFVALS) ++ */ ++ ++ return MFD_SUCCESS; ++} /* dot3StatsTable_rowreq_ctx_init */ ++ ++/** ++ * extra context cleanup ++ * ++ */ ++void ++dot3StatsTable_rowreq_ctx_cleanup(dot3StatsTable_rowreq_ctx * rowreq_ctx) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_rowreq_ctx_cleanup", ++ "called\n")); ++ ++ netsnmp_assert(NULL != rowreq_ctx); ++ ++ /* ++ * TODO:211:o: |-> Perform extra dot3StatsTable rowreq cleanup. ++ */ ++} /* dot3StatsTable_rowreq_ctx_cleanup */ ++ ++/** ++ * pre-request callback ++ * ++ * ++ * @retval MFD_SUCCESS : success. ++ * @retval MFD_ERROR : other error ++ */ ++int ++dot3StatsTable_pre_request(dot3StatsTable_registration * user_context) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_pre_request", ++ "called\n")); ++ ++ /* ++ * TODO:510:o: Perform dot3StatsTable pre-request actions. ++ */ ++ ++ return MFD_SUCCESS; ++} /* dot3StatsTable_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 ++dot3StatsTable_post_request(dot3StatsTable_registration * user_context, ++ int rc) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_post_request", ++ "called\n")); ++ ++ /* ++ * TODO:511:o: Perform dot3StatsTable post-request actions. ++ */ ++ ++ return MFD_SUCCESS; ++} /* dot3StatsTable_post_request */ ++ ++ ++/** @{ */ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.c net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.c +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.c 2009-01-12 03:38:21.000000000 -0500 +@@ -0,0 +1,413 @@ ++/* ++ * Note: this file originally auto-generated by mib2c using ++ * version : 14170 $ of $ ++ * ++ * $Id:$ ++ */ ++/* ++ * standard Net-SNMP includes ++ */ ++ ++#include ++#include ++#include ++ ++/* ++ * include our parent header ++ */ ++#include "dot3StatsTable.h" ++#include "dot3StatsTable_data_access.h" ++ ++#if defined(linux) ++#include "ioctl_imp_common.h" ++#endif ++ ++/** @ingroup interface ++ * @addtogroup data_access data_access: Routines to access data ++ * ++ * These routines are used to locate the data used to satisfy ++ * requests. ++ * ++ * @{ ++ */ ++/********************************************************************** ++ ********************************************************************** ++ *** ++ *** Table dot3StatsTable ++ *** ++ ********************************************************************** ++ **********************************************************************/ ++/* ++ * EtherLike-MIB::dot3StatsTable is subid 2 of dot3. ++ * Its status is Current. ++ * OID: .1.3.6.1.2.1.10.7.2, length: 9 ++ */ ++ ++/** ++ * initialization for dot3StatsTable data access ++ * ++ * This function is called during startup to allow you to ++ * allocate any resources you need for the data table. ++ * ++ * @param dot3StatsTable_reg ++ * Pointer to dot3StatsTable_registration ++ * ++ * @retval MFD_SUCCESS : success. ++ * @retval MFD_ERROR : unrecoverable error. ++ */ ++int ++dot3StatsTable_init_data(dot3StatsTable_registration * dot3StatsTable_reg) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_init_data", ++ "called\n")); ++ ++ /* ++ * TODO:303:o: Initialize dot3StatsTable data. ++ */ ++ ++ return MFD_SUCCESS; ++} /* dot3StatsTable_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 ++dot3StatsTable_container_init(netsnmp_container ** container_ptr_ptr, ++ netsnmp_cache * cache) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_init", ++ "called\n")); ++ ++ if (NULL == container_ptr_ptr) { ++ snmp_log(LOG_ERR, ++ "bad container param to dot3StatsTable_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 dot3StatsTable_container_init\n"); ++ return; ++ } ++ ++ /* ++ * TODO:345:A: Set up dot3StatsTable 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 = DOT3STATSTABLE_CACHE_TIMEOUT; /* seconds */ ++} /* dot3StatsTable_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 dot3StatsTable_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 ++dot3StatsTable_container_shutdown(netsnmp_container * container_ptr) ++{ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_shutdown", ++ "called\n")); ++ ++ if (NULL == container_ptr) { ++ snmp_log(LOG_ERR, ++ "bad params to dot3StatsTable_container_shutdown\n"); ++ return; ++ } ++ ++} /* dot3StatsTable_container_shutdown */ ++ ++/** ++ * load initial data ++ * ++ * TODO:350:M: Implement dot3StatsTable 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 ++ * dot3StatsTable_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. ++ * ++ */ ++ ++/* ++ * ++ * @retval MFD_SUCCESS success ++ * @retval MFD_ERROR could not get the interface names ++ * @retval MFD_RESOURCE_UNAVAILABLE failed to allocate memory ++ * @retval -2 could not open a socket ++ */ ++ ++ ++int ++dot3StatsTable_container_load(netsnmp_container * container) ++{ ++ dot3StatsTable_rowreq_ctx *rowreq_ctx; ++ size_t count = 0; ++ ++ DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_load", ++ "called\n")); ++ ++ /* ++ * TODO:352:M: | |-> set indexes in new dot3StatsTable rowreq context. ++ * data context will be set from the param (unless NULL, ++ * in which case a new data context will be allocated) ++ */ ++ ++ /* ++ * temporary storage for index values ++ */ ++ ++ /* ++ * dot3StatsIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H ++ */ ++ ++ long dot3StatsIndex; ++ int fd; ++ int rc = 0, retval = 0; ++ ++#if defined(linux) ++ struct ifname *list_head = NULL, *p = NULL; ++#endif ++ ++ /* ++ * create socket for ioctls ++ */ ++ ++ fd = socket(AF_INET, SOCK_DGRAM, 0); ++ if(fd < 0) { ++ snmp_log(LOG_ERR, "could not create socket\n"); ++ return -2; ++ } ++ ++ /* ++ * get the interface names of the devices present in the system, in case of failure retval suggests the reson for failure ++ * and list_head contains null ++ */ ++ ++#if defined(linux) ++ list_head = dot3stats_interface_name_list_get (list_head, &retval); ++ ++ if (!list_head) { ++ snmp_log (LOG_ERR, "access:dot3StatsTable, error getting the interface names present in the system\n"); ++ DEBUGMSGTL(("access:dot3StatsTable", "error getting the interface names present in the system")); ++ return MFD_ERROR; ++ } ++ ++ /* ++ * Walk over the list of interface names present in the system and retreive the statistics ++ */ ++ ++ for (p = list_head; p; p = p->ifn_next) { ++ u_int flags; ++ ++ flags = 0; ++ ++ DEBUGMSGTL(("access:dot3StatsTable", "processing '%s'\n", p->name)); ++ ++ /* ++ * get index via ioctl. ++ */ ++ ++ dot3StatsIndex = (long) dot3stats_interface_ioctl_ifindex_get(-1, p->name); ++ ++ /* ++ * get the dot3stats contents populated, if the device is not an ethernet device ++ * the operation will not be supported and an error message will be logged ++ */ ++ ++ rowreq_ctx = dot3StatsTable_allocate_rowreq_ctx(NULL); ++ if (NULL == rowreq_ctx) { ++ snmp_log(LOG_ERR, "memory allocation for dot3StatsTable failed\n"); ++ return MFD_RESOURCE_UNAVAILABLE; ++ } ++ ++ if (MFD_SUCCESS != ++ dot3StatsTable_indexes_set(rowreq_ctx, dot3StatsIndex)) { ++ snmp_log(LOG_ERR, ++ "error setting index while loading " ++ "dot3StatsTable data.\n"); ++ dot3StatsTable_release_rowreq_ctx(rowreq_ctx); ++ continue; ++ } ++ ++ /* ++ * TODO:352:r: | |-> populate dot3StatsTable data context. ++ * Populate data context here. (optionally, delay until row prep) ++ */ ++ /* ++ * non-TRANSIENT data: no need to copy. set pointer to data ++ */ ++ ++ memset (&rowreq_ctx->data, 0, sizeof (rowreq_ctx->data)); ++ rc = interface_ioctl_dot3stats_get (rowreq_ctx, fd, p->name); ++ ++ if (rc < 0) { ++ snmp_log(LOG_ERR, ++ "error getting the statistics for interface |%s| " ++ "dot3StatsTable data, operation might not be supported\n", p->name); ++ DEBUGMSGTL(("access:dot3StatsTable", "error getting the statistics for interface |%s| " ++ "dot3StatsTable data, operation might not be supported\n", p->name)); ++ dot3StatsTable_release_rowreq_ctx(rowreq_ctx); ++ continue; ++ } ++ ++ rc = interface_ioctl_dot3stats_duplex_get(rowreq_ctx, fd, p->name); ++ if (rc < 0) { ++ snmp_log(LOG_ERR, ++ "error getting the duplex status for |%s| " ++ "dot3StatsTable data, operation might not be supported\n", p->name); ++ DEBUGMSGTL(("access:dot3StatsTable", "error getting the duplex status for |%s| " ++ "dot3StatsTable data, operation might not be supported\n", p->name)); ++ dot3StatsTable_release_rowreq_ctx(rowreq_ctx); ++ continue; ++ } ++ ++ /* ++ * insert into table container ++ */ ++ CONTAINER_INSERT(container, rowreq_ctx); ++ ++count; ++ } ++ ++ /* ++ * free the interface names list ++ */ ++ ++ if ( (dot3stats_interface_name_list_free(list_head)) < 0) { ++ snmp_log(LOG_ERR, "access:dot3StatsTable, error freeing the interface name list \n"); ++ DEBUGMSGTL(("access:dot3StatsTable", "error freeing the interface name list\n")); ++ return MFD_ERROR; ++ } ++#endif ++ ++ DEBUGMSGT(("verbose:dot3StatsTable:dot3StatsTable_container_load", ++ "inserted %d records\n", count)); ++ ++ return MFD_SUCCESS; ++} /* dot3StatsTable_container_load */ + +/** + * container clean up @@ -1013,10 +1043,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.c +} /* dot3StatsTable_row_prep */ + +/** @} */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.h 2008-11-21 14:49:15.729015387 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_access.h 2008-08-31 10:26:33.000000000 -0400 @@ -0,0 +1,74 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -1092,10 +1121,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_access.h +} +#endif +#endif /* DOT3STATSTABLE_DATA_ACCESS_H */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_get.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_data_get.c 2008-11-21 14:49:15.746371333 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.c net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.c +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.c 2008-08-11 13:28:29.000000000 -0400 @@ -0,0 +1,1450 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2547,10 +2575,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_get.c + + +/** @} */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_get.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_data_get.h 2008-11-21 14:49:15.812233418 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_get.h 2008-08-08 05:58:09.000000000 -0400 @@ -0,0 +1,143 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2695,10 +2722,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_get.h +#endif +#endif /* DOT3STATSTABLE_DATA_GET_H */ +/** @} */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_set.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_data_set.c 2008-11-21 14:49:15.821015201 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.c net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.c +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.c 2008-08-08 05:58:09.000000000 -0400 @@ -0,0 +1,28 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2728,10 +2754,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_set.c + * @{ + */ +/** @} */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_set.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_data_set.h 2008-11-21 14:49:15.837015420 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_data_set.h 2008-08-08 05:58:09.000000000 -0400 @@ -0,0 +1,28 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2761,10 +2786,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_data_set.h +} +#endif +#endif /* DOT3STATSTABLE_DATA_SET_H */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_enums.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_enums.h 2008-11-21 14:49:15.854950134 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_enums.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_enums.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_enums.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_enums.h 2008-08-08 05:58:09.000000000 -0400 @@ -0,0 +1,89 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2855,10 +2879,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_enums.h +} +#endif +#endif /* DOT3STATSTABLE_ENUMS_H */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable.h 2008-11-21 14:49:15.871679425 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable.h 2008-09-09 12:09:11.000000000 -0400 @@ -0,0 +1,271 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -3131,10 +3154,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable.h +#endif +#endif /* DOT3STATSTABLE_H */ +/** @} */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_interface.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_interface.c 2008-11-21 14:49:15.889030395 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.c net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.c +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.c 2008-09-12 14:18:46.000000000 -0400 @@ -0,0 +1,1188 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -4324,10 +4346,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_interface.c + + return rowreq_ctx; +} -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_interface.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_interface.h 2008-11-21 14:49:15.930132856 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_interface.h 2008-08-08 05:58:09.000000000 -0400 @@ -0,0 +1,94 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -4423,10 +4444,9 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_interface.h +#endif +#endif /* DOT3STATSTABLE_INTERFACE_H */ +/** @} */ -Index: agent/mibgroup/etherlike-mib/dot3StatsTable_oids.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/dot3StatsTable_oids.h 2008-11-21 14:49:15.946860586 +0100 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_oids.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_oids.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_oids.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/dot3StatsTable_oids.h 2008-08-23 11:43:41.000000000 -0400 @@ -0,0 +1,82 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -4510,11 +4530,10 @@ Index: agent/mibgroup/etherlike-mib/dot3StatsTable_oids.h +} +#endif +#endif /* DOT3STATSTABLE_OIDS_H */ -Index: agent/mibgroup/etherlike-mib/ioctl_imp_common.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib/ioctl_imp_common.h 2008-11-21 14:49:15.963587994 +0100 -@@ -0,0 +1,71 @@ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/ioctl_imp_common.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/ioctl_imp_common.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable/ioctl_imp_common.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable/ioctl_imp_common.h 2009-01-05 01:41:44.000000000 -0500 +@@ -0,0 +1,65 @@ +#include +#include +#include @@ -4538,35 +4557,38 @@ Index: agent/mibgroup/etherlike-mib/ioctl_imp_common.h + char name [IF_NAMESIZE]; +}; + -+static struct ifname *interface_name_list_get (struct ifname *, int *); -+static int interface_name_list_free (struct ifname *list_head); -+static int interface_ioctl_ifindex_get (int fd, const char *name); -+static int _dot3Stats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name); ++struct ifname *dot3stats_interface_name_list_get (struct ifname *, int *); ++int dot3stats_interface_name_list_free (struct ifname *list_head); ++int dot3stats_interface_ioctl_ifindex_get (int fd, const char *name); ++int _dot3Stats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name); +int interface_ioctl_dot3stats_get(dot3StatsTable_rowreq_ctx *rowreq_ctx, int fd, const char* name); +int interface_ioctl_dot3stats_duplex_get(dot3StatsTable_rowreq_ctx *rowreq_ctx, int fd, const char* name); + + +/* for maintainability */ + -+#define INTEL_RECEIVE_ALIGN_ERRORS "rx_align_errors" -+#define BROADCOM_RECEIVE_ALIGN_ERRORS INTEL_RECEIVE_ALIGN_ERRORS ++#define INTEL_RECEIVE_ALIGN_ERRORS "rx_align_errors" ++#define BROADCOM_RECEIVE_ALIGN_ERRORS INTEL_RECEIVE_ALIGN_ERRORS + -+#define INTEL_TRANSMIT_MULTIPLE_COLLISIONS "tx_multi_coll_ok" -+#define BROADCOM_TRANSMIT_MULTIPLE_COLLISIONS "tx_multi_collisions" ++#define INTEL_TRANSMIT_MULTIPLE_COLLISIONS "tx_multi_coll_ok" ++#define BROADCOM_TRANSMIT_MULTIPLE_COLLISIONS_BNX2 "tx_multi_collisions" ++#define BROADCOM_TRANSMIT_MULTIPLE_COLLISIONS_TG3 "tx_mult_collisions" + -+#define INTEL_TRANSMIT_LATE_COLLISIONS "tx_abort_late_coll" -+#define BROADCOM_TRANSMIT_LATE_COLLISIONS "tx_late_collisions" ++#define INTEL_TRANSMIT_LATE_COLLISIONS "tx_abort_late_coll" ++#define BROADCOM_TRANSMIT_LATE_COLLISIONS "tx_late_collisions" + -+#define INTEL_TRANSMIT_SINGLE_COLLISIONS "tx_single_coll_ok" -+#define BROADCOM_TRANSMIT_SINGLE_COLLISIONS "tx_single_collisions" ++#define INTEL_TRANSMIT_SINGLE_COLLISIONS "tx_single_coll_ok" ++#define BROADCOM_TRANSMIT_SINGLE_COLLISIONS "tx_single_collisions" + -+#define BROADCOM_TRANSMIT_EXCESS_COLLISIONS "tx_excess_collisions" ++#define BROADCOM_TRANSMIT_EXCESS_COLLISIONS_BNX2 "tx_excess_collisions" ++#define BROADCOM_TRANSMIT_EXCESS_COLLISIONS_TG3 "tx_excessive_collisions" + + +#define DOT3STATSALIGNMENTERRORS(x) strstr(x, INTEL_RECEIVE_ALIGN_ERRORS) + +#define DOT3STATSMULTIPLECOLLISIONFRAMES(x) (strstr(x, INTEL_TRANSMIT_MULTIPLE_COLLISIONS)) || \ -+ (strstr(x, BROADCOM_TRANSMIT_MULTIPLE_COLLISIONS)) ++ (strstr(x, BROADCOM_TRANSMIT_MULTIPLE_COLLISIONS_BNX2)) || \ ++ (strstr(x, BROADCOM_TRANSMIT_MULTIPLE_COLLISIONS_TG3)) + +#define DOT3STATSLATECOLLISIONS(x) (strstr(x, INTEL_TRANSMIT_LATE_COLLISIONS)) || \ + (strstr(x, BROADCOM_TRANSMIT_LATE_COLLISIONS)) @@ -4574,30 +4596,33 @@ Index: agent/mibgroup/etherlike-mib/ioctl_imp_common.h +#define DOT3STATSSINGLECOLLISIONFRAMES(x) (strstr(x, INTEL_TRANSMIT_SINGLE_COLLISIONS)) || \ + (strstr(x, BROADCOM_TRANSMIT_SINGLE_COLLISIONS)) + -+#define DOT3STATSEXCESSIVECOLLISIONS(x) strstr(x, BROADCOM_TRANSMIT_EXCESS_COLLISIONS) ++#define DOT3STATSEXCESSIVECOLLISIONS(x) (strstr(x, BROADCOM_TRANSMIT_EXCESS_COLLISIONS_BNX2)) || \ ++ (strstr(x, BROADCOM_TRANSMIT_EXCESS_COLLISIONS_TG3)) + +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib/dot3StatsTable.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib/dot3StatsTable.h 2008-12-21 05:19:51.000000000 -0500 +@@ -0,0 +1,11 @@ ++/* ++ * module to include the modules ++ */ + ++config_require(etherlike-mib/data_access/dot3stats) ++config_require(etherlike-mib/dot3StatsTable/dot3StatsTable) ++config_require(etherlike-mib/dot3StatsTable/dot3StatsTable_data_get) ++config_require(etherlike-mib/dot3StatsTable/dot3StatsTable_data_set) ++config_require(etherlike-mib/dot3StatsTable/dot3StatsTable_data_access) ++config_require(etherlike-mib/dot3StatsTable/dot3StatsTable_interface) + -+ -+ -+ -+ -+ -+ -+ -+ -Index: agent/mibgroup/etherlike-mib.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/etherlike-mib.h 2008-11-21 14:50:28.965015841 +0100 -@@ -0,0 +1,10 @@ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib.h net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib.h +--- net-snmp-5.4.1.2/agent/mibgroup/etherlike-mib.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/etherlike-mib.h 2008-12-21 05:18:00.000000000 -0500 +@@ -0,0 +1,6 @@ +/* + * module to include the modules + */ + +config_require(etherlike-mib/dot3StatsTable) -+config_require(etherlike-mib/dot3StatsTable_interface) -+config_require(etherlike-mib/dot3StatsTable_data_get) -+config_require(etherlike-mib/dot3StatsTable_data_set) -+config_require(etherlike-mib/dot3StatsTable_data_access) +config_add_mib(EtherLike-MIB) + + diff --git a/net-snmp-5.4.1.2-rmon-mib-revised.patch b/net-snmp-5.4.1.2-rmon-mib-revised_3.patch similarity index 96% rename from net-snmp-5.4.1.2-rmon-mib-revised.patch rename to net-snmp-5.4.1.2-rmon-mib-revised_3.patch index ece6441..5698fae 100644 --- a/net-snmp-5.4.1.2-rmon-mib-revised.patch +++ b/net-snmp-5.4.1.2-rmon-mib-revised_3.patch @@ -1,7 +1,340 @@ -Index: agent/mibgroup/rmon-mib/etherStatsTable.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable.c 2008-09-16 16:36:41.339791677 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/data_access/etherstats.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/data_access/etherstats.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/data_access/etherstats.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/data_access/etherstats.h 2008-12-21 05:47:47.000000000 -0500 +@@ -0,0 +1,7 @@ ++/* ++ * module to include the modules ++ */ ++ ++#if defined(linux) ++config_require(rmon-mib/data_access/etherstats_linux) ++#endif +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/data_access/etherstats_linux.c net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/data_access/etherstats_linux.c +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/data_access/etherstats_linux.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/data_access/etherstats_linux.c 2009-01-12 07:38:52.000000000 -0500 +@@ -0,0 +1,319 @@ ++/* ++ * standard Net-SNMP includes ++ */ ++#include ++#include ++#include ++ ++/* ++ * include our parent header ++ */ ++#include "rmon-mib/etherStatsTable/etherStatsTable.h" ++#include "rmon-mib/etherStatsTable/etherStatsTable_data_access.h" ++#include "rmon-mib/etherStatsTable/ioctl_imp_common.h" ++ ++/* ++ * @retval 0 success ++ * @retval -1 getifaddrs failed ++ * @retval -2 memory allocation failed ++ */ ++ ++struct ifname * ++etherstats_interface_name_list_get (struct ifname *list_head, int *retval) ++{ ++ struct ifaddrs *addrs = NULL, *p = NULL; ++ struct ifname *nameptr1=NULL, *nameptr2 = NULL; ++ ++ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", ++ "called\n")); ++ ++ if ((getifaddrs(&addrs)) < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", ++ "getifaddrs failed\n")); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_name_list_get, getifaddrs failed\n"); ++ *retval = -1; ++ return NULL; ++ } ++ ++ for (p = addrs; p; p = p->ifa_next) { ++ ++ if (!list_head) { ++ if ( (list_head = (struct ifname *) malloc (sizeof(struct ifname))) < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", ++ "memory allocation failed\n")); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_name_list_get, memory allocation failed\n"); ++ freeifaddrs(addrs); ++ *retval = -2; ++ return NULL; ++ } ++ memset (list_head, 0, sizeof (struct ifname)); ++ strncpy (list_head->name, p->ifa_name, IF_NAMESIZE); ++ continue; ++ } ++ for (nameptr1 = list_head; nameptr1; nameptr2 = nameptr1, nameptr1 = nameptr1->ifn_next) ++ if (!strncmp(p->ifa_name, nameptr1->name, IF_NAMESIZE)) ++ break; ++ ++ if (nameptr1) ++ continue; ++ ++ if ( (nameptr2->ifn_next = (struct ifname *) malloc (sizeof(struct ifname))) < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", ++ "memory allocation failed\n")); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_name_list_get, memory allocation failed\n"); ++ interface_name_list_free (list_head); ++ freeifaddrs(addrs); ++ *retval = -2; ++ return NULL; ++ } ++ nameptr2 = nameptr2->ifn_next; ++ memset (nameptr2, 0, sizeof (struct ifname)); ++ strncpy (nameptr2->name, p->ifa_name, IF_NAMESIZE); ++ continue; ++ ++ } ++ ++ freeifaddrs(addrs); ++ *retval = 0; ++ return list_head; ++} ++ ++ ++/* ++ * @retval 0 success ++ * @retval -1 invalid pointer ++ */ ++ ++int ++etherstats_interface_name_list_free (struct ifname *list_head) ++{ ++ struct ifname *nameptr1 = NULL, *nameptr2 = NULL; ++ ++ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_free", ++ "called\n")); ++ ++ if (!list_head) { ++ snmp_log (LOG_ERR, "access:etherStatsTable:interface_name_list_free: invalid pointer list_head"); ++ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_free", ++ "invalid pointer list_head\n")); ++ return -1; ++ } ++ ++ for (nameptr1 = list_head; nameptr1; nameptr1 = nameptr2) { ++ nameptr2 = nameptr1->ifn_next; ++ free (nameptr1); ++ } ++ ++ return 0; ++} ++ ++/* ++ * @retval 0 : not found ++ * @retval !0 : ifIndex ++ */ ++ ++int ++etherstats_interface_ioctl_ifindex_get (int fd, const char *name) { ++#ifndef SIOCGIFINDEX ++ return 0; ++#else ++ struct ifreq ifrq; ++ int rc = 0; ++ ++ DEBUGMSGTL(("access:etherStatsTable:ioctl", "ifindex_get\n")); ++ ++ rc = _etherStats_ioctl_get(fd, SIOCGIFINDEX, &ifrq, name); ++ if (rc < 0) { ++ DEBUGMSGTL(("access:etherStats:ioctl", ++ "ifindex_get error on inerface '%s'\n", name)); ++ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, ifindex_get error on inerface '%s'\n", name); ++ return 0; ++ ++ } ++ ++ return ifrq.ifr_ifindex; ++#endif /* SIOCGIFINDEX */ ++} ++ ++/* ++ * @retval 0 success ++ * @retval -1 cannot get ETHTOOL_DRVINFO failed ++ * @retval -2 n_stats zero - no statistcs available ++ * @retval -3 memory allocation for holding the statistics failed ++ * @retval -4 cannot get ETHTOOL_GSTRINGS information ++ * @retval -5 cannot get ETHTOOL_GSTATS information ++ * @retval -6 function not supported if HAVE_LINUX_ETHTOOL_H not defined ++ */ ++ ++int ++interface_ioctl_etherstats_get (etherStatsTable_rowreq_ctx *rowreq_ctx , int fd, const char *name) { ++ ++#ifdef HAVE_LINUX_ETHTOOL_H ++ ++ etherStatsTable_data *data = &rowreq_ctx->data; ++ struct ethtool_drvinfo driver_info; ++ struct ethtool_gstrings *eth_strings; ++ struct ethtool_stats *eth_stats; ++ struct ifreq ifr; ++ unsigned int nstats, size_str, size_stats, i; ++ int err; ++ ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "called\n")); ++ ++ memset(&ifr, 0, sizeof(ifr)); ++ strcpy(ifr.ifr_name, name); ++ ++ memset(&driver_info, 0, sizeof(driver_info)); ++ driver_info.cmd = ETHTOOL_GDRVINFO; ++ ifr.ifr_data = (char *)&driver_info; ++ ++ err = _etherStats_ioctl_get(fd, SIOCETHTOOL, &ifr, name); ++ if (err < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "ETHTOOL_GETDRVINFO failed on interface |%s| \n", name)); ++ return -1; ++ } ++ ++ nstats = driver_info.n_stats; ++ if (nstats < 1) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "no stats available for interface |%s| \n", name)); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, no stats availablei for interface |%s| \n", name); ++ return -2; ++ } ++ ++ size_str = nstats * ETH_GSTRING_LEN; ++ size_stats = nstats * sizeof(u64); ++ ++ eth_strings = malloc(size_str + sizeof (struct ethtool_gstrings)); ++ if (!eth_strings) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "no memory available\n")); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, no memory available\n"); ++ ++ return -3; ++ } ++ memset (eth_strings, 0, (size_str + sizeof (struct ethtool_gstrings))); ++ ++ eth_stats = malloc (size_str + sizeof (struct ethtool_stats)); ++ if (!eth_stats) { ++ free (eth_strings); ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "no memory available\n")); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, no memory available\n"); ++ ++ return -3; ++ } ++ memset (eth_stats, 0, (size_str + sizeof (struct ethtool_stats))); ++ ++ eth_strings->cmd = ETHTOOL_GSTRINGS; ++ eth_strings->string_set = ETH_SS_STATS; ++ eth_strings->len = nstats; ++ ifr.ifr_data = (char *) eth_strings; ++ ++ err = _etherStats_ioctl_get(fd, SIOCETHTOOL, &ifr, name); ++ if (err < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "cannot get stats strings information for interface |%s| \n", name)); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, cannot get stats strings information for interface |%s| \n", name); ++ ++ free(eth_strings); ++ free(eth_stats); ++ return -4; ++ } ++ ++ eth_stats->cmd = ETHTOOL_GSTATS; ++ eth_stats->n_stats = nstats; ++ ifr.ifr_data = (char *) eth_stats; ++ err = _etherStats_ioctl_get(fd, SIOCETHTOOL, &ifr, name); ++ if (err < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", ++ "cannot get stats strings information for interface |%s| \n", name)); ++ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, cannot get stats information for interface |%s| \n", name); ++ ++ free(eth_strings); ++ free(eth_stats); ++ return -5; ++ } ++ ++ for (i = 0; i < nstats; i++) { ++ char s[ETH_GSTRING_LEN]; ++ ++ strncpy(s, (const char *) ð_strings->data[i * ETH_GSTRING_LEN], ++ ETH_GSTRING_LEN); ++ ++ if (ETHERSTATSJABBERS(s)) { ++ data->etherStatsJabbers = (u_long)eth_stats->data[i]; ++ rowreq_ctx->column_exists_flags |= COLUMN_ETHERSTATSJABBERS_FLAG; ++ } ++ } ++ free(eth_strings); ++ free(eth_stats); ++ ++ return 0; ++#else ++ return -6; ++#endif ++ ++} ++ ++ ++/* ioctl wrapper ++ * ++ * @param fd : socket fd to use w/ioctl, or -1 to open/close one ++ * @param which ++ * @param ifrq ++ * param ifentry : ifentry to update ++ * @param name ++ * ++ * @retval 0 : success ++ * @retval -1 : invalid parameters ++ * @retval -2 : couldn't create socket ++ * @retval -3 : ioctl call failed ++ */ ++int ++_etherStats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name) ++{ ++ int ourfd = -1, rc = 0; ++ ++ DEBUGMSGTL(("access:etherStatsTable:ioctl", "_etherStats_ioctl_get\n")); ++ /* ++ * sanity checks ++ */ ++ if(NULL == name) { ++ DEBUGMSGTL(("access:etherStatsTable:ioctl", ++ "_etherStats_ioctl_get invalid ifname '%s'\n", name)); ++ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, _etherStats_ioctl_get error on inerface '%s'\n", name); ++ return -1; ++ } ++ ++ /* ++ * create socket for ioctls ++ */ ++ if(fd < 0) { ++ fd = ourfd = socket(AF_INET, SOCK_DGRAM, 0); ++ if(ourfd < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:ioctl", ++ "_etherStats_ioctl_get couldn't create a socket\n", name)); ++ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, _etherStats_ioctl_get error on inerface '%s'\n", name); ++ ++ return -2; ++ } ++ } ++ ++ strncpy(ifrq->ifr_name, name, sizeof(ifrq->ifr_name)); ++ ifrq->ifr_name[ sizeof(ifrq->ifr_name)-1 ] = 0; ++ rc = ioctl(fd, which, ifrq); ++ if (rc < 0) { ++ DEBUGMSGTL(("access:etherStatsTable:ioctl", ++ "_etherStats_ioctl_get ioctl %d returned %d\n", which, rc)); ++ rc = -3; ++ } ++ ++ if(ourfd >= 0) ++ close(ourfd); ++ ++ return rc; ++} ++ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.c net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.c +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.c 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,229 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -232,11 +565,10 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable.c + + +/** @{ */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_data_access.c 2008-09-16 16:36:41.375791976 +0200 -@@ -0,0 +1,825 @@ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.c net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.c +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.c 2009-01-12 03:39:26.000000000 -0500 +@@ -0,0 +1,522 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 14170 $ of $ @@ -254,10 +586,11 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c + * include our parent header + */ +#include "etherStatsTable.h" -+ -+ +#include "etherStatsTable_data_access.h" ++ ++#if defined(linux) +#include "ioctl_imp_common.h" ++#endif + +/** @ingroup interface + * @addtogroup data_access data_access: Routines to access data @@ -458,12 +791,14 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c + * etherStatsIndex(1)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + -+ + long etherStatsIndex; + int fd; + int rc = 0, retval = 0; -+ struct ifname *list_head = NULL, *p = NULL; + ++#if defined(linux) ++ struct ifname *list_head = NULL, *p = NULL; ++#endif ++ + /* + * create socket for ioctls + */ @@ -479,7 +814,8 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c + * and list_head contains null + */ + -+ list_head = interface_name_list_get (list_head, &retval); ++#if defined(linux) ++ list_head = etherstats_interface_name_list_get (list_head, &retval); + + if (!list_head) { + snmp_log (LOG_ERR, "access:etherStatsTable, error getting the interface names present in the system\n"); @@ -502,7 +838,7 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c + * get index via ioctl. + */ + -+ etherStatsIndex = (long) interface_ioctl_ifindex_get(-1, p->name); ++ etherStatsIndex = (long) etherstats_interface_ioctl_ifindex_get(-1, p->name); + + /* + * get the etherstats contents populated, if the device is not an ethernet device @@ -556,12 +892,12 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c + * free the interface names list + */ + -+ if ( (interface_name_list_free(list_head)) < 0) { ++ if ( (etherstats_interface_name_list_free(list_head)) < 0) { + snmp_log(LOG_ERR, "access:etherStatsTable, error freeing the interface name list \n"); + DEBUGMSGTL(("access:etherStatsTable", "error freeing the interface name list\n")); + return MFD_ERROR; + } -+ ++#endif + + DEBUGMSGT(("verbose:etherStatsTable:etherStatsTable_container_load", + "inserted %d records\n", count)); @@ -570,313 +906,6 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c +} + /* etherStatsTable_container_load */ + -+/* -+ * @retval 0 success -+ * @retval -1 getifaddrs failed -+ * @retval -2 memory allocation failed -+ */ -+ -+static struct ifname * -+interface_name_list_get (struct ifname *list_head, int *retval) -+{ -+ struct ifaddrs *addrs = NULL, *p = NULL; -+ struct ifname *nameptr1=NULL, *nameptr2 = NULL; -+ -+ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", -+ "called\n")); -+ -+ if ((getifaddrs(&addrs)) < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", -+ "getifaddrs failed\n")); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_name_list_get, getifaddrs failed\n"); -+ *retval = -1; -+ return NULL; -+ } -+ -+ for (p = addrs; p; p = p->ifa_next) { -+ -+ if (!list_head) { -+ if ( (list_head = (struct ifname *) malloc (sizeof(struct ifname))) < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", -+ "memory allocation failed\n")); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_name_list_get, memory allocation failed\n"); -+ freeifaddrs(addrs); -+ *retval = -2; -+ return NULL; -+ } -+ memset (list_head, 0, sizeof (struct ifname)); -+ strncpy (list_head->name, p->ifa_name, IF_NAMESIZE); -+ continue; -+ } -+ for (nameptr1 = list_head; nameptr1; nameptr2 = nameptr1, nameptr1 = nameptr1->ifn_next) -+ if (!strncmp(p->ifa_name, nameptr1->name, IF_NAMESIZE)) -+ break; -+ -+ if (nameptr1) -+ continue; -+ -+ if ( (nameptr2->ifn_next = (struct ifname *) malloc (sizeof(struct ifname))) < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_get", -+ "memory allocation failed\n")); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_name_list_get, memory allocation failed\n"); -+ interface_name_list_free (list_head); -+ freeifaddrs(addrs); -+ *retval = -2; -+ return NULL; -+ } -+ nameptr2 = nameptr2->ifn_next; -+ memset (nameptr2, 0, sizeof (struct ifname)); -+ strncpy (nameptr2->name, p->ifa_name, IF_NAMESIZE); -+ continue; -+ -+ } -+ -+ freeifaddrs(addrs); -+ *retval = 0; -+ return list_head; -+} -+ -+ -+/* -+ * @retval 0 success -+ * @retval -1 invalid pointer -+ */ -+ -+static int -+interface_name_list_free (struct ifname *list_head) -+{ -+ struct ifname *nameptr1 = NULL, *nameptr2 = NULL; -+ -+ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_free", -+ "called\n")); -+ -+ if (!list_head) { -+ snmp_log (LOG_ERR, "access:etherStatsTable:interface_name_list_free: invalid pointer list_head"); -+ DEBUGMSGTL(("access:etherStatsTable:interface_name_list_free", -+ "invalid pointer list_head\n")); -+ return -1; -+ } -+ -+ for (nameptr1 = list_head; nameptr1; nameptr1 = nameptr2) { -+ nameptr2 = nameptr1->ifn_next; -+ free (nameptr1); -+ } -+ -+ return 0; -+} -+ -+/* -+ * @retval 0 : not found -+ * @retval !0 : ifIndex -+ */ -+ -+static int -+interface_ioctl_ifindex_get (int fd, const char *name) { -+#ifndef SIOCGIFINDEX -+ return 0; -+#else -+ struct ifreq ifrq; -+ int rc = 0; -+ -+ DEBUGMSGTL(("access:etherStatsTable:ioctl", "ifindex_get\n")); -+ -+ rc = _etherStats_ioctl_get(fd, SIOCGIFINDEX, &ifrq, name); -+ if (rc < 0) { -+ DEBUGMSGTL(("access:etherStats:ioctl", -+ "ifindex_get error on inerface '%s'\n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, ifindex_get error on inerface '%s'\n", name); -+ return 0; -+ -+ } -+ -+ return ifrq.ifr_ifindex; -+#endif /* SIOCGIFINDEX */ -+} -+ -+/* -+ * @retval 0 success -+ * @retval -1 cannot get ETHTOOL_DRVINFO failed -+ * @retval -2 n_stats zero - no statistcs available -+ * @retval -3 memory allocation for holding the statistics failed -+ * @retval -4 cannot get ETHTOOL_GSTRINGS information -+ * @retval -5 cannot get ETHTOOL_GSTATS information -+ * @retval -6 function not supported if HAVE_LINUX_ETHTOOL_H not defined -+ */ -+ -+int -+interface_ioctl_etherstats_get (etherStatsTable_rowreq_ctx *rowreq_ctx , int fd, const char *name) { -+ -+#ifdef HAVE_LINUX_ETHTOOL_H -+ -+ etherStatsTable_data *data = &rowreq_ctx->data; -+ struct ethtool_drvinfo driver_info; -+ struct ethtool_gstrings *eth_strings; -+ struct ethtool_stats *eth_stats; -+ struct ifreq ifr; -+ unsigned int nstats, size_str, size_stats, i; -+ int err; -+ -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "called\n")); -+ -+ memset(&ifr, 0, sizeof(ifr)); -+ strcpy(ifr.ifr_name, name); -+ -+ memset(&driver_info, 0, sizeof(driver_info)); -+ driver_info.cmd = ETHTOOL_GDRVINFO; -+ ifr.ifr_data = (char *)&driver_info; -+ -+ err = _etherStats_ioctl_get(fd, SIOCETHTOOL, &ifr, name); -+ if (err < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "ETHTOOL_GETDRVINFO failed on interface |%s| \n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, ETHTOOL_GETDRVINFO failed on interface |%s| \n", name); -+ return -1; -+ } -+ -+ nstats = driver_info.n_stats; -+ if (nstats < 1) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "no stats available for interface |%s| \n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, no stats availablei for interface |%s| \n", name); -+ return -2; -+ } -+ -+ size_str = nstats * ETH_GSTRING_LEN; -+ size_stats = nstats * sizeof(u64); -+ -+ eth_strings = malloc(size_str + sizeof (struct ethtool_gstrings)); -+ if (!eth_strings) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "no memory available\n")); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, no memory available\n"); -+ -+ return -3; -+ } -+ memset (eth_strings, 0, (size_str + sizeof (struct ethtool_gstrings))); -+ -+ eth_stats = malloc (size_str + sizeof (struct ethtool_stats)); -+ if (!eth_stats) { -+ free (eth_strings); -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "no memory available\n")); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, no memory available\n"); -+ -+ return -3; -+ } -+ memset (eth_stats, 0, (size_str + sizeof (struct ethtool_stats))); -+ -+ eth_strings->cmd = ETHTOOL_GSTRINGS; -+ eth_strings->string_set = ETH_SS_STATS; -+ eth_strings->len = nstats; -+ ifr.ifr_data = (char *) eth_strings; -+ -+ err = _etherStats_ioctl_get(fd, SIOCETHTOOL, &ifr, name); -+ if (err < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "cannot get stats strings information for interface |%s| \n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, cannot get stats strings information for interface |%s| \n", name); -+ -+ free(eth_strings); -+ free(eth_stats); -+ return -4; -+ } -+ -+ eth_stats->cmd = ETHTOOL_GSTATS; -+ eth_stats->n_stats = nstats; -+ ifr.ifr_data = (char *) eth_stats; -+ err = _etherStats_ioctl_get(fd, SIOCETHTOOL, &ifr, name); -+ if (err < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:interface_ioctl_etherstats_get", -+ "cannot get stats strings information for interface |%s| \n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable,interface_ioctl_etherstats_get, cannot get stats information for interface |%s| \n", name); -+ -+ free(eth_strings); -+ free(eth_stats); -+ return -5; -+ } -+ -+ for (i = 0; i < nstats; i++) { -+ char s[ETH_GSTRING_LEN]; -+ -+ strncpy(s, (const char *) ð_strings->data[i * ETH_GSTRING_LEN], -+ ETH_GSTRING_LEN); -+ -+ if (ETHERSTATSJABBERS(s)) { -+ data->etherStatsJabbers = (u_long)eth_stats->data[i]; -+ rowreq_ctx->column_exists_flags |= COLUMN_ETHERSTATSJABBERS_FLAG; -+ } -+ } -+ free(eth_strings); -+ free(eth_stats); -+ -+ return 0; -+#else -+ return -6; -+#endif -+ -+} -+ -+ -+/* ioctl wrapper -+ * -+ * @param fd : socket fd to use w/ioctl, or -1 to open/close one -+ * @param which -+ * @param ifrq -+ * param ifentry : ifentry to update -+ * @param name -+ * -+ * @retval 0 : success -+ * @retval -1 : invalid parameters -+ * @retval -2 : couldn't create socket -+ * @retval -3 : ioctl call failed -+ */ -+static int -+_etherStats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name) -+{ -+ int ourfd = -1, rc = 0; -+ -+ DEBUGMSGTL(("access:etherStatsTable:ioctl", "_etherStats_ioctl_get\n")); -+ /* -+ * sanity checks -+ */ -+ if(NULL == name) { -+ DEBUGMSGTL(("access:etherStatsTable:ioctl", -+ "_etherStats_ioctl_get invalid ifname '%s'\n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, _etherStats_ioctl_get error on inerface '%s'\n", name); -+ return -1; -+ } -+ -+ /* -+ * create socket for ioctls -+ */ -+ if(fd < 0) { -+ fd = ourfd = socket(AF_INET, SOCK_DGRAM, 0); -+ if(ourfd < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:ioctl", -+ "_etherStats_ioctl_get couldn't create a socket\n", name)); -+ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, _etherStats_ioctl_get error on inerface '%s'\n", name); -+ -+ return -2; -+ } -+ } -+ -+ strncpy(ifrq->ifr_name, name, sizeof(ifrq->ifr_name)); -+ ifrq->ifr_name[ sizeof(ifrq->ifr_name)-1 ] = 0; -+ rc = ioctl(fd, which, ifrq); -+ if (rc < 0) { -+ DEBUGMSGTL(("access:etherStatsTable:ioctl", -+ "_etherStats_ioctl_get ioctl %d returned %d\n", which, rc)); -+ snmp_log (LOG_ERR, "access:etherStatsTable:ioctl, _etherStats_ioctl_get error on inerface '%s'\n", name); -+ -+ rc = -3; -+ } -+ -+ if(ourfd >= 0) -+ close(ourfd); -+ -+ return rc; -+} + +/** + * container clean up @@ -1062,10 +1091,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.c +} /* etherStatsTable_validate_index */ + +/** @} */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_data_access.h 2008-09-16 16:36:41.440291464 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_access.h 2008-08-31 11:04:55.000000000 -0400 @@ -0,0 +1,80 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -1147,10 +1175,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_access.h +} +#endif +#endif /* ETHERSTATSTABLE_DATA_ACCESS_H */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_data_get.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_data_get.c 2008-09-16 16:36:41.479792276 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.c net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.c +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.c 2008-08-25 09:31:32.000000000 -0400 @@ -0,0 +1,1411 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2563,10 +2590,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_get.c + + +/** @} */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_data_get.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_data_get.h 2008-09-16 16:36:41.507791686 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_get.h 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,151 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -2719,10 +2745,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_get.h +#endif +#endif /* ETHERSTATSTABLE_DATA_GET_H */ +/** @} */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_data_set.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_data_set.c 2008-09-16 16:36:41.547792106 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.c net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.c +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.c 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,977 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -3701,10 +3726,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_set.c +} /* etherStatsStatus_undo */ + +/** @} */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_data_set.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_data_set.h 2008-09-16 16:36:41.571792191 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_data_set.h 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,356 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -4062,10 +4086,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_data_set.h +} +#endif +#endif /* ETHERSTATSTABLE_DATA_SET_H */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_enums.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_enums.h 2008-09-16 16:36:41.595792061 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_enums.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_enums.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_enums.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_enums.h 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,57 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -4124,10 +4147,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_enums.h +} +#endif +#endif /* ETHERSTATSTABLE_ENUMS_H */ -Index: agent/mibgroup/rmon-mib/etherStatsTable.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable.h 2008-09-16 16:36:41.639791658 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable.h 2008-09-09 12:03:42.000000000 -0400 @@ -0,0 +1,303 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -4432,10 +4454,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable.h +#endif +#endif /* ETHERSTATSTABLE_H */ +/** @} */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_interface.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_interface.c 2008-09-16 16:36:41.663791903 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.c net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.c +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.c 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.c 2008-09-12 14:15:42.000000000 -0400 @@ -0,0 +1,2225 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -6662,10 +6683,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_interface.c + + return rowreq_ctx; +} -Index: agent/mibgroup/rmon-mib/etherStatsTable_interface.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_interface.h 2008-09-16 16:36:41.687791226 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_interface.h 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,98 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -6765,10 +6785,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_interface.h +#endif +#endif /* ETHERSTATSTABLE_INTERFACE_H */ +/** @} */ -Index: agent/mibgroup/rmon-mib/etherStatsTable_oids.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/etherStatsTable_oids.h 2008-09-16 16:36:41.715791881 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_oids.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_oids.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_oids.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/etherStatsTable_oids.h 2008-08-25 02:37:27.000000000 -0400 @@ -0,0 +1,107 @@ +/* + * Note: this file originally auto-generated by mib2c using @@ -6877,10 +6896,9 @@ Index: agent/mibgroup/rmon-mib/etherStatsTable_oids.h +} +#endif +#endif /* ETHERSTATSTABLE_OIDS_H */ -Index: agent/mibgroup/rmon-mib/ioctl_imp_common.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib/ioctl_imp_common.h 2008-09-16 16:36:41.755791948 +0200 +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/ioctl_imp_common.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/ioctl_imp_common.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable/ioctl_imp_common.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable/ioctl_imp_common.h 2008-12-21 05:55:16.000000000 -0500 @@ -0,0 +1,35 @@ +#include +#include @@ -6905,10 +6923,10 @@ Index: agent/mibgroup/rmon-mib/ioctl_imp_common.h + char name [IF_NAMESIZE]; +}; + -+static struct ifname *interface_name_list_get (struct ifname *, int *); -+static int interface_name_list_free (struct ifname *list_head); -+static int interface_ioctl_ifindex_get (int fd, const char *name); -+static int _etherStats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name); ++struct ifname *etherstats_interface_name_list_get (struct ifname *, int *); ++int etherstats_interface_name_list_free (struct ifname *list_head); ++int etherstats_interface_ioctl_ifindex_get (int fd, const char *name); ++int _etherStats_ioctl_get(int fd, int which, struct ifreq *ifrq, const char* name); +int interface_ioctl_etherstats_get(etherStatsTable_rowreq_ctx *rowreq_ctx, int fd, const char* name); + +/* for maintainability */ @@ -6917,20 +6935,32 @@ Index: agent/mibgroup/rmon-mib/ioctl_imp_common.h + +#define ETHERSTATSJABBERS(x) strstr(x, BROADCOM_RECEIVE_JABBERS) + -Index: agent/mibgroup/rmon-mib.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ agent/mibgroup/rmon-mib.h 2008-09-16 16:36:41.779791875 +0200 -@@ -0,0 +1,12 @@ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib/etherStatsTable.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib/etherStatsTable.h 2008-12-21 05:47:48.000000000 -0500 +@@ -0,0 +1,11 @@ ++/* ++ * module to include the modules ++ */ ++ ++config_require(rmon-mib/data_access/etherstats) ++config_require(rmon-mib/etherStatsTable/etherStatsTable) ++config_require(rmon-mib/etherStatsTable/etherStatsTable_data_get) ++config_require(rmon-mib/etherStatsTable/etherStatsTable_data_set) ++config_require(rmon-mib/etherStatsTable/etherStatsTable_data_access) ++config_require(rmon-mib/etherStatsTable/etherStatsTable_interface) ++ +diff -uNr net-snmp-5.4.1.2/agent/mibgroup/rmon-mib.h net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib.h +--- net-snmp-5.4.1.2/agent/mibgroup/rmon-mib.h 1969-12-31 19:00:00.000000000 -0500 ++++ net-snmp-5.4.1.2-new/agent/mibgroup/rmon-mib.h 2008-12-21 05:41:57.000000000 -0500 +@@ -0,0 +1,8 @@ +/* + * module to include the modules + */ + +config_require(rmon-mib/etherStatsTable) -+config_require(rmon-mib/etherStatsTable_interface) -+config_require(rmon-mib/etherStatsTable_data_get) -+config_require(rmon-mib/etherStatsTable_data_set) -+config_require(rmon-mib/etherStatsTable_data_access) +config_add_mib(RMON-MIB) + + + + diff --git a/net-snmp.changes b/net-snmp.changes index e3782ce..ee00e95 100644 --- a/net-snmp.changes +++ b/net-snmp.changes @@ -1,8 +1,30 @@ +------------------------------------------------------------------- +Thu Jan 22 16:36:00 CET 2009 - mrueckert@suse.de + +- updated patches from Dell: + Those patches incorporate the latest fixes for remarks from the + upstream review + old: net-snmp-5.4.1.2-rmon-mib-revised.patch + new: net-snmp-5.4.1.2-rmon-mib-revised_3.patch + old: net-snmp-5.4.1.2-etherlike-mib-revised_2.patch + new: net-snmp-5.4.1.2-etherlike-mib-revised_4.patch + ------------------------------------------------------------------- Wed Dec 10 12:34:56 CET 2008 - olh@suse.de -- use Obsoletes: -XXbit only for ppc64 to help solver during distupgrade - (bnc#437293) +- use Obsoletes: -XXbit only for ppc64 to help solver during + distupgrade (bnc#437293) + +------------------------------------------------------------------- +Fri Dec 5 22:07:47 CET 2008 - mrueckert@suse.de + +- fix the snmptrapd init script: + 1. make sure the config isnt loaded twice. + 2. do not truncate the net-snmp.log + 3. use SNMPD_LOGLEVEL aswell. + 4. write a pid +- update snmptrapd section in README.SuSE +- whitespace cleanup in both init scripts ------------------------------------------------------------------- Fri Nov 21 14:53:28 CET 2008 - mrueckert@suse.de diff --git a/net-snmp.spec b/net-snmp.spec index 4eed16b..c6e9b0e 100644 --- a/net-snmp.spec +++ b/net-snmp.spec @@ -1,7 +1,7 @@ # # spec file for package net-snmp (Version 5.4.2.1) # -# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,7 +20,7 @@ Name: net-snmp Version: 5.4.2.1 -Release: 5 +Release: 6 # License: BSD 3-Clause; X11/MIT Group: Productivity/Networking/Other @@ -77,8 +77,8 @@ Patch8: net-snmp-5.4.2_net-snmp-config_headercheck.patch Patch9: net-snmp-5.4.2_perl_tk_warning.patch Patch10: net-snmp-5.4.2_snmpconf-selinux.patch Patch11: net-snmp-5.3.0.1_trap-agent-addr_v2.patch -Patch12: net-snmp-5.4.1.2-etherlike-mib-revised_2.patch -Patch13: net-snmp-5.4.1.2-rmon-mib-revised.patch +Patch12: net-snmp-5.4.1.2-etherlike-mib-revised_4.patch +Patch13: net-snmp-5.4.1.2-rmon-mib-revised_3.patch Patch14: net-snmp-5.4.2_velocity-mib.patch Patch15: Fix-for-tcpConnnectionTable-tcpListenerTable-udpEn.patch Patch16: Fix-for-IPv6-Interface-Table.patch @@ -215,8 +215,8 @@ Authors: %patch9 %patch10 %patch11 -%patch12 -%patch13 +%patch12 -p1 +%patch13 -p1 %patch14 %patch15 -p1 %patch16 -p1 @@ -431,9 +431,25 @@ fi %{_bindir}/tkmib %changelog +* Thu Jan 22 2009 mrueckert@suse.de +- updated patches from Dell: + Those patches incorporate the latest fixes for remarks from the + upstream review + old: net-snmp-5.4.1.2-rmon-mib-revised.patch + new: net-snmp-5.4.1.2-rmon-mib-revised_3.patch + old: net-snmp-5.4.1.2-etherlike-mib-revised_2.patch + new: net-snmp-5.4.1.2-etherlike-mib-revised_4.patch * Wed Dec 10 2008 olh@suse.de -- use Obsoletes: -XXbit only for ppc64 to help solver during distupgrade - (bnc#437293) +- use Obsoletes: -XXbit only for ppc64 to help solver during + distupgrade (bnc#437293) +* Fri Dec 05 2008 mrueckert@suse.de +- fix the snmptrapd init script: + 1. make sure the config isnt loaded twice. + 2. do not truncate the net-snmp.log + 3. use SNMPD_LOGLEVEL aswell. + 4. write a pid +- update snmptrapd section in README.SuSE +- whitespace cleanup in both init scripts * Fri Nov 21 2008 mrueckert@suse.de - update patches from Dell: Upstream asked to reduce the logging in the mib module. diff --git a/rc.net-snmp b/rc.net-snmp index 835f3f5..077fbf3 100644 --- a/rc.net-snmp +++ b/rc.net-snmp @@ -26,10 +26,10 @@ test -x $SNMPD || exit 5 # Check for existence of needed config file and read it SNMPD_CONFIG=/etc/sysconfig/net-snmp test -r $SNMPD_CONFIG || { echo "$SNMPD_CONFIG not existing"; - if [ "$1" = "stop" ]; then exit 0; - else exit 6; fi; } + if [ "$1" = "stop" ]; then exit 0; + else exit 6; fi; } -# Read config +# Read config . $SNMPD_CONFIG # Shell functions sourced from /etc/rc.status: @@ -55,7 +55,7 @@ rc_reset # 5 - program is not installed # 6 - program is not configured # 7 - program is not running -# +# # Note that starting an already running service, stopping # or restarting a not-running service as well as the restart # with force-reload (in case signalling is not supported) are @@ -72,11 +72,11 @@ get_agents() agents="$agents $agent" agentargs="-x /var/run/agentx/master" done -} +} case "$1" in start) - echo -n "Starting snmpd" + echo -n "Starting snmpd" # # do not even try to start if the log file is (2GB-1MB) big. # the snmpd doesnt handle LFS properly @@ -90,89 +90,89 @@ case "$1" in /usr/sbin/logrotate /etc/logrotate.d/net-snmp fi # if [ $SNMPD_SIZE_LOGFILE -gt $SNMPD_SIZE_MAX ] ; then fi # if [ -e "$SNMPD_LOGFILE" ] ; then - get_agents - # Do not add -c /etc/snmpd.conf, since it is already loaded by default. - if [ $SNMPDCONF = "/etc/snmp/snmpd.conf" ]; then - SNMPDCONF="" - else - SNMPDCONF="-c $SNMPDCONF" - fi - case "${SNMPD_USE_SMUX:-yes}" in - [Nn][Oo]) - SNMPDNOSMUX="-I -smux" - ;; - esac - case "${SNMPD_LOG_SUCCESSFUL_CONNECTIONS:-yes}" in - [Nn][Oo]) - SNMPDNOTCPWRAPPERLOG="--dontLogTCPWrappersConnects" - ;; - esac - startproc $SNMPD $SNMPDCONF -r -A -LF ${SNMPD_LOGLEVEL:-d} $SNMPD_LOGFILE -p /var/run/snmpd.pid $agentargs $SNMPDNOSMUX $SNMPDNOTCPWRAPPERLOG - rc_status -v - rc_reset + get_agents + # Do not add -c /etc/snmpd.conf, since it is already loaded by default. + if [ $SNMPDCONF = "/etc/snmp/snmpd.conf" ]; then + SNMPDCONF="" + else + SNMPDCONF="-c $SNMPDCONF" + fi + case "${SNMPD_USE_SMUX:-yes}" in + [Nn][Oo]) + SNMPDNOSMUX="-I -smux" + ;; + esac + case "${SNMPD_LOG_SUCCESSFUL_CONNECTIONS:-yes}" in + [Nn][Oo]) + SNMPDNOTCPWRAPPERLOG="--dontLogTCPWrappersConnects" + ;; + esac + startproc $SNMPD $SNMPDCONF -r -A -LF ${SNMPD_LOGLEVEL:-d} $SNMPD_LOGFILE -p /var/run/snmpd.pid $agentargs $SNMPDNOSMUX $SNMPDNOTCPWRAPPERLOG + rc_status -v + rc_reset - # start all agents - if test -n "$agents"; then - usleep 300000 - for agent in $agents; do + # start all agents + if test -n "$agents"; then + usleep 300000 + for agent in $agents; do echo -en "\tStarting `basename $agent`" - startproc -t1 $agent - rc_status -v ; rc_reset + startproc -t1 $agent + rc_status -v ; rc_reset done - fi - ;; + fi + ;; stop) - echo -n "Shutting down snmpd:" - killproc -TERM $SNMPD - rc_status -v ; rc_reset - # we also need to make sure all agents die - if test -n "$agents"; then + echo -n "Shutting down snmpd:" + killproc -TERM $SNMPD + rc_status -v ; rc_reset + # we also need to make sure all agents die + if test -n "$agents"; then for agent in $AGENTDIR/*; do test -x $agent || continue - echo -ne "\tShutting down `basename $agent`:" + echo -ne "\tShutting down `basename $agent`:" killproc $agent - rc_status -v ; rc_reset + rc_status -v ; rc_reset done - fi - ;; + fi + ;; try-restart) - $0 status >/dev/null && $0 restart - rc_status - ;; + $0 status >/dev/null && $0 restart + rc_status + ;; restart) - $0 stop - $0 start - rc_status - ;; + $0 stop + $0 start + rc_status + ;; force-reload) - echo -n "Reload service snmpd:" - killproc -HUP $SNMPD - rc_status -v - ;; + echo -n "Reload service snmpd:" + killproc -HUP $SNMPD + rc_status -v + ;; reload) - echo -n "Reload service snmpd:" - killproc -HUP $SNMPD - rc_status -v - ;; + echo -n "Reload service snmpd:" + killproc -HUP $SNMPD + rc_status -v + ;; status) - echo -n "Checking for service snmpd:" - checkproc $SNMPD - rc_status -v - get_agents - if test -n "$agents"; then - echo -e "Checking for agents:" + echo -n "Checking for service snmpd:" + checkproc $SNMPD + rc_status -v + get_agents + if test -n "$agents"; then + echo -e "Checking for agents:" - for agent in $agents; do + for agent in $agents; do echo -en "\t`basename $agent`" checkproc $agent rc_status -v done - fi - ;; + fi + ;; *) - echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}" - exit 1 - ;; + echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}" + exit 1 + ;; esac rc_exit diff --git a/rc.snmptrapd b/rc.snmptrapd index 7478cc3..65006f9 100644 --- a/rc.snmptrapd +++ b/rc.snmptrapd @@ -15,9 +15,20 @@ ### END INIT INFO SNMPTRAPD=/usr/sbin/snmptrapd +SNMPTRAPD_CONF="/etc/snmp/snmptrapd.conf" +SNMPTRAPD_LOGFILE="/var/log/net-snmp.log" test -x $SNMPTRAPD || exit 5 +# Check for existence of needed config file and read it +SNMPD_CONFIG=/etc/sysconfig/net-snmp +test -r $SNMPD_CONFIG || { echo "$SNMPD_CONFIG not existing"; + if [ "$1" = "stop" ]; then exit 0; + else exit 6; fi; } + +# Read config +. $SNMPD_CONFIG + # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status @@ -46,46 +57,51 @@ rc_reset # or restarting a not-running service as well as the restart # with force-reload (in case signalling is not supported) are # considered a success. - +if [ $SNMPTRAPD_CONF = "/etc/snmp/snmptrapd.conf" ]; then + SNMPTRAPD_CONF="" +else + SNMPTRAPD_CONF="-c $SNMPTRAPD_CONF" +fi +SNMPTRAPD_LOGFILE="${SNMPTRAPD_LOGFILE:-/var/log/net-snmp.log}" case "$1" in start) - echo -n "Starting snmptrapd:" - startproc $SNMPTRAPD -c /etc/snmptrapd.conf -Lf /var/log/net-snmpd.log - rc_status -v - ;; + echo -n "Starting snmptrapd:" + startproc $SNMPTRAPD $SNMPTRAPD_CONF -A -Lf ${SNMPD_LOGLEVEL:-d} $SNMPTRAPD_LOGFILE -p /var/run/snmptrapd.pid + rc_status -v + ;; stop) - echo -n "Shutting down snmptrapd:" - killproc -TERM $SNMPTRAPD - rc_status -v - ;; + echo -n "Shutting down snmptrapd:" + killproc -TERM $SNMPTRAPD + rc_status -v + ;; try-restart) - $0 status >/dev/null && $0 restart - rc_status - ;; + $0 status >/dev/null && $0 restart + rc_status + ;; restart) - $0 stop - $0 start - rc_status - ;; + $0 stop + $0 start + rc_status + ;; force-reload) - echo -n "Reload service snmptrapd:" - killproc -HUP $SNMPTRAPD - rc_status -v - ;; + echo -n "Reload service snmptrapd:" + killproc -HUP $SNMPTRAPD + rc_status -v + ;; reload) - echo -n "Reload service snmptrapd:" - killproc -HUP $SNMPTRAPD - rc_status -v - ;; + echo -n "Reload service snmptrapd:" + killproc -HUP $SNMPTRAPD + rc_status -v + ;; status) - echo -n "Checking for service snmptrapd:" - checkproc $SNMPTRAPD - rc_status -v - ;; + echo -n "Checking for service snmptrapd:" + checkproc $SNMPTRAPD + rc_status -v + ;; *) - echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}" - exit 1 - ;; + echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}" + exit 1 + ;; esac rc_exit