Class: DNS::Question
- Inherits:
-
Object
- Object
- DNS::Question
- Defined in:
- lib/faildns/question.rb
Overview
– The question section is used to carry the “question” in most queries, i.e., the parameters that define what is being asked. The section contains QDCOUNT (usually 1) entries, each of the following format:
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| |
/ QNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QTYPE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QCLASS |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
where:
QNAME a domain name represented as a sequence of labels, where
each label consists of a length octet followed by that
number of octets. The domain name terminates with the
zero length octet for the null label of the root. Note
that this field may be an odd number of octets; no
padding is used.
QTYPE a two octet code which specifies the type of the query.
The values for this field include all codes valid for a
TYPE field, together with some more general codes which
can match more than one type of RR.
QCLASS a two octet code that specifies the class of the query.
For example, the QCLASS field is IN for the Internet.
++
Class Method Summary collapse
Instance Method Summary collapse
- #class ⇒ Object
- #class=(val) ⇒ Object
-
#initialize(what = {}) ⇒ Question
constructor
A new instance of Question.
- #name ⇒ Object
- #name=(val) ⇒ Object
- #pack ⇒ Object
- #type ⇒ Object
- #type=(val) ⇒ Object
Constructor Details
#initialize(what = {}) ⇒ Question
Returns a new instance of Question.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/faildns/question.rb', line 76 def initialize (what={}) if !what.is_a? Hash raise ArgumentError.new('You have to pass a Hash.') end @data = what if block_given? yield self end end |
Class Method Details
Instance Method Details
#class ⇒ Object
90 |
# File 'lib/faildns/question.rb', line 90 def class; @data[:QCLASS] end |
#class=(val) ⇒ Object
94 |
# File 'lib/faildns/question.rb', line 94 def class= (val); @data[:QCLASS] = QClass.new(val) end |
#name ⇒ Object
88 |
# File 'lib/faildns/question.rb', line 88 def name; @data[:QNAME] end |
#name=(val) ⇒ Object
92 |
# File 'lib/faildns/question.rb', line 92 def name= (val); @data[:QNAME] = DomainName.new(val) end |
#pack ⇒ Object
96 97 98 |
# File 'lib/faildns/question.rb', line 96 def pack self.name.pack + self.type.pack + self.class.pack end |
#type ⇒ Object
89 |
# File 'lib/faildns/question.rb', line 89 def type; @data[:QTYPE] end |