def test19(self, datapath): data = struct.pack(osproto.OFP_EXP_STATE_MOD_PACK_STR, osproto.OFPSC_EXP_SET_GLOBAL_STATE) exp_type = osproto.OFPT_EXP_STATE_MOD msg = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(msg)
def test26(self, datapath): command = osproto.OFPSC_EXP_DEL_FLOW_STATE data = struct.pack(osproto.OFP_EXP_STATE_MOD_PACK_STR, command) data += struct.pack('!B3xIBBBB', 0, 3, 0, 0, 0, 1) exp_type = osproto.OFPT_EXP_STATE_MOD msg = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(msg)
def test21(self, datapath): command = osproto.OFPSC_EXP_STATEFUL_TABLE_CONFIG data = struct.pack(osproto.OFP_EXP_STATE_MOD_PACK_STR, command) data += struct.pack('!B', 0) exp_type = osproto.OFPT_EXP_STATE_MOD msg = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(msg)
def test32(self, datapath): from scapy.all import Ether, ARP self.send_table_mod(datapath) self.send_key_lookup(datapath) self.send_key_update(datapath) exp_type = bebaproto.OFPT_EXP_PKTTMP_MOD data = struct.pack('!B', bebaproto.OFPSC_ADD_PKTTMP) req = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(req)
def test14(self, datapath): self.send_table_mod(datapath) self.send_key_lookup(datapath) self.send_key_update(datapath) command = 255 data = struct.pack(osproto.OFP_EXP_STATE_MOD_PACK_STR, command) exp_type = osproto.OFPT_EXP_STATE_MOD msg = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(msg)
def test16(self, datapath): self.send_table_mod(datapath) self.send_key_lookup(datapath) self.send_key_update(datapath) command = osproto.OFPSC_EXP_SET_FLOW_STATE # instead of packing into '!Bx' data = struct.pack('!B', command) exp_type = osproto.OFPT_EXP_STATE_MOD msg = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(msg)
def _state_change(self, ev): dp = ev.datapath print("OFPStateChange {ip}:{port}".format(ip=ev.datapath.address[0], port=ev.datapath.address[1])) actions = [ofp_parser.OFPActionOutput(ofp.OFPP_FLOOD)] # out = ofp_parser.OFPPacketOut(datapath=dp, in_port=1, actions=actions) data = json.dumps({"cumprimento": "Bom dia", "hora": 10, "minuto": 34}) data = data + bytearray(1398 - len(data)) out = ofp_parser.OFPExperimenter(datapath=dp, experimenter=0x00000005, exp_type=20, data=bytearray(data)) dp.send_msg(out) time.sleep(.3)
def test15(self, datapath): self.send_table_mod(datapath) self.send_key_lookup(datapath) self.send_key_update(datapath) # dummy data payload command = 255 data = struct.pack(bebaproto.OFP_EXP_STATE_MOD_PACK_STR, command) exp_type = 2**32 - 1 msg = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(msg)
def test34(self, datapath): from scapy.all import Ether, ARP self.send_table_mod(datapath) self.send_key_lookup(datapath) self.send_key_update(datapath) pkt_data = str( Ether(src='00:01:02:03:04:05', dst='46:9c:96:30:ff:d5') / ARP(hwsrc='00:01:02:03:04:05', hwdst='46:9c:96:30:ff:d5', psrc="172.16.0.2", pdst='172.16.0.1', op=2)) command = bebaproto.OFPSC_DEL_PKTTMP data = struct.pack(bebaproto.OFP_EXP_PKTTMP_MOD_PACK_STR, command) exp_type = bebaproto.OFPT_EXP_PKTTMP_MOD req = ofparser.OFPExperimenter(datapath=datapath, experimenter=0xBEBABEBA, exp_type=exp_type, data=data) datapath.send_msg(req)