2 * Copyright (c) 2013 Ericsson. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
11 import java.math.BigInteger;
12 import java.nio.ByteBuffer;
13 import java.util.ArrayList;
14 import java.util.List;
16 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeader;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6Label;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;
170 import org.slf4j.Logger;
171 import org.slf4j.LoggerFactory;
174 * Utility class for converting a MD-SAL Flow into the OF flow mod
176 public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
177 private static final Logger logger = LoggerFactory.getLogger(MatchConvertorImpl.class);
178 static final String PREFIX_SEPARATOR = "/";
179 private static final byte[] VLAN_VID_MASK = new byte[] { 16, 0 };
180 private static final short PROTO_TCP = 6;
181 private static final short PROTO_UDP = 17;
184 public List<MatchEntries> convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match) {
185 List<MatchEntries> matchEntriesList = new ArrayList<>();
187 if (match.getInPort() != null) {
188 matchEntriesList.add(toOfPort(InPort.class, match.getInPort()));
191 if (match.getInPhyPort() != null) {
192 matchEntriesList.add(toOfPort(InPhyPort.class, match.getInPhyPort()));
195 org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata metadata = match
197 if (metadata != null) {
198 matchEntriesList.add(toOfMetadata(Metadata.class, metadata.getMetadata(), metadata.getMetadataMask()));
201 EthernetMatch ethernetMatch = match.getEthernetMatch();
202 if (ethernetMatch != null) {
203 EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
204 if (ethernetDestination != null) {
205 matchEntriesList.add(toOfMacAddress(EthDst.class, ethernetDestination.getAddress(),
206 ethernetDestination.getMask()));
209 EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
210 if (ethernetSource != null) {
212 .add(toOfMacAddress(EthSrc.class, ethernetSource.getAddress(), ethernetSource.getMask()));
215 if (ethernetMatch.getEthernetType() != null) {
216 matchEntriesList.add(toOfEthernetType(ethernetMatch.getEthernetType()));
220 VlanMatch vlanMatch = match.getVlanMatch();
221 if (vlanMatch != null) {
222 if (vlanMatch.getVlanId() != null) {
223 matchEntriesList.add(toOfVlanVid(vlanMatch.getVlanId()));
226 if (vlanMatch.getVlanPcp() != null) {
227 matchEntriesList.add(toOfVlanPcp(vlanMatch.getVlanPcp()));
231 IpMatch ipMatch = match.getIpMatch();
232 if (ipMatch != null) {
233 if (ipMatch.getIpDscp() != null) {
234 matchEntriesList.add(toOfIpDscp(ipMatch.getIpDscp()));
237 if (ipMatch.getIpEcn() != null) {
238 matchEntriesList.add(toOfIpEcn(ipMatch.getIpEcn()));
241 if (ipMatch.getIpProtocol() != null) {
242 matchEntriesList.add(toOfIpProto(ipMatch.getIpProtocol()));
247 Layer4Match layer4Match = match.getLayer4Match();
248 if (layer4Match != null) {
249 if (layer4Match instanceof TcpMatch) {
250 TcpMatch tcpMatch = (TcpMatch) layer4Match;
251 if (tcpMatch.getTcpSourcePort() != null) {
252 matchEntriesList.add(toOfLayer3Port(TcpSrc.class, tcpMatch.getTcpSourcePort()));
255 if (tcpMatch.getTcpDestinationPort() != null) {
256 matchEntriesList.add(toOfLayer3Port(TcpDst.class, tcpMatch.getTcpDestinationPort()));
258 } else if (layer4Match instanceof UdpMatch) {
259 UdpMatch udpMatch = (UdpMatch) layer4Match;
260 if (udpMatch.getUdpSourcePort() != null) {
261 matchEntriesList.add(toOfLayer3Port(UdpSrc.class, udpMatch.getUdpSourcePort()));
264 if (udpMatch.getUdpDestinationPort() != null) {
265 matchEntriesList.add(toOfLayer3Port(UdpDst.class, udpMatch.getUdpDestinationPort()));
267 } else if (layer4Match instanceof SctpMatch) {
268 SctpMatch sctpMatch = (SctpMatch) layer4Match;
269 if (sctpMatch.getSctpSourcePort() != null) {
270 matchEntriesList.add(toOfLayer3Port(SctpSrc.class, sctpMatch.getSctpSourcePort()));
273 if (sctpMatch.getSctpDestinationPort() != null) {
274 matchEntriesList.add(toOfLayer3Port(SctpDst.class, sctpMatch.getSctpDestinationPort()));
279 Icmpv4Match icmpv4Match = match.getIcmpv4Match();
280 if (icmpv4Match != null) {
281 if (icmpv4Match.getIcmpv4Type() != null) {
282 matchEntriesList.add(toOfIcmpv4Type(icmpv4Match.getIcmpv4Type()));
285 if (icmpv4Match.getIcmpv4Code() != null) {
286 matchEntriesList.add(toOfIcmpv4Code(icmpv4Match.getIcmpv4Code()));
290 Icmpv6Match icmpv6Match = match.getIcmpv6Match();
291 if (icmpv6Match != null) {
292 if (icmpv6Match.getIcmpv6Type() != null) {
293 matchEntriesList.add(toOfIcmpv6Type(icmpv6Match.getIcmpv6Type()));
296 if (icmpv6Match.getIcmpv6Code() != null) {
297 matchEntriesList.add(toOfIcmpv6Code(icmpv6Match.getIcmpv6Code()));
301 Layer3Match layer3Match = match.getLayer3Match();
302 if (layer3Match != null) {
303 if (layer3Match instanceof Ipv4Match) {
304 Ipv4Match ipv4Match = (Ipv4Match) layer3Match;
305 if (ipv4Match.getIpv4Source() != null) {
306 matchEntriesList.add(toOfIpv4Prefix(Ipv4Src.class, ipv4Match.getIpv4Source()));
308 if (ipv4Match.getIpv4Destination() != null) {
309 matchEntriesList.add(toOfIpv4Prefix(Ipv4Dst.class, ipv4Match.getIpv4Destination()));
311 } else if (layer3Match instanceof ArpMatch) {
312 ArpMatch arpMatch = (ArpMatch) layer3Match;
313 if (arpMatch.getArpOp() != null) {
314 matchEntriesList.add(toOfArpOpCode(arpMatch.getArpOp()));
317 if (arpMatch.getArpSourceTransportAddress() != null) {
318 matchEntriesList.add(toOfIpv4Prefix(ArpSpa.class, arpMatch.getArpSourceTransportAddress()));
321 if (arpMatch.getArpTargetTransportAddress() != null) {
322 matchEntriesList.add(toOfIpv4Prefix(ArpTpa.class, arpMatch.getArpTargetTransportAddress()));
325 ArpSourceHardwareAddress arpSourceHardwareAddress = arpMatch.getArpSourceHardwareAddress();
326 if (arpSourceHardwareAddress != null) {
327 matchEntriesList.add(toOfMacAddress(ArpSha.class, arpSourceHardwareAddress.getAddress(),
328 arpSourceHardwareAddress.getMask()));
331 ArpTargetHardwareAddress arpTargetHardwareAddress = arpMatch.getArpTargetHardwareAddress();
332 if (arpTargetHardwareAddress != null) {
333 matchEntriesList.add(toOfMacAddress(ArpTha.class, arpTargetHardwareAddress.getAddress(),
334 arpTargetHardwareAddress.getMask()));
338 else if (layer3Match instanceof Ipv6Match) {
339 Ipv6Match ipv6Match = (Ipv6Match) layer3Match;
340 if (ipv6Match.getIpv6Source() != null) {
341 matchEntriesList.add(toOfIpv6Prefix(Ipv6Src.class, ipv6Match.getIpv6Source()));
344 if (ipv6Match.getIpv6Destination() != null) {
345 matchEntriesList.add(toOfIpv6Prefix(Ipv6Dst.class, ipv6Match.getIpv6Destination()));
348 if (ipv6Match.getIpv6Label() != null) {
349 matchEntriesList.add(toOfIpv6FlowLabel(ipv6Match.getIpv6Label()));
352 if (ipv6Match.getIpv6NdTarget() != null) {
353 matchEntriesList.add(toOfIpv6Address(ipv6Match.getIpv6NdTarget()));
356 if (ipv6Match.getIpv6NdSll() != null) {
357 matchEntriesList.add(toOfMacAddress(Ipv6NdSll.class, ipv6Match.getIpv6NdSll(), null));
360 if (ipv6Match.getIpv6NdTll() != null) {
361 matchEntriesList.add(toOfMacAddress(Ipv6NdTll.class, ipv6Match.getIpv6NdTll(), null));
364 if (ipv6Match.getIpv6ExtHeader() != null) {
365 matchEntriesList.add(toOfIpv6ExtHeader(ipv6Match.getIpv6ExtHeader()));
370 ProtocolMatchFields protocolMatchFields = match.getProtocolMatchFields();
371 if (protocolMatchFields != null) {
372 if (protocolMatchFields.getMplsLabel() != null) {
373 matchEntriesList.add(toOfMplsLabel(protocolMatchFields.getMplsLabel()));
376 if (protocolMatchFields.getMplsBos() != null) {
377 matchEntriesList.add(toOfMplsBos(protocolMatchFields.getMplsBos()));
380 if (protocolMatchFields.getMplsTc() != null) {
381 matchEntriesList.add(toOfMplsTc(protocolMatchFields.getMplsTc()));
384 if (protocolMatchFields.getPbb() != null) {
385 matchEntriesList.add(toOfMplsPbb(protocolMatchFields.getPbb()));
389 org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel tunnel = match
391 if (tunnel != null) {
392 matchEntriesList.add(toOfMetadata(TunnelId.class, tunnel.getTunnelId(), tunnel.getTunnelMask()));
396 return matchEntriesList;
400 * Method convert Openflow 1.0 specific flow match to MD-SAL format
404 * @author avishnoi@in.ibm.com
406 public static Match fromOFMatchV10ToSALMatch(MatchV10 swMatch){
407 MatchBuilder matchBuilder = new MatchBuilder();
408 EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
409 VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
410 Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
411 IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
413 if(swMatch.getInPort() != null){
414 matchBuilder.setInPort((long)swMatch.getInPort());
417 if(swMatch.getDlSrc()!= null){
418 EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
419 ethSrcBuilder.setAddress(swMatch.getDlSrc());
420 ethMatchBuilder.setEthernetSource(ethSrcBuilder.build());
421 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
423 if(swMatch.getDlDst()!= null){
424 EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
425 ethDstBuilder.setAddress(swMatch.getDlDst());
426 ethMatchBuilder.setEthernetDestination(ethDstBuilder.build());
427 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
429 if(swMatch.getDlType()!= null){
430 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
431 ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType((long)swMatch.getDlType()));
432 ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
433 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
435 if(swMatch.getDlVlan()!=null){
436 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
437 vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(swMatch.getDlVlan()));
438 vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
439 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
441 if(swMatch.getDlVlanPcp()!= null){
442 vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(swMatch.getDlVlanPcp()));
443 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
445 if(swMatch.getNwSrc() !=null){
446 String ipv4PrefixStr = swMatch.getNwSrc().getValue();
447 if(swMatch.getNwSrcMask()!= null){
448 ipv4PrefixStr +=PREFIX_SEPARATOR+swMatch.getNwSrcMask();
450 ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
451 matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
453 if(swMatch.getNwDst() !=null){
454 String ipv4PrefixStr = swMatch.getNwDst().getValue();
455 if(swMatch.getNwDstMask()!= null){
456 ipv4PrefixStr +=PREFIX_SEPARATOR+swMatch.getNwDstMask();
458 ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
459 matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
461 if(swMatch.getNwProto()!= null ){
462 ipMatchBuilder.setIpProtocol(swMatch.getNwProto());
463 matchBuilder.setIpMatch(ipMatchBuilder.build());
465 if(swMatch.getNwProto() == PROTO_TCP){
466 TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
467 if(swMatch.getTpSrc()!= null)
468 tcpMatchBuilder.setTcpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpSrc()));
469 if(swMatch.getTpDst()!= null)
470 tcpMatchBuilder.setTcpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpDst()));
471 matchBuilder.setLayer4Match(tcpMatchBuilder.build());
473 if(swMatch.getNwProto() == PROTO_UDP){
474 UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
475 if(swMatch.getTpSrc()!= null)
476 udpMatchBuilder.setUdpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpSrc()));
477 if(swMatch.getTpDst()!= null)
478 udpMatchBuilder.setUdpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpDst()));
479 matchBuilder.setLayer4Match(udpMatchBuilder.build());
481 if(swMatch.getNwTos()!=null){
482 ipMatchBuilder.setIpDscp(new Dscp(swMatch.getNwTos()));
483 matchBuilder.setIpMatch(ipMatchBuilder.build());
486 return matchBuilder.build();
490 * Method converts Openflow 1.3+ specific flow match to MD-SAL format
494 * @author avishnoi@in.ibm.com
496 public static Match fromOFMatchToSALMatch(
497 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match swMatch) {
499 MatchBuilder matchBuilder = new MatchBuilder();
500 EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
501 VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
502 IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
503 TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
504 UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
505 SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
506 Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
507 Icmpv6MatchBuilder icmpv6MatchBuilder = new Icmpv6MatchBuilder();
508 Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
509 ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
510 Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
511 ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
513 List<MatchEntries> swMatchList = swMatch.getMatchEntries();
515 for(MatchEntries ofMatch : swMatchList){
517 if(ofMatch.getOxmMatchField().equals(InPort.class)){
518 PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
519 matchBuilder.setInPort(portNumber.getPortNumber().getValue());
520 }else if (ofMatch.getOxmMatchField().equals(InPhyPort.class)){
521 PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
522 matchBuilder.setInPhyPort(portNumber.getPortNumber().getValue());
523 }else if(ofMatch.getOxmMatchField().equals(Metadata.class)){
524 MetadataBuilder metadataBuilder = new MetadataBuilder();
525 MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
526 if(metadataMatchEntry != null){
527 metadataBuilder.setMetadata(new BigInteger(metadataMatchEntry.getMetadata()));
528 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
529 if(maskMatchEntry != null){
530 metadataBuilder.setMetadataMask(maskMatchEntry.getMask());
532 matchBuilder.setMetadata(metadataBuilder.build());
534 }else if(ofMatch.getOxmMatchField().equals(EthSrc.class)){
535 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
536 if(macAddressMatchEntry != null){
537 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
538 ethSourceBuilder.setAddress(macAddressMatchEntry.getMacAddress());
539 ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
540 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
542 }else if(ofMatch.getOxmMatchField().equals(EthDst.class)){
543 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
544 if(macAddressMatchEntry != null){
545 EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
546 ethDestinationBuilder.setAddress(macAddressMatchEntry.getMacAddress());
547 ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
548 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
550 }else if(ofMatch.getOxmMatchField().equals(EthType.class)){
551 EthTypeMatchEntry ethTypeMatchEntry = ofMatch.getAugmentation(EthTypeMatchEntry.class);
552 if(ethTypeMatchEntry != null){
553 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
554 ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType((long)ethTypeMatchEntry.getEthType().getValue()));
555 ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
556 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
558 }else if(ofMatch.getOxmMatchField().equals(VlanVid.class)){
559 VlanVidMatchEntry vlanVidMatchEntry = ofMatch.getAugmentation(VlanVidMatchEntry.class);
560 if(vlanVidMatchEntry != null){
561 VlanIdBuilder vlanBuilder = new VlanIdBuilder();
562 vlanBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanVidMatchEntry.getVlanVid()));
563 vlanMatchBuilder.setVlanId(vlanBuilder.build());
564 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
566 }else if(ofMatch.getOxmMatchField().equals(VlanPcp.class)){
567 VlanPcpMatchEntry vlanPcpMatchEntry = ofMatch.getAugmentation(VlanPcpMatchEntry.class);
568 if(vlanPcpMatchEntry != null){
569 vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(vlanPcpMatchEntry.getVlanPcp()));
570 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
572 }else if(ofMatch.getOxmMatchField().equals(IpDscp.class)){
573 DscpMatchEntry dscpMatchEntry = ofMatch.getAugmentation(DscpMatchEntry.class);
574 if(dscpMatchEntry != null){
575 ipMatchBuilder.setIpDscp(new Dscp(dscpMatchEntry.getDscp().getValue()));
576 matchBuilder.setIpMatch(ipMatchBuilder.build());
578 }else if(ofMatch.getOxmMatchField().equals(IpEcn.class)){
579 EcnMatchEntry ecnMatchEntry = ofMatch.getAugmentation(EcnMatchEntry.class);
580 if(ecnMatchEntry != null){
581 ipMatchBuilder.setIpEcn(ecnMatchEntry.getEcn());
582 matchBuilder.setIpMatch(ipMatchBuilder.build());
584 }else if(ofMatch.getOxmMatchField().equals(IpProto.class)){
585 ProtocolNumberMatchEntry protocolNumberMatchEntry = ofMatch.getAugmentation(ProtocolNumberMatchEntry.class);
586 if(protocolNumberMatchEntry != null){
587 ipMatchBuilder.setIpProtocol(protocolNumberMatchEntry.getProtocolNumber());
588 matchBuilder.setIpMatch(ipMatchBuilder.build());
590 }else if(ofMatch.getOxmMatchField().equals(TcpSrc.class)){
591 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
592 if(portMatchEntry != null){
593 tcpMatchBuilder.setTcpSourcePort(portMatchEntry.getPort());
594 matchBuilder.setLayer4Match(tcpMatchBuilder.build());
596 }else if(ofMatch.getOxmMatchField().equals(TcpDst.class)){
597 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
598 if(portMatchEntry != null){
599 tcpMatchBuilder.setTcpDestinationPort(portMatchEntry.getPort());
600 matchBuilder.setLayer4Match(tcpMatchBuilder.build());
602 }else if(ofMatch.getOxmMatchField().equals(UdpSrc.class)){
603 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
604 if(portMatchEntry != null){
605 udpMatchBuilder.setUdpSourcePort(portMatchEntry.getPort());
606 matchBuilder.setLayer4Match(udpMatchBuilder.build());
608 }else if(ofMatch.getOxmMatchField().equals(UdpDst.class)){
609 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
610 if(portMatchEntry != null){
611 udpMatchBuilder.setUdpDestinationPort(portMatchEntry.getPort());
612 matchBuilder.setLayer4Match(udpMatchBuilder.build());
614 }else if(ofMatch.getOxmMatchField().equals(SctpSrc.class)){
615 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
616 if(portMatchEntry != null){
617 sctpMatchBuilder.setSctpSourcePort(portMatchEntry.getPort());
618 matchBuilder.setLayer4Match(sctpMatchBuilder.build());
620 }else if(ofMatch.getOxmMatchField().equals(SctpDst.class)){
621 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
622 if(portMatchEntry != null){
623 sctpMatchBuilder.setSctpDestinationPort(portMatchEntry.getPort());
624 matchBuilder.setLayer4Match(sctpMatchBuilder.build());
626 }else if(ofMatch.getOxmMatchField().equals(Icmpv4Type.class)){
627 Icmpv4TypeMatchEntry icmpv4TypeMatchEntry = ofMatch.getAugmentation(Icmpv4TypeMatchEntry.class);
628 if(icmpv4TypeMatchEntry != null){
629 icmpv4MatchBuilder.setIcmpv4Type(icmpv4TypeMatchEntry.getIcmpv4Type());
630 matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
632 }else if(ofMatch.getOxmMatchField().equals(Icmpv4Code.class)){
633 Icmpv4CodeMatchEntry icmpv4CodeMatchEntry = ofMatch.getAugmentation(Icmpv4CodeMatchEntry.class);
634 if(icmpv4CodeMatchEntry != null){
635 icmpv4MatchBuilder.setIcmpv4Code(icmpv4CodeMatchEntry.getIcmpv4Code());
636 matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
638 }else if(ofMatch.getOxmMatchField().equals(Icmpv6Type.class)){
639 Icmpv6TypeMatchEntry icmpv6TypeMatchEntry = ofMatch.getAugmentation(Icmpv6TypeMatchEntry.class);
640 if(icmpv6TypeMatchEntry != null){
641 icmpv6MatchBuilder.setIcmpv6Type(icmpv6TypeMatchEntry.getIcmpv6Type());
642 matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
644 }else if(ofMatch.getOxmMatchField().equals(Icmpv6Code.class)){
645 Icmpv6CodeMatchEntry icmpv6CodeMatchEntry = ofMatch.getAugmentation(Icmpv6CodeMatchEntry.class);
646 if(icmpv6CodeMatchEntry != null){
647 icmpv6MatchBuilder.setIcmpv6Code(icmpv6CodeMatchEntry.getIcmpv6Code());
648 matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
650 }else if(ofMatch.getOxmMatchField().equals(Ipv4Src.class) ||
651 ofMatch.getOxmMatchField().equals(Ipv4Dst.class)){
652 Ipv4AddressMatchEntry ipv4AddressMatchEntry = ofMatch.getAugmentation(Ipv4AddressMatchEntry.class);
653 if(ipv4AddressMatchEntry != null){
654 String ipv4PrefixStr = ipv4AddressMatchEntry.getIpv4Address().getValue();
655 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
656 if(maskMatchEntry != null){
657 ipv4PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
659 if(ofMatch.getOxmMatchField().equals(Ipv4Src.class)){
660 ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
662 if(ofMatch.getOxmMatchField().equals(Ipv4Dst.class)){
663 ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
665 matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
667 }else if(ofMatch.getOxmMatchField().equals(ArpOp.class)){
668 OpCodeMatchEntry opCodeMatchEntry = ofMatch.getAugmentation(OpCodeMatchEntry.class);
669 if(opCodeMatchEntry != null){
670 arpMatchBuilder.setArpOp(opCodeMatchEntry.getOpCode());
671 matchBuilder.setLayer3Match(arpMatchBuilder.build());
673 }else if(ofMatch.getOxmMatchField().equals(ArpSpa.class) ||
674 ofMatch.getOxmMatchField().equals(ArpTpa.class)){
675 Ipv4AddressMatchEntry ipv4AddressMatchEntry = ofMatch.getAugmentation(Ipv4AddressMatchEntry.class);
676 if(ipv4AddressMatchEntry != null){
677 String ipv4PrefixStr = ipv4AddressMatchEntry.getIpv4Address().getValue();
678 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
679 if(maskMatchEntry != null){
680 ipv4PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
682 if(ofMatch.getOxmMatchField().equals(ArpSpa.class)){
683 arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix(ipv4PrefixStr));
685 if(ofMatch.getOxmMatchField().equals(ArpTpa.class)){
686 arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix(ipv4PrefixStr));
688 matchBuilder.setLayer3Match(arpMatchBuilder.build());
690 }else if(ofMatch.getOxmMatchField().equals(ArpSha.class) ||
691 ofMatch.getOxmMatchField().equals(ArpTha.class)){
692 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
693 if(macAddressMatchEntry !=null){
694 if(ofMatch.getOxmMatchField().equals(ArpSha.class)){
695 ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
696 arpSourceHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
697 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
698 if(maskMatchEntry != null){
699 arpSourceHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
701 arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
702 matchBuilder.setLayer3Match(arpMatchBuilder.build());
704 if(ofMatch.getOxmMatchField().equals(ArpTha.class)){
705 ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
706 arpTargetHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
707 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
708 if(maskMatchEntry != null){
709 arpTargetHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
711 arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
712 matchBuilder.setLayer3Match(arpMatchBuilder.build());
715 }else if(ofMatch.getOxmMatchField().equals(Ipv6Src.class) ||
716 ofMatch.getOxmMatchField().equals(Ipv6Dst.class)){
717 Ipv6AddressMatchEntry ipv6AddressMatchEntry = ofMatch.getAugmentation(Ipv6AddressMatchEntry.class);
718 if(ipv6AddressMatchEntry != null){
719 String ipv6PrefixStr = ipv6AddressMatchEntry.getIpv6Address().getValue();
720 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
721 if(maskMatchEntry != null){
722 ipv6PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
724 if(ofMatch.getOxmMatchField().equals(Ipv6Src.class)){
725 ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix(ipv6PrefixStr));
727 if(ofMatch.getOxmMatchField().equals(Ipv6Dst.class)){
728 ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix(ipv6PrefixStr));
730 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
732 }else if(ofMatch.getOxmMatchField().equals(Ipv6Flabel.class)){
733 Ipv6FlabelMatchEntry ipv6FlabelMatchEntry = ofMatch.getAugmentation(Ipv6FlabelMatchEntry.class);
734 if(ipv6FlabelMatchEntry != null){
735 Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
736 ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(ipv6FlabelMatchEntry.getIpv6Flabel()));
737 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
738 if(maskMatchEntry != null){
739 ipv6LabelBuilder.setFlabelMask(maskMatchEntry.getMask());
741 ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
742 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
744 }else if(ofMatch.getOxmMatchField().equals(Ipv6NdTarget.class)){
745 Ipv6AddressMatchEntry ipv6AddressMatchEntry = ofMatch.getAugmentation(Ipv6AddressMatchEntry.class);
746 if(ipv6AddressMatchEntry != null){
747 ipv6MatchBuilder.setIpv6NdTarget(ipv6AddressMatchEntry.getIpv6Address());
748 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
750 }else if(ofMatch.getOxmMatchField().equals(Ipv6NdSll.class)){
751 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
752 if(macAddressMatchEntry != null){
753 ipv6MatchBuilder.setIpv6NdSll(macAddressMatchEntry.getMacAddress());
754 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
756 }else if(ofMatch.getOxmMatchField().equals(Ipv6NdTll.class)){
757 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
758 if(macAddressMatchEntry != null){
759 ipv6MatchBuilder.setIpv6NdTll(macAddressMatchEntry.getMacAddress());
760 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
762 }else if(ofMatch.getOxmMatchField().equals(Ipv6Exthdr.class)){
763 PseudoFieldMatchEntry pseudoFieldMatchEntry = ofMatch.getAugmentation(PseudoFieldMatchEntry.class);
764 if(pseudoFieldMatchEntry != null){
765 Ipv6ExtHeaderBuilder ipv6ExtHeaderBuilder = new Ipv6ExtHeaderBuilder();
767 Ipv6ExthdrFlags pField = pseudoFieldMatchEntry.getPseudoField();
769 bitmap |= pField.isNonext()?(1 << 0): ~(1 << 0);
770 bitmap |= pField.isEsp()?(1 << 1): ~(1 << 1);
771 bitmap |= pField.isAuth()?(1 << 2): ~(1 << 2);
772 bitmap |= pField.isDest()?(1 << 3): ~(1 << 3);
773 bitmap |= pField.isFrag()?(1 << 4): ~(1 << 4);
774 bitmap |= pField.isRouter()?(1 << 5): ~(1 << 5);
775 bitmap |= pField.isHop()?(1 << 6): ~(1 << 6);
776 bitmap |= pField.isUnrep()?(1 << 7): ~(1 << 7);
777 bitmap |= pField.isUnseq()?(1 << 8): ~(1 << 8);
779 ipv6ExtHeaderBuilder.setIpv6Exthdr(bitmap);
780 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
781 if(maskMatchEntry != null){
782 ipv6ExtHeaderBuilder.setIpv6ExthdrMask(maskMatchEntry.getMask());
784 ipv6MatchBuilder.setIpv6ExtHeader(ipv6ExtHeaderBuilder.build());
785 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
787 }else if(ofMatch.getOxmMatchField().equals(MplsLabel.class)){
788 MplsLabelMatchEntry mplsLabelMatchEntry = ofMatch.getAugmentation(MplsLabelMatchEntry.class);
789 if(mplsLabelMatchEntry != null){
790 protocolMatchFieldsBuilder.setMplsLabel(mplsLabelMatchEntry.getMplsLabel());
791 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
793 }else if(ofMatch.getOxmMatchField().equals(MplsBos.class)){
794 BosMatchEntry bosMatchEntry = ofMatch.getAugmentation(BosMatchEntry.class);
795 if(bosMatchEntry != null){
796 protocolMatchFieldsBuilder.setMplsBos(bosMatchEntry.isBos()?(short)1:(short)0);
797 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
799 }else if(ofMatch.getOxmMatchField().equals(MplsTc.class)){
800 TcMatchEntry tcMatchEntry = ofMatch.getAugmentation(TcMatchEntry.class);
801 if(tcMatchEntry != null){
802 protocolMatchFieldsBuilder.setMplsTc(tcMatchEntry.getTc());
803 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
805 }else if(ofMatch.getOxmMatchField().equals(PbbIsid.class)){
806 IsidMatchEntry isidMatchEntry = ofMatch.getAugmentation(IsidMatchEntry.class);
807 if(isidMatchEntry != null){
808 PbbBuilder pbbBuilder = new PbbBuilder();
809 pbbBuilder.setPbbIsid(isidMatchEntry.getIsid());
810 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
811 if(maskMatchEntry != null){
812 pbbBuilder.setPbbMask(maskMatchEntry.getMask());
814 protocolMatchFieldsBuilder.setPbb(pbbBuilder.build());
815 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
817 }else if(ofMatch.getOxmMatchField().equals(TunnelId.class)){
818 TunnelBuilder tunnelBuilder = new TunnelBuilder();
819 MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
820 if(metadataMatchEntry != null){
821 tunnelBuilder.setTunnelId(new BigInteger(metadataMatchEntry.getMetadata()));
822 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
823 if(maskMatchEntry != null){
824 tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
826 matchBuilder.setTunnel(tunnelBuilder.build());
830 return matchBuilder.build();
834 private static MatchEntries toOfMplsPbb(Pbb pbb) {
835 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
836 boolean hasmask = false;
837 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
838 matchEntriesBuilder.setOxmMatchField(PbbIsid.class);
839 IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();
840 isidBuilder.setIsid(pbb.getPbbIsid());
841 matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
842 if (pbb.getPbbMask() != null) {
844 addMaskAugmentation(matchEntriesBuilder, pbb.getPbbMask());
846 matchEntriesBuilder.setHasMask(hasmask);
847 return matchEntriesBuilder.build();
850 private static MatchEntries toOfMplsTc(Short mplsTc) {
851 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
852 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
853 matchEntriesBuilder.setHasMask(false);
854 matchEntriesBuilder.setOxmMatchField(MplsTc.class);
855 TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();
856 tcBuilder.setTc(mplsTc);
857 matchEntriesBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build());
858 return matchEntriesBuilder.build();
861 private static MatchEntries toOfMplsBos(Short mplsBos) {
862 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
863 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
864 matchEntriesBuilder.setHasMask(false);
865 matchEntriesBuilder.setOxmMatchField(MplsBos.class);
866 BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();
868 bosBuilder.setBos(true);
870 bosBuilder.setBos(false);
872 matchEntriesBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build());
873 return matchEntriesBuilder.build();
876 private static MatchEntries toOfMplsLabel(Long mplsLabel) {
877 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
878 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
879 matchEntriesBuilder.setHasMask(false);
880 matchEntriesBuilder.setOxmMatchField(MplsLabel.class);
881 MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();
882 mplsLabelBuilder.setMplsLabel(mplsLabel);
883 matchEntriesBuilder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());
884 return matchEntriesBuilder.build();
887 private static MatchEntries toOfIpv6ExtHeader(Ipv6ExtHeader ipv6ExtHeader) {
888 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
889 boolean hasmask = false;
890 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
891 matchEntriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
892 PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();
893 Integer bitmap = ipv6ExtHeader.getIpv6Exthdr();
894 final Boolean NONEXT = ((bitmap) & (1 << 0)) != 0;
895 final Boolean ESP = ((bitmap) & (1 << 1)) != 0;
896 final Boolean AUTH = ((bitmap) & (1 << 2)) != 0;
897 final Boolean DEST = ((bitmap) & (1 << 3)) != 0;
898 final Boolean FRAG = ((bitmap) & (1 << 4)) != 0;
899 final Boolean ROUTER = ((bitmap) & (1 << 5)) != 0;
900 final Boolean HOP = ((bitmap) & (1 << 6)) != 0;
901 final Boolean UNREP = ((bitmap) & (1 << 7)) != 0;
902 final Boolean UNSEQ = ((bitmap) & (1 << 8)) != 0;
903 pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));
904 matchEntriesBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());
905 if (ipv6ExtHeader.getIpv6ExthdrMask() != null) {
907 addMaskAugmentation(matchEntriesBuilder, ipv6ExtHeader.getIpv6ExthdrMask());
909 matchEntriesBuilder.setHasMask(hasmask);
910 return matchEntriesBuilder.build();
913 private static MatchEntries toOfIpv6FlowLabel(Ipv6Label ipv6Label) {
914 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
915 boolean hasmask = false;
916 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
917 matchEntriesBuilder.setOxmMatchField(Ipv6Flabel.class);
918 Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();
919 ipv6FlabelBuilder.setIpv6Flabel(ipv6Label.getIpv6Flabel());
920 matchEntriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());
921 if (ipv6Label.getFlabelMask() != null) {
923 addMaskAugmentation(matchEntriesBuilder, ipv6Label.getFlabelMask());
925 matchEntriesBuilder.setHasMask(hasmask);
926 return matchEntriesBuilder.build();
929 private static MatchEntries toOfPort(Class<? extends MatchField> field, Long portNumber) {
930 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
931 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
932 matchEntriesBuilder.setHasMask(false);
933 matchEntriesBuilder.setOxmMatchField(field);
934 PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
935 port.setPortNumber(new PortNumber(portNumber));
936 matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
937 return matchEntriesBuilder.build();
940 private static MatchEntries toOfMetadata(Class<? extends MatchField> field, BigInteger metadata, byte[] metadataMask) {
941 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
942 boolean hasmask = false;
943 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
944 matchEntriesBuilder.setOxmMatchField(field);
945 addMetadataAugmentation(matchEntriesBuilder, metadata);
946 if (metadataMask != null) {
948 addMaskAugmentation(matchEntriesBuilder, metadataMask);
950 matchEntriesBuilder.setHasMask(hasmask);
951 return matchEntriesBuilder.build();
954 private static MatchEntries toOfMacAddress(Class<? extends MatchField> field,
955 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress macAddress,
957 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
958 boolean hasmask = false;
959 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
960 matchEntriesBuilder.setOxmMatchField(field);
961 addMacAddressAugmentation(matchEntriesBuilder, macAddress);
964 addMaskAugmentation(matchEntriesBuilder, mask);
966 matchEntriesBuilder.setHasMask(hasmask);
967 return matchEntriesBuilder.build();
970 private static MatchEntries toOfEthernetType(EthernetType ethernetType) {
971 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
972 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
973 matchEntriesBuilder.setHasMask(false);
974 matchEntriesBuilder.setOxmMatchField(EthType.class);
975 EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();
976 ethertypeBuilder.setEthType(new EtherType(ethernetType.getType().getValue().intValue()));
977 matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());
978 return matchEntriesBuilder.build();
981 private static MatchEntries toOfLayer3Port(Class<? extends MatchField> field,
982 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber portNumber) {
983 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
984 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
985 matchEntriesBuilder.setHasMask(false);
986 matchEntriesBuilder.setOxmMatchField(field);
987 PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();
988 portBuilder.setPort(portNumber);
989 matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build());
990 return matchEntriesBuilder.build();
993 private static MatchEntries toOfIcmpv4Type(Short icmpv4Type) {
994 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
995 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
996 matchEntriesBuilder.setHasMask(false);
997 matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
998 Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();
999 icmpv4TypeBuilder.setIcmpv4Type(icmpv4Type);
1000 matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());
1001 return matchEntriesBuilder.build();
1004 private static MatchEntries toOfIcmpv4Code(Short icmpv4Code) {
1005 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1006 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1007 matchEntriesBuilder.setHasMask(false);
1008 matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);
1009 Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();
1010 icmpv4CodeBuilder.setIcmpv4Code(icmpv4Code);
1011 matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());
1012 return matchEntriesBuilder.build();
1015 private static MatchEntries toOfIcmpv6Type(Short icmpv6Type) {
1016 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1017 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1018 matchEntriesBuilder.setHasMask(false);
1019 matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
1020 Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();
1021 icmpv6TypeBuilder.setIcmpv6Type(icmpv6Type);
1022 matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());
1023 return matchEntriesBuilder.build();
1026 private static MatchEntries toOfIcmpv6Code(Short icmpv6Code) {
1027 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1028 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1029 matchEntriesBuilder.setHasMask(false);
1030 matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
1031 Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();
1032 icmpv6CodeBuilder.setIcmpv6Code(icmpv6Code);
1033 matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());
1034 return matchEntriesBuilder.build();
1037 private static MatchEntries toOfIpv4Prefix(Class<? extends MatchField> field, Ipv4Prefix ipv4Prefix) {
1038 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1039 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1040 matchEntriesBuilder.setOxmMatchField(field);
1041 boolean hasMask = addIpv4PrefixAugmentation(matchEntriesBuilder, ipv4Prefix);
1042 matchEntriesBuilder.setHasMask(hasMask);
1043 return matchEntriesBuilder.build();
1046 private static MatchEntries toOfIpv6Prefix(Class<? extends MatchField> field, Ipv6Prefix ipv6Prefix) {
1047 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1048 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1049 matchEntriesBuilder.setOxmMatchField(field);
1050 boolean hasmask = addIpv6PrefixAugmentation(matchEntriesBuilder, ipv6Prefix);
1051 matchEntriesBuilder.setHasMask(hasmask);
1052 return matchEntriesBuilder.build();
1055 private static MatchEntries toOfIpDscp(Dscp ipDscp) {
1056 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1057 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1058 matchEntriesBuilder.setHasMask(false);
1059 matchEntriesBuilder.setOxmMatchField(IpDscp.class);
1060 DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();
1061 dscpBuilder.setDscp(ipDscp);
1062 matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());
1063 return matchEntriesBuilder.build();
1066 private static MatchEntries toOfVlanPcp(
1067 org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp vlanPcp) {
1068 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1069 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1070 matchEntriesBuilder.setHasMask(false);
1071 matchEntriesBuilder.setOxmMatchField(VlanPcp.class);
1072 VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();
1073 vlanPcpBuilder.setVlanPcp(vlanPcp.getValue());
1074 matchEntriesBuilder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());
1075 return matchEntriesBuilder.build();
1078 private static MatchEntries toOfVlanVid(VlanId vlanId) {
1080 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1081 boolean hasmask = false;
1082 boolean setCfiBit = false;
1083 Integer vidEntryValue = 0;
1084 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1085 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
1086 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
1087 if (vlanId.isVlanIdPresent() == true) {
1089 if (vlanId.getVlanId() != null) {
1090 vidEntryValue = vlanId.getVlanId().getValue();
1092 hasmask = (vidEntryValue == 0);
1094 vlanVidBuilder.setCfiBit(setCfiBit);
1095 vlanVidBuilder.setVlanVid(vidEntryValue);
1096 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
1098 addMaskAugmentation(matchEntriesBuilder, VLAN_VID_MASK);
1100 matchEntriesBuilder.setHasMask(hasmask);
1101 return matchEntriesBuilder.build();
1104 private static MatchEntries toOfIpProto(Short ipProtocol) {
1105 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1106 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1107 matchEntriesBuilder.setHasMask(false);
1108 matchEntriesBuilder.setOxmMatchField(IpProto.class);
1109 ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();
1110 protoNumberBuilder.setProtocolNumber(ipProtocol);
1111 matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());
1112 return matchEntriesBuilder.build();
1115 private static MatchEntries toOfIpEcn(Short ipEcn) {
1116 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1117 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1118 matchEntriesBuilder.setHasMask(false);
1119 matchEntriesBuilder.setOxmMatchField(IpEcn.class);
1120 EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();
1121 ecnBuilder.setEcn(ipEcn);
1122 matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());
1123 return matchEntriesBuilder.build();
1126 private static MatchEntries toOfArpOpCode(Integer arpOp) {
1127 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1128 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1129 matchEntriesBuilder.setHasMask(false);
1130 matchEntriesBuilder.setOxmMatchField(ArpOp.class);
1131 OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();
1132 opcodeBuilder.setOpCode(arpOp);
1133 matchEntriesBuilder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());
1134 return matchEntriesBuilder.build();
1137 private static MatchEntries toOfIpv6Address(Ipv6Address address) {
1138 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1139 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1140 matchEntriesBuilder.setHasMask(false);
1141 matchEntriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
1142 Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
1143 ipv6AddressBuilder.setIpv6Address(address);
1144 matchEntriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
1145 return matchEntriesBuilder.build();
1148 private static void addMaskAugmentation(MatchEntriesBuilder builder, byte[] mask) {
1149 MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();
1150 maskBuilder.setMask(mask);
1151 builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
1154 private static boolean addIpv6PrefixAugmentation(MatchEntriesBuilder builder, Ipv6Prefix address) {
1155 boolean hasMask = false;
1156 String[] addressParts = address.getValue().split(PREFIX_SEPARATOR);
1157 Integer prefix = null;
1158 if (addressParts.length == 2) {
1159 prefix = Integer.parseInt(addressParts[1]);
1162 Ipv6Address ipv6Address = new Ipv6Address(addressParts[0]);
1163 Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
1164 ipv6AddressBuilder.setIpv6Address(ipv6Address);
1165 builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
1166 if (prefix != null) {
1168 addMaskAugmentation(builder, convertIpv6PrefixToByteArray(prefix));
1173 private static byte[] convertIpv6PrefixToByteArray(int prefix) {
1174 // TODO: Temporary fix. Has performance impacts.
1175 byte[] mask = new byte[16];
1176 int oneCount = prefix;
1177 for (int count = 0; count < 16; count++) {
1179 if (oneCount >= 8) {
1181 oneCount = oneCount - 8;
1183 byteBits = oneCount;
1187 mask[count] = (byte) (256 - Math.pow(2, 8 - byteBits));
1192 private static void addMetadataAugmentation(MatchEntriesBuilder builder, BigInteger metadata) {
1193 MetadataMatchEntryBuilder metadataMatchEntry = new MetadataMatchEntryBuilder();
1194 metadataMatchEntry.setMetadata(ByteUtil.convertBigIntegerTo64Bit(metadata));
1195 builder.addAugmentation(MetadataMatchEntry.class, metadataMatchEntry.build());
1199 * @return true if Ipv4Prefix contains prefix (and it is used in mask),
1202 private static boolean addIpv4PrefixAugmentation(MatchEntriesBuilder builder, Ipv4Prefix address) {
1203 boolean hasMask = false;
1204 String[] addressParts = address.getValue().split(PREFIX_SEPARATOR);
1205 Integer prefix = null;
1206 if (addressParts.length < 2) {
1209 prefix = Integer.parseInt(addressParts[1]);
1212 Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
1213 Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
1214 ipv4AddressBuilder.setIpv4Address(ipv4Address);
1215 builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
1217 int mask = 0xffffffff << (32 - prefix);
1218 byte[] maskBytes = new byte[] { (byte) (mask >>> 24), (byte) (mask >>> 16), (byte) (mask >>> 8),
1220 addMaskAugmentation(builder, maskBytes);
1226 private static void addMacAddressAugmentation(MatchEntriesBuilder builder, MacAddress address) {
1227 MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();
1228 macAddress.setMacAddress(address);
1229 builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
1233 * Method converts OF SetField Match to SAL SetFiled matches
1234 * TODO: enable or delete
1238 public static SetField ofToSALSetField(
1239 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action action) {
1240 logger.info("OF SetField match to SAL SetField match converstion begins");
1241 SetFieldBuilder setField = new SetFieldBuilder();
1243 * OxmFieldsAction oxmFields =
1244 * action.getAugmentation(OxmFieldsAction.class);
1246 * List<MatchEntries> matchEntries = oxmFields.getMatchEntries();
1248 * .yang.gen.v1.urn.opendaylight.action.types.rev131112.action
1249 * .action.set.field.MatchBuilder match =new
1250 * org.opendaylight.yang.gen.v1
1251 * .urn.opendaylight.action.types.rev131112.action
1252 * .action.set.field.MatchBuilder();
1254 * EthernetMatchBuilder ethernetMatchBuilder = null; VlanMatchBuilder
1255 * vlanMatchBuilder = null; IpMatchBuilder ipMatchBuilder = null;
1256 * TcpMatchBuilder tcpMatchBuilder = null; UdpMatchBuilder
1257 * udpMatchBuilder = null; SctpMatchBuilder sctpMatchBuilder = null;
1258 * Icmpv4MatchBuilder icmpv4MatchBuilder = null; Icmpv6MatchBuilder
1259 * icmpv6MatchBuilder = null; Ipv4MatchBuilder ipv4MatchBuilder = null;
1260 * ArpMatchBuilder arpMatchBuilder = null; Ipv6MatchBuilder
1261 * ipv6MatchBuilder = null; ProtocolMatchFieldsBuilder
1262 * protocolMatchFieldsBuilder = null;
1264 * for(MatchEntries matchEntry : matchEntries){ if(matchEntry instanceof
1265 * InPort){ PortNumberMatchEntry inPort =
1266 * matchEntry.getAugmentation(PortNumberMatchEntry.class);
1267 * match.setInPort(inPort.getPortNumber().getValue()); }else if
1268 * (matchEntry instanceof InPhyPort){ PortNumberMatchEntry phyPort =
1269 * matchEntry.getAugmentation(PortNumberMatchEntry.class);
1270 * match.setInPhyPort(phyPort.getPortNumber().getValue()); }else if
1271 * (matchEntry instanceof Metadata){ MetadataMatchEntry metadataMatch =
1272 * matchEntry.getAugmentation(MetadataMatchEntry.class); MetadataBuilder
1273 * metadataBuilder = new MetadataBuilder();
1274 * metadataBuilder.setMetadata(new
1275 * BigInteger(metadataMatch.getMetadata())); MaskMatchEntry maskMatch =
1276 * matchEntry.getAugmentation(MaskMatchEntry.class); if (maskMatch !=
1277 * null){ metadataBuilder.setMetadataMask(maskMatch.getMask()); }
1278 * match.setMetadata(metadataBuilder.build()); }else if (matchEntry
1279 * instanceof EthDst){
1281 * if(ethernetMatchBuilder == null) ethernetMatchBuilder = new
1282 * EthernetMatchBuilder();
1284 * MacAddressMatchEntry macAddressMatch =
1285 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1286 * MaskMatchEntry maskMatch =
1287 * matchEntry.getAugmentation(MaskMatchEntry.class);
1288 * EthernetDestinationBuilder ethernetDestination = new
1289 * EthernetDestinationBuilder();
1290 * ethernetDestination.setAddress(macAddressMatch.getMacAddress());
1291 * if(maskMatch != null){
1292 * ethernetDestination.setMask(maskMatch.getMask()); }
1293 * ethernetMatchBuilder
1294 * .setEthernetDestination(ethernetDestination.build()); }else if
1295 * (matchEntry instanceof EthSrc){ if(ethernetMatchBuilder == null)
1296 * ethernetMatchBuilder = new EthernetMatchBuilder();
1298 * MacAddressMatchEntry macAddressMatch =
1299 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1300 * MaskMatchEntry maskMatch =
1301 * matchEntry.getAugmentation(MaskMatchEntry.class);
1302 * EthernetSourceBuilder ethernetSource = new EthernetSourceBuilder();
1303 * ethernetSource.setAddress(macAddressMatch.getMacAddress());
1304 * if(maskMatch != null){ ethernetSource.setMask(maskMatch.getMask()); }
1305 * ethernetMatchBuilder.setEthernetSource(ethernetSource.build()); }else
1306 * if (matchEntry instanceof EthType){ if(ethernetMatchBuilder == null)
1307 * ethernetMatchBuilder = new EthernetMatchBuilder();
1309 * EthTypeMatchEntry etherTypeMatch =
1310 * matchEntry.getAugmentation(EthTypeMatchEntry.class);
1311 * EthernetTypeBuilder ethernetType= new EthernetTypeBuilder();
1313 * .yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType etherType
1315 * org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827
1316 * .EtherType((long)etherTypeMatch.getEthType().getValue());
1317 * ethernetType.setType(etherType);
1318 * ethernetMatchBuilder.setEthernetType(ethernetType.build()); }else if
1319 * (matchEntry instanceof VlanVid){ if(vlanMatchBuilder == null)
1320 * vlanMatchBuilder = new VlanMatchBuilder();
1322 * VlanVidMatchEntry vlanVidMatch =
1323 * matchEntry.getAugmentation(VlanVidMatchEntry.class); MaskMatchEntry
1324 * maskMatch = matchEntry.getAugmentation(MaskMatchEntry.class);
1326 * VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
1327 * vlanIdBuilder.setVlanId( new
1328 * org.opendaylight.yang.gen.v1.urn.opendaylight
1329 * .l2.types.rev130827.VlanId(vlanVidMatch.getVlanVid())); if(maskMatch
1330 * != null){ vlanIdBuilder.setMask(maskMatch.getMask()); }
1331 * vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
1333 * }else if (matchEntry instanceof VlanPcp){ if(vlanMatchBuilder ==
1334 * null) vlanMatchBuilder = new VlanMatchBuilder();
1336 * VlanPcpMatchEntry vlanPcpMatch =
1337 * matchEntry.getAugmentation(VlanPcpMatchEntry.class);
1338 * vlanMatchBuilder.setVlanPcp( new
1339 * org.opendaylight.yang.gen.v1.urn.opendaylight
1340 * .l2.types.rev130827.VlanPcp(vlanPcpMatch.getVlanPcp())); }else if
1341 * (matchEntry instanceof IpDscp){ if(ipMatchBuilder == null)
1342 * ipMatchBuilder = new IpMatchBuilder();
1344 * DscpMatchEntry dscpMatchEntry =
1345 * matchEntry.getAugmentation(DscpMatchEntry.class);
1346 * ipMatchBuilder.setIpDscp(dscpMatchEntry.getDscp());
1348 * }else if (matchEntry instanceof IpEcn){ if(ipMatchBuilder == null)
1349 * ipMatchBuilder = new IpMatchBuilder();
1351 * EcnMatchEntry ecnMatchEntry =
1352 * matchEntry.getAugmentation(EcnMatchEntry.class);
1353 * ipMatchBuilder.setIpEcn(ecnMatchEntry.getEcn());
1355 * }else if (matchEntry instanceof IpProto){ if(ipMatchBuilder == null)
1356 * ipMatchBuilder = new IpMatchBuilder();
1358 * ProtocolNumberMatchEntry protocolNumberMatch =
1359 * matchEntry.getAugmentation(ProtocolNumberMatchEntry.class);
1361 * .setIpProtocol(protocolNumberMatch.getProtocolNumber()); }else if
1362 * (matchEntry instanceof TcpSrc){ if(tcpMatchBuilder == null)
1363 * tcpMatchBuilder = new TcpMatchBuilder();
1365 * PortMatchEntry portMatchEntry =
1366 * matchEntry.getAugmentation(PortMatchEntry.class);
1367 * tcpMatchBuilder.setTcpSourcePort(portMatchEntry.getPort());
1369 * }else if (matchEntry instanceof TcpDst){ if(tcpMatchBuilder == null)
1370 * tcpMatchBuilder = new TcpMatchBuilder();
1372 * PortMatchEntry portMatchEntry =
1373 * matchEntry.getAugmentation(PortMatchEntry.class);
1374 * tcpMatchBuilder.setTcpDestinationPort(portMatchEntry.getPort());
1376 * }else if (matchEntry instanceof UdpSrc){ if(udpMatchBuilder == null)
1377 * udpMatchBuilder = new UdpMatchBuilder();
1379 * PortMatchEntry portMatchEntry =
1380 * matchEntry.getAugmentation(PortMatchEntry.class);
1381 * udpMatchBuilder.setUdpSourcePort(portMatchEntry.getPort());
1384 * }else if (matchEntry instanceof UdpDst){ if(udpMatchBuilder == null)
1385 * udpMatchBuilder = new UdpMatchBuilder();
1387 * PortMatchEntry portMatchEntry =
1388 * matchEntry.getAugmentation(PortMatchEntry.class);
1389 * udpMatchBuilder.setUdpDestinationPort(portMatchEntry.getPort());
1390 * }else if (matchEntry instanceof SctpSrc){ if(sctpMatchBuilder ==
1391 * null) sctpMatchBuilder = new SctpMatchBuilder();
1393 * PortMatchEntry portMatchEntry =
1394 * matchEntry.getAugmentation(PortMatchEntry.class);
1395 * sctpMatchBuilder.setSctpSourcePort(portMatchEntry.getPort());
1397 * }else if (matchEntry instanceof SctpDst){ if(sctpMatchBuilder ==
1398 * null) sctpMatchBuilder = new SctpMatchBuilder();
1400 * PortMatchEntry portMatchEntry =
1401 * matchEntry.getAugmentation(PortMatchEntry.class);
1402 * sctpMatchBuilder.setSctpDestinationPort(portMatchEntry.getPort());
1403 * }else if (matchEntry instanceof Icmpv4Type){ if(icmpv4MatchBuilder ==
1404 * null) icmpv4MatchBuilder = new Icmpv4MatchBuilder();
1406 * Icmpv4TypeMatchEntry icmpv4TypeMatchEntry =
1407 * matchEntry.getAugmentation(Icmpv4TypeMatchEntry.class);
1408 * icmpv4MatchBuilder
1409 * .setIcmpv4Type(icmpv4TypeMatchEntry.getIcmpv4Type());
1411 * }else if (matchEntry instanceof Icmpv4Code){ if(icmpv4MatchBuilder ==
1412 * null) icmpv4MatchBuilder = new Icmpv4MatchBuilder();
1414 * Icmpv4CodeMatchEntry icmpv4CodeMatchEntry =
1415 * matchEntry.getAugmentation(Icmpv4CodeMatchEntry.class);
1416 * icmpv4MatchBuilder
1417 * .setIcmpv4Code(icmpv4CodeMatchEntry.getIcmpv4Code());
1419 * }else if (matchEntry instanceof Icmpv6Type){ if(icmpv6MatchBuilder ==
1420 * null) icmpv6MatchBuilder = new Icmpv6MatchBuilder();
1422 * Icmpv6TypeMatchEntry icmpv6TypeMatchEntry =
1423 * matchEntry.getAugmentation(Icmpv6TypeMatchEntry.class);
1424 * icmpv6MatchBuilder
1425 * .setIcmpv6Type(icmpv6TypeMatchEntry.getIcmpv6Type()); }else if
1426 * (matchEntry instanceof Icmpv6Code){ if(icmpv6MatchBuilder == null)
1427 * icmpv6MatchBuilder = new Icmpv6MatchBuilder();
1429 * Icmpv6CodeMatchEntry icmpv6CodeMatchEntry =
1430 * matchEntry.getAugmentation(Icmpv6CodeMatchEntry.class);
1431 * icmpv6MatchBuilder
1432 * .setIcmpv6Code(icmpv6CodeMatchEntry.getIcmpv6Code()); }else if
1433 * (matchEntry instanceof Ipv4Src){ if(ipv4MatchBuilder == null)
1434 * ipv4MatchBuilder = new Ipv4MatchBuilder();
1436 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1437 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1438 * MaskMatchEntry maskMatchEntry =
1439 * matchEntry.getAugmentation(MaskMatchEntry.class);
1440 * ipv4MatchBuilder.setIpv4Source( new
1441 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1442 * String(maskMatchEntry.getMask())));
1444 * }else if (matchEntry instanceof Ipv4Dst){ if(ipv4MatchBuilder ==
1445 * null) ipv4MatchBuilder = new Ipv4MatchBuilder();
1447 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1448 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1449 * MaskMatchEntry maskMatchEntry =
1450 * matchEntry.getAugmentation(MaskMatchEntry.class);
1451 * ipv4MatchBuilder.setIpv4Destination( new
1452 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1453 * String(maskMatchEntry.getMask()))); }else if (matchEntry instanceof
1454 * ArpOp){ if(arpMatchBuilder == null) arpMatchBuilder = new
1455 * ArpMatchBuilder();
1457 * OpCodeMatchEntry opCodeMatchEntry =
1458 * matchEntry.getAugmentation(OpCodeMatchEntry.class);
1459 * arpMatchBuilder.setArpOp(opCodeMatchEntry.getOpCode());
1461 * }else if (matchEntry instanceof ArpSpa){ if(arpMatchBuilder == null)
1462 * arpMatchBuilder = new ArpMatchBuilder();
1464 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1465 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1466 * MaskMatchEntry maskMatchEntry =
1467 * matchEntry.getAugmentation(MaskMatchEntry.class);
1468 * arpMatchBuilder.setArpSourceTransportAddress( new
1469 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1470 * String(maskMatchEntry.getMask())));
1472 * }else if (matchEntry instanceof ArpTpa){ if(arpMatchBuilder == null)
1473 * arpMatchBuilder = new ArpMatchBuilder();
1475 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1476 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1477 * MaskMatchEntry maskMatchEntry =
1478 * matchEntry.getAugmentation(MaskMatchEntry.class);
1479 * arpMatchBuilder.setArpTargetTransportAddress( new
1480 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1481 * String(maskMatchEntry.getMask())));
1483 * }else if (matchEntry instanceof ArpSha){ if(arpMatchBuilder == null)
1484 * arpMatchBuilder = new ArpMatchBuilder();
1486 * MacAddressMatchEntry macAddressMatchEntry =
1487 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1488 * MaskMatchEntry maskMatchEntry =
1489 * matchEntry.getAugmentation(MaskMatchEntry.class);
1490 * ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new
1491 * ArpSourceHardwareAddressBuilder();
1492 * arpSourceHardwareAddressBuilder.setAddress
1493 * (macAddressMatchEntry.getMacAddress());
1494 * arpSourceHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
1496 * .setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder
1499 * }else if (matchEntry instanceof ArpTha){ if(arpMatchBuilder == null)
1500 * arpMatchBuilder = new ArpMatchBuilder();
1502 * MacAddressMatchEntry macAddressMatchEntry =
1503 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1504 * MaskMatchEntry maskMatchEntry =
1505 * matchEntry.getAugmentation(MaskMatchEntry.class);
1506 * ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new
1507 * ArpTargetHardwareAddressBuilder();
1508 * arpTargetHardwareAddressBuilder.setAddress
1509 * (macAddressMatchEntry.getMacAddress());
1510 * arpTargetHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
1512 * .setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder
1513 * .build()); }else if (matchEntry instanceof Ipv6Src){
1514 * if(ipv6MatchBuilder == null) ipv6MatchBuilder = new
1515 * Ipv6MatchBuilder();
1517 * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
1518 * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
1519 * MaskMatchEntry maskMatchEntry =
1520 * matchEntry.getAugmentation(MaskMatchEntry.class);
1521 * ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix
1522 * (ipv6AddressMatchEntry.getIpv6Address().getValue()+ "/"+new
1523 * String(maskMatchEntry.getMask())));
1525 * }else if (matchEntry instanceof Ipv6Dst){ if(ipv6MatchBuilder ==
1526 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1528 * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
1529 * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
1530 * MaskMatchEntry maskMatchEntry =
1531 * matchEntry.getAugmentation(MaskMatchEntry.class);
1532 * ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix
1533 * (ipv6AddressMatchEntry.getIpv6Address().getValue()+ "/"+new
1534 * String(maskMatchEntry.getMask())));
1536 * }else if (matchEntry instanceof Ipv6Flabel){ if(ipv6MatchBuilder ==
1537 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1539 * Ipv6FlabelMatchEntry ipv6FlabelMatchEntry =
1540 * matchEntry.getAugmentation(Ipv6FlabelMatchEntry.class);
1541 * MaskMatchEntry maskMatchEntry =
1542 * matchEntry.getAugmentation(MaskMatchEntry.class); Ipv6LabelBuilder
1543 * ipv6LabelBuilder = new Ipv6LabelBuilder();
1544 * ipv6LabelBuilder.setIpv6Flabel(ipv6FlabelMatchEntry.getIpv6Flabel());
1545 * ipv6LabelBuilder.setFlabelMask(maskMatchEntry.getMask());
1546 * ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
1548 * }else if (matchEntry instanceof Ipv6NdTarget){ if(ipv6MatchBuilder ==
1549 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1550 * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
1551 * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
1553 * .setIpv6NdTarget(ipv6AddressMatchEntry.getIpv6Address());
1555 * }else if (matchEntry instanceof Ipv6NdSll){ if(ipv6MatchBuilder ==
1556 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1558 * MacAddressMatchEntry macAddressMatchEntry =
1559 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1560 * ipv6MatchBuilder.setIpv6NdSll(macAddressMatchEntry.getMacAddress());
1561 * }else if (matchEntry instanceof Ipv6NdTll){ if(ipv6MatchBuilder ==
1562 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1564 * MacAddressMatchEntry macAddressMatchEntry =
1565 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1566 * ipv6MatchBuilder.setIpv6NdTll(macAddressMatchEntry.getMacAddress());
1568 * }else if (matchEntry instanceof Ipv6Exthdr){ if(ipv6MatchBuilder ==
1569 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1571 * PseudoFieldMatchEntry pseudoFieldMatchEntry =
1572 * matchEntry.getAugmentation(PseudoFieldMatchEntry.class); PseudoField
1573 * pseudoField = pseudoFieldMatchEntry.getPseudoField(); int
1574 * pseudoFieldInt = 0; pseudoFieldInt |= pseudoField.isNonext()?(1 <<
1575 * 0):~(1 << 0); pseudoFieldInt |= pseudoField.isEsp()?(1 << 1):~(1 <<
1576 * 1); pseudoFieldInt |= pseudoField.isAuth()?(1 << 2):~(1 << 2);
1577 * pseudoFieldInt |= pseudoField.isDest()?(1 << 3):~(1 << 3);
1578 * pseudoFieldInt |= pseudoField.isFrag()?(1 << 4):~(1 << 4);
1579 * pseudoFieldInt |= pseudoField.isRouter()?(1 << 5):~(1 << 5);
1580 * pseudoFieldInt |= pseudoField.isHop()?(1 << 6):~(1 << 6);
1581 * pseudoFieldInt |= pseudoField.isUnrep()?(1 << 7):~(1 << 7);
1582 * pseudoFieldInt |= pseudoField.isUnseq()?(1 << 8):~(1 << 8);
1584 * ipv6MatchBuilder.setIpv6Exthdr(pseudoFieldInt); }else if (matchEntry
1585 * instanceof MplsLabel){ if(protocolMatchFieldsBuilder == null)
1586 * protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
1588 * MplsLabelMatchEntry MplsLabelMatchEntry =
1589 * matchEntry.getAugmentation(MplsLabelMatchEntry.class);
1590 * protocolMatchFieldsBuilder
1591 * .setMplsLabel(MplsLabelMatchEntry.getMplsLabel());
1593 * }else if (matchEntry instanceof MplsBos){
1594 * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
1595 * new ProtocolMatchFieldsBuilder();
1597 * BosMatchEntry bosMatchEntry =
1598 * matchEntry.getAugmentation(BosMatchEntry.class);
1599 * protocolMatchFieldsBuilder
1600 * .setMplsBos(bosMatchEntry.isBos()?(short)1:(short)0);
1602 * }else if (matchEntry instanceof MplsTc) {
1603 * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
1604 * new ProtocolMatchFieldsBuilder();
1606 * TcMatchEntry tcMatchEntry =
1607 * matchEntry.getAugmentation(TcMatchEntry.class);
1608 * protocolMatchFieldsBuilder.setMplsTc(tcMatchEntry.getTc());
1610 * }else if (matchEntry instanceof PbbIsid){
1611 * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
1612 * new ProtocolMatchFieldsBuilder();
1614 * IsidMatchEntry isidMatchEntry =
1615 * matchEntry.getAugmentation(IsidMatchEntry.class); PbbBuilder
1616 * pbbBuilder = new PbbBuilder();
1617 * pbbBuilder.setPbbIsid(isidMatchEntry.getIsid()); MaskMatchEntry
1618 * maskMatchEntry = matchEntry.getAugmentation(MaskMatchEntry.class);
1619 * if(maskMatchEntry != null)
1620 * pbbBuilder.setPbbMask(maskMatchEntry.getMask());
1622 * protocolMatchFieldsBuilder.setPbb(pbbBuilder.build()); }else if
1623 * (matchEntry instanceof TunnelId){ MetadataMatchEntry
1624 * metadataMatchEntry =
1625 * matchEntry.getAugmentation(MetadataMatchEntry.class); MaskMatchEntry
1626 * maskMatchEntry = matchEntry.getAugmentation(MaskMatchEntry.class);
1627 * TunnelBuilder tunnelBuilder = new TunnelBuilder();
1628 * tunnelBuilder.setTunnelId(new
1629 * BigInteger(metadataMatchEntry.getMetadata()));
1630 * tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
1631 * match.setTunnel(tunnelBuilder.build()); } } if(ethernetMatchBuilder
1632 * != null){ match.setEthernetMatch(ethernetMatchBuilder.build()); } if
1633 * (vlanMatchBuilder != null){
1634 * match.setVlanMatch(vlanMatchBuilder.build()); } if(ipMatchBuilder !=
1635 * null){ match.setIpMatch(ipMatchBuilder.build()); } if(tcpMatchBuilder
1636 * != null){ match.setLayer4Match(tcpMatchBuilder.build()); }
1637 * if(udpMatchBuilder != null){
1638 * match.setLayer4Match(udpMatchBuilder.build()); } if(sctpMatchBuilder
1639 * != null){ match.setLayer4Match(sctpMatchBuilder.build()); }
1640 * if(icmpv4MatchBuilder != null){
1641 * match.setIcmpv4Match(icmpv4MatchBuilder.build()); }
1642 * if(icmpv6MatchBuilder != null){
1643 * match.setIcmpv6Match(icmpv6MatchBuilder.build()); }
1644 * if(ipv4MatchBuilder != null){
1645 * match.setLayer3Match(ipv4MatchBuilder.build()); } if(arpMatchBuilder
1646 * != null){ match.setLayer3Match(arpMatchBuilder.build()); }
1647 * if(ipv6MatchBuilder != null){
1648 * match.setLayer3Match(ipv6MatchBuilder.build()); }
1649 * if(protocolMatchFieldsBuilder != null){
1650 * match.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); }
1651 * setField.setMatch(match.build());
1652 */return setField.build();