SfcScfOfUtils { public static FlowBuilder createClassifierOutFlow(String flowKey, Match match, SfcNshHeader sfcNshHeader, Long outPort) { if ((flowKey == null) || (sfcNshHeader == null) || (sfcNshHeader.getVxlanIpDst()==null)) { return null; } String dstIp = sfcNshHeader.getVxlanIpDst().getValue(); List<Action> theActions = new ArrayList<Action>(){{ int order = 0; add(SfcOpenflowUtils.createActionNxPushNsh(order++)); add(SfcOpenflowUtils.createActionNxLoadNshMdtype(NSH_MDTYPE_ONE, order++)); add(SfcOpenflowUtils.createActionNxLoadNshNp(NSH_NP_ETH, order++)); add(SfcOpenflowUtils.createActionNxSetNsp(sfcNshHeader.getNshNsp(), order++)); add(SfcOpenflowUtils.createActionNxSetNsi(sfcNshHeader.getNshStartNsi(), order++)); add(SfcOpenflowUtils.createActionNxSetNshc1(sfcNshHeader.getNshMetaC1(), order++)); add(SfcOpenflowUtils.createActionNxSetNshc2(sfcNshHeader.getNshMetaC2(), order++)); add(SfcOpenflowUtils.createActionNxSetNshc3(sfcNshHeader.getNshMetaC3(), order++)); add(SfcOpenflowUtils.createActionNxSetNshc4(sfcNshHeader.getNshMetaC4(), order++)); add(SfcOpenflowUtils.createActionNxLoadTunGpeNp(TUN_GPE_NP_NSH, order++)); add(SfcOpenflowUtils.createActionNxSetTunIpv4Dst(dstIp, order++)); add( outPort == null ? SfcOpenflowUtils.createActionOutPort(OutputPortValues.INPORT.toString(), order++) : SfcOpenflowUtils.createActionOutPort(outPort.intValue(), order++)); }}; InstructionsBuilder isb = SfcOpenflowUtils.wrapActionsIntoApplyActionsInstruction(theActions); FlowBuilder flowb = new FlowBuilder(); flowb.setId(new FlowId(flowKey)) .setTableId(TABLE_INDEX_CLASSIFIER) .setKey(new FlowKey(new FlowId(flowKey))) .setPriority(FLOW_PRIORITY_CLASSIFIER) .setMatch(match) .setInstructions(isb.build()); return flowb; }  static FlowBuilder initClassifierTable(); static FlowBuilder initClassifierDpdkOutputFlow(Long outPort); static FlowBuilder initClassifierDpdkInputFlow(String nodeName, Long inPort); static FlowBuilder createClassifierOutFlow(String flowKey, Match match, SfcNshHeader sfcNshHeader,
                                                  Long outPort); static FlowBuilder createClassifierInFlow(String flowKey, SfcNshHeader sfcNshHeader, Long outPort); static FlowBuilder createClassifierRelayFlow(String flowKey, SfcNshHeader sfcNshHeader); static boolean deleteClassifierFlow(String nodeName, String flowKey); static final int FLOW_PRIORITY_CLASSIFIER; static final int FLOW_PRIORITY_MATCH_ANY; static final short NSH_MDTYPE_ONE; static final short NSH_NP_ETH; static final short TUN_GPE_NP_NSH; }
@Test public void testCreateClassifierOutFlow() { Match match = mock(Match.class); SfcNshHeader nsh = mock(SfcNshHeader.class); Ipv4Address ip = mock(Ipv4Address.class); nsh.setVxlanIpDst(ip); assertNull(SfcScfOfUtils.createClassifierOutFlow(null, null, null, 0L)); assertNull(SfcScfOfUtils.createClassifierOutFlow(null, null, null, 0L)); assertNull(SfcScfOfUtils.createClassifierOutFlow("flow", null, null, 0L)); assertNull(SfcScfOfUtils.createClassifierOutFlow(null, match, null, 0L)); assertNull(SfcScfOfUtils.createClassifierOutFlow(null, null, nsh, 0L)); }