Class: PacketGen::Header::DNS::RRSection

Inherits:
Types::Array show all
Defined in:
lib/packetgen/header/dns/rrsection.rb

Overview

Define a DNS Ressource Record Section

Author:

  • Sylvain Daubert

Since:

  • 1.3.0

Direct Known Subclasses

QDSection

Constant Summary

Constants inherited from Types::Array

Types::Array::HUMAN_SEPARATOR

Constants included from Types::LengthFrom

Types::LengthFrom::MAX_SZ_TO_READ

Instance Method Summary collapse

Methods inherited from Types::Array

#<<, #==, #[], #clear, #clear!, #delete, #delete_at, #each, #empty?, #first, #initialize_copy, #last, #push, set_of, set_of_klass, #size, #sz, #to_a, #to_human, #to_s

Methods included from Types::LengthFrom

#initialize_length_from, #read_with_length_from, #sz_to_read

Methods included from Types::Fieldable

#format_inspect, #sz, #to_human, #to_s, #type_name

Constructor Details

#initialize(dns, counter) ⇒ RRSection

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RRSection.

Parameters:

Since:

  • 1.3.0


17
18
19
20
# File 'lib/packetgen/header/dns/rrsection.rb', line 17

def initialize(dns, counter)
  super(counter: counter)
  @dns = dns
end

Instance Method Details

#read(str) ⇒ RRSection

Read RR section from a string

Parameters:

  • str (String)

    binary string

Returns:

Since:

  • 1.3.0


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/packetgen/header/dns/rrsection.rb', line 25

def read(str)
  clear
  return self if str.nil?

  PacketGen.force_binary str
  while !str.empty? && (self.size < @counter.to_i)
    rr = RR.new(@dns).read(str)
    rr = OPT.new(@dns).read(str) if rr.type?('OPT')
    str.slice!(0, rr.sz)
    push rr
  end
  self
end