summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java
blob: f796a2de0f245f21196397d64860acedd8047119 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/*
 * Copyright 2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.provider.pcep.tunnel.impl;

import java.util.Objects;

import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.net.ElementId;
import org.onosproject.net.Path;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;

import com.google.common.base.MoreObjects;

/**
 * To store all tunnel related information from Core and Path computation client.
 */
public class PcepTunnelData {

    private Tunnel tunnel;
    private Path path;
    private int plspId;
    private ElementId elementId;
    private RequestType requestType;
    private boolean rptFlag;

    // data need to store from LSP object
    private boolean lspAFlag;
    private boolean lspDFlag;
    private byte lspOFlag;
    private short tunnelId;
    private int extTunnelId;
    private short lspId;
    private StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv;

    /**
     * Default constructor.
     */
    public PcepTunnelData() {
        this.elementId = null;
        this.tunnel = null;
        this.path = null;
        this.requestType = null;
        this.rptFlag = false;
        this.plspId = 0;
    }

    /**
     * Constructor to initialize Tunnel, Path and Request type.
     *
     * @param tunnel mpls tunnel
     * @param path Path in network
     * @param requestType request type for tunnel
     */
    public PcepTunnelData(Tunnel tunnel, Path path, RequestType requestType) {
        this.tunnel = tunnel;
        this.path = path;
        this.requestType = requestType;
    }

    /**
     * Constructor to initialize ElemendId, Tunnel, Path and Request type.
     *
     * @param elementId Ip element id
     * @param tunnel mpls tunnel
     * @param path Path in network
     * @param requestType request type for tunnel
     */
    public PcepTunnelData(ElementId elementId, Tunnel tunnel, Path path, RequestType requestType) {
        this.elementId = elementId;
        this.tunnel = tunnel;
        this.path = path;
        this.requestType = requestType;
    }

    /**
     * Constructor to initialize Tunnel and Request type.
     *
     * @param tunnel Tunnel from core
     * @param requestType request type for tunnel
     */
    public PcepTunnelData(Tunnel tunnel, RequestType requestType) {
        this.tunnel = tunnel;
        this.requestType = requestType;
    }

    /**
     * Constructor to initialize ElementId, Tunnel and Request type.
     *
     * @param elementId Ip element id
     * @param tunnel mpls tunnel
     * @param requestType request type for tunnel
     */
    public PcepTunnelData(ElementId elementId, Tunnel tunnel, RequestType requestType) {
        this.elementId = elementId;
        this.tunnel = tunnel;
        this.requestType = requestType;
    }

    /**
     * Sets ip element id.
     *
     * @param elementId Ip element id
     */
    public void setElementId(ElementId elementId) {
        this.elementId = elementId;
    }

    /**
     * Sets tunnel.
     *
     * @param tunnel mpls tunnel
     */
    public void setTunnel(Tunnel tunnel) {
        this.tunnel = tunnel;
    }

    /**
     * Sets Path.
     *
     * @param path Path in network
     */
    public void setPath(Path path) {
        this.path = path;
    }

    /**
     * Request type for tunnel.
     *
     * @param requestType request type for tunnel
     */
    public void setRequestType(RequestType requestType) {
        this.requestType = requestType;
    }

    /**
     * Sets plspid generated from pcc.
     *
     * @param plspId plsp identifier
     */
    public void setPlspId(int plspId) {
        this.plspId = plspId;
    }

    /**
     * Sets A flag from lsp object.
     *
     * @param value A flag value
     */
    public void setLspAFlag(boolean value) {
        this.lspAFlag = value;
    }

    /**
     * Sets OF flag from lsp object.
     *
     * @param value OF flag value
     */
    public void setLspOFlag(byte value) {
        this.lspOFlag = value;
    }

    /**
     * Sets tunnel id from PCC.
     *
     * @param value tunnel id value
     */
    public void setTunnelId(short value) {
        this.tunnelId = value;
    }

    /**
     * Sets extended tunnel id from PCC.
     *
     * @param value extended tunnel id value
     */
    public void setExtTunnelId(int value) {
        this.extTunnelId = value;
    }

    /**
     * Sets lsp id from pcc.
     *
     * @param value lsp id
     */
    public void setLspId(short value) {
        this.lspId = value;
    }

