blob: 569a28a51c6d6ba0f2b113bec2a66cec39f1d5b3 [file] [log] [blame]
Phanendra Manda37b97fb2015-08-15 02:04:24 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Phanendra Manda37b97fb2015-08-15 02:04:24 +05303 *
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
7 *
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.
15 */
16package org.onosproject.provider.pcep.tunnel.impl;
17
18import java.util.Objects;
19
20import org.onosproject.incubator.net.tunnel.Tunnel;
21import org.onosproject.net.ElementId;
22import org.onosproject.net.Path;
Avantika-Huawei56c11842016-04-28 00:56:56 +053023import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
Phanendra Manda37b97fb2015-08-15 02:04:24 +053024
25import com.google.common.base.MoreObjects;
26
27/**
28 * To store all tunnel related information from Core and Path computation client.
29 */
30public class PcepTunnelData {
31
32 private Tunnel tunnel;
33 private Path path;
34 private int plspId;
35 private ElementId elementId;
36 private RequestType requestType;
37 private boolean rptFlag;
38
39 // data need to store from LSP object
40 private boolean lspAFlag;
41 private boolean lspDFlag;
42 private byte lspOFlag;
43 private short tunnelId;
44 private int extTunnelId;
45 private short lspId;
Avantika-Huawei56c11842016-04-28 00:56:56 +053046 private StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv;
Phanendra Manda37b97fb2015-08-15 02:04:24 +053047
48 /**
49 * Default constructor.
50 */
51 public PcepTunnelData() {
52 this.elementId = null;
53 this.tunnel = null;
54 this.path = null;
55 this.requestType = null;
56 this.rptFlag = false;
57 this.plspId = 0;
58 }
59
60 /**
61 * Constructor to initialize Tunnel, Path and Request type.
62 *
63 * @param tunnel mpls tunnel
64 * @param path Path in network
65 * @param requestType request type for tunnel
66 */
67 public PcepTunnelData(Tunnel tunnel, Path path, RequestType requestType) {
68 this.tunnel = tunnel;
69 this.path = path;
70 this.requestType = requestType;
71 }
72
73 /**
74 * Constructor to initialize ElemendId, Tunnel, Path and Request type.
75 *
76 * @param elementId Ip element id
77 * @param tunnel mpls tunnel
78 * @param path Path in network
79 * @param requestType request type for tunnel
80 */
81 public PcepTunnelData(ElementId elementId, Tunnel tunnel, Path path, RequestType requestType) {
82 this.elementId = elementId;
83 this.tunnel = tunnel;
84 this.path = path;
85 this.requestType = requestType;
86 }
87
88 /**
89 * Constructor to initialize Tunnel and Request type.
90 *
91 * @param tunnel Tunnel from core
92 * @param requestType request type for tunnel
93 */
94 public PcepTunnelData(Tunnel tunnel, RequestType requestType) {
95 this.tunnel = tunnel;
96 this.requestType = requestType;
97 }
98
99 /**
100 * Constructor to initialize ElementId, Tunnel and Request type.
101 *
102 * @param elementId Ip element id
103 * @param tunnel mpls tunnel
104 * @param requestType request type for tunnel
105 */
106 public PcepTunnelData(ElementId elementId, Tunnel tunnel, RequestType requestType) {
107 this.elementId = elementId;
108 this.tunnel = tunnel;
109 this.requestType = requestType;
110 }
111
112 /**
113 * Sets ip element id.
114 *
115 * @param elementId Ip element id
116 */
117 public void setElementId(ElementId elementId) {
118 this.elementId = elementId;
119 }
120
121 /**
122 * Sets tunnel.
123 *
124 * @param tunnel mpls tunnel
125 */
126 public void setTunnel(Tunnel tunnel) {
127 this.tunnel = tunnel;
128 }
129
130 /**
131 * Sets Path.
132 *
133 * @param path Path in network
134 */
135 public void setPath(Path path) {
136 this.path = path;
137 }
138
139 /**
140 * Request type for tunnel.
141 *
142 * @param requestType request type for tunnel
143 */
144 public void setRequestType(RequestType requestType) {
145 this.requestType = requestType;
146 }
147
148 /**
149 * Sets plspid generated from pcc.
150 *
151 * @param plspId plsp identifier
152 */
153 public void setPlspId(int plspId) {
154 this.plspId = plspId;
155 }
156
157 /**
158 * Sets A flag from lsp object.
159 *
160 * @param value A flag value
161 */
162 public void setLspAFlag(boolean value) {
163 this.lspAFlag = value;
164 }
165
166 /**
167 * Sets OF flag from lsp object.
168 *
169 * @param value OF flag value
170 */
171 public void setLspOFlag(byte value) {
172 this.lspOFlag = value;
173 }
174
175 /**
176 * Sets tunnel id from PCC.
177 *
178 * @param value tunnel id value
179 */
180 public void setTunnelId(short value) {
181 this.tunnelId = value;
182 }
183
184 /**
185 * Sets extended tunnel id from PCC.
186 *
187 * @param value extended tunnel id value
188 */
189 public void setExtTunnelId(int value) {
190 this.extTunnelId = value;
191 }
192
193 /**
194 * Sets lsp id from pcc.
195 *
196 * @param value lsp id
197 */
198 public void setLspId(short value) {
199 this.lspId = value;
200 }
201
202 /**
203 * Sets statefulIpv4Identifiers tlv.
204 * @param value statefulIpv4Identifiers tlv
205 */
Avantika-Huawei56c11842016-04-28 00:56:56 +0530206 public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentifiersTlv value) {
Phanendra Manda37b97fb2015-08-15 02:04:24 +0530207 this.statefulIpv4IndentifierTlv = value;
208 }
209
210 /**
211 * Sets report flag.
212 *
213 * @param rptFlag report flag
214 */
215 public void setRptFlag(boolean rptFlag) {
216 this.rptFlag = rptFlag;
217 }
218
219 /**
220 * Sets D flag from lsp object.
221 *
222 * @param value D flag value
223 */
224 public void setLspDFlag(boolean value) {
225 this.lspDFlag = value;
226 }
227
228 /**
229 * To get Ip element id.
230 *
231 * @return Ip elemend id
232 */
233 public ElementId elementId() {
234 return this.elementId;
235 }
236
237 /**
238 * To get Tunnel.
239 *
240 * @return tunnel
241 */
242 public Tunnel tunnel() {
243 return this.tunnel;
244 }
245
246 /**
247 * To get Path.
248 *
249 * @return path
250 */
251 public Path path() {
252 return this.path;
253 }
254
255 /**
256 * To get request type.
257 *
258 * @return request type
259 */
260 public RequestType requestType() {
261 return this.requestType;
262 }
263
264 /**
265 * To get pLspId.
266 *
267 * @return pLspId
268 */
269 public int plspId() {
270 return this.plspId;
271 }
272
273 /**
274 * To get A flag.
275 *
276 * @return A flag
277 */
278 public boolean lspAFlag() {
279 return this.lspAFlag;
280 }
281
282 /**
283 * To get OF flag.
284 *
285 * @return OF flag
286 */
287 public byte lspOFlag() {
288 return this.lspOFlag;
289 }
290
291 /**
292 * To get tunnel id.
293 *
294 * @return tunnel id
295 */
296 public short tunnelId() {
297 return this.tunnelId;
298 }
299
300 /**
301 * To get extended tunnel id.
302 *
303 * @return extended tunnel id
304 */
305 public int extTunnelId() {
306 return this.extTunnelId;
307 }
308
309 /**
310 * To get pLspId.
311 *
312 * @return pLspId
313 */
314 public short lspId() {
315 return this.lspId;
316 }
317
318 /**
319 * To get D Flag.
320 *
321 * @return d flag
322 */
323 public boolean lspDFlag() {
324 return this.lspDFlag;
325 }
326
327 /**
328 * To get statefulIpv4Indentifier tlv.
329 *
330 * @return statefulIpv4Indentifier tlv
331 */
Avantika-Huawei56c11842016-04-28 00:56:56 +0530332 public StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv() {
Phanendra Manda37b97fb2015-08-15 02:04:24 +0530333 return this.statefulIpv4IndentifierTlv;
334 }
335
336 /**
337 * To get report flag.
338 *
339 * @return report flag
340 */
341 public boolean rptFlag() {
342 return this.rptFlag;
343 }
344
345 @Override
346 public boolean equals(Object obj) {
347 if (this == obj) {
348 return true;
349 }
350
351 if (obj instanceof PcepTunnelData) {
352 PcepTunnelData other = (PcepTunnelData) obj;
353 return Objects.equals(tunnel, other.tunnel)
354 && Objects.equals(path, other.path)
355 && Objects.equals(plspId, other.plspId)
356 && Objects.equals(elementId, other.elementId)
357 && Objects.equals(requestType, other.requestType)
358 && Objects.equals(rptFlag, other.rptFlag)
359 && Objects.equals(lspAFlag, other.lspAFlag)
360 && Objects.equals(lspDFlag, other.lspDFlag)
361 && Objects.equals(lspOFlag, other.lspOFlag)
362 && Objects.equals(tunnelId, other.tunnelId)
363 && Objects.equals(extTunnelId, other.extTunnelId)
364 && Objects.equals(lspId, other.lspId)
365 && Objects.equals(statefulIpv4IndentifierTlv, other.statefulIpv4IndentifierTlv);
366 }
367
368 return false;
369 }
370
371 @Override
372 public int hashCode() {
373 return Objects.hash(tunnel, path, plspId, elementId, requestType, rptFlag, lspAFlag,
374 lspDFlag, lspOFlag, tunnelId, extTunnelId, lspId, statefulIpv4IndentifierTlv);
375 }
376
377 @Override
378 public String toString() {
379 return MoreObjects.toStringHelper(getClass()).add("Tunnel", tunnel)
380 .add("Path", path).add("PlspId", plspId).add("ElementId", elementId)
381 .add("RequestType", requestType).add("RptFlag", rptFlag).add("LspAFlag", lspAFlag)
382 .add("LspDFlag", lspDFlag).add("LspOFlag", lspOFlag).add("TunnelId", tunnelId)
383 .add("ExtTunnelid", extTunnelId).add("LspId", lspId)
384 .add("StatefulIpv4IndentifierTlv", statefulIpv4IndentifierTlv).toString();
385 }
386}