This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SNMP packages with FreeBSD


Hi Folks

The attached patch allows the snmp code to be used with the FreeBSD
stack.

        Andrew

Index: snmp//agent/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/ChangeLog,v
retrieving revision 1.24
diff -u -r1.24 ChangeLog
--- snmp//agent/current/ChangeLog	24 Feb 2003 14:31:10 -0000	1.24
+++ snmp//agent/current/ChangeLog	26 Feb 2003 08:40:21 -0000
@@ -1,3 +1,18 @@
+2003-02-25  Andrew Lunn  <andrew dot lunn at ascom dot 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 at eCosCentric dot com>
 
 	* cdl/snmpagent.cdl: Add doc link.
Index: snmp//agent/current/cdl/snmpagent.cdl
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/cdl/snmpagent.cdl,v
retrieving revision 1.9
diff -u -r1.9 snmpagent.cdl
--- snmp//agent/current/cdl/snmpagent.cdl	24 Feb 2003 14:31:10 -0000	1.9
+++ snmp//agent/current/cdl/snmpagent.cdl	26 Feb 2003 08:40:21 -0000
@@ -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 @@
     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 @@
 		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	\
Index: snmp//agent/current/doc/snmp.sgml
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/doc/snmp.sgml,v
retrieving revision 1.6
diff -u -r1.6 snmp.sgml
--- snmp//agent/current/doc/snmp.sgml	24 Feb 2003 14:31:10 -0000	1.6
+++ snmp//agent/current/doc/snmp.sgml	26 Feb 2003 08:40:21 -0000
@@ -244,23 +244,10 @@
 <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>
Index: snmp//agent/current/include/mibgroup/mibII/ifr_helper.h
===================================================================
RCS file: snmp//agent/current/include/mibgroup/mibII/ifr_helper.h
diff -N snmp//agent/current/include/mibgroup/mibII/ifr_helper.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ snmp//agent/current/include/mibgroup/mibII/ifr_helper.h	26 Feb 2003 08:40:21 -0000
@@ -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_num_interfaces(void);
+struct ifnet *cyg_get_if(int if_num);
+
+#endif //CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
Index: snmp//agent/current/src/snmptask.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/snmptask.c,v
retrieving revision 1.5
diff -u -r1.5 snmptask.c
--- snmp//agent/current/src/snmptask.c	23 May 2002 23:08:10 -0000	1.5
+++ snmp//agent/current/src/snmptask.c	26 Feb 2003 08:40:21 -0000
@@ -152,25 +152,11 @@
 //
 //==========================================================================
 
-
-// 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 @@
 externC void snmpd( void (*initfunc)( void ) );
 
 static void
