Class: PacketGen::Header::DNS

Inherits:
Object
  • Object
show all
Defined in:
lib/pcap2json/packetgen_extensions.rb

Instance Method Summary collapse

Instance Method Details

#to_hObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/pcap2json/packetgen_extensions.rb', line 61

def to_h 
  data = Hash.new
  data["id"] = self.id
  #data[:flags] = self.flags
  data["opcode"] = self.opcode
  data["rcode"] = self.rcode
  data["qdcount"] = self.qdcount
  data["ancount"] = self.ancount
  data["nscount"] = self.nscount
  data["arcount"] = self.arcount
  data["qd"] = []
  data["an"] = []
  data["ns"] = []
  data["ar"] = []
  self.qd.to_a.each do |qd|
    data["qd"] << qd.to_human
  end
  self.an.to_a.each do |an|
    data["an"] << an.to_human
  end
  self.ns.to_a.each do |ns|
    data["ns"] << ns.to_human 
  end
  self.ar.to_a.each do |ar|
    data["ar"] << ar.to_human 
  end
  data
end