class NetAddr::CIDRv4
IPv4 CIDR address - Inherits all methods from NetAddr::CIDR. Addresses of this class are composed of a 32-bit address space.
Public Class Methods
new(ip, netmask=nil, tag={}, wildcard_mask=nil, wildcard_mask_bit_flipped=false)
click to toggle source
This method performs absolutely no error checking, and is meant to be used only by other internal methods for the sake of the speedier creation of CIDR objects. Please consider using #create unless you know what you are doing with 100% certainty.
Arguments:¶ ↑
-
ip - Integer representing an ip address
-
netmask - Integer representing a binary netmask
-
tag - Hash used to append custom tags to CIDR
-
wildcard_mask - Integer representing a binary mask
-
wildcard_mask_bit_flipped - indicates whether or not the wildcard_mask is bit-flipped or not
# File lib/cidr.rb, line 239 def initialize(ip, netmask=nil, tag={}, wildcard_mask=nil, wildcard_mask_bit_flipped=false) @ip = ip if ( self.kind_of?(NetAddr::CIDRv4) ) @version = 4 @address_len = 32 else @version = 6 @address_len = 128 end @all_f = 2**@address_len - 1 if (netmask) @netmask = netmask else @netmask = 2**@address_len - 1 end @network = (@ip & @netmask) @hostmask = @netmask ^ @all_f @tag = tag if (!wildcard_mask) @wildcard_mask = @netmask else @wildcard_mask = wildcard_mask @wildcard_mask = ~@wildcard_mask if (wildcard_mask_bit_flipped) end end
Public Instance Methods
hostmask_ext()
click to toggle source
netmask_ext()
click to toggle source