changeset 777:2bcd1b710e09

* include/mibgroup/mibII/itf_helpers.h: * src/mibgroup/mibII/helpers.c: (New) Functions for finding the interface structure for Free and open BSD. * src/mibgroup/mibII/interfaces.c: Use the helper functions and other changes needed for the FreeBSD stack. * src/mibgroup/mibII/ip.c: Ditto * src/mibgroup/mibII/udp.c: Ditto * src/mibgroup/mibII/tcp.c: Ditto * src/mibgroup/mibII/dot3.c: Ditto * cdl/snmpagent.cdl: Removed the requirement for the OpenBSD stack. * doc/snmp.sgml: Removed the documented requirement for the OpenBSD stack
author asl
date Fri, 28 Feb 2003 09:24:31 +0000
parents f9fb4fb63c6d
children 3b9aa5717c76
files packages/net/snmp/agent/current/ChangeLog packages/net/snmp/agent/current/cdl/snmpagent.cdl packages/net/snmp/agent/current/doc/snmp.sgml packages/net/snmp/agent/current/include/mibgroup/mibII/ifr_helper.h packages/net/snmp/agent/current/src/mibgroup/mibII/dot3.c packages/net/snmp/agent/current/src/mibgroup/mibII/helpers.c packages/net/snmp/agent/current/src/mibgroup/mibII/interfaces.c packages/net/snmp/agent/current/src/mibgroup/mibII/ip.c packages/net/snmp/agent/current/src/mibgroup/mibII/tcp.c packages/net/snmp/agent/current/src/mibgroup/mibII/udp.c packages/net/snmp/agent/current/src/snmptask.c
diffstat 11 files changed, 328 insertions(+), 132 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/snmp/agent/current/ChangeLog
+++ b/packages/net/snmp/agent/current/ChangeLog
@@ -1,3 +1,18 @@
+2003-02-28  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+        * include/mibgroup/mibII/itf_helpers.h:
+	* src/mibgroup/mibII/helpers.c: (New) Functions for finding the
+	interface structure for Free and open BSD.
+	* src/mibgroup/mibII/interfaces.c: Use the helper functions and
+	other changes needed for the FreeBSD stack.
+	* src/mibgroup/mibII/ip.c: Ditto
+	* src/mibgroup/mibII/udp.c: Ditto
+	* src/mibgroup/mibII/tcp.c: Ditto
+	* src/mibgroup/mibII/dot3.c: Ditto
+	* cdl/snmpagent.cdl: Removed the requirement for the OpenBSD stack.
+	* doc/snmp.sgml: Removed the documented requirement for the OpenBSD
+	stack.
+	
 2003-02-24  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* cdl/snmpagent.cdl: Add doc link.
--- a/packages/net/snmp/agent/current/cdl/snmpagent.cdl
+++ b/packages/net/snmp/agent/current/cdl/snmpagent.cdl
@@ -41,7 +41,7 @@
 ######DESCRIPTIONBEGIN####
 #
 # Author(s):      hmt
-# Original data:  hmt
+# Original data:  hmt, Andrew Lunn
 # Contributors:   gthomas
 # Date:           2000-05-30
 #
