salut Stéphane,

> % python3 -c "import sys, ipaddress; addr = 
> ipaddress.ip_address(sys.argv[1]); print(int(addr))" 192.0.2.1
> 3221225985

ne faudrait-il pas tenir compte de l'endianisme? pour ma part j'ai:

/tmp/ipv4int 192.0.2.1
16908480 192.0.2.1

en executant ce code:

// vi: noet
#include <stdio.h>
#include <arpa/inet.h>

int
main (int argc, char ** argv ) {
        struct in_addr addr;
        for (uint8_t i=1; i<argc; i++) {
                inet_pton(AF_INET, argv[i], &addr);
                printf( "%u %s\n", addr.s_addr, inet_ntoa(addr) );
        }
}

'soir
marc

Répondre à