Class: Dnsruby::RR::NXT

### Home Classes Methods

### In Files

- lib/dnsruby/resource/NXT.rb

### Parent

Dnsruby::RR

### Namespace

- MODULE Dnsruby::RR::NXT::NxtTypes
- CLASS Dnsruby::RR::NXT::TypeBitmap

### Methods

- ::build_rdata
- ::decode_rdata
- ::new_from_data
- ::new_from_hash
- ::new_from_string
- #build_rdata
- #encode_rdata
- #from_data
- #from_hash
- #from_string
- #rdata_to_string

### 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

Class for NXT resource records.

NXT-specific data types, present in RDATA, are:

    next_domain: the next domain name, as a Name instance
    types: array of record types as numbers

RFC 2535 (www.ietf.org/rfc/rfc2535.txt)

The RFC mentions that a low bit of zero in the type RDATA indicates that the highest type code does not exceed 127, and that a low bit of 1 indicates that some mechanism other than a bitmap is being used. This class does not support such non-bitmap mechanisms, and assumes there will always be a bitmap.

### Constants

REQUIRED_KEYS

### Attributes

next_domain[RW]
types[RW]

### Public Class Methods

build_rdata(next_domain, types) click to toggle source

Builds rdata from the provided information. @param next_domain either a string or a Name @param types an array of types (where each type is the numeric type code)

    or a TypeBitmap

    # File lib/dnsruby/resource/NXT.rb, line 94
    def self.build_rdata(next_domain, types)
      next_domain = Name.create(next_domain) if next_domain.is_a?(String)
      types = TypeBitmap.from_type_codes(types) if types.is_a?(Array)

      binary_string = ''.force_encoding('ASCII-8BIT')
      binary_string << next_domain.canonical
      binary_string << BitMapping.reverse_binary_string_bits(types.to_binary_string)
      binary_string
    end

decode_rdata(message_decoder) click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 122
    def self.decode_rdata(message_decoder)

      start_index = message_decoder.index

      rdata_len = -> do
        rdata_length_str = message_decoder.data[start_index - 2, 2]
        rdata_length_str.unpack('n').first
      end

      next_domain_and_bitmap = -> do
        next_domain = message_decoder.get_name
        bitmap_start_index = message_decoder.index

        # If we're being called from new_from_data, the MessageDecoder
        # contains only the rdata, not the entire message, and there will
        # be no encoded length for us to read.
        called_from_new_from_data = (start_index == 0)
        bitmap_length = called_from_new_from_data            ? message_decoder.data.size            : rdata_len.() - (bitmap_start_index - start_index)

        bitmap = message_decoder.get_bytes(bitmap_length)
        bitmap = BitMapping.reverse_binary_string_bits(bitmap)
        [next_domain, bitmap]
      end

      next_domain, type_bitmap = next_domain_and_bitmap.()
      types = TypeBitmap.from_binary_string(type_bitmap).to_type_array
      new(next_domain: next_domain, types: types)
    end

new_from_data(*params_data) click to toggle source

Create an instance from an ordered parameter list, e.g.: rdata = RR::NXT.build_rdata('a.dnsruby.com.', [Types::SOA, Types::NXT])

rr = RR::NXT.new_from_data('b.dnsruby.com.', Types::NXT,

    Classes::IN, 10800, rdata.size, rdata, 0)

    # File lib/dnsruby/resource/NXT.rb, line 86
    def self.new_from_data(*params_data)
      RR.new_from_data(*params_data)
    end

new_from_hash(params_hash) click to toggle source

Create an instance from a hash of parameters, e.g.:

rr = RR::NXT.new_from_hash(

    name: 'b.dnsruby.com.',
    ttl: 10800,
    klass: Classes::IN,
    next_domain: 'a.dnsruby.com.',
    types: [Types::SOA, Types::NXT])

Since the type is assumed to be NXT, it will be assigned automatically, and any other value will be overwritten. Therefore, having it present in the hash is not necessary.

    # File lib/dnsruby/resource/NXT.rb, line 70
    def self.new_from_hash(params_hash)
      params_hash[:type] = Types::NXT
      RR.new_from_hash(params_hash)
    end

new_from_string(params_string) click to toggle source

Create an instance from a string containing parameters, e.g.: b.dnsruby.com. 10800 IN NXT A.dnsruby.com. SOA NXT

    # File lib/dnsruby/resource/NXT.rb, line 77
    def self.new_from_string(params_string)
      RR.new_from_string(params_string)
    end

### Public Instance Methods

build_rdata() click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 118
    def build_rdata
      self.class.build_rdata(next_domain, types)
    end

encode_rdata(message_encoder, _canonical) click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 114
    def encode_rdata(message_encoder, _canonical)
      message_encoder.put_bytes(build_rdata)
    end

from_data(data) click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 41
    def from_data(data)
      next_domain, types = data
      from_hash(next_domain: next_domain, types: types)
    end

from_hash(params_hash) click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 33
    def from_hash(params_hash)
      unless REQUIRED_KEYS.all? { |key| params_hash[key] }
        raise ArgumentError.new("NXT hash must contain all of: #{REQUIRED_KEYS.join(', ')}.")
      end
      @next_domain = Name.create(params_hash[:next_domain]) unless @next_domain.is_a?(Name)
      @types       = params_hash[:types]
    end

from_string(string) click to toggle source

    # File lib/dnsruby/resource/NXT.rb, line 46
    def from_string(string)
      next_domain, *type_names = string.split  # type names are all but first
      types = NxtTypes::names_to_codes(type_names)
      from_hash(next_domain: next_domain, types: types)
    end

rdata_to_string() click to toggle source

From the RFC: NXT has the following format: foo.nil. NXT big.foo.nil NS KEY SOA NXT <owner> NXT <next_domain> <record types>

We handle the rdata, the RR superclass does the rest.

    # File lib/dnsruby/resource/NXT.rb, line 110
    def rdata_to_string
      "#{next_domain} #{NxtTypes.codes_to_names(types).join(' ')}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.