Class: PacketGen::Header::DNS::Question
- Inherits:
-
Types::Fields
- Object
- Types::Fields
- PacketGen::Header::DNS::Question
- Includes:
- Types::Fieldable
- 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, 'SRV' => 33, 'NAPTR' => 35, 'KX' => 36, 'CERT' => 37, 'OPT' => 41, 'DS' => 43, 'RRSIG' => 46, 'NSEC' => 47, 'DNSKEY' => 48, 'TKEY' => 249, 'TSIG' => 250, '*' => 255 }.freeze
- CLASSES =
Ressource Record classes
{ 'IN' => 1, 'CH' => 3, 'HS' => 4, 'NONE' => 254, '*' => 255 }.freeze
Instance Attribute Summary collapse
-
#name ⇒ String
Question domain name.
-
#rrclass ⇒ Integer
16-bit question class.
-
#type ⇒ Integer
16-bit question type.
Instance Method Summary collapse
-
#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
-
#type?(type) ⇒ Boolean
Check type.
Methods included from Types::Fieldable
#format_inspect, #read, #sz, #to_s, #type_name
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #inspect, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
#initialize(dns, options = {}) ⇒ Question
Returns a new instance of Question.
77 78 79 80 81 82 |
# File 'lib/packetgen/header/dns/question.rb', line 77 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
62 |
# File 'lib/packetgen/header/dns/question.rb', line 62 define_field :name, Name, default: '.' |
Instance Method Details
#human_rrclass ⇒ String
Get human readable class
117 118 119 120 121 122 123 |
# File 'lib/packetgen/header/dns/question.rb', line 117 def human_rrclass if self[:name].dns.is_a? MDNS self.class::CLASSES.key(self.rrclass & 0x7fff) || '0x%04x' % (self.rrclass & 0x7fff) else self.class::CLASSES.key(self.rrclass) || '0x%04x' % self.rrclass end end |
#human_type ⇒ String
Get human readable type
111 112 113 |
# File 'lib/packetgen/header/dns/question.rb', line 111 def human_type self.class::TYPES.key(type) || '0x%04x' % type end |
#to_human ⇒ String
126 127 128 129 130 131 132 133 |
# File 'lib/packetgen/header/dns/question.rb', line 126 def to_human if self[:name].dns.is_a? MDNS unicast_bit = self.rrclass & 0x8000 == 0x8000 ? 'QU' : 'QM' "#{human_type} #{human_rrclass} #{unicast_bit} #{name}" else "#{human_type} #{human_rrclass} #{name}" end end |
#type?(type) ⇒ Boolean
Check type
105 106 107 |
# File 'lib/packetgen/header/dns/question.rb', line 105 def type?(type) self.class::TYPES[type] == self.type end |