summaryrefslogtreecommitdiffstats
path: root/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp')
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-BUG-a2584-Fix-snmptrap-to-use-clientaddr-from-snmp.c.patch45
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Remove-U64-typedef.patch2524
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_headers-Error-Fix.patch34
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_libs2-Error-Fix.patch31
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-configure-fix-check-for-enable-perl-cc-checks.patch31
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get_pid_from_inode-Include-limit.h.patch29
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-UDPIPv6-transport-Add-a-missing-return-state.patch26
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch33
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0002-configure-fix-a-cc-check-issue.patch30
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0003-CHANGES-BUG-2712-Fix-Perl-module-compilation.patch186
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0004-configure-fix-incorrect-variable.patch30
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/dont-return-incompletely-parsed-varbinds.patch131
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/fix-libtool-finish.patch25
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.7.2-fix-engineBoots-value-on-SIGHUP.patch42
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-add-knob-whether-nlist.h-are-checked.patch35
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-agentx-crash.patch75
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-fix-for-disable-des.patch32
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-testing-add-the-output-format-for-ptest.patch34
-rwxr-xr-xmeta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/run-ptest4
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service13
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service13
-rw-r--r--meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch1652
22 files changed, 5055 insertions, 0 deletions
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-BUG-a2584-Fix-snmptrap-to-use-clientaddr-from-snmp.c.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-BUG-a2584-Fix-snmptrap-to-use-clientaddr-from-snmp.c.patch
new file mode 100644
index 000000000..b14b76128
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-BUG-a2584-Fix-snmptrap-to-use-clientaddr-from-snmp.c.patch
@@ -0,0 +1,45 @@
+From a92628a163ebf1ea62220684736300461c003875 Mon Sep 17 00:00:00 2001
+From: Niels Baggesen <nba@users.sourceforge.net>
+Date: Mon, 26 Jan 2015 20:26:06 +0100
+Subject: [PATCH] BUG#a2584: Fix snmptrap to use clientaddr from snmp.conf.
+ Thanks to rizwan
+
+Upstream-Status: backport
+
+Signed-off-by: Li Zhou <li.zhou@windriver.com>
+---
+ snmplib/transports/snmpUDPIPv6Domain.c | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+Index: net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
+===================================================================
+--- net-snmp-5.7.3.orig/snmplib/transports/snmpUDPIPv6Domain.c
++++ net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
+@@ -286,6 +286,27 @@ netsnmp_udp6_transport(struct sockaddr_i
+ return NULL;
+ #endif /* NETSNMP_NO_LISTEN_SUPPORT */
+ } else {
++ char *client_socket = NULL;
++ /*
++ * This is a client session. If we've been given a
++ * client address to send from, then bind to that.
++ * Otherwise the send will use "something sensible".
++ */
++
++ client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
++ NETSNMP_DS_LIB_CLIENT_ADDR);
++ if (client_socket) {
++ struct sockaddr_in6 client_addr;
++ netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
++ rc = bind(t->sock, (struct sockaddr *)&client_addr,
++ sizeof(struct sockaddr_in6));
++ if ( rc != 0 ) {
++ DEBUGMSGTL(("netsnmp_udp6", "failed to bind for clientaddr: %d %s\n",
++ errno, strerror(errno)));
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ }
++ }
+ /*
+ * This is a client session. Save the address in the
+ * transport-specific data pointer for later use by netsnmp_udp6_send.
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Remove-U64-typedef.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Remove-U64-typedef.patch
new file mode 100644
index 000000000..7314ab16a
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Remove-U64-typedef.patch
@@ -0,0 +1,2524 @@
+net-snmp: remove U64 typedef
+
+From git://git.code.sf.net/p/net-snmp/code
+
+Upstream-Status: Backport (unmodified)
+
+Signed-off-by: Joe Slater <joe.slater@windriver.com>
+
+From 477b4307ef12ddce3b6a9205e0bdddbfb2e0e9b6 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Sat, 20 Feb 2016 18:58:18 -0800
+Subject: [PATCH 1/1] Remove U64 typedef
+
+The U64 typedef conflicts with a typedef in a Perl header file. Hence
+remove the U64 typedef from the Net-SNMP header files. This patch does
+not modify the Net-SNMP ABI.
+---
+ agent/mibgroup/if-mib/ifXTable/ifXTable.c | 16 +-
+ agent/mibgroup/if-mib/ifXTable/ifXTable.h | 48 +-
+ .../mibgroup/if-mib/ifXTable/ifXTable_interface.c | 32 +-
+ .../ip-mib/data_access/systemstats_common.c | 2 +-
+ .../ipIfStatsTable/ipIfStatsTable_data_get.c | 28 +-
+ .../ipIfStatsTable/ipIfStatsTable_data_get.h | 28 +-
+ .../ipIfStatsTable/ipIfStatsTable_interface.c | 56 +-
+ .../ip-mib/ipSystemStatsTable/ipSystemStatsTable.c | 28 +-
+ .../ip-mib/ipSystemStatsTable/ipSystemStatsTable.h | 921 ++-------------------
+ .../ipSystemStatsTable_interface.c | 56 +-
+ include/net-snmp/data_access/ipstats.h | 42 +-
+ include/net-snmp/library/int64.h | 34 +-
+ snmplib/int64.c | 38 +-
+ snmplib/read_config.c | 6 +-
+ testing/fulltests/unit-tests/T015int64_clib.c | 10 +-
+ 15 files changed, 274 insertions(+), 1071 deletions(-)
+
+Index: net-snmp-5.7.3/agent/mibgroup/if-mib/ifXTable/ifXTable.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/if-mib/ifXTable/ifXTable.c
++++ net-snmp-5.7.3/agent/mibgroup/if-mib/ifXTable/ifXTable.c
+@@ -722,7 +722,7 @@ The total number of octets received on t
+ */
+ int
+ ifHCInOctets_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCInOctets_val_ptr)
++ struct counter64 *ifHCInOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCInOctets_val_ptr);
+@@ -779,7 +779,7 @@ The number of packets, delivered by this
+ */
+ int
+ ifHCInUcastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCInUcastPkts_val_ptr)
++ struct counter64 *ifHCInUcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCInUcastPkts_val_ptr);
+@@ -838,7 +838,7 @@ The number of packets, delivered by this
+ */
+ int
+ ifHCInMulticastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCInMulticastPkts_val_ptr)
++ struct counter64 *ifHCInMulticastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCInMulticastPkts_val_ptr);
+@@ -897,7 +897,7 @@ The number of packets, delivered by this
+ */
+ int
+ ifHCInBroadcastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCInBroadcastPkts_val_ptr)
++ struct counter64 *ifHCInBroadcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCInBroadcastPkts_val_ptr);
+@@ -955,7 +955,7 @@ The total number of octets transmitted o
+ */
+ int
+ ifHCOutOctets_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCOutOctets_val_ptr)
++ struct counter64 *ifHCOutOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCOutOctets_val_ptr);
+@@ -1013,7 +1013,7 @@ The total number of packets that higher-
+ */
+ int
+ ifHCOutUcastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCOutUcastPkts_val_ptr)
++ struct counter64 *ifHCOutUcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCOutUcastPkts_val_ptr);
+@@ -1074,7 +1074,7 @@ The total number of packets that higher-
+ */
+ int
+ ifHCOutMulticastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCOutMulticastPkts_val_ptr)
++ struct counter64 *ifHCOutMulticastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCOutMulticastPkts_val_ptr);
+@@ -1134,7 +1134,7 @@ The total number of packets that higher-
+ */
+ int
+ ifHCOutBroadcastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCOutBroadcastPkts_val_ptr)
++ struct counter64 *ifHCOutBroadcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ifHCOutBroadcastPkts_val_ptr);
+Index: net-snmp-5.7.3/agent/mibgroup/if-mib/ifXTable/ifXTable.h
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/if-mib/ifXTable/ifXTable.h
++++ net-snmp-5.7.3/agent/mibgroup/if-mib/ifXTable/ifXTable.h
+@@ -143,28 +143,28 @@ config_require(if-mib/ifXTable/ifXTable_
+ u_long *
+ ifOutBroadcastPkts_val_ptr);
+ int ifHCInOctets_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCInOctets_val_ptr);
++ struct counter64 *ifHCInOctets_val_ptr);
+ int ifHCInUcastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCInUcastPkts_val_ptr);
++ struct counter64 *ifHCInUcastPkts_val_ptr);
+ int ifHCInMulticastPkts_get(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ifHCInMulticastPkts_val_ptr);
+ int ifHCInBroadcastPkts_get(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ifHCInBroadcastPkts_val_ptr);
+ int ifHCOutOctets_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCOutOctets_val_ptr);
++ struct counter64 *ifHCOutOctets_val_ptr);
+ int ifHCOutUcastPkts_get(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 * ifHCOutUcastPkts_val_ptr);
++ struct counter64 *ifHCOutUcastPkts_val_ptr);
+ int ifHCOutMulticastPkts_get(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ifHCOutMulticastPkts_val_ptr);
+ int ifHCOutBroadcastPkts_get(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ifHCOutBroadcastPkts_val_ptr);
+ int ifLinkUpDownTrapEnable_get(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -284,86 +284,86 @@ config_require(if-mib/ifXTable/ifXTable_
+
+ int ifHCInOctets_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCInOctets_val);
++ struct counter64 ifHCInOctets_val);
+ int ifHCInOctets_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCInOctets_set(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 ifHCInOctets_val);
++ struct counter64 ifHCInOctets_val);
+ int ifHCInOctets_undo(ifXTable_rowreq_ctx * rowreq_ctx);
+
+ int ifHCInUcastPkts_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCInUcastPkts_val);
++ struct counter64 ifHCInUcastPkts_val);
+ int ifHCInUcastPkts_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCInUcastPkts_set(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 ifHCInUcastPkts_val);
++ struct counter64 ifHCInUcastPkts_val);
+ int ifHCInUcastPkts_undo(ifXTable_rowreq_ctx * rowreq_ctx);
+
+ int ifHCInMulticastPkts_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64
++ struct counter64
+ ifHCInMulticastPkts_val);
+ int ifHCInMulticastPkts_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCInMulticastPkts_set(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCInMulticastPkts_val);
++ struct counter64 ifHCInMulticastPkts_val);
+ int ifHCInMulticastPkts_undo(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+
+ int ifHCInBroadcastPkts_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64
++ struct counter64
+ ifHCInBroadcastPkts_val);
+ int ifHCInBroadcastPkts_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCInBroadcastPkts_set(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCInBroadcastPkts_val);
++ struct counter64 ifHCInBroadcastPkts_val);
+ int ifHCInBroadcastPkts_undo(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+
+ int ifHCOutOctets_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCOutOctets_val);
++ struct counter64 ifHCOutOctets_val);
+ int ifHCOutOctets_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCOutOctets_set(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 ifHCOutOctets_val);
++ struct counter64 ifHCOutOctets_val);
+ int ifHCOutOctets_undo(ifXTable_rowreq_ctx * rowreq_ctx);
+
+ int ifHCOutUcastPkts_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCOutUcastPkts_val);
++ struct counter64 ifHCOutUcastPkts_val);
+ int ifHCOutUcastPkts_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCOutUcastPkts_set(ifXTable_rowreq_ctx * rowreq_ctx,
+- U64 ifHCOutUcastPkts_val);
++ struct counter64 ifHCOutUcastPkts_val);
+ int ifHCOutUcastPkts_undo(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+
+ int ifHCOutMulticastPkts_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64
++ struct counter64
+ ifHCOutMulticastPkts_val);
+ int ifHCOutMulticastPkts_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCOutMulticastPkts_set(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCOutMulticastPkts_val);
++ struct counter64 ifHCOutMulticastPkts_val);
+ int ifHCOutMulticastPkts_undo(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+
+ int ifHCOutBroadcastPkts_check_value(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64
++ struct counter64
+ ifHCOutBroadcastPkts_val);
+ int ifHCOutBroadcastPkts_undo_setup(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+ int ifHCOutBroadcastPkts_set(ifXTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 ifHCOutBroadcastPkts_val);
++ struct counter64 ifHCOutBroadcastPkts_val);
+ int ifHCOutBroadcastPkts_undo(ifXTable_rowreq_ctx *
+ rowreq_ctx);
+
+Index: net-snmp-5.7.3/agent/mibgroup/if-mib/ifXTable/ifXTable_interface.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/if-mib/ifXTable/ifXTable_interface.c
++++ net-snmp-5.7.3/agent/mibgroup/if-mib/ifXTable/ifXTable_interface.c
+@@ -729,72 +729,72 @@ _ifXTable_get_column(ifXTable_rowreq_ctx
+ * ifHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCINOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCInOctets_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCInOctets_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCInUcastPkts(7)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCINUCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCInUcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCInUcastPkts_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCInMulticastPkts(8)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCINMULTICASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCInMulticastPkts_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCInMulticastPkts_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCInBroadcastPkts(9)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCINBROADCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCInBroadcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCInBroadcastPkts_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCOutOctets(10)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCOUTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCOutOctets_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCOutOctets_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCOutUcastPkts(11)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCOUTUCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCOutUcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCOutUcastPkts_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCOutMulticastPkts(12)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCOUTMULTICASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCOutMulticastPkts_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCOutMulticastPkts_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+ * ifHCOutBroadcastPkts(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IFHCOUTBROADCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ifHCOutBroadcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ifHCOutBroadcastPkts_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/data_access/systemstats_common.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/data_access/systemstats_common.c
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/data_access/systemstats_common.c
+@@ -264,7 +264,7 @@ _calculate_entries(netsnmp_systemstats_e
+ && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTFRAGCREATES]
+ && entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTDISCARDS]) {
+
+- U64 tmp, tmp2, tmp3;
++ struct counter64 tmp, tmp2, tmp3;
+ tmp = entry->stats.HCOutRequests;
+ u64Incr(&tmp, &entry->stats.HCOutForwDatagrams);
+ u64Incr(&tmp, &entry->stats.HCOutFragCreates);
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.c
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.c
+@@ -270,7 +270,7 @@ The total number of input IP datagrams r
+ */
+ int
+ ipIfStatsHCInReceives_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInReceives_val_ptr)
++ struct counter64 *ipIfStatsHCInReceives_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInReceives_val_ptr);
+@@ -395,7 +395,7 @@ The total number of octets received in i
+ */
+ int
+ ipIfStatsHCInOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInOctets_val_ptr)
++ struct counter64 *ipIfStatsHCInOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInOctets_val_ptr);
+@@ -862,7 +862,7 @@ The number of input datagrams for which
+ */
+ int
+ ipIfStatsHCInForwDatagrams_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInForwDatagrams_val_ptr)
++ struct counter64 *ipIfStatsHCInForwDatagrams_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInForwDatagrams_val_ptr);
+@@ -1267,7 +1267,7 @@ The total number of datagrams successful
+ */
+ int
+ ipIfStatsHCInDelivers_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInDelivers_val_ptr)
++ struct counter64 *ipIfStatsHCInDelivers_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInDelivers_val_ptr);
+@@ -1396,7 +1396,7 @@ The total number of IP datagrams that lo
+ */
+ int
+ ipIfStatsHCOutRequests_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutRequests_val_ptr)
++ struct counter64 *ipIfStatsHCOutRequests_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutRequests_val_ptr);
+@@ -1532,7 +1532,7 @@ The number of datagrams for which this e
+ */
+ int
+ ipIfStatsHCOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutForwDatagrams_val_ptr)
++ struct counter64 *ipIfStatsHCOutForwDatagrams_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutForwDatagrams_val_ptr);
+@@ -1999,7 +1999,7 @@ The total number of IP datagrams that th
+ */
+ int
+ ipIfStatsHCOutTransmits_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutTransmits_val_ptr)
++ struct counter64 *ipIfStatsHCOutTransmits_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutTransmits_val_ptr);
+@@ -2123,7 +2123,7 @@ The total number of octets in IP datagra
+ */
+ int
+ ipIfStatsHCOutOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutOctets_val_ptr)
++ struct counter64 *ipIfStatsHCOutOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutOctets_val_ptr);
+@@ -2245,7 +2245,7 @@ The number of IP multicast datagrams rec
+ */
+ int
+ ipIfStatsHCInMcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInMcastPkts_val_ptr)
++ struct counter64 *ipIfStatsHCInMcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInMcastPkts_val_ptr);
+@@ -2372,7 +2372,7 @@ The total number of octets received in I
+ */
+ int
+ ipIfStatsHCInMcastOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInMcastOctets_val_ptr)
++ struct counter64 *ipIfStatsHCInMcastOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInMcastOctets_val_ptr);
+@@ -2497,7 +2497,7 @@ The number of IP multicast datagrams tra
+ */
+ int
+ ipIfStatsHCOutMcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutMcastPkts_val_ptr)
++ struct counter64 *ipIfStatsHCOutMcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutMcastPkts_val_ptr);
+@@ -2621,7 +2621,7 @@ The total number of octets transmitted i
+ */
+ int
+ ipIfStatsHCOutMcastOctets_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutMcastOctets_val_ptr)
++ struct counter64 *ipIfStatsHCOutMcastOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutMcastOctets_val_ptr);
+@@ -2743,7 +2743,7 @@ The number of IP broadcast datagrams rec
+ */
+ int
+ ipIfStatsHCInBcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCInBcastPkts_val_ptr)
++ struct counter64 *ipIfStatsHCInBcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCInBcastPkts_val_ptr);
+@@ -2865,7 +2865,7 @@ The number of IP broadcast datagrams tra
+ */
+ int
+ ipIfStatsHCOutBcastPkts_get(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipIfStatsHCOutBcastPkts_val_ptr)
++ struct counter64 *ipIfStatsHCOutBcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipIfStatsHCOutBcastPkts_val_ptr);
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_data_get.h
+@@ -50,7 +50,7 @@ extern "C" {
+ ipIfStatsInReceives_val_ptr);
+ int ipIfStatsHCInReceives_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInReceives_val_ptr);
+ int ipIfStatsInOctets_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -58,7 +58,7 @@ extern "C" {
+ ipIfStatsInOctets_val_ptr);
+ int ipIfStatsHCInOctets_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInOctets_val_ptr);
+ int ipIfStatsInHdrErrors_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -87,7 +87,7 @@ extern "C" {
+ int
+ ipIfStatsHCInForwDatagrams_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInForwDatagrams_val_ptr);
+ int ipIfStatsReasmReqds_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -111,7 +111,7 @@ extern "C" {
+ ipIfStatsInDelivers_val_ptr);
+ int ipIfStatsHCInDelivers_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInDelivers_val_ptr);
+ int ipIfStatsOutRequests_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -119,7 +119,7 @@ extern "C" {
+ ipIfStatsOutRequests_val_ptr);
+ int ipIfStatsHCOutRequests_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutRequests_val_ptr);
+ int ipIfStatsOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx
+ * rowreq_ctx,
+@@ -128,7 +128,7 @@ extern "C" {
+ int
+ ipIfStatsHCOutForwDatagrams_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutForwDatagrams_val_ptr);
+ int ipIfStatsOutDiscards_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -156,7 +156,7 @@ extern "C" {
+ ipIfStatsOutTransmits_val_ptr);
+ int ipIfStatsHCOutTransmits_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutTransmits_val_ptr);
+ int ipIfStatsOutOctets_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -164,7 +164,7 @@ extern "C" {
+ ipIfStatsOutOctets_val_ptr);
+ int ipIfStatsHCOutOctets_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutOctets_val_ptr);
+ int ipIfStatsInMcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -172,7 +172,7 @@ extern "C" {
+ ipIfStatsInMcastPkts_val_ptr);
+ int ipIfStatsHCInMcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInMcastPkts_val_ptr);
+ int ipIfStatsInMcastOctets_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -180,7 +180,7 @@ extern "C" {
+ ipIfStatsInMcastOctets_val_ptr);
+ int ipIfStatsHCInMcastOctets_get(ipIfStatsTable_rowreq_ctx
+ * rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInMcastOctets_val_ptr);
+ int ipIfStatsOutMcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -188,7 +188,7 @@ extern "C" {
+ ipIfStatsOutMcastPkts_val_ptr);
+ int ipIfStatsHCOutMcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutMcastPkts_val_ptr);
+ int ipIfStatsOutMcastOctets_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -196,7 +196,7 @@ extern "C" {
+ ipIfStatsOutMcastOctets_val_ptr);
+ int ipIfStatsHCOutMcastOctets_get(ipIfStatsTable_rowreq_ctx
+ * rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutMcastOctets_val_ptr);
+ int ipIfStatsInBcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -204,7 +204,7 @@ extern "C" {
+ ipIfStatsInBcastPkts_val_ptr);
+ int ipIfStatsHCInBcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCInBcastPkts_val_ptr);
+ int ipIfStatsOutBcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+@@ -212,7 +212,7 @@ extern "C" {
+ ipIfStatsOutBcastPkts_val_ptr);
+ int ipIfStatsHCOutBcastPkts_get(ipIfStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipIfStatsHCOutBcastPkts_val_ptr);
+ int
+ ipIfStatsDiscontinuityTime_get(ipIfStatsTable_rowreq_ctx *
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c
+@@ -722,10 +722,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINRECEIVES:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCInReceives_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -741,9 +741,9 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ipIfStatsHCInOctets_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ipIfStatsHCInOctets_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -810,10 +810,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINFORWDATAGRAMS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCInForwDatagrams_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -869,10 +869,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINDELIVERS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCInDelivers_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -889,10 +889,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTREQUESTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCOutRequests_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -909,10 +909,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTFORWDATAGRAMS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCOutForwDatagrams_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -979,10 +979,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTTRANSMITS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCOutTransmits_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -999,9 +999,9 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+- rc = ipIfStatsHCOutOctets_get(rowreq_ctx, (U64 *) var->val.string);
++ rc = ipIfStatsHCOutOctets_get(rowreq_ctx, (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1018,10 +1018,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINMCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCInMcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1038,10 +1038,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINMCASTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCInMcastOctets_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1058,10 +1058,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTMCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCOutMcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1078,10 +1078,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTMCASTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCOutMcastOctets_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1098,10 +1098,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCINBCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCInBcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1118,10 +1118,10 @@ _ipIfStatsTable_get_column(ipIfStatsTabl
+ * ipIfStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPIFSTATSHCOUTBCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipIfStatsHCOutBcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.c
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.c
+@@ -452,7 +452,7 @@ The total number of input IP datagrams r
+ */
+ int
+ ipSystemStatsHCInReceives_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCInReceives_val_ptr)
++ struct counter64 *ipSystemStatsHCInReceives_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCInReceives_val_ptr);
+@@ -579,7 +579,7 @@ The total number of octets received in i
+ */
+ int
+ ipSystemStatsHCInOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCInOctets_val_ptr)
++ struct counter64 *ipSystemStatsHCInOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCInOctets_val_ptr);
+@@ -1058,7 +1058,7 @@ The number of input datagrams for which
+ int
+ ipSystemStatsHCInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInForwDatagrams_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+@@ -1474,7 +1474,7 @@ The total number of datagrams successful
+ */
+ int
+ ipSystemStatsHCInDelivers_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCInDelivers_val_ptr)
++ struct counter64 *ipSystemStatsHCInDelivers_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCInDelivers_val_ptr);
+@@ -1602,7 +1602,7 @@ The total number of IP datagrams which l
+ */
+ int
+ ipSystemStatsHCOutRequests_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCOutRequests_val_ptr)
++ struct counter64 *ipSystemStatsHCOutRequests_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCOutRequests_val_ptr);
+@@ -1809,7 +1809,7 @@ The number of datagrams for which this e
+ int
+ ipSystemStatsHCOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutForwDatagrams_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+@@ -2288,7 +2288,7 @@ The total number of IP datagrams that th
+ */
+ int
+ ipSystemStatsHCOutTransmits_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCOutTransmits_val_ptr)
++ struct counter64 *ipSystemStatsHCOutTransmits_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCOutTransmits_val_ptr);
+@@ -2415,7 +2415,7 @@ The total number of octets in IP datagra
+ */
+ int
+ ipSystemStatsHCOutOctets_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCOutOctets_val_ptr)
++ struct counter64 *ipSystemStatsHCOutOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCOutOctets_val_ptr);
+@@ -2539,7 +2539,7 @@ The number of IP multicast datagrams rec
+ */
+ int
+ ipSystemStatsHCInMcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCInMcastPkts_val_ptr)
++ struct counter64 *ipSystemStatsHCInMcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCInMcastPkts_val_ptr);
+@@ -2665,7 +2665,7 @@ The total number of octets received in I
+ int
+ ipSystemStatsHCInMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInMcastOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+@@ -2790,7 +2790,7 @@ The number of IP multicast datagrams tra
+ */
+ int
+ ipSystemStatsHCOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCOutMcastPkts_val_ptr)
++ struct counter64 *ipSystemStatsHCOutMcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCOutMcastPkts_val_ptr);
+@@ -2921,7 +2921,7 @@ The total number of octets transmitted i
+ int
+ ipSystemStatsHCOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutMcastOctets_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+@@ -3046,7 +3046,7 @@ The number of IP broadcast datagrams rec
+ */
+ int
+ ipSystemStatsHCInBcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCInBcastPkts_val_ptr)
++ struct counter64 *ipSystemStatsHCInBcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCInBcastPkts_val_ptr);
+@@ -3170,7 +3170,7 @@ The number of IP broadcast datagrams tra
+ */
+ int
+ ipSystemStatsHCOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
+- U64 * ipSystemStatsHCOutBcastPkts_val_ptr)
++ struct counter64 *ipSystemStatsHCOutBcastPkts_val_ptr)
+ {
+ /** we should have a non-NULL pointer */
+ netsnmp_assert(NULL != ipSystemStatsHCOutBcastPkts_val_ptr);
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable.h
+@@ -144,93 +144,22 @@ config_require(ip-mib/ipSystemStatsTable
+ *********************************************************************
+ * function prototypes
+ */
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsTable_pre_request(ipSystemStatsTable_registration *
++ int ipSystemStatsTable_pre_request(ipSystemStatsTable_registration *
+ user_context);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsTable_post_request(ipSystemStatsTable_registration *
++ int ipSystemStatsTable_post_request(ipSystemStatsTable_registration *
+ user_context, int rc);
+
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsTable_rowreq_ctx_init(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsTable_rowreq_ctx_init(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ void *user_init_ctx);
+ void
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+ ipSystemStatsTable_rowreq_ctx_cleanup(ipSystemStatsTable_rowreq_ctx
+ * rowreq_ctx);
+
+ ipSystemStatsTable_data *ipSystemStatsTable_allocate_data(void);
+ void ipSystemStatsTable_release_data(ipSystemStatsTable_data
+ * data);
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsTable_rowreq_ctx
++ ipSystemStatsTable_rowreq_ctx
+ * ipSystemStatsTable_row_find_by_mib_index
+ (ipSystemStatsTable_mib_index * mib_idx);
+
+@@ -265,226 +194,50 @@ config_require(ip-mib/ipSystemStatsTable
+ * indexes
+ */
+
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInReceives_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInReceives_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInReceives_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInReceives_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInReceives_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInReceives_val_ptr);
+ int ipSystemStatsInOctets_get(ipSystemStatsTable_rowreq_ctx
+ * rowreq_ctx,
+ u_long *
+ ipSystemStatsInOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 * ipSystemStatsHCInOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInHdrErrors_get(ipSystemStatsTable_rowreq_ctx *
++ struct counter64 *ipSystemStatsHCInOctets_val_ptr);
++ int ipSystemStatsInHdrErrors_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInHdrErrors_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInNoRoutes_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInNoRoutes_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInNoRoutes_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInAddrErrors_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInAddrErrors_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInAddrErrors_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInUnknownProtos_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInUnknownProtos_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInUnknownProtos_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInTruncatedPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInTruncatedPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInTruncatedPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInForwDatagrams_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInForwDatagrams_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsReasmReqds_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsReasmReqds_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsReasmReqds_val_ptr);
+@@ -492,690 +245,142 @@ config_require(ip-mib/ipSystemStatsTable
+ * rowreq_ctx,
+ u_long *
+ ipSystemStatsReasmOKs_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsReasmFails_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsReasmFails_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsReasmFails_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInDiscards_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInDiscards_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInDiscards_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInDelivers_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInDelivers_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInDelivers_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInDelivers_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInDelivers_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInDelivers_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutRequests_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutRequests_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutRequests_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutRequests_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutRequests_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutRequests_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutNoRoutes_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutNoRoutes_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutNoRoutes_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutForwDatagrams_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutForwDatagrams_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutForwDatagrams_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutDiscards_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutDiscards_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutDiscards_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutFragReqds_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutFragReqds_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutFragReqds_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutFragOKs_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutFragOKs_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutFragOKs_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutFragFails_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutFragFails_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutFragFails_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutFragCreates_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutFragCreates_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutFragCreates_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutTransmits_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutTransmits_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutTransmits_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutTransmits_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutTransmits_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutTransmits_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInMcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInMcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInMcastOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInMcastOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutMcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutMcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutMcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutMcastOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutMcastOctets_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutMcastOctets_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsInBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsInBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsInBcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCInBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCInBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCInBcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsOutBcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsHCOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsHCOutBcastPkts_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+- U64 *
++ struct counter64 *
+ ipSystemStatsHCOutBcastPkts_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsDiscontinuityTime_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsDiscontinuityTime_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsDiscontinuityTime_val_ptr);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsRefreshRate_get(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsRefreshRate_get(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long *
+ ipSystemStatsRefreshRate_val_ptr);
+-
+-
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsTable_indexes_set_tbl_idx(ipSystemStatsTable_mib_index
++ int ipSystemStatsTable_indexes_set_tbl_idx(ipSystemStatsTable_mib_index
+ * tbl_idx,
+ u_long
+ ipSystemStatsIPVersion_val);
+- int
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- ipSystemStatsTable_indexes_set(ipSystemStatsTable_rowreq_ctx *
++ int ipSystemStatsTable_indexes_set(ipSystemStatsTable_rowreq_ctx *
+ rowreq_ctx,
+ u_long ipSystemStatsIPVersion_val);
+
+-
+-
+ /*
+ *********************************************************************
+ * SET function declarations
+Index: net-snmp-5.7.3/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c
++++ net-snmp-5.7.3/agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c
+@@ -674,10 +674,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINRECEIVES:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInReceives_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -694,10 +694,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInOctets_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -764,10 +764,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINFORWDATAGRAMS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInForwDatagrams_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -824,10 +824,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINDELIVERS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInDelivers_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -844,10 +844,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTREQUESTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutRequests_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -874,10 +874,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTFORWDATAGRAMS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutForwDatagrams_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -944,10 +944,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTTRANSMITS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutTransmits_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -964,10 +964,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutOctets_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -984,10 +984,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINMCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInMcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1004,10 +1004,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINMCASTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInMcastOctets_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1024,10 +1024,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTMCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutMcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1044,10 +1044,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTMCASTOCTETS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutMcastOctets_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1064,10 +1064,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCINBCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCInBcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+@@ -1084,10 +1084,10 @@ _ipSystemStatsTable_get_column(ipSystemS
+ * ipSystemStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
+ */
+ case COLUMN_IPSYSTEMSTATSHCOUTBCASTPKTS:
+- var->val_len = sizeof(U64);
++ var->val_len = sizeof(struct counter64);
+ var->type = ASN_COUNTER64;
+ rc = ipSystemStatsHCOutBcastPkts_get(rowreq_ctx,
+- (U64 *) var->val.string);
++ (struct counter64 *) var->val.string);
+ break;
+
+ /*
+Index: net-snmp-5.7.3/include/net-snmp/data_access/ipstats.h
+===================================================================
+--- net-snmp-5.7.3.orig/include/net-snmp/data_access/ipstats.h
++++ net-snmp-5.7.3/include/net-snmp/data_access/ipstats.h
+@@ -58,45 +58,45 @@ typedef struct netsnmp_ipstats_s {
+ * other columns, when underlying OS does not provide them.
+ * Always fill at least 32 bits, the table is periodically polled -> 32 bit
+ * overflow shall be detected and 64 bit value should be computed automatically. */
+- U64 HCInReceives;
+- U64 HCInOctets;
++ struct counter64 HCInReceives;
++ struct counter64 HCInOctets;
+ u_long InHdrErrors;
+- U64 HCInNoRoutes;
++ struct counter64 HCInNoRoutes;
+ u_long InAddrErrors;
+ u_long InUnknownProtos;
+ u_long InTruncatedPkts;
+
+ /* optional, can be computed from HCInNoRoutes and HCOutForwDatagrams */
+- U64 HCInForwDatagrams;
++ struct counter64 HCInForwDatagrams;
+
+ u_long ReasmReqds;
+ u_long ReasmOKs;
+ u_long ReasmFails;
+ u_long InDiscards;
+- U64 HCInDelivers;
+- U64 HCOutRequests;
+- U64 HCOutNoRoutes;
+- U64 HCOutForwDatagrams;
+- U64 HCOutDiscards;
++ struct counter64 HCInDelivers;
++ struct counter64 HCOutRequests;
++ struct counter64 HCOutNoRoutes;
++ struct counter64 HCOutForwDatagrams;
++ struct counter64 HCOutDiscards;
+
+ /* optional, can be computed from HCOutFragOKs + HCOutFragFails*/
+- U64 HCOutFragReqds;
+- U64 HCOutFragOKs;
+- U64 HCOutFragFails;
+- U64 HCOutFragCreates;
++ struct counter64 HCOutFragReqds;
++ struct counter64 HCOutFragOKs;
++ struct counter64 HCOutFragFails;
++ struct counter64 HCOutFragCreates;
+
+ /* optional, can be computed from
+ * HCOutRequests +HCOutForwDatagrams + HCOutFragCreates
+ * - HCOutFragReqds - HCOutNoRoutes - HCOutDiscards */
+- U64 HCOutTransmits;
++ struct counter64 HCOutTransmits;
+
+- U64 HCOutOctets;
+- U64 HCInMcastPkts;
+- U64 HCInMcastOctets;
+- U64 HCOutMcastPkts;
+- U64 HCOutMcastOctets;
+- U64 HCInBcastPkts;
+- U64 HCOutBcastPkts;
++ struct counter64 HCOutOctets;
++ struct counter64 HCInMcastPkts;
++ struct counter64 HCInMcastOctets;
++ struct counter64 HCOutMcastPkts;
++ struct counter64 HCOutMcastOctets;
++ struct counter64 HCInBcastPkts;
++ struct counter64 HCOutBcastPkts;
+
+ /* Array of available columns.*/
+ int columnAvail[IPSYSTEMSTATSTABLE_LAST+1];
+Index: net-snmp-5.7.3/include/net-snmp/library/int64.h
+===================================================================
+--- net-snmp-5.7.3.orig/include/net-snmp/library/int64.h
++++ net-snmp-5.7.3/include/net-snmp/library/int64.h
+@@ -5,31 +5,29 @@
+ extern "C" {
+ #endif
+
+- typedef struct counter64 U64;
+-
+ #define I64CHARSZ 21
+
+- void divBy10(U64, U64 *, unsigned int *);
+- void multBy10(U64, U64 *);
+- void incrByU16(U64 *, unsigned int);
+- void incrByU32(U64 *, unsigned int);
++ void divBy10(struct counter64, struct counter64 *, unsigned int *);
++ void multBy10(struct counter64, struct counter64 *);
++ void incrByU16(struct counter64 *, unsigned int);
++ void incrByU32(struct counter64 *, unsigned int);
+ NETSNMP_IMPORT
+- void zeroU64(U64 *);
+- int isZeroU64(const U64 *);
++ void zeroU64(struct counter64 *);
++ int isZeroU64(const struct counter64 *);
+ NETSNMP_IMPORT
+- void printU64(char *, const U64 *);
++ void printU64(char *, const struct counter64 *);
+ NETSNMP_IMPORT
+- void printI64(char *, const U64 *);
+- int read64(U64 *, const char *);
++ void printI64(char *, const struct counter64 *);
++ int read64(struct counter64 *, const char *);
+ NETSNMP_IMPORT
+- void u64Subtract(const U64 * pu64one, const U64 * pu64two,
+- U64 * pu64out);
+- void u64Incr(U64 * pu64out, const U64 * pu64one);
+- void u64UpdateCounter(U64 * pu64out, const U64 * pu64one,
+- const U64 * pu64two);
+- void u64Copy(U64 * pu64one, const U64 * pu64two);
++ void u64Subtract(const struct counter64 *pu64one, const struct counter64 *pu64two,
++ struct counter64 *pu64out);
++ void u64Incr(struct counter64 *pu64out, const struct counter64 *pu64one);
++ void u64UpdateCounter(struct counter64 *pu64out, const struct counter64 *pu64one,
++ const struct counter64 *pu64two);
++ void u64Copy(struct counter64 *pu64one, const struct counter64 *pu64two);
+
+- int netsnmp_c64_check_for_32bit_wrap(U64 *old_val, U64 *new_val,
++ int netsnmp_c64_check_for_32bit_wrap(struct counter64 *old_val, struct counter64 *new_val,
+ int adjust);
+ NETSNMP_IMPORT
+ int netsnmp_c64_check32_and_update(struct counter64 *prev_val,
+Index: net-snmp-5.7.3/snmplib/int64.c
+===================================================================
+--- net-snmp-5.7.3.orig/snmplib/int64.c
++++ net-snmp-5.7.3/snmplib/int64.c
+@@ -33,7 +33,7 @@
+ * @param[out] puR Remainder.
+ */
+ void
+-divBy10(U64 u64, U64 * pu64Q, unsigned int *puR)
++divBy10(struct counter64 u64, struct counter64 *pu64Q, unsigned int *puR)
+ {
+ unsigned long ulT;
+ unsigned long ulQ;
+@@ -83,7 +83,7 @@ divBy10(U64 u64, U64 * pu64Q, unsigned i
+ * @param[out] pu64P Product.
+ */
+ void
+-multBy10(U64 u64, U64 * pu64P)
++multBy10(struct counter64 u64, struct counter64 *pu64P)
+ {
+ unsigned long ulT;
+ unsigned long ulP;
+@@ -130,7 +130,7 @@ multBy10(U64 u64, U64 * pu64P)
+ *
+ */
+ void
+-incrByU16(U64 * pu64, unsigned int u16)
++incrByU16(struct counter64 *pu64, unsigned int u16)
+ {
+ incrByU32(pu64, u16);
+ }
+@@ -143,7 +143,7 @@ incrByU16(U64 * pu64, unsigned int u16)
+ *
+ */
+ void
+-incrByU32(U64 * pu64, unsigned int u32)
++incrByU32(struct counter64 *pu64, unsigned int u32)
+ {
+ uint32_t tmp;
+
+@@ -161,7 +161,7 @@ incrByU32(U64 * pu64, unsigned int u32)
+ * @param[out] pu64out pu64one - pu64two.
+ */
+ void
+-u64Subtract(const U64 * pu64one, const U64 * pu64two, U64 * pu64out)
++u64Subtract(const struct counter64 *pu64one, const struct counter64 *pu64two, struct counter64 *pu64out)
+ {
+ int carry;
+
+@@ -177,7 +177,7 @@ u64Subtract(const U64 * pu64one, const U
+ * @param[in,out] pu64out pu64out += pu64one.
+ */
+ void
+-u64Incr(U64 * pu64out, const U64 * pu64one)
++u64Incr(struct counter64 *pu64out, const struct counter64 *pu64one)
+ {
+ pu64out->high = (uint32_t)(pu64out->high + pu64one->high);
+ incrByU32(pu64out, pu64one->low);
+@@ -191,9 +191,9 @@ u64Incr(U64 * pu64out, const U64 * pu64o
+ * @param[out] pu64out pu64out += (pu64one - pu64two)
+ */
+ void
+-u64UpdateCounter(U64 * pu64out, const U64 * pu64one, const U64 * pu64two)
++u64UpdateCounter(struct counter64 *pu64out, const struct counter64 *pu64one, const struct counter64 *pu64two)
+ {
+- U64 tmp;
++ struct counter64 tmp;
+
+ u64Subtract(pu64one, pu64two, &tmp);
+ u64Incr(pu64out, &tmp);
+@@ -208,7 +208,7 @@ netsnmp_feature_child_of(u64copy, netsnm
+ * @param[out] pu64one Where to store the copy - *pu64one = *pu64two.
+ */
+ void
+-u64Copy(U64 * pu64one, const U64 * pu64two)
++u64Copy(struct counter64 *pu64one, const struct counter64 *pu64two)
+ {
+ *pu64one = *pu64two;
+ }
+@@ -220,7 +220,7 @@ u64Copy(U64 * pu64one, const U64 * pu64t
+ * @param[in] pu64 Number to be zeroed.
+ */
+ void
+-zeroU64(U64 * pu64)
++zeroU64(struct counter64 *pu64)
+ {
+ pu64->low = 0;
+ pu64->high = 0;
+@@ -232,7 +232,7 @@ zeroU64(U64 * pu64)
+ * @param[in] pu64 Number to be checked.
+ */
+ int
+-isZeroU64(const U64 * pu64)
++isZeroU64(const struct counter64 *pu64)
+ {
+ return pu64->low == 0 && pu64->high == 0;
+ }
+@@ -390,10 +390,10 @@ netsnmp_c64_check32_and_update(struct co
+ /** Convert an unsigned 64-bit number to ASCII. */
+ void
+ printU64(char *buf, /* char [I64CHARSZ+1]; */
+- const U64 * pu64)
++ const struct counter64 *pu64)
+ {
+- U64 u64a;
+- U64 u64b;
++ struct counter64 u64a;
++ struct counter64 u64b;
+
+ char aRes[I64CHARSZ + 1];
+ unsigned int u;
+@@ -414,9 +414,9 @@ printU64(char *buf, /* char [I64CHARSZ+1
+ /** Convert a signed 64-bit number to ASCII. */
+ void
+ printI64(char *buf, /* char [I64CHARSZ+1]; */
+- const U64 * pu64)
++ const struct counter64 *pu64)
+ {
+- U64 u64a;
++ struct counter64 u64a;
+
+ if (pu64->high & 0x80000000) {
+ u64a.high = (uint32_t) ~pu64->high;
+@@ -429,11 +429,11 @@ printI64(char *buf, /* char [I64CHARSZ+1
+ }
+ }
+
+-/** Convert a signed 64-bit integer from ASCII to U64. */
++/** Convert a signed 64-bit integer from ASCII to struct counter64. */
+ int
+-read64(U64 * i64, const char *str)
++read64(struct counter64 *i64, const char *str)
+ {
+- U64 i64p;
++ struct counter64 i64p;
+ unsigned int u;
+ int sign = 0;
+ int ok = 0;
+Index: net-snmp-5.7.3/snmplib/read_config.c
+===================================================================
+--- net-snmp-5.7.3.orig/snmplib/read_config.c
++++ net-snmp-5.7.3/snmplib/read_config.c
+@@ -2270,10 +2270,10 @@ read_config_read_memory(int type, char *
+ return readfrom;
+
+ case ASN_COUNTER64:
+- if (*len < sizeof(U64))
++ if (*len < sizeof(struct counter64))
+ return NULL;
+- *len = sizeof(U64);
+- read64((U64 *) dataptr, readfrom);
++ *len = sizeof(struct counter64);
++ read64((struct counter64 *) dataptr, readfrom);
+ readfrom = skip_token(readfrom);
+ return readfrom;
+ }
+Index: net-snmp-5.7.3/testing/fulltests/unit-tests/T015int64_clib.c
+===================================================================
+--- net-snmp-5.7.3.orig/testing/fulltests/unit-tests/T015int64_clib.c
++++ net-snmp-5.7.3/testing/fulltests/unit-tests/T015int64_clib.c
+@@ -1,4 +1,4 @@
+-/* HEADER Testing 64-bit integer operations (U64). */
++/* HEADER Testing 64-bit integer operations (struct counter64). */
+
+ int i, j;
+ char buf[22];
+@@ -15,7 +15,7 @@ static const int64_t intval[] = {
+ };
+
+ for (i = 0; i < sizeof(intval)/sizeof(intval[0]); ++i) {
+- U64 a, b;
++ struct counter64 a, b;
+ a.low = (uint32_t)intval[i];
+ a.high = (uint32_t)(intval[i] >> 32);
+ printI64(buf, &a);
+@@ -27,7 +27,7 @@ for (i = 0; i < sizeof(intval)/sizeof(in
+
+ for (i = 0; i < sizeof(intval)/sizeof(intval[0]); ++i) {
+ for (j = i; j < sizeof(intval)/sizeof(intval[0]); ++j) {
+- U64 a, b;
++ struct counter64 a, b;
+ uint64_t d;
+ a.low = (uint32_t)intval[i];
+ a.high = (uint32_t)(intval[i] >> 32);
+@@ -43,7 +43,7 @@ for (i = 0; i < sizeof(intval)/sizeof(in
+
+ for (i = 0; i < sizeof(intval)/sizeof(intval[0]); ++i) {
+ for (j = i; j < sizeof(intval)/sizeof(intval[0]); ++j) {
+- U64 a, b, c;
++ struct counter64 a, b, c;
+ uint64_t d;
+ a.low = (uint32_t)intval[i];
+ a.high = (uint32_t)(intval[i] >> 32);
+@@ -58,7 +58,7 @@ for (i = 0; i < sizeof(intval)/sizeof(in
+ }
+
+ {
+- U64 old_val, new_val;
++ struct counter64 old_val, new_val;
+ old_val.low = 7;
+ old_val.high = 0;
+ new_val = old_val;
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_headers-Error-Fix.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_headers-Error-Fix.patch
new file mode 100644
index 000000000..44359bebe
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_headers-Error-Fix.patch
@@ -0,0 +1,34 @@
+From 261a22096c79f8e6ef7b387514a74d208e4e5945 Mon Sep 17 00:00:00 2001
+From: Li xin <lixin.fnst@cn.fujitsu.com>
+Date: Fri, 21 Aug 2015 18:23:13 +0900
+Subject: [PATCH] config_os_headers: Error Fix
+
+ERROR: This autoconf log indicates errors, it looked at host include
+and/or library paths while determining system capabilities.
+cc1: warning: include location "/usr/local/include" is unsafe for cross-compilation [-Wpoison-system-directories]
+conftest.c:168:17: fatal error: pkg.h: No such file or directory
+ #include <pkg.h>
+ ^
+
+Upstream-Status: pending
+
+Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com>
+---
+ configure.d/config_os_headers | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+Index: net-snmp-5.7.3/configure.d/config_os_headers
+===================================================================
+--- net-snmp-5.7.3.orig/configure.d/config_os_headers
++++ net-snmp-5.7.3/configure.d/config_os_headers
+@@ -484,8 +484,8 @@ then
+ unset ac_cv_header_pkg_h
+ netsnmp_save_CPPFLAGS="$CPPFLAGS"
+ netsnmp_save_LDFLAGS="$LDFLAGS"
+- CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+- LDFLAGS="$LDFLAGS -L/usr/local/lib"
++ CPPFLAGS="$CPPFLAGS"
++ LDFLAGS="$LDFLAGS"
+ AC_CHECK_HEADERS(pkg.h,
+ NETSNMP_SEARCH_LIBS(pkg_init, pkg,
+ AC_DEFINE(HAVE_LIBPKG, 1, [define if you have BSD pkg-ng])))
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_libs2-Error-Fix.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_libs2-Error-Fix.patch
new file mode 100644
index 000000000..5866a95ed
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-config_os_libs2-Error-Fix.patch
@@ -0,0 +1,31 @@
+From e24fcd140f3f6dd18fd836b197c6d4bb773e50e7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <funman@videolan.org>
+Date: Wed, 4 Nov 2015 16:49:30 +0100
+Subject: [PATCH] config_os_libs2: Error Fix
+
+ERROR: This autoconf log indicates errors, it looked at host include
+and/or library paths while determining system capabilities.
+---
+ configure.d/config_os_libs2 | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.d/config_os_libs2 b/configure.d/config_os_libs2
+index 47491e2..e3647f9 100644
+--- a/configure.d/config_os_libs2
++++ b/configure.d/config_os_libs2
+@@ -226,10 +226,10 @@ if test "x$with_nl" != "xno"; then
+ case $target_os in
+ linux*) # Check for libnl (linux)
+ netsnmp_save_CPPFLAGS="$CPPFLAGS"
+- CPPFLAGS="-I/usr/include/libnl3 $CPPFLAGS"
++ CPPFLAGS="$CPPFLAGS"
+ NETSNMP_SEARCH_LIBS(nl_connect, nl-3,
+ [AC_CHECK_HEADERS(netlink/netlink.h)
+- EXTERNAL_MIBGROUP_INCLUDES="$EXTERNAL_MIBGROUP_INCLUDES -I/usr/include/libnl3"],
++ EXTERNAL_MIBGROUP_INCLUDES="$EXTERNAL_MIBGROUP_INCLUDES"],
+ [CPPFLAGS="$netsnmp_save_CPPFLAGS"], [], [], [LMIBLIBS])
+ if test "x$ac_cv_header_netlink_netlink_h" != xyes; then
+ NETSNMP_SEARCH_LIBS(nl_connect, nl, [
+--
+2.5.0
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-configure-fix-check-for-enable-perl-cc-checks.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-configure-fix-check-for-enable-perl-cc-checks.patch
new file mode 100644
index 000000000..b87e9eec2
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-configure-fix-check-for-enable-perl-cc-checks.patch
@@ -0,0 +1,31 @@
+From c6304a3e4b8441ff0a6464c0f1f6c5229092fa32 Mon Sep 17 00:00:00 2001
+From: Niels Baggesen <nba@users.sourceforge.net>
+Date: Wed, 24 May 2017 16:40:03 +0800
+Subject: [PATCH 1/4] configure: fix check for --enable-perl-cc-checks
+
+This patch comes from git://git.code.sf.net/p/net-snmp/code,
+the commit is 8f431d410b803603dc809d82e0893509615d9a11.
+
+Upstream-Status: Backport
+
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+---
+ configure.d/config_project_perl_python | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.d/config_project_perl_python b/configure.d/config_project_perl_python
+index 23f8c7e..475c843 100644
+--- a/configure.d/config_project_perl_python
++++ b/configure.d/config_project_perl_python
+@@ -84,7 +84,7 @@ if test "x$install_perl" != "xno" ; then
+
+ # What compiler was used to build the perl binary?
+ #
+- if test "xenable_perl_cc_checks" != "xno" ; then
++ if test "x$enable_perl_cc_checks" != "xno" ; then
+ AC_MSG_CHECKING([for Perl cc])
+ changequote(, )
+ PERLCC=`$myperl -V:cc | $myperl -n -e 'print if (s/^\s*cc=.([-=\w\s\/]+).;\s*/$1/);'`
+--
+1.9.1
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get_pid_from_inode-Include-limit.h.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get_pid_from_inode-Include-limit.h.patch
new file mode 100644
index 000000000..60ce80996
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get_pid_from_inode-Include-limit.h.patch
@@ -0,0 +1,29 @@
+From 7136d593ba96b64537069637c328bc65e1b66b2d Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 22 Jul 2016 18:34:39 +0000
+Subject: [PATCH] get_pid_from_inode: Include limit.h
+
+PATH_MAX and NAME_MAX are required by this file
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Pending
+
+ agent/mibgroup/util_funcs/get_pid_from_inode.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/agent/mibgroup/util_funcs/get_pid_from_inode.c b/agent/mibgroup/util_funcs/get_pid_from_inode.c
+index 8e157ae..a494ec7 100644
+--- a/agent/mibgroup/util_funcs/get_pid_from_inode.c
++++ b/agent/mibgroup/util_funcs/get_pid_from_inode.c
+@@ -5,6 +5,7 @@
+ #include <net-snmp/output_api.h>
+
+ #include <ctype.h>
++#include <limits.h>
+ #include <stdio.h>
+ #if HAVE_STDLIB_H
+ #include <stdlib.h>
+--
+1.8.3.1
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-UDPIPv6-transport-Add-a-missing-return-state.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-UDPIPv6-transport-Add-a-missing-return-state.patch
new file mode 100644
index 000000000..527aa39f2
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-UDPIPv6-transport-Add-a-missing-return-state.patch
@@ -0,0 +1,26 @@
+From 1ee72102fbe722d232d74abc4660a8b134cec8d6 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Sat, 23 May 2015 07:32:53 +0200
+Subject: [PATCH] snmplib, UDPIPv6 transport: Add a missing return statement
+
+Detected by Coverity.
+
+Upstream-Status: backport
+
+Signed-off-by: Li Zhou <li.zhou@windriver.com>
+---
+ snmplib/transports/snmpUDPIPv6Domain.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+Index: net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
+===================================================================
+--- net-snmp-5.7.3.orig/snmplib/transports/snmpUDPIPv6Domain.c
++++ net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
+@@ -305,6 +305,7 @@ netsnmp_udp6_transport(struct sockaddr_i
+ errno, strerror(errno)));
+ netsnmp_socketbase_close(t);
+ netsnmp_transport_free(t);
++ return NULL;
+ }
+ }
+ /*
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch
new file mode 100644
index 000000000..af242fafb
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmplib-keytools.c-Don-t-check-for-return-from-EVP_M.patch
@@ -0,0 +1,33 @@
+From d3027a227bc0f603a5b650d01f97ee1dec515be5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 18 Sep 2015 00:28:45 -0400
+Subject: [PATCH] snmplib/keytools.c: Don't check for return from
+ EVP_MD_CTX_init()
+
+EVP_MD_CTX_init() API returns void, it fixes errors with new compilers
+
+snmplib/keytools.c: In function 'generate_Ku': error: invalid use of void expression
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Submitted [https://sourceforge.net/p/net-snmp/patches/1317/]
+ snmplib/keytools.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/snmplib/keytools.c b/snmplib/keytools.c
+index 0ccb3a6..880fc14 100644
+--- a/snmplib/keytools.c
++++ b/snmplib/keytools.c
+@@ -153,8 +153,7 @@ generate_Ku(const oid * hashtype, u_int hashtype_len,
+ ctx = EVP_MD_CTX_create();
+ #else
+ ctx = malloc(sizeof(*ctx));
+- if (!EVP_MD_CTX_init(ctx))
+- return SNMPERR_GENERR;
++ EVP_MD_CTX_init(ctx);
+ #endif
+ #ifndef NETSNMP_DISABLE_MD5
+ if (ISTRANSFORM(hashtype, HMACMD5Auth)) {
+--
+2.5.2
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0002-configure-fix-a-cc-check-issue.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0002-configure-fix-a-cc-check-issue.patch
new file mode 100644
index 000000000..999976d27
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0002-configure-fix-a-cc-check-issue.patch
@@ -0,0 +1,30 @@
+From 94e7e4969bc84c945dfea12d67a1e10f61973948 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <wenlin.kang@windriver.com>
+Date: Wed, 24 May 2017 16:45:34 +0800
+Subject: [PATCH 2/4] configure: fix a cc check issue.
+
+When has "." in cc value, the expression
+$myperl -V:cc | $myperl -n -e 'print if (s/^\s*cc=.([-=\w\s\/]+).;\s*/$1/);'
+can't get corretly the cc's value.
+
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+---
+ configure.d/config_project_perl_python | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.d/config_project_perl_python b/configure.d/config_project_perl_python
+index 475c843..22d2ad3 100644
+--- a/configure.d/config_project_perl_python
++++ b/configure.d/config_project_perl_python
+@@ -87,7 +87,7 @@ if test "x$install_perl" != "xno" ; then
+ if test "x$enable_perl_cc_checks" != "xno" ; then
+ AC_MSG_CHECKING([for Perl cc])
+ changequote(, )
+- PERLCC=`$myperl -V:cc | $myperl -n -e 'print if (s/^\s*cc=.([-=\w\s\/]+).;\s*/$1/);'`
++ PERLCC=`$myperl -V:cc | $myperl -n -e 'print if (s/^\s*cc=.([-=\.\w\s\/]+).;\s*/$1/);'`
+ changequote([, ])
+ if test "x$PERLCC" != "x" ; then
+ AC_MSG_RESULT([$PERLCC])
+--
+1.9.1
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0003-CHANGES-BUG-2712-Fix-Perl-module-compilation.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0003-CHANGES-BUG-2712-Fix-Perl-module-compilation.patch
new file mode 100644
index 000000000..7951234a4
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0003-CHANGES-BUG-2712-Fix-Perl-module-compilation.patch
@@ -0,0 +1,186 @@
+From e57fc809ad6ae522670f3dc157aadde20d968ca7 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 24 May 2017 17:05:03 +0800
+Subject: [PATCH 3/4] CHANGES: BUG: 2712: Fix Perl module compilation
+
+Avoid that building the Net-SNMP Perl modules fails as follows:
+
+ERROR from evaluation of /sources/net-snmp-5.7.3/perl/ASN/Makefile.PL: Bizarre \ copy of HASH in list assignment at /usr/lib/perl5/site_perl/5.24.0/Carp.pm line\ 229.
+
+See also https://sourceforge.net/p/net-snmp/bugs/2712/.
+
+This patch comes from git://git.code.sf.net/p/net-snmp/code,
+the commit is 4e793461e96a2b4fd81142ab312d074d5c8841fa.
+
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+---
+ perl/ASN/Makefile.PL | 4 +---
+ perl/Makefile.PL | 4 +---
+ perl/OID/Makefile.PL | 5 +----
+ perl/SNMP/Makefile.PL | 5 +----
+ perl/TrapReceiver/Makefile.PL | 5 +----
+ perl/agent/Makefile.PL | 5 +----
+ perl/agent/Support/Makefile.PL | 5 +----
+ perl/agent/default_store/Makefile.PL | 5 +----
+ perl/default_store/Makefile.PL | 5 +----
+ 9 files changed, 9 insertions(+), 34 deletions(-)
+
+diff --git a/perl/ASN/Makefile.PL b/perl/ASN/Makefile.PL
+index 4576781..c33d8ba 100644
+--- a/perl/ASN/Makefile.PL
++++ b/perl/ASN/Makefile.PL
+@@ -7,9 +7,7 @@ my $lib_version;
+ # See lib/ExtUtils/MakeMaker.pm for details of how to influence
+ # the contents of the Makefile that is written.
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/Makefile.PL b/perl/Makefile.PL
+index 31fdc40..48aba2a 100644
+--- a/perl/Makefile.PL
++++ b/perl/Makefile.PL
+@@ -3,9 +3,7 @@ use Config;
+ use Getopt::Long;
+ require 5;
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ sub InitMakeParams {
+ $nsconfig="net-snmp-config"; # in path by default
+diff --git a/perl/OID/Makefile.PL b/perl/OID/Makefile.PL
+index 6bb1616..2589985 100644
+--- a/perl/OID/Makefile.PL
++++ b/perl/OID/Makefile.PL
+@@ -6,11 +6,8 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/SNMP/Makefile.PL b/perl/SNMP/Makefile.PL
+index e617cb7..8aab9a9 100644
+--- a/perl/SNMP/Makefile.PL
++++ b/perl/SNMP/Makefile.PL
+@@ -3,15 +3,12 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+ my $opts;
+
+ # See lib/ExtUtils/MakeMaker.pm for details of how to influence
+ # the contents of the Makefile that is written.
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/TrapReceiver/Makefile.PL b/perl/TrapReceiver/Makefile.PL
+index 874ee21..7e9e58e 100644
+--- a/perl/TrapReceiver/Makefile.PL
++++ b/perl/TrapReceiver/Makefile.PL
+@@ -3,11 +3,8 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/agent/Makefile.PL b/perl/agent/Makefile.PL
+index 4f7bee3..003c0d1 100644
+--- a/perl/agent/Makefile.PL
++++ b/perl/agent/Makefile.PL
+@@ -3,11 +3,8 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/agent/Support/Makefile.PL b/perl/agent/Support/Makefile.PL
+index 48815b6..2325e10 100644
+--- a/perl/agent/Support/Makefile.PL
++++ b/perl/agent/Support/Makefile.PL
+@@ -3,14 +3,11 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+
+ # See lib/ExtUtils/MakeMaker.pm for details of how to influence
+ # the contents of the Makefile that is written.
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/agent/default_store/Makefile.PL b/perl/agent/default_store/Makefile.PL
+index ed6483a..31cfbee 100644
+--- a/perl/agent/default_store/Makefile.PL
++++ b/perl/agent/default_store/Makefile.PL
+@@ -3,11 +3,8 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+ Check_Version();
+
+diff --git a/perl/default_store/Makefile.PL b/perl/default_store/Makefile.PL
+index 7c671b8..01c8dd0 100644
+--- a/perl/default_store/Makefile.PL
++++ b/perl/default_store/Makefile.PL
+@@ -3,11 +3,8 @@ require 5;
+ use Config;
+ use Getopt::Long;
+ my $lib_version;
+-my %MakeParams = ();
+
+-%MakeParams = InitMakeParams();
+-
+-WriteMakefile(%MakeParams);
++WriteMakefile(InitMakeParams());
+
+
+ sub InitMakeParams {
+--
+1.9.1
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0004-configure-fix-incorrect-variable.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0004-configure-fix-incorrect-variable.patch
new file mode 100644
index 000000000..2b03f9e9a
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/0004-configure-fix-incorrect-variable.patch
@@ -0,0 +1,30 @@
+From 4ad98ef125eb4e7d7a1a93146042002f78254d36 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <wenlin.kang@windriver.com>
+Date: Wed, 24 May 2017 17:10:20 +0800
+Subject: [PATCH 4/4] configure: fix incorrect variable
+
+For cross compile platform, this variable will not be correct, so fix it.
+
+Upstream-Status: Inappropriate [cross compile specific]
+
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+---
+ Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index cfcdf73..164df05 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -171,7 +171,7 @@ OTHERCLEANTODOS=perlclean @PYTHONCLEANTARGS@ cleanfeatures perlcleanfeatures pyt
+ #
+ # override LD_RUN_PATH to avoid dependencies on the build directory
+ perlmodules: perlmakefiles subdirs
+- @(cd perl ; $(MAKE) LD_RUN_PATH="$(libdir):`$(PERL) -e 'use Config; print qq($$Config{archlibexp}/CORE);'`") ; \
++ @(cd perl ; $(MAKE) LD_RUN_PATH="$(libdir):`$(PERL) -e 'use Config; print qq($$Config{installprivlib}/CORE);'`") ; \
+ if test $$? != 0 ; then \
+ exit 1 ; \
+ fi
+--
+1.9.1
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/dont-return-incompletely-parsed-varbinds.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/dont-return-incompletely-parsed-varbinds.patch
new file mode 100644
index 000000000..6bd0f93c4
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/dont-return-incompletely-parsed-varbinds.patch
@@ -0,0 +1,131 @@
+From 6b93e686bdb6a908d00595608646a05527a5326b Mon Sep 17 00:00:00 2001
+From: Li xin <lixin.fnst@cn.fujitsu.com>
+Date: Fri, 21 Aug 2015 12:39:12 +0900
+Subject: [PATCH] the snmp_pdu_parse() function could leave incompletely parsed
+ varBind variables in the list of variables in case the parsing of the SNMP
+ PDU failed. If later processing tries to operate on the stale and
+ incompletely processed varBind (e.g. when printing the variables), this can
+ lead to e.g. crashes or, possibly, execution of arbitrary code
+
+Upstream-Status: Backport [net-snmp]
+
+Written-by: Robert Story
+---
+ snmplib/snmp_api.c | 53 ++++++++++++++++++++++++++++-------------------------
+ 1 file changed, 28 insertions(+), 25 deletions(-)
+
+diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
+index 191debf..15a2d39 100644
+--- a/snmplib/snmp_api.c
++++ b/snmplib/snmp_api.c
+@@ -4350,10 +4350,9 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
+ u_char type;
+ u_char msg_type;
+ u_char *var_val;
+- int badtype = 0;
+ size_t len;
+ size_t four;
+- netsnmp_variable_list *vp = NULL;
++ netsnmp_variable_list *vp = NULL, *vplast = NULL;
+ oid objid[MAX_OID_LEN];
+ u_char *p;
+
+@@ -4493,31 +4492,17 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
+ (ASN_SEQUENCE | ASN_CONSTRUCTOR),
+ "varbinds");
+ if (data == NULL)
+- return -1;
++ goto fail;
+
+ /*
+ * get each varBind sequence
+ */
+ while ((int) *length > 0) {
+- netsnmp_variable_list *vptemp;
+- vptemp = (netsnmp_variable_list *) malloc(sizeof(*vptemp));
+- if (NULL == vptemp) {
+- return -1;
+- }
+- if (NULL == vp) {
+- pdu->variables = vptemp;
+- } else {
+- vp->next_variable = vptemp;
+- }
+- vp = vptemp;
++ vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
++ if (NULL == vp)
++ goto fail;
+
+- vp->next_variable = NULL;
+- vp->val.string = NULL;
+ vp->name_length = MAX_OID_LEN;
+- vp->name = NULL;
+- vp->index = 0;
+- vp->data = NULL;
+- vp->dataFreeHook = NULL;
+ DEBUGDUMPSECTION("recv", "VarBind");
+ data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
+ &vp->val_len, &var_val, length);
+@@ -4604,7 +4589,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
+ vp->val.string = (u_char *) malloc(vp->val_len);
+ }
+ if (vp->val.string == NULL) {
+- return -1;
++ goto fail;
+ }
+ p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
+ &vp->val_len);
+@@ -4619,7 +4604,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
+ vp->val_len *= sizeof(oid);
+ vp->val.objid = (oid *) malloc(vp->val_len);
+ if (vp->val.objid == NULL) {
+- return -1;
++ goto fail;
+ }
+ memmove(vp->val.objid, objid, vp->val_len);
+ break;
+@@ -4631,7 +4616,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
+ case ASN_BIT_STR:
+ vp->val.bitstring = (u_char *) malloc(vp->val_len);
+ if (vp->val.bitstring == NULL) {
+- return -1;
++ goto fail;
+ }
+ p = asn_parse_bitstring(var_val, &len, &vp->type,
+ vp->val.bitstring, &vp->val_len);
+@@ -4640,12 +4625,30 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
+ break;
+ default:
+ snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
+- badtype = -1;
++ goto fail;
+ break;
+ }
+ DEBUGINDENTADD(-4);
++
++ if (NULL == vplast) {
++ pdu->variables = vp;
++ } else {
++ vplast->next_variable = vp;
++ }
++ vplast = vp;
++ vp = NULL;
++
+ }
+- return badtype;
++ return 0;
++
++ fail:
++ DEBUGMSGTL(("recv", "error while parsing VarBindList\n"));
++ /** if we were parsing a var, remove it from the pdu and free it */
++ if (vp)
++ snmp_free_var(vp);
++
++ return -1;
++
+ }
+
+ /*
+--
+1.8.4.2
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/fix-libtool-finish.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/fix-libtool-finish.patch
new file mode 100644
index 000000000..d29be3395
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/fix-libtool-finish.patch
@@ -0,0 +1,25 @@
+LIB_LDCONFIG_CMD failed since it is using a host dir $(libdir)
+which is /usr/lib64 does not exist on host when compile 64bit
+image.
+
+In fact, configuring dynamic linker run-time bindings is meaningless
+at this step, If it is needed, Poky would write ldconfig scripts to
+rpm-postinst for each recipe while do_package, in package.bbclass.
+
+Upstream-Status: Inappropriate [cross compile specific]
+
+Signed-off-by: Roy.Li <rongqing.li@windriver.com>
+---
+Index: net-snmp-5.7.3/Makefile.top
+===================================================================
+--- net-snmp-5.7.3.orig/Makefile.top
++++ net-snmp-5.7.3/Makefile.top
+@@ -87,7 +87,7 @@ LIBREVISION = 3
+ LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
+ LIB_EXTENSION = la
+ LIB_VERSION =
+-LIB_LDCONFIG_CMD = $(LIBTOOL) --mode=finish $(INSTALL_PREFIX)$(libdir)
++LIB_LDCONFIG_CMD = echo "do not ldconfig\n"
+ LINK = $(LIBTOOL) --mode=link $(LINKCC)
+ # RANLIB = @RANLIB@
+ RANLIB = :
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.7.2-fix-engineBoots-value-on-SIGHUP.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.7.2-fix-engineBoots-value-on-SIGHUP.patch
new file mode 100644
index 000000000..fbd274bba
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.7.2-fix-engineBoots-value-on-SIGHUP.patch
@@ -0,0 +1,42 @@
+From e47c60dc7f649959f63e56bc62355de4bdfd73f4 Mon Sep 17 00:00:00 2001
+From: Marian Florea <marian.florea@windriver.com>
+Date: Thu, 20 Jul 2017 16:55:24 +0800
+Subject: [PATCH] net snmp: fix engineBoots value on SIGHUP
+
+Upstream-Status: Pending
+
+Signed-off-by: Marian Florea <marian.florea@windriver.com>
+Signed-off-by: Li Zhou <li.zhou@windriver.com>
+---
+ agent/snmpd.c | 1 +
+ snmplib/snmpv3.c | 4 ++--
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+Index: net-snmp-5.7.3/agent/snmpd.c
+===================================================================
+--- net-snmp-5.7.3.orig/agent/snmpd.c
++++ net-snmp-5.7.3/agent/snmpd.c
+@@ -1253,6 +1253,7 @@ receive(void)
+ snmp_log(LOG_INFO, "NET-SNMP version %s restarted\n",
+ netsnmp_get_version());
+ update_config();
++ snmp_store(app_name);
+ send_easy_trap(SNMP_TRAP_ENTERPRISESPECIFIC, 3);
+ #if HAVE_SIGHOLD
+ sigrelse(SIGHUP);
+Index: net-snmp-5.7.3/snmplib/snmpv3.c
+===================================================================
+--- net-snmp-5.7.3.orig/snmplib/snmpv3.c
++++ net-snmp-5.7.3/snmplib/snmpv3.c
+@@ -984,9 +984,9 @@ init_snmpv3_post_config(int majorid, int
+ /*
+ * if our engineID has changed at all, the boots record must be set to 1
+ */
+- if (engineIDLen != oldEngineIDLength ||
++ if (oldEngineIDLength != (size_t)0 && (engineIDLen != oldEngineIDLength ||
+ oldEngineID == NULL || c_engineID == NULL ||
+- memcmp(oldEngineID, c_engineID, engineIDLen) != 0) {
++ memcmp(oldEngineID, c_engineID, engineIDLen) != 0)) {
+ engineBoots = 1;
+ }
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-add-knob-whether-nlist.h-are-checked.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-add-knob-whether-nlist.h-are-checked.patch
new file mode 100644
index 000000000..74b0c12e0
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-add-knob-whether-nlist.h-are-checked.patch
@@ -0,0 +1,35 @@
+net-snmp: add knob whether nlist.h are checked
+
+Previously, it still was checked when there was no nlish.h in sysroots directory.
+Add knob to decide whether nlist.h are checked or not.
+
+Upstream-status: Pending
+
+Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
+---
+ configure.d/config_os_headers | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/configure.d/config_os_headers b/configure.d/config_os_headers
+index d903f58..a05d30e 100644
+--- a/configure.d/config_os_headers
++++ b/configure.d/config_os_headers
+@@ -31,6 +31,7 @@ AC_CHECK_HEADERS([getopt.h pthread.h regex.h ] dnl
+ [sys/un.h ])
+
+ # Library and Agent:
++if test "x$with_elf" != "xno"; then
+ AC_CHECK_HEADERS([nlist.h],,,[
+ AC_INCLUDES_DEFAULT
+ [
+@@ -38,6 +39,7 @@ AC_INCLUDES_DEFAULT
+ #define LIBBSD_DISABLE_DEPRECATED 1
+ #endif
+ ]])
++fi
+
+ # Library:
+ AC_CHECK_HEADERS([fcntl.h io.h kstat.h ] dnl
+--
+1.7.9.5
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-agentx-crash.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-agentx-crash.patch
new file mode 100644
index 000000000..5eed893e1
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-agentx-crash.patch
@@ -0,0 +1,75 @@
+Description: fix snmpd crash via AgentX connection
+
+ taken from Fedora, net-snmp-5.7-agentx-crash.patch
+
+bz729738 - net-snmp dumps core in netsnmp_oid_find_prefix
+bz1038011 - net-snmp: snmpd crashes/hangs when AgentX subagent times-out
+
+commit f9304c83f76202db0e684269ca1af32e43cd9db4
+Author: Jan Safranek <jsafranek@users.sourceforge.net>
+Date: Tue Feb 7 14:53:44 2012 +0100
+
+ CHANGES: PATCH 1633670: fixed snmpd crashing when an AgentX subagent
+ disconnect in the middle of processing of a request.
+
+ I fixed also the memory leak reported in the tracker comments.
+
+Upstream-Status: Backport
+
+Signed-off-by: Zhu Yanjun <yanjun.zhu@windriver.com>
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+
+---
+ agent/mibgroup/agentx/master.c | 5 +++++
+ agent/mibgroup/agentx/master_admin.c | 9 +++++++--
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/agent/mibgroup/agentx/master.c b/agent/mibgroup/agentx/master.c
+index c42a42a..baeebaf 100644
+--- a/agent/mibgroup/agentx/master.c
++++ b/agent/mibgroup/agentx/master.c
+@@ -219,6 +219,9 @@ agentx_got_response(int operation,
+ if (!cache) {
+ DEBUGMSGTL(("agentx/master", "response too late on session %8p\n",
+ session));
++ /* response is too late, free the cache */
++ if (magic)
++ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic);
+ return 0;
+ }
+ requests = cache->requests;
+@@ -606,6 +609,8 @@ agentx_master_handler(netsnmp_mib_handler *handler,
+ result = snmp_async_send(ax_session, pdu, agentx_got_response, cb_data);
+ if (result == 0) {
+ snmp_free_pdu(pdu);
++ if (cb_data)
++ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) cb_data);
+ }
+
+ return SNMP_ERR_NOERROR;
+diff --git a/agent/mibgroup/agentx/master_admin.c b/agent/mibgroup/agentx/master_admin.c
+index f16f392..b84b85e 100644
+--- a/agent/mibgroup/agentx/master_admin.c
++++ b/agent/mibgroup/agentx/master_admin.c
+@@ -133,11 +133,16 @@ close_agentx_session(netsnmp_session * session, int sessid)
+ * requests, so that the delegated request will be completed and
+ * further requests can be processed
+ */
+- netsnmp_remove_delegated_requests_for_session(session);
++ while (netsnmp_remove_delegated_requests_for_session(session)) {
++ DEBUGMSGTL(("agentx/master", "Continue removing delegated reqests\n"));
++ }
++
+ if (session->subsession != NULL) {
+ netsnmp_session *subsession = session->subsession;
+ for(; subsession; subsession = subsession->next) {
+- netsnmp_remove_delegated_requests_for_session(subsession);
++ while (netsnmp_remove_delegated_requests_for_session(subsession)) {
++ DEBUGMSGTL(("agentx/master", "Continue removing delegated subsession reqests\n"));
++ }
+ }
+ }
+
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-fix-for-disable-des.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-fix-for-disable-des.patch
new file mode 100644
index 000000000..25eb9c96f
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-fix-for-disable-des.patch
@@ -0,0 +1,32 @@
+From 270e952f58a7e5ddeabe5a15e3ddaaadf40017d0 Mon Sep 17 00:00:00 2001
+From: Jackie Huang <jackie.huang@windriver.com>
+Date: Thu, 22 Jun 2017 10:25:08 +0800
+Subject: [PATCH] net-snmp: fix for --disable-des
+
+Include des.h only if it's found in openssl so that
+the --disable-des works correctly.
+
+Upstream-Status: Submitted [net-snmp-coders@lists.sourceforge.net]
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+---
+ snmplib/scapi.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/snmplib/scapi.c b/snmplib/scapi.c
+index 16ac829..271684b 100644
+--- a/snmplib/scapi.c
++++ b/snmplib/scapi.c
+@@ -79,7 +79,9 @@ netsnmp_feature_child_of(usm_scapi, usm_support)
+ #include <openssl/hmac.h>
+ #include <openssl/evp.h>
+ #include <openssl/rand.h>
++#ifdef HAVE_OPENSSL_DES_H
+ #include <openssl/des.h>
++#endif
+ #ifdef HAVE_AES
+ #include <openssl/aes.h>
+ #endif
+--
+2.11.0
+
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-testing-add-the-output-format-for-ptest.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-testing-add-the-output-format-for-ptest.patch
new file mode 100644
index 000000000..8f8336a49
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-testing-add-the-output-format-for-ptest.patch
@@ -0,0 +1,34 @@
+From 4bb4024b395f19d36ab3569e2773ea80d8cc5261 Mon Sep 17 00:00:00 2001
+From: Jackie Huang <jackie.huang@windriver.com>
+Date: Wed, 14 Jan 2015 15:10:06 +0800
+Subject: [PATCH] testing: add the output format for ptest
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+---
+ testing/RUNTESTS | 4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+Index: net-snmp-5.7.3/testing/RUNTESTS
+===================================================================
+--- net-snmp-5.7.3.orig/testing/RUNTESTS
++++ net-snmp-5.7.3/testing/RUNTESTS
+@@ -29,13 +29,17 @@ failed_count=0
+ rm -f failed_tests
+ for i in "${srcdir}"/testing/fulltests/default/T*$1*; do
+ echo "RUNNING $i"
++ test_name=`basename $i`
+ ${srcdir}/testing/fulltests/support/simple_run $i
+ if [ $? = 0 ]; then
++ echo "PASS: $test_name"
+ success_count=`expr $success_count + 1`
+ else
++ echo "FAIL: $test_name"
+ failed_count=`expr $failed_count + 1`
+ echo "$i" >> failed_tests
+ fi
++ echo
+ done
+
+ if [ -f failed_tests ]; then
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/run-ptest b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/run-ptest
new file mode 100755
index 000000000..2334217bc
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/run-ptest
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd testing
+./RUNTESTS
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service
new file mode 100644
index 000000000..447683f85
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Simple Network Management Protocol (SNMP) Daemon.
+After=syslog.target network.target
+
+[Service]
+Type=notify
+Environment=OPTIONS="-Ls0-6d"
+EnvironmentFile=-/etc/default/snmpd
+ExecStart=/usr/sbin/snmpd $OPTIONS -a -f
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service
new file mode 100644
index 000000000..951f9f270
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Simple Network Management Protocol (SNMP) Trap Daemon.
+After=syslog.target network.target
+
+[Service]
+Type=notify
+Environment=OPTIONS="-Lsd"
+EnvironmentFile=-/etc/default/snmptrapd
+ExecStart=/usr/sbin/snmptrapd $OPTIONS -f
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch
new file mode 100644
index 000000000..c6af8c0f3
--- /dev/null
+++ b/meta-openembedded/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch
@@ -0,0 +1,1652 @@
+From 0cad0c6c36af2a2d589563804c9ed2b37b7085fb Mon Sep 17 00:00:00 2001
+From: Li xin <lixin.fnst@cn.fujitsu.com>
+Date: Fri, 21 Aug 2015 14:37:02 +0900
+Subject: [PATCH] ystemd support backported from the master branch as of
+ 23/04/2012 (post 5.7.1, pre 5.8).
+
+The following commits have been cherry-picked:
+
+19499c3c90bf9d7b2b9e5d08baa26cc6bba28a11
+fef6cddfdb94da1a6b1fb768af62918b80f11fd3
+0641e43c694c485cbbffef0556efc4641bd3ff50
+76530a89f1c8bbd0b63acce63e10d5d4812a1a16 (conflict resolved)
+bf108d7f1354f6276fc43c129963f2c49b9fc242
+3692875172352f72cf3afd0d35f355e83d7e421b
+74412748067c685e1d8ab6ed3bcc3ca9c2774844
+86132e3f1e6ef7b4e0b96d8fa24e37c81b71b0e0
+63557cf8986a33dba1d4429b583a901361052c4f
+
+Upstream-Status: Backport
+
+Signed-off-by: Thomas Fitzsimmons <fitzsim@cisco.com>
+---
+ README.systemd | 41 +++
+ agent/snmpd.c | 33 +-
+ apps/snmptrapd.c | 32 +-
+ configure.d/config_modules_lib | 8 +
+ configure.d/config_project_with_enable | 9 +
+ dist/snmpd.servic | 18 +
+ dist/snmpd.socket | 17 +
+ dist/snmptrapd.service | 16 +
+ dist/snmptrapd.socket | 14 +
+ include/net-snmp/library/sd-daemon.h | 290 ++++++++++++++++
+ snmplib/sd-daemon.c | 532 +++++++++++++++++++++++++++++
+ snmplib/transports/snmpTCPDomain.c | 43 ++-
+ snmplib/transports/snmpTCPIPv6Domain.c | 46 ++-
+ snmplib/transports/snmpUDPIPv4BaseDomain.c | 33 +-
+ snmplib/transports/snmpUDPIPv6Domain.c | 34 +-
+ snmplib/transports/snmpUnixDomain.c | 66 ++--
+ win32/libsnmp/Makefile.in | 6 +
+ win32/net-snmp/net-snmp-config.h | 2 +
+ win32/net-snmp/net-snmp-config.h.in | 2 +
+ 19 files changed, 1176 insertions(+), 66 deletions(-)
+ create mode 100644 README.systemd
+ create mode 100644 dist/snmpd.servic
+ create mode 100644 dist/snmpd.socket
+ create mode 100644 dist/snmptrapd.service
+ create mode 100644 dist/snmptrapd.socket
+ create mode 100644 include/net-snmp/library/sd-daemon.h
+ create mode 100644 snmplib/sd-daemon.c
+
+diff --git a/README.systemd b/README.systemd
+new file mode 100644
+index 0000000..dba15d1
+--- /dev/null
++++ b/README.systemd
+@@ -0,0 +1,41 @@
++README.systemd
++--------------
++Net-SNMP provides two daemons, which support systemd system manager.
++See http://www.freedesktop.org/wiki/Software/systemd to learn how
++systemd works. Both socket activation and notification is supported by these
++daemons.
++
++To enable systemd support, the sources must be compiled with
++--with-systemd configure option.
++
++snmpd - The SNMP agent
++----------------------
++Socket activation od snmpd daemon is implemented, but it's discouraged.
++The reason is simple - snmpd not only listens and processes SNMP requests
++from network, but also gathers system statistics counters, sends traps and
++communicates with subagents. It even opens few netlink sockets.
++
++In other words, snmpd should run from system start to properly work.
++This can be done in two ways:
++1) either as snmpd service unit with 'Type=notification' and without a socket
++ unit
++2) or as snmpd service unit with 'Type=simple', appropriate socket socket unit
++ and the snmpd service enabled. This way systemd creates the snmpd listening
++ socket early during boot and passes the sockets to snmpd slightly later
++ (but still during machine boot). This way systemd can paralelize start of
++ services, which depend on snmpd. Admins must adjust the socket file manually,
++ depending if the snmpd support AgentX, IPv6, SMUX etc.
++
++snmpd should be started with '-f' command line parameter to disable forking -
++systemd does that for us automatically.
++
++
++snmptrapd - The trap processing daemon
++--------------------------------------
++snmptrapd supports full socket activation and also notification (if needed).
++Both 'Type=simple' (with appropriate socket unit) and 'Type=notify' services
++will work. Again, '-f' parameter should be provided on snmptrapd command line.
++
++If integration with SNMP agent using AgentX protocol is enabled, snmptrapd should
++start during boot and not after first SNMP trap arrives. Same rules as for snmpd
++applies then.
+diff --git a/agent/snmpd.c b/agent/snmpd.c
+index cfc7bce..116ee5c 100644
+--- a/agent/snmpd.c
++++ b/agent/snmpd.c
+@@ -164,6 +164,10 @@ typedef long fd_mask;
+
+ #endif
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ netsnmp_feature_want(logging_file)
+ netsnmp_feature_want(logging_stdio)
+ netsnmp_feature_want(logging_syslog)
+@@ -443,19 +447,29 @@ main(int argc, char *argv[])
+ int agent_mode = -1;
+ char *pid_file = NULL;
+ char option_compatability[] = "-Le";
++#ifndef WIN32
++ int prepared_sockets = 0;
++#endif
+ #if HAVE_GETPID
+ int fd;
+ FILE *PID;
+ #endif
+
+ #ifndef WIN32
++#ifndef NETSNMP_NO_SYSTEMD
++ /* check if systemd has sockets for us and don't close them */
++ prepared_sockets = netsnmp_sd_listen_fds(0);
++#endif /* NETSNMP_NO_SYSTEMD */
++
+ /*
+ * close all non-standard file descriptors we may have
+ * inherited from the shell.
+ */
+- for (i = getdtablesize() - 1; i > 2; --i) {
+- (void) close(i);
+- }
++ if (!prepared_sockets) {
++ for (i = getdtablesize() - 1; i > 2; --i) {
++ (void) close(i);
++ }
++}
+ #endif /* #WIN32 */
+
+ /*
+@@ -1107,6 +1121,19 @@ main(int argc, char *argv[])
+ netsnmp_addrcache_initialise();
+
+ /*
++ * Let systemd know we're up.
++ */
++#ifndef NETSNMP_NO_SYSTEMD
++ netsnmp_sd_notify(1, "READY=1\n");
++ if (prepared_sockets)
++ /*
++ * Clear the environment variable, we already processed all the sockets
++ * by now.
++ */
++ netsnmp_sd_listen_fds(1);
++#endif
++
++ /*
+ * Forever monitor the dest_port for incoming PDUs.
+ */
+ DEBUGMSGTL(("snmpd/main", "We're up. Starting to process data.\n"));
+diff --git a/apps/snmptrapd.c b/apps/snmptrapd.c
+index bce0d47..c6a74ec 100644
+--- a/apps/snmptrapd.c
++++ b/apps/snmptrapd.c
+@@ -125,6 +125,10 @@ SOFTWARE.
+
+ #include <net-snmp/net-snmp-features.h>
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ #ifndef BSD4_3
+ #define BSD4_2
+ #endif
+@@ -657,16 +661,25 @@ main(int argc, char *argv[])
+ int agentx_subagent = 1;
+ #endif
+ netsnmp_trapd_handler *traph;
++#ifndef WIN32
++ int prepared_sockets = 0;
++#endif
+
+
+ #ifndef WIN32
++#ifndef NETSNMP_NO_SYSTEMD
++ /* check if systemd has sockets for us and don't close them */
++ prepared_sockets = netsnmp_sd_listen_fds(0);
++#endif
+ /*
+ * close all non-standard file descriptors we may have
+ * inherited from the shell.
+ */
+- for (i = getdtablesize() - 1; i > 2; --i) {
+- (void) close(i);
+- }
++ if (!prepared_sockets) {
++ for (i = getdtablesize() - 1; i > 2; --i) {
++ (void) close(i);
++ }
++}
+ #endif /* #WIN32 */
+
+ #ifdef SIGTERM
+@@ -1318,6 +1331,19 @@ main(int argc, char *argv[])
+ #endif
+ #endif
+
++ /*
++ * Let systemd know we're up.
++ */
++#ifndef NETSNMP_NO_SYSTEMD
++ netsnmp_sd_notify(1, "READY=1\n");
++ if (prepared_sockets)
++ /*
++ * Clear the environment variable, we already processed all the sockets
++ * by now.
++ */
++ netsnmp_sd_listen_fds(1);
++#endif
++
+ #ifdef WIN32SERVICE
+ trapd_status = SNMPTRAPD_RUNNING;
+ #endif
+diff --git a/configure.d/config_modules_lib b/configure.d/config_modules_lib
+index 362ba0a..bb69daa 100644
+--- a/configure.d/config_modules_lib
++++ b/configure.d/config_modules_lib
+@@ -53,6 +53,14 @@ if test "x$PARTIALTARGETOS" = "xmingw32" -o "x$PARTIALTARGETOS" = "xmingw32msvc"
+ other_ftobjs_list="$other_ftobjs_list winpipe.ft"
+ fi
+
++# Linux systemd
++if test "x$with_systemd" == "xyes"; then
++ other_src_list="$other_src_list sd-daemon.c"
++ other_objs_list="$other_objs_list sd-daemon.o"
++ other_lobjs_list="$other_lobjs_list sd-daemon.lo"
++ other_ftobjs_list="$other_ftobjs_list sd-daemon.ft"
++fi
++
+ AC_SUBST(other_src_list)
+ AC_SUBST(other_objs_list)
+ AC_SUBST(other_lobjs_list)
+diff --git a/configure.d/config_project_with_enable b/configure.d/config_project_with_enable
+index 61ba026..d782d12 100644
+--- a/configure.d/config_project_with_enable
++++ b/configure.d/config_project_with_enable
+@@ -690,6 +690,15 @@ if test "x$with_dummy_values" != "xyes"; then
+ data for])
+ fi
+
++NETSNMP_ARG_WITH(systemd,
++[ --with-systemd Provide systemd support. See README.systemd
++ for details.])
++# Define unless specifically suppressed (i.e., option defaults to false).
++if test "x$with_systemd" != "xyes"; then
++ AC_DEFINE(NETSNMP_NO_SYSTEMD, 1,
++ [If you don't want to integrate with systemd.])
++fi
++
+ NETSNMP_ARG_ENABLE(set-support,
+ [ --disable-set-support Do not allow SNMP set requests.])
+ if test "x$enable_set_support" = "xno"; then
+diff --git a/dist/snmpd.servic b/dist/snmpd.servic
+new file mode 100644
+index 0000000..31391e5
+--- /dev/null
++++ b/dist/snmpd.servic
+@@ -0,0 +1,18 @@
++#
++# SNMP agent service file for systemd
++#
++#
++# The service should be enabled, i.e. snmpd should start during machine boot.
++# Socket activation shall not be used. See README.systemd for details.
++
++[Unit]
++Description=Simple Network Management Protocol (SNMP) daemon.
++After=syslog.target network.target
++
++[Service]
++# Type=notify is also supported. It should be set when snmpd.socket is not used.
++Type=simple
++ExecStart=/usr/sbin/snmpd -f
++
++[Install]
++WantedBy=multi-user.target
+diff --git a/dist/snmpd.socket b/dist/snmpd.socket
+new file mode 100644
+index 0000000..7f3a2d9
+--- /dev/null
++++ b/dist/snmpd.socket
+@@ -0,0 +1,17 @@
++[Unit]
++Description=Socket listening for SNMP and AgentX messages
++
++[Socket]
++ListenDatagram=0.0.0.0:161
++# Uncomment other listening addresses as needed - TCP, UDP6, TCP6.
++# It must match listening addresses/ports defined in snmpd.service
++# or snmpd.conf.
++# ListenStream=0.0.0.0:161
++# ListenDatagram=[::]:161
++# ListenStream=[::]:161
++#
++# Uncomment AgentX socket if snmpd.conf enables AgentX protocol.
++# ListenStream=/var/agentx/master
++
++[Install]
++WantedBy=sockets.target
+diff --git a/dist/snmptrapd.service b/dist/snmptrapd.service
+new file mode 100644
+index 0000000..e88a5b4
+--- /dev/null
++++ b/dist/snmptrapd.service
+@@ -0,0 +1,16 @@
++#
++# SNMP trap-processing service file for systemd
++#
++
++[Unit]
++Description=Simple Network Management Protocol (SNMP) Trap daemon.
++After=syslog.target network.target
++
++[Service]
++# Type=notify is also supported. It should be set when snmptrapd.socket is not
++# used.
++Type=simple
++ExecStart=/usr/sbin/snmptrapd -f
++
++[Install]
++WantedBy=multi-user.target
+diff --git a/dist/snmptrapd.socket b/dist/snmptrapd.socket
+new file mode 100644
+index 0000000..2d24fb8
+--- /dev/null
++++ b/dist/snmptrapd.socket
+@@ -0,0 +1,14 @@
+++[Unit]
+++Description=Socket listening for SNMP trap messages
+++
+++[Socket]
+++ListenDatagram=0.0.0.0:162
+++# Uncomment other listening addresses as needed - TCP, UDP6, TCP6.
+++# It must match listening addresses/ports defined in snmptrapd.service
+++# or snmptrapd.conf.
+++# ListenStream=0.0.0.0:162
+++# ListenDatagram=[::]:162
+++# ListenStream=[::]:162
+++
+++[Install]
+++WantedBy=sockets.target
+diff --git a/include/net-snmp/library/sd-daemon.h b/include/net-snmp/library/sd-daemon.h
+new file mode 100644
+index 0000000..85274c9
+--- /dev/null
++++ b/include/net-snmp/library/sd-daemon.h
+@@ -0,0 +1,290 @@
++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
++
++#ifndef SNMPD_SD_DAEMON_H
++#define SNMPD_SD_DAEMON_H
++
++/***
++ Copyright 2010 Lennart Poettering
++
++ Permission is hereby granted, free of charge, to any person
++ obtaining a copy of this software and associated documentation files
++ (the "Software"), to deal in the Software without restriction,
++ including without limitation the rights to use, copy, modify, merge,
++ publish, distribute, sublicense, and/or sell copies of the Software,
++ and to permit persons to whom the Software is furnished to do so,
++ subject to the following conditions:
++
++ The above copyright notice and this permission notice shall be
++ included in all copies or substantial portions of the Software.
++
++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
++ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
++ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++ SOFTWARE.
++***/
++
++#ifdef HAVE_SYS_TYPES_H
++#include <sys/types.h>
++#endif
++#ifdef HAVE_INTTYPES_H
++#include <inttypes.h>
++#endif
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++/*
++ Reference implementation of a few systemd related interfaces for
++ writing daemons. These interfaces are trivial to implement. To
++ simplify porting we provide this reference implementation.
++ Applications are welcome to reimplement the algorithms described
++ here if they do not want to include these two source files.
++
++ The following functionality is provided:
++
++ - Support for logging with log levels on stderr
++ - File descriptor passing for socket-based activation
++ - Daemon startup and status notification
++ - Detection of systemd boots
++
++ You may compile this with -DDISABLE_SYSTEMD to disable systemd
++ support. This makes all those calls NOPs that are directly related to
++ systemd (i.e. only sd_is_xxx() will stay useful).
++
++ Since this is drop-in code we don't want any of our symbols to be
++ exported in any case. Hence we declare hidden visibility for all of
++ them.
++
++ You may find an up-to-date version of these source files online:
++
++ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h
++ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c
++
++ This should compile on non-Linux systems, too, but with the
++ exception of the sd_is_xxx() calls all functions will become NOPs.
++
++ See sd-daemon(7) for more information.
++*/
++
++#ifndef _sd_printf_attr_
++#if __GNUC__ >= 4
++#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
++#else
++#define _sd_printf_attr_(a,b)
++#endif
++#endif
++
++/*
++ Log levels for usage on stderr:
++
++ fprintf(stderr, SD_NOTICE "Hello World!\n");
++
++ This is similar to printk() usage in the kernel.
++*/
++#define SD_EMERG "<0>" /* system is unusable */
++#define SD_ALERT "<1>" /* action must be taken immediately */
++#define SD_CRIT "<2>" /* critical conditions */
++#define SD_ERR "<3>" /* error conditions */
++#define SD_WARNING "<4>" /* warning conditions */
++#define SD_NOTICE "<5>" /* normal but significant condition */
++#define SD_INFO "<6>" /* informational */
++#define SD_DEBUG "<7>" /* debug-level messages */
++
++/* The first passed file descriptor is fd 3 */
++#define SD_LISTEN_FDS_START 3
++
++/*
++ Returns how many file descriptors have been passed, or a negative
++ errno code on failure. Optionally, removes the $LISTEN_FDS and
++ $LISTEN_PID file descriptors from the environment (recommended, but
++ problematic in threaded environments). If r is the return value of
++ this function you'll find the file descriptors passed as fds
++ SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative
++ errno style error code on failure. This function call ensures that
++ the FD_CLOEXEC flag is set for the passed file descriptors, to make
++ sure they are not passed on to child processes. If FD_CLOEXEC shall
++ not be set, the caller needs to unset it after this call for all file
++ descriptors that are used.
++
++ See sd_listen_fds(3) for more information.
++*/
++int netsnmp_sd_listen_fds(int unset_environment);
++
++/*
++ Helper call for identifying a passed file descriptor. Returns 1 if
++ the file descriptor is a FIFO in the file system stored under the
++ specified path, 0 otherwise. If path is NULL a path name check will
++ not be done and the call only verifies if the file descriptor
++ refers to a FIFO. Returns a negative errno style error code on
++ failure.
++
++ See sd_is_fifo(3) for more information.
++*/
++int netsnmp_sd_is_fifo(int fd, const char *path);
++
++/*
++ Helper call for identifying a passed file descriptor. Returns 1 if
++ the file descriptor is a special character device on the file
++ system stored under the specified path, 0 otherwise.
++ If path is NULL a path name check will not be done and the call
++ only verifies if the file descriptor refers to a special character.
++ Returns a negative errno style error code on failure.
++
++ See sd_is_special(3) for more information.
++*/
++int netsnmp_sd_is_special(int fd, const char *path);
++
++/*
++ Helper call for identifying a passed file descriptor. Returns 1 if
++ the file descriptor is a socket of the specified family (AF_INET,
++ ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If
++ family is 0 a socket family check will not be done. If type is 0 a
++ socket type check will not be done and the call only verifies if
++ the file descriptor refers to a socket. If listening is > 0 it is
++ verified that the socket is in listening mode. (i.e. listen() has
++ been called) If listening is == 0 it is verified that the socket is
++ not in listening mode. If listening is < 0 no listening mode check
++ is done. Returns a negative errno style error code on failure.
++
++ See sd_is_socket(3) for more information.
++*/
++int netsnmp_sd_is_socket(int fd, int family, int type, int listening);
++
++/*
++ Helper call for identifying a passed file descriptor. Returns 1 if
++ the file descriptor is an Internet socket, of the specified family
++ (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM,
++ SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version
++ check is not done. If type is 0 a socket type check will not be
++ done. If port is 0 a socket port check will not be done. The
++ listening flag is used the same way as in sd_is_socket(). Returns a
++ negative errno style error code on failure.
++
++ See sd_is_socket_inet(3) for more information.
++*/
++int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port);
++
++/*
++ Helper call for identifying a passed file descriptor. Returns 1 if
++ the file descriptor is an AF_UNIX socket of the specified type
++ (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0
++ a socket type check will not be done. If path is NULL a socket path
++ check will not be done. For normal AF_UNIX sockets set length to
++ 0. For abstract namespace sockets set length to the length of the
++ socket name (including the initial 0 byte), and pass the full
++ socket path in path (including the initial 0 byte). The listening
++ flag is used the same way as in sd_is_socket(). Returns a negative
++ errno style error code on failure.
++
++ See sd_is_socket_unix(3) for more information.
++*/
++int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length);
++
++/*
++ Informs systemd about changed daemon state. This takes a number of
++ newline separated environment-style variable assignments in a
++ string. The following variables are known:
++
++ READY=1 Tells systemd that daemon startup is finished (only
++ relevant for services of Type=notify). The passed
++ argument is a boolean "1" or "0". Since there is
++ little value in signaling non-readiness the only
++ value daemons should send is "READY=1".
++
++ STATUS=... Passes a single-line status string back to systemd
++ that describes the daemon state. This is free-from
++ and can be used for various purposes: general state
++ feedback, fsck-like programs could pass completion
++ percentages and failing programs could pass a human
++ readable error message. Example: "STATUS=Completed
++ 66% of file system check..."
++
++ ERRNO=... If a daemon fails, the errno-style error code,
++ formatted as string. Example: "ERRNO=2" for ENOENT.
++
++ BUSERROR=... If a daemon fails, the D-Bus error-style error
++ code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut"
++
++ MAINPID=... The main pid of a daemon, in case systemd did not
++ fork off the process itself. Example: "MAINPID=4711"
++
++ Daemons can choose to send additional variables. However, it is
++ recommended to prefix variable names not listed above with X_.
++
++ Returns a negative errno-style error code on failure. Returns > 0
++ if systemd could be notified, 0 if it couldn't possibly because
++ systemd is not running.
++
++ Example: When a daemon finished starting up, it could issue this
++ call to notify systemd about it:
++
++ sd_notify(0, "READY=1");
++
++ See sd_notifyf() for more complete examples.
++
++ See sd_notify(3) for more information.
++*/
++int netsnmp_sd_notify(int unset_environment, const char *state);
++
++/*
++ Similar to sd_notify() but takes a format string.
++
++ Example 1: A daemon could send the following after initialization:
++
++ sd_notifyf(0, "READY=1\n"
++ "STATUS=Processing requests...\n"
++ "MAINPID=%lu",
++ (unsigned long) getpid());
++
++ Example 2: A daemon could send the following shortly before
++ exiting, on failure:
++
++ sd_notifyf(0, "STATUS=Failed to start up: %s\n"
++ "ERRNO=%i",
++ strerror(errno),
++ errno);
++
++ See sd_notifyf(3) for more information.
++*/
++int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3);
++
++/*
++ Returns > 0 if the system was booted with systemd. Returns < 0 on
++ error. Returns 0 if the system was not booted with systemd. Note
++ that all of the functions above handle non-systemd boots just
++ fine. You should NOT protect them with a call to this function. Also
++ note that this function checks whether the system, not the user
++ session is controlled by systemd. However the functions above work
++ for both user and system services.
++
++ See sd_booted(3) for more information.
++*/
++int netsnmp_sd_booted(void);
++
++/**
++ * Find an socket with given parameters. See man sd_is_socket_inet for
++ * description of the arguments.
++ *
++ * Returns the file descriptor if it is found, 0 otherwise.
++ */
++int netsnmp_sd_find_inet_socket(int family, int type, int listening, int port);
++
++/**
++ * Find an unix socket with given parameters. See man sd_is_socket_unix for
++ * description of the arguments.
++ *
++ * Returns the file descriptor if it is found, 0 otherwise.
++ */
++int
++netsnmp_sd_find_unix_socket(int type, int listening, const char *path);
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif /* SNMPD_SD_DAEMON_H */
+diff --git a/snmplib/sd-daemon.c b/snmplib/sd-daemon.c
+new file mode 100644
+index 0000000..42dba29
+--- /dev/null
++++ b/snmplib/sd-daemon.c
+@@ -0,0 +1,532 @@
++/*
++ * Systemd integration parts.
++ *
++ * Most of this file is directly copied from systemd sources.
++ * Changes:
++ * - all functions were renamed to have netsnmp_ prefix
++ * - includes were changed to match Net-SNMP style.
++ * - removed gcc export macros
++ * - removed POSIX message queues
++ */
++
++#include <net-snmp/net-snmp-config.h>
++#include <net-snmp/net-snmp-features.h>
++#include <net-snmp/types.h>
++#include <net-snmp/library/snmp_debug.h>
++
++#ifndef NETSNMP_NO_SYSTEMD
++
++/***
++ Copyright 2010 Lennart Poettering
++
++ Permission is hereby granted, free of charge, to any person
++ obtaining a copy of this software and associated documentation files
++ (the "Software"), to deal in the Software without restriction,
++ including without limitation the rights to use, copy, modify, merge,
++ publish, distribute, sublicense, and/or sell copies of the Software,
++ and to permit persons to whom the Software is furnished to do so,
++ subject to the following conditions:
++
++ The above copyright notice and this permission notice shall be
++ included in all copies or substantial portions of the Software.
++
++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
++ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
++ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++ SOFTWARE.
++***/
++
++#ifndef _GNU_SOURCE
++#define _GNU_SOURCE
++#endif
++
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/socket.h>
++#include <sys/un.h>
++#include <sys/fcntl.h>
++#include <netinet/in.h>
++#include <stdlib.h>
++#include <errno.h>
++#include <unistd.h>
++#include <string.h>
++#include <stdarg.h>
++#include <stdio.h>
++#include <stddef.h>
++#include <limits.h>
++
++#include <net-snmp/library/sd-daemon.h>
++
++int netsnmp_sd_listen_fds(int unset_environment) {
++
++ int r, fd;
++ const char *e;
++ char *p = NULL;
++ unsigned long l;
++
++ if (!(e = getenv("LISTEN_PID"))) {
++ r = 0;
++ goto finish;
++ }
++
++ errno = 0;
++ l = strtoul(e, &p, 10);
++
++ if (errno != 0) {
++ r = -errno;
++ goto finish;
++ }
++
++ if (!p || *p || l <= 0) {
++ r = -EINVAL;
++ goto finish;
++ }
++
++ /* Is this for us? */
++ if (getpid() != (pid_t) l) {
++ r = 0;
++ goto finish;
++ }
++
++ if (!(e = getenv("LISTEN_FDS"))) {
++ r = 0;
++ goto finish;
++ }
++
++ errno = 0;
++ l = strtoul(e, &p, 10);
++
++ if (errno != 0) {
++ r = -errno;
++ goto finish;
++ }
++
++ if (!p || *p) {
++ r = -EINVAL;
++ goto finish;
++ }
++
++ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
++ int flags;
++
++ if ((flags = fcntl(fd, F_GETFD)) < 0) {
++ r = -errno;
++ goto finish;
++ }
++
++ if (flags & FD_CLOEXEC)
++ continue;
++
++ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
++ r = -errno;
++ goto finish;
++ }
++ }
++
++ r = (int) l;
++
++finish:
++ if (unset_environment) {
++ unsetenv("LISTEN_PID");
++ unsetenv("LISTEN_FDS");
++ }
++
++ return r;
++}
++
++int netsnmp_sd_is_fifo(int fd, const char *path) {
++ struct stat st_fd;
++
++ if (fd < 0)
++ return -EINVAL;
++
++ memset(&st_fd, 0, sizeof(st_fd));
++ if (fstat(fd, &st_fd) < 0)
++ return -errno;
++
++ if (!S_ISFIFO(st_fd.st_mode))
++ return 0;
++
++ if (path) {
++ struct stat st_path;
++
++ memset(&st_path, 0, sizeof(st_path));
++ if (stat(path, &st_path) < 0) {
++
++ if (errno == ENOENT || errno == ENOTDIR)
++ return 0;
++
++ return -errno;
++ }
++
++ return
++ st_path.st_dev == st_fd.st_dev &&
++ st_path.st_ino == st_fd.st_ino;
++ }
++
++ return 1;
++}
++
++int netsnmp_sd_is_special(int fd, const char *path) {
++ struct stat st_fd;
++
++ if (fd < 0)
++ return -EINVAL;
++
++ if (fstat(fd, &st_fd) < 0)
++ return -errno;
++
++ if (!S_ISREG(st_fd.st_mode) && !S_ISCHR(st_fd.st_mode))
++ return 0;
++
++ if (path) {
++ struct stat st_path;
++
++ if (stat(path, &st_path) < 0) {
++
++ if (errno == ENOENT || errno == ENOTDIR)
++ return 0;
++
++ return -errno;
++ }
++
++ if (S_ISREG(st_fd.st_mode) && S_ISREG(st_path.st_mode))
++ return
++ st_path.st_dev == st_fd.st_dev &&
++ st_path.st_ino == st_fd.st_ino;
++ else if (S_ISCHR(st_fd.st_mode) && S_ISCHR(st_path.st_mode))
++ return st_path.st_rdev == st_fd.st_rdev;
++ else
++ return 0;
++ }
++
++ return 1;
++}
++
++static int sd_is_socket_internal(int fd, int type, int listening) {
++ struct stat st_fd;
++
++ if (fd < 0 || type < 0)
++ return -EINVAL;
++
++ if (fstat(fd, &st_fd) < 0)
++ return -errno;
++
++ if (!S_ISSOCK(st_fd.st_mode))
++ return 0;
++
++ if (type != 0) {
++ int other_type = 0;
++ socklen_t l = sizeof(other_type);
++
++ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0)
++ return -errno;
++
++ if (l != sizeof(other_type))
++ return -EINVAL;
++
++ if (other_type != type)
++ return 0;
++ }
++
++ if (listening >= 0) {
++ int accepting = 0;
++ socklen_t l = sizeof(accepting);
++
++ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0)
++ return -errno;
++
++ if (l != sizeof(accepting))
++ return -EINVAL;
++
++ if (!accepting != !listening)
++ return 0;
++ }
++
++ return 1;
++}
++
++union sockaddr_union {
++ struct sockaddr sa;
++ struct sockaddr_in in4;
++ struct sockaddr_in6 in6;
++ struct sockaddr_un un;
++ struct sockaddr_storage storage;
++};
++
++int netsnmp_sd_is_socket(int fd, int family, int type, int listening) {
++ int r;
++
++ if (family < 0)
++ return -EINVAL;
++
++ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
++ return r;
++
++ if (family > 0) {
++ union sockaddr_union sockaddr;
++ socklen_t l;
++
++ memset(&sockaddr, 0, sizeof(sockaddr));
++ l = sizeof(sockaddr);
++
++ if (getsockname(fd, &sockaddr.sa, &l) < 0)
++ return -errno;
++
++ if (l < sizeof(sa_family_t))
++ return -EINVAL;
++
++ return sockaddr.sa.sa_family == family;
++ }
++
++ return 1;
++}
++
++int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
++ union sockaddr_union sockaddr;
++ socklen_t l;
++ int r;
++
++ if (family != 0 && family != AF_INET && family != AF_INET6)
++ return -EINVAL;
++
++ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
++ return r;
++
++ memset(&sockaddr, 0, sizeof(sockaddr));
++ l = sizeof(sockaddr);
++
++ if (getsockname(fd, &sockaddr.sa, &l) < 0)
++ return -errno;
++
++ if (l < sizeof(sa_family_t))
++ return -EINVAL;
++
++ if (sockaddr.sa.sa_family != AF_INET &&
++ sockaddr.sa.sa_family != AF_INET6)
++ return 0;
++
++ if (family > 0)
++ if (sockaddr.sa.sa_family != family)
++ return 0;
++
++ if (port > 0) {
++ if (sockaddr.sa.sa_family == AF_INET) {
++ if (l < sizeof(struct sockaddr_in))
++ return -EINVAL;
++
++ return htons(port) == sockaddr.in4.sin_port;
++ } else {
++ if (l < sizeof(struct sockaddr_in6))
++ return -EINVAL;
++
++ return htons(port) == sockaddr.in6.sin6_port;
++ }
++ }
++
++ return 1;
++}
++
++int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
++ union sockaddr_union sockaddr;
++ socklen_t l;
++ int r;
++
++ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
++ return r;
++
++ memset(&sockaddr, 0, sizeof(sockaddr));
++ l = sizeof(sockaddr);
++
++ if (getsockname(fd, &sockaddr.sa, &l) < 0)
++ return -errno;
++
++ if (l < sizeof(sa_family_t))
++ return -EINVAL;
++
++ if (sockaddr.sa.sa_family != AF_UNIX)
++ return 0;
++
++ if (path) {
++ if (length <= 0)
++ length = strlen(path);
++
++ if (length <= 0)
++ /* Unnamed socket */
++ return l == offsetof(struct sockaddr_un, sun_path);
++
++ if (path[0])
++ /* Normal path socket */
++ return
++ (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
++ memcmp(path, sockaddr.un.sun_path, length+1) == 0;
++ else
++ /* Abstract namespace socket */
++ return
++ (l == offsetof(struct sockaddr_un, sun_path) + length) &&
++ memcmp(path, sockaddr.un.sun_path, length) == 0;
++ }
++
++ return 1;
++}
++
++int netsnmp_sd_notify(int unset_environment, const char *state) {
++ int fd = -1, r;
++ struct msghdr msghdr;
++ struct iovec iovec;
++ union sockaddr_union sockaddr;
++ const char *e;
++
++ if (!state) {
++ r = -EINVAL;
++ goto finish;
++ }
++
++ if (!(e = getenv("NOTIFY_SOCKET")))
++ return 0;
++
++ /* Must be an abstract socket, or an absolute path */
++ if ((e[0] != '@' && e[0] != '/') || e[1] == 0) {
++ r = -EINVAL;
++ goto finish;
++ }
++
++ if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
++ r = -errno;
++ goto finish;
++ }
++
++ memset(&sockaddr, 0, sizeof(sockaddr));
++ sockaddr.sa.sa_family = AF_UNIX;
++ strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
++
++ if (sockaddr.un.sun_path[0] == '@')
++ sockaddr.un.sun_path[0] = 0;
++
++ memset(&iovec, 0, sizeof(iovec));
++ iovec.iov_base = (char *)state;
++ iovec.iov_len = strlen(state);
++
++ memset(&msghdr, 0, sizeof(msghdr));
++ msghdr.msg_name = &sockaddr;
++ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e);
++
++ if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
++ msghdr.msg_namelen = sizeof(struct sockaddr_un);
++
++ msghdr.msg_iov = &iovec;
++ msghdr.msg_iovlen = 1;
++
++ if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) {
++ r = -errno;
++ goto finish;
++ }
++
++ r = 1;
++
++finish:
++ if (unset_environment)
++ unsetenv("NOTIFY_SOCKET");
++
++ if (fd >= 0)
++ close(fd);
++
++ return r;
++}
++
++int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) {
++ va_list ap;
++ char *p = NULL;
++ int r;
++
++ va_start(ap, format);
++ r = vasprintf(&p, format, ap);
++ va_end(ap);
++
++ if (r < 0 || !p)
++ return -ENOMEM;
++
++ r = netsnmp_sd_notify(unset_environment, p);
++ free(p);
++
++ return r;
++}
++
++int netsnmp_sd_booted(void) {
++ struct stat a, b;
++
++ /* We simply test whether the systemd cgroup hierarchy is
++ * mounted */
++
++ if (lstat("/sys/fs/cgroup", &a) < 0)
++ return 0;
++
++ if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
++ return 0;
++
++ return a.st_dev != b.st_dev;
++}
++
++/* End of original sd-daemon.c from systemd sources */
++
++int
++netsnmp_sd_find_inet_socket(int family, int type, int listening, int port)
++{
++ int count, fd;
++
++ count = netsnmp_sd_listen_fds(0);
++ if (count <= 0) {
++ DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\n"));
++ return 0;
++ }
++ DEBUGMSGTL(("systemd:find_inet_socket", "LISTEN_FDS reports %d sockets.\n",
++ count));
++
++ for (fd = 3; fd < 3+count; fd++) {
++ int rc = netsnmp_sd_is_socket_inet(fd, family, type, listening, port);
++ if (rc < 0)
++ DEBUGMSGTL(("systemd:find_inet_socket",
++ "sd_is_socket_inet error: %d\n", rc));
++ if (rc > 0) {
++ DEBUGMSGTL(("systemd:find_inet_socket",
++ "Found the socket in LISTEN_FDS\n"));
++ return fd;
++ }
++ }
++ DEBUGMSGTL(("systemd:find_inet_socket", "Socket not found in LISTEN_FDS\n"));
++ return 0;
++}
++
++int
++netsnmp_sd_find_unix_socket(int type, int listening, const char *path)
++{
++ int count, fd;
++
++ count = netsnmp_sd_listen_fds(0);
++ if (count <= 0) {
++ DEBUGMSGTL(("systemd:find_unix_socket", "No LISTEN_FDS found.\n"));
++ return 0;
++ }
++ DEBUGMSGTL(("systemd:find_unix_socket", "LISTEN_FDS reports %d sockets.\n",
++ count));
++
++ for (fd = 3; fd < 3+count; fd++) {
++ int rc = netsnmp_sd_is_socket_unix(fd, type, listening, path, 0);
++ if (rc < 0)
++ DEBUGMSGTL(("systemd:find_unix_socket",
++ "netsnmp_sd_is_socket_unix error: %d\n", rc));
++ if (rc > 0) {
++ DEBUGMSGTL(("systemd:find_unix_socket",
++ "Found the socket in LISTEN_FDS\n"));
++ return fd;
++ }
++ }
++ DEBUGMSGTL(("systemd:find_unix_socket", "Socket not found in LISTEN_FDS\n"));
++ return 0;
++}
++
++#endif /* ! NETSNMP_NO_SYSTEMD */
+diff --git a/snmplib/transports/snmpTCPDomain.c b/snmplib/transports/snmpTCPDomain.c
+index 7feb028..a41b926 100644
+--- a/snmplib/transports/snmpTCPDomain.c
++++ b/snmplib/transports/snmpTCPDomain.c
+@@ -43,6 +43,10 @@
+ #include <net-snmp/library/snmpTCPBaseDomain.h>
+ #include <net-snmp/library/tools.h>
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ /*
+ * needs to be in sync with the definitions in snmplib/snmpUDPDomain.c
+ * and perl/agent/agent.xs
+@@ -149,6 +153,7 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
+ netsnmp_transport *t = NULL;
+ netsnmp_udp_addr_pair *addr_pair = NULL;
+ int rc = 0;
++ int socket_initialized = 0;
+
+ #ifdef NETSNMP_NO_LISTEN_SUPPORT
+ if (local)
+@@ -178,7 +183,19 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
+ t->domain_length =
+ sizeof(netsnmp_snmpTCPDomain) / sizeof(netsnmp_snmpTCPDomain[0]);
+
+- t->sock = socket(PF_INET, SOCK_STREAM, 0);
++#ifndef NETSNMP_NO_SYSTEMD
++ /*
++ * Maybe the socket was already provided by systemd...
++ */
++ if (local) {
++ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_STREAM, 1,
++ ntohs(addr->sin_port));
++ if (t->sock)
++ socket_initialized = 1;
++ }
++#endif
++ if (!socket_initialized)
++ t->sock = socket(PF_INET, SOCK_STREAM, 0);
+ if (t->sock < 0) {
+ netsnmp_transport_free(t);
+ return NULL;
+@@ -215,11 +232,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
+ setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt,
+ sizeof(opt));
+
+- rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr));
+- if (rc != 0) {
+- netsnmp_socketbase_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr));
++ if (rc != 0) {
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+
+ /*
+@@ -236,11 +255,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
+ * Now sit here and wait for connections to arrive.
+ */
+
+- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
+- if (rc != 0) {
+- netsnmp_socketbase_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
++ if (rc != 0) {
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+
+ /*
+diff --git a/snmplib/transports/snmpTCPIPv6Domain.c b/snmplib/transports/snmpTCPIPv6Domain.c
+index d2e0a2d..22de6d4 100644
+--- a/snmplib/transports/snmpTCPIPv6Domain.c
++++ b/snmplib/transports/snmpTCPIPv6Domain.c
+@@ -49,6 +49,10 @@
+ #include <net-snmp/library/snmpTCPBaseDomain.h>
+ #include <net-snmp/library/tools.h>
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ #include "inet_ntop.h"
+
+ oid netsnmp_TCPIPv6Domain[] = { TRANSPORT_DOMAIN_TCP_IPV6 };
+@@ -140,6 +144,8 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
+ {
+ netsnmp_transport *t = NULL;
+ int rc = 0;
++ char *str = NULL;
++ int socket_initialized = 0;
+
+ #ifdef NETSNMP_NO_LISTEN_SUPPORT
+ if (local)
+@@ -174,7 +180,19 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
+ t->domain = netsnmp_TCPIPv6Domain;
+ t->domain_length = sizeof(netsnmp_TCPIPv6Domain) / sizeof(oid);
+
+- t->sock = socket(PF_INET6, SOCK_STREAM, 0);
++#ifndef NETSNMP_NO_SYSTEMD
++ /*
++ * Maybe the socket was already provided by systemd...
++ */
++ if (local) {
++ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_STREAM, 1,
++ ntohs(addr->sin6_port));
++ if (t->sock)
++ socket_initialized = 1;
++ }
++#endif
++ if (!socket_initialized)
++ t->sock = socket(PF_INET6, SOCK_STREAM, 0);
+ if (t->sock < 0) {
+ netsnmp_transport_free(t);
+ return NULL;
+@@ -220,12 +238,14 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
+
+ setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt));
+
+- rc = bind(t->sock, (struct sockaddr *) addr,
+- sizeof(struct sockaddr_in6));
+- if (rc != 0) {
+- netsnmp_socketbase_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = bind(t->sock, (struct sockaddr *) addr,
++ sizeof(struct sockaddr_in6));
++ if (rc != 0) {
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+
+ /*
+@@ -242,11 +262,13 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
+ * Now sit here and wait for connections to arrive.
+ */
+
+- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
+- if (rc != 0) {
+- netsnmp_socketbase_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
++ if (rc != 0) {
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+
+ /*
+diff --git a/snmplib/transports/snmpUDPIPv4BaseDomain.c b/snmplib/transports/snmpUDPIPv4BaseDomain.c
+index 8c0fb05..00e5bbc 100644
+--- a/snmplib/transports/snmpUDPIPv4BaseDomain.c
++++ b/snmplib/transports/snmpUDPIPv4BaseDomain.c
+@@ -40,6 +40,10 @@
+
+ #include <net-snmp/library/snmpSocketBaseDomain.h>
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ #if defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR)
+ int netsnmp_udpipv4_recvfrom(int s, void *buf, int len, struct sockaddr *from,
+ socklen_t *fromlen, struct sockaddr *dstip,
+@@ -64,6 +68,7 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
+ char *client_socket = NULL;
+ netsnmp_indexed_addr_pair addr_pair;
+ socklen_t local_addr_len;
++ int socket_initialized = 0;
+
+ #ifdef NETSNMP_NO_LISTEN_SUPPORT
+ if (local)
+@@ -88,7 +93,19 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
+ free(str);
+ }
+
+- t->sock = socket(PF_INET, SOCK_DGRAM, 0);
++#ifndef NETSNMP_NO_SYSTEMD
++ /*
++ * Maybe the socket was already provided by systemd...
++ */
++ if (local) {
++ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_DGRAM, -1,
++ ntohs(addr->sin_port));
++ if (t->sock)
++ socket_initialized = 1;
++ }
++#endif
++ if (!socket_initialized)
++ t->sock = socket(PF_INET, SOCK_DGRAM, 0);
+ DEBUGMSGTL(("UDPBase", "openned socket %d as local=%d\n", t->sock, local));
+ if (t->sock < 0) {
+ netsnmp_transport_free(t);
+@@ -151,12 +168,14 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
+ }
+ }
+ #endif /* !defined(WIN32) */
+- rc = bind(t->sock, (struct sockaddr *) addr,
+- sizeof(struct sockaddr));
+- if (rc != 0) {
+- netsnmp_socketbase_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = bind(t->sock, (struct sockaddr *) addr,
++ sizeof(struct sockaddr));
++ if (rc != 0) {
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+ t->data = NULL;
+ t->data_length = 0;
+diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c
+index 18de876..fd2ced4 100644
+--- a/snmplib/transports/snmpUDPIPv6Domain.c
++++ b/snmplib/transports/snmpUDPIPv6Domain.c
+@@ -67,6 +67,10 @@ static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+ #include <net-snmp/library/snmpSocketBaseDomain.h>
+ #include <net-snmp/library/tools.h>
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ #include "inet_ntop.h"
+ #include "inet_pton.h"
+
+@@ -190,6 +194,8 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
+ {
+ netsnmp_transport *t = NULL;
+ int rc = 0;
++ char *str = NULL;
++ int socket_initialized = 0;
+
+ #ifdef NETSNMP_NO_LISTEN_SUPPORT
+ if (local)
+@@ -217,7 +223,19 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
+ t->domain_length =
+ sizeof(netsnmp_UDPIPv6Domain) / sizeof(netsnmp_UDPIPv6Domain[0]);
+
+- t->sock = socket(PF_INET6, SOCK_DGRAM, 0);
++#ifndef NETSNMP_NO_SYSTEMD
++ /*
++ * Maybe the socket was already provided by systemd...
++ */
++ if (local) {
++ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_DGRAM, -1,
++ ntohs(addr->sin6_port));
++ if (t->sock)
++ socket_initialized = 1;
++ }
++#endif
++ if (!socket_initialized)
++ t->sock = socket(PF_INET6, SOCK_DGRAM, 0);
+ if (t->sock < 0) {
+ netsnmp_transport_free(t);
+ return NULL;
+@@ -243,12 +261,14 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
+ }
+ #endif
+
+- rc = bind(t->sock, (struct sockaddr *) addr,
+- sizeof(struct sockaddr_in6));
+- if (rc != 0) {
+- netsnmp_socketbase_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = bind(t->sock, (struct sockaddr *) addr,
++ sizeof(struct sockaddr_in6));
++ if (rc != 0) {
++ netsnmp_socketbase_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+ t->local = (unsigned char*)malloc(18);
+ if (t->local == NULL) {
+diff --git a/snmplib/transports/snmpUnixDomain.c b/snmplib/transports/snmpUnixDomain.c
+index 47dffc1..8f34c37 100644
+--- a/snmplib/transports/snmpUnixDomain.c
++++ b/snmplib/transports/snmpUnixDomain.c
+@@ -37,6 +37,10 @@
+ #include <net-snmp/library/system.h> /* mkdirhier */
+ #include <net-snmp/library/tools.h>
+
++#ifndef NETSNMP_NO_SYSTEMD
++#include <net-snmp/library/sd-daemon.h>
++#endif
++
+ netsnmp_feature_child_of(transport_unix_socket_all, transport_all)
+ netsnmp_feature_child_of(unix_socket_paths, transport_unix_socket_all)
+
+@@ -295,6 +299,8 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
+ netsnmp_transport *t = NULL;
+ sockaddr_un_pair *sup = NULL;
+ int rc = 0;
++ char *string = NULL;
++ int socket_initialized = 0;
+
+ #ifdef NETSNMP_NO_LISTEN_SUPPORT
+ /* SPECIAL CIRCUMSTANCE: We still want AgentX to be able to operate,
+@@ -333,7 +339,18 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
+ t->data_length = sizeof(sockaddr_un_pair);
+ sup = (sockaddr_un_pair *) t->data;
+
+- t->sock = socket(PF_UNIX, SOCK_STREAM, 0);
++#ifndef NETSNMP_NO_SYSTEMD
++ /*
++ * Maybe the socket was already provided by systemd...
++ */
++ if (local) {
++ t->sock = netsnmp_sd_find_unix_socket(SOCK_STREAM, 1, addr->sun_path);
++ if (t->sock)
++ socket_initialized = 1;
++ }
++#endif
++ if (!socket_initialized)
++ t->sock = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (t->sock < 0) {
+ netsnmp_transport_free(t);
+ return NULL;
+@@ -357,25 +374,26 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
+
+ t->flags |= NETSNMP_TRANSPORT_FLAG_LISTEN;
+
+- unlink(addr->sun_path);
+- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
+-
+- if (rc != 0 && errno == ENOENT && create_path) {
+- rc = mkdirhier(addr->sun_path, create_mode, 1);
++ if (!socket_initialized) {
++ unlink(addr->sun_path);
++ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
++ if (rc != 0 && errno == ENOENT && create_path) {
++ rc = mkdirhier(addr->sun_path, create_mode, 1);
++ if (rc != 0) {
++ netsnmp_unix_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
++ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
++ }
+ if (rc != 0) {
++ DEBUGMSGTL(("netsnmp_unix_transport",
++ "couldn't bind \"%s\", errno %d (%s)\n",
++ addr->sun_path, errno, strerror(errno)));
+ netsnmp_unix_close(t);
+ netsnmp_transport_free(t);
+ return NULL;
+ }
+- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
+- }
+- if (rc != 0) {
+- DEBUGMSGTL(("netsnmp_unix_transport",
+- "couldn't bind \"%s\", errno %d (%s)\n",
+- addr->sun_path, errno, strerror(errno)));
+- netsnmp_unix_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
+ }
+
+ /*
+@@ -391,14 +409,16 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
+ * Now sit here and listen for connections to arrive.
+ */
+
+- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
+- if (rc != 0) {
+- DEBUGMSGTL(("netsnmp_unix_transport",
+- "couldn't listen to \"%s\", errno %d (%s)\n",
+- addr->sun_path, errno, strerror(errno)));
+- netsnmp_unix_close(t);
+- netsnmp_transport_free(t);
+- return NULL;
++ if (!socket_initialized) {
++ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
++ if (rc != 0) {
++ DEBUGMSGTL(("netsnmp_unix_transport",
++ "couldn't listen to \"%s\", errno %d (%s)\n",
++ addr->sun_path, errno, strerror(errno)));
++ netsnmp_unix_close(t);
++ netsnmp_transport_free(t);
++ return NULL;
++ }
+ }
+
+ } else {
+diff --git a/win32/libsnmp/Makefile.in b/win32/libsnmp/Makefile.in
+index 98d83c8..b228d20 100644
+--- a/win32/libsnmp/Makefile.in
++++ b/win32/libsnmp/Makefile.in
+@@ -42,6 +42,7 @@ LIB32_OBJS= \
+ "$(INTDIR)\read_config.obj" \
+ "$(INTDIR)\readdir.obj" \
+ "$(INTDIR)\scapi.obj" \
++ "$(INTDIR)\sd-daemon.obj" \
+ "$(INTDIR)\snmp-tc.obj" \
+ "$(INTDIR)\snmp.obj" \
+ "$(INTDIR)\snmpCallbackDomain.obj" \
+@@ -138,6 +139,11 @@ SOURCE=..\..\snmplib\asn1.c
+ "$(INTDIR)\asn1.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
++SOURCE=..\..\snmplib\sd-daemon.c
++
++"$(INTDIR)\sd-daemon.obj" : $(SOURCE) "$(INTDIR)"
++ $(CPP) $(CPP_PROJ) $(SOURCE)
++
+
+ SOURCE=..\..\snmplib\callback.c
+
+diff --git a/win32/net-snmp/net-snmp-config.h b/win32/net-snmp/net-snmp-config.h
+index 1608563..7aec547 100644
+--- a/win32/net-snmp/net-snmp-config.h
++++ b/win32/net-snmp/net-snmp-config.h
+@@ -1717,6 +1717,8 @@ enum {
+ #define DMALLOC_FUNC_CHECK
+ #endif
+
+++#define NETSNMP_NO_SYSTEMD
+++
+ /* #undef NETSNMP_ENABLE_LOCAL_SMUX */
+
+ /* define if agentx transport is to use domain sockets only */
+diff --git a/win32/net-snmp/net-snmp-config.h.in b/win32/net-snmp/net-snmp-config.h.in
+index 9693730..96ec3d9 100644
+--- a/win32/net-snmp/net-snmp-config.h.in
++++ b/win32/net-snmp/net-snmp-config.h.in
+@@ -1717,6 +1717,8 @@ enum {
+ #define DMALLOC_FUNC_CHECK
+ #endif
+
++#define NETSNMP_NO_SYSTEMD
++
+ /* #undef NETSNMP_ENABLE_LOCAL_SMUX */
+
+ /* define if agentx transport is to use domain sockets only */
+--
+1.8.4.2
+
OpenPOWER on IntegriCloud