summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/IPPrefix.java
blob: fa3ca00039dfd4f11997c3bae5f81ef6c3865db9 (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
28
29
package com.lumaserv.bgp.protocol;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.net.InetAddress;
import java.net.UnknownHostException;

@AllArgsConstructor
@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;
        }
    }

}