Class: PacketGen::Header::DNS::RRSection
- Inherits:
-
Types::Array
- Object
- Types::Array
- PacketGen::Header::DNS::RRSection
- Defined in:
- lib/packetgen/header/dns/rrsection.rb
Overview
Define a DNS Ressource Record Section
Direct Known Subclasses
Constant Summary
Constants inherited from Types::Array
Constants included from Types::LengthFrom
Types::LengthFrom::MAX_SZ_TO_READ
Instance Method Summary collapse
-
#initialize(dns, counter) ⇒ RRSection
constructor
private
A new instance of RRSection.
-
#read(str) ⇒ RRSection
Read RR section from a string.
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.
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? 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 |