Interface RoleHandler


  • public interface RoleHandler
    Role handling.
    • Method Detail

      • extractNiciraRoleReply

        RoleState extractNiciraRoleReply​(org.projectfloodlight.openflow.protocol.OFExperimenter experimenterMsg)
                                  throws SwitchStateException
        Extract the role from an OFVendor message. Extract the role from an OFVendor message if the message is a Nicira role reply. Otherwise return null.
        Parameters:
        experimenterMsg - The vendor message to parse.
        Returns:
        The role in the message if the message is a Nicira role reply, null otherwise.
        Throws:
        SwitchStateException - If the message is a Nicira role reply but the numeric role value is unknown.
      • sendRoleRequest

        boolean sendRoleRequest​(RoleState role,
                                RoleRecvStatus exp)
                         throws java.io.IOException
        Send a role request with the given role to the switch and update the pending request and timestamp. Sends an OFPT_ROLE_REQUEST to an OF1.3 switch, OR Sends an NX_ROLE_REQUEST to an OF1.0 switch if configured to support it in the IOFSwitch driver. If not supported, this method sends nothing and returns 'false'. The caller should take appropriate action. One other optimization we do here is that for OF1.0 switches with Nicira role message support, we force the Role.EQUAL to become Role.SLAVE, as there is no defined behavior for the Nicira role OTHER. We cannot expect it to behave like SLAVE. We don't have this problem with OF1.3 switches, because Role.EQUAL is well defined and we can simulate SLAVE behavior by using ASYNC messages.
        Parameters:
        role - role to request
        exp - expectation
        Returns:
        false if and only if the switch does not support role-request messages, according to the switch driver; true otherwise.
        Throws:
        java.io.IOException - when I/O exception of some sort has occurred
      • extractOFRoleReply

        RoleReplyInfo extractOFRoleReply​(org.projectfloodlight.openflow.protocol.OFRoleReply rrmsg)
                                  throws SwitchStateException
        Extract the role information from an OF1.3 Role Reply Message.
        Parameters:
        rrmsg - role reply message
        Returns:
        RoleReplyInfo object
        Throws:
        SwitchStateException - If unknown role encountered
      • deliverRoleReply

        RoleRecvStatus deliverRoleReply​(RoleReplyInfo rri)
                                 throws SwitchStateException
        Deliver a received role reply. Check if a request is pending and if the received reply matches the the expected pending reply (we check both role and xid) we set the role for the switch/channel. If a request is pending but doesn't match the reply we ignore it, and return If no request is pending we disconnect with a SwitchStateException
        Parameters:
        rri - information about role-reply in format that controller can understand.
        Returns:
        result comparing expected and received reply
        Throws:
        SwitchStateException - if no request is pending
      • deliverError

        RoleRecvStatus deliverError​(org.projectfloodlight.openflow.protocol.OFErrorMsg error)
                             throws SwitchStateException
        Called if we receive an error message. If the xid matches the pending request we handle it otherwise we ignore it. Note: since we only keep the last pending request we might get error messages for earlier role requests that we won't be able to handle
        Parameters:
        error - error message
        Returns:
        result comparing expected and received reply
        Throws:
        SwitchStateException - if switch did not support requested role