@@ -63,8 +63,6 @@ cdl_package CYGPKG_SNMPAGENT {
     requires      { 0 != CYGINT_ISO_ERRNO }
     requires      { 0 != CYGINT_ISO_ERRNO_CODES }
     requires      CYGPKG_NET
-# For now we only work with the OpenBSD stack, not FreeBSD
-    requires      CYGPKG_NET_OPENBSD_STACK
     requires      CYGPKG_SNMPLIB
     description   "SNMP agent based on the UCD-SNMP project."
 
@@ -78,6 +76,7 @@ cdl_package CYGPKG_SNMPAGENT {
 		snmp_vars.c			\
 		snmpd.c				\
                 snmptask.c			\
+		mibgroup/mibII/helpers.c        \
 		mibgroup/mibII/system_mib.c	\
 		mibgroup/mibII/sysORTable.c	\
 		mibgroup/mibII/snmp_mib.c	\
--- a/packages/net/snmp/agent/current/doc/snmp.sgml
+++ b/packages/net/snmp/agent/current/doc/snmp.sgml
@@ -244,23 +244,10 @@ again.
 <SECT1 id="net-snmp-configuring-ecos">
 <TITLE>Configuring eCos</TITLE>
 <PARA>
-To use the SNMP agent, the SNMP library and agent packages must
-be included in your configuration. In addition, at this point, the SNMP
-stack only works with the OpenBSD-based TCP/IP stack, not the FreeBSD-based
-stack. The "old_net" template can be used as a starting point for using
-the OpenBSD-based TCP/IP stack, for example:
-<SCREEN>
-$ <USERINPUT>ecosconfig new mytarget old_net</USERINPUT>
-</SCREEN>
-or you can add the various required packages to an existing configuration with:
-<SCREEN>
-$ <USERINPUT>ecosconfig add net openbsd_net eth_drivers</USERINPUT>
-</SCREEN>
-</PARA>
-<PARA>
-To incorporate the stack into your configuration select the SNMP library
-and SNMP agent packages in the eCos Configuration Tool, or at the command
-line type:
+To use the SNMP agent, the SNMP library and agent packages must be
+included in your configuration. To incorporate the stack into your
+configuration select the SNMP library and SNMP agent packages in the
+eCos Configuration Tool, or at the command line type:
 <SCREEN>
 $ <USERINPUT>ecosconfig add snmplib snmpagent</USERINPUT>
 </SCREEN>
new file mode 100644
--- /dev/null
+++ b/packages/net/snmp/agent/current/include/mibgroup/mibII/ifr_helper.h
@@ -0,0 +1,56 @@
+#ifndef CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
+#define CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
+//=============================================================================
+//
+//      ifr_helper.h
+//
+//      Helper functions to deal with getting interface structures.
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003 Andrew Lunn
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):   andrew.lunn
+// Contributors:
+// Date:        2003-02-22
+//
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+long cyg_snmp_num_interfaces(void);
+struct ifnet *cyg_snmp_get_if(int if_num);
+
+#endif //CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
--- a/packages/net/snmp/agent/current/src/mibgroup/mibII/dot3.c
+++ b/packages/net/snmp/agent/current/src/mibgroup/mibII/dot3.c
@@ -101,8 +101,13 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 #include "mibincl.h"
 #include "mibgroup/util_funcs.h"
 #include "mibgroup/mibII/dot3.h"
+#include "mibgroup/mibII/ifr_helper.h"
 
 #include <net/if_types.h>
+#include <net/if.h>
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include <net/if_var.h>
+#endif
 
 // Get info about the device
 #include <pkgconf/system.h>
@@ -226,19 +231,15 @@ var_dot3StatsTable(struct variable *vp,
     int supports_dot3 = 0, i;
     struct ether_drv_stats x;
     
-    for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
-        interface_count++;
-        
+    interface_count = cyg_snmp_num_interfaces();
+
     if ( header_simple_table( vp,name,length,exact,var_len,write_method,
                               interface_count)
          == MATCH_FAILED )
         return NULL;
 
-    for ( interface_count = name[ (*length)-1 ], ifp = ifnet.tqh_first;
-          interface_count > 1 && ifp != 0;
-          interface_count-- )
-        ifp = ifp->if_list.tqe_next;
-    
+    ifp = cyg_snmp_get_if(name[ (*length)-1 ]);
+
     if ( ! ifp )
         return NULL;
 
new file mode 100644
--- /dev/null
+++ b/packages/net/snmp/agent/current/src/mibgroup/mibII/helpers.c
@@ -0,0 +1,116 @@
+//=============================================================================
+//
+//      sntp.c
+//
+//      Helper functions to access the interface information
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003 Andrew Lunn
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):   andrew.lunn
+// Contributors:
+// Date:        2003-02-22
+// Description: Provides helper functions to access the network interface
+//              information.
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+#include <pkgconf/system.h>
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <net/if.h>
+#include <net/if.h>
+
+/* How many interfaces are there? */
+
+#ifdef CYGPKG_NET_FREEBSD_STACK
+struct ifaddr **ifnet_addrs;
+
+long cyg_snmp_num_interfaces(void) {
+  long long_ret=0;
+  int cnt = if_index;
+  
+  while (cnt > 0) {
+    if (ifnet_addrs[cnt] != 0) {
+      long_ret++;
+    }
+    cnt--;
+  }
+  return long_ret;
+}
+
+struct ifnet *cyg_snmp_get_if(int if_num) {
+  int index = 0;
+  struct ifnet *ifp;
+  do {
+    while(0 == ifnet_addrs[index])
+      index++;
+
+    ifp = ifnet_addrs[index]->ifa_ifp;
+    if_num--;
+  } while (if_num);
+
+  return ifp;
+}
+#endif
+
+#ifdef CYGPKG_NET_OPENBSD_STACK
+long cyg_snmp_num_interfaces(void) {
+  register struct ifnet *ifp;
+  long long_ret = 0;
+
+  for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
+    long_ret++;
+  
+  return long_ret;
+}
+
+struct ifnet *cyg_snmp_get_if(int if_num) {
+  struct ifnet *ifp;
+  
+  for ( ifp = ifnet.tqh_first;
+	if_num > 1 && ifp != 0;
+          if_num-- )
+        ifp = ifp->if_list.tqe_next;
+  
+  return ifp;
+}
+#endif
+
+
--- a/packages/net/snmp/agent/current/src/mibgroup/mibII/interfaces.c
+++ b/packages/net/snmp/agent/current/src/mibgroup/mibII/interfaces.c
@@ -54,7 +54,7 @@
 //#####DESCRIPTIONBEGIN####
 //
 // Author(s):    hmt
-// Contributors: hmt
+// Contributors: hmt, Andrew Lunn
 // Date:         2000-05-30
 // Purpose:      Port of UCD-SNMP distribution to eCos.
 // Description:  
@@ -92,6 +92,22 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 /* This file was generated by mib2c and is intended for use as a mib module
    for the ucd-snmp snmpd agent. */
 
+#include <pkgconf/system.h>
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <net/if.h>
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include <net/if_var.h>
+#endif
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+// These two to acquire all the statistics.
+
+#include <cyg/io/eth/eth_drv_stats.h>
+#include <sys/sockio.h>
 
 /* This should always be included first before anything else */
 #include <config.h>
@@ -101,17 +117,9 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 #include "mibincl.h"
 #include "mibgroup/util_funcs.h"
 #include "mibgroup/mibII/interfaces.h"
-
+#include "mibgroup/mibII/ifr_helper.h"
 #include <net/if_types.h>
 
-// Get info about the device
-#include <pkgconf/system.h>
-
-// These two two acquire all the statistics.
-#include <cyg/io/eth/eth_drv.h>
-#include <cyg/io/eth/eth_drv_stats.h>
-#include <sys/sockio.h>
-
 /* 
  * interfaces_variables_oid:
  *   this is the top level oid that we want to register under.  This
@@ -121,10 +129,6 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 oid interfaces_variables_oid[] = { 1,3,6,1,2,1,2 };
 
 
-extern struct ifnet_head ifnet;
-
-
-
 /* 
  * variable4 interfaces_variables:
  *   this variable defines function callbacks and type return information 
@@ -201,7 +205,6 @@ void init_interfaces(void) {
   /* place any other initialization junk you need here */
 }
 
