>>>>> On Fri, 23 Jun 2006 11:49:43 +0200, Thomas Anders <[EMAIL PROTECTED]> 
>>>>> said:

Thomas> Thanks. I've finally applied the fix to all affected branches
Thomas> (5.2.x and up).

New patch based on IRC discussion:

Current positive votes:  tanders, hardaker, dts12

Index: agent/mibgroup/mibII/udpTable.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/udpTable.c,v
retrieving revision 5.22
diff -u -p -r5.22 udpTable.c
--- agent/mibgroup/mibII/udpTable.c     23 Jun 2006 09:47:06 -0000      5.22
+++ agent/mibgroup/mibII/udpTable.c     23 Jun 2006 15:51:09 -0000
@@ -104,6 +104,19 @@ int                      udp_size  = 0;    
 #define UDP_STATS_CACHE_TIMEOUT        MIB_STATS_CACHE_TIMEOUT
 #endif
 
+#ifdef UDP_ADDRESSES_IN_HOST_ORDER
+#define CONVERT_ADDRESS(x) x
+#else
+#define CONVERT_ADDRESS(x) ntohl(x)
+#endif
+
+#ifdef UDP_PORTS_IN_HOST_ORDER
+#define CONVERT_PORT(x) x
+#else
+#define CONVERT_PORT(x) ntohs(x)
+#endif
+
+
 oid             udpTable_oid[] = { SNMP_OID_MIB2, 7, 5 };
 
 void
@@ -200,27 +213,14 @@ udpTable_handler(netsnmp_mib_handler    
                                          (u_char*)&addr,
                                          sizeof(addr));
 #else
-#ifdef solaris2
-                /* solaris x86 already stores stuff in host order;
-                   non x86 is already big endian host order as well */
-                addr = entry->UDPTABLE_LOCALADDRESS;
-#else
-                addr = ntohl(entry->UDPTABLE_LOCALADDRESS);
-#endif
+                addr = CONVERT_ADDRESS(entry->UDPTABLE_LOCALADDRESS);
                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,
                                          (u_char *)&addr,
                                          sizeof(addr));
 #endif
                 break;
             case UDPLOCALPORT:
-#ifdef solaris2
-                /*
-                 * Solaris udpLocalPort is in host byte order
-                 */
-                port = (u_short)entry->UDPTABLE_LOCALPORT;
-#else
-                port = ntohs((u_short)entry->UDPTABLE_LOCALPORT);
-#endif
+                port = CONVERT_PORT((u_short)entry->UDPTABLE_LOCALPORT);
                snmp_set_var_typed_value(requestvb, ASN_INTEGER,
                                  (u_char *)&port, sizeof(port));
                 break;
@@ -293,15 +293,10 @@ udpTable_next_entry( void **loop_context
     /*
      * Set up the indexing for the specified row...
      */
-#if defined (WIN32) || defined (cygwin)
-    port = ntohl((u_long)udp_head[i].UDPTABLE_LOCALADDRESS);
+    port = CONVERT_ADDRESS((u_long)udp_head[i].UDPTABLE_LOCALADDRESS);
     snmp_set_var_value(index, (u_char *)&port,
                                   sizeof(udp_head[i].UDPTABLE_LOCALADDRESS));
-#else
-    snmp_set_var_value(index, (u_char *)&udp_head[i].UDPTABLE_LOCALADDRESS,
-                                  sizeof(udp_head[i].UDPTABLE_LOCALADDRESS));
-#endif 
-    port = ntohs((u_short)udp_head[i].UDPTABLE_LOCALPORT);
+    port = CONVERT_PORT((u_short)udp_head[i].UDPTABLE_LOCALPORT);
     snmp_set_var_value(index->next_variable,
                                (u_char*)&port, sizeof(port));
     /*
@@ -374,14 +369,7 @@ udpTable_next_entry( void **loop_context
     snmp_set_var_value(index, (u_char*)&entry->UDPTABLE_LOCALADDRESS,
                                  sizeof(entry->UDPTABLE_LOCALADDRESS));
 #endif
-#ifdef solaris2
-    /*
-     * Solaris udpLocalPort is in host byte order
-     */
-    port = entry->UDPTABLE_LOCALPORT;
-#else
-    port = ntohs(entry->UDPTABLE_LOCALPORT);
-#endif
+    port = CONVERT_PORT(entry->UDPTABLE_LOCALPORT);
     snmp_set_var_value(index->next_variable,
                                (u_char*)&port, sizeof(port));
 
Index: include/net-snmp/system/cygwin.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/system/cygwin.h,v
retrieving revision 5.3
diff -u -p -r5.3 cygwin.h
--- include/net-snmp/system/cygwin.h    20 Apr 2004 19:09:46 -0000      5.3
+++ include/net-snmp/system/cygwin.h    23 Jun 2006 15:51:09 -0000
@@ -11,3 +11,6 @@
 #undef bsdlike
 #undef MBSTAT_SYMBOL
 #undef TOTAL_MEMORY_SYMBOL
+
+#define UDP_ADDRESSES_IN_HOST_ORDER 1
+#define UDP_PORTS_IN_HOST_ORDER 1
Index: include/net-snmp/system/freebsd.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/system/freebsd.h,v
retrieving revision 5.0
diff -u -p -r5.0 freebsd.h
--- include/net-snmp/system/freebsd.h   20 Apr 2002 07:30:12 -0000      5.0
+++ include/net-snmp/system/freebsd.h   23 Jun 2006 15:51:09 -0000
@@ -19,3 +19,5 @@
 #else
 #define UTMP_FILE "/var/run/utmp"
 #endif
+
+#define UDP_ADDRESSES_IN_HOST_ORDER 1
Index: include/net-snmp/system/solaris.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/system/solaris.h,v
retrieving revision 5.1
diff -u -p -r5.1 solaris.h
--- include/net-snmp/system/solaris.h   12 Feb 2005 13:32:46 -0000      5.1
+++ include/net-snmp/system/solaris.h   23 Jun 2006 15:51:09 -0000
@@ -21,6 +21,9 @@
 #undef TOTAL_MEMORY_SYMBOL
 #undef MBSTAT_SYMBOL
 
+#define UDP_ADDRESSES_IN_HOST_ORDER 1
+#define UDP_PORTS_IN_HOST_ORDER 1
+
 /* get some required prototypes (strtok_r) from include files */
 #define __EXTENSIONS__
 

-- 
Wes Hardaker
Sparta, Inc.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to