summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.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/IPPrefix.java
Initial commit
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java')
-rw-r--r--src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java b/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java
new file mode 100644
index 0000000..be70c4f
--- /dev/null
+++ b/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java
@@ -0,0 +1,27 @@
+package com.lumaserv.bgp.protocol;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+@NoArgsConstructor
+@Setter
+@Getter
+public class IPPrefix {
+
+ byte[] address;
+ byte length;
+
+ public String toString() {
+ try {
+ return InetAddress.getByAddress(address).getHostAddress() + "/" + length;
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+}