예제 #1
0
 def _parse(self, raw):
     data = Raw(raw, self.NAME, self.MIN_LEN, min_=True)
     src_type = data.pop(1)
     dst_type = data.pop(1)
     self.src = SCIONAddr((src_type, data.get()))
     data.pop(len(self.src))
     self.dst = SCIONAddr((dst_type, data.get()))
     data.pop(len(self.dst))
     padding_len = len(data) % OpaqueField.LEN
     self.path = parse_path(data.pop(len(data) - padding_len))
예제 #2
0
 def _parse_path(self, data):
     count = self.cmn_hdr.hdr_len - data.offset()
     if count < 0:
         raise SCIONParseError(
             "Bad header len field (%sB), implies negative path length" %
             self.cmn_hdr.hdr_len, )
     if count > len(data):
         raise SCIONParseError(
             "Bad header len field (%sB), "
             "implies path is longer than packet (%sB)" %
             (self.cmn_hdr.hdr_len, len(data) + data.offset()))
     self.path = parse_path(data.get(count))
     data.pop(len(self.path))
     iof_idx, hof_idx = self.cmn_hdr.get_of_idxs()
     self.path.set_of_idxs(iof_idx, hof_idx)