Re: IP address spec ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Seems linux interprets 010 in octal.

  Yes, simple example ...

#include <stdio.h>
#include <netdb.h>

int
main(int argc, char *argv[])
{
    struct hostent *host = gethostbyname("212.071.138.006");
    unsigned long int addr = *((unsigned long int *)host->h_addr);

    printf("%d.%d.%d.%d\n",
        (addr & 0x000000FF),
        (addr & 0x0000FF00) >> 8,
        (addr & 0x00FF0000) >> 16,
        (addr & 0xFF000000) >> 24);

    return 0;
}

$gcc test.c -o t
$./t
212.57.138.6
$

  and 212.57.138.6 != 212.71.138.6 ...  071 = 57

  Yes, I know this, because if you have number with leading zero it's octal
number and linux works fine in this way, but there are some programs which
are using 010.000.000.001 as decimal numbers, so it's 10.0.0.1 ==
010.000.000.001.
  Now, I don't know what is true. In my previous e-mail there is an example
from rfc with leading zeroes and when I try dotted format with leading zeroes
linux use this numbers as octal one.

Best regards,
  Robert

-- 
   _
  |-|  __      Robert Vojta <vojta-at-ipex.cz>          -= Oo.oO =-
  |=| [Ll]     IPEX, s.r.o.
  "^" ====`o

Attachment: pgp00024.pgp
Description: PGP signature


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux