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

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

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

best regards
--
Peder Chr. Nørgaard             Senior System Developer, M. Sc.
Ericsson Denmark A/S, Telebit Division
Skanderborgvej 232              tel: +45 30 91 84 31
DK-8260 Viby J, Denmark         fax: +45 89 38 51 01
         e-mail: [EMAIL PROTECTED]
(old e-mail 2000-2003: [EMAIL PROTECTED])
          (old e-mail 1992-2000: [EMAIL PROTECTED])
----------------------------------------------------------------
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.
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