/** * Creates {@link EthernetMatch} containing ARP ether-type and the given destination MAC address * @return EthernetMatch */ public static EthernetMatch createEthernetMatch() { return new EthernetMatchBuilder().setEthernetType( new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(EtherTypes.ARP.intValue()))).build()) .build(); }
public EthernetTypeBuilder setType(EtherType value) { if (value != null) { BigInteger _constraint = BigInteger.valueOf(value.getValue()); boolean isValidRange = false; for (Range<BigInteger> r : _type_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _type_range)); } } this._type = value; return this; } public static List<Range<BigInteger>> _type_range() {
public static EthernetMatch ethernetMatch(MacAddress srcMac, MacAddress dstMac, Long etherType) { EthernetMatchBuilder emb = new EthernetMatchBuilder(); if (srcMac != null) { emb.setEthernetSource(new EthernetSourceBuilder() .setAddress(srcMac) .build()); } if (dstMac != null) { emb.setEthernetDestination(new EthernetDestinationBuilder() .setAddress(dstMac) .build()); } if (etherType != null) { emb.setEthernetType(new EthernetTypeBuilder() .setType(new EtherType(etherType)) .build()); } return emb.build(); }
/** * Creates {@link EthernetMatch} containing ARP ether-type */ public static EthernetMatch createEthernetMatch() { return new EthernetMatchBuilder().setEthernetType( new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(EtherTypes.ARP.intValue()))).build()) .build(); }
/** * Add an etherType match to an existing MatchBuilder * @param match * @param etherType */ public static void addMatchEtherType(MatchBuilder match, final long etherType) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(etherType)); ethernetMatch.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(mergeEthernetMatch(match, ethernetMatch)); }
/** * Create EtherType Match * * @param matchBuilder Map matchBuilder MatchBuilder Object without a match * @param etherType Long EtherType * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createEtherTypeMatch(MatchBuilder matchBuilder, EtherType etherType) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(etherType)); ethernetMatch.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
/** * Create EtherType Match * * @param matchBuilder Map matchBuilder MatchBuilder Object without a match * @param etherType Long EtherType * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createEtherTypeMatch(MatchBuilder matchBuilder, Long etherType) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(etherType)); ethernetMatch.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
private static MatchBuilder createLLDPMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x88ccL)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); return match; }
private static MatchBuilder createLLDPMatch() { MatchBuilder match = new MatchBuilder(); EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x88ccL)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); return match; }
/** * Create EtherType Match * * @param matchBuilder Map matchBuilder MatchBuilder Object without a match * @param etherType Long EtherType * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createEtherTypeMatch(MatchBuilder matchBuilder, Long etherType) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(etherType)); ethernetMatch.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
/** * Creates {@link EthernetMatch} containing ARP ether-type and the given destination MAC address * * @param destinationMacAddress the destination MAC address * @return {@link EthernetMatch} */ public static EthernetMatch createEthernetMatch(MacAddress destinationMacAddress) { return new EthernetMatchBuilder().setEthernetType( new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(EtherTypes.ARP.intValue()))).build()) .setEthernetDestination(new EthernetDestinationBuilder().setAddress(destinationMacAddress).build()) .build(); }
@Override public Optional<MatchBuilder> process(@Nonnull EthTypeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final EthernetMatchBuilder ethMatchBuilder = data.getEthernetMatchBuilder(); final EthType ethTypeCase = source.getEthType(); if (ethTypeCase != null) { EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType((long) ethTypeCase.getEthType().getValue())); ethMatchBuilder.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethMatchBuilder.build()); } return Optional.of(matchBuilder); } }
/** * Creates {@link EthernetMatch} containing ARP ether-type and the given destination MAC address */ public static EthernetMatch createEthernetMatch(MacAddress destinationMacAddress) { return new EthernetMatchBuilder().setEthernetType( new EthernetTypeBuilder().setType(new EtherType((long) EtherTypes.ARP.intValue())).build()) .setEthernetDestination(new EthernetDestinationBuilder().setAddress(destinationMacAddress).build()) .build(); }
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()); }
@Override protected List<MatchBuilder> update(List<MatchBuilder> matches, Map<String, ParameterValue> params) { Long type = params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM).getIntValue(); for (MatchBuilder match : matches) { EthernetMatchBuilder em; if (match.getEthernetMatch() != null) { equalOrNotSetValidation(match.getEthernetMatch().getEthernetType(), type); continue; } else { em = new EthernetMatchBuilder(); } em.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(type)).build()); match.setEthernetMatch(em.build()); } return matches; }
/** * @param matchBuilder MatchBuilder Object without a match yet * @param dstip String containing an IPv4 prefix * @return matchBuilder Map Object with a match */ public static MatchBuilder createDstL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix dstip) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder(); ipv4match.setIpv4Destination(dstip); matchBuilder.setLayer3Match(ipv4match.build()); return matchBuilder; }
/** * @param matchBuilder MatchBuilder Object without a match yet * @param srcip String containing an IPv4 prefix * @return matchBuilder Map Object with a match */ public static MatchBuilder createSrcL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix srcip) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder(); ipv4match.setIpv4Source(srcip); matchBuilder.setLayer3Match(ipv4match.build()); return matchBuilder; }
/** * @param matchBuilder MatchBuilder Object without a match yet * @param srcip String containing an IPv4 prefix * @return matchBuilder Map Object with a match */ public static MatchBuilder createSrcL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix srcip) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder(); ipv4match.setIpv4Source(srcip); matchBuilder.setLayer3Match(ipv4match.build()); return matchBuilder; }
/** * @param matchBuilder MatchBuilder Object without a match yet * @param dstip String containing an IPv4 prefix * @return matchBuilder Map Object with a match */ public static MatchBuilder createDstL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix dstip) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder(); ipv4match.setIpv4Destination(dstip); matchBuilder.setLayer3Match(ipv4match.build()); return matchBuilder; }
/** * @param matchBuilder MatchBuilder Object without a match yet * @param srcip String containing an IPv4 prefix * @return matchBuilder Map Object with a match */ public static MatchBuilder createSrcL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix srcip) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder(); ipv4match.setIpv4Source(srcip); matchBuilder.setLayer3Match(ipv4match.build()); return matchBuilder; }