dasiu@admin:~/Dokumenty/Mikrotik/Skrypty$ ./dhcp.perl 16.32.64.128 0.0.0.0/0
DHCP option 121 (249) hex string: 000010204080
- should be 0010204080, and is 00
0010204080. RFC says, that for subnet mask /0 - there should be 0 octets of the network, and the perl script still gives 1 octet in the result
.
From the RFC 3442 - see the first example:
Width of subnet mask Number of significant octets
0 0
1- 8 1
9-16 2
17-24 3
25-32 4
The following table contains some examples of how various subnet
number/mask combinations can be encoded:
Subnet number Subnet mask Destination descriptor
0 0 0
10.0.0.0 255.0.0.0 8.10
10.0.0.0 255.255.255.0 24.10.0.0
10.17.0.0 255.255.0.0 16.10.17
10.27.129.0 255.255.255.0 24.10.27.129
10.229.0.128 255.255.255.128 25.10.229.0.128
10.198.122.47 255.255.255.255 32.10.198.122.47
So then - line 16 of the perl script given by you:
$string .= sprintf('%02x', $b0);
should be:
$string .= sprintf('%02x', $b0)
if($mask > 0);