Module: Dnsruby::RR::NXT::NxtTypes

### Home Classes Methods

### In Files

- lib/dnsruby/resource/NXT.rb

### Methods

- #assert_legal_bitmap_value
- #binary_string_to_codes
- #binary_string_to_names
- #code_to_name
- #codes_to_binary_string
- #codes_to_names
- #codes_to_string
- #legal_code_value?
- #name_to_code
- #names_string_to_codes
- #names_to_codes

### Files

- DNSSEC
- EVENTMACHINE
- EXAMPLES

### Class/Module Index

Quicksearch

- Dnsruby
- Dnsruby::Algorithms
- Dnsruby::BitMapping
- Dnsruby::Bitmap
- Dnsruby::Classes
- Dnsruby::CodeMapper
- Dnsruby::Config
- Dnsruby::DNS
- Dnsruby::DecodeError
- Dnsruby::Dnssec
- Dnsruby::Dnssec::ValidationPolicy
- Dnsruby::EncodeError
- Dnsruby::ExtendedRCode
- Dnsruby::FormErr
- Dnsruby::Header
- Dnsruby::Hosts
- Dnsruby::IPv4
- Dnsruby::IPv6
- Dnsruby::Message
- Dnsruby::Message::SecurityLevel
- Dnsruby::MetaTypes
- Dnsruby::Modes
- Dnsruby::NXDomain
- Dnsruby::NXRRSet
- Dnsruby::Name
- Dnsruby::Name::Label
- Dnsruby::NotAuth
- Dnsruby::NotImp
- Dnsruby::NotZone
- Dnsruby::Nsec3HashAlgorithms
- Dnsruby::OpCode
- Dnsruby::OtherResolvError
- Dnsruby::QTypes
- Dnsruby::Question
- Dnsruby::RCode
- Dnsruby::RR
- Dnsruby::RR::ANY
- Dnsruby::RR::CERT
- Dnsruby::RR::CERT::CertificateTypes
- Dnsruby::RR::CNAME
- Dnsruby::RR::DHCID
- Dnsruby::RR::DLV
- Dnsruby::RR::DNAME
- Dnsruby::RR::DNSKEY
- Dnsruby::RR::DS
- Dnsruby::RR::DS::DigestTypes
- Dnsruby::RR::DomainName
- Dnsruby::RR::GPOS
- Dnsruby::RR::Generic
- Dnsruby::RR::HINFO
- Dnsruby::RR::HIP
- Dnsruby::RR::IN
- Dnsruby::RR::IN::A
- Dnsruby::RR::IN::AAAA
- Dnsruby::RR::IN::AFSDB
- Dnsruby::RR::IN::PX
- Dnsruby::RR::IN::SRV
- Dnsruby::RR::IN::WKS
- Dnsruby::RR::IPSECKEY
- Dnsruby::RR::ISDN
- Dnsruby::RR::KX
- Dnsruby::RR::LOC
- Dnsruby::RR::MB
- Dnsruby::RR::MG
- Dnsruby::RR::MINFO
- Dnsruby::RR::MR
- Dnsruby::RR::MX
- Dnsruby::RR::NAPTR
- Dnsruby::RR::NS
- Dnsruby::RR::NSAP
- Dnsruby::RR::NSEC
- Dnsruby::RR::NSEC3
- Dnsruby::RR::NSEC3PARAM
- Dnsruby::RR::NXT
- Dnsruby::RR::NXT::NxtTypes
- Dnsruby::RR::NXT::TypeBitmap
- Dnsruby::RR::OPT
- Dnsruby::RR::PTR
- Dnsruby::RR::RP
- Dnsruby::RR::RRSIG
- Dnsruby::RR::RT
- Dnsruby::RR::SOA
- Dnsruby::RR::SPF
- Dnsruby::RR::SSHFP
- Dnsruby::RR::SSHFP::Algorithms
- Dnsruby::RR::SSHFP::FpTypes
- Dnsruby::RR::TKEY
- Dnsruby::RR::TSIG
- Dnsruby::RR::TXT
- Dnsruby::RR::X25
- Dnsruby::RRSet
- Dnsruby::Recursor
- Dnsruby::Refused
- Dnsruby::Resolv
- Dnsruby::ResolvError
- Dnsruby::ResolvTimeout
- Dnsruby::Resolver
- Dnsruby::Resolver::EventType
- Dnsruby::Section
- Dnsruby::SelectThread
- Dnsruby::ServFail
- Dnsruby::SingleResolver
- Dnsruby::SocketEofResolvError
- Dnsruby::TheLog
- Dnsruby::TsigError
- Dnsruby::TsigNotSignedResponseError
- Dnsruby::Types
- Dnsruby::Update
- Dnsruby::VerifyError
- Dnsruby::YXDomain
- Dnsruby::YXRRSet
- Dnsruby::ZoneReader
- Dnsruby::ZoneReader::ParseException
- Dnsruby::ZoneSerialError
- Dnsruby::ZoneTransfer
- Dnsruby::ZoneTransfer::Delta
- Base32
- Object

