blob: 2146364d6d0a32dfed112a9345dd82d15492aef3 (
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
30
31
32
33
34
35
36
37
38
39
40
|
package com.lumaserv.bgp.protocol.attribute;
import java.net.InetAddress;
import java.net.UnknownHostException;
import lombok.Getter;
import lombok.Setter;
@Getter
@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() {
return 3;
}
public byte[] build() {
return address;
}
public String toString() {
if (ip != null)
return ip.getHostAddress();
else
return address.toString();
}
}
|