Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: udpTable byte order issues (again)

2 views
Skip to first unread message

Peder Chr. Norgaard

unread,
Jun 23, 2006, 3:52:34 AM6/23/06
to

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

---1613425987-1058667949-1151048298=:22637
Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1; FORMAT=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-ID: <Pine.LNX.4.64.06...@nellike.ted.dk.eu.ericsson.se>

On Thu, 22 Jun 2006, Wes Hardaker wrote:

>
> It's not that simple, I'm afraid. Much of the time it's also how the
> structures used by the kernel store them. I'm pretty sure that some
> systems are storing them in host order and others in network order,
> which means you sometimes need to apply htonl and other times you
> don't. That's what's truly broken.
>
> But you're right, we should have a policy about how things are stored.
>
> I say host-order. Or maybe network.

We had this discussion in October 2005, thread was named "Endian - ness=20
issue". I just wish to repeat the recommendation I made at that time:

The policy should be to store IPv4 address as u_char[4].

Forget about host-order vs network-order. Both are artifacts of the=20
misbegotten idea about storing IPv4 address as integer. An IPv4 address=20
is a sequence of 4 unsigned bytes: store it as such and you will localize=
=20
the ordering problems to the (very few) places where you have to interact=
=20
with interfaces that use this misbegotten representation. One of these,=20
unfortunately, is the classic socket interface; as this is a widely
known interface it has unfortunately added to the misconception that=20
this is "how the kernel store them". It isn't: it is just "how the=20
kernel present them through the socket interface".

Coding details and further arguments of my recommendation can be found in=
=20
the mail archive.

(Actually, in the deepest analysis, because of the way IP routing works,=20
an IPv4 address is best described as a sequence of 32 bits - but there=20
seems be a consensus among processor vendors about which bits are first in=
=20
a byte, so the "sequence of bytes" model does not introduce coding=20
problems, as does the "integer" model).

best regards
--
Peder Chr. N=F8rgaard =09Senior System Developer, M. Sc.
Ericsson Denmark A/S, Telebit Division
Skanderborgvej 232 =09tel: +45 30 91 84 31
DK-8260 Viby J, Denmark fax: +45 89 38 51 01
e-mail: Peder.Chr...@ericsson.com
(old e-mail 2000-2003: Peder.C....@ted.ericsson.se)
(old e-mail 1992-2000: p...@tbit.dk)
----------------------------------------------------------------
This communication is confidential and intended solely for the
addressee(s). Any unauthorized review, use, disclosure or distribution
is prohibited. If you believe this message has been sent to you in
error, please notify the sender by replying to this transmission and
delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption,
interruption, unauthorized amendment, tampering and viruses, and we
only send and receive e-mails on the basis that we are not liable for
any such corruption, interception, amendment, tampering or viruses or
any consequences thereof.

---1613425987-1058667949-1151048298=:22637
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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
---1613425987-1058667949-1151048298=:22637
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-coders mailing list
Net-snm...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

---1613425987-1058667949-1151048298=:22637--

Thomas Anders

unread,
Jun 23, 2006, 4:37:19 AM6/23/06
to
Wes Hardaker wrote:
> I'll vote for this to be included in 5.3.1 (the next rc release of
> which I'll push tomorrow; [...]).

We'd need at least one more vote to make this happen. Anyone?


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

"Silence is *not* sexy when it comes to voting."

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

Dave Shield

unread,
Jun 23, 2006, 5:18:51 AM6/23/06
to
Thomas Anders wrote:

>Wes Hardaker wrote:
>
>
>>I'll vote for this to be included in 5.3.1 (the next rc release of
>>which I'll push tomorrow; [...]).
>>
>>
>
>We'd need at least one more vote to make this happen. Anyone?
>

If you're confident that this fixes the immediate problem, then I'd say
go ahead.
But I'm a little confused - the index values on your "fixed" version
(Solaris/x86)
still seem to be wrong:

> After my proposed patch:
> UDP-MIB::udpLocalAddress.1.0.0.127.123 = IpAddress: 127.0.0.1
> UDP-MIB::udpLocalAddress.1.0.0.127.8765 = IpAddress: 127.0.0.1

The value is as expected, but the index is still reversed.
OK - maybe that doesn't matter too much, since no-one ever
looks at index values :-). But my gut feeling is that it's
probably worth trying to nail this before 5.3.1 if we can.


Dave

Thomas Anders

unread,
Jun 23, 2006, 5:51:05 AM6/23/06
to
Dave Shield wrote:
> If you're confident that this fixes the immediate problem, then I'd say
> go ahead.

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

