blob: 3fc3127a7215b836faa8b6e3dc8d6b3ff417d538 [file] [log] [blame]
tomb36046e2014-08-27 00:22:24 -07001package org.onlab.onos.net;
2
tom545708e2014-10-09 17:10:02 -07003import static org.onlab.onos.net.PortNumber.P0;
4
tomb36046e2014-08-27 00:22:24 -07005/**
6 * Representation of a network edge location where an end-station host is
7 * connected.
8 */
tombb58c202014-09-07 22:51:50 -07009public class HostLocation extends ConnectPoint {
10
tom545708e2014-10-09 17:10:02 -070011 /**
12 * Represents a no location or an unknown location.
13 */
14 public static final HostLocation NONE = new HostLocation(DeviceId.NONE, P0, 0L);
15
toma56d5fe2014-09-17 11:05:47 -070016 // Note that time is explicitly excluded from the notion of equality.
tombb58c202014-09-07 22:51:50 -070017 private final long time;
18
tomf5d85d42014-10-02 05:27:56 -070019 /**
20 * Creates a new host location using the supplied device & port.
21 *
22 * @param deviceId device identity
23 * @param portNumber device port number
24 * @param time time when detected, in millis since start of epoch
25 */
tombb58c202014-09-07 22:51:50 -070026 public HostLocation(DeviceId deviceId, PortNumber portNumber, long time) {
27 super(deviceId, portNumber);
28 this.time = time;
29 }
tomb36046e2014-08-27 00:22:24 -070030
31 /**
tom297dfc02014-10-08 10:42:56 -070032 * Creates a new host location derived from the supplied connection point.
33 *
34 * @param connectPoint connection point
35 * @param time time when detected, in millis since start of epoch
36 */
37 public HostLocation(ConnectPoint connectPoint, long time) {
38 super(connectPoint.deviceId(), connectPoint.port());
39 this.time = time;
40 }
41
42 /**
tomf5d85d42014-10-02 05:27:56 -070043 * Returns the time when the location was established, given in
tomb36046e2014-08-27 00:22:24 -070044 * milliseconds since start of epoch.
45 *
tomf5d85d42014-10-02 05:27:56 -070046 * @return time in milliseconds since start of epoch
tomb36046e2014-08-27 00:22:24 -070047 */
tombb58c202014-09-07 22:51:50 -070048 public long time() {
49 return time;
50 }
51
tomb36046e2014-08-27 00:22:24 -070052}