Class: Net::DNS::RR::ISDN

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

Overview

NAME

Net::DNS::RR::ISDN - DNS ISDN resource record

DESCRIPTION

Class for DNS ISDN 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 3.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

#_canonicalRdata, #_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

#addressObject

Returns the RR’s address field.

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


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

def address
  @address
end

#saObject

Returns the RR’s subaddress field.

print "subaddress = ", rr.sa, "\n"


53
54
55
# File 'lib/Net/DNS/RR/ISDN.rb', line 53

def sa
  @sa
end

Instance Method Details

#new_from_data(data, offset) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/Net/DNS/RR/ISDN.rb', line 54

def new_from_data(data, offset)
  if (@rdlength > 0)
    len = data.unpack("\@#{offset} C")[0];
    offset+=1;
    address = data[offset, len];
    offset += len;
    
    if (len + 1 < @rdlength)
      len = data.unpack("\@#{offset} C")[0];
      offset+=1;
      sa = data[offset, len];
      offset += len;
    else
      sa = "";
    end
    @address = address;
    @sa  = sa;
  end
end

#new_from_hash(values) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/Net/DNS/RR/ISDN.rb', line 87

def new_from_hash(values)
  if values.has_key?(:address)
    @address = values[:address]
  end
  if values.has_key?(:sa)
    @sa = values[:sa]
  end
end

#new_from_string(string) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/Net/DNS/RR/ISDN.rb', line 74

def new_from_string(string)
  if (string && string =~ /^['"](.*?)['"](.*)/s)
    @address = $1;
    rest = $2;
    
    if (rest =~ /^\s+['"](.*?)['"]$/)
      @sa = $1;
    else
      @sa = "";
    end
  end
end

#rdatastrObject



96
97
98
# File 'lib/Net/DNS/RR/ISDN.rb', line 96

def rdatastr
  return @address ? "'#{@address}' '#{@sa}'" : '';
end

#rr_rdata(*args) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/Net/DNS/RR/ISDN.rb', line 100

def rr_rdata(*args)
  rdata = "";
  
  if (defined?@address)
    rdata += [@address.length].pack("C");
    rdata += @address;
    
    if (@sa)
      rdata += [@sa.length].pack("C");
      rdata += @sa;
    end
  end
  
  return rdata;
end