blob: 596720c5f75e3d36af4da77b5f8c0ae148653670 [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
171 /**
172 * Gets the BGP AS_PATH type as a string.
173 *
174 * @param type the BGP AS_PATH type
175 * @return the BGP AS_PATH type as a string
176 */
177 public static String typeToString(int type) {
178 String typeString = "UNKNOWN";
179
180 switch (type) {
181 case AS_SET:
182 typeString = "AS_SET";
183 break;
184 case AS_SEQUENCE:
185 typeString = "AS_SEQUENCE";
186 break;
187 default:
188 break;
189 }
190 return typeString;
191 }
Jonathan Hartab63aac2014-10-16 08:52:55 -0700192 }
193
194 /**
195 * BGP UPDATE: NEXT_HOP related constants.
196 */
197 public static final class NextHop {
198 /**
199 * Default constructor.
200 * <p>
201 * The constructor is private to prevent creating an instance of
202 * this utility class.
203 */
204 private NextHop() {
205 }
206
207 /** BGP UPDATE Attributes Type Code NEXT_HOP. */
208 public static final int TYPE = 3;
209
210 /** BGP UPDATE Attributes Type Code NEXT_HOP length. */
211 public static final int LENGTH = 4;
212 }
213
214 /**
215 * BGP UPDATE: MULTI_EXIT_DISC related constants.
216 */
217 public static final class MultiExitDisc {
218 /**
219 * Default constructor.
220 * <p>
221 * The constructor is private to prevent creating an instance of
222 * this utility class.
223 */
224 private MultiExitDisc() {
225 }
226
227 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC. */
228 public static final int TYPE = 4;
229
230 /** BGP UPDATE Attributes Type Code MULTI_EXIT_DISC length. */
231 public static final int LENGTH = 4;
232
233 /** BGP UPDATE Attributes lowest MULTI_EXIT_DISC value. */
234 public static final int LOWEST_MULTI_EXIT_DISC = 0;
235 }
236
237 /**
238 * BGP UPDATE: LOCAL_PREF related constants.
239 */
240 public static final class LocalPref {
241 /**
242 * Default constructor.
243 * <p>
244 * The constructor is private to prevent creating an instance of
245 * this utility class.
246 */
247 private LocalPref() {
248 }
249
250 /** BGP UPDATE Attributes Type Code LOCAL_PREF. */
251 public static final int TYPE = 5;
252
253 /** BGP UPDATE Attributes Type Code LOCAL_PREF length. */
254 public static final int LENGTH = 4;
255 }
256
257 /**
258 * BGP UPDATE: ATOMIC_AGGREGATE related constants.
259 */
260 public static final class AtomicAggregate {
261 /**
262 * Default constructor.
263 * <p>
264 * The constructor is private to prevent creating an instance of
265 * this utility class.
266 */
267 private AtomicAggregate() {
268 }
269
270 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE. */
271 public static final int TYPE = 6;
272
273 /** BGP UPDATE Attributes Type Code ATOMIC_AGGREGATE length. */
274 public static final int LENGTH = 0;
275 }
276
277 /**
278 * BGP UPDATE: AGGREGATOR related constants.
279 */
280 public static final class Aggregator {
281 /**
282 * Default constructor.
283 * <p>
284 * The constructor is private to prevent creating an instance of
285 * this utility class.
286 */
287 private Aggregator() {
288 }
289
290 /** BGP UPDATE Attributes Type Code AGGREGATOR. */
291 public static final int TYPE = 7;
292
293 /** BGP UPDATE Attributes Type Code AGGREGATOR length. */
294 public static final int LENGTH = 6;
295 }
296 }
297
298 /**
299 * BGP NOTIFICATION related constants.
300 */
301 public static final class Notifications {
302 /**
303 * Default constructor.
304 * <p>
305 * The constructor is private to prevent creating an instance of
306 * this utility class.
307 */
308 private Notifications() {
309 }
310
311 /**
312 * BGP NOTIFICATION: Message Header Error constants.
313 */
314 public static final class MessageHeaderError {
315 /**
316 * Default constructor.
317 * <p>
318 * The constructor is private to prevent creating an instance of
319 * this utility class.
320 */
321 private MessageHeaderError() {
322 }
323
324 /** Message Header Error code. */
325 public static final int ERROR_CODE = 1;
326
327 /** Message Header Error subcode: Connection Not Synchronized. */
328 public static final int CONNECTION_NOT_SYNCHRONIZED = 1;
329
330 /** Message Header Error subcode: Bad Message Length. */
331 public static final int BAD_MESSAGE_LENGTH = 2;
332
333 /** Message Header Error subcode: Bad Message Type. */
334 public static final int BAD_MESSAGE_TYPE = 3;
335 }
336
337 /**
338 * BGP NOTIFICATION: OPEN Message Error constants.
339 */
340 public static final class OpenMessageError {
341 /**
342 * Default constructor.
343 * <p>
344 * The constructor is private to prevent creating an instance of
345 * this utility class.
346 */
347 private OpenMessageError() {
348 }
349
350 /** OPEN Message Error code. */
351 public static final int ERROR_CODE = 2;
352
353 /** OPEN Message Error subcode: Unsupported Version Number. */
354 public static final int UNSUPPORTED_VERSION_NUMBER = 1;
355
356 /** OPEN Message Error subcode: Bad PEER AS. */
357 public static final int BAD_PEER_AS = 2;
358
359 /** OPEN Message Error subcode: Unacceptable Hold Time. */
360 public static final int UNACCEPTABLE_HOLD_TIME = 6;
361 }
362
363 /**
364 * BGP NOTIFICATION: UPDATE Message Error constants.
365 */
366 public static final class UpdateMessageError {
367 /**
368 * Default constructor.
369 * <p>
370 * The constructor is private to prevent creating an instance of
371 * this utility class.
372 */
373 private UpdateMessageError() {
374 }
375
376 /** UPDATE Message Error code. */
377 public static final int ERROR_CODE = 3;
378
379 /** UPDATE Message Error subcode: Malformed Attribute List. */
380 public static final int MALFORMED_ATTRIBUTE_LIST = 1;
381
382 /** UPDATE Message Error subcode: Unrecognized Well-known Attribute. */
383 public static final int UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;
384
385 /** UPDATE Message Error subcode: Missing Well-known Attribute. */
386 public static final int MISSING_WELL_KNOWN_ATTRIBUTE = 3;
387
388 /** UPDATE Message Error subcode: Attribute Flags Error. */
389 public static final int ATTRIBUTE_FLAGS_ERROR = 4;
390
391 /** UPDATE Message Error subcode: Attribute Length Error. */
392 public static final int ATTRIBUTE_LENGTH_ERROR = 5;
393
394 /** UPDATE Message Error subcode: Invalid ORIGIN Attribute. */
395 public static final int INVALID_ORIGIN_ATTRIBUTE = 6;
396
397 /** UPDATE Message Error subcode: Invalid NEXT_HOP Attribute. */
398 public static final int INVALID_NEXT_HOP_ATTRIBUTE = 8;
399
400 /** UPDATE Message Error subcode: Optional Attribute Error. Unused. */
401 public static final int OPTIONAL_ATTRIBUTE_ERROR = 9;
402
403 /** UPDATE Message Error subcode: Invalid Network Field. */
404 public static final int INVALID_NETWORK_FIELD = 10;
405
406 /** UPDATE Message Error subcode: Malformed AS_PATH. */
407 public static final int MALFORMED_AS_PATH = 11;
408 }
409
410 /**
411 * BGP NOTIFICATION: Hold Timer Expired constants.
412 */
413 public static final class HoldTimerExpired {
414 /**
415 * Default constructor.
416 * <p>
417 * The constructor is private to prevent creating an instance of
418 * this utility class.
419 */
420 private HoldTimerExpired() {
421 }
422
423 /** Hold Timer Expired code. */
424 public static final int ERROR_CODE = 4;
425 }
426
427 /** BGP NOTIFICATION message Error subcode: Unspecific. */
428 public static final int ERROR_SUBCODE_UNSPECIFIC = 0;
429 }
430}