    /**
     * Sets statefulIpv4Identifiers tlv.
     * @param value statefulIpv4Identifiers tlv
     */
    public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentidiersTlv value) {
        this.statefulIpv4IndentifierTlv = value;
    }

    /**
     * Sets report flag.
     *
     * @param rptFlag report flag
     */
    public void setRptFlag(boolean rptFlag) {
        this.rptFlag = rptFlag;
    }

    /**
     * Sets D flag from lsp object.
     *
     * @param value D flag value
     */
    public void setLspDFlag(boolean value) {
        this.lspDFlag = value;
    }

    /**
     * To get Ip element id.
     *
     * @return Ip elemend id
     */
    public ElementId elementId() {
        return this.elementId;
    }

    /**
     * To get Tunnel.
     *
     * @return tunnel
     */
    public Tunnel tunnel() {
        return this.tunnel;
    }

    /**
     * To get Path.
     *
     * @return path
     */
    public Path path() {
        return this.path;
    }

    /**
     * To get request type.
     *
     * @return request type
     */
    public RequestType requestType() {
        return this.requestType;
    }

    /**
     * To get pLspId.
     *
     * @return pLspId
     */
    public int plspId() {
        return this.plspId;
    }

    /**
     * To get A flag.
     *
     * @return A flag
     */
    public boolean lspAFlag() {
        return this.lspAFlag;
    }

    /**
     * To get OF flag.
     *
     * @return OF flag
     */
    public byte lspOFlag() {
        return this.lspOFlag;
    }

    /**
     * To get tunnel id.
     *
     * @return tunnel id
     */
    public short tunnelId() {
        return this.tunnelId;
    }

    /**
     * To get extended tunnel id.
     *
     * @return extended tunnel id
     */
    public int extTunnelId() {
        return this.extTunnelId;
    }

    /**
     * To get pLspId.
     *
     * @return pLspId
     */
    public short lspId() {
        return this.lspId;
    }

    /**
     * To get D Flag.
     *
     * @return d flag
     */
    public boolean lspDFlag() {
        return this.lspDFlag;
    }

    /**
     * To get statefulIpv4Indentifier tlv.
     *
     * @return statefulIpv4Indentifier tlv
     */
    public StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv() {
        return this.statefulIpv4IndentifierTlv;
    }

    /**
     * To get report flag.
     *
     * @return report flag
     */
    public boolean rptFlag() {
        return this.rptFlag;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (obj instanceof PcepTunnelData) {
            PcepTunnelData other = (PcepTunnelData) obj;
            return Objects.equals(tunnel, other.tunnel)
                    && Objects.equals(path, other.path)
                    && Objects.equals(plspId, other.plspId)
                    && Objects.equals(elementId, other.elementId)
                    && Objects.equals(requestType, other.requestType)
                    && Objects.equals(rptFlag, other.rptFlag)
                    && Objects.equals(lspAFlag, other.lspAFlag)
                    && Objects.equals(lspDFlag, other.lspDFlag)
                    && Objects.equals(lspOFlag, other.lspOFlag)
                    && Objects.equals(tunnelId, other.tunnelId)
                    && Objects.equals(extTunnelId, other.extTunnelId)
                    && Objects.equals(lspId, other.lspId)
                    && Objects.equals(statefulIpv4IndentifierTlv, other.statefulIpv4IndentifierTlv);
        }

        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(tunnel, path, plspId, elementId, requestType, rptFlag, lspAFlag,
                            lspDFlag, lspOFlag, tunnelId, extTunnelId, lspId, statefulIpv4IndentifierTlv);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(getClass()).add("Tunnel", tunnel)
                .add("Path", path).add("PlspId", plspId).add("ElementId", elementId)
                .add("RequestType", requestType).add("RptFlag", rptFlag).add("LspAFlag", lspAFlag)
                .add("LspDFlag", lspDFlag).add("LspOFlag", lspOFlag).add("TunnelId", tunnelId)
                .add("ExtTunnelid", extTunnelId).add("LspId", lspId)
                .add("StatefulIpv4IndentifierTlv", statefulIpv4IndentifierTlv).toString();
    }
}