summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java7
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java5
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java7
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java5
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java6
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java5
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java6
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java6
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java6
14 files changed, 46 insertions, 27 deletions
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java
index c579210..24a175e 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java
@@ -3,6 +3,8 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@Getter
@Setter
public class AS4AggregatorAttribute implements PathAttribute {
@@ -23,8 +25,9 @@ public class AS4AggregatorAttribute implements PathAttribute {
return 18;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
+ b.putInt(as);
+ b.put(origin);
}
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
index 796fbea..c41f07a 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
@@ -3,6 +3,7 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -33,8 +34,7 @@ public class AS4PathAttribute implements PathAttribute {
return 17;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
@Getter
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java
index 6405924..b39e473 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java
@@ -3,6 +3,7 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -28,8 +29,7 @@ public class ASPathAttribute implements PathAttribute {
return 2;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
@Getter
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java
index 732b018..f4fb0ef 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java
@@ -3,6 +3,8 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@Setter
@Getter
public class ASPathLimitAttribute implements PathAttribute {
@@ -22,8 +24,7 @@ public class ASPathLimitAttribute implements PathAttribute {
return 21;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java
index 25f3e70..4c73476 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java
@@ -3,6 +3,8 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@Getter
@Setter
public class AggregatorAttribute implements PathAttribute {
@@ -20,8 +22,9 @@ public class AggregatorAttribute implements PathAttribute {
return 7;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
+ b.putInt(as);
+ b.put(origin);
}
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java
index 6f7e479..7cc3aa5 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java
@@ -1,5 +1,7 @@
package com.lumaserv.bgp.protocol.attribute;
+import java.nio.ByteBuffer;
+
public class AtomicAggregateAttribute implements PathAttribute {
public AtomicAggregateAttribute(byte typeCode, byte[] data) {
@@ -10,8 +12,7 @@ public class AtomicAggregateAttribute implements PathAttribute {
return 6;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java
index 7c7f060..1c1c791 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java
@@ -3,6 +3,7 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -27,8 +28,7 @@ public class CommunitiesAttribute implements PathAttribute {
return 8;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
@Setter
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java
index 453f934..b4cf213 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java
@@ -3,6 +3,8 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@Getter
@Setter
public class DevelopmentAttribute implements PathAttribute {
@@ -13,8 +15,8 @@ public class DevelopmentAttribute implements PathAttribute {
this.data = data;
}
- public byte[] build() {
- return data;
+ public void build(ByteBuffer b) {
+ b.put(data);
}
public byte getTypeCode() {
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java
index 6909277..0765b3b 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java
@@ -3,6 +3,8 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@Getter
@Setter
public class ExtendedCommuntiesAttribute implements PathAttribute {
@@ -26,8 +28,7 @@ public class ExtendedCommuntiesAttribute implements PathAttribute {
return 16;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
public String toString() {
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java
index 921d5a5..3f10c42 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java
@@ -3,6 +3,7 @@ package com.lumaserv.bgp.protocol.attribute;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -41,8 +42,7 @@ public class LargeCommunityAttribute implements PathAttribute {
return 32;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
}
@Setter
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
index 2146364..c579295 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
@@ -6,6 +6,8 @@ import java.net.UnknownHostException;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@Getter
@Setter
public class NextHopAttribute implements PathAttribute {
@@ -27,8 +29,8 @@ public class NextHopAttribute implements PathAttribute {
return 3;
}
- public byte[] build() {
- return address;
+ public void build(ByteBuffer b) {
+ b.put(address);
}
public String toString() {
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java
index 9827bae..b8c996d 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java
@@ -1,5 +1,7 @@
package com.lumaserv.bgp.protocol.attribute;
+import java.nio.ByteBuffer;
+
import lombok.Getter;
import lombok.Setter;
@@ -40,8 +42,8 @@ public class OriginAttribute implements PathAttribute {
return 1;
}
- public byte[] build() {
- return new byte[0];
+ public void build(ByteBuffer b) {
+ b.put(origin);
}
public String toString() {
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java
index 4a10daa..95156ed 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java
@@ -1,9 +1,11 @@
package com.lumaserv.bgp.protocol.attribute;
+import java.nio.ByteBuffer;
+
public interface PathAttribute {
byte getTypeCode();
- byte[] build();
+ void build(ByteBuffer b);
static PathAttribute from(byte typeCode, byte[] data) {
switch (typeCode & 0xFF) {
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java
index 69dae2d..222c9bf 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java
@@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
+import java.nio.ByteBuffer;
+
@AllArgsConstructor
@Getter
@Setter
@@ -12,8 +14,8 @@ public class UnknownAttribute implements PathAttribute {
byte typeCode;
byte[] data;
- public byte[] build() {
- return data;
+ public void build(ByteBuffer b) {
+ b.put(b);
}
public byte getTypeCode() {