blob: 0cb74cfae50f9debbd3cdf8cab74793fc021c855 [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.sdnip.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
230 /** BGP UPDATE AS_PATH Type: AS_SET. */
231 public static final int AS_SET = 1;
232
233 /** BGP UPDATE AS_PATH Type: AS_SEQUENCE. */
234 public static final int AS_SEQUENCE = 2;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800235
Pavlin Radoslavov49eb64d2014-11-10 17:03:19 -0800236 /** BGP UPDATE AS_PATH Type: AS_CONFED_SEQUENCE. */
237 public static final int AS_CONFED_SEQUENCE = 3;
238
239 /** BGP UPDATE AS_PATH Type: AS_CONFED_SET. */
240 public static final int AS_CONFED_SET = 4;
241
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800242 /**
243 * Gets the BGP AS_PATH type as a string.
244 *
245 * @param type the BGP AS_PATH type
246 * @return the BGP AS_PATH type as a string
247 */
248 public static String typeToString(int type) {
249 String typeString = "UNKNOWN";
250
251 switch (type) {
252 case AS_SET:
253 typeString = "AS_SET";
254 break;
255 case AS_SEQUENCE:
256 typeString = "AS_SEQUENCE";
257 break;
Pavlin Radoslavov49eb64d2014-11-10 17:03:19 -0800258 case AS_CONFED_SEQUENCE:
259 typeString = "AS_CONFED_SEQUENCE";
260 break;
261 case AS_CONFED_SET:
262 typeString = "AS_CONFED_SET";
263 break;
Pavlin Radoslavov2ce1c522014-11-07 10:32:37 -0800264 default:
265 break;
266 }
267 return typeString;
268 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700269 }
270
271 /**
272 * BGP UPDATE: NEXT_HOP related constants.
273 */
274 public static final class NextHop {
275 /**
276 * Default constructor.
277 * <p>
278 * The constructor is private to prevent creating an instance of
279 * this utility class.
280 */
281 private NextHop() {
282 }
283
284 /** BGP UPDATE Attributes Type Code NEXT_HOP. */
285 public static final int TYPE = 3;
286
287 /** BGP UPDATE Attributes Type Code NEXT_HOP length. */
288 public static final int LENGTH = 4;
289 }
290
291 /**
292 * BGP UPDATE: MULTI_EXIT_DISC related constants.
293 */
294 public static final class MultiExitDisc {
295 /**
296 * Default constructor.
297 * <p>
298 * The constructor is private to prevent creating an instance of
299 * this utility class.
300 */
301 private MultiExitDisc() {
302 }
303
304 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC. */
305 public static final int TYPE = 4;
306
307 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC length. */
308 public static final int LENGTH = 4;
309
310 /** BGP UPDATE Attributes lowest MULTI_EXIT_DISC value. */
311 public static final int LOWEST_MULTI_EXIT_DISC = 0;
312 }
313
314 /**
315 * BGP UPDATE: LOCAL_PREF related constants.
316 */
317 public static final class LocalPref {
318 /**
319 * Default constructor.
320 * <p>
321 * The constructor is private to prevent creating an instance of
322 * this utility class.
323 */
324 private LocalPref() {
325 }
326
327 /** BGP UPDATE Attributes Type Code LOCAL_PREF. */
328 public static final int TYPE = 5;
329
330 /** BGP UPDATE Attributes Type Code LOCAL_PREF length. */
331 public static final int LENGTH = 4;
332 }
333
334 /**
335 * BGP UPDATE: ATOMIC_AGGREGATE related constants.
336 */
337 public static final class AtomicAggregate {
338 /**
339 * Default constructor.
340 * <p>
341 * The constructor is private to prevent creating an instance of
342 * this utility class.
343 */
344 private AtomicAggregate() {
345 }
346
347 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE. */
348 public static final int TYPE = 6;
349
350 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE length. */
351 public static final int LENGTH = 0;
352 }
353
354 /**
355 * BGP UPDATE: AGGREGATOR related constants.
356 */
357 public static final class Aggregator {
358 /**
359 * Default constructor.
360 * <p>
361 * The constructor is private to prevent creating an instance of
362 * this utility class.
363 */
364 private Aggregator() {
365 }
366
367 /** BGP UPDATE Attributes Type Code AGGREGATOR. */
368 public static final int TYPE = 7;
369
370 /** BGP UPDATE Attributes Type Code AGGREGATOR length. */
371 public static final int LENGTH = 6;
372 }
373 }
374
375 /**
376 * BGP NOTIFICATION related constants.
377 */
378 public static final class Notifications {
379 /**
380 * Default constructor.
381 * <p>
382 * The constructor is private to prevent creating an instance of
383 * this utility class.
384 */
385 private Notifications() {
386 }
387
388 /**
389 * BGP NOTIFICATION: Message Header Error constants.
390 */
391 public static final class MessageHeaderError {
392 /**
393 * Default constructor.
394 * <p>
395 * The constructor is private to prevent creating an instance of
396 * this utility class.
397 */
398 private MessageHeaderError() {
399 }
400
401 /** Message Header Error code. */
402 public static final int ERROR_CODE = 1;
403
404 /** Message Header Error subcode: Connection Not Synchronized. */
405 public static final int CONNECTION_NOT_SYNCHRONIZED = 1;
406
407 /** Message Header Error subcode: Bad Message Length. */
408 public static final int BAD_MESSAGE_LENGTH = 2;
409
410 /** Message Header Error subcode: Bad Message Type. */
411 public static final int BAD_MESSAGE_TYPE = 3;
412 }
413
414 /**
415 * BGP NOTIFICATION: OPEN Message Error constants.
416 */
417 public static final class OpenMessageError {
418 /**
419 * Default constructor.
420 * <p>
421 * The constructor is private to prevent creating an instance of
422 * this utility class.
423 */
424 private OpenMessageError() {
425 }
426
427 /** OPEN Message Error code. */
428 public static final int ERROR_CODE = 2;
429
430 /** OPEN Message Error subcode: Unsupported Version Number. */
431 public static final int UNSUPPORTED_VERSION_NUMBER = 1;
432
433 /** OPEN Message Error subcode: Bad PEER AS. */
434 public static final int BAD_PEER_AS = 2;
435
436 /** OPEN Message Error subcode: Unacceptable Hold Time. */
437 public static final int UNACCEPTABLE_HOLD_TIME = 6;
438 }
439
440 /**
441 * BGP NOTIFICATION: UPDATE Message Error constants.
442 */
443 public static final class UpdateMessageError {
444 /**
445 * Default constructor.
446 * <p>
447 * The constructor is private to prevent creating an instance of
448 * this utility class.
449 */
450 private UpdateMessageError() {
451 }
452
453 /** UPDATE Message Error code. */
454 public static final int ERROR_CODE = 3;
455
456 /** UPDATE Message Error subcode: Malformed Attribute List. */
457 public static final int MALFORMED_ATTRIBUTE_LIST = 1;
458
459 /** UPDATE Message Error subcode: Unrecognized Well-known Attribute. */
460 public static final int UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;
461
462 /** UPDATE Message Error subcode: Missing Well-known Attribute. */
463 public static final int MISSING_WELL_KNOWN_ATTRIBUTE = 3;
464
465 /** UPDATE Message Error subcode: Attribute Flags Error. */
466 public static final int ATTRIBUTE_FLAGS_ERROR = 4;
467
468 /** UPDATE Message Error subcode: Attribute Length Error. */
469 public static final int ATTRIBUTE_LENGTH_ERROR = 5;
470
471 /** UPDATE Message Error subcode: Invalid ORIGIN Attribute. */
472 public static final int INVALID_ORIGIN_ATTRIBUTE = 6;
473
474 /** UPDATE Message Error subcode: Invalid NEXT_HOP Attribute. */
475 public static final int INVALID_NEXT_HOP_ATTRIBUTE = 8;
476
477 /** UPDATE Message Error subcode: Optional Attribute Error. Unused. */
478 public static final int OPTIONAL_ATTRIBUTE_ERROR = 9;
479
480 /** UPDATE Message Error subcode: Invalid Network Field. */
481 public static final int INVALID_NETWORK_FIELD = 10;
482
483 /** UPDATE Message Error subcode: Malformed AS_PATH. */
484 public static final int MALFORMED_AS_PATH = 11;
485 }
486
487 /**
488 * BGP NOTIFICATION: Hold Timer Expired constants.
489 */
490 public static final class HoldTimerExpired {
491 /**
492 * Default constructor.
493 * <p>
494 * The constructor is private to prevent creating an instance of
495 * this utility class.
496 */
497 private HoldTimerExpired() {
498 }
499
500 /** Hold Timer Expired code. */
501 public static final int ERROR_CODE = 4;
502 }
503
504 /** BGP NOTIFICATION message Error subcode: Unspecific. */
505 public static final int ERROR_SUBCODE_UNSPECIFIC = 0;
506 }
507}