blob: 5f32a3c481613c6b10f502a25b4fb35bd4495e78 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -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 Vachuska83e090e2014-10-22 14:25:35 -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 Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow.instructions;
alshabib55a55d92014-09-16 11:59:31 -070017
alshabib7b808c52015-06-26 14:22:24 -070018import org.onlab.packet.EthType;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070019import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010020import org.onlab.packet.MplsLabel;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070021import org.onlab.packet.VlanId;
alshabib55a55d92014-09-16 11:59:31 -070022
Jonathan Hart54b406b2015-03-06 16:24:14 -080023import java.util.Objects;
24
alshabib55a55d92014-09-16 11:59:31 -070025/**
26 * Abstraction of a single traffic treatment step.
alshabib55a55d92014-09-16 11:59:31 -070027 */
28public abstract class L2ModificationInstruction implements Instruction {
29
Jonathan Hartc7840bd2016-01-21 23:26:29 -080030 private static final String SEPARATOR = ":";
31
alshabib55a55d92014-09-16 11:59:31 -070032 /**
33 * Represents the type of traffic treatment.
34 */
alshabib35edb1a2014-09-16 17:44:44 -070035 public enum L2SubType {
alshabib55a55d92014-09-16 11:59:31 -070036 /**
37 * Ether src modification.
38 */
alshabib99b8fdc2014-09-25 14:30:22 -070039 ETH_SRC,
alshabib55a55d92014-09-16 11:59:31 -070040
41 /**
42 * Ether dst modification.
43 */
alshabib99b8fdc2014-09-25 14:30:22 -070044 ETH_DST,
alshabib55a55d92014-09-16 11:59:31 -070045
46 /**
alshabib55a55d92014-09-16 11:59:31 -070047 * VLAN id modification.
48 */
49 VLAN_ID,
50
51 /**
52 * VLAN priority modification.
53 */
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080054 VLAN_PCP,
55
56 /**
57 * MPLS Label modification.
58 */
59 MPLS_LABEL,
60
61 /**
62 * MPLS Push modification.
63 */
64 MPLS_PUSH,
65
66 /**
67 * MPLS Pop modification.
68 */
sangho3f97a17d2015-01-29 22:56:29 -080069 MPLS_POP,
70
71 /**
72 * MPLS TTL modification.
73 */
Saurav Dasfbe25c52015-03-04 11:12:00 -080074 DEC_MPLS_TTL,
sangho3f97a17d2015-01-29 22:56:29 -080075
Saurav Dasfbe25c52015-03-04 11:12:00 -080076 /**
77 * VLAN Pop modification.
78 */
Jonathan Hart54b406b2015-03-06 16:24:14 -080079 VLAN_POP,
80
81 /**
82 * VLAN Push modification.
83 */
Hyunsun Moona08c5d02015-07-14 17:53:00 -070084 VLAN_PUSH,
85
86 /**
Saurav Das73a7dd42015-08-19 22:20:31 -070087 * Tunnel id modification.
Hyunsun Moona08c5d02015-07-14 17:53:00 -070088 */
Saurav Das73a7dd42015-08-19 22:20:31 -070089 TUNNEL_ID,
90
91 /**
92 * MPLS BOS instruction.
93 */
94 MPLS_BOS
alshabib55a55d92014-09-16 11:59:31 -070095 }
96
alshabib35edb1a2014-09-16 17:44:44 -070097 public abstract L2SubType subtype();
alshabib55a55d92014-09-16 11:59:31 -070098
99 @Override
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800100 public final Type type() {
alshabib35edb1a2014-09-16 17:44:44 -0700101 return Type.L2MODIFICATION;
alshabib55a55d92014-09-16 11:59:31 -0700102 }
103
104 /**
105 * Represents a L2 src/dst modification instruction.
106 */
107 public static final class ModEtherInstruction extends L2ModificationInstruction {
108
alshabib35edb1a2014-09-16 17:44:44 -0700109 private final L2SubType subtype;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700110 private final MacAddress mac;
alshabib55a55d92014-09-16 11:59:31 -0700111
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800112 ModEtherInstruction(L2SubType subType, MacAddress addr) {
alshabib64231f62014-09-16 17:58:36 -0700113
alshabib55a55d92014-09-16 11:59:31 -0700114 this.subtype = subType;
115 this.mac = addr;
116 }
117
118 @Override
alshabib35edb1a2014-09-16 17:44:44 -0700119 public L2SubType subtype() {
alshabib55a55d92014-09-16 11:59:31 -0700120 return this.subtype;
121 }
122
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700123 public MacAddress mac() {
alshabib55a55d92014-09-16 11:59:31 -0700124 return this.mac;
125 }
126
alshabib99b8fdc2014-09-25 14:30:22 -0700127 @Override
128 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800129 return subtype().toString() + SEPARATOR + mac;
alshabib99b8fdc2014-09-25 14:30:22 -0700130 }
131
alshabib8ca53902014-10-07 13:11:17 -0700132 @Override
133 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800134 return Objects.hash(type(), subtype, mac);
alshabib8ca53902014-10-07 13:11:17 -0700135 }
136
137 @Override
138 public boolean equals(Object obj) {
139 if (this == obj) {
140 return true;
141 }
142 if (obj instanceof ModEtherInstruction) {
143 ModEtherInstruction that = (ModEtherInstruction) obj;
144 return Objects.equals(mac, that.mac) &&
145 Objects.equals(subtype, that.subtype);
alshabib8ca53902014-10-07 13:11:17 -0700146 }
147 return false;
148 }
alshabib55a55d92014-09-16 11:59:31 -0700149 }
150
Jian Liddfd2eb2016-05-19 11:32:18 -0700151 /**
152 * @deprecated 1.6.0 Goldeneye release.
153 * Recommended to use ModMplsHeaderInstruction or ModVlanHeaderInstruction instead.
154 */
155 @Deprecated
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800156 public static final class PushHeaderInstructions extends
157 L2ModificationInstruction {
158
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800159
alshabib7b808c52015-06-26 14:22:24 -0700160 private final L2SubType subtype;
161 private final EthType ethernetType; // Ethernet type value: 16 bits
162
163 PushHeaderInstructions(L2SubType subType, EthType ethernetType) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800164 this.subtype = subType;
alshabib7b808c52015-06-26 14:22:24 -0700165 this.ethernetType = ethernetType;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800166 }
167
alshabib7b808c52015-06-26 14:22:24 -0700168 public EthType ethernetType() {
alshabib0ad43982015-05-07 13:43:13 -0700169 return ethernetType;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800170 }
171
172 @Override
173 public L2SubType subtype() {
174 return this.subtype;
175 }
176
177 @Override
178 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800179 return subtype().toString() + SEPARATOR + ethernetType;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800180 }
181
182 @Override
183 public int hashCode() {
Yuta HIGUCHI32a53c52015-02-08 01:25:40 -0800184 return Objects.hash(type(), subtype, ethernetType);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800185 }
186
187 @Override
188 public boolean equals(Object obj) {
189 if (this == obj) {
190 return true;
191 }
192 if (obj instanceof PushHeaderInstructions) {
193 PushHeaderInstructions that = (PushHeaderInstructions) obj;
Yuta HIGUCHI32a53c52015-02-08 01:25:40 -0800194 return Objects.equals(subtype, that.subtype) &&
195 Objects.equals(this.ethernetType, that.ethernetType);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800196 }
197 return false;
198 }
199 }
200
Jian Liddfd2eb2016-05-19 11:32:18 -0700201 /**
202 * Represents a MPLS header modification instruction.
203 */
204 public static final class ModMplsHeaderInstruction extends L2ModificationInstruction {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800205
Jian Liddfd2eb2016-05-19 11:32:18 -0700206 private final L2SubType subtype;
207 private final EthType ethernetType; // Ethernet type value: 16 bits
208
209 ModMplsHeaderInstruction(L2SubType subType, EthType ethernetType) {
210 this.subtype = subType;
211 this.ethernetType = ethernetType;
212 }
213
214 public EthType ethernetType() {
215 return ethernetType;
216 }
217
218 @Override
219 public L2SubType subtype() {
220 return subtype;
221 }
222
223 @Override
224 public String toString() {
225 return subtype().toString() + SEPARATOR + ethernetType;
226 }
227
228 @Override
229 public int hashCode() {
230 return Objects.hash(type(), subtype, ethernetType);
231 }
232
233 @Override
234 public boolean equals(Object obj) {
235 if (this == obj) {
236 return true;
237 }
238 if (obj instanceof ModMplsHeaderInstruction) {
239 ModMplsHeaderInstruction that = (ModMplsHeaderInstruction) obj;
240 return Objects.equals(subtype, that.subtype) &&
241 Objects.equals(this.ethernetType, that.ethernetType);
242 }
243 return false;
244 }
245 }
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800246
alshabib55a55d92014-09-16 11:59:31 -0700247 /**
alshabib55a55d92014-09-16 11:59:31 -0700248 * Represents a VLAN id modification instruction.
249 */
250 public static final class ModVlanIdInstruction extends L2ModificationInstruction {
251
Ray Milkey78081052014-11-05 10:38:12 -0800252 private final VlanId vlanId;
alshabib55a55d92014-09-16 11:59:31 -0700253
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800254 ModVlanIdInstruction(VlanId vlanId) {
alshabib55a55d92014-09-16 11:59:31 -0700255 this.vlanId = vlanId;
256 }
257
258 @Override
alshabib35edb1a2014-09-16 17:44:44 -0700259 public L2SubType subtype() {
alshabib7410fea2014-09-16 13:48:39 -0700260 return L2SubType.VLAN_ID;
alshabib55a55d92014-09-16 11:59:31 -0700261 }
262
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700263 public VlanId vlanId() {
alshabib55a55d92014-09-16 11:59:31 -0700264 return this.vlanId;
265 }
266
alshabib99b8fdc2014-09-25 14:30:22 -0700267 @Override
268 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800269 return subtype().toString() + SEPARATOR + vlanId;
alshabib99b8fdc2014-09-25 14:30:22 -0700270 }
271
alshabib8ca53902014-10-07 13:11:17 -0700272 @Override
273 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800274 return Objects.hash(type(), subtype(), vlanId);
alshabib8ca53902014-10-07 13:11:17 -0700275 }
276
277 @Override
278 public boolean equals(Object obj) {
279 if (this == obj) {
280 return true;
281 }
282 if (obj instanceof ModVlanIdInstruction) {
283 ModVlanIdInstruction that = (ModVlanIdInstruction) obj;
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800284 return Objects.equals(vlanId, that.vlanId);
alshabib8ca53902014-10-07 13:11:17 -0700285 }
286 return false;
287 }
alshabib55a55d92014-09-16 11:59:31 -0700288 }
289
alshabib7410fea2014-09-16 13:48:39 -0700290 /**
291 * Represents a VLAN PCP modification instruction.
292 */
293 public static final class ModVlanPcpInstruction extends L2ModificationInstruction {
294
alshabib0ad43982015-05-07 13:43:13 -0700295 private static final byte MASK = 0x7;
296 private final byte vlanPcp;
alshabib7410fea2014-09-16 13:48:39 -0700297
alshabib0ad43982015-05-07 13:43:13 -0700298 ModVlanPcpInstruction(byte vlanPcp) {
299 this.vlanPcp = (byte) (vlanPcp & MASK);
alshabib7410fea2014-09-16 13:48:39 -0700300 }
301
302 @Override
alshabib35edb1a2014-09-16 17:44:44 -0700303 public L2SubType subtype() {
alshabib7410fea2014-09-16 13:48:39 -0700304 return L2SubType.VLAN_PCP;
305 }
306
alshabib0ad43982015-05-07 13:43:13 -0700307 public byte vlanPcp() {
alshabib7410fea2014-09-16 13:48:39 -0700308 return this.vlanPcp;
309 }
310
alshabib99b8fdc2014-09-25 14:30:22 -0700311 @Override
312 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800313 return subtype().toString() + SEPARATOR + Long.toHexString(vlanPcp);
alshabib99b8fdc2014-09-25 14:30:22 -0700314 }
315
alshabib8ca53902014-10-07 13:11:17 -0700316 @Override
317 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800318 return Objects.hash(type(), subtype(), vlanPcp);
alshabib8ca53902014-10-07 13:11:17 -0700319 }
320
321 @Override
322 public boolean equals(Object obj) {
323 if (this == obj) {
324 return true;
325 }
326 if (obj instanceof ModVlanPcpInstruction) {
327 ModVlanPcpInstruction that = (ModVlanPcpInstruction) obj;
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800328 return Objects.equals(vlanPcp, that.vlanPcp);
alshabib8ca53902014-10-07 13:11:17 -0700329 }
330 return false;
331 }
alshabib7410fea2014-09-16 13:48:39 -0700332 }
333
Saurav Dasfbe25c52015-03-04 11:12:00 -0800334 /**
335 * Represents a VLAN POP modification instruction.
Jian Liddfd2eb2016-05-19 11:32:18 -0700336 * @deprecated 1.6.0 Goldeneye release.
337 * Recommended to use ModVlanHeaderInstruction instead.
Saurav Dasfbe25c52015-03-04 11:12:00 -0800338 */
Jian Liddfd2eb2016-05-19 11:32:18 -0700339 @Deprecated
Saurav Dasfbe25c52015-03-04 11:12:00 -0800340 public static final class PopVlanInstruction extends L2ModificationInstruction {
341 private final L2SubType subtype;
342
343 PopVlanInstruction(L2SubType subType) {
344 this.subtype = subType;
345 }
346
347 @Override
348 public L2SubType subtype() {
349 return subtype;
350 }
351
352 @Override
353 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800354 return subtype().toString();
Saurav Dasfbe25c52015-03-04 11:12:00 -0800355 }
356
357 @Override
358 public int hashCode() {
359 return Objects.hash(type(), subtype);
360 }
361
362 @Override
363 public boolean equals(Object obj) {
364 if (this == obj) {
365 return true;
366 }
HIGUCHI Yuta7bb8b3f2015-03-13 23:21:37 -0700367 if (obj instanceof PopVlanInstruction) {
368 PopVlanInstruction that = (PopVlanInstruction) obj;
Saurav Dasfbe25c52015-03-04 11:12:00 -0800369 return Objects.equals(subtype, that.subtype);
370 }
371 return false;
372 }
373 }
alshabib55a55d92014-09-16 11:59:31 -0700374
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800375 /**
Jian Liddfd2eb2016-05-19 11:32:18 -0700376 * Represents a VLAN Header modification instruction.
377 */
378 public static final class ModVlanHeaderInstruction extends L2ModificationInstruction {
379
380 private final L2SubType subtype;
381 private EthType ethernetType; // Ethernet type value: 16 bits
382
383 ModVlanHeaderInstruction(L2SubType subType, EthType ethernetType) {
384 this.subtype = subType;
385 this.ethernetType = ethernetType;
386 }
387
388 ModVlanHeaderInstruction(L2SubType subType) {
389 this(subType, EthType.EtherType.UNKNOWN.ethType());
390 }
391
392 public EthType ethernetType() {
393 return ethernetType;
394 }
395
396 @Override
397 public L2SubType subtype() {
398 return subtype;
399 }
400
401 @Override
402 public String toString() {
403 return subtype().toString() + SEPARATOR + ethernetType;
404 }
405
406 @Override
407 public int hashCode() {
408 return Objects.hash(type(), subtype, ethernetType);
409 }
410
411 @Override
412 public boolean equals(Object obj) {
413 if (this == obj) {
414 return true;
415 }
416 if (obj instanceof ModVlanHeaderInstruction) {
417 ModVlanHeaderInstruction that = (ModVlanHeaderInstruction) obj;
418 return Objects.equals(subtype, that.subtype) &&
419 Objects.equals(this.ethernetType, that.ethernetType);
420 }
421 return false;
422 }
423 }
424
425 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800426 * Represents a MPLS label modification.
427 */
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800428 public static final class ModMplsLabelInstruction
429 extends L2ModificationInstruction {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800430
Michele Santuari4b6019e2014-12-19 11:31:45 +0100431 private final MplsLabel mplsLabel;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800432
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800433 ModMplsLabelInstruction(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800434 this.mplsLabel = mplsLabel;
435 }
436
Ray Milkey125572b2016-02-22 16:48:17 -0800437 public MplsLabel label() {
438 return mplsLabel;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800439 }
440
Ray Milkey125572b2016-02-22 16:48:17 -0800441 /**
442 * Extracts the MPLS label from the instruction.
443 *
444 * @return MPLS label
445 * @deprecated deprecated in 1.5.0 Falcon
446 */
447 @Deprecated
HIGUCHI Yuta60db9772015-08-26 17:49:34 -0700448 public MplsLabel mplsLabel() {
Ray Milkey125572b2016-02-22 16:48:17 -0800449 return label();
HIGUCHI Yuta60db9772015-08-26 17:49:34 -0700450 }
451
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800452 @Override
453 public L2SubType subtype() {
454 return L2SubType.MPLS_LABEL;
455 }
456
457 @Override
458 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800459 return subtype().toString() + SEPARATOR + mplsLabel;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800460 }
461
462 @Override
463 public int hashCode() {
Yuta HIGUCHIcca5e722015-02-05 14:00:41 -0800464 return Objects.hash(type(), subtype(), mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800465 }
466
467 @Override
468 public boolean equals(Object obj) {
469 if (this == obj) {
470 return true;
471 }
472 if (obj instanceof ModMplsLabelInstruction) {
473 ModMplsLabelInstruction that = (ModMplsLabelInstruction) obj;
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800474 return Objects.equals(mplsLabel, that.mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800475 }
476 return false;
477 }
478 }
sangho3f97a17d2015-01-29 22:56:29 -0800479
480 /**
Saurav Das73a7dd42015-08-19 22:20:31 -0700481 * Represents a MPLS BOS modification.
482 */
483 public static final class ModMplsBosInstruction
484 extends L2ModificationInstruction {
485
486 private final boolean mplsBos;
487
488 ModMplsBosInstruction(boolean mplsBos) {
489 this.mplsBos = mplsBos;
490 }
491
492 public boolean mplsBos() {
493 return mplsBos;
494 }
495
496 @Override
497 public L2SubType subtype() {
498 return L2SubType.MPLS_BOS;
499 }
500
501 @Override
502 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800503 return subtype().toString() + SEPARATOR + mplsBos;
Saurav Das73a7dd42015-08-19 22:20:31 -0700504 }
505
506 @Override
507 public int hashCode() {
508 return Objects.hash(type(), subtype(), mplsBos);
509 }
510
511 @Override
512 public boolean equals(Object obj) {
513 if (this == obj) {
514 return true;
515 }
516 if (obj instanceof ModMplsBosInstruction) {
517 ModMplsBosInstruction that = (ModMplsBosInstruction) obj;
518 return Objects.equals(mplsBos, that.mplsBos());
519 }
520 return false;
521 }
522 }
523
524 /**
Yuta HIGUCHIcca5e722015-02-05 14:00:41 -0800525 * Represents a MPLS TTL modification.
sangho3f97a17d2015-01-29 22:56:29 -0800526 */
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800527 public static final class ModMplsTtlInstruction
528 extends L2ModificationInstruction {
sangho3f97a17d2015-01-29 22:56:29 -0800529
Yuta HIGUCHI6a479642015-02-08 01:28:50 -0800530 ModMplsTtlInstruction() {
sangho3f97a17d2015-01-29 22:56:29 -0800531 }
532
533 @Override
534 public L2SubType subtype() {
535 return L2SubType.DEC_MPLS_TTL;
536 }
537
538 @Override
539 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800540 return subtype().toString();
sangho3f97a17d2015-01-29 22:56:29 -0800541 }
542
543 @Override
544 public int hashCode() {
Yuta HIGUCHIcca5e722015-02-05 14:00:41 -0800545 return Objects.hash(type(), subtype());
sangho3f97a17d2015-01-29 22:56:29 -0800546 }
547
548 @Override
549 public boolean equals(Object obj) {
550 if (this == obj) {
551 return true;
552 }
Yuta HIGUCHIcca5e722015-02-05 14:00:41 -0800553 if (obj instanceof ModMplsTtlInstruction) {
554 return true;
sangho3f97a17d2015-01-29 22:56:29 -0800555 }
556 return false;
557 }
558 }
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700559
560 /**
561 * Represents a Tunnel id modification.
562 */
563 public static final class ModTunnelIdInstruction
564 extends L2ModificationInstruction {
565
566 private final long tunnelId;
567
568 ModTunnelIdInstruction(long tunnelId) {
569 this.tunnelId = tunnelId;
570 }
571
572 public long tunnelId() {
573 return this.tunnelId;
574 }
575
576 @Override
577 public L2SubType subtype() {
578 return L2SubType.TUNNEL_ID;
579 }
580
581 @Override
582 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -0800583 return subtype().toString() + SEPARATOR + Long.toHexString(tunnelId);
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700584 }
585
586 @Override
587 public int hashCode() {
588 return Objects.hash(type(), subtype(), tunnelId);
589 }
590
591 @Override
592 public boolean equals(Object obj) {
593 if (this == obj) {
594 return true;
595 }
596 if (obj instanceof ModTunnelIdInstruction) {
597 ModTunnelIdInstruction that = (ModTunnelIdInstruction) obj;
598 return Objects.equals(tunnelId, that.tunnelId);
599 }
600 return false;
601 }
602 }
alshabib55a55d92014-09-16 11:59:31 -0700603}