Class: Dnsruby::RR::Generic

Inherits:
RR
  • Object
show all
Defined in:
lib/dnsruby/resource/generic.rb

Overview

Class to store generic RRs (RFC 3597)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#data ⇒ Object (readonly)

data for the generic resource record



23
24
25
# File 'lib/dnsruby/resource/generic.rb', line 23

def data
  @data
end

Class Method Details

.const_missing(name) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/dnsruby/resource/generic.rb', line 74

def self.const_missing(name)
  # A subclass lookup with inherit=false must still reject a native
  # ancestor binding. Only virtual generated names need this fallback.
  return super if !equal?(Generic) && GenericConstantInspection::NATIVE_DEFINED.bind_call(self, name)
  found = GenericCache.named(name.to_s)
  return found if found
  pair = /\AType(\d+)_Class(\d+)\z/.match(name.to_s)
  return RR.find_class(*pair.captures.map(&:to_i)) if pair
  super
end

.create(type_value, class_value) ⇒ Object

:nodoc:



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/dnsruby/resource/generic.rb', line 48

def self.create(type_value, class_value) #:nodoc:
  if GenericCache.automatic?(type_value, class_value)
    return GenericCache.create(type_value, class_value)
  end
  c = Class.new(Generic)
  #           c.type = type_value
  #           c.klass = class_value
  c.const_set(:TypeValue, type_value)
  c.const_set(:ClassValue, class_value)
  Generic.const_set("Type#{type_value}_Class#{class_value}", c)
  ClassHash[[type_value, class_value]] = c
  return c
end

.decode_rdata(msg) ⇒ Object

:nodoc: all



44
45
46
# File 'lib/dnsruby/resource/generic.rb', line 44

def self.decode_rdata(msg) #:nodoc: all
  return self.new(msg.get_bytes)
end

.inspect ⇒ Object



70
71
72
# File 'lib/dnsruby/resource/generic.rb', line 70

def self.inspect
  @generic_cache_entry&.klass.equal?(self) ? @generic_display_name.dup : super
end

.name ⇒ Object



62
63
64
# File 'lib/dnsruby/resource/generic.rb', line 62

def self.name
  @generic_cache_entry&.klass.equal?(self) ? @generic_display_name : super
end

.to_s ⇒ Object



66
67
68
# File 'lib/dnsruby/resource/generic.rb', line 66

def self.to_s
  @generic_cache_entry&.klass.equal?(self) ? @generic_display_name.dup : super
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



40
41
42
# File 'lib/dnsruby/resource/generic.rb', line 40

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_bytes(data)
end

#from_data(data) ⇒ Object

:nodoc: all



25
26
27
# File 'lib/dnsruby/resource/generic.rb', line 25

def from_data(data) #:nodoc: all
  @data = data[0]
end

#from_string(data) ⇒ Object

:nodoc: all



36
37
38
# File 'lib/dnsruby/resource/generic.rb', line 36

def from_string(data) #:nodoc: all
  @data = data
end

#rdata_to_string ⇒ Object

:nodoc: all



29
30
31
32
33
34
# File 'lib/dnsruby/resource/generic.rb', line 29

def rdata_to_string #:nodoc: all
  if (@data!=nil)
    return  "\\# " +  @data.length.to_s +  " " + @data.unpack("H*")[0]
  end
  return "#NO DATA"
end