1*7dc08ffcSJunyu Lai% Regression tests for Scapy 2*7dc08ffcSJunyu Lai 3*7dc08ffcSJunyu Lai# More informations at http://www.secdev.org/projects/UTscapy/ 4*7dc08ffcSJunyu Lai 5*7dc08ffcSJunyu Lai############ 6*7dc08ffcSJunyu Lai############ 7*7dc08ffcSJunyu Lai+ Informations on Scapy 8*7dc08ffcSJunyu Lai 9*7dc08ffcSJunyu Lai= Get conf 10*7dc08ffcSJunyu Lai~ conf command 11*7dc08ffcSJunyu Lai* Dump the current configuration 12*7dc08ffcSJunyu Laiconf 13*7dc08ffcSJunyu Lai 14*7dc08ffcSJunyu LaiIP().src 15*7dc08ffcSJunyu Laiscapy.consts.LOOPBACK_INTERFACE 16*7dc08ffcSJunyu Lai 17*7dc08ffcSJunyu Lai= List layers 18*7dc08ffcSJunyu Lai~ conf command 19*7dc08ffcSJunyu Lails() 20*7dc08ffcSJunyu Lai 21*7dc08ffcSJunyu Lai= List commands 22*7dc08ffcSJunyu Lai~ conf command 23*7dc08ffcSJunyu Lailsc() 24*7dc08ffcSJunyu Lai 25*7dc08ffcSJunyu Lai= List contribs 26*7dc08ffcSJunyu Laidef test_list_contrib(): 27*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 28*7dc08ffcSJunyu Lai list_contrib() 29*7dc08ffcSJunyu Lai result_list_contrib = cmco.get_output() 30*7dc08ffcSJunyu Lai assert("http2 : HTTP/2 (RFC 7540, RFC 7541) status=loads" in result_list_contrib) 31*7dc08ffcSJunyu Lai assert(len(result_list_contrib.split('\n')) > 40) 32*7dc08ffcSJunyu Lai 33*7dc08ffcSJunyu Laitest_list_contrib() 34*7dc08ffcSJunyu Lai 35*7dc08ffcSJunyu Lai= Configuration 36*7dc08ffcSJunyu Lai~ conf 37*7dc08ffcSJunyu Laiconf.debug_dissector = True 38*7dc08ffcSJunyu Lai 39*7dc08ffcSJunyu Lai 40*7dc08ffcSJunyu Lai########### 41*7dc08ffcSJunyu Lai########### 42*7dc08ffcSJunyu Lai= UTscapy route check 43*7dc08ffcSJunyu Lai* Check that UTscapy has correctly replaced the routes. Many tests won't work otherwise 44*7dc08ffcSJunyu Lai 45*7dc08ffcSJunyu Laiif WINDOWS: 46*7dc08ffcSJunyu Lai route_add_loopback() 47*7dc08ffcSJunyu Lai 48*7dc08ffcSJunyu LaiIP().src 49*7dc08ffcSJunyu Laiassert _ == "127.0.0.1" 50*7dc08ffcSJunyu Lai 51*7dc08ffcSJunyu Lai############ 52*7dc08ffcSJunyu Lai############ 53*7dc08ffcSJunyu Lai+ Scapy functions tests 54*7dc08ffcSJunyu Lai 55*7dc08ffcSJunyu Lai= Interface related functions 56*7dc08ffcSJunyu Lai 57*7dc08ffcSJunyu Laiget_if_raw_hwaddr(conf.iface) 58*7dc08ffcSJunyu Lai 59*7dc08ffcSJunyu Laibytes_hex(get_if_raw_addr(conf.iface)) 60*7dc08ffcSJunyu Lai 61*7dc08ffcSJunyu Laidef get_dummy_interface(): 62*7dc08ffcSJunyu Lai """Returns a dummy network interface""" 63*7dc08ffcSJunyu Lai if WINDOWS: 64*7dc08ffcSJunyu Lai data = {} 65*7dc08ffcSJunyu Lai data["name"] = "dummy0" 66*7dc08ffcSJunyu Lai data["description"] = "Does not exist" 67*7dc08ffcSJunyu Lai data["win_index"] = -1 68*7dc08ffcSJunyu Lai data["guid"] = "{1XX00000-X000-0X0X-X00X-00XXXX000XXX}" 69*7dc08ffcSJunyu Lai data["invalid"] = True 70*7dc08ffcSJunyu Lai dummy_int = NetworkInterface(data) 71*7dc08ffcSJunyu Lai dummy_int.pcap_name = "\\Device\\NPF_" + data["guid"] 72*7dc08ffcSJunyu Lai conf.cache_ipaddrs[dummy_int.pcap_name] = b'\x7f\x00\x00\x01' 73*7dc08ffcSJunyu Lai return dummy_int 74*7dc08ffcSJunyu Lai else: 75*7dc08ffcSJunyu Lai return "dummy0" 76*7dc08ffcSJunyu Lai 77*7dc08ffcSJunyu Laiget_if_raw_addr(get_dummy_interface()) 78*7dc08ffcSJunyu Lai 79*7dc08ffcSJunyu Laiget_if_list() 80*7dc08ffcSJunyu Lai 81*7dc08ffcSJunyu Laiget_if_raw_addr6(conf.iface6) 82*7dc08ffcSJunyu Lai 83*7dc08ffcSJunyu Lai= Test read_routes6() - default output 84*7dc08ffcSJunyu Lai 85*7dc08ffcSJunyu Lairoutes6 = read_routes6() 86*7dc08ffcSJunyu Laiif WINDOWS: 87*7dc08ffcSJunyu Lai route_add_loopback(routes6, True) 88*7dc08ffcSJunyu Lai 89*7dc08ffcSJunyu Lairoutes6 90*7dc08ffcSJunyu Lai 91*7dc08ffcSJunyu Lai# Expected results: 92*7dc08ffcSJunyu Lai# - one route if there is only the loopback interface 93*7dc08ffcSJunyu Lai# - three routes if there is a network interface 94*7dc08ffcSJunyu Lai 95*7dc08ffcSJunyu Laiif routes6: 96*7dc08ffcSJunyu Lai iflist = get_if_list() 97*7dc08ffcSJunyu Lai if WINDOWS: 98*7dc08ffcSJunyu Lai route_add_loopback(ipv6=True, iflist=iflist) 99*7dc08ffcSJunyu Lai if iflist == [LOOPBACK_NAME]: 100*7dc08ffcSJunyu Lai len(routes6) == 1 101*7dc08ffcSJunyu Lai elif len(iflist) >= 2: 102*7dc08ffcSJunyu Lai len(routes6) >= 3 103*7dc08ffcSJunyu Lai else: 104*7dc08ffcSJunyu Lai False 105*7dc08ffcSJunyu Laielse: 106*7dc08ffcSJunyu Lai # IPv6 seems disabled. Force a route to ::1 107*7dc08ffcSJunyu Lai conf.route6.routes.append(("::1", 128, "::", LOOPBACK_NAME, ["::1"], 1)) 108*7dc08ffcSJunyu Lai True 109*7dc08ffcSJunyu Lai 110*7dc08ffcSJunyu Lai= Test read_routes6() - check mandatory routes 111*7dc08ffcSJunyu Lai 112*7dc08ffcSJunyu Laiif len(routes6): 113*7dc08ffcSJunyu Lai assert(len([r for r in routes6 if r[0] == "::1" and r[4] == ["::1"]]) >= 1) 114*7dc08ffcSJunyu Lai if len(iflist) >= 2: 115*7dc08ffcSJunyu Lai assert(len([r for r in routes6 if r[0] == "fe80::" and r[1] == 64]) >= 1) 116*7dc08ffcSJunyu Lai len([r for r in routes6 if in6_islladdr(r[0]) and r[1] == 128 and r[4] == ["::1"]]) >= 1 117*7dc08ffcSJunyu Laielse: 118*7dc08ffcSJunyu Lai True 119*7dc08ffcSJunyu Lai 120*7dc08ffcSJunyu Lai= Test ifchange() 121*7dc08ffcSJunyu Laiconf.route6.ifchange(LOOPBACK_NAME, "::1/128") 122*7dc08ffcSJunyu LaiTrue 123*7dc08ffcSJunyu Lai 124*7dc08ffcSJunyu Lai 125*7dc08ffcSJunyu Lai############ 126*7dc08ffcSJunyu Lai############ 127*7dc08ffcSJunyu Lai+ Main.py tests 128*7dc08ffcSJunyu Lai 129*7dc08ffcSJunyu Lai= Pickle and unpickle a packet 130*7dc08ffcSJunyu Lai 131*7dc08ffcSJunyu Laiimport scapy.modules.six as six 132*7dc08ffcSJunyu Lai 133*7dc08ffcSJunyu Laia = IP(dst="192.168.0.1")/UDP() 134*7dc08ffcSJunyu Lai 135*7dc08ffcSJunyu Laib = six.moves.cPickle.dumps(a) 136*7dc08ffcSJunyu Laic = six.moves.cPickle.loads(b) 137*7dc08ffcSJunyu Lai 138*7dc08ffcSJunyu Laiassert c[IP].dst == "192.168.0.1" 139*7dc08ffcSJunyu Laiassert raw(c) == raw(a) 140*7dc08ffcSJunyu Lai 141*7dc08ffcSJunyu Lai= Usage test 142*7dc08ffcSJunyu Lai 143*7dc08ffcSJunyu Laifrom scapy.main import _usage 144*7dc08ffcSJunyu Laitry: 145*7dc08ffcSJunyu Lai _usage() 146*7dc08ffcSJunyu Lai assert False 147*7dc08ffcSJunyu Laiexcept SystemExit: 148*7dc08ffcSJunyu Lai assert True 149*7dc08ffcSJunyu Lai 150*7dc08ffcSJunyu Lai= Session test 151*7dc08ffcSJunyu Lai 152*7dc08ffcSJunyu Lai# This is automatic when using the console 153*7dc08ffcSJunyu Laidef get_var(var): 154*7dc08ffcSJunyu Lai return six.moves.builtins.__dict__["scapy_session"][var] 155*7dc08ffcSJunyu Lai 156*7dc08ffcSJunyu Laidef set_var(var, value): 157*7dc08ffcSJunyu Lai six.moves.builtins.__dict__["scapy_session"][var] = value 158*7dc08ffcSJunyu Lai 159*7dc08ffcSJunyu Laidef del_var(var): 160*7dc08ffcSJunyu Lai del(six.moves.builtins.__dict__["scapy_session"][var]) 161*7dc08ffcSJunyu Lai 162*7dc08ffcSJunyu Laiinit_session(None, {"init_value": 123}) 163*7dc08ffcSJunyu Laiset_var("test_value", "8.8.8.8") # test_value = "8.8.8.8" 164*7dc08ffcSJunyu Laisave_session() 165*7dc08ffcSJunyu Laidel_var("test_value") 166*7dc08ffcSJunyu Laiload_session() 167*7dc08ffcSJunyu Laiupdate_session() 168*7dc08ffcSJunyu Laiassert get_var("test_value") == "8.8.8.8" #test_value == "8.8.8.8" 169*7dc08ffcSJunyu Laiassert get_var("init_value") == 123 170*7dc08ffcSJunyu Lai 171*7dc08ffcSJunyu Lai= Session test with fname 172*7dc08ffcSJunyu Lai 173*7dc08ffcSJunyu Laiinit_session("scapySession2") 174*7dc08ffcSJunyu Laiset_var("test_value", IP(dst="192.168.0.1")) # test_value = IP(dst="192.168.0.1") 175*7dc08ffcSJunyu Laisave_session(fname="scapySession1.dat") 176*7dc08ffcSJunyu Laidel_var("test_value") 177*7dc08ffcSJunyu Lai 178*7dc08ffcSJunyu Laiset_var("z", True) #z = True 179*7dc08ffcSJunyu Laiload_session(fname="scapySession1.dat") 180*7dc08ffcSJunyu Laitry: 181*7dc08ffcSJunyu Lai get_var("z") 182*7dc08ffcSJunyu Lai assert False 183*7dc08ffcSJunyu Laiexcept: 184*7dc08ffcSJunyu Lai pass 185*7dc08ffcSJunyu Lai 186*7dc08ffcSJunyu Laiset_var("z", False) #z = False 187*7dc08ffcSJunyu Laiupdate_session(fname="scapySession1.dat") 188*7dc08ffcSJunyu Laiassert get_var("test_value").dst == "192.168.0.1" #test_value.dst == "192.168.0.1" 189*7dc08ffcSJunyu Laiassert not get_var("z") 190*7dc08ffcSJunyu Lai 191*7dc08ffcSJunyu Lai= Clear session files 192*7dc08ffcSJunyu Lai 193*7dc08ffcSJunyu Laios.remove("scapySession1.dat") 194*7dc08ffcSJunyu Lai 195*7dc08ffcSJunyu Lai= Test temporary file creation 196*7dc08ffcSJunyu Lai~ appveyor_only 197*7dc08ffcSJunyu Lai 198*7dc08ffcSJunyu Laiscapy_delete_temp_files() 199*7dc08ffcSJunyu Lai 200*7dc08ffcSJunyu Laitmpfile = get_temp_file(autoext=".ut") 201*7dc08ffcSJunyu Laitmpfile 202*7dc08ffcSJunyu Laiif WINDOWS: 203*7dc08ffcSJunyu Lai assert("scapy" in tmpfile and tmpfile.lower().startswith('c:\\users\\appveyor\\appdata\\local\\temp')) 204*7dc08ffcSJunyu Laielse: 205*7dc08ffcSJunyu Lai import platform 206*7dc08ffcSJunyu Lai BYPASS_TMP = platform.python_implementation().lower() == "pypy" or DARWIN 207*7dc08ffcSJunyu Lai assert("scapy" in tmpfile and (BYPASS_TMP == True or "/tmp/" in tmpfile)) 208*7dc08ffcSJunyu Lai 209*7dc08ffcSJunyu Laiassert(conf.temp_files[0].endswith(".ut")) 210*7dc08ffcSJunyu Laiscapy_delete_temp_files() 211*7dc08ffcSJunyu Laiassert(len(conf.temp_files) == 0) 212*7dc08ffcSJunyu Lai 213*7dc08ffcSJunyu Lai= Emulate interact() 214*7dc08ffcSJunyu Lai 215*7dc08ffcSJunyu Laiimport mock, sys 216*7dc08ffcSJunyu Laifrom scapy.main import interact 217*7dc08ffcSJunyu Lai# Detect IPython 218*7dc08ffcSJunyu Laitry: 219*7dc08ffcSJunyu Lai import IPython 220*7dc08ffcSJunyu Laiexcept: 221*7dc08ffcSJunyu Lai code_interact_import = "scapy.main.code.interact" 222*7dc08ffcSJunyu Laielse: 223*7dc08ffcSJunyu Lai code_interact_import = "IPython.terminal.embed.InteractiveShellEmbed" 224*7dc08ffcSJunyu Lai 225*7dc08ffcSJunyu Lai@mock.patch(code_interact_import) 226*7dc08ffcSJunyu Laidef interact_emulator(code_int, extra_args=[]): 227*7dc08ffcSJunyu Lai try: 228*7dc08ffcSJunyu Lai code_int.side_effect = lambda *args, **kwargs: lambda *args, **kwargs: None 229*7dc08ffcSJunyu Lai interact(argv=["-s scapy1"] + extra_args, mybanner="What a test") 230*7dc08ffcSJunyu Lai return True 231*7dc08ffcSJunyu Lai except: 232*7dc08ffcSJunyu Lai raise 233*7dc08ffcSJunyu Lai return False 234*7dc08ffcSJunyu Lai finally: 235*7dc08ffcSJunyu Lai sys.ps1 = ">>> " 236*7dc08ffcSJunyu Lai 237*7dc08ffcSJunyu Laiassert interact_emulator() # Default 238*7dc08ffcSJunyu Laiassert not interact_emulator(extra_args=["-?"]) # Failing 239*7dc08ffcSJunyu Laiassert interact_emulator(extra_args=["-d"]) # Extended 240*7dc08ffcSJunyu Lai 241*7dc08ffcSJunyu Lai= Test sane function 242*7dc08ffcSJunyu Laisane("A\x00\xFFB") == "A..B" 243*7dc08ffcSJunyu Lai 244*7dc08ffcSJunyu Lai= Test lhex function 245*7dc08ffcSJunyu Laiassert(lhex(42) == "0x2a") 246*7dc08ffcSJunyu Laiassert(lhex((28,7)) == "(0x1c, 0x7)") 247*7dc08ffcSJunyu Laiassert(lhex([28,7]) == "[0x1c, 0x7]") 248*7dc08ffcSJunyu Lai 249*7dc08ffcSJunyu Lai= Test restart function 250*7dc08ffcSJunyu Laiimport mock 251*7dc08ffcSJunyu Laiconf.interactive = True 252*7dc08ffcSJunyu Lai 253*7dc08ffcSJunyu Laitry: 254*7dc08ffcSJunyu Lai from scapy.utils import restart 255*7dc08ffcSJunyu Lai import os 256*7dc08ffcSJunyu Lai @mock.patch("os.execv") 257*7dc08ffcSJunyu Lai @mock.patch("subprocess.call") 258*7dc08ffcSJunyu Lai @mock.patch("os._exit") 259*7dc08ffcSJunyu Lai def _test(e, m, m2): 260*7dc08ffcSJunyu Lai def check(x, y=[]): 261*7dc08ffcSJunyu Lai z = [x] + y if not isinstance(x, list) else x + y 262*7dc08ffcSJunyu Lai assert os.path.isfile(z[0]) 263*7dc08ffcSJunyu Lai assert os.path.isfile(z[1]) 264*7dc08ffcSJunyu Lai return 0 265*7dc08ffcSJunyu Lai m2.side_effect = check 266*7dc08ffcSJunyu Lai m.side_effect = check 267*7dc08ffcSJunyu Lai e.side_effect = lambda x: None 268*7dc08ffcSJunyu Lai restart() 269*7dc08ffcSJunyu Lai _test() 270*7dc08ffcSJunyu Laifinally: 271*7dc08ffcSJunyu Lai conf.interactive = False 272*7dc08ffcSJunyu Lai 273*7dc08ffcSJunyu Lai= Test linehexdump function 274*7dc08ffcSJunyu Laiconf_color_theme = conf.color_theme 275*7dc08ffcSJunyu Laiconf.color_theme = BlackAndWhite() 276*7dc08ffcSJunyu Laiassert(linehexdump(Ether(src="00:01:02:03:04:05"), dump=True) == "FFFFFFFFFFFF0001020304059000 ..............") 277*7dc08ffcSJunyu Laiconf.color_theme = conf_color_theme 278*7dc08ffcSJunyu Lai 279*7dc08ffcSJunyu Lai= Test chexdump function 280*7dc08ffcSJunyu Laichexdump(Ether(src="00:01:02:02:04:05"), dump=True) == "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x02, 0x04, 0x05, 0x90, 0x00" 281*7dc08ffcSJunyu Lai 282*7dc08ffcSJunyu Lai= Test repr_hex function 283*7dc08ffcSJunyu Lairepr_hex("scapy") == "7363617079" 284*7dc08ffcSJunyu Lai 285*7dc08ffcSJunyu Lai= Test hexstr function 286*7dc08ffcSJunyu Laihexstr(b"A\x00\xFFB") == "41 00 ff 42 A..B" 287*7dc08ffcSJunyu Lai 288*7dc08ffcSJunyu Lai= Test fletcher16 functions 289*7dc08ffcSJunyu Laiassert(fletcher16_checksum(b"\x28\x07") == 22319) 290*7dc08ffcSJunyu Laiassert(fletcher16_checkbytes(b"\x28\x07", 1) == b"\xaf(") 291*7dc08ffcSJunyu Lai 292*7dc08ffcSJunyu Lai= Test hexdiff function 293*7dc08ffcSJunyu Lai~ not_pypy 294*7dc08ffcSJunyu Laidef test_hexdiff(): 295*7dc08ffcSJunyu Lai conf_color_theme = conf.color_theme 296*7dc08ffcSJunyu Lai conf.color_theme = BlackAndWhite() 297*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 298*7dc08ffcSJunyu Lai hexdiff("abcde", "abCde") 299*7dc08ffcSJunyu Lai result_hexdiff = cmco.get_output() 300*7dc08ffcSJunyu Lai conf.interactive = True 301*7dc08ffcSJunyu Lai conf.color_theme = conf_color_theme 302*7dc08ffcSJunyu Lai expected = "0000 61 62 63 64 65 abcde\n" 303*7dc08ffcSJunyu Lai expected += " 0000 61 62 43 64 65 abCde\n" 304*7dc08ffcSJunyu Lai assert(result_hexdiff == expected) 305*7dc08ffcSJunyu Lai 306*7dc08ffcSJunyu Laitest_hexdiff() 307*7dc08ffcSJunyu Lai 308*7dc08ffcSJunyu Lai= Test mysummary functions - Ether 309*7dc08ffcSJunyu Lai 310*7dc08ffcSJunyu LaiEther(dst="ff:ff:ff:ff:ff:ff", src="ff:ff:ff:ff:ff:ff", type=0x9000) 311*7dc08ffcSJunyu Laiassert _.mysummary() in ['ff:ff:ff:ff:ff:ff > ff:ff:ff:ff:ff:ff (%s)' % loop 312*7dc08ffcSJunyu Lai for loop in ['0x9000', 'LOOP']] 313*7dc08ffcSJunyu Lai 314*7dc08ffcSJunyu Lai= Test zerofree_randstring function 315*7dc08ffcSJunyu Lairandom.seed(0x2807) 316*7dc08ffcSJunyu Laizerofree_randstring(4) in [b"\xd2\x12\xe4\x5b", b'\xd3\x8b\x13\x12'] 317*7dc08ffcSJunyu Lai 318*7dc08ffcSJunyu Lai= Test export_object and import_object functions 319*7dc08ffcSJunyu Laiimport mock 320*7dc08ffcSJunyu Laidef test_export_import_object(): 321*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 322*7dc08ffcSJunyu Lai export_object(2807) 323*7dc08ffcSJunyu Lai result_export_object = cmco.get_output(eval_bytes=True) 324*7dc08ffcSJunyu Lai assert(result_export_object.startswith("eNprYPL9zqUHAAdrAf8=")) 325*7dc08ffcSJunyu Lai assert(import_object(result_export_object) == 2807) 326*7dc08ffcSJunyu Lai 327*7dc08ffcSJunyu Laitest_export_import_object() 328*7dc08ffcSJunyu Lai 329*7dc08ffcSJunyu Lai= Test tex_escape function 330*7dc08ffcSJunyu Laitex_escape("$#_") == "\\$\\#\\_" 331*7dc08ffcSJunyu Lai 332*7dc08ffcSJunyu Lai= Test colgen function 333*7dc08ffcSJunyu Laif = colgen(range(3)) 334*7dc08ffcSJunyu Laiassert(len([next(f) for i in range(2)]) == 2) 335*7dc08ffcSJunyu Lai 336*7dc08ffcSJunyu Lai= Test incremental_label function 337*7dc08ffcSJunyu Laif = incremental_label() 338*7dc08ffcSJunyu Laiassert([next(f) for i in range(2)] == ["tag00000", "tag00001"]) 339*7dc08ffcSJunyu Lai 340*7dc08ffcSJunyu Lai= Test corrupt_* functions 341*7dc08ffcSJunyu Laiimport random 342*7dc08ffcSJunyu Lairandom.seed(0x2807) 343*7dc08ffcSJunyu Laiassert(corrupt_bytes("ABCDE") in [b"ABCDW", b"ABCDX"]) 344*7dc08ffcSJunyu Laiassert(sane(corrupt_bytes("ABCDE", n=3)) in ["A.8D4", ".2.DE"]) 345*7dc08ffcSJunyu Lai 346*7dc08ffcSJunyu Laiassert(corrupt_bits("ABCDE") in [b"EBCDE", b"ABCDG"]) 347*7dc08ffcSJunyu Laiassert(sane(corrupt_bits("ABCDE", n=3)) in ["AF.EE", "QB.TE"]) 348*7dc08ffcSJunyu Lai 349*7dc08ffcSJunyu Lai= Test save_object and load_object functions 350*7dc08ffcSJunyu Laiimport tempfile 351*7dc08ffcSJunyu Laifd, fname = tempfile.mkstemp() 352*7dc08ffcSJunyu Laisave_object(fname, 2807) 353*7dc08ffcSJunyu Laiassert(load_object(fname) == 2807) 354*7dc08ffcSJunyu Lai 355*7dc08ffcSJunyu Lai= Test whois function 356*7dc08ffcSJunyu Laiif not WINDOWS: 357*7dc08ffcSJunyu Lai result = whois("193.0.6.139") 358*7dc08ffcSJunyu Lai assert(b"inetnum" in result and b"Amsterdam" in result) 359*7dc08ffcSJunyu Lai 360*7dc08ffcSJunyu Lai= Test manuf DB methods 361*7dc08ffcSJunyu Lai~ manufdb 362*7dc08ffcSJunyu Laiassert(conf.manufdb._resolve_MAC("00:00:0F:01:02:03") == "Next:01:02:03") 363*7dc08ffcSJunyu Laiassert(conf.manufdb._get_short_manuf("00:00:0F:01:02:03") == "Next") 364*7dc08ffcSJunyu Laiassert(in6_addrtovendor("fe80::0200:0fff:fe01:0203").lower().startswith("next")) 365*7dc08ffcSJunyu Lai 366*7dc08ffcSJunyu Lai= Test utility functions - network related 367*7dc08ffcSJunyu Lai~ netaccess 368*7dc08ffcSJunyu Lai 369*7dc08ffcSJunyu Laiatol("www.secdev.org") == 3642339845 370*7dc08ffcSJunyu Lai 371*7dc08ffcSJunyu Lai= Test autorun functions 372*7dc08ffcSJunyu Lai 373*7dc08ffcSJunyu Lairet = autorun_get_text_interactive_session("IP().src") 374*7dc08ffcSJunyu Laiassert(ret == (">>> IP().src\n'127.0.0.1'\n", '127.0.0.1')) 375*7dc08ffcSJunyu Lai 376*7dc08ffcSJunyu Lairet = autorun_get_html_interactive_session("IP().src") 377*7dc08ffcSJunyu Laiassert(ret == ("<span class=prompt>>>> </span>IP().src\n'127.0.0.1'\n", '127.0.0.1')) 378*7dc08ffcSJunyu Lai 379*7dc08ffcSJunyu Lairet = autorun_get_latex_interactive_session("IP().src") 380*7dc08ffcSJunyu Laiassert(ret == ("\\textcolor{blue}{{\\tt\\char62}{\\tt\\char62}{\\tt\\char62} }IP().src\n'127.0.0.1'\n", '127.0.0.1')) 381*7dc08ffcSJunyu Lai 382*7dc08ffcSJunyu Lai= Test utility TEX functions 383*7dc08ffcSJunyu Lai 384*7dc08ffcSJunyu Laiassert tex_escape("{scapy}\\^$~#_&%|><") == "{\\tt\\char123}scapy{\\tt\\char125}{\\tt\\char92}\\^{}\\${\\tt\\char126}\\#\\_\\&\\%{\\tt\\char124}{\\tt\\char62}{\\tt\\char60}" 385*7dc08ffcSJunyu Lai 386*7dc08ffcSJunyu Laia = colgen(1, 2, 3) 387*7dc08ffcSJunyu Laiassert next(a) == (1, 2, 2) 388*7dc08ffcSJunyu Laiassert next(a) == (1, 3, 3) 389*7dc08ffcSJunyu Laiassert next(a) == (2, 2, 1) 390*7dc08ffcSJunyu Laiassert next(a) == (2, 3, 2) 391*7dc08ffcSJunyu Laiassert next(a) == (2, 1, 3) 392*7dc08ffcSJunyu Laiassert next(a) == (3, 3, 1) 393*7dc08ffcSJunyu Laiassert next(a) == (3, 1, 2) 394*7dc08ffcSJunyu Laiassert next(a) == (3, 2, 3) 395*7dc08ffcSJunyu Lai 396*7dc08ffcSJunyu Lai= Test config file functions 397*7dc08ffcSJunyu Lai 398*7dc08ffcSJunyu Laisaved_conf_verb = conf.verb 399*7dc08ffcSJunyu Laifd, fname = tempfile.mkstemp() 400*7dc08ffcSJunyu Laios.write(fd, b"conf.verb = 42\n") 401*7dc08ffcSJunyu Laios.close(fd) 402*7dc08ffcSJunyu Laifrom scapy.main import _read_config_file 403*7dc08ffcSJunyu Lai_read_config_file(fname, globals(), locals()) 404*7dc08ffcSJunyu Laiassert(conf.verb == 42) 405*7dc08ffcSJunyu Laiconf.verb = saved_conf_verb 406*7dc08ffcSJunyu Lai 407*7dc08ffcSJunyu Lai= Test CacheInstance repr 408*7dc08ffcSJunyu Lai 409*7dc08ffcSJunyu Laiconf.netcache 410*7dc08ffcSJunyu Lai 411*7dc08ffcSJunyu Lai 412*7dc08ffcSJunyu Lai############ 413*7dc08ffcSJunyu Lai############ 414*7dc08ffcSJunyu Lai+ Basic tests 415*7dc08ffcSJunyu Lai 416*7dc08ffcSJunyu Lai* Those test are here mainly to check nothing has been broken 417*7dc08ffcSJunyu Lai* and to catch Exceptions 418*7dc08ffcSJunyu Lai 419*7dc08ffcSJunyu Lai= Packet class methods 420*7dc08ffcSJunyu Laip = IP()/ICMP() 421*7dc08ffcSJunyu Lairet = p.do_build_ps() 422*7dc08ffcSJunyu Laiassert(ret[0] == b"@\x00\x00\x00\x00\x01\x00\x00@\x01\x00\x00\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\x00\x00\x00\x00\x00\x00") 423*7dc08ffcSJunyu Laiassert(len(ret[1]) == 2) 424*7dc08ffcSJunyu Lai 425*7dc08ffcSJunyu Laiassert(p[ICMP].firstlayer() == p) 426*7dc08ffcSJunyu Lai 427*7dc08ffcSJunyu Laiassert(p.command() == "IP()/ICMP()") 428*7dc08ffcSJunyu Lai 429*7dc08ffcSJunyu Laip.decode_payload_as(UDP) 430*7dc08ffcSJunyu Laiassert(p.sport == 2048 and p.dport == 63487) 431*7dc08ffcSJunyu Lai 432*7dc08ffcSJunyu Lai= hide_defaults 433*7dc08ffcSJunyu Laiconf_color_theme = conf.color_theme 434*7dc08ffcSJunyu Laiconf.color_theme = BlackAndWhite() 435*7dc08ffcSJunyu Laip = IP(ttl=64)/ICMP() 436*7dc08ffcSJunyu Laiassert(repr(p) in ["<IP frag=0 ttl=64 proto=icmp |<ICMP |>>", "<IP frag=0 ttl=64 proto=1 |<ICMP |>>"]) 437*7dc08ffcSJunyu Laip.hide_defaults() 438*7dc08ffcSJunyu Laiassert(repr(p) in ["<IP frag=0 proto=icmp |<ICMP |>>", "<IP frag=0 proto=1 |<ICMP |>>"]) 439*7dc08ffcSJunyu Laiconf.color_theme = conf_color_theme 440*7dc08ffcSJunyu Lai 441*7dc08ffcSJunyu Lai= split_layers 442*7dc08ffcSJunyu Laip = IP()/ICMP() 443*7dc08ffcSJunyu Lais = raw(p) 444*7dc08ffcSJunyu Laisplit_layers(IP, ICMP, proto=1) 445*7dc08ffcSJunyu Laiassert(Raw in IP(s)) 446*7dc08ffcSJunyu Laibind_layers(IP, ICMP, frag=0, proto=1) 447*7dc08ffcSJunyu Lai 448*7dc08ffcSJunyu Lai= fuzz 449*7dc08ffcSJunyu Lai~ not_pypy random_weird_py3 450*7dc08ffcSJunyu Lairandom.seed(0x2807) 451*7dc08ffcSJunyu Lairaw(fuzz(IP()/ICMP())) 452*7dc08ffcSJunyu Laiassert _ in [ 453*7dc08ffcSJunyu Lai b'u\x14\x00\x1c\xc2\xf6\x80\x00\xde\x01k\xd3\x7f\x00\x00\x01\x7f\x00\x00\x01y\xc9>\xa6\x84\xd8\xc2\xb7', 454*7dc08ffcSJunyu Lai b'E\xa7\x00\x1c\xb0c\xc0\x00\xf6\x01U\xd3\x7f\x00\x00\x01\x7f\x00\x00\x01\xfex\xb3\x92B<\x0b\xb8', 455*7dc08ffcSJunyu Lai] 456*7dc08ffcSJunyu Lai 457*7dc08ffcSJunyu Lai= Building some packets 458*7dc08ffcSJunyu Lai~ basic IP TCP UDP NTP LLC SNAP Dot11 459*7dc08ffcSJunyu LaiIP()/TCP() 460*7dc08ffcSJunyu LaiEther()/IP()/UDP()/NTP() 461*7dc08ffcSJunyu LaiDot11()/LLC()/SNAP()/IP()/TCP()/"XXX" 462*7dc08ffcSJunyu LaiIP(ttl=25)/TCP(sport=12, dport=42) 463*7dc08ffcSJunyu LaiIP().summary() 464*7dc08ffcSJunyu Lai 465*7dc08ffcSJunyu Lai= Manipulating some packets 466*7dc08ffcSJunyu Lai~ basic IP TCP 467*7dc08ffcSJunyu Laia=IP(ttl=4)/TCP() 468*7dc08ffcSJunyu Laia.ttl 469*7dc08ffcSJunyu Laia.ttl=10 470*7dc08ffcSJunyu Laidel(a.ttl) 471*7dc08ffcSJunyu Laia.ttl 472*7dc08ffcSJunyu LaiTCP in a 473*7dc08ffcSJunyu Laia[TCP] 474*7dc08ffcSJunyu Laia[TCP].dport=[80,443] 475*7dc08ffcSJunyu Laia 476*7dc08ffcSJunyu Laiassert(a.copy().time == a.time) 477*7dc08ffcSJunyu Laia=3 478*7dc08ffcSJunyu Lai 479*7dc08ffcSJunyu Lai 480*7dc08ffcSJunyu Lai= Checking overloads 481*7dc08ffcSJunyu Lai~ basic IP TCP Ether 482*7dc08ffcSJunyu Laia=Ether()/IP()/TCP() 483*7dc08ffcSJunyu Laia.proto 484*7dc08ffcSJunyu Lai_ == 6 485*7dc08ffcSJunyu Lai 486*7dc08ffcSJunyu Lai 487*7dc08ffcSJunyu Lai= sprintf() function 488*7dc08ffcSJunyu Lai~ basic sprintf Ether IP UDP NTP 489*7dc08ffcSJunyu Laia=Ether()/IP()/IP(ttl=4)/UDP()/NTP() 490*7dc08ffcSJunyu Laia.sprintf("%type% %IP.ttl% %#05xr,UDP.sport% %IP:2.ttl%") 491*7dc08ffcSJunyu Lai_ in [ '0x800 64 0x07b 4', 'IPv4 64 0x07b 4'] 492*7dc08ffcSJunyu Lai 493*7dc08ffcSJunyu Lai 494*7dc08ffcSJunyu Lai= sprintf() function 495*7dc08ffcSJunyu Lai~ basic sprintf IP TCP SNAP LLC Dot11 496*7dc08ffcSJunyu Lai* This test is on the conditionnal substring feature of <tt>sprintf()</tt> 497*7dc08ffcSJunyu Laia=Dot11()/LLC()/SNAP()/IP()/TCP() 498*7dc08ffcSJunyu Laia.sprintf("{IP:{TCP:flags=%TCP.flags%}{UDP:port=%UDP.ports%} %IP.src%}") 499*7dc08ffcSJunyu Lai_ == 'flags=S 127.0.0.1' 500*7dc08ffcSJunyu Lai 501*7dc08ffcSJunyu Lai 502*7dc08ffcSJunyu Lai= haslayer function 503*7dc08ffcSJunyu Lai~ basic haslayer IP TCP ICMP ISAKMP 504*7dc08ffcSJunyu Laix=IP(id=1)/ISAKMP_payload_SA(prop=ISAKMP_payload_SA(prop=IP()/ICMP()))/TCP() 505*7dc08ffcSJunyu LaiTCP in x, ICMP in x, IP in x, UDP in x 506*7dc08ffcSJunyu Lai_ == (True,True,True,False) 507*7dc08ffcSJunyu Lai 508*7dc08ffcSJunyu Lai= getlayer function 509*7dc08ffcSJunyu Lai~ basic getlayer IP ISAKMP UDP 510*7dc08ffcSJunyu Laix=IP(id=1)/ISAKMP_payload_SA(prop=IP(id=2)/UDP(dport=1))/IP(id=3)/UDP(dport=2) 511*7dc08ffcSJunyu Laix[IP] 512*7dc08ffcSJunyu Laix[IP:2] 513*7dc08ffcSJunyu Laix[IP:3] 514*7dc08ffcSJunyu Laix.getlayer(IP,3) 515*7dc08ffcSJunyu Laix.getlayer(IP,4) 516*7dc08ffcSJunyu Laix[UDP] 517*7dc08ffcSJunyu Laix[UDP:1] 518*7dc08ffcSJunyu Laix[UDP:2] 519*7dc08ffcSJunyu Laiassert(x[IP].id == 1 and x[IP:2].id == 2 and x[IP:3].id == 3 and 520*7dc08ffcSJunyu Lai x.getlayer(IP).id == 1 and x.getlayer(IP,3).id == 3 and 521*7dc08ffcSJunyu Lai x.getlayer(IP,4) == None and 522*7dc08ffcSJunyu Lai x[UDP].dport == 1 and x[UDP:2].dport == 2) 523*7dc08ffcSJunyu Laitry: 524*7dc08ffcSJunyu Lai x[IP:4] 525*7dc08ffcSJunyu Laiexcept IndexError: 526*7dc08ffcSJunyu Lai True 527*7dc08ffcSJunyu Laielse: 528*7dc08ffcSJunyu Lai False 529*7dc08ffcSJunyu Lai 530*7dc08ffcSJunyu Lai= getlayer with a filter 531*7dc08ffcSJunyu Lai~ getlayer IP 532*7dc08ffcSJunyu Laipkt = IP() / IP(ttl=3) / IP() 533*7dc08ffcSJunyu Laiassert pkt[IP::{"ttl":3}].ttl == 3 534*7dc08ffcSJunyu Laiassert pkt.getlayer(IP, ttl=3).ttl == 3 535*7dc08ffcSJunyu Lai 536*7dc08ffcSJunyu Lai= specific haslayer and getlayer implementations for NTP 537*7dc08ffcSJunyu Lai~ haslayer getlayer NTP 538*7dc08ffcSJunyu Laipkt = IP() / UDP() / NTPHeader() 539*7dc08ffcSJunyu Laiassert NTP in pkt 540*7dc08ffcSJunyu Laiassert pkt.haslayer(NTP) 541*7dc08ffcSJunyu Laiassert isinstance(pkt[NTP], NTPHeader) 542*7dc08ffcSJunyu Laiassert isinstance(pkt.getlayer(NTP), NTPHeader) 543*7dc08ffcSJunyu Lai 544*7dc08ffcSJunyu Lai= specific haslayer and getlayer implementations for EAP 545*7dc08ffcSJunyu Lai~ haslayer getlayer EAP 546*7dc08ffcSJunyu Laipkt = Ether() / EAPOL() / EAP_MD5() 547*7dc08ffcSJunyu Laiassert EAP in pkt 548*7dc08ffcSJunyu Laiassert pkt.haslayer(EAP) 549*7dc08ffcSJunyu Laiassert isinstance(pkt[EAP], EAP_MD5) 550*7dc08ffcSJunyu Laiassert isinstance(pkt.getlayer(EAP), EAP_MD5) 551*7dc08ffcSJunyu Lai 552*7dc08ffcSJunyu Lai= specific haslayer and getlayer implementations for RadiusAttribute 553*7dc08ffcSJunyu Lai~ haslayer getlayer RadiusAttribute 554*7dc08ffcSJunyu Laipkt = RadiusAttr_EAP_Message() 555*7dc08ffcSJunyu Laiassert RadiusAttribute in pkt 556*7dc08ffcSJunyu Laiassert pkt.haslayer(RadiusAttribute) 557*7dc08ffcSJunyu Laiassert isinstance(pkt[RadiusAttribute], RadiusAttr_EAP_Message) 558*7dc08ffcSJunyu Laiassert isinstance(pkt.getlayer(RadiusAttribute), RadiusAttr_EAP_Message) 559*7dc08ffcSJunyu Lai 560*7dc08ffcSJunyu Lai 561*7dc08ffcSJunyu Lai= equality 562*7dc08ffcSJunyu Lai~ basic 563*7dc08ffcSJunyu Laiw=Ether()/IP()/UDP(dport=53) 564*7dc08ffcSJunyu Laix=Ether()/IP(version=4)/UDP() 565*7dc08ffcSJunyu Laiy=Ether()/IP()/UDP(dport=4) 566*7dc08ffcSJunyu Laiz=Ether()/IP()/UDP()/NTP() 567*7dc08ffcSJunyu Lait=Ether()/IP()/TCP() 568*7dc08ffcSJunyu Laix==y, x==z, x==t, y==z, y==t, z==t, w==x 569*7dc08ffcSJunyu Lai_ == (False, False, False, False, False, False, True) 570*7dc08ffcSJunyu Lai 571*7dc08ffcSJunyu Lai= answers 572*7dc08ffcSJunyu Lai~ basic 573*7dc08ffcSJunyu Laia1, a2 = "1.2.3.4", "5.6.7.8" 574*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/ICMP(type=8) 575*7dc08ffcSJunyu Laip2 = IP(src=a2, dst=a1)/ICMP(type=0) 576*7dc08ffcSJunyu Laiassert p1.hashret() == p2.hashret() 577*7dc08ffcSJunyu Laiassert not p1.answers(p2) 578*7dc08ffcSJunyu Laiassert p2.answers(p1) 579*7dc08ffcSJunyu Laiassert p1 > p2 580*7dc08ffcSJunyu Laiassert p2 < p1 581*7dc08ffcSJunyu Laiassert p1 == p1 582*7dc08ffcSJunyu Laiconf_back = conf.checkIPinIP 583*7dc08ffcSJunyu Laiconf.checkIPinIP = True 584*7dc08ffcSJunyu Laipx = [IP()/p1, IPv6()/p1] 585*7dc08ffcSJunyu Laiassert not any(p.hashret() == p2.hashret() for p in px) 586*7dc08ffcSJunyu Laiassert not any(p.answers(p2) for p in px) 587*7dc08ffcSJunyu Laiassert not any(p2.answers(p) for p in px) 588*7dc08ffcSJunyu Laiconf.checkIPinIP = False 589*7dc08ffcSJunyu Laiassert all(p.hashret() == p2.hashret() for p in px) 590*7dc08ffcSJunyu Laiassert not any(p.answers(p2) for p in px) 591*7dc08ffcSJunyu Laiassert all(p2.answers(p) for p in px) 592*7dc08ffcSJunyu Laiconf.checkIPinIP = conf_back 593*7dc08ffcSJunyu Lai 594*7dc08ffcSJunyu Laia1, a2 = Net("www.google.com"), Net("www.secdev.org") 595*7dc08ffcSJunyu Laiprt1, prt2 = 12345, 54321 596*7dc08ffcSJunyu Lais1, s2 = 2767216324, 3845532842 597*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='SA', seq=s1, ack=s2, sport=prt1, dport=prt2) 598*7dc08ffcSJunyu Laip2 = IP(src=a2, dst=a1)/TCP(flags='R', seq=s2, ack=0, sport=prt2, dport=prt1) 599*7dc08ffcSJunyu Laiassert p2.answers(p1) 600*7dc08ffcSJunyu Laiassert not p1.answers(p2) 601*7dc08ffcSJunyu Lai# Not available yet because of IPv6 602*7dc08ffcSJunyu Lai# a1, a2 = Net6("www.google.com"), Net6("www.secdev.org") 603*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='S', seq=s1, ack=0, sport=prt1, dport=prt2) 604*7dc08ffcSJunyu Laip2 = IP(src=a2, dst=a1)/TCP(flags='RA', seq=0, ack=s1+1, sport=prt2, dport=prt1) 605*7dc08ffcSJunyu Laiassert p2.answers(p1) 606*7dc08ffcSJunyu Laiassert not p1.answers(p2) 607*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='S', seq=s1, ack=0, sport=prt1, dport=prt2) 608*7dc08ffcSJunyu Laip2 = IP(src=a2, dst=a1)/TCP(flags='SA', seq=s2, ack=s1+1, sport=prt2, dport=prt1) 609*7dc08ffcSJunyu Laiassert p2.answers(p1) 610*7dc08ffcSJunyu Laiassert not p1.answers(p2) 611*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='A', seq=s1, ack=s2+1, sport=prt1, dport=prt2) 612*7dc08ffcSJunyu Laiassert not p2.answers(p1) 613*7dc08ffcSJunyu Laiassert p1.answers(p2) 614*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='S', seq=s1, ack=0, sport=prt1, dport=prt2) 615*7dc08ffcSJunyu Laip2 = IP(src=a2, dst=a1)/TCP(flags='SA', seq=s2, ack=s1+10, sport=prt2, dport=prt1) 616*7dc08ffcSJunyu Laiassert not p2.answers(p1) 617*7dc08ffcSJunyu Laiassert not p1.answers(p2) 618*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='A', seq=s1, ack=s2+1, sport=prt1, dport=prt2) 619*7dc08ffcSJunyu Laiassert not p2.answers(p1) 620*7dc08ffcSJunyu Laiassert not p1.answers(p2) 621*7dc08ffcSJunyu Laip1 = IP(src=a1, dst=a2)/TCP(flags='A', seq=s1+9, ack=s2+10, sport=prt1, dport=prt2) 622*7dc08ffcSJunyu Laiassert not p2.answers(p1) 623*7dc08ffcSJunyu Laiassert not p1.answers(p2) 624*7dc08ffcSJunyu Lai 625*7dc08ffcSJunyu Lai 626*7dc08ffcSJunyu Lai############ 627*7dc08ffcSJunyu Lai############ 628*7dc08ffcSJunyu Lai+ Tests on padding 629*7dc08ffcSJunyu Lai 630*7dc08ffcSJunyu Lai= Padding assembly 631*7dc08ffcSJunyu Lairaw(Padding("abc")) 632*7dc08ffcSJunyu Laiassert( _ == b"abc" ) 633*7dc08ffcSJunyu Lairaw(Padding("abc")/Padding("def")) 634*7dc08ffcSJunyu Laiassert( _ == b"abcdef" ) 635*7dc08ffcSJunyu Lairaw(Raw("ABC")/Padding("abc")/Padding("def")) 636*7dc08ffcSJunyu Laiassert( _ == b"ABCabcdef" ) 637*7dc08ffcSJunyu Lairaw(Raw("ABC")/Padding("abc")/Raw("DEF")/Padding("def")) 638*7dc08ffcSJunyu Laiassert( _ == b"ABCDEFabcdef" ) 639*7dc08ffcSJunyu Lai 640*7dc08ffcSJunyu Lai= Padding and length computation 641*7dc08ffcSJunyu LaiIP(raw(IP()/Padding("abc"))) 642*7dc08ffcSJunyu Laiassert( _.len == 20 and len(_) == 23 ) 643*7dc08ffcSJunyu LaiIP(raw(IP()/Raw("ABC")/Padding("abc"))) 644*7dc08ffcSJunyu Laiassert( _.len == 23 and len(_) == 26 ) 645*7dc08ffcSJunyu LaiIP(raw(IP()/Raw("ABC")/Padding("abc")/Padding("def"))) 646*7dc08ffcSJunyu Laiassert( _.len == 23 and len(_) == 29 ) 647*7dc08ffcSJunyu Lai 648*7dc08ffcSJunyu Lai= PadField test 649*7dc08ffcSJunyu Lai~ PadField padding 650*7dc08ffcSJunyu Lai 651*7dc08ffcSJunyu Laiclass TestPad(Packet): 652*7dc08ffcSJunyu Lai fields_desc = [ PadField(StrNullField("st", b""),4), StrField("id", b"")] 653*7dc08ffcSJunyu Lai 654*7dc08ffcSJunyu LaiTestPad() == TestPad(raw(TestPad())) 655*7dc08ffcSJunyu Lai 656*7dc08ffcSJunyu Lai 657*7dc08ffcSJunyu Lai############ 658*7dc08ffcSJunyu Lai############ 659*7dc08ffcSJunyu Lai+ Tests on default value changes mechanism 660*7dc08ffcSJunyu Lai 661*7dc08ffcSJunyu Lai= Creation of an IPv3 class from IP class with different default values 662*7dc08ffcSJunyu Laiclass IPv3(IP): 663*7dc08ffcSJunyu Lai version = 3 664*7dc08ffcSJunyu Lai ttl = 32 665*7dc08ffcSJunyu Lai 666*7dc08ffcSJunyu Lai= Test of IPv3 class 667*7dc08ffcSJunyu Laia = IPv3() 668*7dc08ffcSJunyu Laia.version, a.ttl 669*7dc08ffcSJunyu Laiassert(_ == (3,32)) 670*7dc08ffcSJunyu Lairaw(a) 671*7dc08ffcSJunyu Laiassert(_ == b'5\x00\x00\x14\x00\x01\x00\x00 \x00\xac\xe7\x7f\x00\x00\x01\x7f\x00\x00\x01') 672*7dc08ffcSJunyu Lai 673*7dc08ffcSJunyu Lai 674*7dc08ffcSJunyu Lai############ 675*7dc08ffcSJunyu Lai############ 676*7dc08ffcSJunyu Lai+ ISAKMP transforms test 677*7dc08ffcSJunyu Lai 678*7dc08ffcSJunyu Lai= ISAKMP creation 679*7dc08ffcSJunyu Lai~ IP UDP ISAKMP 680*7dc08ffcSJunyu Laip=IP(src='192.168.8.14',dst='10.0.0.1')/UDP()/ISAKMP()/ISAKMP_payload_SA(prop=ISAKMP_payload_Proposal(trans=ISAKMP_payload_Transform(transforms=[('Encryption', 'AES-CBC'), ('Hash', 'MD5'), ('Authentication', 'PSK'), ('GroupDesc', '1536MODPgr'), ('KeyLength', 256), ('LifeType', 'Seconds'), ('LifeDuration', 86400)])/ISAKMP_payload_Transform(res2=12345,transforms=[('Encryption', '3DES-CBC'), ('Hash', 'SHA'), ('Authentication', 'PSK'), ('GroupDesc', '1024MODPgr'), ('LifeType', 'Seconds'), ('LifeDuration', 86400)]))) 681*7dc08ffcSJunyu Laip.show() 682*7dc08ffcSJunyu Laip 683*7dc08ffcSJunyu Lai 684*7dc08ffcSJunyu Lai 685*7dc08ffcSJunyu Lai= ISAKMP manipulation 686*7dc08ffcSJunyu Lai~ ISAKMP 687*7dc08ffcSJunyu Laip[ISAKMP_payload_Transform:2] 688*7dc08ffcSJunyu Lai_.res2 == 12345 689*7dc08ffcSJunyu Lai 690*7dc08ffcSJunyu Lai= ISAKMP assembly 691*7dc08ffcSJunyu Lai~ ISAKMP 692*7dc08ffcSJunyu Laihexdump(p) 693*7dc08ffcSJunyu Lairaw(p) == b"E\x00\x00\x96\x00\x01\x00\x00@\x11\xa7\x9f\xc0\xa8\x08\x0e\n\x00\x00\x01\x01\xf4\x01\xf4\x00\x82\xbf\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00z\x00\x00\x00^\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00R\x01\x01\x00\x00\x03\x00\x00'\x00\x01\x00\x00\x80\x01\x00\x07\x80\x02\x00\x01\x80\x03\x00\x01\x80\x04\x00\x05\x80\x0e\x01\x00\x80\x0b\x00\x01\x00\x0c\x00\x03\x01Q\x80\x00\x00\x00#\x00\x0109\x80\x01\x00\x05\x80\x02\x00\x02\x80\x03\x00\x01\x80\x04\x00\x02\x80\x0b\x00\x01\x00\x0c\x00\x03\x01Q\x80" 694*7dc08ffcSJunyu Lai 695*7dc08ffcSJunyu Lai 696*7dc08ffcSJunyu Lai= ISAKMP disassembly 697*7dc08ffcSJunyu Lai~ ISAKMP 698*7dc08ffcSJunyu Laiq=IP(raw(p)) 699*7dc08ffcSJunyu Laiq.show() 700*7dc08ffcSJunyu Laiq[ISAKMP_payload_Transform:2] 701*7dc08ffcSJunyu Lai_.res2 == 12345 702*7dc08ffcSJunyu Lai 703*7dc08ffcSJunyu Lai 704*7dc08ffcSJunyu Lai############ 705*7dc08ffcSJunyu Lai############ 706*7dc08ffcSJunyu Lai+ TFTP tests 707*7dc08ffcSJunyu Lai 708*7dc08ffcSJunyu Lai= TFTP Options 709*7dc08ffcSJunyu Laix=IP()/UDP(sport=12345)/TFTP()/TFTP_RRQ(filename="fname")/TFTP_Options(options=[TFTP_Option(oname="blksize", value="8192"),TFTP_Option(oname="other", value="othervalue")]) 710*7dc08ffcSJunyu Laiassert( raw(x) == b'E\x00\x00H\x00\x01\x00\x00@\x11|\xa2\x7f\x00\x00\x01\x7f\x00\x00\x0109\x00E\x004B6\x00\x01fname\x00octet\x00blksize\x008192\x00other\x00othervalue\x00' ) 711*7dc08ffcSJunyu Laiy=IP(raw(x)) 712*7dc08ffcSJunyu Laiy[TFTP_Option].oname 713*7dc08ffcSJunyu Laiy[TFTP_Option:2].oname 714*7dc08ffcSJunyu Laiassert(len(y[TFTP_Options].options) == 2 and y[TFTP_Option].oname == b"blksize") 715*7dc08ffcSJunyu Lai 716*7dc08ffcSJunyu Lai 717*7dc08ffcSJunyu Lai############ 718*7dc08ffcSJunyu Lai############ 719*7dc08ffcSJunyu Lai+ Dot11 tests 720*7dc08ffcSJunyu Lai 721*7dc08ffcSJunyu Lai 722*7dc08ffcSJunyu Lai= WEP tests 723*7dc08ffcSJunyu Lai~ wifi crypto Dot11 LLC SNAP IP TCP 724*7dc08ffcSJunyu Laiconf.wepkey = "Fobar" 725*7dc08ffcSJunyu Lairaw(Dot11WEP()/LLC()/SNAP()/IP()/TCP(seq=12345678)) 726*7dc08ffcSJunyu Laiassert(_ == b'\x00\x00\x00\x00\xe3OjYLw\xc3x_%\xd0\xcf\xdeu-\xc3pH#\x1eK\xae\xf5\xde\xe7\xb8\x1d,\xa1\xfe\xe83\xca\xe1\xfe\xbd\xfe\xec\x00)T`\xde.\x93Td\x95C\x0f\x07\xdd') 727*7dc08ffcSJunyu LaiDot11WEP(_) 728*7dc08ffcSJunyu Laiassert(TCP in _ and _[TCP].seq == 12345678) 729*7dc08ffcSJunyu Lai 730*7dc08ffcSJunyu Lai= RadioTap Big-Small endian dissection 731*7dc08ffcSJunyu Laidata = b'\x00\x00\x1a\x00/H\x00\x00\xe1\xd3\xcb\x05\x00\x00\x00\x00@0x\x14@\x01\xac\x00\x00\x00' 732*7dc08ffcSJunyu Lair = RadioTap(data) 733*7dc08ffcSJunyu Lair.show() 734*7dc08ffcSJunyu Laiassert r.present == 18479 735*7dc08ffcSJunyu Lai 736*7dc08ffcSJunyu Lai 737*7dc08ffcSJunyu Lai############ 738*7dc08ffcSJunyu Lai############ 739*7dc08ffcSJunyu Lai+ SNMP tests 740*7dc08ffcSJunyu Lai 741*7dc08ffcSJunyu Lai= SNMP assembling 742*7dc08ffcSJunyu Lai~ SNMP ASN1 743*7dc08ffcSJunyu Lairaw(SNMP()) 744*7dc08ffcSJunyu Laiassert(_ == b'0\x18\x02\x01\x01\x04\x06public\xa0\x0b\x02\x01\x00\x02\x01\x00\x02\x01\x000\x00') 745*7dc08ffcSJunyu LaiSNMP(version="v2c", community="ABC", PDU=SNMPbulk(id=4,varbindlist=[SNMPvarbind(oid="1.2.3.4",value=ASN1_INTEGER(7)),SNMPvarbind(oid="4.3.2.1.2.3",value=ASN1_IA5_STRING("testing123"))])) 746*7dc08ffcSJunyu Lairaw(_) 747*7dc08ffcSJunyu Laiassert(_ == b'05\x02\x01\x01\x04\x03ABC\xa5+\x02\x01\x04\x02\x01\x00\x02\x01\x000 0\x08\x06\x03*\x03\x04\x02\x01\x070\x14\x06\x06\x81#\x02\x01\x02\x03\x16\ntesting123') 748*7dc08ffcSJunyu Lai 749*7dc08ffcSJunyu Lai= SNMP disassembling 750*7dc08ffcSJunyu Lai~ SNMP ASN1 751*7dc08ffcSJunyu Laix=SNMP(b'0y\x02\x01\x00\x04\x06public\xa2l\x02\x01)\x02\x01\x00\x02\x01\x000a0!\x06\x12+\x06\x01\x04\x01\x81}\x08@\x04\x02\x01\x07\n\x86\xde\xb78\x04\x0b172.31.19.20#\x06\x12+\x06\x01\x04\x01\x81}\x08@\x04\x02\x01\x07\n\x86\xde\xb76\x04\r255.255.255.00\x17\x06\x12+\x06\x01\x04\x01\x81}\x08@\x04\x02\x01\x05\n\x86\xde\xb9`\x02\x01\x01') 752*7dc08ffcSJunyu Laix.show() 753*7dc08ffcSJunyu Laiassert(x.community==b"public" and x.version == 0) 754*7dc08ffcSJunyu Laiassert(x.PDU.id == 41 and len(x.PDU.varbindlist) == 3) 755*7dc08ffcSJunyu Laiassert(x.PDU.varbindlist[0].oid == "1.3.6.1.4.1.253.8.64.4.2.1.7.10.14130104") 756*7dc08ffcSJunyu Laiassert(x.PDU.varbindlist[0].value == b"172.31.19.2") 757*7dc08ffcSJunyu Laiassert(x.PDU.varbindlist[2].oid == "1.3.6.1.4.1.253.8.64.4.2.1.5.10.14130400") 758*7dc08ffcSJunyu Laiassert(x.PDU.varbindlist[2].value == 1) 759*7dc08ffcSJunyu Lai 760*7dc08ffcSJunyu Lai= ASN1 - ASN1_Object 761*7dc08ffcSJunyu Laiassert ASN1_Object(1) == ASN1_Object(1) 762*7dc08ffcSJunyu Laiassert ASN1_Object(1) > ASN1_Object(0) 763*7dc08ffcSJunyu Laiassert ASN1_Object(1) >= ASN1_Object(1) 764*7dc08ffcSJunyu Laiassert ASN1_Object(0) < ASN1_Object(1) 765*7dc08ffcSJunyu Laiassert ASN1_Object(1) <= ASN1_Object(2) 766*7dc08ffcSJunyu Laiassert ASN1_Object(1) != ASN1_Object(2) 767*7dc08ffcSJunyu LaiASN1_Object(2).show() 768*7dc08ffcSJunyu Lai 769*7dc08ffcSJunyu Lai= ASN1 - RandASN1Object 770*7dc08ffcSJunyu Lai~ random_weird_py3 771*7dc08ffcSJunyu Laia = RandASN1Object() 772*7dc08ffcSJunyu Lairandom.seed(0x2807) 773*7dc08ffcSJunyu Laiassert raw(a) in [b'A\x02\x07q', b'C\x02\xfe\x92', b'\x1e\x023V'] 774*7dc08ffcSJunyu Lai 775*7dc08ffcSJunyu Lai= ASN1 - ASN1_BIT_STRING 776*7dc08ffcSJunyu Laia = ASN1_BIT_STRING("test", "value") 777*7dc08ffcSJunyu Laia 778*7dc08ffcSJunyu Laiassert raw(a) == b'test' 779*7dc08ffcSJunyu Lai 780*7dc08ffcSJunyu Laia = ASN1_BIT_STRING(b"\xff"*16, "value") 781*7dc08ffcSJunyu Laia 782*7dc08ffcSJunyu Laiassert raw(a) == b'\xff'*16 783*7dc08ffcSJunyu Lai 784*7dc08ffcSJunyu Lai= ASN1 - ASN1_SEQUENCE 785*7dc08ffcSJunyu Laia = ASN1_SEQUENCE([ASN1_Object(1), ASN1_Object(0)]) 786*7dc08ffcSJunyu Laiassert a.strshow() == '# ASN1_SEQUENCE:\n <ASN1_Object[1]>\n <ASN1_Object[0]>\n' 787*7dc08ffcSJunyu Lai 788*7dc08ffcSJunyu Lai= ASN1 - ASN1_DECODING_ERROR 789*7dc08ffcSJunyu Laia = ASN1_DECODING_ERROR("error", exc=OSError(1)) 790*7dc08ffcSJunyu Laiassert repr(a) == "<ASN1_DECODING_ERROR['error']{{1}}>" 791*7dc08ffcSJunyu Laib = ASN1_DECODING_ERROR("error", exc=OSError(ASN1_BIT_STRING("0"))) 792*7dc08ffcSJunyu Laiassert repr(b) == "<ASN1_DECODING_ERROR['error']{{<ASN1_BIT_STRING[0] (7 unused bits)>}}>" 793*7dc08ffcSJunyu Lai 794*7dc08ffcSJunyu Lai= ASN1 - ASN1_INTEGER 795*7dc08ffcSJunyu Laia = ASN1_INTEGER(int("1"*23)) 796*7dc08ffcSJunyu Laiassert repr(a) in ["0x25a55a46e5da99c71c7 <ASN1_INTEGER[1111111111...1111111111]>", 797*7dc08ffcSJunyu Lai "0x25a55a46e5da99c71c7 <ASN1_INTEGER[1111111111...111111111L]>"] 798*7dc08ffcSJunyu Lai 799*7dc08ffcSJunyu Lai= RandASN1Object(), specific crashes 800*7dc08ffcSJunyu Lai 801*7dc08ffcSJunyu Laiimport random 802*7dc08ffcSJunyu Lai 803*7dc08ffcSJunyu Lai# ASN1F_NUMERIC_STRING 804*7dc08ffcSJunyu Lairandom.seed(1514315682) 805*7dc08ffcSJunyu Lairaw(RandASN1Object()) 806*7dc08ffcSJunyu Lai 807*7dc08ffcSJunyu Lai# ASN1F_VIDEOTEX_STRING 808*7dc08ffcSJunyu Lairandom.seed(1240186058) 809*7dc08ffcSJunyu Lairaw(RandASN1Object()) 810*7dc08ffcSJunyu Lai 811*7dc08ffcSJunyu Lai# ASN1F_UTC_TIME & ASN1F_GENERALIZED_TIME 812*7dc08ffcSJunyu Lairandom.seed(1873503288) 813*7dc08ffcSJunyu Lairaw(RandASN1Object()) 814*7dc08ffcSJunyu Lai 815*7dc08ffcSJunyu Lai 816*7dc08ffcSJunyu Lai############ 817*7dc08ffcSJunyu Lai############ 818*7dc08ffcSJunyu Lai+ Network tests 819*7dc08ffcSJunyu Lai 820*7dc08ffcSJunyu Lai* Those tests need network access 821*7dc08ffcSJunyu Lai 822*7dc08ffcSJunyu Lai= Sending and receiving an ICMP 823*7dc08ffcSJunyu Lai~ netaccess IP ICMP 824*7dc08ffcSJunyu Laiold_debug_dissector = conf.debug_dissector 825*7dc08ffcSJunyu Laiconf.debug_dissector = False 826*7dc08ffcSJunyu Laix = sr1(IP(dst="www.google.com")/ICMP(),timeout=3) 827*7dc08ffcSJunyu Laiconf.debug_dissector = old_debug_dissector 828*7dc08ffcSJunyu Laix 829*7dc08ffcSJunyu Laiassert x[IP].ottl() in [32, 64, 128, 255] 830*7dc08ffcSJunyu Laiassert 0 <= x[IP].hops() <= 126 831*7dc08ffcSJunyu Laix is not None and ICMP in x and x[ICMP].type == 0 832*7dc08ffcSJunyu Lai 833*7dc08ffcSJunyu Lai= Sending an ICMP message at layer 2 and layer 3 834*7dc08ffcSJunyu Lai~ netaccess IP ICMP 835*7dc08ffcSJunyu Laitmp = send(IP(dst="8.8.8.8")/ICMP(), return_packets=True, realtime=True) 836*7dc08ffcSJunyu Laiassert(len(tmp) == 1) 837*7dc08ffcSJunyu Lai 838*7dc08ffcSJunyu Laitmp = sendp(Ether()/IP(dst="8.8.8.8")/ICMP(), return_packets=True, realtime=True) 839*7dc08ffcSJunyu Laiassert(len(tmp) == 1) 840*7dc08ffcSJunyu Lai 841*7dc08ffcSJunyu Lai= Sending an ICMP message 'forever' at layer 2 and layer 3 842*7dc08ffcSJunyu Lai~ netaccess IP ICMP 843*7dc08ffcSJunyu Laitmp = srloop(IP(dst="8.8.8.8")/ICMP(), count=1) 844*7dc08ffcSJunyu Laiassert(type(tmp) == tuple and len(tmp[0]) == 1) 845*7dc08ffcSJunyu Lai 846*7dc08ffcSJunyu Laitmp = srploop(Ether()/IP(dst="8.8.8.8")/ICMP(), count=1) 847*7dc08ffcSJunyu Laiassert(type(tmp) == tuple and len(tmp[0]) == 1) 848*7dc08ffcSJunyu Lai 849*7dc08ffcSJunyu Lai= Sending and receiving an ICMP with flooding methods 850*7dc08ffcSJunyu Lai~ netaccess IP ICMP 851*7dc08ffcSJunyu Laifrom functools import partial 852*7dc08ffcSJunyu Lai# flooding methods do not support timeout. Packing the test for security 853*7dc08ffcSJunyu Laidef _test_flood(flood_function, add_ether=False): 854*7dc08ffcSJunyu Lai old_debug_dissector = conf.debug_dissector 855*7dc08ffcSJunyu Lai conf.debug_dissector = False 856*7dc08ffcSJunyu Lai p = IP(dst="www.google.com")/ICMP() 857*7dc08ffcSJunyu Lai if add_ether: 858*7dc08ffcSJunyu Lai p = Ether()/p 859*7dc08ffcSJunyu Lai x = flood_function(p) 860*7dc08ffcSJunyu Lai conf.debug_dissector = old_debug_dissector 861*7dc08ffcSJunyu Lai if type(x) == tuple: 862*7dc08ffcSJunyu Lai x = x[0][0][1] 863*7dc08ffcSJunyu Lai x 864*7dc08ffcSJunyu Lai assert x[IP].ottl() in [32, 64, 128, 255] 865*7dc08ffcSJunyu Lai assert 0 <= x[IP].hops() <= 126 866*7dc08ffcSJunyu Lai x is not None and ICMP in x and x[ICMP].type == 0 867*7dc08ffcSJunyu Lai 868*7dc08ffcSJunyu Lai_test_srflood = partial(_test_flood, srflood) 869*7dc08ffcSJunyu Lait = Thread(target=_test_srflood) 870*7dc08ffcSJunyu Lait.start() 871*7dc08ffcSJunyu Lait.join(3) 872*7dc08ffcSJunyu Laiassert not t.is_alive() 873*7dc08ffcSJunyu Lai 874*7dc08ffcSJunyu Lai_test_sr1flood = partial(_test_flood, sr1flood) 875*7dc08ffcSJunyu Lait = Thread(target=_test_sr1flood) 876*7dc08ffcSJunyu Lait.start() 877*7dc08ffcSJunyu Lait.join(3) 878*7dc08ffcSJunyu Laiassert not t.is_alive() 879*7dc08ffcSJunyu Lai 880*7dc08ffcSJunyu Lai_test_srpflood = partial(_test_flood, srpflood, True) 881*7dc08ffcSJunyu Lait = Thread(target=_test_sr1flood) 882*7dc08ffcSJunyu Lait.start() 883*7dc08ffcSJunyu Lait.join(3) 884*7dc08ffcSJunyu Laiassert not t.is_alive() 885*7dc08ffcSJunyu Lai 886*7dc08ffcSJunyu Lai_test_srp1flood = partial(_test_flood, srp1flood, True) 887*7dc08ffcSJunyu Lait = Thread(target=_test_sr1flood) 888*7dc08ffcSJunyu Lait.start() 889*7dc08ffcSJunyu Lait.join(3) 890*7dc08ffcSJunyu Laiassert not t.is_alive() 891*7dc08ffcSJunyu Lai 892*7dc08ffcSJunyu Lai= Sending and receiving an ICMPv6EchoRequest 893*7dc08ffcSJunyu Lai~ netaccess ipv6 894*7dc08ffcSJunyu Laiold_debug_dissector = conf.debug_dissector 895*7dc08ffcSJunyu Laiconf.debug_dissector = False 896*7dc08ffcSJunyu Laix = sr1(IPv6(dst="www.google.com")/ICMPv6EchoRequest(),timeout=3) 897*7dc08ffcSJunyu Laiconf.debug_dissector = old_debug_dissector 898*7dc08ffcSJunyu Laix 899*7dc08ffcSJunyu Laiassert x[IPv6].ottl() in [32, 64, 128, 255] 900*7dc08ffcSJunyu Laiassert 0 <= x[IPv6].hops() <= 126 901*7dc08ffcSJunyu Laix is not None and ICMPv6EchoReply in x and x[ICMPv6EchoReply].type == 129 902*7dc08ffcSJunyu Lai 903*7dc08ffcSJunyu Lai= DNS request 904*7dc08ffcSJunyu Lai~ netaccess IP UDP DNS 905*7dc08ffcSJunyu Lai* A possible cause of failure could be that the open DNS (resolver1.opendns.com) 906*7dc08ffcSJunyu Lai* is not reachable or down. 907*7dc08ffcSJunyu Laiold_debug_dissector = conf.debug_dissector 908*7dc08ffcSJunyu Laiconf.debug_dissector = False 909*7dc08ffcSJunyu Laidns_ans = sr1(IP(dst="resolver1.opendns.com")/UDP()/DNS(rd=1,qd=DNSQR(qname="www.slashdot.com")),timeout=5) 910*7dc08ffcSJunyu Laiconf.debug_dissector = old_debug_dissector 911*7dc08ffcSJunyu LaiDNS in dns_ans 912*7dc08ffcSJunyu Lai 913*7dc08ffcSJunyu Lai= Whois request 914*7dc08ffcSJunyu Lai~ netaccess IP 915*7dc08ffcSJunyu Lai* This test retries on failure because it often fails 916*7dc08ffcSJunyu Laiimport time 917*7dc08ffcSJunyu Laiimport socket 918*7dc08ffcSJunyu Laisuccess = False 919*7dc08ffcSJunyu Laifor i in six.moves.range(5): 920*7dc08ffcSJunyu Lai try: 921*7dc08ffcSJunyu Lai IP(src="8.8.8.8").whois() 922*7dc08ffcSJunyu Lai except socket.error: 923*7dc08ffcSJunyu Lai time.sleep(2) 924*7dc08ffcSJunyu Lai else: 925*7dc08ffcSJunyu Lai success = True 926*7dc08ffcSJunyu Lai break 927*7dc08ffcSJunyu Lai 928*7dc08ffcSJunyu Laiassert success 929*7dc08ffcSJunyu Lai 930*7dc08ffcSJunyu Lai= AS resolvers 931*7dc08ffcSJunyu Lai~ netaccess IP 932*7dc08ffcSJunyu Lai* This test retries on failure because it often fails 933*7dc08ffcSJunyu Lai 934*7dc08ffcSJunyu Lairet = list() 935*7dc08ffcSJunyu Laisuccess = False 936*7dc08ffcSJunyu Laifor i in six.moves.range(5): 937*7dc08ffcSJunyu Lai try: 938*7dc08ffcSJunyu Lai ret = conf.AS_resolver.resolve("8.8.8.8", "8.8.4.4") 939*7dc08ffcSJunyu Lai except RuntimeError: 940*7dc08ffcSJunyu Lai time.sleep(2) 941*7dc08ffcSJunyu Lai else: 942*7dc08ffcSJunyu Lai success = True 943*7dc08ffcSJunyu Lai break 944*7dc08ffcSJunyu Lai 945*7dc08ffcSJunyu Laiassert (len(ret) == 2) 946*7dc08ffcSJunyu Laiall(x[1] == "AS15169" for x in ret) 947*7dc08ffcSJunyu Lai 948*7dc08ffcSJunyu Lairet = list() 949*7dc08ffcSJunyu Laisuccess = False 950*7dc08ffcSJunyu Laifor i in six.moves.range(5): 951*7dc08ffcSJunyu Lai try: 952*7dc08ffcSJunyu Lai ret = AS_resolver_riswhois().resolve("8.8.8.8") 953*7dc08ffcSJunyu Lai except socket.error: 954*7dc08ffcSJunyu Lai time.sleep(2) 955*7dc08ffcSJunyu Lai else: 956*7dc08ffcSJunyu Lai success = True 957*7dc08ffcSJunyu Lai break 958*7dc08ffcSJunyu Lai 959*7dc08ffcSJunyu Laiassert (len(ret) == 1) 960*7dc08ffcSJunyu Laiassert all(x[1] == "AS15169" for x in ret) 961*7dc08ffcSJunyu Lai 962*7dc08ffcSJunyu Lai# This test is too buggy, and is simulated below 963*7dc08ffcSJunyu Lai#ret = list() 964*7dc08ffcSJunyu Lai#success = False 965*7dc08ffcSJunyu Lai#for i in six.moves.range(5): 966*7dc08ffcSJunyu Lai# try: 967*7dc08ffcSJunyu Lai# ret = AS_resolver_cymru().resolve("8.8.8.8") 968*7dc08ffcSJunyu Lai# except socket.error: 969*7dc08ffcSJunyu Lai# time.sleep(2) 970*7dc08ffcSJunyu Lai# else: 971*7dc08ffcSJunyu Lai# success = True 972*7dc08ffcSJunyu Lai# break 973*7dc08ffcSJunyu Lai# 974*7dc08ffcSJunyu Lai#assert (len(ret) == 1) 975*7dc08ffcSJunyu Lai# 976*7dc08ffcSJunyu Lai#all(x[1] == "AS15169" for x in ret) 977*7dc08ffcSJunyu Lai 978*7dc08ffcSJunyu Laicymru_bulk_data = """ 979*7dc08ffcSJunyu LaiBulk mode; whois.cymru.com [2017-10-03 08:38:08 +0000] 980*7dc08ffcSJunyu Lai24776 | 217.25.178.5 | INFOCLIP-AS, FR 981*7dc08ffcSJunyu Lai36459 | 192.30.253.112 | GITHUB - GitHub, Inc., US 982*7dc08ffcSJunyu Lai26496 | 68.178.213.61 | AS-26496-GO-DADDY-COM-LLC - GoDaddy.com, LLC, US 983*7dc08ffcSJunyu Lai""" 984*7dc08ffcSJunyu Laitmp = AS_resolver_cymru().parse(cymru_bulk_data) 985*7dc08ffcSJunyu Laiassert(len(tmp) == 3) 986*7dc08ffcSJunyu Laiassert([l[1] for l in tmp] == ['AS24776', 'AS36459', 'AS26496']) 987*7dc08ffcSJunyu Lai 988*7dc08ffcSJunyu Lai= AS resolver - IPv6 989*7dc08ffcSJunyu Lai~ netaccess IP 990*7dc08ffcSJunyu Lai* This test retries on failure because it often fails 991*7dc08ffcSJunyu Lai 992*7dc08ffcSJunyu Lairet = list() 993*7dc08ffcSJunyu Laisuccess = False 994*7dc08ffcSJunyu Laias_resolver6 = AS_resolver6() 995*7dc08ffcSJunyu Laifor i in six.moves.range(5): 996*7dc08ffcSJunyu Lai try: 997*7dc08ffcSJunyu Lai ret = as_resolver6.resolve("2001:4860:4860::8888", "2001:4860:4860::4444") 998*7dc08ffcSJunyu Lai except socket.error: 999*7dc08ffcSJunyu Lai time.sleep(2) 1000*7dc08ffcSJunyu Lai else: 1001*7dc08ffcSJunyu Lai success = True 1002*7dc08ffcSJunyu Lai break 1003*7dc08ffcSJunyu Lai 1004*7dc08ffcSJunyu Laiassert (len(ret) == 2) 1005*7dc08ffcSJunyu Laiassert all(x[1] == 15169 for x in ret) 1006*7dc08ffcSJunyu Lai 1007*7dc08ffcSJunyu Lai= sendpfast 1008*7dc08ffcSJunyu Lai 1009*7dc08ffcSJunyu Laiold_interactive = conf.interactive 1010*7dc08ffcSJunyu Laiconf.interactive = False 1011*7dc08ffcSJunyu Laitry: 1012*7dc08ffcSJunyu Lai sendpfast([]) 1013*7dc08ffcSJunyu Lai assert False 1014*7dc08ffcSJunyu Laiexcept Exception: 1015*7dc08ffcSJunyu Lai assert True 1016*7dc08ffcSJunyu Lai 1017*7dc08ffcSJunyu Laiconf.interactive = old_interactive 1018*7dc08ffcSJunyu Laiassert True 1019*7dc08ffcSJunyu Lai 1020*7dc08ffcSJunyu Lai############ 1021*7dc08ffcSJunyu Lai############ 1022*7dc08ffcSJunyu Lai+ More complex tests 1023*7dc08ffcSJunyu Lai 1024*7dc08ffcSJunyu Lai= Implicit logic 1025*7dc08ffcSJunyu Lai~ IP TCP 1026*7dc08ffcSJunyu Laia = Ether() / IP(ttl=(5, 10)) / TCP(dport=[80, 443]) 1027*7dc08ffcSJunyu Lails(a) 1028*7dc08ffcSJunyu Lails(a, verbose=True) 1029*7dc08ffcSJunyu Lai[p for p in a] 1030*7dc08ffcSJunyu Lailen(_) == 12 1031*7dc08ffcSJunyu Lai 1032*7dc08ffcSJunyu Lai 1033*7dc08ffcSJunyu Lai############ 1034*7dc08ffcSJunyu Lai############ 1035*7dc08ffcSJunyu Lai+ Real usages 1036*7dc08ffcSJunyu Lai 1037*7dc08ffcSJunyu Lai= Port scan 1038*7dc08ffcSJunyu Lai~ netaccess IP TCP 1039*7dc08ffcSJunyu Laiold_debug_dissector = conf.debug_dissector 1040*7dc08ffcSJunyu Laiconf.debug_dissector = False 1041*7dc08ffcSJunyu Laians,unans=sr(IP(dst="www.google.com/30")/TCP(dport=[80,443]),timeout=2) 1042*7dc08ffcSJunyu Laiconf.debug_dissector = old_debug_dissector 1043*7dc08ffcSJunyu Laians.make_table(lambda s_r: (s_r[0].dst, s_r[0].dport, s_r[1].sprintf("{TCP:%TCP.flags%}{ICMP:%ICMP.code%}"))) 1044*7dc08ffcSJunyu Lai 1045*7dc08ffcSJunyu Lai= Send & receive with retry 1046*7dc08ffcSJunyu Lai~ netaccess IP ICMP 1047*7dc08ffcSJunyu Laiold_debug_dissector = conf.debug_dissector 1048*7dc08ffcSJunyu Laiconf.debug_dissector = False 1049*7dc08ffcSJunyu Laians, unans = sr(IP(dst=["8.8.8.8", "1.2.3.4"]) / ICMP(), timeout=2, retry=1) 1050*7dc08ffcSJunyu Laiconf.debug_dissector = old_debug_dissector 1051*7dc08ffcSJunyu Lailen(ans) == 1 and len(unans) == 1 1052*7dc08ffcSJunyu Lai 1053*7dc08ffcSJunyu Lai= Traceroute function 1054*7dc08ffcSJunyu Lai~ netaccess 1055*7dc08ffcSJunyu Lai* Let's test traceroute 1056*7dc08ffcSJunyu Laitraceroute("www.slashdot.org") 1057*7dc08ffcSJunyu Laians,unans=_ 1058*7dc08ffcSJunyu Lai 1059*7dc08ffcSJunyu Lai= Result manipulation 1060*7dc08ffcSJunyu Lai~ netaccess 1061*7dc08ffcSJunyu Laians.nsummary() 1062*7dc08ffcSJunyu Lais,r=ans[0] 1063*7dc08ffcSJunyu Lais.show() 1064*7dc08ffcSJunyu Lais.show(2) 1065*7dc08ffcSJunyu Lai 1066*7dc08ffcSJunyu Lai= DNS packet manipulation 1067*7dc08ffcSJunyu Lai~ netaccess IP UDP DNS 1068*7dc08ffcSJunyu Laidns_ans.show() 1069*7dc08ffcSJunyu Laidns_ans.show2() 1070*7dc08ffcSJunyu Laidns_ans[DNS].an.show() 1071*7dc08ffcSJunyu Laidns_ans2 = IP(raw(dns_ans)) 1072*7dc08ffcSJunyu LaiDNS in dns_ans2 1073*7dc08ffcSJunyu Laiassert(raw(dns_ans2) == raw(dns_ans)) 1074*7dc08ffcSJunyu Laidns_ans2.qd.qname = "www.secdev.org." 1075*7dc08ffcSJunyu Lai* We need to recalculate these values 1076*7dc08ffcSJunyu Laidel(dns_ans2[IP].len) 1077*7dc08ffcSJunyu Laidel(dns_ans2[IP].chksum) 1078*7dc08ffcSJunyu Laidel(dns_ans2[UDP].len) 1079*7dc08ffcSJunyu Laidel(dns_ans2[UDP].chksum) 1080*7dc08ffcSJunyu Laiassert(b"\x03www\x06secdev\x03org\x00" in raw(dns_ans2)) 1081*7dc08ffcSJunyu Laiassert(DNS in IP(raw(dns_ans2))) 1082*7dc08ffcSJunyu Lai 1083*7dc08ffcSJunyu Lai= Arping 1084*7dc08ffcSJunyu Lai~ netaccess 1085*7dc08ffcSJunyu Lai* This test assumes the local network is a /24. This is bad. 1086*7dc08ffcSJunyu Laiconf.route.route("0.0.0.0")[2] 1087*7dc08ffcSJunyu Laiarping(_+"/24") 1088*7dc08ffcSJunyu Lai 1089*7dc08ffcSJunyu Lai= send() and sniff() 1090*7dc08ffcSJunyu Lai~ netaccess 1091*7dc08ffcSJunyu Laiimport time 1092*7dc08ffcSJunyu Laiimport os 1093*7dc08ffcSJunyu Lai 1094*7dc08ffcSJunyu Laifrom scapy.modules.six.moves.queue import Queue 1095*7dc08ffcSJunyu Lai 1096*7dc08ffcSJunyu Laidef _send_or_sniff(pkt, timeout, flt, pid, fork, t_other=None, opened_socket=None): 1097*7dc08ffcSJunyu Lai assert pid != -1 1098*7dc08ffcSJunyu Lai if pid == 0: 1099*7dc08ffcSJunyu Lai time.sleep(1) 1100*7dc08ffcSJunyu Lai (sendp if isinstance(pkt, (Ether, Dot3)) else send)(pkt) 1101*7dc08ffcSJunyu Lai if fork: 1102*7dc08ffcSJunyu Lai os._exit(0) 1103*7dc08ffcSJunyu Lai else: 1104*7dc08ffcSJunyu Lai return 1105*7dc08ffcSJunyu Lai else: 1106*7dc08ffcSJunyu Lai spkt = raw(pkt) 1107*7dc08ffcSJunyu Lai # We do not want to crash when a packet cannot be parsed 1108*7dc08ffcSJunyu Lai old_debug_dissector = conf.debug_dissector 1109*7dc08ffcSJunyu Lai conf.debug_dissector = False 1110*7dc08ffcSJunyu Lai pkts = sniff( 1111*7dc08ffcSJunyu Lai timeout=timeout, filter=flt, opened_socket=opened_socket, 1112*7dc08ffcSJunyu Lai stop_filter=lambda p: pkt.__class__ in p and raw(p[pkt.__class__]) == spkt 1113*7dc08ffcSJunyu Lai ) 1114*7dc08ffcSJunyu Lai conf.debug_dissector = old_debug_dissector 1115*7dc08ffcSJunyu Lai if fork: 1116*7dc08ffcSJunyu Lai os.waitpid(pid, 0) 1117*7dc08ffcSJunyu Lai else: 1118*7dc08ffcSJunyu Lai t_other.join() 1119*7dc08ffcSJunyu Lai assert raw(pkt) in (raw(p[pkt.__class__]) for p in pkts if pkt.__class__ in p) 1120*7dc08ffcSJunyu Lai 1121*7dc08ffcSJunyu Laidef send_and_sniff(pkt, timeout=2, flt=None, opened_socket=None): 1122*7dc08ffcSJunyu Lai """Send a packet, sniff, and check the packet has been seen""" 1123*7dc08ffcSJunyu Lai if hasattr(os, "fork"): 1124*7dc08ffcSJunyu Lai _send_or_sniff(pkt, timeout, flt, os.fork(), True) 1125*7dc08ffcSJunyu Lai else: 1126*7dc08ffcSJunyu Lai from threading import Thread 1127*7dc08ffcSJunyu Lai def run_function(pkt, timeout, flt, pid, thread, results, opened_socket): 1128*7dc08ffcSJunyu Lai _send_or_sniff(pkt, timeout, flt, pid, False, t_other=thread, opened_socket=opened_socket) 1129*7dc08ffcSJunyu Lai results.put(True) 1130*7dc08ffcSJunyu Lai results = Queue() 1131*7dc08ffcSJunyu Lai t_parent = Thread(target=run_function, args=(pkt, timeout, flt, 0, None, results, None)) 1132*7dc08ffcSJunyu Lai t_child = Thread(target=run_function, args=(pkt, timeout, flt, 1, t_parent, results, opened_socket)) 1133*7dc08ffcSJunyu Lai t_parent.start() 1134*7dc08ffcSJunyu Lai t_child.start() 1135*7dc08ffcSJunyu Lai t_parent.join() 1136*7dc08ffcSJunyu Lai t_child.join() 1137*7dc08ffcSJunyu Lai assert results.qsize() >= 2 1138*7dc08ffcSJunyu Lai while not results.empty(): 1139*7dc08ffcSJunyu Lai assert results.get() 1140*7dc08ffcSJunyu Lai 1141*7dc08ffcSJunyu Laisend_and_sniff(IP(dst="secdev.org")/ICMP()) 1142*7dc08ffcSJunyu Laisend_and_sniff(IP(dst="secdev.org")/ICMP(), flt="icmp") 1143*7dc08ffcSJunyu Laisend_and_sniff(Ether()/IP(dst="secdev.org")/ICMP()) 1144*7dc08ffcSJunyu Lai 1145*7dc08ffcSJunyu Lai= Test L2ListenTcpdump socket 1146*7dc08ffcSJunyu Lai~ netaccess FIXME_py3 1147*7dc08ffcSJunyu Lai 1148*7dc08ffcSJunyu Lai# Often (but not always) fails with Python 3 1149*7dc08ffcSJunyu Laiimport time 1150*7dc08ffcSJunyu Laifor i in range(10): 1151*7dc08ffcSJunyu Lai read_s = L2ListenTcpdump(iface=conf.iface) 1152*7dc08ffcSJunyu Lai out_s = conf.L2socket(iface=conf.iface) 1153*7dc08ffcSJunyu Lai time.sleep(5) # wait for read_s to be ready 1154*7dc08ffcSJunyu Lai icmp_r = Ether()/IP(dst="secdev.org")/ICMP() 1155*7dc08ffcSJunyu Lai res = sndrcv(out_s, icmp_r, timeout=5, rcv_pks=read_s)[0] 1156*7dc08ffcSJunyu Lai read_s.close() 1157*7dc08ffcSJunyu Lai out_s.close() 1158*7dc08ffcSJunyu Lai time.sleep(5) 1159*7dc08ffcSJunyu Lai if res: 1160*7dc08ffcSJunyu Lai break 1161*7dc08ffcSJunyu Lai 1162*7dc08ffcSJunyu Lairesponse = res[0][1] 1163*7dc08ffcSJunyu Laiassert response[ICMP].type == 0 1164*7dc08ffcSJunyu Lai 1165*7dc08ffcSJunyu Lai############ 1166*7dc08ffcSJunyu Lai############ 1167*7dc08ffcSJunyu Lai+ ManuFDB tests 1168*7dc08ffcSJunyu Lai 1169*7dc08ffcSJunyu Lai= __repr__ 1170*7dc08ffcSJunyu Lai 1171*7dc08ffcSJunyu Laiif conf.manufdb: 1172*7dc08ffcSJunyu Lai len(conf.manufdb) 1173*7dc08ffcSJunyu Laielse: 1174*7dc08ffcSJunyu Lai True 1175*7dc08ffcSJunyu Lai 1176*7dc08ffcSJunyu Lai= check _resolve_MAC 1177*7dc08ffcSJunyu Lai 1178*7dc08ffcSJunyu Laiif conf.manufdb: 1179*7dc08ffcSJunyu Lai assert conf.manufdb._resolve_MAC("00:00:63") == "HP" 1180*7dc08ffcSJunyu Laielse: 1181*7dc08ffcSJunyu Lai True 1182*7dc08ffcSJunyu Lai 1183*7dc08ffcSJunyu Lai############ 1184*7dc08ffcSJunyu Lai############ 1185*7dc08ffcSJunyu Lai+ Automaton tests 1186*7dc08ffcSJunyu Lai 1187*7dc08ffcSJunyu Lai= Simple automaton 1188*7dc08ffcSJunyu Lai~ automaton 1189*7dc08ffcSJunyu Laiclass ATMT1(Automaton): 1190*7dc08ffcSJunyu Lai def parse_args(self, init, *args, **kargs): 1191*7dc08ffcSJunyu Lai Automaton.parse_args(self, *args, **kargs) 1192*7dc08ffcSJunyu Lai self.init = init 1193*7dc08ffcSJunyu Lai @ATMT.state(initial=1) 1194*7dc08ffcSJunyu Lai def BEGIN(self): 1195*7dc08ffcSJunyu Lai raise self.MAIN(self.init) 1196*7dc08ffcSJunyu Lai @ATMT.state() 1197*7dc08ffcSJunyu Lai def MAIN(self, s): 1198*7dc08ffcSJunyu Lai return s 1199*7dc08ffcSJunyu Lai @ATMT.condition(MAIN, prio=-1) 1200*7dc08ffcSJunyu Lai def go_to_END(self, s): 1201*7dc08ffcSJunyu Lai if len(s) > 20: 1202*7dc08ffcSJunyu Lai raise self.END(s).action_parameters(s) 1203*7dc08ffcSJunyu Lai @ATMT.condition(MAIN) 1204*7dc08ffcSJunyu Lai def trA(self, s): 1205*7dc08ffcSJunyu Lai if s.endswith("b"): 1206*7dc08ffcSJunyu Lai raise self.MAIN(s+"a") 1207*7dc08ffcSJunyu Lai @ATMT.condition(MAIN) 1208*7dc08ffcSJunyu Lai def trB(self, s): 1209*7dc08ffcSJunyu Lai if s.endswith("a"): 1210*7dc08ffcSJunyu Lai raise self.MAIN(s*2+"b") 1211*7dc08ffcSJunyu Lai @ATMT.state(final=1) 1212*7dc08ffcSJunyu Lai def END(self, s): 1213*7dc08ffcSJunyu Lai return s 1214*7dc08ffcSJunyu Lai @ATMT.action(go_to_END) 1215*7dc08ffcSJunyu Lai def action_test(self, s): 1216*7dc08ffcSJunyu Lai self.result = s 1217*7dc08ffcSJunyu Lai 1218*7dc08ffcSJunyu Lai= Simple automaton Tests 1219*7dc08ffcSJunyu Lai~ automaton 1220*7dc08ffcSJunyu Lai 1221*7dc08ffcSJunyu Laia=ATMT1(init="a", ll=lambda: None, recvsock=lambda: None) 1222*7dc08ffcSJunyu Laia.run() 1223*7dc08ffcSJunyu Laiassert( _ == 'aabaaababaaabaaababab' ) 1224*7dc08ffcSJunyu Laia.result 1225*7dc08ffcSJunyu Laiassert( _ == 'aabaaababaaabaaababab' ) 1226*7dc08ffcSJunyu Laia=ATMT1(init="b", ll=lambda: None, recvsock=lambda: None) 1227*7dc08ffcSJunyu Laia.run() 1228*7dc08ffcSJunyu Laiassert( _ == 'babababababababababababababab' ) 1229*7dc08ffcSJunyu Laia.result 1230*7dc08ffcSJunyu Laiassert( _ == 'babababababababababababababab' ) 1231*7dc08ffcSJunyu Lai 1232*7dc08ffcSJunyu Lai= Simple automaton stuck test 1233*7dc08ffcSJunyu Lai~ automaton 1234*7dc08ffcSJunyu Lai 1235*7dc08ffcSJunyu Laitry: 1236*7dc08ffcSJunyu Lai ATMT1(init="", ll=lambda: None, recvsock=lambda: None).run() 1237*7dc08ffcSJunyu Laiexcept Automaton.Stuck: 1238*7dc08ffcSJunyu Lai True 1239*7dc08ffcSJunyu Laielse: 1240*7dc08ffcSJunyu Lai False 1241*7dc08ffcSJunyu Lai 1242*7dc08ffcSJunyu Lai 1243*7dc08ffcSJunyu Lai= Automaton state overloading 1244*7dc08ffcSJunyu Lai~ automaton 1245*7dc08ffcSJunyu Laiclass ATMT2(ATMT1): 1246*7dc08ffcSJunyu Lai @ATMT.state() 1247*7dc08ffcSJunyu Lai def MAIN(self, s): 1248*7dc08ffcSJunyu Lai return "c"+ATMT1.MAIN(self, s).run() 1249*7dc08ffcSJunyu Lai 1250*7dc08ffcSJunyu Laia=ATMT2(init="a", ll=lambda: None, recvsock=lambda: None) 1251*7dc08ffcSJunyu Laia.run() 1252*7dc08ffcSJunyu Laiassert( _ == 'ccccccacabacccacababacccccacabacccacababab' ) 1253*7dc08ffcSJunyu Lai 1254*7dc08ffcSJunyu Lai 1255*7dc08ffcSJunyu Laia.result 1256*7dc08ffcSJunyu Laiassert( _ == 'ccccccacabacccacababacccccacabacccacababab' ) 1257*7dc08ffcSJunyu Laia=ATMT2(init="b", ll=lambda: None, recvsock=lambda: None) 1258*7dc08ffcSJunyu Laia.run() 1259*7dc08ffcSJunyu Laiassert( _ == 'cccccbaccbabaccccbaccbabab') 1260*7dc08ffcSJunyu Laia.result 1261*7dc08ffcSJunyu Laiassert( _ == 'cccccbaccbabaccccbaccbabab') 1262*7dc08ffcSJunyu Lai 1263*7dc08ffcSJunyu Lai 1264*7dc08ffcSJunyu Lai= Automaton condition overloading 1265*7dc08ffcSJunyu Lai~ automaton 1266*7dc08ffcSJunyu Laiclass ATMT3(ATMT2): 1267*7dc08ffcSJunyu Lai @ATMT.condition(ATMT1.MAIN) 1268*7dc08ffcSJunyu Lai def trA(self, s): 1269*7dc08ffcSJunyu Lai if s.endswith("b"): 1270*7dc08ffcSJunyu Lai raise self.MAIN(s+"da") 1271*7dc08ffcSJunyu Lai 1272*7dc08ffcSJunyu Lai 1273*7dc08ffcSJunyu Laia=ATMT3(init="a", debug=2, ll=lambda: None, recvsock=lambda: None) 1274*7dc08ffcSJunyu Laia.run() 1275*7dc08ffcSJunyu Laiassert( _ == 'cccccacabdacccacabdabda') 1276*7dc08ffcSJunyu Laia.result 1277*7dc08ffcSJunyu Laiassert( _ == 'cccccacabdacccacabdabda') 1278*7dc08ffcSJunyu Laia=ATMT3(init="b", ll=lambda: None, recvsock=lambda: None) 1279*7dc08ffcSJunyu Laia.run() 1280*7dc08ffcSJunyu Laiassert( _ == 'cccccbdaccbdabdaccccbdaccbdabdab' ) 1281*7dc08ffcSJunyu Lai 1282*7dc08ffcSJunyu Laia.result 1283*7dc08ffcSJunyu Laiassert( _ == 'cccccbdaccbdabdaccccbdaccbdabdab' ) 1284*7dc08ffcSJunyu Lai 1285*7dc08ffcSJunyu Lai 1286*7dc08ffcSJunyu Lai= Automaton action overloading 1287*7dc08ffcSJunyu Lai~ automaton 1288*7dc08ffcSJunyu Laiclass ATMT4(ATMT3): 1289*7dc08ffcSJunyu Lai @ATMT.action(ATMT1.go_to_END) 1290*7dc08ffcSJunyu Lai def action_test(self, s): 1291*7dc08ffcSJunyu Lai self.result = "e"+s+"e" 1292*7dc08ffcSJunyu Lai 1293*7dc08ffcSJunyu Laia=ATMT4(init="a", ll=lambda: None, recvsock=lambda: None) 1294*7dc08ffcSJunyu Laia.run() 1295*7dc08ffcSJunyu Laiassert( _ == 'cccccacabdacccacabdabda') 1296*7dc08ffcSJunyu Laia.result 1297*7dc08ffcSJunyu Laiassert( _ == 'ecccccacabdacccacabdabdae') 1298*7dc08ffcSJunyu Laia=ATMT4(init="b", ll=lambda: None, recvsock=lambda: None) 1299*7dc08ffcSJunyu Laia.run() 1300*7dc08ffcSJunyu Laiassert( _ == 'cccccbdaccbdabdaccccbdaccbdabdab' ) 1301*7dc08ffcSJunyu Laia.result 1302*7dc08ffcSJunyu Laiassert( _ == 'ecccccbdaccbdabdaccccbdaccbdabdabe' ) 1303*7dc08ffcSJunyu Lai 1304*7dc08ffcSJunyu Lai 1305*7dc08ffcSJunyu Lai= Automaton priorities 1306*7dc08ffcSJunyu Lai~ automaton 1307*7dc08ffcSJunyu Laiclass ATMT5(Automaton): 1308*7dc08ffcSJunyu Lai @ATMT.state(initial=1) 1309*7dc08ffcSJunyu Lai def BEGIN(self): 1310*7dc08ffcSJunyu Lai self.res = "J" 1311*7dc08ffcSJunyu Lai @ATMT.condition(BEGIN, prio=1) 1312*7dc08ffcSJunyu Lai def tr1(self): 1313*7dc08ffcSJunyu Lai self.res += "i" 1314*7dc08ffcSJunyu Lai raise self.END() 1315*7dc08ffcSJunyu Lai @ATMT.condition(BEGIN) 1316*7dc08ffcSJunyu Lai def tr2(self): 1317*7dc08ffcSJunyu Lai self.res += "p" 1318*7dc08ffcSJunyu Lai @ATMT.condition(BEGIN, prio=-1) 1319*7dc08ffcSJunyu Lai def tr3(self): 1320*7dc08ffcSJunyu Lai self.res += "u" 1321*7dc08ffcSJunyu Lai 1322*7dc08ffcSJunyu Lai @ATMT.action(tr1) 1323*7dc08ffcSJunyu Lai def ac1(self): 1324*7dc08ffcSJunyu Lai self.res += "e" 1325*7dc08ffcSJunyu Lai @ATMT.action(tr1, prio=-1) 1326*7dc08ffcSJunyu Lai def ac2(self): 1327*7dc08ffcSJunyu Lai self.res += "t" 1328*7dc08ffcSJunyu Lai @ATMT.action(tr1, prio=1) 1329*7dc08ffcSJunyu Lai def ac3(self): 1330*7dc08ffcSJunyu Lai self.res += "r" 1331*7dc08ffcSJunyu Lai 1332*7dc08ffcSJunyu Lai @ATMT.state(final=1) 1333*7dc08ffcSJunyu Lai def END(self): 1334*7dc08ffcSJunyu Lai return self.res 1335*7dc08ffcSJunyu Lai 1336*7dc08ffcSJunyu Laia=ATMT5(ll=lambda: None, recvsock=lambda: None) 1337*7dc08ffcSJunyu Laia.run() 1338*7dc08ffcSJunyu Laiassert( _ == 'Jupiter' ) 1339*7dc08ffcSJunyu Lai 1340*7dc08ffcSJunyu Lai= Automaton test same action for many conditions 1341*7dc08ffcSJunyu Lai~ automaton 1342*7dc08ffcSJunyu Laiclass ATMT6(Automaton): 1343*7dc08ffcSJunyu Lai @ATMT.state(initial=1) 1344*7dc08ffcSJunyu Lai def BEGIN(self): 1345*7dc08ffcSJunyu Lai self.res="M" 1346*7dc08ffcSJunyu Lai @ATMT.condition(BEGIN) 1347*7dc08ffcSJunyu Lai def tr1(self): 1348*7dc08ffcSJunyu Lai raise self.MIDDLE() 1349*7dc08ffcSJunyu Lai @ATMT.action(tr1) # default prio=0 1350*7dc08ffcSJunyu Lai def add_e(self): 1351*7dc08ffcSJunyu Lai self.res += "e" 1352*7dc08ffcSJunyu Lai @ATMT.action(tr1, prio=2) 1353*7dc08ffcSJunyu Lai def add_c(self): 1354*7dc08ffcSJunyu Lai self.res += "c" 1355*7dc08ffcSJunyu Lai @ATMT.state() 1356*7dc08ffcSJunyu Lai def MIDDLE(self): 1357*7dc08ffcSJunyu Lai self.res += "u" 1358*7dc08ffcSJunyu Lai @ATMT.condition(MIDDLE) 1359*7dc08ffcSJunyu Lai def tr2(self): 1360*7dc08ffcSJunyu Lai raise self.END() 1361*7dc08ffcSJunyu Lai @ATMT.action(tr2, prio=2) 1362*7dc08ffcSJunyu Lai def add_y(self): 1363*7dc08ffcSJunyu Lai self.res += "y" 1364*7dc08ffcSJunyu Lai @ATMT.action(tr1, prio=1) 1365*7dc08ffcSJunyu Lai @ATMT.action(tr2) 1366*7dc08ffcSJunyu Lai def add_r(self): 1367*7dc08ffcSJunyu Lai self.res += "r" 1368*7dc08ffcSJunyu Lai @ATMT.state(final=1) 1369*7dc08ffcSJunyu Lai def END(self): 1370*7dc08ffcSJunyu Lai return self.res 1371*7dc08ffcSJunyu Lai 1372*7dc08ffcSJunyu Laia=ATMT6(ll=lambda: None, recvsock=lambda: None) 1373*7dc08ffcSJunyu Laia.run() 1374*7dc08ffcSJunyu Laiassert( _ == 'Mercury' ) 1375*7dc08ffcSJunyu Lai 1376*7dc08ffcSJunyu Laia.restart() 1377*7dc08ffcSJunyu Laia.run() 1378*7dc08ffcSJunyu Laiassert( _ == 'Mercury' ) 1379*7dc08ffcSJunyu Lai 1380*7dc08ffcSJunyu Lai= Automaton test io event 1381*7dc08ffcSJunyu Lai~ automaton 1382*7dc08ffcSJunyu Lai 1383*7dc08ffcSJunyu Laiclass ATMT7(Automaton): 1384*7dc08ffcSJunyu Lai @ATMT.state(initial=1) 1385*7dc08ffcSJunyu Lai def BEGIN(self): 1386*7dc08ffcSJunyu Lai self.res = "S" 1387*7dc08ffcSJunyu Lai @ATMT.ioevent(BEGIN, name="tst") 1388*7dc08ffcSJunyu Lai def tr1(self, fd): 1389*7dc08ffcSJunyu Lai self.res += fd.recv() 1390*7dc08ffcSJunyu Lai raise self.NEXT_STATE() 1391*7dc08ffcSJunyu Lai @ATMT.state() 1392*7dc08ffcSJunyu Lai def NEXT_STATE(self): 1393*7dc08ffcSJunyu Lai self.oi.tst.send("ur") 1394*7dc08ffcSJunyu Lai @ATMT.ioevent(NEXT_STATE, name="tst") 1395*7dc08ffcSJunyu Lai def tr2(self, fd): 1396*7dc08ffcSJunyu Lai self.res += fd.recv() 1397*7dc08ffcSJunyu Lai raise self.END() 1398*7dc08ffcSJunyu Lai @ATMT.state(final=1) 1399*7dc08ffcSJunyu Lai def END(self): 1400*7dc08ffcSJunyu Lai self.res += "n" 1401*7dc08ffcSJunyu Lai return self.res 1402*7dc08ffcSJunyu Lai 1403*7dc08ffcSJunyu Laia=ATMT7(ll=lambda: None, recvsock=lambda: None) 1404*7dc08ffcSJunyu Laia.run(wait=False) 1405*7dc08ffcSJunyu Laia.io.tst.send("at") 1406*7dc08ffcSJunyu Laia.io.tst.recv() 1407*7dc08ffcSJunyu Laia.io.tst.send(_) 1408*7dc08ffcSJunyu Laia.run() 1409*7dc08ffcSJunyu Laiassert( _ == "Saturn" ) 1410*7dc08ffcSJunyu Lai 1411*7dc08ffcSJunyu Laia.restart() 1412*7dc08ffcSJunyu Laia.run(wait=False) 1413*7dc08ffcSJunyu Laia.io.tst.send("at") 1414*7dc08ffcSJunyu Laia.io.tst.recv() 1415*7dc08ffcSJunyu Laia.io.tst.send(_) 1416*7dc08ffcSJunyu Laia.run() 1417*7dc08ffcSJunyu Laiassert( _ == "Saturn" ) 1418*7dc08ffcSJunyu Lai 1419*7dc08ffcSJunyu Lai= Automaton test io event from external fd 1420*7dc08ffcSJunyu Lai~ automaton 1421*7dc08ffcSJunyu Laiimport os 1422*7dc08ffcSJunyu Lai 1423*7dc08ffcSJunyu Laiclass ATMT8(Automaton): 1424*7dc08ffcSJunyu Lai @ATMT.state(initial=1) 1425*7dc08ffcSJunyu Lai def BEGIN(self): 1426*7dc08ffcSJunyu Lai self.res = b"U" 1427*7dc08ffcSJunyu Lai @ATMT.ioevent(BEGIN, name="extfd") 1428*7dc08ffcSJunyu Lai def tr1(self, fd): 1429*7dc08ffcSJunyu Lai self.res += fd.read(2) 1430*7dc08ffcSJunyu Lai raise self.NEXT_STATE() 1431*7dc08ffcSJunyu Lai @ATMT.state() 1432*7dc08ffcSJunyu Lai def NEXT_STATE(self): 1433*7dc08ffcSJunyu Lai pass 1434*7dc08ffcSJunyu Lai @ATMT.ioevent(NEXT_STATE, name="extfd") 1435*7dc08ffcSJunyu Lai def tr2(self, fd): 1436*7dc08ffcSJunyu Lai self.res += fd.read(2) 1437*7dc08ffcSJunyu Lai raise self.END() 1438*7dc08ffcSJunyu Lai @ATMT.state(final=1) 1439*7dc08ffcSJunyu Lai def END(self): 1440*7dc08ffcSJunyu Lai self.res += b"s" 1441*7dc08ffcSJunyu Lai return self.res 1442*7dc08ffcSJunyu Lai 1443*7dc08ffcSJunyu Laiif WINDOWS: 1444*7dc08ffcSJunyu Lai r = w = ObjectPipe() 1445*7dc08ffcSJunyu Laielse: 1446*7dc08ffcSJunyu Lai r,w = os.pipe() 1447*7dc08ffcSJunyu Lai 1448*7dc08ffcSJunyu Laidef writeOn(w, msg): 1449*7dc08ffcSJunyu Lai if WINDOWS: 1450*7dc08ffcSJunyu Lai w.write(msg) 1451*7dc08ffcSJunyu Lai else: 1452*7dc08ffcSJunyu Lai os.write(w, msg) 1453*7dc08ffcSJunyu Lai 1454*7dc08ffcSJunyu Laia=ATMT8(external_fd={"extfd":r}, ll=lambda: None, recvsock=lambda: None) 1455*7dc08ffcSJunyu Laia.run(wait=False) 1456*7dc08ffcSJunyu LaiwriteOn(w, b"ra") 1457*7dc08ffcSJunyu LaiwriteOn(w, b"nu") 1458*7dc08ffcSJunyu Lai 1459*7dc08ffcSJunyu Laia.run() 1460*7dc08ffcSJunyu Laiassert( _ == b"Uranus" ) 1461*7dc08ffcSJunyu Lai 1462*7dc08ffcSJunyu Laia.restart() 1463*7dc08ffcSJunyu Laia.run(wait=False) 1464*7dc08ffcSJunyu LaiwriteOn(w, b"ra") 1465*7dc08ffcSJunyu LaiwriteOn(w, b"nu") 1466*7dc08ffcSJunyu Laia.run() 1467*7dc08ffcSJunyu Laiassert( _ == b"Uranus" ) 1468*7dc08ffcSJunyu Lai 1469*7dc08ffcSJunyu Lai= Automaton test interception_points, and restart 1470*7dc08ffcSJunyu Lai~ automaton 1471*7dc08ffcSJunyu Laiclass ATMT9(Automaton): 1472*7dc08ffcSJunyu Lai def my_send(self, x): 1473*7dc08ffcSJunyu Lai self.io.loop.send(x) 1474*7dc08ffcSJunyu Lai @ATMT.state(initial=1) 1475*7dc08ffcSJunyu Lai def BEGIN(self): 1476*7dc08ffcSJunyu Lai self.res = "V" 1477*7dc08ffcSJunyu Lai self.send(Raw("ENU")) 1478*7dc08ffcSJunyu Lai @ATMT.ioevent(BEGIN, name="loop") 1479*7dc08ffcSJunyu Lai def received_sth(self, fd): 1480*7dc08ffcSJunyu Lai self.res += plain_str(fd.recv().load) 1481*7dc08ffcSJunyu Lai raise self.END() 1482*7dc08ffcSJunyu Lai @ATMT.state(final=1) 1483*7dc08ffcSJunyu Lai def END(self): 1484*7dc08ffcSJunyu Lai self.res += "s" 1485*7dc08ffcSJunyu Lai return self.res 1486*7dc08ffcSJunyu Lai 1487*7dc08ffcSJunyu Laia=ATMT9(debug=5, ll=lambda: None, recvsock=lambda: None) 1488*7dc08ffcSJunyu Laia.run() 1489*7dc08ffcSJunyu Laiassert( _ == "VENUs" ) 1490*7dc08ffcSJunyu Lai 1491*7dc08ffcSJunyu Laia.restart() 1492*7dc08ffcSJunyu Laia.run() 1493*7dc08ffcSJunyu Laiassert( _ == "VENUs" ) 1494*7dc08ffcSJunyu Lai 1495*7dc08ffcSJunyu Laia.restart() 1496*7dc08ffcSJunyu Laia.BEGIN.intercepts() 1497*7dc08ffcSJunyu Laiwhile True: 1498*7dc08ffcSJunyu Lai try: 1499*7dc08ffcSJunyu Lai x = a.run() 1500*7dc08ffcSJunyu Lai except Automaton.InterceptionPoint as p: 1501*7dc08ffcSJunyu Lai a.accept_packet(Raw(p.packet.load.lower()), wait=False) 1502*7dc08ffcSJunyu Lai else: 1503*7dc08ffcSJunyu Lai break 1504*7dc08ffcSJunyu Lai 1505*7dc08ffcSJunyu Laix 1506*7dc08ffcSJunyu Laiassert( _ == "Venus" ) 1507*7dc08ffcSJunyu Lai 1508*7dc08ffcSJunyu Lai 1509*7dc08ffcSJunyu Lai############ 1510*7dc08ffcSJunyu Lai############ 1511*7dc08ffcSJunyu Lai+ Test IP options 1512*7dc08ffcSJunyu Lai 1513*7dc08ffcSJunyu Lai= IP options individual assembly 1514*7dc08ffcSJunyu Lai~ IP options 1515*7dc08ffcSJunyu Lairaw(IPOption()) 1516*7dc08ffcSJunyu Laiassert(_ == b'\x00\x02') 1517*7dc08ffcSJunyu Lairaw(IPOption_NOP()) 1518*7dc08ffcSJunyu Laiassert(_ == b'\x01') 1519*7dc08ffcSJunyu Lairaw(IPOption_EOL()) 1520*7dc08ffcSJunyu Laiassert(_ == b'\x00') 1521*7dc08ffcSJunyu Lairaw(IPOption_LSRR(routers=["1.2.3.4","5.6.7.8"])) 1522*7dc08ffcSJunyu Laiassert(_ == b'\x83\x0b\x04\x01\x02\x03\x04\x05\x06\x07\x08') 1523*7dc08ffcSJunyu Lai 1524*7dc08ffcSJunyu Lai= IP options individual dissection 1525*7dc08ffcSJunyu Lai~ IP options 1526*7dc08ffcSJunyu LaiIPOption(b"\x00") 1527*7dc08ffcSJunyu Laiassert(_.option == 0 and isinstance(_, IPOption_EOL)) 1528*7dc08ffcSJunyu LaiIPOption(b"\x01") 1529*7dc08ffcSJunyu Laiassert(_.option == 1 and isinstance(_, IPOption_NOP)) 1530*7dc08ffcSJunyu Lailsrr=b'\x83\x0b\x04\x01\x02\x03\x04\x05\x06\x07\x08' 1531*7dc08ffcSJunyu Laip=IPOption_LSRR(lsrr) 1532*7dc08ffcSJunyu Laip 1533*7dc08ffcSJunyu Laiq=IPOption(lsrr) 1534*7dc08ffcSJunyu Laiq 1535*7dc08ffcSJunyu Laiassert(p == q) 1536*7dc08ffcSJunyu Lai 1537*7dc08ffcSJunyu Lai= IP assembly and dissection with options 1538*7dc08ffcSJunyu Lai~ IP options 1539*7dc08ffcSJunyu Laip = IP(src="9.10.11.12",dst="13.14.15.16",options=IPOption_SDBM(addresses=["1.2.3.4","5.6.7.8"]))/TCP() 1540*7dc08ffcSJunyu Lairaw(p) 1541*7dc08ffcSJunyu Laiassert(_ == b'H\x00\x004\x00\x01\x00\x00@\x06\xa2q\t\n\x0b\x0c\r\x0e\x0f\x10\x95\n\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00_K\x00\x00') 1542*7dc08ffcSJunyu Laiq=IP(_) 1543*7dc08ffcSJunyu Laiq 1544*7dc08ffcSJunyu Laiassert( isinstance(q.options[0],IPOption_SDBM) ) 1545*7dc08ffcSJunyu Laiassert( q[IPOption_SDBM].addresses[1] == "5.6.7.8" ) 1546*7dc08ffcSJunyu Laip.options[0].addresses[0] = '5.6.7.8' 1547*7dc08ffcSJunyu Laiassert( IP(raw(p)).options[0].addresses[0] == '5.6.7.8' ) 1548*7dc08ffcSJunyu LaiIP(src="9.10.11.12", dst="13.14.15.16", options=[IPOption_NOP(),IPOption_LSRR(routers=["1.2.3.4","5.6.7.8"]),IPOption_Security(transmission_control_code="XYZ")])/TCP() 1549*7dc08ffcSJunyu Lairaw(_) 1550*7dc08ffcSJunyu Laiassert(_ == b'K\x00\x00@\x00\x01\x00\x00@\x06\xf3\x83\t\n\x0b\x0c\r\x0e\x0f\x10\x01\x83\x0b\x04\x01\x02\x03\x04\x05\x06\x07\x08\x82\x0b\x00\x00\x00\x00\x00\x00XYZ\x00\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00_K\x00\x00') 1551*7dc08ffcSJunyu LaiIP(_) 1552*7dc08ffcSJunyu Laiq=_ 1553*7dc08ffcSJunyu Laiassert(q[IPOption_LSRR].get_current_router() == "1.2.3.4") 1554*7dc08ffcSJunyu Laiassert(q[IPOption_Security].transmission_control_code == b"XYZ") 1555*7dc08ffcSJunyu Laiassert(q[TCP].flags == 2) 1556*7dc08ffcSJunyu Lai 1557*7dc08ffcSJunyu Lai 1558*7dc08ffcSJunyu Lai############ 1559*7dc08ffcSJunyu Lai############ 1560*7dc08ffcSJunyu Lai+ Test PPP 1561*7dc08ffcSJunyu Lai 1562*7dc08ffcSJunyu Lai= PPP/HDLC 1563*7dc08ffcSJunyu Lai~ ppp hdlc 1564*7dc08ffcSJunyu LaiHDLC()/PPP()/PPP_IPCP() 1565*7dc08ffcSJunyu Lairaw(_) 1566*7dc08ffcSJunyu Lais=_ 1567*7dc08ffcSJunyu Laiassert(s == b'\xff\x03\x80!\x01\x00\x00\x04') 1568*7dc08ffcSJunyu LaiPPP(s) 1569*7dc08ffcSJunyu Laip=_ 1570*7dc08ffcSJunyu Laiassert(HDLC in p) 1571*7dc08ffcSJunyu Laiassert(p[HDLC].control==3) 1572*7dc08ffcSJunyu Laiassert(p[PPP].proto==0x8021) 1573*7dc08ffcSJunyu LaiPPP(s[2:]) 1574*7dc08ffcSJunyu Laiq=_ 1575*7dc08ffcSJunyu Laiassert(HDLC not in q) 1576*7dc08ffcSJunyu Laiassert(q[PPP].proto==0x8021) 1577*7dc08ffcSJunyu Lai 1578*7dc08ffcSJunyu Lai 1579*7dc08ffcSJunyu Lai= PPP IPCP 1580*7dc08ffcSJunyu Lai~ ppp ipcp 1581*7dc08ffcSJunyu LaiPPP(b'\x80!\x01\x01\x00\x10\x03\x06\xc0\xa8\x01\x01\x02\x06\x00-\x0f\x01') 1582*7dc08ffcSJunyu Laip=_ 1583*7dc08ffcSJunyu Laiassert(p[PPP_IPCP].code == 1) 1584*7dc08ffcSJunyu Laiassert(p[PPP_IPCP_Option_IPAddress].data=="192.168.1.1") 1585*7dc08ffcSJunyu Laiassert(p[PPP_IPCP_Option].data == b'\x00-\x0f\x01') 1586*7dc08ffcSJunyu Laip=PPP()/PPP_IPCP(options=[PPP_IPCP_Option_DNS1(data="1.2.3.4"),PPP_IPCP_Option_DNS2(data="5.6.7.8"),PPP_IPCP_Option_NBNS2(data="9.10.11.12")]) 1587*7dc08ffcSJunyu Lairaw(p) 1588*7dc08ffcSJunyu Laiassert(_ == b'\x80!\x01\x00\x00\x16\x81\x06\x01\x02\x03\x04\x83\x06\x05\x06\x07\x08\x84\x06\t\n\x0b\x0c') 1589*7dc08ffcSJunyu LaiPPP(_) 1590*7dc08ffcSJunyu Laiq=_ 1591*7dc08ffcSJunyu Laiassert(raw(p) == raw(q)) 1592*7dc08ffcSJunyu Laiassert(PPP(raw(q))==q) 1593*7dc08ffcSJunyu LaiPPP()/PPP_IPCP(options=[PPP_IPCP_Option_DNS1(data="1.2.3.4"),PPP_IPCP_Option_DNS2(data="5.6.7.8"),PPP_IPCP_Option(type=123,data="ABCDEFG"),PPP_IPCP_Option_NBNS2(data="9.10.11.12")]) 1594*7dc08ffcSJunyu Laip=_ 1595*7dc08ffcSJunyu Lairaw(p) 1596*7dc08ffcSJunyu Laiassert(_ == b'\x80!\x01\x00\x00\x1f\x81\x06\x01\x02\x03\x04\x83\x06\x05\x06\x07\x08{\tABCDEFG\x84\x06\t\n\x0b\x0c') 1597*7dc08ffcSJunyu LaiPPP(_) 1598*7dc08ffcSJunyu Laiq=_ 1599*7dc08ffcSJunyu Laiassert( q[PPP_IPCP_Option].type == 123 ) 1600*7dc08ffcSJunyu Laiassert( q[PPP_IPCP_Option].data == b"ABCDEFG" ) 1601*7dc08ffcSJunyu Laiassert( q[PPP_IPCP_Option_NBNS2].data == '9.10.11.12' ) 1602*7dc08ffcSJunyu Lai 1603*7dc08ffcSJunyu Lai 1604*7dc08ffcSJunyu Lai= PPP ECP 1605*7dc08ffcSJunyu Lai~ ppp ecp 1606*7dc08ffcSJunyu Lai 1607*7dc08ffcSJunyu LaiPPP()/PPP_ECP(options=[PPP_ECP_Option_OUI(oui="XYZ")]) 1608*7dc08ffcSJunyu Laip=_ 1609*7dc08ffcSJunyu Lairaw(p) 1610*7dc08ffcSJunyu Laiassert(_ == b'\x80S\x01\x00\x00\n\x00\x06XYZ\x00') 1611*7dc08ffcSJunyu LaiPPP(_) 1612*7dc08ffcSJunyu Laiq=_ 1613*7dc08ffcSJunyu Laiassert( raw(p)==raw(q) ) 1614*7dc08ffcSJunyu LaiPPP()/PPP_ECP(options=[PPP_ECP_Option_OUI(oui="XYZ"),PPP_ECP_Option(type=1,data="ABCDEFG")]) 1615*7dc08ffcSJunyu Laip=_ 1616*7dc08ffcSJunyu Lairaw(p) 1617*7dc08ffcSJunyu Laiassert(_ == b'\x80S\x01\x00\x00\x13\x00\x06XYZ\x00\x01\tABCDEFG') 1618*7dc08ffcSJunyu LaiPPP(_) 1619*7dc08ffcSJunyu Laiq=_ 1620*7dc08ffcSJunyu Laiassert( raw(p) == raw(q) ) 1621*7dc08ffcSJunyu Laiassert( q[PPP_ECP_Option].data == b"ABCDEFG" ) 1622*7dc08ffcSJunyu Lai 1623*7dc08ffcSJunyu Lai 1624*7dc08ffcSJunyu Lai# Scapy6 Regression Test Campaign 1625*7dc08ffcSJunyu Lai 1626*7dc08ffcSJunyu Lai############ 1627*7dc08ffcSJunyu Lai############ 1628*7dc08ffcSJunyu Lai+ Test IPv6 Class 1629*7dc08ffcSJunyu Lai= IPv6 Class basic Instantiation 1630*7dc08ffcSJunyu Laia=IPv6() 1631*7dc08ffcSJunyu Lai 1632*7dc08ffcSJunyu Lai= IPv6 Class basic build (default values) 1633*7dc08ffcSJunyu Lairaw(IPv6()) == b'`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 1634*7dc08ffcSJunyu Lai 1635*7dc08ffcSJunyu Lai= IPv6 Class basic dissection (default values) 1636*7dc08ffcSJunyu Laia=IPv6(raw(IPv6())) 1637*7dc08ffcSJunyu Laia.version == 6 and a.tc == 0 and a.fl == 0 and a.plen == 0 and a.nh == 59 and a.hlim ==64 and a.src == "::1" and a.dst == "::1" 1638*7dc08ffcSJunyu Lai 1639*7dc08ffcSJunyu Lai= IPv6 Class with basic TCP stacked - build 1640*7dc08ffcSJunyu Lairaw(IPv6()/TCP()) == b'`\x00\x00\x00\x00\x14\x06@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x8f}\x00\x00' 1641*7dc08ffcSJunyu Lai 1642*7dc08ffcSJunyu Lai= IPv6 Class with basic TCP stacked - dissection 1643*7dc08ffcSJunyu Laia=IPv6(raw(IPv6()/TCP())) 1644*7dc08ffcSJunyu Laia.nh == 6 and a.plen == 20 and isinstance(a.payload, TCP) and a.payload.chksum == 0x8f7d 1645*7dc08ffcSJunyu Lai 1646*7dc08ffcSJunyu Lai= IPv6 Class with TCP and TCP data - build 1647*7dc08ffcSJunyu Lairaw(IPv6()/TCP()/Raw(load="somedata")) == b'`\x00\x00\x00\x00\x1c\x06@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\xd5\xdd\x00\x00somedata' 1648*7dc08ffcSJunyu Lai 1649*7dc08ffcSJunyu Lai= IPv6 Class with TCP and TCP data - dissection 1650*7dc08ffcSJunyu Laia=IPv6(raw(IPv6()/TCP()/Raw(load="somedata"))) 1651*7dc08ffcSJunyu Laia.nh == 6 and a.plen == 28 and isinstance(a.payload, TCP) and a.payload.chksum == 0xd5dd and isinstance(a.payload.payload, Raw) and a[Raw].load == b"somedata" 1652*7dc08ffcSJunyu Lai 1653*7dc08ffcSJunyu Lai= IPv6 Class binding with Ethernet - build 1654*7dc08ffcSJunyu Lairaw(Ether(src="00:00:00:00:00:00", dst="ff:ff:ff:ff:ff:ff")/IPv6()/TCP()) == b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x86\xdd`\x00\x00\x00\x00\x14\x06@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x8f}\x00\x00' 1655*7dc08ffcSJunyu Lai 1656*7dc08ffcSJunyu Lai= IPv6 Class binding with Ethernet - dissection 1657*7dc08ffcSJunyu Laia=Ether(raw(Ether()/IPv6()/TCP())) 1658*7dc08ffcSJunyu Laia.type == 0x86dd 1659*7dc08ffcSJunyu Lai 1660*7dc08ffcSJunyu Lai= IPv6 Class binding with GRE - build 1661*7dc08ffcSJunyu Lais = raw(IP(src="127.0.0.1")/GRE()/Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:00:00:00:00")/IP()/GRE()/IPv6(src="::1")) 1662*7dc08ffcSJunyu Lais == b'E\x00\x00f\x00\x01\x00\x00@/|f\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00eX\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x08\x00E\x00\x00@\x00\x01\x00\x00@/|\x8c\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x86\xdd`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 1663*7dc08ffcSJunyu Lai 1664*7dc08ffcSJunyu Lai= IPv6 Class binding with GRE - dissection 1665*7dc08ffcSJunyu Laip = IP(s) 1666*7dc08ffcSJunyu LaiGRE in p and p[GRE:1].proto == 0x6558 and p[GRE:2].proto == 0x86DD and IPv6 in p 1667*7dc08ffcSJunyu Lai 1668*7dc08ffcSJunyu Lai 1669*7dc08ffcSJunyu Lai########### IPv6ExtHdrRouting Class ########################### 1670*7dc08ffcSJunyu Lai 1671*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting Class - No address - build 1672*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/IPv6ExtHdrRouting(addresses=[])/TCP(dport=80)) ==b'`\x00\x00\x00\x00\x1c+@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x06\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\xa5&\x00\x00' 1673*7dc08ffcSJunyu Lai 1674*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting Class - One address - build 1675*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/IPv6ExtHdrRouting(addresses=["2022::deca"])/TCP(dport=80)) == b'`\x00\x00\x00\x00,+@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x06\x02\x00\x01\x00\x00\x00\x00 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91\x7f\x00\x00' 1676*7dc08ffcSJunyu Lai 1677*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting Class - Multiple Addresses - build 1678*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/IPv6ExtHdrRouting(addresses=["2001::deca", "2022::deca"])/TCP(dport=80)) == b'`\x00\x00\x00\x00<+@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x06\x04\x00\x02\x00\x00\x00\x00 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91\x7f\x00\x00' 1679*7dc08ffcSJunyu Lai 1680*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting Class - Specific segleft (2->1) - build 1681*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/IPv6ExtHdrRouting(addresses=["2001::deca", "2022::deca"], segleft=1)/TCP(dport=80)) == b'`\x00\x00\x00\x00<+@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x06\x04\x00\x01\x00\x00\x00\x00 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91\x7f\x00\x00' 1682*7dc08ffcSJunyu Lai 1683*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting Class - Specific segleft (2->0) - build 1684*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/IPv6ExtHdrRouting(addresses=["2001::deca", "2022::deca"], segleft=0)/TCP(dport=80)) == b'`\x00\x00\x00\x00<+@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x06\x04\x00\x00\x00\x00\x00\x00 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\xa5&\x00\x00' 1685*7dc08ffcSJunyu Lai 1686*7dc08ffcSJunyu Lai########### IPv6ExtHdrSegmentRouting Class ########################### 1687*7dc08ffcSJunyu Lai 1688*7dc08ffcSJunyu Lai= IPv6ExtHdrSegmentRouting Class - default - build & dissect 1689*7dc08ffcSJunyu Lais = raw(IPv6()/IPv6ExtHdrSegmentRouting()/UDP()) 1690*7dc08ffcSJunyu Laiassert(s == b'`\x00\x00\x00\x00 +@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x11\x02\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x005\x005\x00\x08\xffr') 1691*7dc08ffcSJunyu Lai 1692*7dc08ffcSJunyu Laip = IPv6(s) 1693*7dc08ffcSJunyu Laiassert(UDP in p and IPv6ExtHdrSegmentRouting in p) 1694*7dc08ffcSJunyu Laiassert(len(p[IPv6ExtHdrSegmentRouting].addresses) == 1 and len(p[IPv6ExtHdrSegmentRouting].tlv_objects) == 0) 1695*7dc08ffcSJunyu Lai 1696*7dc08ffcSJunyu Lai= IPv6ExtHdrSegmentRouting Class - empty lists - build & dissect 1697*7dc08ffcSJunyu Lai 1698*7dc08ffcSJunyu Lais = raw(IPv6()/IPv6ExtHdrSegmentRouting(addresses=[], tlv_objects=[])/UDP()) 1699*7dc08ffcSJunyu Laiassert(s == b'`\x00\x00\x00\x00\x10+@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x11\x00\x04\x00\x00\x00\x00\x00\x005\x005\x00\x08\xffr') 1700*7dc08ffcSJunyu Lai 1701*7dc08ffcSJunyu Laip = IPv6(s) 1702*7dc08ffcSJunyu Laiassert(UDP in p and IPv6ExtHdrSegmentRouting in p) 1703*7dc08ffcSJunyu Laiassert(len(p[IPv6ExtHdrSegmentRouting].addresses) == 0 and len(p[IPv6ExtHdrSegmentRouting].tlv_objects) == 0) 1704*7dc08ffcSJunyu Lai 1705*7dc08ffcSJunyu Lai= IPv6ExtHdrSegmentRouting Class - addresses list - build & dissect 1706*7dc08ffcSJunyu Lai 1707*7dc08ffcSJunyu Lais = raw(IPv6()/IPv6ExtHdrSegmentRouting(addresses=["::1", "::2", "::3"])/UDP()) 1708*7dc08ffcSJunyu Laiassert(s == b'`\x00\x00\x00\x00@+@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x11\x06\x04\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x005\x005\x00\x08\xffr') 1709*7dc08ffcSJunyu Lai 1710*7dc08ffcSJunyu Laip = IPv6(s) 1711*7dc08ffcSJunyu Laiassert(UDP in p and IPv6ExtHdrSegmentRouting in p) 1712*7dc08ffcSJunyu Laiassert(len(p[IPv6ExtHdrSegmentRouting].addresses) == 3 and len(p[IPv6ExtHdrSegmentRouting].tlv_objects) == 0) 1713*7dc08ffcSJunyu Lai 1714*7dc08ffcSJunyu Lai= IPv6ExtHdrSegmentRouting Class - TLVs list - build & dissect 1715*7dc08ffcSJunyu Lai 1716*7dc08ffcSJunyu Lais = raw(IPv6()/IPv6ExtHdrSegmentRouting(addresses=[], tlv_objects=[IPv6ExtHdrSegmentRoutingTLV()])/TCP()) 1717*7dc08ffcSJunyu Laiassert(s == b'`\x00\x00\x00\x00$+@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x06\x01\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x02\x00\x00\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x8f}\x00\x00') 1718*7dc08ffcSJunyu Lai 1719*7dc08ffcSJunyu Laip = IPv6(s) 1720*7dc08ffcSJunyu Laiassert(TCP in p and IPv6ExtHdrSegmentRouting in p) 1721*7dc08ffcSJunyu Laiassert(len(p[IPv6ExtHdrSegmentRouting].addresses) == 0 and len(p[IPv6ExtHdrSegmentRouting].tlv_objects) == 2) 1722*7dc08ffcSJunyu Laiassert(isinstance(p[IPv6ExtHdrSegmentRouting].tlv_objects[1], IPv6ExtHdrSegmentRoutingTLVPadding)) 1723*7dc08ffcSJunyu Lai 1724*7dc08ffcSJunyu Lai= IPv6ExtHdrSegmentRouting Class - both lists - build & dissect 1725*7dc08ffcSJunyu Lai 1726*7dc08ffcSJunyu Lais = raw(IPv6()/IPv6ExtHdrSegmentRouting(addresses=["::1", "::2", "::3"], tlv_objects=[IPv6ExtHdrSegmentRoutingTLVIngressNode(),IPv6ExtHdrSegmentRoutingTLVEgressNode()])/ICMPv6EchoRequest()) 1727*7dc08ffcSJunyu Laiassert(s == b'`\x00\x00\x00\x00h+@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01:\x0b\x04\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x01\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x80\x00\x7f\xbb\x00\x00\x00\x00') 1728*7dc08ffcSJunyu Lai 1729*7dc08ffcSJunyu Laip = IPv6(s) 1730*7dc08ffcSJunyu Laiassert(ICMPv6EchoRequest in p and IPv6ExtHdrSegmentRouting in p) 1731*7dc08ffcSJunyu Laiassert(len(p[IPv6ExtHdrSegmentRouting].addresses) == 3 and len(p[IPv6ExtHdrSegmentRouting].tlv_objects) == 2) 1732*7dc08ffcSJunyu Lai 1733*7dc08ffcSJunyu Lai= IPv6ExtHdrSegmentRouting Class - UDP pseudo-header checksum - build & dissect 1734*7dc08ffcSJunyu Lai 1735*7dc08ffcSJunyu Lais= raw(IPv6(src="fc00::1", dst="fd00::42")/IPv6ExtHdrSegmentRouting(addresses=["fd00::42", "fc13::1337"][::-1], segleft=1, lastentry=1) / UDP(sport=11000, dport=4242) / Raw('foobar')) 1736*7dc08ffcSJunyu Laiassert(s == b'`\x00\x00\x00\x006+@\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00B\x11\x04\x04\x01\x01\x00\x00\x00\xfc\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x137\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00B*\xf8\x10\x92\x00\x0e\x81\xb7foobar') 1737*7dc08ffcSJunyu Lai 1738*7dc08ffcSJunyu Lai 1739*7dc08ffcSJunyu Lai############ 1740*7dc08ffcSJunyu Lai############ 1741*7dc08ffcSJunyu Lai+ Test in6_get6to4Prefix() 1742*7dc08ffcSJunyu Lai 1743*7dc08ffcSJunyu Lai= Test in6_get6to4Prefix() - 0.0.0.0 address 1744*7dc08ffcSJunyu Laiin6_get6to4Prefix("0.0.0.0") == "2002::" 1745*7dc08ffcSJunyu Lai 1746*7dc08ffcSJunyu Lai= Test in6_get6to4Prefix() - 255.255.255.255 address 1747*7dc08ffcSJunyu Laiin6_get6to4Prefix("255.255.255.255") == "2002:ffff:ffff::" 1748*7dc08ffcSJunyu Lai 1749*7dc08ffcSJunyu Lai= Test in6_get6to4Prefix() - 1.1.1.1 address 1750*7dc08ffcSJunyu Laiin6_get6to4Prefix("1.1.1.1") == "2002:101:101::" 1751*7dc08ffcSJunyu Lai 1752*7dc08ffcSJunyu Lai= Test in6_get6to4Prefix() - invalid address 1753*7dc08ffcSJunyu Laiin6_get6to4Prefix("somebadrawing") is None 1754*7dc08ffcSJunyu Lai 1755*7dc08ffcSJunyu Lai 1756*7dc08ffcSJunyu Lai############ 1757*7dc08ffcSJunyu Lai############ 1758*7dc08ffcSJunyu Lai+ Test in6_6to4ExtractAddr() 1759*7dc08ffcSJunyu Lai 1760*7dc08ffcSJunyu Lai= Test in6_6to4ExtractAddr() - 2002:: address 1761*7dc08ffcSJunyu Laiin6_6to4ExtractAddr("2002::") == "0.0.0.0" 1762*7dc08ffcSJunyu Lai 1763*7dc08ffcSJunyu Lai= Test in6_6to4ExtractAddr() - 255.255.255.255 address 1764*7dc08ffcSJunyu Laiin6_6to4ExtractAddr("2002:ffff:ffff::") == "255.255.255.255" 1765*7dc08ffcSJunyu Lai 1766*7dc08ffcSJunyu Lai= Test in6_6to4ExtractAddr() - "2002:101:101::" address 1767*7dc08ffcSJunyu Laiin6_6to4ExtractAddr("2002:101:101::") == "1.1.1.1" 1768*7dc08ffcSJunyu Lai 1769*7dc08ffcSJunyu Lai= Test in6_6to4ExtractAddr() - invalid address 1770*7dc08ffcSJunyu Laiin6_6to4ExtractAddr("somebadrawing") is None 1771*7dc08ffcSJunyu Lai 1772*7dc08ffcSJunyu Lai 1773*7dc08ffcSJunyu Lai########### RFC 4489 - Link-Scoped IPv6 Multicast address ########### 1774*7dc08ffcSJunyu Lai 1775*7dc08ffcSJunyu Lai= in6_getLinkScopedMcastAddr() : default generation 1776*7dc08ffcSJunyu Laia = in6_getLinkScopedMcastAddr(addr="FE80::") 1777*7dc08ffcSJunyu Laia == 'ff32:ff::' 1778*7dc08ffcSJunyu Lai 1779*7dc08ffcSJunyu Lai= in6_getLinkScopedMcastAddr() : different valid scope values 1780*7dc08ffcSJunyu Laia = in6_getLinkScopedMcastAddr(addr="FE80::", scope=0) 1781*7dc08ffcSJunyu Laib = in6_getLinkScopedMcastAddr(addr="FE80::", scope=1) 1782*7dc08ffcSJunyu Laic = in6_getLinkScopedMcastAddr(addr="FE80::", scope=2) 1783*7dc08ffcSJunyu Laid = in6_getLinkScopedMcastAddr(addr="FE80::", scope=3) 1784*7dc08ffcSJunyu Laia == 'ff30:ff::' and b == 'ff31:ff::' and c == 'ff32:ff::' and d is None 1785*7dc08ffcSJunyu Lai 1786*7dc08ffcSJunyu Lai= in6_getLinkScopedMcastAddr() : grpid in different formats 1787*7dc08ffcSJunyu Laia = in6_getLinkScopedMcastAddr(addr="FE80::A12:34FF:FE56:7890", grpid=b"\x12\x34\x56\x78") 1788*7dc08ffcSJunyu Laib = in6_getLinkScopedMcastAddr(addr="FE80::A12:34FF:FE56:7890", grpid="12345678") 1789*7dc08ffcSJunyu Laic = in6_getLinkScopedMcastAddr(addr="FE80::A12:34FF:FE56:7890", grpid=305419896) 1790*7dc08ffcSJunyu Laia == b and b == c 1791*7dc08ffcSJunyu Lai 1792*7dc08ffcSJunyu Lai 1793*7dc08ffcSJunyu Lai########### ethernet address to iface ID conversion ################# 1794*7dc08ffcSJunyu Lai 1795*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 1) 1796*7dc08ffcSJunyu Laiin6_mactoifaceid("FD:00:00:00:00:00", ulbit=0) == 'FD00:00FF:FE00:0000' 1797*7dc08ffcSJunyu Lai 1798*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 2) 1799*7dc08ffcSJunyu Laiin6_mactoifaceid("FD:00:00:00:00:00", ulbit=1) == 'FF00:00FF:FE00:0000' 1800*7dc08ffcSJunyu Lai 1801*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 3) 1802*7dc08ffcSJunyu Laiin6_mactoifaceid("FD:00:00:00:00:00") == 'FF00:00FF:FE00:0000' 1803*7dc08ffcSJunyu Lai 1804*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 4) 1805*7dc08ffcSJunyu Laiin6_mactoifaceid("FF:00:00:00:00:00") == 'FD00:00FF:FE00:0000' 1806*7dc08ffcSJunyu Lai 1807*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 5) 1808*7dc08ffcSJunyu Laiin6_mactoifaceid("FF:00:00:00:00:00", ulbit=1) == 'FF00:00FF:FE00:0000' 1809*7dc08ffcSJunyu Lai 1810*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 6) 1811*7dc08ffcSJunyu Laiin6_mactoifaceid("FF:00:00:00:00:00", ulbit=0) == 'FD00:00FF:FE00:0000' 1812*7dc08ffcSJunyu Lai 1813*7dc08ffcSJunyu Lai########### iface ID conversion ################# 1814*7dc08ffcSJunyu Lai 1815*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 1) 1816*7dc08ffcSJunyu Laiin6_ifaceidtomac(in6_mactoifaceid("FD:00:00:00:00:00", ulbit=0)) == 'ff:00:00:00:00:00' 1817*7dc08ffcSJunyu Lai 1818*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 2) 1819*7dc08ffcSJunyu Laiin6_ifaceidtomac(in6_mactoifaceid("FD:00:00:00:00:00", ulbit=1)) == 'fd:00:00:00:00:00' 1820*7dc08ffcSJunyu Lai 1821*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 3) 1822*7dc08ffcSJunyu Laiin6_ifaceidtomac(in6_mactoifaceid("FD:00:00:00:00:00")) == 'fd:00:00:00:00:00' 1823*7dc08ffcSJunyu Lai 1824*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 4) 1825*7dc08ffcSJunyu Laiin6_ifaceidtomac(in6_mactoifaceid("FF:00:00:00:00:00")) == 'ff:00:00:00:00:00' 1826*7dc08ffcSJunyu Lai 1827*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 5) 1828*7dc08ffcSJunyu Laiin6_ifaceidtomac(in6_mactoifaceid("FF:00:00:00:00:00", ulbit=1)) == 'fd:00:00:00:00:00' 1829*7dc08ffcSJunyu Lai 1830*7dc08ffcSJunyu Lai= in6_mactoifaceid() conversion function (test 6) 1831*7dc08ffcSJunyu Laiin6_ifaceidtomac(in6_mactoifaceid("FF:00:00:00:00:00", ulbit=0)) == 'ff:00:00:00:00:00' 1832*7dc08ffcSJunyu Lai 1833*7dc08ffcSJunyu Lai 1834*7dc08ffcSJunyu Lai= in6_addrtomac() conversion function (test 1) 1835*7dc08ffcSJunyu Laiin6_addrtomac("FE80::" + in6_mactoifaceid("FD:00:00:00:00:00", ulbit=0)) == 'ff:00:00:00:00:00' 1836*7dc08ffcSJunyu Lai 1837*7dc08ffcSJunyu Lai= in6_addrtomac() conversion function (test 2) 1838*7dc08ffcSJunyu Laiin6_addrtomac("FE80::" + in6_mactoifaceid("FD:00:00:00:00:00", ulbit=1)) == 'fd:00:00:00:00:00' 1839*7dc08ffcSJunyu Lai 1840*7dc08ffcSJunyu Lai= in6_addrtomac() conversion function (test 3) 1841*7dc08ffcSJunyu Laiin6_addrtomac("FE80::" + in6_mactoifaceid("FD:00:00:00:00:00")) == 'fd:00:00:00:00:00' 1842*7dc08ffcSJunyu Lai 1843*7dc08ffcSJunyu Lai= in6_addrtomac() conversion function (test 4) 1844*7dc08ffcSJunyu Laiin6_addrtomac("FE80::" + in6_mactoifaceid("FF:00:00:00:00:00")) == 'ff:00:00:00:00:00' 1845*7dc08ffcSJunyu Lai 1846*7dc08ffcSJunyu Lai= in6_addrtomac() conversion function (test 5) 1847*7dc08ffcSJunyu Laiin6_addrtomac("FE80::" + in6_mactoifaceid("FF:00:00:00:00:00", ulbit=1)) == 'fd:00:00:00:00:00' 1848*7dc08ffcSJunyu Lai 1849*7dc08ffcSJunyu Lai= in6_addrtomac() conversion function (test 6) 1850*7dc08ffcSJunyu Laiin6_addrtomac("FE80::" + in6_mactoifaceid("FF:00:00:00:00:00", ulbit=0)) == 'ff:00:00:00:00:00' 1851*7dc08ffcSJunyu Lai 1852*7dc08ffcSJunyu Lai########### RFC 3041 related function ############################### 1853*7dc08ffcSJunyu Lai= Test in6_getRandomizedIfaceId 1854*7dc08ffcSJunyu Laiimport socket 1855*7dc08ffcSJunyu Lai 1856*7dc08ffcSJunyu Laires=True 1857*7dc08ffcSJunyu Laifor a in six.moves.range(10): 1858*7dc08ffcSJunyu Lai s1,s2 = in6_getRandomizedIfaceId('20b:93ff:feeb:2d3') 1859*7dc08ffcSJunyu Lai inet_pton(socket.AF_INET6, '::'+s1) 1860*7dc08ffcSJunyu Lai tmp2 = inet_pton(socket.AF_INET6, '::'+s2) 1861*7dc08ffcSJunyu Lai res = res and ((orb(s1[0]) & 0x04) == 0x04) 1862*7dc08ffcSJunyu Lai s1,s2 = in6_getRandomizedIfaceId('20b:93ff:feeb:2d3', previous=tmp2) 1863*7dc08ffcSJunyu Lai tmp = inet_pton(socket.AF_INET6, '::'+s1) 1864*7dc08ffcSJunyu Lai inet_pton(socket.AF_INET6, '::'+s2) 1865*7dc08ffcSJunyu Lai res = res and ((orb(s1[0]) & 0x04) == 0x04) 1866*7dc08ffcSJunyu Lai 1867*7dc08ffcSJunyu Lai########### RFC 1924 related function ############################### 1868*7dc08ffcSJunyu Lai= Test RFC 1924 function - in6_ctop() basic test 1869*7dc08ffcSJunyu Laiin6_ctop("4)+k&C#VzJ4br>0wv%Yp") == '1080::8:800:200c:417a' 1870*7dc08ffcSJunyu Lai 1871*7dc08ffcSJunyu Lai= Test RFC 1924 function - in6_ctop() with character outside charset 1872*7dc08ffcSJunyu Laiin6_ctop("4)+k&C#VzJ4br>0wv%Y'") == None 1873*7dc08ffcSJunyu Lai 1874*7dc08ffcSJunyu Lai= Test RFC 1924 function - in6_ctop() with bad length address 1875*7dc08ffcSJunyu Laiin6_ctop("4)+k&C#VzJ4br>0wv%Y") == None 1876*7dc08ffcSJunyu Lai 1877*7dc08ffcSJunyu Lai= Test RFC 1924 function - in6_ptoc() basic test 1878*7dc08ffcSJunyu Laiin6_ptoc('1080::8:800:200c:417a') == '4)+k&C#VzJ4br>0wv%Yp' 1879*7dc08ffcSJunyu Lai 1880*7dc08ffcSJunyu Lai= Test RFC 1924 function - in6_ptoc() basic test 1881*7dc08ffcSJunyu Laiin6_ptoc('1080::8:800:200c:417a') == '4)+k&C#VzJ4br>0wv%Yp' 1882*7dc08ffcSJunyu Lai 1883*7dc08ffcSJunyu Lai= Test RFC 1924 function - in6_ptoc() with bad input 1884*7dc08ffcSJunyu Laiin6_ptoc('1080:::8:800:200c:417a') == None 1885*7dc08ffcSJunyu Lai 1886*7dc08ffcSJunyu Lai########### in6_getAddrType ######################################### 1887*7dc08ffcSJunyu Lai 1888*7dc08ffcSJunyu Lai= in6_getAddrType - 6to4 addresses 1889*7dc08ffcSJunyu Laiin6_getAddrType("2002::1") == (IPV6_ADDR_UNICAST | IPV6_ADDR_GLOBAL | IPV6_ADDR_6TO4) 1890*7dc08ffcSJunyu Lai 1891*7dc08ffcSJunyu Lai= in6_getAddrType - Assignable Unicast global address 1892*7dc08ffcSJunyu Laiin6_getAddrType("2001:db8::1") == (IPV6_ADDR_UNICAST | IPV6_ADDR_GLOBAL) 1893*7dc08ffcSJunyu Lai 1894*7dc08ffcSJunyu Lai= in6_getAddrType - Multicast global address 1895*7dc08ffcSJunyu Laiin6_getAddrType("FF0E::1") == (IPV6_ADDR_GLOBAL | IPV6_ADDR_MULTICAST) 1896*7dc08ffcSJunyu Lai 1897*7dc08ffcSJunyu Lai= in6_getAddrType - Multicast local address 1898*7dc08ffcSJunyu Laiin6_getAddrType("FF02::1") == (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_MULTICAST) 1899*7dc08ffcSJunyu Lai 1900*7dc08ffcSJunyu Lai= in6_getAddrType - Unicast Link-Local address 1901*7dc08ffcSJunyu Laiin6_getAddrType("FE80::") == (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL) 1902*7dc08ffcSJunyu Lai 1903*7dc08ffcSJunyu Lai= in6_getAddrType - Loopback address 1904*7dc08ffcSJunyu Laiin6_getAddrType("::1") == IPV6_ADDR_LOOPBACK 1905*7dc08ffcSJunyu Lai 1906*7dc08ffcSJunyu Lai= in6_getAddrType - Unspecified address 1907*7dc08ffcSJunyu Laiin6_getAddrType("::") == IPV6_ADDR_UNSPECIFIED 1908*7dc08ffcSJunyu Lai 1909*7dc08ffcSJunyu Lai= in6_getAddrType - Unassigned Global Unicast address 1910*7dc08ffcSJunyu Laiin6_getAddrType("4000::") == (IPV6_ADDR_GLOBAL | IPV6_ADDR_UNICAST) 1911*7dc08ffcSJunyu Lai 1912*7dc08ffcSJunyu Lai= in6_getAddrType - Weird address (FE::1) 1913*7dc08ffcSJunyu Laiin6_getAddrType("FE::") == (IPV6_ADDR_GLOBAL | IPV6_ADDR_UNICAST) 1914*7dc08ffcSJunyu Lai 1915*7dc08ffcSJunyu Lai= in6_getAddrType - Weird address (FE8::1) 1916*7dc08ffcSJunyu Laiin6_getAddrType("FE8::1") == (IPV6_ADDR_GLOBAL | IPV6_ADDR_UNICAST) 1917*7dc08ffcSJunyu Lai 1918*7dc08ffcSJunyu Lai= in6_getAddrType - Weird address (1::1) 1919*7dc08ffcSJunyu Laiin6_getAddrType("1::1") == (IPV6_ADDR_GLOBAL | IPV6_ADDR_UNICAST) 1920*7dc08ffcSJunyu Lai 1921*7dc08ffcSJunyu Lai= in6_getAddrType - Weird address (1000::1) 1922*7dc08ffcSJunyu Laiin6_getAddrType("1000::1") == (IPV6_ADDR_GLOBAL | IPV6_ADDR_UNICAST) 1923*7dc08ffcSJunyu Lai 1924*7dc08ffcSJunyu Lai########### ICMPv6DestUnreach Class ################################# 1925*7dc08ffcSJunyu Lai 1926*7dc08ffcSJunyu Lai= ICMPv6DestUnreach Class - Basic Build (no argument) 1927*7dc08ffcSJunyu Lairaw(ICMPv6DestUnreach()) == b'\x01\x00\x00\x00\x00\x00\x00\x00' 1928*7dc08ffcSJunyu Lai 1929*7dc08ffcSJunyu Lai= ICMPv6DestUnreach Class - Basic Build over IPv6 (for cksum and overload) 1930*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6DestUnreach()) == b'`\x00\x00\x00\x00\x08:@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x01\x00\x14e\x00\x00\x00\x00' 1931*7dc08ffcSJunyu Lai 1932*7dc08ffcSJunyu Lai= ICMPv6DestUnreach Class - Basic Build over IPv6 with some payload 1933*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6DestUnreach()/IPv6(src="2047::cafe", dst="2048::deca")) == b'`\x00\x00\x00\x000:@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x01\x00\x8e\xa3\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@ G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca' 1934*7dc08ffcSJunyu Lai 1935*7dc08ffcSJunyu Lai= ICMPv6DestUnreach Class - Dissection with default values and some payload 1936*7dc08ffcSJunyu Laia = IPv6(raw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6DestUnreach()/IPv6(src="2047::cafe", dst="2048::deca"))) 1937*7dc08ffcSJunyu Laia.plen == 48 and a.nh == 58 and ICMPv6DestUnreach in a and a[ICMPv6DestUnreach].type == 1 and a[ICMPv6DestUnreach].code == 0 and a[ICMPv6DestUnreach].cksum == 0x8ea3 and a[ICMPv6DestUnreach].unused == 0 and IPerror6 in a 1938*7dc08ffcSJunyu Lai 1939*7dc08ffcSJunyu Lai= ICMPv6DestUnreach Class - Dissection with specific values 1940*7dc08ffcSJunyu Laia=IPv6(raw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6DestUnreach(code=1, cksum=0x6666, unused=0x7777)/IPv6(src="2047::cafe", dst="2048::deca"))) 1941*7dc08ffcSJunyu Laia.plen == 48 and a.nh == 58 and ICMPv6DestUnreach in a and a[ICMPv6DestUnreach].type == 1 and a[ICMPv6DestUnreach].cksum == 0x6666 and a[ICMPv6DestUnreach].unused == 0x7777 and IPerror6 in a[ICMPv6DestUnreach] 1942*7dc08ffcSJunyu Lai 1943*7dc08ffcSJunyu Lai= ICMPv6DestUnreach Class - checksum computation related stuff 1944*7dc08ffcSJunyu Laia=IPv6(raw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6DestUnreach(code=1, cksum=0x6666, unused=0x7777)/IPv6(src="2047::cafe", dst="2048::deca")/TCP())) 1945*7dc08ffcSJunyu Laib=IPv6(raw(IPv6(src="2047::cafe", dst="2048::deca")/TCP())) 1946*7dc08ffcSJunyu Laia[ICMPv6DestUnreach][TCPerror].chksum == b.chksum 1947*7dc08ffcSJunyu Lai 1948*7dc08ffcSJunyu Lai 1949*7dc08ffcSJunyu Lai########### ICMPv6PacketTooBig Class ################################ 1950*7dc08ffcSJunyu Lai 1951*7dc08ffcSJunyu Lai= ICMPv6PacketTooBig Class - Basic Build (no argument) 1952*7dc08ffcSJunyu Lairaw(ICMPv6PacketTooBig()) == b'\x02\x00\x00\x00\x00\x00\x05\x00' 1953*7dc08ffcSJunyu Lai 1954*7dc08ffcSJunyu Lai= ICMPv6PacketTooBig Class - Basic Build over IPv6 (for cksum and overload) 1955*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6PacketTooBig()) == b'`\x00\x00\x00\x00\x08:@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x02\x00\x0ee\x00\x00\x05\x00' 1956*7dc08ffcSJunyu Lai 1957*7dc08ffcSJunyu Lai= ICMPv6PacketTooBig Class - Basic Build over IPv6 with some payload 1958*7dc08ffcSJunyu Lairaw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6PacketTooBig()/IPv6(src="2047::cafe", dst="2048::deca")) == b'`\x00\x00\x00\x000:@ H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x02\x00\x88\xa3\x00\x00\x05\x00`\x00\x00\x00\x00\x00;@ G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe H\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca' 1959*7dc08ffcSJunyu Lai 1960*7dc08ffcSJunyu Lai= ICMPv6PacketTooBig Class - Dissection with default values and some payload 1961*7dc08ffcSJunyu Laia = IPv6(raw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6PacketTooBig()/IPv6(src="2047::cafe", dst="2048::deca"))) 1962*7dc08ffcSJunyu Laia.plen == 48 and a.nh == 58 and ICMPv6PacketTooBig in a and a[ICMPv6PacketTooBig].type == 2 and a[ICMPv6PacketTooBig].code == 0 and a[ICMPv6PacketTooBig].cksum == 0x88a3 and a[ICMPv6PacketTooBig].mtu == 1280 and IPerror6 in a 1963*7dc08ffcSJunyu LaiTrue 1964*7dc08ffcSJunyu Lai 1965*7dc08ffcSJunyu Lai= ICMPv6PacketTooBig Class - Dissection with specific values 1966*7dc08ffcSJunyu Laia=IPv6(raw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6PacketTooBig(code=2, cksum=0x6666, mtu=1460)/IPv6(src="2047::cafe", dst="2048::deca"))) 1967*7dc08ffcSJunyu Laia.plen == 48 and a.nh == 58 and ICMPv6PacketTooBig in a and a[ICMPv6PacketTooBig].type == 2 and a[ICMPv6PacketTooBig].code == 2 and a[ICMPv6PacketTooBig].cksum == 0x6666 and a[ICMPv6PacketTooBig].mtu == 1460 and IPerror6 in a 1968*7dc08ffcSJunyu Lai 1969*7dc08ffcSJunyu Lai= ICMPv6PacketTooBig Class - checksum computation related stuff 1970*7dc08ffcSJunyu Laia=IPv6(raw(IPv6(src="2048::deca", dst="2047::cafe")/ICMPv6PacketTooBig(code=1, cksum=0x6666, mtu=0x7777)/IPv6(src="2047::cafe", dst="2048::deca")/TCP())) 1971*7dc08ffcSJunyu Laib=IPv6(raw(IPv6(src="2047::cafe", dst="2048::deca")/TCP())) 1972*7dc08ffcSJunyu Laia[ICMPv6PacketTooBig][TCPerror].chksum == b.chksum 1973*7dc08ffcSJunyu Lai 1974*7dc08ffcSJunyu Lai 1975*7dc08ffcSJunyu Lai########### ICMPv6TimeExceeded Class ################################ 1976*7dc08ffcSJunyu Lai# To be done but not critical. Same mechanisms and format as 1977*7dc08ffcSJunyu Lai# previous ones. 1978*7dc08ffcSJunyu Lai 1979*7dc08ffcSJunyu Lai########### ICMPv6ParamProblem Class ################################ 1980*7dc08ffcSJunyu Lai# See previous note 1981*7dc08ffcSJunyu Lai 1982*7dc08ffcSJunyu Lai############ 1983*7dc08ffcSJunyu Lai############ 1984*7dc08ffcSJunyu Lai+ Test ICMPv6EchoRequest Class 1985*7dc08ffcSJunyu Lai 1986*7dc08ffcSJunyu Lai= ICMPv6EchoRequest - Basic Instantiation 1987*7dc08ffcSJunyu Lairaw(ICMPv6EchoRequest()) == b'\x80\x00\x00\x00\x00\x00\x00\x00' 1988*7dc08ffcSJunyu Lai 1989*7dc08ffcSJunyu Lai= ICMPv6EchoRequest - Instantiation with specific values 1990*7dc08ffcSJunyu Lairaw(ICMPv6EchoRequest(code=0xff, cksum=0x1111, id=0x2222, seq=0x3333, data="thisissomestring")) == b'\x80\xff\x11\x11""33thisissomestring' 1991*7dc08ffcSJunyu Lai 1992*7dc08ffcSJunyu Lai= ICMPv6EchoRequest - Basic dissection 1993*7dc08ffcSJunyu Laia=ICMPv6EchoRequest(b'\x80\x00\x00\x00\x00\x00\x00\x00') 1994*7dc08ffcSJunyu Laia.type == 128 and a.code == 0 and a.cksum == 0 and a.id == 0 and a.seq == 0 and a.data == b"" 1995*7dc08ffcSJunyu Lai 1996*7dc08ffcSJunyu Lai= ICMPv6EchoRequest - Dissection with specific values 1997*7dc08ffcSJunyu Laia=ICMPv6EchoRequest(b'\x80\xff\x11\x11""33thisissomerawing') 1998*7dc08ffcSJunyu Laia.type == 128 and a.code == 0xff and a.cksum == 0x1111 and a.id == 0x2222 and a.seq == 0x3333 and a.data == b"thisissomerawing" 1999*7dc08ffcSJunyu Lai 2000*7dc08ffcSJunyu Lai= ICMPv6EchoRequest - Automatic checksum computation and field overloading (build) 2001*7dc08ffcSJunyu Lairaw(IPv6(dst="2001::cafe", src="2001::deca", hlim=64)/ICMPv6EchoRequest()) == b'`\x00\x00\x00\x00\x08:@ \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x80\x00\x95\xf1\x00\x00\x00\x00' 2002*7dc08ffcSJunyu Lai 2003*7dc08ffcSJunyu Lai= ICMPv6EchoRequest - Automatic checksum computation and field overloading (dissection) 2004*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x08:@ \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x80\x00\x95\xf1\x00\x00\x00\x00') 2005*7dc08ffcSJunyu Laiisinstance(a, IPv6) and a.nh == 58 and isinstance(a.payload, ICMPv6EchoRequest) and a.payload.cksum == 0x95f1 2006*7dc08ffcSJunyu Lai 2007*7dc08ffcSJunyu Lai 2008*7dc08ffcSJunyu Lai############ 2009*7dc08ffcSJunyu Lai############ 2010*7dc08ffcSJunyu Lai+ Test ICMPv6EchoReply Class 2011*7dc08ffcSJunyu Lai 2012*7dc08ffcSJunyu Lai= ICMPv6EchoReply - Basic Instantiation 2013*7dc08ffcSJunyu Lairaw(ICMPv6EchoReply()) == b'\x81\x00\x00\x00\x00\x00\x00\x00' 2014*7dc08ffcSJunyu Lai 2015*7dc08ffcSJunyu Lai= ICMPv6EchoReply - Instantiation with specific values 2016*7dc08ffcSJunyu Lairaw(ICMPv6EchoReply(code=0xff, cksum=0x1111, id=0x2222, seq=0x3333, data="thisissomestring")) == b'\x81\xff\x11\x11""33thisissomestring' 2017*7dc08ffcSJunyu Lai 2018*7dc08ffcSJunyu Lai= ICMPv6EchoReply - Basic dissection 2019*7dc08ffcSJunyu Laia=ICMPv6EchoReply(b'\x80\x00\x00\x00\x00\x00\x00\x00') 2020*7dc08ffcSJunyu Laia.type == 128 and a.code == 0 and a.cksum == 0 and a.id == 0 and a.seq == 0 and a.data == b"" 2021*7dc08ffcSJunyu Lai 2022*7dc08ffcSJunyu Lai= ICMPv6EchoReply - Dissection with specific values 2023*7dc08ffcSJunyu Laia=ICMPv6EchoReply(b'\x80\xff\x11\x11""33thisissomerawing') 2024*7dc08ffcSJunyu Laia.type == 128 and a.code == 0xff and a.cksum == 0x1111 and a.id == 0x2222 and a.seq == 0x3333 and a.data == b"thisissomerawing" 2025*7dc08ffcSJunyu Lai 2026*7dc08ffcSJunyu Lai= ICMPv6EchoReply - Automatic checksum computation and field overloading (build) 2027*7dc08ffcSJunyu Lairaw(IPv6(dst="2001::cafe", src="2001::deca", hlim=64)/ICMPv6EchoReply()) == b'`\x00\x00\x00\x00\x08:@ \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x81\x00\x94\xf1\x00\x00\x00\x00' 2028*7dc08ffcSJunyu Lai 2029*7dc08ffcSJunyu Lai= ICMPv6EchoReply - Automatic checksum computation and field overloading (dissection) 2030*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x08:@ \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xca \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe\x80\x00\x95\xf1\x00\x00\x00\x00') 2031*7dc08ffcSJunyu Laiisinstance(a, IPv6) and a.nh == 58 and isinstance(a.payload, ICMPv6EchoRequest) and a.payload.cksum == 0x95f1 2032*7dc08ffcSJunyu Lai 2033*7dc08ffcSJunyu Lai########### ICMPv6EchoReply/Request answers() and hashret() ######### 2034*7dc08ffcSJunyu Lai 2035*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - hashret() test 1 2036*7dc08ffcSJunyu Laib=IPv6(src="2047::deca", dst="2048::cafe")/ICMPv6EchoReply(data="somedata") 2037*7dc08ffcSJunyu Laia=IPv6(src="2048::cafe", dst="2047::deca")/ICMPv6EchoRequest(data="somedata") 2038*7dc08ffcSJunyu Laib.hashret() == a.hashret() 2039*7dc08ffcSJunyu Lai 2040*7dc08ffcSJunyu Lai# data are not taken into account for hashret 2041*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - hashret() test 2 2042*7dc08ffcSJunyu Laib=IPv6(src="2047::deca", dst="2048::cafe")/ICMPv6EchoReply(data="somedata") 2043*7dc08ffcSJunyu Laia=IPv6(src="2048::cafe", dst="2047::deca")/ICMPv6EchoRequest(data="otherdata") 2044*7dc08ffcSJunyu Laib.hashret() == a.hashret() 2045*7dc08ffcSJunyu Lai 2046*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - hashret() test 3 2047*7dc08ffcSJunyu Laib=IPv6(src="2047::deca", dst="2048::cafe")/ICMPv6EchoReply(id=0x6666, seq=0x7777,data="somedata") 2048*7dc08ffcSJunyu Laia=IPv6(src="2048::cafe", dst="2047::deca")/ICMPv6EchoRequest(id=0x6666, seq=0x8888, data="somedata") 2049*7dc08ffcSJunyu Laib.hashret() != a.hashret() 2050*7dc08ffcSJunyu Lai 2051*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - hashret() test 4 2052*7dc08ffcSJunyu Laib=IPv6(src="2047::deca", dst="2048::cafe")/ICMPv6EchoReply(id=0x6666, seq=0x7777,data="somedata") 2053*7dc08ffcSJunyu Laia=IPv6(src="2048::cafe", dst="2047::deca")/ICMPv6EchoRequest(id=0x8888, seq=0x7777, data="somedata") 2054*7dc08ffcSJunyu Laib.hashret() != a.hashret() 2055*7dc08ffcSJunyu Lai 2056*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - answers() test 5 2057*7dc08ffcSJunyu Laib=IPv6(src="2047::deca", dst="2048::cafe")/ICMPv6EchoReply(data="somedata") 2058*7dc08ffcSJunyu Laia=IPv6(src="2048::cafe", dst="2047::deca")/ICMPv6EchoRequest(data="somedata") 2059*7dc08ffcSJunyu Lai(a > b) == True 2060*7dc08ffcSJunyu Lai 2061*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - answers() test 6 2062*7dc08ffcSJunyu Laib=IPv6(src="2047::deca", dst="2048::cafe")/ICMPv6EchoReply(id=0x6666, seq=0x7777, data="somedata") 2063*7dc08ffcSJunyu Laia=IPv6(src="2048::cafe", dst="2047::deca")/ICMPv6EchoRequest(id=0x6666, seq=0x7777, data="somedata") 2064*7dc08ffcSJunyu Lai(a > b) == True 2065*7dc08ffcSJunyu Lai 2066*7dc08ffcSJunyu Lai= ICMPv6EchoRequest and ICMPv6EchoReply - live answers() use Net6 2067*7dc08ffcSJunyu Lai~ netaccess ipv6 2068*7dc08ffcSJunyu Lai 2069*7dc08ffcSJunyu Laia = IPv6(dst="www.google.com")/ICMPv6EchoRequest() 2070*7dc08ffcSJunyu Laib = IPv6(src="www.google.com", dst=a.src)/ICMPv6EchoReply() 2071*7dc08ffcSJunyu Laiassert b.answers(a) 2072*7dc08ffcSJunyu Laiassert (a > b) 2073*7dc08ffcSJunyu Lai 2074*7dc08ffcSJunyu Lai 2075*7dc08ffcSJunyu Lai########### ICMPv6MRD* Classes ###################################### 2076*7dc08ffcSJunyu Lai 2077*7dc08ffcSJunyu Lai= ICMPv6MRD_Advertisement - Basic instantiation 2078*7dc08ffcSJunyu Lairaw(ICMPv6MRD_Advertisement()) == b'\x97\x14\x00\x00\x00\x00\x00\x00' 2079*7dc08ffcSJunyu Lai 2080*7dc08ffcSJunyu Lai= ICMPv6MRD_Advertisement - Instantiation with specific values 2081*7dc08ffcSJunyu Lairaw(ICMPv6MRD_Advertisement(advinter=0xdd, queryint=0xeeee, robustness=0xffff)) == b'\x97\xdd\x00\x00\xee\xee\xff\xff' 2082*7dc08ffcSJunyu Lai 2083*7dc08ffcSJunyu Lai= ICMPv6MRD_Advertisement - Basic Dissection and overloading mechanisms 2084*7dc08ffcSJunyu Laia=Ether(raw(Ether()/IPv6()/ICMPv6MRD_Advertisement())) 2085*7dc08ffcSJunyu Laia.dst == "33:33:00:00:00:02" and IPv6 in a and a[IPv6].plen == 8 and a[IPv6].nh == 58 and a[IPv6].hlim == 1 and a[IPv6].dst == "ff02::2" and ICMPv6MRD_Advertisement in a and a[ICMPv6MRD_Advertisement].type == 151 and a[ICMPv6MRD_Advertisement].advinter == 20 and a[ICMPv6MRD_Advertisement].queryint == 0 and a[ICMPv6MRD_Advertisement].robustness == 0 2086*7dc08ffcSJunyu Lai 2087*7dc08ffcSJunyu Lai 2088*7dc08ffcSJunyu Lai= ICMPv6MRD_Solicitation - Basic dissection 2089*7dc08ffcSJunyu Lairaw(ICMPv6MRD_Solicitation()) == b'\x98\x00\x00\x00' 2090*7dc08ffcSJunyu Lai 2091*7dc08ffcSJunyu Lai= ICMPv6MRD_Solicitation - Instantiation with specific values 2092*7dc08ffcSJunyu Lairaw(ICMPv6MRD_Solicitation(res=0xbb)) == b'\x98\xbb\x00\x00' 2093*7dc08ffcSJunyu Lai 2094*7dc08ffcSJunyu Lai= ICMPv6MRD_Solicitation - Basic Dissection and overloading mechanisms 2095*7dc08ffcSJunyu Laia=Ether(raw(Ether()/IPv6()/ICMPv6MRD_Solicitation())) 2096*7dc08ffcSJunyu Laia.dst == "33:33:00:00:00:02" and IPv6 in a and a[IPv6].plen == 4 and a[IPv6].nh == 58 and a[IPv6].hlim == 1 and a[IPv6].dst == "ff02::2" and ICMPv6MRD_Solicitation in a and a[ICMPv6MRD_Solicitation].type == 152 and a[ICMPv6MRD_Solicitation].res == 0 2097*7dc08ffcSJunyu Lai 2098*7dc08ffcSJunyu Lai 2099*7dc08ffcSJunyu Lai= ICMPv6MRD_Termination Basic instantiation 2100*7dc08ffcSJunyu Lairaw(ICMPv6MRD_Termination()) == b'\x99\x00\x00\x00' 2101*7dc08ffcSJunyu Lai 2102*7dc08ffcSJunyu Lai= ICMPv6MRD_Termination - Instantiation with specific values 2103*7dc08ffcSJunyu Lairaw(ICMPv6MRD_Termination(res=0xbb)) == b'\x99\xbb\x00\x00' 2104*7dc08ffcSJunyu Lai 2105*7dc08ffcSJunyu Lai= ICMPv6MRD_Termination - Basic Dissection and overloading mechanisms 2106*7dc08ffcSJunyu Laia=Ether(raw(Ether()/IPv6()/ICMPv6MRD_Termination())) 2107*7dc08ffcSJunyu Laia.dst == "33:33:00:00:00:6a" and IPv6 in a and a[IPv6].plen == 4 and a[IPv6].nh == 58 and a[IPv6].hlim == 1 and a[IPv6].dst == "ff02::6a" and ICMPv6MRD_Termination in a and a[ICMPv6MRD_Termination].type == 153 and a[ICMPv6MRD_Termination].res == 0 2108*7dc08ffcSJunyu Lai 2109*7dc08ffcSJunyu Lai 2110*7dc08ffcSJunyu Lai############ 2111*7dc08ffcSJunyu Lai############ 2112*7dc08ffcSJunyu Lai+ Test HBHOptUnknown Class 2113*7dc08ffcSJunyu Lai 2114*7dc08ffcSJunyu Lai= HBHOptUnknown - Basic Instantiation 2115*7dc08ffcSJunyu Lairaw(HBHOptUnknown()) == b'\x01\x00' 2116*7dc08ffcSJunyu Lai 2117*7dc08ffcSJunyu Lai= HBHOptUnknown - Basic Dissection 2118*7dc08ffcSJunyu Laia=HBHOptUnknown(b'\x01\x00') 2119*7dc08ffcSJunyu Laia.otype == 0x01 and a.optlen == 0 and a.optdata == b"" 2120*7dc08ffcSJunyu Lai 2121*7dc08ffcSJunyu Lai= HBHOptUnknown - Automatic optlen computation 2122*7dc08ffcSJunyu Lairaw(HBHOptUnknown(optdata="B"*10)) == b'\x01\nBBBBBBBBBB' 2123*7dc08ffcSJunyu Lai 2124*7dc08ffcSJunyu Lai= HBHOptUnknown - Instantiation with specific values 2125*7dc08ffcSJunyu Lairaw(HBHOptUnknown(optlen=9, optdata="B"*10)) == b'\x01\tBBBBBBBBBB' 2126*7dc08ffcSJunyu Lai 2127*7dc08ffcSJunyu Lai= HBHOptUnknown - Dissection with specific values 2128*7dc08ffcSJunyu Laia=HBHOptUnknown(b'\x01\tBBBBBBBBBB') 2129*7dc08ffcSJunyu Laia.otype == 0x01 and a.optlen == 9 and a.optdata == b"B"*9 and isinstance(a.payload, Raw) and a.payload.load == b"B" 2130*7dc08ffcSJunyu Lai 2131*7dc08ffcSJunyu Lai 2132*7dc08ffcSJunyu Lai############ 2133*7dc08ffcSJunyu Lai############ 2134*7dc08ffcSJunyu Lai+ Test Pad1 Class 2135*7dc08ffcSJunyu Lai 2136*7dc08ffcSJunyu Lai= Pad1 - Basic Instantiation 2137*7dc08ffcSJunyu Lairaw(Pad1()) == b'\x00' 2138*7dc08ffcSJunyu Lai 2139*7dc08ffcSJunyu Lai= Pad1 - Basic Dissection 2140*7dc08ffcSJunyu Lairaw(Pad1(b'\x00')) == b'\x00' 2141*7dc08ffcSJunyu Lai 2142*7dc08ffcSJunyu Lai 2143*7dc08ffcSJunyu Lai############ 2144*7dc08ffcSJunyu Lai############ 2145*7dc08ffcSJunyu Lai+ Test PadN Class 2146*7dc08ffcSJunyu Lai 2147*7dc08ffcSJunyu Lai= PadN - Basic Instantiation 2148*7dc08ffcSJunyu Lairaw(PadN()) == b'\x01\x00' 2149*7dc08ffcSJunyu Lai 2150*7dc08ffcSJunyu Lai= PadN - Optlen Automatic computation 2151*7dc08ffcSJunyu Lairaw(PadN(optdata="B"*10)) == b'\x01\nBBBBBBBBBB' 2152*7dc08ffcSJunyu Lai 2153*7dc08ffcSJunyu Lai= PadN - Basic Dissection 2154*7dc08ffcSJunyu Laia=PadN(b'\x01\x00') 2155*7dc08ffcSJunyu Laia.otype == 1 and a.optlen == 0 and a.optdata == b"" 2156*7dc08ffcSJunyu Lai 2157*7dc08ffcSJunyu Lai= PadN - Dissection with specific values 2158*7dc08ffcSJunyu Laia=PadN(b'\x01\x0cBBBBBBBBBB') 2159*7dc08ffcSJunyu Laia.otype == 1 and a.optlen == 12 and a.optdata == b'BBBBBBBBBB' 2160*7dc08ffcSJunyu Lai 2161*7dc08ffcSJunyu Lai= PadN - Instantiation with forced optlen 2162*7dc08ffcSJunyu Lairaw(PadN(optdata="B"*10, optlen=9)) == b'\x01\x09BBBBBBBBBB' 2163*7dc08ffcSJunyu Lai 2164*7dc08ffcSJunyu Lai 2165*7dc08ffcSJunyu Lai############ 2166*7dc08ffcSJunyu Lai############ 2167*7dc08ffcSJunyu Lai+ Test RouterAlert Class (RFC 2711) 2168*7dc08ffcSJunyu Lai 2169*7dc08ffcSJunyu Lai= RouterAlert - Basic Instantiation 2170*7dc08ffcSJunyu Lairaw(RouterAlert()) == b'\x05\x02\x00\x00' 2171*7dc08ffcSJunyu Lai 2172*7dc08ffcSJunyu Lai= RouterAlert - Basic Dissection 2173*7dc08ffcSJunyu Laia=RouterAlert(b'\x05\x02\x00\x00') 2174*7dc08ffcSJunyu Laia.otype == 0x05 and a.optlen == 2 and a.value == 00 2175*7dc08ffcSJunyu Lai 2176*7dc08ffcSJunyu Lai= RouterAlert - Instantiation with specific values 2177*7dc08ffcSJunyu Lairaw(RouterAlert(optlen=3, value=0xffff)) == b'\x05\x03\xff\xff' 2178*7dc08ffcSJunyu Lai 2179*7dc08ffcSJunyu Lai= RouterAlert - Instantiation with specific values 2180*7dc08ffcSJunyu Laia=RouterAlert(b'\x05\x03\xff\xff') 2181*7dc08ffcSJunyu Laia.otype == 0x05 and a.optlen == 3 and a.value == 0xffff 2182*7dc08ffcSJunyu Lai 2183*7dc08ffcSJunyu Lai 2184*7dc08ffcSJunyu Lai############ 2185*7dc08ffcSJunyu Lai############ 2186*7dc08ffcSJunyu Lai+ Test Jumbo Class (RFC 2675) 2187*7dc08ffcSJunyu Lai 2188*7dc08ffcSJunyu Lai= Jumbo - Basic Instantiation 2189*7dc08ffcSJunyu Lairaw(Jumbo()) == b'\xc2\x04\x00\x00\x00\x00' 2190*7dc08ffcSJunyu Lai 2191*7dc08ffcSJunyu Lai= Jumbo - Basic Dissection 2192*7dc08ffcSJunyu Laia=Jumbo(b'\xc2\x04\x00\x00\x00\x00') 2193*7dc08ffcSJunyu Laia.otype == 0xC2 and a.optlen == 4 and a.jumboplen == 0 2194*7dc08ffcSJunyu Lai 2195*7dc08ffcSJunyu Lai= Jumbo - Instantiation with specific values 2196*7dc08ffcSJunyu Lairaw(Jumbo(optlen=6, jumboplen=0xffffffff)) == b'\xc2\x06\xff\xff\xff\xff' 2197*7dc08ffcSJunyu Lai 2198*7dc08ffcSJunyu Lai= Jumbo - Dissection with specific values 2199*7dc08ffcSJunyu Laia=Jumbo(b'\xc2\x06\xff\xff\xff\xff') 2200*7dc08ffcSJunyu Laia.otype == 0xc2 and a.optlen == 6 and a.jumboplen == 0xffffffff 2201*7dc08ffcSJunyu Lai 2202*7dc08ffcSJunyu Lai 2203*7dc08ffcSJunyu Lai############ 2204*7dc08ffcSJunyu Lai############ 2205*7dc08ffcSJunyu Lai+ Test HAO Class (RFC 3775) 2206*7dc08ffcSJunyu Lai 2207*7dc08ffcSJunyu Lai= HAO - Basic Instantiation 2208*7dc08ffcSJunyu Lairaw(HAO()) == b'\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2209*7dc08ffcSJunyu Lai 2210*7dc08ffcSJunyu Lai= HAO - Basic Dissection 2211*7dc08ffcSJunyu Laia=HAO(b'\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2212*7dc08ffcSJunyu Laia.otype == 0xC9 and a.optlen == 16 and a.hoa == "::" 2213*7dc08ffcSJunyu Lai 2214*7dc08ffcSJunyu Lai= HAO - Instantiation with specific values 2215*7dc08ffcSJunyu Lairaw(HAO(optlen=9, hoa="2001::ffff")) == b'\xc9\t \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff' 2216*7dc08ffcSJunyu Lai 2217*7dc08ffcSJunyu Lai= HAO - Dissection with specific values 2218*7dc08ffcSJunyu Laia=HAO(b'\xc9\t \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff') 2219*7dc08ffcSJunyu Laia.otype == 0xC9 and a.optlen == 9 and a.hoa == "2001::ffff" 2220*7dc08ffcSJunyu Lai 2221*7dc08ffcSJunyu Lai= HAO - hashret 2222*7dc08ffcSJunyu Lai 2223*7dc08ffcSJunyu Laip = IPv6()/IPv6ExtHdrDestOpt(options=HAO(hoa="2001:db8::1"))/ICMPv6EchoRequest() 2224*7dc08ffcSJunyu Laip.hashret() == b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:\x00\x00\x00\x00" 2225*7dc08ffcSJunyu Lai 2226*7dc08ffcSJunyu Lai 2227*7dc08ffcSJunyu Lai############ 2228*7dc08ffcSJunyu Lai############ 2229*7dc08ffcSJunyu Lai+ Test IPv6ExtHdrHopByHop() 2230*7dc08ffcSJunyu Lai 2231*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Basic Instantiation 2232*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop()) == b';\x00\x01\x04\x00\x00\x00\x00' 2233*7dc08ffcSJunyu Lai 2234*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with HAO option 2235*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[HAO()])) == b';\x02\x01\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2236*7dc08ffcSJunyu Lai 2237*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with RouterAlert option 2238*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[RouterAlert()])) == b';\x00\x05\x02\x00\x00\x01\x00' 2239*7dc08ffcSJunyu Lai 2240*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with Jumbo option 2241*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[Jumbo()])) == b';\x00\xc2\x04\x00\x00\x00\x00' 2242*7dc08ffcSJunyu Lai 2243*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with Pad1 option 2244*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[Pad1()])) == b';\x00\x00\x01\x03\x00\x00\x00' 2245*7dc08ffcSJunyu Lai 2246*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with PadN option 2247*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[Pad1()])) == b';\x00\x00\x01\x03\x00\x00\x00' 2248*7dc08ffcSJunyu Lai 2249*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with Jumbo, RouterAlert, HAO 2250*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[Jumbo(), RouterAlert(), HAO()])) == b';\x03\xc2\x04\x00\x00\x00\x00\x05\x02\x00\x00\x01\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2251*7dc08ffcSJunyu Lai 2252*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with HAO, Jumbo, RouterAlert 2253*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[HAO(), Jumbo(), RouterAlert()])) == b';\x04\x01\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\xc2\x04\x00\x00\x00\x00\x05\x02\x00\x00\x01\x02\x00\x00' 2254*7dc08ffcSJunyu Lai 2255*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Instantiation with RouterAlert, HAO, Jumbo 2256*7dc08ffcSJunyu Lairaw(IPv6ExtHdrHopByHop(options=[RouterAlert(), HAO(), Jumbo()])) == b';\x03\x05\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\xc2\x04\x00\x00\x00\x00' 2257*7dc08ffcSJunyu Lai 2258*7dc08ffcSJunyu Lai= IPv6ExtHdrHopByHop - Basic Dissection 2259*7dc08ffcSJunyu Laia=IPv6ExtHdrHopByHop(b';\x00\x01\x04\x00\x00\x00\x00') 2260*7dc08ffcSJunyu Laia.nh == 59 and a.len == 0 and len(a.options) == 1 and isinstance(a.options[0], PadN) and a.options[0].otype == 1 and a.options[0].optlen == 4 and a.options[0].optdata == b'\x00'*4 2261*7dc08ffcSJunyu Lai 2262*7dc08ffcSJunyu Lai#= IPv6ExtHdrHopByHop - Automatic length computation 2263*7dc08ffcSJunyu Lai#raw(IPv6ExtHdrHopByHop(options=["toto"])) == b'\x00\x00toto' 2264*7dc08ffcSJunyu Lai#= IPv6ExtHdrHopByHop - Automatic length computation 2265*7dc08ffcSJunyu Lai#raw(IPv6ExtHdrHopByHop(options=["toto"])) == b'\x00\x00tototo' 2266*7dc08ffcSJunyu Lai 2267*7dc08ffcSJunyu Lai 2268*7dc08ffcSJunyu Lai############ 2269*7dc08ffcSJunyu Lai############ 2270*7dc08ffcSJunyu Lai+ Test ICMPv6ND_RS() class - ICMPv6 Type 133 Code 0 2271*7dc08ffcSJunyu Lai 2272*7dc08ffcSJunyu Lai= ICMPv6ND_RS - Basic instantiation 2273*7dc08ffcSJunyu Lairaw(ICMPv6ND_RS()) == b'\x85\x00\x00\x00\x00\x00\x00\x00' 2274*7dc08ffcSJunyu Lai 2275*7dc08ffcSJunyu Lai= ICMPv6ND_RS - Basic instantiation with empty dst in IPv6 underlayer 2276*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1")/ICMPv6ND_RS()) == b'`\x00\x00\x00\x00\x08:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x85\x00M\xfe\x00\x00\x00\x00' 2277*7dc08ffcSJunyu Lai 2278*7dc08ffcSJunyu Lai= ICMPv6ND_RS - Basic dissection 2279*7dc08ffcSJunyu Laia=ICMPv6ND_RS(b'\x85\x00\x00\x00\x00\x00\x00\x00') 2280*7dc08ffcSJunyu Laia.type == 133 and a.code == 0 and a.cksum == 0 and a.res == 0 2281*7dc08ffcSJunyu Lai 2282*7dc08ffcSJunyu Lai= ICMPv6ND_RS - Basic instantiation with empty dst in IPv6 underlayer 2283*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x08:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x85\x00M\xfe\x00\x00\x00\x00') 2284*7dc08ffcSJunyu Laiisinstance(a, IPv6) and a.nh == 58 and a.hlim == 255 and isinstance(a.payload, ICMPv6ND_RS) and a.payload.type == 133 and a.payload.code == 0 and a.payload.cksum == 0x4dfe and a.payload.res == 0 2285*7dc08ffcSJunyu Lai 2286*7dc08ffcSJunyu Lai 2287*7dc08ffcSJunyu Lai############ 2288*7dc08ffcSJunyu Lai############ 2289*7dc08ffcSJunyu Lai+ Test ICMPv6ND_RA() class - ICMPv6 Type 134 Code 0 2290*7dc08ffcSJunyu Lai 2291*7dc08ffcSJunyu Lai= ICMPv6ND_RA - Basic Instantiation 2292*7dc08ffcSJunyu Lairaw(ICMPv6ND_RA()) == b'\x86\x00\x00\x00\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00' 2293*7dc08ffcSJunyu Lai 2294*7dc08ffcSJunyu Lai= ICMPv6ND_RA - Basic instantiation with empty dst in IPv6 underlayer 2295*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1")/ICMPv6ND_RA()) == b'`\x00\x00\x00\x00\x10:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x86\x00E\xe7\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00' 2296*7dc08ffcSJunyu Lai 2297*7dc08ffcSJunyu Lai= ICMPv6ND_RA - Basic dissection 2298*7dc08ffcSJunyu Laia=ICMPv6ND_RA(b'\x86\x00\x00\x00\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00') 2299*7dc08ffcSJunyu Laia.type == 134 and a.code == 0 and a.cksum == 0 and a.chlim == 0 and a.M == 0 and a.O == 0 and a.H == 0 and a.prf == 1 and a.res == 0 and a.routerlifetime == 1800 and a.reachabletime == 0 and a.retranstimer == 0 2300*7dc08ffcSJunyu Lai 2301*7dc08ffcSJunyu Lai= ICMPv6ND_RA - Basic instantiation with empty dst in IPv6 underlayer 2302*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x10:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x86\x00E\xe7\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00') 2303*7dc08ffcSJunyu Laiisinstance(a, IPv6) and a.nh == 58 and a.hlim == 255 and isinstance(a.payload, ICMPv6ND_RA) and a.payload.type == 134 and a.code == 0 and a.cksum == 0x45e7 and a.chlim == 0 and a.M == 0 and a.O == 0 and a.H == 0 and a.prf == 1 and a.res == 0 and a.routerlifetime == 1800 and a.reachabletime == 0 and a.retranstimer == 0 2304*7dc08ffcSJunyu Lai 2305*7dc08ffcSJunyu Lai= ICMPv6ND_RA - Answers 2306*7dc08ffcSJunyu Laiassert ICMPv6ND_RA().answers(ICMPv6ND_RS()) 2307*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x10:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x86\x00E\xe7\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00') 2308*7dc08ffcSJunyu Laib = IPv6(b"`\x00\x00\x00\x00\x10:\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x85\x00M\xff\x00\x00\x00\x00") 2309*7dc08ffcSJunyu Laiassert a.answers(b) 2310*7dc08ffcSJunyu Lai 2311*7dc08ffcSJunyu Lai############ 2312*7dc08ffcSJunyu Lai############ 2313*7dc08ffcSJunyu Lai+ ICMPv6ND_NS Class Test 2314*7dc08ffcSJunyu Lai 2315*7dc08ffcSJunyu Lai= ICMPv6ND_NS - Basic Instantiation 2316*7dc08ffcSJunyu Lairaw(ICMPv6ND_NS()) == b'\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2317*7dc08ffcSJunyu Lai 2318*7dc08ffcSJunyu Lai= ICMPv6ND_NS - Instantiation with specific values 2319*7dc08ffcSJunyu Lairaw(ICMPv6ND_NS(code=0x11, res=3758096385, tgt="ffff::1111")) == b'\x87\x11\x00\x00\xe0\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2320*7dc08ffcSJunyu Lai 2321*7dc08ffcSJunyu Lai= ICMPv6ND_NS - Basic Dissection 2322*7dc08ffcSJunyu Laia=ICMPv6ND_NS(b'\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2323*7dc08ffcSJunyu Laia.code==0 and a.res==0 and a.tgt=="::" 2324*7dc08ffcSJunyu Lai 2325*7dc08ffcSJunyu Lai= ICMPv6ND_NS - Dissection with specific values 2326*7dc08ffcSJunyu Laia=ICMPv6ND_NS(b'\x87\x11\x00\x00\xe0\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2327*7dc08ffcSJunyu Laia.code==0x11 and a.res==3758096385 and a.tgt=="ffff::1111" 2328*7dc08ffcSJunyu Lai 2329*7dc08ffcSJunyu Lai= ICMPv6ND_NS - IPv6 layer fields overloading 2330*7dc08ffcSJunyu Laia=IPv6(raw(IPv6()/ICMPv6ND_NS())) 2331*7dc08ffcSJunyu Laia.nh == 58 and a.dst=="ff02::1" and a.hlim==255 2332*7dc08ffcSJunyu Lai 2333*7dc08ffcSJunyu Lai############ 2334*7dc08ffcSJunyu Lai############ 2335*7dc08ffcSJunyu Lai+ ICMPv6ND_NA Class Test 2336*7dc08ffcSJunyu Lai 2337*7dc08ffcSJunyu Lai= ICMPv6ND_NA - Basic Instantiation 2338*7dc08ffcSJunyu Lairaw(ICMPv6ND_NA()) == b'\x88\x00\x00\x00\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2339*7dc08ffcSJunyu Lai 2340*7dc08ffcSJunyu Lai= ICMPv6ND_NA - Instantiation with specific values 2341*7dc08ffcSJunyu Lairaw(ICMPv6ND_NA(code=0x11, R=0, S=1, O=0, res=1, tgt="ffff::1111")) == b'\x88\x11\x00\x00@\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2342*7dc08ffcSJunyu Lai 2343*7dc08ffcSJunyu Lai= ICMPv6ND_NA - Basic Dissection 2344*7dc08ffcSJunyu Laia=ICMPv6ND_NA(b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2345*7dc08ffcSJunyu Laia.code==0 and a.R==0 and a.S==0 and a.O==0 and a.res==0 and a.tgt=="::" 2346*7dc08ffcSJunyu Lai 2347*7dc08ffcSJunyu Lai= ICMPv6ND_NA - Dissection with specific values 2348*7dc08ffcSJunyu Laia=ICMPv6ND_NA(b'\x88\x11\x00\x00@\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2349*7dc08ffcSJunyu Laia.code==0x11 and a.R==0 and a.S==1 and a.O==0 and a.res==1 and a.tgt=="ffff::1111" 2350*7dc08ffcSJunyu Laiassert a.hashret() == b'ffff::1111' 2351*7dc08ffcSJunyu Lai 2352*7dc08ffcSJunyu Lai= ICMPv6ND_NS - IPv6 layer fields overloading 2353*7dc08ffcSJunyu Laia=IPv6(raw(IPv6()/ICMPv6ND_NS())) 2354*7dc08ffcSJunyu Laia.nh == 58 and a.dst=="ff02::1" and a.hlim==255 2355*7dc08ffcSJunyu Lai 2356*7dc08ffcSJunyu Lai 2357*7dc08ffcSJunyu Lai############ 2358*7dc08ffcSJunyu Lai############ 2359*7dc08ffcSJunyu Lai+ ICMPv6ND_ND/ICMPv6ND_ND matching test 2360*7dc08ffcSJunyu Lai 2361*7dc08ffcSJunyu Lai= ICMPv6ND_ND/ICMPv6ND_ND matching - test 1 2362*7dc08ffcSJunyu Lai# Sent NS 2363*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x18:\xff\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f\x1f\xff\xfe\xcaFP\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87\x00UC\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f4\xff\xfe\x8a\x8a\xa1') 2364*7dc08ffcSJunyu Lai# Received NA 2365*7dc08ffcSJunyu Laib=IPv6(b'n\x00\x00\x00\x00 :\xff\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f4\xff\xfe\x8a\x8a\xa1\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f\x1f\xff\xfe\xcaFP\x88\x00\xf3F\xe0\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f4\xff\xfe\x8a\x8a\xa1\x02\x01\x00\x0f4\x8a\x8a\xa1') 2366*7dc08ffcSJunyu Laib.answers(a) 2367*7dc08ffcSJunyu Lai 2368*7dc08ffcSJunyu Lai 2369*7dc08ffcSJunyu Lai############ 2370*7dc08ffcSJunyu Lai############ 2371*7dc08ffcSJunyu Lai+ ICMPv6NDOptUnknown Class Test 2372*7dc08ffcSJunyu Lai 2373*7dc08ffcSJunyu Lai= ICMPv6NDOptUnknown - Basic Instantiation 2374*7dc08ffcSJunyu Lairaw(ICMPv6NDOptUnknown()) == b'\x00\x02' 2375*7dc08ffcSJunyu Lai 2376*7dc08ffcSJunyu Lai= ICMPv6NDOptUnknown - Instantiation with specific values 2377*7dc08ffcSJunyu Lairaw(ICMPv6NDOptUnknown(len=4, data="somestring")) == b'\x00\x04somestring' 2378*7dc08ffcSJunyu Lai 2379*7dc08ffcSJunyu Lai= ICMPv6NDOptUnknown - Basic Dissection 2380*7dc08ffcSJunyu Laia=ICMPv6NDOptUnknown(b'\x00\x02') 2381*7dc08ffcSJunyu Laia.type == 0 and a.len == 2 2382*7dc08ffcSJunyu Lai 2383*7dc08ffcSJunyu Lai= ICMPv6NDOptUnknown - Dissection with specific values 2384*7dc08ffcSJunyu Laia=ICMPv6NDOptUnknown(b'\x00\x04somerawing') 2385*7dc08ffcSJunyu Laia.type == 0 and a.len==4 and a.data == b"so" and isinstance(a.payload, Raw) and a.payload.load == b"merawing" 2386*7dc08ffcSJunyu Lai 2387*7dc08ffcSJunyu Lai 2388*7dc08ffcSJunyu Lai############ 2389*7dc08ffcSJunyu Lai############ 2390*7dc08ffcSJunyu Lai+ ICMPv6NDOptSrcLLAddr Class Test 2391*7dc08ffcSJunyu Lai 2392*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcLLAddr - Basic Instantiation 2393*7dc08ffcSJunyu Lairaw(ICMPv6NDOptSrcLLAddr()) == b'\x01\x01\x00\x00\x00\x00\x00\x00' 2394*7dc08ffcSJunyu Lai 2395*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcLLAddr - Instantiation with specific values 2396*7dc08ffcSJunyu Lairaw(ICMPv6NDOptSrcLLAddr(len=2, lladdr="11:11:11:11:11:11")) == b'\x01\x02\x11\x11\x11\x11\x11\x11' 2397*7dc08ffcSJunyu Lai 2398*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcLLAddr - Basic Dissection 2399*7dc08ffcSJunyu Laia=ICMPv6NDOptSrcLLAddr(b'\x01\x01\x00\x00\x00\x00\x00\x00') 2400*7dc08ffcSJunyu Laia.type == 1 and a.len == 1 and a.lladdr == "00:00:00:00:00:00" 2401*7dc08ffcSJunyu Lai 2402*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcLLAddr - Instantiation with specific values 2403*7dc08ffcSJunyu Laia=ICMPv6NDOptSrcLLAddr(b'\x01\x02\x11\x11\x11\x11\x11\x11') 2404*7dc08ffcSJunyu Laia.type == 1 and a.len == 2 and a.lladdr == "11:11:11:11:11:11" 2405*7dc08ffcSJunyu Lai 2406*7dc08ffcSJunyu Lai 2407*7dc08ffcSJunyu Lai############ 2408*7dc08ffcSJunyu Lai############ 2409*7dc08ffcSJunyu Lai+ ICMPv6NDOptDstLLAddr Class Test 2410*7dc08ffcSJunyu Lai 2411*7dc08ffcSJunyu Lai= ICMPv6NDOptDstLLAddr - Basic Instantiation 2412*7dc08ffcSJunyu Lairaw(ICMPv6NDOptDstLLAddr()) == b'\x02\x01\x00\x00\x00\x00\x00\x00' 2413*7dc08ffcSJunyu Lai 2414*7dc08ffcSJunyu Lai= ICMPv6NDOptDstLLAddr - Instantiation with specific values 2415*7dc08ffcSJunyu Lairaw(ICMPv6NDOptDstLLAddr(len=2, lladdr="11:11:11:11:11:11")) == b'\x02\x02\x11\x11\x11\x11\x11\x11' 2416*7dc08ffcSJunyu Lai 2417*7dc08ffcSJunyu Lai= ICMPv6NDOptDstLLAddr - Basic Dissection 2418*7dc08ffcSJunyu Laia=ICMPv6NDOptDstLLAddr(b'\x02\x01\x00\x00\x00\x00\x00\x00') 2419*7dc08ffcSJunyu Laia.type == 2 and a.len == 1 and a.lladdr == "00:00:00:00:00:00" 2420*7dc08ffcSJunyu Lai 2421*7dc08ffcSJunyu Lai= ICMPv6NDOptDstLLAddr - Instantiation with specific values 2422*7dc08ffcSJunyu Laia=ICMPv6NDOptDstLLAddr(b'\x02\x02\x11\x11\x11\x11\x11\x11') 2423*7dc08ffcSJunyu Laia.type == 2 and a.len == 2 and a.lladdr == "11:11:11:11:11:11" 2424*7dc08ffcSJunyu Lai 2425*7dc08ffcSJunyu Lai 2426*7dc08ffcSJunyu Lai############ 2427*7dc08ffcSJunyu Lai############ 2428*7dc08ffcSJunyu Lai+ ICMPv6NDOptPrefixInfo Class Test 2429*7dc08ffcSJunyu Lai 2430*7dc08ffcSJunyu Lai= ICMPv6NDOptPrefixInfo - Basic Instantiation 2431*7dc08ffcSJunyu Lairaw(ICMPv6NDOptPrefixInfo()) == b'\x03\x04\x00\xc0\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2432*7dc08ffcSJunyu Lai 2433*7dc08ffcSJunyu Lai= ICMPv6NDOptPrefixInfo - Instantiation with specific values 2434*7dc08ffcSJunyu Lairaw(ICMPv6NDOptPrefixInfo(len=5, prefixlen=64, L=0, A=0, R=1, res1=1, validlifetime=0x11111111, preferredlifetime=0x22222222, res2=0x33333333, prefix="2001:db8::1")) == b'\x03\x05@!\x11\x11\x11\x11""""3333 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 2435*7dc08ffcSJunyu Lai 2436*7dc08ffcSJunyu Lai= ICMPv6NDOptPrefixInfo - Basic Dissection 2437*7dc08ffcSJunyu Laia=ICMPv6NDOptPrefixInfo(b'\x03\x04\x00\xc0\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2438*7dc08ffcSJunyu Laia.type == 3 and a.len == 4 and a.prefixlen == 0 and a.L == 1 and a.A == 1 and a.R == 0 and a.res1 == 0 and a.validlifetime == 0xffffffff and a.preferredlifetime == 0xffffffff and a.res2 == 0 and a.prefix == "::" 2439*7dc08ffcSJunyu Lai 2440*7dc08ffcSJunyu Lai= ICMPv6NDOptPrefixInfo - Instantiation with specific values 2441*7dc08ffcSJunyu Laia=ICMPv6NDOptPrefixInfo(b'\x03\x05@!\x11\x11\x11\x11""""3333 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 2442*7dc08ffcSJunyu Laia.type == 3 and a.len == 5 and a.prefixlen == 64 and a.L == 0 and a.A == 0 and a.R == 1 and a.res1 == 1 and a.validlifetime == 0x11111111 and a.preferredlifetime == 0x22222222 and a.res2 == 0x33333333 and a.prefix == "2001:db8::1" 2443*7dc08ffcSJunyu Lai 2444*7dc08ffcSJunyu Lai 2445*7dc08ffcSJunyu Lai############ 2446*7dc08ffcSJunyu Lai############ 2447*7dc08ffcSJunyu Lai+ ICMPv6NDOptRedirectedHdr Class Test 2448*7dc08ffcSJunyu Lai 2449*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Basic Instantiation 2450*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2451*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRedirectedHdr()) == b'\x04\x01\x00\x00\x00\x00\x00\x00' 2452*7dc08ffcSJunyu Lai 2453*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Instantiation with specific values 2454*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2455*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRedirectedHdr(len=0xff, res="abcdef", pkt="somestringthatisnotanipv6packet")) == b'\x04\xffabcdefsomestringthatisnotanipv' 2456*7dc08ffcSJunyu Lai 2457*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Instantiation with simple IPv6 packet (no upper layer) 2458*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2459*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRedirectedHdr(pkt=IPv6())) == b'\x04\x06\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 2460*7dc08ffcSJunyu Lai 2461*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Basic Dissection 2462*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2463*7dc08ffcSJunyu Laia=ICMPv6NDOptRedirectedHdr(b'\x04\x00\x00\x00') 2464*7dc08ffcSJunyu Laiassert(a.type == 4) 2465*7dc08ffcSJunyu Laiassert(a.len == 0) 2466*7dc08ffcSJunyu Laiassert(a.res == b"\x00\x00") 2467*7dc08ffcSJunyu Laiassert(a.pkt == b"") 2468*7dc08ffcSJunyu Lai 2469*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Disssection with specific values 2470*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2471*7dc08ffcSJunyu Laia=ICMPv6NDOptRedirectedHdr(b'\x04\xff\x11\x11\x00\x00\x00\x00somerawingthatisnotanipv6pac') 2472*7dc08ffcSJunyu Laia.type == 4 and a.len == 255 and a.res == b'\x11\x11\x00\x00\x00\x00' and isinstance(a.pkt, Raw) and a.pkt.load == b"somerawingthatisnotanipv6pac" 2473*7dc08ffcSJunyu Lai 2474*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Dissection with cut IPv6 Header 2475*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2476*7dc08ffcSJunyu Laia=ICMPv6NDOptRedirectedHdr(b'\x04\x06\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2477*7dc08ffcSJunyu Laia.type == 4 and a.len == 6 and a.res == b"\x00\x00\x00\x00\x00\x00" and isinstance(a.pkt, Raw) and a.pkt.load == b'`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2478*7dc08ffcSJunyu Lai 2479*7dc08ffcSJunyu Lai= ICMPv6NDOptRedirectedHdr - Complete dissection 2480*7dc08ffcSJunyu Lai~ ICMPv6NDOptRedirectedHdr 2481*7dc08ffcSJunyu Laix=ICMPv6NDOptRedirectedHdr(b'\x04\x06\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 2482*7dc08ffcSJunyu Laiy=x.copy() 2483*7dc08ffcSJunyu Laidel(y.len) 2484*7dc08ffcSJunyu Laix == ICMPv6NDOptRedirectedHdr(raw(y)) 2485*7dc08ffcSJunyu Lai 2486*7dc08ffcSJunyu Lai# Add more tests 2487*7dc08ffcSJunyu Lai 2488*7dc08ffcSJunyu Lai 2489*7dc08ffcSJunyu Lai############ 2490*7dc08ffcSJunyu Lai############ 2491*7dc08ffcSJunyu Lai+ ICMPv6NDOptMTU Class Test 2492*7dc08ffcSJunyu Lai 2493*7dc08ffcSJunyu Lai= ICMPv6NDOptMTU - Basic Instantiation 2494*7dc08ffcSJunyu Lairaw(ICMPv6NDOptMTU()) == b'\x05\x01\x00\x00\x00\x00\x05\x00' 2495*7dc08ffcSJunyu Lai 2496*7dc08ffcSJunyu Lai= ICMPv6NDOptMTU - Instantiation with specific values 2497*7dc08ffcSJunyu Lairaw(ICMPv6NDOptMTU(len=2, res=0x1111, mtu=1500)) == b'\x05\x02\x11\x11\x00\x00\x05\xdc' 2498*7dc08ffcSJunyu Lai 2499*7dc08ffcSJunyu Lai= ICMPv6NDOptMTU - Basic dissection 2500*7dc08ffcSJunyu Laia=ICMPv6NDOptMTU(b'\x05\x01\x00\x00\x00\x00\x05\x00') 2501*7dc08ffcSJunyu Laia.type == 5 and a.len == 1 and a.res == 0 and a.mtu == 1280 2502*7dc08ffcSJunyu Lai 2503*7dc08ffcSJunyu Lai= ICMPv6NDOptMTU - Dissection with specific values 2504*7dc08ffcSJunyu Laia=ICMPv6NDOptMTU(b'\x05\x02\x11\x11\x00\x00\x05\xdc') 2505*7dc08ffcSJunyu Laia.type == 5 and a.len == 2 and a.res == 0x1111 and a.mtu == 1500 2506*7dc08ffcSJunyu Lai 2507*7dc08ffcSJunyu Lai 2508*7dc08ffcSJunyu Lai############ 2509*7dc08ffcSJunyu Lai############ 2510*7dc08ffcSJunyu Lai+ ICMPv6NDOptShortcutLimit Class Test (RFC2491) 2511*7dc08ffcSJunyu Lai 2512*7dc08ffcSJunyu Lai= ICMPv6NDOptShortcutLimit - Basic Instantiation 2513*7dc08ffcSJunyu Lairaw(ICMPv6NDOptShortcutLimit()) == b'\x06\x01(\x00\x00\x00\x00\x00' 2514*7dc08ffcSJunyu Lai 2515*7dc08ffcSJunyu Lai= ICMPv6NDOptShortcutLimit - Instantiation with specific values 2516*7dc08ffcSJunyu Lairaw(ICMPv6NDOptShortcutLimit(len=2, shortcutlim=0x11, res1=0xee, res2=0xaaaaaaaa)) == b'\x06\x02\x11\xee\xaa\xaa\xaa\xaa' 2517*7dc08ffcSJunyu Lai 2518*7dc08ffcSJunyu Lai= ICMPv6NDOptShortcutLimit - Basic Dissection 2519*7dc08ffcSJunyu Laia=ICMPv6NDOptShortcutLimit(b'\x06\x01(\x00\x00\x00\x00\x00') 2520*7dc08ffcSJunyu Laia.type == 6 and a.len == 1 and a.shortcutlim == 40 and a.res1 == 0 and a.res2 == 0 2521*7dc08ffcSJunyu Lai 2522*7dc08ffcSJunyu Lai= ICMPv6NDOptShortcutLimit - Dissection with specific values 2523*7dc08ffcSJunyu Laia=ICMPv6NDOptShortcutLimit(b'\x06\x02\x11\xee\xaa\xaa\xaa\xaa') 2524*7dc08ffcSJunyu Laia.len==2 and a.shortcutlim==0x11 and a.res1==0xee and a.res2==0xaaaaaaaa 2525*7dc08ffcSJunyu Lai 2526*7dc08ffcSJunyu Lai 2527*7dc08ffcSJunyu Lai############ 2528*7dc08ffcSJunyu Lai############ 2529*7dc08ffcSJunyu Lai+ ICMPv6NDOptAdvInterval Class Test 2530*7dc08ffcSJunyu Lai 2531*7dc08ffcSJunyu Lai= ICMPv6NDOptAdvInterval - Basic Instantiation 2532*7dc08ffcSJunyu Lairaw(ICMPv6NDOptAdvInterval()) == b'\x07\x01\x00\x00\x00\x00\x00\x00' 2533*7dc08ffcSJunyu Lai 2534*7dc08ffcSJunyu Lai= ICMPv6NDOptAdvInterval - Instantiation with specific values 2535*7dc08ffcSJunyu Lairaw(ICMPv6NDOptAdvInterval(len=2, res=0x1111, advint=0xffffffff)) == b'\x07\x02\x11\x11\xff\xff\xff\xff' 2536*7dc08ffcSJunyu Lai 2537*7dc08ffcSJunyu Lai= ICMPv6NDOptAdvInterval - Basic dissection 2538*7dc08ffcSJunyu Laia=ICMPv6NDOptAdvInterval(b'\x07\x01\x00\x00\x00\x00\x00\x00') 2539*7dc08ffcSJunyu Laia.type == 7 and a.len == 1 and a.res == 0 and a.advint == 0 2540*7dc08ffcSJunyu Lai 2541*7dc08ffcSJunyu Lai= ICMPv6NDOptAdvInterval - Dissection with specific values 2542*7dc08ffcSJunyu Laia=ICMPv6NDOptAdvInterval(b'\x07\x02\x11\x11\xff\xff\xff\xff') 2543*7dc08ffcSJunyu Laia.type == 7 and a.len == 2 and a.res == 0x1111 and a.advint == 0xffffffff 2544*7dc08ffcSJunyu Lai 2545*7dc08ffcSJunyu Lai 2546*7dc08ffcSJunyu Lai############ 2547*7dc08ffcSJunyu Lai############ 2548*7dc08ffcSJunyu Lai+ ICMPv6NDOptHAInfo Class Test 2549*7dc08ffcSJunyu Lai 2550*7dc08ffcSJunyu Lai= ICMPv6NDOptHAInfo - Basic Instantiation 2551*7dc08ffcSJunyu Lairaw(ICMPv6NDOptHAInfo()) == b'\x08\x01\x00\x00\x00\x00\x00\x01' 2552*7dc08ffcSJunyu Lai 2553*7dc08ffcSJunyu Lai= ICMPv6NDOptHAInfo - Instantiation with specific values 2554*7dc08ffcSJunyu Lairaw(ICMPv6NDOptHAInfo(len=2, res=0x1111, pref=0x2222, lifetime=0x3333)) == b'\x08\x02\x11\x11""33' 2555*7dc08ffcSJunyu Lai 2556*7dc08ffcSJunyu Lai= ICMPv6NDOptHAInfo - Basic dissection 2557*7dc08ffcSJunyu Laia=ICMPv6NDOptHAInfo(b'\x08\x01\x00\x00\x00\x00\x00\x01') 2558*7dc08ffcSJunyu Laia.type == 8 and a.len == 1 and a.res == 0 and a.pref == 0 and a.lifetime == 1 2559*7dc08ffcSJunyu Lai 2560*7dc08ffcSJunyu Lai= ICMPv6NDOptHAInfo - Dissection with specific values 2561*7dc08ffcSJunyu Laia=ICMPv6NDOptHAInfo(b'\x08\x02\x11\x11""33') 2562*7dc08ffcSJunyu Laia.type == 8 and a.len == 2 and a.res == 0x1111 and a.pref == 0x2222 and a.lifetime == 0x3333 2563*7dc08ffcSJunyu Lai 2564*7dc08ffcSJunyu Lai 2565*7dc08ffcSJunyu Lai############ 2566*7dc08ffcSJunyu Lai############ 2567*7dc08ffcSJunyu Lai+ ICMPv6NDOptSrcAddrList Class Test 2568*7dc08ffcSJunyu Lai 2569*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcAddrList - Basic Instantiation 2570*7dc08ffcSJunyu Lairaw(ICMPv6NDOptSrcAddrList()) == b'\t\x01\x00\x00\x00\x00\x00\x00' 2571*7dc08ffcSJunyu Lai 2572*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcAddrList - Instantiation with specific values (auto len) 2573*7dc08ffcSJunyu Lairaw(ICMPv6NDOptSrcAddrList(res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\t\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2574*7dc08ffcSJunyu Lai 2575*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcAddrList - Instantiation with specific values 2576*7dc08ffcSJunyu Lairaw(ICMPv6NDOptSrcAddrList(len=3, res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\t\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2577*7dc08ffcSJunyu Lai 2578*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcAddrList - Basic Dissection 2579*7dc08ffcSJunyu Laia=ICMPv6NDOptSrcAddrList(b'\t\x01\x00\x00\x00\x00\x00\x00') 2580*7dc08ffcSJunyu Laia.type == 9 and a.len == 1 and a.res == b'\x00\x00\x00\x00\x00\x00' and not a.addrlist 2581*7dc08ffcSJunyu Lai 2582*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcAddrList - Dissection with specific values (auto len) 2583*7dc08ffcSJunyu Laia=ICMPv6NDOptSrcAddrList(b'\t\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2584*7dc08ffcSJunyu Laia.type == 9 and a.len == 5 and a.res == b'BBBBBB' and len(a.addrlist) == 2 and a.addrlist[0] == "ffff::ffff" and a.addrlist[1] == "1111::1111" 2585*7dc08ffcSJunyu Lai 2586*7dc08ffcSJunyu Lai= ICMPv6NDOptSrcAddrList - Dissection with specific values 2587*7dc08ffcSJunyu Laiconf.debug_dissector = False 2588*7dc08ffcSJunyu Laia=ICMPv6NDOptSrcAddrList(b'\t\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2589*7dc08ffcSJunyu Laiconf.debug_dissector = True 2590*7dc08ffcSJunyu Laia.type == 9 and a.len == 3 and a.res == b'BBBBBB' and len(a.addrlist) == 1 and a.addrlist[0] == "ffff::ffff" and isinstance(a.payload, Raw) and a.payload.load == b'\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2591*7dc08ffcSJunyu Lai 2592*7dc08ffcSJunyu Lai 2593*7dc08ffcSJunyu Lai############ 2594*7dc08ffcSJunyu Lai############ 2595*7dc08ffcSJunyu Lai+ ICMPv6NDOptTgtAddrList Class Test 2596*7dc08ffcSJunyu Lai 2597*7dc08ffcSJunyu Lai= ICMPv6NDOptTgtAddrList - Basic Instantiation 2598*7dc08ffcSJunyu Lairaw(ICMPv6NDOptTgtAddrList()) == b'\n\x01\x00\x00\x00\x00\x00\x00' 2599*7dc08ffcSJunyu Lai 2600*7dc08ffcSJunyu Lai= ICMPv6NDOptTgtAddrList - Instantiation with specific values (auto len) 2601*7dc08ffcSJunyu Lairaw(ICMPv6NDOptTgtAddrList(res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\n\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2602*7dc08ffcSJunyu Lai 2603*7dc08ffcSJunyu Lai= ICMPv6NDOptTgtAddrList - Instantiation with specific values 2604*7dc08ffcSJunyu Lairaw(ICMPv6NDOptTgtAddrList(len=3, res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\n\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2605*7dc08ffcSJunyu Lai 2606*7dc08ffcSJunyu Lai= ICMPv6NDOptTgtAddrList - Basic Dissection 2607*7dc08ffcSJunyu Laia=ICMPv6NDOptTgtAddrList(b'\n\x01\x00\x00\x00\x00\x00\x00') 2608*7dc08ffcSJunyu Laia.type == 10 and a.len == 1 and a.res == b'\x00\x00\x00\x00\x00\x00' and not a.addrlist 2609*7dc08ffcSJunyu Lai 2610*7dc08ffcSJunyu Lai= ICMPv6NDOptTgtAddrList - Dissection with specific values (auto len) 2611*7dc08ffcSJunyu Laia=ICMPv6NDOptTgtAddrList(b'\n\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2612*7dc08ffcSJunyu Laia.type == 10 and a.len == 5 and a.res == b'BBBBBB' and len(a.addrlist) == 2 and a.addrlist[0] == "ffff::ffff" and a.addrlist[1] == "1111::1111" 2613*7dc08ffcSJunyu Lai 2614*7dc08ffcSJunyu Lai= ICMPv6NDOptTgtAddrList - Instantiation with specific values 2615*7dc08ffcSJunyu Laiconf.debug_dissector = False 2616*7dc08ffcSJunyu Laia=ICMPv6NDOptTgtAddrList(b'\n\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2617*7dc08ffcSJunyu Laiconf.debug_dissector = True 2618*7dc08ffcSJunyu Laia.type == 10 and a.len == 3 and a.res == b'BBBBBB' and len(a.addrlist) == 1 and a.addrlist[0] == "ffff::ffff" and isinstance(a.payload, Raw) and a.payload.load == b'\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2619*7dc08ffcSJunyu Lai 2620*7dc08ffcSJunyu Lai 2621*7dc08ffcSJunyu Lai############ 2622*7dc08ffcSJunyu Lai############ 2623*7dc08ffcSJunyu Lai+ ICMPv6NDOptIPAddr Class Test (RFC 4068) 2624*7dc08ffcSJunyu Lai 2625*7dc08ffcSJunyu Lai= ICMPv6NDOptIPAddr - Basic Instantiation 2626*7dc08ffcSJunyu Lairaw(ICMPv6NDOptIPAddr()) == b'\x11\x03\x01@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2627*7dc08ffcSJunyu Lai 2628*7dc08ffcSJunyu Lai= ICMPv6NDOptIPAddr - Instantiation with specific values 2629*7dc08ffcSJunyu Lairaw(ICMPv6NDOptIPAddr(len=5, optcode=0xff, plen=40, res=0xeeeeeeee, addr="ffff::1111")) == b'\x11\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2630*7dc08ffcSJunyu Lai 2631*7dc08ffcSJunyu Lai= ICMPv6NDOptIPAddr - Basic Dissection 2632*7dc08ffcSJunyu Laia=ICMPv6NDOptIPAddr(b'\x11\x03\x01@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2633*7dc08ffcSJunyu Laia.type == 17 and a.len == 3 and a.optcode == 1 and a.plen == 64 and a.res == 0 and a.addr == "::" 2634*7dc08ffcSJunyu Lai 2635*7dc08ffcSJunyu Lai= ICMPv6NDOptIPAddr - Dissection with specific values 2636*7dc08ffcSJunyu Laia=ICMPv6NDOptIPAddr(b'\x11\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2637*7dc08ffcSJunyu Laia.type == 17 and a.len == 5 and a.optcode == 0xff and a.plen == 40 and a.res == 0xeeeeeeee and a.addr == "ffff::1111" 2638*7dc08ffcSJunyu Lai 2639*7dc08ffcSJunyu Lai 2640*7dc08ffcSJunyu Lai############ 2641*7dc08ffcSJunyu Lai############ 2642*7dc08ffcSJunyu Lai+ ICMPv6NDOptNewRtrPrefix Class Test (RFC 4068) 2643*7dc08ffcSJunyu Lai 2644*7dc08ffcSJunyu Lai= ICMPv6NDOptNewRtrPrefix - Basic Instantiation 2645*7dc08ffcSJunyu Lairaw(ICMPv6NDOptNewRtrPrefix()) == b'\x12\x03\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2646*7dc08ffcSJunyu Lai 2647*7dc08ffcSJunyu Lai= ICMPv6NDOptNewRtrPrefix - Instantiation with specific values 2648*7dc08ffcSJunyu Lairaw(ICMPv6NDOptNewRtrPrefix(len=5, optcode=0xff, plen=40, res=0xeeeeeeee, prefix="ffff::1111")) == b'\x12\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2649*7dc08ffcSJunyu Lai 2650*7dc08ffcSJunyu Lai= ICMPv6NDOptNewRtrPrefix - Basic Dissection 2651*7dc08ffcSJunyu Laia=ICMPv6NDOptNewRtrPrefix(b'\x12\x03\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2652*7dc08ffcSJunyu Laia.type == 18 and a.len == 3 and a.optcode == 0 and a.plen == 64 and a.res == 0 and a.prefix == "::" 2653*7dc08ffcSJunyu Lai 2654*7dc08ffcSJunyu Lai= ICMPv6NDOptNewRtrPrefix - Dissection with specific values 2655*7dc08ffcSJunyu Laia=ICMPv6NDOptNewRtrPrefix(b'\x12\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2656*7dc08ffcSJunyu Laia.type == 18 and a.len == 5 and a.optcode == 0xff and a.plen == 40 and a.res == 0xeeeeeeee and a.prefix == "ffff::1111" 2657*7dc08ffcSJunyu Lai 2658*7dc08ffcSJunyu Lai 2659*7dc08ffcSJunyu Lai############ 2660*7dc08ffcSJunyu Lai############ 2661*7dc08ffcSJunyu Lai+ ICMPv6NDOptLLA Class Test (RFC 4068) 2662*7dc08ffcSJunyu Lai 2663*7dc08ffcSJunyu Lai= ICMPv6NDOptLLA - Basic Instantiation 2664*7dc08ffcSJunyu Lairaw(ICMPv6NDOptLLA()) == b'\x13\x01\x00\x00\x00\x00\x00\x00\x00' 2665*7dc08ffcSJunyu Lai 2666*7dc08ffcSJunyu Lai= ICMPv6NDOptLLA - Instantiation with specific values 2667*7dc08ffcSJunyu Lairaw(ICMPv6NDOptLLA(len=2, optcode=3, lla="ff:11:ff:11:ff:11")) == b'\x13\x02\x03\xff\x11\xff\x11\xff\x11' 2668*7dc08ffcSJunyu Lai 2669*7dc08ffcSJunyu Lai= ICMPv6NDOptLLA - Basic Dissection 2670*7dc08ffcSJunyu Laia=ICMPv6NDOptLLA(b'\x13\x01\x00\x00\x00\x00\x00\x00\x00') 2671*7dc08ffcSJunyu Laia.type == 19 and a.len == 1 and a.optcode == 0 and a.lla == "00:00:00:00:00:00" 2672*7dc08ffcSJunyu Lai 2673*7dc08ffcSJunyu Lai= ICMPv6NDOptLLA - Dissection with specific values 2674*7dc08ffcSJunyu Laia=ICMPv6NDOptLLA(b'\x13\x02\x03\xff\x11\xff\x11\xff\x11') 2675*7dc08ffcSJunyu Laia.type == 19 and a.len == 2 and a.optcode == 3 and a.lla == "ff:11:ff:11:ff:11" 2676*7dc08ffcSJunyu Lai 2677*7dc08ffcSJunyu Lai 2678*7dc08ffcSJunyu Lai############ 2679*7dc08ffcSJunyu Lai############ 2680*7dc08ffcSJunyu Lai+ ICMPv6NDOptRouteInfo Class Test 2681*7dc08ffcSJunyu Lai 2682*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Basic Instantiation 2683*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo()) == b'\x18\x01\x00\x00\xff\xff\xff\xff' 2684*7dc08ffcSJunyu Lai 2685*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Instantiation with forced prefix but no length 2686*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo(prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01' 2687*7dc08ffcSJunyu Lai 2688*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Instantiation with forced length values (1/4) 2689*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo(len=1, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x01\x00\x00\xff\xff\xff\xff' 2690*7dc08ffcSJunyu Lai 2691*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Instantiation with forced length values (2/4) 2692*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo(len=2, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x02\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01' 2693*7dc08ffcSJunyu Lai 2694*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Instantiation with forced length values (3/4) 2695*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo(len=3, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01' 2696*7dc08ffcSJunyu Lai 2697*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Instantiation with forced length values (4/4) 2698*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo(len=4, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x04\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00' 2699*7dc08ffcSJunyu Lai 2700*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Instantiation with specific values 2701*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRouteInfo(len=6, plen=0x11, res1=1, prf=3, res2=1, rtlifetime=0x22222222, prefix="2001:db8::1")) == b'\x18\x06\x119"""" \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2702*7dc08ffcSJunyu Lai 2703*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Basic dissection 2704*7dc08ffcSJunyu Laia=ICMPv6NDOptRouteInfo(b'\x18\x03\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2705*7dc08ffcSJunyu Laia.type == 24 and a.len == 3 and a.plen == 0 and a.res1 == 0 and a.prf == 0 and a.res2 == 0 and a.rtlifetime == 0xffffffff and a. prefix == "::" 2706*7dc08ffcSJunyu Lai 2707*7dc08ffcSJunyu Lai= ICMPv6NDOptRouteInfo - Dissection with specific values 2708*7dc08ffcSJunyu Laia=ICMPv6NDOptRouteInfo(b'\x18\x04\x119"""" \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 2709*7dc08ffcSJunyu Laia.plen == 0x11 and a.res1 == 1 and a.prf == 3 and a.res2 == 1 and a.rtlifetime == 0x22222222 and a.prefix == "2001:db8::1" 2710*7dc08ffcSJunyu Lai 2711*7dc08ffcSJunyu Lai 2712*7dc08ffcSJunyu Lai############ 2713*7dc08ffcSJunyu Lai############ 2714*7dc08ffcSJunyu Lai+ ICMPv6NDOptMAP Class Test 2715*7dc08ffcSJunyu Lai 2716*7dc08ffcSJunyu Lai= ICMPv6NDOptMAP - Basic Instantiation 2717*7dc08ffcSJunyu Lairaw(ICMPv6NDOptMAP()) == b'\x17\x03\x1f\x80\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2718*7dc08ffcSJunyu Lai 2719*7dc08ffcSJunyu Lai= ICMPv6NDOptMAP - Instantiation with specific values 2720*7dc08ffcSJunyu Lairaw(ICMPv6NDOptMAP(len=5, dist=3, pref=10, R=0, res=1, validlifetime=0x11111111, addr="ffff::1111")) == b'\x17\x05:\x01\x11\x11\x11\x11\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11' 2721*7dc08ffcSJunyu Lai 2722*7dc08ffcSJunyu Lai= ICMPv6NDOptMAP - Basic Dissection 2723*7dc08ffcSJunyu Laia=ICMPv6NDOptMAP(b'\x17\x03\x1f\x80\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2724*7dc08ffcSJunyu Laia.type==23 and a.len==3 and a.dist==1 and a.pref==15 and a.R==1 and a.res==0 and a.validlifetime==0xffffffff and a.addr=="::" 2725*7dc08ffcSJunyu Lai 2726*7dc08ffcSJunyu Lai= ICMPv6NDOptMAP - Dissection with specific values 2727*7dc08ffcSJunyu Laia=ICMPv6NDOptMAP(b'\x17\x05:\x01\x11\x11\x11\x11\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11') 2728*7dc08ffcSJunyu Laia.type==23 and a.len==5 and a.dist==3 and a.pref==10 and a.R==0 and a.res==1 and a.validlifetime==0x11111111 and a.addr=="ffff::1111" 2729*7dc08ffcSJunyu Lai 2730*7dc08ffcSJunyu Lai 2731*7dc08ffcSJunyu Lai############ 2732*7dc08ffcSJunyu Lai############ 2733*7dc08ffcSJunyu Lai+ ICMPv6NDOptRDNSS Class Test 2734*7dc08ffcSJunyu Lai 2735*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Basic Instantiation 2736*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRDNSS()) == b'\x19\x01\x00\x00\xff\xff\xff\xff' 2737*7dc08ffcSJunyu Lai 2738*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Basic instantiation with 1 DNS address 2739*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRDNSS(dns=["2001:db8::1"])) == b'\x19\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 2740*7dc08ffcSJunyu Lai 2741*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Basic instantiation with 2 DNS addresses 2742*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRDNSS(dns=["2001:db8::1", "2001:db8::2"])) == b'\x19\x05\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 2743*7dc08ffcSJunyu Lai 2744*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Instantiation with specific values 2745*7dc08ffcSJunyu Lairaw(ICMPv6NDOptRDNSS(len=43, res=0xaaee, lifetime=0x11111111, dns=["2001:db8::2"])) == b'\x19+\xaa\xee\x11\x11\x11\x11 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 2746*7dc08ffcSJunyu Lai 2747*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Basic Dissection 2748*7dc08ffcSJunyu Laia=ICMPv6NDOptRDNSS(b'\x19\x01\x00\x00\xff\xff\xff\xff') 2749*7dc08ffcSJunyu Laia.type==25 and a.len==1 and a.res == 0 and a.dns==[] 2750*7dc08ffcSJunyu Lai 2751*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Dissection (with 1 DNS address) 2752*7dc08ffcSJunyu Laia=ICMPv6NDOptRDNSS(b'\x19\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 2753*7dc08ffcSJunyu Laia.type==25 and a.len==3 and a.res ==0 and len(a.dns) == 1 and a.dns[0] == "2001:db8::1" 2754*7dc08ffcSJunyu Lai 2755*7dc08ffcSJunyu Lai= ICMPv6NDOptRDNSS - Dissection (with 2 DNS addresses) 2756*7dc08ffcSJunyu Laia=ICMPv6NDOptRDNSS(b'\x19\x05\xaa\xee\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 2757*7dc08ffcSJunyu Laia.type==25 and a.len==5 and a.res == 0xaaee and len(a.dns) == 2 and a.dns[0] == "2001:db8::1" and a.dns[1] == "2001:db8::2" 2758*7dc08ffcSJunyu Lai 2759*7dc08ffcSJunyu Lai 2760*7dc08ffcSJunyu Lai############ 2761*7dc08ffcSJunyu Lai############ 2762*7dc08ffcSJunyu Lai+ ICMPv6NDOptDNSSL Class Test 2763*7dc08ffcSJunyu Lai 2764*7dc08ffcSJunyu Lai= ICMPv6NDOptDNSSL - Basic Instantiation 2765*7dc08ffcSJunyu Lairaw(ICMPv6NDOptDNSSL()) == b'\x1f\x01\x00\x00\xff\xff\xff\xff' 2766*7dc08ffcSJunyu Lai 2767*7dc08ffcSJunyu Lai= ICMPv6NDOptDNSSL - Instantiation with 1 search domain, as seen in the wild 2768*7dc08ffcSJunyu Lairaw(ICMPv6NDOptDNSSL(lifetime=60, searchlist=["home."])) == b'\x1f\x02\x00\x00\x00\x00\x00<\x04home\x00\x00\x00' 2769*7dc08ffcSJunyu Lai 2770*7dc08ffcSJunyu Lai= ICMPv6NDOptDNSSL - Basic instantiation with 2 search domains 2771*7dc08ffcSJunyu Lairaw(ICMPv6NDOptDNSSL(searchlist=["home.", "office."])) == b'\x1f\x03\x00\x00\xff\xff\xff\xff\x04home\x00\x06office\x00\x00\x00' 2772*7dc08ffcSJunyu Lai 2773*7dc08ffcSJunyu Lai= ICMPv6NDOptDNSSL - Basic instantiation with 3 search domains 2774*7dc08ffcSJunyu Lairaw(ICMPv6NDOptDNSSL(searchlist=["home.", "office.", "here.there."])) == b'\x1f\x05\x00\x00\xff\xff\xff\xff\x04home\x00\x06office\x00\x04here\x05there\x00\x00\x00\x00\x00\x00\x00' 2775*7dc08ffcSJunyu Lai 2776*7dc08ffcSJunyu Lai= ICMPv6NDOptDNSSL - Basic Dissection 2777*7dc08ffcSJunyu Laip = ICMPv6NDOptDNSSL(b'\x1f\x01\x00\x00\xff\xff\xff\xff') 2778*7dc08ffcSJunyu Laip.type == 31 and p.len == 1 and p.res == 0 and p.searchlist == [] 2779*7dc08ffcSJunyu Lai 2780*7dc08ffcSJunyu Lai= ICMPv6NDOptDNSSL - Basic Dissection with specific values 2781*7dc08ffcSJunyu Laip = ICMPv6NDOptDNSSL(b'\x1f\x02\x00\x00\x00\x00\x00<\x04home\x00\x00\x00') 2782*7dc08ffcSJunyu Laip.type == 31 and p.len == 2 and p.res == 0 and p.lifetime == 60 and p.searchlist == ["home."] 2783*7dc08ffcSJunyu Lai 2784*7dc08ffcSJunyu Lai 2785*7dc08ffcSJunyu Lai############ 2786*7dc08ffcSJunyu Lai############ 2787*7dc08ffcSJunyu Lai+ ICMPv6NDOptEFA Class Test 2788*7dc08ffcSJunyu Lai 2789*7dc08ffcSJunyu Lai= ICMPv6NDOptEFA - Basic Instantiation 2790*7dc08ffcSJunyu Lairaw(ICMPv6NDOptEFA()) == b'\x1a\x01\x00\x00\x00\x00\x00\x00' 2791*7dc08ffcSJunyu Lai 2792*7dc08ffcSJunyu Lai= ICMPv6NDOptEFA - Basic Dissection 2793*7dc08ffcSJunyu Laia=ICMPv6NDOptEFA(b'\x1a\x01\x00\x00\x00\x00\x00\x00') 2794*7dc08ffcSJunyu Laia.type==26 and a.len==1 and a.res == 0 2795*7dc08ffcSJunyu Lai 2796*7dc08ffcSJunyu Lai 2797*7dc08ffcSJunyu Lai############ 2798*7dc08ffcSJunyu Lai############ 2799*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIQueryNOOP 2800*7dc08ffcSJunyu Lai 2801*7dc08ffcSJunyu Lai= ICMPv6NIQueryNOOP - Basic Instantiation 2802*7dc08ffcSJunyu Lairaw(ICMPv6NIQueryNOOP(nonce=b"\x00"*8)) == b'\x8b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 2803*7dc08ffcSJunyu Lai 2804*7dc08ffcSJunyu Lai= ICMPv6NIQueryNOOP - Basic Dissection 2805*7dc08ffcSJunyu Laia = ICMPv6NIQueryNOOP(b'\x8b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 2806*7dc08ffcSJunyu Laia.type == 139 and a.code == 1 and a.cksum == 0 and a.qtype == 0 and a.unused == 0 and a.flags == 0 and a.nonce == b"\x00"*8 and a.data == b"" 2807*7dc08ffcSJunyu Lai 2808*7dc08ffcSJunyu Lai 2809*7dc08ffcSJunyu Lai############ 2810*7dc08ffcSJunyu Lai############ 2811*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIQueryName 2812*7dc08ffcSJunyu Lai 2813*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - single label DNS name (internal) 2814*7dc08ffcSJunyu Laia=ICMPv6NIQueryName(data="abricot").getfieldval("data") 2815*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x07abricot\x00\x00' 2816*7dc08ffcSJunyu Lai 2817*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - single label DNS name 2818*7dc08ffcSJunyu LaiICMPv6NIQueryName(data="abricot").data == b"abricot" 2819*7dc08ffcSJunyu Lai 2820*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - fqdn (internal) 2821*7dc08ffcSJunyu Laia=ICMPv6NIQueryName(data="n.d.org").getfieldval("data") 2822*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x01n\x01d\x03org\x00' 2823*7dc08ffcSJunyu Lai 2824*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - fqdn 2825*7dc08ffcSJunyu LaiICMPv6NIQueryName(data="n.d.org").data == b"n.d.org" 2826*7dc08ffcSJunyu Lai 2827*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - IPv6 address (internal) 2828*7dc08ffcSJunyu Laia=ICMPv6NIQueryName(data="2001:db8::1").getfieldval("data") 2829*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == '2001:db8::1' 2830*7dc08ffcSJunyu Lai 2831*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - IPv6 address 2832*7dc08ffcSJunyu LaiICMPv6NIQueryName(data="2001:db8::1").data == "2001:db8::1" 2833*7dc08ffcSJunyu Lai 2834*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - IPv4 address (internal) 2835*7dc08ffcSJunyu Laia=ICMPv6NIQueryName(data="169.254.253.252").getfieldval("data") 2836*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and a[1] == '169.254.253.252' 2837*7dc08ffcSJunyu Lai 2838*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - IPv4 address 2839*7dc08ffcSJunyu LaiICMPv6NIQueryName(data="169.254.253.252").data == '169.254.253.252' 2840*7dc08ffcSJunyu Lai 2841*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - build & dissection 2842*7dc08ffcSJunyu Lais = raw(IPv6()/ICMPv6NIQueryName(data="n.d.org")) 2843*7dc08ffcSJunyu Laip = IPv6(s) 2844*7dc08ffcSJunyu LaiICMPv6NIQueryName in p and p[ICMPv6NIQueryName].data == b"n.d.org" 2845*7dc08ffcSJunyu Lai 2846*7dc08ffcSJunyu Lai 2847*7dc08ffcSJunyu Lai############ 2848*7dc08ffcSJunyu Lai############ 2849*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIQueryIPv6 2850*7dc08ffcSJunyu Lai 2851*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - single label DNS name (internal) 2852*7dc08ffcSJunyu Laia = ICMPv6NIQueryIPv6(data="abricot") 2853*7dc08ffcSJunyu Lails(a) 2854*7dc08ffcSJunyu Laia = a.getfieldval("data") 2855*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x07abricot\x00\x00' 2856*7dc08ffcSJunyu Lai 2857*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - single label DNS name 2858*7dc08ffcSJunyu LaiICMPv6NIQueryIPv6(data="abricot").data == b"abricot" 2859*7dc08ffcSJunyu Lai 2860*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - fqdn (internal) 2861*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv6(data="n.d.org").getfieldval("data") 2862*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x01n\x01d\x03org\x00' 2863*7dc08ffcSJunyu Lai 2864*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - fqdn 2865*7dc08ffcSJunyu LaiICMPv6NIQueryIPv6(data="n.d.org").data == b"n.d.org" 2866*7dc08ffcSJunyu Lai 2867*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - IPv6 address (internal) 2868*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv6(data="2001:db8::1").getfieldval("data") 2869*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == '2001:db8::1' 2870*7dc08ffcSJunyu Lai 2871*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - IPv6 address 2872*7dc08ffcSJunyu LaiICMPv6NIQueryIPv6(data="2001:db8::1").data == "2001:db8::1" 2873*7dc08ffcSJunyu Lai 2874*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - IPv4 address (internal) 2875*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv6(data="169.254.253.252").getfieldval("data") 2876*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and a[1] == '169.254.253.252' 2877*7dc08ffcSJunyu Lai 2878*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - IPv4 address 2879*7dc08ffcSJunyu LaiICMPv6NIQueryIPv6(data="169.254.253.252").data == '169.254.253.252' 2880*7dc08ffcSJunyu Lai 2881*7dc08ffcSJunyu Lai 2882*7dc08ffcSJunyu Lai############ 2883*7dc08ffcSJunyu Lai############ 2884*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIQueryIPv4 2885*7dc08ffcSJunyu Lai 2886*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - single label DNS name (internal) 2887*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv4(data="abricot").getfieldval("data") 2888*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x07abricot\x00\x00' 2889*7dc08ffcSJunyu Lai 2890*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - single label DNS name 2891*7dc08ffcSJunyu LaiICMPv6NIQueryIPv4(data="abricot").data == b"abricot" 2892*7dc08ffcSJunyu Lai 2893*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - fqdn (internal) 2894*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv4(data="n.d.org").getfieldval("data") 2895*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x01n\x01d\x03org\x00' 2896*7dc08ffcSJunyu Lai 2897*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - fqdn 2898*7dc08ffcSJunyu LaiICMPv6NIQueryIPv4(data="n.d.org").data == b"n.d.org" 2899*7dc08ffcSJunyu Lai 2900*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - IPv6 address (internal) 2901*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv4(data="2001:db8::1").getfieldval("data") 2902*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == '2001:db8::1' 2903*7dc08ffcSJunyu Lai 2904*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - IPv6 address 2905*7dc08ffcSJunyu LaiICMPv6NIQueryIPv4(data="2001:db8::1").data == "2001:db8::1" 2906*7dc08ffcSJunyu Lai 2907*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - IPv4 address (internal) 2908*7dc08ffcSJunyu Laia=ICMPv6NIQueryIPv4(data="169.254.253.252").getfieldval("data") 2909*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and a[1] == '169.254.253.252' 2910*7dc08ffcSJunyu Lai 2911*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - IPv4 address 2912*7dc08ffcSJunyu LaiICMPv6NIQueryIPv4(data="169.254.253.252").data == '169.254.253.252' 2913*7dc08ffcSJunyu Lai 2914*7dc08ffcSJunyu Lai 2915*7dc08ffcSJunyu Lai############ 2916*7dc08ffcSJunyu Lai############ 2917*7dc08ffcSJunyu Lai+ Test Node Information Query - Flags tests 2918*7dc08ffcSJunyu Lai 2919*7dc08ffcSJunyu Lai= ICMPv6NIQuery* - flags handling (Test 1) 2920*7dc08ffcSJunyu Lait = ICMPv6NIQueryIPv6(flags="T") 2921*7dc08ffcSJunyu Laia = ICMPv6NIQueryIPv6(flags="A") 2922*7dc08ffcSJunyu Laic = ICMPv6NIQueryIPv6(flags="C") 2923*7dc08ffcSJunyu Lail = ICMPv6NIQueryIPv6(flags="L") 2924*7dc08ffcSJunyu Lais = ICMPv6NIQueryIPv6(flags="S") 2925*7dc08ffcSJunyu Laig = ICMPv6NIQueryIPv6(flags="G") 2926*7dc08ffcSJunyu Laiallflags = ICMPv6NIQueryIPv6(flags="TALCLSG") 2927*7dc08ffcSJunyu Lait.flags == 1 and a.flags == 2 and c.flags == 4 and l.flags == 8 and s.flags == 16 and g.flags == 32 and allflags.flags == 63 2928*7dc08ffcSJunyu Lai 2929*7dc08ffcSJunyu Lai 2930*7dc08ffcSJunyu Lai= ICMPv6NIQuery* - flags handling (Test 2) 2931*7dc08ffcSJunyu Lait = raw(ICMPv6NIQueryNOOP(flags="T", nonce="A"*8))[6:8] 2932*7dc08ffcSJunyu Laia = raw(ICMPv6NIQueryNOOP(flags="A", nonce="A"*8))[6:8] 2933*7dc08ffcSJunyu Laic = raw(ICMPv6NIQueryNOOP(flags="C", nonce="A"*8))[6:8] 2934*7dc08ffcSJunyu Lail = raw(ICMPv6NIQueryNOOP(flags="L", nonce="A"*8))[6:8] 2935*7dc08ffcSJunyu Lais = raw(ICMPv6NIQueryNOOP(flags="S", nonce="A"*8))[6:8] 2936*7dc08ffcSJunyu Laig = raw(ICMPv6NIQueryNOOP(flags="G", nonce="A"*8))[6:8] 2937*7dc08ffcSJunyu Laiallflags = raw(ICMPv6NIQueryNOOP(flags="TALCLSG", nonce="A"*8))[6:8] 2938*7dc08ffcSJunyu Lait == b'\x00\x01' and a == b'\x00\x02' and c == b'\x00\x04' and l == b'\x00\x08' and s == b'\x00\x10' and g == b'\x00\x20' and allflags == b'\x00\x3F' 2939*7dc08ffcSJunyu Lai 2940*7dc08ffcSJunyu Lai 2941*7dc08ffcSJunyu Lai= ICMPv6NIReply* - flags handling (Test 1) 2942*7dc08ffcSJunyu Lait = ICMPv6NIReplyIPv6(flags="T") 2943*7dc08ffcSJunyu Laia = ICMPv6NIReplyIPv6(flags="A") 2944*7dc08ffcSJunyu Laic = ICMPv6NIReplyIPv6(flags="C") 2945*7dc08ffcSJunyu Lail = ICMPv6NIReplyIPv6(flags="L") 2946*7dc08ffcSJunyu Lais = ICMPv6NIReplyIPv6(flags="S") 2947*7dc08ffcSJunyu Laig = ICMPv6NIReplyIPv6(flags="G") 2948*7dc08ffcSJunyu Laiallflags = ICMPv6NIReplyIPv6(flags="TALCLSG") 2949*7dc08ffcSJunyu Lait.flags == 1 and a.flags == 2 and c.flags == 4 and l.flags == 8 and s.flags == 16 and g.flags == 32 and allflags.flags == 63 2950*7dc08ffcSJunyu Lai 2951*7dc08ffcSJunyu Lai 2952*7dc08ffcSJunyu Lai= ICMPv6NIReply* - flags handling (Test 2) 2953*7dc08ffcSJunyu Lait = raw(ICMPv6NIReplyNOOP(flags="T", nonce="A"*8))[6:8] 2954*7dc08ffcSJunyu Laia = raw(ICMPv6NIReplyNOOP(flags="A", nonce="A"*8))[6:8] 2955*7dc08ffcSJunyu Laic = raw(ICMPv6NIReplyNOOP(flags="C", nonce="A"*8))[6:8] 2956*7dc08ffcSJunyu Lail = raw(ICMPv6NIReplyNOOP(flags="L", nonce="A"*8))[6:8] 2957*7dc08ffcSJunyu Lais = raw(ICMPv6NIReplyNOOP(flags="S", nonce="A"*8))[6:8] 2958*7dc08ffcSJunyu Laig = raw(ICMPv6NIReplyNOOP(flags="G", nonce="A"*8))[6:8] 2959*7dc08ffcSJunyu Laiallflags = raw(ICMPv6NIReplyNOOP(flags="TALCLSG", nonce="A"*8))[6:8] 2960*7dc08ffcSJunyu Lait == b'\x00\x01' and a == b'\x00\x02' and c == b'\x00\x04' and l == b'\x00\x08' and s == b'\x00\x10' and g == b'\x00\x20' and allflags == b'\x00\x3F' 2961*7dc08ffcSJunyu Lai 2962*7dc08ffcSJunyu Lai 2963*7dc08ffcSJunyu Lai= ICMPv6NIQuery* - Flags Default values 2964*7dc08ffcSJunyu Laia = ICMPv6NIQueryNOOP() 2965*7dc08ffcSJunyu Laib = ICMPv6NIQueryName() 2966*7dc08ffcSJunyu Laic = ICMPv6NIQueryIPv4() 2967*7dc08ffcSJunyu Laid = ICMPv6NIQueryIPv6() 2968*7dc08ffcSJunyu Laia.flags == 0 and b.flags == 0 and c.flags == 0 and d.flags == 62 2969*7dc08ffcSJunyu Lai 2970*7dc08ffcSJunyu Lai= ICMPv6NIReply* - Flags Default values 2971*7dc08ffcSJunyu Laia = ICMPv6NIReplyIPv6() 2972*7dc08ffcSJunyu Laib = ICMPv6NIReplyName() 2973*7dc08ffcSJunyu Laic = ICMPv6NIReplyIPv6() 2974*7dc08ffcSJunyu Laid = ICMPv6NIReplyIPv4() 2975*7dc08ffcSJunyu Laie = ICMPv6NIReplyRefuse() 2976*7dc08ffcSJunyu Laif = ICMPv6NIReplyUnknown() 2977*7dc08ffcSJunyu Laia.flags == 0 and b.flags == 0 and c.flags == 0 and d.flags == 0 and e.flags == 0 and f.flags == 0 2978*7dc08ffcSJunyu Lai 2979*7dc08ffcSJunyu Lai 2980*7dc08ffcSJunyu Lai 2981*7dc08ffcSJunyu Lai# Nonces 2982*7dc08ffcSJunyu Lai# hashret and answers 2983*7dc08ffcSJunyu Lai# payload guess 2984*7dc08ffcSJunyu Lai# automatic destination address computation when integrated in scapy6 2985*7dc08ffcSJunyu Lai# at least computeNIGroupAddr 2986*7dc08ffcSJunyu Lai 2987*7dc08ffcSJunyu Lai 2988*7dc08ffcSJunyu Lai############ 2989*7dc08ffcSJunyu Lai############ 2990*7dc08ffcSJunyu Lai+ Test Node Information Query - Dispatching 2991*7dc08ffcSJunyu Lai 2992*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - dispatch with nothing in data 2993*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6()) 2994*7dc08ffcSJunyu Laip = IPv6(s) 2995*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv6) 2996*7dc08ffcSJunyu Lai 2997*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - dispatch with IPv6 address in data 2998*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6(data="2001::db8::1")) 2999*7dc08ffcSJunyu Laip = IPv6(s) 3000*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv6) 3001*7dc08ffcSJunyu Lai 3002*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - dispatch with IPv4 address in data 3003*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6(data="192.168.0.1")) 3004*7dc08ffcSJunyu Laip = IPv6(s) 3005*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv6) 3006*7dc08ffcSJunyu Lai 3007*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv6 - dispatch with name in data 3008*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6(data="alfred")) 3009*7dc08ffcSJunyu Laip = IPv6(s) 3010*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv6) 3011*7dc08ffcSJunyu Lai 3012*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - dispatch with nothing in data 3013*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName()) 3014*7dc08ffcSJunyu Laip = IPv6(s) 3015*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryName) 3016*7dc08ffcSJunyu Lai 3017*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - dispatch with IPv6 address in data 3018*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName(data="2001:db8::1")) 3019*7dc08ffcSJunyu Laip = IPv6(s) 3020*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryName) 3021*7dc08ffcSJunyu Lai 3022*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - dispatch with IPv4 address in data 3023*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName(data="192.168.0.1")) 3024*7dc08ffcSJunyu Laip = IPv6(s) 3025*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryName) 3026*7dc08ffcSJunyu Lai 3027*7dc08ffcSJunyu Lai= ICMPv6NIQueryName - dispatch with name in data 3028*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName(data="alfred")) 3029*7dc08ffcSJunyu Laip = IPv6(s) 3030*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryName) 3031*7dc08ffcSJunyu Lai 3032*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - dispatch with nothing in data 3033*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4()) 3034*7dc08ffcSJunyu Laip = IPv6(s) 3035*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv4) 3036*7dc08ffcSJunyu Lai 3037*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - dispatch with IPv6 address in data 3038*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4(data="2001:db8::1")) 3039*7dc08ffcSJunyu Laip = IPv6(s) 3040*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv4) 3041*7dc08ffcSJunyu Lai 3042*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - dispatch with IPv6 address in data 3043*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4(data="192.168.0.1")) 3044*7dc08ffcSJunyu Laip = IPv6(s) 3045*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv4) 3046*7dc08ffcSJunyu Lai 3047*7dc08ffcSJunyu Lai= ICMPv6NIQueryIPv4 - dispatch with name in data 3048*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4(data="alfred")) 3049*7dc08ffcSJunyu Laip = IPv6(s) 3050*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIQueryIPv4) 3051*7dc08ffcSJunyu Lai 3052*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - dispatch 3053*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyName()) 3054*7dc08ffcSJunyu Laip = IPv6(s) 3055*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIReplyName) 3056*7dc08ffcSJunyu Lai 3057*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - dispatch 3058*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyIPv6()) 3059*7dc08ffcSJunyu Laip = IPv6(s) 3060*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIReplyIPv6) 3061*7dc08ffcSJunyu Lai 3062*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - dispatch 3063*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyIPv4()) 3064*7dc08ffcSJunyu Laip = IPv6(s) 3065*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIReplyIPv4) 3066*7dc08ffcSJunyu Lai 3067*7dc08ffcSJunyu Lai= ICMPv6NIReplyRefuse - dispatch 3068*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyRefuse()) 3069*7dc08ffcSJunyu Laip = IPv6(s) 3070*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIReplyRefuse) 3071*7dc08ffcSJunyu Lai 3072*7dc08ffcSJunyu Lai= ICMPv6NIReplyUnknown - dispatch 3073*7dc08ffcSJunyu Lais = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyUnknown()) 3074*7dc08ffcSJunyu Laip = IPv6(s) 3075*7dc08ffcSJunyu Laiisinstance(p.payload, ICMPv6NIReplyUnknown) 3076*7dc08ffcSJunyu Lai 3077*7dc08ffcSJunyu Lai 3078*7dc08ffcSJunyu Lai############ 3079*7dc08ffcSJunyu Lai############ 3080*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIReplyNOOP 3081*7dc08ffcSJunyu Lai 3082*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - single DNS name without hint => understood as string (internal) 3083*7dc08ffcSJunyu Laia=ICMPv6NIReplyNOOP(data="abricot").getfieldval("data") 3084*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == b"abricot" 3085*7dc08ffcSJunyu Lai 3086*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - single DNS name without hint => understood as string 3087*7dc08ffcSJunyu LaiICMPv6NIReplyNOOP(data="abricot").data == b"abricot" 3088*7dc08ffcSJunyu Lai 3089*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - fqdn without hint => understood as string (internal) 3090*7dc08ffcSJunyu Laia=ICMPv6NIReplyNOOP(data="n.d.tld").getfieldval("data") 3091*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == b"n.d.tld" 3092*7dc08ffcSJunyu Lai 3093*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - fqdn without hint => understood as string 3094*7dc08ffcSJunyu LaiICMPv6NIReplyNOOP(data="n.d.tld").data == b"n.d.tld" 3095*7dc08ffcSJunyu Lai 3096*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - IPv6 address without hint => understood as string (internal) 3097*7dc08ffcSJunyu Laia=ICMPv6NIReplyNOOP(data="2001:0db8::1").getfieldval("data") 3098*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == b"2001:0db8::1" 3099*7dc08ffcSJunyu Lai 3100*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - IPv6 address without hint => understood as string 3101*7dc08ffcSJunyu LaiICMPv6NIReplyNOOP(data="2001:0db8::1").data == b"2001:0db8::1" 3102*7dc08ffcSJunyu Lai 3103*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - IPv4 address without hint => understood as string (internal) 3104*7dc08ffcSJunyu Laia=ICMPv6NIReplyNOOP(data="169.254.253.010").getfieldval("data") 3105*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == b"169.254.253.010" 3106*7dc08ffcSJunyu Lai 3107*7dc08ffcSJunyu Lai= ICMPv6NIReplyNOOP - IPv4 address without hint => understood as string 3108*7dc08ffcSJunyu LaiICMPv6NIReplyNOOP(data="169.254.253.010").data == b"169.254.253.010" 3109*7dc08ffcSJunyu Lai 3110*7dc08ffcSJunyu Lai 3111*7dc08ffcSJunyu Lai############ 3112*7dc08ffcSJunyu Lai############ 3113*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIReplyName 3114*7dc08ffcSJunyu Lai 3115*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - single label DNS name as a rawing (without ttl) (internal) 3116*7dc08ffcSJunyu Laia=ICMPv6NIReplyName(data="abricot").getfieldval("data") 3117*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 0 and a[1][1] == b'\x07abricot\x00\x00' 3118*7dc08ffcSJunyu Lai 3119*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - single label DNS name as a rawing (without ttl) 3120*7dc08ffcSJunyu LaiICMPv6NIReplyName(data="abricot").data == [0, b"abricot"] 3121*7dc08ffcSJunyu Lai 3122*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - fqdn name as a rawing (without ttl) (internal) 3123*7dc08ffcSJunyu Laia=ICMPv6NIReplyName(data="n.d.tld").getfieldval("data") 3124*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 0 and a[1][1] == b'\x01n\x01d\x03tld\x00' 3125*7dc08ffcSJunyu Lai 3126*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - fqdn name as a rawing (without ttl) 3127*7dc08ffcSJunyu LaiICMPv6NIReplyName(data="n.d.tld").data == [0, b'n.d.tld'] 3128*7dc08ffcSJunyu Lai 3129*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - list of 2 single label DNS names (without ttl) (internal) 3130*7dc08ffcSJunyu Laia=ICMPv6NIReplyName(data=["abricot", "poire"]).getfieldval("data") 3131*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 0 and a[1][1] == b'\x07abricot\x00\x00\x05poire\x00\x00' 3132*7dc08ffcSJunyu Lai 3133*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - list of 2 single label DNS names (without ttl) 3134*7dc08ffcSJunyu LaiICMPv6NIReplyName(data=["abricot", "poire"]).data == [0, b"abricot", b"poire"] 3135*7dc08ffcSJunyu Lai 3136*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - [ttl, single-label, single-label, fqdn] (internal) 3137*7dc08ffcSJunyu Laia=ICMPv6NIReplyName(data=[42, "abricot", "poire", "n.d.tld"]).getfieldval("data") 3138*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 42 and a[1][1] == b'\x07abricot\x00\x00\x05poire\x00\x00\x01n\x01d\x03tld\x00' 3139*7dc08ffcSJunyu Lai 3140*7dc08ffcSJunyu Lai= ICMPv6NIReplyName - [ttl, single-label, single-label, fqdn] 3141*7dc08ffcSJunyu LaiICMPv6NIReplyName(data=[42, "abricot", "poire", "n.d.tld"]).data == [42, b"abricot", b"poire", b"n.d.tld"] 3142*7dc08ffcSJunyu Lai 3143*7dc08ffcSJunyu Lai 3144*7dc08ffcSJunyu Lai############ 3145*7dc08ffcSJunyu Lai############ 3146*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIReplyIPv6 3147*7dc08ffcSJunyu Lai 3148*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - one IPv6 address without TTL (internal) 3149*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv6(data="2001:db8::1").getfieldval("data") 3150*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" 3151*7dc08ffcSJunyu Lai 3152*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - one IPv6 address without TTL 3153*7dc08ffcSJunyu LaiICMPv6NIReplyIPv6(data="2001:db8::1").data == [(0, '2001:db8::1')] 3154*7dc08ffcSJunyu Lai 3155*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - one IPv6 address without TTL (as a list) (internal) 3156*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv6(data=["2001:db8::1"]).getfieldval("data") 3157*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" 3158*7dc08ffcSJunyu Lai 3159*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - one IPv6 address without TTL (as a list) 3160*7dc08ffcSJunyu LaiICMPv6NIReplyIPv6(data=["2001:db8::1"]).data == [(0, '2001:db8::1')] 3161*7dc08ffcSJunyu Lai 3162*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - one IPv6 address with TTL (internal) 3163*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv6(data=[(0, "2001:db8::1")]).getfieldval("data") 3164*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" 3165*7dc08ffcSJunyu Lai 3166*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - one IPv6 address with TTL 3167*7dc08ffcSJunyu LaiICMPv6NIReplyIPv6(data=[(0, "2001:db8::1")]).data == [(0, '2001:db8::1')] 3168*7dc08ffcSJunyu Lai 3169*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list of rawings (without TTL) (internal) 3170*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv6(data=["2001:db8::1", "2001:db8::2"]).getfieldval("data") 3171*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 2 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" and len(a[1][1]) == 2 and a[1][1][0] == 0 and a[1][1][1] == "2001:db8::2" 3172*7dc08ffcSJunyu Lai 3173*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list of rawings (without TTL) 3174*7dc08ffcSJunyu LaiICMPv6NIReplyIPv6(data=["2001:db8::1", "2001:db8::2"]).data == [(0, '2001:db8::1'), (0, '2001:db8::2')] 3175*7dc08ffcSJunyu Lai 3176*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list (first with ttl, second without) (internal) 3177*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv6(data=[(42, "2001:db8::1"), "2001:db8::2"]).getfieldval("data") 3178*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 2 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 42 and a[1][0][1] == "2001:db8::1" and len(a[1][1]) == 2 and a[1][1][0] == 0 and a[1][1][1] == "2001:db8::2" 3179*7dc08ffcSJunyu Lai 3180*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list (first with ttl, second without) 3181*7dc08ffcSJunyu LaiICMPv6NIReplyIPv6(data=[(42, "2001:db8::1"), "2001:db8::2"]).data == [(42, "2001:db8::1"), (0, "2001:db8::2")] 3182*7dc08ffcSJunyu Lai 3183*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv6 - build & dissection 3184*7dc08ffcSJunyu Lai 3185*7dc08ffcSJunyu Lais = raw(IPv6()/ICMPv6NIReplyIPv6(data="2001:db8::1")) 3186*7dc08ffcSJunyu Laip = IPv6(s) 3187*7dc08ffcSJunyu LaiICMPv6NIReplyIPv6 in p and p.data == [(0, '2001:db8::1')] 3188*7dc08ffcSJunyu Lai 3189*7dc08ffcSJunyu Lai############ 3190*7dc08ffcSJunyu Lai############ 3191*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIReplyIPv4 3192*7dc08ffcSJunyu Lai 3193*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - one IPv4 address without TTL (internal) 3194*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv4(data="169.254.253.252").getfieldval("data") 3195*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 4 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "169.254.253.252" 3196*7dc08ffcSJunyu Lai 3197*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - one IPv4 address without TTL 3198*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4(data="169.254.253.252").data == [(0, '169.254.253.252')] 3199*7dc08ffcSJunyu Lai 3200*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - one IPv4 address without TTL (as a list) (internal) 3201*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv4(data=["169.254.253.252"]).getfieldval("data") 3202*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 4 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "169.254.253.252" 3203*7dc08ffcSJunyu Lai 3204*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - one IPv4 address without TTL (as a list) 3205*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4(data=["169.254.253.252"]).data == [(0, '169.254.253.252')] 3206*7dc08ffcSJunyu Lai 3207*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - one IPv4 address with TTL (internal) 3208*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv4(data=[(0, "169.254.253.252")]).getfieldval("data") 3209*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 4 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "169.254.253.252" 3210*7dc08ffcSJunyu Lai 3211*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - one IPv4 address with TTL (internal) 3212*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4(data=[(0, "169.254.253.252")]).data == [(0, '169.254.253.252')] 3213*7dc08ffcSJunyu Lai 3214*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - two IPv4 addresses as a list of rawings (without TTL) 3215*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv4(data=["169.254.253.252", "169.254.253.253"]).getfieldval("data") 3216*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 4 and type(a[1]) is list and len(a[1]) == 2 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "169.254.253.252" and len(a[1][1]) == 2 and a[1][1][0] == 0 and a[1][1][1] == "169.254.253.253" 3217*7dc08ffcSJunyu Lai 3218*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - two IPv4 addresses as a list of rawings (without TTL) (internal) 3219*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4(data=["169.254.253.252", "169.254.253.253"]).data == [(0, '169.254.253.252'), (0, '169.254.253.253')] 3220*7dc08ffcSJunyu Lai 3221*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - two IPv4 addresses as a list (first with ttl, second without) 3222*7dc08ffcSJunyu Laia=ICMPv6NIReplyIPv4(data=[(42, "169.254.253.252"), "169.254.253.253"]).getfieldval("data") 3223*7dc08ffcSJunyu Laitype(a) is tuple and len(a) == 2 and a[0] == 4 and type(a[1]) is list and len(a[1]) == 2 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 42 and a[1][0][1] == "169.254.253.252" and len(a[1][1]) == 2 and a[1][1][0] == 0 and a[1][1][1] == "169.254.253.253" 3224*7dc08ffcSJunyu Lai 3225*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - two IPv4 addresses as a list (first with ttl, second without) (internal) 3226*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4(data=[(42, "169.254.253.252"), "169.254.253.253"]).data == [(42, "169.254.253.252"), (0, "169.254.253.253")] 3227*7dc08ffcSJunyu Lai 3228*7dc08ffcSJunyu Lai= ICMPv6NIReplyIPv4 - build & dissection 3229*7dc08ffcSJunyu Lai 3230*7dc08ffcSJunyu Lais = raw(IPv6()/ICMPv6NIReplyIPv4(data="192.168.0.1")) 3231*7dc08ffcSJunyu Laip = IPv6(s) 3232*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4 in p and p.data == [(0, '192.168.0.1')] 3233*7dc08ffcSJunyu Lai 3234*7dc08ffcSJunyu Lais = raw(IPv6()/ICMPv6NIReplyIPv4(data=[(2807, "192.168.0.1")])) 3235*7dc08ffcSJunyu Laip = IPv6(s) 3236*7dc08ffcSJunyu LaiICMPv6NIReplyIPv4 in p and p.data == [(2807, "192.168.0.1")] 3237*7dc08ffcSJunyu Lai 3238*7dc08ffcSJunyu Lai 3239*7dc08ffcSJunyu Lai############ 3240*7dc08ffcSJunyu Lai############ 3241*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIReplyRefuse 3242*7dc08ffcSJunyu Lai= ICMPv6NIReplyRefuse - basic instantiation 3243*7dc08ffcSJunyu Lairaw(ICMPv6NIReplyRefuse())[:8] == b'\x8c\x01\x00\x00\x00\x00\x00\x00' 3244*7dc08ffcSJunyu Lai 3245*7dc08ffcSJunyu Lai= ICMPv6NIReplyRefuse - basic dissection 3246*7dc08ffcSJunyu Laia=ICMPv6NIReplyRefuse(b'\x8c\x01\x00\x00\x00\x00\x00\x00\xf1\xe9\xab\xc9\x8c\x0by\x18') 3247*7dc08ffcSJunyu Laia.type == 140 and a.code == 1 and a.cksum == 0 and a.unused == 0 and a.flags == 0 and a.nonce == b'\xf1\xe9\xab\xc9\x8c\x0by\x18' and a.data == None 3248*7dc08ffcSJunyu Lai 3249*7dc08ffcSJunyu Lai 3250*7dc08ffcSJunyu Lai############ 3251*7dc08ffcSJunyu Lai############ 3252*7dc08ffcSJunyu Lai+ Test Node Information Query - ICMPv6NIReplyUnknown 3253*7dc08ffcSJunyu Lai 3254*7dc08ffcSJunyu Lai= ICMPv6NIReplyUnknown - basic instantiation 3255*7dc08ffcSJunyu Lairaw(ICMPv6NIReplyUnknown(nonce=b'\x00'*8)) == b'\x8c\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3256*7dc08ffcSJunyu Lai 3257*7dc08ffcSJunyu Lai= ICMPv6NIReplyRefuse - basic dissection 3258*7dc08ffcSJunyu Laia=ICMPv6NIReplyRefuse(b'\x8c\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3259*7dc08ffcSJunyu Laia.type == 140 and a.code == 2 and a.cksum == 0 and a.unused == 0 and a.flags == 0 and a.nonce == b'\x00'*8 and a.data == None 3260*7dc08ffcSJunyu Lai 3261*7dc08ffcSJunyu Lai 3262*7dc08ffcSJunyu Lai############ 3263*7dc08ffcSJunyu Lai############ 3264*7dc08ffcSJunyu Lai+ Test Node Information Query - utilities 3265*7dc08ffcSJunyu Lai 3266*7dc08ffcSJunyu Lai= computeNIGroupAddr 3267*7dc08ffcSJunyu LaicomputeNIGroupAddr("scapy") == "ff02::2:f886:2f66" 3268*7dc08ffcSJunyu Lai 3269*7dc08ffcSJunyu Lai 3270*7dc08ffcSJunyu Lai############ 3271*7dc08ffcSJunyu Lai############ 3272*7dc08ffcSJunyu Lai+ IPv6ExtHdrFragment Class Test 3273*7dc08ffcSJunyu Lai 3274*7dc08ffcSJunyu Lai= IPv6ExtHdrFragment - Basic Instantiation 3275*7dc08ffcSJunyu Lairaw(IPv6ExtHdrFragment()) == b';\x00\x00\x00\x00\x00\x00\x00' 3276*7dc08ffcSJunyu Lai 3277*7dc08ffcSJunyu Lai= IPv6ExtHdrFragment - Instantiation with specific values 3278*7dc08ffcSJunyu Lairaw(IPv6ExtHdrFragment(nh=0xff, res1=0xee, offset=0x1fff, res2=1, m=1, id=0x11111111)) == b'\xff\xee\xff\xfb\x11\x11\x11\x11' 3279*7dc08ffcSJunyu Lai 3280*7dc08ffcSJunyu Lai= IPv6ExtHdrFragment - Basic Dissection 3281*7dc08ffcSJunyu Laia=IPv6ExtHdrFragment(b';\x00\x00\x00\x00\x00\x00\x00') 3282*7dc08ffcSJunyu Laia.nh == 59 and a.res1 == 0 and a.offset == 0 and a.res2 == 0 and a.m == 0 and a.id == 0 3283*7dc08ffcSJunyu Lai 3284*7dc08ffcSJunyu Lai= IPv6ExtHdrFragment - Instantiation with specific values 3285*7dc08ffcSJunyu Laia=IPv6ExtHdrFragment(b'\xff\xee\xff\xfb\x11\x11\x11\x11') 3286*7dc08ffcSJunyu Laia.nh == 0xff and a.res1 == 0xee and a.offset==0x1fff and a.res2==1 and a.m == 1 and a.id == 0x11111111 3287*7dc08ffcSJunyu Lai 3288*7dc08ffcSJunyu Lai 3289*7dc08ffcSJunyu Lai############ 3290*7dc08ffcSJunyu Lai############ 3291*7dc08ffcSJunyu Lai+ Test fragment6 function 3292*7dc08ffcSJunyu Lai 3293*7dc08ffcSJunyu Lai= fragment6 - test against a long TCP packet with a 1280 MTU 3294*7dc08ffcSJunyu Lail=fragment6(IPv6()/IPv6ExtHdrFragment()/TCP()/Raw(load="A"*40000), 1280) 3295*7dc08ffcSJunyu Lailen(l) == 33 and len(raw(l[-1])) == 644 3296*7dc08ffcSJunyu Lai 3297*7dc08ffcSJunyu Lai 3298*7dc08ffcSJunyu Lai############ 3299*7dc08ffcSJunyu Lai############ 3300*7dc08ffcSJunyu Lai+ Test defragment6 function 3301*7dc08ffcSJunyu Lai 3302*7dc08ffcSJunyu Lai= defragment6 - test against a long TCP packet fragmented with a 1280 MTU 3303*7dc08ffcSJunyu Lail=fragment6(IPv6()/IPv6ExtHdrFragment()/TCP()/Raw(load="A"*40000), 1280) 3304*7dc08ffcSJunyu Lairaw(defragment6(l)) == (b'`\x00\x00\x00\x9cT\x06@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\xe92\x00\x00' + b'A'*40000) 3305*7dc08ffcSJunyu Lai 3306*7dc08ffcSJunyu Lai 3307*7dc08ffcSJunyu Lai= defragment6 - test against a large TCP packet fragmented with a 1280 bytes MTU and missing fragments 3308*7dc08ffcSJunyu Lail=fragment6(IPv6()/IPv6ExtHdrFragment()/TCP()/Raw(load="A"*40000), 1280) 3309*7dc08ffcSJunyu Laidel(l[2]) 3310*7dc08ffcSJunyu Laidel(l[4]) 3311*7dc08ffcSJunyu Laidel(l[12]) 3312*7dc08ffcSJunyu Laidel(l[18]) 3313*7dc08ffcSJunyu Lairaw(defragment6(l)) == (b'`\x00\x00\x00\x9cT\x06@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\xe92\x00\x00' + 2444*b'A' + 1232*b'X' + 2464*b'A' + 1232*b'X' + 9856*b'A' + 1232*b'X' + 7392*b'A' + 1232*b'X' + 12916*b'A') 3314*7dc08ffcSJunyu Lai 3315*7dc08ffcSJunyu Lai 3316*7dc08ffcSJunyu Lai= defragment6 - test against a TCP packet fragmented with a 800 bytes MTU and missing fragments 3317*7dc08ffcSJunyu Lail=fragment6(IPv6()/IPv6ExtHdrFragment()/TCP()/Raw(load="A"*4000), 800) 3318*7dc08ffcSJunyu Laidel(l[4]) 3319*7dc08ffcSJunyu Laidel(l[2]) 3320*7dc08ffcSJunyu Lairaw(defragment6(l)) == b'`\x00\x00\x00\x0f\xb4\x06@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\xb2\x0f\x00\x00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' 3321*7dc08ffcSJunyu Lai 3322*7dc08ffcSJunyu Lai 3323*7dc08ffcSJunyu Lai############ 3324*7dc08ffcSJunyu Lai############ 3325*7dc08ffcSJunyu Lai+ Test Route6 class 3326*7dc08ffcSJunyu Lai 3327*7dc08ffcSJunyu Lai= Route6 - Route6 flushing 3328*7dc08ffcSJunyu Laiconf.route6.routes=[ 3329*7dc08ffcSJunyu Lai( '::1', 128, '::', 'lo', ['::1'], 1), 3330*7dc08ffcSJunyu Lai( 'fe80::20f:1fff:feca:4650', 128, '::', 'lo', ['::1'], 1)] 3331*7dc08ffcSJunyu Laiconf.route6.flush() 3332*7dc08ffcSJunyu Lainot conf.route6.routes 3333*7dc08ffcSJunyu Lai 3334*7dc08ffcSJunyu Lai= Route6 - Route6.route 3335*7dc08ffcSJunyu Laiconf.route6.flush() 3336*7dc08ffcSJunyu Laiconf.route6.routes=[ 3337*7dc08ffcSJunyu Lai( '::1', 128, '::', 'lo', ['::1'], 1), 3338*7dc08ffcSJunyu Lai( 'fe80::20f:1fff:feca:4650', 128, '::', 'lo', ['::1'], 1), 3339*7dc08ffcSJunyu Lai( 'fe80::', 64, '::', 'eth0', ['fe80::20f:1fff:feca:4650'], 1), 3340*7dc08ffcSJunyu Lai('2001:db8:0:4444:20f:1fff:feca:4650', 128, '::', 'lo', ['::1'], 1), 3341*7dc08ffcSJunyu Lai( '2001:db8:0:4444::', 64, '::', 'eth0', ['2001:db8:0:4444:20f:1fff:feca:4650'], 1), 3342*7dc08ffcSJunyu Lai( '::', 0, 'fe80::20f:34ff:fe8a:8aa1', 'eth0', ['2001:db8:0:4444:20f:1fff:feca:4650', '2002:db8:0:4444:20f:1fff:feca:4650'], 1) 3343*7dc08ffcSJunyu Lai] 3344*7dc08ffcSJunyu Laiconf.route6.route("2002::1") == ('eth0', '2002:db8:0:4444:20f:1fff:feca:4650', 'fe80::20f:34ff:fe8a:8aa1') and conf.route6.route("2001::1") == ('eth0', '2001:db8:0:4444:20f:1fff:feca:4650', 'fe80::20f:34ff:fe8a:8aa1') and conf.route6.route("fe80::20f:1fff:feab:4870") == ('eth0', 'fe80::20f:1fff:feca:4650', '::') and conf.route6.route("::1") == ('lo', '::1', '::') and conf.route6.route("::") == ('eth0', '2001:db8:0:4444:20f:1fff:feca:4650', 'fe80::20f:34ff:fe8a:8aa1') and conf.route6.route('ff00::') == ('eth0', '2001:db8:0:4444:20f:1fff:feca:4650', 'fe80::20f:34ff:fe8a:8aa1') 3345*7dc08ffcSJunyu Laiconf.route6.resync() 3346*7dc08ffcSJunyu Laiif not len(conf.route6.routes): 3347*7dc08ffcSJunyu Lai # IPv6 seems disabled. Force a route to ::1 3348*7dc08ffcSJunyu Lai conf.route6.routes.append(("::1", 128, "::", LOOPBACK_NAME, ["::1"], 1)) 3349*7dc08ffcSJunyu Lai True 3350*7dc08ffcSJunyu Lai 3351*7dc08ffcSJunyu Lai= Route6 - Route6.make_route 3352*7dc08ffcSJunyu Lai 3353*7dc08ffcSJunyu Lair6 = Route6() 3354*7dc08ffcSJunyu Lair6.make_route("2001:db8::1", dev=LOOPBACK_NAME) == ("2001:db8::1", 128, "::", LOOPBACK_NAME, [], 1) 3355*7dc08ffcSJunyu Lailen_r6 = len(r6.routes) 3356*7dc08ffcSJunyu Lai 3357*7dc08ffcSJunyu Lai= Route6 - Route6.add & Route6.delt 3358*7dc08ffcSJunyu Lai 3359*7dc08ffcSJunyu Lair6.add(dst="2001:db8:cafe:f000::/64", gw="2001:db8:cafe::1", dev="eth0") 3360*7dc08ffcSJunyu Laiassert(len(r6.routes) == len_r6 + 1) 3361*7dc08ffcSJunyu Lair6.delt(dst="2001:db8:cafe:f000::/64", gw="2001:db8:cafe::1") 3362*7dc08ffcSJunyu Laiassert(len(r6.routes) == len_r6) 3363*7dc08ffcSJunyu Lai 3364*7dc08ffcSJunyu Lai= Route6 - Route6.ifadd & Route6.ifdel 3365*7dc08ffcSJunyu Lair6.ifadd("scapy0", "2001:bd8:cafe:1::1/64") 3366*7dc08ffcSJunyu Lair6.ifdel("scapy0") 3367*7dc08ffcSJunyu Lai 3368*7dc08ffcSJunyu Lai= IPv6 - utils 3369*7dc08ffcSJunyu Lai 3370*7dc08ffcSJunyu Lai@mock.patch("scapy.layers.inet6.get_if_hwaddr") 3371*7dc08ffcSJunyu Lai@mock.patch("scapy.layers.inet6.srp1") 3372*7dc08ffcSJunyu Laidef test_neighsol(mock_srp1, mock_get_if_hwaddr): 3373*7dc08ffcSJunyu Lai mock_srp1.return_value = Ether()/IPv6()/ICMPv6ND_NA()/ICMPv6NDOptDstLLAddr(lladdr="05:04:03:02:01:00") 3374*7dc08ffcSJunyu Lai mock_get_if_hwaddr.return_value = "00:01:02:03:04:05" 3375*7dc08ffcSJunyu Lai return neighsol("fe80::f6ce:46ff:fea9:e04b", "fe80::f6ce:46ff:fea9:e04b", "scapy0") 3376*7dc08ffcSJunyu Lai 3377*7dc08ffcSJunyu Laip = test_neighsol() 3378*7dc08ffcSJunyu LaiICMPv6NDOptDstLLAddr in p and p[ICMPv6NDOptDstLLAddr].lladdr == "05:04:03:02:01:00" 3379*7dc08ffcSJunyu Lai 3380*7dc08ffcSJunyu Lai 3381*7dc08ffcSJunyu Lai@mock.patch("scapy.layers.inet6.neighsol") 3382*7dc08ffcSJunyu Lai@mock.patch("scapy.layers.inet6.conf.route6.route") 3383*7dc08ffcSJunyu Laidef test_getmacbyip6(mock_route6, mock_neighsol): 3384*7dc08ffcSJunyu Lai mock_route6.return_value = ("scapy0", "fe80::baca:3aff:fe72:b08b", "::") 3385*7dc08ffcSJunyu Lai mock_neighsol.return_value = test_neighsol() 3386*7dc08ffcSJunyu Lai return getmacbyip6("fe80::704:3ff:fe2:100") 3387*7dc08ffcSJunyu Lai 3388*7dc08ffcSJunyu Laitest_getmacbyip6() == "05:04:03:02:01:00" 3389*7dc08ffcSJunyu Lai 3390*7dc08ffcSJunyu Lai= IPv6 - IPerror6 & UDPerror & _ICMPv6Error 3391*7dc08ffcSJunyu Lai 3392*7dc08ffcSJunyu Laiquery = IPv6(dst="2001:db8::1", src="2001:db8::2", hlim=1)/UDP()/DNS() 3393*7dc08ffcSJunyu Laianswer = IPv6(dst="2001:db8::2", src="2001:db8::1", hlim=1)/ICMPv6TimeExceeded()/IPerror6(dst="2001:db8::1", src="2001:db8::2", hlim=0)/UDPerror()/DNS() 3394*7dc08ffcSJunyu Laianswer.answers(query) == True 3395*7dc08ffcSJunyu Lai 3396*7dc08ffcSJunyu Lai# Test _ICMPv6Error 3397*7dc08ffcSJunyu Laifrom scapy.layers.inet6 import _ICMPv6Error 3398*7dc08ffcSJunyu Laiassert _ICMPv6Error().guess_payload_class(None) == IPerror6 3399*7dc08ffcSJunyu Lai 3400*7dc08ffcSJunyu Lai############ 3401*7dc08ffcSJunyu Lai############ 3402*7dc08ffcSJunyu Lai+ ICMPv6ML 3403*7dc08ffcSJunyu Lai 3404*7dc08ffcSJunyu Lai= ICMPv6MLQuery - build & dissection 3405*7dc08ffcSJunyu Lais = raw(IPv6()/ICMPv6MLQuery()) 3406*7dc08ffcSJunyu Lais == b"`\x00\x00\x00\x00\x18:\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xba\xca:\xff\xfer\xb0\x8b\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x82\x00\xb4O'\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 3407*7dc08ffcSJunyu Lai 3408*7dc08ffcSJunyu Laip = IPv6(s) 3409*7dc08ffcSJunyu LaiICMPv6MLQuery in p and p[IPv6].dst == "ff02::1" 3410*7dc08ffcSJunyu Lai 3411*7dc08ffcSJunyu Lai############ 3412*7dc08ffcSJunyu Lai############ 3413*7dc08ffcSJunyu Lai+ Ether tests with IPv6 3414*7dc08ffcSJunyu Lai 3415*7dc08ffcSJunyu Lai= Ether IPv6 checking for dst 3416*7dc08ffcSJunyu Lai~ netaccess ipv6 3417*7dc08ffcSJunyu Lai 3418*7dc08ffcSJunyu Laip = Ether()/IPv6(dst="www.google.com")/TCP() 3419*7dc08ffcSJunyu Laiassert p.dst != p[IPv6].dst 3420*7dc08ffcSJunyu Laip.show() 3421*7dc08ffcSJunyu Lai 3422*7dc08ffcSJunyu Lai############ 3423*7dc08ffcSJunyu Lai############ 3424*7dc08ffcSJunyu Lai+ TracerouteResult6 3425*7dc08ffcSJunyu Lai 3426*7dc08ffcSJunyu Lai= get_trace() 3427*7dc08ffcSJunyu Laiip6_hlim = [("2001:db8::%d" % i, i) for i in six.moves.range(1, 12)] 3428*7dc08ffcSJunyu Lai 3429*7dc08ffcSJunyu Laitr6_packets = [ (IPv6(dst="2001:db8::1", src="2001:db8::254", hlim=hlim)/UDP()/"scapy", 3430*7dc08ffcSJunyu Lai IPv6(dst="2001:db8::254", src=ip)/ICMPv6TimeExceeded()/IPerror6(dst="2001:db8::1", src="2001:db8::254", hlim=0)/UDPerror()/"scapy") 3431*7dc08ffcSJunyu Lai for (ip, hlim) in ip6_hlim ] 3432*7dc08ffcSJunyu Lai 3433*7dc08ffcSJunyu Laitr6 = TracerouteResult6(tr6_packets) 3434*7dc08ffcSJunyu Laitr6.get_trace() == {'2001:db8::1': {1: ('2001:db8::1', False), 2: ('2001:db8::2', False), 3: ('2001:db8::3', False), 4: ('2001:db8::4', False), 5: ('2001:db8::5', False), 6: ('2001:db8::6', False), 7: ('2001:db8::7', False), 8: ('2001:db8::8', False), 9: ('2001:db8::9', False), 10: ('2001:db8::10', False), 11: ('2001:db8::11', False)}} 3435*7dc08ffcSJunyu Lai 3436*7dc08ffcSJunyu Lai= show() 3437*7dc08ffcSJunyu Laidef test_show(): 3438*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 3439*7dc08ffcSJunyu Lai tr6 = TracerouteResult6(tr6_packets) 3440*7dc08ffcSJunyu Lai tr6.show() 3441*7dc08ffcSJunyu Lai result = cmco.get_output() 3442*7dc08ffcSJunyu Lai expected = " 2001:db8::1 :udpdomain \n" 3443*7dc08ffcSJunyu Lai expected += "1 2001:db8::1 3 \n" 3444*7dc08ffcSJunyu Lai expected += "2 2001:db8::2 3 \n" 3445*7dc08ffcSJunyu Lai expected += "3 2001:db8::3 3 \n" 3446*7dc08ffcSJunyu Lai expected += "4 2001:db8::4 3 \n" 3447*7dc08ffcSJunyu Lai expected += "5 2001:db8::5 3 \n" 3448*7dc08ffcSJunyu Lai expected += "6 2001:db8::6 3 \n" 3449*7dc08ffcSJunyu Lai expected += "7 2001:db8::7 3 \n" 3450*7dc08ffcSJunyu Lai expected += "8 2001:db8::8 3 \n" 3451*7dc08ffcSJunyu Lai expected += "9 2001:db8::9 3 \n" 3452*7dc08ffcSJunyu Lai expected += "10 2001:db8::10 3 \n" 3453*7dc08ffcSJunyu Lai expected += "11 2001:db8::11 3 \n" 3454*7dc08ffcSJunyu Lai index_result = result.index("\n1") 3455*7dc08ffcSJunyu Lai index_expected = expected.index("\n1") 3456*7dc08ffcSJunyu Lai assert(result[index_result:] == expected[index_expected:]) 3457*7dc08ffcSJunyu Lai 3458*7dc08ffcSJunyu Laitest_show() 3459*7dc08ffcSJunyu Lai 3460*7dc08ffcSJunyu Lai= graph() 3461*7dc08ffcSJunyu Laisaved_AS_resolver = conf.AS_resolver 3462*7dc08ffcSJunyu Laiconf.AS_resolver = None 3463*7dc08ffcSJunyu Laitr6.make_graph() 3464*7dc08ffcSJunyu Lailen(tr6.graphdef) == 492 3465*7dc08ffcSJunyu Laitr6.graphdef.startswith("digraph trace {") == True 3466*7dc08ffcSJunyu Lai'"2001:db8::1 53/udp";' in tr6.graphdef 3467*7dc08ffcSJunyu Laiconf.AS_resolver = conf.AS_resolver 3468*7dc08ffcSJunyu Lai 3469*7dc08ffcSJunyu Lai 3470*7dc08ffcSJunyu Lai# Below is our Homework : here is the mountain ... 3471*7dc08ffcSJunyu Lai# 3472*7dc08ffcSJunyu Lai 3473*7dc08ffcSJunyu Lai########### ICMPv6MLReport Class #################################### 3474*7dc08ffcSJunyu Lai########### ICMPv6MLDone Class ###################################### 3475*7dc08ffcSJunyu Lai########### ICMPv6ND_Redirect Class ################################# 3476*7dc08ffcSJunyu Lai########### ICMPv6NDOptSrcAddrList Class ############################ 3477*7dc08ffcSJunyu Lai########### ICMPv6NDOptTgtAddrList Class ############################ 3478*7dc08ffcSJunyu Lai########### ICMPv6ND_INDSol Class ################################### 3479*7dc08ffcSJunyu Lai########### ICMPv6ND_INDAdv Class ################################### 3480*7dc08ffcSJunyu Lai 3481*7dc08ffcSJunyu Lai 3482*7dc08ffcSJunyu Lai 3483*7dc08ffcSJunyu Lai 3484*7dc08ffcSJunyu Lai 3485*7dc08ffcSJunyu Lai##################################################################### 3486*7dc08ffcSJunyu Lai##################################################################### 3487*7dc08ffcSJunyu Lai########################## DHCPv6 ########################## 3488*7dc08ffcSJunyu Lai##################################################################### 3489*7dc08ffcSJunyu Lai##################################################################### 3490*7dc08ffcSJunyu Lai 3491*7dc08ffcSJunyu Lai 3492*7dc08ffcSJunyu Lai############ 3493*7dc08ffcSJunyu Lai############ 3494*7dc08ffcSJunyu Lai+ Test DHCP6 DUID_LLT 3495*7dc08ffcSJunyu Lai 3496*7dc08ffcSJunyu Lai= DUID_LLT basic instantiation 3497*7dc08ffcSJunyu Laia=DUID_LLT() 3498*7dc08ffcSJunyu Lai 3499*7dc08ffcSJunyu Lai= DUID_LLT basic build 3500*7dc08ffcSJunyu Lairaw(DUID_LLT()) == b'\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3501*7dc08ffcSJunyu Lai 3502*7dc08ffcSJunyu Lai= DUID_LLT build with specific values 3503*7dc08ffcSJunyu Lairaw(DUID_LLT(lladdr="ff:ff:ff:ff:ff:ff", timeval=0x11111111, hwtype=0x2222)) == b'\x00\x01""\x11\x11\x11\x11\xff\xff\xff\xff\xff\xff' 3504*7dc08ffcSJunyu Lai 3505*7dc08ffcSJunyu Lai= DUID_LLT basic dissection 3506*7dc08ffcSJunyu Laia=DUID_LLT(raw(DUID_LLT())) 3507*7dc08ffcSJunyu Laia.type == 1 and a.hwtype == 1 and a.timeval == 0 and a.lladdr == "00:00:00:00:00:00" 3508*7dc08ffcSJunyu Lai 3509*7dc08ffcSJunyu Lai= DUID_LLT dissection with specific values 3510*7dc08ffcSJunyu Laia=DUID_LLT(b'\x00\x01""\x11\x11\x11\x11\xff\xff\xff\xff\xff\xff') 3511*7dc08ffcSJunyu Laia.type == 1 and a.hwtype == 0x2222 and a.timeval == 0x11111111 and a.lladdr == "ff:ff:ff:ff:ff:ff" 3512*7dc08ffcSJunyu Lai 3513*7dc08ffcSJunyu Lai 3514*7dc08ffcSJunyu Lai############ 3515*7dc08ffcSJunyu Lai############ 3516*7dc08ffcSJunyu Lai+ Test DHCP6 DUID_EN 3517*7dc08ffcSJunyu Lai 3518*7dc08ffcSJunyu Lai= DUID_EN basic instantiation 3519*7dc08ffcSJunyu Laia=DUID_EN() 3520*7dc08ffcSJunyu Lai 3521*7dc08ffcSJunyu Lai= DUID_EN basic build 3522*7dc08ffcSJunyu Lairaw(DUID_EN()) == b'\x00\x02\x00\x00\x017' 3523*7dc08ffcSJunyu Lai 3524*7dc08ffcSJunyu Lai= DUID_EN build with specific values 3525*7dc08ffcSJunyu Lairaw(DUID_EN(enterprisenum=0x11111111, id="iamastring")) == b'\x00\x02\x11\x11\x11\x11iamastring' 3526*7dc08ffcSJunyu Lai 3527*7dc08ffcSJunyu Lai= DUID_EN basic dissection 3528*7dc08ffcSJunyu Laia=DUID_EN(b'\x00\x02\x00\x00\x017') 3529*7dc08ffcSJunyu Laia.type == 2 and a.enterprisenum == 311 3530*7dc08ffcSJunyu Lai 3531*7dc08ffcSJunyu Lai= DUID_EN dissection with specific values 3532*7dc08ffcSJunyu Laia=DUID_EN(b'\x00\x02\x11\x11\x11\x11iamarawing') 3533*7dc08ffcSJunyu Laia.type == 2 and a.enterprisenum == 0x11111111 and a.id == b"iamarawing" 3534*7dc08ffcSJunyu Lai 3535*7dc08ffcSJunyu Lai 3536*7dc08ffcSJunyu Lai############ 3537*7dc08ffcSJunyu Lai############ 3538*7dc08ffcSJunyu Lai+ Test DHCP6 DUID_LL 3539*7dc08ffcSJunyu Lai 3540*7dc08ffcSJunyu Lai= DUID_LL basic instantiation 3541*7dc08ffcSJunyu Laia=DUID_LL() 3542*7dc08ffcSJunyu Lai 3543*7dc08ffcSJunyu Lai= DUID_LL basic build 3544*7dc08ffcSJunyu Lairaw(DUID_LL()) == b'\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00' 3545*7dc08ffcSJunyu Lai 3546*7dc08ffcSJunyu Lai= DUID_LL build with specific values 3547*7dc08ffcSJunyu Lairaw(DUID_LL(hwtype=1, lladdr="ff:ff:ff:ff:ff:ff")) == b'\x00\x03\x00\x01\xff\xff\xff\xff\xff\xff' 3548*7dc08ffcSJunyu Lai 3549*7dc08ffcSJunyu Lai= DUID_LL basic dissection 3550*7dc08ffcSJunyu Laia=DUID_LL(raw(DUID_LL())) 3551*7dc08ffcSJunyu Laia.type == 3 and a.hwtype == 1 and a.lladdr == "00:00:00:00:00:00" 3552*7dc08ffcSJunyu Lai 3553*7dc08ffcSJunyu Lai= DUID_LL with specific values 3554*7dc08ffcSJunyu Laia=DUID_LL(b'\x00\x03\x00\x01\xff\xff\xff\xff\xff\xff') 3555*7dc08ffcSJunyu Laia.hwtype == 1 and a.lladdr == "ff:ff:ff:ff:ff:ff" 3556*7dc08ffcSJunyu Lai 3557*7dc08ffcSJunyu Lai 3558*7dc08ffcSJunyu Lai############ 3559*7dc08ffcSJunyu Lai############ 3560*7dc08ffcSJunyu Lai+ Test DHCP6 Opt Unknown 3561*7dc08ffcSJunyu Lai 3562*7dc08ffcSJunyu Lai= DHCP6 Opt Unknown basic instantiation 3563*7dc08ffcSJunyu Laia=DHCP6OptUnknown() 3564*7dc08ffcSJunyu Lai 3565*7dc08ffcSJunyu Lai= DHCP6 Opt Unknown basic build (default values) 3566*7dc08ffcSJunyu Lairaw(DHCP6OptUnknown()) == b'\x00\x00\x00\x00' 3567*7dc08ffcSJunyu Lai 3568*7dc08ffcSJunyu Lai= DHCP6 Opt Unknown - len computation test 3569*7dc08ffcSJunyu Lairaw(DHCP6OptUnknown(data="shouldbe9")) == b'\x00\x00\x00\tshouldbe9' 3570*7dc08ffcSJunyu Lai 3571*7dc08ffcSJunyu Lai 3572*7dc08ffcSJunyu Lai############ 3573*7dc08ffcSJunyu Lai############ 3574*7dc08ffcSJunyu Lai+ Test DHCP6 Client Identifier option 3575*7dc08ffcSJunyu Lai 3576*7dc08ffcSJunyu Lai= DHCP6OptClientId basic instantiation 3577*7dc08ffcSJunyu Laia=DHCP6OptClientId() 3578*7dc08ffcSJunyu Lai 3579*7dc08ffcSJunyu Lai= DHCP6OptClientId basic build 3580*7dc08ffcSJunyu Lairaw(DHCP6OptClientId()) == b'\x00\x01\x00\x00' 3581*7dc08ffcSJunyu Lai 3582*7dc08ffcSJunyu Lai= DHCP6OptClientId instantiation with specific values 3583*7dc08ffcSJunyu Lairaw(DHCP6OptClientId(duid="toto")) == b'\x00\x01\x00\x04toto' 3584*7dc08ffcSJunyu Lai 3585*7dc08ffcSJunyu Lai= DHCP6OptClientId instantiation with DUID_LL 3586*7dc08ffcSJunyu Lairaw(DHCP6OptClientId(duid=DUID_LL())) == b'\x00\x01\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00' 3587*7dc08ffcSJunyu Lai 3588*7dc08ffcSJunyu Lai= DHCP6OptClientId instantiation with DUID_LLT 3589*7dc08ffcSJunyu Lairaw(DHCP6OptClientId(duid=DUID_LLT())) == b'\x00\x01\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3590*7dc08ffcSJunyu Lai 3591*7dc08ffcSJunyu Lai= DHCP6OptClientId instantiation with DUID_EN 3592*7dc08ffcSJunyu Lairaw(DHCP6OptClientId(duid=DUID_EN())) == b'\x00\x01\x00\x06\x00\x02\x00\x00\x017' 3593*7dc08ffcSJunyu Lai 3594*7dc08ffcSJunyu Lai= DHCP6OptClientId instantiation with specified length 3595*7dc08ffcSJunyu Lairaw(DHCP6OptClientId(optlen=80, duid="somestring")) == b'\x00\x01\x00Psomestring' 3596*7dc08ffcSJunyu Lai 3597*7dc08ffcSJunyu Lai= DHCP6OptClientId basic dissection 3598*7dc08ffcSJunyu Laia=DHCP6OptClientId(b'\x00\x01\x00\x00') 3599*7dc08ffcSJunyu Laia.optcode == 1 and a.optlen == 0 3600*7dc08ffcSJunyu Lai 3601*7dc08ffcSJunyu Lai= DHCP6OptClientId instantiation with specified length 3602*7dc08ffcSJunyu Lairaw(DHCP6OptClientId(optlen=80, duid="somestring")) == b'\x00\x01\x00Psomestring' 3603*7dc08ffcSJunyu Lai 3604*7dc08ffcSJunyu Lai= DHCP6OptClientId basic dissection 3605*7dc08ffcSJunyu Laia=DHCP6OptClientId(b'\x00\x01\x00\x00') 3606*7dc08ffcSJunyu Laia.optcode == 1 and a.optlen == 0 3607*7dc08ffcSJunyu Lai 3608*7dc08ffcSJunyu Lai= DHCP6OptClientId dissection with specific duid value 3609*7dc08ffcSJunyu Laia=DHCP6OptClientId(b'\x00\x01\x00\x04somerawing') 3610*7dc08ffcSJunyu Laia.optcode == 1 and a.optlen == 4 and isinstance(a.duid, Raw) and a.duid.load == b'some' and isinstance(a.payload, DHCP6OptUnknown) 3611*7dc08ffcSJunyu Lai 3612*7dc08ffcSJunyu Lai= DHCP6OptClientId dissection with specific DUID_LL as duid value 3613*7dc08ffcSJunyu Laia=DHCP6OptClientId(b'\x00\x01\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00') 3614*7dc08ffcSJunyu Laia.optcode == 1 and a.optlen == 10 and isinstance(a.duid, DUID_LL) and a.duid.type == 3 and a.duid.hwtype == 1 and a.duid.lladdr == "00:00:00:00:00:00" 3615*7dc08ffcSJunyu Lai 3616*7dc08ffcSJunyu Lai= DHCP6OptClientId dissection with specific DUID_LLT as duid value 3617*7dc08ffcSJunyu Laia=DHCP6OptClientId(b'\x00\x01\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3618*7dc08ffcSJunyu Laia.optcode == 1 and a.optlen == 14 and isinstance(a.duid, DUID_LLT) and a.duid.type == 1 and a.duid.hwtype == 1 and a.duid.timeval == 0 and a.duid.lladdr == "00:00:00:00:00:00" 3619*7dc08ffcSJunyu Lai 3620*7dc08ffcSJunyu Lai= DHCP6OptClientId dissection with specific DUID_EN as duid value 3621*7dc08ffcSJunyu Laia=DHCP6OptClientId(b'\x00\x01\x00\x06\x00\x02\x00\x00\x017') 3622*7dc08ffcSJunyu Laia.optcode == 1 and a.optlen == 6 and isinstance(a.duid, DUID_EN) and a.duid.type == 2 and a.duid.enterprisenum == 311 and a.duid.id == b"" 3623*7dc08ffcSJunyu Lai 3624*7dc08ffcSJunyu Lai 3625*7dc08ffcSJunyu Lai############ 3626*7dc08ffcSJunyu Lai############ 3627*7dc08ffcSJunyu Lai+ Test DHCP6 Server Identifier option 3628*7dc08ffcSJunyu Lai 3629*7dc08ffcSJunyu Lai= DHCP6OptServerId basic instantiation 3630*7dc08ffcSJunyu Laia=DHCP6OptServerId() 3631*7dc08ffcSJunyu Lai 3632*7dc08ffcSJunyu Lai= DHCP6OptServerId basic build 3633*7dc08ffcSJunyu Lairaw(DHCP6OptServerId()) == b'\x00\x02\x00\x00' 3634*7dc08ffcSJunyu Lai 3635*7dc08ffcSJunyu Lai= DHCP6OptServerId basic build with specific values 3636*7dc08ffcSJunyu Lairaw(DHCP6OptServerId(duid="toto")) == b'\x00\x02\x00\x04toto' 3637*7dc08ffcSJunyu Lai 3638*7dc08ffcSJunyu Lai= DHCP6OptServerId instantiation with DUID_LL 3639*7dc08ffcSJunyu Lairaw(DHCP6OptServerId(duid=DUID_LL())) == b'\x00\x02\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00' 3640*7dc08ffcSJunyu Lai 3641*7dc08ffcSJunyu Lai= DHCP6OptServerId instantiation with DUID_LLT 3642*7dc08ffcSJunyu Lairaw(DHCP6OptServerId(duid=DUID_LLT())) == b'\x00\x02\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3643*7dc08ffcSJunyu Lai 3644*7dc08ffcSJunyu Lai= DHCP6OptServerId instantiation with DUID_EN 3645*7dc08ffcSJunyu Lairaw(DHCP6OptServerId(duid=DUID_EN())) == b'\x00\x02\x00\x06\x00\x02\x00\x00\x017' 3646*7dc08ffcSJunyu Lai 3647*7dc08ffcSJunyu Lai= DHCP6OptServerId instantiation with specified length 3648*7dc08ffcSJunyu Lairaw(DHCP6OptServerId(optlen=80, duid="somestring")) == b'\x00\x02\x00Psomestring' 3649*7dc08ffcSJunyu Lai 3650*7dc08ffcSJunyu Lai= DHCP6OptServerId basic dissection 3651*7dc08ffcSJunyu Laia=DHCP6OptServerId(b'\x00\x02\x00\x00') 3652*7dc08ffcSJunyu Laia.optcode == 2 and a.optlen == 0 3653*7dc08ffcSJunyu Lai 3654*7dc08ffcSJunyu Lai= DHCP6OptServerId dissection with specific duid value 3655*7dc08ffcSJunyu Laia=DHCP6OptServerId(b'\x00\x02\x00\x04somerawing') 3656*7dc08ffcSJunyu Laia.optcode == 2 and a.optlen == 4 and isinstance(a.duid, Raw) and a.duid.load == b'some' and isinstance(a.payload, DHCP6OptUnknown) 3657*7dc08ffcSJunyu Lai 3658*7dc08ffcSJunyu Lai= DHCP6OptServerId dissection with specific DUID_LL as duid value 3659*7dc08ffcSJunyu Laia=DHCP6OptServerId(b'\x00\x02\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00') 3660*7dc08ffcSJunyu Laia.optcode == 2 and a.optlen == 10 and isinstance(a.duid, DUID_LL) and a.duid.type == 3 and a.duid.hwtype == 1 and a.duid.lladdr == "00:00:00:00:00:00" 3661*7dc08ffcSJunyu Lai 3662*7dc08ffcSJunyu Lai= DHCP6OptServerId dissection with specific DUID_LLT as duid value 3663*7dc08ffcSJunyu Laia=DHCP6OptServerId(b'\x00\x02\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3664*7dc08ffcSJunyu Laia.optcode == 2 and a.optlen == 14 and isinstance(a.duid, DUID_LLT) and a.duid.type == 1 and a.duid.hwtype == 1 and a.duid.timeval == 0 and a.duid.lladdr == "00:00:00:00:00:00" 3665*7dc08ffcSJunyu Lai 3666*7dc08ffcSJunyu Lai= DHCP6OptServerId dissection with specific DUID_EN as duid value 3667*7dc08ffcSJunyu Laia=DHCP6OptServerId(b'\x00\x02\x00\x06\x00\x02\x00\x00\x017') 3668*7dc08ffcSJunyu Laia.optcode == 2 and a.optlen == 6 and isinstance(a.duid, DUID_EN) and a.duid.type == 2 and a.duid.enterprisenum == 311 and a.duid.id == b"" 3669*7dc08ffcSJunyu Lai 3670*7dc08ffcSJunyu Lai 3671*7dc08ffcSJunyu Lai############ 3672*7dc08ffcSJunyu Lai############ 3673*7dc08ffcSJunyu Lai+ Test DHCP6 IA Address Option (IA_TA or IA_NA suboption) 3674*7dc08ffcSJunyu Lai 3675*7dc08ffcSJunyu Lai= DHCP6OptIAAddress - Basic Instantiation 3676*7dc08ffcSJunyu Lairaw(DHCP6OptIAAddress()) == b'\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3677*7dc08ffcSJunyu Lai 3678*7dc08ffcSJunyu Lai= DHCP6OptIAAddress - Basic Dissection 3679*7dc08ffcSJunyu Laia = DHCP6OptIAAddress(b'\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3680*7dc08ffcSJunyu Laia.optcode == 5 and a.optlen == 24 and a.addr == "::" and a.preflft == 0 and a. validlft == 0 and a.iaaddropts == b"" 3681*7dc08ffcSJunyu Lai 3682*7dc08ffcSJunyu Lai= DHCP6OptIAAddress - Instantiation with specific values 3683*7dc08ffcSJunyu Lairaw(DHCP6OptIAAddress(optlen=0x1111, addr="2222:3333::5555", preflft=0x66666666, validlft=0x77777777, iaaddropts="somestring")) == b'\x00\x05\x11\x11""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomestring' 3684*7dc08ffcSJunyu Lai 3685*7dc08ffcSJunyu Lai= DHCP6OptIAAddress - Instantiation with specific values (default optlen computation) 3686*7dc08ffcSJunyu Lairaw(DHCP6OptIAAddress(addr="2222:3333::5555", preflft=0x66666666, validlft=0x77777777, iaaddropts="somestring")) == b'\x00\x05\x00"""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomestring' 3687*7dc08ffcSJunyu Lai 3688*7dc08ffcSJunyu Lai= DHCP6OptIAAddress - Dissection with specific values 3689*7dc08ffcSJunyu Laia = DHCP6OptIAAddress(b'\x00\x05\x00"""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomerawing') 3690*7dc08ffcSJunyu Laia.optcode == 5 and a.optlen == 34 and a.addr == "2222:3333::5555" and a.preflft == 0x66666666 and a. validlft == 0x77777777 and a.iaaddropts == b"somerawing" 3691*7dc08ffcSJunyu Lai 3692*7dc08ffcSJunyu Lai 3693*7dc08ffcSJunyu Lai############ 3694*7dc08ffcSJunyu Lai############ 3695*7dc08ffcSJunyu Lai+ Test DHCP6 Identity Association for Non-temporary Addresses Option 3696*7dc08ffcSJunyu Lai 3697*7dc08ffcSJunyu Lai= DHCP6OptIA_NA - Basic Instantiation 3698*7dc08ffcSJunyu Lairaw(DHCP6OptIA_NA()) == b'\x00\x03\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3699*7dc08ffcSJunyu Lai 3700*7dc08ffcSJunyu Lai= DHCP6OptIA_NA - Basic Dissection 3701*7dc08ffcSJunyu Laia = DHCP6OptIA_NA(b'\x00\x03\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3702*7dc08ffcSJunyu Laia.optcode == 3 and a.optlen == 12 and a.iaid == 0 and a.T1 == 0 and a.T2==0 and a.ianaopts == [] 3703*7dc08ffcSJunyu Lai 3704*7dc08ffcSJunyu Lai= DHCP6OptIA_NA - Instantiation with specific values (keep automatic length computation) 3705*7dc08ffcSJunyu Lairaw(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == b'\x00\x03\x00\x0c""""3333DDDD' 3706*7dc08ffcSJunyu Lai 3707*7dc08ffcSJunyu Lai= DHCP6OptIA_NA - Instantiation with specific values (forced optlen) 3708*7dc08ffcSJunyu Lairaw(DHCP6OptIA_NA(optlen=0x1111, iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == b'\x00\x03\x11\x11""""3333DDDD' 3709*7dc08ffcSJunyu Lai 3710*7dc08ffcSJunyu Lai= DHCP6OptIA_NA - Instantiation with a list of IA Addresses (optlen automatic computation) 3711*7dc08ffcSJunyu Lairaw(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444, ianaopts=[DHCP6OptIAAddress(), DHCP6OptIAAddress()])) == b'\x00\x03\x00D""""3333DDDD\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3712*7dc08ffcSJunyu Lai 3713*7dc08ffcSJunyu Lai= DHCP6OptIA_NA - Dissection with specific values 3714*7dc08ffcSJunyu Laia = DHCP6OptIA_NA(b'\x00\x03\x00L""""3333DDDD\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3715*7dc08ffcSJunyu Laia.optcode == 3 and a.optlen == 76 and a.iaid == 0x22222222 and a.T1 == 0x33333333 and a.T2==0x44444444 and len(a.ianaopts) == 2 and isinstance(a.ianaopts[0], DHCP6OptIAAddress) and isinstance(a.ianaopts[1], DHCP6OptIAAddress) 3716*7dc08ffcSJunyu Lai 3717*7dc08ffcSJunyu Lai 3718*7dc08ffcSJunyu Lai############ 3719*7dc08ffcSJunyu Lai############ 3720*7dc08ffcSJunyu Lai+ Test DHCP6 Identity Association for Temporary Addresses Option 3721*7dc08ffcSJunyu Lai 3722*7dc08ffcSJunyu Lai= DHCP6OptIA_TA - Basic Instantiation 3723*7dc08ffcSJunyu Lairaw(DHCP6OptIA_TA()) == b'\x00\x04\x00\x04\x00\x00\x00\x00' 3724*7dc08ffcSJunyu Lai 3725*7dc08ffcSJunyu Lai= DHCP6OptIA_TA - Basic Dissection 3726*7dc08ffcSJunyu Laia = DHCP6OptIA_TA(b'\x00\x04\x00\x04\x00\x00\x00\x00') 3727*7dc08ffcSJunyu Laia.optcode == 4 and a.optlen == 4 and a.iaid == 0 and a.iataopts == [] 3728*7dc08ffcSJunyu Lai 3729*7dc08ffcSJunyu Lai= DHCP6OptIA_TA - Instantiation with specific values 3730*7dc08ffcSJunyu Lairaw(DHCP6OptIA_TA(optlen=0x1111, iaid=0x22222222, iataopts=[DHCP6OptIAAddress(), DHCP6OptIAAddress()])) == b'\x00\x04\x11\x11""""\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3731*7dc08ffcSJunyu Lai 3732*7dc08ffcSJunyu Lai= DHCP6OptIA_TA - Dissection with specific values 3733*7dc08ffcSJunyu Laia = DHCP6OptIA_TA(b'\x00\x04\x11\x11""""\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3734*7dc08ffcSJunyu Laia.optcode == 4 and a.optlen == 0x1111 and a.iaid == 0x22222222 and len(a.iataopts) == 2 and isinstance(a.iataopts[0], DHCP6OptIAAddress) and isinstance(a.iataopts[1], DHCP6OptIAAddress) 3735*7dc08ffcSJunyu Lai 3736*7dc08ffcSJunyu Lai 3737*7dc08ffcSJunyu Lai############ 3738*7dc08ffcSJunyu Lai############ 3739*7dc08ffcSJunyu Lai+ Test DHCP6 Option Request Option 3740*7dc08ffcSJunyu Lai 3741*7dc08ffcSJunyu Lai= DHCP6OptOptReq - Basic Instantiation 3742*7dc08ffcSJunyu Lairaw(DHCP6OptOptReq()) == b'\x00\x06\x00\x04\x00\x17\x00\x18' 3743*7dc08ffcSJunyu Lai 3744*7dc08ffcSJunyu Lai= DHCP6OptOptReq - optlen field computation 3745*7dc08ffcSJunyu Lairaw(DHCP6OptOptReq(reqopts=[1,2,3,4])) == b'\x00\x06\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04' 3746*7dc08ffcSJunyu Lai 3747*7dc08ffcSJunyu Lai= DHCP6OptOptReq - instantiation with empty list 3748*7dc08ffcSJunyu Lairaw(DHCP6OptOptReq(reqopts=[])) == b'\x00\x06\x00\x00' 3749*7dc08ffcSJunyu Lai 3750*7dc08ffcSJunyu Lai= DHCP6OptOptReq - Basic dissection 3751*7dc08ffcSJunyu Laia=DHCP6OptOptReq(b'\x00\x06\x00\x00') 3752*7dc08ffcSJunyu Laia.optcode == 6 and a.optlen == 0 and a.reqopts == [23,24] 3753*7dc08ffcSJunyu Lai 3754*7dc08ffcSJunyu Lai= DHCP6OptOptReq - Dissection with specific value 3755*7dc08ffcSJunyu Laia=DHCP6OptOptReq(b'\x00\x06\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04') 3756*7dc08ffcSJunyu Laia.optcode == 6 and a.optlen == 8 and a.reqopts == [1,2,3,4] 3757*7dc08ffcSJunyu Lai 3758*7dc08ffcSJunyu Lai= DHCP6OptOptReq - repr 3759*7dc08ffcSJunyu Laia.show() 3760*7dc08ffcSJunyu Lai 3761*7dc08ffcSJunyu Lai 3762*7dc08ffcSJunyu Lai############ 3763*7dc08ffcSJunyu Lai############ 3764*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Preference option 3765*7dc08ffcSJunyu Lai 3766*7dc08ffcSJunyu Lai= DHCP6OptPref - Basic instantiation 3767*7dc08ffcSJunyu Lairaw(DHCP6OptPref()) == b'\x00\x07\x00\x01\xff' 3768*7dc08ffcSJunyu Lai 3769*7dc08ffcSJunyu Lai= DHCP6OptPref - Instantiation with specific values 3770*7dc08ffcSJunyu Lairaw(DHCP6OptPref(optlen=0xffff, prefval= 0x11)) == b'\x00\x07\xff\xff\x11' 3771*7dc08ffcSJunyu Lai 3772*7dc08ffcSJunyu Lai= DHCP6OptPref - Basic Dissection 3773*7dc08ffcSJunyu Laia=DHCP6OptPref(b'\x00\x07\x00\x01\xff') 3774*7dc08ffcSJunyu Laia.optcode == 7 and a.optlen == 1 and a.prefval == 255 3775*7dc08ffcSJunyu Lai 3776*7dc08ffcSJunyu Lai= DHCP6OptPref - Dissection with specific values 3777*7dc08ffcSJunyu Laia=DHCP6OptPref(b'\x00\x07\xff\xff\x11') 3778*7dc08ffcSJunyu Laia.optcode == 7 and a.optlen == 0xffff and a.prefval == 0x11 3779*7dc08ffcSJunyu Lai 3780*7dc08ffcSJunyu Lai 3781*7dc08ffcSJunyu Lai############ 3782*7dc08ffcSJunyu Lai############ 3783*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Elapsed Time 3784*7dc08ffcSJunyu Lai 3785*7dc08ffcSJunyu Lai= DHCP6OptElapsedTime - Basic Instantiation 3786*7dc08ffcSJunyu Lairaw(DHCP6OptElapsedTime()) == b'\x00\x08\x00\x02\x00\x00' 3787*7dc08ffcSJunyu Lai 3788*7dc08ffcSJunyu Lai= DHCP6OptElapsedTime - Instantiation with specific elapsedtime value 3789*7dc08ffcSJunyu Lairaw(DHCP6OptElapsedTime(elapsedtime=421)) == b'\x00\x08\x00\x02\x01\xa5' 3790*7dc08ffcSJunyu Lai 3791*7dc08ffcSJunyu Lai= DHCP6OptElapsedTime - Basic Dissection 3792*7dc08ffcSJunyu Laia=DHCP6OptElapsedTime(b'\x00\x08\x00\x02\x00\x00') 3793*7dc08ffcSJunyu Laia.optcode == 8 and a.optlen == 2 and a.elapsedtime == 0 3794*7dc08ffcSJunyu Lai 3795*7dc08ffcSJunyu Lai= DHCP6OptElapsedTime - Dissection with specific values 3796*7dc08ffcSJunyu Laia=DHCP6OptElapsedTime(b'\x00\x08\x00\x02\x01\xa5') 3797*7dc08ffcSJunyu Laia.optcode == 8 and a.optlen == 2 and a.elapsedtime == 421 3798*7dc08ffcSJunyu Lai 3799*7dc08ffcSJunyu Lai= DHCP6OptElapsedTime - Repr 3800*7dc08ffcSJunyu Laia.show() 3801*7dc08ffcSJunyu Lai 3802*7dc08ffcSJunyu Lai 3803*7dc08ffcSJunyu Lai############ 3804*7dc08ffcSJunyu Lai############ 3805*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Server Unicast Address 3806*7dc08ffcSJunyu Lai 3807*7dc08ffcSJunyu Lai= DHCP6OptServerUnicast - Basic Instantiation 3808*7dc08ffcSJunyu Lairaw(DHCP6OptServerUnicast()) == b'\x00\x0c\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 3809*7dc08ffcSJunyu Lai 3810*7dc08ffcSJunyu Lai= DHCP6OptServerUnicast - Instantiation with specific values (test 1) 3811*7dc08ffcSJunyu Lairaw(DHCP6OptServerUnicast(srvaddr="2001::1")) == b'\x00\x0c\x00\x10 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 3812*7dc08ffcSJunyu Lai 3813*7dc08ffcSJunyu Lai= DHCP6OptServerUnicast - Instantiation with specific values (test 2) 3814*7dc08ffcSJunyu Lairaw(DHCP6OptServerUnicast(srvaddr="2001::1", optlen=42)) == b'\x00\x0c\x00* \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 3815*7dc08ffcSJunyu Lai 3816*7dc08ffcSJunyu Lai= DHCP6OptServerUnicast - Dissection with default values 3817*7dc08ffcSJunyu Laia=DHCP6OptServerUnicast(b'\x00\x0c\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 3818*7dc08ffcSJunyu Laia.optcode == 12 and a.optlen == 16 and a.srvaddr == "::" 3819*7dc08ffcSJunyu Lai 3820*7dc08ffcSJunyu Lai= DHCP6OptServerUnicast - Dissection with specific values (test 1) 3821*7dc08ffcSJunyu Laia=DHCP6OptServerUnicast(b'\x00\x0c\x00\x10 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 3822*7dc08ffcSJunyu Laia.optcode == 12 and a.optlen == 16 and a.srvaddr == "2001::1" 3823*7dc08ffcSJunyu Lai 3824*7dc08ffcSJunyu Lai= DHCP6OptServerUnicast - Dissection with specific values (test 2) 3825*7dc08ffcSJunyu Laia=DHCP6OptServerUnicast(b'\x00\x0c\x00* \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 3826*7dc08ffcSJunyu Laia.optcode == 12 and a.optlen == 42 and a.srvaddr == "2001::1" 3827*7dc08ffcSJunyu Lai 3828*7dc08ffcSJunyu Lai 3829*7dc08ffcSJunyu Lai############ 3830*7dc08ffcSJunyu Lai############ 3831*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Status Code 3832*7dc08ffcSJunyu Lai 3833*7dc08ffcSJunyu Lai= DHCP6OptStatusCode - Basic Instantiation 3834*7dc08ffcSJunyu Lairaw(DHCP6OptStatusCode()) == b'\x00\r\x00\x02\x00\x00' 3835*7dc08ffcSJunyu Lai 3836*7dc08ffcSJunyu Lai= DHCP6OptStatusCode - Instantiation with specific values 3837*7dc08ffcSJunyu Lairaw(DHCP6OptStatusCode(optlen=42, statuscode=0xff, statusmsg="Hello")) == b'\x00\r\x00*\x00\xffHello' 3838*7dc08ffcSJunyu Lai 3839*7dc08ffcSJunyu Lai= DHCP6OptStatusCode - Automatic Length computation 3840*7dc08ffcSJunyu Lairaw(DHCP6OptStatusCode(statuscode=0xff, statusmsg="Hello")) == b'\x00\r\x00\x07\x00\xffHello' 3841*7dc08ffcSJunyu Lai 3842*7dc08ffcSJunyu Lai# Add tests to verify Unicode behavior 3843*7dc08ffcSJunyu Lai 3844*7dc08ffcSJunyu Lai 3845*7dc08ffcSJunyu Lai############ 3846*7dc08ffcSJunyu Lai############ 3847*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Rapid Commit 3848*7dc08ffcSJunyu Lai 3849*7dc08ffcSJunyu Lai= DHCP6OptRapidCommit - Basic Instantiation 3850*7dc08ffcSJunyu Lairaw(DHCP6OptRapidCommit()) == b'\x00\x0e\x00\x00' 3851*7dc08ffcSJunyu Lai 3852*7dc08ffcSJunyu Lai= DHCP6OptRapidCommit - Basic Dissection 3853*7dc08ffcSJunyu Laia=DHCP6OptRapidCommit(b'\x00\x0e\x00\x00') 3854*7dc08ffcSJunyu Laia.optcode == 14 and a.optlen == 0 3855*7dc08ffcSJunyu Lai 3856*7dc08ffcSJunyu Lai 3857*7dc08ffcSJunyu Lai############ 3858*7dc08ffcSJunyu Lai############ 3859*7dc08ffcSJunyu Lai+ Test DHCP6 Option - User class 3860*7dc08ffcSJunyu Lai 3861*7dc08ffcSJunyu Lai= DHCP6OptUserClass - Basic Instantiation 3862*7dc08ffcSJunyu Lairaw(DHCP6OptUserClass()) == b'\x00\x0f\x00\x00' 3863*7dc08ffcSJunyu Lai 3864*7dc08ffcSJunyu Lai= DHCP6OptUserClass - Basic Dissection 3865*7dc08ffcSJunyu Laia = DHCP6OptUserClass(b'\x00\x0f\x00\x00') 3866*7dc08ffcSJunyu Laia.optcode == 15 and a.optlen == 0 and a.userclassdata == [] 3867*7dc08ffcSJunyu Lai 3868*7dc08ffcSJunyu Lai= DHCP6OptUserClass - Instantiation with one user class data rawucture 3869*7dc08ffcSJunyu Lairaw(DHCP6OptUserClass(userclassdata=[USER_CLASS_DATA(data="something")])) == b'\x00\x0f\x00\x0b\x00\tsomething' 3870*7dc08ffcSJunyu Lai 3871*7dc08ffcSJunyu Lai= DHCP6OptUserClass - Dissection with one user class data rawucture 3872*7dc08ffcSJunyu Laia = DHCP6OptUserClass(b'\x00\x0f\x00\x0b\x00\tsomething') 3873*7dc08ffcSJunyu Laia.optcode == 15 and a.optlen == 11 and len(a.userclassdata) == 1 and isinstance(a.userclassdata[0], USER_CLASS_DATA) and a.userclassdata[0].len == 9 and a.userclassdata[0].data == b'something' 3874*7dc08ffcSJunyu Lai 3875*7dc08ffcSJunyu Lai= DHCP6OptUserClass - Instantiation with two user class data rawuctures 3876*7dc08ffcSJunyu Lairaw(DHCP6OptUserClass(userclassdata=[USER_CLASS_DATA(data="something"), USER_CLASS_DATA(data="somethingelse")])) == b'\x00\x0f\x00\x1a\x00\tsomething\x00\rsomethingelse' 3877*7dc08ffcSJunyu Lai 3878*7dc08ffcSJunyu Lai= DHCP6OptUserClass - Dissection with two user class data rawuctures 3879*7dc08ffcSJunyu Laia = DHCP6OptUserClass(b'\x00\x0f\x00\x1a\x00\tsomething\x00\rsomethingelse') 3880*7dc08ffcSJunyu Laia.optcode == 15 and a.optlen == 26 and len(a.userclassdata) == 2 and isinstance(a.userclassdata[0], USER_CLASS_DATA) and isinstance(a.userclassdata[1], USER_CLASS_DATA) and a.userclassdata[0].len == 9 and a.userclassdata[0].data == b'something' and a.userclassdata[1].len == 13 and a.userclassdata[1].data == b'somethingelse' 3881*7dc08ffcSJunyu Lai 3882*7dc08ffcSJunyu Lai 3883*7dc08ffcSJunyu Lai############ 3884*7dc08ffcSJunyu Lai############ 3885*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Vendor class 3886*7dc08ffcSJunyu Lai 3887*7dc08ffcSJunyu Lai= DHCP6OptVendorClass - Basic Instantiation 3888*7dc08ffcSJunyu Lairaw(DHCP6OptVendorClass()) == b'\x00\x10\x00\x04\x00\x00\x00\x00' 3889*7dc08ffcSJunyu Lai 3890*7dc08ffcSJunyu Lai= DHCP6OptVendorClass - Basic Dissection 3891*7dc08ffcSJunyu Laia = DHCP6OptVendorClass(b'\x00\x10\x00\x04\x00\x00\x00\x00') 3892*7dc08ffcSJunyu Laia.optcode == 16 and a.optlen == 4 and a.enterprisenum == 0 and a.vcdata == [] 3893*7dc08ffcSJunyu Lai 3894*7dc08ffcSJunyu Lai= DHCP6OptVendorClass - Instantiation with one vendor class data rawucture 3895*7dc08ffcSJunyu Lairaw(DHCP6OptVendorClass(vcdata=[VENDOR_CLASS_DATA(data="something")])) == b'\x00\x10\x00\x0f\x00\x00\x00\x00\x00\tsomething' 3896*7dc08ffcSJunyu Lai 3897*7dc08ffcSJunyu Lai= DHCP6OptVendorClass - Dissection with one vendor class data rawucture 3898*7dc08ffcSJunyu Laia = DHCP6OptVendorClass(b'\x00\x10\x00\x0f\x00\x00\x00\x00\x00\tsomething') 3899*7dc08ffcSJunyu Laia.optcode == 16 and a.optlen == 15 and a.enterprisenum == 0 and len(a.vcdata) == 1 and isinstance(a.vcdata[0], VENDOR_CLASS_DATA) and a.vcdata[0].len == 9 and a.vcdata[0].data == b'something' 3900*7dc08ffcSJunyu Lai 3901*7dc08ffcSJunyu Lai= DHCP6OptVendorClass - Instantiation with two vendor class data rawuctures 3902*7dc08ffcSJunyu Lairaw(DHCP6OptVendorClass(vcdata=[VENDOR_CLASS_DATA(data="something"), VENDOR_CLASS_DATA(data="somethingelse")])) == b'\x00\x10\x00\x1e\x00\x00\x00\x00\x00\tsomething\x00\rsomethingelse' 3903*7dc08ffcSJunyu Lai 3904*7dc08ffcSJunyu Lai= DHCP6OptVendorClass - Dissection with two vendor class data rawuctures 3905*7dc08ffcSJunyu Laia = DHCP6OptVendorClass(b'\x00\x10\x00\x1e\x00\x00\x00\x00\x00\tsomething\x00\rsomethingelse') 3906*7dc08ffcSJunyu Laia.optcode == 16 and a.optlen == 30 and a.enterprisenum == 0 and len(a.vcdata) == 2 and isinstance(a.vcdata[0], VENDOR_CLASS_DATA) and isinstance(a.vcdata[1], VENDOR_CLASS_DATA) and a.vcdata[0].len == 9 and a.vcdata[0].data == b'something' and a.vcdata[1].len == 13 and a.vcdata[1].data == b'somethingelse' 3907*7dc08ffcSJunyu Lai 3908*7dc08ffcSJunyu Lai 3909*7dc08ffcSJunyu Lai############ 3910*7dc08ffcSJunyu Lai############ 3911*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Vendor-specific information 3912*7dc08ffcSJunyu Lai 3913*7dc08ffcSJunyu Lai= DHCP6OptVendorSpecificInfo - Basic Instantiation 3914*7dc08ffcSJunyu Lairaw(DHCP6OptVendorSpecificInfo()) == b'\x00\x11\x00\x04\x00\x00\x00\x00' 3915*7dc08ffcSJunyu Lai 3916*7dc08ffcSJunyu Lai= DHCP6OptVendorSpecificInfo - Basic Dissection 3917*7dc08ffcSJunyu Laia = DHCP6OptVendorSpecificInfo(b'\x00\x11\x00\x04\x00\x00\x00\x00') 3918*7dc08ffcSJunyu Laia.optcode == 17 and a.optlen == 4 and a.enterprisenum == 0 3919*7dc08ffcSJunyu Lai 3920*7dc08ffcSJunyu Lai= DHCP6OptVendorSpecificInfo - Instantiation with specific values (one option) 3921*7dc08ffcSJunyu Lairaw(DHCP6OptVendorSpecificInfo(enterprisenum=0xeeeeeeee, vso=[VENDOR_SPECIFIC_OPTION(optcode=43, optdata="something")])) == b'\x00\x11\x00\x11\xee\xee\xee\xee\x00+\x00\tsomething' 3922*7dc08ffcSJunyu Lai 3923*7dc08ffcSJunyu Lai= DHCP6OptVendorSpecificInfo - Dissection with with specific values (one option) 3924*7dc08ffcSJunyu Laia = DHCP6OptVendorSpecificInfo(b'\x00\x11\x00\x11\xee\xee\xee\xee\x00+\x00\tsomething') 3925*7dc08ffcSJunyu Laia.optcode == 17 and a.optlen == 17 and a.enterprisenum == 0xeeeeeeee and len(a.vso) == 1 and isinstance(a.vso[0], VENDOR_SPECIFIC_OPTION) and a.vso[0].optlen == 9 and a.vso[0].optdata == b'something' 3926*7dc08ffcSJunyu Lai 3927*7dc08ffcSJunyu Lai= DHCP6OptVendorSpecificInfo - Instantiation with specific values (two options) 3928*7dc08ffcSJunyu Lairaw(DHCP6OptVendorSpecificInfo(enterprisenum=0xeeeeeeee, vso=[VENDOR_SPECIFIC_OPTION(optcode=43, optdata="something"), VENDOR_SPECIFIC_OPTION(optcode=42, optdata="somethingelse")])) == b'\x00\x11\x00"\xee\xee\xee\xee\x00+\x00\tsomething\x00*\x00\rsomethingelse' 3929*7dc08ffcSJunyu Lai 3930*7dc08ffcSJunyu Lai= DHCP6OptVendorSpecificInfo - Dissection with with specific values (two options) 3931*7dc08ffcSJunyu Laia = DHCP6OptVendorSpecificInfo(b'\x00\x11\x00"\xee\xee\xee\xee\x00+\x00\tsomething\x00*\x00\rsomethingelse') 3932*7dc08ffcSJunyu Laia.optcode == 17 and a.optlen == 34 and a.enterprisenum == 0xeeeeeeee and len(a.vso) == 2 and isinstance(a.vso[0], VENDOR_SPECIFIC_OPTION) and isinstance(a.vso[1], VENDOR_SPECIFIC_OPTION) and a.vso[0].optlen == 9 and a.vso[0].optdata == b'something' and a.vso[1].optlen == 13 and a.vso[1].optdata == b'somethingelse' 3933*7dc08ffcSJunyu Lai 3934*7dc08ffcSJunyu Lai 3935*7dc08ffcSJunyu Lai############ 3936*7dc08ffcSJunyu Lai############ 3937*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Interface-Id 3938*7dc08ffcSJunyu Lai 3939*7dc08ffcSJunyu Lai= DHCP6OptIfaceId - Basic Instantiation 3940*7dc08ffcSJunyu Lairaw(DHCP6OptIfaceId()) == b'\x00\x12\x00\x00' 3941*7dc08ffcSJunyu Lai 3942*7dc08ffcSJunyu Lai= DHCP6OptIfaceId - Basic Dissection 3943*7dc08ffcSJunyu Laia = DHCP6OptIfaceId(b'\x00\x12\x00\x00') 3944*7dc08ffcSJunyu Laia.optcode == 18 and a.optlen == 0 3945*7dc08ffcSJunyu Lai 3946*7dc08ffcSJunyu Lai= DHCP6OptIfaceId - Instantiation with specific value 3947*7dc08ffcSJunyu Lairaw(DHCP6OptIfaceId(ifaceid="something")) == b'\x00\x12\x00\x09something' 3948*7dc08ffcSJunyu Lai 3949*7dc08ffcSJunyu Lai= DHCP6OptIfaceId - Dissection with specific value 3950*7dc08ffcSJunyu Laia = DHCP6OptIfaceId(b'\x00\x12\x00\x09something') 3951*7dc08ffcSJunyu Laia.optcode == 18 and a.optlen == 9 and a.ifaceid == b"something" 3952*7dc08ffcSJunyu Lai 3953*7dc08ffcSJunyu Lai 3954*7dc08ffcSJunyu Lai############ 3955*7dc08ffcSJunyu Lai############ 3956*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Reconfigure Message 3957*7dc08ffcSJunyu Lai 3958*7dc08ffcSJunyu Lai= DHCP6OptReconfMsg - Basic Instantiation 3959*7dc08ffcSJunyu Lairaw(DHCP6OptReconfMsg()) == b'\x00\x13\x00\x01\x0b' 3960*7dc08ffcSJunyu Lai 3961*7dc08ffcSJunyu Lai= DHCP6OptReconfMsg - Basic Dissection 3962*7dc08ffcSJunyu Laia = DHCP6OptReconfMsg(b'\x00\x13\x00\x01\x0b') 3963*7dc08ffcSJunyu Laia.optcode == 19 and a.optlen == 1 and a.msgtype == 11 3964*7dc08ffcSJunyu Lai 3965*7dc08ffcSJunyu Lai= DHCP6OptReconfMsg - Instantiation with specific values 3966*7dc08ffcSJunyu Lairaw(DHCP6OptReconfMsg(optlen=4, msgtype=5)) == b'\x00\x13\x00\x04\x05' 3967*7dc08ffcSJunyu Lai 3968*7dc08ffcSJunyu Lai= DHCP6OptReconfMsg - Dissection with specific values 3969*7dc08ffcSJunyu Laia = DHCP6OptReconfMsg(b'\x00\x13\x00\x04\x05') 3970*7dc08ffcSJunyu Laia.optcode == 19 and a.optlen == 4 and a.msgtype == 5 3971*7dc08ffcSJunyu Lai 3972*7dc08ffcSJunyu Lai 3973*7dc08ffcSJunyu Lai############ 3974*7dc08ffcSJunyu Lai############ 3975*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Reconfigure Accept 3976*7dc08ffcSJunyu Lai 3977*7dc08ffcSJunyu Lai= DHCP6OptReconfAccept - Basic Instantiation 3978*7dc08ffcSJunyu Lairaw(DHCP6OptReconfAccept()) == b'\x00\x14\x00\x00' 3979*7dc08ffcSJunyu Lai 3980*7dc08ffcSJunyu Lai= DHCP6OptReconfAccept - Basic Dissection 3981*7dc08ffcSJunyu Laia = DHCP6OptReconfAccept(b'\x00\x14\x00\x00') 3982*7dc08ffcSJunyu Laia.optcode == 20 and a.optlen == 0 3983*7dc08ffcSJunyu Lai 3984*7dc08ffcSJunyu Lai= DHCP6OptReconfAccept - Instantiation with specific values 3985*7dc08ffcSJunyu Lairaw(DHCP6OptReconfAccept(optlen=23)) == b'\x00\x14\x00\x17' 3986*7dc08ffcSJunyu Lai 3987*7dc08ffcSJunyu Lai= DHCP6OptReconfAccept - Dssection with specific values 3988*7dc08ffcSJunyu Laia = DHCP6OptReconfAccept(b'\x00\x14\x00\x17') 3989*7dc08ffcSJunyu Laia.optcode == 20 and a.optlen == 23 3990*7dc08ffcSJunyu Lai 3991*7dc08ffcSJunyu Lai 3992*7dc08ffcSJunyu Lai############ 3993*7dc08ffcSJunyu Lai############ 3994*7dc08ffcSJunyu Lai+ Test DHCP6 Option - SIP Servers Domain Name List 3995*7dc08ffcSJunyu Lai 3996*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Basic Instantiation 3997*7dc08ffcSJunyu Lairaw(DHCP6OptSIPDomains()) == b'\x00\x15\x00\x00' 3998*7dc08ffcSJunyu Lai 3999*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Basic Dissection 4000*7dc08ffcSJunyu Laia = DHCP6OptSIPDomains(b'\x00\x15\x00\x00') 4001*7dc08ffcSJunyu Laia.optcode == 21 and a.optlen == 0 and a.sipdomains == [] 4002*7dc08ffcSJunyu Lai 4003*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Instantiation with one domain 4004*7dc08ffcSJunyu Lairaw(DHCP6OptSIPDomains(sipdomains=["toto.example.org"])) == b'\x00\x15\x00\x12\x04toto\x07example\x03org\x00' 4005*7dc08ffcSJunyu Lai 4006*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Dissection with one domain 4007*7dc08ffcSJunyu Laia = DHCP6OptSIPDomains(b'\x00\x15\x00\x12\x04toto\x07example\x03org\x00') 4008*7dc08ffcSJunyu Laia.optcode == 21 and a.optlen == 18 and len(a.sipdomains) == 1 and a.sipdomains[0] == "toto.example.org." 4009*7dc08ffcSJunyu Lai 4010*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Instantiation with two domains 4011*7dc08ffcSJunyu Lairaw(DHCP6OptSIPDomains(sipdomains=["toto.example.org", "titi.example.org"])) == b'\x00\x15\x00$\x04toto\x07example\x03org\x00\x04titi\x07example\x03org\x00' 4012*7dc08ffcSJunyu Lai 4013*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Dissection with two domains 4014*7dc08ffcSJunyu Laia = DHCP6OptSIPDomains(b'\x00\x15\x00$\x04toto\x07example\x03org\x00\x04TITI\x07example\x03org\x00') 4015*7dc08ffcSJunyu Laia.optcode == 21 and a.optlen == 36 and len(a.sipdomains) == 2 and a.sipdomains[0] == "toto.example.org." and a.sipdomains[1] == "TITI.example.org." 4016*7dc08ffcSJunyu Lai 4017*7dc08ffcSJunyu Lai= DHCP6OptSIPDomains - Enforcing only one dot at end of domain 4018*7dc08ffcSJunyu Lairaw(DHCP6OptSIPDomains(sipdomains=["toto.example.org."])) == b'\x00\x15\x00\x12\x04toto\x07example\x03org\x00' 4019*7dc08ffcSJunyu Lai 4020*7dc08ffcSJunyu Lai 4021*7dc08ffcSJunyu Lai############ 4022*7dc08ffcSJunyu Lai############ 4023*7dc08ffcSJunyu Lai+ Test DHCP6 Option - SIP Servers IPv6 Address List 4024*7dc08ffcSJunyu Lai 4025*7dc08ffcSJunyu Lai= DHCP6OptSIPServers - Basic Instantiation 4026*7dc08ffcSJunyu Lairaw(DHCP6OptSIPServers()) == b'\x00\x16\x00\x00' 4027*7dc08ffcSJunyu Lai 4028*7dc08ffcSJunyu Lai= DHCP6OptSIPServers - Basic Dissection 4029*7dc08ffcSJunyu Laia = DHCP6OptSIPServers(b'\x00\x16\x00\x00') 4030*7dc08ffcSJunyu Laia.optcode == 22 and a. optlen == 0 and a.sipservers == [] 4031*7dc08ffcSJunyu Lai 4032*7dc08ffcSJunyu Lai= DHCP6OptSIPServers - Instantiation with specific values (1 address) 4033*7dc08ffcSJunyu Lairaw(DHCP6OptSIPServers(sipservers = ["2001:db8::1"] )) == b'\x00\x16\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4034*7dc08ffcSJunyu Lai 4035*7dc08ffcSJunyu Lai= DHCP6OptSIPServers - Dissection with specific values (1 address) 4036*7dc08ffcSJunyu Laia = DHCP6OptSIPServers(b'\x00\x16\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 4037*7dc08ffcSJunyu Laia.optcode == 22 and a.optlen == 16 and len(a.sipservers) == 1 and a.sipservers[0] == "2001:db8::1" 4038*7dc08ffcSJunyu Lai 4039*7dc08ffcSJunyu Lai= DHCP6OptSIPServers - Instantiation with specific values (2 addresses) 4040*7dc08ffcSJunyu Lairaw(DHCP6OptSIPServers(sipservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x16\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 4041*7dc08ffcSJunyu Lai 4042*7dc08ffcSJunyu Lai= DHCP6OptSIPServers - Dissection with specific values (2 addresses) 4043*7dc08ffcSJunyu Laia = DHCP6OptSIPServers(b'\x00\x16\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 4044*7dc08ffcSJunyu Laia.optcode == 22 and a.optlen == 32 and len(a.sipservers) == 2 and a.sipservers[0] == "2001:db8::1" and a.sipservers[1] == "2001:db8::2" 4045*7dc08ffcSJunyu Lai 4046*7dc08ffcSJunyu Lai 4047*7dc08ffcSJunyu Lai############ 4048*7dc08ffcSJunyu Lai############ 4049*7dc08ffcSJunyu Lai+ Test DHCP6 Option - DNS Recursive Name Server 4050*7dc08ffcSJunyu Lai 4051*7dc08ffcSJunyu Lai= DHCP6OptDNSServers - Basic Instantiation 4052*7dc08ffcSJunyu Lairaw(DHCP6OptDNSServers()) == b'\x00\x17\x00\x00' 4053*7dc08ffcSJunyu Lai 4054*7dc08ffcSJunyu Lai= DHCP6OptDNSServers - Basic Dissection 4055*7dc08ffcSJunyu Laia = DHCP6OptDNSServers(b'\x00\x17\x00\x00') 4056*7dc08ffcSJunyu Laia.optcode == 23 and a. optlen == 0 and a.dnsservers == [] 4057*7dc08ffcSJunyu Lai 4058*7dc08ffcSJunyu Lai= DHCP6OptDNSServers - Instantiation with specific values (1 address) 4059*7dc08ffcSJunyu Lairaw(DHCP6OptDNSServers(dnsservers = ["2001:db8::1"] )) == b'\x00\x17\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4060*7dc08ffcSJunyu Lai 4061*7dc08ffcSJunyu Lai= DHCP6OptDNSServers - Dissection with specific values (1 address) 4062*7dc08ffcSJunyu Laia = DHCP6OptDNSServers(b'\x00\x17\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 4063*7dc08ffcSJunyu Laia.optcode == 23 and a.optlen == 16 and len(a.dnsservers) == 1 and a.dnsservers[0] == "2001:db8::1" 4064*7dc08ffcSJunyu Lai 4065*7dc08ffcSJunyu Lai= DHCP6OptDNSServers - Instantiation with specific values (2 addresses) 4066*7dc08ffcSJunyu Lairaw(DHCP6OptDNSServers(dnsservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x17\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 4067*7dc08ffcSJunyu Lai 4068*7dc08ffcSJunyu Lai= DHCP6OptDNSServers - Dissection with specific values (2 addresses) 4069*7dc08ffcSJunyu Laia = DHCP6OptDNSServers(b'\x00\x17\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 4070*7dc08ffcSJunyu Laia.optcode == 23 and a.optlen == 32 and len(a.dnsservers) == 2 and a.dnsservers[0] == "2001:db8::1" and a.dnsservers[1] == "2001:db8::2" 4071*7dc08ffcSJunyu Lai 4072*7dc08ffcSJunyu Lai 4073*7dc08ffcSJunyu Lai############ 4074*7dc08ffcSJunyu Lai############ 4075*7dc08ffcSJunyu Lai+ Test DHCP6 Option - DNS Domain Search List Option 4076*7dc08ffcSJunyu Lai 4077*7dc08ffcSJunyu Lai= DHCP6OptDNSDomains - Basic Instantiation 4078*7dc08ffcSJunyu Lairaw(DHCP6OptDNSDomains()) == b'\x00\x18\x00\x00' 4079*7dc08ffcSJunyu Lai 4080*7dc08ffcSJunyu Lai= DHCP6OptDNSDomains - Basic Dissection 4081*7dc08ffcSJunyu Laia = DHCP6OptDNSDomains(b'\x00\x18\x00\x00') 4082*7dc08ffcSJunyu Laia.optcode == 24 and a.optlen == 0 and a.dnsdomains == [] 4083*7dc08ffcSJunyu Lai 4084*7dc08ffcSJunyu Lai= DHCP6OptDNSDomains - Instantiation with specific values (1 domain) 4085*7dc08ffcSJunyu Lairaw(DHCP6OptDNSDomains(dnsdomains=["toto.example.com."])) == b'\x00\x18\x00\x12\x04toto\x07example\x03com\x00' 4086*7dc08ffcSJunyu Lai 4087*7dc08ffcSJunyu Lai= DHCP6OptDNSDomains - Dissection with specific values (1 domain) 4088*7dc08ffcSJunyu Laia = DHCP6OptDNSDomains(b'\x00\x18\x00\x12\x04toto\x07example\x03com\x00') 4089*7dc08ffcSJunyu Laia.optcode == 24 and a.optlen == 18 and len(a.dnsdomains) == 1 and a.dnsdomains[0] == "toto.example.com." 4090*7dc08ffcSJunyu Lai 4091*7dc08ffcSJunyu Lai= DHCP6OptDNSDomains - Instantiation with specific values (2 domains) 4092*7dc08ffcSJunyu Lairaw(DHCP6OptDNSDomains(dnsdomains=["toto.example.com.", "titi.example.com."])) == b'\x00\x18\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00' 4093*7dc08ffcSJunyu Lai 4094*7dc08ffcSJunyu Lai= DHCP6OptDNSDomains - Dissection with specific values (2 domains) 4095*7dc08ffcSJunyu Laia = DHCP6OptDNSDomains(b'\x00\x18\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00') 4096*7dc08ffcSJunyu Laia.optcode == 24 and a.optlen == 36 and len(a.dnsdomains) == 2 and a.dnsdomains[0] == "toto.example.com." and a.dnsdomains[1] == "titi.example.com." 4097*7dc08ffcSJunyu Lai 4098*7dc08ffcSJunyu Lai 4099*7dc08ffcSJunyu Lai############ 4100*7dc08ffcSJunyu Lai############ 4101*7dc08ffcSJunyu Lai+ Test DHCP6 Option - IA_PD Prefix Option 4102*7dc08ffcSJunyu Lai 4103*7dc08ffcSJunyu Lai= DHCP6OptIAPrefix - Basic Instantiation 4104*7dc08ffcSJunyu Lairaw(DHCP6OptIAPrefix()) == b'\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4105*7dc08ffcSJunyu Lai 4106*7dc08ffcSJunyu Lai#TODO : finish me 4107*7dc08ffcSJunyu Lai 4108*7dc08ffcSJunyu Lai 4109*7dc08ffcSJunyu Lai############ 4110*7dc08ffcSJunyu Lai############ 4111*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Identity Association for Prefix Delegation 4112*7dc08ffcSJunyu Lai 4113*7dc08ffcSJunyu Lai= DHCP6OptIA_PD - Basic Instantiation 4114*7dc08ffcSJunyu Lairaw(DHCP6OptIA_PD()) == b'\x00\x19\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4115*7dc08ffcSJunyu Lai 4116*7dc08ffcSJunyu Lai#TODO : finish me 4117*7dc08ffcSJunyu Lai 4118*7dc08ffcSJunyu Lai 4119*7dc08ffcSJunyu Lai############ 4120*7dc08ffcSJunyu Lai############ 4121*7dc08ffcSJunyu Lai+ Test DHCP6 Option - NIS Servers 4122*7dc08ffcSJunyu Lai 4123*7dc08ffcSJunyu Lai= DHCP6OptNISServers - Basic Instantiation 4124*7dc08ffcSJunyu Lairaw(DHCP6OptNISServers()) == b'\x00\x1b\x00\x00' 4125*7dc08ffcSJunyu Lai 4126*7dc08ffcSJunyu Lai= DHCP6OptNISServers - Basic Dissection 4127*7dc08ffcSJunyu Laia = DHCP6OptNISServers(b'\x00\x1b\x00\x00') 4128*7dc08ffcSJunyu Laia.optcode == 27 and a. optlen == 0 and a.nisservers == [] 4129*7dc08ffcSJunyu Lai 4130*7dc08ffcSJunyu Lai= DHCP6OptNISServers - Instantiation with specific values (1 address) 4131*7dc08ffcSJunyu Lairaw(DHCP6OptNISServers(nisservers = ["2001:db8::1"] )) == b'\x00\x1b\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4132*7dc08ffcSJunyu Lai 4133*7dc08ffcSJunyu Lai= DHCP6OptNISServers - Dissection with specific values (1 address) 4134*7dc08ffcSJunyu Laia = DHCP6OptNISServers(b'\x00\x1b\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 4135*7dc08ffcSJunyu Laia.optcode == 27 and a.optlen == 16 and len(a.nisservers) == 1 and a.nisservers[0] == "2001:db8::1" 4136*7dc08ffcSJunyu Lai 4137*7dc08ffcSJunyu Lai= DHCP6OptNISServers - Instantiation with specific values (2 addresses) 4138*7dc08ffcSJunyu Lairaw(DHCP6OptNISServers(nisservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x1b\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 4139*7dc08ffcSJunyu Lai 4140*7dc08ffcSJunyu Lai= DHCP6OptNISServers - Dissection with specific values (2 addresses) 4141*7dc08ffcSJunyu Laia = DHCP6OptNISServers(b'\x00\x1b\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 4142*7dc08ffcSJunyu Laia.optcode == 27 and a.optlen == 32 and len(a.nisservers) == 2 and a.nisservers[0] == "2001:db8::1" and a.nisservers[1] == "2001:db8::2" 4143*7dc08ffcSJunyu Lai 4144*7dc08ffcSJunyu Lai 4145*7dc08ffcSJunyu Lai############ 4146*7dc08ffcSJunyu Lai############ 4147*7dc08ffcSJunyu Lai+ Test DHCP6 Option - NIS+ Servers 4148*7dc08ffcSJunyu Lai 4149*7dc08ffcSJunyu Lai= DHCP6OptNISPServers - Basic Instantiation 4150*7dc08ffcSJunyu Lairaw(DHCP6OptNISPServers()) == b'\x00\x1c\x00\x00' 4151*7dc08ffcSJunyu Lai 4152*7dc08ffcSJunyu Lai= DHCP6OptNISPServers - Basic Dissection 4153*7dc08ffcSJunyu Laia = DHCP6OptNISPServers(b'\x00\x1c\x00\x00') 4154*7dc08ffcSJunyu Laia.optcode == 28 and a. optlen == 0 and a.nispservers == [] 4155*7dc08ffcSJunyu Lai 4156*7dc08ffcSJunyu Lai= DHCP6OptNISPServers - Instantiation with specific values (1 address) 4157*7dc08ffcSJunyu Lairaw(DHCP6OptNISPServers(nispservers = ["2001:db8::1"] )) == b'\x00\x1c\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4158*7dc08ffcSJunyu Lai 4159*7dc08ffcSJunyu Lai= DHCP6OptNISPServers - Dissection with specific values (1 address) 4160*7dc08ffcSJunyu Laia = DHCP6OptNISPServers(b'\x00\x1c\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 4161*7dc08ffcSJunyu Laia.optcode == 28 and a.optlen == 16 and len(a.nispservers) == 1 and a.nispservers[0] == "2001:db8::1" 4162*7dc08ffcSJunyu Lai 4163*7dc08ffcSJunyu Lai= DHCP6OptNISPServers - Instantiation with specific values (2 addresses) 4164*7dc08ffcSJunyu Lairaw(DHCP6OptNISPServers(nispservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x1c\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 4165*7dc08ffcSJunyu Lai 4166*7dc08ffcSJunyu Lai= DHCP6OptNISPServers - Dissection with specific values (2 addresses) 4167*7dc08ffcSJunyu Laia = DHCP6OptNISPServers(b'\x00\x1c\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 4168*7dc08ffcSJunyu Laia.optcode == 28 and a.optlen == 32 and len(a.nispservers) == 2 and a.nispservers[0] == "2001:db8::1" and a.nispservers[1] == "2001:db8::2" 4169*7dc08ffcSJunyu Lai 4170*7dc08ffcSJunyu Lai 4171*7dc08ffcSJunyu Lai############ 4172*7dc08ffcSJunyu Lai############ 4173*7dc08ffcSJunyu Lai+ Test DHCP6 Option - NIS Domain Name 4174*7dc08ffcSJunyu Lai 4175*7dc08ffcSJunyu Lai= DHCP6OptNISDomain - Basic Instantiation 4176*7dc08ffcSJunyu Lairaw(DHCP6OptNISDomain()) == b'\x00\x1d\x00\x00' 4177*7dc08ffcSJunyu Lai 4178*7dc08ffcSJunyu Lai= DHCP6OptNISDomain - Basic Dissection 4179*7dc08ffcSJunyu Laia = DHCP6OptNISDomain(b'\x00\x1d\x00\x00') 4180*7dc08ffcSJunyu Laia.optcode == 29 and a.optlen == 0 and a.nisdomain == b"" 4181*7dc08ffcSJunyu Lai 4182*7dc08ffcSJunyu Lai= DHCP6OptNISDomain - Instantiation with one domain name 4183*7dc08ffcSJunyu Lairaw(DHCP6OptNISDomain(nisdomain="toto.example.org")) == b'\x00\x1d\x00\x11\x04toto\x07example\x03org' 4184*7dc08ffcSJunyu Lai 4185*7dc08ffcSJunyu Lai= DHCP6OptNISDomain - Dissection with one domain name 4186*7dc08ffcSJunyu Laia = DHCP6OptNISDomain(b'\x00\x1d\x00\x11\x04toto\x07example\x03org\x00') 4187*7dc08ffcSJunyu Laia.optcode == 29 and a.optlen == 17 and a.nisdomain == b"toto.example.org" 4188*7dc08ffcSJunyu Lai 4189*7dc08ffcSJunyu Lai= DHCP6OptNISDomain - Instantiation with one domain with trailing dot 4190*7dc08ffcSJunyu Lairaw(DHCP6OptNISDomain(nisdomain="toto.example.org.")) == b'\x00\x1d\x00\x12\x04toto\x07example\x03org\x00' 4191*7dc08ffcSJunyu Lai 4192*7dc08ffcSJunyu Lai 4193*7dc08ffcSJunyu Lai############ 4194*7dc08ffcSJunyu Lai############ 4195*7dc08ffcSJunyu Lai+ Test DHCP6 Option - NIS+ Domain Name 4196*7dc08ffcSJunyu Lai 4197*7dc08ffcSJunyu Lai= DHCP6OptNISPDomain - Basic Instantiation 4198*7dc08ffcSJunyu Lairaw(DHCP6OptNISPDomain()) == b'\x00\x1e\x00\x00' 4199*7dc08ffcSJunyu Lai 4200*7dc08ffcSJunyu Lai= DHCP6OptNISPDomain - Basic Dissection 4201*7dc08ffcSJunyu Laia = DHCP6OptNISPDomain(b'\x00\x1e\x00\x00') 4202*7dc08ffcSJunyu Laia.optcode == 30 and a.optlen == 0 and a.nispdomain == b"" 4203*7dc08ffcSJunyu Lai 4204*7dc08ffcSJunyu Lai= DHCP6OptNISPDomain - Instantiation with one domain name 4205*7dc08ffcSJunyu Lairaw(DHCP6OptNISPDomain(nispdomain="toto.example.org")) == b'\x00\x1e\x00\x11\x04toto\x07example\x03org' 4206*7dc08ffcSJunyu Lai 4207*7dc08ffcSJunyu Lai= DHCP6OptNISPDomain - Dissection with one domain name 4208*7dc08ffcSJunyu Laia = DHCP6OptNISPDomain(b'\x00\x1e\x00\x11\x04toto\x07example\x03org\x00') 4209*7dc08ffcSJunyu Laia.optcode == 30 and a.optlen == 17 and a.nispdomain == b"toto.example.org" 4210*7dc08ffcSJunyu Lai 4211*7dc08ffcSJunyu Lai= DHCP6OptNISPDomain - Instantiation with one domain with trailing dot 4212*7dc08ffcSJunyu Lairaw(DHCP6OptNISPDomain(nispdomain="toto.example.org.")) == b'\x00\x1e\x00\x12\x04toto\x07example\x03org\x00' 4213*7dc08ffcSJunyu Lai 4214*7dc08ffcSJunyu Lai 4215*7dc08ffcSJunyu Lai############ 4216*7dc08ffcSJunyu Lai############ 4217*7dc08ffcSJunyu Lai+ Test DHCP6 Option - SNTP Servers 4218*7dc08ffcSJunyu Lai 4219*7dc08ffcSJunyu Lai= DHCP6OptSNTPServers - Basic Instantiation 4220*7dc08ffcSJunyu Lairaw(DHCP6OptSNTPServers()) == b'\x00\x1f\x00\x00' 4221*7dc08ffcSJunyu Lai 4222*7dc08ffcSJunyu Lai= DHCP6OptSNTPServers - Basic Dissection 4223*7dc08ffcSJunyu Laia = DHCP6OptSNTPServers(b'\x00\x1f\x00\x00') 4224*7dc08ffcSJunyu Laia.optcode == 31 and a. optlen == 0 and a.sntpservers == [] 4225*7dc08ffcSJunyu Lai 4226*7dc08ffcSJunyu Lai= DHCP6OptSNTPServers - Instantiation with specific values (1 address) 4227*7dc08ffcSJunyu Lairaw(DHCP6OptSNTPServers(sntpservers = ["2001:db8::1"] )) == b'\x00\x1f\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4228*7dc08ffcSJunyu Lai 4229*7dc08ffcSJunyu Lai= DHCP6OptSNTPServers - Dissection with specific values (1 address) 4230*7dc08ffcSJunyu Laia = DHCP6OptSNTPServers(b'\x00\x1f\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 4231*7dc08ffcSJunyu Laia.optcode == 31 and a.optlen == 16 and len(a.sntpservers) == 1 and a.sntpservers[0] == "2001:db8::1" 4232*7dc08ffcSJunyu Lai 4233*7dc08ffcSJunyu Lai= DHCP6OptSNTPServers - Instantiation with specific values (2 addresses) 4234*7dc08ffcSJunyu Lairaw(DHCP6OptSNTPServers(sntpservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x1f\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 4235*7dc08ffcSJunyu Lai 4236*7dc08ffcSJunyu Lai= DHCP6OptSNTPServers - Dissection with specific values (2 addresses) 4237*7dc08ffcSJunyu Laia = DHCP6OptSNTPServers(b'\x00\x1f\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 4238*7dc08ffcSJunyu Laia.optcode == 31 and a.optlen == 32 and len(a.sntpservers) == 2 and a.sntpservers[0] == "2001:db8::1" and a.sntpservers[1] == "2001:db8::2" 4239*7dc08ffcSJunyu Lai 4240*7dc08ffcSJunyu Lai############ 4241*7dc08ffcSJunyu Lai############ 4242*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Information Refresh Time 4243*7dc08ffcSJunyu Lai 4244*7dc08ffcSJunyu Lai= DHCP6OptInfoRefreshTime - Basic Instantiation 4245*7dc08ffcSJunyu Lairaw(DHCP6OptInfoRefreshTime()) == b'\x00 \x00\x04\x00\x01Q\x80' 4246*7dc08ffcSJunyu Lai 4247*7dc08ffcSJunyu Lai= DHCP6OptInfoRefreshTime - Basic Dissction 4248*7dc08ffcSJunyu Laia = DHCP6OptInfoRefreshTime(b'\x00 \x00\x04\x00\x01Q\x80') 4249*7dc08ffcSJunyu Laia.optcode == 32 and a.optlen == 4 and a.reftime == 86400 4250*7dc08ffcSJunyu Lai 4251*7dc08ffcSJunyu Lai= DHCP6OptInfoRefreshTime - Instantiation with specific values 4252*7dc08ffcSJunyu Lairaw(DHCP6OptInfoRefreshTime(optlen=7, reftime=42)) == b'\x00 \x00\x07\x00\x00\x00*' 4253*7dc08ffcSJunyu Lai 4254*7dc08ffcSJunyu Lai############ 4255*7dc08ffcSJunyu Lai############ 4256*7dc08ffcSJunyu Lai+ Test DHCP6 Option - BCMCS Servers 4257*7dc08ffcSJunyu Lai 4258*7dc08ffcSJunyu Lai= DHCP6OptBCMCSServers - Basic Instantiation 4259*7dc08ffcSJunyu Lairaw(DHCP6OptBCMCSServers()) == b'\x00"\x00\x00' 4260*7dc08ffcSJunyu Lai 4261*7dc08ffcSJunyu Lai= DHCP6OptBCMCSServers - Basic Dissection 4262*7dc08ffcSJunyu Laia = DHCP6OptBCMCSServers(b'\x00"\x00\x00') 4263*7dc08ffcSJunyu Laia.optcode == 34 and a. optlen == 0 and a.bcmcsservers == [] 4264*7dc08ffcSJunyu Lai 4265*7dc08ffcSJunyu Lai= DHCP6OptBCMCSServers - Instantiation with specific values (1 address) 4266*7dc08ffcSJunyu Lairaw(DHCP6OptBCMCSServers(bcmcsservers = ["2001:db8::1"] )) == b'\x00"\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4267*7dc08ffcSJunyu Lai 4268*7dc08ffcSJunyu Lai= DHCP6OptBCMCSServers - Dissection with specific values (1 address) 4269*7dc08ffcSJunyu Laia = DHCP6OptBCMCSServers(b'\x00"\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') 4270*7dc08ffcSJunyu Laia.optcode == 34 and a.optlen == 16 and len(a.bcmcsservers) == 1 and a.bcmcsservers[0] == "2001:db8::1" 4271*7dc08ffcSJunyu Lai 4272*7dc08ffcSJunyu Lai= DHCP6OptBCMCSServers - Instantiation with specific values (2 addresses) 4273*7dc08ffcSJunyu Lairaw(DHCP6OptBCMCSServers(bcmcsservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00"\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 4274*7dc08ffcSJunyu Lai 4275*7dc08ffcSJunyu Lai= DHCP6OptBCMCSServers - Dissection with specific values (2 addresses) 4276*7dc08ffcSJunyu Laia = DHCP6OptBCMCSServers(b'\x00"\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02') 4277*7dc08ffcSJunyu Laia.optcode == 34 and a.optlen == 32 and len(a.bcmcsservers) == 2 and a.bcmcsservers[0] == "2001:db8::1" and a.bcmcsservers[1] == "2001:db8::2" 4278*7dc08ffcSJunyu Lai 4279*7dc08ffcSJunyu Lai 4280*7dc08ffcSJunyu Lai############ 4281*7dc08ffcSJunyu Lai############ 4282*7dc08ffcSJunyu Lai+ Test DHCP6 Option - BCMCS Domains 4283*7dc08ffcSJunyu Lai 4284*7dc08ffcSJunyu Lai= DHCP6OptBCMCSDomains - Basic Instantiation 4285*7dc08ffcSJunyu Lairaw(DHCP6OptBCMCSDomains()) == b'\x00!\x00\x00' 4286*7dc08ffcSJunyu Lai 4287*7dc08ffcSJunyu Lai= DHCP6OptBCMCSDomains - Basic Dissection 4288*7dc08ffcSJunyu Laia = DHCP6OptBCMCSDomains(b'\x00!\x00\x00') 4289*7dc08ffcSJunyu Laia.optcode == 33 and a.optlen == 0 and a.bcmcsdomains == [] 4290*7dc08ffcSJunyu Lai 4291*7dc08ffcSJunyu Lai= DHCP6OptBCMCSDomains - Instantiation with specific values (1 domain) 4292*7dc08ffcSJunyu Lairaw(DHCP6OptBCMCSDomains(bcmcsdomains=["toto.example.com."])) == b'\x00!\x00\x12\x04toto\x07example\x03com\x00' 4293*7dc08ffcSJunyu Lai 4294*7dc08ffcSJunyu Lai= DHCP6OptBCMCSDomains - Dissection with specific values (1 domain) 4295*7dc08ffcSJunyu Laia = DHCP6OptBCMCSDomains(b'\x00!\x00\x12\x04toto\x07example\x03com\x00') 4296*7dc08ffcSJunyu Laia.optcode == 33 and a.optlen == 18 and len(a.bcmcsdomains) == 1 and a.bcmcsdomains[0] == "toto.example.com." 4297*7dc08ffcSJunyu Lai 4298*7dc08ffcSJunyu Lai= DHCP6OptBCMCSDomains - Instantiation with specific values (2 domains) 4299*7dc08ffcSJunyu Lairaw(DHCP6OptBCMCSDomains(bcmcsdomains=["toto.example.com.", "titi.example.com."])) == b'\x00!\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00' 4300*7dc08ffcSJunyu Lai 4301*7dc08ffcSJunyu Lai= DHCP6OptBCMCSDomains - Dissection with specific values (2 domains) 4302*7dc08ffcSJunyu Laia = DHCP6OptBCMCSDomains(b'\x00!\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00') 4303*7dc08ffcSJunyu Laia.optcode == 33 and a.optlen == 36 and len(a.bcmcsdomains) == 2 and a.bcmcsdomains[0] == "toto.example.com." and a.bcmcsdomains[1] == "titi.example.com." 4304*7dc08ffcSJunyu Lai 4305*7dc08ffcSJunyu Lai 4306*7dc08ffcSJunyu Lai############ 4307*7dc08ffcSJunyu Lai############ 4308*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Relay Agent Remote-ID 4309*7dc08ffcSJunyu Lai 4310*7dc08ffcSJunyu Lai= DHCP6OptRemoteID - Basic Instantiation 4311*7dc08ffcSJunyu Lairaw(DHCP6OptRemoteID()) == b'\x00%\x00\x04\x00\x00\x00\x00' 4312*7dc08ffcSJunyu Lai 4313*7dc08ffcSJunyu Lai= DHCP6OptRemoteID - Basic Dissection 4314*7dc08ffcSJunyu Laia = DHCP6OptRemoteID(b'\x00%\x00\x04\x00\x00\x00\x00') 4315*7dc08ffcSJunyu Laia.optcode == 37 and a.optlen == 4 and a.enterprisenum == 0 and a.remoteid == b"" 4316*7dc08ffcSJunyu Lai 4317*7dc08ffcSJunyu Lai= DHCP6OptRemoteID - Instantiation with specific values 4318*7dc08ffcSJunyu Lairaw(DHCP6OptRemoteID(enterprisenum=0xeeeeeeee, remoteid="someid")) == b'\x00%\x00\n\xee\xee\xee\xeesomeid' 4319*7dc08ffcSJunyu Lai 4320*7dc08ffcSJunyu Lai= DHCP6OptRemoteID - Dissection with specific values 4321*7dc08ffcSJunyu Laia = DHCP6OptRemoteID(b'\x00%\x00\n\xee\xee\xee\xeesomeid') 4322*7dc08ffcSJunyu Laia.optcode == 37 and a.optlen == 10 and a.enterprisenum == 0xeeeeeeee and a.remoteid == b"someid" 4323*7dc08ffcSJunyu Lai 4324*7dc08ffcSJunyu Lai 4325*7dc08ffcSJunyu Lai############ 4326*7dc08ffcSJunyu Lai############ 4327*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Subscriber ID 4328*7dc08ffcSJunyu Lai 4329*7dc08ffcSJunyu Lai= DHCP6OptSubscriberID - Basic Instantiation 4330*7dc08ffcSJunyu Lairaw(DHCP6OptSubscriberID()) == b'\x00&\x00\x00' 4331*7dc08ffcSJunyu Lai 4332*7dc08ffcSJunyu Lai= DHCP6OptSubscriberID - Basic Dissection 4333*7dc08ffcSJunyu Laia = DHCP6OptSubscriberID(b'\x00&\x00\x00') 4334*7dc08ffcSJunyu Laia.optcode == 38 and a.optlen == 0 and a.subscriberid == b"" 4335*7dc08ffcSJunyu Lai 4336*7dc08ffcSJunyu Lai= DHCP6OptSubscriberID - Instantiation with specific values 4337*7dc08ffcSJunyu Lairaw(DHCP6OptSubscriberID(subscriberid="someid")) == b'\x00&\x00\x06someid' 4338*7dc08ffcSJunyu Lai 4339*7dc08ffcSJunyu Lai= DHCP6OptSubscriberID - Dissection with specific values 4340*7dc08ffcSJunyu Laia = DHCP6OptSubscriberID(b'\x00&\x00\x06someid') 4341*7dc08ffcSJunyu Laia.optcode == 38 and a.optlen == 6 and a.subscriberid == b"someid" 4342*7dc08ffcSJunyu Lai 4343*7dc08ffcSJunyu Lai 4344*7dc08ffcSJunyu Lai############ 4345*7dc08ffcSJunyu Lai############ 4346*7dc08ffcSJunyu Lai+ Test DHCP6 Option - Client FQDN 4347*7dc08ffcSJunyu Lai 4348*7dc08ffcSJunyu Lai= DHCP6OptClientFQDN - Basic Instantiation 4349*7dc08ffcSJunyu Lairaw(DHCP6OptClientFQDN()) == b"\x00'\x00\x01\x00" 4350*7dc08ffcSJunyu Lai 4351*7dc08ffcSJunyu Lai= DHCP6OptClientFQDN - Basic Dissection 4352*7dc08ffcSJunyu Laia = DHCP6OptClientFQDN(b"\x00'\x00\x01\x00") 4353*7dc08ffcSJunyu Laia.optcode == 39 and a.optlen == 1 and a.res == 0 and a.flags == 0 and a.fqdn == b"" 4354*7dc08ffcSJunyu Lai 4355*7dc08ffcSJunyu Lai= DHCP6OptClientFQDN - Instantiation with various flags combinations 4356*7dc08ffcSJunyu Lairaw(DHCP6OptClientFQDN(flags="S")) == b"\x00'\x00\x01\x01" and raw(DHCP6OptClientFQDN(flags="O")) == b"\x00'\x00\x01\x02" and raw(DHCP6OptClientFQDN(flags="N")) == b"\x00'\x00\x01\x04" and raw(DHCP6OptClientFQDN(flags="SON")) == b"\x00'\x00\x01\x07" and raw(DHCP6OptClientFQDN(flags="ON")) == b"\x00'\x00\x01\x06" 4357*7dc08ffcSJunyu Lai 4358*7dc08ffcSJunyu Lai= DHCP6OptClientFQDN - Instantiation with one fqdn 4359*7dc08ffcSJunyu Lairaw(DHCP6OptClientFQDN(fqdn="toto.example.org")) == b"\x00'\x00\x12\x00\x04toto\x07example\x03org" 4360*7dc08ffcSJunyu Lai 4361*7dc08ffcSJunyu Lai= DHCP6OptClientFQDN - Dissection with one fqdn 4362*7dc08ffcSJunyu Laia = DHCP6OptClientFQDN(b"\x00'\x00\x12\x00\x04toto\x07example\x03org\x00") 4363*7dc08ffcSJunyu Laia.optcode == 39 and a.optlen == 18 and a.res == 0 and a.flags == 0 and a.fqdn == b"toto.example.org" 4364*7dc08ffcSJunyu Lai 4365*7dc08ffcSJunyu Lai 4366*7dc08ffcSJunyu Lai############ 4367*7dc08ffcSJunyu Lai############ 4368*7dc08ffcSJunyu Lai+ Test DHCP6 Option Relay Agent Echo Request Option 4369*7dc08ffcSJunyu Lai 4370*7dc08ffcSJunyu Lai= DHCP6OptRelayAgentERO - Basic Instantiation 4371*7dc08ffcSJunyu Lairaw(DHCP6OptRelayAgentERO()) == b'\x00+\x00\x04\x00\x17\x00\x18' 4372*7dc08ffcSJunyu Lai 4373*7dc08ffcSJunyu Lai= DHCP6OptRelayAgentERO - optlen field computation 4374*7dc08ffcSJunyu Lairaw(DHCP6OptRelayAgentERO(reqopts=[1,2,3,4])) == b'\x00+\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04' 4375*7dc08ffcSJunyu Lai 4376*7dc08ffcSJunyu Lai= DHCP6OptRelayAgentERO - instantiation with empty list 4377*7dc08ffcSJunyu Lairaw(DHCP6OptRelayAgentERO(reqopts=[])) == b'\x00+\x00\x00' 4378*7dc08ffcSJunyu Lai 4379*7dc08ffcSJunyu Lai= DHCP6OptRelayAgentERO - Basic dissection 4380*7dc08ffcSJunyu Laia=DHCP6OptRelayAgentERO(b'\x00+\x00\x00') 4381*7dc08ffcSJunyu Laia.optcode == 43 and a.optlen == 0 and a.reqopts == [23,24] 4382*7dc08ffcSJunyu Lai 4383*7dc08ffcSJunyu Lai= DHCP6OptRelayAgentERO - Dissection with specific value 4384*7dc08ffcSJunyu Laia=DHCP6OptRelayAgentERO(b'\x00+\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04') 4385*7dc08ffcSJunyu Laia.optcode == 43 and a.optlen == 8 and a.reqopts == [1,2,3,4] 4386*7dc08ffcSJunyu Lai 4387*7dc08ffcSJunyu Lai 4388*7dc08ffcSJunyu Lai############ 4389*7dc08ffcSJunyu Lai############ 4390*7dc08ffcSJunyu Lai+ Test DHCP6 Option Client Link Layer address 4391*7dc08ffcSJunyu Lai 4392*7dc08ffcSJunyu Lai= Basic build & dissect 4393*7dc08ffcSJunyu Lais = raw(DHCP6OptClientLinkLayerAddr()) 4394*7dc08ffcSJunyu Laiassert(s == b"\x00O\x00\x07\x00\x01\x00\x00\x00\x00\x00\x00") 4395*7dc08ffcSJunyu Lai 4396*7dc08ffcSJunyu Laip = DHCP6OptClientLinkLayerAddr(s) 4397*7dc08ffcSJunyu Laiassert(p.clladdr == "00:00:00:00:00:00") 4398*7dc08ffcSJunyu Lai 4399*7dc08ffcSJunyu Lai 4400*7dc08ffcSJunyu Lai############ 4401*7dc08ffcSJunyu Lai############ 4402*7dc08ffcSJunyu Lai+ Test DHCP6 Option Virtual Subnet Selection 4403*7dc08ffcSJunyu Lai 4404*7dc08ffcSJunyu Lai= Basic build & dissect 4405*7dc08ffcSJunyu Lais = raw(DHCP6OptVSS()) 4406*7dc08ffcSJunyu Laiassert(s == b"\x00D\x00\x01\xff") 4407*7dc08ffcSJunyu Lai 4408*7dc08ffcSJunyu Laip = DHCP6OptVSS(s) 4409*7dc08ffcSJunyu Laiassert(p.type == 255) 4410*7dc08ffcSJunyu Lai 4411*7dc08ffcSJunyu Lai 4412*7dc08ffcSJunyu Lai############ 4413*7dc08ffcSJunyu Lai############ 4414*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Solicit 4415*7dc08ffcSJunyu Lai 4416*7dc08ffcSJunyu Lai= DHCP6_Solicit - Basic Instantiation 4417*7dc08ffcSJunyu Lairaw(DHCP6_Solicit()) == b'\x01\x00\x00\x00' 4418*7dc08ffcSJunyu Lai 4419*7dc08ffcSJunyu Lai= DHCP6_Solicit - Basic Dissection 4420*7dc08ffcSJunyu Laia = DHCP6_Solicit(b'\x01\x00\x00\x00') 4421*7dc08ffcSJunyu Laia.msgtype == 1 and a.trid == 0 4422*7dc08ffcSJunyu Lai 4423*7dc08ffcSJunyu Lai= DHCP6_Solicit - Basic test of DHCP6_solicit.hashret() 4424*7dc08ffcSJunyu LaiDHCP6_Solicit().hashret() == b'\x00\x00\x00' 4425*7dc08ffcSJunyu Lai 4426*7dc08ffcSJunyu Lai= DHCP6_Solicit - Test of DHCP6_solicit.hashret() with specific values 4427*7dc08ffcSJunyu LaiDHCP6_Solicit(trid=0xbbccdd).hashret() == b'\xbb\xcc\xdd' 4428*7dc08ffcSJunyu Lai 4429*7dc08ffcSJunyu Lai= DHCP6_Solicit - UDP ports overload 4430*7dc08ffcSJunyu Laia=UDP()/DHCP6_Solicit() 4431*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4432*7dc08ffcSJunyu Lai 4433*7dc08ffcSJunyu Lai= DHCP6_Solicit - Dispatch based on UDP port 4434*7dc08ffcSJunyu Laia=UDP(raw(UDP()/DHCP6_Solicit())) 4435*7dc08ffcSJunyu Laiisinstance(a.payload, DHCP6_Solicit) 4436*7dc08ffcSJunyu Lai 4437*7dc08ffcSJunyu Lai 4438*7dc08ffcSJunyu Lai############ 4439*7dc08ffcSJunyu Lai############ 4440*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Advertise 4441*7dc08ffcSJunyu Lai 4442*7dc08ffcSJunyu Lai= DHCP6_Advertise - Basic Instantiation 4443*7dc08ffcSJunyu Lairaw(DHCP6_Advertise()) == b'\x02\x00\x00\x00' 4444*7dc08ffcSJunyu Lai 4445*7dc08ffcSJunyu Lai= DHCP6_Advertise - Basic test of DHCP6_solicit.hashret() 4446*7dc08ffcSJunyu LaiDHCP6_Advertise().hashret() == b'\x00\x00\x00' 4447*7dc08ffcSJunyu Lai 4448*7dc08ffcSJunyu Lai= DHCP6_Advertise - Test of DHCP6_Advertise.hashret() with specific values 4449*7dc08ffcSJunyu LaiDHCP6_Advertise(trid=0xbbccdd).hashret() == b'\xbb\xcc\xdd' 4450*7dc08ffcSJunyu Lai 4451*7dc08ffcSJunyu Lai= DHCP6_Advertise - Basic test of answers() with solicit message 4452*7dc08ffcSJunyu Laia = DHCP6_Solicit() 4453*7dc08ffcSJunyu Laib = DHCP6_Advertise() 4454*7dc08ffcSJunyu Laia > b 4455*7dc08ffcSJunyu Lai 4456*7dc08ffcSJunyu Lai= DHCP6_Advertise - Test of answers() with solicit message 4457*7dc08ffcSJunyu Laia = DHCP6_Solicit(trid=0xbbccdd) 4458*7dc08ffcSJunyu Laib = DHCP6_Advertise(trid=0xbbccdd) 4459*7dc08ffcSJunyu Laia > b 4460*7dc08ffcSJunyu Lai 4461*7dc08ffcSJunyu Lai= DHCP6_Advertise - UDP ports overload 4462*7dc08ffcSJunyu Laia=UDP()/DHCP6_Advertise() 4463*7dc08ffcSJunyu Laia.sport == 547 and a.dport == 546 4464*7dc08ffcSJunyu Lai 4465*7dc08ffcSJunyu Lai 4466*7dc08ffcSJunyu Lai############ 4467*7dc08ffcSJunyu Lai############ 4468*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Request 4469*7dc08ffcSJunyu Lai 4470*7dc08ffcSJunyu Lai= DHCP6_Request - Basic Instantiation 4471*7dc08ffcSJunyu Lairaw(DHCP6_Request()) == b'\x03\x00\x00\x00' 4472*7dc08ffcSJunyu Lai 4473*7dc08ffcSJunyu Lai= DHCP6_Request - Basic Dissection 4474*7dc08ffcSJunyu Laia=DHCP6_Request(b'\x03\x00\x00\x00') 4475*7dc08ffcSJunyu Laia.msgtype == 3 and a.trid == 0 4476*7dc08ffcSJunyu Lai 4477*7dc08ffcSJunyu Lai= DHCP6_Request - UDP ports overload 4478*7dc08ffcSJunyu Laia=UDP()/DHCP6_Request() 4479*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4480*7dc08ffcSJunyu Lai 4481*7dc08ffcSJunyu Lai 4482*7dc08ffcSJunyu Lai############ 4483*7dc08ffcSJunyu Lai############ 4484*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Confirm 4485*7dc08ffcSJunyu Lai 4486*7dc08ffcSJunyu Lai= DHCP6_Confirm - Basic Instantiation 4487*7dc08ffcSJunyu Lairaw(DHCP6_Confirm()) == b'\x04\x00\x00\x00' 4488*7dc08ffcSJunyu Lai 4489*7dc08ffcSJunyu Lai= DHCP6_Confirm - Basic Dissection 4490*7dc08ffcSJunyu Laia=DHCP6_Confirm(b'\x04\x00\x00\x00') 4491*7dc08ffcSJunyu Laia.msgtype == 4 and a.trid == 0 4492*7dc08ffcSJunyu Lai 4493*7dc08ffcSJunyu Lai= DHCP6_Confirm - UDP ports overload 4494*7dc08ffcSJunyu Laia=UDP()/DHCP6_Confirm() 4495*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4496*7dc08ffcSJunyu Lai 4497*7dc08ffcSJunyu Lai 4498*7dc08ffcSJunyu Lai############ 4499*7dc08ffcSJunyu Lai############ 4500*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Renew 4501*7dc08ffcSJunyu Lai 4502*7dc08ffcSJunyu Lai= DHCP6_Renew - Basic Instantiation 4503*7dc08ffcSJunyu Lairaw(DHCP6_Renew()) == b'\x05\x00\x00\x00' 4504*7dc08ffcSJunyu Lai 4505*7dc08ffcSJunyu Lai= DHCP6_Renew - Basic Dissection 4506*7dc08ffcSJunyu Laia=DHCP6_Renew(b'\x05\x00\x00\x00') 4507*7dc08ffcSJunyu Laia.msgtype == 5 and a.trid == 0 4508*7dc08ffcSJunyu Lai 4509*7dc08ffcSJunyu Lai= DHCP6_Renew - UDP ports overload 4510*7dc08ffcSJunyu Laia=UDP()/DHCP6_Renew() 4511*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4512*7dc08ffcSJunyu Lai 4513*7dc08ffcSJunyu Lai 4514*7dc08ffcSJunyu Lai############ 4515*7dc08ffcSJunyu Lai############ 4516*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Rebind 4517*7dc08ffcSJunyu Lai 4518*7dc08ffcSJunyu Lai= DHCP6_Rebind - Basic Instantiation 4519*7dc08ffcSJunyu Lairaw(DHCP6_Rebind()) == b'\x06\x00\x00\x00' 4520*7dc08ffcSJunyu Lai 4521*7dc08ffcSJunyu Lai= DHCP6_Rebind - Basic Dissection 4522*7dc08ffcSJunyu Laia=DHCP6_Rebind(b'\x06\x00\x00\x00') 4523*7dc08ffcSJunyu Laia.msgtype == 6 and a.trid == 0 4524*7dc08ffcSJunyu Lai 4525*7dc08ffcSJunyu Lai= DHCP6_Rebind - UDP ports overload 4526*7dc08ffcSJunyu Laia=UDP()/DHCP6_Rebind() 4527*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4528*7dc08ffcSJunyu Lai 4529*7dc08ffcSJunyu Lai 4530*7dc08ffcSJunyu Lai############ 4531*7dc08ffcSJunyu Lai############ 4532*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Reply 4533*7dc08ffcSJunyu Lai 4534*7dc08ffcSJunyu Lai= DHCP6_Reply - Basic Instantiation 4535*7dc08ffcSJunyu Lairaw(DHCP6_Reply()) == b'\x07\x00\x00\x00' 4536*7dc08ffcSJunyu Lai 4537*7dc08ffcSJunyu Lai= DHCP6_Reply - Basic Dissection 4538*7dc08ffcSJunyu Laia=DHCP6_Reply(b'\x07\x00\x00\x00') 4539*7dc08ffcSJunyu Laia.msgtype == 7 and a.trid == 0 4540*7dc08ffcSJunyu Lai 4541*7dc08ffcSJunyu Lai= DHCP6_Reply - UDP ports overload 4542*7dc08ffcSJunyu Laia=UDP()/DHCP6_Reply() 4543*7dc08ffcSJunyu Laia.sport == 547 and a.dport == 546 4544*7dc08ffcSJunyu Lai 4545*7dc08ffcSJunyu Lai= DHCP6_Reply - Answers 4546*7dc08ffcSJunyu Lai 4547*7dc08ffcSJunyu Laiassert not DHCP6_Reply(trid=0).answers(DHCP6_Request(trid=1)) 4548*7dc08ffcSJunyu Laiassert DHCP6_Reply(trid=1).answers(DHCP6_Request(trid=1)) 4549*7dc08ffcSJunyu Lai 4550*7dc08ffcSJunyu Lai 4551*7dc08ffcSJunyu Lai############ 4552*7dc08ffcSJunyu Lai############ 4553*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Release 4554*7dc08ffcSJunyu Lai 4555*7dc08ffcSJunyu Lai= DHCP6_Release - Basic Instantiation 4556*7dc08ffcSJunyu Lairaw(DHCP6_Release()) == b'\x08\x00\x00\x00' 4557*7dc08ffcSJunyu Lai 4558*7dc08ffcSJunyu Lai= DHCP6_Release - Basic Dissection 4559*7dc08ffcSJunyu Laia=DHCP6_Release(b'\x08\x00\x00\x00') 4560*7dc08ffcSJunyu Laia.msgtype == 8 and a.trid == 0 4561*7dc08ffcSJunyu Lai 4562*7dc08ffcSJunyu Lai= DHCP6_Release - UDP ports overload 4563*7dc08ffcSJunyu Laia=UDP()/DHCP6_Release() 4564*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4565*7dc08ffcSJunyu Lai 4566*7dc08ffcSJunyu Lai 4567*7dc08ffcSJunyu Lai############ 4568*7dc08ffcSJunyu Lai############ 4569*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Decline 4570*7dc08ffcSJunyu Lai 4571*7dc08ffcSJunyu Lai= DHCP6_Decline - Basic Instantiation 4572*7dc08ffcSJunyu Lairaw(DHCP6_Decline()) == b'\x09\x00\x00\x00' 4573*7dc08ffcSJunyu Lai 4574*7dc08ffcSJunyu Lai= DHCP6_Confirm - Basic Dissection 4575*7dc08ffcSJunyu Laia=DHCP6_Confirm(b'\x09\x00\x00\x00') 4576*7dc08ffcSJunyu Laia.msgtype == 9 and a.trid == 0 4577*7dc08ffcSJunyu Lai 4578*7dc08ffcSJunyu Lai= DHCP6_Decline - UDP ports overload 4579*7dc08ffcSJunyu Laia=UDP()/DHCP6_Decline() 4580*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4581*7dc08ffcSJunyu Lai 4582*7dc08ffcSJunyu Lai 4583*7dc08ffcSJunyu Lai############ 4584*7dc08ffcSJunyu Lai############ 4585*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_Reconf 4586*7dc08ffcSJunyu Lai 4587*7dc08ffcSJunyu Lai= DHCP6_Reconf - Basic Instantiation 4588*7dc08ffcSJunyu Lairaw(DHCP6_Reconf()) == b'\x0A\x00\x00\x00' 4589*7dc08ffcSJunyu Lai 4590*7dc08ffcSJunyu Lai= DHCP6_Reconf - Basic Dissection 4591*7dc08ffcSJunyu Laia=DHCP6_Reconf(b'\x0A\x00\x00\x00') 4592*7dc08ffcSJunyu Laia.msgtype == 10 and a.trid == 0 4593*7dc08ffcSJunyu Lai 4594*7dc08ffcSJunyu Lai= DHCP6_Reconf - UDP ports overload 4595*7dc08ffcSJunyu Laia=UDP()/DHCP6_Reconf() 4596*7dc08ffcSJunyu Laia.sport == 547 and a.dport == 546 4597*7dc08ffcSJunyu Lai 4598*7dc08ffcSJunyu Lai 4599*7dc08ffcSJunyu Lai############ 4600*7dc08ffcSJunyu Lai############ 4601*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_InfoRequest 4602*7dc08ffcSJunyu Lai 4603*7dc08ffcSJunyu Lai= DHCP6_InfoRequest - Basic Instantiation 4604*7dc08ffcSJunyu Lairaw(DHCP6_InfoRequest()) == b'\x0B\x00\x00\x00' 4605*7dc08ffcSJunyu Lai 4606*7dc08ffcSJunyu Lai= DHCP6_InfoRequest - Basic Dissection 4607*7dc08ffcSJunyu Laia=DHCP6_InfoRequest(b'\x0B\x00\x00\x00') 4608*7dc08ffcSJunyu Laia.msgtype == 11 and a.trid == 0 4609*7dc08ffcSJunyu Lai 4610*7dc08ffcSJunyu Lai= DHCP6_InfoRequest - UDP ports overload 4611*7dc08ffcSJunyu Laia=UDP()/DHCP6_InfoRequest() 4612*7dc08ffcSJunyu Laia.sport == 546 and a.dport == 547 4613*7dc08ffcSJunyu Lai 4614*7dc08ffcSJunyu Lai 4615*7dc08ffcSJunyu Lai############ 4616*7dc08ffcSJunyu Lai############ 4617*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_RelayForward 4618*7dc08ffcSJunyu Lai 4619*7dc08ffcSJunyu Lai= DHCP6_RelayForward - Basic Instantiation 4620*7dc08ffcSJunyu Lairaw(DHCP6_RelayForward()) == b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4621*7dc08ffcSJunyu Lai 4622*7dc08ffcSJunyu Lai= DHCP6_RelayForward - Basic Dissection 4623*7dc08ffcSJunyu Laia=DHCP6_RelayForward(b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 4624*7dc08ffcSJunyu Laia.msgtype == 12 and a.hopcount == 0 and a.linkaddr == "::" and a.peeraddr == "::" 4625*7dc08ffcSJunyu Lai 4626*7dc08ffcSJunyu Lai= DHCP6_RelayForward - Dissection with options 4627*7dc08ffcSJunyu Laia = DHCP6_RelayForward(b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x04\x00\x01\x00\x00') 4628*7dc08ffcSJunyu Laia.msgtype == 12 and DHCP6OptRelayMsg in a and isinstance(a.message, DHCP6) 4629*7dc08ffcSJunyu Lai 4630*7dc08ffcSJunyu Lai 4631*7dc08ffcSJunyu Lai############ 4632*7dc08ffcSJunyu Lai############ 4633*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6OptRelayMsg 4634*7dc08ffcSJunyu Lai 4635*7dc08ffcSJunyu Lai= DHCP6OptRelayMsg - Basic Instantiation 4636*7dc08ffcSJunyu Lairaw(DHCP6OptRelayMsg(optcode=37)) == b'\x00%\x00\x04\x00\x00\x00\x00' 4637*7dc08ffcSJunyu Lai 4638*7dc08ffcSJunyu Lai= DHCP6OptRelayMsg - Basic Dissection 4639*7dc08ffcSJunyu Laia=DHCP6OptRelayMsg(b'\x00\r\x00\x00') 4640*7dc08ffcSJunyu Laiassert a.optcode == 13 4641*7dc08ffcSJunyu Lai 4642*7dc08ffcSJunyu Lai= DHCP6OptRelayMsg - Embedded DHCP6 packet 4643*7dc08ffcSJunyu Laip = DHCP6OptRelayMsg(b'\x00\t\x00\x04\x00\x00\x00\x00') 4644*7dc08ffcSJunyu Laiisinstance(p.message, DHCP6) 4645*7dc08ffcSJunyu Lai 4646*7dc08ffcSJunyu Lai############ 4647*7dc08ffcSJunyu Lai############ 4648*7dc08ffcSJunyu Lai+ Test DHCP6 Messages - DHCP6_RelayReply 4649*7dc08ffcSJunyu Lai 4650*7dc08ffcSJunyu Lai= DHCP6_RelayReply - Basic Instantiation 4651*7dc08ffcSJunyu Lairaw(DHCP6_RelayReply()) == b'\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4652*7dc08ffcSJunyu Lai 4653*7dc08ffcSJunyu Lai= DHCP6_RelayReply - Basic Dissection 4654*7dc08ffcSJunyu Laia=DHCP6_RelayReply(b'\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 4655*7dc08ffcSJunyu Laia.msgtype == 13 and a.hopcount == 0 and a.linkaddr == "::" and a.peeraddr == "::" 4656*7dc08ffcSJunyu Lai 4657*7dc08ffcSJunyu Lai 4658*7dc08ffcSJunyu Lai############ 4659*7dc08ffcSJunyu Lai############ 4660*7dc08ffcSJunyu Lai+ Home Agent Address Discovery 4661*7dc08ffcSJunyu Lai 4662*7dc08ffcSJunyu Lai= in6_getha() 4663*7dc08ffcSJunyu Laiin6_getha('2001:db8::') == '2001:db8::fdff:ffff:ffff:fffe' 4664*7dc08ffcSJunyu Lai 4665*7dc08ffcSJunyu Lai= ICMPv6HAADRequest - build/dissection 4666*7dc08ffcSJunyu Laip = IPv6(raw(IPv6(dst=in6_getha('2001:db8::'), src='2001:db8::1')/ICMPv6HAADRequest(id=42))) 4667*7dc08ffcSJunyu Laip.cksum == 0x9620 and p.dst == '2001:db8::fdff:ffff:ffff:fffe' and p.R == 1 4668*7dc08ffcSJunyu Lai 4669*7dc08ffcSJunyu Lai= ICMPv6HAADReply - build/dissection 4670*7dc08ffcSJunyu Laip = IPv6(raw(IPv6(dst='2001:db8::1', src='2001:db8::42')/ICMPv6HAADReply(id=42, addresses=['2001:db8::2', '2001:db8::3']))) 4671*7dc08ffcSJunyu Laip.cksum = 0x3747 and p.addresses == [ '2001:db8::2', '2001:db8::3' ] 4672*7dc08ffcSJunyu Lai 4673*7dc08ffcSJunyu Lai= ICMPv6HAADRequest / ICMPv6HAADReply - build/dissection 4674*7dc08ffcSJunyu Laia=ICMPv6HAADRequest(id=42) 4675*7dc08ffcSJunyu Laib=ICMPv6HAADReply(id=42) 4676*7dc08ffcSJunyu Lainot a < b and a > b 4677*7dc08ffcSJunyu Lai 4678*7dc08ffcSJunyu Lai 4679*7dc08ffcSJunyu Lai############ 4680*7dc08ffcSJunyu Lai############ 4681*7dc08ffcSJunyu Lai+ Mobile Prefix Solicitation/Advertisement 4682*7dc08ffcSJunyu Lai 4683*7dc08ffcSJunyu Lai= ICMPv6MPSol - build (default values) 4684*7dc08ffcSJunyu Lai 4685*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00\x08:@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x92\x00m\xbb\x00\x00\x00\x00' 4686*7dc08ffcSJunyu Lairaw(IPv6()/ICMPv6MPSol()) == s 4687*7dc08ffcSJunyu Lai 4688*7dc08ffcSJunyu Lai= ICMPv6MPSol - dissection (default values) 4689*7dc08ffcSJunyu Laip = IPv6(s) 4690*7dc08ffcSJunyu Laip[ICMPv6MPSol].type == 146 and p[ICMPv6MPSol].cksum == 0x6dbb and p[ICMPv6MPSol].id == 0 4691*7dc08ffcSJunyu Lai 4692*7dc08ffcSJunyu Lai= ICMPv6MPSol - build 4693*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00\x08:@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x92\x00(\x08\x00\x08\x00\x00' 4694*7dc08ffcSJunyu Lairaw(IPv6()/ICMPv6MPSol(cksum=0x2808, id=8)) == s 4695*7dc08ffcSJunyu Lai 4696*7dc08ffcSJunyu Lai= ICMPv6MPSol - dissection 4697*7dc08ffcSJunyu Laip = IPv6(s) 4698*7dc08ffcSJunyu Laip[ICMPv6MPSol].cksum == 0x2808 and p[ICMPv6MPSol].id == 8 4699*7dc08ffcSJunyu Lai 4700*7dc08ffcSJunyu Lai= ICMPv6MPAdv - build (default values) 4701*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00(:@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x93\x00\xe8\xd6\x00\x00\x80\x00\x03\x04\x00\xc0\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4702*7dc08ffcSJunyu Lairaw(IPv6()/ICMPv6MPAdv()/ICMPv6NDOptPrefixInfo()) == s 4703*7dc08ffcSJunyu Lai 4704*7dc08ffcSJunyu Lai= ICMPv6MPAdv - dissection (default values) 4705*7dc08ffcSJunyu Laip = IPv6(s) 4706*7dc08ffcSJunyu Laip[ICMPv6MPAdv].type == 147 and p[ICMPv6MPAdv].cksum == 0xe8d6 and p[ICMPv6NDOptPrefixInfo].prefix == '::' 4707*7dc08ffcSJunyu Lai 4708*7dc08ffcSJunyu Lai= ICMPv6MPAdv - build 4709*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00(:@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x93\x00(\x07\x00*@\x00\x03\x04\x00@\xff\xff\xff\xff\x00\x00\x00\x0c\x00\x00\x00\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4710*7dc08ffcSJunyu Lairaw(IPv6()/ICMPv6MPAdv(cksum=0x2807, flags=1, id=42)/ICMPv6NDOptPrefixInfo(prefix='2001:db8::1', L=0, preferredlifetime=12)) == s 4711*7dc08ffcSJunyu Lai 4712*7dc08ffcSJunyu Lai= ICMPv6MPAdv - dissection 4713*7dc08ffcSJunyu Laip = IPv6(s) 4714*7dc08ffcSJunyu Laip[ICMPv6MPAdv].cksum == 0x2807 and p[ICMPv6MPAdv].flags == 1 and p[ICMPv6MPAdv].id == 42 and p[ICMPv6NDOptPrefixInfo].prefix == '2001:db8::1' and p[ICMPv6NDOptPrefixInfo].preferredlifetime == 12 4715*7dc08ffcSJunyu Lai 4716*7dc08ffcSJunyu Lai 4717*7dc08ffcSJunyu Lai############ 4718*7dc08ffcSJunyu Lai############ 4719*7dc08ffcSJunyu Lai+ Type 2 Routing Header 4720*7dc08ffcSJunyu Lai 4721*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting - type 2 - build/dissection 4722*7dc08ffcSJunyu Laip = IPv6(raw(IPv6(dst='2001:db8::1', src='2001:db8::2')/IPv6ExtHdrRouting(type=2, addresses=['2001:db8::3'])/ICMPv6EchoRequest())) 4723*7dc08ffcSJunyu Laip.type == 2 and len(p.addresses) == 1 and p.cksum == 0x2446 4724*7dc08ffcSJunyu Lai 4725*7dc08ffcSJunyu Lai= IPv6ExtHdrRouting - type 2 - hashret 4726*7dc08ffcSJunyu Lai 4727*7dc08ffcSJunyu Laip = IPv6()/IPv6ExtHdrRouting(addresses=["2001:db8::1", "2001:db8::2"])/ICMPv6EchoRequest() 4728*7dc08ffcSJunyu Laip.hashret() == b" \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:\x00\x00\x00\x00" 4729*7dc08ffcSJunyu Lai 4730*7dc08ffcSJunyu Lai 4731*7dc08ffcSJunyu Lai############ 4732*7dc08ffcSJunyu Lai############ 4733*7dc08ffcSJunyu Lai+ Mobility Options - Binding Refresh Advice 4734*7dc08ffcSJunyu Lai 4735*7dc08ffcSJunyu Lai= MIP6OptBRAdvice - build (default values) 4736*7dc08ffcSJunyu Lais = b'\x02\x02\x00\x00' 4737*7dc08ffcSJunyu Lairaw(MIP6OptBRAdvice()) == s 4738*7dc08ffcSJunyu Lai 4739*7dc08ffcSJunyu Lai= MIP6OptBRAdvice - dissection (default values) 4740*7dc08ffcSJunyu Laip = MIP6OptBRAdvice(s) 4741*7dc08ffcSJunyu Laip.otype == 2 and p.olen == 2 and p.rinter == 0 4742*7dc08ffcSJunyu Lai 4743*7dc08ffcSJunyu Lai= MIP6OptBRAdvice - build 4744*7dc08ffcSJunyu Lais = b'\x03*\n\xf7' 4745*7dc08ffcSJunyu Lairaw(MIP6OptBRAdvice(otype=3, olen=42, rinter=2807)) == s 4746*7dc08ffcSJunyu Lai 4747*7dc08ffcSJunyu Lai= MIP6OptBRAdvice - dissection 4748*7dc08ffcSJunyu Laip = MIP6OptBRAdvice(s) 4749*7dc08ffcSJunyu Laip.otype == 3 and p.olen == 42 and p.rinter == 2807 4750*7dc08ffcSJunyu Lai 4751*7dc08ffcSJunyu Lai 4752*7dc08ffcSJunyu Lai############ 4753*7dc08ffcSJunyu Lai############ 4754*7dc08ffcSJunyu Lai+ Mobility Options - Alternate Care-of Address 4755*7dc08ffcSJunyu Lai 4756*7dc08ffcSJunyu Lai= MIP6OptAltCoA - build (default values) 4757*7dc08ffcSJunyu Lais = b'\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4758*7dc08ffcSJunyu Lairaw(MIP6OptAltCoA()) == s 4759*7dc08ffcSJunyu Lai 4760*7dc08ffcSJunyu Lai= MIP6OptAltCoA - dissection (default values) 4761*7dc08ffcSJunyu Laip = MIP6OptAltCoA(s) 4762*7dc08ffcSJunyu Laip.otype == 3 and p.olen == 16 and p.acoa == '::' 4763*7dc08ffcSJunyu Lai 4764*7dc08ffcSJunyu Lai= MIP6OptAltCoA - build 4765*7dc08ffcSJunyu Lais = b'*\x08 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' 4766*7dc08ffcSJunyu Lairaw(MIP6OptAltCoA(otype=42, olen=8, acoa='2001:db8::1')) == s 4767*7dc08ffcSJunyu Lai 4768*7dc08ffcSJunyu Lai= MIP6OptAltCoA - dissection 4769*7dc08ffcSJunyu Laip = MIP6OptAltCoA(s) 4770*7dc08ffcSJunyu Laip.otype == 42 and p.olen == 8 and p.acoa == '2001:db8::1' 4771*7dc08ffcSJunyu Lai 4772*7dc08ffcSJunyu Lai 4773*7dc08ffcSJunyu Lai############ 4774*7dc08ffcSJunyu Lai############ 4775*7dc08ffcSJunyu Lai+ Mobility Options - Nonce Indices 4776*7dc08ffcSJunyu Lai 4777*7dc08ffcSJunyu Lai= MIP6OptNonceIndices - build (default values) 4778*7dc08ffcSJunyu Lais = b'\x04\x10\x00\x00\x00\x00' 4779*7dc08ffcSJunyu Lairaw(MIP6OptNonceIndices()) == s 4780*7dc08ffcSJunyu Lai 4781*7dc08ffcSJunyu Lai= MIP6OptNonceIndices - dissection (default values) 4782*7dc08ffcSJunyu Laip = MIP6OptNonceIndices(s) 4783*7dc08ffcSJunyu Laip.otype == 4 and p.olen == 16 and p.hni == 0 and p.coni == 0 4784*7dc08ffcSJunyu Lai 4785*7dc08ffcSJunyu Lai= MIP6OptNonceIndices - build 4786*7dc08ffcSJunyu Lais = b'\x04\x12\x00\x13\x00\x14' 4787*7dc08ffcSJunyu Lairaw(MIP6OptNonceIndices(olen=18, hni=19, coni=20)) == s 4788*7dc08ffcSJunyu Lai 4789*7dc08ffcSJunyu Lai= MIP6OptNonceIndices - dissection 4790*7dc08ffcSJunyu Laip = MIP6OptNonceIndices(s) 4791*7dc08ffcSJunyu Laip.hni == 19 and p.coni == 20 4792*7dc08ffcSJunyu Lai 4793*7dc08ffcSJunyu Lai 4794*7dc08ffcSJunyu Lai############ 4795*7dc08ffcSJunyu Lai############ 4796*7dc08ffcSJunyu Lai+ Mobility Options - Binding Authentication Data 4797*7dc08ffcSJunyu Lai 4798*7dc08ffcSJunyu Lai= MIP6OptBindingAuthData - build (default values) 4799*7dc08ffcSJunyu Lais = b'\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4800*7dc08ffcSJunyu Lairaw(MIP6OptBindingAuthData()) == s 4801*7dc08ffcSJunyu Lai 4802*7dc08ffcSJunyu Lai= MIP6OptBindingAuthData - dissection (default values) 4803*7dc08ffcSJunyu Laip = MIP6OptBindingAuthData(s) 4804*7dc08ffcSJunyu Laip.otype == 5 and p.olen == 16 and p.authenticator == 0 4805*7dc08ffcSJunyu Lai 4806*7dc08ffcSJunyu Lai= MIP6OptBindingAuthData - build 4807*7dc08ffcSJunyu Lais = b'\x05*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\xf7' 4808*7dc08ffcSJunyu Lairaw(MIP6OptBindingAuthData(olen=42, authenticator=2807)) == s 4809*7dc08ffcSJunyu Lai 4810*7dc08ffcSJunyu Lai= MIP6OptBindingAuthData - dissection 4811*7dc08ffcSJunyu Laip = MIP6OptBindingAuthData(s) 4812*7dc08ffcSJunyu Laip.otype == 5 and p.olen == 42 and p.authenticator == 2807 4813*7dc08ffcSJunyu Lai 4814*7dc08ffcSJunyu Lai 4815*7dc08ffcSJunyu Lai############ 4816*7dc08ffcSJunyu Lai############ 4817*7dc08ffcSJunyu Lai+ Mobility Options - Mobile Network Prefix 4818*7dc08ffcSJunyu Lai 4819*7dc08ffcSJunyu Lai= MIP6OptMobNetPrefix - build (default values) 4820*7dc08ffcSJunyu Lais = b'\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4821*7dc08ffcSJunyu Lairaw(MIP6OptMobNetPrefix()) == s 4822*7dc08ffcSJunyu Lai 4823*7dc08ffcSJunyu Lai= MIP6OptMobNetPrefix - dissection (default values) 4824*7dc08ffcSJunyu Laip = MIP6OptMobNetPrefix(s) 4825*7dc08ffcSJunyu Laip.otype == 6 and p.olen == 18 and p.plen == 64 and p.prefix == '::' 4826*7dc08ffcSJunyu Lai 4827*7dc08ffcSJunyu Lai= MIP6OptMobNetPrefix - build 4828*7dc08ffcSJunyu Lais = b'\x06*\x02 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4829*7dc08ffcSJunyu Lairaw(MIP6OptMobNetPrefix(olen=42, reserved=2, plen=32, prefix='2001:db8::')) == s 4830*7dc08ffcSJunyu Lai 4831*7dc08ffcSJunyu Lai= MIP6OptMobNetPrefix - dissection 4832*7dc08ffcSJunyu Laip = MIP6OptMobNetPrefix(s) 4833*7dc08ffcSJunyu Laip.olen == 42 and p.reserved == 2 and p.plen == 32 and p.prefix == '2001:db8::' 4834*7dc08ffcSJunyu Lai 4835*7dc08ffcSJunyu Lai 4836*7dc08ffcSJunyu Lai############ 4837*7dc08ffcSJunyu Lai############ 4838*7dc08ffcSJunyu Lai+ Mobility Options - Link-Layer Address (MH-LLA) 4839*7dc08ffcSJunyu Lai 4840*7dc08ffcSJunyu Lai= MIP6OptLLAddr - basic build 4841*7dc08ffcSJunyu Lairaw(MIP6OptLLAddr()) == b'\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00' 4842*7dc08ffcSJunyu Lai 4843*7dc08ffcSJunyu Lai= MIP6OptLLAddr - basic dissection 4844*7dc08ffcSJunyu Laip = MIP6OptLLAddr(b'\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00') 4845*7dc08ffcSJunyu Laip.otype == 7 and p.olen == 7 and p.ocode == 2 and p.pad == 0 and p.lla == "00:00:00:00:00:00" 4846*7dc08ffcSJunyu Lai 4847*7dc08ffcSJunyu Lai= MIP6OptLLAddr - build with specific values 4848*7dc08ffcSJunyu Lairaw(MIP6OptLLAddr(olen=42, ocode=4, pad=0xff, lla='EE:EE:EE:EE:EE:EE')) == b'\x07*\x04\xff\xee\xee\xee\xee\xee\xee' 4849*7dc08ffcSJunyu Lai 4850*7dc08ffcSJunyu Lai= MIP6OptLLAddr - dissection with specific values 4851*7dc08ffcSJunyu Laip = MIP6OptLLAddr(b'\x07*\x04\xff\xee\xee\xee\xee\xee\xee') 4852*7dc08ffcSJunyu Lai 4853*7dc08ffcSJunyu Lairaw(MIP6OptLLAddr(olen=42, ocode=4, pad=0xff, lla='EE:EE:EE:EE:EE:EE')) 4854*7dc08ffcSJunyu Laip.otype == 7 and p.olen == 42 and p.ocode == 4 and p.pad == 0xff and p.lla == "ee:ee:ee:ee:ee:ee" 4855*7dc08ffcSJunyu Lai 4856*7dc08ffcSJunyu Lai 4857*7dc08ffcSJunyu Lai############ 4858*7dc08ffcSJunyu Lai############ 4859*7dc08ffcSJunyu Lai+ Mobility Options - Mobile Node Identifier 4860*7dc08ffcSJunyu Lai 4861*7dc08ffcSJunyu Lai= MIP6OptMNID - basic build 4862*7dc08ffcSJunyu Lairaw(MIP6OptMNID()) == b'\x08\x01\x01' 4863*7dc08ffcSJunyu Lai 4864*7dc08ffcSJunyu Lai= MIP6OptMNID - basic dissection 4865*7dc08ffcSJunyu Laip = MIP6OptMNID(b'\x08\x01\x01') 4866*7dc08ffcSJunyu Laip.otype == 8 and p.olen == 1 and p.subtype == 1 and p.id == b"" 4867*7dc08ffcSJunyu Lai 4868*7dc08ffcSJunyu Lai= MIP6OptMNID - build with specific values 4869*7dc08ffcSJunyu Lairaw(MIP6OptMNID(subtype=42, id="someid")) == b'\x08\x07*someid' 4870*7dc08ffcSJunyu Lai 4871*7dc08ffcSJunyu Lai= MIP6OptMNID - dissection with specific values 4872*7dc08ffcSJunyu Laip = MIP6OptMNID(b'\x08\x07*someid') 4873*7dc08ffcSJunyu Laip.otype == 8 and p.olen == 7 and p.subtype == 42 and p.id == b"someid" 4874*7dc08ffcSJunyu Lai 4875*7dc08ffcSJunyu Lai 4876*7dc08ffcSJunyu Lai 4877*7dc08ffcSJunyu Lai############ 4878*7dc08ffcSJunyu Lai############ 4879*7dc08ffcSJunyu Lai+ Mobility Options - Message Authentication 4880*7dc08ffcSJunyu Lai 4881*7dc08ffcSJunyu Lai= MIP6OptMsgAuth - basic build 4882*7dc08ffcSJunyu Lairaw(MIP6OptMsgAuth()) == b'\x09\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA' 4883*7dc08ffcSJunyu Lai 4884*7dc08ffcSJunyu Lai= MIP6OptMsgAuth - basic dissection 4885*7dc08ffcSJunyu Laip = MIP6OptMsgAuth(b'\x09\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA') 4886*7dc08ffcSJunyu Laip.otype == 9 and p.olen == 17 and p.subtype == 1 and p.mspi == 0 and p.authdata == b"A"*12 4887*7dc08ffcSJunyu Lai 4888*7dc08ffcSJunyu Lai= MIP6OptMsgAuth - build with specific values 4889*7dc08ffcSJunyu Lairaw(MIP6OptMsgAuth(authdata="B"*16, mspi=0xeeeeeeee, subtype=0xff)) == b'\t\x15\xff\xee\xee\xee\xeeBBBBBBBBBBBBBBBB' 4890*7dc08ffcSJunyu Lai 4891*7dc08ffcSJunyu Lai= MIP6OptMsgAuth - dissection with specific values 4892*7dc08ffcSJunyu Laip = MIP6OptMsgAuth(b'\t\x15\xff\xee\xee\xee\xeeBBBBBBBBBBBBBBBB') 4893*7dc08ffcSJunyu Laip.otype == 9 and p.olen == 21 and p.subtype == 255 and p.mspi == 0xeeeeeeee and p.authdata == b"B"*16 4894*7dc08ffcSJunyu Lai 4895*7dc08ffcSJunyu Lai 4896*7dc08ffcSJunyu Lai############ 4897*7dc08ffcSJunyu Lai############ 4898*7dc08ffcSJunyu Lai+ Mobility Options - Replay Protection 4899*7dc08ffcSJunyu Lai 4900*7dc08ffcSJunyu Lai= MIP6OptReplayProtection - basic build 4901*7dc08ffcSJunyu Lairaw(MIP6OptReplayProtection()) == b'\n\x08\x00\x00\x00\x00\x00\x00\x00\x00' 4902*7dc08ffcSJunyu Lai 4903*7dc08ffcSJunyu Lai= MIP6OptReplayProtection - basic dissection 4904*7dc08ffcSJunyu Laip = MIP6OptReplayProtection(b'\n\x08\x00\x00\x00\x00\x00\x00\x00\x00') 4905*7dc08ffcSJunyu Laip.otype == 10 and p.olen == 8 and p.timestamp == 0 4906*7dc08ffcSJunyu Lai 4907*7dc08ffcSJunyu Lai= MIP6OptReplayProtection - build with specific values 4908*7dc08ffcSJunyu Lais = raw(MIP6OptReplayProtection(olen=42, timestamp=(72*31536000)<<32)) 4909*7dc08ffcSJunyu Lais == b'\n*\x87V|\x00\x00\x00\x00\x00' 4910*7dc08ffcSJunyu Lai 4911*7dc08ffcSJunyu Lai= MIP6OptReplayProtection - dissection with specific values 4912*7dc08ffcSJunyu Laip = MIP6OptReplayProtection(s) 4913*7dc08ffcSJunyu Laip.otype == 10 and p.olen == 42 and p.timestamp == 9752118382559232000 4914*7dc08ffcSJunyu Laip.fields_desc[-1].i2repr("", p.timestamp) == 'Mon, 13 Dec 1971 23:50:39 +0000 (9752118382559232000)' 4915*7dc08ffcSJunyu Lai 4916*7dc08ffcSJunyu Lai 4917*7dc08ffcSJunyu Lai############ 4918*7dc08ffcSJunyu Lai############ 4919*7dc08ffcSJunyu Lai+ Mobility Options - CGA Parameters 4920*7dc08ffcSJunyu Lai= MIP6OptCGAParams 4921*7dc08ffcSJunyu Lai 4922*7dc08ffcSJunyu Lai 4923*7dc08ffcSJunyu Lai############ 4924*7dc08ffcSJunyu Lai############ 4925*7dc08ffcSJunyu Lai+ Mobility Options - Signature 4926*7dc08ffcSJunyu Lai= MIP6OptSignature 4927*7dc08ffcSJunyu Lai 4928*7dc08ffcSJunyu Lai 4929*7dc08ffcSJunyu Lai############ 4930*7dc08ffcSJunyu Lai############ 4931*7dc08ffcSJunyu Lai+ Mobility Options - Permanent Home Keygen Token 4932*7dc08ffcSJunyu Lai= MIP6OptHomeKeygenToken 4933*7dc08ffcSJunyu Lai 4934*7dc08ffcSJunyu Lai 4935*7dc08ffcSJunyu Lai############ 4936*7dc08ffcSJunyu Lai############ 4937*7dc08ffcSJunyu Lai+ Mobility Options - Care-of Test Init 4938*7dc08ffcSJunyu Lai= MIP6OptCareOfTestInit 4939*7dc08ffcSJunyu Lai 4940*7dc08ffcSJunyu Lai 4941*7dc08ffcSJunyu Lai############ 4942*7dc08ffcSJunyu Lai############ 4943*7dc08ffcSJunyu Lai+ Mobility Options - Care-of Test 4944*7dc08ffcSJunyu Lai= MIP6OptCareOfTest 4945*7dc08ffcSJunyu Lai 4946*7dc08ffcSJunyu Lai 4947*7dc08ffcSJunyu Lai############ 4948*7dc08ffcSJunyu Lai############ 4949*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptBRAdvice 4950*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptBRAdvice 4951*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptBRAdvice()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x02\x02\x00\x00' 4952*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x00\x02\x02\x00\x00\x01\x04\x00\x00\x00\x00' 4953*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x02\x02\x00\x00\x01\x04\x00\x00\x00\x00' 4954*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x00\x02\x02\x00\x00\x01\x02\x00\x00' 4955*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x02\x02\x00\x00\x01\x02\x00\x00' 4956*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x00\x02\x02\x00\x00\x01\x00' 4957*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x02\x02\x00\x00\x01\x00' 4958*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x00\x02\x02\x00\x00' 4959*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptBRAdvice()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x02\x02\x00\x00' 4960*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 4961*7dc08ffcSJunyu Lai 4962*7dc08ffcSJunyu Lai############ 4963*7dc08ffcSJunyu Lai############ 4964*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptAltCoA 4965*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptAltCoA 4966*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptAltCoA()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4967*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptAltCoA()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4968*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptAltCoA()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4969*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptAltCoA()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x01\x05\x00\x00\x00\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4970*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptAltCoA()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x01\x04\x00\x00\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4971*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptAltCoA()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x01\x03\x00\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4972*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptAltCoA()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x01\x02\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4973*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptAltCoA()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x01\x01\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4974*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptAltCoA()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x01\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4975*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 4976*7dc08ffcSJunyu Lai 4977*7dc08ffcSJunyu Lai 4978*7dc08ffcSJunyu Lai############ 4979*7dc08ffcSJunyu Lai############ 4980*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptNonceIndices 4981*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptNonceIndices 4982*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x04\x10\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00' 4983*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x00\x04\x10\x00\x00\x00\x00\x01\x02\x00\x00' 4984*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x04\x10\x00\x00\x00\x00\x01\x02\x00\x00' 4985*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x00\x04\x10\x00\x00\x00\x00\x01\x00' 4986*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x04\x10\x00\x00\x00\x00\x01\x00' 4987*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x00\x04\x10\x00\x00\x00\x00' 4988*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptNonceIndices()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x04\x10\x00\x00\x00\x00' 4989*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptNonceIndices()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x00\x04\x10\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00' 4990*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptNonceIndices()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x04\x10\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00' 4991*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 4992*7dc08ffcSJunyu Lai 4993*7dc08ffcSJunyu Lai 4994*7dc08ffcSJunyu Lai############ 4995*7dc08ffcSJunyu Lai############ 4996*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptBindingAuthData 4997*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptBindingAuthData 4998*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 4999*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x01\x03\x00\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5000*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x01\x02\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5001*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x01\x01\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5002*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x01\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5003*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5004*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptBindingAuthData()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5005*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptBindingAuthData()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x01\x05\x00\x00\x00\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5006*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptBindingAuthData()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5007*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5008*7dc08ffcSJunyu Lai 5009*7dc08ffcSJunyu Lai 5010*7dc08ffcSJunyu Lai############ 5011*7dc08ffcSJunyu Lai############ 5012*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptMobNetPrefix 5013*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptMobNetPrefix 5014*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptMobNetPrefix()])) == b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5015*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x01\x05\x00\x00\x00\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5016*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x01\x04\x00\x00\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5017*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x01\x03\x00\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5018*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x01\x02\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5019*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x01\x01\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5020*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x01\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5021*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5022*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptMobNetPrefix()])) == b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5023*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5024*7dc08ffcSJunyu Lai 5025*7dc08ffcSJunyu Lai 5026*7dc08ffcSJunyu Lai############ 5027*7dc08ffcSJunyu Lai############ 5028*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptLLAddr 5029*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptLLAddr 5030*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptLLAddr()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00' 5031*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptLLAddr()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x00' 5032*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptLLAddr()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00' 5033*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptLLAddr()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x05\x00\x00\x00\x00\x00' 5034*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptLLAddr()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00' 5035*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptLLAddr()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00' 5036*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptLLAddr()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5037*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptLLAddr()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00' 5038*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptLLAddr()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00' 5039*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5040*7dc08ffcSJunyu Lai 5041*7dc08ffcSJunyu Lai 5042*7dc08ffcSJunyu Lai############ 5043*7dc08ffcSJunyu Lai############ 5044*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptMNID 5045*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptMNID 5046*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptMNID()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x08\x01\x01\x00' 5047*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptMNID()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x08\x01\x01' 5048*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x08\x01\x01\x01\x05\x00\x00\x00\x00\x00' 5049*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x08\x01\x01\x01\x04\x00\x00\x00\x00' 5050*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x08\x01\x01\x01\x03\x00\x00\x00' 5051*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x08\x01\x01\x01\x02\x00\x00' 5052*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x08\x01\x01\x01\x01\x00' 5053*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x08\x01\x01\x01\x00' 5054*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptMNID()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x08\x01\x01\x00' 5055*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5056*7dc08ffcSJunyu Lai 5057*7dc08ffcSJunyu Lai 5058*7dc08ffcSJunyu Lai############ 5059*7dc08ffcSJunyu Lai############ 5060*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptMsgAuth 5061*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptMsgAuth 5062*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptMsgAuth()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA' 5063*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptMsgAuth()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA' 5064*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x01\x01\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA\x01\x02\x00\x00' 5065*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x01\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA\x01\x02\x00\x00' 5066*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA\x01\x02\x00\x00' 5067*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA\x01\x02\x00\x00' 5068*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x01\x01\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA' 5069*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x01\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA' 5070*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptMsgAuth()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x00\t\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA' 5071*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5072*7dc08ffcSJunyu Lai 5073*7dc08ffcSJunyu Lai 5074*7dc08ffcSJunyu Lai############ 5075*7dc08ffcSJunyu Lai############ 5076*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptReplayProtection 5077*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptReplayProtection 5078*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5079*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x01\x03\x00\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5080*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x01\x02\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5081*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x01\x01\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5082*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x01\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5083*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5084*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptReplayProtection()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5085*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptReplayProtection()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x01\x05\x00\x00\x00\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5086*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptReplayProtection()])) ==b';\x04\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00\n\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5087*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5088*7dc08ffcSJunyu Lai 5089*7dc08ffcSJunyu Lai 5090*7dc08ffcSJunyu Lai############ 5091*7dc08ffcSJunyu Lai############ 5092*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptCGAParamsReq 5093*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptCGAParamsReq 5094*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptCGAParamsReq()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x0b\x00\x01\x00' 5095*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptCGAParamsReq()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x0b\x00\x00' 5096*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptCGAParamsReq()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x0b\x00' 5097*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptCGAParamsReq()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x0b\x00\x01\x05\x00\x00\x00\x00\x00' 5098*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptCGAParamsReq()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x0b\x00\x01\x04\x00\x00\x00\x00' 5099*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptCGAParamsReq()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x0b\x00\x01\x03\x00\x00\x00' 5100*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptCGAParamsReq()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x0b\x00\x01\x02\x00\x00' 5101*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptCGAParamsReq()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x0b\x00\x01\x01\x00' 5102*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptCGAParamsReq()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x0b\x00\x01\x00' 5103*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5104*7dc08ffcSJunyu Lai 5105*7dc08ffcSJunyu Lai 5106*7dc08ffcSJunyu Lai############ 5107*7dc08ffcSJunyu Lai############ 5108*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptCGAParams 5109*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptCGAParams 5110*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptCGAParams()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x0c\x00\x01\x00' 5111*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptCGAParams()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x0c\x00\x00' 5112*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptCGAParams()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x0c\x00' 5113*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptCGAParams()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x0c\x00\x01\x05\x00\x00\x00\x00\x00' 5114*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptCGAParams()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x0c\x00\x01\x04\x00\x00\x00\x00' 5115*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptCGAParams()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x0c\x00\x01\x03\x00\x00\x00' 5116*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptCGAParams()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x0c\x00\x01\x02\x00\x00' 5117*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptCGAParams()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x0c\x00\x01\x01\x00' 5118*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptCGAParams()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x0c\x00\x01\x00' 5119*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5120*7dc08ffcSJunyu Lai 5121*7dc08ffcSJunyu Lai 5122*7dc08ffcSJunyu Lai############ 5123*7dc08ffcSJunyu Lai############ 5124*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptSignature 5125*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptSignature 5126*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptSignature()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\r\x00\x01\x00' 5127*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptSignature()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\r\x00\x00' 5128*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptSignature()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\r\x00' 5129*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptSignature()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\r\x00\x01\x05\x00\x00\x00\x00\x00' 5130*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptSignature()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\r\x00\x01\x04\x00\x00\x00\x00' 5131*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptSignature()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\r\x00\x01\x03\x00\x00\x00' 5132*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptSignature()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\r\x00\x01\x02\x00\x00' 5133*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptSignature()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\r\x00\x01\x01\x00' 5134*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptSignature()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\r\x00\x01\x00' 5135*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5136*7dc08ffcSJunyu Lai 5137*7dc08ffcSJunyu Lai 5138*7dc08ffcSJunyu Lai############ 5139*7dc08ffcSJunyu Lai############ 5140*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptHomeKeygenToken 5141*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptHomeKeygenToken 5142*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptHomeKeygenToken()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x0e\x00\x01\x00' 5143*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptHomeKeygenToken()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x0e\x00\x00' 5144*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptHomeKeygenToken()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x0e\x00' 5145*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptHomeKeygenToken()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x0e\x00\x01\x05\x00\x00\x00\x00\x00' 5146*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptHomeKeygenToken()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x0e\x00\x01\x04\x00\x00\x00\x00' 5147*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptHomeKeygenToken()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x0e\x00\x01\x03\x00\x00\x00' 5148*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptHomeKeygenToken()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x0e\x00\x01\x02\x00\x00' 5149*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptHomeKeygenToken()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x0e\x00\x01\x01\x00' 5150*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptHomeKeygenToken()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x0e\x00\x01\x00' 5151*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5152*7dc08ffcSJunyu Lai 5153*7dc08ffcSJunyu Lai 5154*7dc08ffcSJunyu Lai############ 5155*7dc08ffcSJunyu Lai############ 5156*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptCareOfTestInit 5157*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptCareOfTestInit 5158*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptCareOfTestInit()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x0f\x00\x01\x00' 5159*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptCareOfTestInit()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x0f\x00\x00' 5160*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptCareOfTestInit()])) ==b';\x01\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x0f\x00' 5161*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptCareOfTestInit()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x0f\x00\x01\x05\x00\x00\x00\x00\x00' 5162*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptCareOfTestInit()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x0f\x00\x01\x04\x00\x00\x00\x00' 5163*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptCareOfTestInit()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x0f\x00\x01\x03\x00\x00\x00' 5164*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptCareOfTestInit()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x0f\x00\x01\x02\x00\x00' 5165*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptCareOfTestInit()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x0f\x00\x01\x01\x00' 5166*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptCareOfTestInit()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x0f\x00\x01\x00' 5167*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5168*7dc08ffcSJunyu Lai 5169*7dc08ffcSJunyu Lai 5170*7dc08ffcSJunyu Lai############ 5171*7dc08ffcSJunyu Lai############ 5172*7dc08ffcSJunyu Lai+ Mobility Options - Automatic Padding - MIP6OptCareOfTest 5173*7dc08ffcSJunyu Lai= Mobility Options - Automatic Padding - MIP6OptCareOfTest 5174*7dc08ffcSJunyu Laia = raw(MIP6MH_BU(seq=0x4242, options=[MIP6OptCareOfTest()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00' 5175*7dc08ffcSJunyu Laib = raw(MIP6MH_BU(seq=0x4242, options=[Pad1(),MIP6OptCareOfTest()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5176*7dc08ffcSJunyu Laic = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*0),MIP6OptCareOfTest()])) ==b';\x02\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00' 5177*7dc08ffcSJunyu Laid = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*1),MIP6OptCareOfTest()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x01\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x05\x00\x00\x00\x00\x00' 5178*7dc08ffcSJunyu Laie = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*2),MIP6OptCareOfTest()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x02\x00\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x04\x00\x00\x00\x00' 5179*7dc08ffcSJunyu Laig = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*3),MIP6OptCareOfTest()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x03\x00\x00\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00' 5180*7dc08ffcSJunyu Laih = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*4),MIP6OptCareOfTest()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x04\x00\x00\x00\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00' 5181*7dc08ffcSJunyu Laii = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*5),MIP6OptCareOfTest()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x05\x00\x00\x00\x00\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00' 5182*7dc08ffcSJunyu Laij = raw(MIP6MH_BU(seq=0x4242, options=[PadN(optdata=b'\x00'*6),MIP6OptCareOfTest()])) ==b';\x03\x05\x00\x00\x00BB\xd0\x00\x00\x03\x01\x06\x00\x00\x00\x00\x00\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00' 5183*7dc08ffcSJunyu Laia and b and c and d and e and g and h and i and j 5184*7dc08ffcSJunyu Lai 5185*7dc08ffcSJunyu Lai 5186*7dc08ffcSJunyu Lai############ 5187*7dc08ffcSJunyu Lai############ 5188*7dc08ffcSJunyu Lai+ Binding Refresh Request Message 5189*7dc08ffcSJunyu Lai= MIP6MH_BRR - Build (default values) 5190*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_BRR()) == b'`\x00\x00\x00\x00\x08\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x00\x00\x00h\xfb\x00\x00' 5191*7dc08ffcSJunyu Lai 5192*7dc08ffcSJunyu Lai= MIP6MH_BRR - Build with specific values 5193*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_BRR(nh=0xff, res=0xee, res2=0xaaaa, options=[MIP6OptLLAddr(), MIP6OptAltCoA()])) == b'`\x00\x00\x00\x00(\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xff\x04\x00\xee\xec$\xaa\xaa\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5194*7dc08ffcSJunyu Lai 5195*7dc08ffcSJunyu Lai= MIP6MH_BRR - Basic dissection 5196*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x08\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x00\x00\x00h\xfb\x00\x00') 5197*7dc08ffcSJunyu Laib=a.payload 5198*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_BRR) and b.nh == 59 and b.len == 0 and b.mhtype == 0 and b.res == 0 and b.cksum == 0x68fb and b.res2 == 0 and b.options == [] 5199*7dc08ffcSJunyu Lai 5200*7dc08ffcSJunyu Lai= MIP6MH_BRR - Dissection with specific values 5201*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00(\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xff\x04\x00\xee\xec$\xaa\xaa\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5202*7dc08ffcSJunyu Laib=a.payload 5203*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_BRR) and b.nh == 0xff and b.len == 4 and b.mhtype == 0 and b.res == 238 and b.cksum == 0xec24 and b.res2 == 43690 and len(b.options) == 3 and isinstance(b.options[0], MIP6OptLLAddr) and isinstance(b.options[1], PadN) and isinstance(b.options[2], MIP6OptAltCoA) 5204*7dc08ffcSJunyu Lai 5205*7dc08ffcSJunyu Lai= MIP6MH_BRR / MIP6MH_BU / MIP6MH_BA hashret() and answers() 5206*7dc08ffcSJunyu Laihoa="2001:db8:9999::1" 5207*7dc08ffcSJunyu Laicoa="2001:db8:7777::1" 5208*7dc08ffcSJunyu Laicn="2001:db8:8888::1" 5209*7dc08ffcSJunyu Laiha="2001db8:6666::1" 5210*7dc08ffcSJunyu Laia=IPv6(raw(IPv6(src=cn, dst=hoa)/MIP6MH_BRR())) 5211*7dc08ffcSJunyu Laib=IPv6(raw(IPv6(src=coa, dst=cn)/IPv6ExtHdrDestOpt(options=HAO(hoa=hoa))/MIP6MH_BU(flags=0x01))) 5212*7dc08ffcSJunyu Laib2=IPv6(raw(IPv6(src=coa, dst=cn)/IPv6ExtHdrDestOpt(options=HAO(hoa=hoa))/MIP6MH_BU(flags=~0x01))) 5213*7dc08ffcSJunyu Laic=IPv6(raw(IPv6(src=cn, dst=coa)/IPv6ExtHdrRouting(type=2, addresses=[hoa])/MIP6MH_BA())) 5214*7dc08ffcSJunyu Laib.answers(a) and not a.answers(b) and c.answers(b) and not b.answers(c) and not c.answers(b2) 5215*7dc08ffcSJunyu Lai 5216*7dc08ffcSJunyu Lailen(b[IPv6ExtHdrDestOpt].options) == 2 5217*7dc08ffcSJunyu Lai 5218*7dc08ffcSJunyu Lai 5219*7dc08ffcSJunyu Lai############ 5220*7dc08ffcSJunyu Lai############ 5221*7dc08ffcSJunyu Lai+ Home Test Init Message 5222*7dc08ffcSJunyu Lai 5223*7dc08ffcSJunyu Lai= MIP6MH_HoTI - Build (default values) 5224*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_HoTI()) == b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x01\x00g\xf2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5225*7dc08ffcSJunyu Lai 5226*7dc08ffcSJunyu Lai= MIP6MH_HoTI - Dissection (default values) 5227*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x01\x00g\xf2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5228*7dc08ffcSJunyu Laib = a.payload 5229*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_HoTI) and b.nh==59 and b.mhtype == 1 and b.len== 1 and b.res == 0 and b.cksum == 0x67f2 and b.cookie == b'\x00'*8 5230*7dc08ffcSJunyu Lai 5231*7dc08ffcSJunyu Lai 5232*7dc08ffcSJunyu Lai= MIP6MH_HoTI - Build (specific values) 5233*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_HoTI(res=0x77, cksum=0x8899, cookie=b"\xAA"*8)) == b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x01w\x88\x99\x00\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa' 5234*7dc08ffcSJunyu Lai 5235*7dc08ffcSJunyu Lai= MIP6MH_HoTI - Dissection (specific values) 5236*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x01w\x88\x99\x00\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa') 5237*7dc08ffcSJunyu Laib=a.payload 5238*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_HoTI) and b.nh==59 and b.mhtype == 1 and b.len == 1 and b.res == 0x77 and b.cksum == 0x8899 and b.cookie == b'\xAA'*8 5239*7dc08ffcSJunyu Lai 5240*7dc08ffcSJunyu Lai 5241*7dc08ffcSJunyu Lai############ 5242*7dc08ffcSJunyu Lai############ 5243*7dc08ffcSJunyu Lai+ Care-of Test Init Message 5244*7dc08ffcSJunyu Lai 5245*7dc08ffcSJunyu Lai= MIP6MH_CoTI - Build (default values) 5246*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_CoTI()) == b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x02\x00f\xf2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5247*7dc08ffcSJunyu Lai 5248*7dc08ffcSJunyu Lai= MIP6MH_CoTI - Dissection (default values) 5249*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x02\x00f\xf2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5250*7dc08ffcSJunyu Laib = a.payload 5251*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_CoTI) and b.nh==59 and b.mhtype == 2 and b.len== 1 and b.res == 0 and b.cksum == 0x66f2 and b.cookie == b'\x00'*8 5252*7dc08ffcSJunyu Lai 5253*7dc08ffcSJunyu Lai= MIP6MH_CoTI - Build (specific values) 5254*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_CoTI(res=0x77, cksum=0x8899, cookie=b"\xAA"*8)) == b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x02w\x88\x99\x00\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa' 5255*7dc08ffcSJunyu Lai 5256*7dc08ffcSJunyu Lai= MIP6MH_CoTI - Dissection (specific values) 5257*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x10\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x01\x02w\x88\x99\x00\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa') 5258*7dc08ffcSJunyu Laib=a.payload 5259*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_CoTI) and b.nh==59 and b.mhtype == 2 and b.len == 1 and b.res == 0x77 and b.cksum == 0x8899 and b.cookie == b'\xAA'*8 5260*7dc08ffcSJunyu Lai 5261*7dc08ffcSJunyu Lai 5262*7dc08ffcSJunyu Lai############ 5263*7dc08ffcSJunyu Lai############ 5264*7dc08ffcSJunyu Lai+ Home Test Message 5265*7dc08ffcSJunyu Lai 5266*7dc08ffcSJunyu Lai= MIP6MH_HoT - Build (default values) 5267*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_HoT()) == b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x03\x00e\xe9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5268*7dc08ffcSJunyu Lai 5269*7dc08ffcSJunyu Lai= MIP6MH_HoT - Dissection (default values) 5270*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x03\x00e\xe9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5271*7dc08ffcSJunyu Laib = a.payload 5272*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_HoT) and b.nh==59 and b.mhtype == 3 and b.len== 2 and b.res == 0 and b.cksum == 0x65e9 and b.index == 0 and b.cookie == b'\x00'*8 and b.token == b'\x00'*8 5273*7dc08ffcSJunyu Lai 5274*7dc08ffcSJunyu Lai= MIP6MH_HoT - Build (specific values) 5275*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_HoT(res=0x77, cksum=0x8899, cookie=b"\xAA"*8, index=0xAABB, token=b'\xCC'*8)) == b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x03w\x88\x99\xaa\xbb\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc' 5276*7dc08ffcSJunyu Lai 5277*7dc08ffcSJunyu Lai= MIP6MH_HoT - Dissection (specific values) 5278*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x03w\x88\x99\xaa\xbb\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc') 5279*7dc08ffcSJunyu Laib = a.payload 5280*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_HoT) and b.nh==59 and b.mhtype == 3 and b.len== 2 and b.res == 0x77 and b.cksum == 0x8899 and b.index == 0xAABB and b.cookie == b'\xAA'*8 and b.token == b'\xCC'*8 5281*7dc08ffcSJunyu Lai 5282*7dc08ffcSJunyu Lai= MIP6MH_HoT answers 5283*7dc08ffcSJunyu Laia1, a2 = "2001:db8::1", "2001:db8::2" 5284*7dc08ffcSJunyu Laicookie = RandString(8)._fix() 5285*7dc08ffcSJunyu Laip1 = IPv6(src=a1, dst=a2)/MIP6MH_HoTI(cookie=cookie) 5286*7dc08ffcSJunyu Laip2 = IPv6(src=a2, dst=a1)/MIP6MH_HoT(cookie=cookie) 5287*7dc08ffcSJunyu Laip2_ko = IPv6(src=a2, dst=a1)/MIP6MH_HoT(cookie="".join(chr((orb(b'\xff') + 1) % 256))) 5288*7dc08ffcSJunyu Laiassert p1.hashret() == p2.hashret() and p2.answers(p1) and not p1.answers(p2) 5289*7dc08ffcSJunyu Laiassert p1.hashret() != p2_ko.hashret() and not p2_ko.answers(p1) and not p1.answers(p2_ko) 5290*7dc08ffcSJunyu Lai 5291*7dc08ffcSJunyu Lai 5292*7dc08ffcSJunyu Lai############ 5293*7dc08ffcSJunyu Lai############ 5294*7dc08ffcSJunyu Lai+ Care-of Test Message 5295*7dc08ffcSJunyu Lai 5296*7dc08ffcSJunyu Lai= MIP6MH_CoT - Build (default values) 5297*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_CoT()) == b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x04\x00d\xe9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5298*7dc08ffcSJunyu Lai 5299*7dc08ffcSJunyu Lai= MIP6MH_CoT - Dissection (default values) 5300*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x04\x00d\xe9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5301*7dc08ffcSJunyu Laib = a.payload 5302*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_HoT) and b.nh==59 and b.mhtype == 4 and b.len== 2 and b.res == 0 and b.cksum == 0x64e9 and b.index == 0 and b.cookie == b'\x00'*8 and b.token == b'\x00'*8 5303*7dc08ffcSJunyu Lai 5304*7dc08ffcSJunyu Lai= MIP6MH_CoT - Build (specific values) 5305*7dc08ffcSJunyu Lairaw(IPv6(src="2001:db8::1", dst="2001:db8::2")/MIP6MH_CoT(res=0x77, cksum=0x8899, cookie=b"\xAA"*8, index=0xAABB, token=b'\xCC'*8)) == b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x04w\x88\x99\xaa\xbb\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc' 5306*7dc08ffcSJunyu Lai 5307*7dc08ffcSJunyu Lai= MIP6MH_CoT - Dissection (specific values) 5308*7dc08ffcSJunyu Laia=IPv6(b'`\x00\x00\x00\x00\x18\x87@ \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02;\x02\x04w\x88\x99\xaa\xbb\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc') 5309*7dc08ffcSJunyu Laib = a.payload 5310*7dc08ffcSJunyu Laia.nh == 135 and isinstance(b, MIP6MH_CoT) and b.nh==59 and b.mhtype == 4 and b.len== 2 and b.res == 0x77 and b.cksum == 0x8899 and b.index == 0xAABB and b.cookie == b'\xAA'*8 and b.token == b'\xCC'*8 5311*7dc08ffcSJunyu Lai 5312*7dc08ffcSJunyu Lai 5313*7dc08ffcSJunyu Lai############ 5314*7dc08ffcSJunyu Lai############ 5315*7dc08ffcSJunyu Lai+ Binding Update Message 5316*7dc08ffcSJunyu Lai 5317*7dc08ffcSJunyu Lai= MIP6MH_BU - build (default values) 5318*7dc08ffcSJunyu Lais= b'`\x00\x00\x00\x00(<@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87\x02\x01\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;\x01\x05\x00\xee`\x00\x00\xd0\x00\x00\x03\x01\x02\x00\x00' 5319*7dc08ffcSJunyu Lairaw(IPv6()/IPv6ExtHdrDestOpt(options=[HAO()])/MIP6MH_BU()) == s 5320*7dc08ffcSJunyu Lai 5321*7dc08ffcSJunyu Lai= MIP6MH_BU - dissection (default values) 5322*7dc08ffcSJunyu Laip = IPv6(s) 5323*7dc08ffcSJunyu Laip[MIP6MH_BU].len == 1 5324*7dc08ffcSJunyu Lai 5325*7dc08ffcSJunyu Lai= MIP6MH_BU - build 5326*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00P<@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87\x02\x01\x02\x00\x00\xc9\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\xfe;\x06\x05\x00\xea\xf2\x00\x00\xd0\x00\x00*\x01\x00\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5327*7dc08ffcSJunyu Lairaw(IPv6()/IPv6ExtHdrDestOpt(options=[HAO(hoa='2001:db8::cafe')])/MIP6MH_BU(mhtime=42, options=[MIP6OptAltCoA(),MIP6OptMobNetPrefix()])) == s 5328*7dc08ffcSJunyu Lai 5329*7dc08ffcSJunyu Lai= MIP6MH_BU - dissection 5330*7dc08ffcSJunyu Laip = IPv6(s) 5331*7dc08ffcSJunyu Laip[MIP6MH_BU].cksum == 0xeaf2 and p[MIP6MH_BU].len == 6 and len(p[MIP6MH_BU].options) == 4 and p[MIP6MH_BU].mhtime == 42 5332*7dc08ffcSJunyu Lai 5333*7dc08ffcSJunyu Lai 5334*7dc08ffcSJunyu Lai############ 5335*7dc08ffcSJunyu Lai############ 5336*7dc08ffcSJunyu Lai+ Binding ACK Message 5337*7dc08ffcSJunyu Lai 5338*7dc08ffcSJunyu Lai= MIP6MH_BA - build 5339*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00\x10\x87@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01;\x01\x06\x00\xbc\xb9\x00\x80\x00\x00\x00*\x01\x02\x00\x00' 5340*7dc08ffcSJunyu Lairaw(IPv6()/MIP6MH_BA(mhtime=42)) == s 5341*7dc08ffcSJunyu Lai 5342*7dc08ffcSJunyu Lai= MIP6MH_BA - dissection 5343*7dc08ffcSJunyu Laip = IPv6(s) 5344*7dc08ffcSJunyu Laip[MIP6MH_BA].cksum == 0xbcb9 and p[MIP6MH_BA].len == 1 and len(p[MIP6MH_BA].options) == 1 and p[MIP6MH_BA].mhtime == 42 5345*7dc08ffcSJunyu Lai 5346*7dc08ffcSJunyu Lai 5347*7dc08ffcSJunyu Lai############ 5348*7dc08ffcSJunyu Lai############ 5349*7dc08ffcSJunyu Lai+ Binding ERR Message 5350*7dc08ffcSJunyu Lai 5351*7dc08ffcSJunyu Lai= MIP6MH_BE - build 5352*7dc08ffcSJunyu Lais = b'`\x00\x00\x00\x00\x18\x87@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01;\x02\x07\x00\xbbY\x02\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02' 5353*7dc08ffcSJunyu Lairaw(IPv6()/MIP6MH_BE(status=2, ha='1::2')) == s 5354*7dc08ffcSJunyu Lai 5355*7dc08ffcSJunyu Lai= MIP6MH_BE - dissection 5356*7dc08ffcSJunyu Laip = IPv6(s) 5357*7dc08ffcSJunyu Laip[MIP6MH_BE].cksum=0xba10 and p[MIP6MH_BE].len == 1 and len(p[MIP6MH_BE].options) == 1 5358*7dc08ffcSJunyu Lai 5359*7dc08ffcSJunyu Lai 5360*7dc08ffcSJunyu Lai############ 5361*7dc08ffcSJunyu Lai############ 5362*7dc08ffcSJunyu Lai+ Netflow v5 5363*7dc08ffcSJunyu Lai 5364*7dc08ffcSJunyu Lai= NetflowHeaderV5 - basic building 5365*7dc08ffcSJunyu Lai 5366*7dc08ffcSJunyu Lairaw(NetflowHeader()/NetflowHeaderV5()) == b'\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5367*7dc08ffcSJunyu Lai 5368*7dc08ffcSJunyu Lairaw(NetflowHeaderV5(engineID=42)) == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x00\x00' 5369*7dc08ffcSJunyu Lai 5370*7dc08ffcSJunyu Lairaw(NetflowRecordV5(dst="192.168.0.1")) == b'\x7f\x00\x00\x01\xc0\xa8\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5371*7dc08ffcSJunyu Lai 5372*7dc08ffcSJunyu Lairaw(NetflowHeader()/NetflowHeaderV5(count=1)/NetflowRecordV5(dst="192.168.0.1")) == b'\x00\x05\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x01\xc0\xa8\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00' 5373*7dc08ffcSJunyu Lai 5374*7dc08ffcSJunyu Lai 5375*7dc08ffcSJunyu Lai= NetflowHeaderV5 - basic dissection 5376*7dc08ffcSJunyu Lai 5377*7dc08ffcSJunyu Lainf5 = NetflowHeader(b'\x00\x05\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5378*7dc08ffcSJunyu Lainf5.version == 5 and nf5[NetflowHeaderV5].count == 2 and isinstance(nf5[NetflowRecordV5].payload, NetflowRecordV5) 5379*7dc08ffcSJunyu Lai 5380*7dc08ffcSJunyu Lai############ 5381*7dc08ffcSJunyu Lai############ 5382*7dc08ffcSJunyu Lai+ Netflow v9 5383*7dc08ffcSJunyu Lai 5384*7dc08ffcSJunyu Lai= NetflowHeaderV9 - advanced building 5385*7dc08ffcSJunyu Lai 5386*7dc08ffcSJunyu Laiimport time 5387*7dc08ffcSJunyu Lai 5388*7dc08ffcSJunyu Laipkt = NetflowHeader()/\ 5389*7dc08ffcSJunyu Lai NetflowHeaderV9(unixSecs=int(time.time()))/\ 5390*7dc08ffcSJunyu Lai NetflowFlowsetV9(templates=[ 5391*7dc08ffcSJunyu Lai NetflowTemplateV9(templateID=258, template_fields=[ 5392*7dc08ffcSJunyu Lai NetflowTemplateFieldV9(fieldType=1), 5393*7dc08ffcSJunyu Lai NetflowTemplateFieldV9(fieldType=62), 5394*7dc08ffcSJunyu Lai ]), 5395*7dc08ffcSJunyu Lai NetflowTemplateV9(templateID=257, template_fields=[ 5396*7dc08ffcSJunyu Lai NetflowTemplateFieldV9(fieldType=1), 5397*7dc08ffcSJunyu Lai NetflowTemplateFieldV9(fieldType=62), 5398*7dc08ffcSJunyu Lai ]), 5399*7dc08ffcSJunyu Lai ])/NetflowDataflowsetV9(templateID=258, records=[ 5400*7dc08ffcSJunyu Lai NetflowRecordV9(fieldValue=b"\x01\x02\x03\x05"), 5401*7dc08ffcSJunyu Lai NetflowRecordV9(fieldValue=b"\x05\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01"), 5402*7dc08ffcSJunyu Lai ])/NetflowDataflowsetV9(templateID=257, records=[ 5403*7dc08ffcSJunyu Lai NetflowRecordV9(fieldValue=b"\x01\x02\x03\x04"), 5404*7dc08ffcSJunyu Lai NetflowRecordV9(fieldValue=b"\x04\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01"), 5405*7dc08ffcSJunyu Lai ])/NetflowOptionsFlowsetV9(templateID=256, scopes=[NetflowOptionsFlowsetScopeV9(scopeFieldType=1, scopeFieldlength=4), 5406*7dc08ffcSJunyu Lai NetflowOptionsFlowsetScopeV9(scopeFieldType=1, scopeFieldlength=3)], 5407*7dc08ffcSJunyu Lai options=[NetflowOptionsFlowsetOptionV9(optionFieldType=1, optionFieldlength=2), 5408*7dc08ffcSJunyu Lai NetflowOptionsFlowsetOptionV9(optionFieldType=1, optionFieldlength=1)])/\ 5409*7dc08ffcSJunyu Lai NetflowOptionsDataRecordV9(templateID=256, records=[NetflowOptionsRecordScopeV9(fieldValue=b"\x01\x02\x03\x04"), 5410*7dc08ffcSJunyu Lai NetflowOptionsRecordScopeV9(fieldValue=b"\x01\x02\x03"), 5411*7dc08ffcSJunyu Lai NetflowOptionsRecordOptionV9(fieldValue=b"\x01\x02"), 5412*7dc08ffcSJunyu Lai NetflowOptionsRecordOptionV9(fieldValue=b"\x01")]) 5413*7dc08ffcSJunyu Lai 5414*7dc08ffcSJunyu Laiassert pkt[NetflowFlowsetV9].templates[0].template_fields[0].fieldLength == 4 5415*7dc08ffcSJunyu Laiassert pkt[NetflowFlowsetV9].templates[0].template_fields[1].fieldLength == 16 5416*7dc08ffcSJunyu Lai 5417*7dc08ffcSJunyu Lai= NetflowHeaderV9 - advanced dissection 5418*7dc08ffcSJunyu Lai 5419*7dc08ffcSJunyu Laid = NetflowHeader(raw(pkt)) 5420*7dc08ffcSJunyu Laid.show() 5421*7dc08ffcSJunyu Laiassert len(d[NetflowDataflowsetV9].records) == 2 5422*7dc08ffcSJunyu Laiassert d.getlayer(NetflowDataflowsetV9, templateID=257).records[0].fieldValue == b"\x01\x02\x03\x04" 5423*7dc08ffcSJunyu Laiassert d.getlayer(NetflowDataflowsetV9, templateID=257).records[1].fieldValue == b"\x04\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01" 5424*7dc08ffcSJunyu Lai 5425*7dc08ffcSJunyu Laiassert d.getlayer(NetflowDataflowsetV9, templateID=258).records[0].fieldValue == b"\x01\x02\x03\x05" 5426*7dc08ffcSJunyu Laiassert d.getlayer(NetflowDataflowsetV9, templateID=258).records[1].fieldValue == b"\x05\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01\x04\x03\x02\x01" 5427*7dc08ffcSJunyu Lai 5428*7dc08ffcSJunyu Laiassert d[NetflowOptionsFlowsetV9].scopes[0].scopeFieldType == 1 5429*7dc08ffcSJunyu Laiassert d[NetflowOptionsDataRecordV9].records[1].fieldValue == b"\x01\x02\x03" 5430*7dc08ffcSJunyu Laiassert d[NetflowOptionsDataRecordV9].records[3].fieldValue == b"\x01" 5431*7dc08ffcSJunyu Lai 5432*7dc08ffcSJunyu Lai############ 5433*7dc08ffcSJunyu Lai############ 5434*7dc08ffcSJunyu Lai+ pcap / pcapng format support 5435*7dc08ffcSJunyu Lai 5436*7dc08ffcSJunyu Lai= Variable creations 5437*7dc08ffcSJunyu Laifrom io import BytesIO 5438*7dc08ffcSJunyu Laipcapfile = BytesIO(b'\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00e\x00\x00\x00\xcf\xc5\xacVo*\n\x00(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00\xcf\xc5\xacV_-\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r\xcf\xc5\xacV\xf90\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00') 5439*7dc08ffcSJunyu Laipcapngfile = BytesIO(b'\n\r\r\n\\\x00\x00\x00M<+\x1a\x01\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x01\x00,\x00File created by merging: \nFile1: test.pcap \n\x04\x00\x08\x00mergecap\x00\x00\x00\x00\\\x00\x00\x00\x01\x00\x00\x00\\\x00\x00\x00e\x00\x00\x00\xff\xff\x00\x00\x02\x006\x00Unknown/not available in original file format(libpcap)\x00\x00\t\x00\x01\x00\x06\x00\x00\x00\x00\x00\x00\x00\\\x00\x00\x00\x06\x00\x00\x00H\x00\x00\x00\x00\x00\x00\x00\x8d*\x05\x00/\xfc[\xcd(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00H\x00\x00\x00\x06\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x8d*\x05\x00\x1f\xff[\xcd\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r<\x00\x00\x00\x06\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x8d*\x05\x00\xb9\x02\\\xcd\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00<\x00\x00\x00') 5440*7dc08ffcSJunyu Laipcapnanofile = BytesIO(b"M<\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00e\x00\x00\x00\xcf\xc5\xacV\xc9\xc1\xb5'(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00\xcf\xc5\xacV-;\xc1'\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r\xcf\xc5\xacV\x9aL\xcf'\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00") 5441*7dc08ffcSJunyu Lai 5442*7dc08ffcSJunyu Lai= Read a pcap file 5443*7dc08ffcSJunyu Laipktpcap = rdpcap(pcapfile) 5444*7dc08ffcSJunyu Lai 5445*7dc08ffcSJunyu Lai= Read a pcapng file 5446*7dc08ffcSJunyu Laipktpcapng = rdpcap(pcapngfile) 5447*7dc08ffcSJunyu Lai 5448*7dc08ffcSJunyu Lai= Read a pcap file with nanosecond precision 5449*7dc08ffcSJunyu Laipktpcapnano = rdpcap(pcapnanofile) 5450*7dc08ffcSJunyu Lai 5451*7dc08ffcSJunyu Lai= Check all packet lists are the same 5452*7dc08ffcSJunyu Laiassert list(pktpcap) == list(pktpcapng) == list(pktpcapnano) 5453*7dc08ffcSJunyu Laiassert [p.time for p in pktpcap] == [p.time for p in pktpcapng] == [p.time for p in pktpcapnano] 5454*7dc08ffcSJunyu Lai 5455*7dc08ffcSJunyu Lai= Check packets from pcap file 5456*7dc08ffcSJunyu Laiassert all(IP in pkt for pkt in pktpcap) 5457*7dc08ffcSJunyu Laiassert all(any(proto in pkt for pkt in pktpcap) for proto in [ICMP, UDP, TCP]) 5458*7dc08ffcSJunyu Lai 5459*7dc08ffcSJunyu Lai= Check wrpcap() 5460*7dc08ffcSJunyu Laiimport os, tempfile 5461*7dc08ffcSJunyu Laifdesc, filename = tempfile.mkstemp() 5462*7dc08ffcSJunyu Laifdesc = os.fdopen(fdesc, "wb") 5463*7dc08ffcSJunyu Laiwrpcap(fdesc, pktpcap) 5464*7dc08ffcSJunyu Laifdesc.close() 5465*7dc08ffcSJunyu Lai 5466*7dc08ffcSJunyu Lai= Check offline sniff() (by filename) 5467*7dc08ffcSJunyu Laiassert list(pktpcap) == list(sniff(offline=filename)) 5468*7dc08ffcSJunyu Lai 5469*7dc08ffcSJunyu Lai= Check offline sniff() (by file object) 5470*7dc08ffcSJunyu Laifdesc = open(filename, "rb") 5471*7dc08ffcSJunyu Laiassert list(pktpcap) == list(sniff(offline=fdesc)) 5472*7dc08ffcSJunyu Laifdesc.close() 5473*7dc08ffcSJunyu Lai 5474*7dc08ffcSJunyu Lai= Check offline sniff() with a filter (by filename) 5475*7dc08ffcSJunyu Lai~ tcpdump 5476*7dc08ffcSJunyu Laipktpcap_flt = [(proto, sniff(offline=filename, filter=proto.__name__.lower())) 5477*7dc08ffcSJunyu Lai for proto in [ICMP, UDP, TCP]] 5478*7dc08ffcSJunyu Laiassert all(list(pktpcap[proto]) == list(packets) for proto, packets in pktpcap_flt) 5479*7dc08ffcSJunyu Lai 5480*7dc08ffcSJunyu Lai= Check offline sniff() with a filter (by file object) 5481*7dc08ffcSJunyu Lai~ tcpdump 5482*7dc08ffcSJunyu Laifdesc = open(filename, "rb") 5483*7dc08ffcSJunyu Laipktpcap_tcp = sniff(offline=fdesc, filter="tcp") 5484*7dc08ffcSJunyu Laifdesc.close() 5485*7dc08ffcSJunyu Laiassert list(pktpcap[TCP]) == list(pktpcap_tcp) 5486*7dc08ffcSJunyu Laios.unlink(filename) 5487*7dc08ffcSJunyu Lai 5488*7dc08ffcSJunyu Lai= Check wrpcap(nano=True) 5489*7dc08ffcSJunyu Laifdesc, filename = tempfile.mkstemp() 5490*7dc08ffcSJunyu Laifdesc = os.fdopen(fdesc, "wb") 5491*7dc08ffcSJunyu Laipktpcapnano[0].time += 0.000000001 5492*7dc08ffcSJunyu Laiwrpcap(fdesc, pktpcapnano, nano=True) 5493*7dc08ffcSJunyu Laifdesc.close() 5494*7dc08ffcSJunyu Laipktpcapnanoread = rdpcap(filename) 5495*7dc08ffcSJunyu Laiassert pktpcapnanoread[0].time == pktpcapnano[0].time 5496*7dc08ffcSJunyu Laiassert pktpcapnanoread[0].time == pktpcap[0].time + 0.000000001 5497*7dc08ffcSJunyu Laios.unlink(filename) 5498*7dc08ffcSJunyu Lai 5499*7dc08ffcSJunyu Lai= Check PcapNg with nanosecond precision using obsolete packet block 5500*7dc08ffcSJunyu Lai* first packet from capture file icmp2.ntar -- https://wiki.wireshark.org/Development/PcapNg?action=AttachFile&do=view&target=icmp2.ntar 5501*7dc08ffcSJunyu Laipcapngfile = BytesIO(b'\n\r\r\n\x1c\x00\x00\x00M<+\x1a\x01\x00\x00\x00\xa8\x03\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x01\x00\x00\x00(\x00\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\r\x00\x01\x00\x04\x04K\x00\t\x00\x01\x00\tK=N\x00\x00\x00\x00(\x00\x00\x00\x02\x00\x00\x00n\x00\x00\x00\x00\x00\x00\x00e\x14\x00\x00)4\'ON\x00\x00\x00N\x00\x00\x00\x00\x12\xf0\x11h\xd6\x00\x13r\t{\xea\x08\x00E\x00\x00<\x90\xa1\x00\x00\x80\x01\x8e\xad\xc0\xa8M\x07\xc0\xa8M\x1a\x08\x00r[\x03\x00\xd8\x00abcdefghijklmnopqrstuvwabcdefghi\xeay$\xf6\x00\x00n\x00\x00\x00') 5502*7dc08ffcSJunyu Laipktpcapng = rdpcap(pcapngfile) 5503*7dc08ffcSJunyu Laiassert len(pktpcapng) == 1 5504*7dc08ffcSJunyu Laipkt = pktpcapng[0] 5505*7dc08ffcSJunyu Lai# weird, but wireshark agrees 5506*7dc08ffcSJunyu Laiassert pkt.time == 22425.352221737 5507*7dc08ffcSJunyu Laiassert isinstance(pkt, Ether) 5508*7dc08ffcSJunyu Laipkt = pkt.payload 5509*7dc08ffcSJunyu Laiassert isinstance(pkt, IP) 5510*7dc08ffcSJunyu Laipkt = pkt.payload 5511*7dc08ffcSJunyu Laiassert isinstance(pkt, ICMP) 5512*7dc08ffcSJunyu Laipkt = pkt.payload 5513*7dc08ffcSJunyu Laiassert isinstance(pkt, Raw) and pkt.load == b'abcdefghijklmnopqrstuvwabcdefghi' 5514*7dc08ffcSJunyu Laipkt = pkt.payload 5515*7dc08ffcSJunyu Laiassert isinstance(pkt, Padding) and pkt.load == b'\xeay$\xf6' 5516*7dc08ffcSJunyu Laipkt = pkt.payload 5517*7dc08ffcSJunyu Laiassert isinstance(pkt, NoPayload) 5518*7dc08ffcSJunyu Lai 5519*7dc08ffcSJunyu Lai= Check PcapNg using Simple Packet Block 5520*7dc08ffcSJunyu Lai* previous file with the (obsolete) packet block replaced by a Simple Packet Block 5521*7dc08ffcSJunyu Laipcapngfile = BytesIO(b'\n\r\r\n\x1c\x00\x00\x00M<+\x1a\x01\x00\x00\x00\xa8\x03\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x01\x00\x00\x00(\x00\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\r\x00\x01\x00\x04\x04K\x00\t\x00\x01\x00\tK=N\x00\x00\x00\x00(\x00\x00\x00\x03\x00\x00\x00`\x00\x00\x00N\x00\x00\x00\x00\x12\xf0\x11h\xd6\x00\x13r\t{\xea\x08\x00E\x00\x00<\x90\xa1\x00\x00\x80\x01\x8e\xad\xc0\xa8M\x07\xc0\xa8M\x1a\x08\x00r[\x03\x00\xd8\x00abcdefghijklmnopqrstuvwabcdefghi\xeay$\xf6\x00\x00`\x00\x00\x00') 5522*7dc08ffcSJunyu Laipktpcapng = rdpcap(pcapngfile) 5523*7dc08ffcSJunyu Laiassert len(pktpcapng) == 1 5524*7dc08ffcSJunyu Laipkt = pktpcapng[0] 5525*7dc08ffcSJunyu Laiassert isinstance(pkt, Ether) 5526*7dc08ffcSJunyu Laipkt = pkt.payload 5527*7dc08ffcSJunyu Laiassert isinstance(pkt, IP) 5528*7dc08ffcSJunyu Laipkt = pkt.payload 5529*7dc08ffcSJunyu Laiassert isinstance(pkt, ICMP) 5530*7dc08ffcSJunyu Laipkt = pkt.payload 5531*7dc08ffcSJunyu Laiassert isinstance(pkt, Raw) and pkt.load == b'abcdefghijklmnopqrstuvwabcdefghi' 5532*7dc08ffcSJunyu Laipkt = pkt.payload 5533*7dc08ffcSJunyu Laiassert isinstance(pkt, Padding) and pkt.load == b'\xeay$\xf6' 5534*7dc08ffcSJunyu Laipkt = pkt.payload 5535*7dc08ffcSJunyu Laiassert isinstance(pkt, NoPayload) 5536*7dc08ffcSJunyu Lai 5537*7dc08ffcSJunyu Lai= Check tcpdump() 5538*7dc08ffcSJunyu Lai~ tcpdump 5539*7dc08ffcSJunyu Lai* No very specific tests because we do not want to depend on tcpdump output 5540*7dc08ffcSJunyu Laipcapfile = BytesIO(b'\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00e\x00\x00\x00\xcf\xc5\xacVo*\n\x00(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00\xcf\xc5\xacV_-\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r\xcf\xc5\xacV\xf90\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00') 5541*7dc08ffcSJunyu Laidata = tcpdump(pcapfile, dump=True, args=['-n']).split(b'\n') 5542*7dc08ffcSJunyu Laiprint(data) 5543*7dc08ffcSJunyu Laiassert b'IP 127.0.0.1.20 > 127.0.0.1.80:' in data[0] 5544*7dc08ffcSJunyu Laiassert b'IP 127.0.0.1.53 > 127.0.0.1.53:' in data[1] 5545*7dc08ffcSJunyu Laiassert b'IP 127.0.0.1 > 127.0.0.1:' in data[2] 5546*7dc08ffcSJunyu Lai 5547*7dc08ffcSJunyu Lai= Check tcpdump() command with tshark 5548*7dc08ffcSJunyu Lai~ tshark 5549*7dc08ffcSJunyu Laipcapfile = BytesIO(b'\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00e\x00\x00\x00\xcf\xc5\xacVo*\n\x00(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00\xcf\xc5\xacV_-\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r\xcf\xc5\xacV\xf90\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00') 5550*7dc08ffcSJunyu Laivalues = [tuple(int(val) for val in line[:-1].split(b'\t')) for line in tcpdump(pcapfile, prog=conf.prog.tshark, getfd=True, args=['-T', 'fields', '-e', 'ip.ttl', '-e', 'ip.proto'])] 5551*7dc08ffcSJunyu Laiassert values == [(64, 6), (64, 17), (64, 1)] 5552*7dc08ffcSJunyu Lai 5553*7dc08ffcSJunyu Lai= Run scapy's tshark command 5554*7dc08ffcSJunyu Lai~ netaccess 5555*7dc08ffcSJunyu Laitshark(count=1, timeout=3) 5556*7dc08ffcSJunyu Lai 5557*7dc08ffcSJunyu Lai= Check Raw IP pcap files 5558*7dc08ffcSJunyu Lai 5559*7dc08ffcSJunyu Laiimport tempfile 5560*7dc08ffcSJunyu Laifilename = tempfile.mktemp(suffix=".pcap") 5561*7dc08ffcSJunyu Laiwrpcap(filename, [IP()/UDP(), IPv6()/UDP()], linktype=DLT_RAW) 5562*7dc08ffcSJunyu Laipackets = rdpcap(filename) 5563*7dc08ffcSJunyu Laiassert(isinstance(packets[0], IP) and isinstance(packets[1], IPv6)) 5564*7dc08ffcSJunyu Lai 5565*7dc08ffcSJunyu Lai############ 5566*7dc08ffcSJunyu Lai############ 5567*7dc08ffcSJunyu Lai+ LLMNR protocol 5568*7dc08ffcSJunyu Lai 5569*7dc08ffcSJunyu Lai= Simple packet dissection 5570*7dc08ffcSJunyu Laipkt = Ether(b'\x11\x11\x11\x11\x11\x11\x99\x99\x99\x99\x99\x99\x08\x00E\x00\x00(\x00\x01\x00\x00@\x11:\xa4\xc0\xa8\x00w\x7f\x00\x00\x01\x14\xeb\x14\xeb\x00\x14\x95\xcf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5571*7dc08ffcSJunyu Laiassert pkt.sport == 5355 5572*7dc08ffcSJunyu Laiassert pkt.dport == 5355 5573*7dc08ffcSJunyu Laiassert pkt[LLMNRQuery].opcode == 0 5574*7dc08ffcSJunyu Lai 5575*7dc08ffcSJunyu Lai= Packet build / dissection 5576*7dc08ffcSJunyu Laipkt = UDP(raw(UDP()/LLMNRResponse())) 5577*7dc08ffcSJunyu Laiassert LLMNRResponse in pkt 5578*7dc08ffcSJunyu Laiassert pkt.qr == 1 5579*7dc08ffcSJunyu Laiassert pkt.c == 0 5580*7dc08ffcSJunyu Laiassert pkt.tc == 0 5581*7dc08ffcSJunyu Laiassert pkt.z == 0 5582*7dc08ffcSJunyu Laiassert pkt.rcode == 0 5583*7dc08ffcSJunyu Laiassert pkt.qdcount == 0 5584*7dc08ffcSJunyu Laiassert pkt.arcount == 0 5585*7dc08ffcSJunyu Laiassert pkt.nscount == 0 5586*7dc08ffcSJunyu Laiassert pkt.ancount == 0 5587*7dc08ffcSJunyu Lai 5588*7dc08ffcSJunyu Lai= Answers - building 5589*7dc08ffcSJunyu Laia = UDP()/LLMNRResponse(id=12) 5590*7dc08ffcSJunyu Laib = UDP()/LLMNRQuery(id=12) 5591*7dc08ffcSJunyu Laiassert a.answers(b) 5592*7dc08ffcSJunyu Laiassert not b.answers(a) 5593*7dc08ffcSJunyu Laiassert b.hashret() == b'\x00\x0c' 5594*7dc08ffcSJunyu Lai 5595*7dc08ffcSJunyu Lai= Answers - dissecting 5596*7dc08ffcSJunyu Laia = Ether(b'\xd0P\x99V\xdd\xf9\x14\x0cv\x8f\xfe(\x08\x00E\x00\x00(\x00\x01\x00\x00@\x11:\xa4\x7f\x00\x00\x01\xc0\xa8\x00w\x14\xeb\x14\xeb\x00\x14\x95\xcf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5597*7dc08ffcSJunyu Laib = Ether(b'\x14\x0cv\x8f\xfe(\xd0P\x99V\xdd\xf9\x08\x00E\x00\x00(\x00\x01\x00\x00@\x11:\xa4\xc0\xa8\x00w\x7f\x00\x00\x01\x14\xeb\x14\xeb\x00\x14\x15\xcf\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00') 5598*7dc08ffcSJunyu Laiassert b.answers(a) 5599*7dc08ffcSJunyu Laiassert not a.answers(b) 5600*7dc08ffcSJunyu Lai 5601*7dc08ffcSJunyu Lai############ 5602*7dc08ffcSJunyu Lai############ 5603*7dc08ffcSJunyu Lai+ LLTD protocol 5604*7dc08ffcSJunyu Lai 5605*7dc08ffcSJunyu Lai= Simple packet dissection 5606*7dc08ffcSJunyu Laipkt = Ether(b'\xff\xff\xff\xff\xff\xff\x86\x14\xf0\xc7[.\x88\xd9\x01\x00\x00\x01\xff\xff\xff\xff\xff\xff\x86\x14\xf0\xc7[.\x00\x00\xfe\xe9[\xa9\xaf\xc1\x0bS[\xa9\xaf\xc1\x0bS\x01\x06}[G\x8f\xec.\x02\x04p\x00\x00\x00\x03\x04\x00\x00\x00\x06\x07\x04\xac\x19\x88\xe4\t\x02\x00l\n\x08\x00\x00\x00\x00\x00\x0fB@\x0c\x04\x00\x08=`\x0e\x00\x0f\x0eT\x00E\x00S\x00T\x00-\x00A\x00P\x00\x12\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x04\x00\x00\x00\x00\x15\x01\x02\x18\x00\x19\x02\x04\x00\x1a\x00\x00') 5607*7dc08ffcSJunyu Laiassert pkt.dst == pkt.real_dst 5608*7dc08ffcSJunyu Laiassert pkt.src == pkt.real_src 5609*7dc08ffcSJunyu Laiassert pkt.current_mapper_address == pkt.apparent_mapper_address 5610*7dc08ffcSJunyu Laiassert pkt.mac == '7d:5b:47:8f:ec:2e' 5611*7dc08ffcSJunyu Laiassert pkt.hostname == "TEST-AP" 5612*7dc08ffcSJunyu Laiassert isinstance(pkt[LLTDAttributeEOP].payload, NoPayload) 5613*7dc08ffcSJunyu Lai 5614*7dc08ffcSJunyu Lai= Packet build / dissection 5615*7dc08ffcSJunyu Laipkt = Ether(raw(Ether(dst=ETHER_BROADCAST, src=RandMAC()) / LLTD(tos=0, function=0))) 5616*7dc08ffcSJunyu Laiassert LLTD in pkt 5617*7dc08ffcSJunyu Laiassert pkt.dst == pkt.real_dst 5618*7dc08ffcSJunyu Laiassert pkt.src == pkt.real_src 5619*7dc08ffcSJunyu Laiassert pkt.tos == 0 5620*7dc08ffcSJunyu Laiassert pkt.function == 0 5621*7dc08ffcSJunyu Lai 5622*7dc08ffcSJunyu Lai= Attribute build / dissection 5623*7dc08ffcSJunyu Laiassert isinstance(LLTDAttribute(), LLTDAttribute) 5624*7dc08ffcSJunyu Laiassert isinstance(LLTDAttribute(raw(LLTDAttribute())), LLTDAttribute) 5625*7dc08ffcSJunyu Laiassert all(isinstance(LLTDAttribute(type=i), LLTDAttribute) for i in six.moves.range(256)) 5626*7dc08ffcSJunyu Laiassert all(isinstance(LLTDAttribute(raw(LLTDAttribute(type=i))), LLTDAttribute) for i in six.moves.range(256)) 5627*7dc08ffcSJunyu Lai 5628*7dc08ffcSJunyu Lai= Large TLV 5629*7dc08ffcSJunyu Laim1, m2, seq = RandMAC()._fix(), RandMAC()._fix(), 123 5630*7dc08ffcSJunyu Laipreqbase = Ether(src=m1, dst=m2) / LLTD() / \ 5631*7dc08ffcSJunyu Lai LLTDQueryLargeTlv(type="Detailed Icon Image") 5632*7dc08ffcSJunyu Laiprespbase = Ether(src=m2, dst=m1) / LLTD() / \ 5633*7dc08ffcSJunyu Lai LLTDQueryLargeTlvResp() 5634*7dc08ffcSJunyu Laiplist = [] 5635*7dc08ffcSJunyu Laipkt = preqbase.copy() 5636*7dc08ffcSJunyu Laipkt.seq = seq 5637*7dc08ffcSJunyu Laiplist.append(Ether(raw(pkt))) 5638*7dc08ffcSJunyu Laipkt = prespbase.copy() 5639*7dc08ffcSJunyu Laipkt.seq = seq 5640*7dc08ffcSJunyu Laipkt.flags = "M" 5641*7dc08ffcSJunyu Laipkt.value = "abcd" 5642*7dc08ffcSJunyu Laiplist.append(Ether(raw(pkt))) 5643*7dc08ffcSJunyu Laipkt = preqbase.copy() 5644*7dc08ffcSJunyu Laipkt.seq = seq + 1 5645*7dc08ffcSJunyu Laipkt.offset = 4 5646*7dc08ffcSJunyu Laiplist.append(Ether(raw(pkt))) 5647*7dc08ffcSJunyu Laipkt = prespbase.copy() 5648*7dc08ffcSJunyu Laipkt.seq = seq + 1 5649*7dc08ffcSJunyu Laipkt.value = "efg" 5650*7dc08ffcSJunyu Laiplist.append(Ether(raw(pkt))) 5651*7dc08ffcSJunyu Laibuilder = LargeTlvBuilder() 5652*7dc08ffcSJunyu Laibuilder.parse(plist) 5653*7dc08ffcSJunyu Laidata = builder.get_data() 5654*7dc08ffcSJunyu Laiassert len(data) == 1 5655*7dc08ffcSJunyu Laikey, value = data.popitem() 5656*7dc08ffcSJunyu Laiassert key.endswith(' [Detailed Icon Image]') 5657*7dc08ffcSJunyu Laiassert value == 'abcdefg' 5658*7dc08ffcSJunyu Lai 5659*7dc08ffcSJunyu Lai 5660*7dc08ffcSJunyu Lai############ 5661*7dc08ffcSJunyu Lai############ 5662*7dc08ffcSJunyu Lai+ Test fragment() / defragment() functions 5663*7dc08ffcSJunyu Lai 5664*7dc08ffcSJunyu Lai= fragment() 5665*7dc08ffcSJunyu Laipayloadlen, fragsize = 100, 8 5666*7dc08ffcSJunyu Laiassert fragsize % 8 == 0 5667*7dc08ffcSJunyu Laifragcount = (payloadlen // fragsize) + bool(payloadlen % fragsize) 5668*7dc08ffcSJunyu Lai* create the packet 5669*7dc08ffcSJunyu Laipkt = IP() / ("X" * payloadlen) 5670*7dc08ffcSJunyu Lai* create the fragments 5671*7dc08ffcSJunyu Laifrags = fragment(pkt, fragsize) 5672*7dc08ffcSJunyu Lai* count the fragments 5673*7dc08ffcSJunyu Laiassert len(frags) == fragcount 5674*7dc08ffcSJunyu Lai* each fragment except the last one should have MF set 5675*7dc08ffcSJunyu Laiassert all(p.flags == 1 for p in frags[:-1]) 5676*7dc08ffcSJunyu Laiassert frags[-1].flags == 0 5677*7dc08ffcSJunyu Lai* each fragment except the last one should have a payload of fragsize bytes 5678*7dc08ffcSJunyu Laiassert all(len(p.payload) == 8 for p in frags[:-1]) 5679*7dc08ffcSJunyu Laiassert len(frags[-1].payload) == ((payloadlen % fragsize) or fragsize) 5680*7dc08ffcSJunyu Lai 5681*7dc08ffcSJunyu Lai= fragment() and overloaded_fields 5682*7dc08ffcSJunyu Laipkt1 = Ether() / IP() / UDP() 5683*7dc08ffcSJunyu Laipkt2 = fragment(pkt1)[0] 5684*7dc08ffcSJunyu Laipkt3 = pkt2.__class__(raw(pkt2)) 5685*7dc08ffcSJunyu Laiassert pkt1[IP].proto == pkt2[IP].proto == pkt3[IP].proto 5686*7dc08ffcSJunyu Lai 5687*7dc08ffcSJunyu Lai= fragment() already fragmented packets 5688*7dc08ffcSJunyu Laipayloadlen = 1480 * 3 5689*7dc08ffcSJunyu Laiffrags = fragment(IP() / ("X" * payloadlen), 1480) 5690*7dc08ffcSJunyu Laiffrags = fragment(ffrags, 1400) 5691*7dc08ffcSJunyu Lailen(ffrags) == 6 5692*7dc08ffcSJunyu Lai* each fragment except the last one should have MF set 5693*7dc08ffcSJunyu Laiassert all(p.flags == 1 for p in ffrags[:-1]) 5694*7dc08ffcSJunyu Laiassert ffrags[-1].flags == 0 5695*7dc08ffcSJunyu Lai* fragment offset should be well computed 5696*7dc08ffcSJunyu Laiplen = 0 5697*7dc08ffcSJunyu Laifor p in ffrags: 5698*7dc08ffcSJunyu Lai assert p.frag == plen // 8 5699*7dc08ffcSJunyu Lai plen += len(p.payload) 5700*7dc08ffcSJunyu Lai 5701*7dc08ffcSJunyu Laiassert plen == payloadlen 5702*7dc08ffcSJunyu Lai 5703*7dc08ffcSJunyu Lai= defrag() 5704*7dc08ffcSJunyu Lainonfrag, unfrag, badfrag = defrag(frags) 5705*7dc08ffcSJunyu Laiassert not nonfrag 5706*7dc08ffcSJunyu Laiassert not badfrag 5707*7dc08ffcSJunyu Laiassert len(unfrag) == 1 5708*7dc08ffcSJunyu Lai 5709*7dc08ffcSJunyu Lai= defragment() 5710*7dc08ffcSJunyu Laidefrags = defragment(frags) 5711*7dc08ffcSJunyu Lai* we should have one single packet 5712*7dc08ffcSJunyu Laiassert len(defrags) == 1 5713*7dc08ffcSJunyu Lai* which should be the same as pkt reconstructed 5714*7dc08ffcSJunyu Laiassert defrags[0] == IP(raw(pkt)) 5715*7dc08ffcSJunyu Lai 5716*7dc08ffcSJunyu Lai= defrag() / defragment() - Real DNS packets 5717*7dc08ffcSJunyu Lai 5718*7dc08ffcSJunyu Laiimport base64 5719*7dc08ffcSJunyu Lai 5720*7dc08ffcSJunyu Laia = base64.b64decode('bnmYJ63mREVTUwEACABFAAV0U8UgADIR+u0EAgIECv0DxAA1sRIL83Z7gbCBgAABAB0AAAANA255YwNnb3YAAP8AAcAMAAYAAQAAA4QAKgZ2d2FsbDDADApob3N0bWFzdGVywAx4Og5wAAA4QAAADhAAJOoAAAACWMAMAC4AAQAAA4QAmwAGCAIAAAOEWWm9jVlgdP0mfQNueWMDZ292AHjCDBL0C1rEKUjsuG6Zg3+Rs6gj6llTABm9UZnWk+rRu6nPqW4N7AEllTYqNK+r6uFJ2KhfG3MDPS1F/M5QCVR8qkcbgrqPVRBJAG67/ZqpGORppQV6ib5qqo4ST5KyrgKpa8R1fWH8Fyp881NWLOZekM3TQyczcLFrvw9FFjdRwAwAAQABAAADhAAEobkenMAMAC4AAQAAA4QAmwABCAIAAAOEWWm9jVlgdP0mfQNueWMDZ292ABW8t5tEv9zTLdB6UsoTtZIF6Kx/c4ukIud8UIGM0XdXnJYx0ZDyPDyLVy2rfwmXdEph3KBWAi5dpRT16nthlMmWPQxD1ecg9rc8jcaTGo8z833fYJjzPT8MpMTxhapu4ANSBVbv3LRBnce2abu9QaoCdlHPFHdNphp6JznCLt4jwAwAMAABAAADhAEIAQEDCAMBAAF77useCfI+6T+m6Tsf2ami8/q5XDtgS0Ae7F0jUZ0cpyYxy/28DLFjJaS57YiwAYaabkkugxsoSv9roqBNZjD+gjoUB+MK8fmfaqqkSOgQuIQLZJeOORWD0gAj8mekw+S84DECylbKyYEGf8CB3/59IfV+YkTcHhXBYrMNxhMK1Eiypz4cgYxXiYUSz7jbOmqE3hU2GinhRmNW4Trt4ImUruSO+iQbTTj6LtCtIsScOF4vn4gcLJURLHOs+mf1NU9Yqq9mPC9wlYZk+8rwqcjVIiRpDmmv83huv4be1x1kkz2YqTFwtc33Fzt6SZk96Qtk2wCgg8ZQqLKGx5uwIIyrwAwAMAABAAADhAEIAQEDCAMBAAGYc7SWbSinSc3u8ZcYlO0+yZcJD1vqC5JARxZjKNzszHxc9dpabBtR9covySVu1YaBVrlxNBzfyFd4PKyjvPcBER5sQImoCikC+flD5NwXJbnrO1SG0Kzp8XXDCZpBASxuBF0vjUSU9yMqp0FywCrIfrbfCcOGAFIVP0M2u8dVuoI4nWbkRFc0hiRefoxc1O2IdpR22GAp2OYeeN2/tnFBz/ZMQitU2IZIKBMybKmWLC96tPcqVdWJX6+M1an1ox0+NqBZuPjsCx0/lZbuB/rLHppJOmkRc7q2Fw/tpHOyWHV+ulCfXem9Up/sbrMcP7uumFz0FeNhBPtg3u5kA5OVwAwAMAABAAADhACIAQADCAMBAAF5mlzmmq8cs6Hff0qZLlGKYCGPlG23HZw2qAd7N2FmrLRqPQ0R/hbnw54MYiIs18zyfm2J+ZmzUvGd+gjHGx3ooRRffQQ4RFLq6g6oxaLTbtvqPFbWt4Kr2GwX3UslgZCzH5mXLNpPI2QoetIcQCNRdcxn5QpWxPppCVXbKdNvvcAMADAAAQAAA4QAiAEAAwgDAQABqeGHtNFc0Yh6Pp/aM+ntlDW1fLwuAWToGQhmnQFBTiIUZlH7QMjwh5oMExNp5/ABUb3qBsyk9CLanRfateRgFJCYCNYofrI4S2yqT5X9vvtCXeIoG/QqMSl3PJk4ClYufIKjMPgl5IyN6yBIMNmmsATlMMu5TxM68a/CLCh92L3ADAAuAAEAAAOEAJsAMAgCAAADhFlpvY1ZYHT9Jn0DbnljA2dvdgAViVpFoYwy9dMUbOPDHTKt/LOtoicvtQbHeXiUSQeBkGWTLyiPc/NTW9ZC4WK5AuSj/0+V') 5721*7dc08ffcSJunyu Laib = base64.b64decode('bnmYJ63mREVTUwEACABFAAV0U8UgrDIR+kEEAgIECv0DxApz1F5olFRytjhNlG/JbdW0NSAFeUUF4rBRqsly/h6nFWKoQfih35Lm+BFLE0FoMaikWCjGJQIuf0CXiElMSQifiDM+KTeecNkCgTXADAAuAAEAAAOEARsAMAgCAAADhFlpvY1ZYHT9VwUDbnljA2dvdgAdRZxvC6VlbYUVarYjan0/PlP70gSz1SiYCDZyw5dsGo9vrZd+lMcAm5GFjtKYDXeCb5gVuegzHSNzxDQOa5lVKLQZfXgVHsl3jguCpYwKAygRR3mLBGtnhPrbYcPGMOzIxO6/UE5Hltx9SDqKNe2+rtVeZs5FyHQE5pTVGVjNED9iaauEW9UF3bwEP3K+wLgxWeVycjNry/l4vt9Z0fyTU15kogCZG8MXyStJlzIgdzVZRB96gTJbGBDRFQJfbE2Af+INl0HRY4p+bqQYwFomWg6Tzs30LcqAnkptknb5peUNmQTBI/MU00A6NeVJxkKK3+lf2EuuiJl+nFpfWiKpwAwAMwABAAADhAAJAQAADASqu8zdwAwALgABAAADhACbADMIAgAAA4RZab2NWWB0/SZ9A255YwNnb3YAVhcqgSl33lqjLLFR8pQ2cNhdX7dKZ2gRy0vUHOa+980Nljcj4I36rfjEVJCLKodpbseQl0OeTsbfNfqOmi1VrsypDl+YffyPMtHferm02xBK0agcTMdP/glpuKzdKHTiHTlnSOuBpPnEpgxYPNeBGx8yzMvIaU5rOCxuO49Sh/PADAACAAEAAAOEAAoHdndhbGw0YcAMwAwAAgABAAADhAAKB3Z3YWxsMmHADMAMAAIAAQAAA4QACgd2d2FsbDNhwAzADAACAAEAAAOEAAoHdndhbGwxYcAMwAwALgABAAADhACbAAIIAgAAA4RZab2NWWB0/SZ9A255YwNnb3YANn7LVY7YsKLtpH7LKhUz0SVsM/Gk3T/V8I9wIEZ4vEklM9hI92D2aYe+9EKxOts+/py6itZfANXU197pCufktASDxlH5eWSc9S2uqrRnUNnMUe4p3Jy9ZCGhiHDemgFphKGWYTNZUJoML2+SDzbv9tXo4sSbZiKJCDkNdzSv2lfADAAQAAEAAAOEAEVEZ29vZ2xlLXNpdGUtdmVyaWZpY2F0aW9uPWMycnhTa2VPZUxpSG5iY24tSXhZZm5mQjJQcTQzU3lpeEVka2k2ODZlNDTADAAQAAEAAAOEADc2dj1zcGYxIGlwNDoxNjEuMTg1LjIuMC8yNSBpcDQ6MTY3LjE1My4xMzIuMC8yNSBteCAtYWxswAwALgABAAADhACbABAIAgAAA4RZab2NWWB0/SZ9A255YwNnb3YAjzLOj5HUtVGhi/emNG90g2zK80hrI6gh2d+twgVLYgWebPeTI2D2ylobevXeq5rK5RQgbg2iG1UiTBnlKPgLPYt8ZL+bi+/v5NTaqHfyHFYdKzZeL0dhrmebRbYzG7tzOllcAOOqieeO29Yr4gz1rpiU6g75vkz6yQoHNfmNVMXADAAPAAEAAAOEAAsAZAZ2d2FsbDLADMAMAA8AAQAAA4QACwBkBnZ3YWxsNMAMwAwADwABAAADhAALAAoGdndhbGwzwAzADAAPAAEAAAOEAAsACgZ2d2FsbDXADMAMAA8AAQAAA4QACwAKBnZ3YWxsNsAMwAwADwABAAADhAALAAoGdndhbGw3wAzADAAPAAEAAAOEAAsACgZ2d2FsbDjADMAMAA8AAQAAA4QACwBkBnZ3YWxsMcAMwAwALgABAAADhACbAA8IAgAAA4RZab2NWWB0/SZ9A255YwNnb3YAooXBSj6PfsdBd8sEN/2AA4cvOl2bcioO') 5722*7dc08ffcSJunyu Laic = base64.b64decode('bnmYJ63mREVTUwEACABFAAFHU8UBWDIRHcMEAgIECv0DxDtlufeCT1zQktat4aEVA8MF0FO1sNbpEQtqfu5Al//OJISaRvtaArR/tLUj2CoZjS7uEnl7QpP/Ui/gR0YtyLurk9yTw7Vei0lSz4cnaOJqDiTGAKYwzVxjnoR1F3n8lplgQaOalVsHx9UAAQABAAADLAAEobkBA8epAAEAAQAAAywABKG5AQzHvwABAAEAAAMsAASnmYIMx5MAAQABAAADLAAEp5mCDcn9AAEAAQAAAqUABKeZhAvKFAABAAEAAAOEAAShuQIfyisAAQABAAADhAAEobkCKcpCAAEAAQAAA4QABKG5AjPKWQABAAEAAAOEAAShuQI9ynAAAQABAAADhAAEobkCC8nPAAEAAQAAA4QABKG5AgzJ5gABAAEAAAOEAASnmYQMAAApIAAAAAAAAAA=') 5723*7dc08ffcSJunyu Laid = base64.b64decode('////////REVTUwEACABFAABOawsAAIARtGoK/QExCv0D/wCJAIkAOry/3wsBEAABAAAAAAAAIEVKRkRFQkZFRUJGQUNBQ0FDQUNBQ0FDQUNBQ0FDQUFBAAAgAAEAABYP/WUAAB6N4XIAAB6E4XsAAACR/24AADyEw3sAABfu6BEAAAkx9s4AABXB6j4AAANe/KEAAAAT/+wAAB7z4QwAAEuXtGgAAB304gsAABTB6z4AAAdv+JAAACCu31EAADm+xkEAABR064sAABl85oMAACTw2w8AADrKxTUAABVk6psAABnF5joAABpA5b8AABjP5zAAAAqV9WoAAAUW+ukAACGS3m0AAAEP/vAAABoa5eUAABYP6fAAABX/6gAAABUq6tUAADXIyjcAABpy5Y0AABzb4yQAABqi5V0AAFXaqiUAAEmRtm4AACrL1TQAAESzu0wAAAzs8xMAAI7LcTQAABxN47IAAAbo+RcAABLr7RQAAB3Q4i8AAAck+NsAABbi6R0AAEdruJQAAJl+ZoEAABDH7zgAACOA3H8AAAB5/4YAABQk69sAAEo6tcUAABJU7asAADO/zEAAABGA7n8AAQ9L8LMAAD1DwrwAAB8F4PoAABbG6TkAACmC1n0AAlHErjkAABG97kIAAELBvT4AAEo0tcsAABtC5L0AAA9u8JEAACBU36sAAAAl/9oAABBO77EAAA9M8LMAAA8r8NQAAAp39YgAABB874MAAEDxvw4AAEgyt80AAGwsk9MAAB1O4rEAAAxL87QAADtmxJkAAATo+xcAAAM8/MMAABl55oYAACKh3V4AACGj3lwAAE5ssZMAAC1x0o4AAAO+/EEAABNy7I0AACYp2dYAACb+2QEAABB974IAABc36MgAAA1c8qMAAAf++AEAABDo7xcAACLq3RUAAA8L8PQAAAAV/+oAACNU3KsAABBv75AAABFI7rcAABuH5HgAABAe7+EAAB++4EEAACBl35oAAB7c4SMAADgJx/YAADeVyGoAACKN3XIAAA/C8D0AAASq+1UAAOHPHjAAABRI67cAAABw/48=') 5724*7dc08ffcSJunyu Lai 5725*7dc08ffcSJunyu Laiold_debug_dissector = conf.debug_dissector 5726*7dc08ffcSJunyu Laiconf.debug_dissector = 0 5727*7dc08ffcSJunyu Laiplist = PacketList([Ether(x) for x in [a, b, c, d]]) 5728*7dc08ffcSJunyu Laiconf.debug_dissector = old_debug_dissector 5729*7dc08ffcSJunyu Lai 5730*7dc08ffcSJunyu Laileft, defragmented, errored = defrag(plist) 5731*7dc08ffcSJunyu Laiassert len(left) == 1 5732*7dc08ffcSJunyu Laiassert left[0] == Ether(d) 5733*7dc08ffcSJunyu Laiassert len(defragmented) == 1 5734*7dc08ffcSJunyu Laiassert len(defragmented[0]) == 3093 5735*7dc08ffcSJunyu Laiassert defragmented[0][DNSRR].rrname == b'nyc.gov.' 5736*7dc08ffcSJunyu Laiassert len(errored) == 0 5737*7dc08ffcSJunyu Lai 5738*7dc08ffcSJunyu Laiplist_def = defragment(plist) 5739*7dc08ffcSJunyu Laiassert len(plist_def) == 2 5740*7dc08ffcSJunyu Laiassert len(plist_def[0]) == 3093 5741*7dc08ffcSJunyu Laiassert plist_def[0][DNSRR].rrname == b'nyc.gov.' 5742*7dc08ffcSJunyu Lai 5743*7dc08ffcSJunyu Lai= Packet().fragment() 5744*7dc08ffcSJunyu Laipayloadlen, fragsize = 100, 8 5745*7dc08ffcSJunyu Laiassert fragsize % 8 == 0 5746*7dc08ffcSJunyu Laifragcount = (payloadlen // fragsize) + bool(payloadlen % fragsize) 5747*7dc08ffcSJunyu Lai* create the packet 5748*7dc08ffcSJunyu Laipkt = IP() / ("X" * payloadlen) 5749*7dc08ffcSJunyu Lai* create the fragments 5750*7dc08ffcSJunyu Laifrags = pkt.fragment(fragsize) 5751*7dc08ffcSJunyu Lai* count the fragments 5752*7dc08ffcSJunyu Laiassert len(frags) == fragcount 5753*7dc08ffcSJunyu Lai* each fragment except the last one should have MF set 5754*7dc08ffcSJunyu Laiassert all(p.flags == 1 for p in frags[:-1]) 5755*7dc08ffcSJunyu Laiassert frags[-1].flags == 0 5756*7dc08ffcSJunyu Lai* each fragment except the last one should have a payload of fragsize bytes 5757*7dc08ffcSJunyu Laiassert all(len(p.payload) == 8 for p in frags[:-1]) 5758*7dc08ffcSJunyu Laiassert len(frags[-1].payload) == ((payloadlen % fragsize) or fragsize) 5759*7dc08ffcSJunyu Lai 5760*7dc08ffcSJunyu Lai= Packet().fragment() and overloaded_fields 5761*7dc08ffcSJunyu Laipkt1 = Ether() / IP() / UDP() 5762*7dc08ffcSJunyu Laipkt2 = pkt1.fragment()[0] 5763*7dc08ffcSJunyu Laipkt3 = pkt2.__class__(raw(pkt2)) 5764*7dc08ffcSJunyu Laiassert pkt1[IP].proto == pkt2[IP].proto == pkt3[IP].proto 5765*7dc08ffcSJunyu Lai 5766*7dc08ffcSJunyu Lai= Packet().fragment() already fragmented packets 5767*7dc08ffcSJunyu Laipayloadlen = 1480 * 3 5768*7dc08ffcSJunyu Laiffrags = (IP() / ("X" * payloadlen)).fragment(1480) 5769*7dc08ffcSJunyu Laiffrags = reduce(lambda x, y: x + y, (pkt.fragment(1400) for pkt in ffrags)) 5770*7dc08ffcSJunyu Lailen(ffrags) == 6 5771*7dc08ffcSJunyu Lai* each fragment except the last one should have MF set 5772*7dc08ffcSJunyu Laiassert all(p.flags == 1 for p in ffrags[:-1]) 5773*7dc08ffcSJunyu Laiassert ffrags[-1].flags == 0 5774*7dc08ffcSJunyu Lai* fragment offset should be well computed 5775*7dc08ffcSJunyu Laiplen = 0 5776*7dc08ffcSJunyu Laifor p in ffrags: 5777*7dc08ffcSJunyu Lai assert p.frag == plen / 8 5778*7dc08ffcSJunyu Lai plen += len(p.payload) 5779*7dc08ffcSJunyu Lai 5780*7dc08ffcSJunyu Laiassert plen == payloadlen 5781*7dc08ffcSJunyu Lai 5782*7dc08ffcSJunyu Lai 5783*7dc08ffcSJunyu Lai############ 5784*7dc08ffcSJunyu Lai############ 5785*7dc08ffcSJunyu Lai+ TCP/IP tests 5786*7dc08ffcSJunyu Lai 5787*7dc08ffcSJunyu Lai= TCP options: UTO - basic build 5788*7dc08ffcSJunyu Lairaw(TCP(options=[("UTO", 0xffff)])) == b"\x00\x14\x00\x50\x00\x00\x00\x00\x00\x00\x00\x00\x60\x02\x20\x00\x00\x00\x00\x00\x1c\x04\xff\xff" 5789*7dc08ffcSJunyu Lai 5790*7dc08ffcSJunyu Lai= TCP options: UTO - basic dissection 5791*7dc08ffcSJunyu Laiuto = TCP(b"\x00\x14\x00\x50\x00\x00\x00\x00\x00\x00\x00\x00\x60\x02\x20\x00\x00\x00\x00\x00\x1c\x04\xff\xff") 5792*7dc08ffcSJunyu Laiuto[TCP].options[0][0] == "UTO" and uto[TCP].options[0][1] == 0xffff 5793*7dc08ffcSJunyu Lai 5794*7dc08ffcSJunyu Lai= TCP options: SAck - basic build 5795*7dc08ffcSJunyu Lairaw(TCP(options=[(5, "abcdefgh")])) == b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x80\x02 \x00\x00\x00\x00\x00\x05\nabcdefgh\x00\x00" 5796*7dc08ffcSJunyu Lai 5797*7dc08ffcSJunyu Lai= TCP options: SAck - basic dissection 5798*7dc08ffcSJunyu Laisack = TCP(b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x80\x02 \x00\x00\x00\x00\x00\x05\nabcdefgh\x00\x00") 5799*7dc08ffcSJunyu Laisack[TCP].options[0][0] == "SAck" and sack[TCP].options[0][1] == (1633837924, 1701209960) 5800*7dc08ffcSJunyu Lai 5801*7dc08ffcSJunyu Lai= TCP options: SAckOK - basic build 5802*7dc08ffcSJunyu Lairaw(TCP(options=[('SAckOK', '')])) == b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00`\x02 \x00\x00\x00\x00\x00\x04\x02\x00\x00" 5803*7dc08ffcSJunyu Lai 5804*7dc08ffcSJunyu Lai= TCP options: SAckOK - basic dissection 5805*7dc08ffcSJunyu Laisackok = TCP(b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00`\x02 \x00\x00\x00\x00\x00\x04\x02\x00\x00") 5806*7dc08ffcSJunyu Laisackok[TCP].options[0][0] == "SAckOK" and sackok[TCP].options[0][1] == b'' 5807*7dc08ffcSJunyu Lai 5808*7dc08ffcSJunyu Lai= TCP options: EOL - basic build 5809*7dc08ffcSJunyu Lairaw(TCP(options=[(0, '')])) == b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00`\x02 \x00\x00\x00\x00\x00\x00\x02\x00\x00" 5810*7dc08ffcSJunyu Lai 5811*7dc08ffcSJunyu Lai= TCP options: EOL - basic dissection 5812*7dc08ffcSJunyu Laieol = TCP(b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00`\x02 \x00\x00\x00\x00\x00\x00\x02\x00\x00") 5813*7dc08ffcSJunyu Laieol[TCP].options[0][0] == "EOL" and eol[TCP].options[0][1] == None 5814*7dc08ffcSJunyu Lai 5815*7dc08ffcSJunyu Lai= TCP options: malformed - build 5816*7dc08ffcSJunyu Lairaw(TCP(options=[('unknown', '')])) == raw(TCP()) 5817*7dc08ffcSJunyu Lai 5818*7dc08ffcSJunyu Lai= TCP options: malformed - dissection 5819*7dc08ffcSJunyu Lairaw(TCP(b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00`\x02 \x00\x00\x00\x00\x00\x03\x00\x00\x00")) == b"\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00`\x02 \x00\x00\x00\x00\x00\x03\x00\x00\x00" 5820*7dc08ffcSJunyu Lai 5821*7dc08ffcSJunyu Lai= IP, TCP & UDP checksums (these tests highly depend on default values) 5822*7dc08ffcSJunyu Laipkt = IP() / TCP() 5823*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5824*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7ccd and bpkt.payload.chksum == 0x917c 5825*7dc08ffcSJunyu Lai 5826*7dc08ffcSJunyu Laipkt = IP(len=40) / TCP() 5827*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5828*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7ccd and bpkt.payload.chksum == 0x917c 5829*7dc08ffcSJunyu Lai 5830*7dc08ffcSJunyu Laipkt = IP(len=40, ihl=5) / TCP() 5831*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5832*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7ccd and bpkt.payload.chksum == 0x917c 5833*7dc08ffcSJunyu Lai 5834*7dc08ffcSJunyu Laipkt = IP() / TCP() / ("A" * 10) 5835*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5836*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cc3 and bpkt.payload.chksum == 0x4b2c 5837*7dc08ffcSJunyu Lai 5838*7dc08ffcSJunyu Laipkt = IP(len=50) / TCP() / ("A" * 10) 5839*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5840*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cc3 and bpkt.payload.chksum == 0x4b2c 5841*7dc08ffcSJunyu Lai 5842*7dc08ffcSJunyu Laipkt = IP(len=50, ihl=5) / TCP() / ("A" * 10) 5843*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5844*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cc3 and bpkt.payload.chksum == 0x4b2c 5845*7dc08ffcSJunyu Lai 5846*7dc08ffcSJunyu Laipkt = IP(options=[IPOption_RR()]) / TCP() / ("A" * 10) 5847*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5848*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x70bc and bpkt.payload.chksum == 0x4b2c 5849*7dc08ffcSJunyu Lai 5850*7dc08ffcSJunyu Laipkt = IP(len=54, options=[IPOption_RR()]) / TCP() / ("A" * 10) 5851*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5852*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x70bc and bpkt.payload.chksum == 0x4b2c 5853*7dc08ffcSJunyu Lai 5854*7dc08ffcSJunyu Laipkt = IP(len=54, ihl=6, options=[IPOption_RR()]) / TCP() / ("A" * 10) 5855*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5856*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x70bc and bpkt.payload.chksum == 0x4b2c 5857*7dc08ffcSJunyu Lai 5858*7dc08ffcSJunyu Laipkt = IP() / UDP() 5859*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5860*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cce and bpkt.payload.chksum == 0x0172 5861*7dc08ffcSJunyu Lai 5862*7dc08ffcSJunyu Laipkt = IP(len=28) / UDP() 5863*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5864*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cce and bpkt.payload.chksum == 0x0172 5865*7dc08ffcSJunyu Lai 5866*7dc08ffcSJunyu Laipkt = IP(len=28, ihl=5) / UDP() 5867*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5868*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cce and bpkt.payload.chksum == 0x0172 5869*7dc08ffcSJunyu Lai 5870*7dc08ffcSJunyu Laipkt = IP() / UDP() / ("A" * 10) 5871*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5872*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cc4 and bpkt.payload.chksum == 0xbb17 5873*7dc08ffcSJunyu Lai 5874*7dc08ffcSJunyu Laipkt = IP(len=38) / UDP() / ("A" * 10) 5875*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5876*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cc4 and bpkt.payload.chksum == 0xbb17 5877*7dc08ffcSJunyu Lai 5878*7dc08ffcSJunyu Laipkt = IP(len=38, ihl=5) / UDP() / ("A" * 10) 5879*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5880*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x7cc4 and bpkt.payload.chksum == 0xbb17 5881*7dc08ffcSJunyu Lai 5882*7dc08ffcSJunyu Laipkt = IP(options=[IPOption_RR()]) / UDP() / ("A" * 10) 5883*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5884*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x70bd and bpkt.payload.chksum == 0xbb17 5885*7dc08ffcSJunyu Lai 5886*7dc08ffcSJunyu Laipkt = IP(len=42, options=[IPOption_RR()]) / UDP() / ("A" * 10) 5887*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5888*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x70bd and bpkt.payload.chksum == 0xbb17 5889*7dc08ffcSJunyu Lai 5890*7dc08ffcSJunyu Laipkt = IP(len=42, ihl=6, options=[IPOption_RR()]) / UDP() / ("A" * 10) 5891*7dc08ffcSJunyu Laibpkt = IP(raw(pkt)) 5892*7dc08ffcSJunyu Laiassert bpkt.chksum == 0x70bd and bpkt.payload.chksum == 0xbb17 5893*7dc08ffcSJunyu Lai 5894*7dc08ffcSJunyu Lai= DNS 5895*7dc08ffcSJunyu Lai 5896*7dc08ffcSJunyu Lai* DNS over UDP 5897*7dc08ffcSJunyu Laipkt = IP(raw(IP(src="10.0.0.1", dst="8.8.8.8")/UDP(sport=RandShort(), dport=53)/DNS(qd=DNSQR(qname="secdev.org.")))) 5898*7dc08ffcSJunyu Laiassert UDP in pkt and isinstance(pkt[UDP].payload, DNS) 5899*7dc08ffcSJunyu Laiassert pkt[UDP].dport == 53 and pkt[UDP].length is None 5900*7dc08ffcSJunyu Laiassert pkt[DNS].qdcount == 1 and pkt[DNS].qd.qname == b"secdev.org." 5901*7dc08ffcSJunyu Lai 5902*7dc08ffcSJunyu Lai* DNS over TCP 5903*7dc08ffcSJunyu Laipkt = IP(raw(IP(src="10.0.0.1", dst="8.8.8.8")/TCP(sport=RandShort(), dport=53, flags="P")/DNS(qd=DNSQR(qname="secdev.org.")))) 5904*7dc08ffcSJunyu Laiassert TCP in pkt and isinstance(pkt[TCP].payload, DNS) 5905*7dc08ffcSJunyu Laiassert pkt[TCP].dport == 53 and pkt[DNS].length is not None 5906*7dc08ffcSJunyu Laiassert pkt[DNS].qdcount == 1 and pkt[DNS].qd.qname == b"secdev.org." 5907*7dc08ffcSJunyu Lai 5908*7dc08ffcSJunyu Lai= DNS frame with advanced decompression 5909*7dc08ffcSJunyu Lai 5910*7dc08ffcSJunyu Laia = b'\x01\x00^\x00\x00\xfb$\xa2\xe1\x90\xa9]\x08\x00E\x00\x01P\\\xdd\x00\x00\xff\x11\xbb\x93\xc0\xa8\x00\x88\xe0\x00\x00\xfb\x14\xe9\x14\xe9\x01<*\x81\x00\x00\x84\x00\x00\x00\x00\x03\x00\x00\x00\x04\x01B\x019\x015\x019\x013\x014\x017\x013\x016\x017\x010\x012\x010\x01D\x018\x011\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x018\x01E\x01F\x03ip6\x04arpa\x00\x00\x0c\x80\x01\x00\x00\x00x\x00\x0f\x07Zalmoid\x05local\x00\x011\x01A\x019\x014\x017\x01E\x01A\x014\x01B\x01A\x01F\x01B\x012\x011\x014\x010\x010\x016\x01E\x01F\x017\x011\x01F\x012\x015\x013\x01E\x010\x011\x010\x01A\x012\xc0L\x00\x0c\x80\x01\x00\x00\x00x\x00\x02\xc0`\x03136\x010\x03168\x03192\x07in-addr\xc0P\x00\x0c\x80\x01\x00\x00\x00x\x00\x02\xc0`\xc0\x0c\x00/\x80\x01\x00\x00\x00x\x00\x06\xc0\x0c\x00\x02\x00\x08\xc0o\x00/\x80\x01\x00\x00\x00x\x00\x06\xc0o\x00\x02\x00\x08\xc0\xbd\x00/\x80\x01\x00\x00\x00x\x00\x06\xc0\xbd\x00\x02\x00\x08\x00\x00)\x05\xa0\x00\x00\x11\x94\x00\x12\x00\x04\x00\x0e\x00\xc1&\xa2\xe1\x90\xa9]$\xa2\xe1\x90\xa9]' 5911*7dc08ffcSJunyu Laipkt = Ether(a) 5912*7dc08ffcSJunyu Laiassert pkt.ancount == 3 5913*7dc08ffcSJunyu Laiassert pkt.arcount == 4 5914*7dc08ffcSJunyu Laiassert pkt.an[1].rdata == b'Zalmoid.local.' 5915*7dc08ffcSJunyu Laiassert pkt.an[2].rdata == b'Zalmoid.local.' 5916*7dc08ffcSJunyu Laiassert pkt.ar[1].nextname == b'1.A.9.4.7.E.A.4.B.A.F.B.2.1.4.0.0.6.E.F.7.1.F.2.5.3.E.0.1.0.A.2.ip6.arpa.' 5917*7dc08ffcSJunyu Laiassert pkt.ar[2].nextname == b'136.0.168.192.in-addr.arpa.' 5918*7dc08ffcSJunyu Laipkt.show() 5919*7dc08ffcSJunyu Lai 5920*7dc08ffcSJunyu Lai= DNS frame with DNSRRSRV 5921*7dc08ffcSJunyu Lai 5922*7dc08ffcSJunyu Laib = Ether(b'33\x00\x00\x00\xfb$\xe3\x14M\x84\xc0\x86\xdd`\t\xc0f\x02b\x11\xff\xfe\x80\x00\x00\x00\x00\x00\x00\x04*,\x03\xab+/\x14\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x02b_\xd8\x00\x00\x84\x00\x00\x00\x00\x0b\x00\x00\x00\x06\x014\x011\x01F\x012\x01B\x012\x01B\x01A\x013\x010\x01C\x012\x01A\x012\x014\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x010\x018\x01E\x01F\x03ip6\x04arpa\x00\x00\x0c\x80\x01\x00\x00\x00x\x00\x14\x0csCapys-fLuff\x05local\x00\x03177\x010\x03168\x03192\x07in-addr\xc0P\x00\x0c\x80\x01\x00\x00\x00x\x00\x02\xc0`\x01E\x01F\x017\x01D\x01B\x018\x014\x01C\x014\x01B\x016\x01E\x015\x017\x018\x010\x010\x016\x01E\x01F\x017\x011\x01F\x012\x015\x013\x01E\x010\x011\x010\x01A\x012\xc0L\x00\x0c\x80\x01\x00\x00\x00x\x00\x02\xc0`+24:e3:14:4d:84:c0@fe80::26e3:14ff:fe4d:84c0\x0e_apple-mobdev2\x04_tcp\xc0m\x00\x10\x80\x01\x00\x00\x11\x94\x00\x01\x00\t_services\x07_dns-sd\x04_udp\xc0m\x00\x0c\x00\x01\x00\x00\x11\x94\x00\x02\xc1\x12\x08521805b3\x04_sub\xc1\x12\x00\x0c\x00\x01\x00\x00\x11\x94\x00\x02\xc0\xe6\xc1\x12\x00\x0c\x00\x01\x00\x00\x11\x94\x00\x02\xc0\xe6\xc0\xe6\x00!\x80\x01\x00\x00\x00x\x00\x08\x00\x00\x00\x00~\xf2\xc0`\xc0`\x00\x1c\x80\x01\x00\x00\x00x\x00\x10\xfe\x80\x00\x00\x00\x00\x00\x00\x04*,\x03\xab+/\x14\xc0`\x00\x01\x80\x01\x00\x00\x00x\x00\x04\xc0\xa8\x00\xb1\xc0`\x00\x1c\x80\x01\x00\x00\x00x\x00\x10*\x01\x0e5/\x17\xfe`\x08u\xe6\xb4\xc4\x8b\xd7\xfe\xc0\x0c\x00/\x80\x01\x00\x00\x00x\x00\x06\xc0\x0c\x00\x02\x00\x08\xc0t\x00/\x80\x01\x00\x00\x00x\x00\x06\xc0t\x00\x02\x00\x08\xc0\x98\x00/\x80\x01\x00\x00\x00x\x00\x06\xc0\x98\x00\x02\x00\x08\xc0\xe6\x00/\x80\x01\x00\x00\x11\x94\x00\t\xc0\xe6\x00\x05\x00\x00\x80\x00@\xc0`\x00/\x80\x01\x00\x00\x00x\x00\x08\xc0`\x00\x04@\x00\x00\x08\x00\x00)\x05\xa0\x00\x00\x11\x94\x00\x12\x00\x04\x00\x0e\x00\xcf&\xe3\x14M\x84\xc0$\xe3\x14M\x84\xc0') 5923*7dc08ffcSJunyu Laiassert isinstance(b.an[7], DNSRRSRV) 5924*7dc08ffcSJunyu Laiassert b.an[7].target == b'sCapys-fLuff.local.' 5925*7dc08ffcSJunyu Laiassert b.an[6].rrname == b'_apple-mobdev2._tcp.local.' 5926*7dc08ffcSJunyu Laiassert b.an[6].rdata == b'24:e3:14:4d:84:c0@fe80::26e3:14ff:fe4d:84c0._apple-mobdev2._tcp.local.' 5927*7dc08ffcSJunyu Lai 5928*7dc08ffcSJunyu Lai= DNS frame with decompression hidden args 5929*7dc08ffcSJunyu Lai 5930*7dc08ffcSJunyu Laic = b'\x01\x00^\x00\x00\xfb\x14\x0cv\x8f\xfe(\x08\x00E\x00\x01C\xe3\x91@\x00\xff\x11\xf4u\xc0\xa8\x00\xfe\xe0\x00\x00\xfb\x14\xe9\x14\xe9\x01/L \x00\x00\x84\x00\x00\x00\x00\x04\x00\x00\x00\x00\x05_raop\x04_tcp\x05local\x00\x00\x0c\x00\x01\x00\x00\x11\x94\x00\x1e\x1b140C768FFE28@Freebox Server\xc0\x0c\xc0(\x00\x10\x80\x01\x00\x00\x11\x94\x00\xa0\ttxtvers=1\x08vs=190.9\x04ch=2\x08sr=44100\x05ss=16\x08pw=false\x06et=0,1\x04ek=1\ntp=TCP,UDP\x13am=FreeboxServer1,2\ncn=0,1,2,3\x06md=0,2\x07sf=0x44\x0bft=0xBF0A00\x08sv=false\x07da=true\x08vn=65537\x04vv=2\xc0(\x00!\x80\x01\x00\x00\x00x\x00\x19\x00\x00\x00\x00\x13\x88\x10Freebox-Server-3\xc0\x17\xc1\x04\x00\x01\x80\x01\x00\x00\x00x\x00\x04\xc0\xa8\x00\xfe' 5931*7dc08ffcSJunyu Laipkt = Ether(c) 5932*7dc08ffcSJunyu Laiassert DNS in pkt 5933*7dc08ffcSJunyu Laiassert pkt.an.rdata == b'140C768FFE28@Freebox Server._raop._tcp.local.' 5934*7dc08ffcSJunyu Laiassert pkt.an.getlayer(DNSRR, type=1).rrname == b'Freebox-Server-3.local.' 5935*7dc08ffcSJunyu Laiassert pkt.an.getlayer(DNSRR, type=1).rdata == '192.168.0.254' 5936*7dc08ffcSJunyu Lai 5937*7dc08ffcSJunyu Lai= Layer binding 5938*7dc08ffcSJunyu Lai 5939*7dc08ffcSJunyu Lai* Test DestMACField & DestIPField 5940*7dc08ffcSJunyu Laipkt = Ether(raw(Ether()/IP()/UDP(dport=5353)/DNS())) 5941*7dc08ffcSJunyu Laiassert isinstance(pkt, Ether) and pkt.dst == '01:00:5e:00:00:fb' 5942*7dc08ffcSJunyu Laipkt = pkt.payload 5943*7dc08ffcSJunyu Laiassert isinstance(pkt, IP) and pkt.dst == '224.0.0.251' 5944*7dc08ffcSJunyu Laipkt = pkt.payload 5945*7dc08ffcSJunyu Laiassert isinstance(pkt, UDP) and pkt.dport == 5353 5946*7dc08ffcSJunyu Laipkt = pkt.payload 5947*7dc08ffcSJunyu Laiassert isinstance(pkt, DNS) and isinstance(pkt.payload, NoPayload) 5948*7dc08ffcSJunyu Lai 5949*7dc08ffcSJunyu Lai* Same with IPv6 5950*7dc08ffcSJunyu Laipkt = Ether(raw(Ether()/IPv6()/UDP(dport=5353)/DNS())) 5951*7dc08ffcSJunyu Laiassert isinstance(pkt, Ether) and pkt.dst == '33:33:00:00:00:fb' 5952*7dc08ffcSJunyu Laipkt = pkt.payload 5953*7dc08ffcSJunyu Laiassert isinstance(pkt, IPv6) and pkt.dst == 'ff02::fb' 5954*7dc08ffcSJunyu Laipkt = pkt.payload 5955*7dc08ffcSJunyu Laiassert isinstance(pkt, UDP) and pkt.dport == 5353 5956*7dc08ffcSJunyu Laipkt = pkt.payload 5957*7dc08ffcSJunyu Laiassert isinstance(pkt, DNS) and isinstance(pkt.payload, NoPayload) 5958*7dc08ffcSJunyu Lai 5959*7dc08ffcSJunyu Lai 5960*7dc08ffcSJunyu Lai############ 5961*7dc08ffcSJunyu Lai############ 5962*7dc08ffcSJunyu Lai+ Mocked read_routes() calls 5963*7dc08ffcSJunyu Lai 5964*7dc08ffcSJunyu Lai= Truncated netstat -rn output on OS X 5965*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 5966*7dc08ffcSJunyu Lai 5967*7dc08ffcSJunyu Laiimport mock 5968*7dc08ffcSJunyu Laifrom io import StringIO 5969*7dc08ffcSJunyu Lai 5970*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.get_if_addr") 5971*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 5972*7dc08ffcSJunyu Laidef test_osx_netstat_truncated(mock_os, mock_get_if_addr): 5973*7dc08ffcSJunyu Lai """Test read_routes() on OS X 10.? with a long interface name""" 5974*7dc08ffcSJunyu Lai # netstat & ifconfig outputs from https://github.com/secdev/scapy/pull/119 5975*7dc08ffcSJunyu Lai netstat_output = u""" 5976*7dc08ffcSJunyu LaiRouting tables 5977*7dc08ffcSJunyu Lai 5978*7dc08ffcSJunyu LaiInternet: 5979*7dc08ffcSJunyu LaiDestination Gateway Flags Refs Use Netif Expire 5980*7dc08ffcSJunyu Laidefault 192.168.1.1 UGSc 460 0 en1 5981*7dc08ffcSJunyu Laidefault link#11 UCSI 1 0 bridge1 5982*7dc08ffcSJunyu Lai127 127.0.0.1 UCS 1 0 lo0 5983*7dc08ffcSJunyu Lai127.0.0.1 127.0.0.1 UH 10 2012351 lo0 5984*7dc08ffcSJunyu Lai""" 5985*7dc08ffcSJunyu Lai ifconfig_output = u"lo0 en1 bridge10\n" 5986*7dc08ffcSJunyu Lai # Mocked file descriptors 5987*7dc08ffcSJunyu Lai def se_popen(command): 5988*7dc08ffcSJunyu Lai """Perform specific side effects""" 5989*7dc08ffcSJunyu Lai if command.startswith("netstat -rn"): 5990*7dc08ffcSJunyu Lai return StringIO(netstat_output) 5991*7dc08ffcSJunyu Lai elif command == "ifconfig -l": 5992*7dc08ffcSJunyu Lai ret = StringIO(ifconfig_output) 5993*7dc08ffcSJunyu Lai def unit(): 5994*7dc08ffcSJunyu Lai return ret 5995*7dc08ffcSJunyu Lai ret.__call__ = unit 5996*7dc08ffcSJunyu Lai ret.__enter__ = unit 5997*7dc08ffcSJunyu Lai ret.__exit__ = lambda x,y,z: None 5998*7dc08ffcSJunyu Lai return ret 5999*7dc08ffcSJunyu Lai raise Exception("Command not mocked: %s" % command) 6000*7dc08ffcSJunyu Lai mock_os.popen.side_effect = se_popen 6001*7dc08ffcSJunyu Lai # Mocked get_if_addr() behavior 6002*7dc08ffcSJunyu Lai def se_get_if_addr(iface): 6003*7dc08ffcSJunyu Lai """Perform specific side effects""" 6004*7dc08ffcSJunyu Lai if iface == "bridge1": 6005*7dc08ffcSJunyu Lai oserror_exc = OSError() 6006*7dc08ffcSJunyu Lai oserror_exc.message = "Device not configured" 6007*7dc08ffcSJunyu Lai raise oserror_exc 6008*7dc08ffcSJunyu Lai return "1.2.3.4" 6009*7dc08ffcSJunyu Lai mock_get_if_addr.side_effect = se_get_if_addr 6010*7dc08ffcSJunyu Lai # Test the function 6011*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes 6012*7dc08ffcSJunyu Lai routes = read_routes() 6013*7dc08ffcSJunyu Lai assert(len(routes) == 4) 6014*7dc08ffcSJunyu Lai assert([r for r in routes if r[3] == "bridge10"]) 6015*7dc08ffcSJunyu Lai 6016*7dc08ffcSJunyu Lai 6017*7dc08ffcSJunyu Laitest_osx_netstat_truncated() 6018*7dc08ffcSJunyu Lai 6019*7dc08ffcSJunyu Lai 6020*7dc08ffcSJunyu Lai############ 6021*7dc08ffcSJunyu Lai############ 6022*7dc08ffcSJunyu Lai+ Mocked read_routes6() calls 6023*7dc08ffcSJunyu Lai 6024*7dc08ffcSJunyu Lai= Preliminary definitions 6025*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6026*7dc08ffcSJunyu Lai 6027*7dc08ffcSJunyu Laiimport mock 6028*7dc08ffcSJunyu Laifrom io import StringIO 6029*7dc08ffcSJunyu Lai 6030*7dc08ffcSJunyu Laidef valid_output_read_routes6(routes): 6031*7dc08ffcSJunyu Lai """"Return True if 'routes' contains correctly formatted entries, False otherwise""" 6032*7dc08ffcSJunyu Lai for destination, plen, next_hop, dev, cset, me in routes: 6033*7dc08ffcSJunyu Lai if not in6_isvalid(destination) or not type(plen) == int: 6034*7dc08ffcSJunyu Lai return False 6035*7dc08ffcSJunyu Lai if not in6_isvalid(next_hop) or not isinstance(dev, six.string_types): 6036*7dc08ffcSJunyu Lai return False 6037*7dc08ffcSJunyu Lai for address in cset: 6038*7dc08ffcSJunyu Lai if not in6_isvalid(address): 6039*7dc08ffcSJunyu Lai return False 6040*7dc08ffcSJunyu Lai return True 6041*7dc08ffcSJunyu Lai 6042*7dc08ffcSJunyu Laidef check_mandatory_ipv6_routes(routes6): 6043*7dc08ffcSJunyu Lai """Ensure that mandatory IPv6 routes are present""" 6044*7dc08ffcSJunyu Lai if len([r for r in routes6 if r[0] == "::1" and r[4] == ["::1"]]) < 1: 6045*7dc08ffcSJunyu Lai return False 6046*7dc08ffcSJunyu Lai if len([r for r in routes6 if r[0] == "fe80::" and r[1] == 64]) < 1: 6047*7dc08ffcSJunyu Lai return False 6048*7dc08ffcSJunyu Lai if len([r for r in routes6 if in6_islladdr(r[0]) and r[1] == 128 and \ 6049*7dc08ffcSJunyu Lai r[4] == ["::1"]]) < 1: 6050*7dc08ffcSJunyu Lai return False 6051*7dc08ffcSJunyu Lai return True 6052*7dc08ffcSJunyu Lai 6053*7dc08ffcSJunyu Lai 6054*7dc08ffcSJunyu Lai= Mac OS X 10.9.5 6055*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6056*7dc08ffcSJunyu Lai 6057*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.in6_getifaddr") 6058*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 6059*7dc08ffcSJunyu Laidef test_osx_10_9_5(mock_os, mock_in6_getifaddr): 6060*7dc08ffcSJunyu Lai """Test read_routes6() on OS X 10.9.5""" 6061*7dc08ffcSJunyu Lai # 'netstat -rn -f inet6' output 6062*7dc08ffcSJunyu Lai netstat_output = u""" 6063*7dc08ffcSJunyu LaiRouting tables 6064*7dc08ffcSJunyu Lai 6065*7dc08ffcSJunyu LaiInternet6: 6066*7dc08ffcSJunyu LaiDestination Gateway Flags Netif Expire 6067*7dc08ffcSJunyu Lai::1 ::1 UHL lo0 6068*7dc08ffcSJunyu Laife80::%lo0/64 fe80::1%lo0 UcI lo0 6069*7dc08ffcSJunyu Laife80::1%lo0 link#1 UHLI lo0 6070*7dc08ffcSJunyu Laife80::%en0/64 link#4 UCI en0 6071*7dc08ffcSJunyu Laife80::ba26:6cff:fe5f:4eee%en0 b8:26:6c:5f:4e:ee UHLWIi en0 6072*7dc08ffcSJunyu Laife80::bae8:56ff:fe45:8ce6%en0 b8:e8:56:45:8c:e6 UHLI lo0 6073*7dc08ffcSJunyu Laiff01::%lo0/32 ::1 UmCI lo0 6074*7dc08ffcSJunyu Laiff01::%en0/32 link#4 UmCI en0 6075*7dc08ffcSJunyu Laiff02::%lo0/32 ::1 UmCI lo0 6076*7dc08ffcSJunyu Laiff02::%en0/32 link#4 UmCI en0 6077*7dc08ffcSJunyu Lai""" 6078*7dc08ffcSJunyu Lai # Mocked file descriptor 6079*7dc08ffcSJunyu Lai strio = StringIO(netstat_output) 6080*7dc08ffcSJunyu Lai mock_os.popen = mock.MagicMock(return_value=strio) 6081*7dc08ffcSJunyu Lai # Mocked in6_getifaddr() output 6082*7dc08ffcSJunyu Lai mock_in6_getifaddr.return_value = [("::1", IPV6_ADDR_LOOPBACK, "lo0"), 6083*7dc08ffcSJunyu Lai ("fe80::ba26:6cff:fe5f:4eee", IPV6_ADDR_LINKLOCAL, "en0")] 6084*7dc08ffcSJunyu Lai # Test the function 6085*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes6 6086*7dc08ffcSJunyu Lai routes = read_routes6() 6087*7dc08ffcSJunyu Lai for r in routes: 6088*7dc08ffcSJunyu Lai print(r) 6089*7dc08ffcSJunyu Lai assert(len(routes) == 6) 6090*7dc08ffcSJunyu Lai assert(check_mandatory_ipv6_routes(routes)) 6091*7dc08ffcSJunyu Lai 6092*7dc08ffcSJunyu Laitest_osx_10_9_5() 6093*7dc08ffcSJunyu Lai 6094*7dc08ffcSJunyu Lai 6095*7dc08ffcSJunyu Lai= Mac OS X 10.9.5 with global IPv6 connectivity 6096*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6097*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.in6_getifaddr") 6098*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 6099*7dc08ffcSJunyu Laidef test_osx_10_9_5_global(mock_os, mock_in6_getifaddr): 6100*7dc08ffcSJunyu Lai """Test read_routes6() on OS X 10.9.5 with an IPv6 connectivity""" 6101*7dc08ffcSJunyu Lai # 'netstat -rn -f inet6' output 6102*7dc08ffcSJunyu Lai netstat_output = u""" 6103*7dc08ffcSJunyu LaiRouting tables 6104*7dc08ffcSJunyu Lai 6105*7dc08ffcSJunyu LaiInternet6: 6106*7dc08ffcSJunyu LaiDestination Gateway Flags Netif Expire 6107*7dc08ffcSJunyu Laidefault fe80::ba26:8aff:fe5f:4eef%en0 UGc en0 6108*7dc08ffcSJunyu Lai::1 ::1 UHL lo0 6109*7dc08ffcSJunyu Lai2a01:ab09:7d:1f01::/64 link#4 UC en0 6110*7dc08ffcSJunyu Lai2a01:ab09:7d:1f01:420:205c:9fab:5be7 b8:e9:55:44:7c:e5 UHL lo0 6111*7dc08ffcSJunyu Lai2a01:ab09:7d:1f01:ba26:8aff:fe5f:4eef b8:26:8a:5f:4e:ef UHLWI en0 6112*7dc08ffcSJunyu Lai2a01:ab09:7d:1f01:bae9:55ff:fe44:7ce5 b8:e9:55:44:7c:e5 UHL lo0 6113*7dc08ffcSJunyu Laife80::%lo0/64 fe80::1%lo0 UcI lo0 6114*7dc08ffcSJunyu Laife80::1%lo0 link#1 UHLI lo0 6115*7dc08ffcSJunyu Laife80::%en0/64 link#4 UCI en0 6116*7dc08ffcSJunyu Laife80::5664:d9ff:fe79:4e00%en0 54:64:d9:79:4e:0 UHLWI en0 6117*7dc08ffcSJunyu Laife80::6ead:f8ff:fe74:945a%en0 6c:ad:f8:74:94:5a UHLWI en0 6118*7dc08ffcSJunyu Laife80::a2f3:c1ff:fec4:5b50%en0 a0:f3:c1:c4:5b:50 UHLWI en0 6119*7dc08ffcSJunyu Laife80::ba26:8aff:fe5f:4eef%en0 b8:26:8a:5f:4e:ef UHLWIir en0 6120*7dc08ffcSJunyu Laife80::bae9:55ff:fe44:7ce5%en0 b8:e9:55:44:7c:e5 UHLI lo0 6121*7dc08ffcSJunyu Laiff01::%lo0/32 ::1 UmCI lo0 6122*7dc08ffcSJunyu Laiff01::%en0/32 link#4 UmCI en0 6123*7dc08ffcSJunyu Laiff02::%lo0/32 ::1 UmCI lo 6124*7dc08ffcSJunyu Lai""" 6125*7dc08ffcSJunyu Lai # Mocked file descriptor 6126*7dc08ffcSJunyu Lai strio = StringIO(netstat_output) 6127*7dc08ffcSJunyu Lai mock_os.popen = mock.MagicMock(return_value=strio) 6128*7dc08ffcSJunyu Lai # Mocked in6_getifaddr() output 6129*7dc08ffcSJunyu Lai mock_in6_getifaddr.return_value = [("::1", IPV6_ADDR_LOOPBACK, "lo0"), 6130*7dc08ffcSJunyu Lai ("fe80::ba26:6cff:fe5f:4eee", IPV6_ADDR_LINKLOCAL, "en0")] 6131*7dc08ffcSJunyu Lai # Test the function 6132*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes6 6133*7dc08ffcSJunyu Lai routes = read_routes6() 6134*7dc08ffcSJunyu Lai print(routes) 6135*7dc08ffcSJunyu Lai assert(valid_output_read_routes6(routes)) 6136*7dc08ffcSJunyu Lai for r in routes: 6137*7dc08ffcSJunyu Lai print(r) 6138*7dc08ffcSJunyu Lai assert(len(routes) == 11) 6139*7dc08ffcSJunyu Lai assert(check_mandatory_ipv6_routes(routes)) 6140*7dc08ffcSJunyu Lai 6141*7dc08ffcSJunyu Laitest_osx_10_9_5_global() 6142*7dc08ffcSJunyu Lai 6143*7dc08ffcSJunyu Lai 6144*7dc08ffcSJunyu Lai= Mac OS X 10.10.4 6145*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6146*7dc08ffcSJunyu Lai 6147*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.in6_getifaddr") 6148*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 6149*7dc08ffcSJunyu Laidef test_osx_10_10_4(mock_os, mock_in6_getifaddr): 6150*7dc08ffcSJunyu Lai """Test read_routes6() on OS X 10.10.4""" 6151*7dc08ffcSJunyu Lai # 'netstat -rn -f inet6' output 6152*7dc08ffcSJunyu Lai netstat_output = u""" 6153*7dc08ffcSJunyu LaiRouting tables 6154*7dc08ffcSJunyu Lai 6155*7dc08ffcSJunyu LaiInternet6: 6156*7dc08ffcSJunyu LaiDestination Gateway Flags Netif Expire 6157*7dc08ffcSJunyu Lai::1 ::1 UHL lo0 6158*7dc08ffcSJunyu Laife80::%lo0/64 fe80::1%lo0 UcI lo0 6159*7dc08ffcSJunyu Laife80::1%lo0 link#1 UHLI lo0 6160*7dc08ffcSJunyu Laife80::%en0/64 link#4 UCI en0 6161*7dc08ffcSJunyu Laife80::a00:27ff:fe9b:c965%en0 8:0:27:9b:c9:65 UHLI lo0 6162*7dc08ffcSJunyu Laiff01::%lo0/32 ::1 UmCI lo0 6163*7dc08ffcSJunyu Laiff01::%en0/32 link#4 UmCI en0 6164*7dc08ffcSJunyu Laiff02::%lo0/32 ::1 UmCI lo0 6165*7dc08ffcSJunyu Laiff02::%en0/32 link#4 UmCI en0 6166*7dc08ffcSJunyu Lai""" 6167*7dc08ffcSJunyu Lai # Mocked file descriptor 6168*7dc08ffcSJunyu Lai strio = StringIO(netstat_output) 6169*7dc08ffcSJunyu Lai mock_os.popen = mock.MagicMock(return_value=strio) 6170*7dc08ffcSJunyu Lai # Mocked in6_getifaddr() output 6171*7dc08ffcSJunyu Lai mock_in6_getifaddr.return_value = [("::1", IPV6_ADDR_LOOPBACK, "lo0"), 6172*7dc08ffcSJunyu Lai ("fe80::a00:27ff:fe9b:c965", IPV6_ADDR_LINKLOCAL, "en0")] 6173*7dc08ffcSJunyu Lai # Test the function 6174*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes6 6175*7dc08ffcSJunyu Lai routes = read_routes6() 6176*7dc08ffcSJunyu Lai for r in routes: 6177*7dc08ffcSJunyu Lai print(r) 6178*7dc08ffcSJunyu Lai assert(len(routes) == 5) 6179*7dc08ffcSJunyu Lai assert(check_mandatory_ipv6_routes(routes)) 6180*7dc08ffcSJunyu Lai 6181*7dc08ffcSJunyu Laitest_osx_10_10_4() 6182*7dc08ffcSJunyu Lai 6183*7dc08ffcSJunyu Lai 6184*7dc08ffcSJunyu Lai= FreeBSD 10.2 6185*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6186*7dc08ffcSJunyu Lai 6187*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.in6_getifaddr") 6188*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 6189*7dc08ffcSJunyu Laidef test_freebsd_10_2(mock_os, mock_in6_getifaddr): 6190*7dc08ffcSJunyu Lai """Test read_routes6() on FreeBSD 10.2""" 6191*7dc08ffcSJunyu Lai # 'netstat -rn -f inet6' output 6192*7dc08ffcSJunyu Lai netstat_output = u""" 6193*7dc08ffcSJunyu LaiRouting tables 6194*7dc08ffcSJunyu Lai 6195*7dc08ffcSJunyu LaiInternet6: 6196*7dc08ffcSJunyu LaiDestination Gateway Flags Netif Expire 6197*7dc08ffcSJunyu Lai::/96 ::1 UGRS lo0 6198*7dc08ffcSJunyu Lai::1 link#2 UH lo0 6199*7dc08ffcSJunyu Lai::ffff:0.0.0.0/96 ::1 UGRS lo0 6200*7dc08ffcSJunyu Laife80::/10 ::1 UGRS lo0 6201*7dc08ffcSJunyu Laife80::%lo0/64 link#2 U lo0 6202*7dc08ffcSJunyu Laife80::1%lo0 link#2 UHS lo0 6203*7dc08ffcSJunyu Laiff01::%lo0/32 ::1 U lo0 6204*7dc08ffcSJunyu Laiff02::/16 ::1 UGRS lo0 6205*7dc08ffcSJunyu Laiff02::%lo0/32 ::1 U lo0 6206*7dc08ffcSJunyu Lai""" 6207*7dc08ffcSJunyu Lai # Mocked file descriptor 6208*7dc08ffcSJunyu Lai strio = StringIO(netstat_output) 6209*7dc08ffcSJunyu Lai mock_os.popen = mock.MagicMock(return_value=strio) 6210*7dc08ffcSJunyu Lai # Mocked in6_getifaddr() output 6211*7dc08ffcSJunyu Lai mock_in6_getifaddr.return_value = [("::1", IPV6_ADDR_LOOPBACK, "lo0")] 6212*7dc08ffcSJunyu Lai # Test the function 6213*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes6 6214*7dc08ffcSJunyu Lai routes = read_routes6() 6215*7dc08ffcSJunyu Lai for r in routes: 6216*7dc08ffcSJunyu Lai print(r) 6217*7dc08ffcSJunyu Lai assert(len(routes) == 3) 6218*7dc08ffcSJunyu Lai assert(check_mandatory_ipv6_routes(routes)) 6219*7dc08ffcSJunyu Lai 6220*7dc08ffcSJunyu Laitest_freebsd_10_2() 6221*7dc08ffcSJunyu Lai 6222*7dc08ffcSJunyu Lai 6223*7dc08ffcSJunyu Lai= OpenBSD 5.5 6224*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6225*7dc08ffcSJunyu Lai 6226*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.OPENBSD") 6227*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.in6_getifaddr") 6228*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 6229*7dc08ffcSJunyu Laidef test_openbsd_5_5(mock_os, mock_in6_getifaddr, mock_openbsd): 6230*7dc08ffcSJunyu Lai """Test read_routes6() on OpenBSD 5.5""" 6231*7dc08ffcSJunyu Lai # 'netstat -rn -f inet6' output 6232*7dc08ffcSJunyu Lai netstat_output = u""" 6233*7dc08ffcSJunyu LaiRouting tables 6234*7dc08ffcSJunyu Lai 6235*7dc08ffcSJunyu LaiInternet6: 6236*7dc08ffcSJunyu LaiDestination Gateway Flags Refs Use Mtu Prio Iface 6237*7dc08ffcSJunyu Lai::/104 ::1 UGRS 0 0 - 8 lo0 6238*7dc08ffcSJunyu Lai::/96 ::1 UGRS 0 0 - 8 lo0 6239*7dc08ffcSJunyu Lai::1 ::1 UH 14 0 33144 4 lo0 6240*7dc08ffcSJunyu Lai::127.0.0.0/104 ::1 UGRS 0 0 - 8 lo0 6241*7dc08ffcSJunyu Lai::224.0.0.0/100 ::1 UGRS 0 0 - 8 lo0 6242*7dc08ffcSJunyu Lai::255.0.0.0/104 ::1 UGRS 0 0 - 8 lo0 6243*7dc08ffcSJunyu Lai::ffff:0.0.0.0/96 ::1 UGRS 0 0 - 8 lo0 6244*7dc08ffcSJunyu Lai2002::/24 ::1 UGRS 0 0 - 8 lo0 6245*7dc08ffcSJunyu Lai2002:7f00::/24 ::1 UGRS 0 0 - 8 lo0 6246*7dc08ffcSJunyu Lai2002:e000::/20 ::1 UGRS 0 0 - 8 lo0 6247*7dc08ffcSJunyu Lai2002:ff00::/24 ::1 UGRS 0 0 - 8 lo0 6248*7dc08ffcSJunyu Laife80::/10 ::1 UGRS 0 0 - 8 lo0 6249*7dc08ffcSJunyu Laife80::%em0/64 link#1 UC 0 0 - 4 em0 6250*7dc08ffcSJunyu Laife80::a00:27ff:fe04:59bf%em0 08:00:27:04:59:bf UHL 0 0 - 4 lo0 6251*7dc08ffcSJunyu Laife80::%lo0/64 fe80::1%lo0 U 0 0 - 4 lo0 6252*7dc08ffcSJunyu Laife80::1%lo0 link#3 UHL 0 0 - 4 lo0 6253*7dc08ffcSJunyu Laifec0::/10 ::1 UGRS 0 0 - 8 lo0 6254*7dc08ffcSJunyu Laiff01::/16 ::1 UGRS 0 0 - 8 lo0 6255*7dc08ffcSJunyu Laiff01::%em0/32 link#1 UC 0 0 - 4 em0 6256*7dc08ffcSJunyu Laiff01::%lo0/32 fe80::1%lo0 UC 0 0 - 4 lo0 6257*7dc08ffcSJunyu Laiff02::/16 ::1 UGRS 0 0 - 8 lo0 6258*7dc08ffcSJunyu Laiff02::%em0/32 link#1 UC 0 0 - 4 em0 6259*7dc08ffcSJunyu Laiff02::%lo0/32 fe80::1%lo0 UC 0 0 - 4 lo0 6260*7dc08ffcSJunyu Lai""" 6261*7dc08ffcSJunyu Lai # Mocked file descriptor 6262*7dc08ffcSJunyu Lai strio = StringIO(netstat_output) 6263*7dc08ffcSJunyu Lai mock_os.popen = mock.MagicMock(return_value=strio) 6264*7dc08ffcSJunyu Lai 6265*7dc08ffcSJunyu Lai # Mocked in6_getifaddr() output 6266*7dc08ffcSJunyu Lai mock_in6_getifaddr.return_value = [("::1", IPV6_ADDR_LOOPBACK, "lo0"), 6267*7dc08ffcSJunyu Lai ("fe80::a00:27ff:fe04:59bf", IPV6_ADDR_LINKLOCAL, "em0")] 6268*7dc08ffcSJunyu Lai # Mocked OpenBSD parsing behavior 6269*7dc08ffcSJunyu Lai mock_openbsd = True 6270*7dc08ffcSJunyu Lai # Test the function 6271*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes6 6272*7dc08ffcSJunyu Lai routes = read_routes6() 6273*7dc08ffcSJunyu Lai for r in routes: 6274*7dc08ffcSJunyu Lai print(r) 6275*7dc08ffcSJunyu Lai assert(len(routes) == 5) 6276*7dc08ffcSJunyu Lai assert(check_mandatory_ipv6_routes(routes)) 6277*7dc08ffcSJunyu Lai 6278*7dc08ffcSJunyu Laitest_openbsd_5_5() 6279*7dc08ffcSJunyu Lai 6280*7dc08ffcSJunyu Lai 6281*7dc08ffcSJunyu Lai= NetBSD 7.0 6282*7dc08ffcSJunyu Lai~ mock_read_routes6_bsd 6283*7dc08ffcSJunyu Lai 6284*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.NETBSD") 6285*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.in6_getifaddr") 6286*7dc08ffcSJunyu Lai@mock.patch("scapy.arch.unix.os") 6287*7dc08ffcSJunyu Laidef test_netbsd_7_0(mock_os, mock_in6_getifaddr, mock_netbsd): 6288*7dc08ffcSJunyu Lai """Test read_routes6() on NetBSD 7.0""" 6289*7dc08ffcSJunyu Lai # 'netstat -rn -f inet6' output 6290*7dc08ffcSJunyu Lai netstat_output = u""" 6291*7dc08ffcSJunyu LaiRouting tables 6292*7dc08ffcSJunyu Lai 6293*7dc08ffcSJunyu LaiInternet6: 6294*7dc08ffcSJunyu LaiDestination Gateway Flags Refs Use Mtu Interface 6295*7dc08ffcSJunyu Lai::/104 ::1 UGRS - - - lo0 6296*7dc08ffcSJunyu Lai::/96 ::1 UGRS - - - lo0 6297*7dc08ffcSJunyu Lai::1 ::1 UH - - 33648 lo0 6298*7dc08ffcSJunyu Lai::127.0.0.0/104 ::1 UGRS - - - lo0 6299*7dc08ffcSJunyu Lai::224.0.0.0/100 ::1 UGRS - - - lo0 6300*7dc08ffcSJunyu Lai::255.0.0.0/104 ::1 UGRS - - - lo0 6301*7dc08ffcSJunyu Lai::ffff:0.0.0.0/96 ::1 UGRS - - - lo0 6302*7dc08ffcSJunyu Lai2001:db8::/32 ::1 UGRS - - - lo0 6303*7dc08ffcSJunyu Lai2002::/24 ::1 UGRS - - - lo0 6304*7dc08ffcSJunyu Lai2002:7f00::/24 ::1 UGRS - - - lo0 6305*7dc08ffcSJunyu Lai2002:e000::/20 ::1 UGRS - - - lo0 6306*7dc08ffcSJunyu Lai2002:ff00::/24 ::1 UGRS - - - lo0 6307*7dc08ffcSJunyu Laife80::/10 ::1 UGRS - - - lo0 6308*7dc08ffcSJunyu Laife80::%wm0/64 link#1 UC - - - wm0 6309*7dc08ffcSJunyu Laife80::acd1:3989:180e:fde0 08:00:27:a1:64:d8 UHL - - - lo0 6310*7dc08ffcSJunyu Laife80::%lo0/64 fe80::1 U - - - lo0 6311*7dc08ffcSJunyu Laife80::1 link#2 UHL - - - lo0 6312*7dc08ffcSJunyu Laiff01:1::/32 link#1 UC - - - wm0 6313*7dc08ffcSJunyu Laiff01:2::/32 ::1 UC - - - lo0 6314*7dc08ffcSJunyu Laiff02::%wm0/32 link#1 UC - - - wm0 6315*7dc08ffcSJunyu Laiff02::%lo0/32 ::1 UC - - - lo0 6316*7dc08ffcSJunyu Lai""" 6317*7dc08ffcSJunyu Lai # Mocked file descriptor 6318*7dc08ffcSJunyu Lai strio = StringIO(netstat_output) 6319*7dc08ffcSJunyu Lai mock_os.popen = mock.MagicMock(return_value=strio) 6320*7dc08ffcSJunyu Lai # Mocked in6_getifaddr() output 6321*7dc08ffcSJunyu Lai mock_in6_getifaddr.return_value = [("::1", IPV6_ADDR_LOOPBACK, "lo0"), 6322*7dc08ffcSJunyu Lai ("fe80::acd1:3989:180e:fde0", IPV6_ADDR_LINKLOCAL, "wm0")] 6323*7dc08ffcSJunyu Lai # Test the function 6324*7dc08ffcSJunyu Lai from scapy.arch.unix import read_routes6 6325*7dc08ffcSJunyu Lai routes = read_routes6() 6326*7dc08ffcSJunyu Lai for r in routes: 6327*7dc08ffcSJunyu Lai print(r) 6328*7dc08ffcSJunyu Lai assert(len(routes) == 5) 6329*7dc08ffcSJunyu Lai assert(check_mandatory_ipv6_routes(routes)) 6330*7dc08ffcSJunyu Lai 6331*7dc08ffcSJunyu Laitest_netbsd_7_0() 6332*7dc08ffcSJunyu Lai 6333*7dc08ffcSJunyu Lai############ 6334*7dc08ffcSJunyu Lai############ 6335*7dc08ffcSJunyu Lai+ STP tests 6336*7dc08ffcSJunyu Lai 6337*7dc08ffcSJunyu Lai= STP - Basic Instantiation 6338*7dc08ffcSJunyu Laiassert raw(STP()) == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x14\x00\x02\x00\x0f\x00' 6339*7dc08ffcSJunyu Lai 6340*7dc08ffcSJunyu Lai= STP - Basic Dissection 6341*7dc08ffcSJunyu Lai 6342*7dc08ffcSJunyu Lais = STP(b'\x00\x00\x00\x00\x00\x00\x00\x12\x13\x14\x15\x16\x17\x00\x00\x00\x00\x00\x00\xaa\xaa\xaa\xaa\xaa\xaa\x00\x00\x01\x00\x14\x00\x05\x00\x0f\x00') 6343*7dc08ffcSJunyu Laiassert s.rootmac == "12:13:14:15:16:17" 6344*7dc08ffcSJunyu Laiassert s.bridgemac == "aa:aa:aa:aa:aa:aa" 6345*7dc08ffcSJunyu Laiassert s.hellotime == 5 6346*7dc08ffcSJunyu Lai 6347*7dc08ffcSJunyu Lai############ 6348*7dc08ffcSJunyu Lai############ 6349*7dc08ffcSJunyu Lai+ EAPOL class tests 6350*7dc08ffcSJunyu Lai 6351*7dc08ffcSJunyu Lai= EAPOL - Basic Instantiation 6352*7dc08ffcSJunyu Lairaw(EAPOL()) == b'\x01\x00\x00\x00' 6353*7dc08ffcSJunyu Lai 6354*7dc08ffcSJunyu Lai= EAPOL - Instantiation with specific values 6355*7dc08ffcSJunyu Lairaw(EAPOL(version = 3, type = 5)) == b'\x03\x05\x00\x00' 6356*7dc08ffcSJunyu Lai 6357*7dc08ffcSJunyu Lai= EAPOL - Dissection (1) 6358*7dc08ffcSJunyu Lais = b'\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6359*7dc08ffcSJunyu Laieapol = EAPOL(s) 6360*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6361*7dc08ffcSJunyu Laiassert(eapol.type == 1) 6362*7dc08ffcSJunyu Laiassert(eapol.len == 0) 6363*7dc08ffcSJunyu Lai 6364*7dc08ffcSJunyu Lai= EAPOL - Dissection (2) 6365*7dc08ffcSJunyu Lais = b'\x03\x00\x00\x05\x01\x01\x00\x05\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6366*7dc08ffcSJunyu Laieapol = EAPOL(s) 6367*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6368*7dc08ffcSJunyu Laiassert(eapol.type == 0) 6369*7dc08ffcSJunyu Laiassert(eapol.len == 5) 6370*7dc08ffcSJunyu Lai 6371*7dc08ffcSJunyu Lai= EAPOL - Dissection (3) 6372*7dc08ffcSJunyu Lais = b'\x03\x00\x00\x0e\x02\x01\x00\x0e\x01anonymous\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6373*7dc08ffcSJunyu Laieapol = EAPOL(s) 6374*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6375*7dc08ffcSJunyu Laiassert(eapol.type == 0) 6376*7dc08ffcSJunyu Laiassert(eapol.len == 14) 6377*7dc08ffcSJunyu Lai 6378*7dc08ffcSJunyu Lai= EAPOL - Dissection (4) 6379*7dc08ffcSJunyu Laireq = EAPOL(b'\x03\x00\x00\x05\x01\x01\x00\x05\x01') 6380*7dc08ffcSJunyu Laians = EAPOL(b'\x03\x00\x00\x0e\x02\x01\x00\x0e\x01anonymous') 6381*7dc08ffcSJunyu Laians.answers(req) 6382*7dc08ffcSJunyu Lai 6383*7dc08ffcSJunyu Lai= EAPOL - Dissection (5) 6384*7dc08ffcSJunyu Lais = b'\x02\x00\x00\x06\x01\x01\x00\x06\r ' 6385*7dc08ffcSJunyu Laieapol = EAPOL(s) 6386*7dc08ffcSJunyu Laiassert(eapol.version == 2) 6387*7dc08ffcSJunyu Laiassert(eapol.type == 0) 6388*7dc08ffcSJunyu Laiassert(eapol.len == 6) 6389*7dc08ffcSJunyu Laiassert(eapol.haslayer(EAP_TLS)) 6390*7dc08ffcSJunyu Lai 6391*7dc08ffcSJunyu Lai= EAPOL - Dissection (6) 6392*7dc08ffcSJunyu Lais = b'\x03\x00\x00<\x02\x9e\x00<+\x01\x16\x03\x01\x001\x01\x00\x00-\x03\x01dr1\x93ZS\x0en\xad\x1f\xbaH\xbb\xfe6\xe6\xd0\xcb\xec\xd7\xc0\xd7\xb9\xa5\xc9\x0c\xfd\x98o\xa7T \x00\x00\x04\x004\x00\x00\x01\x00\x00\x00' 6393*7dc08ffcSJunyu Laieapol = EAPOL(s) 6394*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6395*7dc08ffcSJunyu Laiassert(eapol.type == 0) 6396*7dc08ffcSJunyu Laiassert(eapol.len == 60) 6397*7dc08ffcSJunyu Laiassert(eapol.haslayer(EAP_FAST)) 6398*7dc08ffcSJunyu Lai 6399*7dc08ffcSJunyu Lai 6400*7dc08ffcSJunyu Lai############ 6401*7dc08ffcSJunyu Lai############ 6402*7dc08ffcSJunyu Lai+ EAPOL-MKA class tests 6403*7dc08ffcSJunyu Lai 6404*7dc08ffcSJunyu Lai= EAPOL-MKA - With Basic parameter set - Dissection 6405*7dc08ffcSJunyu Laieapol = None 6406*7dc08ffcSJunyu Lais = b'\x03\x05\x00T\x01\xff\xf0<\x00Bh\xa8\x1e\x03\x00\n\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7\x00\x00\x00\x01\x00\x80\xc2\x01\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\xff\x00\x00\x10\xe5\xf5j\x86V\\\xb1\xcc\xa9\xb95\x04m*Cj' 6407*7dc08ffcSJunyu Laieapol = EAPOL(s) 6408*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6409*7dc08ffcSJunyu Laiassert(eapol.type == 5) 6410*7dc08ffcSJunyu Laiassert(eapol.len == 84) 6411*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKAPDU)) 6412*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].basic_param_set.actor_member_id == b"\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7") 6413*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].haslayer(MKAICVSet)) 6414*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKAICVSet].icv == b"\xe5\xf5j\x86V\\\xb1\xcc\xa9\xb95\x04m*Cj") 6415*7dc08ffcSJunyu Lai 6416*7dc08ffcSJunyu Lai 6417*7dc08ffcSJunyu Lai= EAPOL-MKA - With Potential Peer List parameter set - Dissection 6418*7dc08ffcSJunyu Laieapol = None 6419*7dc08ffcSJunyu Lais = b'\x03\x05\x00h\x01\x10\xe0<\xccN$\xc4\xf7\x7f\x00\x80q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00}\x00\x80\xc2\x01\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x02\x00\x00\x10\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7\x00\x00\x00\x01\xff\x00\x00\x105\x01\xdc)\xfd\xd1\xff\xd55\x9c_o\xc9\x9c\xca\xc0' 6420*7dc08ffcSJunyu Laieapol = EAPOL(s) 6421*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6422*7dc08ffcSJunyu Laiassert(eapol.type == 5) 6423*7dc08ffcSJunyu Laiassert(eapol.len == 104) 6424*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKAPDU)) 6425*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].basic_param_set.actor_member_id == b"q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6") 6426*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKAPotentialPeerListParamSet)) 6427*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKAPotentialPeerListParamSet].member_id_message_num[0].member_id == b"\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7") 6428*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].haslayer(MKAICVSet)) 6429*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKAICVSet].icv == b"5\x01\xdc)\xfd\xd1\xff\xd55\x9c_o\xc9\x9c\xca\xc0") 6430*7dc08ffcSJunyu Lai 6431*7dc08ffcSJunyu Lai= EAPOL-MKA - With Live Peer List parameter set - Dissection 6432*7dc08ffcSJunyu Laieapol = None 6433*7dc08ffcSJunyu Lais = b"\x03\x05\x00h\x01\xffp<\x00Bh\xa8\x1e\x03\x00\n\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7\x00\x00\x00\x02\x00\x80\xc2\x01\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x01\x00\x00\x10q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00\x80\xff\x00\x00\x10\xf4\xa1d\x18\tD\xa2}\x8e'\x0c/\xda,\xea\xb7" 6434*7dc08ffcSJunyu Laieapol = EAPOL(s) 6435*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6436*7dc08ffcSJunyu Laiassert(eapol.type == 5) 6437*7dc08ffcSJunyu Laiassert(eapol.len == 104) 6438*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKAPDU)) 6439*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].basic_param_set.actor_member_id == b'\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7') 6440*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKALivePeerListParamSet)) 6441*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKALivePeerListParamSet].member_id_message_num[0].member_id == b"q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6") 6442*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].haslayer(MKAICVSet)) 6443*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKAICVSet].icv == b"\xf4\xa1d\x18\tD\xa2}\x8e'\x0c/\xda,\xea\xb7") 6444*7dc08ffcSJunyu Lai 6445*7dc08ffcSJunyu Lai= EAPOL-MKA - With SAK Use parameter set - Dissection 6446*7dc08ffcSJunyu Laieapol = None 6447*7dc08ffcSJunyu Lais = b'\x03\x05\x00\x94\x01\xffp<\x00Bh\xa8\x1e\x03\x00\n\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7\x00\x00\x00\x03\x00\x80\xc2\x01\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x03\x10\x00(q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00\x01\x00\x00\x00\x00q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00\x10q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00\x83\xff\x00\x00\x10OF\x84\xf1@%\x95\xe6Fw9\x1a\xfa\x03(\xae' 6448*7dc08ffcSJunyu Laieapol = EAPOL(s) 6449*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6450*7dc08ffcSJunyu Laiassert(eapol.type == 5) 6451*7dc08ffcSJunyu Laiassert(eapol.len == 148) 6452*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKAPDU)) 6453*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].basic_param_set.actor_member_id == b'\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7') 6454*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKASAKUseParamSet)) 6455*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKASAKUseParamSet].latest_key_key_server_member_id == b"q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6") 6456*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKALivePeerListParamSet)) 6457*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKALivePeerListParamSet].member_id_message_num[0].member_id == b"q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6") 6458*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].haslayer(MKAICVSet)) 6459*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKAICVSet].icv == b"OF\x84\xf1@%\x95\xe6Fw9\x1a\xfa\x03(\xae") 6460*7dc08ffcSJunyu Lai 6461*7dc08ffcSJunyu Lai= EAPOL-MKA - With Distributed SAK parameter set - Dissection 6462*7dc08ffcSJunyu Laieapol = None 6463*7dc08ffcSJunyu Lais = b"\x03\x05\x00\xb4\x01\x10\xe0<\xccN$\xc4\xf7\x7f\x00\x80q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00\x81\x00\x80\xc2\x01\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x01\x00\x00\x10\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7\x00\x00\x00\x02\x03\x10\x00(q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x10\x00\x1c\x00\x00\x00\x01Cz\x05\x88\x9f\xe8-\x94W+?\x13~\xfb\x016yVB?\xbd\xa1\x9fu\xff\x00\x00\x10\xb0H\xcf\xe0:\xa1\x94RD'\x03\xe67\xe1Ur" 6464*7dc08ffcSJunyu Laieapol = EAPOL(s) 6465*7dc08ffcSJunyu Laiassert(eapol.version == 3) 6466*7dc08ffcSJunyu Laiassert(eapol.type == 5) 6467*7dc08ffcSJunyu Laiassert(eapol.len == 180) 6468*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKAPDU)) 6469*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].basic_param_set.actor_member_id == b"q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6") 6470*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKASAKUseParamSet)) 6471*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKASAKUseParamSet].latest_key_key_server_member_id == b"q\x8b\x8a9\x86k/X\x14\xc9\xdc\xf6") 6472*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKALivePeerListParamSet)) 6473*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKALivePeerListParamSet].member_id_message_num[0].member_id == b"\xbcj\x00\x96Ywz\x82:\x90\xd9\xe7") 6474*7dc08ffcSJunyu Laiassert(eapol.haslayer(MKADistributedSAKParamSet)) 6475*7dc08ffcSJunyu Laiassert(eapol[MKADistributedSAKParamSet].sak_aes_key_wrap == b"Cz\x05\x88\x9f\xe8-\x94W+?\x13~\xfb\x016yVB?\xbd\xa1\x9fu") 6476*7dc08ffcSJunyu Laiassert(eapol[MKAPDU].haslayer(MKAICVSet)) 6477*7dc08ffcSJunyu Laiassert(eapol[MKAPDU][MKAICVSet].icv == b"\xb0H\xcf\xe0:\xa1\x94RD'\x03\xe67\xe1Ur") 6478*7dc08ffcSJunyu Lai 6479*7dc08ffcSJunyu Lai 6480*7dc08ffcSJunyu Lai############ 6481*7dc08ffcSJunyu Lai############ 6482*7dc08ffcSJunyu Lai############ 6483*7dc08ffcSJunyu Lai+ EAP class tests 6484*7dc08ffcSJunyu Lai 6485*7dc08ffcSJunyu Lai= EAP - Basic Instantiation 6486*7dc08ffcSJunyu Lairaw(EAP()) == b'\x04\x00\x00\x04' 6487*7dc08ffcSJunyu Lai 6488*7dc08ffcSJunyu Lai= EAP - Instantiation with specific values 6489*7dc08ffcSJunyu Lairaw(EAP(code = 1, id = 1, len = 5, type = 1)) == b'\x01\x01\x00\x05\x01' 6490*7dc08ffcSJunyu Lai 6491*7dc08ffcSJunyu Lai= EAP - Dissection (1) 6492*7dc08ffcSJunyu Lais = b'\x01\x01\x00\x05\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6493*7dc08ffcSJunyu Laieap = EAP(s) 6494*7dc08ffcSJunyu Laiassert(eap.code == 1) 6495*7dc08ffcSJunyu Laiassert(eap.id == 1) 6496*7dc08ffcSJunyu Laiassert(eap.len == 5) 6497*7dc08ffcSJunyu Laiassert(hasattr(eap, "type")) 6498*7dc08ffcSJunyu Laiassert(eap.type == 1) 6499*7dc08ffcSJunyu Lai 6500*7dc08ffcSJunyu Lai= EAP - Dissection (2) 6501*7dc08ffcSJunyu Lais = b'\x02\x01\x00\x0e\x01anonymous\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6502*7dc08ffcSJunyu Laieap = EAP(s) 6503*7dc08ffcSJunyu Laiassert(eap.code == 2) 6504*7dc08ffcSJunyu Laiassert(eap.id == 1) 6505*7dc08ffcSJunyu Laiassert(eap.len == 14) 6506*7dc08ffcSJunyu Laiassert(eap.type == 1) 6507*7dc08ffcSJunyu Laiassert(hasattr(eap, 'identity')) 6508*7dc08ffcSJunyu Laiassert(eap.identity == b'anonymous') 6509*7dc08ffcSJunyu Lai 6510*7dc08ffcSJunyu Lai= EAP - Dissection (3) 6511*7dc08ffcSJunyu Lais = b'\x01\x01\x00\x06\r ' 6512*7dc08ffcSJunyu Laieap = EAP(s) 6513*7dc08ffcSJunyu Laiassert(eap.code == 1) 6514*7dc08ffcSJunyu Laiassert(eap.id == 1) 6515*7dc08ffcSJunyu Laiassert(eap.len == 6) 6516*7dc08ffcSJunyu Laiassert(eap.type == 13) 6517*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_TLS)) 6518*7dc08ffcSJunyu Laiassert(eap[EAP_TLS].L == 0) 6519*7dc08ffcSJunyu Laiassert(eap[EAP_TLS].M == 0) 6520*7dc08ffcSJunyu Laiassert(eap[EAP_TLS].S == 1) 6521*7dc08ffcSJunyu Lai 6522*7dc08ffcSJunyu Lai= EAP - Dissection (4) 6523*7dc08ffcSJunyu Lais = b'\x02\x01\x00\xd1\r\x00\x16\x03\x01\x00\xc6\x01\x00\x00\xc2\x03\x01UK\x02\xdf\x1e\xde5\xab\xfa[\x15\xef\xbe\xa2\xe4`\xc6g\xb9\xa8\xaa%vAs\xb2\x1cXt\x1c0\xb7\x00\x00P\xc0\x14\xc0\n\x009\x008\x00\x88\x00\x87\xc0\x0f\xc0\x05\x005\x00\x84\xc0\x12\xc0\x08\x00\x16\x00\x13\xc0\r\xc0\x03\x00\n\xc0\x13\xc0\t\x003\x002\x00\x9a\x00\x99\x00E\x00D\xc0\x0e\xc0\x04\x00/\x00\x96\x00A\xc0\x11\xc0\x07\xc0\x0c\xc0\x02\x00\x05\x00\x04\x00\x15\x00\x12\x00\t\x00\xff\x01\x00\x00I\x00\x0b\x00\x04\x03\x00\x01\x02\x00\n\x004\x002\x00\x0e\x00\r\x00\x19\x00\x0b\x00\x0c\x00\x18\x00\t\x00\n\x00\x16\x00\x17\x00\x08\x00\x06\x00\x07\x00\x14\x00\x15\x00\x04\x00\x05\x00\x12\x00\x13\x00\x01\x00\x02\x00\x03\x00\x0f\x00\x10\x00\x11\x00#\x00\x00\x00\x0f\x00\x01\x01' 6524*7dc08ffcSJunyu Laieap = EAP(s) 6525*7dc08ffcSJunyu Laiassert(eap.code == 2) 6526*7dc08ffcSJunyu Laiassert(eap.id == 1) 6527*7dc08ffcSJunyu Laiassert(eap.len == 209) 6528*7dc08ffcSJunyu Laiassert(eap.type == 13) 6529*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_TLS)) 6530*7dc08ffcSJunyu Laiassert(eap[EAP_TLS].L == 0) 6531*7dc08ffcSJunyu Laiassert(eap[EAP_TLS].M == 0) 6532*7dc08ffcSJunyu Laiassert(eap[EAP_TLS].S == 0) 6533*7dc08ffcSJunyu Lai 6534*7dc08ffcSJunyu Lai= EAP - Dissection (5) 6535*7dc08ffcSJunyu Lais = b'\x02\x9e\x00<+\x01\x16\x03\x01\x001\x01\x00\x00-\x03\x01dr1\x93ZS\x0en\xad\x1f\xbaH\xbb\xfe6\xe6\xd0\xcb\xec\xd7\xc0\xd7\xb9\xa5\xc9\x0c\xfd\x98o\xa7T \x00\x00\x04\x004\x00\x00\x01\x00\x00\x00' 6536*7dc08ffcSJunyu Laieap = EAP(s) 6537*7dc08ffcSJunyu Laiassert(eap.code == 2) 6538*7dc08ffcSJunyu Laiassert(eap.id == 158) 6539*7dc08ffcSJunyu Laiassert(eap.len == 60) 6540*7dc08ffcSJunyu Laiassert(eap.type == 43) 6541*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_FAST)) 6542*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].L == 0) 6543*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].M == 0) 6544*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].S == 0) 6545*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].version == 1) 6546*7dc08ffcSJunyu Lai 6547*7dc08ffcSJunyu Lai= EAP - Dissection (6) 6548*7dc08ffcSJunyu Lais = b'\x02\x9f\x01L+\x01\x16\x03\x01\x01\x06\x10\x00\x01\x02\x01\x00Y\xc9\x8a\tcw\t\xdcbU\xfd\x035\xcd\x1a\t\x10f&[(9\xf6\x88W`\xc6\x0f\xb3\x84\x15\x19\xf5\tk\xbd\x8fp&0\xb0\xa4B\x85\x0c<:s\xf2zT\xc3\xbd\x8a\xe4D{m\xe7\x97\xfe>\xda\x14\xb8T1{\xd7H\x9c\xa6\xcb\xe3,u\xdf\xe0\x82\xe5R\x1e<\xe5\x03}\xeb\x98\xe2\xf7\x8d3\xc6\x83\xac"\x8f\xd7\x12\xe5{:"\x84A\xd9\x14\xc2cZF\xd4\t\xab\xdar\xc7\xe0\x0e\x00o\xce\x05g\xdc?\xcc\xf7\xe83\x83E\xb3>\xe8<3-QB\xfd$C/\x1be\xcf\x03\xd6Q4\xbe\\h\xba)<\x99N\x89\xd9\xb1\xfa!\xd7a\xef\xa3\xd3o\xed8Uz\xb5k\xb0`\xfeC\xbc\xb3aS,d\xe6\xdc\x13\xa4A\x1e\x9b\r{\xd6s \xd0cQ\x95y\xc8\x1d\xc3\xd9\x87\xf2=\x81\x96q~\x99E\xc3\x97\xa8px\xe2\xc7\x92\xeb\xff/v\x84\x1e\xfb\x00\x95#\xba\xfb\xd88h\x90K\xa7\xbd9d\xb4\xf2\xf2\x14\x02vtW\xaa\xadY\x14\x03\x01\x00\x01\x01\x16\x03\x01\x000\x97\xc5l\xd6\xef\xffcM\x81\x90Q\x96\xf6\xfeX1\xf7\xfc\x84\xc6\xa0\xf6Z\xcd\xb6\xe1\xd4\xdb\x88\xf9t%Q!\xe7,~#2G-\xdf\x83\xbf\x86Q\xa2$' 6549*7dc08ffcSJunyu Laieap = EAP(s) 6550*7dc08ffcSJunyu Laiassert(eap.code == 2) 6551*7dc08ffcSJunyu Laiassert(eap.id == 159) 6552*7dc08ffcSJunyu Laiassert(eap.len == 332) 6553*7dc08ffcSJunyu Laiassert(eap.type == 43) 6554*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_FAST)) 6555*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].L == 0) 6556*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].M == 0) 6557*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].S == 0) 6558*7dc08ffcSJunyu Laiassert(eap[EAP_FAST].version == 1) 6559*7dc08ffcSJunyu Lai 6560*7dc08ffcSJunyu Lai= EAP - Dissection (7) 6561*7dc08ffcSJunyu Lais = b'\x02\xf1\x00\x06\x03+' 6562*7dc08ffcSJunyu Laieap = EAP(s) 6563*7dc08ffcSJunyu Laiassert(eap.code == 2) 6564*7dc08ffcSJunyu Laiassert(eap.id == 241) 6565*7dc08ffcSJunyu Laiassert(eap.len == 6) 6566*7dc08ffcSJunyu Laiassert(eap.type == 3) 6567*7dc08ffcSJunyu Laiassert(hasattr(eap, 'desired_auth_type')) 6568*7dc08ffcSJunyu Laiassert(eap.desired_auth_type == 43) 6569*7dc08ffcSJunyu Lai 6570*7dc08ffcSJunyu Lai= EAP - Dissection (8) 6571*7dc08ffcSJunyu Lais = b"\x02\x03\x01\x15\x15\x00\x16\x03\x01\x01\n\x01\x00\x01\x06\x03\x03\xd5\xd9\xd5rT\x9e\xb8\xbe,>\xcf!\xcf\xc7\x02\x8c\xb1\x1e^F\xf7\xc84\x8c\x01t4\x91[\x02\xc8/\x00\x00\x8c\xc00\xc0,\xc0(\xc0$\xc0\x14\xc0\n\x00\xa5\x00\xa3\x00\xa1\x00\x9f\x00k\x00j\x00i\x00h\x009\x008\x007\x006\x00\x88\x00\x87\x00\x86\x00\x85\xc02\xc0.\xc0*\xc0&\xc0\x0f\xc0\x05\x00\x9d\x00=\x005\x00\x84\xc0/\xc0+\xc0'\xc0#\xc0\x13\xc0\t\x00\xa4\x00\xa2\x00\xa0\x00\x9e\x00g\x00@\x00?\x00>\x003\x002\x001\x000\x00\x9a\x00\x99\x00\x98\x00\x97\x00E\x00D\x00C\x00B\xc01\xc0-\xc0)\xc0%\xc0\x0e\xc0\x04\x00\x9c\x00<\x00/\x00\x96\x00A\x00\xff\x01\x00\x00Q\x00\x0b\x00\x04\x03\x00\x01\x02\x00\n\x00\x1c\x00\x1a\x00\x17\x00\x19\x00\x1c\x00\x1b\x00\x18\x00\x1a\x00\x16\x00\x0e\x00\r\x00\x0b\x00\x0c\x00\t\x00\n\x00\r\x00 \x00\x1e\x06\x01\x06\x02\x06\x03\x05\x01\x05\x02\x05\x03\x04\x01\x04\x02\x04\x03\x03\x01\x03\x02\x03\x03\x02\x01\x02\x02\x02\x03\x00\x0f\x00\x01\x01" 6572*7dc08ffcSJunyu Laieap = EAP(s) 6573*7dc08ffcSJunyu Laiassert(eap.code == 2) 6574*7dc08ffcSJunyu Laiassert(eap.id == 3) 6575*7dc08ffcSJunyu Laiassert(eap.len == 277) 6576*7dc08ffcSJunyu Laiassert(eap.type == 21) 6577*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_TTLS)) 6578*7dc08ffcSJunyu Laiassert(eap[EAP_TTLS].L == 0) 6579*7dc08ffcSJunyu Laiassert(eap[EAP_TTLS].M == 0) 6580*7dc08ffcSJunyu Laiassert(eap[EAP_TTLS].S == 0) 6581*7dc08ffcSJunyu Laiassert(eap[EAP_TTLS].version == 0) 6582*7dc08ffcSJunyu Lai 6583*7dc08ffcSJunyu Lai= EAP - EAP_TLS - Basic Instantiation 6584*7dc08ffcSJunyu Lairaw(EAP_TLS()) == b'\x01\x00\x00\x06\r\x00' 6585*7dc08ffcSJunyu Lai 6586*7dc08ffcSJunyu Lai= EAP - EAP_FAST - Basic Instantiation 6587*7dc08ffcSJunyu Lairaw(EAP_FAST()) == b'\x01\x00\x00\x06+\x00' 6588*7dc08ffcSJunyu Lai 6589*7dc08ffcSJunyu Lai= EAP - EAP_TTLS - Basic Instantiation 6590*7dc08ffcSJunyu Lairaw(EAP_TTLS()) == b'\x01\x00\x00\x06\x15\x00' 6591*7dc08ffcSJunyu Lai 6592*7dc08ffcSJunyu Lai= EAP - EAP_MD5 - Basic Instantiation 6593*7dc08ffcSJunyu Lairaw(EAP_MD5()) == b'\x01\x00\x00\x06\x04\x00' 6594*7dc08ffcSJunyu Lai 6595*7dc08ffcSJunyu Lai= EAP - EAP_MD5 - Request - Dissection (8) 6596*7dc08ffcSJunyu Lais = b'\x01\x02\x00\x16\x04\x10\x86\xf9\x89\x94\x81\x01\xb3 nHh\x1b\x8d\xe7^\xdb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6597*7dc08ffcSJunyu Laieap = EAP(s) 6598*7dc08ffcSJunyu Laiassert(eap.code == 1) 6599*7dc08ffcSJunyu Laiassert(eap.id == 2) 6600*7dc08ffcSJunyu Laiassert(eap.len == 22) 6601*7dc08ffcSJunyu Laiassert(eap.type == 4) 6602*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_MD5)) 6603*7dc08ffcSJunyu Laiassert(eap[EAP_MD5].value_size == 16) 6604*7dc08ffcSJunyu Laiassert(eap[EAP_MD5].value == b'\x86\xf9\x89\x94\x81\x01\xb3 nHh\x1b\x8d\xe7^\xdb') 6605*7dc08ffcSJunyu Laiassert(eap[EAP_MD5].optional_name == b'') 6606*7dc08ffcSJunyu Lai 6607*7dc08ffcSJunyu Lai= EAP - EAP_MD5 - Response - Dissection (9) 6608*7dc08ffcSJunyu Lais = b'\x02\x02\x00\x16\x04\x10\xfd\x1e\xffe\xf5\x80y\xa8\xe3\xc8\xf1\xbd\xc2\x85\xae\xcf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6609*7dc08ffcSJunyu Laieap = EAP(s) 6610*7dc08ffcSJunyu Laiassert(eap.code == 2) 6611*7dc08ffcSJunyu Laiassert(eap.id == 2) 6612*7dc08ffcSJunyu Laiassert(eap.len == 22) 6613*7dc08ffcSJunyu Laiassert(eap.type == 4) 6614*7dc08ffcSJunyu Laiassert(eap.haslayer(EAP_MD5)) 6615*7dc08ffcSJunyu Laiassert(eap[EAP_MD5].value_size == 16) 6616*7dc08ffcSJunyu Laiassert(eap[EAP_MD5].value == b'\xfd\x1e\xffe\xf5\x80y\xa8\xe3\xc8\xf1\xbd\xc2\x85\xae\xcf') 6617*7dc08ffcSJunyu Laiassert(eap[EAP_MD5].optional_name == b'') 6618*7dc08ffcSJunyu Lai 6619*7dc08ffcSJunyu Lai= EAP - LEAP - Basic Instantiation 6620*7dc08ffcSJunyu Lairaw(LEAP()) == b'\x01\x00\x00\x08\x11\x01\x00\x00' 6621*7dc08ffcSJunyu Lai 6622*7dc08ffcSJunyu Lai= EAP - LEAP - Request - Dissection (10) 6623*7dc08ffcSJunyu Lais = b'\x01D\x00\x1c\x11\x01\x00\x088\xb6\xd7\xa1E<!\x15supplicant-1' 6624*7dc08ffcSJunyu Laieap = LEAP(s) 6625*7dc08ffcSJunyu Laiassert(eap.code == 1) 6626*7dc08ffcSJunyu Laiassert(eap.id == 68) 6627*7dc08ffcSJunyu Laiassert(eap.len == 28) 6628*7dc08ffcSJunyu Laiassert(eap.type == 17) 6629*7dc08ffcSJunyu Laiassert(eap.haslayer(LEAP)) 6630*7dc08ffcSJunyu Laiassert(eap[LEAP].version == 1) 6631*7dc08ffcSJunyu Laiassert(eap[LEAP].count == 8) 6632*7dc08ffcSJunyu Laiassert(eap[LEAP].challenge_response == b'8\xb6\xd7\xa1E<!\x15') 6633*7dc08ffcSJunyu Laiassert(eap[LEAP].username == b"supplicant-1") 6634*7dc08ffcSJunyu Lai 6635*7dc08ffcSJunyu Lai= EAP - LEAP - Response - Dissection (11) 6636*7dc08ffcSJunyu Lais = b'\x02D\x00,\x11\x01\x00\x18\xb3\x82[\x82\x8a\xc8M*\xf3\xe7\xb3\xad,7\x8b\xbfG\x81\xda\xbf\xe6\xc1\x9b\x95supplicant-1' 6637*7dc08ffcSJunyu Laieap = LEAP(s) 6638*7dc08ffcSJunyu Laiassert(eap.code == 2) 6639*7dc08ffcSJunyu Laiassert(eap.id == 68) 6640*7dc08ffcSJunyu Laiassert(eap.len == 44) 6641*7dc08ffcSJunyu Laiassert(eap.type == 17) 6642*7dc08ffcSJunyu Laiassert(eap.haslayer(LEAP)) 6643*7dc08ffcSJunyu Laiassert(eap[LEAP].version == 1) 6644*7dc08ffcSJunyu Laiassert(eap[LEAP].count == 24) 6645*7dc08ffcSJunyu Laiassert(eap[LEAP].challenge_response == b'\xb3\x82[\x82\x8a\xc8M*\xf3\xe7\xb3\xad,7\x8b\xbfG\x81\xda\xbf\xe6\xc1\x9b\x95') 6646*7dc08ffcSJunyu Laiassert(eap[LEAP].username == b"supplicant-1") 6647*7dc08ffcSJunyu Lai 6648*7dc08ffcSJunyu Lai= EAP - Layers (1) 6649*7dc08ffcSJunyu Laieap = EAP_MD5() 6650*7dc08ffcSJunyu Laiassert(EAP_MD5 in eap) 6651*7dc08ffcSJunyu Laiassert(not EAP_TLS in eap) 6652*7dc08ffcSJunyu Laiassert(not EAP_FAST in eap) 6653*7dc08ffcSJunyu Laiassert(not LEAP in eap) 6654*7dc08ffcSJunyu Laiassert(EAP in eap) 6655*7dc08ffcSJunyu Laieap = EAP_TLS() 6656*7dc08ffcSJunyu Laiassert(EAP_TLS in eap) 6657*7dc08ffcSJunyu Laiassert(not EAP_MD5 in eap) 6658*7dc08ffcSJunyu Laiassert(not EAP_FAST in eap) 6659*7dc08ffcSJunyu Laiassert(not LEAP in eap) 6660*7dc08ffcSJunyu Laiassert(EAP in eap) 6661*7dc08ffcSJunyu Laieap = EAP_FAST() 6662*7dc08ffcSJunyu Laiassert(EAP_FAST in eap) 6663*7dc08ffcSJunyu Laiassert(not EAP_MD5 in eap) 6664*7dc08ffcSJunyu Laiassert(not EAP_TLS in eap) 6665*7dc08ffcSJunyu Laiassert(not LEAP in eap) 6666*7dc08ffcSJunyu Laiassert(EAP in eap) 6667*7dc08ffcSJunyu Laieap = EAP_TTLS() 6668*7dc08ffcSJunyu Laiassert(EAP_TTLS in eap) 6669*7dc08ffcSJunyu Laiassert(not EAP_MD5 in eap) 6670*7dc08ffcSJunyu Laiassert(not EAP_TLS in eap) 6671*7dc08ffcSJunyu Laiassert(not EAP_FAST in eap) 6672*7dc08ffcSJunyu Laiassert(not LEAP in eap) 6673*7dc08ffcSJunyu Laiassert(EAP in eap) 6674*7dc08ffcSJunyu Laieap = LEAP() 6675*7dc08ffcSJunyu Laiassert(not EAP_MD5 in eap) 6676*7dc08ffcSJunyu Laiassert(not EAP_TLS in eap) 6677*7dc08ffcSJunyu Laiassert(not EAP_FAST in eap) 6678*7dc08ffcSJunyu Laiassert(LEAP in eap) 6679*7dc08ffcSJunyu Laiassert(EAP in eap) 6680*7dc08ffcSJunyu Lai 6681*7dc08ffcSJunyu Lai= EAP - Layers (2) 6682*7dc08ffcSJunyu Laieap = EAP_MD5() 6683*7dc08ffcSJunyu Laiassert(type(eap[EAP]) == EAP_MD5) 6684*7dc08ffcSJunyu Laieap = EAP_TLS() 6685*7dc08ffcSJunyu Laiassert(type(eap[EAP]) == EAP_TLS) 6686*7dc08ffcSJunyu Laieap = EAP_FAST() 6687*7dc08ffcSJunyu Laiassert(type(eap[EAP]) == EAP_FAST) 6688*7dc08ffcSJunyu Laieap = EAP_TTLS() 6689*7dc08ffcSJunyu Laiassert(type(eap[EAP]) == EAP_TTLS) 6690*7dc08ffcSJunyu Laieap = LEAP() 6691*7dc08ffcSJunyu Laiassert(type(eap[EAP]) == LEAP) 6692*7dc08ffcSJunyu Lai 6693*7dc08ffcSJunyu Lai 6694*7dc08ffcSJunyu Lai 6695*7dc08ffcSJunyu Lai############ 6696*7dc08ffcSJunyu Lai############ 6697*7dc08ffcSJunyu Lai+ NTP module tests 6698*7dc08ffcSJunyu Lai 6699*7dc08ffcSJunyu Lai= NTP - Layers (1) 6700*7dc08ffcSJunyu Laip = NTPHeader() 6701*7dc08ffcSJunyu Laiassert(NTPHeader in p) 6702*7dc08ffcSJunyu Laiassert(not NTPControl in p) 6703*7dc08ffcSJunyu Laiassert(not NTPPrivate in p) 6704*7dc08ffcSJunyu Laiassert(NTP in p) 6705*7dc08ffcSJunyu Laip = NTPControl() 6706*7dc08ffcSJunyu Laiassert(not NTPHeader in p) 6707*7dc08ffcSJunyu Laiassert(NTPControl in p) 6708*7dc08ffcSJunyu Laiassert(not NTPPrivate in p) 6709*7dc08ffcSJunyu Laiassert(NTP in p) 6710*7dc08ffcSJunyu Laip = NTPPrivate() 6711*7dc08ffcSJunyu Laiassert(not NTPHeader in p) 6712*7dc08ffcSJunyu Laiassert(not NTPControl in p) 6713*7dc08ffcSJunyu Laiassert(NTPPrivate in p) 6714*7dc08ffcSJunyu Laiassert(NTP in p) 6715*7dc08ffcSJunyu Lai 6716*7dc08ffcSJunyu Lai 6717*7dc08ffcSJunyu Lai= NTP - Layers (2) 6718*7dc08ffcSJunyu Laip = NTPHeader() 6719*7dc08ffcSJunyu Laiassert(type(p[NTP]) == NTPHeader) 6720*7dc08ffcSJunyu Laip = NTPControl() 6721*7dc08ffcSJunyu Laiassert(type(p[NTP]) == NTPControl) 6722*7dc08ffcSJunyu Laip = NTPPrivate() 6723*7dc08ffcSJunyu Laiassert(type(p[NTP]) == NTPPrivate) 6724*7dc08ffcSJunyu Lai 6725*7dc08ffcSJunyu Lai 6726*7dc08ffcSJunyu Lai############ 6727*7dc08ffcSJunyu Lai############ 6728*7dc08ffcSJunyu Lai+ NTPHeader tests 6729*7dc08ffcSJunyu Lai 6730*7dc08ffcSJunyu Lai= NTPHeader - Basic checks 6731*7dc08ffcSJunyu Lailen(raw(NTP())) == 48 6732*7dc08ffcSJunyu Lai 6733*7dc08ffcSJunyu Lai 6734*7dc08ffcSJunyu Lai= NTPHeader - Dissection 6735*7dc08ffcSJunyu Lais = b"!\x0b\x06\xea\x00\x00\x00\x00\x00\x00\xf2\xc1\x7f\x7f\x01\x00\xdb9\xe8\xa21\x02\xe6\xbc\xdb9\xe8\x81\x02U8\xef\xdb9\xe8\x80\xdcl+\x06\xdb9\xe8\xa91\xcbI\xbf\x00\x00\x00\x01\xady\xf3\xa1\xe5\xfc\xd02\xd2j\x1e'\xc3\xc1\xb6\x0e" 6736*7dc08ffcSJunyu Laip = NTP(s) 6737*7dc08ffcSJunyu Laiassert(isinstance(p, NTPHeader)) 6738*7dc08ffcSJunyu Laiassert(p[NTPAuthenticator].key_id == 1) 6739*7dc08ffcSJunyu Laiassert(bytes_hex(p[NTPAuthenticator].dgst) == b'ad79f3a1e5fcd032d26a1e27c3c1b60e') 6740*7dc08ffcSJunyu Lai 6741*7dc08ffcSJunyu Lai 6742*7dc08ffcSJunyu Lai= NTPHeader - KoD 6743*7dc08ffcSJunyu Lais = b'\xe4\x00\x06\xe8\x00\x00\x00\x00\x00\x00\x02\xcaINIT\x00\x00\x00\x00\x00\x00\x00\x00\xdb@\xe3\x9eH\xa3pj\xdb@\xe3\x9eH\xf0\xc3\\\xdb@\xe3\x9eH\xfaL\xac\x00\x00\x00\x01B\x86)\xc1Q4\x8bW8\xe7Q\xda\xd0Z\xbc\xb8' 6744*7dc08ffcSJunyu Laip = NTP(s) 6745*7dc08ffcSJunyu Laiassert(isinstance(p, NTPHeader)) 6746*7dc08ffcSJunyu Laiassert(p.leap == 3) 6747*7dc08ffcSJunyu Laiassert(p.version == 4) 6748*7dc08ffcSJunyu Laiassert(p.mode == 4) 6749*7dc08ffcSJunyu Laiassert(p.stratum == 0) 6750*7dc08ffcSJunyu Laiassert(p.ref_id == b'INIT') 6751*7dc08ffcSJunyu Lai 6752*7dc08ffcSJunyu Lai 6753*7dc08ffcSJunyu Lai= NTPHeader - Extension dissection test 6754*7dc08ffcSJunyu Lais = b'#\x02\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\xdbM\xdf\x19e\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdbM\xdf\x19e\x89\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 6755*7dc08ffcSJunyu Laip = NTP(s) 6756*7dc08ffcSJunyu Laiassert(isinstance(p, NTPHeader)) 6757*7dc08ffcSJunyu Laiassert(p.leap == 0) 6758*7dc08ffcSJunyu Laiassert(p.version == 4) 6759*7dc08ffcSJunyu Laiassert(p.mode == 3) 6760*7dc08ffcSJunyu Laiassert(p.stratum == 2) 6761*7dc08ffcSJunyu Lai 6762*7dc08ffcSJunyu Lai 6763*7dc08ffcSJunyu Lai############ 6764*7dc08ffcSJunyu Lai############ 6765*7dc08ffcSJunyu Lai+ NTP Control (mode 6) tests 6766*7dc08ffcSJunyu Lai 6767*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READSTAT (1) - request 6768*7dc08ffcSJunyu Lais = b'\x16\x01\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00' 6769*7dc08ffcSJunyu Laip = NTP(s) 6770*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6771*7dc08ffcSJunyu Laiassert(p.version == 2) 6772*7dc08ffcSJunyu Laiassert(p.mode == 6) 6773*7dc08ffcSJunyu Laiassert(p.response == 0) 6774*7dc08ffcSJunyu Laiassert(p.err == 0) 6775*7dc08ffcSJunyu Laiassert(p.more == 0) 6776*7dc08ffcSJunyu Laiassert(p.op_code == 1) 6777*7dc08ffcSJunyu Laiassert(p.sequence == 12) 6778*7dc08ffcSJunyu Laiassert(p.status == 0) 6779*7dc08ffcSJunyu Laiassert(p.association_id == 0) 6780*7dc08ffcSJunyu Laiassert(p.offset == 0) 6781*7dc08ffcSJunyu Laiassert(p.count == 0) 6782*7dc08ffcSJunyu Laiassert(p.data == b'') 6783*7dc08ffcSJunyu Lai 6784*7dc08ffcSJunyu Lai 6785*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READSTAT (2) - response 6786*7dc08ffcSJunyu Lais = b'\x16\x81\x00\x0c\x06d\x00\x00\x00\x00\x00\x04\xe5\xfc\xf6$' 6787*7dc08ffcSJunyu Laip = NTP(s) 6788*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6789*7dc08ffcSJunyu Laiassert(p.version == 2) 6790*7dc08ffcSJunyu Laiassert(p.mode == 6) 6791*7dc08ffcSJunyu Laiassert(p.response == 1) 6792*7dc08ffcSJunyu Laiassert(p.err == 0) 6793*7dc08ffcSJunyu Laiassert(p.more == 0) 6794*7dc08ffcSJunyu Laiassert(p.op_code == 1) 6795*7dc08ffcSJunyu Laiassert(p.sequence == 12) 6796*7dc08ffcSJunyu Laiassert(isinstance(p.status_word, NTPSystemStatusPacket)) 6797*7dc08ffcSJunyu Laiassert(p.status_word.leap_indicator == 0) 6798*7dc08ffcSJunyu Laiassert(p.status_word.clock_source == 6) 6799*7dc08ffcSJunyu Laiassert(p.status_word.system_event_counter == 6) 6800*7dc08ffcSJunyu Laiassert(p.status_word.system_event_code == 4) 6801*7dc08ffcSJunyu Laiassert(p.association_id == 0) 6802*7dc08ffcSJunyu Laiassert(p.offset == 0) 6803*7dc08ffcSJunyu Laiassert(p.count == 4) 6804*7dc08ffcSJunyu Laiassert(isinstance(p.data, NTPPeerStatusDataPacket)) 6805*7dc08ffcSJunyu Laiassert(p.data.association_id == 58876) 6806*7dc08ffcSJunyu Laiassert(isinstance(p.data.peer_status, NTPPeerStatusPacket)) 6807*7dc08ffcSJunyu Laiassert(p.data.peer_status.configured == 1) 6808*7dc08ffcSJunyu Laiassert(p.data.peer_status.auth_enabled == 1) 6809*7dc08ffcSJunyu Laiassert(p.data.peer_status.authentic == 1) 6810*7dc08ffcSJunyu Laiassert(p.data.peer_status.reachability == 1) 6811*7dc08ffcSJunyu Laiassert(p.data.peer_status.reserved == 0) 6812*7dc08ffcSJunyu Laiassert(p.data.peer_status.peer_sel == 6) 6813*7dc08ffcSJunyu Laiassert(p.data.peer_status.peer_event_counter == 2) 6814*7dc08ffcSJunyu Laiassert(p.data.peer_status.peer_event_code == 4) 6815*7dc08ffcSJunyu Lai 6816*7dc08ffcSJunyu Lai 6817*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READVAR (1) - request 6818*7dc08ffcSJunyu Lais = b'\x16\x02\x00\x12\x00\x00\xfc\x8f\x00\x00\x00\x00' 6819*7dc08ffcSJunyu Laip = NTP(s) 6820*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6821*7dc08ffcSJunyu Laiassert(p.version == 2) 6822*7dc08ffcSJunyu Laiassert(p.mode == 6) 6823*7dc08ffcSJunyu Laiassert(p.response == 0) 6824*7dc08ffcSJunyu Laiassert(p.op_code == 2) 6825*7dc08ffcSJunyu Laiassert(p.sequence == 18) 6826*7dc08ffcSJunyu Laiassert(p.status == 0) 6827*7dc08ffcSJunyu Laiassert(p.association_id == 64655) 6828*7dc08ffcSJunyu Laiassert(p.data == b'') 6829*7dc08ffcSJunyu Lai 6830*7dc08ffcSJunyu Lai 6831*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READVAR (2) - reponse (1st packet) 6832*7dc08ffcSJunyu Lais = b'\xd6\xa2\x00\x12\xc0\x11\xfc\x8f\x00\x00\x01\xd4srcadr=192.168.122.1, srcport=123, dstadr=192.168.122.100, dstport=123,\r\nleap=3, stratum=16, precision=-24, rootdelay=0.000, rootdisp=0.000,\r\nrefid=INIT, reftime=0x00000000.00000000, rec=0x00000000.00000000,\r\nreach=0x0, unreach=5, hmode=1, pmode=0, hpoll=6, ppoll=10, headway=62,\r\nflash=0x1200, keyid=1, offset=0.000, delay=0.000, dispersion=15937.500,\r\njitter=0.000, xleave=0.240,\r\nfiltdelay= 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00,\r\nfiltoffset= 0.00 0.00 0.00 0.00 ' 6833*7dc08ffcSJunyu Laip = NTP(s) 6834*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6835*7dc08ffcSJunyu Laiassert(p.version == 2) 6836*7dc08ffcSJunyu Laiassert(p.mode == 6) 6837*7dc08ffcSJunyu Laiassert(p.response == 1) 6838*7dc08ffcSJunyu Laiassert(p.err == 0) 6839*7dc08ffcSJunyu Laiassert(p.more == 1) 6840*7dc08ffcSJunyu Laiassert(p.op_code == 2) 6841*7dc08ffcSJunyu Laiassert(p.sequence == 18) 6842*7dc08ffcSJunyu Laiassert(isinstance(p.status_word, NTPPeerStatusPacket)) 6843*7dc08ffcSJunyu Laiassert(p.status_word.configured == 1) 6844*7dc08ffcSJunyu Laiassert(p.status_word.auth_enabled == 1) 6845*7dc08ffcSJunyu Laiassert(p.status_word.authentic == 0) 6846*7dc08ffcSJunyu Laiassert(p.status_word.reachability == 0) 6847*7dc08ffcSJunyu Laiassert(p.status_word.peer_sel == 0) 6848*7dc08ffcSJunyu Laiassert(p.status_word.peer_event_counter == 1) 6849*7dc08ffcSJunyu Laiassert(p.status_word.peer_event_code == 1) 6850*7dc08ffcSJunyu Laiassert(p.association_id == 64655) 6851*7dc08ffcSJunyu Laiassert(p.offset == 0) 6852*7dc08ffcSJunyu Laiassert(p.count == 468) 6853*7dc08ffcSJunyu Laiassert(p.data.load == b'srcadr=192.168.122.1, srcport=123, dstadr=192.168.122.100, dstport=123,\r\nleap=3, stratum=16, precision=-24, rootdelay=0.000, rootdisp=0.000,\r\nrefid=INIT, reftime=0x00000000.00000000, rec=0x00000000.00000000,\r\nreach=0x0, unreach=5, hmode=1, pmode=0, hpoll=6, ppoll=10, headway=62,\r\nflash=0x1200, keyid=1, offset=0.000, delay=0.000, dispersion=15937.500,\r\njitter=0.000, xleave=0.240,\r\nfiltdelay= 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00,\r\nfiltoffset= 0.00 0.00 0.00 0.00 ') 6854*7dc08ffcSJunyu Lai 6855*7dc08ffcSJunyu Lai 6856*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READVAR (3) - reponse (2nd packet) 6857*7dc08ffcSJunyu Lais = b'\xd6\x82\x00\x12\xc0\x11\xfc\x8f\x01\xd4\x00i0.00 0.00 0.00 0.00,\r\nfiltdisp= 16000.00 16000.00 16000.00 16000.00 16000.00 16000.00 16000.00 16000.00\r\n\x00\x00\x00' 6858*7dc08ffcSJunyu Laip = NTP(s) 6859*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6860*7dc08ffcSJunyu Laiassert(p.version == 2) 6861*7dc08ffcSJunyu Laiassert(p.mode == 6) 6862*7dc08ffcSJunyu Laiassert(p.response == 1) 6863*7dc08ffcSJunyu Laiassert(p.err == 0) 6864*7dc08ffcSJunyu Laiassert(p.more == 0) 6865*7dc08ffcSJunyu Laiassert(p.op_code == 2) 6866*7dc08ffcSJunyu Laiassert(p.sequence == 18) 6867*7dc08ffcSJunyu Laiassert(isinstance(p.status_word, NTPPeerStatusPacket)) 6868*7dc08ffcSJunyu Laiassert(p.association_id == 64655) 6869*7dc08ffcSJunyu Laiassert(p.offset == 468) 6870*7dc08ffcSJunyu Laiassert(p.count == 105) 6871*7dc08ffcSJunyu Laiassert(p.data.load == b'0.00 0.00 0.00 0.00,\r\nfiltdisp= 16000.00 16000.00 16000.00 16000.00 16000.00 16000.00 16000.00 16000.00\r\n\x00\x00\x00') 6872*7dc08ffcSJunyu Lai 6873*7dc08ffcSJunyu Lai 6874*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READVAR (4) - request 6875*7dc08ffcSJunyu Lais = b'\x16\x02\x00\x13\x00\x00s\xb5\x00\x00\x00\x0btest1,test2\x00\x00\x00\x00\x01=\xc2;\xc7\xed\xb9US9\xd6\x89\x08\xc8\xaf\xa6\x12' 6876*7dc08ffcSJunyu Laip = NTP(s) 6877*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6878*7dc08ffcSJunyu Laiassert(p.version == 2) 6879*7dc08ffcSJunyu Laiassert(p.mode == 6) 6880*7dc08ffcSJunyu Laiassert(p.response == 0) 6881*7dc08ffcSJunyu Laiassert(p.err == 0) 6882*7dc08ffcSJunyu Laiassert(p.more == 0) 6883*7dc08ffcSJunyu Laiassert(p.op_code == 2) 6884*7dc08ffcSJunyu Laiassert(len(p.data.load) == 12) 6885*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6886*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'3dc23bc7edb9555339d68908c8afa612') 6887*7dc08ffcSJunyu Lai 6888*7dc08ffcSJunyu Lai 6889*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READVAR (5) - response 6890*7dc08ffcSJunyu Lais = b'\xd6\xc2\x00\x13\x05\x00s\xb5\x00\x00\x00\x00\x00\x00\x00\x01\x97(\x02I\xdb\xa0s8\xedr(`\xdbJX\n' 6891*7dc08ffcSJunyu Laip = NTP(s) 6892*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6893*7dc08ffcSJunyu Laiassert(p.version == 2) 6894*7dc08ffcSJunyu Laiassert(p.mode == 6) 6895*7dc08ffcSJunyu Laiassert(p.response == 1) 6896*7dc08ffcSJunyu Laiassert(p.err == 1) 6897*7dc08ffcSJunyu Laiassert(p.more == 0) 6898*7dc08ffcSJunyu Laiassert(p.op_code == 2) 6899*7dc08ffcSJunyu Laiassert(len(p.data.load) == 0) 6900*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6901*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'97280249dba07338ed722860db4a580a') 6902*7dc08ffcSJunyu Lai 6903*7dc08ffcSJunyu Lai 6904*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_WRITEVAR (1) - request 6905*7dc08ffcSJunyu Lais = b'\x16\x03\x00\x11\x00\x00\x00\x00\x00\x00\x00\x0btest1,test2\x00\x00\x00\x00\x01\xaf\xf1\x0c\xb4\xc9\x94m\xfcM\x90\tJ\xa1p\x94J' 6906*7dc08ffcSJunyu Laip = NTP(s) 6907*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6908*7dc08ffcSJunyu Laiassert(p.version == 2) 6909*7dc08ffcSJunyu Laiassert(p.mode == 6) 6910*7dc08ffcSJunyu Laiassert(p.response == 0) 6911*7dc08ffcSJunyu Laiassert(p.err == 0) 6912*7dc08ffcSJunyu Laiassert(p.more == 0) 6913*7dc08ffcSJunyu Laiassert(p.op_code == 3) 6914*7dc08ffcSJunyu Laiassert(len(p.data.load) == 12) 6915*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6916*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'aff10cb4c9946dfc4d90094aa170944a') 6917*7dc08ffcSJunyu Lai 6918*7dc08ffcSJunyu Lai 6919*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_WRITEVAR (2) - response 6920*7dc08ffcSJunyu Lais = b'\xd6\xc3\x00\x11\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x80z\x80\xfb\xaf\xc4pg\x98S\xa8\xe5xe\x81\x1c' 6921*7dc08ffcSJunyu Laip = NTP(s) 6922*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6923*7dc08ffcSJunyu Laiassert(p.version == 2) 6924*7dc08ffcSJunyu Laiassert(p.mode == 6) 6925*7dc08ffcSJunyu Laiassert(p.response == 1) 6926*7dc08ffcSJunyu Laiassert(p.err == 1) 6927*7dc08ffcSJunyu Laiassert(p.more == 0) 6928*7dc08ffcSJunyu Laiassert(p.op_code == 3) 6929*7dc08ffcSJunyu Laiassert(hasattr(p, 'status_word')) 6930*7dc08ffcSJunyu Laiassert(isinstance(p.status_word, NTPErrorStatusPacket)) 6931*7dc08ffcSJunyu Laiassert(p.status_word.error_code == 5) 6932*7dc08ffcSJunyu Laiassert(len(p.data.load) == 0) 6933*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6934*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'807a80fbafc470679853a8e57865811c') 6935*7dc08ffcSJunyu Lai 6936*7dc08ffcSJunyu Lai 6937*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_CONFIGURE (1) - request 6938*7dc08ffcSJunyu Lais = b'\x16\x08\x00\x16\x00\x00\x00\x00\x00\x00\x00\x0ccontrolkey 1\x00\x00\x00\x01\xea\xa7\xac\xa8\x1bj\x9c\xdbX\xe1S\r6\xfb\xef\xa4' 6939*7dc08ffcSJunyu Laip = NTP(s) 6940*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6941*7dc08ffcSJunyu Laiassert(p.version == 2) 6942*7dc08ffcSJunyu Laiassert(p.mode == 6) 6943*7dc08ffcSJunyu Laiassert(p.response == 0) 6944*7dc08ffcSJunyu Laiassert(p.err == 0) 6945*7dc08ffcSJunyu Laiassert(p.more == 0) 6946*7dc08ffcSJunyu Laiassert(p.op_code == 8) 6947*7dc08ffcSJunyu Laiassert(p.count == 12) 6948*7dc08ffcSJunyu Laiassert(p.data.load == b'controlkey 1') 6949*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6950*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'eaa7aca81b6a9cdb58e1530d36fbefa4') 6951*7dc08ffcSJunyu Lai 6952*7dc08ffcSJunyu Lai 6953*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_CONFIGURE (2) - response 6954*7dc08ffcSJunyu Lais = b'\xd6\x88\x00\x16\x00\x00\x00\x00\x00\x00\x00\x12Config Succeeded\r\n\x00\x00\x00\x00\x00\x01\xbf\xa6\xd8_\xf9m\x1e2l)<\xac\xee\xc2\xa59' 6955*7dc08ffcSJunyu Laip = NTP(s) 6956*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6957*7dc08ffcSJunyu Laiassert(p.version == 2) 6958*7dc08ffcSJunyu Laiassert(p.mode == 6) 6959*7dc08ffcSJunyu Laiassert(p.response == 1) 6960*7dc08ffcSJunyu Laiassert(p.err == 0) 6961*7dc08ffcSJunyu Laiassert(p.more == 0) 6962*7dc08ffcSJunyu Laiassert(p.op_code == 8) 6963*7dc08ffcSJunyu Laiassert(p.count == 18) 6964*7dc08ffcSJunyu Laiassert(p.data.load == b'Config Succeeded\r\n\x00\x00') 6965*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6966*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'bfa6d85ff96d1e326c293caceec2a539') 6967*7dc08ffcSJunyu Lai 6968*7dc08ffcSJunyu Lai 6969*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_SAVECONFIG (1) - request 6970*7dc08ffcSJunyu Lais = b'\x16\t\x00\x1d\x00\x00\x00\x00\x00\x00\x00\x0fntp.test.2.conf\x00\x00\x00\x00\x00\x00\x00\x00\x01\xc9\xfb\x8a\xbe<`_\xfa6\xd2\x18\xc3\xb7d\x89#' 6971*7dc08ffcSJunyu Laip = NTP(s) 6972*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6973*7dc08ffcSJunyu Laiassert(p.version == 2) 6974*7dc08ffcSJunyu Laiassert(p.mode == 6) 6975*7dc08ffcSJunyu Laiassert(p.response == 0) 6976*7dc08ffcSJunyu Laiassert(p.err == 0) 6977*7dc08ffcSJunyu Laiassert(p.more == 0) 6978*7dc08ffcSJunyu Laiassert(p.op_code == 9) 6979*7dc08ffcSJunyu Laiassert(p.count == 15) 6980*7dc08ffcSJunyu Laiassert(p.data.load == b'ntp.test.2.conf\x00') 6981*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6982*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'c9fb8abe3c605ffa36d218c3b7648923') 6983*7dc08ffcSJunyu Lai 6984*7dc08ffcSJunyu Lai 6985*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_SAVECONFIG (2) - response 6986*7dc08ffcSJunyu Lais = b"\xd6\x89\x00\x1d\x00\x00\x00\x00\x00\x00\x00*Configuration saved to 'ntp.test.2.conf'\r\n\x00\x00\x00\x00\x00\x012\xc2\xbaY\xc53\xfe(\xf5P\xe5\xa0\x86\x02\x95\xd9" 6987*7dc08ffcSJunyu Laip = NTP(s) 6988*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 6989*7dc08ffcSJunyu Laiassert(p.version == 2) 6990*7dc08ffcSJunyu Laiassert(p.mode == 6) 6991*7dc08ffcSJunyu Laiassert(p.response == 1) 6992*7dc08ffcSJunyu Laiassert(p.err == 0) 6993*7dc08ffcSJunyu Laiassert(p.more == 0) 6994*7dc08ffcSJunyu Laiassert(p.op_code == 9) 6995*7dc08ffcSJunyu Laiassert(p.count == 42) 6996*7dc08ffcSJunyu Laiassert(p.data.load == b"Configuration saved to 'ntp.test.2.conf'\r\n\x00\x00") 6997*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 6998*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'32c2ba59c533fe28f550e5a0860295d9') 6999*7dc08ffcSJunyu Lai 7000*7dc08ffcSJunyu Lai 7001*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_REQ_NONCE (1) - request 7002*7dc08ffcSJunyu Lais = b'\x16\x0c\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00' 7003*7dc08ffcSJunyu Laip = NTP(s) 7004*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 7005*7dc08ffcSJunyu Laiassert(p.version == 2) 7006*7dc08ffcSJunyu Laiassert(p.mode == 6) 7007*7dc08ffcSJunyu Laiassert(p.response == 0) 7008*7dc08ffcSJunyu Laiassert(p.err == 0) 7009*7dc08ffcSJunyu Laiassert(p.more == 0) 7010*7dc08ffcSJunyu Laiassert(p.op_code == 12) 7011*7dc08ffcSJunyu Laiassert(p.data == b'') 7012*7dc08ffcSJunyu Laiassert(p.authenticator == b'') 7013*7dc08ffcSJunyu Lai 7014*7dc08ffcSJunyu Lai 7015*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_REQ_NONCE (2) - response 7016*7dc08ffcSJunyu Lais = b'\xd6\x8c\x00\x07\x00\x00\x00\x00\x00\x00\x00 nonce=db4186a2e1d9022472e24bc9\r\n' 7017*7dc08ffcSJunyu Laip = NTP(s) 7018*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 7019*7dc08ffcSJunyu Laiassert(p.version == 2) 7020*7dc08ffcSJunyu Laiassert(p.mode == 6) 7021*7dc08ffcSJunyu Laiassert(p.response == 1) 7022*7dc08ffcSJunyu Laiassert(p.err == 0) 7023*7dc08ffcSJunyu Laiassert(p.more == 0) 7024*7dc08ffcSJunyu Laiassert(p.op_code == 12) 7025*7dc08ffcSJunyu Laiassert(p.data.load == b'nonce=db4186a2e1d9022472e24bc9\r\n') 7026*7dc08ffcSJunyu Laiassert(p.authenticator == b'') 7027*7dc08ffcSJunyu Lai 7028*7dc08ffcSJunyu Lai 7029*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READ_MRU (1) - request 7030*7dc08ffcSJunyu Lais = b'\x16\n\x00\x08\x00\x00\x00\x00\x00\x00\x00(nonce=db4186a2e1d9022472e24bc9, frags=32' 7031*7dc08ffcSJunyu Laip = NTP(s) 7032*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 7033*7dc08ffcSJunyu Laiassert(p.version == 2) 7034*7dc08ffcSJunyu Laiassert(p.mode == 6) 7035*7dc08ffcSJunyu Laiassert(p.response == 0) 7036*7dc08ffcSJunyu Laiassert(p.err == 0) 7037*7dc08ffcSJunyu Laiassert(p.op_code == 10) 7038*7dc08ffcSJunyu Laiassert(p.count == 40) 7039*7dc08ffcSJunyu Laiassert(p.data.load == b'nonce=db4186a2e1d9022472e24bc9, frags=32') 7040*7dc08ffcSJunyu Laiassert(p.authenticator == b'') 7041*7dc08ffcSJunyu Lai 7042*7dc08ffcSJunyu Lai= NTP Control (mode 6) - CTL_OP_READ_MRU (2) - response 7043*7dc08ffcSJunyu Lais = b'\xd6\x8a\x00\x08\x00\x00\x00\x00\x00\x00\x00\xe9nonce=db4186a2e2073198b93c6419, addr.0=192.168.122.100:123,\r\nfirst.0=0xdb418673.323e1a89, last.0=0xdb418673.323e1a89, ct.0=1,\r\nmv.0=36, rs.0=0x0, WWQ.0=18446744073709509383, now=0xdb4186a2.e20ff8f4,\r\nlast.newest=0xdb418673.323e1a89\r\n\x00\x00\x00' 7044*7dc08ffcSJunyu Laip = NTP(s) 7045*7dc08ffcSJunyu Laiassert(isinstance(p, NTPControl)) 7046*7dc08ffcSJunyu Laiassert(p.version == 2) 7047*7dc08ffcSJunyu Laiassert(p.mode == 6) 7048*7dc08ffcSJunyu Laiassert(p.response == 1) 7049*7dc08ffcSJunyu Laiassert(p.err == 0) 7050*7dc08ffcSJunyu Laiassert(p.op_code == 10) 7051*7dc08ffcSJunyu Laiassert(p.count == 233) 7052*7dc08ffcSJunyu Laiassert(p.data.load == b'nonce=db4186a2e2073198b93c6419, addr.0=192.168.122.100:123,\r\nfirst.0=0xdb418673.323e1a89, last.0=0xdb418673.323e1a89, ct.0=1,\r\nmv.0=36, rs.0=0x0, WWQ.0=18446744073709509383, now=0xdb4186a2.e20ff8f4,\r\nlast.newest=0xdb418673.323e1a89\r\n\x00\x00\x00') 7053*7dc08ffcSJunyu Laiassert(p.authenticator == b'') 7054*7dc08ffcSJunyu Lai 7055*7dc08ffcSJunyu Lai 7056*7dc08ffcSJunyu Lai############ 7057*7dc08ffcSJunyu Lai############ 7058*7dc08ffcSJunyu Lai+ NTP Private (mode 7) tests 7059*7dc08ffcSJunyu Lai 7060*7dc08ffcSJunyu Lai= NTP Private (mode 7) - error - Dissection 7061*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x1d@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7062*7dc08ffcSJunyu Laip = NTP(s) 7063*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7064*7dc08ffcSJunyu Laiassert(p.response == 1) 7065*7dc08ffcSJunyu Laiassert(p.version == 2) 7066*7dc08ffcSJunyu Laiassert(p.mode == 7) 7067*7dc08ffcSJunyu Laiassert(p.request_code == 29) 7068*7dc08ffcSJunyu Laiassert(p.err == 4) 7069*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7070*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7071*7dc08ffcSJunyu Lai 7072*7dc08ffcSJunyu Lai 7073*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_LIST (1) - request 7074*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7075*7dc08ffcSJunyu Laip = NTP(s) 7076*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7077*7dc08ffcSJunyu Laiassert(p.response == 0) 7078*7dc08ffcSJunyu Laiassert(p.version == 2) 7079*7dc08ffcSJunyu Laiassert(p.mode == 7) 7080*7dc08ffcSJunyu Laiassert(p.request_code == 0) 7081*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7082*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7083*7dc08ffcSJunyu Lai 7084*7dc08ffcSJunyu Lai 7085*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_LIST (2) - response 7086*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x00\x00\x01\x00 \x7f\x7f\x01\x00\x00{\x03\x83\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7087*7dc08ffcSJunyu Laip = NTP(s) 7088*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7089*7dc08ffcSJunyu Laiassert(p.response == 1) 7090*7dc08ffcSJunyu Laiassert(p.version == 2) 7091*7dc08ffcSJunyu Laiassert(p.mode == 7) 7092*7dc08ffcSJunyu Laiassert(p.request_code == 0) 7093*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7094*7dc08ffcSJunyu Laiassert(p.data_item_size == 32) 7095*7dc08ffcSJunyu Laiassert(type(p.data[0]) == NTPInfoPeerList) 7096*7dc08ffcSJunyu Laiassert(p.data[0].addr) == "127.127.1.0" 7097*7dc08ffcSJunyu Laiassert(p.data[0].port) == 123 7098*7dc08ffcSJunyu Lai 7099*7dc08ffcSJunyu Lai 7100*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_INFO (1) - request 7101*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x02\x00\x01\x00 \xc0\xa8zf\x00{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7102*7dc08ffcSJunyu Laip = NTP(s) 7103*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7104*7dc08ffcSJunyu Laiassert(p.response == 0) 7105*7dc08ffcSJunyu Laiassert(p.version == 2) 7106*7dc08ffcSJunyu Laiassert(p.mode == 7) 7107*7dc08ffcSJunyu Laiassert(p.request_code == 2) 7108*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7109*7dc08ffcSJunyu Laiassert(p.data_item_size == 32) 7110*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPInfoPeerList)) 7111*7dc08ffcSJunyu Laiassert(p.req_data[0].addr == "192.168.122.102") 7112*7dc08ffcSJunyu Laiassert(p.req_data[0].port == 123) 7113*7dc08ffcSJunyu Lai 7114*7dc08ffcSJunyu Lai 7115*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_INFO (2) - response 7116*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x02\x00\x01\x01\x18\xc0\xa8zf\xc0\xa8ze\x00{\x01\x03\x01\x00\x10\x06\n\xea\x04\x00\x00\xaf"\x00"\x16\x04\xb3\x01\x00\x00\x00\x00\x00\x00\x00INIT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x82\x9d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb<\x8d\xc5\xde\x7fB\x89\xdb<\x8d\xc5\xde\x7fB\x89\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7117*7dc08ffcSJunyu Laip = NTP(s) 7118*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7119*7dc08ffcSJunyu Laiassert(p.response == 1) 7120*7dc08ffcSJunyu Laiassert(p.version == 2) 7121*7dc08ffcSJunyu Laiassert(p.mode == 7) 7122*7dc08ffcSJunyu Laiassert(p.request_code == 2) 7123*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoPeer)) 7124*7dc08ffcSJunyu Laiassert(p.data[0].dstaddr == "192.168.122.102") 7125*7dc08ffcSJunyu Laiassert(p.data[0].srcaddr == "192.168.122.101") 7126*7dc08ffcSJunyu Laiassert(p.data[0].srcport == 123) 7127*7dc08ffcSJunyu Laiassert(p.data[0].associd == 1203) 7128*7dc08ffcSJunyu Laiassert(p.data[0].keyid == 1) 7129*7dc08ffcSJunyu Lai 7130*7dc08ffcSJunyu Lai 7131*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_LIST_SUM (1) - request 7132*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7133*7dc08ffcSJunyu Laip = NTP(s) 7134*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7135*7dc08ffcSJunyu Laiassert(p.response == 0) 7136*7dc08ffcSJunyu Laiassert(p.version == 2) 7137*7dc08ffcSJunyu Laiassert(p.mode == 7) 7138*7dc08ffcSJunyu Laiassert(p.request_code == 1) 7139*7dc08ffcSJunyu Lai 7140*7dc08ffcSJunyu Lai 7141*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_LIST_SUM (2) - response (1st packet) 7142*7dc08ffcSJunyu Lais = b'\xd7\x00\x03\x01\x00\x06\x00H\n\x00\x02\x0f\xc0\x00\x02\x01\x00{\x10\x06\n\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x02\x0f\xc0\x00\x02\x02\x00{\x10\x06\n\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x01\x02\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x02\x0f\xc0\xa8d\x01\x00{\x10\x07\n\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01eth0\xc0\xa8zg\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x02\x0f\xc0\xa8d\x02\x00{\x10\x07\n\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x02\xc0\xa8zh\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\n\x00\x02\x0f\xc0\xa8d\r\x00{\x10\x07\n\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8zk\x00{\x01\x01\xc0\xa8ze\xc0\xa8zf\x00{\x0b\x06\x07\xf4\x83\x01\x00\x00\x07\x89\x00\x00\x00\x007\xb1\x00h\x00\x00o?\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8zm\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00' 7143*7dc08ffcSJunyu Laip = NTP(s) 7144*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7145*7dc08ffcSJunyu Laiassert(p.response == 1) 7146*7dc08ffcSJunyu Laiassert(p.more == 1) 7147*7dc08ffcSJunyu Laiassert(p.version == 2) 7148*7dc08ffcSJunyu Laiassert(p.mode == 7) 7149*7dc08ffcSJunyu Laiassert(p.request_code == 1) 7150*7dc08ffcSJunyu Laiassert(isinstance(x, NTPInfoPeerSummary) for x in p.data) 7151*7dc08ffcSJunyu Laiassert(p.data[0].srcaddr == "192.0.2.1") 7152*7dc08ffcSJunyu Lai 7153*7dc08ffcSJunyu Lai 7154*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_LIST_SUM (3) - response (2nd packet) 7155*7dc08ffcSJunyu Lais = b'\xd7\x01\x03\x01\x00\x06\x00H\xc0\xa8ze\xc0\xa8zg\x00{\x10\x08\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01eth1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8ze\xc0\xa8zg\x00{\x10\x08\n\x00\x11\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x01\x02\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8ze\xc0\xa8zh\x00{\x10\x08\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01eth0\xc0\xa8zg\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8ze\xc0\xa8zi\x00{\x10\x07\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x02\xc0\xa8zh\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xc0\xa8ze\xc0\xa8zj\x00{\x10\x07\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8zk\x00{\x01\x01\xc0\xa8ze\xc0\xa8zk\x00{\x10\x07\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8zm\x00{\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00' 7156*7dc08ffcSJunyu Laip = NTP(s) 7157*7dc08ffcSJunyu Lai 7158*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7159*7dc08ffcSJunyu Laiassert(p.response == 1) 7160*7dc08ffcSJunyu Laiassert(p.more == 1) 7161*7dc08ffcSJunyu Laiassert(p.version == 2) 7162*7dc08ffcSJunyu Laiassert(p.mode == 7) 7163*7dc08ffcSJunyu Laiassert(p.request_code == 1) 7164*7dc08ffcSJunyu Laiassert(isinstance(x, NTPInfoPeerSummary) for x in p.data) 7165*7dc08ffcSJunyu Laiassert(p.data[0].srcaddr == "192.168.122.103") 7166*7dc08ffcSJunyu Lai 7167*7dc08ffcSJunyu Lai 7168*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_LIST_SUM (3) - response (3rd packet) 7169*7dc08ffcSJunyu Lais = b'\x97\x02\x03\x01\x00\x02\x00H\xc0\xa8ze\xc0\xa8zl\x00{\x10\x07\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01eth1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8ze\xc0\xa8zm\x00{\x10\x07\n\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xfd\xff\x00\x00\x00\x00\x00\x00\x01\x02\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7170*7dc08ffcSJunyu Laip = NTP(s) 7171*7dc08ffcSJunyu Lai 7172*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7173*7dc08ffcSJunyu Laiassert(p.response == 1) 7174*7dc08ffcSJunyu Laiassert(p.more == 0) 7175*7dc08ffcSJunyu Laiassert(p.version == 2) 7176*7dc08ffcSJunyu Laiassert(p.mode == 7) 7177*7dc08ffcSJunyu Laiassert(p.request_code == 1) 7178*7dc08ffcSJunyu Laiassert(isinstance(x, NTPInfoPeerSummary) for x in p.data) 7179*7dc08ffcSJunyu Laiassert(p.data[0].srcaddr == "192.168.122.108") 7180*7dc08ffcSJunyu Lai 7181*7dc08ffcSJunyu Lai 7182*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_STATS (1) - request 7183*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x03\x00\x01\x00 \xc0\xa8ze\x00{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7184*7dc08ffcSJunyu Laip = NTP(s) 7185*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7186*7dc08ffcSJunyu Laiassert(p.response == 0) 7187*7dc08ffcSJunyu Laiassert(p.more == 0) 7188*7dc08ffcSJunyu Laiassert(p.version == 2) 7189*7dc08ffcSJunyu Laiassert(p.mode == 7) 7190*7dc08ffcSJunyu Laiassert(p.request_code == 3) 7191*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPInfoPeerList)) 7192*7dc08ffcSJunyu Lai 7193*7dc08ffcSJunyu Lai 7194*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_PEER_STATS (2) - response 7195*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x03\x00\x01\x00x\xc0\xa8zf\xc0\xa8ze\x00{\x00\x01\x01\x00\x10\x06\x00\x00\x00)\x00\x00\x00\x1e\x00\x02\xda|\x00\x00\x00\xbc\x00\x00\x00\x00\x00\x00\x0b\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\nJ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\x07\x00\x00\x00\x00\xde\x7fB\x89\x00<\x8d\xc5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7196*7dc08ffcSJunyu Laip = NTP(s) 7197*7dc08ffcSJunyu Lai 7198*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7199*7dc08ffcSJunyu Laiassert(p.response == 1) 7200*7dc08ffcSJunyu Laiassert(p.more == 0) 7201*7dc08ffcSJunyu Laiassert(p.version == 2) 7202*7dc08ffcSJunyu Laiassert(p.mode == 7) 7203*7dc08ffcSJunyu Laiassert(p.request_code == 3) 7204*7dc08ffcSJunyu Laiassert(isinstance(x, NTPInfoPeerStats) for x in p.data) 7205*7dc08ffcSJunyu Lai 7206*7dc08ffcSJunyu Lai 7207*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_SYS_INFO (1) - request 7208*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7209*7dc08ffcSJunyu Laip = NTP(s) 7210*7dc08ffcSJunyu Lai 7211*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7212*7dc08ffcSJunyu Laiassert(p.response == 0) 7213*7dc08ffcSJunyu Laiassert(p.more == 0) 7214*7dc08ffcSJunyu Laiassert(p.version == 2) 7215*7dc08ffcSJunyu Laiassert(p.mode == 7) 7216*7dc08ffcSJunyu Laiassert(p.request_code == 4) 7217*7dc08ffcSJunyu Lai 7218*7dc08ffcSJunyu Lai 7219*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_SYS_INFO (2) - response 7220*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x04\x00\x01\x00P\x7f\x7f\x01\x00\x03\x00\x0b\xf0\x00\x00\x00\x00\x00\x00\x03\x06\x7f\x7f\x01\x00\xdb<\xca\xf3\xa1\x92\xe1\xf7\x06\x00\x00\x00\xce\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\x07\x00\x00\x00\x00\xde\x7fB\x89\x00<\x8d\xc5' 7221*7dc08ffcSJunyu Laip = NTP(s) 7222*7dc08ffcSJunyu Lai 7223*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7224*7dc08ffcSJunyu Laiassert(p.response == 1) 7225*7dc08ffcSJunyu Laiassert(p.more == 0) 7226*7dc08ffcSJunyu Laiassert(p.version == 2) 7227*7dc08ffcSJunyu Laiassert(p.mode == 7) 7228*7dc08ffcSJunyu Laiassert(p.request_code == 4) 7229*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoSys)) 7230*7dc08ffcSJunyu Laiassert(p.data[0].peer == "127.127.1.0") 7231*7dc08ffcSJunyu Laiassert(p.data[0].peer_mode == 3) 7232*7dc08ffcSJunyu Laiassert(p.data[0].leap == 0) 7233*7dc08ffcSJunyu Laiassert(p.data[0].stratum == 11) 7234*7dc08ffcSJunyu Laiassert(p.data[0].precision == 240) 7235*7dc08ffcSJunyu Laiassert(p.data[0].refid == "127.127.1.0") 7236*7dc08ffcSJunyu Lai 7237*7dc08ffcSJunyu Lai 7238*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_SYS_STATS (1) - request 7239*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7240*7dc08ffcSJunyu Laip = NTP(s) 7241*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7242*7dc08ffcSJunyu Laiassert(p.response == 0) 7243*7dc08ffcSJunyu Laiassert(p.more == 0) 7244*7dc08ffcSJunyu Laiassert(p.version == 2) 7245*7dc08ffcSJunyu Laiassert(p.mode == 7) 7246*7dc08ffcSJunyu Laiassert(p.request_code == 5) 7247*7dc08ffcSJunyu Lai 7248*7dc08ffcSJunyu Lai 7249*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_SYS_STATS (2) - response 7250*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x05\x00\x01\x00,\x00\x02\xe2;\x00\x02\xe2;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b%\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b%\x00\x00\x00\x00\x00\x00\x0b=\x00\x00\x00\x00' 7251*7dc08ffcSJunyu Laip = NTP(s) 7252*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7253*7dc08ffcSJunyu Laiassert(p.response == 1) 7254*7dc08ffcSJunyu Laiassert(p.more == 0) 7255*7dc08ffcSJunyu Laiassert(p.version == 2) 7256*7dc08ffcSJunyu Laiassert(p.mode == 7) 7257*7dc08ffcSJunyu Laiassert(p.request_code == 5) 7258*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoSysStats)) 7259*7dc08ffcSJunyu Laiassert(p.data[0].timeup == 188987) 7260*7dc08ffcSJunyu Laiassert(p.data[0].received == 2877) 7261*7dc08ffcSJunyu Lai 7262*7dc08ffcSJunyu Lai 7263*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IO_STATS (1) - request 7264*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7265*7dc08ffcSJunyu Laip = NTP(s) 7266*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7267*7dc08ffcSJunyu Laiassert(p.response == 0) 7268*7dc08ffcSJunyu Laiassert(p.more == 0) 7269*7dc08ffcSJunyu Laiassert(p.version == 2) 7270*7dc08ffcSJunyu Laiassert(p.mode == 7) 7271*7dc08ffcSJunyu Laiassert(p.request_code == 6) 7272*7dc08ffcSJunyu Lai 7273*7dc08ffcSJunyu Lai 7274*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IO_STATS (2) - response 7275*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x06\x00\x01\x00(\x00\x00\x03\x04\x00\n\x00\t\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00J\x00\x00\x00\xd9\x00\x00\x00\x00\x00\x00\x00J\x00\x00\x00J' 7276*7dc08ffcSJunyu Laip = NTP(s) 7277*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7278*7dc08ffcSJunyu Laiassert(p.response == 1) 7279*7dc08ffcSJunyu Laiassert(p.more == 0) 7280*7dc08ffcSJunyu Laiassert(p.version == 2) 7281*7dc08ffcSJunyu Laiassert(p.mode == 7) 7282*7dc08ffcSJunyu Laiassert(p.request_code == 6) 7283*7dc08ffcSJunyu Laiassert(p.data[0].timereset == 772) 7284*7dc08ffcSJunyu Laiassert(p.data[0].sent == 217) 7285*7dc08ffcSJunyu Lai 7286*7dc08ffcSJunyu Lai 7287*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_MEM_STATS (1) - request 7288*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7289*7dc08ffcSJunyu Laip = NTP(s) 7290*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7291*7dc08ffcSJunyu Laiassert(p.response == 0) 7292*7dc08ffcSJunyu Laiassert(p.more == 0) 7293*7dc08ffcSJunyu Laiassert(p.version == 2) 7294*7dc08ffcSJunyu Laiassert(p.mode == 7) 7295*7dc08ffcSJunyu Laiassert(p.request_code == 7) 7296*7dc08ffcSJunyu Lai 7297*7dc08ffcSJunyu Lai 7298*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_MEM_STATS (2) - response 7299*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x07\x00\x01\x00\x94\x00\x00\n\xee\x00\x0f\x00\r\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7300*7dc08ffcSJunyu Laip = NTP(s) 7301*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7302*7dc08ffcSJunyu Laiassert(p.response == 1) 7303*7dc08ffcSJunyu Laiassert(p.more == 0) 7304*7dc08ffcSJunyu Laiassert(p.version == 2) 7305*7dc08ffcSJunyu Laiassert(p.mode == 7) 7306*7dc08ffcSJunyu Laiassert(p.request_code == 7) 7307*7dc08ffcSJunyu Laiassert(p.data[0].timereset == 2798) 7308*7dc08ffcSJunyu Laiassert(p.data[0].totalpeermem == 15) 7309*7dc08ffcSJunyu Laiassert(p.data[0].freepeermem == 13) 7310*7dc08ffcSJunyu Laiassert(p.data[0].findpeer_calls == 60) 7311*7dc08ffcSJunyu Laiassert(p.data[0].hashcount[25] == 1 and p.data[0].hashcount[89] == 1) 7312*7dc08ffcSJunyu Lai 7313*7dc08ffcSJunyu Lai 7314*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_LOOP_INFO (1) - request 7315*7dc08ffcSJunyu Lais = b'\x17\x00\x03\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7316*7dc08ffcSJunyu Laip = NTP(s) 7317*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7318*7dc08ffcSJunyu Laiassert(p.response == 0) 7319*7dc08ffcSJunyu Laiassert(p.more == 0) 7320*7dc08ffcSJunyu Laiassert(p.version == 2) 7321*7dc08ffcSJunyu Laiassert(p.mode == 7) 7322*7dc08ffcSJunyu Laiassert(p.request_code == 8) 7323*7dc08ffcSJunyu Lai 7324*7dc08ffcSJunyu Lai 7325*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_LOOP_INFO (2) - response 7326*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x08\x00\x01\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x04' 7327*7dc08ffcSJunyu Laip = NTP(s) 7328*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7329*7dc08ffcSJunyu Laiassert(p.response == 1) 7330*7dc08ffcSJunyu Laiassert(p.more == 0) 7331*7dc08ffcSJunyu Laiassert(p.version == 2) 7332*7dc08ffcSJunyu Laiassert(p.mode == 7) 7333*7dc08ffcSJunyu Laiassert(p.request_code == 8) 7334*7dc08ffcSJunyu Laiassert(p.data[0].last_offset == 0.0) 7335*7dc08ffcSJunyu Laiassert(p.data[0].watchdog_timer == 4) 7336*7dc08ffcSJunyu Lai 7337*7dc08ffcSJunyu Lai 7338*7dc08ffcSJunyu Lai 7339*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_TIMER_STATS (1) - request 7340*7dc08ffcSJunyu Lais = b'\x17\x00\x03\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7341*7dc08ffcSJunyu Laip = NTP(s) 7342*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7343*7dc08ffcSJunyu Laiassert(p.response == 0) 7344*7dc08ffcSJunyu Laiassert(p.more == 0) 7345*7dc08ffcSJunyu Laiassert(p.version == 2) 7346*7dc08ffcSJunyu Laiassert(p.mode == 7) 7347*7dc08ffcSJunyu Laiassert(p.request_code == 9) 7348*7dc08ffcSJunyu Lai 7349*7dc08ffcSJunyu Lai 7350*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_TIMER_STATS (2) - response 7351*7dc08ffcSJunyu Lais = b'\x97\x00\x03\t\x00\x01\x00\x10\x00\x00\x01h\x00\x00\x01h\x00\x00\x00\x00\x00\x00\x00\x00' 7352*7dc08ffcSJunyu Laip = NTP(s) 7353*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7354*7dc08ffcSJunyu Laiassert(p.response == 1) 7355*7dc08ffcSJunyu Laiassert(p.more == 0) 7356*7dc08ffcSJunyu Laiassert(p.version == 2) 7357*7dc08ffcSJunyu Laiassert(p.mode == 7) 7358*7dc08ffcSJunyu Laiassert(p.request_code == 9) 7359*7dc08ffcSJunyu Laiassert(p.data[0].timereset == 360) 7360*7dc08ffcSJunyu Laiassert(p.data[0].alarms == 360) 7361*7dc08ffcSJunyu Lai 7362*7dc08ffcSJunyu Lai 7363*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_CONFIG (1) - request 7364*7dc08ffcSJunyu Lais = b'\x17\x80\x03\n\x00\x01\x00\xa8\xc0\xa8zm\x01\x03\x06\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xec\x93\xb1\xa8\xa0a\x00\x00\x00\x01Z\xba\xfe\x01\x1cr\x05d\xa1\x14\xb1)\xe9vD\x8d' 7365*7dc08ffcSJunyu Laip = NTP(s) 7366*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7367*7dc08ffcSJunyu Laiassert(p.response == 0) 7368*7dc08ffcSJunyu Laiassert(p.more == 0) 7369*7dc08ffcSJunyu Laiassert(p.version == 2) 7370*7dc08ffcSJunyu Laiassert(p.mode == 7) 7371*7dc08ffcSJunyu Laiassert(p.request_code == 10) 7372*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7373*7dc08ffcSJunyu Laiassert(p.data_item_size == 168) 7374*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7375*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfPeer)) 7376*7dc08ffcSJunyu Laiassert(p.req_data[0].peeraddr == "192.168.122.109") 7377*7dc08ffcSJunyu Laiassert(p.req_data[0].hmode == 1) 7378*7dc08ffcSJunyu Laiassert(p.req_data[0].version == 3) 7379*7dc08ffcSJunyu Laiassert(p.req_data[0].minpoll == 6) 7380*7dc08ffcSJunyu Laiassert(p.req_data[0].maxpoll == 10) 7381*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7382*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7383*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'5abafe011c720564a114b129e976448d') 7384*7dc08ffcSJunyu Lai 7385*7dc08ffcSJunyu Lai 7386*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_CONFIG (2) - response 7387*7dc08ffcSJunyu Lais = b'\x97\x00\x03\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7388*7dc08ffcSJunyu Laip = NTP(s) 7389*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7390*7dc08ffcSJunyu Laiassert(p.response == 1) 7391*7dc08ffcSJunyu Laiassert(p.more == 0) 7392*7dc08ffcSJunyu Laiassert(p.version == 2) 7393*7dc08ffcSJunyu Laiassert(p.mode == 7) 7394*7dc08ffcSJunyu Laiassert(p.auth == 0) 7395*7dc08ffcSJunyu Laiassert(p.request_code == 10) 7396*7dc08ffcSJunyu Laiassert(p.err == 0) 7397*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7398*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7399*7dc08ffcSJunyu Lai 7400*7dc08ffcSJunyu Lai 7401*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_UNCONFIG (1) - request 7402*7dc08ffcSJunyu Lais = b'\x17\x80\x03\x0b\x00\x01\x00\x18\xc0\xa8zk\x00\x00\x00\x00X\x88P\xb1\xff\x7f\x00\x008\x88P\xb1\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xf0\x1bq\xc8\xe5\xa6\x00\x00\x00\x01\x1dM;\xfeZ~]Z\xe3Ea\x92\x9aE\xd8%' 7403*7dc08ffcSJunyu Laip = NTP(s) 7404*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7405*7dc08ffcSJunyu Laiassert(p.response == 0) 7406*7dc08ffcSJunyu Laiassert(p.more == 0) 7407*7dc08ffcSJunyu Laiassert(p.version == 2) 7408*7dc08ffcSJunyu Laiassert(p.mode == 7) 7409*7dc08ffcSJunyu Laiassert(p.request_code == 11) 7410*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7411*7dc08ffcSJunyu Laiassert(p.data_item_size == 24) 7412*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7413*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfUnpeer)) 7414*7dc08ffcSJunyu Laiassert(p.req_data[0].peeraddr == "192.168.122.107") 7415*7dc08ffcSJunyu Laiassert(p.req_data[0].v6_flag == 0) 7416*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7417*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7418*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'1d4d3bfe5a7e5d5ae34561929a45d825') 7419*7dc08ffcSJunyu Lai 7420*7dc08ffcSJunyu Lai 7421*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_UNCONFIG (2) - response 7422*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7423*7dc08ffcSJunyu Laip = NTP(s) 7424*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7425*7dc08ffcSJunyu Laiassert(p.response == 1) 7426*7dc08ffcSJunyu Laiassert(p.more == 0) 7427*7dc08ffcSJunyu Laiassert(p.version == 2) 7428*7dc08ffcSJunyu Laiassert(p.mode == 7) 7429*7dc08ffcSJunyu Laiassert(p.auth == 0) 7430*7dc08ffcSJunyu Laiassert(p.request_code == 11) 7431*7dc08ffcSJunyu Laiassert(p.err == 0) 7432*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7433*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7434*7dc08ffcSJunyu Lai 7435*7dc08ffcSJunyu Lai 7436*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_RESADDFLAGS (1) - request 7437*7dc08ffcSJunyu Lais = b'\x17\x80\x03\x11\x00\x01\x000\xc0\xa8zi\xff\xff\xff\xff\x04\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xf0V\xa9"\xe6_\x00\x00\x00\x01>=\xb70Tp\xee\xae\xe1\xad4b\xef\xe3\x80\xc8' 7438*7dc08ffcSJunyu Laip = NTP(s) 7439*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7440*7dc08ffcSJunyu Laiassert(p.response == 0) 7441*7dc08ffcSJunyu Laiassert(p.more == 0) 7442*7dc08ffcSJunyu Laiassert(p.version == 2) 7443*7dc08ffcSJunyu Laiassert(p.mode == 7) 7444*7dc08ffcSJunyu Laiassert(p.request_code == 17) 7445*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7446*7dc08ffcSJunyu Laiassert(p.data_item_size == 48) 7447*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7448*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfRestrict)) 7449*7dc08ffcSJunyu Laiassert(p.req_data[0].addr == "192.168.122.105") 7450*7dc08ffcSJunyu Laiassert(p.req_data[0].mask == "255.255.255.255") 7451*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7452*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7453*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'3e3db7305470eeaee1ad3462efe380c8') 7454*7dc08ffcSJunyu Lai 7455*7dc08ffcSJunyu Lai 7456*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_RESSUBFLAGS (1) - request 7457*7dc08ffcSJunyu Lais = b'\x17\x80\x03\x12\x00\x01\x000\xc0\xa8zi\xff\xff\xff\xff\x00\x10\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xf0F\xe0C\xa9@\x00\x00\x00\x01>e\r\xdf\xdb\x1e1h\xd0\xca)L\x07k\x90\n' 7458*7dc08ffcSJunyu Laip = NTP(s) 7459*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7460*7dc08ffcSJunyu Laiassert(p.response == 0) 7461*7dc08ffcSJunyu Laiassert(p.more == 0) 7462*7dc08ffcSJunyu Laiassert(p.version == 2) 7463*7dc08ffcSJunyu Laiassert(p.mode == 7) 7464*7dc08ffcSJunyu Laiassert(p.request_code == 18) 7465*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7466*7dc08ffcSJunyu Laiassert(p.data_item_size == 48) 7467*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7468*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfRestrict)) 7469*7dc08ffcSJunyu Laiassert(p.req_data[0].addr == "192.168.122.105") 7470*7dc08ffcSJunyu Laiassert(p.req_data[0].mask == "255.255.255.255") 7471*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7472*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7473*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'3e650ddfdb1e3168d0ca294c076b900a') 7474*7dc08ffcSJunyu Lai 7475*7dc08ffcSJunyu Lai 7476*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_RESET_PEER (1) - request 7477*7dc08ffcSJunyu Lais = b"\x17\x80\x03\x16\x00\x01\x00\x18\xc0\xa8zf\x00\x00\x00\x00X\x88P\xb1\xff\x7f\x00\x008\x88P\xb1\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xef!\x99\x88\xa3\xf1\x00\x00\x00\x01\xb1\xff\xe8\xefB=\xa9\x96\xdc\xe3\x13'\xb3\xfc\xc2\xf5" 7478*7dc08ffcSJunyu Laip = NTP(s) 7479*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7480*7dc08ffcSJunyu Laiassert(p.response == 0) 7481*7dc08ffcSJunyu Laiassert(p.more == 0) 7482*7dc08ffcSJunyu Laiassert(p.version == 2) 7483*7dc08ffcSJunyu Laiassert(p.mode == 7) 7484*7dc08ffcSJunyu Laiassert(p.request_code == 22) 7485*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7486*7dc08ffcSJunyu Laiassert(p.data_item_size == 24) 7487*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7488*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfUnpeer)) 7489*7dc08ffcSJunyu Laiassert(p.req_data[0].peeraddr == "192.168.122.102") 7490*7dc08ffcSJunyu Laiassert(p.req_data[0].v6_flag == 0) 7491*7dc08ffcSJunyu Lai 7492*7dc08ffcSJunyu Lai 7493*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_AUTHINFO (1) - response 7494*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x1c\x00\x01\x00$\x00\x00\x01\xdd\x00\x00\x00\x02\x00\x00\x00\n\x00\x00\x00`\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00/\x00\x00\x00\x00\x00\x00\x00\x01' 7495*7dc08ffcSJunyu Laip = NTP(s) 7496*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7497*7dc08ffcSJunyu Laiassert(p.response == 1) 7498*7dc08ffcSJunyu Laiassert(p.more == 0) 7499*7dc08ffcSJunyu Laiassert(p.version == 2) 7500*7dc08ffcSJunyu Laiassert(p.mode == 7) 7501*7dc08ffcSJunyu Laiassert(p.auth == 0) 7502*7dc08ffcSJunyu Laiassert(p.request_code == 28) 7503*7dc08ffcSJunyu Laiassert(p.err == 0) 7504*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7505*7dc08ffcSJunyu Laiassert(p.data_item_size == 36) 7506*7dc08ffcSJunyu Laiassert(hasattr(p, 'data')) 7507*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoAuth)) 7508*7dc08ffcSJunyu Laiassert(p.data[0].timereset == 477) 7509*7dc08ffcSJunyu Laiassert(p.data[0].numkeys == 2) 7510*7dc08ffcSJunyu Laiassert(p.data[0].numfreekeys == 10) 7511*7dc08ffcSJunyu Laiassert(p.data[0].keylookups == 96) 7512*7dc08ffcSJunyu Laiassert(p.data[0].keynotfound == 0) 7513*7dc08ffcSJunyu Laiassert(p.data[0].encryptions == 9) 7514*7dc08ffcSJunyu Laiassert(p.data[0].decryptions == 47) 7515*7dc08ffcSJunyu Laiassert(p.data[0].expired == 0) 7516*7dc08ffcSJunyu Laiassert(p.data[0].keyuncached == 1) 7517*7dc08ffcSJunyu Lai 7518*7dc08ffcSJunyu Lai 7519*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_ADD_TRAP (1) - request 7520*7dc08ffcSJunyu Lais = b'\x17\x80\x03\x1e\x00\x01\x000\x00\x00\x00\x00\xc0\x00\x02\x03H\x0f\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xedB\xdd\xda\x7f\x97\x00\x00\x00\x01b$\xb8IM.\xa61\xd0\x85I\x8f\xa7\'\x89\x92' 7521*7dc08ffcSJunyu Laip = NTP(s) 7522*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7523*7dc08ffcSJunyu Laiassert(p.response == 0) 7524*7dc08ffcSJunyu Laiassert(p.more == 0) 7525*7dc08ffcSJunyu Laiassert(p.version == 2) 7526*7dc08ffcSJunyu Laiassert(p.mode == 7) 7527*7dc08ffcSJunyu Laiassert(p.auth == 1) 7528*7dc08ffcSJunyu Laiassert(p.request_code == 30) 7529*7dc08ffcSJunyu Laiassert(p.err == 0) 7530*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7531*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7532*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfTrap)) 7533*7dc08ffcSJunyu Laiassert(p.req_data[0].trap_address == '192.0.2.3') 7534*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7535*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7536*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'6224b8494d2ea631d085498fa7278992') 7537*7dc08ffcSJunyu Lai 7538*7dc08ffcSJunyu Lai 7539*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_ADD_TRAP (2) - response 7540*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7541*7dc08ffcSJunyu Laip = NTP(s) 7542*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7543*7dc08ffcSJunyu Laiassert(p.response == 1) 7544*7dc08ffcSJunyu Laiassert(p.more == 0) 7545*7dc08ffcSJunyu Laiassert(p.version == 2) 7546*7dc08ffcSJunyu Laiassert(p.mode == 7) 7547*7dc08ffcSJunyu Laiassert(p.auth == 0) 7548*7dc08ffcSJunyu Laiassert(p.request_code == 30) 7549*7dc08ffcSJunyu Laiassert(p.err == 0) 7550*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7551*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7552*7dc08ffcSJunyu Lai 7553*7dc08ffcSJunyu Lai 7554*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_CLR_TRAP (1) - request 7555*7dc08ffcSJunyu Lais = b'\x17\x80\x03\x1f\x00\x01\x000\x00\x00\x00\x00\xc0\x00\x02\x03H\x0f\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xedb\xb3\x18\x1c\x00\x00\x00\x00\x01\xa5_V\x9e\xb8qD\x92\x1b\x1c>Z\xad]*\x89' 7556*7dc08ffcSJunyu Laip = NTP(s) 7557*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7558*7dc08ffcSJunyu Laiassert(p.response == 0) 7559*7dc08ffcSJunyu Laiassert(p.more == 0) 7560*7dc08ffcSJunyu Laiassert(p.version == 2) 7561*7dc08ffcSJunyu Laiassert(p.mode == 7) 7562*7dc08ffcSJunyu Laiassert(p.auth == 1) 7563*7dc08ffcSJunyu Laiassert(p.request_code == 31) 7564*7dc08ffcSJunyu Laiassert(p.err == 0) 7565*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7566*7dc08ffcSJunyu Laiassert(hasattr(p, 'req_data')) 7567*7dc08ffcSJunyu Laiassert(isinstance(p.req_data[0], NTPConfTrap)) 7568*7dc08ffcSJunyu Laiassert(p.req_data[0].trap_address == '192.0.2.3') 7569*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7570*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7571*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'a55f569eb87144921b1c3e5aad5d2a89') 7572*7dc08ffcSJunyu Lai 7573*7dc08ffcSJunyu Lai 7574*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_CLR_TRAP (2) - response 7575*7dc08ffcSJunyu Lais = b'\x97\x00\x03\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7576*7dc08ffcSJunyu Laip = NTP(s) 7577*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7578*7dc08ffcSJunyu Laiassert(p.response == 1) 7579*7dc08ffcSJunyu Laiassert(p.more == 0) 7580*7dc08ffcSJunyu Laiassert(p.version == 2) 7581*7dc08ffcSJunyu Laiassert(p.mode == 7) 7582*7dc08ffcSJunyu Laiassert(p.auth == 0) 7583*7dc08ffcSJunyu Laiassert(p.request_code == 31) 7584*7dc08ffcSJunyu Laiassert(p.err == 0) 7585*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7586*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7587*7dc08ffcSJunyu Lai 7588*7dc08ffcSJunyu Lai 7589*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_GET_CTLSTATS - response 7590*7dc08ffcSJunyu Lais = b'\x97\x00\x03"\x00\x01\x00<\x00\x00\x00\xed\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7591*7dc08ffcSJunyu Laip = NTP(s) 7592*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7593*7dc08ffcSJunyu Laiassert(p.response == 1) 7594*7dc08ffcSJunyu Laiassert(p.more == 0) 7595*7dc08ffcSJunyu Laiassert(p.version == 2) 7596*7dc08ffcSJunyu Laiassert(p.mode == 7) 7597*7dc08ffcSJunyu Laiassert(p.auth == 0) 7598*7dc08ffcSJunyu Laiassert(p.request_code == 34) 7599*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7600*7dc08ffcSJunyu Laiassert(p.data_item_size == 60) 7601*7dc08ffcSJunyu Laiassert(type(p.data[0]) == NTPInfoControl) 7602*7dc08ffcSJunyu Laiassert(p.data[0].ctltimereset == 237) 7603*7dc08ffcSJunyu Lai 7604*7dc08ffcSJunyu Lai 7605*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_GET_KERNEL (1) - request 7606*7dc08ffcSJunyu Lais = b'\x17\x00\x03&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7607*7dc08ffcSJunyu Laip = NTP(s) 7608*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7609*7dc08ffcSJunyu Laiassert(p.response == 0) 7610*7dc08ffcSJunyu Laiassert(p.more == 0) 7611*7dc08ffcSJunyu Laiassert(p.version == 2) 7612*7dc08ffcSJunyu Laiassert(p.mode == 7) 7613*7dc08ffcSJunyu Laiassert(p.auth == 0) 7614*7dc08ffcSJunyu Laiassert(p.request_code == 38) 7615*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7616*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7617*7dc08ffcSJunyu Lai 7618*7dc08ffcSJunyu Lai 7619*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_GET_KERNEL (2) - response 7620*7dc08ffcSJunyu Lais = b'\x97\x00\x03&\x00\x01\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4$\x00\x00\xf4$\x00 A\x00\x00\x00\x00\x00\x03\x00\x00\x00\x01\x01\xf4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7621*7dc08ffcSJunyu Laip = NTP(s) 7622*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7623*7dc08ffcSJunyu Laiassert(p.response == 1) 7624*7dc08ffcSJunyu Laiassert(p.more == 0) 7625*7dc08ffcSJunyu Laiassert(p.version == 2) 7626*7dc08ffcSJunyu Laiassert(p.mode == 7) 7627*7dc08ffcSJunyu Laiassert(p.auth == 0) 7628*7dc08ffcSJunyu Laiassert(p.request_code == 38) 7629*7dc08ffcSJunyu Laiassert(p.nb_items == 1) 7630*7dc08ffcSJunyu Laiassert(p.data_item_size == 60) 7631*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoKernel)) 7632*7dc08ffcSJunyu Laiassert(p.data[0].maxerror == 16000000) 7633*7dc08ffcSJunyu Laiassert(p.data[0].esterror == 16000000) 7634*7dc08ffcSJunyu Laiassert(p.data[0].status == 8257) 7635*7dc08ffcSJunyu Laiassert(p.data[0].constant == 3) 7636*7dc08ffcSJunyu Laiassert(p.data[0].precision == 1) 7637*7dc08ffcSJunyu Laiassert(p.data[0].tolerance == 32768000) 7638*7dc08ffcSJunyu Lai 7639*7dc08ffcSJunyu Lai 7640*7dc08ffcSJunyu Lai 7641*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_MON_GETLIST_1 (1) - request 7642*7dc08ffcSJunyu Lais = b'\x17\x00\x03*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7643*7dc08ffcSJunyu Laip = NTP(s) 7644*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7645*7dc08ffcSJunyu Laiassert(p.response == 0) 7646*7dc08ffcSJunyu Laiassert(p.more == 0) 7647*7dc08ffcSJunyu Laiassert(p.version == 2) 7648*7dc08ffcSJunyu Laiassert(p.mode == 7) 7649*7dc08ffcSJunyu Laiassert(p.request_code == 42) 7650*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7651*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7652*7dc08ffcSJunyu Lai 7653*7dc08ffcSJunyu Lai 7654*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_MON_GETLIST_1 (2) - response 7655*7dc08ffcSJunyu Lais = b'\xd7\x00\x03*\x00\x06\x00H\x00\x00\x00;\x00\x00\x00;\x00\x00\x01\xd0\x00\x00\x00\x01\x94mw\xe9\xc0\xa8zg\x00\x00\x00\x01\x00{\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;\x00\x00\x00;\x00\x00\x01\xd0\x00\x00\x00\x01\x13\xb6\xa9J\xc0\xa8zg\x00\x00\x00\x01\x00{\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;\x00\x00\x00;\x00\x00\x01\xd0\x00\x00\x00\x01\xbb]\x81\xea\xc0\xa8zg\x00\x00\x00\x01\x00{\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;\x00\x00\x00;\x00\x00\x01\xd0\x00\x00\x00\x01\xfc\xbf\xd5a\xc0\xa8zg\x00\x00\x00\x01\x00{\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;\x00\x00\x00;\x00\x00\x01\xd0\x00\x00\x00\x01\xbe\x10x\xa8\xc0\xa8zg\x00\x00\x00\x01\x00{\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;\x00\x00\x00;\x00\x00\x01\xd0\x00\x00\x00\x01\xde[ng\xc0\xa8zg\x00\x00\x00\x01\x00{\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 7656*7dc08ffcSJunyu Laip = NTP(s) 7657*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7658*7dc08ffcSJunyu Laiassert(p.response == 1) 7659*7dc08ffcSJunyu Laiassert(p.more == 1) 7660*7dc08ffcSJunyu Laiassert(p.version == 2) 7661*7dc08ffcSJunyu Laiassert(p.mode == 7) 7662*7dc08ffcSJunyu Laiassert(p.request_code == 42) 7663*7dc08ffcSJunyu Laiassert(p.nb_items == 6) 7664*7dc08ffcSJunyu Laiassert(p.data_item_size == 72) 7665*7dc08ffcSJunyu Lai 7666*7dc08ffcSJunyu Lai 7667*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IF_STATS (1) - request 7668*7dc08ffcSJunyu Lais = b'\x17\x80\x03,\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xeb\xdd\x8cH\xefe\x00\x00\x00\x01\x8b\xfb\x90u\xa8ad\xe8\x87\xca\xbf\x96\xd2\x9d\xddI' 7669*7dc08ffcSJunyu Laip = NTP(s) 7670*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7671*7dc08ffcSJunyu Laiassert(p.response == 0) 7672*7dc08ffcSJunyu Laiassert(p.more == 0) 7673*7dc08ffcSJunyu Laiassert(p.version == 2) 7674*7dc08ffcSJunyu Laiassert(p.mode == 7) 7675*7dc08ffcSJunyu Laiassert(p.auth == 1) 7676*7dc08ffcSJunyu Laiassert(p.request_code == 44) 7677*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7678*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7679*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7680*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7681*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'8bfb9075a86164e887cabf96d29ddd49') 7682*7dc08ffcSJunyu Lai 7683*7dc08ffcSJunyu Lai 7684*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IF_STATS (2) - response 7685*7dc08ffcSJunyu Lais = b"\xd7\x00\x03,\x00\x03\x00\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x01lo\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00\x00\x00\n\x00\x01\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\n\x00'\xff\xfe\xe3\x81r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01eth0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x06\x00\x00\x00\x00\x00\n\x00\x01\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\n\x00'\xff\xfe\xa0\x1d\xd0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01eth1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00\x03\x00\x00\x00\x03\x00\x00\x00\x05\x00\x00\x00\x00\x00\n\x00\x01\x00\x00\x00\x00" 7686*7dc08ffcSJunyu Laip = NTP(s) 7687*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7688*7dc08ffcSJunyu Laiassert(p.response == 1) 7689*7dc08ffcSJunyu Laiassert(p.more == 1) 7690*7dc08ffcSJunyu Laiassert(p.version == 2) 7691*7dc08ffcSJunyu Laiassert(p.mode == 7) 7692*7dc08ffcSJunyu Laiassert(p.auth == 0) 7693*7dc08ffcSJunyu Laiassert(p.request_code == 44) 7694*7dc08ffcSJunyu Laiassert(p.err == 0) 7695*7dc08ffcSJunyu Laiassert(p.nb_items == 3) 7696*7dc08ffcSJunyu Laiassert(p.data_item_size == 136) 7697*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoIfStatsIPv6)) 7698*7dc08ffcSJunyu Laiassert(p.data[0].unaddr == "::1") 7699*7dc08ffcSJunyu Laiassert(p.data[0].unmask == "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") 7700*7dc08ffcSJunyu Laiassert(p.data[0].ifname.startswith(b"lo")) 7701*7dc08ffcSJunyu Lai 7702*7dc08ffcSJunyu Lai 7703*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IF_STATS (3) - response 7704*7dc08ffcSJunyu Lais = b'\xd7\x01\x03,\x00\x03\x00\x88\xc0\xa8ze\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8z\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00eth1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x02\x00\x02\x00\x01\x00\x00\x00\x00\n\x00\x02\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x02\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00eth0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x02\x00\x01\x00\x00\x00\x00\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00lo\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x02\x00\x01\x00\x00\x00\x00' 7705*7dc08ffcSJunyu Laip = NTP(s) 7706*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7707*7dc08ffcSJunyu Laiassert(p.response == 1) 7708*7dc08ffcSJunyu Laiassert(p.more == 1) 7709*7dc08ffcSJunyu Laiassert(p.version == 2) 7710*7dc08ffcSJunyu Laiassert(p.mode == 7) 7711*7dc08ffcSJunyu Laiassert(p.auth == 0) 7712*7dc08ffcSJunyu Laiassert(p.request_code == 44) 7713*7dc08ffcSJunyu Laiassert(p.err == 0) 7714*7dc08ffcSJunyu Laiassert(p.nb_items == 3) 7715*7dc08ffcSJunyu Laiassert(p.data_item_size == 136) 7716*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoIfStatsIPv4)) 7717*7dc08ffcSJunyu Laiassert(p.data[0].unaddr == "192.168.122.101") 7718*7dc08ffcSJunyu Laiassert(p.data[0].unmask == "255.255.255.0") 7719*7dc08ffcSJunyu Laiassert(p.data[0].ifname.startswith(b"eth1")) 7720*7dc08ffcSJunyu Lai 7721*7dc08ffcSJunyu Lai 7722*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IF_RELOAD (1) - request 7723*7dc08ffcSJunyu Lais = b'\x17\x80\x03-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdb9\xed\xa3\xdc\x7f\xc6\x11\x00\x00\x00\x01\xfb>\x96*\xe7O\xf7\x8feh\xd4\x07L\xc0\x08\xcb' 7724*7dc08ffcSJunyu Laip = NTP(s) 7725*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7726*7dc08ffcSJunyu Laiassert(p.response == 0) 7727*7dc08ffcSJunyu Laiassert(p.more == 0) 7728*7dc08ffcSJunyu Laiassert(p.version == 2) 7729*7dc08ffcSJunyu Laiassert(p.mode == 7) 7730*7dc08ffcSJunyu Laiassert(p.auth == 1) 7731*7dc08ffcSJunyu Laiassert(p.request_code == 45) 7732*7dc08ffcSJunyu Laiassert(p.nb_items == 0) 7733*7dc08ffcSJunyu Laiassert(p.data_item_size == 0) 7734*7dc08ffcSJunyu Laiassert(hasattr(p, 'authenticator')) 7735*7dc08ffcSJunyu Laiassert(p.authenticator.key_id == 1) 7736*7dc08ffcSJunyu Laiassert(bytes_hex(p.authenticator.dgst) == b'fb3e962ae74ff78f6568d4074cc008cb') 7737*7dc08ffcSJunyu Lai 7738*7dc08ffcSJunyu Lai 7739*7dc08ffcSJunyu Lai= NTP Private (mode 7) - REQ_IF_RELOAD (2) - response 7740*7dc08ffcSJunyu Lais = b'\xd7\x00\x03-\x00\x03\x00\x88\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00lo\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x02\x00\x01\x00\x00\x00\x00\n\x00\x02\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x02\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00eth0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x01\xf4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x05\x00\x02\x00\x01\x00\x00\x00\x00\xc0\xa8ze\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8z\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00eth1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00=\x00\x00\x00}\x00\x00\x00\x00\x00\x00\x01\xf4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\t\x00\x02\x00\x01\x00\x00\x00\x00' 7741*7dc08ffcSJunyu Laip = NTP(s) 7742*7dc08ffcSJunyu Laiassert(isinstance(p, NTPPrivate)) 7743*7dc08ffcSJunyu Laiassert(p.response == 1) 7744*7dc08ffcSJunyu Laiassert(p.more == 1) 7745*7dc08ffcSJunyu Laiassert(p.version == 2) 7746*7dc08ffcSJunyu Laiassert(p.mode == 7) 7747*7dc08ffcSJunyu Laiassert(p.auth == 0) 7748*7dc08ffcSJunyu Laiassert(p.request_code == 45) 7749*7dc08ffcSJunyu Laiassert(p.err == 0) 7750*7dc08ffcSJunyu Laiassert(p.nb_items == 3) 7751*7dc08ffcSJunyu Laiassert(p.data_item_size == 136) 7752*7dc08ffcSJunyu Laiassert(isinstance(p.data[0], NTPInfoIfStatsIPv4)) 7753*7dc08ffcSJunyu Laiassert(p.data[0].unaddr == "127.0.0.1") 7754*7dc08ffcSJunyu Laiassert(p.data[0].unmask == "255.0.0.0") 7755*7dc08ffcSJunyu Laiassert(p.data[0].ifname.startswith(b"lo")) 7756*7dc08ffcSJunyu Lai 7757*7dc08ffcSJunyu Lai 7758*7dc08ffcSJunyu Lai############ 7759*7dc08ffcSJunyu Lai############ 7760*7dc08ffcSJunyu Lai+ VXLAN layer 7761*7dc08ffcSJunyu Lai 7762*7dc08ffcSJunyu Lai= Build a VXLAN packet with VNI of 42 7763*7dc08ffcSJunyu Lairaw(UDP(sport=1024, dport=4789, len=None, chksum=None)/VXLAN(flags=0x08, vni=42)) == b'\x04\x00\x12\xb5\x00\x10\x00\x00\x08\x00\x00\x00\x00\x00\x2a\x00' 7764*7dc08ffcSJunyu Lai 7765*7dc08ffcSJunyu Lai= Verify VXLAN Ethernet Binding 7766*7dc08ffcSJunyu Laipkt = VXLAN(raw(VXLAN(vni=23)/Ether(dst="11:11:11:11:11:11", src="11:11:11:11:11:11", type=0x800))) 7767*7dc08ffcSJunyu Laipkt.flags.NextProtocol and pkt.NextProtocol == 3 7768*7dc08ffcSJunyu Lai 7769*7dc08ffcSJunyu Lai= Verify UDP dport overloading 7770*7dc08ffcSJunyu Laip = Ether(dst="11:11:11:11:11:11", src="22:22:22:22:22:22") 7771*7dc08ffcSJunyu Laip /= IP(src="1.1.1.1", dst="2.2.2.2") / UDP(sport=1111) 7772*7dc08ffcSJunyu Laip /= VXLAN(flags=0x8, vni=42) / Ether() / IP() 7773*7dc08ffcSJunyu Laip = Ether(raw(p)) 7774*7dc08ffcSJunyu Laiassert(p[UDP].dport == 4789) 7775*7dc08ffcSJunyu Laiassert(p[Ether:2].type == 0x800) 7776*7dc08ffcSJunyu Lai 7777*7dc08ffcSJunyu Lai= Build a VXLAN packet with next protocol field 7778*7dc08ffcSJunyu Laip = Ether(dst="11:11:11:11:11:11", src="22:22:22:22:22:22") 7779*7dc08ffcSJunyu Laip /= IP(src="1.1.1.1", dst="2.2.2.2") / UDP(sport=1111) 7780*7dc08ffcSJunyu Laip /= VXLAN(flags=0xC, vni=42, NextProtocol=3) / Ether() / IP() 7781*7dc08ffcSJunyu Laip = Ether(raw(p)) 7782*7dc08ffcSJunyu Laiassert(p[UDP].dport == 4789) 7783*7dc08ffcSJunyu Laiassert(p[VXLAN].reserved0 == 0x0) 7784*7dc08ffcSJunyu Laiassert(p[VXLAN].NextProtocol == 3) 7785*7dc08ffcSJunyu Laiassert(p[Ether:2].type == 0x800) 7786*7dc08ffcSJunyu Lai 7787*7dc08ffcSJunyu Lai= Build a VXLAN packet with no group policy ID 7788*7dc08ffcSJunyu Laip = Ether(dst="11:11:11:11:11:11", src="22:22:22:22:22:22") 7789*7dc08ffcSJunyu Laip /= IP(src="1.1.1.1", dst="2.2.2.2") / UDP(sport=1111) 7790*7dc08ffcSJunyu Laip /= VXLAN(flags=0x8, vni=42) / Ether() / IP() 7791*7dc08ffcSJunyu Laip = Ether(raw(p)) 7792*7dc08ffcSJunyu Laiassert(p[VXLAN].reserved1 == 0x0) 7793*7dc08ffcSJunyu Laiassert(p[VXLAN].gpid is None) 7794*7dc08ffcSJunyu Laiassert(p[Ether:2].type == 0x800) 7795*7dc08ffcSJunyu Lai 7796*7dc08ffcSJunyu Lai= Build a VXLAN packet with group policy ID = 42 7797*7dc08ffcSJunyu Laip = Ether(dst="11:11:11:11:11:11", src="22:22:22:22:22:22") 7798*7dc08ffcSJunyu Laip /= IP(src="1.1.1.1", dst="2.2.2.2") / UDP(sport=1111) 7799*7dc08ffcSJunyu Laip /= VXLAN(flags=0x88, gpid=42, vni=42) / Ether() / IP() 7800*7dc08ffcSJunyu Laip = Ether(raw(p)) 7801*7dc08ffcSJunyu Laiassert(p[VXLAN].gpid == 42) 7802*7dc08ffcSJunyu Laiassert(p[VXLAN].reserved1 is None) 7803*7dc08ffcSJunyu Laiassert(p[Ether:2].type == 0x800) 7804*7dc08ffcSJunyu Lai 7805*7dc08ffcSJunyu Lai 7806*7dc08ffcSJunyu Lai############ 7807*7dc08ffcSJunyu Lai############ 7808*7dc08ffcSJunyu Lai############ 7809*7dc08ffcSJunyu Lai+ Tests of StreamSocket 7810*7dc08ffcSJunyu Lai 7811*7dc08ffcSJunyu Lai= Test with DNS over TCP 7812*7dc08ffcSJunyu Lai~ netaccess 7813*7dc08ffcSJunyu Lai 7814*7dc08ffcSJunyu Laiimport socket 7815*7dc08ffcSJunyu Laisck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 7816*7dc08ffcSJunyu Laisck.connect(("8.8.8.8", 53)) 7817*7dc08ffcSJunyu Lai 7818*7dc08ffcSJunyu Laiclass DNSTCP(Packet): 7819*7dc08ffcSJunyu Lai name = "DNS over TCP" 7820*7dc08ffcSJunyu Lai fields_desc = [ FieldLenField("len", None, fmt="!H", length_of="dns"), 7821*7dc08ffcSJunyu Lai PacketLenField("dns", 0, DNS, length_from=lambda p: p.len)] 7822*7dc08ffcSJunyu Lai 7823*7dc08ffcSJunyu Laissck = StreamSocket(sck) 7824*7dc08ffcSJunyu Laissck.basecls = DNSTCP 7825*7dc08ffcSJunyu Lai 7826*7dc08ffcSJunyu Lair = ssck.sr1(DNSTCP(dns=DNS(rd=1, qd=DNSQR(qname="www.example.com")))) 7827*7dc08ffcSJunyu Laisck.close() 7828*7dc08ffcSJunyu Laiassert(DNSTCP in r and len(r.dns.an)) 7829*7dc08ffcSJunyu Lai 7830*7dc08ffcSJunyu Lai############ 7831*7dc08ffcSJunyu Lai+ Tests of SSLStreamContext 7832*7dc08ffcSJunyu Lai 7833*7dc08ffcSJunyu Lai= Test with recv() calls that return exact packet-length rawings 7834*7dc08ffcSJunyu Lai~ sslraweamsocket 7835*7dc08ffcSJunyu Lai 7836*7dc08ffcSJunyu Laiimport socket 7837*7dc08ffcSJunyu Laiclass MockSocket(object): 7838*7dc08ffcSJunyu Lai def __init__(self): 7839*7dc08ffcSJunyu Lai self.l = [ b'\x00\x00\x00\x01', b'\x00\x00\x00\x02', b'\x00\x00\x00\x03' ] 7840*7dc08ffcSJunyu Lai def recv(self, x): 7841*7dc08ffcSJunyu Lai if len(self.l) == 0: 7842*7dc08ffcSJunyu Lai raise socket.error(100, 'EOF') 7843*7dc08ffcSJunyu Lai return self.l.pop(0) 7844*7dc08ffcSJunyu Lai 7845*7dc08ffcSJunyu Laiclass TestPacket(Packet): 7846*7dc08ffcSJunyu Lai name = 'TestPacket' 7847*7dc08ffcSJunyu Lai fields_desc = [ 7848*7dc08ffcSJunyu Lai IntField('data', 0) 7849*7dc08ffcSJunyu Lai ] 7850*7dc08ffcSJunyu Lai def guess_payload_class(self, p): 7851*7dc08ffcSJunyu Lai return conf.padding_layer 7852*7dc08ffcSJunyu Lai 7853*7dc08ffcSJunyu Lais = MockSocket() 7854*7dc08ffcSJunyu Laiss = SSLStreamSocket(s, basecls=TestPacket) 7855*7dc08ffcSJunyu Lai 7856*7dc08ffcSJunyu Laip = ss.recv() 7857*7dc08ffcSJunyu Laiassert(p.data == 1) 7858*7dc08ffcSJunyu Laip = ss.recv() 7859*7dc08ffcSJunyu Laiassert(p.data == 2) 7860*7dc08ffcSJunyu Laip = ss.recv() 7861*7dc08ffcSJunyu Laiassert(p.data == 3) 7862*7dc08ffcSJunyu Laitry: 7863*7dc08ffcSJunyu Lai ss.recv() 7864*7dc08ffcSJunyu Lai ret = False 7865*7dc08ffcSJunyu Laiexcept socket.error: 7866*7dc08ffcSJunyu Lai ret = True 7867*7dc08ffcSJunyu Lai 7868*7dc08ffcSJunyu Laiassert(ret) 7869*7dc08ffcSJunyu Lai 7870*7dc08ffcSJunyu Lai= Test with recv() calls that return twice as much data as the exact packet-length 7871*7dc08ffcSJunyu Lai~ sslraweamsocket 7872*7dc08ffcSJunyu Lai 7873*7dc08ffcSJunyu Laiimport socket 7874*7dc08ffcSJunyu Laiclass MockSocket(object): 7875*7dc08ffcSJunyu Lai def __init__(self): 7876*7dc08ffcSJunyu Lai self.l = [ b'\x00\x00\x00\x01\x00\x00\x00\x02', b'\x00\x00\x00\x03\x00\x00\x00\x04' ] 7877*7dc08ffcSJunyu Lai def recv(self, x): 7878*7dc08ffcSJunyu Lai if len(self.l) == 0: 7879*7dc08ffcSJunyu Lai raise socket.error(100, 'EOF') 7880*7dc08ffcSJunyu Lai return self.l.pop(0) 7881*7dc08ffcSJunyu Lai 7882*7dc08ffcSJunyu Laiclass TestPacket(Packet): 7883*7dc08ffcSJunyu Lai name = 'TestPacket' 7884*7dc08ffcSJunyu Lai fields_desc = [ 7885*7dc08ffcSJunyu Lai IntField('data', 0) 7886*7dc08ffcSJunyu Lai ] 7887*7dc08ffcSJunyu Lai def guess_payload_class(self, p): 7888*7dc08ffcSJunyu Lai return conf.padding_layer 7889*7dc08ffcSJunyu Lai 7890*7dc08ffcSJunyu Lais = MockSocket() 7891*7dc08ffcSJunyu Laiss = SSLStreamSocket(s, basecls=TestPacket) 7892*7dc08ffcSJunyu Lai 7893*7dc08ffcSJunyu Laip = ss.recv() 7894*7dc08ffcSJunyu Laiassert(p.data == 1) 7895*7dc08ffcSJunyu Laip = ss.recv() 7896*7dc08ffcSJunyu Laiassert(p.data == 2) 7897*7dc08ffcSJunyu Laip = ss.recv() 7898*7dc08ffcSJunyu Laiassert(p.data == 3) 7899*7dc08ffcSJunyu Laip = ss.recv() 7900*7dc08ffcSJunyu Laiassert(p.data == 4) 7901*7dc08ffcSJunyu Laitry: 7902*7dc08ffcSJunyu Lai ss.recv() 7903*7dc08ffcSJunyu Lai ret = False 7904*7dc08ffcSJunyu Laiexcept socket.error: 7905*7dc08ffcSJunyu Lai ret = True 7906*7dc08ffcSJunyu Lai 7907*7dc08ffcSJunyu Laiassert(ret) 7908*7dc08ffcSJunyu Lai 7909*7dc08ffcSJunyu Lai= Test with recv() calls that return not enough data 7910*7dc08ffcSJunyu Lai~ sslraweamsocket 7911*7dc08ffcSJunyu Lai 7912*7dc08ffcSJunyu Laiimport socket 7913*7dc08ffcSJunyu Laiclass MockSocket(object): 7914*7dc08ffcSJunyu Lai def __init__(self): 7915*7dc08ffcSJunyu Lai self.l = [ b'\x00\x00', b'\x00\x01', b'\x00\x00\x00', b'\x02', b'\x00\x00', b'\x00', b'\x03' ] 7916*7dc08ffcSJunyu Lai def recv(self, x): 7917*7dc08ffcSJunyu Lai if len(self.l) == 0: 7918*7dc08ffcSJunyu Lai raise socket.error(100, 'EOF') 7919*7dc08ffcSJunyu Lai return self.l.pop(0) 7920*7dc08ffcSJunyu Lai 7921*7dc08ffcSJunyu Laiclass TestPacket(Packet): 7922*7dc08ffcSJunyu Lai name = 'TestPacket' 7923*7dc08ffcSJunyu Lai fields_desc = [ 7924*7dc08ffcSJunyu Lai IntField('data', 0) 7925*7dc08ffcSJunyu Lai ] 7926*7dc08ffcSJunyu Lai def guess_payload_class(self, p): 7927*7dc08ffcSJunyu Lai return conf.padding_layer 7928*7dc08ffcSJunyu Lai 7929*7dc08ffcSJunyu Lais = MockSocket() 7930*7dc08ffcSJunyu Laiss = SSLStreamSocket(s, basecls=TestPacket) 7931*7dc08ffcSJunyu Lai 7932*7dc08ffcSJunyu Laitry: 7933*7dc08ffcSJunyu Lai p = ss.recv() 7934*7dc08ffcSJunyu Lai ret = False 7935*7dc08ffcSJunyu Laiexcept: 7936*7dc08ffcSJunyu Lai ret = True 7937*7dc08ffcSJunyu Lai 7938*7dc08ffcSJunyu Laiassert(ret) 7939*7dc08ffcSJunyu Laip = ss.recv() 7940*7dc08ffcSJunyu Laiassert(p.data == 1) 7941*7dc08ffcSJunyu Laitry: 7942*7dc08ffcSJunyu Lai p = ss.recv() 7943*7dc08ffcSJunyu Lai ret = False 7944*7dc08ffcSJunyu Laiexcept: 7945*7dc08ffcSJunyu Lai ret = True 7946*7dc08ffcSJunyu Lai 7947*7dc08ffcSJunyu Laiassert(ret) 7948*7dc08ffcSJunyu Laip = ss.recv() 7949*7dc08ffcSJunyu Laiassert(p.data == 2) 7950*7dc08ffcSJunyu Laitry: 7951*7dc08ffcSJunyu Lai p = ss.recv() 7952*7dc08ffcSJunyu Lai ret = False 7953*7dc08ffcSJunyu Laiexcept: 7954*7dc08ffcSJunyu Lai ret = True 7955*7dc08ffcSJunyu Lai 7956*7dc08ffcSJunyu Laiassert(ret) 7957*7dc08ffcSJunyu Laitry: 7958*7dc08ffcSJunyu Lai p = ss.recv() 7959*7dc08ffcSJunyu Lai ret = False 7960*7dc08ffcSJunyu Laiexcept: 7961*7dc08ffcSJunyu Lai ret = True 7962*7dc08ffcSJunyu Lai 7963*7dc08ffcSJunyu Laiassert(ret) 7964*7dc08ffcSJunyu Laip = ss.recv() 7965*7dc08ffcSJunyu Laiassert(p.data == 3) 7966*7dc08ffcSJunyu Lai 7967*7dc08ffcSJunyu Lai 7968*7dc08ffcSJunyu Lai############ 7969*7dc08ffcSJunyu Lai############ 7970*7dc08ffcSJunyu Lai+ Test correct conversion from binary to rawing of IPv6 addresses 7971*7dc08ffcSJunyu Lai 7972*7dc08ffcSJunyu Lai= IPv6 bin to rawing conversion 7973*7dc08ffcSJunyu Laifrom scapy.pton_ntop import _inet6_ntop, inet_ntop 7974*7dc08ffcSJunyu Laiimport socket 7975*7dc08ffcSJunyu Laifor binfrm, address in [ 7976*7dc08ffcSJunyu Lai (b'\x00' * 16, '::'), 7977*7dc08ffcSJunyu Lai (b'\x11\x11\x22\x22\x33\x33\x44\x44\x55\x55\x66\x66\x77\x77\x88\x88', 7978*7dc08ffcSJunyu Lai '1111:2222:3333:4444:5555:6666:7777:8888'), 7979*7dc08ffcSJunyu Lai (b'\x11\x11\x22\x22\x33\x33\x44\x44\x55\x55\x00\x00\x00\x00\x00\x00', 7980*7dc08ffcSJunyu Lai '1111:2222:3333:4444:5555::'), 7981*7dc08ffcSJunyu Lai (b'\x00\x00\x00\x00\x00\x00\x44\x44\x55\x55\x66\x66\x77\x77\x88\x88', 7982*7dc08ffcSJunyu Lai '::4444:5555:6666:7777:8888'), 7983*7dc08ffcSJunyu Lai (b'\x00\x00\x00\x00\x33\x33\x44\x44\x00\x00\x00\x00\x00\x00\x88\x88', 7984*7dc08ffcSJunyu Lai '0:0:3333:4444::8888'), 7985*7dc08ffcSJunyu Lai (b'\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 7986*7dc08ffcSJunyu Lai '1::'), 7987*7dc08ffcSJunyu Lai (b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01', 7988*7dc08ffcSJunyu Lai '::1'), 7989*7dc08ffcSJunyu Lai (b'\x11\x11\x00\x00\x00\x00\x44\x44\x00\x00\x00\x00\x77\x77\x88\x88', 7990*7dc08ffcSJunyu Lai '1111::4444:0:0:7777:8888'), 7991*7dc08ffcSJunyu Lai (b'\x10\x00\x02\x00\x00\x30\x00\x04\x00\x05\x00\x60\x07\x00\x80\x00', 7992*7dc08ffcSJunyu Lai '1000:200:30:4:5:60:700:8000'), 7993*7dc08ffcSJunyu Lai]: 7994*7dc08ffcSJunyu Lai addr1 = inet_ntop(socket.AF_INET6, binfrm) 7995*7dc08ffcSJunyu Lai addr2 = _inet6_ntop(binfrm) 7996*7dc08ffcSJunyu Lai assert address == addr1 == addr2 7997*7dc08ffcSJunyu Lai 7998*7dc08ffcSJunyu Lai= IPv6 bin to rawing conversion - Zero-block of length 1 7999*7dc08ffcSJunyu Laibinfrm = b'\x11\x11\x22\x22\x33\x33\x44\x44\x55\x55\x66\x66\x00\x00\x88\x88' 8000*7dc08ffcSJunyu Laiaddr1, addr2 = inet_ntop(socket.AF_INET6, binfrm), _inet6_ntop(binfrm) 8001*7dc08ffcSJunyu Lai# On Mac OS socket.inet_ntop is not fully compliant with RFC 5952 and 8002*7dc08ffcSJunyu Lai# shortens the single zero block to '::'. This is a valid IPv6 address 8003*7dc08ffcSJunyu Lai# representation anyway. 8004*7dc08ffcSJunyu Laiassert(addr1 in ['1111:2222:3333:4444:5555:6666:0:8888', 8005*7dc08ffcSJunyu Lai '1111:2222:3333:4444:5555:6666::8888']) 8006*7dc08ffcSJunyu Laiassert(addr2 == '1111:2222:3333:4444:5555:6666:0:8888') 8007*7dc08ffcSJunyu Lai 8008*7dc08ffcSJunyu Lai= IPv6 bin to rawing conversion - Illegal sizes 8009*7dc08ffcSJunyu Laifor binfrm in ["\x00" * 15, b"\x00" * 17]: 8010*7dc08ffcSJunyu Lai rc = False 8011*7dc08ffcSJunyu Lai try: 8012*7dc08ffcSJunyu Lai inet_ntop(socket.AF_INET6, binfrm) 8013*7dc08ffcSJunyu Lai except Exception as exc1: 8014*7dc08ffcSJunyu Lai _exc1 = exc1 8015*7dc08ffcSJunyu Lai rc = True 8016*7dc08ffcSJunyu Lai assert rc 8017*7dc08ffcSJunyu Lai try: 8018*7dc08ffcSJunyu Lai _inet6_ntop(binfrm) 8019*7dc08ffcSJunyu Lai except Exception as exc2: 8020*7dc08ffcSJunyu Lai rc = isinstance(exc2, type(_exc1)) 8021*7dc08ffcSJunyu Lai assert rc 8022*7dc08ffcSJunyu Lai 8023*7dc08ffcSJunyu Lai 8024*7dc08ffcSJunyu Lai############ 8025*7dc08ffcSJunyu Lai############ 8026*7dc08ffcSJunyu Lai+ VRRP tests 8027*7dc08ffcSJunyu Lai 8028*7dc08ffcSJunyu Lai= VRRP - build 8029*7dc08ffcSJunyu Lais = raw(IP()/VRRP()) 8030*7dc08ffcSJunyu Lais == b'E\x00\x00$\x00\x01\x00\x00@p|g\x7f\x00\x00\x01\x7f\x00\x00\x01!\x01d\x00\x00\x01z\xfd\x00\x00\x00\x00\x00\x00\x00\x00' 8031*7dc08ffcSJunyu Lai 8032*7dc08ffcSJunyu Lai= VRRP - dissection 8033*7dc08ffcSJunyu Laip = IP(s) 8034*7dc08ffcSJunyu LaiVRRP in p and p[VRRP].chksum == 0x7afd 8035*7dc08ffcSJunyu Lai 8036*7dc08ffcSJunyu Lai= VRRP - chksums 8037*7dc08ffcSJunyu Lai# VRRPv3 8038*7dc08ffcSJunyu Laip = Ether(src="00:00:5e:00:02:02",dst="01:00:5e:00:00:12")/IP(src="20.0.0.3", dst="224.0.0.18",ttl=255)/VRRPv3(priority=254,vrid=2,version=3,adv=1,addrlist=["20.0.1.2","20.0.1.3"]) 8039*7dc08ffcSJunyu Laia = Ether(raw(p)) 8040*7dc08ffcSJunyu Laiassert a[VRRPv3].chksum == 0xb25e 8041*7dc08ffcSJunyu Lai# VRRPv1 8042*7dc08ffcSJunyu Laip = Ether(src="00:00:5e:00:02:02",dst="01:00:5e:00:00:12")/IP(src="20.0.0.3", dst="224.0.0.18",ttl=255)/VRRP(priority=254,vrid=2,version=1,adv=1,addrlist=["20.0.1.2","20.0.1.3"]) 8043*7dc08ffcSJunyu Laib = Ether(raw(p)) 8044*7dc08ffcSJunyu Laiassert b[VRRP].chksum == 0xc6f4 8045*7dc08ffcSJunyu Lai 8046*7dc08ffcSJunyu Lai############ 8047*7dc08ffcSJunyu Lai############ 8048*7dc08ffcSJunyu Lai+ L2TP tests 8049*7dc08ffcSJunyu Lai 8050*7dc08ffcSJunyu Lai= L2TP - build 8051*7dc08ffcSJunyu Lais = raw(IP()/UDP()/L2TP()) 8052*7dc08ffcSJunyu Lais == b'E\x00\x00"\x00\x01\x00\x00@\x11|\xc8\x7f\x00\x00\x01\x7f\x00\x00\x01\x06\xa5\x06\xa5\x00\x0e\xf4\x83\x00\x02\x00\x00\x00\x00' 8053*7dc08ffcSJunyu Lai 8054*7dc08ffcSJunyu Lai= L2TP - dissection 8055*7dc08ffcSJunyu Laip = IP(s) 8056*7dc08ffcSJunyu LaiL2TP in p and len(p[L2TP]) == 6 and p.tunnel_id == 0 and p.session_id == 0 and p[UDP].chksum == 0xf483 8057*7dc08ffcSJunyu Lai 8058*7dc08ffcSJunyu Lai 8059*7dc08ffcSJunyu Lai############ 8060*7dc08ffcSJunyu Lai############ 8061*7dc08ffcSJunyu Lai+ HSRP tests 8062*7dc08ffcSJunyu Lai 8063*7dc08ffcSJunyu Lai= HSRP - build & dissection 8064*7dc08ffcSJunyu Laidefaddr = conf.route.route('0.0.0.0')[1] 8065*7dc08ffcSJunyu Laipkt = IP(raw(IP()/UDP(dport=1985, sport=1985)/HSRP()/HSRPmd5())) 8066*7dc08ffcSJunyu Laiassert pkt[IP].dst == "224.0.0.2" and pkt[UDP].sport == pkt[UDP].dport == 1985 8067*7dc08ffcSJunyu Laiassert pkt[HSRP].opcode == 0 and pkt[HSRP].state == 16 8068*7dc08ffcSJunyu Laiassert pkt[HSRPmd5].type == 4 and pkt[HSRPmd5].sourceip == defaddr 8069*7dc08ffcSJunyu Lai 8070*7dc08ffcSJunyu Lai 8071*7dc08ffcSJunyu Lai############ 8072*7dc08ffcSJunyu Lai############ 8073*7dc08ffcSJunyu Lai+ RIP tests 8074*7dc08ffcSJunyu Lai 8075*7dc08ffcSJunyu Lai= RIP - build 8076*7dc08ffcSJunyu Lais = raw(IP()/UDP(sport=520)/RIP()/RIPEntry()/RIPAuth(authtype=2, password="scapy")) 8077*7dc08ffcSJunyu Lais == b'E\x00\x00H\x00\x01\x00\x00@\x11|\xa2\x7f\x00\x00\x01\x7f\x00\x00\x01\x02\x08\x02\x08\x004\xae\x99\x01\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\xff\x00\x02scapy\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 8078*7dc08ffcSJunyu Lai 8079*7dc08ffcSJunyu Lai= RIP - dissection 8080*7dc08ffcSJunyu Laip = IP(s) 8081*7dc08ffcSJunyu LaiRIPEntry in p and RIPAuth in p and p[RIPAuth].password.startswith(b"scapy") 8082*7dc08ffcSJunyu Lai 8083*7dc08ffcSJunyu Lai 8084*7dc08ffcSJunyu Lai############ 8085*7dc08ffcSJunyu Lai############ 8086*7dc08ffcSJunyu Lai+ RADIUS tests 8087*7dc08ffcSJunyu Lai 8088*7dc08ffcSJunyu Lai= IP/UDP/RADIUS - Build 8089*7dc08ffcSJunyu Lais = raw(IP()/UDP(sport=1812)/Radius(authenticator="scapy")/RadiusAttribute(value="scapy")) 8090*7dc08ffcSJunyu Lais == b'E\x00\x007\x00\x01\x00\x00@\x11|\xb3\x7f\x00\x00\x01\x7f\x00\x00\x01\x07\x14\x07\x15\x00#U\xb2\x01\x00\x00\x1bscapy\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x07scapy' 8091*7dc08ffcSJunyu Lai 8092*7dc08ffcSJunyu Lai= IP/UDP/RADIUS - Dissection 8093*7dc08ffcSJunyu Laip = IP(s) 8094*7dc08ffcSJunyu LaiRadius in p and len(p[Radius].attributes) == 1 and p[Radius].attributes[0].value == b"scapy" 8095*7dc08ffcSJunyu Lai 8096*7dc08ffcSJunyu Lai= RADIUS - Access-Request - Dissection (1) 8097*7dc08ffcSJunyu Lais = b'\x01\xae\x01\x17>k\xd4\xc4\x19V\x0b*1\x99\xc8D\xea\xc2\x94Z\x01\x06leap\x06\x06\x00\x00\x00\x02\x1a\x1b\x00\x00\x00\t\x01\x15service-type=Framed\x0c\x06\x00\x00#\xee\x1e\x13AC-7E-8A-4E-E2-92\x1f\x1300-26-73-9E-0F-D3O\x0b\x02\x01\x00\t\x01leapP\x12U\xbc\x12\xcdM\x00\xf8\xdb4\xf1\x18r\xca_\x8c\xf6f\x02\x1a1\x00\x00\x00\t\x01+audit-session-id=0AC8090E0000001A0354CA00\x1a\x14\x00\x00\x00\t\x01\x0emethod=dot1x\x08\x06\xc0\xa8\n\xb9\x04\x06\xc0\xa8\n\x80\x1a\x1d\x00\x00\x00\t\x02\x17GigabitEthernet1/0/18W\x17GigabitEthernet1/0/18=\x06\x00\x00\x00\x0f\x05\x06\x00\x00\xc3\xc6' 8098*7dc08ffcSJunyu Lairadius_packet = Radius(s) 8099*7dc08ffcSJunyu Laiassert(radius_packet.id == 174) 8100*7dc08ffcSJunyu Laiassert(radius_packet.len == 279) 8101*7dc08ffcSJunyu Laiassert(radius_packet.authenticator == b'>k\xd4\xc4\x19V\x0b*1\x99\xc8D\xea\xc2\x94Z') 8102*7dc08ffcSJunyu Laiassert(len(radius_packet.attributes) == 17) 8103*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].type == 1) 8104*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[0]) == RadiusAttribute) 8105*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].len == 6) 8106*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].value == b"leap") 8107*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].type == 6) 8108*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[1]) == RadiusAttr_Service_Type) 8109*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].len == 6) 8110*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].value == 2) 8111*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].type == 26) 8112*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[2]) == RadiusAttr_Vendor_Specific) 8113*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].len == 27) 8114*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].vendor_id == 9) 8115*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].vendor_type == 1) 8116*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].vendor_len == 21) 8117*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].value == b"service-type=Framed") 8118*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].type == 79) 8119*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[6]) == RadiusAttr_EAP_Message) 8120*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].len == 11) 8121*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value.haslayer(EAP)) 8122*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].code == 2) 8123*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].id == 1) 8124*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].len == 9) 8125*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].type == 1) 8126*7dc08ffcSJunyu Laiassert(hasattr(radius_packet.attributes[6].value[EAP], "identity")) 8127*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].identity == b"leap") 8128*7dc08ffcSJunyu Laiassert(radius_packet.attributes[7].type == 80) 8129*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[7]) == RadiusAttr_Message_Authenticator) 8130*7dc08ffcSJunyu Laiassert(radius_packet.attributes[7].len == 18) 8131*7dc08ffcSJunyu Laiassert(radius_packet.attributes[7].value == b'U\xbc\x12\xcdM\x00\xf8\xdb4\xf1\x18r\xca_\x8c\xf6') 8132*7dc08ffcSJunyu Laiassert(radius_packet.attributes[11].type == 8) 8133*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[11]) == RadiusAttr_Framed_IP_Address) 8134*7dc08ffcSJunyu Laiassert(radius_packet.attributes[11].len == 6) 8135*7dc08ffcSJunyu Laiassert(radius_packet.attributes[11].value == '192.168.10.185') 8136*7dc08ffcSJunyu Laiassert(radius_packet.attributes[16].type == 5) 8137*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[16]) == RadiusAttr_NAS_Port) 8138*7dc08ffcSJunyu Laiassert(radius_packet.attributes[16].len == 6) 8139*7dc08ffcSJunyu Laiassert(radius_packet.attributes[16].value == 50118) 8140*7dc08ffcSJunyu Lai 8141*7dc08ffcSJunyu Lai= RADIUS - compute_message_authenticator() 8142*7dc08ffcSJunyu Lairam = radius_packet[RadiusAttr_Message_Authenticator] 8143*7dc08ffcSJunyu Laiassert ram.compute_message_authenticator(radius_packet, b"dummy bytes", b"scapy") == b'\x19\xa4\x0e*Y4\xe0l?,\x94\x9f \xb8Jb' 8144*7dc08ffcSJunyu Lai 8145*7dc08ffcSJunyu Lai= RADIUS - Access-Challenge - Dissection (2) 8146*7dc08ffcSJunyu Lais = b'\x0b\xae\x00[\xc7\xae\xfc6\xa1=\xb5\x99&^\xdf=\xe9\x00\xa6\xe8\x12\rHello, leapO\x16\x01\x02\x00\x14\x11\x01\x00\x08\xb8\xc4\x1a4\x97x\xd3\x82leapP\x12\xd3\x12\x17\xa6\x0c.\x94\x85\x03]t\xd1\xdb\xd0\x13\x8c\x18\x12iQs\xf7iSb@k\x9d,\xa0\x99\x8ehO' 8147*7dc08ffcSJunyu Lairadius_packet = Radius(s) 8148*7dc08ffcSJunyu Laiassert(radius_packet.id == 174) 8149*7dc08ffcSJunyu Laiassert(radius_packet.len == 91) 8150*7dc08ffcSJunyu Laiassert(radius_packet.authenticator == b'\xc7\xae\xfc6\xa1=\xb5\x99&^\xdf=\xe9\x00\xa6\xe8') 8151*7dc08ffcSJunyu Laiassert(len(radius_packet.attributes) == 4) 8152*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].type == 18) 8153*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[0]) == RadiusAttribute) 8154*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].len == 13) 8155*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].value == b"Hello, leap") 8156*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].type == 79) 8157*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[1]) == RadiusAttr_EAP_Message) 8158*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].len == 22) 8159*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].code == 1) 8160*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].id == 2) 8161*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].len == 20) 8162*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].type == 17) 8163*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].type == 80) 8164*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[2]) == RadiusAttr_Message_Authenticator) 8165*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].len == 18) 8166*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].value == b'\xd3\x12\x17\xa6\x0c.\x94\x85\x03]t\xd1\xdb\xd0\x13\x8c') 8167*7dc08ffcSJunyu Laiassert(radius_packet.attributes[3].type == 24) 8168*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[3]) == RadiusAttr_State) 8169*7dc08ffcSJunyu Laiassert(radius_packet.attributes[3].len == 18) 8170*7dc08ffcSJunyu Laiassert(radius_packet.attributes[3].value == b'iQs\xf7iSb@k\x9d,\xa0\x99\x8ehO') 8171*7dc08ffcSJunyu Lai 8172*7dc08ffcSJunyu Lai= RADIUS - Access-Request - Dissection (3) 8173*7dc08ffcSJunyu Lais = b'\x01\xaf\x01DC\xbe!J\x08\xdf\xcf\x9f\x00v~,\xfb\x8e`\xc8\x01\x06leap\x06\x06\x00\x00\x00\x02\x1a\x1b\x00\x00\x00\t\x01\x15service-type=Framed\x0c\x06\x00\x00#\xee\x1e\x13AC-7E-8A-4E-E2-92\x1f\x1300-26-73-9E-0F-D3O&\x02\x02\x00$\x11\x01\x00\x18\rE\xc9\x92\xf6\x9ae\x04\xa2\x06\x13\x8f\x0b#\xf1\xc56\x8eU\xd9\x89\xe5\xa1)leapP\x12|\x1c\x9d[dv\x9c\x19\x96\xc6\xec\xb82\x8f\n f\x02\x1a1\x00\x00\x00\t\x01+audit-session-id=0AC8090E0000001A0354CA00\x1a\x14\x00\x00\x00\t\x01\x0emethod=dot1x\x08\x06\xc0\xa8\n\xb9\x04\x06\xc0\xa8\n\x80\x1a\x1d\x00\x00\x00\t\x02\x17GigabitEthernet1/0/18W\x17GigabitEthernet1/0/18=\x06\x00\x00\x00\x0f\x05\x06\x00\x00\xc3\xc6\x18\x12iQs\xf7iSb@k\x9d,\xa0\x99\x8ehO' 8174*7dc08ffcSJunyu Lairadius_packet = Radius(s) 8175*7dc08ffcSJunyu Laiassert(radius_packet.id == 175) 8176*7dc08ffcSJunyu Laiassert(radius_packet.len == 324) 8177*7dc08ffcSJunyu Laiassert(radius_packet.authenticator == b'C\xbe!J\x08\xdf\xcf\x9f\x00v~,\xfb\x8e`\xc8') 8178*7dc08ffcSJunyu Laiassert(len(radius_packet.attributes) == 18) 8179*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].type == 1) 8180*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[0]) == RadiusAttribute) 8181*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].len == 6) 8182*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].value == b"leap") 8183*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].type == 6) 8184*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[1]) == RadiusAttr_Service_Type) 8185*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].len == 6) 8186*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].value == 2) 8187*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].type == 26) 8188*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[2]) == RadiusAttr_Vendor_Specific) 8189*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].len == 27) 8190*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].vendor_id == 9) 8191*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].vendor_type == 1) 8192*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].vendor_len == 21) 8193*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].value == b"service-type=Framed") 8194*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].type == 79) 8195*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[6]) == RadiusAttr_EAP_Message) 8196*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].len == 38) 8197*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value.haslayer(EAP)) 8198*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].code == 2) 8199*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].id == 2) 8200*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].len == 36) 8201*7dc08ffcSJunyu Laiassert(radius_packet.attributes[6].value[EAP].type == 17) 8202*7dc08ffcSJunyu Laiassert(radius_packet.attributes[7].type == 80) 8203*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[7]) == RadiusAttr_Message_Authenticator) 8204*7dc08ffcSJunyu Laiassert(radius_packet.attributes[7].len == 18) 8205*7dc08ffcSJunyu Laiassert(radius_packet.attributes[7].value == b'|\x1c\x9d[dv\x9c\x19\x96\xc6\xec\xb82\x8f\n ') 8206*7dc08ffcSJunyu Laiassert(radius_packet.attributes[11].type == 8) 8207*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[11]) == RadiusAttr_Framed_IP_Address) 8208*7dc08ffcSJunyu Laiassert(radius_packet.attributes[11].len == 6) 8209*7dc08ffcSJunyu Laiassert(radius_packet.attributes[11].value == '192.168.10.185') 8210*7dc08ffcSJunyu Laiassert(radius_packet.attributes[16].type == 5) 8211*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[16]) == RadiusAttr_NAS_Port) 8212*7dc08ffcSJunyu Laiassert(radius_packet.attributes[16].len == 6) 8213*7dc08ffcSJunyu Laiassert(radius_packet.attributes[16].value == 50118) 8214*7dc08ffcSJunyu Laiassert(radius_packet.attributes[17].type == 24) 8215*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[17]) == RadiusAttr_State) 8216*7dc08ffcSJunyu Laiassert(radius_packet.attributes[17].len == 18) 8217*7dc08ffcSJunyu Laiassert(radius_packet.attributes[17].value == b'iQs\xf7iSb@k\x9d,\xa0\x99\x8ehO') 8218*7dc08ffcSJunyu Lai 8219*7dc08ffcSJunyu Lai= RADIUS - Access-Challenge - Dissection (4) 8220*7dc08ffcSJunyu Lais = b'\x0b\xaf\x00K\x82 \x95=\xfd\x80\x05 -l}\xab)\xa5kU\x12\rHello, leapO\x06\x03\x03\x00\x04P\x12l0\xb9\x8d\xca\xfc!\xf3\xa7\x08\x80\xe1\xf6}\x84\xff\x18\x12iQs\xf7hRb@k\x9d,\xa0\x99\x8ehO' 8221*7dc08ffcSJunyu Lairadius_packet = Radius(s) 8222*7dc08ffcSJunyu Laiassert(radius_packet.id == 175) 8223*7dc08ffcSJunyu Laiassert(radius_packet.len == 75) 8224*7dc08ffcSJunyu Laiassert(radius_packet.authenticator == b'\x82 \x95=\xfd\x80\x05 -l}\xab)\xa5kU') 8225*7dc08ffcSJunyu Laiassert(len(radius_packet.attributes) == 4) 8226*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].type == 18) 8227*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[0]) == RadiusAttribute) 8228*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].len == 13) 8229*7dc08ffcSJunyu Laiassert(radius_packet.attributes[0].value == b"Hello, leap") 8230*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].type == 79) 8231*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[1]) == RadiusAttr_EAP_Message) 8232*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1].len == 6) 8233*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].code == 3) 8234*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].id == 3) 8235*7dc08ffcSJunyu Laiassert(radius_packet.attributes[1][EAP].len == 4) 8236*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].type == 80) 8237*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[2]) == RadiusAttr_Message_Authenticator) 8238*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].len == 18) 8239*7dc08ffcSJunyu Laiassert(radius_packet.attributes[2].value == b'l0\xb9\x8d\xca\xfc!\xf3\xa7\x08\x80\xe1\xf6}\x84\xff') 8240*7dc08ffcSJunyu Laiassert(radius_packet.attributes[3].type == 24) 8241*7dc08ffcSJunyu Laiassert(type(radius_packet.attributes[3]) == RadiusAttr_State) 8242*7dc08ffcSJunyu Laiassert(radius_packet.attributes[3].len == 18) 8243*7dc08ffcSJunyu Laiassert(radius_packet.attributes[3].value == b'iQs\xf7hRb@k\x9d,\xa0\x99\x8ehO') 8244*7dc08ffcSJunyu Lai 8245*7dc08ffcSJunyu Lai= RADIUS - Response Authenticator computation 8246*7dc08ffcSJunyu Lais = b'\x01\xae\x01\x17>k\xd4\xc4\x19V\x0b*1\x99\xc8D\xea\xc2\x94Z\x01\x06leap\x06\x06\x00\x00\x00\x02\x1a\x1b\x00\x00\x00\t\x01\x15service-type=Framed\x0c\x06\x00\x00#\xee\x1e\x13AC-7E-8A-4E-E2-92\x1f\x1300-26-73-9E-0F-D3O\x0b\x02\x01\x00\t\x01leapP\x12U\xbc\x12\xcdM\x00\xf8\xdb4\xf1\x18r\xca_\x8c\xf6f\x02\x1a1\x00\x00\x00\t\x01+audit-session-id=0AC8090E0000001A0354CA00\x1a\x14\x00\x00\x00\t\x01\x0emethod=dot1x\x08\x06\xc0\xa8\n\xb9\x04\x06\xc0\xa8\n\x80\x1a\x1d\x00\x00\x00\t\x02\x17GigabitEthernet1/0/18W\x17GigabitEthernet1/0/18=\x06\x00\x00\x00\x0f\x05\x06\x00\x00\xc3\xc6' 8247*7dc08ffcSJunyu Laiaccess_request = Radius(s) 8248*7dc08ffcSJunyu Lais = b'\x0b\xae\x00[\xc7\xae\xfc6\xa1=\xb5\x99&^\xdf=\xe9\x00\xa6\xe8\x12\rHello, leapO\x16\x01\x02\x00\x14\x11\x01\x00\x08\xb8\xc4\x1a4\x97x\xd3\x82leapP\x12\xd3\x12\x17\xa6\x0c.\x94\x85\x03]t\xd1\xdb\xd0\x13\x8c\x18\x12iQs\xf7iSb@k\x9d,\xa0\x99\x8ehO' 8249*7dc08ffcSJunyu Laiaccess_challenge = Radius(s) 8250*7dc08ffcSJunyu Laiaccess_challenge.compute_authenticator(access_request.authenticator, b"radiuskey") == access_challenge.authenticator 8251*7dc08ffcSJunyu Lai 8252*7dc08ffcSJunyu Lai= RADIUS - Layers (1) 8253*7dc08ffcSJunyu Lairadius_attr = RadiusAttr_EAP_Message(value = EAP()) 8254*7dc08ffcSJunyu Laiassert(RadiusAttr_EAP_Message in radius_attr) 8255*7dc08ffcSJunyu Laiassert(RadiusAttribute in radius_attr) 8256*7dc08ffcSJunyu Laitype(radius_attr[RadiusAttribute]) 8257*7dc08ffcSJunyu Laiassert(type(radius_attr[RadiusAttribute]) == RadiusAttr_EAP_Message) 8258*7dc08ffcSJunyu Laiassert(EAP in radius_attr.value) 8259*7dc08ffcSJunyu Lai 8260*7dc08ffcSJunyu Lai 8261*7dc08ffcSJunyu Lai############ 8262*7dc08ffcSJunyu Lai############ 8263*7dc08ffcSJunyu Lai+ Addresses generators 8264*7dc08ffcSJunyu Lai 8265*7dc08ffcSJunyu Lai= Net 8266*7dc08ffcSJunyu Lai 8267*7dc08ffcSJunyu Lain1 = Net("192.168.0.0/31") 8268*7dc08ffcSJunyu Lai[ip for ip in n1] == ["192.168.0.0", "192.168.0.1"] 8269*7dc08ffcSJunyu Lai 8270*7dc08ffcSJunyu Lain2 = Net("192.168.0.*") 8271*7dc08ffcSJunyu Lailen([ip for ip in n2]) == 256 8272*7dc08ffcSJunyu Lai 8273*7dc08ffcSJunyu Lain3 = Net("192.168.0.1-5") 8274*7dc08ffcSJunyu Lailen([ip for ip in n3]) == 5 8275*7dc08ffcSJunyu Lai 8276*7dc08ffcSJunyu Lai(n1 == n3) == False 8277*7dc08ffcSJunyu Lai 8278*7dc08ffcSJunyu Lai(n3 in n2) == True 8279*7dc08ffcSJunyu Lai 8280*7dc08ffcSJunyu Lai= Net using web address 8281*7dc08ffcSJunyu Lai 8282*7dc08ffcSJunyu Laiip = IP(dst="www.google.com") 8283*7dc08ffcSJunyu Lain1 = ip.dst 8284*7dc08ffcSJunyu Laiassert isinstance(n1, Net) 8285*7dc08ffcSJunyu Laiassert n1.ip_regex.match(str(n1)) 8286*7dc08ffcSJunyu Laiip.show() 8287*7dc08ffcSJunyu Lai 8288*7dc08ffcSJunyu Lai= OID 8289*7dc08ffcSJunyu Lai 8290*7dc08ffcSJunyu Laioid = OID("1.2.3.4.5.6-8") 8291*7dc08ffcSJunyu Lailen([ o for o in oid ]) == 3 8292*7dc08ffcSJunyu Lai 8293*7dc08ffcSJunyu Lai= Net6 8294*7dc08ffcSJunyu Lai 8295*7dc08ffcSJunyu Lain1 = Net6("2001:db8::/127") 8296*7dc08ffcSJunyu Lailen([ip for ip in n1]) == 2 8297*7dc08ffcSJunyu Lai 8298*7dc08ffcSJunyu Lai= Net6 using web address 8299*7dc08ffcSJunyu Lai~ netaccess ipv6 8300*7dc08ffcSJunyu Lai 8301*7dc08ffcSJunyu Laiip = IPv6(dst="www.google.com") 8302*7dc08ffcSJunyu Lain1 = ip.dst 8303*7dc08ffcSJunyu Laiassert isinstance(n1, Net6) 8304*7dc08ffcSJunyu Laiassert n1.ip_regex.match(str(n1)) 8305*7dc08ffcSJunyu Laiip.show() 8306*7dc08ffcSJunyu Lai 8307*7dc08ffcSJunyu Lai############ 8308*7dc08ffcSJunyu Lai############ 8309*7dc08ffcSJunyu Lai+ IPv6 helpers 8310*7dc08ffcSJunyu Lai 8311*7dc08ffcSJunyu Lai= in6_getLocalUniquePrefix() 8312*7dc08ffcSJunyu Lai 8313*7dc08ffcSJunyu Laip = in6_getLocalUniquePrefix() 8314*7dc08ffcSJunyu Lailen(inet_pton(socket.AF_INET6, p)) == 16 and p.startswith("fd") 8315*7dc08ffcSJunyu Lai 8316*7dc08ffcSJunyu Lai= Misc addresses manipulation functions 8317*7dc08ffcSJunyu Lai 8318*7dc08ffcSJunyu LaiteredoAddrExtractInfo("2001:0:0a0b:0c0d:0028:f508:f508:08f5") == ("10.11.12.13", 40, "10.247.247.10", 2807) 8319*7dc08ffcSJunyu Lai 8320*7dc08ffcSJunyu Laiip6 = IP6Field("test", None) 8321*7dc08ffcSJunyu Laiip6.i2repr("", "2001:0:0a0b:0c0d:0028:f508:f508:08f5") == "2001:0:0a0b:0c0d:0028:f508:f508:08f5 [Teredo srv: 10.11.12.13 cli: 10.247.247.10:2807]" 8322*7dc08ffcSJunyu Laiip6.i2repr("", "2002:0102:0304::1") == "2002:0102:0304::1 [6to4 GW: 1.2.3.4]" 8323*7dc08ffcSJunyu Lai 8324*7dc08ffcSJunyu Laiin6_iseui64("fe80::bae8:58ff:fed4:e5f6") == True 8325*7dc08ffcSJunyu Lai 8326*7dc08ffcSJunyu Laiin6_isanycast("2001:db8::fdff:ffff:ffff:ff80") == True 8327*7dc08ffcSJunyu Lai 8328*7dc08ffcSJunyu Laia = inet_pton(socket.AF_INET6, "2001:db8::2807") 8329*7dc08ffcSJunyu Laiin6_xor(a, a) == b"\x00" * 16 8330*7dc08ffcSJunyu Lai 8331*7dc08ffcSJunyu Laia = inet_pton(socket.AF_INET6, "fe80::bae8:58ff:fed4:e5f6") 8332*7dc08ffcSJunyu Lair = inet_ntop(socket.AF_INET6, in6_getnsma(a)) 8333*7dc08ffcSJunyu Lair == "ff02::1:ffd4:e5f6" 8334*7dc08ffcSJunyu Lai 8335*7dc08ffcSJunyu Laiin6_isllsnmaddr(r) == True 8336*7dc08ffcSJunyu Lai 8337*7dc08ffcSJunyu Laiin6_isdocaddr("2001:db8::2807") == True 8338*7dc08ffcSJunyu Lai 8339*7dc08ffcSJunyu Laiin6_isaddrllallnodes("ff02::1") == True 8340*7dc08ffcSJunyu Lai 8341*7dc08ffcSJunyu Laiin6_isaddrllallservers("ff02::2") == True 8342*7dc08ffcSJunyu Lai 8343*7dc08ffcSJunyu Lai= in6_getscope() 8344*7dc08ffcSJunyu Lai 8345*7dc08ffcSJunyu Laiassert in6_getscope("2001:db8::2807") == IPV6_ADDR_GLOBAL 8346*7dc08ffcSJunyu Laiassert in6_getscope("fec0::2807") == IPV6_ADDR_SITELOCAL 8347*7dc08ffcSJunyu Laiassert in6_getscope("fe80::2807") == IPV6_ADDR_LINKLOCAL 8348*7dc08ffcSJunyu Laiassert in6_getscope("ff02::2807") == IPV6_ADDR_LINKLOCAL 8349*7dc08ffcSJunyu Laiassert in6_getscope("ff0e::2807") == IPV6_ADDR_GLOBAL 8350*7dc08ffcSJunyu Laiassert in6_getscope("ff05::2807") == IPV6_ADDR_SITELOCAL 8351*7dc08ffcSJunyu Laiassert in6_getscope("ff01::2807") == IPV6_ADDR_LOOPBACK 8352*7dc08ffcSJunyu Laiassert in6_getscope("::1") == IPV6_ADDR_LOOPBACK 8353*7dc08ffcSJunyu Lai 8354*7dc08ffcSJunyu Lai= construct_source_candidate_set() 8355*7dc08ffcSJunyu Lai 8356*7dc08ffcSJunyu Laidev_addresses = [('fe80::', IPV6_ADDR_LINKLOCAL, "linklocal"),('fec0::', IPV6_ADDR_SITELOCAL, "sitelocal"),('ff0e::', IPV6_ADDR_GLOBAL, "global")] 8357*7dc08ffcSJunyu Lai 8358*7dc08ffcSJunyu Laiassert construct_source_candidate_set("2001:db8::2807", 0, dev_addresses) == ["ff0e::"] 8359*7dc08ffcSJunyu Laiassert construct_source_candidate_set("fec0::2807", 0, dev_addresses) == ["fec0::"] 8360*7dc08ffcSJunyu Laiassert construct_source_candidate_set("fe80::2807", 0, dev_addresses) == ["fe80::"] 8361*7dc08ffcSJunyu Laiassert construct_source_candidate_set("ff02::2807", 0, dev_addresses) == ["fe80::"] 8362*7dc08ffcSJunyu Laiassert construct_source_candidate_set("ff0e::2807", 0, dev_addresses) == ["ff0e::"] 8363*7dc08ffcSJunyu Laiassert construct_source_candidate_set("ff05::2807", 0, dev_addresses) == ["fec0::"] 8364*7dc08ffcSJunyu Laiassert construct_source_candidate_set("ff01::2807", 0, dev_addresses) == ["::1"] 8365*7dc08ffcSJunyu Laiassert construct_source_candidate_set("::", 0, dev_addresses) == ["ff0e::"] 8366*7dc08ffcSJunyu Lai 8367*7dc08ffcSJunyu Lai= inet_pton() 8368*7dc08ffcSJunyu Lai 8369*7dc08ffcSJunyu Laifrom scapy.pton_ntop import _inet6_pton, inet_pton 8370*7dc08ffcSJunyu Laiimport socket 8371*7dc08ffcSJunyu Lai 8372*7dc08ffcSJunyu Laiip6_bad_addrs = ["fe80::2e67:ef2d:7eca::ed8a", 8373*7dc08ffcSJunyu Lai "fe80:1234:abcd::192.168.40.12:abcd", 8374*7dc08ffcSJunyu Lai "fe80:1234:abcd::192.168.40", 8375*7dc08ffcSJunyu Lai "fe80:1234:abcd::192.168.400.12", 8376*7dc08ffcSJunyu Lai "1234:5678:9abc:def0:1234:5678:9abc:def0:", 8377*7dc08ffcSJunyu Lai "1234:5678:9abc:def0:1234:5678:9abc:def0:1234"] 8378*7dc08ffcSJunyu Laifor ip6 in ip6_bad_addrs: 8379*7dc08ffcSJunyu Lai rc = False 8380*7dc08ffcSJunyu Lai exc1 = None 8381*7dc08ffcSJunyu Lai try: 8382*7dc08ffcSJunyu Lai res1 = inet_pton(socket.AF_INET6, ip6) 8383*7dc08ffcSJunyu Lai except Exception as e: 8384*7dc08ffcSJunyu Lai rc = True 8385*7dc08ffcSJunyu Lai exc1 = e 8386*7dc08ffcSJunyu Lai assert rc 8387*7dc08ffcSJunyu Lai rc = False 8388*7dc08ffcSJunyu Lai try: 8389*7dc08ffcSJunyu Lai res2 = _inet6_pton(ip6) 8390*7dc08ffcSJunyu Lai except Exception as exc2: 8391*7dc08ffcSJunyu Lai rc = isinstance(exc2, type(exc1)) 8392*7dc08ffcSJunyu Lai assert rc 8393*7dc08ffcSJunyu Lai 8394*7dc08ffcSJunyu Laiip6_good_addrs = [("fe80:1234:abcd::192.168.40.12", 8395*7dc08ffcSJunyu Lai b'\xfe\x80\x124\xab\xcd\x00\x00\x00\x00\x00\x00\xc0\xa8(\x0c'), 8396*7dc08ffcSJunyu Lai ("fe80:1234:abcd::fe06", 8397*7dc08ffcSJunyu Lai b'\xfe\x80\x124\xab\xcd\x00\x00\x00\x00\x00\x00\x00\x00\xfe\x06'), 8398*7dc08ffcSJunyu Lai ("fe80::2e67:ef2d:7ece:ed8a", 8399*7dc08ffcSJunyu Lai b'\xfe\x80\x00\x00\x00\x00\x00\x00.g\xef-~\xce\xed\x8a'), 8400*7dc08ffcSJunyu Lai ("::ffff", 8401*7dc08ffcSJunyu Lai b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff'), 8402*7dc08ffcSJunyu Lai ("ffff::", 8403*7dc08ffcSJunyu Lai b'\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), 8404*7dc08ffcSJunyu Lai ('::', b'\x00' * 16)] 8405*7dc08ffcSJunyu Laifor ip6, res in ip6_good_addrs: 8406*7dc08ffcSJunyu Lai res1 = inet_pton(socket.AF_INET6, ip6) 8407*7dc08ffcSJunyu Lai res2 = _inet6_pton(ip6) 8408*7dc08ffcSJunyu Lai assert res == res1 == res2 8409*7dc08ffcSJunyu Lai 8410*7dc08ffcSJunyu Lai 8411*7dc08ffcSJunyu Lai############ 8412*7dc08ffcSJunyu Lai############ 8413*7dc08ffcSJunyu Lai+ Test Route class 8414*7dc08ffcSJunyu Lai 8415*7dc08ffcSJunyu Lai= make_route() 8416*7dc08ffcSJunyu Lai 8417*7dc08ffcSJunyu Lair4 = Route() 8418*7dc08ffcSJunyu Laitmp_route = r4.make_route(host="10.12.13.14") 8419*7dc08ffcSJunyu Lai(tmp_route[0], tmp_route[1], tmp_route[2]) == (168561934, 4294967295, '0.0.0.0') 8420*7dc08ffcSJunyu Lai 8421*7dc08ffcSJunyu Laitmp_route = r4.make_route(net="10.12.13.0/24") 8422*7dc08ffcSJunyu Lai(tmp_route[0], tmp_route[1], tmp_route[2]) == (168561920, 4294967040, '0.0.0.0') 8423*7dc08ffcSJunyu Lai 8424*7dc08ffcSJunyu Lai= add() & delt() 8425*7dc08ffcSJunyu Lai 8426*7dc08ffcSJunyu Lair4 = Route() 8427*7dc08ffcSJunyu Lailen_r4 = len(r4.routes) 8428*7dc08ffcSJunyu Lair4.add(net="192.168.1.0/24", gw="1.2.3.4") 8429*7dc08ffcSJunyu Lailen(r4.routes) == len_r4 + 1 8430*7dc08ffcSJunyu Lair4.delt(net="192.168.1.0/24", gw="1.2.3.4") 8431*7dc08ffcSJunyu Lailen(r4.routes) == len_r4 8432*7dc08ffcSJunyu Lai 8433*7dc08ffcSJunyu Lai= ifchange() 8434*7dc08ffcSJunyu Lai 8435*7dc08ffcSJunyu Lair4.add(net="192.168.1.0/24", gw="1.2.3.4", dev=get_dummy_interface()) 8436*7dc08ffcSJunyu Lair4.ifchange(get_dummy_interface(), "5.6.7.8") 8437*7dc08ffcSJunyu Lair4.routes[-1][4] == "5.6.7.8" 8438*7dc08ffcSJunyu Lai 8439*7dc08ffcSJunyu Lai= ifdel() 8440*7dc08ffcSJunyu Lai 8441*7dc08ffcSJunyu Lair4.ifdel(get_dummy_interface()) 8442*7dc08ffcSJunyu Lailen(r4.routes) == len_r4 8443*7dc08ffcSJunyu Lai 8444*7dc08ffcSJunyu Lai= ifadd() & get_if_bcast() 8445*7dc08ffcSJunyu Lai 8446*7dc08ffcSJunyu Lair4 = Route() 8447*7dc08ffcSJunyu Lailen_r4 = len(r4.routes) 8448*7dc08ffcSJunyu Lai 8449*7dc08ffcSJunyu Lair4.ifadd(get_dummy_interface(), "1.2.3.4/24") 8450*7dc08ffcSJunyu Lailen(r4.routes) == len_r4 +1 8451*7dc08ffcSJunyu Lai 8452*7dc08ffcSJunyu Lair4.get_if_bcast(get_dummy_interface()) == "1.2.3.255" 8453*7dc08ffcSJunyu Lai 8454*7dc08ffcSJunyu Lair4.ifdel(get_dummy_interface()) 8455*7dc08ffcSJunyu Lailen(r4.routes) == len_r4 8456*7dc08ffcSJunyu Lai 8457*7dc08ffcSJunyu Lai 8458*7dc08ffcSJunyu Lai############ 8459*7dc08ffcSJunyu Lai############ 8460*7dc08ffcSJunyu Lai+ Random objects 8461*7dc08ffcSJunyu Lai 8462*7dc08ffcSJunyu Lai= RandomEnumeration 8463*7dc08ffcSJunyu Lai 8464*7dc08ffcSJunyu Laire = RandomEnumeration(0, 7, seed=0x2807, forever=False) 8465*7dc08ffcSJunyu Lai[x for x in re] == ([3, 4, 2, 5, 1, 6, 0, 7] if six.PY2 else [5, 0, 2, 7, 6, 3, 1, 4]) 8466*7dc08ffcSJunyu Lai 8467*7dc08ffcSJunyu Lai= RandIP6 8468*7dc08ffcSJunyu Lai 8469*7dc08ffcSJunyu Lairandom.seed(0x2807) 8470*7dc08ffcSJunyu Lair6 = RandIP6() 8471*7dc08ffcSJunyu Laiassert(r6 == ("d279:1205:e445:5a9f:db28:efc9:afd7:f594" if six.PY2 else 8472*7dc08ffcSJunyu Lai "240b:238f:b53f:b727:d0f9:bfc4:2007:e265")) 8473*7dc08ffcSJunyu Lai 8474*7dc08ffcSJunyu Lairandom.seed(0x2807) 8475*7dc08ffcSJunyu Lair6 = RandIP6("2001:db8::-") 8476*7dc08ffcSJunyu Laiassert(r6 == ("2001:0db8::e445" if six.PY2 else "2001:0db8::b53f")) 8477*7dc08ffcSJunyu Lai 8478*7dc08ffcSJunyu Lair6 = RandIP6("2001:db8::*") 8479*7dc08ffcSJunyu Laiassert(r6 == ("2001:0db8::efc9" if six.PY2 else "2001:0db8::bfc4")) 8480*7dc08ffcSJunyu Lai 8481*7dc08ffcSJunyu Lai= RandMAC 8482*7dc08ffcSJunyu Lai 8483*7dc08ffcSJunyu Lairandom.seed(0x2807) 8484*7dc08ffcSJunyu Lairm = RandMAC() 8485*7dc08ffcSJunyu Laiassert(rm == ("d2:12:e4:5a:db:ef" if six.PY2 else "24:23:b5:b7:d0:bf")) 8486*7dc08ffcSJunyu Lai 8487*7dc08ffcSJunyu Lairm = RandMAC("00:01:02:03:04:0-7") 8488*7dc08ffcSJunyu Laiassert(rm == ("00:01:02:03:04:05" if six.PY2 else "00:01:02:03:04:01")) 8489*7dc08ffcSJunyu Lai 8490*7dc08ffcSJunyu Lai 8491*7dc08ffcSJunyu Lai= RandOID 8492*7dc08ffcSJunyu Lai 8493*7dc08ffcSJunyu Lairandom.seed(0x2807) 8494*7dc08ffcSJunyu Lairo = RandOID() 8495*7dc08ffcSJunyu Laiassert(ro == "7.222.44.194.276.116.320.6.84.97.31.5.25.20.13.84.104.18") 8496*7dc08ffcSJunyu Lai 8497*7dc08ffcSJunyu Lairo = RandOID("1.2.3.*") 8498*7dc08ffcSJunyu Laiassert(ro == "1.2.3.41") 8499*7dc08ffcSJunyu Lai 8500*7dc08ffcSJunyu Lairo = RandOID("1.2.3.0-28") 8501*7dc08ffcSJunyu Laiassert(ro == ("1.2.3.11" if six.PY2 else "1.2.3.12")) 8502*7dc08ffcSJunyu Lai 8503*7dc08ffcSJunyu Lai= RandRegExp 8504*7dc08ffcSJunyu Lai 8505*7dc08ffcSJunyu Lairandom.seed(0x2807) 8506*7dc08ffcSJunyu Laire = RandRegExp("[g-v]* @? [0-9]{3} . (g|v)") 8507*7dc08ffcSJunyu Laibytes(re) == ('vmuvr @ 906 \x9e g' if six.PY2 else b'irrtv @ 517 \xc2\xb8 v') 8508*7dc08ffcSJunyu Lai 8509*7dc08ffcSJunyu Lai= Corrupted(Bytes|Bits) 8510*7dc08ffcSJunyu Lai 8511*7dc08ffcSJunyu Lairandom.seed(0x2807) 8512*7dc08ffcSJunyu Laicb = CorruptedBytes("ABCDE", p=0.5) 8513*7dc08ffcSJunyu Laiassert(sane(raw(cb)) in [".BCD)", "&BCDW"]) 8514*7dc08ffcSJunyu Lai 8515*7dc08ffcSJunyu Laicb = CorruptedBits("ABCDE", p=0.2) 8516*7dc08ffcSJunyu Laiassert(sane(raw(cb)) in ["ECk@Y", "QB.P."]) 8517*7dc08ffcSJunyu Lai 8518*7dc08ffcSJunyu Lai= RandEnumKeys 8519*7dc08ffcSJunyu Lai~ not_pypy random_weird_py3 8520*7dc08ffcSJunyu Lairandom.seed(0x2807) 8521*7dc08ffcSJunyu Lairek = RandEnumKeys({'a': 1, 'b': 2, 'c': 3}, seed=0x2807) 8522*7dc08ffcSJunyu Lairek.enum.sort() 8523*7dc08ffcSJunyu Laiassert(rek == ('c' if six.PY2 else 'a')) 8524*7dc08ffcSJunyu Lai 8525*7dc08ffcSJunyu Lai= RandSingNum 8526*7dc08ffcSJunyu Lai~ not_pypy random_weird_py3 8527*7dc08ffcSJunyu Lairandom.seed(0x2807) 8528*7dc08ffcSJunyu Lairs = RandSingNum(-28, 7) 8529*7dc08ffcSJunyu Laiassert(rs == (3 if six.PY2 else 2)) 8530*7dc08ffcSJunyu Laiassert(rs == (-27 if six.PY2 else -17)) 8531*7dc08ffcSJunyu Lai 8532*7dc08ffcSJunyu Lai= Rand* 8533*7dc08ffcSJunyu Lairandom.seed(0x2807) 8534*7dc08ffcSJunyu Lairss = RandSingString() 8535*7dc08ffcSJunyu Laiassert(rss == ("CON:" if six.PY2 else "foo.exe:")) 8536*7dc08ffcSJunyu Lai 8537*7dc08ffcSJunyu Lairandom.seed(0x2807) 8538*7dc08ffcSJunyu Lairts = RandTermString(4, "scapy") 8539*7dc08ffcSJunyu Laiassert(sane(raw(rts)) in ["...[scapy", "......scapy"]) 8540*7dc08ffcSJunyu Lai 8541*7dc08ffcSJunyu Lai 8542*7dc08ffcSJunyu Lai############ 8543*7dc08ffcSJunyu Lai############ 8544*7dc08ffcSJunyu Lai+ Flags 8545*7dc08ffcSJunyu Lai 8546*7dc08ffcSJunyu Lai= IP flags 8547*7dc08ffcSJunyu Lai~ IP 8548*7dc08ffcSJunyu Lai 8549*7dc08ffcSJunyu Laipkt = IP(flags="MF") 8550*7dc08ffcSJunyu Laiassert pkt.flags.MF 8551*7dc08ffcSJunyu Laiassert not pkt.flags.DF 8552*7dc08ffcSJunyu Laiassert not pkt.flags.evil 8553*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 1 (MF)>' 8554*7dc08ffcSJunyu Laipkt.flags.MF = 0 8555*7dc08ffcSJunyu Laipkt.flags.DF = 1 8556*7dc08ffcSJunyu Laiassert not pkt.flags.MF 8557*7dc08ffcSJunyu Laiassert pkt.flags.DF 8558*7dc08ffcSJunyu Laiassert not pkt.flags.evil 8559*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 2 (DF)>' 8560*7dc08ffcSJunyu Laipkt.flags |= 'evil+MF' 8561*7dc08ffcSJunyu Laipkt.flags &= 'DF+MF' 8562*7dc08ffcSJunyu Laiassert pkt.flags.MF 8563*7dc08ffcSJunyu Laiassert pkt.flags.DF 8564*7dc08ffcSJunyu Laiassert not pkt.flags.evil 8565*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 3 (MF+DF)>' 8566*7dc08ffcSJunyu Lai 8567*7dc08ffcSJunyu Laipkt = IP(flags=3) 8568*7dc08ffcSJunyu Laiassert pkt.flags.MF 8569*7dc08ffcSJunyu Laiassert pkt.flags.DF 8570*7dc08ffcSJunyu Laiassert not pkt.flags.evil 8571*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 3 (MF+DF)>' 8572*7dc08ffcSJunyu Laipkt.flags = 6 8573*7dc08ffcSJunyu Laiassert not pkt.flags.MF 8574*7dc08ffcSJunyu Laiassert pkt.flags.DF 8575*7dc08ffcSJunyu Laiassert pkt.flags.evil 8576*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 6 (DF+evil)>' 8577*7dc08ffcSJunyu Lai 8578*7dc08ffcSJunyu Laiassert len({IP().flags, IP().flags}) == 1 8579*7dc08ffcSJunyu Lai 8580*7dc08ffcSJunyu Lai= TCP flags 8581*7dc08ffcSJunyu Lai~ TCP 8582*7dc08ffcSJunyu Lai 8583*7dc08ffcSJunyu Laipkt = TCP(flags="SA") 8584*7dc08ffcSJunyu Laiassert pkt.flags == 18 8585*7dc08ffcSJunyu Laiassert pkt.flags.S 8586*7dc08ffcSJunyu Laiassert pkt.flags.A 8587*7dc08ffcSJunyu Laiassert pkt.flags.SA 8588*7dc08ffcSJunyu Laiassert not any(getattr(pkt.flags, f) for f in 'FRPUECN') 8589*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 18 (SA)>' 8590*7dc08ffcSJunyu Laipkt.flags.U = True 8591*7dc08ffcSJunyu Laipkt.flags.S = False 8592*7dc08ffcSJunyu Laiassert pkt.flags.A 8593*7dc08ffcSJunyu Laiassert pkt.flags.U 8594*7dc08ffcSJunyu Laiassert pkt.flags.AU 8595*7dc08ffcSJunyu Laiassert not any(getattr(pkt.flags, f) for f in 'FSRPECN') 8596*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 48 (AU)>' 8597*7dc08ffcSJunyu Laipkt.flags &= 'SFA' 8598*7dc08ffcSJunyu Laipkt.flags |= 'P' 8599*7dc08ffcSJunyu Laiassert pkt.flags.P 8600*7dc08ffcSJunyu Laiassert pkt.flags.A 8601*7dc08ffcSJunyu Laiassert pkt.flags.PA 8602*7dc08ffcSJunyu Laiassert not any(getattr(pkt.flags, f) for f in 'FSRUECN') 8603*7dc08ffcSJunyu Lai 8604*7dc08ffcSJunyu Laipkt = TCP(flags=56) 8605*7dc08ffcSJunyu Laiassert all(getattr(pkt.flags, f) for f in 'PAU') 8606*7dc08ffcSJunyu Laiassert pkt.flags.PAU 8607*7dc08ffcSJunyu Laiassert not any(getattr(pkt.flags, f) for f in 'FSRECN') 8608*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 56 (PAU)>' 8609*7dc08ffcSJunyu Laipkt.flags = 50 8610*7dc08ffcSJunyu Laiassert all(getattr(pkt.flags, f) for f in 'SAU') 8611*7dc08ffcSJunyu Laiassert pkt.flags.SAU 8612*7dc08ffcSJunyu Laiassert not any(getattr(pkt.flags, f) for f in 'FRPECN') 8613*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 50 (SAU)>' 8614*7dc08ffcSJunyu Lai 8615*7dc08ffcSJunyu Lai= Flag values mutation with .raw_packet_cache 8616*7dc08ffcSJunyu Lai~ IP TCP 8617*7dc08ffcSJunyu Lai 8618*7dc08ffcSJunyu Laipkt = IP(raw(IP(flags="MF")/TCP(flags="SA"))) 8619*7dc08ffcSJunyu Laiassert pkt.raw_packet_cache is not None 8620*7dc08ffcSJunyu Laiassert pkt[TCP].raw_packet_cache is not None 8621*7dc08ffcSJunyu Laiassert pkt.flags.MF 8622*7dc08ffcSJunyu Laiassert not pkt.flags.DF 8623*7dc08ffcSJunyu Laiassert not pkt.flags.evil 8624*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 1 (MF)>' 8625*7dc08ffcSJunyu Laiassert pkt[TCP].flags.S 8626*7dc08ffcSJunyu Laiassert pkt[TCP].flags.A 8627*7dc08ffcSJunyu Laiassert pkt[TCP].flags.SA 8628*7dc08ffcSJunyu Laiassert not any(getattr(pkt[TCP].flags, f) for f in 'FRPUECN') 8629*7dc08ffcSJunyu Laiassert repr(pkt[TCP].flags) == '<Flag 18 (SA)>' 8630*7dc08ffcSJunyu Laipkt.flags.MF = 0 8631*7dc08ffcSJunyu Laipkt.flags.DF = 1 8632*7dc08ffcSJunyu Laipkt[TCP].flags.U = True 8633*7dc08ffcSJunyu Laipkt[TCP].flags.S = False 8634*7dc08ffcSJunyu Laipkt = IP(raw(pkt)) 8635*7dc08ffcSJunyu Laiassert not pkt.flags.MF 8636*7dc08ffcSJunyu Laiassert pkt.flags.DF 8637*7dc08ffcSJunyu Laiassert not pkt.flags.evil 8638*7dc08ffcSJunyu Laiassert repr(pkt.flags) == '<Flag 2 (DF)>' 8639*7dc08ffcSJunyu Laiassert pkt[TCP].flags.A 8640*7dc08ffcSJunyu Laiassert pkt[TCP].flags.U 8641*7dc08ffcSJunyu Laiassert pkt[TCP].flags.AU 8642*7dc08ffcSJunyu Laiassert not any(getattr(pkt[TCP].flags, f) for f in 'FSRPECN') 8643*7dc08ffcSJunyu Laiassert repr(pkt[TCP].flags) == '<Flag 48 (AU)>' 8644*7dc08ffcSJunyu Lai 8645*7dc08ffcSJunyu Lai= Operations on flag values 8646*7dc08ffcSJunyu Lai~ TCP 8647*7dc08ffcSJunyu Lai 8648*7dc08ffcSJunyu Laip1, p2 = TCP(flags="SU"), TCP(flags="AU") 8649*7dc08ffcSJunyu Laiassert (p1.flags & p2.flags).U 8650*7dc08ffcSJunyu Laiassert not any(getattr(p1.flags & p2.flags, f) for f in 'FSRPAECN') 8651*7dc08ffcSJunyu Laiassert all(getattr(p1.flags | p2.flags, f) for f in 'SAU') 8652*7dc08ffcSJunyu Laiassert (p1.flags | p2.flags).SAU 8653*7dc08ffcSJunyu Laiassert not any(getattr(p1.flags | p2.flags, f) for f in 'FRPECN') 8654*7dc08ffcSJunyu Lai 8655*7dc08ffcSJunyu Laiassert TCP(flags="SA").flags & TCP(flags="S").flags == TCP(flags="S").flags 8656*7dc08ffcSJunyu Laiassert TCP(flags="SA").flags | TCP(flags="S").flags == TCP(flags="SA").flags 8657*7dc08ffcSJunyu Lai 8658*7dc08ffcSJunyu Lai= Using tuples and lists as flag values 8659*7dc08ffcSJunyu Lai~ IP TCP 8660*7dc08ffcSJunyu Lai 8661*7dc08ffcSJunyu Laiplist = PacketList(list(IP()/TCP(flags=(0, 2**9 - 1)))) 8662*7dc08ffcSJunyu Laiassert [p[TCP].flags for p in plist] == [x for x in range(512)] 8663*7dc08ffcSJunyu Lai 8664*7dc08ffcSJunyu Laiplist = PacketList(list(IP()/TCP(flags=["S", "SA", "A"]))) 8665*7dc08ffcSJunyu Laiassert [p[TCP].flags for p in plist] == [2, 18, 16] 8666*7dc08ffcSJunyu Lai 8667*7dc08ffcSJunyu Lai 8668*7dc08ffcSJunyu Lai############ 8669*7dc08ffcSJunyu Lai############ 8670*7dc08ffcSJunyu Lai+ SCTP 8671*7dc08ffcSJunyu Lai 8672*7dc08ffcSJunyu Lai= SCTP - Chunk Init - build 8673*7dc08ffcSJunyu Lais = raw(IP()/SCTP()/SCTPChunkInit(params=[SCTPChunkParamIPv4Addr()])) 8674*7dc08ffcSJunyu Lais == b'E\x00\x00<\x00\x01\x00\x00@\x84|;\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00@,\x0b_\x01\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x08\x7f\x00\x00\x01' 8675*7dc08ffcSJunyu Lai 8676*7dc08ffcSJunyu Lai= SCTP - Chunk Init - dissection 8677*7dc08ffcSJunyu Laip = IP(s) 8678*7dc08ffcSJunyu LaiSCTPChunkParamIPv4Addr in p and p[SCTP].chksum == 0x402c0b5f and p[SCTPChunkParamIPv4Addr].addr == "127.0.0.1" 8679*7dc08ffcSJunyu Lai 8680*7dc08ffcSJunyu Lai= SCTP - SCTPChunkSACK - build 8681*7dc08ffcSJunyu Lais = raw(IP()/SCTP()/SCTPChunkSACK(gap_ack_list=["7:28"])) 8682*7dc08ffcSJunyu Lais == b'E\x00\x004\x00\x01\x00\x00@\x84|C\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00;\x01\xd4\x04\x03\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x07\x00\x1c' 8683*7dc08ffcSJunyu Lai 8684*7dc08ffcSJunyu Lai= SCTP - SCTPChunkSACK - dissection 8685*7dc08ffcSJunyu Laip = IP(s) 8686*7dc08ffcSJunyu LaiSCTPChunkSACK in p and p[SCTP].chksum == 0x3b01d404 and p[SCTPChunkSACK].gap_ack_list[0] == "7:28" 8687*7dc08ffcSJunyu Lai 8688*7dc08ffcSJunyu Lai= SCTP - answers 8689*7dc08ffcSJunyu Lai(IP()/SCTP()).answers(IP()/SCTP()) == True 8690*7dc08ffcSJunyu Lai 8691*7dc08ffcSJunyu Lai= SCTP basic header - Dissection 8692*7dc08ffcSJunyu Lai~ sctp 8693*7dc08ffcSJunyu Laiblob = b"\x1A\x85\x26\x94\x00\x00\x00\x0D\x00\x00\x04\xD2" 8694*7dc08ffcSJunyu Laip = SCTP(blob) 8695*7dc08ffcSJunyu Laiassert(p.dport == 9876) 8696*7dc08ffcSJunyu Laiassert(p.sport == 6789) 8697*7dc08ffcSJunyu Laiassert(p.tag == 13) 8698*7dc08ffcSJunyu Laiassert(p.chksum == 1234) 8699*7dc08ffcSJunyu Lai 8700*7dc08ffcSJunyu Lai= basic SCTPChunkData - Dissection 8701*7dc08ffcSJunyu Lai~ sctp 8702*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\x61\x74\x61" 8703*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8704*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkData)) 8705*7dc08ffcSJunyu Laiassert(p.reserved == 0) 8706*7dc08ffcSJunyu Laiassert(p.delay_sack == 0) 8707*7dc08ffcSJunyu Laiassert(p.unordered == 0) 8708*7dc08ffcSJunyu Laiassert(p.beginning == 0) 8709*7dc08ffcSJunyu Laiassert(p.ending == 0) 8710*7dc08ffcSJunyu Laiassert(p.tsn == 0) 8711*7dc08ffcSJunyu Laiassert(p.stream_id == 0) 8712*7dc08ffcSJunyu Laiassert(p.stream_seq == 0) 8713*7dc08ffcSJunyu Laiassert(p.len == (len("data") + 16)) 8714*7dc08ffcSJunyu Laiassert(p.data == b"data") 8715*7dc08ffcSJunyu Lai 8716*7dc08ffcSJunyu Lai= basic SCTPChunkInit - Dissection 8717*7dc08ffcSJunyu Lai~ sctp 8718*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 8719*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8720*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkInit)) 8721*7dc08ffcSJunyu Laiassert(p.flags == 0) 8722*7dc08ffcSJunyu Laiassert(p.len == 20) 8723*7dc08ffcSJunyu Laiassert(p.init_tag == 0) 8724*7dc08ffcSJunyu Laiassert(p.a_rwnd == 0) 8725*7dc08ffcSJunyu Laiassert(p.n_out_streams == 0) 8726*7dc08ffcSJunyu Laiassert(p.n_in_streams == 0) 8727*7dc08ffcSJunyu Laiassert(p.init_tsn == 0) 8728*7dc08ffcSJunyu Laiassert(p.params == []) 8729*7dc08ffcSJunyu Lai 8730*7dc08ffcSJunyu Lai= SCTPChunkInit multiple valid parameters - Dissection 8731*7dc08ffcSJunyu Lai~ sctp 8732*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x5C\x00\x00\x00\x65\x00\x00\x00\x66\x00\x67\x00\x68\x00\x00\x00\x69\x00\x0C\x00\x06\x00\x05\x00\x00\x80\x00\x00\x04\xC0\x00\x00\x04\x80\x08\x00\x07\x0F\xC1\x80\x00\x80\x03\x00\x04\x80\x02\x00\x24\x87\x77\x21\x29\x3F\xDA\x62\x0C\x06\x6F\x10\xA5\x39\x58\x60\x98\x4C\xD4\x59\xD8\x8A\x00\x85\xFB\x9E\x2E\x66\xBA\x3A\x23\x54\xEF\x80\x04\x00\x06\x00\x01\x00\x00" 8733*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8734*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkInit)) 8735*7dc08ffcSJunyu Laiassert(p.flags == 0) 8736*7dc08ffcSJunyu Laiassert(p.len == 92) 8737*7dc08ffcSJunyu Laiassert(p.init_tag == 101) 8738*7dc08ffcSJunyu Laiassert(p.a_rwnd == 102) 8739*7dc08ffcSJunyu Laiassert(p.n_out_streams == 103) 8740*7dc08ffcSJunyu Laiassert(p.n_in_streams == 104) 8741*7dc08ffcSJunyu Laiassert(p.init_tsn == 105) 8742*7dc08ffcSJunyu Laiassert(len(p.params) == 7) 8743*7dc08ffcSJunyu Laiparams = {type(param): param for param in p.params} 8744*7dc08ffcSJunyu Laiassert(set(params.keys()) == {SCTPChunkParamECNCapable, SCTPChunkParamFwdTSN, 8745*7dc08ffcSJunyu Lai SCTPChunkParamSupportedExtensions, SCTPChunkParamChunkList, 8746*7dc08ffcSJunyu Lai SCTPChunkParamRandom, SCTPChunkParamRequestedHMACFunctions, 8747*7dc08ffcSJunyu Lai SCTPChunkParamSupportedAddrTypes}) 8748*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamECNCapable] == SCTPChunkParamECNCapable()) 8749*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamFwdTSN] == SCTPChunkParamFwdTSN()) 8750*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamSupportedExtensions] == SCTPChunkParamSupportedExtensions(len=7)) 8751*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamChunkList] == SCTPChunkParamChunkList(len=4)) 8752*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamRandom].len == 4+32) 8753*7dc08ffcSJunyu Laiassert(len(params[SCTPChunkParamRandom].random) == 32) 8754*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamRequestedHMACFunctions] == SCTPChunkParamRequestedHMACFunctions(len=6)) 8755*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamSupportedAddrTypes] == SCTPChunkParamSupportedAddrTypes(len=6)) 8756*7dc08ffcSJunyu Lai 8757*7dc08ffcSJunyu Lai= basic SCTPChunkInitAck - Dissection 8758*7dc08ffcSJunyu Lai~ sctp 8759*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 8760*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8761*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkInitAck)) 8762*7dc08ffcSJunyu Laiassert(p.flags == 0) 8763*7dc08ffcSJunyu Laiassert(p.len == 20) 8764*7dc08ffcSJunyu Laiassert(p.init_tag == 0) 8765*7dc08ffcSJunyu Laiassert(p.a_rwnd == 0) 8766*7dc08ffcSJunyu Laiassert(p.n_out_streams == 0) 8767*7dc08ffcSJunyu Laiassert(p.n_in_streams == 0) 8768*7dc08ffcSJunyu Laiassert(p.init_tsn == 0) 8769*7dc08ffcSJunyu Laiassert(p.params == []) 8770*7dc08ffcSJunyu Lai 8771*7dc08ffcSJunyu Lai= SCTPChunkInitAck with state cookie - Dissection 8772*7dc08ffcSJunyu Lai~ sctp 8773*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x4C\x00\x00\x00\x65\x00\x00\x00\x66\x00\x67\x00\x68\x00\x00\x00\x69\x80\x00\x00\x04\x00\x0B\x00\x0D\x6C\x6F\x63\x61\x6C\x68\x6F\x73\x74\x00\x00\x00\xC0\x00\x00\x04\x80\x08\x00\x07\x0F\xC1\x80\x00\x00\x07\x00\x14\x00\x10\x9E\xB2\x86\xCE\xE1\x7D\x0F\x6A\xAD\xFD\xB3\x5D\xBC\x00" 8774*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8775*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkInitAck)) 8776*7dc08ffcSJunyu Laiassert(p.flags == 0) 8777*7dc08ffcSJunyu Laiassert(p.len == 76) 8778*7dc08ffcSJunyu Laiassert(p.init_tag == 101) 8779*7dc08ffcSJunyu Laiassert(p.a_rwnd == 102) 8780*7dc08ffcSJunyu Laiassert(p.n_out_streams == 103) 8781*7dc08ffcSJunyu Laiassert(p.n_in_streams == 104) 8782*7dc08ffcSJunyu Laiassert(p.init_tsn == 105) 8783*7dc08ffcSJunyu Laiassert(len(p.params) == 5) 8784*7dc08ffcSJunyu Laiparams = {type(param): param for param in p.params} 8785*7dc08ffcSJunyu Laiassert(set(params.keys()) == {SCTPChunkParamECNCapable, SCTPChunkParamHostname, 8786*7dc08ffcSJunyu Lai SCTPChunkParamFwdTSN, SCTPChunkParamSupportedExtensions, 8787*7dc08ffcSJunyu Lai SCTPChunkParamStateCookie}) 8788*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamECNCapable] == SCTPChunkParamECNCapable()) 8789*7dc08ffcSJunyu Laiassert(raw(params[SCTPChunkParamHostname]) == raw(SCTPChunkParamHostname(len=13, hostname="localhost"))) 8790*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamFwdTSN] == SCTPChunkParamFwdTSN()) 8791*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamSupportedExtensions] == SCTPChunkParamSupportedExtensions(len=7)) 8792*7dc08ffcSJunyu Laiassert(params[SCTPChunkParamStateCookie].len == 4+16) 8793*7dc08ffcSJunyu Laiassert(len(params[SCTPChunkParamStateCookie].cookie) == 16) 8794*7dc08ffcSJunyu Lai 8795*7dc08ffcSJunyu Lai= basic SCTPChunkSACK - Dissection 8796*7dc08ffcSJunyu Lai~ sctp 8797*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 8798*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8799*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkSACK)) 8800*7dc08ffcSJunyu Laiassert(p.flags == 0) 8801*7dc08ffcSJunyu Laiassert(p.len == 16) 8802*7dc08ffcSJunyu Laiassert(p.cumul_tsn_ack == 0) 8803*7dc08ffcSJunyu Laiassert(p.a_rwnd == 0) 8804*7dc08ffcSJunyu Laiassert(p.n_gap_ack == 0) 8805*7dc08ffcSJunyu Laiassert(p.n_dup_tsn == 0) 8806*7dc08ffcSJunyu Laiassert(p.gap_ack_list == []) 8807*7dc08ffcSJunyu Laiassert(p.dup_tsn_list == []) 8808*7dc08ffcSJunyu Lai 8809*7dc08ffcSJunyu Lai= basic SCTPChunkHeartbeatReq - Dissection 8810*7dc08ffcSJunyu Lai~ sctp 8811*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x04" 8812*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8813*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkHeartbeatReq)) 8814*7dc08ffcSJunyu Laiassert(p.flags == 0) 8815*7dc08ffcSJunyu Laiassert(p.len == 4) 8816*7dc08ffcSJunyu Laiassert(p.params == []) 8817*7dc08ffcSJunyu Lai 8818*7dc08ffcSJunyu Lai= basic SCTPChunkHeartbeatAck - Dissection 8819*7dc08ffcSJunyu Lai~ sctp 8820*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x04" 8821*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8822*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkHeartbeatAck)) 8823*7dc08ffcSJunyu Laiassert(p.flags == 0) 8824*7dc08ffcSJunyu Laiassert(p.len == 4) 8825*7dc08ffcSJunyu Laiassert(p.params == []) 8826*7dc08ffcSJunyu Lai 8827*7dc08ffcSJunyu Lai= basic SCTPChunkAbort - Dissection 8828*7dc08ffcSJunyu Lai~ sctp 8829*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x04" 8830*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8831*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkAbort)) 8832*7dc08ffcSJunyu Laiassert(p.reserved == 0) 8833*7dc08ffcSJunyu Laiassert(p.TCB == 0) 8834*7dc08ffcSJunyu Laiassert(p.len == 4) 8835*7dc08ffcSJunyu Laiassert(p.error_causes == b"") 8836*7dc08ffcSJunyu Lai 8837*7dc08ffcSJunyu Lai= basic SCTPChunkShutDown - Dissection 8838*7dc08ffcSJunyu Lai~ sctp 8839*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x08\x00\x00\x00\x00" 8840*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8841*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkShutdown)) 8842*7dc08ffcSJunyu Laiassert(p.flags == 0) 8843*7dc08ffcSJunyu Laiassert(p.len == 8) 8844*7dc08ffcSJunyu Laiassert(p.cumul_tsn_ack == 0) 8845*7dc08ffcSJunyu Lai 8846*7dc08ffcSJunyu Lai= basic SCTPChunkShutDownAck - Dissection 8847*7dc08ffcSJunyu Lai~ sctp 8848*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x04" 8849*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8850*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkShutdownAck)) 8851*7dc08ffcSJunyu Laiassert(p.flags == 0) 8852*7dc08ffcSJunyu Laiassert(p.len == 4) 8853*7dc08ffcSJunyu Lai 8854*7dc08ffcSJunyu Lai= basic SCTPChunkError - Dissection 8855*7dc08ffcSJunyu Lai~ sctp 8856*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x04" 8857*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8858*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkError)) 8859*7dc08ffcSJunyu Laiassert(p.flags == 0) 8860*7dc08ffcSJunyu Laiassert(p.len == 4) 8861*7dc08ffcSJunyu Laiassert(p.error_causes == b"") 8862*7dc08ffcSJunyu Lai 8863*7dc08ffcSJunyu Lai= basic SCTPChunkCookieEcho - Dissection 8864*7dc08ffcSJunyu Lai~ sctp 8865*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0A\x00\x00\x04" 8866*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8867*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkCookieEcho)) 8868*7dc08ffcSJunyu Laiassert(p.flags == 0) 8869*7dc08ffcSJunyu Laiassert(p.len == 4) 8870*7dc08ffcSJunyu Laiassert(p.cookie == b"") 8871*7dc08ffcSJunyu Lai 8872*7dc08ffcSJunyu Lai= basic SCTPChunkCookieAck - Dissection 8873*7dc08ffcSJunyu Lai~ sctp 8874*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0B\x00\x00\x04" 8875*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8876*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkCookieAck)) 8877*7dc08ffcSJunyu Laiassert(p.flags == 0) 8878*7dc08ffcSJunyu Laiassert(p.len == 4) 8879*7dc08ffcSJunyu Lai 8880*7dc08ffcSJunyu Lai= basic SCTPChunkShutdownComplete - Dissection 8881*7dc08ffcSJunyu Lai~ sctp 8882*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0E\x00\x00\x04" 8883*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8884*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkShutdownComplete)) 8885*7dc08ffcSJunyu Laiassert(p.reserved == 0) 8886*7dc08ffcSJunyu Laiassert(p.TCB == 0) 8887*7dc08ffcSJunyu Laiassert(p.len == 4) 8888*7dc08ffcSJunyu Lai 8889*7dc08ffcSJunyu Lai= basic SCTPChunkAuthentication - Dissection 8890*7dc08ffcSJunyu Lai~ sctp 8891*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x08\x00\x00\x00\x00" 8892*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8893*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkAuthentication)) 8894*7dc08ffcSJunyu Laiassert(p.flags == 0) 8895*7dc08ffcSJunyu Laiassert(p.len == 8) 8896*7dc08ffcSJunyu Laiassert(p.shared_key_id == 0) 8897*7dc08ffcSJunyu Laiassert(p.HMAC_function == 0) 8898*7dc08ffcSJunyu Lai 8899*7dc08ffcSJunyu Lai= basic SCTPChunkAddressConf - Dissection 8900*7dc08ffcSJunyu Lai~ sctp 8901*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc1\x00\x00\x08\x00\x00\x00\x00" 8902*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8903*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkAddressConf)) 8904*7dc08ffcSJunyu Laiassert(p.flags == 0) 8905*7dc08ffcSJunyu Laiassert(p.len == 8) 8906*7dc08ffcSJunyu Laiassert(p.seq == 0) 8907*7dc08ffcSJunyu Laiassert(p.params == []) 8908*7dc08ffcSJunyu Lai 8909*7dc08ffcSJunyu Lai= basic SCTPChunkAddressConfAck - Dissection 8910*7dc08ffcSJunyu Lai~ sctp 8911*7dc08ffcSJunyu Laiblob = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x08\x00\x00\x00\x00" 8912*7dc08ffcSJunyu Laip = SCTP(blob).lastlayer() 8913*7dc08ffcSJunyu Laiassert(isinstance(p, SCTPChunkAddressConfAck)) 8914*7dc08ffcSJunyu Laiassert(p.flags == 0) 8915*7dc08ffcSJunyu Laiassert(p.len == 8) 8916*7dc08ffcSJunyu Laiassert(p.seq == 0) 8917*7dc08ffcSJunyu Laiassert(p.params == []) 8918*7dc08ffcSJunyu Lai 8919*7dc08ffcSJunyu Lai= SCTPChunkParamRandom - Consecutive calls 8920*7dc08ffcSJunyu Lai~ sctp 8921*7dc08ffcSJunyu Laiparam1, param2 = SCTPChunkParamRandom(), SCTPChunkParamRandom() 8922*7dc08ffcSJunyu Laiassert(param1.random != param2.random) 8923*7dc08ffcSJunyu Lai 8924*7dc08ffcSJunyu Lai############ 8925*7dc08ffcSJunyu Lai############ 8926*7dc08ffcSJunyu Lai+ DHCP 8927*7dc08ffcSJunyu Lai 8928*7dc08ffcSJunyu Lai= BOOTP - misc 8929*7dc08ffcSJunyu LaiBOOTP().answers(BOOTP()) == True 8930*7dc08ffcSJunyu LaiBOOTP().hashret() == b"\x00\x00\x00\x00" 8931*7dc08ffcSJunyu Lai 8932*7dc08ffcSJunyu Laiimport random 8933*7dc08ffcSJunyu Lairandom.seed(0x2807) 8934*7dc08ffcSJunyu Laistr(RandDHCPOptions()) == "[('WWW_server', '90.219.239.175')]" 8935*7dc08ffcSJunyu Lai 8936*7dc08ffcSJunyu Laivalue = ("hostname", "scapy") 8937*7dc08ffcSJunyu Laidof = DHCPOptionsField("options", value) 8938*7dc08ffcSJunyu Laidof.i2repr("", value) == '[hostname scapy]' 8939*7dc08ffcSJunyu Laidof.i2m("", value) == b'\x0cscapy' 8940*7dc08ffcSJunyu Lai 8941*7dc08ffcSJunyu Laiunknown_value_end = b"\xfe" + b"\xff"*257 8942*7dc08ffcSJunyu Laiudof = DHCPOptionsField("options", unknown_value_end) 8943*7dc08ffcSJunyu Laiudof.m2i("", unknown_value_end) == [(254, b'\xff'*255), 'end'] 8944*7dc08ffcSJunyu Lai 8945*7dc08ffcSJunyu Laiunknown_value_pad = b"\xfe" + b"\xff"*256 + b"\x00" 8946*7dc08ffcSJunyu Laiudof = DHCPOptionsField("options", unknown_value_pad) 8947*7dc08ffcSJunyu Laiudof.m2i("", unknown_value_pad) == [(254, b'\xff'*255), 'pad'] 8948*7dc08ffcSJunyu Lai 8949*7dc08ffcSJunyu Lai= DHCP - build 8950*7dc08ffcSJunyu Lais = raw(IP(src="127.0.0.1")/UDP()/BOOTP(chaddr="00:01:02:03:04:05")/DHCP(options=[("message-type","discover"),"end"])) 8951*7dc08ffcSJunyu Laiassert s == b'E\x00\x01\x10\x00\x01\x00\x00@\x11{\xda\x7f\x00\x00\x01\x7f\x00\x00\x01\x00C\x00D\x00\xfcf\xea\x01\x01\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0000:01:02:03:04:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x82Sc5\x01\x01\xff' 8952*7dc08ffcSJunyu Lai 8953*7dc08ffcSJunyu Lais2 = raw(IP(src="127.0.0.1")/UDP()/BOOTP(chaddr="05:04:03:02:01:00")/DHCP(options=[("param_req_list",[12,57,45,254]),("requested_addr", "192.168.0.1"),"end"])) 8954*7dc08ffcSJunyu Laiassert s2 == b'E\x00\x01\x19\x00\x01\x00\x00@\x11{\xd1\x7f\x00\x00\x01\x7f\x00\x00\x01\x00C\x00D\x01\x058\xeb\x01\x01\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0005:04:03:02:01:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x82Sc7\x04\x0c9-\xfe2\x04\xc0\xa8\x00\x01\xff' 8955*7dc08ffcSJunyu Lai 8956*7dc08ffcSJunyu Lai= DHCP - dissection 8957*7dc08ffcSJunyu Laip = IP(s) 8958*7dc08ffcSJunyu Laiassert DHCP in p and p[DHCP].options[0] == ('message-type', 1) 8959*7dc08ffcSJunyu Lai 8960*7dc08ffcSJunyu Laip2 = IP(s2) 8961*7dc08ffcSJunyu Laiassert DHCP in p2 8962*7dc08ffcSJunyu Laiassert p2[DHCP].options[0] == ("param_req_list",[12,57,45,254]) 8963*7dc08ffcSJunyu Laiassert p2[DHCP].options[1] == ("requested_addr", "192.168.0.1") 8964*7dc08ffcSJunyu Lai 8965*7dc08ffcSJunyu Lai############ 8966*7dc08ffcSJunyu Lai############ 8967*7dc08ffcSJunyu Lai+ 802.11 8968*7dc08ffcSJunyu Lai 8969*7dc08ffcSJunyu Lai= 802.11 - misc 8970*7dc08ffcSJunyu LaiPrismHeader().answers(PrismHeader()) == True 8971*7dc08ffcSJunyu Lai 8972*7dc08ffcSJunyu Laidpl = Dot11PacketList([Dot11()/LLC()/SNAP()/IP()/UDP()]) 8973*7dc08ffcSJunyu Lailen(dpl) == 1 8974*7dc08ffcSJunyu Lai 8975*7dc08ffcSJunyu Laidpl_ether = dpl.toEthernet() 8976*7dc08ffcSJunyu Lailen(dpl_ether) == 1 and Ether in dpl_ether[0] 8977*7dc08ffcSJunyu Lai 8978*7dc08ffcSJunyu Lai= Dot11 - build 8979*7dc08ffcSJunyu Lais = raw(Dot11()) 8980*7dc08ffcSJunyu Lais == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 8981*7dc08ffcSJunyu Lai 8982*7dc08ffcSJunyu Lai= Dot11 - dissection 8983*7dc08ffcSJunyu Laip = Dot11(s) 8984*7dc08ffcSJunyu LaiDot11 in p and p.addr3 == "00:00:00:00:00:00" 8985*7dc08ffcSJunyu Laip.mysummary() == '802.11 Management 0 00:00:00:00:00:00 > 00:00:00:00:00:00' 8986*7dc08ffcSJunyu Lai 8987*7dc08ffcSJunyu Lai= Dot11QoS - build 8988*7dc08ffcSJunyu Lais = raw(Dot11(type=2, subtype=8)/Dot11QoS(TID=4)) 8989*7dc08ffcSJunyu Lais == b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' 8990*7dc08ffcSJunyu Lai 8991*7dc08ffcSJunyu Lai= Dot11 - binary in SSID 8992*7dc08ffcSJunyu Laipkt = Dot11() / Dot11Beacon() / Dot11Elt(ID=0, info=b"".join(chb(i) for i in range(32))) 8993*7dc08ffcSJunyu Laipkt.show() 8994*7dc08ffcSJunyu Laipkt.summary() 8995*7dc08ffcSJunyu Laiassert pkt[Dot11Elt::{"ID": 0}].summary() in [ 8996*7dc08ffcSJunyu Lai "SSID='%s'" % "".join(repr(chr(d))[1:-1] for d in range(32)), 8997*7dc08ffcSJunyu Lai 'SSID="%s"' % "".join(repr(chr(d))[1:-1] for d in range(32)), 8998*7dc08ffcSJunyu Lai] 8999*7dc08ffcSJunyu Laipkt = Dot11(raw(pkt)) 9000*7dc08ffcSJunyu Laipkt.show() 9001*7dc08ffcSJunyu Laipkt.summary() 9002*7dc08ffcSJunyu Laiassert pkt[Dot11Elt::{"ID": 0}].summary() in [ 9003*7dc08ffcSJunyu Lai "SSID='%s'" % "".join(repr(chr(d))[1:-1] for d in range(32)), 9004*7dc08ffcSJunyu Lai 'SSID="%s"' % "".join(repr(chr(d))[1:-1] for d in range(32)), 9005*7dc08ffcSJunyu Lai] 9006*7dc08ffcSJunyu Lai 9007*7dc08ffcSJunyu Lai= Dot11QoS - dissection 9008*7dc08ffcSJunyu Laip = Dot11(s) 9009*7dc08ffcSJunyu LaiDot11QoS in p 9010*7dc08ffcSJunyu Lai 9011*7dc08ffcSJunyu Lai= Dot11 - answers 9012*7dc08ffcSJunyu Laiquery = Dot11(type=0, subtype=0) 9013*7dc08ffcSJunyu LaiDot11(type=0, subtype=1).answers(query) == True 9014*7dc08ffcSJunyu Lai 9015*7dc08ffcSJunyu Lai= Dot11 - misc 9016*7dc08ffcSJunyu Laiassert Dot11Elt(info="scapy").summary() == "SSID='scapy'" 9017*7dc08ffcSJunyu Laiassert Dot11Elt(ID=1).mysummary() == "" 9018*7dc08ffcSJunyu Lai 9019*7dc08ffcSJunyu Lai= Multiple Dot11Elt layers 9020*7dc08ffcSJunyu Laipkt = Dot11() / Dot11Beacon() / Dot11Elt(ID="Rates") / Dot11Elt(ID="SSID", info="Scapy") 9021*7dc08ffcSJunyu Laiassert pkt[Dot11Elt::{"ID": 0}].info == b"Scapy" 9022*7dc08ffcSJunyu Laiassert pkt.getlayer(Dot11Elt, ID=0).info == b"Scapy" 9023*7dc08ffcSJunyu Lai 9024*7dc08ffcSJunyu Lai= Dot11WEP - build 9025*7dc08ffcSJunyu Lai~ crypto 9026*7dc08ffcSJunyu Laiconf.wepkey = "" 9027*7dc08ffcSJunyu Laiassert raw(PPI()/Dot11(FCfield=0x40)/Dot11WEP()) == b'\x00\x00\x08\x00i\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 9028*7dc08ffcSJunyu Laiconf.wepkey = "test123" 9029*7dc08ffcSJunyu Laiassert raw(PPI()/Dot11(type=2, subtype=8, FCfield=0x40)/Dot11QoS()/Dot11WEP()) == b'\x00\x00\x08\x00i\x00\x00\x00\x88@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x008(^a' 9030*7dc08ffcSJunyu Lai 9031*7dc08ffcSJunyu Lai= Dot11WEP - dissect 9032*7dc08ffcSJunyu Lai~ crypto 9033*7dc08ffcSJunyu Laiconf.wepkey = "test123" 9034*7dc08ffcSJunyu Laia = PPI(b'\x00\x00\x08\x00i\x00\x00\x00\x88@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x008(^a') 9035*7dc08ffcSJunyu Laiassert a[Dot11QoS][Dot11WEP].icv == 942169697 9036*7dc08ffcSJunyu Lai 9037*7dc08ffcSJunyu Lai= Dot11 - answers 9038*7dc08ffcSJunyu Laia = Dot11()/Dot11Auth(seqnum=1) 9039*7dc08ffcSJunyu Laib = Dot11()/Dot11Auth(seqnum=2) 9040*7dc08ffcSJunyu Laiassert b.answers(a) 9041*7dc08ffcSJunyu Laiassert not a.answers(b) 9042*7dc08ffcSJunyu Lai 9043*7dc08ffcSJunyu Laiassert not (Dot11()/Dot11Ack()).answers(Dot11()) 9044*7dc08ffcSJunyu Laiassert (Dot11()/LLC(dsap=2, ctrl=4)).answers(Dot11()/LLC(dsap=1, ctrl=5)) 9045*7dc08ffcSJunyu Lai 9046*7dc08ffcSJunyu Lai 9047*7dc08ffcSJunyu Lai############ 9048*7dc08ffcSJunyu Lai############ 9049*7dc08ffcSJunyu Lai+ 802.3 9050*7dc08ffcSJunyu Lai 9051*7dc08ffcSJunyu Lai= Test detection 9052*7dc08ffcSJunyu Lai 9053*7dc08ffcSJunyu Laiassert isinstance(Dot3(raw(Ether())),Ether) 9054*7dc08ffcSJunyu Laiassert isinstance(Ether(raw(Dot3())),Dot3) 9055*7dc08ffcSJunyu Lai 9056*7dc08ffcSJunyu Laia = Ether(b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00') 9057*7dc08ffcSJunyu Laiassert isinstance(a,Dot3) 9058*7dc08ffcSJunyu Laiassert a.dst == 'ff:ff:ff:ff:ff:ff' 9059*7dc08ffcSJunyu Laiassert a.src == '00:00:00:00:00:00' 9060*7dc08ffcSJunyu Lai 9061*7dc08ffcSJunyu Laia = Dot3(b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x90\x00') 9062*7dc08ffcSJunyu Laiassert isinstance(a,Ether) 9063*7dc08ffcSJunyu Laiassert a.dst == 'ff:ff:ff:ff:ff:ff' 9064*7dc08ffcSJunyu Laiassert a.src == '00:00:00:00:00:00' 9065*7dc08ffcSJunyu Lai 9066*7dc08ffcSJunyu Lai 9067*7dc08ffcSJunyu Lai############ 9068*7dc08ffcSJunyu Lai############ 9069*7dc08ffcSJunyu Lai+ ASN.1 9070*7dc08ffcSJunyu Lai 9071*7dc08ffcSJunyu Lai= MIB 9072*7dc08ffcSJunyu Lai 9073*7dc08ffcSJunyu Laiimport tempfile 9074*7dc08ffcSJunyu Laifd, fname = tempfile.mkstemp() 9075*7dc08ffcSJunyu Laios.write(fd, b"-- MIB test\nscapy OBJECT IDENTIFIER ::= {test 2807}\n") 9076*7dc08ffcSJunyu Laios.close(fd) 9077*7dc08ffcSJunyu Lai 9078*7dc08ffcSJunyu Laiload_mib(fname) 9079*7dc08ffcSJunyu Laiassert(len([k for k in conf.mib.iterkeys() if "scapy" in k]) == 1) 9080*7dc08ffcSJunyu Lai 9081*7dc08ffcSJunyu Laiassert(len([oid for oid in conf.mib]) > 100) 9082*7dc08ffcSJunyu Lai 9083*7dc08ffcSJunyu Laiassert(conf.mib._my_find("MIB", "keyUsage")) 9084*7dc08ffcSJunyu Lai 9085*7dc08ffcSJunyu Laiassert(len(conf.mib._find("MIB", "keyUsage"))) 9086*7dc08ffcSJunyu Lai 9087*7dc08ffcSJunyu Laiassert(len(conf.mib._recurs_find_all((), "MIB", "keyUsage"))) 9088*7dc08ffcSJunyu Lai 9089*7dc08ffcSJunyu Lai= MIB - graph 9090*7dc08ffcSJunyu Lai 9091*7dc08ffcSJunyu Lai@mock.patch("scapy.asn1.mib.do_graph") 9092*7dc08ffcSJunyu Laidef get_mib_graph(do_graph): 9093*7dc08ffcSJunyu Lai def store_graph(graph, **kargs): 9094*7dc08ffcSJunyu Lai assert graph.startswith("""digraph "mib" {""") 9095*7dc08ffcSJunyu Lai assert """"test.2807" [ label="scapy" ];""" in graph 9096*7dc08ffcSJunyu Lai do_graph.side_effect = store_graph 9097*7dc08ffcSJunyu Lai conf.mib._make_graph() 9098*7dc08ffcSJunyu Lai 9099*7dc08ffcSJunyu Laiget_mib_graph() 9100*7dc08ffcSJunyu Lai 9101*7dc08ffcSJunyu Lai= DADict tests 9102*7dc08ffcSJunyu Lai 9103*7dc08ffcSJunyu Laia = DADict("test") 9104*7dc08ffcSJunyu Laia.test_value = "scapy" 9105*7dc08ffcSJunyu Laiwith ContextManagerCaptureOutput() as cmco: 9106*7dc08ffcSJunyu Lai a._show() 9107*7dc08ffcSJunyu Lai assert(cmco.get_output() == "test_value = 'scapy'\n") 9108*7dc08ffcSJunyu Lai 9109*7dc08ffcSJunyu Laib = DADict("test2") 9110*7dc08ffcSJunyu Laib.test_value_2 = "hello_world" 9111*7dc08ffcSJunyu Lai 9112*7dc08ffcSJunyu Laia._branch(b, 1) 9113*7dc08ffcSJunyu Laitry: 9114*7dc08ffcSJunyu Lai a._branch(b, 1) 9115*7dc08ffcSJunyu Lai assert False 9116*7dc08ffcSJunyu Laiexcept DADict_Exception: 9117*7dc08ffcSJunyu Lai pass 9118*7dc08ffcSJunyu Lai 9119*7dc08ffcSJunyu Laiassert(len(a._find("test2"))) 9120*7dc08ffcSJunyu Lai 9121*7dc08ffcSJunyu Laiassert(len(a._find(test_value_2="hello_world"))) 9122*7dc08ffcSJunyu Lai 9123*7dc08ffcSJunyu Laiassert(len(a._find_all("test2"))) 9124*7dc08ffcSJunyu Lai 9125*7dc08ffcSJunyu Laiassert(not a._recurs_find((a,))) 9126*7dc08ffcSJunyu Lai 9127*7dc08ffcSJunyu Laiassert(not a._recurs_find_all((a,))) 9128*7dc08ffcSJunyu Lai 9129*7dc08ffcSJunyu Lai= BER tests 9130*7dc08ffcSJunyu Lai 9131*7dc08ffcSJunyu LaiBER_id_enc(42) == '*' 9132*7dc08ffcSJunyu LaiBER_id_enc(2807) == b'\xbfw' 9133*7dc08ffcSJunyu Lai 9134*7dc08ffcSJunyu Laib = BERcodec_IPADDRESS() 9135*7dc08ffcSJunyu Lair1 = b.enc("8.8.8.8") 9136*7dc08ffcSJunyu Lair1 == b'@\x04\x08\x08\x08\x08' 9137*7dc08ffcSJunyu Lai 9138*7dc08ffcSJunyu Lair2 = b.dec(r1)[0] 9139*7dc08ffcSJunyu Lair2.val == '8.8.8.8' 9140*7dc08ffcSJunyu Lai 9141*7dc08ffcSJunyu Lai 9142*7dc08ffcSJunyu Lai############ 9143*7dc08ffcSJunyu Lai############ 9144*7dc08ffcSJunyu Lai+ inet.py 9145*7dc08ffcSJunyu Lai 9146*7dc08ffcSJunyu Lai= IPv4 - ICMPTimeStampField 9147*7dc08ffcSJunyu Laitest = ICMPTimeStampField("test", None) 9148*7dc08ffcSJunyu Laivalue = test.any2i("", "07:28:28.07") 9149*7dc08ffcSJunyu Laivalue == 26908070 9150*7dc08ffcSJunyu Laitest.i2repr("", value) == '7:28:28.70' 9151*7dc08ffcSJunyu Lai 9152*7dc08ffcSJunyu Lai= IPv4 - UDP null checksum 9153*7dc08ffcSJunyu LaiIP(raw(IP()/UDP()/Raw(b"\xff\xff\x01\x6a")))[UDP].chksum == 0xFFFF 9154*7dc08ffcSJunyu Lai 9155*7dc08ffcSJunyu Lai= IPv4 - (IP|UDP|TCP|ICMP)Error 9156*7dc08ffcSJunyu Laiquery = IP(dst="192.168.0.1", src="192.168.0.254", ttl=1)/UDP()/DNS() 9157*7dc08ffcSJunyu Laianswer = IP(dst="192.168.0.254", src="192.168.0.2", ttl=1)/ICMP()/IPerror(dst="192.168.0.1", src="192.168.0.254", ttl=0)/UDPerror()/DNS() 9158*7dc08ffcSJunyu Lai 9159*7dc08ffcSJunyu Laiquery = IP(dst="192.168.0.1", src="192.168.0.254", ttl=1)/UDP()/DNS() 9160*7dc08ffcSJunyu Laianswer = IP(dst="192.168.0.254", src="192.168.0.2")/ICMP(type=11)/IPerror(dst="192.168.0.1", src="192.168.0.254", ttl=0)/UDPerror()/DNS() 9161*7dc08ffcSJunyu Laiassert(answer.answers(query) == True) 9162*7dc08ffcSJunyu Lai 9163*7dc08ffcSJunyu Laiquery = IP(dst="192.168.0.1", src="192.168.0.254", ttl=1)/TCP() 9164*7dc08ffcSJunyu Laianswer = IP(dst="192.168.0.254", src="192.168.0.2")/ICMP(type=11)/IPerror(dst="192.168.0.1", src="192.168.0.254", ttl=0)/TCPerror() 9165*7dc08ffcSJunyu Lai 9166*7dc08ffcSJunyu Laiassert(answer.answers(query) == True) 9167*7dc08ffcSJunyu Lai 9168*7dc08ffcSJunyu Laiquery = IP(dst="192.168.0.1", src="192.168.0.254", ttl=1)/ICMP()/"scapy" 9169*7dc08ffcSJunyu Laianswer = IP(dst="192.168.0.254", src="192.168.0.2")/ICMP(type=11)/IPerror(dst="192.168.0.1", src="192.168.0.254", ttl=0)/ICMPerror()/"scapy" 9170*7dc08ffcSJunyu Laiassert(answer.answers(query) == True) 9171*7dc08ffcSJunyu Lai 9172*7dc08ffcSJunyu Lai= IPv4 - mDNS 9173*7dc08ffcSJunyu Laia = IP(dst="224.0.0.251") 9174*7dc08ffcSJunyu Laiassert a.hashret() == b"\x00" 9175*7dc08ffcSJunyu Lai 9176*7dc08ffcSJunyu Lai# TODO add real case here 9177*7dc08ffcSJunyu Lai 9178*7dc08ffcSJunyu Lai= IPv4 - utilities 9179*7dc08ffcSJunyu Lail = overlap_frag(IP(dst="1.2.3.4")/ICMP()/("AB"*8), ICMP()/("CD"*8)) 9180*7dc08ffcSJunyu Laiassert(len(l) == 6) 9181*7dc08ffcSJunyu Laiassert([len(raw(p[IP].payload)) for p in l] == [8, 8, 8, 8, 8, 8]) 9182*7dc08ffcSJunyu Laiassert([(p.frag, p.flags.MF) for p in [IP(raw(p)) for p in l]] == [(0, True), (1, True), (2, True), (0, True), (1, True), (2, False)]) 9183*7dc08ffcSJunyu Lai 9184*7dc08ffcSJunyu Lai= IPv4 - traceroute utilities 9185*7dc08ffcSJunyu Laiip_ttl = [("192.168.0.%d" % i, i) for i in six.moves.range(1, 10)] 9186*7dc08ffcSJunyu Lai 9187*7dc08ffcSJunyu Laitr_packets = [ (IP(dst="192.168.0.1", src="192.168.0.254", ttl=ttl)/TCP(options=[("Timestamp", "00:00:%.2d.00" % ttl)])/"scapy", 9188*7dc08ffcSJunyu Lai IP(dst="192.168.0.254", src=ip)/ICMP(type=11)/IPerror(dst="192.168.0.1", src="192.168.0.254", ttl=0)/TCPerror()/"scapy") 9189*7dc08ffcSJunyu Lai for (ip, ttl) in ip_ttl ] 9190*7dc08ffcSJunyu Lai 9191*7dc08ffcSJunyu Laitr = TracerouteResult(tr_packets) 9192*7dc08ffcSJunyu Laiassert(tr.get_trace() == {'192.168.0.1': {1: ('192.168.0.1', False), 2: ('192.168.0.2', False), 3: ('192.168.0.3', False), 4: ('192.168.0.4', False), 5: ('192.168.0.5', False), 6: ('192.168.0.6', False), 7: ('192.168.0.7', False), 8: ('192.168.0.8', False), 9: ('192.168.0.9', False)}}) 9193*7dc08ffcSJunyu Lai 9194*7dc08ffcSJunyu Laidef test_show(): 9195*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9196*7dc08ffcSJunyu Lai tr = TracerouteResult(tr_packets) 9197*7dc08ffcSJunyu Lai tr.show() 9198*7dc08ffcSJunyu Lai result_show = cmco.get_output() 9199*7dc08ffcSJunyu Lai expected = " 192.168.0.1:tcp80 \n" 9200*7dc08ffcSJunyu Lai expected += "1 192.168.0.1 11 \n" 9201*7dc08ffcSJunyu Lai expected += "2 192.168.0.2 11 \n" 9202*7dc08ffcSJunyu Lai expected += "3 192.168.0.3 11 \n" 9203*7dc08ffcSJunyu Lai expected += "4 192.168.0.4 11 \n" 9204*7dc08ffcSJunyu Lai expected += "5 192.168.0.5 11 \n" 9205*7dc08ffcSJunyu Lai expected += "6 192.168.0.6 11 \n" 9206*7dc08ffcSJunyu Lai expected += "7 192.168.0.7 11 \n" 9207*7dc08ffcSJunyu Lai expected += "8 192.168.0.8 11 \n" 9208*7dc08ffcSJunyu Lai expected += "9 192.168.0.9 11 \n" 9209*7dc08ffcSJunyu Lai index_result = result_show.index("\n1") 9210*7dc08ffcSJunyu Lai index_expected = expected.index("\n1") 9211*7dc08ffcSJunyu Lai assert(result_show[index_result:] == expected[index_expected:]) 9212*7dc08ffcSJunyu Lai 9213*7dc08ffcSJunyu Laitest_show() 9214*7dc08ffcSJunyu Lai 9215*7dc08ffcSJunyu Laidef test_summary(): 9216*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9217*7dc08ffcSJunyu Lai tr = TracerouteResult(tr_packets) 9218*7dc08ffcSJunyu Lai tr.summary() 9219*7dc08ffcSJunyu Lai result_summary = cmco.get_output() 9220*7dc08ffcSJunyu Lai assert(len(result_summary.split('\n')) == 10) 9221*7dc08ffcSJunyu Lai assert(any( 9222*7dc08ffcSJunyu Lai "IP / TCP 192.168.0.254:%s > 192.168.0.1:%s S / Raw ==> " 9223*7dc08ffcSJunyu Lai "IP / ICMP 192.168.0.9 > 192.168.0.254 time-exceeded " 9224*7dc08ffcSJunyu Lai "ttl-zero-during-transit / IPerror / TCPerror / " 9225*7dc08ffcSJunyu Lai "Raw" % (ftp_data, http) in result_summary 9226*7dc08ffcSJunyu Lai for ftp_data in ['21', 'ftp_data'] 9227*7dc08ffcSJunyu Lai for http in ['80', 'http', 'www_http', 'www'] 9228*7dc08ffcSJunyu Lai )) 9229*7dc08ffcSJunyu Lai 9230*7dc08ffcSJunyu Laitest_summary() 9231*7dc08ffcSJunyu Lai 9232*7dc08ffcSJunyu Lai@mock.patch("scapy.layers.inet.plt") 9233*7dc08ffcSJunyu Laidef test_timeskew_graph(mock_plt): 9234*7dc08ffcSJunyu Lai def fake_plot(data, **kwargs): 9235*7dc08ffcSJunyu Lai return data 9236*7dc08ffcSJunyu Lai mock_plt.plot = fake_plot 9237*7dc08ffcSJunyu Lai srl = SndRcvList([(a, a) for a in [IP(raw(p[0])) for p in tr_packets]]) 9238*7dc08ffcSJunyu Lai ret = srl.timeskew_graph("192.168.0.254") 9239*7dc08ffcSJunyu Lai assert(len(ret) == 9) 9240*7dc08ffcSJunyu Lai assert(ret[0][1] == 0.0) 9241*7dc08ffcSJunyu Lai 9242*7dc08ffcSJunyu Laitest_timeskew_graph() 9243*7dc08ffcSJunyu Lai 9244*7dc08ffcSJunyu Laitr = TracerouteResult(tr_packets) 9245*7dc08ffcSJunyu Laisaved_AS_resolver = conf.AS_resolver 9246*7dc08ffcSJunyu Laiconf.AS_resolver = None 9247*7dc08ffcSJunyu Laitr.make_graph() 9248*7dc08ffcSJunyu Laiassert(len(tr.graphdef) == 491) 9249*7dc08ffcSJunyu Laitr.graphdef.startswith("digraph trace {") == True 9250*7dc08ffcSJunyu Laiassert(('"192.168.0.9" ->' in tr.graphdef) == True) 9251*7dc08ffcSJunyu Laiconf.AS_resolver = conf.AS_resolver 9252*7dc08ffcSJunyu Lai 9253*7dc08ffcSJunyu Laipl = PacketList(list([Ether()/x for x in itertools.chain(*tr_packets)])) 9254*7dc08ffcSJunyu Laisrl, ul = pl.sr() 9255*7dc08ffcSJunyu Laiassert(len(srl) == 9 and len(ul) == 0) 9256*7dc08ffcSJunyu Lai 9257*7dc08ffcSJunyu Laiconf_color_theme = conf.color_theme 9258*7dc08ffcSJunyu Laiconf.color_theme = BlackAndWhite() 9259*7dc08ffcSJunyu Laiassert(len(pl.sessions().keys()) == 10) 9260*7dc08ffcSJunyu Laiconf.color_theme = conf_color_theme 9261*7dc08ffcSJunyu Lai 9262*7dc08ffcSJunyu Lainew_pl = pl.replace(IP.src, "192.168.0.254", "192.168.0.42") 9263*7dc08ffcSJunyu Laiassert("192.168.0.254" not in [p[IP].src for p in new_pl]) 9264*7dc08ffcSJunyu Lai 9265*7dc08ffcSJunyu Lai= IPv4 - reporting 9266*7dc08ffcSJunyu Lai 9267*7dc08ffcSJunyu Lai@mock.patch("scapy.layers.inet.sr") 9268*7dc08ffcSJunyu Laidef test_report_ports(mock_sr): 9269*7dc08ffcSJunyu Lai def sr(*args, **kargs): 9270*7dc08ffcSJunyu Lai return [(IP()/TCP(dport=65081, flags="S"), IP()/TCP(sport=65081, flags="SA")), 9271*7dc08ffcSJunyu Lai (IP()/TCP(dport=65082, flags="S"), IP()/ICMP(type=3, code=1)), 9272*7dc08ffcSJunyu Lai (IP()/TCP(dport=65083, flags="S"), IP()/TCP(sport=65083, flags="R"))], [IP()/TCP(dport=65084, flags="S")] 9273*7dc08ffcSJunyu Lai mock_sr.side_effect = sr 9274*7dc08ffcSJunyu Lai report = "\\begin{tabular}{|r|l|l|}\n\hline\n65081 & open & SA \\\\\n\hline\n?? & closed & ICMP type dest-unreach/host-unreachable from 127.0.0.1 \\\\\n65083 & closed & TCP R \\\\\n\hline\n65084 & ? & unanswered \\\\\n\hline\n\end{tabular}\n" 9275*7dc08ffcSJunyu Lai assert(report_ports("www.secdev.org", [65081,65082,65083,65084]) == report) 9276*7dc08ffcSJunyu Lai 9277*7dc08ffcSJunyu Laitest_report_ports() 9278*7dc08ffcSJunyu Lai 9279*7dc08ffcSJunyu Laidef test_IPID_count(): 9280*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9281*7dc08ffcSJunyu Lai random.seed(0x2807) 9282*7dc08ffcSJunyu Lai IPID_count([(IP()/UDP(), IP(id=random.randint(0, 65535))/UDP()) for i in range(3)]) 9283*7dc08ffcSJunyu Lai result_IPID_count = cmco.get_output() 9284*7dc08ffcSJunyu Lai lines = result_IPID_count.split("\n") 9285*7dc08ffcSJunyu Lai assert(len(lines) == 5) 9286*7dc08ffcSJunyu Lai assert(lines[0] in ["Probably 3 classes: [4613, 53881, 58437]", 9287*7dc08ffcSJunyu Lai "Probably 3 classes: [9103, 9227, 46399]"]) 9288*7dc08ffcSJunyu Lai 9289*7dc08ffcSJunyu Laitest_IPID_count() 9290*7dc08ffcSJunyu Lai 9291*7dc08ffcSJunyu Lai 9292*7dc08ffcSJunyu Lai############ 9293*7dc08ffcSJunyu Lai############ 9294*7dc08ffcSJunyu Lai+ Fields 9295*7dc08ffcSJunyu Lai 9296*7dc08ffcSJunyu Lai= FieldLenField with BitField 9297*7dc08ffcSJunyu Laiclass Test(Packet): 9298*7dc08ffcSJunyu Lai name = "Test" 9299*7dc08ffcSJunyu Lai fields_desc = [ 9300*7dc08ffcSJunyu Lai FieldLenField("BitCount", None, fmt="H", count_of="Values"), 9301*7dc08ffcSJunyu Lai FieldLenField("ByteCount", None, fmt="B", length_of="Values"), 9302*7dc08ffcSJunyu Lai FieldListField("Values", [], BitField("data", 0x0, size=1), 9303*7dc08ffcSJunyu Lai count_from=lambda pkt: pkt.BitCount), 9304*7dc08ffcSJunyu Lai ] 9305*7dc08ffcSJunyu Lai 9306*7dc08ffcSJunyu Laipkt = Test(raw(Test(Values=[0, 0, 0, 0, 1, 1, 1, 1]))) 9307*7dc08ffcSJunyu Laiassert(pkt.BitCount == 8) 9308*7dc08ffcSJunyu Laiassert(pkt.ByteCount == 1) 9309*7dc08ffcSJunyu Lai 9310*7dc08ffcSJunyu Lai############ 9311*7dc08ffcSJunyu Lai############ 9312*7dc08ffcSJunyu Lai+ MPLS tests 9313*7dc08ffcSJunyu Lai 9314*7dc08ffcSJunyu Lai= MPLS - build/dissection 9315*7dc08ffcSJunyu Laifrom scapy.contrib.mpls import MPLS 9316*7dc08ffcSJunyu Laip1 = MPLS()/IP()/UDP() 9317*7dc08ffcSJunyu Laiassert(p1[MPLS].s == 1) 9318*7dc08ffcSJunyu Laip2 = MPLS()/MPLS()/IP()/UDP() 9319*7dc08ffcSJunyu Laiassert(p2[MPLS].s == 0) 9320*7dc08ffcSJunyu Lai 9321*7dc08ffcSJunyu Laip1[MPLS] 9322*7dc08ffcSJunyu Laip1[IP] 9323*7dc08ffcSJunyu Laip2[MPLS] 9324*7dc08ffcSJunyu Laip2[MPLS:1] 9325*7dc08ffcSJunyu Laip2[IP] 9326*7dc08ffcSJunyu Lai 9327*7dc08ffcSJunyu Lai 9328*7dc08ffcSJunyu Lai+ Restore normal routes & Ifaces 9329*7dc08ffcSJunyu Lai 9330*7dc08ffcSJunyu Lai= Windows 9331*7dc08ffcSJunyu Lai 9332*7dc08ffcSJunyu Laiif WINDOWS: 9333*7dc08ffcSJunyu Lai IFACES.reload() 9334*7dc08ffcSJunyu Lai conf.route.resync() 9335*7dc08ffcSJunyu Lai conf.route6.resync() 9336*7dc08ffcSJunyu Lai 9337*7dc08ffcSJunyu LaiTrue 9338*7dc08ffcSJunyu Lai 9339*7dc08ffcSJunyu Lai 9340*7dc08ffcSJunyu Lai############ 9341*7dc08ffcSJunyu Lai############ 9342*7dc08ffcSJunyu Lai+ PacketList methods 9343*7dc08ffcSJunyu Lai 9344*7dc08ffcSJunyu Lai= plot() 9345*7dc08ffcSJunyu Lai 9346*7dc08ffcSJunyu Laiimport mock 9347*7dc08ffcSJunyu Lai@mock.patch("scapy.plist.plt") 9348*7dc08ffcSJunyu Laidef test_plot(mock_plt): 9349*7dc08ffcSJunyu Lai def fake_plot(data, **kwargs): 9350*7dc08ffcSJunyu Lai return data 9351*7dc08ffcSJunyu Lai mock_plt.plot = fake_plot 9352*7dc08ffcSJunyu Lai plist = PacketList([IP(id=i)/TCP() for i in range(10)]) 9353*7dc08ffcSJunyu Lai lines = plist.plot(lambda p: (p.time, p.id)) 9354*7dc08ffcSJunyu Lai assert(len(lines) == 10) 9355*7dc08ffcSJunyu Lai 9356*7dc08ffcSJunyu Laitest_plot() 9357*7dc08ffcSJunyu Lai 9358*7dc08ffcSJunyu Lai= diffplot() 9359*7dc08ffcSJunyu Lai 9360*7dc08ffcSJunyu Laiimport mock 9361*7dc08ffcSJunyu Lai@mock.patch("scapy.plist.plt") 9362*7dc08ffcSJunyu Laidef test_diffplot(mock_plt): 9363*7dc08ffcSJunyu Lai def fake_plot(data, **kwargs): 9364*7dc08ffcSJunyu Lai return data 9365*7dc08ffcSJunyu Lai mock_plt.plot = fake_plot 9366*7dc08ffcSJunyu Lai plist = PacketList([IP(id=i)/TCP() for i in range(10)]) 9367*7dc08ffcSJunyu Lai lines = plist.diffplot(lambda x,y: (x.time, y.id-x.id)) 9368*7dc08ffcSJunyu Lai assert(len(lines) == 9) 9369*7dc08ffcSJunyu Lai 9370*7dc08ffcSJunyu Laitest_diffplot() 9371*7dc08ffcSJunyu Lai 9372*7dc08ffcSJunyu Lai= multiplot() 9373*7dc08ffcSJunyu Lai 9374*7dc08ffcSJunyu Laiimport mock 9375*7dc08ffcSJunyu Lai@mock.patch("scapy.plist.plt") 9376*7dc08ffcSJunyu Laidef test_multiplot(mock_plt): 9377*7dc08ffcSJunyu Lai def fake_plot(data, **kwargs): 9378*7dc08ffcSJunyu Lai return data 9379*7dc08ffcSJunyu Lai mock_plt.plot = fake_plot 9380*7dc08ffcSJunyu Lai tmp = [IP(id=i)/TCP() for i in range(10)] 9381*7dc08ffcSJunyu Lai plist = PacketList([tuple(tmp[i-2:i]) for i in range(2, 10, 2)]) 9382*7dc08ffcSJunyu Lai lines = plist.multiplot(lambda x: (x[1][IP].src, (x[1].time, x[1][IP].id))) 9383*7dc08ffcSJunyu Lai assert(len(lines) == 1) 9384*7dc08ffcSJunyu Lai assert(len(lines[0]) == 4) 9385*7dc08ffcSJunyu Lai 9386*7dc08ffcSJunyu Laitest_multiplot() 9387*7dc08ffcSJunyu Lai 9388*7dc08ffcSJunyu Lai= rawhexdump() 9389*7dc08ffcSJunyu Lai 9390*7dc08ffcSJunyu Laidef test_rawhexdump(): 9391*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9392*7dc08ffcSJunyu Lai p = PacketList([IP()/TCP() for i in range(2)]) 9393*7dc08ffcSJunyu Lai p.rawhexdump() 9394*7dc08ffcSJunyu Lai result_pl_rawhexdump = cmco.get_output() 9395*7dc08ffcSJunyu Lai assert(len(result_pl_rawhexdump.split('\n')) == 7) 9396*7dc08ffcSJunyu Lai assert(result_pl_rawhexdump.startswith("0000 45000028")) 9397*7dc08ffcSJunyu Lai 9398*7dc08ffcSJunyu Laitest_rawhexdump() 9399*7dc08ffcSJunyu Lai 9400*7dc08ffcSJunyu Lai= hexraw() 9401*7dc08ffcSJunyu Lai 9402*7dc08ffcSJunyu Laidef test_hexraw(): 9403*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9404*7dc08ffcSJunyu Lai p = PacketList([IP()/Raw(str(i)) for i in range(2)]) 9405*7dc08ffcSJunyu Lai p.hexraw() 9406*7dc08ffcSJunyu Lai result_pl_hexraw = cmco.get_output() 9407*7dc08ffcSJunyu Lai assert(len(result_pl_hexraw.split('\n')) == 5) 9408*7dc08ffcSJunyu Lai assert("0000 30" in result_pl_hexraw) 9409*7dc08ffcSJunyu Lai 9410*7dc08ffcSJunyu Laitest_hexraw() 9411*7dc08ffcSJunyu Lai 9412*7dc08ffcSJunyu Lai= hexdump() 9413*7dc08ffcSJunyu Lai 9414*7dc08ffcSJunyu Laidef test_hexdump(): 9415*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9416*7dc08ffcSJunyu Lai p = PacketList([IP()/Raw(str(i)) for i in range(2)]) 9417*7dc08ffcSJunyu Lai p.hexdump() 9418*7dc08ffcSJunyu Lai result_pl_hexdump = cmco.get_output() 9419*7dc08ffcSJunyu Lai assert(len(result_pl_hexdump.split('\n')) == 7) 9420*7dc08ffcSJunyu Lai assert("0010 7F00000131" in result_pl_hexdump) 9421*7dc08ffcSJunyu Lai 9422*7dc08ffcSJunyu Laitest_hexdump() 9423*7dc08ffcSJunyu Lai 9424*7dc08ffcSJunyu Lai= padding() 9425*7dc08ffcSJunyu Lai 9426*7dc08ffcSJunyu Laidef test_padding(): 9427*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9428*7dc08ffcSJunyu Lai p = PacketList([IP()/conf.padding_layer(str(i)) for i in range(2)]) 9429*7dc08ffcSJunyu Lai p.padding() 9430*7dc08ffcSJunyu Lai result_pl_padding = cmco.get_output() 9431*7dc08ffcSJunyu Lai assert(len(result_pl_padding.split('\n')) == 5) 9432*7dc08ffcSJunyu Lai assert("0000 30" in result_pl_padding) 9433*7dc08ffcSJunyu Lai 9434*7dc08ffcSJunyu Laitest_padding() 9435*7dc08ffcSJunyu Lai 9436*7dc08ffcSJunyu Lai= nzpadding() 9437*7dc08ffcSJunyu Lai 9438*7dc08ffcSJunyu Laidef test_nzpadding(): 9439*7dc08ffcSJunyu Lai with ContextManagerCaptureOutput() as cmco: 9440*7dc08ffcSJunyu Lai p = PacketList([IP()/conf.padding_layer("A%s" % i) for i in range(2)]) 9441*7dc08ffcSJunyu Lai p.nzpadding() 9442*7dc08ffcSJunyu Lai result_pl_nzpadding = cmco.get_output() 9443*7dc08ffcSJunyu Lai assert(len(result_pl_nzpadding.split('\n')) == 5) 9444*7dc08ffcSJunyu Lai assert("0000 4130" in result_pl_nzpadding) 9445*7dc08ffcSJunyu Lai 9446*7dc08ffcSJunyu Laitest_nzpadding() 9447*7dc08ffcSJunyu Lai 9448*7dc08ffcSJunyu Lai= conversations() 9449*7dc08ffcSJunyu Lai 9450*7dc08ffcSJunyu Laiimport mock 9451*7dc08ffcSJunyu Lai@mock.patch("scapy.plist.do_graph") 9452*7dc08ffcSJunyu Laidef test_conversations(mock_do_graph): 9453*7dc08ffcSJunyu Lai def fake_do_graph(graph, **kwargs): 9454*7dc08ffcSJunyu Lai return graph 9455*7dc08ffcSJunyu Lai mock_do_graph.side_effect = fake_do_graph 9456*7dc08ffcSJunyu Lai plist = PacketList([IP(dst="127.0.0.2")/TCP(dport=i) for i in range(2)]) 9457*7dc08ffcSJunyu Lai plist.extend([IP(src="127.0.0.2")/TCP(sport=i) for i in range(2)]) 9458*7dc08ffcSJunyu Lai result_conversations = plist.conversations() 9459*7dc08ffcSJunyu Lai assert(len(result_conversations.split('\n')) == 5) 9460*7dc08ffcSJunyu Lai assert(result_conversations.startswith('digraph "conv" {')) 9461*7dc08ffcSJunyu Lai 9462*7dc08ffcSJunyu Laitest_conversations() 9463*7dc08ffcSJunyu Lai 9464*7dc08ffcSJunyu Lai= afterglow() 9465*7dc08ffcSJunyu Lai 9466*7dc08ffcSJunyu Laiimport mock 9467*7dc08ffcSJunyu Lai@mock.patch("scapy.plist.do_graph") 9468*7dc08ffcSJunyu Laidef test_afterglow(mock_do_graph): 9469*7dc08ffcSJunyu Lai def fake_do_graph(graph, **kwargs): 9470*7dc08ffcSJunyu Lai return graph 9471*7dc08ffcSJunyu Lai mock_do_graph.side_effect = fake_do_graph 9472*7dc08ffcSJunyu Lai plist = PacketList([IP(dst="127.0.0.2")/TCP(dport=i) for i in range(2)]) 9473*7dc08ffcSJunyu Lai plist.extend([IP(src="127.0.0.2")/TCP(sport=i) for i in range(2)]) 9474*7dc08ffcSJunyu Lai result_afterglow = plist.afterglow() 9475*7dc08ffcSJunyu Lai assert(len(result_afterglow.split('\n')) == 19) 9476*7dc08ffcSJunyu Lai assert(result_afterglow.startswith('digraph "afterglow" {')) 9477*7dc08ffcSJunyu Lai 9478*7dc08ffcSJunyu Laitest_afterglow() 9479*7dc08ffcSJunyu Lai 9480*7dc08ffcSJunyu Lai= psdump() 9481*7dc08ffcSJunyu Lai 9482*7dc08ffcSJunyu Laiprint("PYX: %d" % PYX) 9483*7dc08ffcSJunyu Laiif PYX: 9484*7dc08ffcSJunyu Lai import tempfile 9485*7dc08ffcSJunyu Lai import os 9486*7dc08ffcSJunyu Lai filename = tempfile.mktemp(suffix=".ps") 9487*7dc08ffcSJunyu Lai plist = PacketList([IP()/TCP()]) 9488*7dc08ffcSJunyu Lai plist.psdump(filename) 9489*7dc08ffcSJunyu Lai assert(os.path.exists(filename)) 9490*7dc08ffcSJunyu Lai os.unlink(filename) 9491*7dc08ffcSJunyu Lai 9492*7dc08ffcSJunyu Lai= pdfdump() 9493*7dc08ffcSJunyu Lai 9494*7dc08ffcSJunyu Laiprint("PYX: %d" % PYX) 9495*7dc08ffcSJunyu Laiif PYX: 9496*7dc08ffcSJunyu Lai import tempfile 9497*7dc08ffcSJunyu Lai import os 9498*7dc08ffcSJunyu Lai filename = tempfile.mktemp(suffix=".pdf") 9499*7dc08ffcSJunyu Lai plist = PacketList([IP()/TCP()]) 9500*7dc08ffcSJunyu Lai plist.pdfdump(filename) 9501*7dc08ffcSJunyu Lai assert(os.path.exists(filename)) 9502*7dc08ffcSJunyu Lai os.unlink(filename) 9503*7dc08ffcSJunyu Lai 9504*7dc08ffcSJunyu Lai############ 9505*7dc08ffcSJunyu Lai############ 9506*7dc08ffcSJunyu Lai+ Scapy version 9507*7dc08ffcSJunyu Lai 9508*7dc08ffcSJunyu Lai= _version() 9509*7dc08ffcSJunyu Lai 9510*7dc08ffcSJunyu Laiimport os 9511*7dc08ffcSJunyu Laiversion_filename = os.path.join(scapy._SCAPY_PKG_DIR, "VERSION") 9512*7dc08ffcSJunyu Lai 9513*7dc08ffcSJunyu Laiversion = scapy._version() 9514*7dc08ffcSJunyu Laiassert(os.path.exists(version_filename)) 9515*7dc08ffcSJunyu Lai 9516*7dc08ffcSJunyu Laiimport mock 9517*7dc08ffcSJunyu Laiwith mock.patch("scapy._version_from_git_describe") as version_mocked: 9518*7dc08ffcSJunyu Lai version_mocked.side_effect = Exception() 9519*7dc08ffcSJunyu Lai assert(scapy._version() == version) 9520*7dc08ffcSJunyu Lai os.unlink(version_filename) 9521*7dc08ffcSJunyu Lai assert(scapy._version() == "git-archive.dev$Format:%h") 9522*7dc08ffcSJunyu Lai 9523*7dc08ffcSJunyu Lai 9524*7dc08ffcSJunyu Lai############ 9525*7dc08ffcSJunyu Lai# RTP 9526*7dc08ffcSJunyu Lai############ 9527*7dc08ffcSJunyu Lai 9528*7dc08ffcSJunyu Lai+ RTP tests 9529*7dc08ffcSJunyu Lai 9530*7dc08ffcSJunyu Lai= test rtp with extension header 9531*7dc08ffcSJunyu Lai~ rtp 9532*7dc08ffcSJunyu Lai 9533*7dc08ffcSJunyu Laidata = b'\x90o\x14~YY\xf5h\xcc#\xd7\xcfUH\x00\x03\x167116621 \x000\x00' 9534*7dc08ffcSJunyu Laipkt = RTP(data) 9535*7dc08ffcSJunyu Laiassert "RTP" in pkt 9536*7dc08ffcSJunyu Laiparsed = pkt["RTP"] 9537*7dc08ffcSJunyu Laiassert parsed.version == 2 9538*7dc08ffcSJunyu Laiassert parsed.extension 9539*7dc08ffcSJunyu Laiassert parsed.numsync == 0 9540*7dc08ffcSJunyu Laiassert not parsed.marker 9541*7dc08ffcSJunyu Laiassert parsed.payload_type == 111 9542*7dc08ffcSJunyu Laiassert parsed.sequence == 5246 9543*7dc08ffcSJunyu Laiassert parsed.timestamp == 1499067752 9544*7dc08ffcSJunyu Laiassert parsed.sourcesync == 0xcc23d7cf 9545*7dc08ffcSJunyu Laiassert "RTPExtension" in parsed, parsed.show() 9546*7dc08ffcSJunyu Laiassert parsed["RTPExtension"].header_id == 0x5548 9547*7dc08ffcSJunyu Laiassert parsed["RTPExtension"].header == [0x16373131,0x36363231,0x20003000] 9548*7dc08ffcSJunyu Lai 9549*7dc08ffcSJunyu Lai= test layer creation 9550*7dc08ffcSJunyu Lai 9551*7dc08ffcSJunyu Laicreated = RTP(extension=True, payload_type="PCMA", sequence=0x1234, timestamp=12345678, sourcesync=0xabcdef01) 9552*7dc08ffcSJunyu Laicreated /= RTPExtension(header_id=0x4321, header=[0x11223344]) 9553*7dc08ffcSJunyu Laiassert raw(created) == b'\x90\x08\x124\x00\xbcaN\xab\xcd\xef\x01C!\x00\x01\x11"3D' 9554*7dc08ffcSJunyu Laiparsed = RTP(raw(created)) 9555*7dc08ffcSJunyu Laiassert parsed.payload_type == 8 9556*7dc08ffcSJunyu Laiassert "RTPExtension" in parsed, parsed.show() 9557*7dc08ffcSJunyu Laiassert parsed["RTPExtension"].header == [0x11223344] 9558*7dc08ffcSJunyu Lai 9559*7dc08ffcSJunyu Lai= test RTP without extension 9560*7dc08ffcSJunyu Lai 9561*7dc08ffcSJunyu Laicreated = RTP(extension=False, payload_type="DVI4", sequence=0x1234, timestamp=12345678, sourcesync=0xabcdef01) 9562*7dc08ffcSJunyu Laiassert raw(created) == b'\x80\x11\x124\x00\xbcaN\xab\xcd\xef\x01' 9563*7dc08ffcSJunyu Laiparsed = RTP(raw(created)) 9564*7dc08ffcSJunyu Laiassert parsed.sourcesync == 0xabcdef01 9565*7dc08ffcSJunyu Laiassert "RTPExtension" not in parsed 9566