Class: Net::DNS::RR::PX
- Inherits:
-
Net::DNS::RR
- Object
- Net::DNS::RR
- Net::DNS::RR::PX
- Defined in:
- lib/Net/DNS/RR/PX.rb
Overview
NAME
Net::DNS::RR::PX - DNS PX resource record
DESCRIPTION
Class for DNS X.400 Mail Mapping Information (PX) resource records.
COPYRIGHT
Copyright © 1997-2002 Michael Fuhr.
Portions Copyright © 2002-2004 Chris Reinhardt. Portions Copyright © 2005 Olaf Kolkman NLnet Labs. Ruby version Copyright © 2006 Alexd ( Nominet UK ).
All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC822, RFC 1327, RFC 2163
Constant Summary
Constants inherited from Net::DNS::RR
Instance Attribute Summary collapse
-
#map822 ⇒ Object
Returns the RFC822 part of the RFC1327 mapping information.
-
#mapx400 ⇒ Object
Returns the X.400 part of the RFC1327 mapping information.
-
#preference ⇒ Object
Returns the preference given to this RR.
Attributes inherited from Net::DNS::RR
#name, #rdata, #rdlength, #rrclass, #ttl, #type
Instance Method Summary collapse
- #_canonicalRdata ⇒ Object
-
#init_rrsort_func ⇒ Object
Highest preference sorted first.
- #new_from_data(data, offset) ⇒ Object
- #new_from_hash(values) ⇒ Object
- #new_from_string(string) ⇒ Object
- #rdatastr ⇒ Object
- #rr_rdata(packet, offset) ⇒ Object
Methods inherited from Net::DNS::RR
#_canonicaldata, _get_subclass, #_name2wire, _name2wire, build_regex, create, #create_rrsort_func, #data, #get_rrsort_func, #init, #inspect, new_from_data, new_from_hash, new_from_string, #set_rrsort_func
Instance Attribute Details
#map822 ⇒ Object
Returns the RFC822 part of the RFC1327 mapping information.
print "map822 = ", rr.map822, "\n"
53 54 55 |
# File 'lib/Net/DNS/RR/PX.rb', line 53 def map822 @map822 end |
#mapx400 ⇒ Object
Returns the X.400 part of the RFC1327 mapping information.
print "mapx400 = ", rr.mapx400, "\n"
58 59 60 |
# File 'lib/Net/DNS/RR/PX.rb', line 58 def mapx400 @mapx400 end |
#preference ⇒ Object
Returns the preference given to this RR.
print "preference = ", rr.preference, "\n"
48 49 50 |
# File 'lib/Net/DNS/RR/PX.rb', line 48 def preference @preference end |
Instance Method Details
#_canonicalRdata ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/Net/DNS/RR/PX.rb', line 117 def _canonicalRdata rdata = ""; if (defined?@preference) rdata += [@preference].pack("n"); rdata += _name2wire(@map822); rdata += _name2wire(@mapx400); end return rdata; end |
#init_rrsort_func ⇒ Object
Highest preference sorted first.
61 62 63 64 |
# File 'lib/Net/DNS/RR/PX.rb', line 61 def init_rrsort_func set_rrsort_func("preference", Proc.new { |a,b| a.preference <=> b.preference}); set_rrsort_func("default_sort", get_rrsort_func("preference")); end |
#new_from_data(data, offset) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/Net/DNS/RR/PX.rb', line 66 def new_from_data(data, offset) if (@rdlength > 0) @preference = data.unpack("\@#{offset} n")[0]; offset += Net::DNS::INT16SZ; (@map822, offset) = Net::DNS::Packet::(data, offset); (@mapx400, offset) = Net::DNS::Packet::(data, offset); end end |
#new_from_hash(values) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/Net/DNS/RR/PX.rb', line 86 def new_from_hash(values) if values.has_key?(:preference) @preference = values[:preference] end if values.has_key?(:map822) @map822 = values[:map822] end if values.has_key?(:mapx400) @mapx400 = values[:mapx400] end end |
#new_from_string(string) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/Net/DNS/RR/PX.rb', line 76 def new_from_string(string) if (string && (string =~ /^(\d+)\s+(\S+)\s+(\S+)$/)) @preference = $1; @map822 = $2; @mapx400 = $3; @map822.sub!(/\.+$/,"") @mapx400.sub!(/\.+$/,"") end end |
#rdatastr ⇒ Object
98 99 100 |
# File 'lib/Net/DNS/RR/PX.rb', line 98 def rdatastr return @preference ? "#{@preference} #{@map822}. #{@mapx400}." : ''; end |
#rr_rdata(packet, offset) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/Net/DNS/RR/PX.rb', line 102 def rr_rdata(packet, offset) rdata = ""; if (defined?@preference) rdata += [@preference].pack("n"); rdata += packet.dn_comp(@map822, offset + rdata.length); rdata += packet.dn_comp(@mapx400, offset + rdata.length); end return rdata; end |