Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.host; |
| 2 | |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 3 | import java.util.HashSet; |
| 4 | import java.util.Set; |
| 5 | |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 6 | import org.onlab.onos.net.ConnectPoint; |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 7 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 8 | import org.onlab.packet.MacAddress; |
| 9 | |
| 10 | /** |
| 11 | * Represents address information bound to a port. |
| 12 | */ |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 13 | public class PortAddresses { |
| 14 | |
| 15 | private final ConnectPoint connectPoint; |
| 16 | private final Set<IpPrefix> ipAddresses; |
| 17 | private final MacAddress macAddress; |
| 18 | |
| 19 | /** |
| 20 | * Constructs a PortAddress object for the given connection point, with a |
| 21 | * set of IP addresses and a MAC address. |
| 22 | * <p/> |
| 23 | * Both address parameters are optional and can be set to null. |
| 24 | * |
| 25 | * @param connectPoint the connection point these addresses are for |
| 26 | * @param ips a set of IP addresses |
| 27 | * @param mac a MAC address |
| 28 | */ |
| 29 | public PortAddresses(ConnectPoint connectPoint, |
| 30 | Set<IpPrefix> ips, MacAddress mac) { |
| 31 | this.connectPoint = connectPoint; |
| 32 | this.ipAddresses = (ips == null) ? null : new HashSet<>(ips); |
| 33 | this.macAddress = mac; |
| 34 | } |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Returns the connection point this address information is bound to. |
| 38 | * |
| 39 | * @return the connection point |
| 40 | */ |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 41 | public ConnectPoint connectPoint() { |
| 42 | return connectPoint; |
| 43 | } |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 46 | * Returns the set of IP addresses. |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 47 | * |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 48 | * @return the IP addresses |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 49 | */ |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 50 | public Set<IpPrefix> ips() { |
| 51 | return ipAddresses; |
| 52 | } |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 55 | * Returns the MAC address. |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 56 | * |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 57 | * @return the MAC address |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 58 | */ |
Jonathan Hart | 09585c6 | 2014-09-23 16:58:04 -0700 | [diff] [blame] | 59 | public MacAddress mac() { |
| 60 | return macAddress; |
| 61 | } |
| 62 | |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 63 | } |