Questions tagged [inet-aton]

C language programming: inet_aton() converts an Internet host address from the IPv4 numbers-and-dots notation into binary form (in network byte order). The dotted address can be specified in decimal, octal (with a leading 0), or hexadecimal, with a leading 0X).

20 questions
9
votes
2 answers

Find available IP range in mysql table

I have following sql. Works fine for searching IPs. But I also would like to be able so search select * from table where (INET_ATON(ip) BETWEEN INET_ATON('10.12.77.1') AND INET_ATON('10.12.77.10') ) limit 30 results is…
7
votes
1 answer

inet_aton normalization of a IPv4 address

doesn't inet_aton suppose to normalize the dot version of the internet address? why do I get different output values for the example below? int main(){ char USER_IP[16] = "192.168.002.025"; char USER_IP2[16] = "192.168.2.25"; struct…
sven
  • 1,101
  • 7
  • 21
  • 44
7
votes
1 answer

inet_aton converts 010.000.000.001 wrong?

I am having problem with inet_aton to convert a network address. The code below works fine to convert the address 10.0.0.1 char *x1; struct sockaddr_in si_other; inet_aton("10.0.0.1", &si_other.sin_addr); printf("si_other.sin_addr…
sven
  • 1,101
  • 7
  • 21
  • 44
3
votes
2 answers

warning: passing argument 2 of ‘inet_aton’ from incompatible pointer type........ERROR

I don't know what this error means and what to do to fix it. I've been following the Sock)et Programming Tutorials In C For Beginners | Part 2 by Eduonix on Youtube but I haven't been able to run anything from this guy, the code is from his…
somethingSomething
  • 830
  • 7
  • 20
  • 43
3
votes
3 answers

Python pack IP string to bytes

I want to kind of implement my own struct.pack specific function to pack an IP string (i.e. "192.168.0.1") to a 32-bit packed value, without using the socket.inet_aton built in method. I got so far: ip = "192.168.0.1" hex_list = map(hex, map(int,…
Ofer Arial
  • 1,129
  • 1
  • 10
  • 25
3
votes
3 answers

Are there any .NET Framework Method that does INET_ATON()

That does this calculation below address = '174.36.207.186' ( o1, o2, o3, o4 ) = address.split('.') integer_ip = ( 16777216 * o1 ) + ( 65536 * o2 ) + ( 256 * o3 ) + o4
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
2
votes
2 answers

How to do wildcard search for IP addresses using INET_ATON in MySQL?

I found this method to store IP addresses in MySQL database as integer using INET_ATON: https://stackoverflow.com/a/5133610/4491952 Since IPv4 addresses are 4 byte long, you could use an INT (UNSIGNED) that has exactly 4 bytes: `ipv4` INT…
Trondro Mulligan
  • 485
  • 3
  • 19
2
votes
2 answers

Differences between inet_aton() and gethostbyname() in C?

I'm studying C and TCP/UDP. As the title... Is there any difference between inet_aton() and gethostbyname() in C? From what I know, both convert an IP address from a string to a number.
testermaster
  • 1,031
  • 6
  • 21
  • 40
2
votes
1 answer

Returning null when using INET6_ATON in LOAD DATA LOCAL INFILE

I am using MySQL 5.6, experimenting with the new features, like INET6_ATON and IS_IPV6. When the script reads IPV4, it inserts the data into the table perfectly. But when it comes to IPv6, one of the rows (ipTo) fails, even though the INET6_ATON…
Ágota Horváth
  • 1,353
  • 3
  • 13
  • 20
1
vote
1 answer

ISSUE: java.net.InetAddress RESULTS are wrong when compared with MYSQL results

I've followed the answer in https://stackoverflow.com/a/2241269/2458223 (which William Brendel suggested) but most of the time returns wrong results when i compare the results with MYSQL. Please review InetAddress bar =…
1
vote
1 answer

inet_ntoa for ipv6 in perl

I am new to perl and I am trying to convert an ipv6 address in network format to the ascii string format. I could do this for ipv4 address using the "inet_ntoa" function in the "Socket" module. How to do this for ipv6 address without installing any…
kiran
  • 525
  • 1
  • 9
  • 26
0
votes
1 answer

I'm developing a server and ip passed as parameter not working

I'm using: struct in_addr ip; #define HOST_PORT atoi(argv[2]) #define HOST_IP inet_aton(argv[1], &ip) sockaddr_in sockaddr; sockaddr.sin_family = AF_INET; sockaddr.sin_addr.s_addr =…
0
votes
1 answer

Why I can't store INET_ATON result to VARBINARY(4)?

MySQL documentation says that: Data type VARBINARY(16) is for IPv6 addresses and data type VARBINARY(4) is for IPv4 addresses. But when I try to store INET_ATON result to VARBINARY(4) column, I get the following error message: Data too long for…
NoSkill
  • 718
  • 5
  • 15
0
votes
1 answer

How to select available IP address from mysql db table

I have mysql table called ip_address with column called ip and it contains following data 192.168.1.52 192.168.1.7 192.168.1.21 192.168.1.107 . . . my problem is how to get the available IP address from the subnet, I mean this subnet must…
iQalalwa
  • 281
  • 3
  • 4
0
votes
2 answers

How does one load IP addresses into Mysql Table from a CSV file?

I'm trying to find a way to load a mysql table which I call ipCompare_tbl with IP addresses from a CSV file called myIPs.csv. The fields in ipCompare_tbl are ipStart, and ipEnd. I've also included an auto_incrementor for a primary key generator…
1
2