diff -rwu net-snmp-5.9.3.orig/agent/mibgroup/mibII/interfaces.c net-snmp-5.9.3/agent/mibgroup/mibII/interfaces.c
--- net-snmp-5.9.3.orig/agent/mibgroup/mibII/interfaces.c	2022-11-12 18:11:18.689309000 +1100
+++ net-snmp-5.9.3/agent/mibgroup/mibII/interfaces.c	2022-11-12 18:45:45.880882000 +1100
@@ -22,6 +22,35 @@
 #include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-features.h>

+#if __rtems__
+ #define NETSNMP_IFNET_NEEDS_KERNEL_LATE
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <sys/errno.h>
+ /* kernel headers */
+ /* Clean up the RTEMS name conflicts */
+ #define asprintf ___bsd_asprintf
+ #define vasprintf ___bsd_vasprintf
+ #define qsort_r ___bsd_qsort_r
+ #define inet_ntop ___bsd_inet_ntop
+ #define malloc __bsd_malloc
+ #define _KERNEL 1
+ #include <machine/rtems-bsd-kernel-space.h>
+ #include <machine/_kernel_lock.h>
+ #include <sys/malloc.h>
+ #include <sys/systm.h>
+ #include <sys/mutex.h>
+ #undef _KERNEL
+ #undef asprintf
+ #undef vasprintf
+ #undef qsort_r
+ #undef inet_ntop
+ #undef malloc
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <net/if_var.h>
+#endif
+
 netsnmp_feature_provide(interface_legacy);

 #if defined(NETSNMP_IFNET_NEEDS_KERNEL) && !defined(_KERNEL) && !defined(NETSNMP_IFNET_NEEDS_KERNEL_LATE)
@@ -78,7 +107,15 @@
 #include <fcntl.h>
 #endif
 #if HAVE_SYS_IOCTL_H
+#if __rtems__ && defined(_KERNEL)
+#define RTEMS_KERNEL_PUSH
+#undef _KERNEL
+#endif
 #include <sys/ioctl.h>
+#if __rtems__ && defined(RTEMS_KERNEL_PUSH)
+#undef RTEMS_KERNEL_PUSH
+#define _KERNEL 1
+#endif
 #endif
 #if HAVE_NETINET_IN_H
 #include <netinet/in.h>
diff -rwu net-snmp-5.9.3.orig/agent/mibgroup/mibII/ip.c net-snmp-5.9.3/agent/mibgroup/mibII/ip.c
--- net-snmp-5.9.3.orig/agent/mibgroup/mibII/ip.c	2022-11-12 18:11:18.689399000 +1100
+++ net-snmp-5.9.3/agent/mibgroup/mibII/ip.c	2022-11-13 11:50:48.813948000 +1100
@@ -1005,4 +1005,3 @@
     memset(&ipstat, 0, sizeof(ipstat));
 #endif
 }
-
diff -rwu net-snmp-5.9.3.orig/agent/mibgroup/mibII/mibII_common.h net-snmp-5.9.3/agent/mibgroup/mibII/mibII_common.h
--- net-snmp-5.9.3.orig/agent/mibgroup/mibII/mibII_common.h	2022-11-12 18:11:18.689512000 +1100
+++ net-snmp-5.9.3/agent/mibgroup/mibII/mibII_common.h	2022-11-12 18:45:45.882824000 +1100
@@ -1,3 +1,24 @@
+#if __rtems__
+#if !defined(RTEMS_MIBII_COMMON) && defined(NETSNMP_IFNET_NEEDS_KERNEL)
+ #define RTEMS_MIBII_COMMON 1
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <sys/errno.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ /* kernel headers */
+ #include <machine/rtems-bsd-kernel-space.h>
+ #include <machine/_kernel_lock.h>
+ #include <machine/_kernel_in6.h>
+ /* Clean up the RTEMS name conflicts */
+ #define asprintf ___bsd_asprintf
+ #define vasprintf ___bsd_vasprintf
+ #define qsort_r ___bsd_qsort_r
+ #define inet_ntop ___bsd_inet_ntop
+ #define malloc __bsd_malloc
+#endif
+#endif
+
 #if HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
diff -rwu net-snmp-5.9.3.orig/agent/mibgroup/mibII/tcp.c net-snmp-5.9.3/agent/mibgroup/mibII/tcp.c
--- net-snmp-5.9.3.orig/agent/mibgroup/mibII/tcp.c	2022-11-12 18:11:18.689717000 +1100
+++ net-snmp-5.9.3/agent/mibgroup/mibII/tcp.c	2022-11-13 10:49:48.142434000 +1100
@@ -47,6 +47,10 @@
 #include <netinet/tcp_fsm.h>
 #endif

+#if __rtems__
+extern int hz;
+#endif
+
 #include <net-snmp/net-snmp-includes.h>
 #include <net-snmp/agent/net-snmp-agent-includes.h>
 #include <net-snmp/agent/auto_nlist.h>
