aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpConstants.java
blob: 89060ad5aebba5935f0ebd072c9b9751a4479a92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
/*
 * Copyright 2014-2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.routing.bgp;

/**
 * BGP related constants.
 */
public final class BgpConstants {
    /**
     * Default constructor.
     * <p>
     * The constructor is private to prevent creating an instance of
     * this utility class.
     */
    private BgpConstants() {
    }

    /** BGP port number (RFC 4271). */
    public static final int BGP_PORT = 179;

    /** BGP version. */
    public static final int BGP_VERSION = 4;

    /** BGP OPEN message type. */
    public static final int BGP_TYPE_OPEN = 1;

    /** BGP UPDATE message type. */
    public static final int BGP_TYPE_UPDATE = 2;

    /** BGP NOTIFICATION message type. */
    public static final int BGP_TYPE_NOTIFICATION = 3;

    /** BGP KEEPALIVE message type. */
    public static final int BGP_TYPE_KEEPALIVE = 4;

    /** BGP Header Marker field length. */
    public static final int BGP_HEADER_MARKER_LENGTH = 16;

    /** BGP Header length. */
    public static final int BGP_HEADER_LENGTH = 19;

    /** BGP message maximum length. */
    public static final int BGP_MESSAGE_MAX_LENGTH = 4096;

    /** BGP OPEN message minimum length (BGP Header included). */
    public static final int BGP_OPEN_MIN_LENGTH = 29;

    /** BGP UPDATE message minimum length (BGP Header included). */
    public static final int BGP_UPDATE_MIN_LENGTH = 23;

    /** BGP NOTIFICATION message minimum length (BGP Header included). */
    public static final int BGP_NOTIFICATION_MIN_LENGTH = 21;

    /** BGP KEEPALIVE message expected length (BGP Header included). */
    public static final int BGP_KEEPALIVE_EXPECTED_LENGTH = 19;

    /** BGP KEEPALIVE messages transmitted per Hold interval. */
    public static final int BGP_KEEPALIVE_PER_HOLD_INTERVAL = 3;

    /** BGP KEEPALIVE messages minimum Holdtime (in seconds). */
    public static final int BGP_KEEPALIVE_MIN_HOLDTIME = 3;

    /** BGP KEEPALIVE messages minimum transmission interval (in seconds). */
    public static final int BGP_KEEPALIVE_MIN_INTERVAL = 1;

    /** BGP AS 0 (zero) value. See draft-ietf-idr-as0-06.txt Internet Draft. */
    public static final long BGP_AS_0 = 0;

    /**
     * BGP OPEN related constants.
     */
    public static final class Open {
        /**
         * Default constructor.
         * <p>
         * The constructor is private to prevent creating an instance of
         * this utility class.
         */
        private Open() {
        }

        /**
         * BGP OPEN: Optional Parameters related constants.
         */
        public static final class OptionalParameters {
        }

        /**
         * BGP OPEN: Capabilities related constants (RFC 5492).
         */
        public static final class Capabilities {
            /** BGP OPEN Optional Parameter Type: Capabilities. */
            public static final int TYPE = 2;

            /** BGP OPEN Optional Parameter minimum length. */
            public static final int MIN_LENGTH = 2;

            /**
             * BGP OPEN: Multiprotocol Extensions Capabilities (RFC 4760).
             */
            public static final class MultiprotocolExtensions {
                /** BGP OPEN Multiprotocol Extensions code. */
                public static final int CODE = 1;

                /** BGP OPEN Multiprotocol Extensions length. */
                public static final int LENGTH = 4;

                /** BGP OPEN Multiprotocol Extensions AFI: IPv4. */
                public static final int AFI_IPV4 = 1;

                /** BGP OPEN Multiprotocol Extensions AFI: IPv6. */
                public static final int AFI_IPV6 = 2;

                /** BGP OPEN Multiprotocol Extensions SAFI: unicast. */
                public static final int SAFI_UNICAST = 1;

                /** BGP OPEN Multiprotocol Extensions SAFI: multicast. */
                public static final int SAFI_MULTICAST = 2;
            }

            /**
             * BGP OPEN: Support for 4-octet AS Number Capability (RFC 6793).
             */
            public static final class As4Octet {
                /** BGP OPEN Support for 4-octet AS Number Capability code. */
                public static final int CODE = 65;

                /** BGP OPEN 4-octet AS Number Capability length. */
                public static final int LENGTH = 4;
            }
        }
    }

    /**
     * BGP UPDATE related constants.
     */
    public static final class Update {
        /**
         * Default constructor.
         * <p>
         * The constructor is private to prevent creating an instance of
         * this utility class.
         */
        private Update() {
        }

        /** BGP AS length. */
        public static final int AS_LENGTH = 2;

