def next_subnet(options=nil)
known_args = [:Bitstep, :Objectify, :Short]
bitstep = 1
objectify = false
short = false
if (options)
if (!options.kind_of?(Hash))
raise Argumenterror, "Expected Hash, but " +
"#{options.class} provided."
end
NetAddr.validate_args(options.keys,known_args)
if( options.has_key?(:Bitstep) )
bitstep = options[:Bitstep]
end
if( options.has_key?(:Short) && options[:Short] == true )
short = true
end
if( options.has_key?(:Objectify) && options[:Objectify] == true )
objectify = true
end
end
bitstep = bitstep * (2**(@address_len - self.bits) )
next_sub = @network + bitstep
if (next_sub > @all_f)
raise BoundaryError, "Returned subnet is out of bounds for IPv#{@version}."
end
if (!objectify)
next_sub = NetAddr.ip_int_to_str(next_sub, @version)
next_sub = NetAddr.shorten(next_sub) if (short && @version == 6)
next_sub = next_sub << "/" << self.bits.to_s
else
next_sub = NetAddr.cidr_build(@version,next_sub,self.to_i(:netmask))
end
return(next_sub)
end