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.object;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.protocol.pcep.PCEPObject;
14 import org.opendaylight.protocol.pcep.PCEPTlv;
15 import com.google.common.base.Objects.ToStringHelper;
18 * Structure for PCEP LSPA Object.
20 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.11">PCEP LSPA
23 * href="http://tools.ietf.org/html/rfc3209#section-4.7">SessionAttribute
26 * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-protection-00#section-4.1">
27 * The Standby flag in the LSPA object</a>
29 public class PCEPLspaObject extends PCEPObject {
31 private final long excludedAny;
33 private final long includeAny;
35 private final long includeAll;
37 private final short setupPriority;
39 private final short holdingPriority;
41 private final boolean standByPath;
43 private final boolean localProtected;
45 private final List<PCEPTlv> tlvs;
48 * Constructs object only with mandatory objects.
56 * @param setupPriority
58 * @param holdingPriority
62 * @param localProtected
69 public PCEPLspaObject(long excludedAny, long includeAny, long includeAll, short setupPriority, short holdingPriority, boolean standByPath,
70 boolean localProtected, boolean processed, boolean ignored) {
71 this(excludedAny, includeAny, includeAll, setupPriority, holdingPriority, standByPath, localProtected, null, processed, ignored);
75 * Constructs object also with optional objects.
83 * @param setupPriority
85 * @param holdingPriority
87 * @param localProtected
96 public PCEPLspaObject(long excludedAny, long includeAny, long includeAll, short setupPriority, short holdingPriority, boolean standByPath,
97 boolean localProtected, List<PCEPTlv> tlvs, boolean processed, boolean ignored) {
98 super(processed, ignored);
99 this.excludedAny = excludedAny;
100 this.includeAny = includeAny;
101 this.includeAll = includeAll;
102 this.setupPriority = setupPriority;
103 this.holdingPriority = holdingPriority;
104 this.standByPath = standByPath;
105 this.localProtected = localProtected;
109 this.tlvs = Collections.emptyList();
113 * A 32-bit vector representing a set of attribute filters associated with a
114 * tunnel any of which renders a link unacceptable.
118 public long getExcludeAny() {
119 return this.excludedAny;
123 * A 32-bit vector representing a set of attribute filters associated with a
124 * tunnel any of which renders a link acceptable (with respect to this
125 * test). A null set (all bits set to zero) automatically passes.
129 public long getIncludeAny() {
130 return this.includeAny;
134 * A 32-bit vector representing a set of attribute filters associated with a
135 * tunnel all of which must be present for a link to be acceptable (with
136 * respect to this test). A null set (all bits set to zero) automatically
141 public long getIncludeAll() {
142 return this.includeAll;
146 * The priority of TE LSP with respect to taking resources, in the range of
147 * 0 to 7 (validation not included). The value 0 is the highest priority.
148 * The Setup Priority is used in deciding whether this session can preempt
153 public short getSetupPriority() {
154 return this.setupPriority;
158 * The priority of TE LSP with respect to holding resources, in the range of
159 * 0 to 7 (validation not included). The value 0 is the highest priority.
160 * Holding Priority is used in deciding whether this session can be
161 * preempted by another session.
165 public short getHoldingPriority() {
166 return this.holdingPriority;
170 * Corresponds to the "Local Protection Desired" bit ([RFC3209]) of
171 * SESSION-ATTRIBUTE Object. When set, this means that the computed path
172 * must include links protected with Fast REroute as defined in [RFC4090].
176 public boolean isLocalProtected() {
177 return this.localProtected;
181 * The protection path setup regimen (standby or not) is specified in the
182 * path using a new per-path flag in the LSPA object, the S (standby) flag
186 public boolean isStandByPath() {
187 return this.standByPath;
191 * Gets list of {@link PCEPTlv}
193 * @return List<PCEPTlv>. Can't be null, but may be empty.
195 public List<PCEPTlv> getTlvs() {
202 * @see java.lang.Object#hashCode()
205 public int hashCode() {
206 final int prime = 31;
207 int result = super.hashCode();
208 result = prime * result + (int) (this.excludedAny ^ (this.excludedAny >>> 32));
209 result = prime * result + this.holdingPriority;
210 result = prime * result + (int) (this.includeAll ^ (this.includeAll >>> 32));
211 result = prime * result + (int) (this.includeAny ^ (this.includeAny >>> 32));
212 result = prime * result + (this.localProtected ? 1231 : 1237);
213 result = prime * result + this.setupPriority;
214 result = prime * result + (this.standByPath ? 1231 : 1237);
215 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
222 * @see java.lang.Object#equals(java.lang.Object)
225 public boolean equals(Object obj) {
228 if (!super.equals(obj))
230 if (!(obj instanceof PCEPLspaObject))
232 final PCEPLspaObject other = (PCEPLspaObject) obj;
233 if (this.excludedAny != other.excludedAny)
235 if (this.holdingPriority != other.holdingPriority)
237 if (this.includeAll != other.includeAll)
239 if (this.includeAny != other.includeAny)
241 if (this.localProtected != other.localProtected)
243 if (this.setupPriority != other.setupPriority)
245 if (this.standByPath != other.standByPath)
247 if (this.tlvs == null) {
248 if (other.tlvs != null)
250 } else if (!this.tlvs.equals(other.tlvs))
256 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
257 toStringHelper.add("excludedAny", this.excludedAny);
258 toStringHelper.add("includeAny", this.includeAny);
259 toStringHelper.add("includeAll", this.includeAll);
260 toStringHelper.add("setupPriority", this.setupPriority);
261 toStringHelper.add("holdingPriority", this.holdingPriority);
262 toStringHelper.add("standByPath", this.standByPath);
263 toStringHelper.add("localProtected", this.localProtected);
264 toStringHelper.add("tlvs", this.tlvs);
265 return super.addToStringAttributes(toStringHelper);