use of org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleReply in project onos by opennetworkinglab.
the class RoleManager method extractNiciraRoleReply.
/**
* 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.
*
* @param experimenterMsg message
* @return 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.
*/
@Override
public RoleState extractNiciraRoleReply(OFExperimenter experimenterMsg) throws SwitchStateException {
int vendor = (int) experimenterMsg.getExperimenter();
if (vendor != 0x2320) {
return null;
}
OFNiciraControllerRoleReply nrr = (OFNiciraControllerRoleReply) experimenterMsg;
RoleState role = null;
OFNiciraControllerRole ncr = nrr.getRole();
switch(ncr) {
case ROLE_MASTER:
role = RoleState.MASTER;
break;
case ROLE_OTHER:
role = RoleState.EQUAL;
break;
case ROLE_SLAVE:
role = RoleState.SLAVE;
break;
// handled below
default:
}
if (role == null) {
String msg = String.format("Switch: [%s], " + "received NX_ROLE_REPLY with invalid role " + "value %s", sw.getStringId(), nrr.getRole());
throw new SwitchStateException(msg);
}
return role;
}
Aggregations