lib/wmap/cidr_tracker.rb
# Return the matching CIDR block for a ip
Return the matching CIDR block for a ip
Return the matching CIDR block for a ip
def cidr_lookup (ip)
		puts "Lookup the CIDR name from the known CIDR list for the IP: #{ip}" if @verbose
		return nil if @known_cidr_blks==nil
		puts "CIDR Lookup: #{ip} ..." if @verbose
		@known_cidr_blks_desc_index.each do |line|
			first_octet_ip = ip.split('.').first.to_i
			first_octet_blk = line.split('.').first.to_i
			next if first_octet_blk > first_octet_ip
			cidr4 = NetAddr::CIDR.create(line)
			known = cidr4.contains?(ip+'/32')
			return line if known
		end
	rescue => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return nil
	end
def cidr_lookup ( ip ) puts "Lookup the CIDR name from the known CIDR list for the IP: #{ip}" if @verbose return nil if @known_cidr_blks == nil puts "CIDR Lookup: #{ip} ..." if @verbose @known_cidr_blks_desc_index . each do | line | first_octet_ip = ip . split ( '.' ) . first . to_i first_octet_blk = line . split ( '.' ) . first . to_i next if first_octet_blk > first_octet_ip cidr4 = NetAddr :: CIDR . create ( line ) known = cidr4 . contains? ( ip + '/32' ) return line if known end rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose return nil end
Return the matching CIDR block for a ip
Return the matching CIDR block for a ip
ip
<not_specific>