1% HICP test campaign 2 3# 4# execute test: 5# > test/run_tests -t test/contrib/hicp.uts 6# 7 8+ Syntax check 9= Import the HICP layer 10from scapy.contrib.hicp import * 11 12+ HICP Module scan request 13= Build and dissect module scan 14pkt = HICPModuleScan() 15assert(pkt.hicp_command == b"Module scan") 16assert(raw(pkt) == b"MODULE SCAN\x00") 17pkt = HICP(b"Module scan\x00") 18assert(pkt.hicp_command == b"Module scan") 19 20+ HICP Module scan response 21= Build and dissect device description 22pkt=HICPModuleScanResponse(fieldbus_type="kwack") 23assert(pkt.protocol_version == b"1.00") 24assert(pkt.fieldbus_type == b"kwack") 25assert(pkt.mac_address == "ff:ff:ff:ff:ff:ff") 26pkt=HICP( 27b"\x50\x72\x6f\x74\x6f\x63\x6f\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e" \ 28b"\x20\x3d\x20\x31\x2e\x30\x30\x3b\x46\x42\x20\x74\x79\x70\x65\x20" \ 29b"\x3d\x20\x3b\x4d\x6f\x64\x75\x6c\x65\x20\x76\x65\x72\x73\x69\x6f" \ 30b"\x6e\x20\x3d\x20\x3b\x4d\x41\x43\x20\x3d\x20\x65\x65\x3a\x65\x65" \ 31b"\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3b\x49\x50\x20" \ 32b"\x3d\x20\x32\x35\x35\x2e\x32\x35\x35\x2e\x32\x35\x35\x2e\x32\x35" \ 33b"\x35\x3b\x53\x4e\x20\x3d\x20\x32\x35\x35\x2e\x32\x35\x35\x2e\x32" \ 34b"\x35\x35\x2e\x30\x3b\x47\x57\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e" \ 35b"\x30\x3b\x44\x48\x43\x50\x20\x3d\x20\x4f\x46\x46\x3b\x48\x4e\x20" \ 36b"\x3d\x20\x3b\x44\x4e\x53\x31\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e" \ 37b"\x30\x3b\x44\x4e\x53\x32\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e\x30" \ 38b"\x3b\x00" 39) 40assert(pkt.hicp_command == b"Module scan response") 41assert(pkt.protocol_version == b"1.00") 42assert(pkt.mac_address == "ee:ee:ee:ee:ee:ee") 43assert(pkt.subnet_mask == "255.255.255.0") 44pkt=HICP(b"Protocol version = 2; FB type = TEST;Module version = 1.0.0;MAC = cc:cc:cc:cc:cc:cc;IP = 192.168.1.1;SN = 255.255.255.0;GW = 192.168.1.254;DHCP=ON;HN = bonjour;DNS1 = 1.1.1.1;DNS2 = 2.2.2.2") 45assert(pkt.hicp_command == b"Module scan response") 46assert(pkt.protocol_version == b"2") 47assert(pkt.fieldbus_type == b"TEST") 48assert(pkt.module_version == b"1.0.0") 49assert(pkt.mac_address == "cc:cc:cc:cc:cc:cc") 50assert(pkt.ip_address == "192.168.1.1") 51assert(pkt.subnet_mask == "255.255.255.0") 52assert(pkt.gateway_address == "192.168.1.254") 53assert(pkt.dhcp == b"ON") 54assert(pkt.hostname == b"bonjour") 55assert(pkt.dns1 == "1.1.1.1") 56assert(pkt.dns2 == "2.2.2.2") 57 58+ HICP Wink request 59= Build and dissect Winks 60pkt = HICPWink(target="dd:dd:dd:dd:dd:dd") 61assert(pkt.target == "dd:dd:dd:dd:dd:dd") 62pkt = HICP(b"To: bb:bb:bb:bb:bb:bb;WINK;\x00") 63assert(pkt.target == "bb:bb:bb:bb:bb:bb") 64 65+ HICP Configure request 66= Build and dissect new network settings 67pkt = HICPConfigure(target="aa:aa:aa:aa:aa:aa", hostname="llama") 68assert(pkt.target == "aa:aa:aa:aa:aa:aa") 69assert(pkt.ip_address == "255.255.255.255") 70assert(pkt.hostname == b"llama") 71assert(raw(pkt) == b"Configure: aa-aa-aa-aa-aa-aa;IP = 255.255.255.255;SN = 255.255.255.0;GW = 0.0.0.0;DHCP = OFF;HN = llama;DNS1 = 0.0.0.0;DNS2 = 0.0.0.0;\x00") 72pkt = HICP(b"Configure: aa-aa-aa-aa-aa-aa;IP = 255.255.255.255;SN = 255.255.255.0;GW = 0.0.0.0;DHCP = OFF;HN = llama;DNS1 = 0.0.0.0;DNS2 = 0.0.0.0;\x00") 73assert(pkt.hicp_command == b"Configure") 74assert(pkt.target == "aa:aa:aa:aa:aa:aa") 75assert(pkt.ip_address == "255.255.255.255") 76assert(pkt.hostname == b"llama") 77 78+ HICP Configure response 79= Build and dissect successful response to configure request 80 81pkt = HICPReconfigured(source="11:00:00:00:00:00") 82assert(pkt.source == "11:00:00:00:00:00") 83assert(raw(pkt) == b"Reconfigured: 11-00-00-00-00-00\x00") 84pkt = HICP(b"\x52\x65\x63\x6f\x6e\x66\x69\x67\x75\x72\x65\x64\x3a\x20\x31\x31" \ 85b"\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00") 86assert(pkt.hicp_command == b"Reconfigured") 87assert(pkt.source == "11:00:00:00:00:00") 88 89+ HICP Configure error 90= Build and dissect error response to configure request 91 92pkt = HICPInvalidConfiguration(source="00:11:00:00:00:00") 93assert(pkt.source == "00:11:00:00:00:00") 94assert(raw(pkt) == b"Invalid Configuration: 00-11-00-00-00-00\x00") 95pkt = HICP( 96b"\x49\x6e\x76\x61\x6c\x69\x64\x20\x43\x6f\x6e\x66\x69\x67\x75\x72" \ 97b"\x61\x74\x69\x6f\x6e\x3a\x20\x30\x30\x2d\x31\x31\x2d\x30\x30\x2d" \ 98b"\x30\x30\x2d\x30\x30\x2d\x30\x30\x00" 99) 100assert(pkt.hicp_command == b"Invalid Configuration") 101assert(pkt.source == "00:11:00:00:00:00") 102 103+ HICP Configure invalid password 104= Build and dissect invalid password response to configure request 105 106pkt = HICPInvalidPassword(source="00:00:11:00:00:00") 107assert(pkt.source == "00:00:11:00:00:00") 108assert(raw(pkt) == b"Invalid Password: 00-00-11-00-00-00\x00") 109pkt = HICP(b"\x49\x6e\x76\x61\x6c\x69" \ 110b"\x64\x20\x50\x61\x73\x73\x77\x6f\x72\x64\x3a\x20\x30\x30\x2d\x30" \ 111b"\x30\x2d\x31\x31\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00") 112assert(pkt.hicp_command == b"Invalid Password") 113assert(pkt.source == "00:00:11:00:00:00") 114