Class: Net::DNS::RR::HINFO

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

Overview

RFC 1035 Section 3.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

#cpuObject

print “cpu = ”, rr.cpu, “n”



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

def cpu
  @cpu
end

#osObject

Returns the operating system type for this RR.

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


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

def os
  @os
end

Instance Method Details

#new_from_data(data, offset) ⇒ Object



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

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

#new_from_hash(values) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/Net/DNS/RR/HINFO.rb', line 79

def new_from_hash(values)
  if values.has_key?(:cpu)
    @cpu = values[:cpu]
  end
  if values.has_key?(:os)
    @os = values[:os]
  end
end

#new_from_string(string) ⇒ Object



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

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

#rdatastrObject



88
89
90
# File 'lib/Net/DNS/RR/HINFO.rb', line 88

def rdatastr
  return @cpu ? "'#{@cpu}' '#{@os}'" : '';
end

#rr_rdata(*args) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/Net/DNS/RR/HINFO.rb', line 92

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