# -*- coding: binary -*-
##
#
# Net::DNS::RR::HINFO
# $Id: HINFO.rb,v 1.4 2006/07/28 07:33:36 bluemonk Exp $
module Net
module DNS
class RR
#------------------------------------------------------------
# RR type HINFO
class HINFO < RR
attr_reader :cpu, :os
private
def check_hinfo(str)
if str.strip =~ /^["'](.*?)["']\s+["'](.*?)["']$/
return $1,$2
else
raise RRArgumentError, "HINFO section not valid: #{str.inspect}"
end
def build_pack
@hinfo_pack = [@cpu.size].pack("C") + @cpu
@hinfo_pack += [@os.size].pack("C") + @os
@rdlength = @hinfo_pack.size
def set_type
@type = Net::DNS::RR::Types.new("HINFO")
def get_data
@hinfo_pack
def get_inspect
"#@cpu #@os"
def subclass_new_from_hash(args)
if args.has_key? :cpu and args.has_key? :os
@cpu = args[:cpu]
@os = args[:os]
raise RRArgumentError, ":cpu and :os fields are mandatory but missing"
def subclass_new_from_string(str)
@cpu,@os = check_hinfo(str)
def subclass_new_from_binary(data,offset)
len = data.unpack("@#{offset} C")[0]
@cpu = data[offset+1..offset+1+len]
offset += len+1
@os = data[offset+1..offset+1+len]
return offset += len+1
end # class HINFO
end # class RR
end # module DNS
end # module Net