@Override protected void checkPrereqs(List<MatchBuilder> matches) { for (MatchBuilder match : matches) { Long readEthType = null; try { readEthType = match.getEthernetMatch().getEthernetType().getType().getValue(); } catch (NullPointerException e) { throw new IllegalArgumentException( "Parameter " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " " + MSG_IS_MISSING); } if (!FlowUtils.IPv4.equals(readEthType) && !FlowUtils.IPv6.equals(readEthType)) { throw new IllegalArgumentException("Parameter " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " must have value " + FlowUtils.IPv4 + " or " + FlowUtils.IPv6 + "."); } } }
private MatchImpl(MatchBuilder base) { this._ethernetMatch = base.getEthernetMatch(); this._icmpv4Match = base.getIcmpv4Match(); this._icmpv6Match = base.getIcmpv6Match(); this._inPhyPort = base.getInPhyPort(); this._inPort = base.getInPort(); this._ipMatch = base.getIpMatch(); this._layer3Match = base.getLayer3Match(); this._layer4Match = base.getLayer4Match(); this._metadata = base.getMetadata(); this._protocolMatchFields = base.getProtocolMatchFields(); this._tcpFlagMatch = base.getTcpFlagMatch(); this._tunnel = base.getTunnel(); this._vlanMatch = base.getVlanMatch(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
@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; }
public static MatchBuilder createEthSrcDstMatch(MatchBuilder matchBuilder, MacAddress srcMac, MacAddress dstMac) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); if (srcMac != null) { EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder(); ethSourceBuilder.setAddress(srcMac); ethernetMatch.setEthernetSource(ethSourceBuilder.build()); } if (dstMac != null) { EthernetDestinationBuilder ethDestinationBuild = new EthernetDestinationBuilder(); ethDestinationBuild.setAddress(dstMac); ethernetMatch.setEthernetDestination(ethDestinationBuild.build()); } if (matchBuilder.getEthernetMatch() != null && matchBuilder.getEthernetMatch().getEthernetType() != null) { ethernetMatch.setEthernetType(matchBuilder.getEthernetMatch().getEthernetType()); } matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
private static EthernetMatch mergeEthernetMatch(MatchBuilder match, EthernetMatchBuilder ethMatchBuilder) { EthernetMatch ethMatch = match.getEthernetMatch(); if(ethMatch == null) { return ethMatchBuilder.build(); } if(ethMatch.getEthernetDestination() != null) { ethMatchBuilder.setEthernetDestination(ethMatch.getEthernetDestination()); } if(ethMatch.getEthernetSource() != null) { ethMatchBuilder.setEthernetSource(ethMatch.getEthernetSource()); } if(ethMatch.getEthernetType() != null) { ethMatchBuilder.setEthernetType(ethMatch.getEthernetType()); } return ethMatchBuilder.build(); }