blob: a53531607982af68e9c70fb0b3c7226f8f7b27fc [file] [log] [blame]
Jonathan Hart382623d2014-04-03 09:48:11 -07001package net.onrc.onos.apps.bgproute;
Jonathan Hart832a7cb2013-06-24 11:25:35 +12002
3import java.net.InetAddress;
4
Jonathan Hart832a7cb2013-06-24 11:25:35 +12005import org.codehaus.jackson.annotate.JsonProperty;
6
7import com.google.common.net.InetAddresses;
8
Jonathan Hart4e7c22e2014-04-09 10:59:34 -07009/**
10 * Configuration details for a BGP peer. It contains the peer's IP address and
11 * an interface name which maps to the interface they are attached at.
12 */
Jonathan Hart832a7cb2013-06-24 11:25:35 +120013public class BgpPeer {
Ray Milkey269ffb92014-04-03 14:43:30 -070014 private final String interfaceName;
15 private final InetAddress ipAddress;
Jonathan Hart4aa2b4e2013-09-24 14:50:23 +120016
Jonathan Hart4e7c22e2014-04-09 10:59:34 -070017 /**
18 * Class constructor, taking the interface name and IP address of the peer.
19 *
20 * @param interfaceName the String name of the interface which can be used
21 * to look up the interface this peer is attached at
22 * @param ipAddress the IP address of the peer as a String
23 */
Ray Milkey269ffb92014-04-03 14:43:30 -070024 public BgpPeer(@JsonProperty("interface") String interfaceName,
25 @JsonProperty("ipAddress") String ipAddress) {
26 this.interfaceName = interfaceName;
27 this.ipAddress = InetAddresses.forString(ipAddress);
28 }
29
Jonathan Hart4e7c22e2014-04-09 10:59:34 -070030 /**
31 * Gets the interface name.
32 *
33 * @return the interface name as a String
34 */
Ray Milkey269ffb92014-04-03 14:43:30 -070035 public String getInterfaceName() {
36 return interfaceName;
37 }
38
Jonathan Hart4e7c22e2014-04-09 10:59:34 -070039 /**
40 * Gets the IP address of the peer.
41 *
42 * @return the IP address as an {@link InetAddress} object
43 */
Ray Milkey269ffb92014-04-03 14:43:30 -070044 public InetAddress getIpAddress() {
45 return ipAddress;
46 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +120047}