- return flowMod.build();
- }
-
- public static Match toMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
-
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
- MatchBuilder matchBuilder = new MatchBuilder();
- List<MatchEntries> matchEntriesList = new ArrayList<>();
-
- if (match.getInPort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(InPort.class);
- PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
- port.setPortNumber(new PortNumber(match.getInPort()));
- matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (match.getInPhyPort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(InPhyPort.class);
- PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder();
- phyPort.setPortNumber(new PortNumber(match.getInPhyPort()));
- matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (match.getMetadata() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(Metadata.class);
- addMetadataAugmentation(matchEntriesBuilder, match.getMetadata().getMetadata());
- if (match.getMetadata().getMetadataMask() != null) {
- addMaskAugmentation(matchEntriesBuilder, match.getMetadata().getMetadataMask());
- }
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (match.getEthernetMatch() != null) {
- EthernetMatch ethernetMatch = match.getEthernetMatch();
- EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
- if (ethernetDestination != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(EthDst.class);
- addMacAddressAugmentation(matchEntriesBuilder, ethernetDestination.getAddress());
- if (ethernetDestination.getMask() != null) {
- addMaskAugmentation(matchEntriesBuilder, ethernetDestination.getMask());
- }
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
- if (ethernetSource != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(EthSrc.class);
- addMacAddressAugmentation(matchEntriesBuilder, ethernetSource.getAddress());
- if (ethernetSource.getMask() != null) {
- addMaskAugmentation(matchEntriesBuilder, ethernetSource.getMask());
- }
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (ethernetMatch.getEthernetType() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(EthType.class);
- EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();
- ethertypeBuilder.setEthType(new EtherType(ethernetMatch.getEthernetType().getType().getValue()
- .intValue()));
- matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
- }
-
- VlanMatch vlanMatch = match.getVlanMatch();
- if (vlanMatch != null) {
- if (vlanMatch.getVlanId() != null) {
- // verify
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(true);
- matchEntriesBuilder.setOxmMatchField(VlanVid.class);
- VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
- Integer vidEntryValue = vlanMatch.getVlanId().getVlanId().getValue();
- vlanVidBuilder.setCfiBit(vidEntryValue != 0);
- vlanVidBuilder.setVlanVid(vidEntryValue);
- matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
- if (vlanMatch.getVlanId().getMask() != null) {
- addMaskAugmentation(matchEntriesBuilder, vlanMatch.getVlanId().getMask());
- }
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (vlanMatch.getVlanPcp() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(VlanPcp.class);
- VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();
- vlanPcpBuilder.setVlanPcp(vlanMatch.getVlanPcp().getValue());
- matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanPcpBuilder.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
- }
-
- IpMatch ipMatch = match.getIpMatch();
- if (ipMatch != null) {
- if (ipMatch.getIpDscp() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(IpDscp.class);
- DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();
- dscpBuilder.setDscp(ipMatch.getIpDscp());
- matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (ipMatch.getIpEcn() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(IpDscp.class);
- EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();
- ecnBuilder.setEcn(ipMatch.getIpEcn());
- matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (ipMatch.getIpProto() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(IpProto.class);
- ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();
- protoNumberBuilder.setProtocolNumber((short) ipMatch.getIpProto().getIntValue());
- matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- }
-
- Layer4Match layer4Match = match.getLayer4Match();
- if (layer4Match != null) {
- if (layer4Match instanceof TcpMatch) {
- TcpMatch tcpMatch = (TcpMatch) layer4Match;
- if (tcpMatch.getTcpSourcePort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
- addPortAugmentation(matchEntriesBuilder, tcpMatch.getTcpSourcePort());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (tcpMatch.getTcpDestinationPort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(TcpDst.class);
- addPortAugmentation(matchEntriesBuilder, tcpMatch.getTcpDestinationPort());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
- }
-
- else if (layer4Match instanceof UdpMatch) {
- UdpMatch udpMatch = (UdpMatch) layer4Match;
- if (udpMatch.getUdpSourcePort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
- addPortAugmentation(matchEntriesBuilder, udpMatch.getUdpSourcePort());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (udpMatch.getUdpDestinationPort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(UdpDst.class);
- addPortAugmentation(matchEntriesBuilder, udpMatch.getUdpDestinationPort());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
- }
-
- else if (layer4Match instanceof SctpMatch) {
- SctpMatch sctpMatch = (SctpMatch) layer4Match;
- if (sctpMatch.getSctpSourcePort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(SctpSrc.class);
- addPortAugmentation(matchEntriesBuilder, sctpMatch.getSctpSourcePort());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
-
- if (sctpMatch.getSctpDestinationPort() != null) {
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setHasMask(false);
- matchEntriesBuilder.setOxmMatchField(SctpDst.class);
- addPortAugmentation(matchEntriesBuilder, sctpMatch.getSctpDestinationPort());
- matchEntriesList.add(matchEntriesBuilder.build());
- }
- }