summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java
blob: f68677c45ca7e882ac9a5d48ddf4232a94ab92cc (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;
    int length;

    public String toString() {
        try {
            return InetAddress.getByAddress(address).getHostAddress() + "/" + length;
        } catch (UnknownHostException e) {
            e.printStackTrace();
            return null;
        }
    }

}