-
 /*
  * var_interfaces():
  *   This function is called every time the agent gets a request for
@@ -224,34 +227,24 @@ var_interfaces(struct variable *vp,
 {
     
 
-    /* variables we may use later */
-    static long long_ret;
-//    static unsigned char string[SPRINT_MAX_LEN];
-//    static oid objid[MAX_OID_LEN];
-//    static struct counter64 c64;
-
-
-    if ( MATCH_FAILED ==
-         header_generic(vp,name,length,exact,var_len,write_method) )
-        return NULL;
-
-    /* 
-     * this is where we do the value assignments for the mib results.
-     */
-    switch(vp->magic) {
-    case IFNUMBER: {
-        register struct ifnet *ifp;
-        long_ret = 0;
-        for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
-            long_ret++;
-        
-        return (unsigned char *) &long_ret;
-    }   
-
-    default:
-        ERROR_MSG("");
-    }
+  static long long_ret;
+  
+  if ( MATCH_FAILED ==
+       header_generic(vp,name,length,exact,var_len,write_method) )
     return NULL;
+  
+  /* 
+   * this is where we do the value assignments for the mib results.
+   */
+  switch(vp->magic) {
+  case IFNUMBER: {
+    long_ret = cyg_snmp_num_interfaces();
+    return (unsigned char *) &long_ret;
+  }
+  default:
+    ERROR_MSG("");
+  }
+  return NULL;
 }
 
 
