@Override public void write(Dpid dpid, OFMessage msg) { this.getSwitch(dpid).sendMsg(msg); }
@Override public void setRole(Dpid dpid, RoleState role) { final OpenFlowSwitch sw = getSwitch(dpid); if (sw == null) { log.debug("Switch not connected. Ignoring setRole({}, {})", dpid, role); return; } sw.setRole(role); }
@Override public void transitionToMasterSwitch(Dpid dpid) { switchLock.lock(); try { if (activeMasterSwitches.containsKey(dpid)) { return; } OpenFlowSwitch sw = activeEqualSwitches.remove(dpid); if (sw == null) { sw = getSwitch(dpid); if (sw == null) { log.error("Transition to master called on sw {}, but switch " + "was not found in controller-cache", dpid); return; } } log.info("Transitioned switch {} to MASTER", dpid); activeMasterSwitches.put(dpid, sw); } finally { switchLock.unlock(); } }
@Override public void transitionToEqualSwitch(Dpid dpid) { switchLock.lock(); try { if (activeEqualSwitches.containsKey(dpid)) { return; } OpenFlowSwitch sw = activeMasterSwitches.remove(dpid); if (sw == null) { sw = getSwitch(dpid); if (sw == null) { log.error("Transition to equal called on sw {}, but switch " + "was not found in controller-cache", dpid); return; } } log.info("Transitioned switch {} to EQUAL", dpid); activeEqualSwitches.put(dpid, sw); } finally { switchLock.unlock(); } }
case PACKET_IN: OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext .packetContextFromPacketIn(this.getSwitch(dpid), (OFPacketIn) msg); for (PacketListener p : ofPacketListener.values()) { OFFlowStatsReply.Builder fsr = getSwitch(dpid).factory().buildFlowStatsReply(); List<OFFlowStatsEntry> entries = new LinkedList<>(); for (OFCalientFlowStatsEntry entry : ((OFCalientFlowStatsReply) msg).getEntries()) { .instructions() .applyActions(Collections.singletonList(action)); OFFlowStatsEntry fs = getSwitch(dpid).factory().buildFlowStatsEntry() .setMatch(entry.getMatch()) .setTableId(entry.getTableId()) OFPortStatus.Builder portStatus = this.getSwitch(dpid).factory().buildPortStatus(); OFPortDesc.Builder portDesc = this.getSwitch(dpid).factory().buildPortDesc(); portDesc.setPortNo(circuitPortStatus.getPortNo()) .setHwAddr(circuitPortStatus.getHwAddr())