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

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

Overview

Define a DNS Question Section

Author:

  • Sylvain Daubert

Since:

  • 1.3.0

Instance Method Summary collapse

Methods inherited from RRSection

#initialize

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 15

#delete(q) ⇒ Question

Delete a question

Parameters:

Returns:



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

#push(q) ⇒ QDSection

Add a question to this section without incrementing associated counter

Parameters:

Returns:



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

#read(str) ⇒ QDSection

Read Question section from a binary string

Parameters:

  • str (String)

    binary string

Returns:

Since:

  • 1.3.0



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

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

  str = str.b unless str.encoding == Encoding::ASCII_8BIT
  while !str.empty? && (self.size < @counter.to_i)
    question = Question.new(@dns).read(str)
    str.slice!(0, question.sz)
    push(question)
  end
  self
end