Class: PacketGen::Header::DNS::QDSection

Inherits:
RRSection show all
Defined in:
lib/packetgen/header/dns/qdsection.rb

Overview

Define a DNS Question Section

Author:

  • Sylvain Daubert

Since:

  • 1.3.0

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 RRSection

#initialize

Methods inherited from Types::Array

#==, #[], #clear, #clear!, #delete_at, #each, #empty?, #first, #initialize, #initialize_copy, #last, 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

This class inherits a constructor from PacketGen::Header::DNS::RRSection

Instance Method Details

#<<(q) ⇒ QDSection

Add a question to this section. Increment associated counter

Parameters:

Returns:


# File 'lib/packetgen/header/dns/qdsection.rb', line 14

#delete(q) ⇒ Question

Delete a question

Parameters:

Returns:


# File 'lib/packetgen/header/dns/qdsection.rb', line 14

#push(q) ⇒ QDSection

Add a question to this section without incrementing associated counter

Parameters:

Returns:


# File 'lib/packetgen/header/dns/qdsection.rb', line 14

#read(str) ⇒ QDSection

Read Question section from a string

Parameters:

  • str (String)

    binary string

Returns:

Since:

  • 1.3.0


30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/packetgen/header/dns/qdsection.rb', line 30

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

  PacketGen.force_binary str
  while !str.empty? && (self.size < @counter.to_i)
    question = Question.new(@dns).read(str)
    str.slice!(0, question.sz)
    push question
  end
  self
end