blob: 33fe4118395d8e77578d1a5973df4e63266a889d [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
Jonathan Hartab63aac2014-10-16 08:52:55 -070016package org.onlab.onos.sdnip.bgp;
17
18/**
19 * BGP related constants.
20 */
21public final class BgpConstants {
22 /**
23 * Default constructor.
24 * <p>
25 * The constructor is private to prevent creating an instance of
26 * this utility class.
27 */
28 private BgpConstants() {
29 }
30
31 /** BGP port number (RFC 4271). */
32 public static final int BGP_PORT = 179;
33
34 /** BGP version. */
35 public static final int BGP_VERSION = 4;
36
37 /** BGP OPEN message type. */
38 public static final int BGP_TYPE_OPEN = 1;
39
40 /** BGP UPDATE message type. */
41 public static final int BGP_TYPE_UPDATE = 2;
42
43 /** BGP NOTIFICATION message type. */
44 public static final int BGP_TYPE_NOTIFICATION = 3;
45
46 /** BGP KEEPALIVE message type. */
47 public static final int BGP_TYPE_KEEPALIVE = 4;
48
49 /** BGP Header Marker field length. */
50 public static final int BGP_HEADER_MARKER_LENGTH = 16;
51
52 /** BGP Header length. */
53 public static final int BGP_HEADER_LENGTH = 19;
54
55 /** BGP message maximum length. */
56 public static final int BGP_MESSAGE_MAX_LENGTH = 4096;
57
58 /** BGP OPEN message minimum length (BGP Header included). */
59 public static final int BGP_OPEN_MIN_LENGTH = 29;
60
61 /** BGP UPDATE message minimum length (BGP Header included). */
62 public static final int BGP_UPDATE_MIN_LENGTH = 23;
63
64 /** BGP NOTIFICATION message minimum length (BGP Header included). */
65 public static final int BGP_NOTIFICATION_MIN_LENGTH = 21;
66
67 /** BGP KEEPALIVE message expected length (BGP Header included). */
68 public static final int BGP_KEEPALIVE_EXPECTED_LENGTH = 19;
69
70 /** BGP KEEPALIVE messages transmitted per Hold interval. */
71 public static final int BGP_KEEPALIVE_PER_HOLD_INTERVAL = 3;
72
73 /** BGP KEEPALIVE messages minimum Holdtime (in seconds). */
74 public static final int BGP_KEEPALIVE_MIN_HOLDTIME = 3;
75
76 /** BGP KEEPALIVE messages minimum transmission interval (in seconds). */
77 public static final int BGP_KEEPALIVE_MIN_INTERVAL = 1;
78
79 /** BGP AS 0 (zero) value. See draft-ietf-idr-as0-06.txt Internet Draft. */
80 public static final long BGP_AS_0 = 0;
81
82 /**
83 * BGP UPDATE related constants.
84 */
85 public static final class Update {
86 /**
87 * Default constructor.
88 * <p>
89 * The constructor is private to prevent creating an instance of
90 * this utility class.
91 */
92 private Update() {
93 }
94
95 /**
96 * BGP UPDATE: ORIGIN related constants.
97 */
98 public static final class Origin {
99 /**
100 * Default constructor.
101 * <p>
102 * The constructor is private to prevent creating an instance of
103 * this utility class.
104 */
105 private Origin() {
106 }
107
108 /** BGP UPDATE Attributes Type Code ORIGIN. */
109 public static final int TYPE = 1;
110
111 /** BGP UPDATE Attributes Type Code ORIGIN length. */
112 public static final int LENGTH = 1;
113
114 /** BGP UPDATE ORIGIN: IGP. */
115 public static final int IGP = 0;
116
117 /** BGP UPDATE ORIGIN: EGP. */
118 public static final int EGP = 1;
119
120 /** BGP UPDATE ORIGIN: INCOMPLETE. */
121 public static final int INCOMPLETE = 2;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800122
123 /**
124 * Gets the BGP UPDATE origin type as a string.
125 *
126 * @param type the BGP UPDATE origin type
127 * @return the BGP UPDATE origin type as a string
128 */
129 public static String typeToString(int type) {
130 String typeString = "UNKNOWN";
131
132 switch (type) {
133 case IGP:
134 typeString = "IGP";
135 break;
136 case EGP:
137 typeString = "EGP";
138 break;
139 case INCOMPLETE:
140 typeString = "INCOMPLETE";
141 break;
142 default:
143 break;
144 }
145 return typeString;
146 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700147 }
148
149 /**
150 * BGP UPDATE: AS_PATH related constants.
151 */
152 public static final class AsPath {
153 /**
154 * Default constructor.
155 * <p>
156 * The constructor is private to prevent creating an instance of
157 * this utility class.
158 */
159 private AsPath() {
160 }
161
162 /** BGP UPDATE Attributes Type Code AS_PATH. */
163 public static final int TYPE = 2;
164
165 /** BGP UPDATE AS_PATH Type: AS_SET. */
166 public static final int AS_SET = 1;
167
168 /** BGP UPDATE AS_PATH Type: AS_SEQUENCE. */
169 public static final int AS_SEQUENCE = 2;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800170
Pavlin Radoslavov49eb64d2014-11-10 17:03:19 -0800171 /** BGP UPDATE AS_PATH Type: AS_CONFED_SEQUENCE. */
172 public static final int AS_CONFED_SEQUENCE = 3;
173
174 /** BGP UPDATE AS_PATH Type: AS_CONFED_SET. */
175 public static final int AS_CONFED_SET = 4;
176
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800177 /**
178 * Gets the BGP AS_PATH type as a string.
179 *
180 * @param type the BGP AS_PATH type
181 * @return the BGP AS_PATH type as a string
182 */
183 public static String typeToString(int type) {
184 String typeString = "UNKNOWN";
185
186 switch (type) {
187 case AS_SET:
188 typeString = "AS_SET";
189 break;
190 case AS_SEQUENCE:
191 typeString = "AS_SEQUENCE";
192 break;
Pavlin Radoslavov49eb64d2014-11-10 17:03:19 -0800193 case AS_CONFED_SEQUENCE:
194 typeString = "AS_CONFED_SEQUENCE";
195 break;
196 case AS_CONFED_SET:
197 typeString = "AS_CONFED_SET";
198 break;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800199 default:
200 break;
201 }
202 return typeString;
203 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700204 }
205
206 /**
207 * BGP UPDATE: NEXT_HOP related constants.
208 */
209 public static final class NextHop {
210 /**
211 * Default constructor.
212 * <p>
213 * The constructor is private to prevent creating an instance of
214 * this utility class.
215 */
216 private NextHop() {
217 }
218
219 /** BGP UPDATE Attributes Type Code NEXT_HOP. */
220 public static final int TYPE = 3;
221
222 /** BGP UPDATE Attributes Type Code NEXT_HOP length. */
223 public static final int LENGTH = 4;
224 }
225
226 /**
227 * BGP UPDATE: MULTI_EXIT_DISC related constants.
228 */
229 public static final class MultiExitDisc {
230 /**
231 * Default constructor.
232 * <p>
233 * The constructor is private to prevent creating an instance of
234 * this utility class.
235 */
236 private MultiExitDisc() {
237 }
238
239 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC. */
240 public static final int TYPE = 4;
241
242 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC length. */
243 public static final int LENGTH = 4;
244
245 /** BGP UPDATE Attributes lowest MULTI_EXIT_DISC value. */
246 public static final int LOWEST_MULTI_EXIT_DISC = 0;
247 }
248
249 /**
250 * BGP UPDATE: LOCAL_PREF related constants.
251 */
252 public static final class LocalPref {
253 /**
254 * Default constructor.
255 * <p>
256 * The constructor is private to prevent creating an instance of
257 * this utility class.
258 */
259 private LocalPref() {
260 }
261
262 /** BGP UPDATE Attributes Type Code LOCAL_PREF. */
263 public static final int TYPE = 5;
264
265 /** BGP UPDATE Attributes Type Code LOCAL_PREF length. */
266 public static final int LENGTH = 4;
267 }
268
269 /**
270 * BGP UPDATE: ATOMIC_AGGREGATE related constants.
271 */
272 public static final class AtomicAggregate {
273 /**
274 * Default constructor.
275 * <p>
276 * The constructor is private to prevent creating an instance of
277 * this utility class.
278 */
279 private AtomicAggregate() {
280 }
281
282 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE. */
283 public static final int TYPE = 6;
284
285 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE length. */
286 public static final int LENGTH = 0;
287 }
288
289 /**
290 * BGP UPDATE: AGGREGATOR related constants.
291 */
292 public static final class Aggregator {
293 /**
294 * Default constructor.
295 * <p>
296 * The constructor is private to prevent creating an instance of
297 * this utility class.
298 */
299 private Aggregator() {
300 }
301
302 /** BGP UPDATE Attributes Type Code AGGREGATOR. */
303 public static final int TYPE = 7;
304
305 /** BGP UPDATE Attributes Type Code AGGREGATOR length. */
306 public static final int LENGTH = 6;
307 }
308 }
309
310 /**
311 * BGP NOTIFICATION related constants.
312 */
313 public static final class Notifications {
314 /**
315 * Default constructor.
316 * <p>
317 * The constructor is private to prevent creating an instance of
318 * this utility class.
319 */
320 private Notifications() {
321 }
322
323 /**
324 * BGP NOTIFICATION: Message Header Error constants.
325 */
326 public static final class MessageHeaderError {
327 /**
328 * Default constructor.
329 * <p>
330 * The constructor is private to prevent creating an instance of
331 * this utility class.
332 */
333 private MessageHeaderError() {
334 }
335
336 /** Message Header Error code. */
337 public static final int ERROR_CODE = 1;
338
339 /** Message Header Error subcode: Connection Not Synchronized. */
340 public static final int CONNECTION_NOT_SYNCHRONIZED = 1;
341
342 /** Message Header Error subcode: Bad Message Length. */
343 public static final int BAD_MESSAGE_LENGTH = 2;
344
345 /** Message Header Error subcode: Bad Message Type. */
346 public static final int BAD_MESSAGE_TYPE = 3;
347 }
348
349 /**
350 * BGP NOTIFICATION: OPEN Message Error constants.
351 */
352 public static final class OpenMessageError {
353 /**
354 * Default constructor.
355 * <p>
356 * The constructor is private to prevent creating an instance of
357 * this utility class.
358 */
359 private OpenMessageError() {
360 }
361
362 /** OPEN Message Error code. */
363 public static final int ERROR_CODE = 2;
364
365 /** OPEN Message Error subcode: Unsupported Version Number. */
366 public static final int UNSUPPORTED_VERSION_NUMBER = 1;
367
368 /** OPEN Message Error subcode: Bad PEER AS. */
369 public static final int BAD_PEER_AS = 2;
370
371 /** OPEN Message Error subcode: Unacceptable Hold Time. */
372 public static final int UNACCEPTABLE_HOLD_TIME = 6;
373 }
374
375 /**
376 * BGP NOTIFICATION: UPDATE Message Error constants.
377 */
378 public static final class UpdateMessageError {
379 /**
380 * Default constructor.
381 * <p>
382 * The constructor is private to prevent creating an instance of
383 * this utility class.
384 */
385 private UpdateMessageError() {
386 }
387
388 /** UPDATE Message Error code. */
389 public static final int ERROR_CODE = 3;
390
391 /** UPDATE Message Error subcode: Malformed Attribute List. */
392 public static final int MALFORMED_ATTRIBUTE_LIST = 1;
393
394 /** UPDATE Message Error subcode: Unrecognized Well-known Attribute. */
395 public static final int UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;
396
397 /** UPDATE Message Error subcode: Missing Well-known Attribute. */
398 public static final int MISSING_WELL_KNOWN_ATTRIBUTE = 3;
399
400 /** UPDATE Message Error subcode: Attribute Flags Error. */
401 public static final int ATTRIBUTE_FLAGS_ERROR = 4;
402
403 /** UPDATE Message Error subcode: Attribute Length Error. */
404 public static final int ATTRIBUTE_LENGTH_ERROR = 5;
405
406 /** UPDATE Message Error subcode: Invalid ORIGIN Attribute. */
407 public static final int INVALID_ORIGIN_ATTRIBUTE = 6;
408
409 /** UPDATE Message Error subcode: Invalid NEXT_HOP Attribute. */
410 public static final int INVALID_NEXT_HOP_ATTRIBUTE = 8;
411
412 /** UPDATE Message Error subcode: Optional Attribute Error. Unused. */
413 public static final int OPTIONAL_ATTRIBUTE_ERROR = 9;
414
415 /** UPDATE Message Error subcode: Invalid Network Field. */
416 public static final int INVALID_NETWORK_FIELD = 10;
417
418 /** UPDATE Message Error subcode: Malformed AS_PATH. */
419 public static final int MALFORMED_AS_PATH = 11;
420 }
421
422 /**
423 * BGP NOTIFICATION: Hold Timer Expired constants.
424 */
425 public static final class HoldTimerExpired {
426 /**
427 * Default constructor.
428 * <p>
429 * The constructor is private to prevent creating an instance of
430 * this utility class.
431 */
432 private HoldTimerExpired() {
433 }
434
435 /** Hold Timer Expired code. */
436 public static final int ERROR_CODE = 4;
437 }
438
439 /** BGP NOTIFICATION message Error subcode: Unspecific. */
440 public static final int ERROR_SUBCODE_UNSPECIFIC = 0;
441 }
442}