blob: c4069549c3242650fd1d0be3039e2ce624fd1d35 [file] [log] [blame]
tom80c0e5e2014-09-08 18:08:58 -07001package org.onlab.onos.net;
2
tom7869ad92014-09-09 14:32:08 -07003import org.onlab.packet.MACAddress;
Ayaka Koshibe3a25aec2014-09-12 11:52:53 -07004import org.onlab.packet.VLANID;
tom7869ad92014-09-09 14:32:08 -07005
tom80c0e5e2014-09-08 18:08:58 -07006import java.net.URI;
7
8/**
9 * Immutable representation of a host identity.
10 */
11public final class HostId extends ElementId {
12
13 // Public construction is prohibited
14 private HostId(URI uri) {
15 super(uri);
16 }
17
18 /**
19 * Creates a device id using the supplied URI.
20 *
21 * @param uri device URI
tom7869ad92014-09-09 14:32:08 -070022 * @return host identifier
tom80c0e5e2014-09-08 18:08:58 -070023 */
24 public static HostId hostId(URI uri) {
25 return new HostId(uri);
26 }
27
28 /**
29 * Creates a device id using the supplied URI string.
30 *
31 * @param string device URI string
tom7869ad92014-09-09 14:32:08 -070032 * @return host identifier
tom80c0e5e2014-09-08 18:08:58 -070033 */
34 public static HostId hostId(String string) {
tom568581d2014-09-08 20:13:36 -070035 return hostId(URI.create(string));
tom80c0e5e2014-09-08 18:08:58 -070036 }
37
tom7869ad92014-09-09 14:32:08 -070038 /**
39 * Creates a device id using the supplied MAC & VLAN ID.
40 *
41 * @param mac mac address
42 * @param vlanId vlan identifier
43 * @return host identifier
44 */
45 // FIXME: replace vlanId long with a rich data-type, e.g. VLanId or something like that
Ayaka Koshibe3a25aec2014-09-12 11:52:53 -070046 public static HostId hostId(MACAddress mac, VLANID vlanId) {
tom7869ad92014-09-09 14:32:08 -070047 // FIXME: use more efficient means of encoding
48 return hostId("nic" + ":" + mac + "/" + vlanId);
49 }
50
tom80c0e5e2014-09-08 18:08:58 -070051}