markrogoyski/ipv4-subnet-calculator-php

Get HostMin and HostMax

abhimanyu003 opened this issue · 3 comments

Thanks for great work, it works perfectly.
Whats your thoughts on adding HostMin and HostMax range that can be assigned.

For IP: 192.168.112.203/23

HostMin:   192.168.112.1
HostMax:   192.168.113.254

Example: http://jodies.de/ipcalc?host=192.168.112.203&mask1=23

May be we can add these functions as well.

$sub->getHostsRange();
$sub->getHostMin();
$sub->getHostMax();

Hi,
Thanks for the suggestions.

Would getHostsRange() return an array of the min and max hosts?

Yes, it must be same getIPAddressRange()

 $sub->getHostsRange();         // [ 192.168.112.1, 192.168.113.254 ]

Im not sure to keep method name as getHostsRange or getHostRange

Hi,
These features have been implemented in the newly released version v2.1.0.

Given the following IP address and network:

$sub = new IPv4\SubnetCalculator('192.168.112.203', 23);

Then the following new methods are available.

// Min host
$min_host        = $sub->getMinHost();       // 192.168.112.1
$min_host_quads  = $sub->getMinHostQuads();  // [192, 168, 112, 1]
$min_host_hex    = $sub->getMinHostHex();    // C0A87001
$min_host_binary = $sub->getMinHostBinary(); // 11000000101010000111000000000001

// Max host
$max_host        = $sub->getMaxHost();       // 192.168.113.254
$max_host_quads  = $sub->getMaxHostQuads();  // [192, 168, 113, 254]
$max_host_hex    = $sub->getMaxHostHex();    // C0A871FE
$max_host_binary = $sub->getMaxHostBinary(); // 11000000101010000111000111111110

// Addressable host range
$addressable_host_range = $sub->getAddressableHostRange(); // [192.168.112.1, 192.168.113.254]

Thank you again for the suggestion of adding these features. Sorry for the long delay in implementing them.

Please let me know if you have any other feedback or feature suggestions for IPv4 SubnetCalculator.

Thanks,
Mark