Exemplo n.º 1
0
    def unpack(self, packet):
       """
       Checks the CRC and unpacks the header and payload.

       Header and payload fields are unpacked into the class variables.
       Returns True if unpacking is successful, False if there are any
          errors or the CRC check fails
       """
       (crc_ok, checked_pkt) = gru.check_crc32(packet)
       if not crc_ok:
          if self.verbose:
             print "CRC check failed."
          return False
       hdr_len = self.unpack_header(checked_pkt)
       self.payload = checked_pkt[hdr_len:]
       return True
Exemplo n.º 2
0
def unmake_packet(whitened_payload_with_footer, whitener_offset=0, dewhitening=1):
    """
    Return (ok, payload)

    @param whitened_payload_with_footer: string
    @param whitener_offset        offset into whitener string to use [0-16)
    @param dewhitening:           Turn whitener on or off
    @type  dewhitening:           bool
    """
    
    if dewhitening:
        payload_with_footer = dewhiten(whitened_payload_with_footer[:-flex.CODED_OFDM_FOOTERLEN_BYTES], whitener_offset) + whitened_payload_with_footer[-flex.CODED_OFDM_FOOTERLEN_BYTES:]
    else:
        payload_with_footer = whitened_payload_with_footer

    # TODO: check if CRC works, why -1?
    ok, payload = gru.check_crc32(payload_with_footer[:-1]) # strip off tail + pad

    return ok, payload_with_footer
Exemplo n.º 3
0
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True):
    """
    Return (ok, payload)

    @param whitened_payload_with_crc: string
    """

    if dewhitening:
        payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset)
    else:
        payload_with_crc = (whitened_payload_with_crc)

    ok, payload = gru.check_crc32(payload_with_crc)

    if 0:
        print "payload_with_crc =", string_to_hex_list(payload_with_crc)
        print "ok = %r, len(payload) = %d" % (ok, len(payload))
        print "payload =", string_to_hex_list(payload)

    return ok, payload
Exemplo n.º 4
0
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True):
    """
    Return (ok, payload)

    @param whitened_payload_with_crc: string
    """

    if dewhitening:
        payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset)
    else:
        payload_with_crc = (whitened_payload_with_crc)

    ok, payload = gru.check_crc32(payload_with_crc)

    if 0:
        print "payload_with_crc =", string_to_hex_list(payload_with_crc)
        print "ok = %r, len(payload) = %d" % (ok, len(payload))
        print "payload =", string_to_hex_list(payload)

    return ok, payload
Exemplo n.º 5
0
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1):
    """
    Return (ok, payload)

    @param whitened_payload_with_crc: string
    @param whitener_offset        offset into whitener string to use [0-16)
    @param dewhitening:           Turn whitener on or off
    @type  dewhitening:           bool
    """

    if dewhitening:
        payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset)
    else:
        payload_with_crc = whitened_payload_with_crc

    ok, payload = gru.check_crc32(payload_with_crc)

    #if 0:
    #    print "payload_with_crc =", string_to_hex_list(payload_with_crc)
    #    print "ok = %r, len(payload) = %d" % (ok, len(payload))
    #    print "payload =", string_to_hex_list(payload)

    return ok, payload
Exemplo n.º 6
0
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1):
    """
    Return (ok, payload)

    @param whitened_payload_with_crc: string
    @param whitener_offset        offset into whitener string to use [0-16)
    @param dewhitening:           Turn whitener on or off
    @type  dewhitening:           bool
    """

    if dewhitening:
        payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset)
    else:
        payload_with_crc = whitened_payload_with_crc

    ok, payload = gru.check_crc32(payload_with_crc)

    if 0:
        print "payload_with_crc =", string_to_hex_list(payload_with_crc)
        print "ok = %r, len(payload) = %d" % (ok, len(payload))
        print "payload =", string_to_hex_list(payload)

    return ok, payload