Jonathan Hart | 382623d | 2014-04-03 09:48:11 -0700 | [diff] [blame] | 1 | package net.onrc.onos.apps.bgproute; |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 2 | |
| 3 | import java.net.InetAddress; |
| 4 | |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 5 | import org.codehaus.jackson.annotate.JsonProperty; |
| 6 | |
| 7 | import com.google.common.net.InetAddresses; |
| 8 | |
Jonathan Hart | 4e7c22e | 2014-04-09 10:59:34 -0700 | [diff] [blame] | 9 | /** |
| 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 Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 13 | public class BgpPeer { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 14 | private final String interfaceName; |
| 15 | private final InetAddress ipAddress; |
Jonathan Hart | 4aa2b4e | 2013-09-24 14:50:23 +1200 | [diff] [blame] | 16 | |
Jonathan Hart | 4e7c22e | 2014-04-09 10:59:34 -0700 | [diff] [blame] | 17 | /** |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 24 | public BgpPeer(@JsonProperty("interface") String interfaceName, |
| 25 | @JsonProperty("ipAddress") String ipAddress) { |
| 26 | this.interfaceName = interfaceName; |
| 27 | this.ipAddress = InetAddresses.forString(ipAddress); |
| 28 | } |
| 29 | |
Jonathan Hart | 4e7c22e | 2014-04-09 10:59:34 -0700 | [diff] [blame] | 30 | /** |
| 31 | * Gets the interface name. |
| 32 | * |
| 33 | * @return the interface name as a String |
| 34 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 35 | public String getInterfaceName() { |
| 36 | return interfaceName; |
| 37 | } |
| 38 | |
Jonathan Hart | 4e7c22e | 2014-04-09 10:59:34 -0700 | [diff] [blame] | 39 | /** |
| 40 | * Gets the IP address of the peer. |
| 41 | * |
| 42 | * @return the IP address as an {@link InetAddress} object |
| 43 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 44 | public InetAddress getIpAddress() { |
| 45 | return ipAddress; |
| 46 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 47 | } |