        /** BGP 4 Octet AS length (RFC 6793). */
        public static final int AS_4OCTET_LENGTH = 4;

        /**
         * BGP UPDATE: ORIGIN related constants.
         */
        public static final class Origin {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private Origin() {
            }

            /** BGP UPDATE Attributes Type Code ORIGIN. */
            public static final int TYPE = 1;

            /** BGP UPDATE Attributes Type Code ORIGIN length. */
            public static final int LENGTH = 1;

            /** BGP UPDATE ORIGIN: IGP. */
            public static final int IGP = 0;

            /** BGP UPDATE ORIGIN: EGP. */
            public static final int EGP = 1;

            /** BGP UPDATE ORIGIN: INCOMPLETE. */
            public static final int INCOMPLETE = 2;

            /**
             * Gets the BGP UPDATE origin type as a string.
             *
             * @param type the BGP UPDATE origin type
             * @return the BGP UPDATE origin type as a string
             */
            public static String typeToString(int type) {
                String typeString = "UNKNOWN";

                switch (type) {
                case IGP:
                    typeString = "IGP";
                    break;
                case EGP:
                    typeString = "EGP";
                    break;
                case INCOMPLETE:
                    typeString = "INCOMPLETE";
                    break;
                default:
                    break;
                }
                return typeString;
            }
        }

        /**
         * BGP UPDATE: AS_PATH related constants.
         */
        public static final class AsPath {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private AsPath() {
            }

            /** BGP UPDATE Attributes Type Code AS_PATH. */
            public static final int TYPE = 2;

            /** BGP UPDATE AS_PATH Type: AS_SET. */
            public static final int AS_SET = 1;

            /** BGP UPDATE AS_PATH Type: AS_SEQUENCE. */
            public static final int AS_SEQUENCE = 2;

            /** BGP UPDATE AS_PATH Type: AS_CONFED_SEQUENCE. */
            public static final int AS_CONFED_SEQUENCE = 3;

            /** BGP UPDATE AS_PATH Type: AS_CONFED_SET. */
            public static final int AS_CONFED_SET = 4;

            /**
             * Gets the BGP AS_PATH type as a string.
             *
             * @param type the BGP AS_PATH type
             * @return the BGP AS_PATH type as a string
             */
            public static String typeToString(int type) {
                String typeString = "UNKNOWN";

                switch (type) {
                case AS_SET:
                    typeString = "AS_SET";
                    break;
                case AS_SEQUENCE:
                    typeString = "AS_SEQUENCE";
                    break;
                case AS_CONFED_SEQUENCE:
                    typeString = "AS_CONFED_SEQUENCE";
                    break;
                case AS_CONFED_SET:
                    typeString = "AS_CONFED_SET";
                    break;
                default:
                    break;
                }
                return typeString;
            }
        }

        /**
         * BGP UPDATE: NEXT_HOP related constants.
         */
        public static final class NextHop {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private NextHop() {
            }

            /** BGP UPDATE Attributes Type Code NEXT_HOP. */
            public static final int TYPE = 3;

            /** BGP UPDATE Attributes Type Code NEXT_HOP length. */
            public static final int LENGTH = 4;
        }

        /**
         * BGP UPDATE: MULTI_EXIT_DISC related constants.
         */
        public static final class MultiExitDisc {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private MultiExitDisc() {
            }

            /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC. */
            public static final int TYPE = 4;

            /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC length. */
            public static final int LENGTH = 4;

            /** BGP UPDATE Attributes lowest MULTI_EXIT_DISC value. */
            public static final int LOWEST_MULTI_EXIT_DISC = 0;
        }

        /**
         * BGP UPDATE: LOCAL_PREF related constants.
         */
        public static final class LocalPref {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private LocalPref() {
            }

            /** BGP UPDATE Attributes Type Code LOCAL_PREF. */
            public static final int TYPE = 5;

            /** BGP UPDATE Attributes Type Code LOCAL_PREF length. */
            public static final int LENGTH = 4;
        }

        /**
         * BGP UPDATE: ATOMIC_AGGREGATE related constants.
         */
        public static final class AtomicAggregate {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private AtomicAggregate() {
            }

            /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE. */
            public static final int TYPE = 6;

            /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE length. */
            public static final int LENGTH = 0;
        }

        /**
         * BGP UPDATE: AGGREGATOR related constants.
         */
        public static final class Aggregator {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private Aggregator() {
            }

            /** BGP UPDATE Attributes Type Code AGGREGATOR. */
            public static final int TYPE = 7;

            /** BGP UPDATE Attributes Type Code AGGREGATOR length: 2 octet AS. */
            public static final int AS2_LENGTH = 6;

