@Override public Boolean supportNxRole() { if (this.factory().getVersion() == OFVersion.OF_10) { return true; } return false; }
private boolean isGroupSupported(OpenFlowSwitch sw) { if (sw.factory().getVersion() == OFVersion.OF_10 || sw.factory().getVersion() == OFVersion.OF_11 || sw.factory().getVersion() == OFVersion.OF_12) { return false; } return true; }
@Override public List<OFPortDesc> getPorts() { if (this.factory().getVersion() == OFVersion.OF_10) { return Collections.unmodifiableList(features.getPorts()); } else { return Collections.unmodifiableList( ports.stream().flatMap(p -> p.getEntries().stream()) .collect(Collectors.toList())); } } }
/** * Creates a new flow mod builder. * * @param flowRule the flow rule to transform into a flow mod * @param factory the OpenFlow factory to use to build the flow mod * @param xid the transaction ID * @param driverService the device driver service * @return the new flow mod builder */ public static FlowModBuilder builder(FlowRule flowRule, OFFactory factory, Optional<Long> xid, Optional<DriverService> driverService) { switch (factory.getVersion()) { case OF_10: return new FlowModBuilderVer10(flowRule, factory, xid, driverService); case OF_13: return new FlowModBuilderVer13(flowRule, factory, xid, driverService); default: throw new UnsupportedOperationException( "No flow mod builder for protocol version " + factory.getVersion()); } }
@Override public synchronized boolean sendRoleRequest(RoleState role, RoleRecvStatus exp) throws IOException { this.expectation = exp; if (sw.factory().getVersion() == OFVersion.OF_10) { Boolean supportsNxRole = sw.supportNxRole(); if (!supportsNxRole) { log.debug("Switch driver indicates no support for Nicira " + "role request messages. Not sending ..."); handleUnsentRoleMessage(role, expectation); return false; } // OF1.0 switch with support for NX_ROLE_REQUEST vendor extn. // make Role.EQUAL become Role.SLAVE RoleState roleToSend = (role == RoleState.EQUAL) ? RoleState.SLAVE : role; pendingReplies.put(sendNxRoleRequest(roleToSend), role); } else { // OF1.3 switch, use OFPT_ROLE_REQUEST message pendingReplies.put(sendOF13RoleRequest(role), role); } return true; }
@Override public void startDriverHandshake() { if (factory().getVersion() == OFVersion.OF_10) { OFFlowAdd.Builder fmBuilder = factory().buildFlowAdd(); fmBuilder.setPriority(LOWEST_PRIORITY); sendHandshakeMessage(fmBuilder.build()); } }
@Override public void triggerProbe(DeviceId deviceId) { LOG.debug("Triggering probe on device {}", deviceId); final Dpid dpid = dpid(deviceId.uri()); OpenFlowSwitch sw = controller.getSwitch(dpid); if (sw == null || !sw.isConnected()) { LOG.error("Failed to probe device {} on sw={}", deviceId, sw); providerService.deviceDisconnected(deviceId); return; } else { LOG.trace("Confirmed device {} connection", deviceId); } // Prompt an update of port information. We can use any XID for this. OFFactory fact = sw.factory(); switch (fact.getVersion()) { case OF_10: sw.sendMsg(fact.buildFeaturesRequest().setXid(0).build()); break; case OF_13: sw.sendMsg(fact.buildPortDescStatsRequest().setXid(0).build()); break; default: LOG.warn("Unhandled protocol version"); } }
case METADATA: log.warn("Instruction type {} not supported with protocol version {}", i.type(), factory().getVersion()); break; default:
.set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString()) .set(AnnotationKeys.CHANNEL_ID, sw.channelId()) .set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0])