summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
diff options
context:
space:
mode:
authorJanHolger <jan@bebendorf.eu>2021-07-06 17:01:33 +0200
committerJanHolger <jan@bebendorf.eu>2021-07-06 17:01:33 +0200
commit1d26c0a20d3c595d2846de31c2034e27595540b1 (patch)
treed19fb1f538c0c0cd5e0db55e45e1f16230782aac /src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
Initial commit
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java')
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
new file mode 100644
index 0000000..415dd5f
--- /dev/null
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
@@ -0,0 +1,45 @@
+package com.lumaserv.bgp.protocol.attribute;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 byte[] build() {
+ return new byte[0];
+ }
+
+ @Getter
+ @Setter
+ public static class Segment {
+ byte type;
+ List<Integer> asns = new ArrayList<>();
+ }
+
+}