blob: 7c7f0603eb689de07e2ff904ae3584659b309b5b (
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
|
package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
public class CommunitiesAttribute implements PathAttribute {
List<Community> communities = new ArrayList<>();
public CommunitiesAttribute(byte typeCode, byte[] data) {
int offset = 0;
while (offset < data.length) {
communities.add(new Community()
.setValueA(((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF))
.setValueB(((data[offset + 2] & 0xFF) << 8) | (data[offset + 3] & 0xFF))
);
offset += 4;
}
}
public byte getTypeCode() {
return 8;
}
public byte[] build() {
return new byte[0];
}
@Setter
@Getter
public static class Community {
int valueA;
int valueB;
}
}
|