            /** BGP UPDATE Attributes Type Code AGGREGATOR length: 4 octet AS. */
            public static final int AS4_LENGTH = 8;
        }

        /**
         * BGP UPDATE: MP_REACH_NLRI related constants.
         */
        public static final class MpReachNlri {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private MpReachNlri() {
            }

            /** BGP UPDATE Attributes Type Code MP_REACH_NLRI. */
            public static final int TYPE = 14;

            /** BGP UPDATE Attributes Type Code MP_REACH_NLRI min length. */
            public static final int MIN_LENGTH = 5;
        }

        /**
         * BGP UPDATE: MP_UNREACH_NLRI related constants.
         */
        public static final class MpUnreachNlri {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private MpUnreachNlri() {
            }

            /** BGP UPDATE Attributes Type Code MP_UNREACH_NLRI. */
            public static final int TYPE = 15;

            /** BGP UPDATE Attributes Type Code MP_UNREACH_NLRI min length. */
            public static final int MIN_LENGTH = 3;
        }
    }

    /**
     * BGP NOTIFICATION related constants.
     */
    public static final class Notifications {
        /**
         * Default constructor.
         * <p>
         * The constructor is private to prevent creating an instance of
         * this utility class.
         */
        private Notifications() {
        }

        /**
         * BGP NOTIFICATION: Message Header Error constants.
         */
        public static final class MessageHeaderError {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private MessageHeaderError() {
            }

            /** Message Header Error code. */
            public static final int ERROR_CODE = 1;

            /** Message Header Error subcode: Connection Not Synchronized. */
            public static final int CONNECTION_NOT_SYNCHRONIZED = 1;

            /** Message Header Error subcode: Bad Message Length. */
            public static final int BAD_MESSAGE_LENGTH = 2;

            /** Message Header Error subcode: Bad Message Type. */
            public static final int BAD_MESSAGE_TYPE = 3;
        }

        /**
         * BGP NOTIFICATION: OPEN Message Error constants.
         */
        public static final class OpenMessageError {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private OpenMessageError() {
            }

            /** OPEN Message Error code. */
            public static final int ERROR_CODE = 2;

            /** OPEN Message Error subcode: Unsupported Version Number. */
            public static final int UNSUPPORTED_VERSION_NUMBER = 1;

            /** OPEN Message Error subcode: Bad PEER AS. */
            public static final int BAD_PEER_AS = 2;

            /** OPEN Message Error subcode: Unacceptable Hold Time. */
            public static final int UNACCEPTABLE_HOLD_TIME = 6;
        }

        /**
         * BGP NOTIFICATION: UPDATE Message Error constants.
         */
        public static final class UpdateMessageError {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private UpdateMessageError() {
            }

            /** UPDATE Message Error code. */
            public static final int ERROR_CODE = 3;

            /** UPDATE Message Error subcode: Malformed Attribute List. */
            public static final int MALFORMED_ATTRIBUTE_LIST = 1;

            /** UPDATE Message Error subcode: Unrecognized Well-known Attribute. */
            public static final int UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;

            /** UPDATE Message Error subcode: Missing Well-known Attribute. */
            public static final int MISSING_WELL_KNOWN_ATTRIBUTE = 3;

           /** UPDATE Message Error subcode: Attribute Flags Error. */
            public static final int ATTRIBUTE_FLAGS_ERROR = 4;

            /** UPDATE Message Error subcode: Attribute Length Error. */
            public static final int ATTRIBUTE_LENGTH_ERROR = 5;

            /** UPDATE Message Error subcode: Invalid ORIGIN Attribute. */
            public static final int INVALID_ORIGIN_ATTRIBUTE = 6;

            /** UPDATE Message Error subcode: Invalid NEXT_HOP Attribute. */
            public static final int INVALID_NEXT_HOP_ATTRIBUTE = 8;

            /** UPDATE Message Error subcode: Optional Attribute Error. Unused. */
            public static final int OPTIONAL_ATTRIBUTE_ERROR = 9;

            /** UPDATE Message Error subcode: Invalid Network Field. */
            public static final int INVALID_NETWORK_FIELD = 10;

            /** UPDATE Message Error subcode: Malformed AS_PATH. */
            public static final int MALFORMED_AS_PATH = 11;
        }

        /**
         * BGP NOTIFICATION: Hold Timer Expired constants.
         */
        public static final class HoldTimerExpired {
            /**
             * Default constructor.
             * <p>
             * The constructor is private to prevent creating an instance of
             * this utility class.
             */
            private HoldTimerExpired() {
            }

            /** Hold Timer Expired code. */
            public static final int ERROR_CODE = 4;
        }

        /** BGP NOTIFICATION message Error subcode: Unspecific. */
        public static final int ERROR_SUBCODE_UNSPECIFIC = 0;
    }
}