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 //DSCP default value is 0 from the library but controller side it is null.
483 // look if there better solution
484 if(0 != swMatch.getNwTos())
486 ipMatchBuilder.setIpDscp(new Dscp(swMatch.getNwTos()));
488 matchBuilder.setIpMatch(ipMatchBuilder.build());
491 return matchBuilder.build();
495 * Method converts Openflow 1.3+ specific flow match to MD-SAL format
499 * @author avishnoi@in.ibm.com
501 public static Match fromOFMatchToSALMatch(
502 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match swMatch) {
504 MatchBuilder matchBuilder = new MatchBuilder();
505 EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
506 VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
507 IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
508 TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
509 UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
510 SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
511 Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
512 Icmpv6MatchBuilder icmpv6MatchBuilder = new Icmpv6MatchBuilder();
513 Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
514 ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
515 Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
516 ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
518 List<MatchEntries> swMatchList = swMatch.getMatchEntries();
520 for(MatchEntries ofMatch : swMatchList){
522 if(ofMatch.getOxmMatchField().equals(InPort.class)){
523 PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
524 matchBuilder.setInPort(portNumber.getPortNumber().getValue());
525 }else if (ofMatch.getOxmMatchField().equals(InPhyPort.class)){
526 PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
527 matchBuilder.setInPhyPort(portNumber.getPortNumber().getValue());
528 }else if(ofMatch.getOxmMatchField().equals(Metadata.class)){
529 MetadataBuilder metadataBuilder = new MetadataBuilder();
530 MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
531 if(metadataMatchEntry != null){
532 metadataBuilder.setMetadata(new BigInteger(metadataMatchEntry.getMetadata()));
533 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
534 if(maskMatchEntry != null){
535 metadataBuilder.setMetadataMask(maskMatchEntry.getMask());
537 matchBuilder.setMetadata(metadataBuilder.build());
539 }else if(ofMatch.getOxmMatchField().equals(EthSrc.class)){
540 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
541 if(macAddressMatchEntry != null){
542 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
543 ethSourceBuilder.setAddress(macAddressMatchEntry.getMacAddress());
544 ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
545 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
547 }else if(ofMatch.getOxmMatchField().equals(EthDst.class)){
548 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
549 if(macAddressMatchEntry != null){
550 EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
551 ethDestinationBuilder.setAddress(macAddressMatchEntry.getMacAddress());
552 ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
553 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
555 }else if(ofMatch.getOxmMatchField().equals(EthType.class)){
556 EthTypeMatchEntry ethTypeMatchEntry = ofMatch.getAugmentation(EthTypeMatchEntry.class);
557 if(ethTypeMatchEntry != null){
558 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
559 ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType((long)ethTypeMatchEntry.getEthType().getValue()));
560 ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
561 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
563 }else if(ofMatch.getOxmMatchField().equals(VlanVid.class)){
564 VlanVidMatchEntry vlanVidMatchEntry = ofMatch.getAugmentation(VlanVidMatchEntry.class);
565 if(vlanVidMatchEntry != null){
566 VlanIdBuilder vlanBuilder = new VlanIdBuilder();
567 vlanBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanVidMatchEntry.getVlanVid()));
568 vlanMatchBuilder.setVlanId(vlanBuilder.build());
569 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
571 }else if(ofMatch.getOxmMatchField().equals(VlanPcp.class)){
572 VlanPcpMatchEntry vlanPcpMatchEntry = ofMatch.getAugmentation(VlanPcpMatchEntry.class);
573 if(vlanPcpMatchEntry != null){
574 vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(vlanPcpMatchEntry.getVlanPcp()));
575 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
577 }else if(ofMatch.getOxmMatchField().equals(IpDscp.class)){
578 DscpMatchEntry dscpMatchEntry = ofMatch.getAugmentation(DscpMatchEntry.class);
579 if(dscpMatchEntry != null){
580 ipMatchBuilder.setIpDscp(new Dscp(dscpMatchEntry.getDscp().getValue()));
581 matchBuilder.setIpMatch(ipMatchBuilder.build());
583 }else if(ofMatch.getOxmMatchField().equals(IpEcn.class)){
584 EcnMatchEntry ecnMatchEntry = ofMatch.getAugmentation(EcnMatchEntry.class);
585 if(ecnMatchEntry != null){
586 ipMatchBuilder.setIpEcn(ecnMatchEntry.getEcn());
587 matchBuilder.setIpMatch(ipMatchBuilder.build());
589 }else if(ofMatch.getOxmMatchField().equals(IpProto.class)){
590 ProtocolNumberMatchEntry protocolNumberMatchEntry = ofMatch.getAugmentation(ProtocolNumberMatchEntry.class);
591 if(protocolNumberMatchEntry != null){
592 ipMatchBuilder.setIpProtocol(protocolNumberMatchEntry.getProtocolNumber());
593 matchBuilder.setIpMatch(ipMatchBuilder.build());
595 }else if(ofMatch.getOxmMatchField().equals(TcpSrc.class)){
596 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
597 if(portMatchEntry != null){
598 tcpMatchBuilder.setTcpSourcePort(portMatchEntry.getPort());
599 matchBuilder.setLayer4Match(tcpMatchBuilder.build());
601 }else if(ofMatch.getOxmMatchField().equals(TcpDst.class)){
602 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
603 if(portMatchEntry != null){
604 tcpMatchBuilder.setTcpDestinationPort(portMatchEntry.getPort());
605 matchBuilder.setLayer4Match(tcpMatchBuilder.build());
607 }else if(ofMatch.getOxmMatchField().equals(UdpSrc.class)){
608 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
609 if(portMatchEntry != null){
610 udpMatchBuilder.setUdpSourcePort(portMatchEntry.getPort());
611 matchBuilder.setLayer4Match(udpMatchBuilder.build());
613 }else if(ofMatch.getOxmMatchField().equals(UdpDst.class)){
614 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
615 if(portMatchEntry != null){
616 udpMatchBuilder.setUdpDestinationPort(portMatchEntry.getPort());
617 matchBuilder.setLayer4Match(udpMatchBuilder.build());
619 }else if(ofMatch.getOxmMatchField().equals(SctpSrc.class)){
620 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
621 if(portMatchEntry != null){
622 sctpMatchBuilder.setSctpSourcePort(portMatchEntry.getPort());
623 matchBuilder.setLayer4Match(sctpMatchBuilder.build());
625 }else if(ofMatch.getOxmMatchField().equals(SctpDst.class)){
626 PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
627 if(portMatchEntry != null){
628 sctpMatchBuilder.setSctpDestinationPort(portMatchEntry.getPort());
629 matchBuilder.setLayer4Match(sctpMatchBuilder.build());
631 }else if(ofMatch.getOxmMatchField().equals(Icmpv4Type.class)){
632 Icmpv4TypeMatchEntry icmpv4TypeMatchEntry = ofMatch.getAugmentation(Icmpv4TypeMatchEntry.class);
633 if(icmpv4TypeMatchEntry != null){
634 icmpv4MatchBuilder.setIcmpv4Type(icmpv4TypeMatchEntry.getIcmpv4Type());
635 matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
637 }else if(ofMatch.getOxmMatchField().equals(Icmpv4Code.class)){
638 Icmpv4CodeMatchEntry icmpv4CodeMatchEntry = ofMatch.getAugmentation(Icmpv4CodeMatchEntry.class);
639 if(icmpv4CodeMatchEntry != null){
640 icmpv4MatchBuilder.setIcmpv4Code(icmpv4CodeMatchEntry.getIcmpv4Code());
641 matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
643 }else if(ofMatch.getOxmMatchField().equals(Icmpv6Type.class)){
644 Icmpv6TypeMatchEntry icmpv6TypeMatchEntry = ofMatch.getAugmentation(Icmpv6TypeMatchEntry.class);
645 if(icmpv6TypeMatchEntry != null){
646 icmpv6MatchBuilder.setIcmpv6Type(icmpv6TypeMatchEntry.getIcmpv6Type());
647 matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
649 }else if(ofMatch.getOxmMatchField().equals(Icmpv6Code.class)){
650 Icmpv6CodeMatchEntry icmpv6CodeMatchEntry = ofMatch.getAugmentation(Icmpv6CodeMatchEntry.class);
651 if(icmpv6CodeMatchEntry != null){
652 icmpv6MatchBuilder.setIcmpv6Code(icmpv6CodeMatchEntry.getIcmpv6Code());
653 matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
655 }else if(ofMatch.getOxmMatchField().equals(Ipv4Src.class) ||
656 ofMatch.getOxmMatchField().equals(Ipv4Dst.class)){
657 Ipv4AddressMatchEntry ipv4AddressMatchEntry = ofMatch.getAugmentation(Ipv4AddressMatchEntry.class);
658 if(ipv4AddressMatchEntry != null){
659 String ipv4PrefixStr = ipv4AddressMatchEntry.getIpv4Address().getValue();
660 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
661 if(maskMatchEntry != null){
662 ipv4PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
664 if(ofMatch.getOxmMatchField().equals(Ipv4Src.class)){
665 ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
667 if(ofMatch.getOxmMatchField().equals(Ipv4Dst.class)){
668 ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
670 matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
672 }else if(ofMatch.getOxmMatchField().equals(ArpOp.class)){
673 OpCodeMatchEntry opCodeMatchEntry = ofMatch.getAugmentation(OpCodeMatchEntry.class);
674 if(opCodeMatchEntry != null){
675 arpMatchBuilder.setArpOp(opCodeMatchEntry.getOpCode());
676 matchBuilder.setLayer3Match(arpMatchBuilder.build());
678 }else if(ofMatch.getOxmMatchField().equals(ArpSpa.class) ||
679 ofMatch.getOxmMatchField().equals(ArpTpa.class)){
680 Ipv4AddressMatchEntry ipv4AddressMatchEntry = ofMatch.getAugmentation(Ipv4AddressMatchEntry.class);
681 if(ipv4AddressMatchEntry != null){
682 String ipv4PrefixStr = ipv4AddressMatchEntry.getIpv4Address().getValue();
683 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
684 if(maskMatchEntry != null){
685 ipv4PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
687 if(ofMatch.getOxmMatchField().equals(ArpSpa.class)){
688 arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix(ipv4PrefixStr));
690 if(ofMatch.getOxmMatchField().equals(ArpTpa.class)){
691 arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix(ipv4PrefixStr));
693 matchBuilder.setLayer3Match(arpMatchBuilder.build());
695 }else if(ofMatch.getOxmMatchField().equals(ArpSha.class) ||
696 ofMatch.getOxmMatchField().equals(ArpTha.class)){
697 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
698 if(macAddressMatchEntry !=null){
699 if(ofMatch.getOxmMatchField().equals(ArpSha.class)){
700 ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
701 arpSourceHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
702 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
703 if(maskMatchEntry != null){
704 arpSourceHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
706 arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
707 matchBuilder.setLayer3Match(arpMatchBuilder.build());
709 if(ofMatch.getOxmMatchField().equals(ArpTha.class)){
710 ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
711 arpTargetHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
712 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
713 if(maskMatchEntry != null){
714 arpTargetHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
716 arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
717 matchBuilder.setLayer3Match(arpMatchBuilder.build());
720 }else if(ofMatch.getOxmMatchField().equals(Ipv6Src.class) ||
721 ofMatch.getOxmMatchField().equals(Ipv6Dst.class)){
722 Ipv6AddressMatchEntry ipv6AddressMatchEntry = ofMatch.getAugmentation(Ipv6AddressMatchEntry.class);
723 if(ipv6AddressMatchEntry != null){
724 String ipv6PrefixStr = ipv6AddressMatchEntry.getIpv6Address().getValue();
725 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
726 if(maskMatchEntry != null){
727 ipv6PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
729 if(ofMatch.getOxmMatchField().equals(Ipv6Src.class)){
730 ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix(ipv6PrefixStr));
732 if(ofMatch.getOxmMatchField().equals(Ipv6Dst.class)){
733 ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix(ipv6PrefixStr));
735 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
737 }else if(ofMatch.getOxmMatchField().equals(Ipv6Flabel.class)){
738 Ipv6FlabelMatchEntry ipv6FlabelMatchEntry = ofMatch.getAugmentation(Ipv6FlabelMatchEntry.class);
739 if(ipv6FlabelMatchEntry != null){
740 Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
741 ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(ipv6FlabelMatchEntry.getIpv6Flabel()));
742 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
743 if(maskMatchEntry != null){
744 ipv6LabelBuilder.setFlabelMask(maskMatchEntry.getMask());
746 ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
747 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
749 }else if(ofMatch.getOxmMatchField().equals(Ipv6NdTarget.class)){
750 Ipv6AddressMatchEntry ipv6AddressMatchEntry = ofMatch.getAugmentation(Ipv6AddressMatchEntry.class);
751 if(ipv6AddressMatchEntry != null){
752 ipv6MatchBuilder.setIpv6NdTarget(ipv6AddressMatchEntry.getIpv6Address());
753 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
755 }else if(ofMatch.getOxmMatchField().equals(Ipv6NdSll.class)){
756 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
757 if(macAddressMatchEntry != null){
758 ipv6MatchBuilder.setIpv6NdSll(macAddressMatchEntry.getMacAddress());
759 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
761 }else if(ofMatch.getOxmMatchField().equals(Ipv6NdTll.class)){
762 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
763 if(macAddressMatchEntry != null){
764 ipv6MatchBuilder.setIpv6NdTll(macAddressMatchEntry.getMacAddress());
765 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
767 }else if(ofMatch.getOxmMatchField().equals(Ipv6Exthdr.class)){
768 PseudoFieldMatchEntry pseudoFieldMatchEntry = ofMatch.getAugmentation(PseudoFieldMatchEntry.class);
769 if(pseudoFieldMatchEntry != null){
770 Ipv6ExtHeaderBuilder ipv6ExtHeaderBuilder = new Ipv6ExtHeaderBuilder();
772 Ipv6ExthdrFlags pField = pseudoFieldMatchEntry.getPseudoField();
774 bitmap |= pField.isNonext()?(1 << 0): ~(1 << 0);
775 bitmap |= pField.isEsp()?(1 << 1): ~(1 << 1);
776 bitmap |= pField.isAuth()?(1 << 2): ~(1 << 2);
777 bitmap |= pField.isDest()?(1 << 3): ~(1 << 3);
778 bitmap |= pField.isFrag()?(1 << 4): ~(1 << 4);
779 bitmap |= pField.isRouter()?(1 << 5): ~(1 << 5);
780 bitmap |= pField.isHop()?(1 << 6): ~(1 << 6);
781 bitmap |= pField.isUnrep()?(1 << 7): ~(1 << 7);
782 bitmap |= pField.isUnseq()?(1 << 8): ~(1 << 8);
784 ipv6ExtHeaderBuilder.setIpv6Exthdr(bitmap);
785 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
786 if(maskMatchEntry != null){
787 ipv6ExtHeaderBuilder.setIpv6ExthdrMask(maskMatchEntry.getMask());
789 ipv6MatchBuilder.setIpv6ExtHeader(ipv6ExtHeaderBuilder.build());
790 matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
792 }else if(ofMatch.getOxmMatchField().equals(MplsLabel.class)){
793 MplsLabelMatchEntry mplsLabelMatchEntry = ofMatch.getAugmentation(MplsLabelMatchEntry.class);
794 if(mplsLabelMatchEntry != null){
795 protocolMatchFieldsBuilder.setMplsLabel(mplsLabelMatchEntry.getMplsLabel());
796 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
798 }else if(ofMatch.getOxmMatchField().equals(MplsBos.class)){
799 BosMatchEntry bosMatchEntry = ofMatch.getAugmentation(BosMatchEntry.class);
800 if(bosMatchEntry != null){
801 protocolMatchFieldsBuilder.setMplsBos(bosMatchEntry.isBos()?(short)1:(short)0);
802 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
804 }else if(ofMatch.getOxmMatchField().equals(MplsTc.class)){
805 TcMatchEntry tcMatchEntry = ofMatch.getAugmentation(TcMatchEntry.class);
806 if(tcMatchEntry != null){
807 protocolMatchFieldsBuilder.setMplsTc(tcMatchEntry.getTc());
808 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
810 }else if(ofMatch.getOxmMatchField().equals(PbbIsid.class)){
811 IsidMatchEntry isidMatchEntry = ofMatch.getAugmentation(IsidMatchEntry.class);
812 if(isidMatchEntry != null){
813 PbbBuilder pbbBuilder = new PbbBuilder();
814 pbbBuilder.setPbbIsid(isidMatchEntry.getIsid());
815 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
816 if(maskMatchEntry != null){
817 pbbBuilder.setPbbMask(maskMatchEntry.getMask());
819 protocolMatchFieldsBuilder.setPbb(pbbBuilder.build());
820 matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
822 }else if(ofMatch.getOxmMatchField().equals(TunnelId.class)){
823 TunnelBuilder tunnelBuilder = new TunnelBuilder();
824 MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
825 if(metadataMatchEntry != null){
826 tunnelBuilder.setTunnelId(new BigInteger(metadataMatchEntry.getMetadata()));
827 MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
828 if(maskMatchEntry != null){
829 tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
831 matchBuilder.setTunnel(tunnelBuilder.build());
835 return matchBuilder.build();
839 private static MatchEntries toOfMplsPbb(Pbb pbb) {
840 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
841 boolean hasmask = false;
842 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
843 matchEntriesBuilder.setOxmMatchField(PbbIsid.class);
844 IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();
845 isidBuilder.setIsid(pbb.getPbbIsid());
846 matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
847 if (pbb.getPbbMask() != null) {
849 addMaskAugmentation(matchEntriesBuilder, pbb.getPbbMask());
851 matchEntriesBuilder.setHasMask(hasmask);
852 return matchEntriesBuilder.build();
855 private static MatchEntries toOfMplsTc(Short mplsTc) {
856 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
857 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
858 matchEntriesBuilder.setHasMask(false);
859 matchEntriesBuilder.setOxmMatchField(MplsTc.class);
860 TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();
861 tcBuilder.setTc(mplsTc);
862 matchEntriesBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build());
863 return matchEntriesBuilder.build();
866 private static MatchEntries toOfMplsBos(Short mplsBos) {
867 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
868 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
869 matchEntriesBuilder.setHasMask(false);
870 matchEntriesBuilder.setOxmMatchField(MplsBos.class);
871 BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();
873 bosBuilder.setBos(true);
875 bosBuilder.setBos(false);
877 matchEntriesBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build());
878 return matchEntriesBuilder.build();
881 private static MatchEntries toOfMplsLabel(Long mplsLabel) {
882 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
883 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
884 matchEntriesBuilder.setHasMask(false);
885 matchEntriesBuilder.setOxmMatchField(MplsLabel.class);
886 MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();
887 mplsLabelBuilder.setMplsLabel(mplsLabel);
888 matchEntriesBuilder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());
889 return matchEntriesBuilder.build();
892 private static MatchEntries toOfIpv6ExtHeader(Ipv6ExtHeader ipv6ExtHeader) {
893 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
894 boolean hasmask = false;
895 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
896 matchEntriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
897 PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();
898 Integer bitmap = ipv6ExtHeader.getIpv6Exthdr();
899 final Boolean NONEXT = ((bitmap) & (1 << 0)) != 0;
900 final Boolean ESP = ((bitmap) & (1 << 1)) != 0;
901 final Boolean AUTH = ((bitmap) & (1 << 2)) != 0;
902 final Boolean DEST = ((bitmap) & (1 << 3)) != 0;
903 final Boolean FRAG = ((bitmap) & (1 << 4)) != 0;
904 final Boolean ROUTER = ((bitmap) & (1 << 5)) != 0;
905 final Boolean HOP = ((bitmap) & (1 << 6)) != 0;
906 final Boolean UNREP = ((bitmap) & (1 << 7)) != 0;
907 final Boolean UNSEQ = ((bitmap) & (1 << 8)) != 0;
908 pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));
909 matchEntriesBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());
910 if (ipv6ExtHeader.getIpv6ExthdrMask() != null) {
912 addMaskAugmentation(matchEntriesBuilder, ipv6ExtHeader.getIpv6ExthdrMask());
914 matchEntriesBuilder.setHasMask(hasmask);
915 return matchEntriesBuilder.build();
918 private static MatchEntries toOfIpv6FlowLabel(Ipv6Label ipv6Label) {
919 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
920 boolean hasmask = false;
921 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
922 matchEntriesBuilder.setOxmMatchField(Ipv6Flabel.class);
923 Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();
924 ipv6FlabelBuilder.setIpv6Flabel(ipv6Label.getIpv6Flabel());
925 matchEntriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());
926 if (ipv6Label.getFlabelMask() != null) {
928 addMaskAugmentation(matchEntriesBuilder, ipv6Label.getFlabelMask());
930 matchEntriesBuilder.setHasMask(hasmask);
931 return matchEntriesBuilder.build();
934 private static MatchEntries toOfPort(Class<? extends MatchField> field, Long portNumber) {
935 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
936 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
937 matchEntriesBuilder.setHasMask(false);
938 matchEntriesBuilder.setOxmMatchField(field);
939 PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
940 port.setPortNumber(new PortNumber(portNumber));
941 matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
942 return matchEntriesBuilder.build();
945 private static MatchEntries toOfMetadata(Class<? extends MatchField> field, BigInteger metadata, byte[] metadataMask) {
946 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
947 boolean hasmask = false;
948 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
949 matchEntriesBuilder.setOxmMatchField(field);
950 addMetadataAugmentation(matchEntriesBuilder, metadata);
951 if (metadataMask != null) {
953 addMaskAugmentation(matchEntriesBuilder, metadataMask);
955 matchEntriesBuilder.setHasMask(hasmask);
956 return matchEntriesBuilder.build();
959 private static MatchEntries toOfMacAddress(Class<? extends MatchField> field,
960 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress macAddress,
962 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
963 boolean hasmask = false;
964 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
965 matchEntriesBuilder.setOxmMatchField(field);
966 addMacAddressAugmentation(matchEntriesBuilder, macAddress);
969 addMaskAugmentation(matchEntriesBuilder, mask);
971 matchEntriesBuilder.setHasMask(hasmask);
972 return matchEntriesBuilder.build();
975 private static MatchEntries toOfEthernetType(EthernetType ethernetType) {
976 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
977 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
978 matchEntriesBuilder.setHasMask(false);
979 matchEntriesBuilder.setOxmMatchField(EthType.class);
980 EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();
981 ethertypeBuilder.setEthType(new EtherType(ethernetType.getType().getValue().intValue()));
982 matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());
983 return matchEntriesBuilder.build();
986 private static MatchEntries toOfLayer3Port(Class<? extends MatchField> field,
987 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber portNumber) {
988 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
989 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
990 matchEntriesBuilder.setHasMask(false);
991 matchEntriesBuilder.setOxmMatchField(field);
992 PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();
993 portBuilder.setPort(portNumber);
994 matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build());
995 return matchEntriesBuilder.build();
998 private static MatchEntries toOfIcmpv4Type(Short icmpv4Type) {
999 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1000 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1001 matchEntriesBuilder.setHasMask(false);
1002 matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
1003 Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();
1004 icmpv4TypeBuilder.setIcmpv4Type(icmpv4Type);
1005 matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());
1006 return matchEntriesBuilder.build();
1009 private static MatchEntries toOfIcmpv4Code(Short icmpv4Code) {
1010 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1011 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1012 matchEntriesBuilder.setHasMask(false);
1013 matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);
1014 Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();
1015 icmpv4CodeBuilder.setIcmpv4Code(icmpv4Code);
1016 matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());
1017 return matchEntriesBuilder.build();
1020 private static MatchEntries toOfIcmpv6Type(Short icmpv6Type) {
1021 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1022 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1023 matchEntriesBuilder.setHasMask(false);
1024 matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
1025 Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();
1026 icmpv6TypeBuilder.setIcmpv6Type(icmpv6Type);
1027 matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());
1028 return matchEntriesBuilder.build();
1031 private static MatchEntries toOfIcmpv6Code(Short icmpv6Code) {
1032 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1033 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1034 matchEntriesBuilder.setHasMask(false);
1035 matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
1036 Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();
1037 icmpv6CodeBuilder.setIcmpv6Code(icmpv6Code);
1038 matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());
1039 return matchEntriesBuilder.build();
1042 private static MatchEntries toOfIpv4Prefix(Class<? extends MatchField> field, Ipv4Prefix ipv4Prefix) {
1043 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1044 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1045 matchEntriesBuilder.setOxmMatchField(field);
1046 boolean hasMask = addIpv4PrefixAugmentation(matchEntriesBuilder, ipv4Prefix);
1047 matchEntriesBuilder.setHasMask(hasMask);
1048 return matchEntriesBuilder.build();
1051 private static MatchEntries toOfIpv6Prefix(Class<? extends MatchField> field, Ipv6Prefix ipv6Prefix) {
1052 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1053 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1054 matchEntriesBuilder.setOxmMatchField(field);
1055 boolean hasmask = addIpv6PrefixAugmentation(matchEntriesBuilder, ipv6Prefix);
1056 matchEntriesBuilder.setHasMask(hasmask);
1057 return matchEntriesBuilder.build();
1060 private static MatchEntries toOfIpDscp(Dscp ipDscp) {
1061 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1062 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1063 matchEntriesBuilder.setHasMask(false);
1064 matchEntriesBuilder.setOxmMatchField(IpDscp.class);
1065 DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();
1066 dscpBuilder.setDscp(ipDscp);
1067 matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());
1068 return matchEntriesBuilder.build();
1071 private static MatchEntries toOfVlanPcp(
1072 org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp vlanPcp) {
1073 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1074 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1075 matchEntriesBuilder.setHasMask(false);
1076 matchEntriesBuilder.setOxmMatchField(VlanPcp.class);
1077 VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();
1078 vlanPcpBuilder.setVlanPcp(vlanPcp.getValue());
1079 matchEntriesBuilder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());
1080 return matchEntriesBuilder.build();
1083 private static MatchEntries toOfVlanVid(VlanId vlanId) {
1085 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1086 boolean hasmask = false;
1087 boolean setCfiBit = false;
1088 Integer vidEntryValue = 0;
1089 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1090 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
1091 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
1092 if (vlanId.isVlanIdPresent() == true) {
1094 if (vlanId.getVlanId() != null) {
1095 vidEntryValue = vlanId.getVlanId().getValue();
1097 hasmask = (vidEntryValue == 0);
1099 vlanVidBuilder.setCfiBit(setCfiBit);
1100 vlanVidBuilder.setVlanVid(vidEntryValue);
1101 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
1103 addMaskAugmentation(matchEntriesBuilder, VLAN_VID_MASK);
1105 matchEntriesBuilder.setHasMask(hasmask);
1106 return matchEntriesBuilder.build();
1109 private static MatchEntries toOfIpProto(Short ipProtocol) {
1110 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1111 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1112 matchEntriesBuilder.setHasMask(false);
1113 matchEntriesBuilder.setOxmMatchField(IpProto.class);
1114 ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();
1115 protoNumberBuilder.setProtocolNumber(ipProtocol);
1116 matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());
1117 return matchEntriesBuilder.build();
1120 private static MatchEntries toOfIpEcn(Short ipEcn) {
1121 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1122 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1123 matchEntriesBuilder.setHasMask(false);
1124 matchEntriesBuilder.setOxmMatchField(IpEcn.class);
1125 EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();
1126 ecnBuilder.setEcn(ipEcn);
1127 matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());
1128 return matchEntriesBuilder.build();
1131 private static MatchEntries toOfArpOpCode(Integer arpOp) {
1132 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1133 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1134 matchEntriesBuilder.setHasMask(false);
1135 matchEntriesBuilder.setOxmMatchField(ArpOp.class);
1136 OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();
1137 opcodeBuilder.setOpCode(arpOp);
1138 matchEntriesBuilder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());
1139 return matchEntriesBuilder.build();
1142 private static MatchEntries toOfIpv6Address(Ipv6Address address) {
1143 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
1144 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
1145 matchEntriesBuilder.setHasMask(false);
1146 matchEntriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
1147 Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
1148 ipv6AddressBuilder.setIpv6Address(address);
1149 matchEntriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
1150 return matchEntriesBuilder.build();
1153 private static void addMaskAugmentation(MatchEntriesBuilder builder, byte[] mask) {
1154 MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();
1155 maskBuilder.setMask(mask);
1156 builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
1159 private static boolean addIpv6PrefixAugmentation(MatchEntriesBuilder builder, Ipv6Prefix address) {
1160 boolean hasMask = false;
1161 String[] addressParts = address.getValue().split(PREFIX_SEPARATOR);
1162 Integer prefix = null;
1163 if (addressParts.length == 2) {
1164 prefix = Integer.parseInt(addressParts[1]);
1167 Ipv6Address ipv6Address = new Ipv6Address(addressParts[0]);
1168 Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
1169 ipv6AddressBuilder.setIpv6Address(ipv6Address);
1170 builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
1171 if (prefix != null) {
1173 addMaskAugmentation(builder, convertIpv6PrefixToByteArray(prefix));
1178 private static byte[] convertIpv6PrefixToByteArray(int prefix) {
1179 // TODO: Temporary fix. Has performance impacts.
1180 byte[] mask = new byte[16];
1181 int oneCount = prefix;
1182 for (int count = 0; count < 16; count++) {
1184 if (oneCount >= 8) {
1186 oneCount = oneCount - 8;
1188 byteBits = oneCount;
1192 mask[count] = (byte) (256 - Math.pow(2, 8 - byteBits));
1197 private static void addMetadataAugmentation(MatchEntriesBuilder builder, BigInteger metadata) {
1198 MetadataMatchEntryBuilder metadataMatchEntry = new MetadataMatchEntryBuilder();
1199 metadataMatchEntry.setMetadata(ByteUtil.convertBigIntegerTo64Bit(metadata));
1200 builder.addAugmentation(MetadataMatchEntry.class, metadataMatchEntry.build());
1204 * @return true if Ipv4Prefix contains prefix (and it is used in mask),
1207 private static boolean addIpv4PrefixAugmentation(MatchEntriesBuilder builder, Ipv4Prefix address) {
1208 boolean hasMask = false;
1209 String[] addressParts = address.getValue().split(PREFIX_SEPARATOR);
1210 Integer prefix = null;
1211 if (addressParts.length < 2) {
1214 prefix = Integer.parseInt(addressParts[1]);
1217 Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
1218 Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
1219 ipv4AddressBuilder.setIpv4Address(ipv4Address);
1220 builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
1222 int mask = 0xffffffff << (32 - prefix);
1223 byte[] maskBytes = new byte[] { (byte) (mask >>> 24), (byte) (mask >>> 16), (byte) (mask >>> 8),
1225 addMaskAugmentation(builder, maskBytes);
1231 private static void addMacAddressAugmentation(MatchEntriesBuilder builder, MacAddress address) {
1232 MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();
1233 macAddress.setMacAddress(address);
1234 builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
1238 * Method converts OF SetField Match to SAL SetFiled matches
1239 * TODO: enable or delete
1243 public static SetField ofToSALSetField(
1244 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action action) {
1245 logger.info("OF SetField match to SAL SetField match converstion begins");
1246 SetFieldBuilder setField = new SetFieldBuilder();
1248 * OxmFieldsAction oxmFields =
1249 * action.getAugmentation(OxmFieldsAction.class);
1251 * List<MatchEntries> matchEntries = oxmFields.getMatchEntries();
1253 * .yang.gen.v1.urn.opendaylight.action.types.rev131112.action
1254 * .action.set.field.MatchBuilder match =new
1255 * org.opendaylight.yang.gen.v1
1256 * .urn.opendaylight.action.types.rev131112.action
1257 * .action.set.field.MatchBuilder();
1259 * EthernetMatchBuilder ethernetMatchBuilder = null; VlanMatchBuilder
1260 * vlanMatchBuilder = null; IpMatchBuilder ipMatchBuilder = null;
1261 * TcpMatchBuilder tcpMatchBuilder = null; UdpMatchBuilder
1262 * udpMatchBuilder = null; SctpMatchBuilder sctpMatchBuilder = null;
1263 * Icmpv4MatchBuilder icmpv4MatchBuilder = null; Icmpv6MatchBuilder
1264 * icmpv6MatchBuilder = null; Ipv4MatchBuilder ipv4MatchBuilder = null;
1265 * ArpMatchBuilder arpMatchBuilder = null; Ipv6MatchBuilder
1266 * ipv6MatchBuilder = null; ProtocolMatchFieldsBuilder
1267 * protocolMatchFieldsBuilder = null;
1269 * for(MatchEntries matchEntry : matchEntries){ if(matchEntry instanceof
1270 * InPort){ PortNumberMatchEntry inPort =
1271 * matchEntry.getAugmentation(PortNumberMatchEntry.class);
1272 * match.setInPort(inPort.getPortNumber().getValue()); }else if
1273 * (matchEntry instanceof InPhyPort){ PortNumberMatchEntry phyPort =
1274 * matchEntry.getAugmentation(PortNumberMatchEntry.class);
1275 * match.setInPhyPort(phyPort.getPortNumber().getValue()); }else if
1276 * (matchEntry instanceof Metadata){ MetadataMatchEntry metadataMatch =
1277 * matchEntry.getAugmentation(MetadataMatchEntry.class); MetadataBuilder
1278 * metadataBuilder = new MetadataBuilder();
1279 * metadataBuilder.setMetadata(new
1280 * BigInteger(metadataMatch.getMetadata())); MaskMatchEntry maskMatch =
1281 * matchEntry.getAugmentation(MaskMatchEntry.class); if (maskMatch !=
1282 * null){ metadataBuilder.setMetadataMask(maskMatch.getMask()); }
1283 * match.setMetadata(metadataBuilder.build()); }else if (matchEntry
1284 * instanceof EthDst){
1286 * if(ethernetMatchBuilder == null) ethernetMatchBuilder = new
1287 * EthernetMatchBuilder();
1289 * MacAddressMatchEntry macAddressMatch =
1290 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1291 * MaskMatchEntry maskMatch =
1292 * matchEntry.getAugmentation(MaskMatchEntry.class);
1293 * EthernetDestinationBuilder ethernetDestination = new
1294 * EthernetDestinationBuilder();
1295 * ethernetDestination.setAddress(macAddressMatch.getMacAddress());
1296 * if(maskMatch != null){
1297 * ethernetDestination.setMask(maskMatch.getMask()); }
1298 * ethernetMatchBuilder
1299 * .setEthernetDestination(ethernetDestination.build()); }else if
1300 * (matchEntry instanceof EthSrc){ if(ethernetMatchBuilder == null)
1301 * ethernetMatchBuilder = new EthernetMatchBuilder();
1303 * MacAddressMatchEntry macAddressMatch =
1304 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1305 * MaskMatchEntry maskMatch =
1306 * matchEntry.getAugmentation(MaskMatchEntry.class);
1307 * EthernetSourceBuilder ethernetSource = new EthernetSourceBuilder();
1308 * ethernetSource.setAddress(macAddressMatch.getMacAddress());
1309 * if(maskMatch != null){ ethernetSource.setMask(maskMatch.getMask()); }
1310 * ethernetMatchBuilder.setEthernetSource(ethernetSource.build()); }else
1311 * if (matchEntry instanceof EthType){ if(ethernetMatchBuilder == null)
1312 * ethernetMatchBuilder = new EthernetMatchBuilder();
1314 * EthTypeMatchEntry etherTypeMatch =
1315 * matchEntry.getAugmentation(EthTypeMatchEntry.class);
1316 * EthernetTypeBuilder ethernetType= new EthernetTypeBuilder();
1318 * .yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType etherType
1320 * org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827
1321 * .EtherType((long)etherTypeMatch.getEthType().getValue());
1322 * ethernetType.setType(etherType);
1323 * ethernetMatchBuilder.setEthernetType(ethernetType.build()); }else if
1324 * (matchEntry instanceof VlanVid){ if(vlanMatchBuilder == null)
1325 * vlanMatchBuilder = new VlanMatchBuilder();
1327 * VlanVidMatchEntry vlanVidMatch =
1328 * matchEntry.getAugmentation(VlanVidMatchEntry.class); MaskMatchEntry
1329 * maskMatch = matchEntry.getAugmentation(MaskMatchEntry.class);
1331 * VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
1332 * vlanIdBuilder.setVlanId( new
1333 * org.opendaylight.yang.gen.v1.urn.opendaylight
1334 * .l2.types.rev130827.VlanId(vlanVidMatch.getVlanVid())); if(maskMatch
1335 * != null){ vlanIdBuilder.setMask(maskMatch.getMask()); }
1336 * vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
1338 * }else if (matchEntry instanceof VlanPcp){ if(vlanMatchBuilder ==
1339 * null) vlanMatchBuilder = new VlanMatchBuilder();
1341 * VlanPcpMatchEntry vlanPcpMatch =
1342 * matchEntry.getAugmentation(VlanPcpMatchEntry.class);
1343 * vlanMatchBuilder.setVlanPcp( new
1344 * org.opendaylight.yang.gen.v1.urn.opendaylight
1345 * .l2.types.rev130827.VlanPcp(vlanPcpMatch.getVlanPcp())); }else if
1346 * (matchEntry instanceof IpDscp){ if(ipMatchBuilder == null)
1347 * ipMatchBuilder = new IpMatchBuilder();
1349 * DscpMatchEntry dscpMatchEntry =
1350 * matchEntry.getAugmentation(DscpMatchEntry.class);
1351 * ipMatchBuilder.setIpDscp(dscpMatchEntry.getDscp());
1353 * }else if (matchEntry instanceof IpEcn){ if(ipMatchBuilder == null)
1354 * ipMatchBuilder = new IpMatchBuilder();
1356 * EcnMatchEntry ecnMatchEntry =
1357 * matchEntry.getAugmentation(EcnMatchEntry.class);
1358 * ipMatchBuilder.setIpEcn(ecnMatchEntry.getEcn());
1360 * }else if (matchEntry instanceof IpProto){ if(ipMatchBuilder == null)
1361 * ipMatchBuilder = new IpMatchBuilder();
1363 * ProtocolNumberMatchEntry protocolNumberMatch =
1364 * matchEntry.getAugmentation(ProtocolNumberMatchEntry.class);
1366 * .setIpProtocol(protocolNumberMatch.getProtocolNumber()); }else if
1367 * (matchEntry instanceof TcpSrc){ if(tcpMatchBuilder == null)
1368 * tcpMatchBuilder = new TcpMatchBuilder();
1370 * PortMatchEntry portMatchEntry =
1371 * matchEntry.getAugmentation(PortMatchEntry.class);
1372 * tcpMatchBuilder.setTcpSourcePort(portMatchEntry.getPort());
1374 * }else if (matchEntry instanceof TcpDst){ if(tcpMatchBuilder == null)
1375 * tcpMatchBuilder = new TcpMatchBuilder();
1377 * PortMatchEntry portMatchEntry =
1378 * matchEntry.getAugmentation(PortMatchEntry.class);
1379 * tcpMatchBuilder.setTcpDestinationPort(portMatchEntry.getPort());
1381 * }else if (matchEntry instanceof UdpSrc){ if(udpMatchBuilder == null)
1382 * udpMatchBuilder = new UdpMatchBuilder();
1384 * PortMatchEntry portMatchEntry =
1385 * matchEntry.getAugmentation(PortMatchEntry.class);
1386 * udpMatchBuilder.setUdpSourcePort(portMatchEntry.getPort());
1389 * }else if (matchEntry instanceof UdpDst){ if(udpMatchBuilder == null)
1390 * udpMatchBuilder = new UdpMatchBuilder();
1392 * PortMatchEntry portMatchEntry =
1393 * matchEntry.getAugmentation(PortMatchEntry.class);
1394 * udpMatchBuilder.setUdpDestinationPort(portMatchEntry.getPort());
1395 * }else if (matchEntry instanceof SctpSrc){ if(sctpMatchBuilder ==
1396 * null) sctpMatchBuilder = new SctpMatchBuilder();
1398 * PortMatchEntry portMatchEntry =
1399 * matchEntry.getAugmentation(PortMatchEntry.class);
1400 * sctpMatchBuilder.setSctpSourcePort(portMatchEntry.getPort());
1402 * }else if (matchEntry instanceof SctpDst){ if(sctpMatchBuilder ==
1403 * null) sctpMatchBuilder = new SctpMatchBuilder();
1405 * PortMatchEntry portMatchEntry =
1406 * matchEntry.getAugmentation(PortMatchEntry.class);
1407 * sctpMatchBuilder.setSctpDestinationPort(portMatchEntry.getPort());
1408 * }else if (matchEntry instanceof Icmpv4Type){ if(icmpv4MatchBuilder ==
1409 * null) icmpv4MatchBuilder = new Icmpv4MatchBuilder();
1411 * Icmpv4TypeMatchEntry icmpv4TypeMatchEntry =
1412 * matchEntry.getAugmentation(Icmpv4TypeMatchEntry.class);
1413 * icmpv4MatchBuilder
1414 * .setIcmpv4Type(icmpv4TypeMatchEntry.getIcmpv4Type());
1416 * }else if (matchEntry instanceof Icmpv4Code){ if(icmpv4MatchBuilder ==
1417 * null) icmpv4MatchBuilder = new Icmpv4MatchBuilder();
1419 * Icmpv4CodeMatchEntry icmpv4CodeMatchEntry =
1420 * matchEntry.getAugmentation(Icmpv4CodeMatchEntry.class);
1421 * icmpv4MatchBuilder
1422 * .setIcmpv4Code(icmpv4CodeMatchEntry.getIcmpv4Code());
1424 * }else if (matchEntry instanceof Icmpv6Type){ if(icmpv6MatchBuilder ==
1425 * null) icmpv6MatchBuilder = new Icmpv6MatchBuilder();
1427 * Icmpv6TypeMatchEntry icmpv6TypeMatchEntry =
1428 * matchEntry.getAugmentation(Icmpv6TypeMatchEntry.class);
1429 * icmpv6MatchBuilder
1430 * .setIcmpv6Type(icmpv6TypeMatchEntry.getIcmpv6Type()); }else if
1431 * (matchEntry instanceof Icmpv6Code){ if(icmpv6MatchBuilder == null)
1432 * icmpv6MatchBuilder = new Icmpv6MatchBuilder();
1434 * Icmpv6CodeMatchEntry icmpv6CodeMatchEntry =
1435 * matchEntry.getAugmentation(Icmpv6CodeMatchEntry.class);
1436 * icmpv6MatchBuilder
1437 * .setIcmpv6Code(icmpv6CodeMatchEntry.getIcmpv6Code()); }else if
1438 * (matchEntry instanceof Ipv4Src){ if(ipv4MatchBuilder == null)
1439 * ipv4MatchBuilder = new Ipv4MatchBuilder();
1441 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1442 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1443 * MaskMatchEntry maskMatchEntry =
1444 * matchEntry.getAugmentation(MaskMatchEntry.class);
1445 * ipv4MatchBuilder.setIpv4Source( new
1446 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1447 * String(maskMatchEntry.getMask())));
1449 * }else if (matchEntry instanceof Ipv4Dst){ if(ipv4MatchBuilder ==
1450 * null) ipv4MatchBuilder = new Ipv4MatchBuilder();
1452 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1453 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1454 * MaskMatchEntry maskMatchEntry =
1455 * matchEntry.getAugmentation(MaskMatchEntry.class);
1456 * ipv4MatchBuilder.setIpv4Destination( new
1457 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1458 * String(maskMatchEntry.getMask()))); }else if (matchEntry instanceof
1459 * ArpOp){ if(arpMatchBuilder == null) arpMatchBuilder = new
1460 * ArpMatchBuilder();
1462 * OpCodeMatchEntry opCodeMatchEntry =
1463 * matchEntry.getAugmentation(OpCodeMatchEntry.class);
1464 * arpMatchBuilder.setArpOp(opCodeMatchEntry.getOpCode());
1466 * }else if (matchEntry instanceof ArpSpa){ if(arpMatchBuilder == null)
1467 * arpMatchBuilder = new ArpMatchBuilder();
1469 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1470 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1471 * MaskMatchEntry maskMatchEntry =
1472 * matchEntry.getAugmentation(MaskMatchEntry.class);
1473 * arpMatchBuilder.setArpSourceTransportAddress( new
1474 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1475 * String(maskMatchEntry.getMask())));
1477 * }else if (matchEntry instanceof ArpTpa){ if(arpMatchBuilder == null)
1478 * arpMatchBuilder = new ArpMatchBuilder();
1480 * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
1481 * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
1482 * MaskMatchEntry maskMatchEntry =
1483 * matchEntry.getAugmentation(MaskMatchEntry.class);
1484 * arpMatchBuilder.setArpTargetTransportAddress( new
1485 * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
1486 * String(maskMatchEntry.getMask())));
1488 * }else if (matchEntry instanceof ArpSha){ if(arpMatchBuilder == null)
1489 * arpMatchBuilder = new ArpMatchBuilder();
1491 * MacAddressMatchEntry macAddressMatchEntry =
1492 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1493 * MaskMatchEntry maskMatchEntry =
1494 * matchEntry.getAugmentation(MaskMatchEntry.class);
1495 * ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new
1496 * ArpSourceHardwareAddressBuilder();
1497 * arpSourceHardwareAddressBuilder.setAddress
1498 * (macAddressMatchEntry.getMacAddress());
1499 * arpSourceHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
1501 * .setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder
1504 * }else if (matchEntry instanceof ArpTha){ if(arpMatchBuilder == null)
1505 * arpMatchBuilder = new ArpMatchBuilder();
1507 * MacAddressMatchEntry macAddressMatchEntry =
1508 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1509 * MaskMatchEntry maskMatchEntry =
1510 * matchEntry.getAugmentation(MaskMatchEntry.class);
1511 * ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new
1512 * ArpTargetHardwareAddressBuilder();
1513 * arpTargetHardwareAddressBuilder.setAddress
1514 * (macAddressMatchEntry.getMacAddress());
1515 * arpTargetHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
1517 * .setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder
1518 * .build()); }else if (matchEntry instanceof Ipv6Src){
1519 * if(ipv6MatchBuilder == null) ipv6MatchBuilder = new
1520 * Ipv6MatchBuilder();
1522 * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
1523 * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
1524 * MaskMatchEntry maskMatchEntry =
1525 * matchEntry.getAugmentation(MaskMatchEntry.class);
1526 * ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix
1527 * (ipv6AddressMatchEntry.getIpv6Address().getValue()+ "/"+new
1528 * String(maskMatchEntry.getMask())));
1530 * }else if (matchEntry instanceof Ipv6Dst){ if(ipv6MatchBuilder ==
1531 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1533 * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
1534 * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
1535 * MaskMatchEntry maskMatchEntry =
1536 * matchEntry.getAugmentation(MaskMatchEntry.class);
1537 * ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix
1538 * (ipv6AddressMatchEntry.getIpv6Address().getValue()+ "/"+new
1539 * String(maskMatchEntry.getMask())));
1541 * }else if (matchEntry instanceof Ipv6Flabel){ if(ipv6MatchBuilder ==
1542 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1544 * Ipv6FlabelMatchEntry ipv6FlabelMatchEntry =
1545 * matchEntry.getAugmentation(Ipv6FlabelMatchEntry.class);
1546 * MaskMatchEntry maskMatchEntry =
1547 * matchEntry.getAugmentation(MaskMatchEntry.class); Ipv6LabelBuilder
1548 * ipv6LabelBuilder = new Ipv6LabelBuilder();
1549 * ipv6LabelBuilder.setIpv6Flabel(ipv6FlabelMatchEntry.getIpv6Flabel());
1550 * ipv6LabelBuilder.setFlabelMask(maskMatchEntry.getMask());
1551 * ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
1553 * }else if (matchEntry instanceof Ipv6NdTarget){ if(ipv6MatchBuilder ==
1554 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1555 * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
1556 * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
1558 * .setIpv6NdTarget(ipv6AddressMatchEntry.getIpv6Address());
1560 * }else if (matchEntry instanceof Ipv6NdSll){ if(ipv6MatchBuilder ==
1561 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1563 * MacAddressMatchEntry macAddressMatchEntry =
1564 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1565 * ipv6MatchBuilder.setIpv6NdSll(macAddressMatchEntry.getMacAddress());
1566 * }else if (matchEntry instanceof Ipv6NdTll){ if(ipv6MatchBuilder ==
1567 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1569 * MacAddressMatchEntry macAddressMatchEntry =
1570 * matchEntry.getAugmentation(MacAddressMatchEntry.class);
1571 * ipv6MatchBuilder.setIpv6NdTll(macAddressMatchEntry.getMacAddress());
1573 * }else if (matchEntry instanceof Ipv6Exthdr){ if(ipv6MatchBuilder ==
1574 * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
1576 * PseudoFieldMatchEntry pseudoFieldMatchEntry =
1577 * matchEntry.getAugmentation(PseudoFieldMatchEntry.class); PseudoField
1578 * pseudoField = pseudoFieldMatchEntry.getPseudoField(); int
1579 * pseudoFieldInt = 0; pseudoFieldInt |= pseudoField.isNonext()?(1 <<
1580 * 0):~(1 << 0); pseudoFieldInt |= pseudoField.isEsp()?(1 << 1):~(1 <<
1581 * 1); pseudoFieldInt |= pseudoField.isAuth()?(1 << 2):~(1 << 2);
1582 * pseudoFieldInt |= pseudoField.isDest()?(1 << 3):~(1 << 3);
1583 * pseudoFieldInt |= pseudoField.isFrag()?(1 << 4):~(1 << 4);
1584 * pseudoFieldInt |= pseudoField.isRouter()?(1 << 5):~(1 << 5);
1585 * pseudoFieldInt |= pseudoField.isHop()?(1 << 6):~(1 << 6);
1586 * pseudoFieldInt |= pseudoField.isUnrep()?(1 << 7):~(1 << 7);
1587 * pseudoFieldInt |= pseudoField.isUnseq()?(1 << 8):~(1 << 8);
1589 * ipv6MatchBuilder.setIpv6Exthdr(pseudoFieldInt); }else if (matchEntry
1590 * instanceof MplsLabel){ if(protocolMatchFieldsBuilder == null)
1591 * protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
1593 * MplsLabelMatchEntry MplsLabelMatchEntry =
1594 * matchEntry.getAugmentation(MplsLabelMatchEntry.class);
1595 * protocolMatchFieldsBuilder
1596 * .setMplsLabel(MplsLabelMatchEntry.getMplsLabel());
1598 * }else if (matchEntry instanceof MplsBos){
1599 * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
1600 * new ProtocolMatchFieldsBuilder();
1602 * BosMatchEntry bosMatchEntry =
1603 * matchEntry.getAugmentation(BosMatchEntry.class);
1604 * protocolMatchFieldsBuilder
1605 * .setMplsBos(bosMatchEntry.isBos()?(short)1:(short)0);
1607 * }else if (matchEntry instanceof MplsTc) {
1608 * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
1609 * new ProtocolMatchFieldsBuilder();
1611 * TcMatchEntry tcMatchEntry =
1612 * matchEntry.getAugmentation(TcMatchEntry.class);
1613 * protocolMatchFieldsBuilder.setMplsTc(tcMatchEntry.getTc());
1615 * }else if (matchEntry instanceof PbbIsid){
1616 * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
1617 * new ProtocolMatchFieldsBuilder();
1619 * IsidMatchEntry isidMatchEntry =
1620 * matchEntry.getAugmentation(IsidMatchEntry.class); PbbBuilder
1621 * pbbBuilder = new PbbBuilder();
1622 * pbbBuilder.setPbbIsid(isidMatchEntry.getIsid()); MaskMatchEntry
1623 * maskMatchEntry = matchEntry.getAugmentation(MaskMatchEntry.class);
1624 * if(maskMatchEntry != null)
1625 * pbbBuilder.setPbbMask(maskMatchEntry.getMask());
1627 * protocolMatchFieldsBuilder.setPbb(pbbBuilder.build()); }else if
1628 * (matchEntry instanceof TunnelId){ MetadataMatchEntry
1629 * metadataMatchEntry =
1630 * matchEntry.getAugmentation(MetadataMatchEntry.class); MaskMatchEntry
1631 * maskMatchEntry = matchEntry.getAugmentation(MaskMatchEntry.class);
1632 * TunnelBuilder tunnelBuilder = new TunnelBuilder();
1633 * tunnelBuilder.setTunnelId(new
1634 * BigInteger(metadataMatchEntry.getMetadata()));
1635 * tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
1636 * match.setTunnel(tunnelBuilder.build()); } } if(ethernetMatchBuilder
1637 * != null){ match.setEthernetMatch(ethernetMatchBuilder.build()); } if
1638 * (vlanMatchBuilder != null){
1639 * match.setVlanMatch(vlanMatchBuilder.build()); } if(ipMatchBuilder !=
1640 * null){ match.setIpMatch(ipMatchBuilder.build()); } if(tcpMatchBuilder
1641 * != null){ match.setLayer4Match(tcpMatchBuilder.build()); }
1642 * if(udpMatchBuilder != null){
1643 * match.setLayer4Match(udpMatchBuilder.build()); } if(sctpMatchBuilder
1644 * != null){ match.setLayer4Match(sctpMatchBuilder.build()); }
1645 * if(icmpv4MatchBuilder != null){
1646 * match.setIcmpv4Match(icmpv4MatchBuilder.build()); }
1647 * if(icmpv6MatchBuilder != null){
1648 * match.setIcmpv6Match(icmpv6MatchBuilder.build()); }
1649 * if(ipv4MatchBuilder != null){
1650 * match.setLayer3Match(ipv4MatchBuilder.build()); } if(arpMatchBuilder
1651 * != null){ match.setLayer3Match(arpMatchBuilder.build()); }
1652 * if(ipv6MatchBuilder != null){
1653 * match.setLayer3Match(ipv6MatchBuilder.build()); }
1654 * if(protocolMatchFieldsBuilder != null){
1655 * match.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); }
1656 * setField.setMatch(match.build());
1657 */return setField.build();