Permalink
Browse files

added support to decode rrdata for A IN records

  • Loading branch information...
1 parent 5ac27cc commit eb053955c437870c19a1c317df1e40c3100b14e7 Joe Ferner committed Nov 16, 2011
Showing with 14 additions and 0 deletions.
  1. +14 −0 pcap.js
View
14 pcap.js
@@ -759,6 +759,15 @@ var dns_util = {
return dns_util.class_to_string(qclass_num);
}
},
+ expandRRData: function(raw_packet, offset, rrRecord) {
+ if(rrRecord.rrtype == 'A' && rrRecord.rrclass == 'IN' && rrRecord.rdlength == 4) {
+ var data = {};
+ data.ipAddress = raw_packet[offset] + '.' + raw_packet[offset+1] + '.' + raw_packet[offset+2] + '.' + raw_packet[offset+3];
+ return data;
+ }
+
+ return null;
+ },
readName: function(raw_packet, offset, internal_offset, result) {
var lenOrPtr = raw_packet[offset + internal_offset];
internal_offset++;
@@ -804,6 +813,11 @@ var dns_util = {
result.rdlength = unpack.uint16(raw_packet, internal_offset);
internal_offset += 2;
+ var data = dns_util.expandRRData(raw_packet, internal_offset, result);
+ if(data) {
+ result.rddata = data;
+ }
+
// skip rdata. TODO: store the rdata somewhere?
internal_offset += result.rdlength;

0 comments on commit eb05395

Please sign in to comment.