def test_IPv6_t(): # pylint: disable=line-too-long pkt = b"X\x01\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\xa8\x00\xee\xea\xec\xfa\xf9" stream = BitStreamReader(pkt) assert stream.byte() == 88 assert stream.byte() == 1 assert stream.bits(5) == 0 assert stream.bit() == 0 assert stream.bits(2) == 0 assert stream.byte() == 6 ipv6 = IPv6.deserialize(stream) assert ipv6 == ipaddress.ip_address("::ffff:c0a8:ee") streamWriter = BitStreamWriter() ipv6.serialize(streamWriter) assert ( streamWriter == b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\xa8\x00\xee")
def deserialize(cls, stream: BitStreamReader): """Deserialize metadata extension""" retval = {} while stream.bytesLeft(): metadataType = stream.bits(7) _critical = stream.bit() length = stream.byte() retval[metadataType] = stream.value(length) return retval