Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow.instructions; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 17 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 20 | import java.util.Objects; |
| 21 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 22 | import org.onlab.packet.MacAddress; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 23 | import org.onlab.packet.MplsLabel; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 24 | import org.onlab.packet.VlanId; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Abstraction of a single traffic treatment step. |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 28 | */ |
| 29 | public abstract class L2ModificationInstruction implements Instruction { |
| 30 | |
| 31 | /** |
| 32 | * Represents the type of traffic treatment. |
| 33 | */ |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 34 | public enum L2SubType { |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Ether src modification. |
| 37 | */ |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 38 | ETH_SRC, |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Ether dst modification. |
| 42 | */ |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 43 | ETH_DST, |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 46 | * VLAN id modification. |
| 47 | */ |
| 48 | VLAN_ID, |
| 49 | |
| 50 | /** |
| 51 | * VLAN priority modification. |
| 52 | */ |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 53 | VLAN_PCP, |
| 54 | |
| 55 | /** |
| 56 | * MPLS Label modification. |
| 57 | */ |
| 58 | MPLS_LABEL, |
| 59 | |
| 60 | /** |
| 61 | * MPLS Push modification. |
| 62 | */ |
| 63 | MPLS_PUSH, |
| 64 | |
| 65 | /** |
| 66 | * MPLS Pop modification. |
| 67 | */ |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 68 | MPLS_POP, |
| 69 | |
| 70 | /** |
| 71 | * MPLS TTL modification. |
| 72 | */ |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame^] | 73 | DEC_MPLS_TTL, |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 74 | |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame^] | 75 | /** |
| 76 | * VLAN Pop modification. |
| 77 | */ |
| 78 | VLAN_POP |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | // TODO: Create factory class 'Instructions' that will have various factory |
| 82 | // to create specific instructions. |
| 83 | |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 84 | public abstract L2SubType subtype(); |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 85 | |
| 86 | @Override |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 87 | public final Type type() { |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 88 | return Type.L2MODIFICATION; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Represents a L2 src/dst modification instruction. |
| 93 | */ |
| 94 | public static final class ModEtherInstruction extends L2ModificationInstruction { |
| 95 | |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 96 | private final L2SubType subtype; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 97 | private final MacAddress mac; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 98 | |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 99 | ModEtherInstruction(L2SubType subType, MacAddress addr) { |
alshabib | 64231f6 | 2014-09-16 17:58:36 -0700 | [diff] [blame] | 100 | |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 101 | this.subtype = subType; |
| 102 | this.mac = addr; |
| 103 | } |
| 104 | |
| 105 | @Override |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 106 | public L2SubType subtype() { |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 107 | return this.subtype; |
| 108 | } |
| 109 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 110 | public MacAddress mac() { |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 111 | return this.mac; |
| 112 | } |
| 113 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 114 | @Override |
| 115 | public String toString() { |
| 116 | return toStringHelper(subtype().toString()) |
| 117 | .add("mac", mac).toString(); |
| 118 | } |
| 119 | |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 120 | @Override |
| 121 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 122 | return Objects.hash(type(), subtype, mac); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | @Override |
| 126 | public boolean equals(Object obj) { |
| 127 | if (this == obj) { |
| 128 | return true; |
| 129 | } |
| 130 | if (obj instanceof ModEtherInstruction) { |
| 131 | ModEtherInstruction that = (ModEtherInstruction) obj; |
| 132 | return Objects.equals(mac, that.mac) && |
| 133 | Objects.equals(subtype, that.subtype); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 134 | } |
| 135 | return false; |
| 136 | } |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 139 | // TODO This instruction is reused for Pop-Mpls. Consider renaming. |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 140 | public static final class PushHeaderInstructions extends |
| 141 | L2ModificationInstruction { |
| 142 | |
| 143 | private final L2SubType subtype; |
Yuta HIGUCHI | 32a53c5 | 2015-02-08 01:25:40 -0800 | [diff] [blame] | 144 | private final short ethernetType; // uint16_t |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 145 | |
Yuta HIGUCHI | 32a53c5 | 2015-02-08 01:25:40 -0800 | [diff] [blame] | 146 | PushHeaderInstructions(L2SubType subType, short ethernetType) { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 147 | this.subtype = subType; |
| 148 | this.ethernetType = ethernetType; |
| 149 | } |
| 150 | |
Yuta HIGUCHI | 32a53c5 | 2015-02-08 01:25:40 -0800 | [diff] [blame] | 151 | public int ethernetType() { |
| 152 | return Short.toUnsignedInt(ethernetType); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public L2SubType subtype() { |
| 157 | return this.subtype; |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public String toString() { |
Yuta HIGUCHI | 32a53c5 | 2015-02-08 01:25:40 -0800 | [diff] [blame] | 162 | return toStringHelper(subtype().toString()) |
| 163 | .add("ethernetType", String.format("0x%04x", ethernetType())) |
| 164 | .toString(); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | @Override |
| 168 | public int hashCode() { |
Yuta HIGUCHI | 32a53c5 | 2015-02-08 01:25:40 -0800 | [diff] [blame] | 169 | return Objects.hash(type(), subtype, ethernetType); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | @Override |
| 173 | public boolean equals(Object obj) { |
| 174 | if (this == obj) { |
| 175 | return true; |
| 176 | } |
| 177 | if (obj instanceof PushHeaderInstructions) { |
| 178 | PushHeaderInstructions that = (PushHeaderInstructions) obj; |
Yuta HIGUCHI | 32a53c5 | 2015-02-08 01:25:40 -0800 | [diff] [blame] | 179 | return Objects.equals(subtype, that.subtype) && |
| 180 | Objects.equals(this.ethernetType, that.ethernetType); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 181 | } |
| 182 | return false; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | |
| 187 | |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 188 | /** |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 189 | * Represents a VLAN id modification instruction. |
| 190 | */ |
| 191 | public static final class ModVlanIdInstruction extends L2ModificationInstruction { |
| 192 | |
Ray Milkey | 7808105 | 2014-11-05 10:38:12 -0800 | [diff] [blame] | 193 | private final VlanId vlanId; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 194 | |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 195 | ModVlanIdInstruction(VlanId vlanId) { |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 196 | this.vlanId = vlanId; |
| 197 | } |
| 198 | |
| 199 | @Override |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 200 | public L2SubType subtype() { |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 201 | return L2SubType.VLAN_ID; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 204 | public VlanId vlanId() { |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 205 | return this.vlanId; |
| 206 | } |
| 207 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 208 | @Override |
| 209 | public String toString() { |
| 210 | return toStringHelper(subtype().toString()) |
| 211 | .add("id", vlanId).toString(); |
| 212 | } |
| 213 | |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 214 | @Override |
| 215 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 216 | return Objects.hash(type(), subtype(), vlanId); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | @Override |
| 220 | public boolean equals(Object obj) { |
| 221 | if (this == obj) { |
| 222 | return true; |
| 223 | } |
| 224 | if (obj instanceof ModVlanIdInstruction) { |
| 225 | ModVlanIdInstruction that = (ModVlanIdInstruction) obj; |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 226 | return Objects.equals(vlanId, that.vlanId); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 227 | } |
| 228 | return false; |
| 229 | } |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 230 | } |
| 231 | |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 232 | /** |
| 233 | * Represents a VLAN PCP modification instruction. |
| 234 | */ |
| 235 | public static final class ModVlanPcpInstruction extends L2ModificationInstruction { |
| 236 | |
Ray Milkey | 7808105 | 2014-11-05 10:38:12 -0800 | [diff] [blame] | 237 | private final Byte vlanPcp; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 238 | |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 239 | ModVlanPcpInstruction(Byte vlanPcp) { |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 240 | this.vlanPcp = vlanPcp; |
| 241 | } |
| 242 | |
| 243 | @Override |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 244 | public L2SubType subtype() { |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 245 | return L2SubType.VLAN_PCP; |
| 246 | } |
| 247 | |
| 248 | public Byte vlanPcp() { |
| 249 | return this.vlanPcp; |
| 250 | } |
| 251 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 252 | @Override |
| 253 | public String toString() { |
| 254 | return toStringHelper(subtype().toString()) |
| 255 | .add("pcp", Long.toHexString(vlanPcp)).toString(); |
| 256 | } |
| 257 | |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 258 | @Override |
| 259 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 260 | return Objects.hash(type(), subtype(), vlanPcp); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | @Override |
| 264 | public boolean equals(Object obj) { |
| 265 | if (this == obj) { |
| 266 | return true; |
| 267 | } |
| 268 | if (obj instanceof ModVlanPcpInstruction) { |
| 269 | ModVlanPcpInstruction that = (ModVlanPcpInstruction) obj; |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 270 | return Objects.equals(vlanPcp, that.vlanPcp); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 271 | } |
| 272 | return false; |
| 273 | } |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame^] | 276 | /** |
| 277 | * Represents a VLAN POP modification instruction. |
| 278 | */ |
| 279 | public static final class PopVlanInstruction extends L2ModificationInstruction { |
| 280 | private final L2SubType subtype; |
| 281 | |
| 282 | PopVlanInstruction(L2SubType subType) { |
| 283 | this.subtype = subType; |
| 284 | } |
| 285 | |
| 286 | @Override |
| 287 | public L2SubType subtype() { |
| 288 | return subtype; |
| 289 | } |
| 290 | |
| 291 | @Override |
| 292 | public String toString() { |
| 293 | return toStringHelper(subtype().toString()) |
| 294 | .toString(); |
| 295 | } |
| 296 | |
| 297 | @Override |
| 298 | public int hashCode() { |
| 299 | return Objects.hash(type(), subtype); |
| 300 | } |
| 301 | |
| 302 | @Override |
| 303 | public boolean equals(Object obj) { |
| 304 | if (this == obj) { |
| 305 | return true; |
| 306 | } |
| 307 | if (obj instanceof PushHeaderInstructions) { |
| 308 | PushHeaderInstructions that = (PushHeaderInstructions) obj; |
| 309 | return Objects.equals(subtype, that.subtype); |
| 310 | } |
| 311 | return false; |
| 312 | } |
| 313 | } |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 314 | |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 315 | /** |
| 316 | * Represents a MPLS label modification. |
| 317 | */ |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 318 | public static final class ModMplsLabelInstruction |
| 319 | extends L2ModificationInstruction { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 320 | |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 321 | private final MplsLabel mplsLabel; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 322 | |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 323 | ModMplsLabelInstruction(MplsLabel mplsLabel) { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 324 | this.mplsLabel = mplsLabel; |
| 325 | } |
| 326 | |
| 327 | public Integer label() { |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 328 | return mplsLabel.toInt(); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | @Override |
| 332 | public L2SubType subtype() { |
| 333 | return L2SubType.MPLS_LABEL; |
| 334 | } |
| 335 | |
| 336 | @Override |
| 337 | public String toString() { |
Pavlin Radoslavov | 3ebe170 | 2015-02-17 09:53:17 -0800 | [diff] [blame] | 338 | return toStringHelper(subtype().toString()) |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 339 | .add("mpls", mplsLabel).toString(); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public int hashCode() { |
Yuta HIGUCHI | cca5e72 | 2015-02-05 14:00:41 -0800 | [diff] [blame] | 344 | return Objects.hash(type(), subtype(), mplsLabel); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public boolean equals(Object obj) { |
| 349 | if (this == obj) { |
| 350 | return true; |
| 351 | } |
| 352 | if (obj instanceof ModMplsLabelInstruction) { |
| 353 | ModMplsLabelInstruction that = (ModMplsLabelInstruction) obj; |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 354 | return Objects.equals(mplsLabel, that.mplsLabel); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 355 | } |
| 356 | return false; |
| 357 | } |
| 358 | } |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 359 | |
| 360 | /** |
Yuta HIGUCHI | cca5e72 | 2015-02-05 14:00:41 -0800 | [diff] [blame] | 361 | * Represents a MPLS TTL modification. |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 362 | */ |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 363 | public static final class ModMplsTtlInstruction |
| 364 | extends L2ModificationInstruction { |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 365 | |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 366 | ModMplsTtlInstruction() { |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public L2SubType subtype() { |
| 371 | return L2SubType.DEC_MPLS_TTL; |
| 372 | } |
| 373 | |
| 374 | @Override |
| 375 | public String toString() { |
Yuta HIGUCHI | cca5e72 | 2015-02-05 14:00:41 -0800 | [diff] [blame] | 376 | return toStringHelper(subtype().toString()) |
| 377 | .toString(); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | @Override |
| 381 | public int hashCode() { |
Yuta HIGUCHI | cca5e72 | 2015-02-05 14:00:41 -0800 | [diff] [blame] | 382 | return Objects.hash(type(), subtype()); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | @Override |
| 386 | public boolean equals(Object obj) { |
| 387 | if (this == obj) { |
| 388 | return true; |
| 389 | } |
Yuta HIGUCHI | cca5e72 | 2015-02-05 14:00:41 -0800 | [diff] [blame] | 390 | if (obj instanceof ModMplsTtlInstruction) { |
| 391 | return true; |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 392 | } |
| 393 | return false; |
| 394 | } |
| 395 | } |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 396 | } |