Class: PacketGen::Header::DNS::OPT
- Inherits:
-
RR
show all
- Defined in:
- lib/packetgen/header/dns/opt.rb
Overview
OPT pseudo-RR. Used by Extended DNS (EDNS(0), cf. RFC 6891).
a OPT record may contain zero or more options in its RR#rdata.
Constant Summary
Constants inherited
from Question
Question::CLASSES, Question::TYPES
Instance Attribute Summary collapse
Attributes inherited from RR
#rdata, #rdlength, #ttl
Attributes inherited from Question
#name, #rrclass, #type
Instance Method Summary
collapse
Methods inherited from RR
#human_rdata, #human_rrclass
Methods inherited from Question
#human_rrclass, #human_type, #type?
#format_inspect, #read, #sz, #to_s, #type_name
#[], #[]=, #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 = {}) ⇒ OPT
Returns a new instance of OPT.
39
40
41
42
43
44
45
46
47
|
# File 'lib/packetgen/header/dns/opt.rb', line 39
def initialize(dns, options={})
opts = { name: '.', rrclass: 512, type: 41 }.merge!(options)
super(dns, opts)
self.udp_size = options[:udp_size] if options[:udp_size]
self.ext_rcode = options[:ext_rcode] if options[:ext_rcode]
self.version = options[:version] if options[:version]
self.do = options[:do] unless options[:do].nil?
end
|
Instance Attribute Details
23
|
# File 'lib/packetgen/header/dns/opt.rb', line 23
define_field_after :rdata, :options, ArrayOfOptions
|
Instance Method Details
#do=(value) ⇒ Boolean
#do? ⇒ Boolean
Also known as:
do?
91
92
93
94
95
96
97
98
|
# File 'lib/packetgen/header/dns/opt.rb', line 91
def do=(value=nil)
b = value ? 1 : 0
unless value.nil?
self[:ttl].value = self[:ttl].to_i & (0xffffffff & ~(1 << 15))
self[:ttl].value |= (b & 1) << 15
end
((self[:ttl].to_i >> 15) & 1) == 1
end
|
#ext_rcode=(value) ⇒ Integer
#ext_rcode ⇒ Integer
Also known as:
ext_rcode
57
58
59
60
61
62
63
|
# File 'lib/packetgen/header/dns/opt.rb', line 57
def ext_rcode=(value=nil)
if value
self[:ttl].value = self[:ttl].to_i & (0xffffffff & ~(0xff << 24))
self[:ttl].value |= (value & 0xff) << 24
end
(self[:ttl].to_i >> 24) & 0xff
end
|
#human_flags ⇒ String
122
123
124
|
# File 'lib/packetgen/header/dns/opt.rb', line 122
def human_flags
do? ? 'do' : 'none'
end
|
#to_human ⇒ String
127
128
129
130
131
|
# File 'lib/packetgen/header/dns/opt.rb', line 127
def to_human
"#{name} #{human_type} UDPsize:#{udp_size} " \
"extRCODE:#{ext_rcode} EDNSversion:#{version} flags:#{human_flags} " \
"options:#{options.empty? ? 'none' : options.to_human}"
end
|
#version=(ver) ⇒ Integer
#version ⇒ Integer
Also known as:
version
74
75
76
77
78
79
80
|
# File 'lib/packetgen/header/dns/opt.rb', line 74
def version=(ver=nil)
if ver
self[:ttl].value = self[:ttl].to_i & (0xffffffff & ~(0xff << 16))
self[:ttl].value |= (ver & 0xff) << 16
end
(self[:ttl].to_i >> 16) & 0xff
end
|
#z=(value) ⇒ Integer
#z ⇒ Integer
Also known as:
z
107
108
109
110
111
112
113
|
# File 'lib/packetgen/header/dns/opt.rb', line 107
def z=(value=nil)
if value
self[:ttl].value = self[:ttl].to_i & (0xffffffff & ~0x7fff)
self[:ttl].value |= value & 0x7fff
end
self[:ttl].to_i & 0x7fff
end
|