Sha256: 0a4c24e0c3546e9010b3986fb7e8bf51ba3ae13f57d3583a47cbcc2f89d87c16

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

# This file is part of PacketGen
# See https://github.com/sdaubert/packetgen for more informations
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
# This program is published under MIT license.

# frozen_string_literal: true

module PacketGen
  module Header
    class DNS

      # Define a DNS Question Section
      # @author Sylvain Daubert
      class QDSection < RRSection
        # @!method push(q)
        #  Add a question to this section without incrementing associated counter
        #  @param [Question,Hash] q
        #  @return [QDSection] self
        # @!method <<(q)
        #  Add a question to this section. Increment associated counter
        #  @param [Question,Hash] q
        #  @return [QDSection] self
        # @!method delete(q)
        #  Delete a question
        #  @param [Question] q
        #  @return [Question]

        # Read Question section from a string
        # @param [String] str binary string
        # @return [QDSection] self
        def read(str)
          clear
          return self if str.nil?
          force_binary str
          while str.length > 0 and self.size < @counter.to_i
            question = Question.new(@dns).read(str)
            str.slice!(0, question.sz)
            self.push question
          end
          self
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packetgen-2.6.0 lib/packetgen/header/dns/qdsection.rb
packetgen-2.5.2 lib/packetgen/header/dns/qdsection.rb
packetgen-2.5.1 lib/packetgen/header/dns/qdsection.rb
packetgen-2.5.0 lib/packetgen/header/dns/qdsection.rb