> But I'm a little confused - the index values on your "fixed" version
> (Solaris/x86)
> still seem to be wrong:
>
>> After my proposed patch:
>> UDP-MIB::udpLocalAddress.1.0.0.127.123 = IpAddress: 127.0.0.1
>> UDP-MIB::udpLocalAddress.1.0.0.127.8765 = IpAddress: 127.0.0.1
>
> The value is as expected, but the index is still reversed.
> OK - maybe that doesn't matter too much, since no-one ever
> looks at index values :-). But my gut feeling is that it's
> probably worth trying to nail this before 5.3.1 if we can.

This additional problem has been there for a very long time (probably
always) on Solaris/x86. It'll likely be a small (one-line plus #ifdef)
patch also, but I was trying to keep things simple and just fix the
immediate problem (affecting *all* platforms) at hand.

Anyone feel free to come up with an additional patch and post here for
review.


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

Using Tomcat but need to do more? Need to support web services, security?

Wes Hardaker

unread,
Jun 23, 2006, 12:02:00 PM6/23/06
to
>>>>> On Fri, 23 Jun 2006 11:49:43 +0200, Thomas Anders <thomas...@blue-cable.de> 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.

Wes Hardaker

unread,
Jun 23, 2006, 12:03:44 PM6/23/06
to
>>>>> On Fri, 23 Jun 2006 09:51:10 +0200 (CEST), "Peder Chr. Norgaard" <Peder.Chr...@ericsson.com> said:

Peder> The policy should be to store IPv4 address as u_char[4].

I agree, that's the ideal thing to do.

Peder> Forget about host-order vs network-order.

But you can't do that. Unfortunately, frequently the kernel
structures themselves store things in one form or another. We *can't*
just change our code to do one thing and not care about what comes out
of the kernel.

D.T.S...@csc.liv.ac.uk

unread,
Jun 23, 2006, 2:27:21 PM6/23/06
to
Status report:

Testing was incomplete (due to arriving into Manchester before I'd
finished!), but results so far are as follows:

Linux:
udpTable: reported correctly
tcpTable: reported correctly

FreeBSD:
udpTable: IP value reported correctly, index reversed
tcpTable: reported correctly
[agent requires root access]

NetBSD:
udpTable: IP value and index both reversed
tcpTable: bogus contents
[agent requires root access]

OpenBSD:
udpTable: IP value and index both reversed
tcpTable: bogus contents
[agent requires root access]


I'll start looking at Windows-based behaviour after we've eaten....
To think about: which of these problems should be addressed for 5.3.1,
and which left for a later releasee?

Dave

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Thomas Anders

unread,
Jun 24, 2006, 10:05:58 AM6/24/06
to
D.T.S...@csc.liv.ac.uk wrote:
> FreeBSD:
> udpTable: IP value reported correctly, index reversed
> tcpTable: reported correctly
> [agent requires root access]

Requires root access? I can access both tables as non-root just fine on
FreeBSD 5.4 (w/ "snmpd -r").

> NetBSD:
> udpTable: IP value and index both reversed
> tcpTable: bogus contents
> [agent requires root access]
>
> OpenBSD:
> udpTable: IP value and index both reversed
> tcpTable: bogus contents
> [agent requires root access]

Can you please add

#define UDP_ADDRESSES_IN_HOST_ORDER 1

to include/net-snmp/system/openbsd.h and
include/net-snmp/system/netbsd.h and try again? This should fix the IP
values (but not the index).

At the end, we're still left with the udpTable indices being reversed on
at least (Open|Net|Free)BSD and Solaris/x86 (but not Solaris/SPARC). Ideas?


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

Using Tomcat but need to do more? Need to support web services, security?

Dave Shield

unread,
Jun 26, 2006, 11:07:22 AM6/26/06
to
This is a multi-part message in MIME format.
--------------000709040103070409080801
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Thomas Anders wrote:

>D.T.S...@csc.liv.ac.uk wrote:
>
>
>> FreeBSD:
>> udpTable: IP value reported correctly, index reversed
>> tcpTable: reported correctly
>> [agent requires root access]
>>
>>
>
>Requires root access? I can access both tables as non-root just fine on
>FreeBSD 5.4 (w/ "snmpd -r").
>
>

Sorry - you're correct. This works OK with FreeBSD.
It's just NetBSD and OpenBSD that require full root access.

