def decode_name(self): """ Decode label at current offset in buffer (following pointers to cached elements where necessary) """ label = [] done = False while not done: (len,) = self.unpack("!B") if get_bits(len,6,2) == 3: # Pointer self.offset -= 1 pointer = get_bits(self.unpack("!H")[0],0,14) save = self.offset self.offset = pointer label.extend(self.decode_name().label) self.offset = save done = True else: if len > 0: label.append(self.get(len)) else: done = True return DNSLabel(label)
def decode_name(self): """ Decode label at current offset in buffer (following pointers to cached elements where necessary) """ label = [] done = False while not done: (len, ) = self.unpack("!B") if get_bits(len, 6, 2) == 3: # Pointer self.offset -= 1 pointer = get_bits(self.unpack("!H")[0], 0, 14) save = self.offset self.offset = pointer label.extend(self.decode_name().label) self.offset = save done = True else: if len > 0: label.append(self.get(len)) else: done = True return DNSLabel(label)
def get_rcode(self): return get_bits(self.bitmap,0,4)
def get_ra(self): return get_bits(self.bitmap,7)
def get_rd(self): return get_bits(self.bitmap,8)
def get_tc(self): return get_bits(self.bitmap,9)
def get_aa(self): return get_bits(self.bitmap,10)
def get_opcode(self): return get_bits(self.bitmap,11,4)
def get_qr(self): return get_bits(self.bitmap,15)
def get_rcode(self): return get_bits(self.bitmap, 0, 4)
def get_ra(self): return get_bits(self.bitmap, 7)
def get_rd(self): return get_bits(self.bitmap, 8)
def get_tc(self): return get_bits(self.bitmap, 9)
def get_aa(self): return get_bits(self.bitmap, 10)
def get_opcode(self): return get_bits(self.bitmap, 11, 4)
def get_qr(self): return get_bits(self.bitmap, 15)