% Tests for OpenFlow v1.0 with Scapy + Preparation = Be sure we have loaded OpenFlow v1 load_contrib("openflow") + Usual OFv1.0 messages = OFPTHello(), simple hello message ofm = OFPTHello() raw(ofm) == b'\x01\x00\x00\x08\x00\x00\x00\x00' = OFPTEchoRequest(), echo request ofm = OFPTEchoRequest() raw(ofm) == b'\x01\x02\x00\x08\x00\x00\x00\x00' = OFPMatch(), check wildcard completion ofm = OFPMatch(in_port=1, nw_tos=8) ofm = OFPMatch(raw(ofm)) assert(ofm.wildcards1 == 0x1) ofm.wildcards2 == 0xee = OpenFlow(), generic method test with OFPTEchoRequest() ofm = OFPTEchoRequest() s = raw(ofm) isinstance(OpenFlow(s), OFPTEchoRequest) = OFPTFlowMod(), check codes and defaults values ofm = OFPTFlowMod(cmd='OFPFC_DELETE', out_port='CONTROLLER', flags='CHECK_OVERLAP+EMERG') assert(ofm.cmd == 3) assert(ofm.buffer_id == 0xffffffff) assert(ofm.out_port == 0xfffd) ofm.flags == 6 + Complex OFv1.0 messages = OFPTFlowMod(), complex flow_mod mtc = OFPMatch(dl_vlan=10, nw_src='192.168.42.0', nw_src_mask=8) act1 = OFPATSetNwSrc(nw_addr='192.168.42.1') act2 = OFPATOutput(port='CONTROLLER') act3 = OFPATSetDlSrc(dl_addr='1a:d5:cb:4e:3c:64') ofm = OFPTFlowMod(priority=1000, match=mtc, flags='CHECK_OVERLAP', actions=[act1,act2,act3]) raw(ofm) s = b'\x01\x0e\x00h\x00\x00\x00\x00\x00?\xc8\xed\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x08\x00\x00\x00\x00\x00\xc0\xa8*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xe8\xff\xff\xff\xff\xff\xff\x00\x02\x00\x06\x00\x08\xc0\xa8*\x01\x00\x00\x00\x08\xff\xfd\xff\xff\x00\x04\x00\x10\x1a\xd5\xcbN