summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2023-03-07 00:48:57 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2023-11-11 23:59:40 +0100
commit91cb8c9aa089a57a03250088ef62030daf508880 (patch)
tree31014968de2b2dcbe32bc32891fbef6573632ac7
parent775790de50a74bbaca50bee837b3e41501699cb1 (diff)
Add flags to attributes
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java4
-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.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java4
-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.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/MPReachableNLRIAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/MPUnreachableNLRIAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java5
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/TunnelEncapsAttribute.java4
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java5
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/message/BGPUpdate.java4
18 files changed, 70 insertions, 4 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..9a55351 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4AggregatorAttribute.java
@@ -19,6 +19,10 @@ public class AS4AggregatorAttribute implements PathAttribute {
System.arraycopy(data, 4, origin, 0, origin.length);
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 18;
}
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 cd52173..5e66427 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AS4PathAttribute.java
@@ -31,6 +31,10 @@ public class AS4PathAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 17;
}
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 44deb8f..5d0ee3d 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathAttribute.java
@@ -46,6 +46,10 @@ public class ASPathAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 2;
}
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..8f3dfdc 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/ASPathLimitAttribute.java
@@ -18,6 +18,10 @@ public class ASPathLimitAttribute implements PathAttribute {
(data[4] & 0xFF);
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 21;
}
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..9f73424 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AggregatorAttribute.java
@@ -16,6 +16,10 @@ public class AggregatorAttribute implements PathAttribute {
System.arraycopy(data, 2, origin, 0, origin.length);
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 7;
}
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..cc7e49a 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/AtomicAggregateAttribute.java
@@ -6,6 +6,10 @@ public class AtomicAggregateAttribute implements PathAttribute {
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 6;
}
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..509b2c4 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/CommunitiesAttribute.java
@@ -23,6 +23,10 @@ public class CommunitiesAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 8;
}
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..38d84d2 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/DevelopmentAttribute.java
@@ -13,6 +13,10 @@ public class DevelopmentAttribute implements PathAttribute {
this.data = data;
}
+ public byte getFlags() {
+ return (byte)0x80;
+ }
+
public byte[] build() {
return data;
}
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..8b9e2f0 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/ExtendedCommuntiesAttribute.java
@@ -22,6 +22,10 @@ public class ExtendedCommuntiesAttribute implements PathAttribute {
an = ((data[6] & 0xFF) << 8) | (data[7] & 0xFF);
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 16;
}
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..3170ed6 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/LargeCommunityAttribute.java
@@ -37,6 +37,10 @@ public class LargeCommunityAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 32;
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/MPReachableNLRIAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/MPReachableNLRIAttribute.java
index 392b2de..a02f5c2 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/MPReachableNLRIAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/MPReachableNLRIAttribute.java
@@ -51,6 +51,10 @@ public class MPReachableNLRIAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return (byte)0x80;
+ }
+
public byte getTypeCode() {
return 14;
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/MPUnreachableNLRIAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/MPUnreachableNLRIAttribute.java
index fdbec22..a8a04e2 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/MPUnreachableNLRIAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/MPUnreachableNLRIAttribute.java
@@ -40,6 +40,10 @@ public class MPUnreachableNLRIAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return (byte)0x80;
+ }
+
public byte getTypeCode() {
return 15;
}
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 98cda4b..5cba05c 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
@@ -25,6 +25,10 @@ public class NextHopAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 3;
}
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 575b848..d907de2 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/OriginAttribute.java
@@ -38,6 +38,10 @@ public class OriginAttribute implements PathAttribute {
origin = Origin.fromByte(data[0]);
}
+ public byte getFlags() {
+ return 0x40;
+ }
+
public byte getTypeCode() {
return 1;
}
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 06bbed5..9a3a71b 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/PathAttribute.java
@@ -5,9 +5,10 @@ import com.lumaserv.bgp.BGPSession;
public interface PathAttribute {
byte getTypeCode();
+ byte getFlags();
byte[] build();
- static PathAttribute from(BGPSession session, byte typeCode, byte[] data) {
+ static PathAttribute from(BGPSession session, byte typeCode, byte flags, byte[] data) {
switch (typeCode & 0xFF) {
case 1:
return new OriginAttribute(typeCode, data);
@@ -40,7 +41,7 @@ public interface PathAttribute {
case 255:
return new DevelopmentAttribute(typeCode, data);
}
- return new UnknownAttribute(typeCode, data);
+ return new UnknownAttribute(typeCode, flags, data);
}
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/attribute/TunnelEncapsAttribute.java b/src/main/java/com/lumaserv/bgp/protocol/attribute/TunnelEncapsAttribute.java
index 0a29820..ee6941f 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/TunnelEncapsAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/TunnelEncapsAttribute.java
@@ -451,6 +451,10 @@ public class TunnelEncapsAttribute implements PathAttribute {
}
}
+ public byte getFlags() {
+ return (byte)0x80;
+ }
+
public byte getTypeCode() { return 23; }
public byte[] build() {
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..b9644a1 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/UnknownAttribute.java
@@ -10,12 +10,17 @@ import lombok.Setter;
public class UnknownAttribute implements PathAttribute {
byte typeCode;
+ byte flags;
byte[] data;
public byte[] build() {
return data;
}
+ public byte getFlags() {
+ return flags;
+ }
+
public byte getTypeCode() {
return typeCode;
}
diff --git a/src/main/java/com/lumaserv/bgp/protocol/message/BGPUpdate.java b/src/main/java/com/lumaserv/bgp/protocol/message/BGPUpdate.java
index 8621118..13d5aeb 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/message/BGPUpdate.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/message/BGPUpdate.java
@@ -50,7 +50,7 @@ public class BGPUpdate {
byte[] data = new byte[length];
System.arraycopy(message, offset, data, 0, length);
offset += length;
- attributes.add(PathAttribute.from(session, typeCode, data));
+ attributes.add(PathAttribute.from(session, typeCode, flags, data));
}
while (offset < message.length) {
IPPrefix prefix = new IPPrefix()
@@ -81,7 +81,7 @@ public class BGPUpdate {
int pos = message.position();
for (PathAttribute attr: attributes) {
// FIXME add header
- byte flags = 0b0100_0000; // TODO
+ byte flags = attr.getFlags();
int start = message.position();
message.put(flags);
message.put(attr.getTypeCode());