use of org.projectfloodlight.openflow.protocol.OFExperimenter in project onos by opennetworkinglab.
the class RoleManager method sendNxRoleRequest.
/**
* Send NX role request message to the switch requesting the specified
* role.
*
* @param role role to request
*/
private long sendNxRoleRequest(RoleState role) throws IOException {
// Convert the role enum to the appropriate role to send
OFNiciraControllerRole roleToSend = OFNiciraControllerRole.ROLE_OTHER;
switch(role) {
case MASTER:
roleToSend = OFNiciraControllerRole.ROLE_MASTER;
break;
case SLAVE:
case EQUAL:
default:
// ensuring that the only two roles sent to 1.0 switches with
// Nicira role support, are MASTER and SLAVE
roleToSend = OFNiciraControllerRole.ROLE_OTHER;
log.debug("Sending Nx Role.SLAVE to switch {}.", sw);
}
long xid = sw.getNextTransactionId();
OFExperimenter roleRequest = OFFactories.getFactory(OFVersion.OF_10).buildNiciraControllerRoleRequest().setXid(xid).setRole(roleToSend).build();
sw.sendRoleRequest(roleRequest);
return xid;
}
use of org.projectfloodlight.openflow.protocol.OFExperimenter in project onos by opennetworkinglab.
the class OpenFlowControllerImpl method processPacket.
@Override
public void processPacket(Dpid dpid, OFMessage msg) {
OpenFlowSwitch sw = this.getSwitch(dpid);
if (log.isTraceEnabled()) {
log.trace("Processing message from switch {} via openflow: {}", dpid, msg);
}
// Check if someone is waiting for this message
ConcurrentMap<Long, CompletableFuture<OFMessage>> xids = responses.get(dpid);
if (xids != null) {
CompletableFuture<OFMessage> future = xids.remove(msg.getXid());
if (future != null) {
future.complete(msg);
}
}
switch(msg.getType()) {
case PORT_STATUS:
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.portChanged(dpid, (OFPortStatus) msg);
}
break;
case FEATURES_REPLY:
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.switchChanged(dpid);
}
break;
case PACKET_IN:
if (sw == null) {
log.error("Ignoring PACKET_IN, switch {} is not found", dpid);
break;
}
OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext.packetContextFromPacketIn(sw, (OFPacketIn) msg);
for (PacketListener p : ofPacketListener.values()) {
p.handlePacket(pktCtx);
}
break;
// ie. Back to back error could cause us to starve.
case FLOW_REMOVED:
executorMsgs.execute(new OFMessageHandler(dpid, msg));
break;
case ERROR:
log.debug("Received error message from {}: {}", dpid, msg);
errorMsgs.putIfAbsent(msg.getXid(), true);
executorErrorMsgs.execute(new OFMessageHandler(dpid, msg));
break;
case STATS_REPLY:
processStatsReply(dpid, (OFStatsReply) msg);
break;
case BARRIER_REPLY:
if (errorMsgs.containsKey(msg.getXid())) {
// To make oferror msg handling and corresponding barrier reply serialized,
// executorErrorMsgs is used for both transaction
errorMsgs.remove(msg.getXid());
executorErrorMsgs.execute(new OFMessageHandler(dpid, msg));
} else {
executorBarrier.execute(new OFMessageHandler(dpid, msg));
}
break;
case EXPERIMENTER:
if (sw == null) {
log.error("Switch {} is not found", dpid);
break;
}
long experimenter = ((OFExperimenter) msg).getExperimenter();
if (experimenter == 0x748771) {
// LINC-OE port stats
OFCircuitPortStatus circuitPortStatus = (OFCircuitPortStatus) msg;
OFPortStatus.Builder portStatus = sw.factory().buildPortStatus();
OFPortDesc.Builder portDesc = sw.factory().buildPortDesc();
portDesc.setPortNo(circuitPortStatus.getPortNo()).setHwAddr(circuitPortStatus.getHwAddr()).setName(circuitPortStatus.getName()).setConfig(circuitPortStatus.getConfig()).setState(circuitPortStatus.getState());
portStatus.setReason(circuitPortStatus.getReason()).setDesc(portDesc.build());
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.portChanged(dpid, portStatus.build());
}
} else {
log.warn("Handling experimenter type {} not yet implemented", ((OFExperimenter) msg).getExperimenter(), msg);
}
break;
default:
log.warn("Handling message type {} not yet implemented {}", msg.getType(), msg);
}
}
Aggregations