blob: 31e2e76e504fea1dde8e326b5a2edc3badaa330d [file] [log] [blame]
Jonathan Hartac60c082014-09-23 08:55:17 -07001package org.onlab.onos.net.host;
2
Jonathan Hart09585c62014-09-23 16:58:04 -07003import java.util.HashSet;
4import java.util.Set;
5
Jonathan Hartac60c082014-09-23 08:55:17 -07006import org.onlab.onos.net.ConnectPoint;
Jonathan Hart09585c62014-09-23 16:58:04 -07007import org.onlab.packet.IpPrefix;
Jonathan Hartac60c082014-09-23 08:55:17 -07008import org.onlab.packet.MacAddress;
9
10/**
11 * Represents address information bound to a port.
12 */
Jonathan Hart09585c62014-09-23 16:58:04 -070013public 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 Hartac60c082014-09-23 08:55:17 -070035
36 /**
37 * Returns the connection point this address information is bound to.
38 *
39 * @return the connection point
40 */
Jonathan Hart09585c62014-09-23 16:58:04 -070041 public ConnectPoint connectPoint() {
42 return connectPoint;
43 }
Jonathan Hartac60c082014-09-23 08:55:17 -070044
45 /**
Jonathan Hart09585c62014-09-23 16:58:04 -070046 * Returns the set of IP addresses.
Jonathan Hartac60c082014-09-23 08:55:17 -070047 *
Jonathan Hart09585c62014-09-23 16:58:04 -070048 * @return the IP addresses
Jonathan Hartac60c082014-09-23 08:55:17 -070049 */
Jonathan Hart09585c62014-09-23 16:58:04 -070050 public Set<IpPrefix> ips() {
51 return ipAddresses;
52 }
Jonathan Hartac60c082014-09-23 08:55:17 -070053
54 /**
Jonathan Hart09585c62014-09-23 16:58:04 -070055 * Returns the MAC address.
Jonathan Hartac60c082014-09-23 08:55:17 -070056 *
Jonathan Hart09585c62014-09-23 16:58:04 -070057 * @return the MAC address
Jonathan Hartac60c082014-09-23 08:55:17 -070058 */
Jonathan Hart09585c62014-09-23 16:58:04 -070059 public MacAddress mac() {
60 return macAddress;
61 }
62
Jonathan Hartac60c082014-09-23 08:55:17 -070063}