예제 #1
0
    def run_instruction(self, switch, inst, packet):
        """
        Private function to execute one instruction on a packet.
        Need switch for immeidate apply
        """
        if inst.__class__ == instruction.instruction_goto_table:
            if inst.table_id >= self.n_tables:
                self.logger.error("Bad goto table %d" % inst.table_id)
            else:
                return inst.table_id
        elif inst.__class__ == instruction.instruction_write_actions:
            for action in inst.actions:
                packet.write_action(action)
        elif inst.__class__ == instruction.instruction_apply_actions:
            execute_actions(switch, packet, inst.actions)
        elif inst.__class__ == instruction.instruction_experimenter:
            self.logger.error("Got experimenter instruction")
        elif inst.__class__ == instruction.instruction_write_metadata:
            packet.set_metadata(inst.metadata, inst.metadata_mask)
        elif inst.__class__ == instruction.instruction_clear_actions:
            packet.clear_actions()
        else:
            self.logger.error("Bad instruction")

        return None
예제 #2
0
    def run_instruction(self, switch, inst, packet):
        """
        Private function to execute one instruction on a packet.
        Need switch for immeidate apply
        """
        if inst.__class__ == instruction.instruction_goto_table:
            if inst.table_id >= self.n_tables:
                self.logger.error("Bad goto table %d" % inst.table_id)
            else:
                return inst.table_id
        elif inst.__class__ == instruction.instruction_write_actions:
            for action in inst.actions:
                packet.write_action(action)
        elif inst.__class__ == instruction.instruction_apply_actions:
            execute_actions(switch, packet, inst.actions)
        elif inst.__class__ == instruction.instruction_experimenter:
            self.logger.error("Got experimenter instruction")
        elif inst.__class__ == instruction.instruction_write_metadata:
            packet.set_metadata(inst.metadata, inst.metadata_mask)
        elif inst.__class__ == instruction.instruction_clear_actions:
            packet.clear_actions()
        else:
            self.logger.error("Bad instruction")

        return None
예제 #3
0
def packet_out(switch, msg, rawmsg):
    """
    Process a packet_out message from the controller
    @param switch The main switch object
    @param msg The parsed message object of type packet_out
    @param rawmsg The actual packet received as a string
    """
    switch.logger.debug("Received packet_out from controller")
    packet = Packet(in_port=msg.in_port, data=msg.data)
    switch.logger.debug("Executing action list")
    print msg.actions.show()
    execute_actions(switch, packet, msg.actions)
예제 #4
0
def packet_out(switch, msg, rawmsg):
    """
    Process a packet_out message from the controller
    @param switch The main switch object
    @param msg The parsed message object of type packet_out
    @param rawmsg The actual packet received as a string
    """
    switch.logger.debug("Received packet_out from controller")
    packet = Packet(in_port=msg.in_port, data=msg.data)
    switch.logger.debug("Executing action list")
    print msg.actions.show()
    execute_actions(switch, packet, msg.actions)