No matching classes.

# Dnsruby::RR::NXT::NxtTypes

Methods used to manipulate the storage and representation of record types as stored in NXT record bitmaps.

### Constants

MAX_BITMAP_NUMBER_VALUE

  Maximum bitmap size is 128 bytes; since it's zero offset values are 0..(2 ** 128 - 1). However, the least significant bit must not be set, so the maximum is 1 less than that.

### Public Instance Methods

assert_legal_bitmap_value(number) click to toggle source

Assert that the specified number is a legal value with which to instantiate a NXT type bitmap. Raise on error, do nothing on success.

    # File lib/dnsruby/resource/NXT.rb, line 238
    def assert_legal_bitmap_value(number)
      max_value = NxtTypes::MAX_BITMAP_NUMBER_VALUE
      if number > max_value
        raise ArgumentError.new("Bitmap maximum value is #{max_value} (0x#{max_value.to_s(16)}).")
      end
      if number & 1 == 1
        raise ArgumentError.new("Bitmap number must not have low bit set.")
      end
    end

binary_string_to_codes(binary_string) click to toggle source

From a binary string of type code bits, return an array of type codes.

    # File lib/dnsruby/resource/NXT.rb, line 213
    def binary_string_to_codes(binary_string)
      bitmap_number = BitMapping.binary_string_to_number(binary_string)
      assert_legal_bitmap_value(bitmap_number)
      BitMapping.number_to_set_bit_positions_array(bitmap_number)
    end

binary_string_to_names(binary_string) click to toggle source

From a binary string of type code bits, return an array of type names.

    # File lib/dnsruby/resource/NXT.rb, line 221
    def binary_string_to_names(binary_string)
      codes = binary_string_to_codes(binary_string)
      codes_to_names(codes)
    end

code_to_name(number) click to toggle source

Convert a numeric type code to its corresponding name (e.g. "A" => 1). Unknown types are named "TYPE#{number}".

    # File lib/dnsruby/resource/NXT.rb, line 172
    def code_to_name(number)
      Types.to_string(number) || "TYPE#{number}"
    end

codes_to_binary_string(codes) click to toggle source

From an array of type codes, return a binary string.

    # File lib/dnsruby/resource/NXT.rb, line 227
    def codes_to_binary_string(codes)
      codes = codes.sort
      unless legal_code_value?(codes.first) && legal_code_value?(codes.last)
        raise ArgumentError.new("All codes must be between 1 and 127: #{codes.inspect}.")
      end
      bitmap_number = BitMapping.set_bit_position_array_to_number(codes)
      BitMapping.number_to_binary_string(bitmap_number)
    end

codes_to_names(codes) click to toggle source

For the given array of type codes, return an array of their corresponding names.

    # File lib/dnsruby/resource/NXT.rb, line 201
    def codes_to_names(codes)
      codes.map { |code| code_to_name(code) }
    end

codes_to_string(codes) click to toggle source

Generate a string containing the names corresponding to the numeric type codes. Sort it by the numeric type code, ascending.

    # File lib/dnsruby/resource/NXT.rb, line 207
    def codes_to_string(codes)
      codes.sort.map { |code| code_to_name(code) }.join(' ')
    end

legal_code_value?(code) click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 248
    def legal_code_value?(code)
      (1..127).include?(code)
    end

name_to_code(name) click to toggle source

Convert a type name to its corresponding numeric type code. Names matching /^TYPE(d+)$/ are assumed to have a code corresponding to the numeric value of the substring following 'TYPE'.

    # File lib/dnsruby/resource/NXT.rb, line 179
    def name_to_code(name)
      code = Types.to_code(name)
      if code.nil?
        matches = /^TYPE(\d+)$/.match(name)
        code = matches[1].to_i if matches
      end
      code
    end

names_string_to_codes(name_string) click to toggle source

For the specified string containing names (e.g. 'A NS'), return an array containing the corresponding codes.

    # File lib/dnsruby/resource/NXT.rb, line 195
    def names_string_to_codes(name_string)
      names_to_codes(name_string.split(' '))
    end

names_to_codes(names) click to toggle source

For a given array of type names, return an array of codes.

    # File lib/dnsruby/resource/NXT.rb, line 189
    def names_to_codes(names)
      names.map { |s| name_to_code(s) }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.