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.bgp.parser;
11 * Possible errors from implemented RFCs and drafts. Each error consists of error code and error subcode (code/subcode
14 * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.5">BGP Notification Message</a>
16 public enum BGPError {
18 * Connection Not Synchronized. 1/1
20 CONNECTION_NOT_SYNC((short) 1, (short) 1),
22 * Bad Message Length. 1/2
24 BAD_MSG_LENGTH((short) 1, (short) 2),
26 * Bad Message Type. 1/3
28 BAD_MSG_TYPE((short) 1, (short) 3),
30 * Unspecific Open Message error.
32 UNSPECIFIC_OPEN_ERROR((short) 2, (short) 0),
34 * Unsupported Version Number. 2/1
36 VERSION_NOT_SUPPORTED((short) 2, (short) 1),
40 BAD_PEER_AS((short) 2, (short) 2),
42 * Bad BGP Identifier. 2/3
44 BAD_BGP_ID((short) 2, (short) 3),
46 * Unsupported Optional Parameter. 2/4
48 OPT_PARAM_NOT_SUPPORTED((short) 2, (short) 4),
50 * Unacceptable Hold Time. 2/6
52 HOLD_TIME_NOT_ACC((short) 2, (short) 6),
54 * Malformed Attribute List. 3/1
56 MALFORMED_ATTR_LIST((short) 3, (short) 1),
58 * Unrecognized Well-known Attribute. 3/2
60 WELL_KNOWN_ATTR_NOT_RECOGNIZED((short) 3, (short) 2),
62 * Missing Well-known Attribute. 3/3
64 WELL_KNOWN_ATTR_MISSING((short) 3, (short) 3),
66 * Attribute Flags Error. 3/4
68 ATTR_FLAGS_MISSING((short) 3, (short) 4),
70 * Attribute Length Error. 3/5
72 ATTR_LENGTH_ERROR((short) 3, (short) 5),
74 * Invalid ORIGIN Attribute. 3/6
76 ORIGIN_ATTR_NOT_VALID((short) 3, (short) 6),
78 * Invalid NEXT_HOP Attribute. 3/8
80 NEXT_HOP_NOT_VALID((short) 3, (short) 8),
82 * Optional Attribute Error. 3/9
84 OPT_ATTR_ERROR((short) 3, (short) 9),
86 * Invalid Network Field. 3/10
88 NETWORK_NOT_VALID((short) 3, (short) 10),
90 * Malformed AS_PATH. 3/11
92 AS_PATH_MALFORMED((short) 3, (short) 11),
94 * Hold Timer Expired. 4/0
96 HOLD_TIMER_EXPIRED((short) 4, (short) 0),
98 * Finite State Machine Error. 5/0
100 FSM_ERROR((short) 5, (short) 0),
104 CEASE((short) 6, (short) 0);
106 private final short code;
108 private final short subcode;
110 BGPError(final short code, final short subcode) {
112 this.subcode = subcode;
115 public short getCode() {
119 public short getSubcode() {
123 public static BGPError forValue(final int e, final int s) {
126 return BGPError.CONNECTION_NOT_SYNC;
129 return BGPError.BAD_MSG_LENGTH;
132 return BGPError.BAD_MSG_TYPE;
136 return BGPError.UNSPECIFIC_OPEN_ERROR;
139 return BGPError.VERSION_NOT_SUPPORTED;
142 return BGPError.BAD_PEER_AS;
145 return BGPError.BAD_BGP_ID;
148 return BGPError.OPT_PARAM_NOT_SUPPORTED;
151 return BGPError.HOLD_TIME_NOT_ACC;
155 return BGPError.MALFORMED_ATTR_LIST;
158 return BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED;
161 return BGPError.WELL_KNOWN_ATTR_MISSING;
164 return BGPError.ATTR_FLAGS_MISSING;
167 return BGPError.ATTR_LENGTH_ERROR;
170 return BGPError.ORIGIN_ATTR_NOT_VALID;
173 return BGPError.NEXT_HOP_NOT_VALID;
176 return BGPError.OPT_ATTR_ERROR;
179 return BGPError.NETWORK_NOT_VALID;
182 return BGPError.AS_PATH_MALFORMED;
185 return BGPError.HOLD_TIMER_EXPIRED;
187 return BGPError.FSM_ERROR;
189 return BGPError.CEASE;
191 throw new IllegalArgumentException("BGP Error code " + e + " and subcode " + s + " not recognized.");