(self,last=-1)
return DNSLabel(label)
Decode label at current offset in buffer (following pointers
            to cached elements where necessary)
Decode label at current offset in buffer (following pointers
            to cached elements where necessary)
Decode label at current offset in buffer ( following pointers to cached elements where necessary )
def decode_name(self,last=-1):
        """
            Decode label at current offset in buffer (following pointers
            to cached elements where necessary)
        """
        label = []
        done = False
        while not done:
            (length,) = self.unpack("!B")
            if get_bits(length,6,2) == 3:
                # Pointer
                self.offset -= 1
                pointer = get_bits(self.unpack("!H")[0],0,14)
                save = self.offset
                if last == save:
                    raise BufferError("Recursive pointer in DNSLabel [offset=%d,pointer=%d,length=%d]" % 
                            (self.offset,pointer,len(self.data)))
                if pointer < self.offset:
                    self.offset = pointer
                else:
                    # Pointer can't point forwards
                    raise BufferError("Invalid pointer in DNSLabel [offset=%d,pointer=%d,length=%d]" % 
                            (self.offset,pointer,len(self.data)))
                label.extend(self.decode_name(save).label)
                self.offset = save
                done = True
            else:
                if length > 0:
                    l = self.get(length)
                    try:
                        l.decode()
                    except UnicodeDecodeError:
                        raise BufferError("Invalid label <%s>" % l)
                    label.append(l)
                else:
                    done = True
        return DNSLabel(label)
def decode_name ( self , last = - 1 ) : label = [ ] done = False while not done : ( length , ) = self . unpack ( "!B" ) if get_bits ( length , 6 , 2 ) == 3 : # Pointer self . offset -= 1 pointer = get_bits ( self . unpack ( "!H" ) [ 0 ] , 0 , 14 ) save = self . offset if last == save : raise BufferError ( "Recursive pointer in DNSLabel [offset=%d,pointer=%d,length=%d]" % ( self . offset , pointer , len ( self . data ) ) ) if pointer < self . offset : self . offset = pointer else : # Pointer can't point forwards raise BufferError ( "Invalid pointer in DNSLabel [offset=%d,pointer=%d,length=%d]" % ( self . offset , pointer , len ( self . data ) ) ) label . extend ( self . decode_name ( save ) . label ) self . offset = save done = True else : if length > 0 : l = self . get ( length ) try : l . decode ( ) except UnicodeDecodeError : raise BufferError ( "Invalid label <%s>" % l ) label . append ( l ) else : done = True return DNSLabel ( label )