blob: 504482f44ae36bcba5e412b5fa5f6f328c7d7bab [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present 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 Hart41349e92015-02-09 14:14:02 -080016package org.onosproject.routing.bgp;
Jonathan Hartab63aac2014-10-16 08:52:55 -070017
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 /**
Pavlin Radoslavov278cdde2014-12-16 14:09:31 -080083 * BGP OPEN related constants.
84 */
85 public static final class Open {
86 /**
87 * Default constructor.
88 * <p>
89 * The constructor is private to prevent creating an instance of
90 * this utility class.
91 */
92 private Open() {
93 }
94
95 /**
96 * BGP OPEN: Optional Parameters related constants.
97 */
98 public static final class OptionalParameters {
99 }
100
101 /**
102 * BGP OPEN: Capabilities related constants (RFC 5492).
103 */
104 public static final class Capabilities {
105 /** BGP OPEN Optional Parameter Type: Capabilities. */
106 public static final int TYPE = 2;
107
108 /** BGP OPEN Optional Parameter minimum length. */
109 public static final int MIN_LENGTH = 2;
110
111 /**
112 * BGP OPEN: Multiprotocol Extensions Capabilities (RFC 4760).
113 */
114 public static final class MultiprotocolExtensions {
115 /** BGP OPEN Multiprotocol Extensions code. */
116 public static final int CODE = 1;
117
118 /** BGP OPEN Multiprotocol Extensions length. */
119 public static final int LENGTH = 4;
120
121 /** BGP OPEN Multiprotocol Extensions AFI: IPv4. */
122 public static final int AFI_IPV4 = 1;
123
124 /** BGP OPEN Multiprotocol Extensions AFI: IPv6. */
125 public static final int AFI_IPV6 = 2;
126
127 /** BGP OPEN Multiprotocol Extensions SAFI: unicast. */
128 public static final int SAFI_UNICAST = 1;
129
130 /** BGP OPEN Multiprotocol Extensions SAFI: multicast. */
131 public static final int SAFI_MULTICAST = 2;
132 }
133
134 /**
135 * BGP OPEN: Support for 4-octet AS Number Capability (RFC 6793).
136 */
137 public static final class As4Octet {
138 /** BGP OPEN Support for 4-octet AS Number Capability code. */
139 public static final int CODE = 65;
140
141 /** BGP OPEN 4-octet AS Number Capability length. */
142 public static final int LENGTH = 4;
143 }
144 }
145 }
146
147 /**
Jonathan Hartab63aac2014-10-16 08:52:55 -0700148 * BGP UPDATE related constants.
149 */
150 public static final class Update {
151 /**
152 * Default constructor.
153 * <p>
154 * The constructor is private to prevent creating an instance of
155 * this utility class.
156 */
157 private Update() {
158 }
159
Pavlin Radoslavova460e292015-03-17 18:04:56 -0700160 /** BGP AS length. */
161 public static final int AS_LENGTH = 2;
162
163 /** BGP 4 Octet AS length (RFC 6793). */
164 public static final int AS_4OCTET_LENGTH = 4;
165
Jonathan Hartab63aac2014-10-16 08:52:55 -0700166 /**
167 * BGP UPDATE: ORIGIN related constants.
168 */
169 public static final class Origin {
170 /**
171 * Default constructor.
172 * <p>
173 * The constructor is private to prevent creating an instance of
174 * this utility class.
175 */
176 private Origin() {
177 }
178
179 /** BGP UPDATE Attributes Type Code ORIGIN. */
180 public static final int TYPE = 1;
181
182 /** BGP UPDATE Attributes Type Code ORIGIN length. */
183 public static final int LENGTH = 1;
184
185 /** BGP UPDATE ORIGIN: IGP. */
186 public static final int IGP = 0;
187
188 /** BGP UPDATE ORIGIN: EGP. */
189 public static final int EGP = 1;
190
191 /** BGP UPDATE ORIGIN: INCOMPLETE. */
192 public static final int INCOMPLETE = 2;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800193
194 /**
195 * Gets the BGP UPDATE origin type as a string.
196 *
197 * @param type the BGP UPDATE origin type
198 * @return the BGP UPDATE origin type as a string
199 */
200 public static String typeToString(int type) {
201 String typeString = "UNKNOWN";
202
203 switch (type) {
204 case IGP:
205 typeString = "IGP";
206 break;
207 case EGP:
208 typeString = "EGP";
209 break;
210 case INCOMPLETE:
211 typeString = "INCOMPLETE";
212 break;
213 default:
214 break;
215 }
216 return typeString;
217 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700218 }
219
220 /**
221 * BGP UPDATE: AS_PATH related constants.
222 */
223 public static final class AsPath {
224 /**
225 * Default constructor.
226 * <p>
227 * The constructor is private to prevent creating an instance of
228 * this utility class.
229 */
230 private AsPath() {
231 }
232
233 /** BGP UPDATE Attributes Type Code AS_PATH. */
234 public static final int TYPE = 2;
235
236 /** BGP UPDATE AS_PATH Type: AS_SET. */
237 public static final int AS_SET = 1;
238
239 /** BGP UPDATE AS_PATH Type: AS_SEQUENCE. */
240 public static final int AS_SEQUENCE = 2;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800241
Pavlin Radoslavov49eb64d2014-11-10 17:03:19 -0800242 /** BGP UPDATE AS_PATH Type: AS_CONFED_SEQUENCE. */
243 public static final int AS_CONFED_SEQUENCE = 3;
244
245 /** BGP UPDATE AS_PATH Type: AS_CONFED_SET. */
246 public static final int AS_CONFED_SET = 4;
247
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800248 /**
249 * Gets the BGP AS_PATH type as a string.
250 *
251 * @param type the BGP AS_PATH type
252 * @return the BGP AS_PATH type as a string
253 */
254 public static String typeToString(int type) {
255 String typeString = "UNKNOWN";
256
257 switch (type) {
258 case AS_SET:
259 typeString = "AS_SET";
260 break;
261 case AS_SEQUENCE:
262 typeString = "AS_SEQUENCE";
263 break;
Pavlin Radoslavov49eb64d2014-11-10 17:03:19 -0800264 case AS_CONFED_SEQUENCE:
265 typeString = "AS_CONFED_SEQUENCE";
266 break;
267 case AS_CONFED_SET:
268 typeString = "AS_CONFED_SET";
269 break;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800270 default:
271 break;
272 }
273 return typeString;
274 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700275 }
276
277 /**
278 * BGP UPDATE: NEXT_HOP related constants.
279 */
280 public static final class NextHop {
281 /**
282 * Default constructor.
283 * <p>
284 * The constructor is private to prevent creating an instance of
285 * this utility class.
286 */
287 private NextHop() {
288 }
289
290 /** BGP UPDATE Attributes Type Code NEXT_HOP. */
291 public static final int TYPE = 3;
292
293 /** BGP UPDATE Attributes Type Code NEXT_HOP length. */
294 public static final int LENGTH = 4;
295 }
296
297 /**
298 * BGP UPDATE: MULTI_EXIT_DISC related constants.
299 */
300 public static final class MultiExitDisc {
301 /**
302 * Default constructor.
303 * <p>
304 * The constructor is private to prevent creating an instance of
305 * this utility class.
306 */
307 private MultiExitDisc() {
308 }
309
310 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC. */
311 public static final int TYPE = 4;
312
313 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC length. */
314 public static final int LENGTH = 4;
315
316 /** BGP UPDATE Attributes lowest MULTI_EXIT_DISC value. */
317 public static final int LOWEST_MULTI_EXIT_DISC = 0;
318 }
319
320 /**
321 * BGP UPDATE: LOCAL_PREF related constants.
322 */
323 public static final class LocalPref {
324 /**
325 * Default constructor.
326 * <p>
327 * The constructor is private to prevent creating an instance of
328 * this utility class.
329 */
330 private LocalPref() {
331 }
332
333 /** BGP UPDATE Attributes Type Code LOCAL_PREF. */
334 public static final int TYPE = 5;
335
336 /** BGP UPDATE Attributes Type Code LOCAL_PREF length. */
337 public static final int LENGTH = 4;
338 }
339
340 /**
341 * BGP UPDATE: ATOMIC_AGGREGATE related constants.
342 */
343 public static final class AtomicAggregate {
344 /**
345 * Default constructor.
346 * <p>
347 * The constructor is private to prevent creating an instance of
348 * this utility class.
349 */
350 private AtomicAggregate() {
351 }
352
353 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE. */
354 public static final int TYPE = 6;
355
356 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE length. */
357 public static final int LENGTH = 0;
358 }
359
360 /**
361 * BGP UPDATE: AGGREGATOR related constants.
362 */
363 public static final class Aggregator {
364 /**
365 * Default constructor.
366 * <p>
367 * The constructor is private to prevent creating an instance of
368 * this utility class.
369 */
370 private Aggregator() {
371 }
372
373 /** BGP UPDATE Attributes Type Code AGGREGATOR. */
374 public static final int TYPE = 7;
375
Pavlin Radoslavova460e292015-03-17 18:04:56 -0700376 /** BGP UPDATE Attributes Type Code AGGREGATOR length: 2 octet AS. */
377 public static final int AS2_LENGTH = 6;
378
379 /** BGP UPDATE Attributes Type Code AGGREGATOR length: 4 octet AS. */
380 public static final int AS4_LENGTH = 8;
Jonathan Hartab63aac2014-10-16 08:52:55 -0700381 }
Pavlin Radoslavovc7648ee2014-12-19 16:20:33 -0800382
383 /**
384 * BGP UPDATE: MP_REACH_NLRI related constants.
385 */
386 public static final class MpReachNlri {
387 /**
388 * Default constructor.
389 * <p>
390 * The constructor is private to prevent creating an instance of
391 * this utility class.
392 */
393 private MpReachNlri() {
394 }
395
396 /** BGP UPDATE Attributes Type Code MP_REACH_NLRI. */
397 public static final int TYPE = 14;
398
399 /** BGP UPDATE Attributes Type Code MP_REACH_NLRI min length. */
400 public static final int MIN_LENGTH = 5;
401 }
402
403 /**
404 * BGP UPDATE: MP_UNREACH_NLRI related constants.
405 */
406 public static final class MpUnreachNlri {
407 /**
408 * Default constructor.
409 * <p>
410 * The constructor is private to prevent creating an instance of
411 * this utility class.
412 */
413 private MpUnreachNlri() {
414 }
415
416 /** BGP UPDATE Attributes Type Code MP_UNREACH_NLRI. */
417 public static final int TYPE = 15;
418
419 /** BGP UPDATE Attributes Type Code MP_UNREACH_NLRI min length. */
420 public static final int MIN_LENGTH = 3;
421 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700422 }
423
424 /**
425 * BGP NOTIFICATION related constants.
426 */
427 public static final class Notifications {
428 /**
429 * Default constructor.
430 * <p>
431 * The constructor is private to prevent creating an instance of
432 * this utility class.
433 */
434 private Notifications() {
435 }
436
437 /**
438 * BGP NOTIFICATION: Message Header Error constants.
439 */
440 public static final class MessageHeaderError {
441 /**
442 * Default constructor.
443 * <p>
444 * The constructor is private to prevent creating an instance of
445 * this utility class.
446 */
447 private MessageHeaderError() {
448 }
449
450 /** Message Header Error code. */
451 public static final int ERROR_CODE = 1;
452
453 /** Message Header Error subcode: Connection Not Synchronized. */
454 public static final int CONNECTION_NOT_SYNCHRONIZED = 1;
455
456 /** Message Header Error subcode: Bad Message Length. */
457 public static final int BAD_MESSAGE_LENGTH = 2;
458
459 /** Message Header Error subcode: Bad Message Type. */
460 public static final int BAD_MESSAGE_TYPE = 3;
461 }
462
463 /**
464 * BGP NOTIFICATION: OPEN Message Error constants.
465 */
466 public static final class OpenMessageError {
467 /**
468 * Default constructor.
469 * <p>
470 * The constructor is private to prevent creating an instance of
471 * this utility class.
472 */
473 private OpenMessageError() {
474 }
475
476 /** OPEN Message Error code. */
477 public static final int ERROR_CODE = 2;
478
479 /** OPEN Message Error subcode: Unsupported Version Number. */
480 public static final int UNSUPPORTED_VERSION_NUMBER = 1;
481
482 /** OPEN Message Error subcode: Bad PEER AS. */
483 public static final int BAD_PEER_AS = 2;
484
485 /** OPEN Message Error subcode: Unacceptable Hold Time. */
486 public static final int UNACCEPTABLE_HOLD_TIME = 6;
487 }
488
489 /**
490 * BGP NOTIFICATION: UPDATE Message Error constants.
491 */
492 public static final class UpdateMessageError {
493 /**
494 * Default constructor.
495 * <p>
496 * The constructor is private to prevent creating an instance of
497 * this utility class.
498 */
499 private UpdateMessageError() {
500 }
501
502 /** UPDATE Message Error code. */
503 public static final int ERROR_CODE = 3;
504
505 /** UPDATE Message Error subcode: Malformed Attribute List. */
506 public static final int MALFORMED_ATTRIBUTE_LIST = 1;
507
508 /** UPDATE Message Error subcode: Unrecognized Well-known Attribute. */
509 public static final int UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;
510
511 /** UPDATE Message Error subcode: Missing Well-known Attribute. */
512 public static final int MISSING_WELL_KNOWN_ATTRIBUTE = 3;
513
514 /** UPDATE Message Error subcode: Attribute Flags Error. */
515 public static final int ATTRIBUTE_FLAGS_ERROR = 4;
516
517 /** UPDATE Message Error subcode: Attribute Length Error. */
518 public static final int ATTRIBUTE_LENGTH_ERROR = 5;
519
520 /** UPDATE Message Error subcode: Invalid ORIGIN Attribute. */
521 public static final int INVALID_ORIGIN_ATTRIBUTE = 6;
522
523 /** UPDATE Message Error subcode: Invalid NEXT_HOP Attribute. */
524 public static final int INVALID_NEXT_HOP_ATTRIBUTE = 8;
525
526 /** UPDATE Message Error subcode: Optional Attribute Error. Unused. */
527 public static final int OPTIONAL_ATTRIBUTE_ERROR = 9;
528
529 /** UPDATE Message Error subcode: Invalid Network Field. */
530 public static final int INVALID_NETWORK_FIELD = 10;
531
532 /** UPDATE Message Error subcode: Malformed AS_PATH. */
533 public static final int MALFORMED_AS_PATH = 11;
534 }
535
536 /**
537 * BGP NOTIFICATION: Hold Timer Expired constants.
538 */
539 public static final class HoldTimerExpired {
540 /**
541 * Default constructor.
542 * <p>
543 * The constructor is private to prevent creating an instance of
544 * this utility class.
545 */
546 private HoldTimerExpired() {
547 }
548
549 /** Hold Timer Expired code. */
550 public static final int ERROR_CODE = 4;
551 }
552
553 /** BGP NOTIFICATION message Error subcode: Unspecific. */
554 public static final int ERROR_SUBCODE_UNSPECIFIC = 0;
555 }
556}