Does anyone know how you can most easily output all IP addresses of a network in a specific range set by an IP and a subnet mask.
Example input: 192.168.15.13 255.255.255.0
Example output: IPs from 192.168.15.0-192.168.15.255
I was searching for some kind of library, but I haven't found anything yet. At first the boost::asio::ip library seemed promising, but I could not figure out a way to get the job done.
The subnet mask is "old" and unintuitive. The prefix notation is harder to mess.
Your address with prefix notation: 192.168.15.13/24
The IPv4 address is unsigned 32-bit integer that is merely formatted as four 8-bit values.
There is program 'ipcalc' that calculates first (network) and last (broadcast) addresses for you.
See https://www.mankier.com/1/ipcalc
"free software; see the source for copying conditions"
The main question: do you really need to do this math within your code?
I don't think that this tool can output all IPs of a network, only information about it.
As a background: I am currently writing an SNMP scanner and I want to enable the user to scan a whole network. I have to send an SNMP request to each host of the network separately, that is why I need to generate a list of all IPs in a certain "range".