def get_rddata(self, l, type, dlen, beg_index): if beg_index + dlen > len(l): raise Trunc('(dns) truncated rdata') # A if type == 1: if dlen != 4: raise Exception('(dns) invalid a data size', system='packet') return IPAddr(l[beg_index:beg_index + 4]) # AAAA elif type == 28: if dlen != 16: raise Exception('(dns) invalid a data size', system='packet') return IPAddr6.from_raw(l[beg_index:beg_index + dlen]) # NS elif type == 2: return self.read_dns_name_from_index(l, beg_index)[1] # PTR elif type == 12: return self.read_dns_name_from_index(l, beg_index)[1] # CNAME elif type == 5: return self.read_dns_name_from_index(l, beg_index)[1] # MX elif type == 15: #TODO: Save priority (don't just jump past it) return self.read_dns_name_from_index(l, beg_index + 2)[1] else: return l[beg_index:beg_index + dlen]
def get_rddata(self, l, type, dlen, beg_index): if beg_index + dlen > len(l): raise Trunc('(dns) truncated rdata') # A if type == 1: if dlen != 4: raise Exception('(dns) invalid a data size',system='packet') return IPAddr(l[beg_index : beg_index + 4]) # AAAA elif type == 28: if dlen != 16: raise Exception('(dns) invalid a data size',system='packet') return IPAddr6.from_raw(l[beg_index : beg_index + dlen]) # NS elif type == 2: return self.read_dns_name_from_index(l, beg_index)[1] # PTR elif type == 12: return self.read_dns_name_from_index(l, beg_index)[1] # CNAME elif type == 5: return self.read_dns_name_from_index(l, beg_index)[1] # MX elif type == 15: #TODO: Save priority (don't just jump past it) return self.read_dns_name_from_index(l, beg_index + 2)[1] else: return l[beg_index : beg_index + dlen]
def ip6(addr): if addr is None: return None return IPAddr6.from_raw(addr)
def ip6(addr): if addr is None: return None return IPAddr6.from_raw(addr)