Beispiel #1
0
 def test(self, super_pack):
     inst = SCIONExtPacket()
     inst._l4_proto = 0x42
     super_pack.return_value = b"super"
     inst.ext_hdrs = []
     for idx, class_, len_, type_ in ((0, 0x1, 0x0, 0x0),
                                      (1, 0x2, 0x1, 0x11), (2, 0x3, 0x2,
                                                            0x1)):
         hdr = create_mock(["hdr_len", "EXT_CLASS", "EXT_TYPE", "pack"])
         hdr.EXT_CLASS = class_
         hdr.hdr_len.return_value = len_
         hdr.EXT_TYPE = type_
         hdr.pack.return_value = bytes(
             range(5 + len_ * ExtensionHeader.LINE_LEN))
         inst.ext_hdrs.append(hdr)
     expected = b"".join([
         b"super",
         bytes([0x2, 0x0, 0x0]),
         bytes(range(5)),
         bytes([0x3, 0x1, 0x11]),
         bytes(range(13)),
         bytes([0x42, 0x2, 0x1]),
         bytes(range(21)),
     ])
     # Call
     ntools.eq_(inst._inner_pack(), expected)
Beispiel #2
0
 def test_with_exts(self):
     inst = SCIONExtPacket()
     inst.ext_hdrs = [create_mock(["EXT_CLASS"]), 0]
     # Call
     ntools.eq_(inst._get_next_hdr(), inst.ext_hdrs[0].EXT_CLASS)
Beispiel #3
0
 def test_no_exts(self):
     inst = SCIONExtPacket()
     inst.ext_hdrs = []
     inst._l4_proto = 42
     # Call
     ntools.eq_(inst._get_next_hdr(), 42)
Beispiel #4
0
 def test(self, super_offset):
     inst = SCIONExtPacket()
     inst.ext_hdrs = ["a", "bb", "cccc"]
     super_offset.return_value = 42
     # Call
     ntools.eq_(inst._get_offset_len(), 49)