@Override public Optional<MatchBuilder> process(@Nonnull MplsLabelCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder(); MplsLabel mplsLabel = source.getMplsLabel(); if (mplsLabel != null) { protocolMatchFieldsBuilder.setMplsLabel(mplsLabel.getMplsLabel()); matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); } return Optional.of(matchBuilder); } }
@Override public Optional<MatchBuilder> process(@Nonnull MplsTcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder(); MplsTc mplsTc = source.getMplsTc(); if (mplsTc != null) { protocolMatchFieldsBuilder.setMplsTc(mplsTc.getTc()); matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); } return Optional.of(matchBuilder); } }
@Override public Optional<MatchBuilder> process(@Nonnull MplsBosCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder(); MplsBos mplsBos = source.getMplsBos(); if (mplsBos != null) { protocolMatchFieldsBuilder.setMplsBos(mplsBos.isBos() ? (short) 1 : (short) 0); matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); } return Optional.of(matchBuilder); } }
@Override public Optional<MatchBuilder> process(@Nonnull PbbIsidCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder(); PbbIsid pbbIsid = source.getPbbIsid(); if (pbbIsid != null) { PbbBuilder pbbBuilder = new PbbBuilder(); pbbBuilder.setPbbIsid(pbbIsid.getIsid()); byte[] mask = pbbIsid.getMask(); if (mask != null) { pbbBuilder.setPbbMask(ByteUtil.bytesToUnsignedMedium(mask)); } protocolMatchFieldsBuilder.setPbb(pbbBuilder.build()); matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); } return Optional.of(matchBuilder); } }
/** * @return */ private static MatchBuilder createPbbMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x88E7L)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls // match protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[]{0, 1, 0, 0}).longValue()).build()); match.setProtocolMatchFields(protomatch.build()); return match; }
public static void addMatchMplsLabel(MatchBuilder match, long label) { EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType((long) ETHERTYPE_MPLS_UCAST)); EthernetMatchBuilder eth = new EthernetMatchBuilder(); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); protomatch.setMplsLabel(label); match.setProtocolMatchFields(protomatch.build()); }
/** * Create MPLS label Match * * @param label Long representing a Label value * @param bos Boolean indicating bottom of stack for this label * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createMplsLabelBosMatch(Long label, boolean bos) { MatchBuilder matchBuilder = new MatchBuilder(); EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(MPLSUCAST_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); ProtocolMatchFieldsBuilder matchFieldsBuilder = new ProtocolMatchFieldsBuilder() .setMplsLabel(label) .setMplsBos((short) (bos ? 1 : 0)); matchBuilder.setProtocolMatchFields(matchFieldsBuilder.build()); return matchBuilder; }
/** * Create MPLS label Match * * @param matchBuilder MatchBuilder Object * @param label Long representing a Label value * @param bos Boolean indicating bottom of stack for this label * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createMplsLabelBosMatch(MatchBuilder matchBuilder, Long label, boolean bos) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(MPLSUCAST_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); ProtocolMatchFieldsBuilder matchFieldsBuilder = new ProtocolMatchFieldsBuilder() .setMplsLabel(label) .setMplsBos((short) (bos?1:0)); matchBuilder.setProtocolMatchFields(matchFieldsBuilder.build()); return matchBuilder; }
/** * @return */ private static MatchBuilder createMplsMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x8847L)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls // match protomatch.setMplsLabel((long) 36008); protomatch.setMplsTc((short) 4); protomatch.setMplsBos((short) 1); match.setProtocolMatchFields(protomatch.build()); return match; }