blob: 1c1c791cb55d028e759b33f93cb73bbe545699f2 (
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.nio.ByteBuffer;
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 void build(ByteBuffer b) {
}
@Setter
@Getter
public static class Community {
int valueA;
int valueB;
}
}
|