Solved Generating list of all possible IP in Subnet
-
Hi,
I can't found a simple solution to obtain a list of all available ip addresses in a given subnet.
For exemple if I give the ip (192.168.1.1) with the subnet mask (255.255.255.0) I need a returned list of all addresses from 192.168.1.0 to 192.168.1.255.In other word I want to write a method like this :
QList<QHostAddress> getAllAddresses(QHostAddress ip, QHostAddress subnetMask);
Any suggestion?
Regads -
@Foufy said in Generating list of all possible IP in Subnet:
Any suggestion?
Iterate from 0 to 256 and add the generated IPs to your QList
-
That's an idea but I need a generic function working for any possible ip, subnet pair
-
Hi
You can have a look here for inspiration
http://www.cplusplus.com/articles/4S2z3TCk/ -
@Foufy said in Generating list of all possible IP in Subnet:
but I need a generic function working for any possible ip, subnet pair
So where's the problem?
btw: It's even easier - IPv4 is a simple 32bit integer counting up. So 192.168.1.1 is 0xc0.0xa8.0x01.0x01 = 0xc0a80101 = 3232235777. So simply count up and you get your ips.
-
This post is deleted! -
Is the IP list of a subnet always results in a continuous IP range? I that way counting is a simple solution indeed.
-
@Foufy said in Generating list of all possible IP in Subnet:
Is the IP list of a subnet always results in a continuous IP range?
I already told you in my first post...