def test_default_args(self): ip = ipv6.ipv6() buf = ip.serialize(bytearray(), None) res = struct.unpack(ipv6.ipv6._PACK_STR, str(buf)) eq_(res[0], 6 << 28) eq_(res[1], 0) eq_(res[2], 6) eq_(res[3], 255) eq_(res[4], addrconv.ipv6.text_to_bin('::')) eq_(res[5], addrconv.ipv6.text_to_bin('::')) # with extension header ip = ipv6.ipv6( nxt=0, ext_hdrs=[ ipv6.hop_opts(58, 0, [ ipv6.option(5, 2, '\x00\x00'), ipv6.option(1, 0, None)])]) buf = ip.serialize(bytearray(), None) res = struct.unpack(ipv6.ipv6._PACK_STR + '8s', str(buf)) eq_(res[0], 6 << 28) eq_(res[1], 8) eq_(res[2], 0) eq_(res[3], 255) eq_(res[4], addrconv.ipv6.text_to_bin('::')) eq_(res[5], addrconv.ipv6.text_to_bin('::')) eq_(res[6], '\x3a\x00\x05\x02\x00\x00\x01\x00')
def test_default_args(self): ip = ipv6.ipv6() buf = ip.serialize(bytearray(), None) res = struct.unpack(ipv6.ipv6._PACK_STR, str(buf)) eq_(res[0], 6 << 28) eq_(res[1], 0) eq_(res[2], 6) eq_(res[3], 255) eq_(res[4], addrconv.ipv6.text_to_bin('::')) eq_(res[5], addrconv.ipv6.text_to_bin('::')) # with extension header ip = ipv6.ipv6( nxt=0, ext_hdrs=[ ipv6.hop_opts( 58, 0, [ipv6.option(5, 2, '\x00\x00'), ipv6.option(1, 0, None)]) ]) buf = ip.serialize(bytearray(), None) res = struct.unpack(ipv6.ipv6._PACK_STR + '8s', str(buf)) eq_(res[0], 6 << 28) eq_(res[1], 8) eq_(res[2], 0) eq_(res[3], 255) eq_(res[4], addrconv.ipv6.text_to_bin('::')) eq_(res[5], addrconv.ipv6.text_to_bin('::')) eq_(res[6], '\x3a\x00\x05\x02\x00\x00\x01\x00')