>> NetBSD:
>> udpTable: IP value and index both reversed
>> tcpTable: bogus contents
>> [agent requires root access]
>>
>> OpenBSD:
>> udpTable: IP value and index both reversed
>> tcpTable: bogus contents
>> [agent requires root access]
>>
>>
>
>Can you please add
>
>#define UDP_ADDRESSES_IN_HOST_ORDER 1
>
>to include/net-snmp/system/openbsd.h and
>include/net-snmp/system/netbsd.h and try again?
>

Adding this line to 'include/net-snmp/system/netbsd.h'
is sufficient to fix the value on both systems, as expected.
(Note that openbsd.h explicitly includes netbsd.h)

>At the end, we're still left with the udpTable indices being reversed on
>at least (Open|Net|Free)BSD and Solaris/x86 (but not Solaris/SPARC). Ideas?
>
>

I've been comparing the UDP table with the equivalent code in the TCP table,
which seems to be working correctly. I thought I'd got a patch that
fixed the
problem on *BSD systems, but it breaks Linux :-(
I'm attaching a patch that seems to give the correct results on *BSD and
Linux, but I don't really like it....

Dave

--------------000709040103070409080801
Content-Type: text/x-patch;
name="udpTable.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="udpTable.patch"

Index: udpTable.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/udpTable.c,v
retrieving revision 5.23
diff -u -r5.23 udpTable.c
--- udpTable.c 23 Jun 2006 16:06:56 -0000 5.23
+++ udpTable.c 26 Jun 2006 13:48:09 -0000
@@ -106,8 +106,10 @@

#ifdef UDP_ADDRESSES_IN_HOST_ORDER
#define CONVERT_ADDRESS(x) x
+#define TREVNOC_ADDRESS(x) ntohl(x)
#else
#define CONVERT_ADDRESS(x) ntohl(x)
+#define TREVNOC_ADDRESS(x) x
#endif

#ifdef UDP_PORTS_IN_HOST_ORDER
@@ -293,9 +295,14 @@


/*
* 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));

+#else
+ snmp_set_var_value(index, (u_char *)&udp_head[i].UDPTABLE_LOCALADDRESS,
+ sizeof(udp_head[i].UDPTABLE_LOCALADDRESS));
+#endif


port = CONVERT_PORT((u_short)udp_head[i].UDPTABLE_LOCALPORT);
snmp_set_var_value(index->next_variable,
(u_char*)&port, sizeof(port));

@@ -366,7 +373,8 @@
(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,
+ port = TREVNOC_ADDRESS((u_long)entry->UDPTABLE_LOCALADDRESS);
+ snmp_set_var_value(index, (u_char *)&port,
sizeof(entry->UDPTABLE_LOCALADDRESS));
#endif
port = CONVERT_PORT(entry->UDPTABLE_LOCALPORT);

--------------000709040103070409080801


Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--------------000709040103070409080801


Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________

--------------000709040103070409080801--

Thomas Anders

unread,
Jun 26, 2006, 12:33:01 PM6/26/06
to
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.

BTW, I've already committed the related change to netbsd.h based on
votes on IRC.


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

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

Thomas Anders

unread,
Jun 26, 2006, 7:16:39 PM6/26/06
to
This is a multi-part message in MIME format.
--------------010303000900020302040403
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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)

--------------010303000900020302040403
Content-Type: text/x-patch;
name="net-snmp-5.3.1.rc1-udpTable3.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="net-snmp-5.3.1.rc1-udpTable3.diff"

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));

--------------010303000900020302040403


Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--------------010303000900020302040403


Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________

--------------010303000900020302040403--

Robert Story

unread,
Jun 27, 2006, 9:31:12 AM6/27/06
to
On Tue, 27 Jun 2006 01:14:14 +0200 Thomas wrote:
TA> Thomas Anders wrote:
TA> > Neither do I, but it's working fine on any system I could test
TA> > (Solaris/SPARC 10, Solaris/x86 9, Linux/x86, Linux/x86_64,
TA> > Linux/openpower) at least. Robert tested OpenBSD 3.8 and it worked, too.
TA> > So unless we can come up with a polished version, I think it should go
TA> > in.
TA>
TA> Here's a somewhat polished version. Tested on Linux/x86, Solaris/SPARC
TA> and Solaris/x86. Let me know what you think and how it works on *BSD (as
TA> root).

OpenBSD still works fine...

--
Robert Story; NET-SNMP Junkie
Support: <http://www.net-snmp.org/> <irc://irc.freenode.net/#net-snmp>
Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-coders>

You are lost in a twisty maze of little standards, all different.

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

Wes Hardaker

unread,
Jun 27, 2006, 10:07:27 AM6/27/06
to
>>>>> On Tue, 27 Jun 2006 01:14:14 +0200, Thomas Anders <thomas...@blue-cable.de> said:

Thomas> Here's a somewhat polished version. Tested on Linux/x86,
Thomas> Solaris/SPARC and Solaris/x86. Let me know what you think and
Thomas> how it works on *BSD (as root).

It gets my vote.


--
Wes Hardaker
Sparta, Inc.

Using Tomcat but need to do more? Need to support web services, security?

Dave Shield

unread,
Jun 27, 2006, 11:08:40 AM6/27/06
to
Thomas Anders wrote:

>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).
>
>
Looks good on Free, Net and OpenBSD.
I'd say you've got the go-ahead to put this in place.

Dave

Thomas Anders

unread,
Jun 27, 2006, 12:23:05 PM6/27/06
to
Dave Shield wrote:

> Thomas Anders wrote:
>
>> Can you please add
>>
>> #define UDP_ADDRESSES_IN_HOST_ORDER 1
>>
>> to include/net-snmp/system/openbsd.h and
>> include/net-snmp/system/netbsd.h and try again? This should fix the IP
>> values (but not the index).
>>
>>
> Note that adding this same define to 'win32/net-snmp/net-snmp-config.h'
> (plus your latest udpTable.c patch) gives the correct results - both
> indexes
> and values - with a MSVC++ build on x86 kit.

And without this define both indices and values have been wrong? If so,
we should no doubt add it.


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

Using Tomcat but need to do more? Need to support web services, security?

Dave Shield

unread,
Jun 28, 2006, 6:02:41 AM6/28/06
to
Thomas Anders wrote:

>Dave Shield wrote:
>
>
>>Note that adding this same define to 'win32/net-snmp/net-snmp-config.h'
>>(plus your latest udpTable.c patch) gives the correct results - both
>>indexes and values - with a MSVC++ build on x86 kit.
>>
>>
>
>And without this define both indices and values have been wrong?
>

Without this define, the values were wrong.
Without the udpTable.c patch, the indexes were wrong.

Dave

Thomas Anders

unread,
Jun 28, 2006, 6:08:15 AM6/28/06
to
Dave Shield wrote:
> Thomas Anders wrote:
>
>> Dave Shield wrote:
>>
>>
>>> Note that adding this same define to 'win32/net-snmp/net-snmp-config.h'
>>> (plus your latest udpTable.c patch) gives the correct results - both
>>> indexes and values - with a MSVC++ build on x86 kit.
>>>
>>>
>> And without this define both indices and values have been wrong?
>>
> Without this define, the values were wrong.
> Without the udpTable.c patch, the indexes were wrong.

Then you have my vote to commit.


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

Using Tomcat but need to do more? Need to support web services, security?

Dave Shield

unread,
Jun 28, 2006, 10:13:38 AM6/28/06
to

>>>Dave Shield wrote:
>>>
>>>>Note that adding this same define to 'win32/net-snmp/net-snmp-config.h'
>>>>(plus your latest udpTable.c patch) gives the correct results - both
>>>>indexes and values - with a MSVC++ build on x86 kit.
>>>>
The same holds for MinGW and Cygwin compilations as well.
Defining UDP_ADDRESSES_IN_HOST_ORDER in the appropriate
header files, and applying Thomas' udpTable.c patch - then both indexes
and values are displayed correctly.

Is it OK to add these definitions as well?

Dave

Thomas Anders

unread,
Jun 28, 2006, 10:45:04 AM6/28/06
to
Dave Shield wrote:
> The same holds for MinGW and Cygwin compilations as well.
> Defining UDP_ADDRESSES_IN_HOST_ORDER in the appropriate
> header files, and applying Thomas' udpTable.c patch - then both indexes
> and values are displayed correctly.
>
> Is it OK to add these definitions as well?

+1


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)

Using Tomcat but need to do more? Need to support web services, security?

Wes Hardaker

unread,
Jun 28, 2006, 12:30:30 PM6/28/06
to
>>>>> On Wed, 28 Jun 2006 16:43:29 +0200, Thomas Anders <thomas...@blue-cable.de> said:

>> Is it OK to add these definitions as well?

Thomas> +1

My vote too. Which should make it the 3 total.


--
Wes Hardaker
Sparta, Inc.

Using Tomcat but need to do more? Need to support web services, security?

0 new messages