@@ -825,4 +829,3 @@
     memset(&tcpstat, 0, sizeof(tcpstat));
 #endif
 }
-
diff -rwu net-snmp-5.9.3.orig/agent/mibgroup/udp-mib/data_access/udp_endpoint_freebsd4.c net-snmp-5.9.3/agent/mibgroup/udp-mib/data_access/udp_endpoint_freebsd4.c
--- net-snmp-5.9.3.orig/agent/mibgroup/udp-mib/data_access/udp_endpoint_freebsd4.c	2022-11-12 18:11:18.682713000 +1100
+++ net-snmp-5.9.3/agent/mibgroup/udp-mib/data_access/udp_endpoint_freebsd4.c	2022-11-13 14:26:37.966367000 +1100
@@ -20,6 +20,10 @@
 #include <netinet/udp_var.h>
 #endif

+#if __rtems__
+#define INP_ISIPV6(x) 0
+#endif
+
 static int _load(netsnmp_container *container, u_int flags);

 /*
diff -rwu net-snmp-5.9.3.orig/agent/mibgroup/utilities/execute.c net-snmp-5.9.3/agent/mibgroup/utilities/execute.c
--- net-snmp-5.9.3.orig/agent/mibgroup/utilities/execute.c	2022-11-12 18:11:18.684733000 +1100
+++ net-snmp-5.9.3/agent/mibgroup/utilities/execute.c	2022-11-13 14:21:11.321962000 +1100
@@ -45,6 +45,10 @@
 #define pclose _pclose
 #endif

+#if __rtems__
+#define popen(x ...) NULL
+#define pclose(x) 0
+#endif

 /**
  * Run a shell command by calling system() or popen().
diff -rwu net-snmp-5.9.3.orig/configure.d/config_net_snmp_config_h net-snmp-5.9.3/configure.d/config_net_snmp_config_h
--- net-snmp-5.9.3.orig/configure.d/config_net_snmp_config_h	2022-11-12 18:11:18.699340000 +1100
+++ net-snmp-5.9.3/configure.d/config_net_snmp_config_h	2022-11-12 18:45:45.905996000 +1100
@@ -191,6 +191,7 @@
 #define NETSNMP_AIXID 15
 #define NETSNMP_MACOSXID 16
 #define NETSNMP_DRAGONFLYID 17
+#define NETSNMP_RTEMSID 18
 #define NETSNMP_UNKNOWNID 255

 #ifdef hpux9
@@ -244,6 +245,9 @@
 #if defined(darwin) && (darwin >= 8)
 #define NETSNMP_OSTYPE NETSNMP_MACOSXID
 #endif
+#if defined(__rtems__)
+#define NETSNMP_OSTYPE NETSNMP_RTEMSID
+#endif
 /* unknown */
 #ifndef NETSNMP_OSTYPE
 #define NETSNMP_OSTYPE NETSNMP_UNKNOWNID
@@ -662,6 +666,7 @@
 #define HPUX11ID      NETSNMP_HPUX11ID
 #define AIXID         NETSNMP_AIXID
 #define MACOSXID      NETSNMP_MACOSXID
+#define RTEMSID       NETSNMP_RTEMSID
 #define UNKNOWNID     NETSNMP_UNKNOWNID

 #define ENTERPRISE_OID            NETSNMP_ENTERPRISE_OID
diff -rwu net-snmp-5.9.3.orig/include/net-snmp/net-snmp-config.h.in net-snmp-5.9.3/include/net-snmp/net-snmp-config.h.in
--- net-snmp-5.9.3.orig/include/net-snmp/net-snmp-config.h.in	2022-11-12 18:11:18.567337000 +1100
+++ net-snmp-5.9.3/include/net-snmp/net-snmp-config.h.in	2022-11-12 18:45:45.908391000 +1100
@@ -2059,6 +2059,7 @@
 #define NETSNMP_AIXID 15
 #define NETSNMP_MACOSXID 16
 #define NETSNMP_DRAGONFLYID 17
+#define NETSNMP_RTEMSID 18
 #define NETSNMP_UNKNOWNID 255

 #ifdef hpux9
@@ -2112,6 +2113,9 @@
 #if defined(darwin) && (darwin >= 8)
 #define NETSNMP_OSTYPE NETSNMP_MACOSXID
 #endif
+#if defined(__rtems__)
+#define NETSNMP_OSTYPE NETSNMP_RTEMSID
+#endif
 /* unknown */
 #ifndef NETSNMP_OSTYPE
 #define NETSNMP_OSTYPE NETSNMP_UNKNOWNID
@@ -2530,6 +2534,7 @@
 #define HPUX11ID      NETSNMP_HPUX11ID
 #define AIXID         NETSNMP_AIXID
 #define MACOSXID      NETSNMP_MACOSXID
+#define RTEMSID       NETSNMP_RTEMSID
 #define UNKNOWNID     NETSNMP_UNKNOWNID

 #define ENTERPRISE_OID            NETSNMP_ENTERPRISE_OID
