On Thu, Oct 03, 2002 at 04:00:26PM +0300, Artem Okounev wrote: > To my great surprise I found out that: > ping 192.168.0.26, > ping 192.168.0.032, > and even ping 192.168.0.0x1a - all correct commands doing > the same thing: pinging 192.168.0.26.
Yep. > That was my problem. IP addresses was stored in text file in > the form of 192.168.000.032, and after issuing command: arp > - -s 192.168.000.032 xx:xx:xx:xx:xx:xx (which actually was > treated as arp -s 192.168.0.26) I had a great headache. That should be pretty easy to fix in your script. > After some investigation I found that both ping and arp use > inet_aton() libc call to interpret their command arguments > into network format. Futher, inet_aton() uses > strtoul(c,&endptr, 0) for each octet in IP address to > convert string representation of number to unsigned long. > > Why not to use strtoul(x, x, 10) and fix aforementioned > confusing thing with arp/ping/...? Does anybody write > command arguments to ping using octal or hex format :)? > > I am not hacker. Just curious. This is a feature not a bug since it is documented in inet_aton(3), All numbers supplied as ``parts'' in a `.' notation may be decimal, octal, or hexadecimal, as specified in the C language (i.e., a leading 0x or 0X implies hexadecimal; otherwise, a leading 0 implies octal; other- wise, the number is interpreted as decimal). People use this notation all of the time, # ifconfig if0 172.16.1.10 netmask 0xffffff00 ^^^^^^^^^^ -- Crist J. Clark | [EMAIL PROTECTED] | [EMAIL PROTECTED] http://people.freebsd.org/~cjc/ | [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message