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
|
package com.lumaserv.bgp.protocol.attribute;
import java.nio.ByteBuffer;
public interface PathAttribute {
byte getTypeCode();
void build(ByteBuffer b);
static PathAttribute from(byte typeCode, byte[] data) {
switch (typeCode & 0xFF) {
case 1:
return new OriginAttribute(typeCode, data);
case 2:
return new ASPathAttribute(typeCode, data);
case 3:
return new NextHopAttribute(typeCode, data);
case 6:
return new AtomicAggregateAttribute(typeCode, data);
case 7:
return new AggregatorAttribute(typeCode, data);
case 8:
return new CommunitiesAttribute(typeCode, data);
case 14:
return new MPReachableNLRIAttribute(typeCode, data);
case 15:
return new MPUnreachableNLRIAttribute(typeCode, data);
case 16:
return new ExtendedCommuntiesAttribute(typeCode, data);
case 17:
return new AS4PathAttribute(typeCode, data);
case 18:
return new AS4AggregatorAttribute(typeCode, data);
case 21:
return new ASPathLimitAttribute(typeCode, data);
case 32:
return new LargeCommunityAttribute(typeCode, data);
case 255:
return new DevelopmentAttribute(typeCode, data);
}
return new UnknownAttribute(typeCode, data);
}
}
|