-snmpdloop( void )
+snmpdloop( cyg_addrword_t data )
 {
     while ( 1 )
         snmpd(snmpd_reinit_function);
Index: snmp//agent/current/src/mibgroup/mibII/dot3.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/mibgroup/mibII/dot3.c,v
retrieving revision 1.7
diff -u -r1.7 dot3.c
--- snmp//agent/current/src/mibgroup/mibII/dot3.c	23 May 2002 23:08:10 -0000	1.7
+++ snmp//agent/current/src/mibgroup/mibII/dot3.c	26 Feb 2003 08:40:21 -0000
@@ -101,8 +101,13 @@
 #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 @@
     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_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_get_if(name[ (*length)-1 ]);
+
     if ( ! ifp )
         return NULL;
 
Index: snmp//agent/current/src/mibgroup/mibII/helpers.c
===================================================================
RCS file: snmp//agent/current/src/mibgroup/mibII/helpers.c
diff -N snmp//agent/current/src/mibgroup/mibII/helpers.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ snmp//agent/current/src/mibgroup/mibII/helpers.c	26 Feb 2003 08:40:21 -0000
@@ -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_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_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_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_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
+
+
Index: snmp//agent/current/src/mibgroup/mibII/interfaces.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/mibgroup/mibII/interfaces.c,v
retrieving revision 1.7
diff -u -r1.7 interfaces.c
--- snmp//agent/current/src/mibgroup/mibII/interfaces.c	23 May 2002 23:08:11 -0000	1.7
+++ snmp//agent/current/src/mibgroup/mibII/interfaces.c	26 Feb 2003 08:40:21 -0000
@@ -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 @@
 /* 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 @@
 #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 @@
 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 @@
   /* 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 @@
 {
     
 
-    /* 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_num_interfaces();
+    return (unsigned char *) &long_ret;
+  }
+  default:
+    ERROR_MSG("");
+  }
+  return NULL;
 }
 
 
@@ -274,13 +267,10 @@
     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_num_interfaces();
         
     /* 
      * This assumes that the table is a 'simple' table.
@@ -297,13 +287,11 @@
          == 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_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
Index: snmp//agent/current/src/mibgroup/mibII/ip.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/mibgroup/mibII/ip.c,v
retrieving revision 1.5
diff -u -r1.5 ip.c
--- snmp//agent/current/src/mibgroup/mibII/ip.c	23 May 2002 23:08:11 -0000	1.5
+++ snmp//agent/current/src/mibgroup/mibII/ip.c	26 Feb 2003 08:40:21 -0000
@@ -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 @@
 /* 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 @@
 
 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 @@
             + 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 @@
             + 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 @@
     /* 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 @@
     /* 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
Index: snmp//agent/current/src/mibgroup/mibII/tcp.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/mibgroup/mibII/tcp.c,v
retrieving revision 1.3
diff -u -r1.3 tcp.c
--- snmp//agent/current/src/mibgroup/mibII/tcp.c	23 May 2002 23:08:12 -0000	1.3
+++ snmp//agent/current/src/mibgroup/mibII/tcp.c	26 Feb 2003 08:40:21 -0000
@@ -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 @@
 /* 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 @@
     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 @@
     /* 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;
Index: snmp//agent/current/src/mibgroup/mibII/udp.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/mibgroup/mibII/udp.c,v
retrieving revision 1.3
diff -u -r1.3 udp.c
--- snmp//agent/current/src/mibgroup/mibII/udp.c	23 May 2002 23:08:12 -0000	1.3
+++ snmp//agent/current/src/mibgroup/mibII/udp.c	26 Feb 2003 08:40:21 -0000
@@ -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 @@
 /* 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 @@
     /* 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++;
Index: snmp//lib/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/lib/current/ChangeLog,v
retrieving revision 1.10
diff -u -r1.10 ChangeLog
--- snmp//lib/current/ChangeLog	24 Feb 2003 14:31:38 -0000	1.10
+++ snmp//lib/current/ChangeLog	26 Feb 2003 08:40:21 -0000
@@ -1,3 +1,9 @@
+2003-02-26  Andrew Lunn  <andrew dot lunn at ascom dot ch>
+
+	* include/config.h: Make random use rand on FreeBSD.
+	* include/system.h: For FreeBSD include param.h so we get the aliases.
+	#Undefine printf so stdio.h will compile. printf is not used anywhere.
+
 2003-02-24  Jonathan Larmour  <jifl at eCosCentric dot com>
 
 	* cdl/snmplib.cdl: Add doc link.
Index: snmp//lib/current/include/config.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/lib/current/include/config.h,v
retrieving revision 1.8
diff -u -r1.8 config.h
--- snmp//lib/current/include/config.h	3 Feb 2003 16:34:46 -0000	1.8
+++ snmp//lib/current/include/config.h	26 Feb 2003 08:40:22 -0000
@@ -1157,7 +1157,14 @@
 #define srandom(s) srand48(s)
 #else
 #ifdef HAVE_RAND
+#ifdef __ECOS
+#include <pkgconf/system.h>
+#ifndef CYGPKG_NET_FREEBSD_STACK
+
 #define random rand
+
+#endif //CYGPKG_NET_FREEBSD_STACK
+#endif // __ECOS
 #define srandom(s) srand(s)
 #endif
 #endif
@@ -1221,7 +1228,7 @@
 #define HAVE_SYS_FILE_H                         0
 #define HAVE_KSTAT_H                            0
 #define HAVE_SYS_UN_H                           0
-#define SOCK_MAXADDRLEN                         0
+#define SOCK_MAXADDRLEN                         255
 #define HAVE_SYS_STREAM_H                       0
 #define HAVE_INET_MIB2_H                        0
 #define HAVE_GETPID                             0
Index: snmp//lib/current/include/system.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/lib/current/include/system.h,v
retrieving revision 1.3
diff -u -r1.3 system.h
--- snmp//lib/current/include/system.h	23 May 2002 23:08:18 -0000	1.3
+++ snmp//lib/current/include/system.h	26 Feb 2003 08:40:22 -0000
@@ -189,6 +189,14 @@
 int setenv (const char *, const char *, int);
 #endif
 
+#ifdef __ECOS
+#include <pkgconf/system.h>
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include <sys/param.h>
+#undef printf
+#endif //CYGPKG_NET_FREEBSD_STACK
+#endif // __ECOS
+
 #if TIME_WITH_SYS_TIME	
 #	ifdef WIN32
 #		include <sys/timeb.h>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]