blob: 1c1f2d7149ade525c5cafcc5b462616b417d6062 [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;
4
tom80c0e5e2014-09-08 18:08:58 -07005import java.net.URI;
6
7/**
8 * Immutable representation of a host identity.
9 */
10public final class HostId extends ElementId {
11
12 // Public construction is prohibited
13 private HostId(URI uri) {
14 super(uri);
15 }
16
17 /**
18 * Creates a device id using the supplied URI.
19 *
20 * @param uri device URI
tom7869ad92014-09-09 14:32:08 -070021 * @return host identifier
tom80c0e5e2014-09-08 18:08:58 -070022 */
23 public static HostId hostId(URI uri) {
24 return new HostId(uri);
25 }
26
27 /**
28 * Creates a device id using the supplied URI string.
29 *
30 * @param string device URI string
tom7869ad92014-09-09 14:32:08 -070031 * @return host identifier
tom80c0e5e2014-09-08 18:08:58 -070032 */
33 public static HostId hostId(String string) {
tom568581d2014-09-08 20:13:36 -070034 return hostId(URI.create(string));
tom80c0e5e2014-09-08 18:08:58 -070035 }
36
tom7869ad92014-09-09 14:32:08 -070037 /**
38 * Creates a device id using the supplied MAC & VLAN ID.
39 *
40 * @param mac mac address
41 * @param vlanId vlan identifier
42 * @return host identifier
43 */
44 // FIXME: replace vlanId long with a rich data-type, e.g. VLanId or something like that
45 public static HostId hostId(MACAddress mac, long vlanId) {
46 // FIXME: use more efficient means of encoding
47 return hostId("nic" + ":" + mac + "/" + vlanId);
48 }
49
tom80c0e5e2014-09-08 18:08:58 -070050}