Class: PacketGen::Header::DNS::Question
- Inherits:
-
Base
- Object
- Types::Fields
- Base
- PacketGen::Header::DNS::Question
- Defined in:
- lib/packetgen/header/dns/question.rb
Overview
DNS Question
Direct Known Subclasses
Constant Summary collapse
- TYPES =
Ressource Record types
{ 'A' => 1, 'NS' => 2, 'MD' => 3, 'MF' => 4, 'CNAME' => 5, 'SOA' => 6, 'MB' => 7, 'MG' => 8, 'MR' => 9, 'NULL' => 10, 'WKS' => 11, 'PTR' => 12, 'HINFO' => 13, 'MINFO' => 14, 'MX' => 15, 'TXT' => 16, 'AAAA' => 28, 'NAPTR' => 35, 'KX' => 36, 'CERT' => 37, 'OPT' => 41, 'DS' => 43, 'RRSIG' => 46, 'NSEC' => 47, 'DNSKEY' => 48, 'TKEY' => 249, 'TSIG' => 250, '*' => 255 }
- CLASSES =
Ressource Record classes
{ 'IN' => 1, 'CH' => 3, 'HS' => 4, 'NONE' => 254, '*' => 255 }
Instance Attribute Summary collapse
-
#name ⇒ String
Question domain name.
-
#rrclass ⇒ Integer
16-bit question class.
-
#type ⇒ Integer
16-bit question type.
Attributes inherited from Base
Instance Method Summary collapse
-
#has_type?(type) ⇒ Boolean
Check type.
-
#human_rrclass ⇒ String
Get human readable class.
-
#human_type ⇒ String
Get human readable type.
-
#initialize(dns, options = {}) ⇒ Question
constructor
A new instance of Question.
- #to_human ⇒ String
Methods inherited from Base
bind_header, #header_id, inherited, #ip_header, known_headers, #parse?, #protocol_name
Methods inherited from Types::Fields
#[], #[]=, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, #force_binary, inherited, #inspect, #read, #sz, #to_h, #to_s
Constructor Details
#initialize(dns, options = {}) ⇒ Question
Returns a new instance of Question.
68 69 70 71 72 73 |
# File 'lib/packetgen/header/dns/question.rb', line 68 def initialize(dns, ={}) super() self[:name].dns = dns self.type = [:type] if [:type] self.rrclass = [:rrclass] if [:rrclass] end |
Instance Attribute Details
#name ⇒ String
Question domain name
12 |
# File 'lib/packetgen/header/dns/question.rb', line 12 define_field :name, Name, default: '.' |
#rrclass ⇒ Integer
16-bit question class
20 |
# File 'lib/packetgen/header/dns/question.rb', line 20 define_field :rrclass, Types::Int16, default: 1 |
#type ⇒ Integer
16-bit question type
16 |
# File 'lib/packetgen/header/dns/question.rb', line 16 define_field :type, Types::Int16, default: 1 |
Instance Method Details
#has_type?(type) ⇒ Boolean
Check type
106 107 108 |
# File 'lib/packetgen/header/dns/question.rb', line 106 def has_type?(type) self.class::TYPES[type] == self.type end |
#human_rrclass ⇒ String
Get human readable class
118 119 120 |
# File 'lib/packetgen/header/dns/question.rb', line 118 def human_rrclass self.class::CLASSES.key(self.rrclass) || "0x%04x" % self.rrclass end |
#human_type ⇒ String
Get human readable type
112 113 114 |
# File 'lib/packetgen/header/dns/question.rb', line 112 def human_type self.class::TYPES.key(type) || "0x%04x" % type end |
#to_human ⇒ String
123 124 125 |
# File 'lib/packetgen/header/dns/question.rb', line 123 def to_human "#{human_type} #{human_rrclass} #{name}" end |