def _getResourceRecords(self, structure): ''' Given a DnsResourceRecordArray() structure, return a list of Resource Records as (dnstype, dnsclass, ttl, fqdn, adata) tuples. If a parser is available for the dnsclass, the 'rdata' field will be further parsed into its components (as a tuple if necessary). ''' ret = [] for fname, rr in structure.vsGetFields(): fqdn = self.getDnsName(*rr.dnsname.getTypeVal()) rdata = None if rr.rrtype == DNS_TYPE_A: rdata = vs_inet.reprIPv4Addr(rr.rdata.address) elif rr.rrtype == DNS_TYPE_NS: rdata = self.getDnsName(*rr.rdata.nsdname.getTypeVal()) elif rr.rrtype == DNS_TYPE_CNAME: rdata = self.getDnsName(*rr.rdata.cname.getTypeVal()) elif rr.rrtype == DNS_TYPE_SOA: rdata = (self.getDnsName(*rr.rdata.mname.getTypeVal()), self.getDnsName(*rr.rdata.rname.getTypeVal()), rr.rdata.serial, rr.rdata.refresh, rr.rdata.retry, rr.rdata.expire, rr.rdata.minimum) elif rr.rrtype == DNS_TYPE_PTR: rdata = self.getDnsName(*rr.rdata.ptrdname.getTypeVal()) elif rr.rrtype == DNS_TYPE_MX: rdata = (rr.rdata.preference, self.getDnsName(*rr.rdata.exchange.getTypeVal())) elif rr.rrtype == DNS_TYPE_TXT: rdata = rr.rdata.txtdata else: rdata = rr.rdata.bytez ret.append((rr.rrtype, rr.dnsclass, rr.ttl, fqdn, rdata)) return ret
def _getResourceRecords(self, structure): ''' Given a DnsResourceRecordArray() structure, return a list of Resource Records as (dnstype, dnsclass, ttl, fqdn, adata) tuples. If a parser is available for the dnsclass, the 'rdata' field will be further parsed into its components (as a tuple if necessary). ''' ret = [] for fname,rr in structure.vsGetFields(): fqdn = self.getDnsName(*rr.dnsname.getTypeVal()) rdata = None if rr.rrtype == DNS_TYPE_A: rdata = vs_inet.reprIPv4Addr(rr.rdata.address) elif rr.rrtype == DNS_TYPE_AAAA: rdata = vs_inet.reprIPv6Addr(rr.rdata.address) elif rr.rrtype == DNS_TYPE_NS: rdata = self.getDnsName(*rr.rdata.nsdname.getTypeVal()) elif rr.rrtype == DNS_TYPE_CNAME: rdata = self.getDnsName(*rr.rdata.cname.getTypeVal()) elif rr.rrtype == DNS_TYPE_SOA: rdata = (self.getDnsName(*rr.rdata.mname.getTypeVal()), self.getDnsName(*rr.rdata.rname.getTypeVal()), rr.rdata.serial, rr.rdata.refresh, rr.rdata.retry, rr.rdata.expire, rr.rdata.minimum) elif rr.rrtype == DNS_TYPE_PTR: rdata = self.getDnsName(*rr.rdata.ptrdname.getTypeVal()) elif rr.rrtype == DNS_TYPE_MX: rdata = (rr.rdata.preference, self.getDnsName(*rr.rdata.exchange.getTypeVal())) elif rr.rrtype == DNS_TYPE_TXT: rdata = rr.rdata.txtdata else: rdata = rr.rdata.bytez ret.append((rr.rrtype, rr.dnsclass, rr.ttl, fqdn, rdata)) return ret