Exemple #1
0
 def test(self, raw, scmp_info):
     inst = SCMPPayload()
     data = create_mock(["pop"])
     data.pop.side_effect = (
         bytes.fromhex("0102030405060700"),
         "info",
         "cmn hdr",
         "addrs",
         "path",
         "exts",
         "l4 hdr",
     )
     raw.return_value = data
     # Call
     inst._parse("class", "type", "data")
     # Tests
     raw.assert_called_once_with("data", inst.NAME)
     ntools.eq_(inst.l4_proto, 0x07)
     pop_calls = [call(inst.META_LEN)
                  ] + [call(x * LINE_LEN) for x in range(1, 7)]
     assert_these_calls(data.pop, pop_calls)
     scmp_info.assert_called_once_with("class", "type", "info")
     ntools.eq_(inst.info, scmp_info.return_value)
     ntools.eq_(inst._cmn_hdr, "cmn hdr")
     ntools.eq_(inst._addrs, "addrs")
     ntools.eq_(inst._path, "path")
     ntools.eq_(inst._exts, "exts")
     ntools.eq_(inst._l4_hdr, "l4 hdr")
Exemple #2
0
 def _setup(self):
     inst = SCMPPayload()
     inst._cmn_hdr = b"cmn hdr "
     inst._addrs = b"addr hdr"
     inst._path = b"path hdr"
     inst._exts = b"ext hdrs"
     inst._l4_hdr = b"l4 proto header "
     inst.l4_proto = 42
     return inst
Exemple #3
0
 def parse_payload(self):
     if not self.l4_hdr:
         raise SCIONParseError("Cannot parse payload of non-L4 packet")
     praw = self._payload.pack()
     if self.l4_hdr.TYPE == L4Proto.UDP:
         # Treat as SCION control message
         pld = SignedCtrlPayload.from_raw(praw).pld()
     elif self.l4_hdr.TYPE == L4Proto.SCMP:
         pld = SCMPPayload((self.l4_hdr.class_, self.l4_hdr.type, praw))
     self.set_payload(pld)
     return pld
Exemple #4
0
 def _parse_pld_scmp(self, data):  # pragma: no cover
     return SCMPPayload((self.l4_hdr.class_, self.l4_hdr.type, data.pop()))
Exemple #5
0
 def _setup(self):
     inst = SCMPPayload()
     inst._pack_meta = create_mock()
     inst._pack_meta.return_value = b"metadata"
     return inst