Thomas Anders wrote:
> Dave Shield wrote:
>> I'm attaching a patch that seems to give the correct results on *BSD and
>> Linux, but I don't really like it....
>
> Neither do I, but it's working fine on any system I could test
> (Solaris/SPARC 10, Solaris/x86 9, Linux/x86, Linux/x86_64,
> Linux/openpower) at least. Robert tested OpenBSD 3.8 and it worked, too.
> So unless we can come up with a polished version, I think it should go in.
Here's a somewhat polished version. Tested on Linux/x86, Solaris/SPARC
and Solaris/x86. Let me know what you think and how it works on *BSD (as
root).
+Thomas
--
Thomas Anders (thomas.anders at blue-cable.de)
Index: agent/mibgroup/mibII/udpTable.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/udpTable.c,v
retrieving revision 5.18.2.4
diff -u -r5.18.2.4 udpTable.c
--- agent/mibgroup/mibII/udpTable.c 23 Jun 2006 16:06:32 -0000 5.18.2.4
+++ agent/mibgroup/mibII/udpTable.c 26 Jun 2006 21:52:06 -0000
@@ -105,15 +105,17 @@
#endif
#ifdef UDP_ADDRESSES_IN_HOST_ORDER
-#define CONVERT_ADDRESS(x) x
+#define UDP_ADDRESS_TO_HOST_ORDER(x) x
+#define UDP_ADDRESS_TO_NETWORK_ORDER(x) htonl(x)
#else
-#define CONVERT_ADDRESS(x) ntohl(x)
+#define UDP_ADDRESS_TO_HOST_ORDER(x) ntohl(x)
+#define UDP_ADDRESS_TO_NETWORK_ORDER(x) x
#endif
#ifdef UDP_PORTS_IN_HOST_ORDER
-#define CONVERT_PORT(x) x
+#define UDP_PORT_TO_HOST_ORDER(x) x
#else
-#define CONVERT_PORT(x) ntohs(x)
+#define UDP_PORT_TO_HOST_ORDER(x) ntohs(x)
#endif
@@ -213,14 +215,14 @@
(u_char*)&addr,
sizeof(addr));
#else
- addr = CONVERT_ADDRESS(entry->UDPTABLE_LOCALADDRESS);
+ addr = UDP_ADDRESS_TO_HOST_ORDER(entry->UDPTABLE_LOCALADDRESS);
snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,
(u_char *)&addr,
sizeof(addr));
#endif
break;
case UDPLOCALPORT:
- port = CONVERT_PORT((u_short)entry->UDPTABLE_LOCALPORT);
+ port = UDP_PORT_TO_HOST_ORDER((u_short)entry->UDPTABLE_LOCALPORT);
snmp_set_var_typed_value(requestvb, ASN_INTEGER,
(u_char *)&port, sizeof(port));
break;
@@ -293,10 +295,15 @@
/*
* Set up the indexing for the specified row...
*/
- port = CONVERT_ADDRESS((u_long)udp_head[i].UDPTABLE_LOCALADDRESS);
+#if defined (WIN32) || defined (cygwin)
+ port = ntohl((u_long)udp_head[i].UDPTABLE_LOCALADDRESS);
snmp_set_var_value(index, (u_char *)&port,
sizeof(udp_head[i].UDPTABLE_LOCALADDRESS));
- port = CONVERT_PORT((u_short)udp_head[i].UDPTABLE_LOCALPORT);
+#else
+ snmp_set_var_value(index, (u_char *)&udp_head[i].UDPTABLE_LOCALADDRESS,
+ sizeof(udp_head[i].UDPTABLE_LOCALADDRESS));
+#endif
+ port = UDP_PORT_TO_HOST_ORDER((u_short)udp_head[i].UDPTABLE_LOCALPORT);
snmp_set_var_value(index->next_variable,
(u_char*)&port, sizeof(port));
/*
@@ -353,7 +360,7 @@
netsnmp_iterator_info *data)
{
UDPTABLE_ENTRY_TYPE *entry = (UDPTABLE_ENTRY_TYPE *)*loop_context;
- long port;
+ long port, addr;
if (!entry)
return NULL;
@@ -366,10 +373,11 @@
(u_char*)&IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr),
sizeof(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr)));
#else
- snmp_set_var_value(index, (u_char*)&entry->UDPTABLE_LOCALADDRESS,
+ addr = UDP_ADDRESS_TO_NETWORK_ORDER((u_long)entry->UDPTABLE_LOCALADDRESS);
+ snmp_set_var_value(index, (u_char *)&addr,
sizeof(entry->UDPTABLE_LOCALADDRESS));
#endif
- port = CONVERT_PORT(entry->UDPTABLE_LOCALPORT);
+ port = UDP_PORT_TO_HOST_ORDER(entry->UDPTABLE_LOCALPORT);
snmp_set_var_value(index->next_variable,
(u_char*)&port, sizeof(port));
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