Networking devices from both Juniper and Cisco (and others) use the
address/prefix of
0.0.0.0/0 to represent ANY in both routing and
access control config (the /0 effectively indicating ignore all bits
so in theory the address could be anything, but I digress). I'm
parsing such configs and was hoping that I could simply do the same
but IPAddress:Prefix32.new raises an exception if the prefix length is
less than 1.
def initialize(num)
unless (1..32).include? num
raise ArgumentError, "Prefix must be in range 1..32, got:
#{num}"
end
super(num)
end
Any reason this particular decision was made not to support a 0 length
mask?
I did try a quick change to the range (allowed) zero, but found the
to_ip didn't respond as I would expect:
ruby-1.9.2-p0 > a = IPAddress::Prefix32.new 0
=> 0
ruby-1.9.2-p0 > a.hostmask
=> "255.255.255.255"
ruby-1.9.2-p0 > a.to_ip
=> "0..."
Cheers
MS