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