def add_simple_flow(self, table_id=0, in_port=None, out_port=None, priority=15, flags=0): # add simple entry that forward data from in_port to out_port match_req = None instruction_req = None if in_port != None: match_req = ofp.match([ofp.oxm.in_port(in_port)]) if out_port is not None: instruction_req = [ ofp.instruction.apply_actions([ofp.action.output(out_port)]) ] request = ofp.message.flow_add(table_id=table_id, match=match_req, instructions=instruction_req, buffer_id=ofp.OFP_NO_BUFFER, out_port=ofp.OFPP_ANY, out_group=ofp.OFPG_ANY, priority=priority, flags=flags) self.controller.message_send(request) testutils.do_barrier(self.controller)
def runTest(self): INFO = " 1.2.10 - Slave Controller Violation" role, gen = role_setup.request(self, ofp.OFPCR_ROLE_NOCHANGE) role_setup.request(self, ofp.OFPCR_ROLE_SLAVE, gen) # Generate requests not allowed in Slave Controller Role # Packet Out self.controller.message_send( ofp.message.packet_out(buffer_id=ofp.OFP_NO_BUFFER)) # Flow Modification self.controller.message_send( ofp.message.flow_delete( buffer_id=ofp.OFP_NO_BUFFER, out_port=ofp.OFPP_ANY, out_group=ofp.OFPG_ANY)) # Group Modification self.controller.message_send( ofp.message.group_mod( command=ofp.OFPGC_DELETE, group_id=ofp.OFPG_ALL)) # Port Modification self.controller.message_send( ofp.message.port_mod( port_no=ofp.OFPP_MAX)) # Table Modification self.controller.message_send( ofp.message.table_mod( table_id=1)) # Since Table Features is unsupported in OF1.3, we skip it testutils.do_barrier(self.controller) try: err_count = 0 while self.controller.packets: msg = self.controller.packets.pop(0)[0] if msg.type == ofp.OFPT_ERROR: self.assertEquals(msg.err_type, ofp.OFPET_BAD_REQUEST) self.assertEquals(msg.code, ofp.OFPBRC_EPERM) err_count += 1 self.assertEquals(err_count, 5, "Expected errors for each message") log.info(PASS + INFO) except AssertionError, Err: log.info(FAIL + INFO) log.info(REASON + " -> "+ str(Err))
def runTest(self): INFO = " 1.2.10 - Slave Controller Violation" role, gen = role_setup.request(self, ofp.OFPCR_ROLE_NOCHANGE) role_setup.request(self, ofp.OFPCR_ROLE_SLAVE, gen) # Generate requests not allowed in Slave Controller Role # Packet Out self.controller.message_send( ofp.message.packet_out(buffer_id=ofp.OFP_NO_BUFFER)) # Flow Modification self.controller.message_send( ofp.message.flow_delete(buffer_id=ofp.OFP_NO_BUFFER, out_port=ofp.OFPP_ANY, out_group=ofp.OFPG_ANY)) # Group Modification self.controller.message_send( ofp.message.group_mod(command=ofp.OFPGC_DELETE, group_id=ofp.OFPG_ALL)) # Port Modification self.controller.message_send( ofp.message.port_mod(port_no=ofp.OFPP_MAX)) # Table Modification self.controller.message_send(ofp.message.table_mod(table_id=1)) # Since Table Features is unsupported in OF1.3, we skip it testutils.do_barrier(self.controller) try: err_count = 0 while self.controller.packets: msg = self.controller.packets.pop(0)[0] if msg.type == ofp.OFPT_ERROR: self.assertEquals(msg.err_type, ofp.OFPET_BAD_REQUEST) self.assertEquals(msg.code, ofp.OFPBRC_EPERM) err_count += 1 self.assertEquals(err_count, 5, "Expected errors for each message") log.info(PASS + INFO) except AssertionError, Err: log.info(FAIL + INFO) log.info(REASON + " -> " + str(Err))
def add_simple_flow(self, table_id=0, in_port=None, out_port=None, priority=15, flags=0): # add simple entry that forward data from in_port to out_port match_req = None instruction_req = None if in_port != None: match_req = ofp.match([ofp.oxm.in_port(in_port)]) if out_port is not None: instruction_req = [ofp.instruction.apply_actions([ofp.action.output(out_port)])] request = ofp.message.flow_add( table_id=table_id, match=match_req, instructions=instruction_req, buffer_id=ofp.OFP_NO_BUFFER, out_port=ofp.OFPP_ANY, out_group=ofp.OFPG_ANY, priority=priority, flags=flags ) self.controller.message_send(request) testutils.do_barrier(self.controller)