summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java
blob: be70c4f67b0f9135766e7dc1f0bf007e4baaa92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
        }
    }

}