d61808b4b6b35c7e9d9ccb125458f0fa511b7210
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / PCEPErrors.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.pcep.spi;
9
10 import com.google.common.collect.Maps;
11 import java.util.Map;
12
13
14
15
16 /**
17  * Possible errors listed in RFC5440, RFC 5455 and stateful draft.
18  *
19  * @see <a href="http://tools.ietf.org/html/rfc5440#section-9.12">PCEP-ERROR Object(RFC5440)</a>, <a href=
20  *      "http://tools.ietf.org/html/draft-ietf-pce-stateful-pce-07#section-8.4" >PCEP-ERROR Object(stateful draft)</a>,
21  *      <a href="http://tools.ietf.org/html/rfc5455#section-3.6">Error Codes for CLASSTYPE Object(RFC5455)</a>, <a href=
22  *      "http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt#section-7.1" >PCEP-Error Object</a>
23  */
24 public enum PCEPErrors {
25
26     /**
27      * Reception of an invalid Open message or a non Open message.
28      */
29     NON_OR_INVALID_OPEN_MSG(1, 1),
30     /**
31      * No Open message received before the expiration of the OpenWait timer.
32      */
33     NO_OPEN_BEFORE_EXP_OPENWAIT(1, 2),
34     /**
35      * Unacceptable and non-negotiable session characteristics.
36      */
37     NON_ACC_NON_NEG_SESSION_CHAR(1, 3),
38     /**
39      * Unacceptable but negotiable session characteristics.
40      */
41     NON_ACC_NEG_SESSION_CHAR(1, 4),
42     /**
43      * Reception of a second Open message with still unacceptable session characteristics.
44      */
45     SECOND_OPEN_MSG(1, 5),
46     /**
47      * Reception of a PCErr message proposing unacceptable session characteristics.
48      */
49     PCERR_NON_ACC_SESSION_CHAR(1, 6),
50     /**
51      * No Keepalive or PCErr message received before the expiration of the KeepWait timer.
52      */
53     NO_MSG_BEFORE_EXP_KEEPWAIT(1, 7),
54     /**
55      * Capability not supported.
56      */
57     CAPABILITY_NOT_SUPPORTED(2, 0),
58     /**
59      * PCEP version not supported.
60      */
61     PCEP_VERSION_NOT_SUPPORTED(1, 8),
62     /**
63      * Unrecognized object class.
64      */
65     UNRECOGNIZED_OBJ_CLASS(3, 1),
66     /**
67      * Unrecognized object Type.
68      */
69     UNRECOGNIZED_OBJ_TYPE(3, 2),
70     /**
71      * Not supported object class.
72      */
73     NOT_SUPPORTED_OBJ_CLASS(4, 1),
74     /**
75      * Not supported object Type.
76      */
77     NOT_SUPPORTED_OBJ_TYPE(4, 2),
78     /**
79      * C bit of the METRIC object set (request rejected).
80      */
81     C_BIT_SET(5, 1),
82     /**
83      * O bit of the RP object cleared (request rejected).
84      */
85     O_BIT_SET(5, 2),
86     /**
87      * Objective function not allowed (request rejected)
88      */
89     OF_NOT_ALLOWED(5, 3),
90     /**
91      * OF bit of the RP object set (request rejected)
92      */
93     OF_BIT_SET(5, 4),
94     /**
95      * Global concurrent optimization not allowed (GCO extension)
96      */
97     GCO_NOT_ALLOWED(5, 5),
98     /**
99      * P2MP Path computation is not allowed
100      */
101     P2MP_COMPUTATION_NOT_ALLOWED(5, 7),
102     /**
103      * RP object missing
104      */
105     RP_MISSING(6, 1),
106     /**
107      * RRO missing for a reoptimization request (R bit of the RP object set).
108      */
109     RRO_MISSING(6, 2),
110     /**
111      * END-POINTS object missing
112      */
113     END_POINTS_MISSING(6, 3),
114     /**
115      * LSP cleanup TLV missing
116      */
117     LSP_CLEANUP_TLV_MISSING(6, 13),
118     /**
119      * SYMBOLIC-PATH-NAME TLV missing
120      */
121     SYMBOLIC_PATH_NAME_MISSING(6, 14),
122     /**
123      * Synchronized path computation request missing.
124      */
125     SYNC_PATH_COMP_REQ_MISSING(7, 0),
126     /**
127      * Unknown request reference
128      */
129     UNKNOWN_REQ_REF(8, 0),
130     /**
131      * Attempt to establish a second PCEP session.
132      */
133     ATTEMPT_2ND_SESSION(9, 0),
134     /**
135      * LSP Object missing.
136      */
137     LSP_MISSING(6, 8),
138     /**
139      * ERO Object missing for a path in an LSP Update Request where TE-LSP setup is requested.
140      */
141     ERO_MISSING(6, 9),
142     /**
143      * Srp Object missing for a path in an LSP Update Request where TE-LSP setup is requested.
144      */
145     SRP_MISSING(6, 10),
146     /**
147      * LSP-IDENTIFIERS TLV missing for a path in an LSP Update Request where TE-LSP setup is requested.
148      */
149     LSP_IDENTIFIERS_TLV_MISSING(6, 11),
150     /**
151      * Reception of an object with P flag not set although the P flag must be set according to this specification.
152      */
153     P_FLAG_NOT_SET(10, 1),
154     /**
155      * Insufficient memory (GCO extension)
156      */
157     INSUFFICIENT_MEMORY(15, 1),
158     /**
159      * Global concurrent optimization not supported (GCO extension)
160      */
161     GCO_NOT_SUPPORTED(15, 2),
162     /**
163      * Diffserv-aware TE error: Unsupported Class-Type.
164      */
165     UNSUPPORTED_CT(12, 1),
166     /**
167      * Diffserv-aware TE error: Invalid Class-Type.
168      */
169     INVALID_CT(12, 2),
170     /**
171      * Diffserv-aware TE error: Class-Type and setup priority do not form a configured TE-class.
172      */
173     CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS(12, 3),
174
175     /**
176      * The PCE cannot satisfy the request due to insufficient memory
177      */
178     CANNOT_SATISFY_P2MP_REQUEST_DUE_TO_INSUFFISIENT_MEMMORY(16, 1),
179     /**
180      * The PCE is not capable of P2MP computation
181      */
182     NOT_CAPPABLE_P2MP_COMPUTATION(16, 2),
183     /**
184      * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 2
185      */
186     P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_LT2(17, 1),
187     /**
188      * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 3
189      */
190     P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_LT3(17, 2),
191     /**
192      * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 4
193      */
194     P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_LT4(17, 3),
195     /**
196      * The PCE is not capable to satisfy the request due to inconsistent END-POINTS
197      */
198     P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_INCONSISTENT_EP(17, 4),
199     /**
200      * P2MP Fragmented request failure
201      */
202     P2MP_FRAGMENTATION_FAILRUE(18, 1),
203     /**
204      * Attempted LSP Update Request for a non- delegated LSP. The PCEP-ERROR Object is followed by the LSP Object that
205      * identifies the LSP.
206      */
207     UPDATE_REQ_FOR_NON_LSP(19, 1),
208     /**
209      * Attempted LSP Update Request if active stateful PCE capability was not negotiated active PCE.
210      */
211     UPDATE_REQ_FOR_NO_STATEFUL(19, 2),
212     /**
213      * Attempted LSP Update Request for an LSP identified by an unknown PLSP-ID.
214      */
215     UNKNOWN_PLSP_ID(19, 3),
216     /**
217      * A PCE indicates to a PCC that it has exceeded the resource limit allocated for its state, and thus it cannot
218      * accept and process its LSP State Report message.
219      */
220     RESOURCE_LIMIT_EXCEEDED(19, 4),
221     /**
222      * PCE-initiated LSP limit reached
223      */
224     LSP_LIMIT_EXCEEDED(19, 6),
225     /**
226      * Delegation for PCE-initiated LSP cannot be revoked
227      */
228     DELEGATION_NON_REVOKABLE(19, 7),
229     /**
230      * Non-zero PLSP-ID in LSP initiation request
231      */
232     NON_ZERO_PLSPID(19, 8),
233     /**
234      * A PCE indicates to a PCC that it can not process (an otherwise valid) LSP State Report. The PCEP-ERROR Object is
235      * followed by the LSP Object that identifies the LSP.
236      */
237     CANNOT_PROCESS_STATE_REPORT(20, 1),
238     /**
239      * LSP Database version mismatch.
240      */
241     LSP_DB_VERSION_MISMATCH(20, 2),
242     /**
243      * The LSP-DB-VERSION TLV Missing when State Synchronization Avoidance enabled.
244      */
245     DB_VERSION_TLV_MISSING_WHEN_SYNC_ALLOWED(20, 3),
246     /**
247      * A PCC indicates to a PCE that it can not complete the state synchronization,
248      */
249     CANNOT_COMPLETE_STATE_SYNC(20, 5),
250     /**
251      * SYMBOLIC-PATH-NAME in use
252      */
253     USED_SYMBOLIC_PATH_NAME(23, 1),
254     /**
255      * LSP instantiation error: Unacceptable instantiation parameters
256      */
257     LSP_UNACC_INST_PARAMS(24, 1),
258     /**
259      * LSP instantiation error: Internal error
260      */
261     LSP_INTERNAL_ERROR(24, 2),
262     /**
263      * LSP instantiation error: RSVP signaling error
264      */
265     LSP_RSVP_ERROR(24, 3),
266     /**
267      * Segment Routing error: Non-identical ERO subobjects
268      */
269     NON_IDENTICAL_ERO_SUBOBJECTS(10, 5),
270     /**
271      * Segment Routing error: ERO subobject with invalid SID value;
272      * */
273     BAD_LABEL_VALUE(10, 2);
274
275     private PCEPErrorIdentifier errorId;
276     private static final Map<PCEPErrorIdentifier, PCEPErrors> VALUE_MAP;
277
278     static {
279         VALUE_MAP = Maps.newHashMap();
280         for (final PCEPErrors enumItem : PCEPErrors.values()) {
281             VALUE_MAP.put(enumItem.getErrorIdentifier(), enumItem);
282         }
283     }
284
285     public static PCEPErrors forValue(final short errorType, final short errorValue) {
286         return VALUE_MAP.get(new PCEPErrorIdentifier(errorType, errorValue));
287     }
288
289     private PCEPErrors(final int type, final int value) {
290         this.errorId = new PCEPErrorIdentifier((short) type, (short) value);
291     }
292
293     private PCEPErrorIdentifier getErrorIdentifier() {
294         return this.errorId;
295     }
296
297     public short getErrorType() {
298         return this.errorId.getType();
299     }
300
301     public short getErrorValue() {
302         return this.errorId.getValue();
303     }
304
305     /**
306      * Caret for combination of Error-type and Error-value
307      */
308     static class PCEPErrorIdentifier {
309         private final short type;
310         private final short value;
311
312         PCEPErrorIdentifier(final short type, final short value) {
313             this.type = type;
314             this.value = value;
315         }
316
317         public short getType() {
318             return this.type;
319         }
320
321         public short getValue() {
322             return this.value;
323         }
324
325         @Override
326         public int hashCode() {
327             final int prime = 31;
328             int result = 1;
329             result = prime * result + this.type;
330             result = prime * result + this.value;
331             return result;
332         }
333
334         @Override
335         public boolean equals(final java.lang.Object obj) {
336             if (this == obj) {
337                 return true;
338             }
339             if (obj == null) {
340                 return false;
341             }
342             if (this.getClass() != obj.getClass()) {
343                 return false;
344             }
345             final PCEPErrorIdentifier other = (PCEPErrorIdentifier) obj;
346             if (this.type != other.type) {
347                 return false;
348             }
349             if (this.value != other.value) {
350                 return false;
351             }
352             return true;
353         }
354
355         @Override
356         public String toString() {
357             return "type " + this.type + " value " + this.value;
358         }
359     }
360 }