<snip/>

> Off-list pedantry:

:-)


> Leading zeroes mean octal in C source code, not elsewhere. You don't
> happen to live in or near Boston, do you? If you do, is your zip code
> octal? ;)

No, because those are defined as digits (and in non IT world, digits are
decimal digits) - see the USPS DMM at http://pe.usps.gov/.  That's clear
from many places, such as L002 and A020.


> Anyway, when sorting IP addresses it's generally a good idea to call
> sprintf( "%03d.%03d.%03d.%03d", ... ) and then strcmp on the result.
> That way, the sort conforms to user expectations.

<snip/>

Read the standards.  It doesn't say anything more than a 32bit address.
However, most RFCs are specified in C, in fact in early days a C reference
implementation was required - thus C-isms invade most RFC/STD docs.

Where it gets really, really ugly is that a lot of RFCs (e.g. 820) show the
leading zeros... and a lot of code doesn't like them.

Try it

02/19/04 08:05:39 dns www.ntop.org
Canonical name: faeta.unipi.it
Aliases:
  www.ntop.org
  www-serra.unipi.it
Addresses:
  131.114.21.9

If you use the numeric address, you would expect to arrive at the root page
for the Pisa Hosting service, right?

So http://131.114.025.011
vs
   http://131.114.21.9
vs
   http://131.114.021.009

If you're right the last two should take you to Pisa and the 1st to
somewhere else.  If I'm right, then the 1st and 2nd are Pisa and the third
is somewhere else...

SamSpade makes the translation explicit:

02/19/04 08:12:20 IP block 131.114.025.011
Address 131.114.025.011 is 131.114.21.9
Trying 131.114.21.9 at ARIN
Trying 131.114.21 at ARIN

Real world?  Not so simple...

IE6 sends you to the same site for all of them (which is correct under
neither scenario), Netscape 4.xx doesn't... (Netscape 7 mirrors IE's
behavior)

Microsoft obviously believes it's not octal -
http://support.microsoft.com/default.aspx?scid=kb;en-us;q115388 - but that's
also not the way many of their products are coded.

However, flip over to Linux - Mozilla and ilk follows your expected behavior
(probably because all use the basic Linux resolution functions).

man gethostbyname

...
       The gethostbyname() function returns a structure of  type  hostent
for
       the  given  host  name.   Here  name  is either a host name, or an
IPv4
       address in standard dot notation, or an IPv6 address in colon (and
pos-
       sibly  dot)  notation.
...

What ever 'standard dot notation' is...  want to follow that one?

http://www.opengroup.org/onlinepubs/007908799/xns/inet_addr.html

All numbers supplied as parts in dot notation may be decimal, octal, or
hexadecimal, as specified in the ISO C standard (that is, a leading 0x or 0X
implies hexadecimal; otherwise, a leading 0 implies octal; otherwise, the
number is interpreted as decimal).



Realistically, however, it's not a right vs. wrong argument, it's a reality
check that bounces.  Given the range of browsers we encounter - and their
different behaviors - putting the leading 0s in is just not safe.  If you
use the %03d construct for searching, you have to remove the leading 0s when
you display it AND when you use it to create a host link, or you won't end
up at the expected site (and at different sites from different browsers!!!)

That becomes a lot of work, since there are almost 200 references to
hostSymIpAddress.  Realistically, it may be better for the sort to ignore
the hostSymIpAddress field and use a planned sequence of address sorts i.e.
character host name 1st, then ip then MAC, with the added proviso that a
hostname is ALWAYS < and IP# < MAC.  Which is what I'm working on.

-----Burton





_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop

Reply via email to