Exemplo n.º 1
0
Arquivo: flic.py Projeto: s3lph/PiCN
 def _indexTable2data(self, pfx: Name, decoder, end: int):
     # traverse the manifest tree
     # input: decoder with index table
     # output: reassembled data
     data = b''
     while decoder._offset < end:
         if decoder.peekType(NDN_TYPE_MANIFEST_DATAPTR, end):
             ptr = decoder.readBlobTlv(NDN_TYPE_MANIFEST_DATAPTR)
             # print("data ptr %s" % binascii.hexlify(ptr))
             name = copy.copy(pfx).setDigest(ptr)
             # print(name.to_json())
             chunk = self.icn.readChunk(name)
             data += NdnTlvEncoder().decode(chunk).get_bytes()
         elif decoder.peekType(NDN_TYPE_MANIFEST_MANIFESTPTR, end):
             ptr = decoder.readBlobTlv(NDN_TYPE_MANIFEST_MANIFESTPTR)
             # print("manifest ptr %s" % binascii.hexlify(ptr))
             name = copy.copy(pfx).setDigest(ptr)
             chunk = self.icn.readChunk(name)
             content = NdnTlvEncoder().decode(chunk)
             data += self._manifestToBytes(content.get_bytes())
         else:
             print("invalid index table entry")
             return data
     return data
Exemplo n.º 2
0
Arquivo: flic.py Projeto: s3lph/PiCN
 def bytesFromManifestName(self, name: Name):
     chunk = self.icn.readChunk(name)
     content = NdnTlvEncoder().decode(chunk)
     name._components.pop()  # drop the last component (e.g. '_')
     return self._manifestToBytes(name, content.get_bytes())