blob: c41f07a696b29cf701d86190cd1e15f1904d178a (
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
|
package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
public class AS4PathAttribute implements PathAttribute {
List<Segment> segments = new ArrayList<>();
public AS4PathAttribute(byte typeCode, byte[] data) {
int offset = 0;
while (offset < data.length) {
Segment segment = new Segment().setType(data[offset]);
byte length = data[offset + 1];
for(int i=0; i<length; i++)
segment.asns.add(
((data[offset + 2 + (i * 4)] & 0xFF) << 24) |
((data[offset + 3 + (i * 4)] & 0xFF) << 16) |
((data[offset + 4 + (i * 4)] & 0xFF) << 8) |
(data[offset + 5 + (i * 4)] & 0xFF)
);
offset += 2 + (length * 4);
segments.add(segment);
}
}
public byte getTypeCode() {
return 17;
}
public void build(ByteBuffer b) {
}
@Getter
@Setter
public static class Segment {
byte type;
List<Integer> asns = new ArrayList<>();
}
}
|