xref: /aosp_15_r20/external/scapy/scapy/contrib/homeplugav.uts (revision 7dc08ffc4802948ccbc861daaf1e81c405c2c4bd)
1*7dc08ffcSJunyu Lai% Regression tests for Scapy
2*7dc08ffcSJunyu Lai
3*7dc08ffcSJunyu Lai# HomePlugAV
4*7dc08ffcSJunyu Lai
5*7dc08ffcSJunyu Lai############
6*7dc08ffcSJunyu Lai############
7*7dc08ffcSJunyu Lai+ Basic tests
8*7dc08ffcSJunyu Lai
9*7dc08ffcSJunyu Lai* Those test are here mainly to check nothing has been broken
10*7dc08ffcSJunyu Lai
11*7dc08ffcSJunyu Lai= Building packets packet
12*7dc08ffcSJunyu Lai~ basic HomePlugAV GetDeviceVersion StartMACRequest StartMACConfirmation ResetDeviceRequest ResetDeviceConfirmation NetworkInformationRequest ReadMACMemoryRequest ReadMACMemoryConfirmation ReadModuleDataRequest ReadModuleDataConfirmation WriteModuleDataRequest WriteModuleData2NVMRequest WriteModuleData2NVMConfirmation NetworkInfoConfirmationV10 NetworkInfoConfirmationV11 NetworkInfoV10 NetworkInfoV11 HostActionRequired LoopbackRequest LoopbackConfirmation SetEncryptionKeyRequest SetEncryptionKeyConfirmation ReadConfBlockRequest ReadConfBlockConfirmation QUAResetFactoryConfirm GetNVMParametersRequest GetNVMParametersConfirmation SnifferRequest SnifferConfirmation SnifferIndicate
13*7dc08ffcSJunyu Lai
14*7dc08ffcSJunyu LaiHomePlugAV()
15*7dc08ffcSJunyu LaiHomePlugAV()/GetDeviceVersion()
16*7dc08ffcSJunyu LaiHomePlugAV()/StartMACRequest()
17*7dc08ffcSJunyu LaiHomePlugAV()/StartMACConfirmation()
18*7dc08ffcSJunyu LaiHomePlugAV()/ResetDeviceRequest()
19*7dc08ffcSJunyu LaiHomePlugAV()/ResetDeviceConfirmation()
20*7dc08ffcSJunyu LaiHomePlugAV()/NetworkInformationRequest()
21*7dc08ffcSJunyu LaiHomePlugAV()/ReadMACMemoryRequest()
22*7dc08ffcSJunyu LaiHomePlugAV()/ReadMACMemoryConfirmation()
23*7dc08ffcSJunyu LaiHomePlugAV()/ReadModuleDataRequest()
24*7dc08ffcSJunyu LaiHomePlugAV()/ReadModuleDataConfirmation()
25*7dc08ffcSJunyu LaiHomePlugAV()/WriteModuleDataRequest()
26*7dc08ffcSJunyu LaiHomePlugAV()/WriteModuleData2NVMRequest()
27*7dc08ffcSJunyu LaiHomePlugAV()/WriteModuleData2NVMConfirmation()
28*7dc08ffcSJunyu LaiHomePlugAV()/NetworkInfoConfirmationV10()
29*7dc08ffcSJunyu LaiHomePlugAV()/NetworkInfoConfirmationV11()
30*7dc08ffcSJunyu LaiHomePlugAV()/NetworkInfoConfirmationV10()/NetworkInfoV10()
31*7dc08ffcSJunyu LaiHomePlugAV()/NetworkInfoConfirmationV11()/NetworkInfoV11()
32*7dc08ffcSJunyu LaiHomePlugAV()/HostActionRequired()
33*7dc08ffcSJunyu LaiHomePlugAV()/LoopbackRequest()
34*7dc08ffcSJunyu LaiHomePlugAV()/LoopbackConfirmation()
35*7dc08ffcSJunyu LaiHomePlugAV()/SetEncryptionKeyRequest()
36*7dc08ffcSJunyu LaiHomePlugAV()/SetEncryptionKeyConfirmation()
37*7dc08ffcSJunyu LaiHomePlugAV()/ReadConfBlockRequest()
38*7dc08ffcSJunyu LaiHomePlugAV()/ReadConfBlockConfirmation()
39*7dc08ffcSJunyu LaiHomePlugAV()/QUAResetFactoryConfirm()
40*7dc08ffcSJunyu LaiHomePlugAV()/GetNVMParametersRequest()
41*7dc08ffcSJunyu LaiHomePlugAV()/GetNVMParametersConfirmation()
42*7dc08ffcSJunyu LaiHomePlugAV()/SnifferRequest()
43*7dc08ffcSJunyu LaiHomePlugAV()/SnifferConfirmation()
44*7dc08ffcSJunyu LaiHomePlugAV()/SnifferIndicate()
45*7dc08ffcSJunyu Lai
46*7dc08ffcSJunyu Lai= Some important manipulations
47*7dc08ffcSJunyu Lai~ field
48*7dc08ffcSJunyu Laipkt = HomePlugAV()/SetEncryptionKeyRequest()
49*7dc08ffcSJunyu Laipkt.NMK = "A" * 16
50*7dc08ffcSJunyu Laipkt.DAK = "B" * 16
51*7dc08ffcSJunyu Lairaw(pkt)
52*7dc08ffcSJunyu Lai_ == b"\x00P\xa0\x00\xb0R\x00AAAAAAAAAAAAAAAA\x00\xff\xff\xff\xff\xff\xffBBBBBBBBBBBBBBBB"
53*7dc08ffcSJunyu Lai
54*7dc08ffcSJunyu Laipkt = HomePlugAV()/ReadMACMemoryRequest()
55*7dc08ffcSJunyu Laipkt.Address = 0x31337
56*7dc08ffcSJunyu Laipkt.Length = 0x666
57*7dc08ffcSJunyu Lairaw(pkt)
58*7dc08ffcSJunyu Lai_ == b"\x00\x08\xa0\x00\xb0R7\x13\x03\x00f\x06\x00\x00"
59*7dc08ffcSJunyu Lai
60*7dc08ffcSJunyu Laipkt = HomePlugAV()/ReadModuleDataRequest()
61*7dc08ffcSJunyu Laipkt.Length = 0x666
62*7dc08ffcSJunyu Laipkt.Offset = 0x1337
63*7dc08ffcSJunyu Lairaw(pkt)
64*7dc08ffcSJunyu Laiassert(_ == b"\x00$\xa0\x00\xb0R\x02\x00f\x067\x13\x00\x00")
65*7dc08ffcSJunyu Lai
66*7dc08ffcSJunyu Laipkt = HomePlugAV()/SnifferRequest()
67*7dc08ffcSJunyu Laipkt.SnifferControl = 0x1
68*7dc08ffcSJunyu Lairaw(pkt)
69*7dc08ffcSJunyu Lai_ == b"\x004\xa0\x00\xb0R\x01"
70*7dc08ffcSJunyu Lai
71*7dc08ffcSJunyu Lai= Some important fields parsing
72*7dc08ffcSJunyu Lai~ field
73*7dc08ffcSJunyu Lai_xstr = b"\x00%\xa0\x00\xb0R\x00\x00\x00\x00\x02\x00\x00\x04\x00\x00\x00\x00`\x8d\x05\xf9\x04\x01\x00\x00\x88)\x00\x00\x87`[\x14\x00$\xd4okm\x1f\xedHu\x85\x16>\x86\x1aKM\xd2\xe91\xfc6\x00\x00603506A112119017\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00z]\xa9\xe2]\xedR\x8b\x85\\\xdf\xe8~\xe9\xb2\x14637000A112139290\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00FREEPLUG_LC_6400_4-1_1.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\xbb\xcb\x0e\x10 \xad\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\x01\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00`\xe5\x16\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\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\x01\x03\x02\x80\x84\x1e\x00\x80\x84\x1e\x00\xe0\x93\x04\x00\xe0\x93\x04\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\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
74*7dc08ffcSJunyu Lai
75*7dc08ffcSJunyu Laipkt = HomePlugAV(_xstr)
76*7dc08ffcSJunyu LaiReadModuleDataConfirmation in pkt
77*7dc08ffcSJunyu Lai_ == True
78*7dc08ffcSJunyu Lai(pkt[ReadModuleDataConfirmation].ModuleID == 2, pkt[ReadModuleDataConfirmation].checksum == 4177890656, pkt[ReadModuleDataConfirmation].DataLen == 1024, pkt[ReadModuleDataConfirmation].Offset == 0)
79*7dc08ffcSJunyu Lai_ == (True, True, True, True)
80*7dc08ffcSJunyu Lai
81*7dc08ffcSJunyu LaiModulePIB(pkt.ModuleData, pkt.Offset, pkt.DataLen)
82*7dc08ffcSJunyu Lai(_.NMK == b"z]\xa9\xe2]\xedR\x8b\x85\\\xdf\xe8~\xe9\xb2\x14", _.DAK == b"\x1f\xedHu\x85\x16>\x86\x1aKM\xd2\xe91\xfc6")
83*7dc08ffcSJunyu Lai_ == (True, True)
84*7dc08ffcSJunyu Lai
85*7dc08ffcSJunyu Lai#= Discovery packet tests in local
86*7dc08ffcSJunyu Lai#~ netaccess HomePlugAV NetworkInfoConfirmationV10 NetworkInfoConfirmationV11
87*7dc08ffcSJunyu Lai#pkt = Ether()/HomePlugAV()
88*7dc08ffcSJunyu Lai#old_debug_dissector = conf.debug_dissector
89*7dc08ffcSJunyu Lai#conf.debug_dissector = False
90*7dc08ffcSJunyu Lai#a = srp1(pkt, iface="eth0")
91*7dc08ffcSJunyu Lai#conf.debug_dissector = old_debug_dissector
92*7dc08ffcSJunyu Lai#a
93*7dc08ffcSJunyu Lai#pkt.version = a.version
94*7dc08ffcSJunyu Lai#pkt /= NetworkInformationRequest()
95*7dc08ffcSJunyu Lai#old_debug_dissector = conf.debug_dissector
96*7dc08ffcSJunyu Lai#conf.debug_dissector = False
97*7dc08ffcSJunyu Lai#a = srp1(pkt, iface="eth0")
98*7dc08ffcSJunyu Lai#conf.debug_dissector = old_debug_dissector
99*7dc08ffcSJunyu Lai#NetworkInfoConfirmationV10 in a or NetworkInfoConfirmationV11 in a
100*7dc08ffcSJunyu Lai#_ == True
101*7dc08ffcSJunyu Lai
102*7dc08ffcSJunyu Lai#= Reading local 0x400st octets of Software Image in Module Data blocks
103*7dc08ffcSJunyu Lai#~ netaccess HomePlugAV ReadModuleDataRequest
104*7dc08ffcSJunyu Lai#pkt = Ether()/HomePlugAV()/ReadModuleDataRequest(ModuleID=0x1)
105*7dc08ffcSJunyu Lai#old_debug_dissector = conf.debug_dissector
106*7dc08ffcSJunyu Lai#conf.debug_dissector = False
107*7dc08ffcSJunyu Lai#a = srp1(pkt, iface="eth0")
108*7dc08ffcSJunyu Lai#conf.debug_dissector = old_debug_dissector
109*7dc08ffcSJunyu Lai#a
110*7dc08ffcSJunyu Lai#len(a.ModuleData) == pkt.Length
111*7dc08ffcSJunyu Lai#_ == True
112*7dc08ffcSJunyu Lai
113*7dc08ffcSJunyu Lai= Testing length and checksum on a generated Write Module Data Request
114*7dc08ffcSJunyu Laistring = b"goodchoucroute\x00\x00"
115*7dc08ffcSJunyu Laipkt = WriteModuleDataRequest(ModuleData=string)
116*7dc08ffcSJunyu Laipkt = WriteModuleDataRequest(pkt.build())
117*7dc08ffcSJunyu Laipkt.show()
118*7dc08ffcSJunyu Lai(pkt.checksum == chksum32(pkt.ModuleData), pkt.DataLen == len(pkt.ModuleData))
119*7dc08ffcSJunyu Lai_ == (True, True)
120