blob: 96d74e22371788b0342c49ec3c4255eddbe546c0 [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 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
160 /**
161 * BGP UPDATE: ORIGIN related constants.
162 */
163 public static final class Origin {
164 /**
165 * Default constructor.
166 * <p>
167 * The constructor is private to prevent creating an instance of
168 * this utility class.
169 */
170 private Origin() {
171 }
172
173 /** BGP UPDATE Attributes Type Code ORIGIN. */
174 public static final int TYPE = 1;
175
176 /** BGP UPDATE Attributes Type Code ORIGIN length. */
177 public static final int LENGTH = 1;
178
179 /** BGP UPDATE ORIGIN: IGP. */
180 public static final int IGP = 0;
181
182 /** BGP UPDATE ORIGIN: EGP. */
183 public static final int EGP = 1;
184
185 /** BGP UPDATE ORIGIN: INCOMPLETE. */
186 public static final int INCOMPLETE = 2;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800187
188 /**
189 * Gets the BGP UPDATE origin type as a string.
190 *
191 * @param type the BGP UPDATE origin type
192 * @return the BGP UPDATE origin type as a string
193 */
194 public static String typeToString(int type) {
195 String typeString = "UNKNOWN";
196
197 switch (type) {
198 case IGP:
199 typeString = "IGP";
200 break;
201 case EGP:
202 typeString = "EGP";
203 break;
204 case INCOMPLETE:
205 typeString = "INCOMPLETE";
206 break;
207 default:
208 break;
209 }
210 return typeString;
211 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700212 }
213
214 /**
215 * BGP UPDATE: AS_PATH related constants.
216 */
217 public static final class AsPath {
218 /**
219 * Default constructor.
220 * <p>
221 * The constructor is private to prevent creating an instance of
222 * this utility class.
223 */
224 private AsPath() {
225 }
226
227 /** BGP UPDATE Attributes Type Code AS_PATH. */
228 public static final int TYPE = 2;
229
Kunihiro Ishiguro923d9d82014-12-21 15:47:28 +0900230 /** BGP AS length. */
231 public static final int AS_LENGTH = 2;
232
233 /** BGP 4 Octet AS length (RFC 6793). */
234 public static final int AS_4OCTET_LENGTH = 4;
235
Jonathan Hartab63aac2014-10-16 08:52:55 -0700236 /** 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
376 /** BGP UPDATE Attributes Type Code AGGREGATOR length. */
377 public static final int LENGTH = 6;
378 }
Pavlin Radoslavovc7648ee2014-12-19 16:20:33 -0800379
380 /**
381 * BGP UPDATE: MP_REACH_NLRI related constants.
382 */
383 public static final class MpReachNlri {
384 /**
385 * Default constructor.
386 * <p>
387 * The constructor is private to prevent creating an instance of
388 * this utility class.
389 */
390 private MpReachNlri() {
391 }
392
393 /** BGP UPDATE Attributes Type Code MP_REACH_NLRI. */
394 public static final int TYPE = 14;
395
396 /** BGP UPDATE Attributes Type Code MP_REACH_NLRI min length. */
397 public static final int MIN_LENGTH = 5;
398 }
399
400 /**
401 * BGP UPDATE: MP_UNREACH_NLRI related constants.
402 */
403 public static final class MpUnreachNlri {
404 /**
405 * Default constructor.
406 * <p>
407 * The constructor is private to prevent creating an instance of
408 * this utility class.
409 */
410 private MpUnreachNlri() {
411 }
412
413 /** BGP UPDATE Attributes Type Code MP_UNREACH_NLRI. */
414 public static final int TYPE = 15;
415
416 /** BGP UPDATE Attributes Type Code MP_UNREACH_NLRI min length. */
417 public static final int MIN_LENGTH = 3;
418 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700419 }
420
421 /**
422 * BGP NOTIFICATION related constants.
423 */
424 public static final class Notifications {
425 /**
426 * Default constructor.
427 * <p>
428 * The constructor is private to prevent creating an instance of
429 * this utility class.
430 */
431 private Notifications() {
432 }
433
434 /**
435 * BGP NOTIFICATION: Message Header Error constants.
436 */
437 public static final class MessageHeaderError {
438 /**
439 * Default constructor.
440 * <p>
441 * The constructor is private to prevent creating an instance of
442 * this utility class.
443 */
444 private MessageHeaderError() {
445 }
446
447 /** Message Header Error code. */
448 public static final int ERROR_CODE = 1;
449
450 /** Message Header Error subcode: Connection Not Synchronized. */
451 public static final int CONNECTION_NOT_SYNCHRONIZED = 1;
452
453 /** Message Header Error subcode: Bad Message Length. */
454 public static final int BAD_MESSAGE_LENGTH = 2;
455
456 /** Message Header Error subcode: Bad Message Type. */
457 public static final int BAD_MESSAGE_TYPE = 3;
458 }
459
460 /**
461 * BGP NOTIFICATION: OPEN Message Error constants.
462 */
463 public static final class OpenMessageError {
464 /**
465 * Default constructor.
466 * <p>
467 * The constructor is private to prevent creating an instance of
468 * this utility class.
469 */
470 private OpenMessageError() {
471 }
472
473 /** OPEN Message Error code. */
474 public static final int ERROR_CODE = 2;
475
476 /** OPEN Message Error subcode: Unsupported Version Number. */
477 public static final int UNSUPPORTED_VERSION_NUMBER = 1;
478
479 /** OPEN Message Error subcode: Bad PEER AS. */
480 public static final int BAD_PEER_AS = 2;
481
482 /** OPEN Message Error subcode: Unacceptable Hold Time. */
483 public static final int UNACCEPTABLE_HOLD_TIME = 6;
484 }
485
486 /**
487 * BGP NOTIFICATION: UPDATE Message Error constants.
488 */
489 public static final class UpdateMessageError {
490 /**
491 * Default constructor.
492 * <p>
493 * The constructor is private to prevent creating an instance of
494 * this utility class.
495 */
496 private UpdateMessageError() {
497 }
498
499 /** UPDATE Message Error code. */
500 public static final int ERROR_CODE = 3;
501
502 /** UPDATE Message Error subcode: Malformed Attribute List. */
503 public static final int MALFORMED_ATTRIBUTE_LIST = 1;
504
505 /** UPDATE Message Error subcode: Unrecognized Well-known Attribute. */
506 public static final int UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;
507
508 /** UPDATE Message Error subcode: Missing Well-known Attribute. */
509 public static final int MISSING_WELL_KNOWN_ATTRIBUTE = 3;
510
511 /** UPDATE Message Error subcode: Attribute Flags Error. */
512 public static final int ATTRIBUTE_FLAGS_ERROR = 4;
513
514 /** UPDATE Message Error subcode: Attribute Length Error. */
515 public static final int ATTRIBUTE_LENGTH_ERROR = 5;
516
517 /** UPDATE Message Error subcode: Invalid ORIGIN Attribute. */
518 public static final int INVALID_ORIGIN_ATTRIBUTE = 6;
519
520 /** UPDATE Message Error subcode: Invalid NEXT_HOP Attribute. */
521 public static final int INVALID_NEXT_HOP_ATTRIBUTE = 8;
522
523 /** UPDATE Message Error subcode: Optional Attribute Error. Unused. */
524 public static final int OPTIONAL_ATTRIBUTE_ERROR = 9;
525
526 /** UPDATE Message Error subcode: Invalid Network Field. */
527 public static final int INVALID_NETWORK_FIELD = 10;
528
529 /** UPDATE Message Error subcode: Malformed AS_PATH. */
530 public static final int MALFORMED_AS_PATH = 11;
531 }
532
533 /**
534 * BGP NOTIFICATION: Hold Timer Expired constants.
535 */
536 public static final class HoldTimerExpired {
537 /**
538 * Default constructor.
539 * <p>
540 * The constructor is private to prevent creating an instance of
541 * this utility class.
542 */
543 private HoldTimerExpired() {
544 }
545
546 /** Hold Timer Expired code. */
547 public static final int ERROR_CODE = 4;
548 }
549
550 /** BGP NOTIFICATION message Error subcode: Unspecific. */
551 public static final int ERROR_SUBCODE_UNSPECIFIC = 0;
552 }
553}