class PacketGen::Header::DNS::Question

DNS Question @author Sylvain Daubert

Constants

CLASSES

Ressource Record classes

TYPES

Ressource Record types

Public Class Methods

new(dns, options={}) click to toggle source

@param [DNS] dns @param [Hash] options @option options [String] :name domain as a dotted string @option options [Integer,String] :type see {TYPES}. Default to +'A'+ @option options [Integer,String] :rrclass see {CLASSES}. Default to +'IN'+

Calls superclass method
# File lib/packetgen/header/dns/question.rb, line 76
def initialize(dns, options={})
  super(options)
  self[:name].dns = dns
  self.type = options[:type] if options[:type]
  self.rrclass = options[:rrclass] if options[:rrclass]
end

Public Instance Methods

human_rrclass() click to toggle source

Get human readable class @return [String]

# File lib/packetgen/header/dns/question.rb, line 116
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() click to toggle source

Get human readable type @return [String]

# File lib/packetgen/header/dns/question.rb, line 110
def human_type
  self.class::TYPES.key(type) || '0x%04x' % type
end
rrclass=(val) click to toggle source

Setter for class @param [Integer] val @return [Integer,String]

# File lib/packetgen/header/dns/question.rb, line 88
def rrclass=(val)
  v = case val
      when String
        self.class::CLASSES[val.upcase]
      else
        val
      end
  raise ArgumentError, "unknown class #{val.inspect}" unless v

  self[:rrclass].read v
end
to_human() click to toggle source

@return [String]

# File lib/packetgen/header/dns/question.rb, line 125
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) click to toggle source

Check type @param [String] type name @return [Boolean] @since 2.7.0

# File lib/packetgen/header/dns/question.rb, line 104
def type?(type)
  self.class::TYPES[type] == self.type
end