1) first you can transform the ipaddress
and the subnetmask
from string format to binary format with inet_pton()
.
2) make a check on the subnetmask
mask it should be a valid subnet mask
3) get the subnetmask
inverse value (~subnetmask
)
4)
for (i=1; i<(~subnetmask); i++) {
ip = ipaddress & (subnetmask + i);
//append ip to your ip list
}