Class: Net::DNS::RR::RP

Inherits:
Net::DNS::RR show all
Defined in:
lib/Net/DNS/RR/RP.rb

Overview

NAME

Net::DNS::RR::RP - DNS RP resource record

DESCRIPTION

Class for DNS Responsible Person (RP) resource records.

COPYRIGHT

Copyright © 1997-2002 Michael Fuhr.

Portions Copyright © 2002-2004 Chris Reinhardt.

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, RFC 1183 Section 2.2

Constant Summary

Constants inherited from Net::DNS::RR

RRS

Instance Attribute Summary collapse

Attributes inherited from Net::DNS::RR

#name, #rdata, #rdlength, #rrclass, #ttl, #type

Instance Method Summary collapse

Methods inherited from Net::DNS::RR

#_canonicaldata, _get_subclass, _name2wire, #_name2wire, build_regex, create, #create_rrsort_func, #data, #get_rrsort_func, #init, #init_rrsort_func, #inspect, new_from_data, new_from_hash, new_from_string, #set_rrsort_func

Instance Attribute Details

#mboxObject

Returns a domain name that specifies the mailbox for the responsible person.

print "mbox = ", rr.mbox, "\n"


48
49
50
# File 'lib/Net/DNS/RR/RP.rb', line 48

def mbox
  @mbox
end

#txtdnameObject

Returns a domain name that specifies a TXT record containing further information about the responsible person.

print "txtdname = ", rr.txtdname, "\n"


54
55
56
# File 'lib/Net/DNS/RR/RP.rb', line 54

def txtdname
  @txtdname
end

Instance Method Details

#_canonicalRdataObject



96
97
98
99
100
101
102
103
104
# File 'lib/Net/DNS/RR/RP.rb', line 96

def _canonicalRdata
  rdata = "";
  if (defined?@mbox)
    rdata += _name2wire(@mbox);
    rdata += _name2wire(@txtdname);
  end
  
  return rdata;
end

#new_from_data(data, offset) ⇒ Object



55
56
57
58
59
60
# File 'lib/Net/DNS/RR/RP.rb', line 55

def new_from_data(data, offset)
  if (@rdlength > 0)
   (@mbox,     offset) = Net::DNS::Packet::dn_expand(data, offset);
   (@txtdname, offset) = Net::DNS::Packet::dn_expand(data, offset);
  end
end

#new_from_hash(values) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/Net/DNS/RR/RP.rb', line 71

def new_from_hash(values)
  if values.has_key?(:mbox)
    @mbox = values[:mbox]
  end
  if values.has_key?(:txtdname)
    @txtdname = values[:txtdname]
  end
end

#new_from_string(string) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/Net/DNS/RR/RP.rb', line 62

def new_from_string(string)
  if (string && (string =~ /^(\S+)\s+(\S+)$/))
    @mbox     = $1;
    @txtdname = $2;
    @mbox.sub!(/\.+$/,"");
    @txtdname.sub!(/\.+$/,"");
  end
end

#rdatastrObject



80
81
82
# File 'lib/Net/DNS/RR/RP.rb', line 80

def rdatastr
  return @mbox ? "#{@mbox}. #{@txtdname}." : '';
end

#rr_rdata(packet, offset) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/Net/DNS/RR/RP.rb', line 84

def rr_rdata(packet, offset)
  rdata = "";
  
  if (defined?@mbox)
    rdata += packet.dn_comp(@mbox, offset);
    rdata += packet.dn_comp(@txtdname, offset + rdata.length);
  end
  
  return rdata;
end