@@ -274,13 +267,10 @@ var_ifTable(struct variable *vp,
     static long long_ret;
     static unsigned char string[SPRINT_MAX_LEN];
     static oid objid[MAX_OID_LEN];
-//  static struct counter64 c64;
-    
-    register struct ifnet *ifp;
-    int interface_count = 0;
-    
-    for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
-        interface_count++;
+    struct ifnet *ifp;
+    int if_num;
+
+    int interface_count = cyg_snmp_num_interfaces();
         
     /* 
      * This assumes that the table is a 'simple' table.
@@ -297,13 +287,11 @@ var_ifTable(struct variable *vp,
          == MATCH_FAILED )
         return NULL;
     
-    for ( interface_count = name[ (*length)-1 ], ifp = ifnet.tqh_first;
-          interface_count > 1 && ifp != 0;
-          interface_count-- )
-        ifp = ifp->if_list.tqe_next;
-
-    if ( ! ifp )
-        return NULL;
+    if_num = name[ (*length)-1 ];
+    
+    ifp = cyg_snmp_get_if(if_num);
+    if (!ifp)
+      return NULL;
 
 // This is to assist customers with their own special interfaces; if they
 // define IFT_CUSTOMER_SPECIAL to whatever their own device is, then its
--- a/packages/net/snmp/agent/current/src/mibgroup/mibII/ip.c
+++ b/packages/net/snmp/agent/current/src/mibgroup/mibII/ip.c
@@ -54,7 +54,7 @@
 //#####DESCRIPTIONBEGIN####
 //
 // Author(s):    hmt
-// Contributors: hmt
+// Contributors: hmt, Andrew Lunn
 // Date:         2000-05-30
 // Purpose:      Port of UCD-SNMP distribution to eCos.
 // Description:  
@@ -92,25 +92,31 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 /* This file was generated by mib2c and is intended for use as a mib module
    for the ucd-snmp snmpd agent. */
 
+#include <sys/param.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <net/if.h>
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include <net/if_var.h>
+#endif
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+#include <netinet/in_var.h>
+#include <netinet/ip_var.h>
 
 /* This should always be included first before anything else */
 #include <config.h>
 
-
 /* minimal include directives */
 #include "mibincl.h"
 #include "mibgroup/util_funcs.h"
 #include "mibgroup/mibII/ip.h"
 
-#define _KERNEL 1
-
-#include <netinet/in_var.h>
-#include <netinet/ip_var.h>
+#include <cyg/io/eth/eth_drv.h>
 
 extern struct in_ifaddrhead in_ifaddr;
-extern struct ifnet_head ifnet;
-
-#include <cyg/io/eth/eth_drv.h>
 
 /* 
  * ip_variables_oid:
@@ -122,7 +128,6 @@ extern struct ifnet_head ifnet;
 
 oid ip_variables_oid[] = { 1,3,6,1,2,1,4 };
 
-
 /* 
  * variable4 ip_variables:
  *   this variable defines function callbacks and type return information 
@@ -294,7 +299,9 @@ var_ip(struct variable *vp,
             + ipstat.ips_badlen
             + ipstat.ips_badoptions
             + ipstat.ips_badvers
+#ifdef CYGPKG_NET_OPENBSD_STACK
             + ipstat.ips_badfrags
+#endif
             + ipstat.ips_toolong
             ;
         return (unsigned char *) &long_ret;
@@ -319,7 +326,9 @@ var_ip(struct variable *vp,
             + ipstat.ips_badlen
             + ipstat.ips_badoptions
             + ipstat.ips_badvers
+#ifdef CYGPKG_NET_OPENBSD_STACK
             + ipstat.ips_badfrags
+#endif
             + ipstat.ips_toolong
                 ) -
             ipstat.ips_cantforward;
@@ -417,7 +426,16 @@ var_ipAddrTable(struct variable *vp,
     /* fill in object part of name for current (less sizeof instance part) */
     memcpy( (char *)current,(char *)vp->name, (int)vp->namelen * sizeof(oid));
 
-    for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
+    for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+	 ia = in_ifaddr.tqh_first; ia; 
+	 ia = ia->ia_list.tqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+	 ia = in_ifaddrhead.tqh_first; ia; 
+	 ia = ia->ia_link.tqe_next
+#endif
+	 ) {
 	cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
 
 	op = current + 10;
@@ -544,7 +562,16 @@ var_ipNetToMediaTable(struct variable *v
     /* fill in object part of name for current (less sizeof instance part) */
     memcpy((char *)current, (char *)vp->name, (int)vp->namelen * sizeof(oid));
 
-    for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
+    for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+	 ia = in_ifaddr.tqh_first; ia; 
+	 ia = ia->ia_list.tqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK	 
+	   ia = in_ifaddrhead.tqh_first; ia; 
+	 ia = ia->ia_link.tqe_next
+#endif
+	 ) {
         // interface number
         current[10] = ia->ia_ifa.ifa_ifp->if_index;
         // IP address
--- a/packages/net/snmp/agent/current/src/mibgroup/mibII/tcp.c
+++ b/packages/net/snmp/agent/current/src/mibgroup/mibII/tcp.c
@@ -54,7 +54,7 @@
 //#####DESCRIPTIONBEGIN####
 //
 // Author(s):    hmt
-// Contributors: hmt
+// Contributors: hmt, Andrew Lunn
 // Date:         2000-05-30
 // Purpose:      Port of UCD-SNMP distribution to eCos.
 // Description:  
@@ -92,7 +92,7 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 /* This file was generated by mib2c and is intended for use as a mib module
    for the ucd-snmp snmpd agent. */
 
-
+#include <pkgconf/system.h>
 /* This should always be included first before anything else */
 #include <config.h>
 
@@ -264,9 +264,18 @@ var_tcp(struct variable *vp,
     case TCPCURRESTAB: {
         struct inpcb *inp;
         long_ret = 0;
-        for (inp = tcbtable.inpt_queue.cqh_first;
+        for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+	     inp = tcbtable.inpt_queue.cqh_first;
              inp != (struct inpcb *)&tcbtable.inpt_queue;
-             inp = inp->inp_queue.cqe_next) {
+             inp = inp->inp_queue.cqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+	     inp = tcb.lh_first;
+             inp;
+             inp = inp->inp_list.le_next
+#endif
+	     ) {
             struct tcpcb *tp = intotcpcb( inp );
             if ( tp && (TCPS_ESTABLISHED == tp->t_state ||
                         TCPS_CLOSE_WAIT  == tp->t_state) )
@@ -349,9 +358,18 @@ var_tcpConnTable(struct variable *vp,
     /* fill in object part of name for current (less sizeof instance part) */
     memcpy((char *)newname, (char *)vp->name, (int)vp->namelen * sizeof(oid));
 
-    for (inp = tcbtable.inpt_queue.cqh_first;
-         inp != (struct inpcb *)&tcbtable.inpt_queue;
-         inp = inp->inp_queue.cqe_next) {
+    for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+	     inp = tcbtable.inpt_queue.cqh_first;
+             inp != (struct inpcb *)&tcbtable.inpt_queue;
+             inp = inp->inp_queue.cqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+	     inp = tcb.lh_first;
+             inp;
+             inp = inp->inp_list.le_next
+#endif
+	 ) {
 
         cp = (u_char *)&inp->inp_laddr.s_addr;
         op = newname + 10;
--- a/packages/net/snmp/agent/current/src/mibgroup/mibII/udp.c
+++ b/packages/net/snmp/agent/current/src/mibgroup/mibII/udp.c
@@ -54,7 +54,7 @@
 //#####DESCRIPTIONBEGIN####
 //
 // Author(s):    hmt
-// Contributors: hmt
+// Contributors: hmt, Andrew Lunn
 // Date:         2000-05-30
 // Purpose:      Port of UCD-SNMP distribution to eCos.
 // Description:  
@@ -92,30 +92,24 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 /* This file was generated by mib2c and is intended for use as a mib module
    for the ucd-snmp snmpd agent. */
 
+#include <pkgconf/system.h>
 
 /* This should always be included first before anything else */
 #include <config.h>
 
-
 /* minimal include directives */
 #include "mibincl.h"
 #include "mibgroup/util_funcs.h"
 #include "mibgroup/mibII/udp.h"
 
-
+#include <sys/protosw.h>
 
 #define _KERNEL
-
-#include <net/if.h>
-#include <net/route.h>
-
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
-#include <netinet/in_var.h>
 #include <netinet/ip.h>
 #include <netinet/in_pcb.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip_icmp.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
 
@@ -257,9 +251,18 @@ var_udpTable(struct variable *vp,
     /* fill in object part of name for current (less sizeof instance part) */
     memcpy((char *)newname, (char *)vp->name, (int)vp->namelen * sizeof(oid));
 
-    for (inp = udbtable.inpt_queue.cqh_first;
+    for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+	 inp = udbtable.inpt_queue.cqh_first;
          inp != (struct inpcb *)&udbtable.inpt_queue;
-         inp = inp->inp_queue.cqe_next) {
+         inp = inp->inp_queue.cqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+	 inp = udb.lh_first;
+         inp;
+         inp = inp->inp_list.le_next
+#endif
+	 ) {
         cp = (u_char *)&inp->inp_laddr.s_addr;
         op = newname + 10;
         *op++ = *cp++;
--- a/packages/net/snmp/agent/current/src/snmptask.c
+++ b/packages/net/snmp/agent/current/src/snmptask.c
@@ -152,25 +152,11 @@ CONNECTION WITH THE USE OR PERFORMANCE O
 //
 //==========================================================================
 
-
-// Support routines, etc., used by network code
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/kernel.h>
-#include <sys/domain.h>
-#include <sys/protosw.h>
-#include <net/netisr.h>
-
-#include <machine/cpu.h>
-
-#include <cyg/infra/diag.h>
-#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/hal_arch.h>
 #include <cyg/kernel/kapi.h>
 
-
-
+#include <pkgconf/system.h>
+#include CYGDAT_NET_STACK_CFG
 
 #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL + 102400
 static char netsnmp_stack[STACK_SIZE];
@@ -188,7 +174,7 @@ void (*snmpd_reinit_function)( void ) = 
 externC void snmpd( void (*initfunc)( void ) );
 
 static void
-snmpdloop( void )
+snmpdloop( cyg_addrword_t data )
 {
     while ( 1 )
         snmpd(snmpd_reinit_function);