summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java')
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java15
1 files changed, 15 insertions, 0 deletions
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 14d5367..2146364 100644
--- a/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
+++ b/src/main/java/com/lumaserv/bgp/protocol/attribute/NextHopAttribute.java
@@ -1,5 +1,8 @@
package com.lumaserv.bgp.protocol.attribute;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
import lombok.Getter;
import lombok.Setter;
@@ -8,10 +11,16 @@ import lombok.Setter;
public class NextHopAttribute implements PathAttribute {
byte[] address;
+ InetAddress ip;
public NextHopAttribute(byte typeCode, byte[] data) {
this.address = new byte[data.length];
System.arraycopy(data, 0, address, 0, address.length);
+ try {
+ ip = InetAddress.getByAddress(address);
+ } catch (UnknownHostException ex) {
+ // Ignore
+ }
}
public byte getTypeCode() {
@@ -22,4 +31,10 @@ public class NextHopAttribute implements PathAttribute {
return address;
}
+ public String toString() {
+ if (ip != null)
+ return ip.getHostAddress();
+ else
+ return address.toString();
+ }
}