public FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow arg) { this._match = arg.getMatch(); this._instructions = arg.getInstructions(); this._containerName = arg.getContainerName(); this._cookieMask = arg.getCookieMask(); this._bufferId = arg.getBufferId(); this._outPort = arg.getOutPort(); this._outGroup = arg.getOutGroup(); this._flags = arg.getFlags(); this._flowName = arg.getFlowName(); this._installHw = arg.isInstallHw(); this._barrier = arg.isBarrier(); this._strict = arg.isStrict(); this._priority = arg.getPriority(); this._idleTimeout = arg.getIdleTimeout(); this._hardTimeout = arg.getHardTimeout(); this._cookie = arg.getCookie(); this._tableId = arg.getTableId(); }
/** * Determine whether the given MD-SAL flow entry is identical to this * instance or not. * * @param flow The MD-SAL flow entry to be compared. * @return {@code true} if identical. Otherwise {@code false}. */ public boolean equalsFlow( org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow flow) { return (tableId == getInteger(flow.getTableId(), FIELD_TABLE_ID) && priority == getInteger(flow.getPriority(), FIELD_PRIORITY) && flowMatch.equals(flow.getMatch())); }
if (statsFlow.getContainerName()== null) { if (storedFlow.getContainerName()!= null) { return false; } else if(!statsFlow.getContainerName().equals(storedFlow.getContainerName())) { return false; if (storedFlow.getPriority() == null) { if (statsFlow.getPriority() != null && statsFlow.getPriority()!= 0x8000) { return false; } else if(!statsFlow.getPriority().equals(storedFlow.getPriority())) { return false; if (statsFlow.getMatch()== null) { if (storedFlow.getMatch() != null) { return false; } else if(!matchEquals(statsFlow.getMatch(), storedFlow.getMatch())) { return false; if (statsFlow.getTableId() == null) { if (storedFlow.getTableId() != null) { return false; } else if(!statsFlow.getTableId().equals(storedFlow.getTableId())) { return false;
boolean isValidArg = false; if (arg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) { this._match = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getMatch(); this._instructions = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getInstructions(); this._containerName = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getContainerName(); this._cookieMask = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getCookieMask(); this._bufferId = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getBufferId(); this._outPort = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getOutPort(); this._outGroup = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getOutGroup(); this._flags = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getFlags(); this._flowName = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getFlowName(); this._installHw = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).isInstallHw(); this._barrier = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).isBarrier(); this._strict = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).isStrict(); isValidArg = true;
/** * Construct a new instance. * * @param nid The node identifier. * @param flow A {@link Flow} instance. * @throws IllegalArgumentException * {@code flow} is invalid. */ public OfMockFlowEntry( String nid, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow flow) { if (flow == null) { throw new IllegalArgumentException("Input cannot be null."); } nodeIdentifier = nid; tableId = getInteger(flow.getTableId(), FIELD_TABLE_ID); priority = getInteger(flow.getPriority(), FIELD_PRIORITY); idleTimeout = getInteger(flow.getIdleTimeout(), FIELD_IDLE_TIMEOUT); hardTimeout = getInteger(flow.getHardTimeout(), FIELD_HARD_TIMEOUT); flowCookie = OfMockUtils.getCookie(flow.getCookie()); flowMatch = verify(flow.getMatch()); flowInstructions = flow.getInstructions(); flowModFlags = flow.getFlags(); }
/** * Construct a new instance. * * @param node The target node. * @param cond The MD-SAL flow entry that specifies the condition to * select flow entries. */ public FlowMatcher(OfNode node, Flow cond) { tableId = cond.getTableId(); flowMatch = cond.getMatch(); BigInteger oport = cond.getOutPort(); outPort = (oport == null) ? null : OfMockUtils.getPortIdentifier(node.getNodeIdentifier(), oport); cookieMatcher = new CookieMatcher( node.getOfVersion(), cond.getCookie(), cond.getCookieMask()); validMatch = isMatchValid(); }
private FlowModInputBuilder toFlowModInput(Flow flow, short version, BigInteger datapathid) { FlowModInputBuilder flowMod = new FlowModInputBuilder(); salToOFFlowCookie(flow, flowMod); salToOFFlowCookieMask(flow, flowMod); salToOFFlowTableId(flow, flowMod); salToOFFlowCommand(flow, flowMod); salToOFFlowIdleTimeout(flow, flowMod); salToOFFlowHardTimeout(flow, flowMod); salToOFFlowPriority(flow, flowMod); salToOFFlowBufferId(flow, flowMod); salToOFFlowOutPort(flow, flowMod); salToOFFlowOutGroup(flow, flowMod); // convert and inject flowFlags FlowFlagReactor.getInstance().convert(flow.getFlags(), version, flowMod, getConvertorExecutor()); // convert and inject match MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod, getConvertorExecutor()); if (flow.getInstructions() != null) { flowMod.setInstruction(toInstructions(flow, version, datapathid)); flowMod.setAction(getActions(version, datapathid, flow)); } flowMod.setVersion(version); return flowMod; }
/** * Compares flows by whole match */ @Override public boolean areObjectsEqual(final Flow statsFlow, final Flow storedFlow) { if (statsFlow.getMatch() == null) { if (storedFlow.getMatch() != null) { return false; } } else if (!compareMatches(statsFlow.getMatch(), storedFlow.getMatch())) { return false; } return true; } };
/** * Compares flows by table ID */ @Override public boolean areObjectsEqual(final Flow statsFlow, final Flow storedFlow) { if (statsFlow.getTableId() == null) { if (storedFlow.getTableId() != null) { return false; } } else if (!statsFlow.getTableId().equals(storedFlow.getTableId())) { return false; } return true; } };
/** * Check whether the output port configured in the specified MD-SAL flow * entry meets the condition specified by this instance. * * @param flow The MD-SAL flow entry to be tested. * @return {@code true} if the specified flow entry meets the conditions. * {@code false} otherwise. */ private boolean checkOutPort(Flow flow) { return (outPort == null || OfMockUtils.hasOutput(flow.getInstructions(), outPort)); } }
/** * Compares flows by cookie value */ @Override public boolean areObjectsEqual(final Flow statsFlow, final Flow storedFlow) { /* * Cookie is an optional field, so user might not set it, but if switch * get flow without cookie value , it will use 0 as a default cookie value * and return cookie=0 when openflowplugin fetch the flow stats from switch. * In this scenario flow comparison will fail. Below check make sure that * if user didn't set cookie value while flow installation, skip the comparison. */ if(storedFlow.getCookie() == null){ return true; } if (statsFlow.getCookie() == null) { if (storedFlow.getCookie() != null) { return false; } } else if (!statsFlow.getCookie().equals(storedFlow.getCookie())) { return false; } return true; } };
/** * Compares flows by priority */ @Override public boolean areObjectsEqual(final Flow statsFlow, final Flow storedFlow) { if (storedFlow.getPriority() == null) { if (statsFlow.getPriority() != null && statsFlow.getPriority() != 0x8000) { return false; } } else if (!statsFlow.getPriority().equals(storedFlow.getPriority())) { return false; } return true; } };
/** * Compares flows by container name */ @Override public boolean areObjectsEqual(Flow statsFlow, Flow storedFlow) { if (statsFlow.getContainerName() == null) { if (storedFlow.getContainerName() != null) { return false; } } else if (!statsFlow.getContainerName().equals(storedFlow.getContainerName())) { return false; } return true; } };
private static void salToOFFlowHardTimeout(Flow flow, FlowModInputBuilder flowMod) { if (flow.getHardTimeout() != null) { flowMod.setHardTimeout(flow.getHardTimeout()); } else { flowMod.setHardTimeout(DEFAULT_HARD_TIMEOUT); } }
private static void salToOFFlowIdleTimeout(Flow flow, FlowModInputBuilder flowMod) { if (flow.getIdleTimeout() != null) { flowMod.setIdleTimeout(flow.getIdleTimeout()); } else { flowMod.setIdleTimeout(DEFAULT_IDLE_TIMEOUT); } }
private static void salToOFFlowCookieMask(Flow flow, FlowModInputBuilder flowMod) { if (flow.getCookieMask() != null) { flowMod.setCookieMask(flow.getCookieMask().getValue()); } else { flowMod.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK); } }
boolean isValidArg = false; if (arg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) { this._match = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getMatch(); this._instructions = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getInstructions(); this._containerName = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getContainerName(); this._cookieMask = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getCookieMask(); this._bufferId = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getBufferId(); this._outPort = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getOutPort(); this._outGroup = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getOutGroup(); this._flags = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getFlags(); this._flowName = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).getFlowName(); this._installHw = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).isInstallHw(); this._barrier = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).isBarrier(); this._strict = ((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)arg).isStrict(); isValidArg = true;
/** * Safely gets ip protocol from flow. * * @param flow the flow * @return the ip protocol from flow */ public static Short getIpProtocolFromFlow(Flow flow) { Short ipProtocol = null; if (flow.getMatch() != null && flow.getMatch().getIpMatch() != null) { ipProtocol = flow.getMatch().getIpMatch().getIpProtocol(); } return ipProtocol; } }
/** * Return the flow table ID in the given flow entry. * * @param flow The MD-SAL flow entry. * @return The flow table ID in the given flow entry. * @throws IllegalArgumentException * The flow table ID in the given flow entry is invalid. */ public Short getTableId(Flow flow) { Short table = flow.getTableId(); if (table == null) { throw new IllegalArgumentException("table-id cannot be null."); } if (table.shortValue() != TABLE_ID) { throw new IllegalArgumentException( "Unsupported table-id: " + table); } return table; }
public static List<Action> getAction( org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source) { if (source.getInstructions() != null) { for (Instruction instruction : source.getInstructions().getInstruction()) { if (instruction.getInstruction() instanceof ApplyActionsCase) { return (((ApplyActionsCase) instruction.getInstruction()).getApplyActions().getAction()); } } } // TODO Auto-generated method stub return Collections.emptyList(); }