2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.pcep.tlv;
10 import org.opendaylight.protocol.concepts.IPv4Address;
11 import org.opendaylight.protocol.pcep.PCEPTlv;
14 * Structure of No Path Vector TLV.
16 * @see <a href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-protection-00#section-4.3"
19 public class ByPassTlv implements PCEPTlv {
21 private static final long serialVersionUID = 5879892226322401651L;
23 private final boolean nodeProtection;
25 private final boolean localProtectionInUse;
27 private final IPv4Address bypassAddress;
30 * Constructs ByPass Tlv.
32 * @param nodeProtection
34 * @param localProtectionInUse
36 * @param bypassAddress
39 public ByPassTlv(final boolean nodeProtection, final boolean localProtectionInUse,
40 final IPv4Address bypassAddress) {
41 this.nodeProtection = nodeProtection;
42 this.localProtectionInUse = localProtectionInUse;
43 this.bypassAddress = bypassAddress;
47 * The N Flag indicates whether the Bypass is used for node-protection.
48 * If the N flag is set to 1, the Bypass is used for node-protection.
49 * If the N flag is 0, the Bypass is used for link-protection.
51 * @return the nodeProtection
53 public final boolean isNodeProtection() {
54 return this.nodeProtection;
58 * The I Flag indicates that local repair mechanism is in use.
60 * @return the localProtectionInUse
62 public final boolean isLocalProtectionInUse() {
63 return this.localProtectionInUse;
67 * For link protection, the Bypass IPv4 Address is
68 * the nexthop address of the protected link in the paths of the
69 * protected LSPs. For node protection, the Bypass IPv4 Address is
70 * the node addresses of the protected node.
72 * @return the bypassAddress
74 public final IPv4Address getBypassAddress() {
75 return this.bypassAddress;
79 * @see java.lang.Object#toString()
82 public String toString() {
83 final StringBuilder builder = new StringBuilder();
84 builder.append("ByPassTlv [nodeProtection=");
85 builder.append(this.nodeProtection);
86 builder.append(", localProtectionInUse=");
87 builder.append(this.localProtectionInUse);
88 builder.append(", bypassAddress=");
89 builder.append(this.bypassAddress);
91 return builder.toString();
95 * @see java.lang.Object#hashCode()
98 public int hashCode() {
101 result = prime * result
102 + ((this.bypassAddress == null) ? 0 : this.bypassAddress.hashCode());
103 result = prime * result + (this.localProtectionInUse ? 1231 : 1237);
104 result = prime * result + (this.nodeProtection ? 1231 : 1237);
109 * @see java.lang.Object#equals(java.lang.Object)
112 public boolean equals(Object obj) {
117 if (!(obj instanceof ByPassTlv))
119 final ByPassTlv other = (ByPassTlv) obj;
120 if (this.bypassAddress == null) {
121 if (other.bypassAddress != null)
123 } else if (!this.bypassAddress.equals(other.bypassAddress))
125 if (this.localProtectionInUse != other.localProtectionInUse)
127 if (this.nodeProtection != other.nodeProtection)