blob: b21ea0bf7bcfad4b0dfa6c353363418076c8e185 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.provider.of.flow.impl;
alshabibeec3a062014-09-17 18:01:26 -070017
Jonathan Hart6cd2f352015-01-13 17:44:45 -080018import org.onlab.packet.Ip4Address;
19import org.onlab.packet.Ip4Prefix;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +080020import org.onlab.packet.Ip6Address;
21import org.onlab.packet.Ip6Prefix;
Jonathan Hart6cd2f352015-01-13 17:44:45 -080022import org.onlab.packet.VlanId;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.flow.FlowRule;
24import org.onosproject.net.flow.TrafficSelector;
25import org.onosproject.net.flow.criteria.Criteria;
26import org.onosproject.net.flow.criteria.Criteria.EthCriterion;
27import org.onosproject.net.flow.criteria.Criteria.EthTypeCriterion;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080028import org.onosproject.net.flow.criteria.Criteria.IcmpCodeCriterion;
29import org.onosproject.net.flow.criteria.Criteria.IcmpTypeCriterion;
Jonathan Hart6cd2f352015-01-13 17:44:45 -080030import org.onosproject.net.flow.criteria.Criteria.Icmpv6CodeCriterion;
31import org.onosproject.net.flow.criteria.Criteria.Icmpv6TypeCriterion;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080032import org.onosproject.net.flow.criteria.Criteria.IPCriterion;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080033import org.onosproject.net.flow.criteria.Criteria.IPDscpCriterion;
34import org.onosproject.net.flow.criteria.Criteria.IPEcnCriterion;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080035import org.onosproject.net.flow.criteria.Criteria.IPProtocolCriterion;
36import org.onosproject.net.flow.criteria.Criteria.IPv6FlowLabelCriterion;
37import org.onosproject.net.flow.criteria.Criteria.IPv6NDLinkLayerAddressCriterion;
38import org.onosproject.net.flow.criteria.Criteria.IPv6NDTargetAddressCriterion;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import org.onosproject.net.flow.criteria.Criteria.LambdaCriterion;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080040import org.onosproject.net.flow.criteria.Criteria.MetadataCriterion;
Brian O'Connorabafb502014-12-02 22:26:20 -080041import org.onosproject.net.flow.criteria.Criteria.PortCriterion;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080042import org.onosproject.net.flow.criteria.Criteria.SctpPortCriterion;
Brian O'Connorabafb502014-12-02 22:26:20 -080043import org.onosproject.net.flow.criteria.Criteria.TcpPortCriterion;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080044import org.onosproject.net.flow.criteria.Criteria.UdpPortCriterion;
Brian O'Connorabafb502014-12-02 22:26:20 -080045import org.onosproject.net.flow.criteria.Criteria.VlanIdCriterion;
46import org.onosproject.net.flow.criteria.Criteria.VlanPcpCriterion;
47import org.onosproject.net.flow.criteria.Criterion;
alshabibeec3a062014-09-17 18:01:26 -070048import org.projectfloodlight.openflow.protocol.OFFactory;
alshabib193525b2014-10-08 18:58:03 -070049import org.projectfloodlight.openflow.protocol.OFFlowAdd;
50import org.projectfloodlight.openflow.protocol.OFFlowDelete;
alshabibeec3a062014-09-17 18:01:26 -070051import org.projectfloodlight.openflow.protocol.OFFlowMod;
alshabibeec3a062014-09-17 18:01:26 -070052import org.projectfloodlight.openflow.protocol.match.Match;
53import org.projectfloodlight.openflow.protocol.match.MatchField;
Marc De Leenheer49087752014-10-23 13:54:09 -070054import org.projectfloodlight.openflow.types.CircuitSignalID;
alshabibeec3a062014-09-17 18:01:26 -070055import org.projectfloodlight.openflow.types.EthType;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080056import org.projectfloodlight.openflow.types.ICMPv4Code;
57import org.projectfloodlight.openflow.types.ICMPv4Type;
alshabibeec3a062014-09-17 18:01:26 -070058import org.projectfloodlight.openflow.types.IPv4Address;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +080059import org.projectfloodlight.openflow.types.IPv6Address;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080060import org.projectfloodlight.openflow.types.IPv6FlowLabel;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080061import org.projectfloodlight.openflow.types.IpDscp;
62import org.projectfloodlight.openflow.types.IpEcn;
alshabibeec3a062014-09-17 18:01:26 -070063import org.projectfloodlight.openflow.types.IpProtocol;
64import org.projectfloodlight.openflow.types.MacAddress;
65import org.projectfloodlight.openflow.types.Masked;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080066import org.projectfloodlight.openflow.types.OFMetadata;
alshabibeec3a062014-09-17 18:01:26 -070067import org.projectfloodlight.openflow.types.OFPort;
68import org.projectfloodlight.openflow.types.OFVlanVidMatch;
Jonathan Hart34bc6142014-10-17 11:00:43 -070069import org.projectfloodlight.openflow.types.TransportPort;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -080070import org.projectfloodlight.openflow.types.U16;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080071import org.projectfloodlight.openflow.types.U32;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -080072import org.projectfloodlight.openflow.types.U8;
alshabibeec3a062014-09-17 18:01:26 -070073import org.projectfloodlight.openflow.types.VlanPcp;
74import org.projectfloodlight.openflow.types.VlanVid;
75import org.slf4j.Logger;
76
Brian O'Connor427a1762014-11-19 18:40:32 -080077import java.util.Optional;
78
Jonathan Hart6cd2f352015-01-13 17:44:45 -080079import static org.slf4j.LoggerFactory.getLogger;
80
Jonathan Hart86e59352014-10-22 10:42:16 -070081/**
82 * Builder for OpenFlow flow mods based on FlowRules.
83 */
84public abstract class FlowModBuilder {
alshabibeec3a062014-09-17 18:01:26 -070085
86 private final Logger log = getLogger(getClass());
87
88 private final OFFactory factory;
Jonathan Hart86e59352014-10-22 10:42:16 -070089 private final FlowRule flowRule;
alshabibeec3a062014-09-17 18:01:26 -070090 private final TrafficSelector selector;
Brian O'Connor427a1762014-11-19 18:40:32 -080091 protected final Long xid;
alshabibeec3a062014-09-17 18:01:26 -070092
Jonathan Hart86e59352014-10-22 10:42:16 -070093 /**
94 * Creates a new flow mod builder.
95 *
96 * @param flowRule the flow rule to transform into a flow mod
97 * @param factory the OpenFlow factory to use to build the flow mod
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -080098 * @param xid the transaction ID
Jonathan Hart86e59352014-10-22 10:42:16 -070099 * @return the new flow mod builder
100 */
Brian O'Connor427a1762014-11-19 18:40:32 -0800101 public static FlowModBuilder builder(FlowRule flowRule,
102 OFFactory factory, Optional<Long> xid) {
Jonathan Hart86e59352014-10-22 10:42:16 -0700103 switch (factory.getVersion()) {
104 case OF_10:
Brian O'Connor427a1762014-11-19 18:40:32 -0800105 return new FlowModBuilderVer10(flowRule, factory, xid);
Jonathan Hart86e59352014-10-22 10:42:16 -0700106 case OF_13:
Brian O'Connor427a1762014-11-19 18:40:32 -0800107 return new FlowModBuilderVer13(flowRule, factory, xid);
Jonathan Hart86e59352014-10-22 10:42:16 -0700108 default:
109 throw new UnsupportedOperationException(
110 "No flow mod builder for protocol version " + factory.getVersion());
111 }
112 }
alshabibeec3a062014-09-17 18:01:26 -0700113
Jonathan Hart86e59352014-10-22 10:42:16 -0700114 /**
115 * Constructs a flow mod builder.
116 *
117 * @param flowRule the flow rule to transform into a flow mod
118 * @param factory the OpenFlow factory to use to build the flow mod
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -0800119 * @param xid the transaction ID
Jonathan Hart86e59352014-10-22 10:42:16 -0700120 */
Brian O'Connor427a1762014-11-19 18:40:32 -0800121 protected FlowModBuilder(FlowRule flowRule, OFFactory factory, Optional<Long> xid) {
alshabibeec3a062014-09-17 18:01:26 -0700122 this.factory = factory;
Jonathan Hart86e59352014-10-22 10:42:16 -0700123 this.flowRule = flowRule;
alshabibeec3a062014-09-17 18:01:26 -0700124 this.selector = flowRule.selector();
Brian O'Connor427a1762014-11-19 18:40:32 -0800125 this.xid = xid.orElse((long) 0);
126
alshabibeec3a062014-09-17 18:01:26 -0700127 }
128
Jonathan Hart86e59352014-10-22 10:42:16 -0700129 /**
130 * Builds an ADD flow mod.
131 *
132 * @return the flow mod
133 */
134 public abstract OFFlowAdd buildFlowAdd();
alshabibeec3a062014-09-17 18:01:26 -0700135
Jonathan Hart86e59352014-10-22 10:42:16 -0700136 /**
137 * Builds a MODIFY flow mod.
138 *
139 * @return the flow mod
140 */
141 public abstract OFFlowMod buildFlowMod();
alshabibeec3a062014-09-17 18:01:26 -0700142
Jonathan Hart86e59352014-10-22 10:42:16 -0700143 /**
144 * Builds a DELETE flow mod.
145 *
146 * @return the flow mod
147 */
148 public abstract OFFlowDelete buildFlowDel();
alshabibeec3a062014-09-17 18:01:26 -0700149
Jonathan Hart86e59352014-10-22 10:42:16 -0700150 /**
151 * Builds the match for the flow mod.
152 *
153 * @return the match
154 */
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800155 // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES
Jonathan Hart86e59352014-10-22 10:42:16 -0700156 protected Match buildMatch() {
alshabibeec3a062014-09-17 18:01:26 -0700157 Match.Builder mBuilder = factory.buildMatch();
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800158 Ip6Address ip6Address;
Pavlin Radoslavov23e398d2014-11-05 15:17:57 -0800159 Ip4Prefix ip4Prefix;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800160 Ip6Prefix ip6Prefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800161 EthCriterion ethCriterion;
162 IPCriterion ipCriterion;
163 TcpPortCriterion tcpPortCriterion;
164 UdpPortCriterion udpPortCriterion;
165 SctpPortCriterion sctpPortCriterion;
166 IPv6NDLinkLayerAddressCriterion llAddressCriterion;
167
alshabibeec3a062014-09-17 18:01:26 -0700168 for (Criterion c : selector.criteria()) {
169 switch (c.type()) {
170 case IN_PORT:
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800171 PortCriterion inPort = (PortCriterion) c;
172 mBuilder.setExact(MatchField.IN_PORT,
173 OFPort.of((int) inPort.port().toLong()));
174 break;
175 case IN_PHY_PORT:
176 PortCriterion inPhyPort = (PortCriterion) c;
177 mBuilder.setExact(MatchField.IN_PORT,
178 OFPort.of((int) inPhyPort.port().toLong()));
179 break;
180 case METADATA:
181 MetadataCriterion metadata = (MetadataCriterion) c;
182 mBuilder.setExact(MatchField.METADATA,
183 OFMetadata.ofRaw(metadata.metadata()));
alshabibeec3a062014-09-17 18:01:26 -0700184 break;
alshabibeec3a062014-09-17 18:01:26 -0700185 case ETH_DST:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800186 ethCriterion = (EthCriterion) c;
187 mBuilder.setExact(MatchField.ETH_DST,
188 MacAddress.of(ethCriterion.mac().toLong()));
189 break;
190 case ETH_SRC:
191 ethCriterion = (EthCriterion) c;
192 mBuilder.setExact(MatchField.ETH_SRC,
193 MacAddress.of(ethCriterion.mac().toLong()));
alshabibeec3a062014-09-17 18:01:26 -0700194 break;
195 case ETH_TYPE:
196 EthTypeCriterion ethType = (EthTypeCriterion) c;
197 mBuilder.setExact(MatchField.ETH_TYPE, EthType.of(ethType.ethType()));
198 break;
alshabibeec3a062014-09-17 18:01:26 -0700199 case VLAN_VID:
200 VlanIdCriterion vid = (VlanIdCriterion) c;
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800201
202 if (vid.vlanId().equals(VlanId.ANY)) {
203 mBuilder.setMasked(MatchField.VLAN_VID, OFVlanVidMatch.PRESENT,
204 OFVlanVidMatch.PRESENT);
205 } else {
206 mBuilder.setExact(MatchField.VLAN_VID,
207 OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vid.vlanId().toShort())));
208 }
alshabibeec3a062014-09-17 18:01:26 -0700209 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800210 case VLAN_PCP:
211 VlanPcpCriterion vpcp = (VlanPcpCriterion) c;
212 mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority()));
213 break;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800214 case IP_DSCP:
215 IPDscpCriterion ipDscpCriterion = (IPDscpCriterion) c;
216 mBuilder.setExact(MatchField.IP_DSCP,
217 IpDscp.of(ipDscpCriterion.ipDscp()));
218 break;
219 case IP_ECN:
220 IPEcnCriterion ipEcnCriterion = (IPEcnCriterion) c;
221 mBuilder.setExact(MatchField.IP_ECN,
222 IpEcn.of(ipEcnCriterion.ipEcn()));
223 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800224 case IP_PROTO:
225 IPProtocolCriterion p = (IPProtocolCriterion) c;
226 mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol()));
227 break;
228 case IPV4_SRC:
229 ipCriterion = (IPCriterion) c;
230 ip4Prefix = ipCriterion.ip().getIp4Prefix();
231 if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) {
232 Ip4Address maskAddr =
233 Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength());
234 Masked<IPv4Address> maskedIp =
235 Masked.of(IPv4Address.of(ip4Prefix.address().toInt()),
236 IPv4Address.of(maskAddr.toInt()));
237 mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp);
238 } else {
239 mBuilder.setExact(MatchField.IPV4_SRC,
240 IPv4Address.of(ip4Prefix.address().toInt()));
241 }
242 break;
243 case IPV4_DST:
244 ipCriterion = (IPCriterion) c;
245 ip4Prefix = ipCriterion.ip().getIp4Prefix();
246 if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) {
247 Ip4Address maskAddr =
248 Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength());
249 Masked<IPv4Address> maskedIp =
250 Masked.of(IPv4Address.of(ip4Prefix.address().toInt()),
251 IPv4Address.of(maskAddr.toInt()));
252 mBuilder.setMasked(MatchField.IPV4_DST, maskedIp);
253 } else {
254 mBuilder.setExact(MatchField.IPV4_DST,
255 IPv4Address.of(ip4Prefix.address().toInt()));
256 }
Jonathan Hart34bc6142014-10-17 11:00:43 -0700257 break;
258 case TCP_SRC:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800259 tcpPortCriterion = (TcpPortCriterion) c;
260 mBuilder.setExact(MatchField.TCP_SRC,
261 TransportPort.of(tcpPortCriterion.tcpPort()));
262 break;
263 case TCP_DST:
264 tcpPortCriterion = (TcpPortCriterion) c;
265 mBuilder.setExact(MatchField.TCP_DST,
266 TransportPort.of(tcpPortCriterion.tcpPort()));
267 break;
268 case UDP_SRC:
269 udpPortCriterion = (UdpPortCriterion) c;
270 mBuilder.setExact(MatchField.UDP_SRC,
271 TransportPort.of(udpPortCriterion.udpPort()));
272 break;
273 case UDP_DST:
274 udpPortCriterion = (UdpPortCriterion) c;
275 mBuilder.setExact(MatchField.UDP_DST,
276 TransportPort.of(udpPortCriterion.udpPort()));
277 break;
278 case SCTP_SRC:
279 sctpPortCriterion = (SctpPortCriterion) c;
280 mBuilder.setExact(MatchField.SCTP_SRC,
281 TransportPort.of(sctpPortCriterion.sctpPort()));
282 break;
283 case SCTP_DST:
284 sctpPortCriterion = (SctpPortCriterion) c;
285 mBuilder.setExact(MatchField.SCTP_DST,
286 TransportPort.of(sctpPortCriterion.sctpPort()));
287 break;
288 case ICMPV4_TYPE:
289 IcmpTypeCriterion icmpType = (IcmpTypeCriterion) c;
290 mBuilder.setExact(MatchField.ICMPV4_TYPE,
291 ICMPv4Type.of(icmpType.icmpType()));
292 break;
293 case ICMPV4_CODE:
294 IcmpCodeCriterion icmpCode = (IcmpCodeCriterion) c;
295 mBuilder.setExact(MatchField.ICMPV4_CODE,
296 ICMPv4Code.of(icmpCode.icmpCode()));
297 break;
298 case IPV6_SRC:
299 ipCriterion = (IPCriterion) c;
300 ip6Prefix = ipCriterion.ip().getIp6Prefix();
301 if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) {
302 Ip6Address maskAddr =
303 Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength());
304 Masked<IPv6Address> maskedIp =
305 Masked.of(IPv6Address.of(ip6Prefix.address().toString()),
306 IPv6Address.of(maskAddr.toString()));
307 mBuilder.setMasked(MatchField.IPV6_SRC, maskedIp);
308 } else {
309 mBuilder.setExact(MatchField.IPV6_SRC,
310 IPv6Address.of(ip6Prefix.address().toString()));
311 }
312 break;
313 case IPV6_DST:
314 ipCriterion = (IPCriterion) c;
315 ip6Prefix = ipCriterion.ip().getIp6Prefix();
316 if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) {
317 Ip6Address maskAddr =
318 Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength());
319 Masked<IPv6Address> maskedIp =
320 Masked.of(IPv6Address.of(ip6Prefix.address().toString()),
321 IPv6Address.of(maskAddr.toString()));
322 mBuilder.setMasked(MatchField.IPV6_DST, maskedIp);
323 } else {
324 mBuilder.setExact(MatchField.IPV6_DST,
325 IPv6Address.of(ip6Prefix.address().toString()));
326 }
327 break;
328 case IPV6_FLABEL:
329 IPv6FlowLabelCriterion flowLabelCriterion =
330 (IPv6FlowLabelCriterion) c;
331 mBuilder.setExact(MatchField.IPV6_FLABEL,
332 IPv6FlowLabel.of(flowLabelCriterion.flowLabel()));
333 break;
334 case ICMPV6_TYPE:
335 Icmpv6TypeCriterion icmpv6Type = (Icmpv6TypeCriterion) c;
336 mBuilder.setExact(MatchField.ICMPV6_TYPE,
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800337 U8.of(icmpv6Type.icmpv6Type()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800338 break;
339 case ICMPV6_CODE:
340 Icmpv6CodeCriterion icmpv6Code = (Icmpv6CodeCriterion) c;
341 mBuilder.setExact(MatchField.ICMPV6_CODE,
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800342 U8.of(icmpv6Code.icmpv6Code()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800343 break;
344 case IPV6_ND_TARGET:
345 IPv6NDTargetAddressCriterion targetAddressCriterion =
346 (IPv6NDTargetAddressCriterion) c;
347 ip6Address = targetAddressCriterion.targetAddress();
348 mBuilder.setExact(MatchField.IPV6_ND_TARGET,
349 IPv6Address.of(ip6Address.toOctets()));
350 break;
351 case IPV6_ND_SLL:
352 llAddressCriterion =
353 (IPv6NDLinkLayerAddressCriterion) c;
354 mBuilder.setExact(MatchField.IPV6_ND_SLL,
355 MacAddress.of(llAddressCriterion.mac().toLong()));
356 break;
357 case IPV6_ND_TLL:
358 llAddressCriterion =
359 (IPv6NDLinkLayerAddressCriterion) c;
360 mBuilder.setExact(MatchField.IPV6_ND_TLL,
361 MacAddress.of(llAddressCriterion.mac().toLong()));
Jonathan Hart34bc6142014-10-17 11:00:43 -0700362 break;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800363 case MPLS_LABEL:
364 Criteria.MplsCriterion mp = (Criteria.MplsCriterion) c;
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800365 mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800366 break;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800367 case IPV6_EXTHDR:
368 Criteria.IPv6ExthdrFlagsCriterion exthdrFlagsCriterion =
369 (Criteria.IPv6ExthdrFlagsCriterion) c;
370 mBuilder.setExact(MatchField.IPV6_EXTHDR,
371 U16.of(exthdrFlagsCriterion.exthdrFlags()));
372 break;
Marc De Leenheer49087752014-10-23 13:54:09 -0700373 case OCH_SIGID:
374 LambdaCriterion lc = (LambdaCriterion) c;
375 mBuilder.setExact(MatchField.OCH_SIGID,
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800376 new CircuitSignalID((byte) 1, (byte) 2,
377 (short) lc.lambda(), (short) 1));
Marc De Leenheer49087752014-10-23 13:54:09 -0700378 break;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800379 case OCH_SIGTYPE:
380 Criteria.OpticalSignalTypeCriterion sc =
381 (Criteria.OpticalSignalTypeCriterion) c;
382 mBuilder.setExact(MatchField.OCH_SIGTYPE,
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800383 U8.of(sc.signalType()));
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800384 break;
alshabibeec3a062014-09-17 18:01:26 -0700385 case ARP_OP:
386 case ARP_SHA:
387 case ARP_SPA:
388 case ARP_THA:
389 case ARP_TPA:
alshabibeec3a062014-09-17 18:01:26 -0700390 case MPLS_BOS:
alshabibeec3a062014-09-17 18:01:26 -0700391 case MPLS_TC:
392 case PBB_ISID:
alshabibeec3a062014-09-17 18:01:26 -0700393 case TUNNEL_ID:
alshabibeec3a062014-09-17 18:01:26 -0700394 default:
395 log.warn("Match type {} not yet implemented.", c.type());
396 }
397 }
398 return mBuilder.build();
399 }
400
Jonathan Hart86e59352014-10-22 10:42:16 -0700401 /**
402 * Returns the flow rule for this builder.
403 *
404 * @return the flow rule
405 */
406 protected FlowRule flowRule() {
407 return flowRule;
408 }
alshabib219ebaa2014-09-22 15:41:24 -0700409
Jonathan Hart86e59352014-10-22 10:42:16 -0700410 /**
411 * Returns the factory used for building OpenFlow constructs.
412 *
413 * @return the factory
414 */
415 protected OFFactory factory() {
416 return factory;
417 }
alshabib219ebaa2014-09-22 15:41:24 -0700418
alshabibeec3a062014-09-17 18:01:26 -0700419}