コード例 #1
0
def get_ID(fname):  # CHANGE BY LORA_LINK
    try:
        p = PCAP(fname)
        p.open('r')
        fid = ''
        for w in p:
            e = cbor2.loads(w)
            href = hashlib.sha256(e[0]).digest()
            e[0] = cbor2.loads(e[0])
            #e[0] = base64ify(e[0])
            fid = e[0][0]
        return fid
    except:
        print('ERROR: currupted pcap file')
        return 0
コード例 #2
0
ファイル: pcap.py プロジェクト: PatrickSteiner311/BACnet
def dump(fname):
    p = PCAP(fname)
    p.open('r')
    for w in p:
        # here we apply our knowledge about the event/pkt's internal struct
        e = cbor2.loads(w)
        href = hashlib.sha256(e[0]).digest()
        e[0] = cbor2.loads(e[0])
        # rewrite the packet's byte arrays for pretty printing:
        e[0] = base64ify(e[0])
        fid = e[0][0]
        seq = e[0][1]
        if e[2] != None:
            e[2] = cbor2.loads(e[2])
        print("** fid={fid}, seq={seq}, ${len(w)} bytes")
        print("   hashref={href.hex()}")
        print("   content={e[2]}")
    p.close()
コード例 #3
0
def dump(fname):
    p = PCAP(fname)
    p.open('r')
    for w in p:
        # here we apply our knowledge about the event/pkt's internal struct
        e = cbor2.loads(w)
        href = hashlib.sha256(e[0]).digest()
        e[0] = cbor2.loads(e[0])
        # rewrite the packet's byte arrays for pretty printing:
        e[0] = base64ify(e[0])
        fid = e[0][0]
        seq = e[0][1]
        if e[2] != None:
            e[2] = cbor2.loads(e[2])
        print("** fid=" + str(fid) + ", seq=" + str(seq) + ", " + str(len(w)) +
              " bytes")  #CHANGES FOR LOPY4
        print("   hashref=" + str(binascii.hexlify(href)))  #CHANGES FOR LOPY4
        print("   content=" + str(e[2]))  #CHANGES FOR LOPY4
    p.close()
コード例 #4
0
def deserialize(s):
    return cbor2.loads(s)