Class: PacketGen::Header::DNS::RRSection
- Inherits:
-
BinStruct::Array
- Object
- BinStruct::Array
- PacketGen::Header::DNS::RRSection
- Defined in:
- lib/packetgen/header/dns/rrsection.rb
Overview
Define a DNS Ressource Record Section
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(dns, counter) ⇒ RRSection
constructor
private
A new instance of RRSection.
-
#read(str) ⇒ RRSection
Read RR section from a string.
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.
18 19 20 21 |
# File 'lib/packetgen/header/dns/rrsection.rb', line 18 def initialize(dns, counter) super(counter: counter) @dns = dns end |
Instance Method Details
#read(str) ⇒ RRSection
Read RR section from a string
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/packetgen/header/dns/rrsection.rb', line 26 def read(str) clear return self if str.nil? str = str.b unless str.encoding == Encoding::BINARY 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 |