SF.net SVN: gar:[24479] csw/mgar/pkg/netsnmp/trunk
cgrzemba at users.sourceforge.net
cgrzemba at users.sourceforge.net
Thu Dec 18 16:42:46 CET 2014
Revision: 24479
http://sourceforge.net/p/gar/code/24479
Author: cgrzemba
Date: 2014-12-18 15:42:45 +0000 (Thu, 18 Dec 2014)
Log Message:
-----------
netsnmp/trunk: add patches from solaris-userland
Modified Paths:
--------------
csw/mgar/pkg/netsnmp/trunk/Makefile
Added Paths:
-----------
csw/mgar/pkg/netsnmp/trunk/files/0002-pkcs.patch
csw/mgar/pkg/netsnmp/trunk/files/0011-Makefile.in.patch
csw/mgar/pkg/netsnmp/trunk/files/0012-Makefile.PL.patch
csw/mgar/pkg/netsnmp/trunk/files/0015+0016-vmstat_solaris2.patch
csw/mgar/pkg/netsnmp/trunk/files/0024-kernel_sunos5.patch
csw/mgar/pkg/netsnmp/trunk/files/0034-manpage-snmptrapd.conf.5.def.patch
csw/mgar/pkg/netsnmp/trunk/files/0035-bug-1849903.patch
csw/mgar/pkg/netsnmp/trunk/files/0048+0027-mnt-cache-hr_filesys.patch
csw/mgar/pkg/netsnmp/trunk/files/0051-CVE-2014-2285.patch
csw/mgar/pkg/netsnmp/trunk/files/0052-dyn-cpu-cpu_kstat.patch
csw/mgar/pkg/netsnmp/trunk/files/net-snmp-CVE-2014-3565.patch
Modified: csw/mgar/pkg/netsnmp/trunk/Makefile
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/Makefile 2014-12-18 13:53:49 UTC (rev 24478)
+++ csw/mgar/pkg/netsnmp/trunk/Makefile 2014-12-18 15:42:45 UTC (rev 24479)
@@ -35,6 +35,16 @@
PATCHFILES += 0002-workaround-ksh-stop-alias-problem.patch
PATCHFILES += 0003-configure-disable-perl-cc-checks.patch
PATCHFILES += 0004-enable-python-version-select.patch
+PATCHFILES += 0002-pkcs.patch
+PATCHFILES += 0011-Makefile.in.patch
+PATCHFILES += 0012-Makefile.PL.patch
+PATCHFILES += 0015+0016-vmstat_solaris2.patch
+PATCHFILES += 0024-kernel_sunos5.patch
+PATCHFILES += 0034-manpage-snmptrapd.conf.5.def.patch
+PATCHFILES += 0035-bug-1849903.patch
+PATCHFILES += 0048+0027-mnt-cache-hr_filesys.patch
+PATCHFILES += 0051-CVE-2014-2285.patch
+PATCHFILES += 0052-dyn-cpu-cpu_kstat.patch
VENDOR_URL = http://www.net-snmp.org/
Added: csw/mgar/pkg/netsnmp/trunk/files/0002-pkcs.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0002-pkcs.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0002-pkcs.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,32 @@
+--- a/snmplib/pkcs.c
++++ b/snmplib/pkcs.c
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright Copyright 2003 Sun Microsystems, Inc. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms specified in the COPYING file
+ * distributed with the Net-SNMP package.
+ */
+@@ -105,19 +105,13 @@ pkcs_init(void)
+ static int
+ free_slots(int majorID, int minorID, void *serverarg, void *clientarg)
+ {
+- int slotcount, i;
++ (void) C_Finalize(NULL);
+
+ if (pSlot != NULL) {
+- slotcount = pSlot->count;
+- for (i = 0; i < slotcount; i++) {
+- if (pSlot->pSession->hdl != NULL) {
+- free(pSlot->pSession->hdl);
+- }
+- }
+- free(pSlot);
++ SNMP_FREE(pSlot->pSession);
++ SNMP_FREE(pSlot);
+ }
+
+- (void) C_Finalize(NULL);
+ return 0;
+ }
+
Added: csw/mgar/pkg/netsnmp/trunk/files/0011-Makefile.in.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0011-Makefile.in.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0011-Makefile.in.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,64 @@
+--- a/agent/Makefile.in
++++ b/agent/Makefile.in
+@@ -276,7 +276,10 @@ FTOBJS = $(LLIBAGENTFTS) $(FTAGENTOBJS) mib_modules.ft auto_nlist.ft
+
+ FEATUREFILE = $(top_builddir)/include/net-snmp/agent/features.h
+
+-all: agentlib subdirs miblib $(INSTALLBINPROGS) $(INSTALLSBINPROGS)
++LIB_LD_ADD_AGENT =-lnetsnmp -lnetsnmphelpers
++LIB_LD_ADD_PATH_MIBS =-Lhelpers -L../snmplib
++
++all: agentlib subdirs miblib relinklib $(INSTALLBINPROGS) $(INSTALLSBINPROGS)
+
+ #
+ # build stuff targets
+@@ -306,6 +309,10 @@ libnetsnmpmibs.$(LIB_EXTENSION)$(LIB_VERSION): ${LMIBOBJS} $(AGENTLIB) $(USELIBS
+
+ agentlib: $(AGENTLIB)
+
++relinklib: ${LLIBAGENTOBJS} $(USELIBS)
++ $(LIB_LD_CMD) $(AGENTLIB) $(LIB_LD_ADD_PATH_MIBS) ${LLIBAGENTOBJS} $(USELIBS) ${LAGENTLIBS} $(LDFLAGS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) $(LIB_LD_ADD_AGENT)
++ $(RANLIB) $(AGENTLIB) $(LIB_LD_ADD_AGENT)
++
+ miblib: $(MIBLIB)
+
+ libs: $(AGENTLIB) $(MIBLIB)
+--- a/agent/helpers/Makefile.in
++++ b/agent/helpers/Makefile.in
+@@ -31,8 +31,11 @@ OBJS = dummy.o
+
+ LOBJS = dummy.lo
+
++LIB_LD_ADD =-lnetsnmp
++LIB_LD_ADD_PATH =-L../../snmplib
++
+ all: standardall
+
+ libnetsnmphelpers.$(LIB_EXTENSION)$(LIB_VERSION): $(LOBJS)
+- $(LIB_LD_CMD) $@ $(LOBJS) @LD_NO_UNDEFINED@ $(LDFLAGS) $(LIB_LD_LIBS)
+- $(RANLIB) $@
++ $(LIB_LD_CMD) $@ $(LIB_LD_ADD_PATH) $(LOBJS) @LD_NO_UNDEFINED@ $(LDFLAGS) $(LIB_LD_LIBS) $(LIB_LD_ADD)
++ $(RANLIB) $@ $(LIB_LD_ADD)
+--- a/snmplib/Makefile.in
++++ b/snmplib/Makefile.in
+@@ -223,6 +223,9 @@ TOBJS=$(LOBJS)
+
+ FEATUREFILE = $(top_builddir)/include/net-snmp/library/features.h
+
++# To satisfy -zdefs
++LIB_LD_ADD =-lnsl -lsocket -L$(libdir)
++
+ #
+ CPPFLAGS = $(TOP_INCLUDES) -I. $(SNMPLIB_INCLUDES) @CPPFLAGS@
+
+@@ -230,8 +233,8 @@ all: standardall
+
+ # how to build the libraries.
+ libnetsnmp.$(LIB_EXTENSION)$(LIB_VERSION): $(TOBJS)
+- $(LIB_LD_CMD) $@ $(TOBJS) @LD_NO_UNDEFINED@ $(LDFLAGS) @LNETSNMPLIBS@
+- $(RANLIB) $@
++ $(LIB_LD_CMD) $@ $(TOBJS) @LD_NO_UNDEFINED@ $(LDFLAGS) @LNETSNMPLIBS@ $(LIB_LD_ADD)
++ $(RANLIB) $@ $(LIB_LD_ADD)
+
+ libsnmp.$(LIB_EXTENSION)$(LIB_VERSION): $(TOBJS)
+ $(LIB_LD_CMD) $@ $(TOBJS) @LD_NO_UNDEFINED@ $(LDFLAGS) @LNETSNMPLIBS@
Added: csw/mgar/pkg/netsnmp/trunk/files/0012-Makefile.PL.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0012-Makefile.PL.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0012-Makefile.PL.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,11 @@
+--- a/perl/agent/Makefile.PL
++++ b/perl/agent/Makefile.PL
+@@ -89,7 +89,7 @@ sub InitMakeParams {
+ $Params{'LIBS'} = "-L../../snmplib/.libs -L../../snmplib/ -L../../agent/.libs -L../../agent/ " . $Params{'LIBS'};
+ $Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
+ # } else {
+- $Params{'LIBS'} = `$opts->{'nsconfig'} --libdir` . $Params{'LIBS'};
++ $Params{'LIBS'} = $Params{'LIBS'} . `$opts->{'nsconfig'} --libdir`;
+ # $Params{'PREREQ_PM'} = {'NetSNMP::OID' => '0.1'};
+ }
+ $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
Added: csw/mgar/pkg/netsnmp/trunk/files/0015+0016-vmstat_solaris2.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0015+0016-vmstat_solaris2.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0015+0016-vmstat_solaris2.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,82 @@
+--- a/agent/mibgroup/ucd-snmp/vmstat_solaris2.c
++++ b/agent/mibgroup/ucd-snmp/vmstat_solaris2.c
+@@ -590,6 +590,7 @@ update_stats(unsigned int registrationNumber, void *clientarg)
+ cpu_sum += (css_new->css_cpu[i] - css_old->css_cpu[i]);
+ }
+
++ if (cpu_sum == 0) { cpu_sum = 1; }
+ /*
+ * Now calculate the absolute percentage values
+ * Looks somewhat complicated sometimes but tries to get around using floats to increase speed
+--- a/agent/mibgroup/ucd-snmp/vmstat_solaris2.c
++++ b/agent/mibgroup/ucd-snmp/vmstat_solaris2.c
+@@ -703,7 +704,12 @@ var_extensible_vmstat(struct variable *vp,
+ case CPUIDLE:
+ return ((u_char *) (&cpu_perc[CPU_IDLE]));
+ case CPURAWUSER:
+- take_snapshot(&raw_values);
++ /* Take the current snapshot */
++ if ((take_snapshot(&raw_values) == -1) && (raw_values.css_cpus == 0)) {
++ snmp_log(LOG_WARNING,
++ "vmstat_solaris2 (var_extensible_vmstat): Something went wrong with take_snapshot.\n");
++ return (NULL);
++ }
+ /*
+ * LINTED has to be 'long'
+ */
+@@ -717,7 +723,12 @@ var_extensible_vmstat(struct variable *vp,
+ * (Has been changed to Counter32 in the latest MIB version!)
+ */
+ case CPURAWSYSTEM:
+- take_snapshot(&raw_values);
++ /* Take the current snapshot */
++ if ((take_snapshot(&raw_values) == -1) && (raw_values.css_cpus == 0)) {
++ snmp_log(LOG_WARNING,
++ "vmstat_solaris2 (var_extensible_vmstat): Something went wrong with take_snapshot.\n");
++ return (NULL);
++ }
+ /*
+ * LINTED has to be 'long'
+ */
+@@ -726,7 +737,12 @@ var_extensible_vmstat(struct variable *vp,
+ raw_values.css_cpu[CPU_WAIT]) / raw_values.css_cpus);
+ return ((u_char *) (&long_ret));
+ case CPURAWIDLE:
+- take_snapshot(&raw_values);
++ /* Take the current snapshot */
++ if ((take_snapshot(&raw_values) == -1) && (raw_values.css_cpus == 0)) {
++ snmp_log(LOG_WARNING,
++ "vmstat_solaris2 (var_extensible_vmstat): Something went wrong with take_snapshot.\n");
++ return (NULL);
++ }
+ /*
+ * LINTED has to be 'long'
+ */
+@@ -734,7 +750,12 @@ var_extensible_vmstat(struct variable *vp,
+ (long) (raw_values.css_cpu[CPU_IDLE] / raw_values.css_cpus);
+ return ((u_char *) (&long_ret));
+ case CPURAWWAIT:
+- take_snapshot(&raw_values);
++ /* Take the current snapshot */
++ if ((take_snapshot(&raw_values) == -1) && (raw_values.css_cpus == 0)) {
++ snmp_log(LOG_WARNING,
++ "vmstat_solaris2 (var_extensible_vmstat): Something went wrong with take_snapshot.\n");
++ return (NULL);
++ }
+ /*
+ * LINTED has to be 'long'
+ */
+@@ -742,7 +763,12 @@ var_extensible_vmstat(struct variable *vp,
+ (long) (raw_values.css_cpu[CPU_WAIT] / raw_values.css_cpus);
+ return ((u_char *) (&long_ret));
+ case CPURAWKERNEL:
+- take_snapshot(&raw_values);
++ /* Take the current snapshot */
++ if ((take_snapshot(&raw_values) == -1) && (raw_values.css_cpus == 0)) {
++ snmp_log(LOG_WARNING,
++ "vmstat_solaris2 (var_extensible_vmstat): Something went wrong with take_snapshot.\n");
++ return (NULL);
++ }
+ /*
+ * LINTED has to be 'long'
+ */
Added: csw/mgar/pkg/netsnmp/trunk/files/0024-kernel_sunos5.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0024-kernel_sunos5.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0024-kernel_sunos5.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,629 @@
+--- a/agent/mibgroup/kernel_sunos5.c
++++ b/agent/mibgroup/kernel_sunos5.c
+@@ -60,6 +60,8 @@
+ #include <net/if.h>
+ #include <netinet/in.h>
+
++#include <libdladm.h>
++#include <libdllink.h>
+ /*-
+ * Includes of local application header files
+ */
+@@ -82,15 +84,15 @@ kstat_ctl_t *kstat_fd = 0;
+ static
+ mibcache Mibcache[MIBCACHE_SIZE+1] = {
+ {MIB_SYSTEM, 0, (void *) -1, 0, 0, 0, 0},
+- {MIB_INTERFACES, 50 * sizeof(mib2_ifEntry_t), (void *) -1, 0, 30, 0,
++ {MIB_INTERFACES, 128 * sizeof(mib2_ifEntry_t), (void *) -1, 0, 30, 0,
+ 0},
+ {MIB_AT, 0, (void *) -1, 0, 0, 0, 0},
+ {MIB_IP, sizeof(mib2_ip_t), (void *) -1, 0, 60, 0, 0},
+- {MIB_IP_ADDR, 20 * sizeof(mib2_ipAddrEntry_t), (void *) -1, 0, 60, 0,
++ {MIB_IP_ADDR, 128 * sizeof(mib2_ipAddrEntry_t), (void *) -1, 0, 60, 0,
+ 0},
+- {MIB_IP_ROUTE, 200 * sizeof(mib2_ipRouteEntry_t), (void *) -1, 0, 30,
++ {MIB_IP_ROUTE, 400 * sizeof(mib2_ipRouteEntry_t), (void *) -1, 0, 30,
+ 0, 0},
+- {MIB_IP_NET, 100 * sizeof(mib2_ipNetToMediaEntry_t), (void *) -1, 0,
++ {MIB_IP_NET, 400 * sizeof(mib2_ipNetToMediaEntry_t), (void *) -1, 0,
+ 300, 0, 0},
+ {MIB_ICMP, sizeof(mib2_icmp_t), (void *) -1, 0, 60, 0, 0},
+ {MIB_TCP, sizeof(mib2_tcp_t), (void *) -1, 0, 60, 0, 0},
+@@ -105,13 +107,13 @@ mibcache Mibcache[MIBCACHE_SIZE+1] = {
+ {MIB_SNMP, 0, (void *) -1, 0, 0, 0, 0},
+ #ifdef SOLARIS_HAVE_IPV6_MIB_SUPPORT
+ #ifdef SOLARIS_HAVE_RFC4293_SUPPORT
+- {MIB_IP_TRAFFIC_STATS, 20 * sizeof(mib2_ipIfStatsEntry_t), (void *)-1, 0,
++ {MIB_IP_TRAFFIC_STATS, 128 * sizeof(mib2_ipIfStatsEntry_t), (void *)-1, 0,
+ 30, 0, 0},
+- {MIB_IP6, 20 * sizeof(mib2_ipIfStatsEntry_t), (void *)-1, 0, 30, 0, 0},
++ {MIB_IP6, 128 * sizeof(mib2_ipIfStatsEntry_t), (void *)-1, 0, 30, 0, 0},
+ #else
+- {MIB_IP6, 20 * sizeof(mib2_ipv6IfStatsEntry_t), (void *)-1, 0, 30, 0, 0},
++ {MIB_IP6, 128 * sizeof(mib2_ipv6IfStatsEntry_t), (void *)-1, 0, 30, 0, 0},
+ #endif
+- {MIB_IP6_ADDR, 20 * sizeof(mib2_ipv6AddrEntry_t), (void *)-1, 0, 30, 0, 0},
++ {MIB_IP6_ADDR, 128 * sizeof(mib2_ipv6AddrEntry_t), (void *)-1, 0, 30, 0, 0},
+ {MIB_TCP6_CONN, 1000 * sizeof(mib2_tcp6ConnEntry_t), (void *) -1, 0, 30,
+ 0, 0},
+ {MIB_UDP6_ENDPOINT, 1000 * sizeof(mib2_udp6Entry_t), (void *) -1, 0, 30,
+@@ -184,9 +186,9 @@ getif(mib2_ifEntry_t *ifbuf, size_t size, req_e req_type, mib2_ifEntry_t *resp,
+ size_t *length, int (*comp)(void *, void *), void *arg);
+ static void
+ set_if_info(mib2_ifEntry_t *ifp, unsigned index, char *name, uint64_t flags,
+- int mtu);
++ boolean_t flags_unknown, int mtu);
+ static int get_if_stats(mib2_ifEntry_t *ifp);
+-
++static int link_to_phydev(char *link, char *phy_devname);
+ #if defined(HAVE_IF_NAMEINDEX) && defined(NETSNMP_INCLUDE_IFTABLE_REWRITES)
+ static int _dlpi_open(const char *devname);
+ static int _dlpi_get_phys_address(int fd, char *paddr, int maxlen,
+@@ -294,7 +296,9 @@ getKstatInt(const char *classname, const char *statname,
+ kstat_t *ks;
+ kid_t kid;
+ kstat_named_t *named;
++
+ int ret = -1; /* fail unless ... */
++ int lookup_stat = 0;
+
+ if (kstat_fd == 0) {
+ kstat_fd = kstat_open();
+@@ -305,27 +309,88 @@ getKstatInt(const char *classname, const char *statname,
+ if ((ksc = kstat_fd) == NULL) {
+ goto Return;
+ }
+- ks = kstat_lookup(ksc, classname, -1, statname);
+- if (ks == NULL) {
+- DEBUGMSGTL(("kernel_sunos5", "class %s, stat %s not found\n",
+- classname ? classname : "NULL",
+- statname ? statname : "NULL"));
+- goto Return;
+- }
+- kid = kstat_read(ksc, ks, NULL);
+- if (kid == -1) {
+- DEBUGMSGTL(("kernel_sunos5", "cannot read class %s stats %s\n",
+- classname ? classname : "NULL", statname ? statname : "NULL"));
+- goto Return;
+- }
+- named = kstat_data_lookup(ks, varname);
+- if (named == NULL) {
+- DEBUGMSGTL(("kernel_sunos5", "no var %s for class %s stat %s\n",
+- varname, classname ? classname : "NULL",
+- statname ? statname : "NULL"));
+- goto Return;
++
++ if ((ks = kstat_lookup(ksc, statname, -1, "link")) != NULL)
++ {
++ kid = kstat_read(ksc, ks, NULL);
++ if (kid == -1) {
++ DEBUGMSGTL(("kernel_sunos5", "cannot read class %s stats %s\n",
++ statname ? statname : "NULL", "link"));
++ }
++ else
++ {
++ named = kstat_data_lookup(ks, varname);
++ if (named == NULL) {
++ DEBUGMSGTL(("kernel_sunos5", "no var %s for class %s stat %s\n",
++ varname, statname ? statname : "NULL", "link"));
++ }
++ else {
++ switch (named->data_type) {
++#ifdef KSTAT_DATA_INT32 /* Solaris 2.6 and up */
++ case KSTAT_DATA_INT32:
++ if(named->value.i32)
++ lookup_stat = 1;
++ break;
++ case KSTAT_DATA_UINT32:
++ if(named->value.ui32)
++ lookup_stat = 1;
++ break;
++ case KSTAT_DATA_INT64:
++ if(named->value.i64)
++ lookup_stat = 1;
++ break;
++ case KSTAT_DATA_UINT64:
++ if(named->value.ui64)
++ lookup_stat = 1;
++ break;
++#else
++ case KSTAT_DATA_LONG:
++ if(named->value.l)
++ lookup_stat = 1;
++ break;
++ case KSTAT_DATA_ULONG:
++ if(named->value.ul)
++ lookup_stat = 1;
++ break;
++ case KSTAT_DATA_LONGLONG:
++ if(named->value.ll)
++ lookup_stat = 1;
++ break;
++ case KSTAT_DATA_ULONGLONG:
++ if(named->value.ull)
++ lookup_stat = 1;
++ break;
++#endif
++ }
++ }
++ }
+ }
+-
++
++ if(!lookup_stat)
++ {
++ ks = kstat_lookup(ksc, classname, -1, statname);
++ if (ks == NULL) {
++ DEBUGMSGTL(("kernel_sunos5", "class %s, stat %s not found\n",
++ classname ? classname : "NULL",
++ statname ? statname : "NULL"));
++ goto Return;
++ }
++
++ kid = kstat_read(ksc, ks, NULL);
++ if (kid == -1) {
++ DEBUGMSGTL(("kernel_sunos5", "cannot read class %s stats %s\n",
++ classname ? classname : "NULL", statname ? statname : "NULL"));
++ goto Return;
++ }
++
++ named = kstat_data_lookup(ks, varname);
++ if (named == NULL) {
++ DEBUGMSGTL(("kernel_sunos5", "no var %s for class %s stat %s\n",
++ varname, classname ? classname : "NULL",
++ statname ? statname : "NULL"));
++ goto Return;
++ }
++ }
+ ret = 0; /* maybe successful */
+ switch (named->data_type) {
+ #ifdef KSTAT_DATA_INT32 /* Solaris 2.6 and up */
+@@ -442,11 +507,20 @@ getKstat(const char *statname, const char *varname, void *value)
+ /*
+ * Get the named statistics
+ */
+- if ((ks = kstat_lookup(ksc, module_name, instance, statname)) == NULL) {
+- ret = -10;
+- goto Return; /* kstat errors */
+- }
+
++ if ((ks = kstat_lookup(ksc, module_name, instance, statname)) == NULL)
++ {
++ /*
++ * Try to lookup the kstat module with
++ * modulename = linkname and statname = "link".
++ */
++
++ if ((ks = kstat_lookup(ksc, statname, 0, "link")) == NULL) {
++ ret = -10;
++ goto Return; /* kstat errors */
++ }
++ }
++
+ if (kstat_read(ksc, ks, NULL) <= 0) {
+ ret = -10;
+ goto Return; /* kstat errors */
+@@ -1080,18 +1154,21 @@ getmib(int groupname, int subgroupname, void **statbuf, size_t *size,
+ static int
+ _dlpi_open(const char *devname)
+ {
+- char *devstr;
++ char devstr[255], devstrcpy[255];
+ int fd = -1;
+ int ppa = -1;
++ int ret = -1;
+
+ DEBUGMSGTL(("kernel_sunos5", "_dlpi_open called\n"));
+
+ if (devname == NULL)
+- return (-1);
++ return (-1);
++
++ ret = snprintf(devstr, sizeof(devstr), "/dev/%s", devname);
+
+- if ((devstr = malloc(5 + strlen(devname) + 1)) == NULL)
+- return (-1);
+- (void) sprintf(devstr, "/dev/%s", devname);
++ if(ret < 0 || ret > sizeof(devstr) - 1)
++ return -1;
++
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "devstr(%s)\n", devstr));
+ /*
+ * First try opening the device using style 1, if the device does not
+@@ -1102,13 +1179,49 @@ _dlpi_open(const char *devname)
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "style1 open(%s)\n", devstr));
+ if ((fd = open(devstr, O_RDWR | O_NONBLOCK)) < 0) {
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "style1 open failed\n"));
+- if (_dlpi_parse_devname(devstr, &ppa) == 0) {
+- DEBUGMSGTL(("kernel_sunos5:dlpi", "style2 parse: %s, %d\n",
+- devstr, ppa));
+- /* try style 2 */
+- DEBUGMSGTL(("kernel_sunos5:dlpi", "style2 open(%s)\n", devstr));
++ fd = -1;
++ } else {
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "style1 open succeeded\n"));
++ }
++
++ /* Creating a copy of the devname incase style 3 open
++ * is required
++ */
++ ret = strlcpy(devstrcpy, devstr, sizeof(devstrcpy));
++
++ if(ret > sizeof(devstrcpy) - 1)
++ return -1;
+
+- if ((fd = open(devstr, O_RDWR | O_NONBLOCK)) != -1) {
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "devstrcpy(%s)\n", devstrcpy));
++
++
++ if (fd == -1 ) {
++ ret = snprintf(devstr, sizeof(devstr), "/dev/net/%s", devname);
++
++ if(ret < 0 || ret > sizeof(devstr) - 1)
++ return -1;
++
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "devstr(%s)\n", devstr));
++
++ /* try style 2 */
++
++ if ((fd = open(devstr, O_RDWR | O_NONBLOCK)) < 0) {
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "style2 open failed\n"));
++ fd = -1;
++ } else {
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "style2 open succeeded\n"));
++ }
++ }
++
++
++ if (fd == -1 ) {
++ if (_dlpi_parse_devname(devstrcpy, &ppa) == 0) {
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "style3 parse: %s, %d\n",
++ devstrcpy, ppa));
++ /* try style 3 */
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "style3 open(%s)\n", devstrcpy));
++
++ if ((fd = open(devstrcpy, O_RDWR | O_NONBLOCK)) != -1) {
+ if (_dlpi_attach(fd, ppa) == 0) {
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "attached\n"));
+ } else {
+@@ -1117,16 +1230,11 @@ _dlpi_open(const char *devname)
+ fd = -1;
+ }
+ } else {
+- DEBUGMSGTL(("kernel_sunos5:dlpi", "style2 open failed\n"));
++ DEBUGMSGTL(("kernel_sunos5:dlpi", "style3 open failed\n"));
+ }
+ }
+- } else {
+- DEBUGMSGTL(("kernel_sunos5:dlpi", "style1 open succeeded\n"));
+ }
+
+- /* clean up */
+- free(devstr);
+-
+ return (fd);
+ }
+
+@@ -1141,7 +1249,9 @@ _dlpi_get_phys_address(int fd, char *addr, int maxlen, int *addrlen)
+ struct strbuf ctlbuf;
+ char buf[MAX(DL_PHYS_ADDR_ACK_SIZE+64, DL_ERROR_ACK_SIZE)];
+ int flag = 0;
+-
++ struct pollfd pfd;
++ int timeout = 100;
++
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "_dlpi_get_phys_address\n"));
+
+ paddr_req.dl_primitive = DL_PHYS_ADDR_REQ;
+@@ -1154,7 +1264,22 @@ _dlpi_get_phys_address(int fd, char *addr, int maxlen, int *addrlen)
+ ctlbuf.maxlen = sizeof(buf);
+ ctlbuf.len = 0;
+ ctlbuf.buf = buf;
+- if (getmsg(fd, &ctlbuf, NULL, &flag) < 0)
++
++ pfd.fd = fd;
++ pfd.events = POLLIN | POLLPRI;
++
++ switch (poll(&pfd, 1, timeout)) {
++ default:
++ if (pfd.revents & POLLHUP)
++ return (-1);
++ break;
++ case 0:
++ return (-1);
++ case -1:
++ return (-1);
++ }
++
++ if (getmsg(fd, &ctlbuf, NULL, &flag) < 0)
+ return (-1);
+
+ if (ctlbuf.len < sizeof(uint32_t))
+@@ -1196,6 +1321,8 @@ _dlpi_get_iftype(int fd, unsigned int *iftype)
+ struct strbuf ctlbuf;
+ char buf[MAX(DL_INFO_ACK_SIZE, DL_ERROR_ACK_SIZE)];
+ int flag = 0;
++ struct pollfd pfd;
++ int timeout = 100;
+
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "_dlpi_get_iftype\n"));
+
+@@ -1210,7 +1337,22 @@ _dlpi_get_iftype(int fd, unsigned int *iftype)
+ ctlbuf.maxlen = sizeof(buf);
+ ctlbuf.len = 0;
+ ctlbuf.buf = buf;
+- if (getmsg(fd, &ctlbuf, NULL, &flag) < 0) {
++
++ pfd.fd = fd;
++ pfd.events = POLLIN | POLLPRI;
++
++ switch (poll(&pfd, 1, timeout)) {
++ default:
++ if (pfd.revents & POLLHUP)
++ return (-1);
++ break;
++ case 0:
++ return (-1);
++ case -1:
++ return (-1);
++ }
++
++ if (getmsg(fd, &ctlbuf, NULL, &flag) < 0) {
+ DEBUGMSGTL(("kernel_sunos5:dlpi", "getmsg failed: %d\n", errno));
+ return (-1);
+ }
+@@ -1367,8 +1509,9 @@ getif(mib2_ifEntry_t *ifbuf, size_t size, req_e req_type,
+ mib2_ifEntry_t *ifp;
+ int nentries = size / sizeof(mib2_ifEntry_t);
+ found_e result = NOT_FOUND;
+- boolean_t if_isv6;
++ boolean_t if_isv6, flags_unknown;
+ uint64_t if_flags;
++ short mtu = 0;
+ struct if_nameindex *ifname, *ifnp;
+
+ lifrp = &lifreq;
+@@ -1400,6 +1543,7 @@ getif(mib2_ifEntry_t *ifbuf, size_t size, req_e req_type,
+ memcpy(lifrp->lifr_name, ifnp->if_name, LIFNAMSIZ);
+ if_isv6 = B_FALSE;
+
++ flags_unknown = B_FALSE;
+ if (ioctl(ifsd, SIOCGLIFFLAGS, lifrp) < 0) {
+ if (ifsd6 == -1) {
+ if ((ifsd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+@@ -1408,17 +1552,19 @@ getif(mib2_ifEntry_t *ifbuf, size_t size, req_e req_type,
+ }
+ }
+ if (ioctl(ifsd6, SIOCGLIFFLAGS, lifrp) < 0) {
+- snmp_log(LOG_ERR, "SIOCGLIFFLAGS %s: %s\n",
+- lifrp->lifr_name, strerror(errno));
+- continue;
++ DEBUGMSGTL(("kernel_sunos5",
++ "...... SIOCGLIFFLAGS failed\n"));
++ flags_unknown = B_TRUE;
+ }
+ if_isv6 = B_TRUE;
+ }
+ if_flags = lifrp->lifr_flags;
+
+ if (ioctl(if_isv6?ifsd6:ifsd, SIOCGLIFMTU, lifrp) < 0) {
++ mtu = 0;
+ DEBUGMSGTL(("kernel_sunos5", "...... SIOCGLIFMTU failed\n"));
+- continue;
++ } else {
++ mtu = lifrp->lifr_mtu;
+ }
+
+ memset(ifp, 0, sizeof(mib2_ifEntry_t));
+@@ -1433,11 +1579,12 @@ getif(mib2_ifEntry_t *ifbuf, size_t size, req_e req_type,
+ }
+
+ set_if_info(ifp, ifnp->if_index, ifnp->if_name, if_flags,
+- lifrp->lifr_metric);
++ flags_unknown, mtu);
+
+ if (get_if_stats(ifp) < 0) {
++ snmp_log(LOG_ERR, "Failed to get interface statistics for %s\n",
++ ifnp->if_name);
+ DEBUGMSGTL(("kernel_sunos5", "...... get_if_stats failed\n"));
+- continue;
+ }
+
+ /*
+@@ -1614,11 +1761,155 @@ getif(mib2_ifEntry_t *ifbuf, size_t size, req_e req_type,
+ }
+ #endif /*defined(HAVE_IF_NAMEINDEX)&&defined(NETSNMP_INCLUDE_IFTABLE_REWRITES)*/
+
++int link_to_phydev(char *link, char *phy_devname)
++{
++ char *key = NULL;
++ datalink_id_t linkid;
++ dladm_phys_attr_t dpa;
++ dladm_handle_t handle;
++
++ if (dladm_open(&handle, NULL) != DLADM_STATUS_OK) {
++ DEBUGMSGTL(("kernel_sunos5","dladm_open failed "
++ "with errno=%d\n",errno));
++ return (-1);
++ }
++
++ if (dladm_name2info(handle, link, &linkid, NULL, NULL, NULL) !=
++ DLADM_STATUS_OK) {
++ DEBUGMSGTL(("kernel_sunos5","dladm_name2info failed "
++ "with errno=%d\n",errno));
++ dladm_close(handle);
++ return (-1);
++ }
++
++ /*
++ * Get the device name of the link, which will be used as the door
++ * file name used to communicate with the driver.
++ */
++ if (dladm_phys_info(handle, linkid, &dpa, DLADM_OPT_ACTIVE) !=
++ DLADM_STATUS_OK) {
++ DEBUGMSGTL(("kernel_sunos5","dladm_phys_info failed "
++ "with errno=%d\n",errno));
++ dladm_close(handle);
++ return (-1);
++ }
++
++ if(dpa.dp_dev == NULL) {
++ DEBUGMSGTL(("kernel_sunos5","device name from "
++ "dladm_phys_info = NULL\n"));
++ dladm_close(handle);
++ return -1;
++
++ }
++ strcpy(phy_devname, dpa.dp_dev);
++ dladm_close(handle);
++
++ return 0;
++}
++
++
++static int getKstatIntInstance(const char *classname, int instance,
++ const char *statname, const char *varname,
++ int *value)
++{
++ kstat_ctl_t *ksc;
++ kstat_t *ks;
++ kid_t kid;
++ kstat_named_t *named;
++
++ int ret = -1; /* fail unless ... */
++ int lookup_stat = 0;
++
++ DEBUGMSGTL(("kernel_sunos5","\n Inside getKstatIntInstance: variable = %s",
++ varname));
++
++ if (kstat_fd == 0) {
++ kstat_fd = kstat_open();
++ if (kstat_fd == 0) {
++ snmp_log_perror("kstat_open");
++ }
++ }
++ if ((ksc = kstat_fd) == NULL) {
++ goto Return;
++ }
++
++ ks = kstat_lookup(ksc, classname, instance, statname);
++ if (ks == NULL) {
++ DEBUGMSGTL(("kernel_sunos5","\nclass %s, stat %s not found\n",
++ classname ? classname : "NULL",
++ statname ? statname : "NULL"));
++ goto Return;
++ }
++
++ kid = kstat_read(ksc, ks, NULL);
++ if (kid == -1) {
++ DEBUGMSGTL(("kernel_sunos5","\ncannot read class %s stats %s\n",
++ classname ? classname : "NULL",
++ statname ? statname : "NULL"));
++ goto Return;
++ }
++
++ named = kstat_data_lookup(ks, varname);
++ if (named == NULL) {
++ DEBUGMSGTL(("kernel_sunos5","\nno var %s for class %s stat %s\n",
++ varname, classname ? classname : "NULL",
++ statname ? statname : "NULL"));
++ goto Return;
++ }
++ ret = 0; /* maybe successful */
++ switch (named->data_type) {
++#ifdef KSTAT_DATA_INT32 /* Solaris 2.6 and up */
++ case KSTAT_DATA_INT32:
++ DEBUGMSGTL(("kernel_sunos5"," value: %d\n", named->value.i32));
++ *value = named->value.i32;
++ break;
++ case KSTAT_DATA_UINT32:
++ DEBUGMSGTL(("kernel_sunos5"," value: %u\n", named->value.ui32));
++ *value = named->value.ui32;
++ break;
++ case KSTAT_DATA_INT64:
++ DEBUGMSGTL(("kernel_sunos5"," value: %ld\n", named->value.i64));
++ *value = named->value.i64;
++ break;
++ case KSTAT_DATA_UINT64:
++ DEBUGMSGTL(("kernel_sunos5"," value: %llu\n", named->value.ui64));
++ *value = named->value.ui64;
++ break;
++#else
++ case KSTAT_DATA_LONG:
++ DEBUGMSGTL(("kernel_sunos5"," value: %ld\n", named->value.l));
++ *value = named->value.l;
++ break;
++ case KSTAT_DATA_ULONG:
++ DEBUGMSGTL(("kernel_sunos5"," value: %lu\n", named->value.ul));
++ *value = named->value.ul;
++ break;
++ case KSTAT_DATA_LONGLONG:
++ DEBUGMSGTL(("kernel_sunos5"," value: %lld\n", (long) named->value.ll));
++ *value = (long)named->value.ll;
++ break;
++ case KSTAT_DATA_ULONGLONG:
++ DEBUGMSGTL(("kernel_sunos5"," value: %llu\n",
++ (unsigned long) named->value.ull));
++ *value = (unsigned long)named->value.ull;
++ break;
++#endif
++ default:
++ ret = -1; /* fail */
++ break;
++ }
++ Return:
++ return ret;
++}
++
+ static void
+ set_if_info(mib2_ifEntry_t *ifp, unsigned index, char *name, uint64_t flags,
+- int mtu)
++ boolean_t flags_unknown, int mtu)
+ {
+ boolean_t havespeed = B_FALSE;
++ char phydevname[100];
++ char devbasename[100];
++ int instance = -1;
+
+ /*
+ * Set basic information
+@@ -1627,7 +1918,10 @@ set_if_info(mib2_ifEntry_t *ifp, unsigned index, char *name, uint64_t flags,
+ ifp->ifDescr.o_length = strlen(name);
+ strcpy(ifp->ifDescr.o_bytes, name);
+ ifp->ifAdminStatus = (flags & IFF_UP) ? 1 : 2;
+- ifp->ifOperStatus = ((flags & IFF_UP) && (flags & IFF_RUNNING)) ? 1 : 2;
++ if (flags_unknown)
++ ifp->ifOperStatus = 4; /* status unknown */
++ else
++ ifp->ifOperStatus = ((flags & IFF_UP) && (flags & IFF_RUNNING)) ? 1 : 2;
+ ifp->ifLastChange = 0; /* Who knows ... */
+ ifp->flags = flags;
+ ifp->ifMtu = mtu;
+@@ -1649,14 +1943,26 @@ set_if_info(mib2_ifEntry_t *ifp, unsigned index, char *name, uint64_t flags,
+ * this is good
+ */
+ havespeed = B_TRUE;
++ } else if ((getKstatInt("link", name, "ifspeed", &ifp->ifSpeed) == 0) ||
++ (getKstatInt("link", name, "ifSpeed", &ifp->ifSpeed) == 0)) {
++ havespeed = B_TRUE;
+ }
+-
+ /* make ifOperStatus depend on link status if available */
+ if (ifp->ifAdminStatus == 1) {
+ int i_tmp;
+ /* only UPed interfaces get correct link status - if any */
+ if (getKstatInt(NULL, name,"link_up",&i_tmp) == 0) {
+ ifp->ifOperStatus = i_tmp ? 1 : 2;
++ } else if(link_to_phydev(name, phydevname) == 0) {
++ strcpy(devbasename, phydevname);
++ DEBUGMSGTL(("kernel_sunos5","phydevname = %s\n", phydevname));
++ _dlpi_parse_devname(devbasename, &instance);
++ DEBUGMSGTL(("kernel_sunos5","devbasename = %s, "
++ "instance= %d\n", devbasename, instance));
++ if(getKstatIntInstance(devbasename, instance, "phys",
++ "link_up", &i_tmp) == 0) {
++ ifp->ifOperStatus = i_tmp ? 1 : 2;
++ }
+ #ifdef IFF_FAILED
+ } else if (flags & IFF_FAILED) {
+ /*
Added: csw/mgar/pkg/netsnmp/trunk/files/0034-manpage-snmptrapd.conf.5.def.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0034-manpage-snmptrapd.conf.5.def.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0034-manpage-snmptrapd.conf.5.def.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,19 @@
+--- a/man/snmptrapd.conf.5.def
++++ b/man/snmptrapd.conf.5.def
+@@ -203,12 +203,11 @@ SNMPv1 traps being converted as per RFC 2576, before being passed to the
+ program.
+ The input format is as follows, one entry per line:
+ .RS
+-.IP HOSTNAME
+-The name of the host that sent the notification, as determined by
+-.IR gethostbyaddr(3) .
++.IP HOSTDETAILS
++The details of the host that sent the notification in the format :
++.IP
++Host : HOSTNAME (PROTOCOL: [IPADDRESS]:PORTNO)
+ .br
+-.IP IPADDRESS
+-The IP address of the host that sent the notification.
+ .\"
+ .\" XXX - What about non-IPv4 transports?
+ .\"
Added: csw/mgar/pkg/netsnmp/trunk/files/0035-bug-1849903.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0035-bug-1849903.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0035-bug-1849903.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,123 @@
+--- a/agent/mibgroup/if-mib/ifTable/ifTable_data_access.c
++++ b/agent/mibgroup/if-mib/ifTable/ifTable_data_access.c
+@@ -14,6 +14,12 @@
+
+ netsnmp_feature_require(container_linked_list)
+
++typedef struct cd_container_s {
++ netsnmp_container *current;
++ netsnmp_container *deleted;
++} cd_container;
++
++
+ /*
+ * include our parent header
+ */
+@@ -485,8 +491,21 @@ static void
+ _add_new_interface(netsnmp_interface_entry *ifentry,
+ netsnmp_container *container)
+ {
+- ifTable_rowreq_ctx *rowreq_ctx;
+-
++ ifTable_rowreq_ctx *rowreq_ctx, *container_entry;
++ netsnmp_iterator *ctxit;
++ ctxit = CONTAINER_ITERATOR(container);
++ container_entry = ITERATOR_FIRST(ctxit);
++
++ for(; container_entry; container_entry = ITERATOR_NEXT(ctxit)) {
++ if(!strcmp(ifentry->name, container_entry->data.ifName) && \
++ ifentry->index != container_entry->data.ifentry->index) {
++ DEBUGMSGTL(("ifTable:access", "removing old entry %s (index %d != %d)\n",
++ container_entry->data.ifName, container_entry->data.ifentry->index, ifentry->index));
++ se_remove_value_from_slist("interfaces", container_entry->data.ifName);
++ CONTAINER_REMOVE(container, container_entry);
++ ifTable_release_rowreq_ctx(container_entry);
++ }
++ }
+ DEBUGMSGTL(("ifTable:access", "creating new entry\n"));
+
+ /*
+@@ -533,6 +552,21 @@ _add_new_interface(netsnmp_interface_entry *ifentry,
+ }
+ }
+ }
++
++/**
++ * delete removed entry
++ */
++static void
++_delete_missing_interface(ifTable_rowreq_ctx *rowreq_ctx,
++ netsnmp_container *container)
++{
++ DEBUGMSGTL(("ifTable:access", "removing missing entry %s\n",
++ rowreq_ctx->data.ifName));
++
++ CONTAINER_REMOVE(container, rowreq_ctx);
++
++ ifTable_release_rowreq_ctx(rowreq_ctx);
++}
+
+ /**
+ * add new entry
+--- a/agent/mibgroup/if-mib/ifTable/ifTable_data_access.h
++++ b/agent/mibgroup/if-mib/ifTable/ifTable_data_access.h
+@@ -50,6 +50,8 @@ extern "C" {
+
+ #define IFTABLE_REMOVE_MISSING_AFTER (5 * 60) /* seconds */
+
++#define IFTABLE_REMOVE_MISSING_AFTER (5 * 60) /* seconds */
++
+ void ifTable_container_init(netsnmp_container
+ **container_ptr_ptr,
+ netsnmp_cache * cache);
+--- a/snmplib/snmp_enum.c
++++ b/snmplib/snmp_enum.c
+@@ -220,6 +220,28 @@ se_find_value_in_list(struct snmp_enum_list *list, const char *label)
+ return SE_DNE; /* XXX: um, no good solution here */
+ }
+
++int se_remove_value_from_list(struct snmp_enum_list **list, const char *label)
++{
++ struct snmp_enum_list *lastlist;
++ if(!list)
++ return SE_DNE;
++
++ lastlist = NULL;
++ while(*list) {
++ if(strcmp((*list)->label, label) == 0) {
++ free((*list)->label);
++ if(lastlist)
++ lastlist->next = (*list)->next;
++ free(*list);
++ *list = NULL;
++ return 0;
++ }
++ lastlist = *list;
++ (*list) = (*list)->next;
++ }
++
++}
++
+ int
+ se_find_free_value_in_list(struct snmp_enum_list *list)
+ {
+@@ -341,6 +363,19 @@ se_find_label_in_slist(const char *listname, int value)
+ return (se_find_label_in_list(se_find_slist(listname), value));
+ }
+
++void se_remove_value_from_slist(const char *listname, const char *label)
++{
++ struct snmp_enum_list_str *sptr, *lastp = NULL;
++ struct snmp_enum_list *list;
++ if (!listname)
++ return;
++
++ for (sptr = sliststorage;
++ sptr != NULL; lastp = sptr, sptr = sptr->next)
++ if (sptr->name && strcmp(sptr->name, listname) == 0)
++ se_remove_value_from_list(&sptr->list, label);
++}
++
+ int
+ se_find_value_in_slist(const char *listname, const char *label)
+ {
Added: csw/mgar/pkg/netsnmp/trunk/files/0048+0027-mnt-cache-hr_filesys.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0048+0027-mnt-cache-hr_filesys.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0048+0027-mnt-cache-hr_filesys.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,244 @@
+--- a/agent/mibgroup/host/hr_filesys.c
++++ b/agent/mibgroup/host/hr_filesys.c
+@@ -46,6 +46,10 @@
+ #include <sys/mount.h>
+ #endif
+
++#ifdef solaris2
++#include <sys/stat.h>
++#endif
++
+ #include <ctype.h>
+ #if HAVE_STRING_H
+ #include <string.h>
+@@ -108,7 +112,11 @@ netsnmp_feature_require(ctime_to_timet)
+ #ifdef solaris2
+
+ struct mnttab HRFS_entry_struct;
+-struct mnttab *HRFS_entry = &HRFS_entry_struct;
++struct mnttab *HRFS_entry;
++struct mnttab *HRFS_list;
++static int fscount;
++static time_t last_access = -1;
++
+ #define HRFS_name mnt_special
+ #define HRFS_mount mnt_mountp
+ #define HRFS_type mnt_fstype
+@@ -207,6 +215,9 @@ char *cook_device(char *);
+ static u_char *when_dumped(char *filesys, int level, size_t * length);
+ int header_hrfilesys(struct variable *, oid *, size_t *, int,
+ size_t *, WriteMethod **);
++#ifdef solaris2
++static int load_mnttab_cache_solaris(void);
++#endif
+
+ /*********************
+ *
+@@ -662,7 +673,12 @@ Init_HR_FileSys(void)
+ HRFS_index = 1;
+ if (fp != NULL)
+ fclose(fp);
++#ifdef solaris2
++ if(!load_mnttab_cache_solaris())
++ return;
++#else
+ fp = fopen(ETC_MNTTAB, "r");
++#endif
+ if (!fp) {
+ netsnmp_config_error("Can't open mnttab %s\n", ETC_MNTTAB);
+ }
+@@ -722,6 +738,140 @@ const char *HRFS_ignores[] = {
+ NULL
+ };
+
++#ifdef solaris2
++
++/*
++ * This function has been introduced to reduce the overhead
++ * of the getmntent() calls used to fetch the details of
++ * the /etc/mnttab entries in Init_HR_FileSys().
++ *
++ * We maintain a cache of all the /etc/mnttab entries and
++ * walk through the cache instead of opening /etc/mnttab and
++ * walking all the entries for each mountpoint.
++ */
++
++static int
++load_mnttab_cache_solaris()
++{
++ char buf[MNT_LINE_MAX] = {NULL};
++ int i = 0;
++ struct stat file_stat;
++ const char **cpp;
++ char *ch, *token_ptr;
++ int token_flag = 0;
++ int skip_flag = 0;
++ int ignore_flag = 0;
++ int j = 0;
++ int lines = 0;
++ int ret = 0;
++ int chk_mnt = -1;
++ HRFS_index = 0;
++
++ if(stat(ETC_MNTTAB, &file_stat) != 0)
++ {
++ DEBUGMSGTL(("host/hr_filesys", "stat failed for mnttab.\n"));
++ return -1;
++ }
++ if (last_access == -1 || last_access != file_stat.st_mtime) {
++ fp = fopen(ETC_MNTTAB, "r");
++ if(fp == NULL)
++ {
++ DEBUGMSGTL(("host/hr_filesys", "fopen failed for mnttab.\n"));
++ return -1;
++ }
++
++ /* find the number of valid entries in mnttab. */
++
++ while ((fgets((char *) &buf, sizeof(buf), fp)) != NULL) {
++ j = 0;
++ skip_flag = 0;
++ token_flag = 0;
++
++ /* tokenize the mnttab entries to fetch the fstype
++ * which determines the valid entries.
++ */
++
++ ch = strtok_r(buf, " \t", &token_ptr);
++ while (ch != NULL) {
++ j++;
++ if(j == 3) {
++ for (cpp = HRFS_ignores; *cpp != NULL; ++cpp) {
++ if(!strncmp(ch, *cpp, strlen(ch))) {
++ skip_flag = 1;
++ break;
++ }
++ }
++ token_flag = 1;
++ }
++ if(token_flag)
++ break;
++ ch = strtok_r(NULL, " \t", &token_ptr);
++ }
++ if(!skip_flag)
++ lines++;
++ }
++ fclose(fp);
++
++ fscount = lines;
++ HRFS_list = (struct mnttab *) malloc (sizeof(struct mnttab) * fscount);
++ if(HRFS_list == NULL) {
++ DEBUGMSGTL(("host/hr_filesys", "Memory allocation for mnttab cache failed.\n"));
++ return -1;
++ }
++
++ fp = fopen(ETC_MNTTAB, "r");
++ if(fp == NULL) {
++ DEBUGMSGTL(("host/hr_filesys", "fopen failed for mnttab.\n"));
++ free(HRFS_list);
++ return -1;
++ }
++ while ((chk_mnt = getmntent(fp, &HRFS_entry_struct)) != -1) {
++ if(chk_mnt != 0)
++ continue;
++ for (cpp = HRFS_ignores; *cpp != NULL; ++cpp) {
++ if (!strcmp(HRFS_entry_struct.mnt_fstype, *cpp)) {
++ ignore_flag = 1;
++ break;
++ }
++ }
++ if(!ignore_flag) {
++ if(i >= fscount)
++ {
++ DEBUGMSGTL(("host/hr_filesys","increasing cachesize from %d to %d",fscount,i+1));
++ HRFS_list = realloc(HRFS_list, sizeof(struct mnttab) * (i+1));
++ fscount = i+1;
++ if(HRFS_list == NULL)
++ {
++ DEBUGMSGTL(("host/hr_filesys","\nrealloc failed for mnttab cache.\n"));
++ return -1;
++ }
++ }
++ HRFS_list[i].mnt_special = strdup(HRFS_entry_struct.mnt_special);
++ HRFS_list[i].mnt_mountp = strdup(HRFS_entry_struct.mnt_mountp);
++ HRFS_list[i].mnt_fstype = strdup(HRFS_entry_struct.mnt_fstype);
++ HRFS_list[i].mnt_mntopts = strdup(HRFS_entry_struct.mnt_mntopts);
++ i++;
++ }
++ ignore_flag = 0;
++ }
++ if(i < fscount)
++ {
++ DEBUGMSGTL(("host/hr_filesys","\ndecreasing cachesize from %d to %d\n",fscount,i));
++ HRFS_list = realloc(HRFS_list, sizeof(struct mnttab) * i );
++ if(HRFS_list == NULL)
++ {
++ DEBUGMSGTL(("host/hr_filesys","\nrealloc failed for mnttab cache.\n"));
++ return -1;
++ }
++ }
++
++ HRFS_entry = HRFS_list;
++ last_access = file_stat.st_mtime;
++ }
++ return ret;
++}
++#endif
++
+ int
+ Get_Next_HR_FileSys(void)
+ {
+@@ -758,17 +908,18 @@ Get_Next_HR_FileSys(void)
+ #else
+ const char **cpp;
+
+- if (fp == NULL)
+- return -1;
+
+ #ifdef solaris2
+- if (getmntent(fp, HRFS_entry) != 0)
++ if (HRFS_index >= fscount)
+ return -1;
++ HRFS_entry = &HRFS_list[HRFS_index];
++ return ++HRFS_index;
+ #else
++ if (fp == NULL)
++ return -1;
+ HRFS_entry = getmntent(fp);
+ if (HRFS_entry == NULL)
+ return -1;
+-#endif /* solaris2 */
+
+ for (cpp = HRFS_ignores; *cpp != NULL; ++cpp)
+ if (!strcmp(HRFS_entry->HRFS_type, *cpp))
+@@ -787,6 +938,8 @@ Get_Next_HR_FileSys(void)
+ }
+
+ return HRFS_index++;
++#endif
++
+ #endif /* HAVE_GETFSSTAT */
+ }
+
+@@ -857,6 +1010,21 @@ End_HR_FileSys(void)
+ if (fp != NULL)
+ fclose(fp);
+ fp = NULL;
++
++#ifdef solaris2
++ int i = 0;
++ while (i < fscount) {
++ free(HRFS_list[i].mnt_special);
++ free(HRFS_list[i].mnt_mountp);
++ free(HRFS_list[i].mnt_fstype);
++ free(HRFS_list[i].mnt_mntopts);
++ i++;
++ }
++ if (HRFS_list != NULL)
++ free(HRFS_list);
++ last_access = -1;
++#endif
++
+ #endif
+ }
+
Added: csw/mgar/pkg/netsnmp/trunk/files/0051-CVE-2014-2285.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0051-CVE-2014-2285.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0051-CVE-2014-2285.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,26 @@
+--- a/perl/TrapReceiver/TrapReceiver.xs
++++ b/perl/TrapReceiver/TrapReceiver.xs
+@@ -81,18 +81,18 @@ int perl_trapd_handler( netsnmp_pdu *pdu,
+ STOREPDUi("securitymodel", pdu->securityModel);
+ STOREPDUi("securitylevel", pdu->securityLevel);
+ STOREPDU("contextName",
+- newSVpv(pdu->contextName, pdu->contextNameLen));
++ newSVpv(pdu->contextName ? pdu->contextName : "", pdu->contextNameLen));
+ STOREPDU("contextEngineID",
+- newSVpv((char *) pdu->contextEngineID,
++ newSVpv(pdu->contextEngineID ? (char *) pdu->contextEngineID : "",
+ pdu->contextEngineIDLen));
+ STOREPDU("securityEngineID",
+- newSVpv((char *) pdu->securityEngineID,
++ newSVpv(pdu->securityEngineID ? (char *) pdu->securityEngineID : "",
+ pdu->securityEngineIDLen));
+ STOREPDU("securityName",
+- newSVpv((char *) pdu->securityName, pdu->securityNameLen));
++ newSVpv(pdu->securityName ? (char *) pdu->securityName : "", pdu->securityNameLen));
+ } else {
+ STOREPDU("community",
+- newSVpv((char *) pdu->community, pdu->community_len));
++ newSVpv(pdu->community ? (char *) pdu->community : "", pdu->community_len));
+ }
+
+ if (transport && transport->f_fmtaddr) {
Added: csw/mgar/pkg/netsnmp/trunk/files/0052-dyn-cpu-cpu_kstat.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/0052-dyn-cpu-cpu_kstat.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/0052-dyn-cpu-cpu_kstat.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,187 @@
+--- a/agent/mibgroup/hardware/cpu/cpu_kstat.c
++++ b/agent/mibgroup/hardware/cpu/cpu_kstat.c
+@@ -17,16 +17,16 @@
+ extern kstat_ctl_t *kstat_fd;
+ extern int cpu_num;
+ int _cpu_status(char *state);
+-
++static void add_new_kstat_cpu_entry(kstat_t *ksp);
++static struct cpu_idx * add_cpu_idx(struct cpu_idx * head, int idx);
++
+ /*
+ * Initialise the list of CPUs on the system
+ * (including descriptions)
+ */
+ void init_cpu_kstat( void ) {
+- int i = 0, n = 0, clock, state_begin;
+- char ctype[15], ftype[15], state[10];
++ int n = 0;
+ kstat_t *ksp;
+- kstat_named_t *ks_data;
+ netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 1 );
+ strcpy(cpu->name, "Overall CPU statistics");
+
+@@ -41,45 +41,61 @@ void init_cpu_kstat( void ) {
+ if ((strcmp(ksp->ks_module, "cpu_info") == 0) &&
+ (strcmp(ksp->ks_class, "misc" ) == 0)) {
+ kstat_read(kstat_fd, ksp, NULL );
++ add_new_kstat_cpu_entry(ksp);
+ n++;
+- clock = 999999;
+- memset(ctype, 0, sizeof(ctype));
+- memset(ftype, 0, sizeof(ftype));
+- memset(state, 0, sizeof(state));
+- for (i=0, ks_data = ksp->ks_data; i < ksp->ks_ndata; i++, ks_data++) {
+- if ( strcmp( ks_data->name, "state" ) == 0 ) {
+- strlcpy(state, ks_data->value.c, sizeof(state));
+- } else if ( strcmp( ks_data->name, "state_begin" ) == 0 ) {
+- state_begin = ks_data->value.i32;
+- } else if ( strcmp( ks_data->name, "cpu_type" ) == 0 ) {
+- strlcpy(ctype, ks_data->value.c, sizeof(ctype));
+- } else if ( strcmp( ks_data->name, "fpu_type" ) == 0 ) {
+- strlcpy(ftype, ks_data->value.c, sizeof(ftype));
+- } else if ( strcmp( ks_data->name, "clock_MHz" ) == 0 ) {
+- clock = ks_data->value.i32;
+- }
+- }
+- i = ksp->ks_instance;
+- cpu = netsnmp_cpu_get_byIdx( i, 1 );
+- sprintf( cpu->name, "cpu%d", i );
+- sprintf( cpu->descr, "CPU %d Sun %d MHz %s with %s FPU %s",
+- i, clock, ctype, ftype, state );
+- cpu->status = _cpu_status(state); /* XXX - or in 'n_c_a_load' ? */
+ }
+ }
+- cpu_num = i;
++ cpu_num = n;
+ }
+
++ /*
++ * adds the new cpu entry to the exisitng list
++ */
++static void
++add_new_kstat_cpu_entry( kstat_t *ksp ) {
++ int i, clock, state_begin;
++ char ctype[15], ftype[15], state[10];
++ kstat_named_t *ks_data;
++ netsnmp_cpu_info *cpu;
++
++ clock = 999999;
++ memset(ctype, 0, sizeof(ctype));
++ memset(ftype, 0, sizeof(ftype));
++ memset(state, 0, sizeof(state));
++
++ for (i=0, ks_data = ksp->ks_data; i < ksp->ks_ndata; i++, ks_data++) {
++ if ( strcmp( ks_data->name, "state" ) == 0 ) {
++ strncpy( state, ks_data->value.c, sizeof(state));
++ state[sizeof(state)-1] = '\0';
++ } else if ( strcmp( ks_data->name, "state_begin" ) == 0 ) {
++ state_begin = ks_data->value.i32;
++ } else if ( strcmp( ks_data->name, "cpu_type" ) == 0 ) {
++ strncpy( ctype, ks_data->value.c, sizeof(ctype));
++ ctype[sizeof(ctype)-1] = '\0';
++ } else if ( strcmp( ks_data->name, "fpu_type" ) == 0 ) {
++ strncpy( ftype, ks_data->value.c, sizeof(ftype));
++ ftype[sizeof(ftype)-1] = '\0';
++ } else if ( strcmp( ks_data->name, "clock_MHz" ) == 0 ) {
++ clock = ks_data->value.i32;
++ }
++ }
++ i = ksp->ks_instance;
++ cpu = netsnmp_cpu_get_byIdx( i, 1 );
++ sprintf( cpu->name, "cpu%d", i );
++ sprintf( cpu->descr, "CPU %d Sun %d MHz %s with %s FPU %s", i, clock, ctype, ftype, state );
++ cpu->status = _cpu_status(state);
++}
+
+ /*
+ * Load the latest CPU usage statistics
+ */
+ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
+- int i=1;
++ int i=1, n=0;
+ kstat_t *ksp;
+ cpu_stat_t cs;
+ netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 );
+ netsnmp_cpu_info *cpu2;
++ struct cpu_idx *new_cpu_list = NULL, *temp_cpu_idx;
+
+ /* Clear overall stats, ready for summing individual CPUs */
+ cpu->user_ticks = 0;
+@@ -94,6 +110,32 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
+
+ kstat_chain_update( kstat_fd );
+ DEBUGMSGTL(("cpu", "cpu_kstat load\n "));
++
++ /*
++ * The stats update is three step.
++ * First - add in the new cpus' info to the linked list
++ */
++ for (ksp = kstat_fd->kc_chain; ksp != NULL; ksp = ksp->ks_next) {
++ if (ksp->ks_flags & KSTAT_FLAG_INVALID)
++ continue;
++ if ((strcmp(ksp->ks_module, "cpu_info") == 0) &&
++ (strcmp(ksp->ks_class, "misc" ) == 0)) {
++ kstat_read(kstat_fd, ksp, NULL );
++ i = ksp->ks_instance;
++ new_cpu_list = add_cpu_idx( new_cpu_list, i);
++ cpu2 = netsnmp_cpu_get_byIdx( i, 0 );
++ if ( !cpu2 ) {
++ add_new_kstat_cpu_entry(ksp);
++ n++;
++ }
++ }
++ }
++
++
++ /* Second - update the CPU list to reflect new kernel structures */
++ n -= netsnmp_update_cpu_list( new_cpu_list );
++
++ /* Third - for updating stats for the new CPU set */
+ for (ksp = kstat_fd->kc_chain; ksp != NULL; ksp = ksp->ks_next) {
+ if (ksp->ks_flags & KSTAT_FLAG_INVALID)
+ continue;
+@@ -135,9 +177,43 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
+ cpu->nCtxSwitches += (unsigned long long)cs.cpu_sysinfo.pswitch;
+ }
+ }
++ cpu_num += n;
++ /* Clean up the temporary CPU index list */
++ while(new_cpu_list) {
++ temp_cpu_idx = new_cpu_list;
++ new_cpu_list = new_cpu_list->next;
++ SNMP_FREE(temp_cpu_idx);
++ }
+ return 0;
+ }
+
++ /* returns the new head */
++static struct cpu_idx *
++add_cpu_idx(struct cpu_idx * head, int idx)
++{
++ struct cpu_idx *cpu_idx, *current;
++ cpu_idx = SNMP_MALLOC_TYPEDEF( struct cpu_idx );
++ if ( !cpu_idx ) {
++ DEBUGMSG(("cpu", "(cpu_idx creation failed)\n"));
++ return head;
++ }
++
++ cpu_idx->idx = idx;
++ if ( !head || head->idx > idx ) {
++ cpu_idx->next = head;
++ return cpu_idx;
++ }
++
++ for ( current=head; current; current=current->next ) {
++ if ( !current->next || current->next->idx > idx ) {
++ cpu_idx->next = current->next;
++ current->next = cpu_idx;
++ return head;
++ }
++ }
++
++}
++
+ int
+ _cpu_status( char *state)
+ {
Added: csw/mgar/pkg/netsnmp/trunk/files/net-snmp-CVE-2014-3565.patch
===================================================================
--- csw/mgar/pkg/netsnmp/trunk/files/net-snmp-CVE-2014-3565.patch (rev 0)
+++ csw/mgar/pkg/netsnmp/trunk/files/net-snmp-CVE-2014-3565.patch 2014-12-18 15:42:45 UTC (rev 24479)
@@ -0,0 +1,446 @@
+commit 7f4a7b891332899cea26e95be0337aae01648742
+Author: Jan Safranek <jsafranek at users.sourceforge.net>
+Date: Thu Jul 31 13:46:49 2014 +0200
+
+ Added checks for printing variables with wrong types.
+
+ When -OQ command line argument is used, variable formatter preffers the type
+ of the varible parsed from a MIB file instead of checking type of the variable
+ as parsed from SNMP message.
+
+ This can lead to crashes when incoming packets contains a variable with
+ NULL type, while the MIB says the variable should be non-NULL, like Integer.
+ The formatter then tries to interpret the NULL (from packet) as Integer (from
+ MIB file).
+
+diff --git a/snmplib/mib.c b/snmplib/mib.c
+index 9d3ca41..c6e0010 100644
+--- a/snmplib/mib.c
++++ b/snmplib/mib.c
+@@ -439,17 +439,16 @@ sprint_realloc_octet_string(u_char ** buf, size_t * buf_len,
+ u_char *cp;
+ int output_format, cnt;
+
+- if ((var->type != ASN_OCTET_STR) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- const char str[] = "Wrong Type (should be OCTET STRING): ";
+- if (snmp_cstrcat
+- (buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_OCTET_STR) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ const char str[] = "Wrong Type (should be OCTET STRING): ";
++ if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+
+@@ -702,16 +701,16 @@ sprint_realloc_float(u_char ** buf, size_t * buf_len,
+ const struct enum_list *enums,
+ const char *hint, const char *units)
+ {
+- if ((var->type != ASN_OPAQUE_FLOAT) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
+- "Wrong Type (should be Float): ")) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_OPAQUE_FLOAT) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Float): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -772,17 +771,16 @@ sprint_realloc_double(u_char ** buf, size_t * buf_len,
+ const struct enum_list *enums,
+ const char *hint, const char *units)
+ {
+- if ((var->type != ASN_OPAQUE_DOUBLE) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- if (snmp_cstrcat
+- (buf, buf_len, out_len, allow_realloc,
+- "Wrong Type (should be Double): ")) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_OPAQUE_DOUBLE) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Double): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -847,20 +845,21 @@ sprint_realloc_counter64(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ char a64buf[I64CHARSZ + 1];
+
+- if ((var->type != ASN_COUNTER64
++ if (var->type != ASN_COUNTER64
+ #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
+ && var->type != ASN_OPAQUE_COUNTER64
+ && var->type != ASN_OPAQUE_I64 && var->type != ASN_OPAQUE_U64
+ #endif
+- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
+- "Wrong Type (should be Counter64): ")) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ ) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Counter64): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -948,23 +947,25 @@ sprint_realloc_opaque(u_char ** buf, size_t * buf_len,
+ const struct enum_list *enums,
+ const char *hint, const char *units)
+ {
+- if ((var->type != ASN_OPAQUE
++ if (var->type != ASN_OPAQUE
+ #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
+ && var->type != ASN_OPAQUE_COUNTER64
+ && var->type != ASN_OPAQUE_U64
+ && var->type != ASN_OPAQUE_I64
+ && var->type != ASN_OPAQUE_FLOAT && var->type != ASN_OPAQUE_DOUBLE
+ #endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
+- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
+- "Wrong Type (should be Opaque): ")) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ ) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Opaque): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
++
+ #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
+ switch (var->type) {
+ case ASN_OPAQUE_COUNTER64:
+@@ -1040,17 +1041,16 @@ sprint_realloc_object_identifier(u_char ** buf, size_t * buf_len,
+ {
+ int buf_overflow = 0;
+
+- if ((var->type != ASN_OBJECT_ID) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] =
+- "Wrong Type (should be OBJECT IDENTIFIER): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_OBJECT_ID) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be OBJECT IDENTIFIER): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -1110,16 +1110,16 @@ sprint_realloc_timeticks(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ char timebuf[40];
+
+- if ((var->type != ASN_TIMETICKS) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be Timeticks): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_TIMETICKS) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Timeticks): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS)) {
+@@ -1277,17 +1277,18 @@ sprint_realloc_integer(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ char *enum_string = NULL;
+
+- if ((var->type != ASN_INTEGER) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be INTEGER): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_INTEGER) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be INTEGER): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
++
+ for (; enums; enums = enums->next) {
+ if (enums->value == *var->val.integer) {
+ enum_string = enums->label;
+@@ -1380,16 +1381,16 @@ sprint_realloc_uinteger(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ char *enum_string = NULL;
+
+- if ((var->type != ASN_UINTEGER) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be UInteger32): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_UINTEGER) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be UInteger32): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ for (; enums; enums = enums->next) {
+@@ -1477,17 +1478,16 @@ sprint_realloc_gauge(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ char tmp[32];
+
+- if ((var->type != ASN_GAUGE) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] =
+- "Wrong Type (should be Gauge32 or Unsigned32): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_GAUGE) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Gauge32 or Unsigned32): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -1550,16 +1550,16 @@ sprint_realloc_counter(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ char tmp[32];
+
+- if ((var->type != ASN_COUNTER) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be Counter32): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_COUNTER) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be Counter32): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -1613,16 +1613,16 @@ sprint_realloc_networkaddress(u_char ** buf, size_t * buf_len,
+ {
+ size_t i;
+
+- if ((var->type != ASN_IPADDRESS) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be NetworkAddress): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_IPADDRESS) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be NetworkAddress): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -1679,16 +1679,16 @@ sprint_realloc_ipaddress(u_char ** buf, size_t * buf_len, size_t * out_len,
+ {
+ u_char *ip = var->val.string;
+
+- if ((var->type != ASN_IPADDRESS) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be IpAddress): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_IPADDRESS) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be IpAddress): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -1737,20 +1737,20 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
+ const struct enum_list *enums,
+ const char *hint, const char *units)
+ {
+- if ((var->type != ASN_NULL) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be NULL): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_NULL) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be NULL): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+- } else {
+- u_char str[] = "NULL";
+- return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
+ }
++
++ u_char str[] = "NULL";
++ return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
+ }
+
+
+@@ -1785,16 +1785,16 @@ sprint_realloc_bitstring(u_char ** buf, size_t * buf_len, size_t * out_len,
+ u_char *cp;
+ char *enum_string;
+
+- if ((var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be BITS): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be BITS): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
+@@ -1869,16 +1869,16 @@ sprint_realloc_nsapaddress(u_char ** buf, size_t * buf_len,
+ const struct enum_list *enums, const char *hint,
+ const char *units)
+ {
+- if ((var->type != ASN_NSAP) &&
+- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
+- u_char str[] = "Wrong Type (should be NsapAddress): ";
+- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
+- return sprint_realloc_by_type(buf, buf_len, out_len,
++ if (var->type != ASN_NSAP) {
++ if (!netsnmp_ds_get_boolean(
++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
++ u_char str[] = "Wrong Type (should be NsapAddress): ";
++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
++ return 0;
++ }
++ return sprint_realloc_by_type(buf, buf_len, out_len,
+ allow_realloc, var, NULL, NULL,
+ NULL);
+- } else {
+- return 0;
+- }
+ }
+
+ if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list