blob: 108dbf87ad2c1b39a191fe3f7fb1b23dc764df3d [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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;
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070025import org.onosproject.net.flow.criteria.EthCriterion;
26import org.onosproject.net.flow.criteria.EthTypeCriterion;
27import org.onosproject.net.flow.criteria.IPCriterion;
28import org.onosproject.net.flow.criteria.IPDscpCriterion;
29import org.onosproject.net.flow.criteria.IPEcnCriterion;
30import org.onosproject.net.flow.criteria.IPProtocolCriterion;
31import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion;
32import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion;
33import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion;
34import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion;
35import org.onosproject.net.flow.criteria.IcmpCodeCriterion;
36import org.onosproject.net.flow.criteria.IcmpTypeCriterion;
37import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion;
38import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion;
39import org.onosproject.net.flow.criteria.LambdaCriterion;
40import org.onosproject.net.flow.criteria.MetadataCriterion;
41import org.onosproject.net.flow.criteria.MplsCriterion;
42import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion;
43import org.onosproject.net.flow.criteria.PortCriterion;
44import org.onosproject.net.flow.criteria.SctpPortCriterion;
45import org.onosproject.net.flow.criteria.TcpPortCriterion;
46import org.onosproject.net.flow.criteria.UdpPortCriterion;
47import org.onosproject.net.flow.criteria.VlanIdCriterion;
48import org.onosproject.net.flow.criteria.VlanPcpCriterion;
Brian O'Connorabafb502014-12-02 22:26:20 -080049import org.onosproject.net.flow.criteria.Criterion;
alshabibeec3a062014-09-17 18:01:26 -070050import org.projectfloodlight.openflow.protocol.OFFactory;
alshabib193525b2014-10-08 18:58:03 -070051import org.projectfloodlight.openflow.protocol.OFFlowAdd;
52import org.projectfloodlight.openflow.protocol.OFFlowDelete;
alshabibeec3a062014-09-17 18:01:26 -070053import org.projectfloodlight.openflow.protocol.OFFlowMod;
alshabibeec3a062014-09-17 18:01:26 -070054import org.projectfloodlight.openflow.protocol.match.Match;
55import org.projectfloodlight.openflow.protocol.match.MatchField;
Marc De Leenheer49087752014-10-23 13:54:09 -070056import org.projectfloodlight.openflow.types.CircuitSignalID;
alshabibeec3a062014-09-17 18:01:26 -070057import org.projectfloodlight.openflow.types.EthType;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080058import org.projectfloodlight.openflow.types.ICMPv4Code;
59import org.projectfloodlight.openflow.types.ICMPv4Type;
alshabibeec3a062014-09-17 18:01:26 -070060import org.projectfloodlight.openflow.types.IPv4Address;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +080061import org.projectfloodlight.openflow.types.IPv6Address;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080062import org.projectfloodlight.openflow.types.IPv6FlowLabel;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080063import org.projectfloodlight.openflow.types.IpDscp;
64import org.projectfloodlight.openflow.types.IpEcn;
alshabibeec3a062014-09-17 18:01:26 -070065import org.projectfloodlight.openflow.types.IpProtocol;
66import org.projectfloodlight.openflow.types.MacAddress;
67import org.projectfloodlight.openflow.types.Masked;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080068import org.projectfloodlight.openflow.types.OFMetadata;
alshabibeec3a062014-09-17 18:01:26 -070069import org.projectfloodlight.openflow.types.OFPort;
70import org.projectfloodlight.openflow.types.OFVlanVidMatch;
Jonathan Hart34bc6142014-10-17 11:00:43 -070071import org.projectfloodlight.openflow.types.TransportPort;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -080072import org.projectfloodlight.openflow.types.U16;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080073import org.projectfloodlight.openflow.types.U32;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -080074import org.projectfloodlight.openflow.types.U8;
alshabibeec3a062014-09-17 18:01:26 -070075import org.projectfloodlight.openflow.types.VlanPcp;
76import org.projectfloodlight.openflow.types.VlanVid;
77import org.slf4j.Logger;
78
Brian O'Connor427a1762014-11-19 18:40:32 -080079import java.util.Optional;
80
Jonathan Hart6cd2f352015-01-13 17:44:45 -080081import static org.slf4j.LoggerFactory.getLogger;
82
Jonathan Hart86e59352014-10-22 10:42:16 -070083/**
84 * Builder for OpenFlow flow mods based on FlowRules.
85 */
86public abstract class FlowModBuilder {
alshabibeec3a062014-09-17 18:01:26 -070087
88 private final Logger log = getLogger(getClass());
89
90 private final OFFactory factory;
Jonathan Hart86e59352014-10-22 10:42:16 -070091 private final FlowRule flowRule;
alshabibeec3a062014-09-17 18:01:26 -070092 private final TrafficSelector selector;
Brian O'Connor427a1762014-11-19 18:40:32 -080093 protected final Long xid;
alshabibeec3a062014-09-17 18:01:26 -070094
Jonathan Hart86e59352014-10-22 10:42:16 -070095 /**
96 * Creates a new flow mod builder.
97 *
98 * @param flowRule the flow rule to transform into a flow mod
99 * @param factory the OpenFlow factory to use to build the flow mod
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -0800100 * @param xid the transaction ID
Jonathan Hart86e59352014-10-22 10:42:16 -0700101 * @return the new flow mod builder
102 */
Brian O'Connor427a1762014-11-19 18:40:32 -0800103 public static FlowModBuilder builder(FlowRule flowRule,
alshabib9af70072015-02-09 14:34:16 -0800104 OFFactory factory,
105 Optional<Long> xid) {
Jonathan Hart86e59352014-10-22 10:42:16 -0700106 switch (factory.getVersion()) {
107 case OF_10:
Brian O'Connor427a1762014-11-19 18:40:32 -0800108 return new FlowModBuilderVer10(flowRule, factory, xid);
Jonathan Hart86e59352014-10-22 10:42:16 -0700109 case OF_13:
Brian O'Connor427a1762014-11-19 18:40:32 -0800110 return new FlowModBuilderVer13(flowRule, factory, xid);
Jonathan Hart86e59352014-10-22 10:42:16 -0700111 default:
112 throw new UnsupportedOperationException(
113 "No flow mod builder for protocol version " + factory.getVersion());
114 }
115 }
alshabibeec3a062014-09-17 18:01:26 -0700116
Jonathan Hart86e59352014-10-22 10:42:16 -0700117 /**
118 * Constructs a flow mod builder.
119 *
120 * @param flowRule the flow rule to transform into a flow mod
121 * @param factory the OpenFlow factory to use to build the flow mod
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -0800122 * @param xid the transaction ID
Jonathan Hart86e59352014-10-22 10:42:16 -0700123 */
Brian O'Connor427a1762014-11-19 18:40:32 -0800124 protected FlowModBuilder(FlowRule flowRule, OFFactory factory, Optional<Long> xid) {
alshabibeec3a062014-09-17 18:01:26 -0700125 this.factory = factory;
Jonathan Hart86e59352014-10-22 10:42:16 -0700126 this.flowRule = flowRule;
alshabibeec3a062014-09-17 18:01:26 -0700127 this.selector = flowRule.selector();
Brian O'Connor427a1762014-11-19 18:40:32 -0800128 this.xid = xid.orElse((long) 0);
129
alshabibeec3a062014-09-17 18:01:26 -0700130 }
131
Jonathan Hart86e59352014-10-22 10:42:16 -0700132 /**
133 * Builds an ADD flow mod.
134 *
135 * @return the flow mod
136 */
137 public abstract OFFlowAdd buildFlowAdd();
alshabibeec3a062014-09-17 18:01:26 -0700138
Jonathan Hart86e59352014-10-22 10:42:16 -0700139 /**
140 * Builds a MODIFY flow mod.
141 *
142 * @return the flow mod
143 */
144 public abstract OFFlowMod buildFlowMod();
alshabibeec3a062014-09-17 18:01:26 -0700145
Jonathan Hart86e59352014-10-22 10:42:16 -0700146 /**
147 * Builds a DELETE flow mod.
148 *
149 * @return the flow mod
150 */
151 public abstract OFFlowDelete buildFlowDel();
alshabibeec3a062014-09-17 18:01:26 -0700152
Jonathan Hart86e59352014-10-22 10:42:16 -0700153 /**
154 * Builds the match for the flow mod.
155 *
156 * @return the match
157 */
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800158 // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES
Jonathan Hart86e59352014-10-22 10:42:16 -0700159 protected Match buildMatch() {
alshabibeec3a062014-09-17 18:01:26 -0700160 Match.Builder mBuilder = factory.buildMatch();
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800161 Ip6Address ip6Address;
Pavlin Radoslavov23e398d2014-11-05 15:17:57 -0800162 Ip4Prefix ip4Prefix;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800163 Ip6Prefix ip6Prefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800164 EthCriterion ethCriterion;
165 IPCriterion ipCriterion;
166 TcpPortCriterion tcpPortCriterion;
167 UdpPortCriterion udpPortCriterion;
168 SctpPortCriterion sctpPortCriterion;
169 IPv6NDLinkLayerAddressCriterion llAddressCriterion;
170
alshabibeec3a062014-09-17 18:01:26 -0700171 for (Criterion c : selector.criteria()) {
172 switch (c.type()) {
173 case IN_PORT:
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800174 PortCriterion inPort = (PortCriterion) c;
175 mBuilder.setExact(MatchField.IN_PORT,
176 OFPort.of((int) inPort.port().toLong()));
177 break;
178 case IN_PHY_PORT:
179 PortCriterion inPhyPort = (PortCriterion) c;
180 mBuilder.setExact(MatchField.IN_PORT,
181 OFPort.of((int) inPhyPort.port().toLong()));
182 break;
183 case METADATA:
184 MetadataCriterion metadata = (MetadataCriterion) c;
185 mBuilder.setExact(MatchField.METADATA,
186 OFMetadata.ofRaw(metadata.metadata()));
alshabibeec3a062014-09-17 18:01:26 -0700187 break;
alshabibeec3a062014-09-17 18:01:26 -0700188 case ETH_DST:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800189 ethCriterion = (EthCriterion) c;
190 mBuilder.setExact(MatchField.ETH_DST,
191 MacAddress.of(ethCriterion.mac().toLong()));
192 break;
193 case ETH_SRC:
194 ethCriterion = (EthCriterion) c;
195 mBuilder.setExact(MatchField.ETH_SRC,
196 MacAddress.of(ethCriterion.mac().toLong()));
alshabibeec3a062014-09-17 18:01:26 -0700197 break;
198 case ETH_TYPE:
199 EthTypeCriterion ethType = (EthTypeCriterion) c;
200 mBuilder.setExact(MatchField.ETH_TYPE, EthType.of(ethType.ethType()));
201 break;
alshabibeec3a062014-09-17 18:01:26 -0700202 case VLAN_VID:
203 VlanIdCriterion vid = (VlanIdCriterion) c;
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800204
205 if (vid.vlanId().equals(VlanId.ANY)) {
206 mBuilder.setMasked(MatchField.VLAN_VID, OFVlanVidMatch.PRESENT,
207 OFVlanVidMatch.PRESENT);
208 } else {
209 mBuilder.setExact(MatchField.VLAN_VID,
alshabib346b5b32015-03-06 00:42:16 -0800210 OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vid.vlanId().toShort())));
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800211 }
alshabibeec3a062014-09-17 18:01:26 -0700212 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800213 case VLAN_PCP:
214 VlanPcpCriterion vpcp = (VlanPcpCriterion) c;
215 mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority()));
216 break;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800217 case IP_DSCP:
218 IPDscpCriterion ipDscpCriterion = (IPDscpCriterion) c;
219 mBuilder.setExact(MatchField.IP_DSCP,
220 IpDscp.of(ipDscpCriterion.ipDscp()));
221 break;
222 case IP_ECN:
223 IPEcnCriterion ipEcnCriterion = (IPEcnCriterion) c;
224 mBuilder.setExact(MatchField.IP_ECN,
225 IpEcn.of(ipEcnCriterion.ipEcn()));
226 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800227 case IP_PROTO:
228 IPProtocolCriterion p = (IPProtocolCriterion) c;
229 mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol()));
230 break;
231 case IPV4_SRC:
232 ipCriterion = (IPCriterion) c;
233 ip4Prefix = ipCriterion.ip().getIp4Prefix();
234 if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) {
235 Ip4Address maskAddr =
236 Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength());
237 Masked<IPv4Address> maskedIp =
238 Masked.of(IPv4Address.of(ip4Prefix.address().toInt()),
239 IPv4Address.of(maskAddr.toInt()));
240 mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp);
241 } else {
242 mBuilder.setExact(MatchField.IPV4_SRC,
243 IPv4Address.of(ip4Prefix.address().toInt()));
244 }
245 break;
246 case IPV4_DST:
247 ipCriterion = (IPCriterion) c;
248 ip4Prefix = ipCriterion.ip().getIp4Prefix();
249 if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) {
250 Ip4Address maskAddr =
251 Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength());
252 Masked<IPv4Address> maskedIp =
253 Masked.of(IPv4Address.of(ip4Prefix.address().toInt()),
254 IPv4Address.of(maskAddr.toInt()));
255 mBuilder.setMasked(MatchField.IPV4_DST, maskedIp);
256 } else {
257 mBuilder.setExact(MatchField.IPV4_DST,
258 IPv4Address.of(ip4Prefix.address().toInt()));
259 }
Jonathan Hart34bc6142014-10-17 11:00:43 -0700260 break;
261 case TCP_SRC:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800262 tcpPortCriterion = (TcpPortCriterion) c;
263 mBuilder.setExact(MatchField.TCP_SRC,
264 TransportPort.of(tcpPortCriterion.tcpPort()));
265 break;
266 case TCP_DST:
267 tcpPortCriterion = (TcpPortCriterion) c;
268 mBuilder.setExact(MatchField.TCP_DST,
269 TransportPort.of(tcpPortCriterion.tcpPort()));
270 break;
271 case UDP_SRC:
272 udpPortCriterion = (UdpPortCriterion) c;
273 mBuilder.setExact(MatchField.UDP_SRC,
274 TransportPort.of(udpPortCriterion.udpPort()));
275 break;
276 case UDP_DST:
277 udpPortCriterion = (UdpPortCriterion) c;
278 mBuilder.setExact(MatchField.UDP_DST,
279 TransportPort.of(udpPortCriterion.udpPort()));
280 break;
281 case SCTP_SRC:
282 sctpPortCriterion = (SctpPortCriterion) c;
283 mBuilder.setExact(MatchField.SCTP_SRC,
284 TransportPort.of(sctpPortCriterion.sctpPort()));
285 break;
286 case SCTP_DST:
287 sctpPortCriterion = (SctpPortCriterion) c;
288 mBuilder.setExact(MatchField.SCTP_DST,
289 TransportPort.of(sctpPortCriterion.sctpPort()));
290 break;
291 case ICMPV4_TYPE:
292 IcmpTypeCriterion icmpType = (IcmpTypeCriterion) c;
293 mBuilder.setExact(MatchField.ICMPV4_TYPE,
294 ICMPv4Type.of(icmpType.icmpType()));
295 break;
296 case ICMPV4_CODE:
297 IcmpCodeCriterion icmpCode = (IcmpCodeCriterion) c;
298 mBuilder.setExact(MatchField.ICMPV4_CODE,
299 ICMPv4Code.of(icmpCode.icmpCode()));
300 break;
301 case IPV6_SRC:
302 ipCriterion = (IPCriterion) c;
303 ip6Prefix = ipCriterion.ip().getIp6Prefix();
304 if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) {
305 Ip6Address maskAddr =
306 Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength());
307 Masked<IPv6Address> maskedIp =
308 Masked.of(IPv6Address.of(ip6Prefix.address().toString()),
309 IPv6Address.of(maskAddr.toString()));
310 mBuilder.setMasked(MatchField.IPV6_SRC, maskedIp);
311 } else {
312 mBuilder.setExact(MatchField.IPV6_SRC,
313 IPv6Address.of(ip6Prefix.address().toString()));
314 }
315 break;
316 case IPV6_DST:
317 ipCriterion = (IPCriterion) c;
318 ip6Prefix = ipCriterion.ip().getIp6Prefix();
319 if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) {
320 Ip6Address maskAddr =
321 Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength());
322 Masked<IPv6Address> maskedIp =
323 Masked.of(IPv6Address.of(ip6Prefix.address().toString()),
324 IPv6Address.of(maskAddr.toString()));
325 mBuilder.setMasked(MatchField.IPV6_DST, maskedIp);
326 } else {
327 mBuilder.setExact(MatchField.IPV6_DST,
328 IPv6Address.of(ip6Prefix.address().toString()));
329 }
330 break;
331 case IPV6_FLABEL:
332 IPv6FlowLabelCriterion flowLabelCriterion =
333 (IPv6FlowLabelCriterion) c;
334 mBuilder.setExact(MatchField.IPV6_FLABEL,
335 IPv6FlowLabel.of(flowLabelCriterion.flowLabel()));
336 break;
337 case ICMPV6_TYPE:
338 Icmpv6TypeCriterion icmpv6Type = (Icmpv6TypeCriterion) c;
339 mBuilder.setExact(MatchField.ICMPV6_TYPE,
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800340 U8.of(icmpv6Type.icmpv6Type()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800341 break;
342 case ICMPV6_CODE:
343 Icmpv6CodeCriterion icmpv6Code = (Icmpv6CodeCriterion) c;
344 mBuilder.setExact(MatchField.ICMPV6_CODE,
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800345 U8.of(icmpv6Code.icmpv6Code()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800346 break;
347 case IPV6_ND_TARGET:
348 IPv6NDTargetAddressCriterion targetAddressCriterion =
349 (IPv6NDTargetAddressCriterion) c;
350 ip6Address = targetAddressCriterion.targetAddress();
351 mBuilder.setExact(MatchField.IPV6_ND_TARGET,
352 IPv6Address.of(ip6Address.toOctets()));
353 break;
354 case IPV6_ND_SLL:
355 llAddressCriterion =
356 (IPv6NDLinkLayerAddressCriterion) c;
357 mBuilder.setExact(MatchField.IPV6_ND_SLL,
358 MacAddress.of(llAddressCriterion.mac().toLong()));
359 break;
360 case IPV6_ND_TLL:
361 llAddressCriterion =
362 (IPv6NDLinkLayerAddressCriterion) c;
363 mBuilder.setExact(MatchField.IPV6_ND_TLL,
364 MacAddress.of(llAddressCriterion.mac().toLong()));
Jonathan Hart34bc6142014-10-17 11:00:43 -0700365 break;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800366 case MPLS_LABEL:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700367 MplsCriterion mp = (MplsCriterion) c;
Michele Santuari4b6019e2014-12-19 11:31:45 +0100368 mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label().toInt()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800369 break;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800370 case IPV6_EXTHDR:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700371 IPv6ExthdrFlagsCriterion exthdrFlagsCriterion =
372 (IPv6ExthdrFlagsCriterion) c;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800373 mBuilder.setExact(MatchField.IPV6_EXTHDR,
374 U16.of(exthdrFlagsCriterion.exthdrFlags()));
375 break;
Marc De Leenheer49087752014-10-23 13:54:09 -0700376 case OCH_SIGID:
377 LambdaCriterion lc = (LambdaCriterion) c;
378 mBuilder.setExact(MatchField.OCH_SIGID,
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800379 new CircuitSignalID((byte) 1, (byte) 2,
380 (short) lc.lambda(), (short) 1));
Marc De Leenheer49087752014-10-23 13:54:09 -0700381 break;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800382 case OCH_SIGTYPE:
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700383 OpticalSignalTypeCriterion sc =
384 (OpticalSignalTypeCriterion) c;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800385 mBuilder.setExact(MatchField.OCH_SIGTYPE,
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800386 U8.of(sc.signalType()));
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800387 break;
alshabibeec3a062014-09-17 18:01:26 -0700388 case ARP_OP:
389 case ARP_SHA:
390 case ARP_SPA:
391 case ARP_THA:
392 case ARP_TPA:
alshabibeec3a062014-09-17 18:01:26 -0700393 case MPLS_BOS:
alshabibeec3a062014-09-17 18:01:26 -0700394 case MPLS_TC:
395 case PBB_ISID:
alshabibeec3a062014-09-17 18:01:26 -0700396 case TUNNEL_ID:
alshabibeec3a062014-09-17 18:01:26 -0700397 default:
398 log.warn("Match type {} not yet implemented.", c.type());
399 }
400 }
401 return mBuilder.build();
402 }
403
Jonathan Hart86e59352014-10-22 10:42:16 -0700404 /**
405 * Returns the flow rule for this builder.
406 *
407 * @return the flow rule
408 */
409 protected FlowRule flowRule() {
410 return flowRule;
411 }
alshabib219ebaa2014-09-22 15:41:24 -0700412
Jonathan Hart86e59352014-10-22 10:42:16 -0700413 /**
414 * Returns the factory used for building OpenFlow constructs.
415 *
416 * @return the factory
417 */
418 protected OFFactory factory() {
419 return factory;
420 }
alshabib219ebaa2014-09-22 15:41:24 -0700421
alshabibeec3a062014-09-17 18:01:26 -0700422}