SfcScfOfUtils { public static FlowBuilder createClassifierRelayFlow(String flowKey, SfcNshHeader sfcNshHeader) { if ((flowKey == null) || (sfcNshHeader == null) || (sfcNshHeader.getVxlanIpDst()==null)) { return null; } MatchBuilder mb = SfcOpenflowUtils.getNshMatches(sfcNshHeader.getNshNsp(), sfcNshHeader.getNshEndNsi()); String dstIp = sfcNshHeader.getVxlanIpDst().getValue(); List<Action> theActions = new ArrayList<Action>() {{ int order = 0; add(SfcOpenflowUtils.createActionNxLoadTunGpeNp(TUN_GPE_NP_NSH, order++)); add(SfcOpenflowUtils.createActionNxSetTunIpv4Dst(dstIp, order++)); add(SfcOpenflowUtils.createActionNxMoveNsp(order++)); add(SfcOpenflowUtils.createActionNxMoveNsi(order++)); add(SfcOpenflowUtils.createActionNxMoveNsc1(order++)); add(SfcOpenflowUtils.createActionNxMoveNsc2(order++)); add(SfcOpenflowUtils.createActionOutPort(OutputPortValues.INPORT.toString(), 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(mb.build()) .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 testCreateClassifierRelayFlow() { SfcNshHeader nsh = mock(SfcNshHeader.class); Ipv4Address ip = mock(Ipv4Address.class); nsh.setVxlanIpDst(ip); assertNull(SfcScfOfUtils.createClassifierRelayFlow(null, null)); assertNull(SfcScfOfUtils.createClassifierRelayFlow(null, null)); assertNull(SfcScfOfUtils.createClassifierRelayFlow("flow", null)); assertNull(SfcScfOfUtils.createClassifierRelayFlow(null, nsh)); }