Showing
16 changed files
with
156 additions
and
147 deletions
... | @@ -141,7 +141,7 @@ public class TopologyResource extends BaseResource { | ... | @@ -141,7 +141,7 @@ public class TopologyResource extends BaseResource { |
141 | private ObjectNode json(ObjectMapper mapper, ElementId id, int group, | 141 | private ObjectNode json(ObjectMapper mapper, ElementId id, int group, |
142 | String label, boolean isOnline) { | 142 | String label, boolean isOnline) { |
143 | return mapper.createObjectNode() | 143 | return mapper.createObjectNode() |
144 | - .put("name", id.uri().toString()) | 144 | + .put("name", id.toString()) |
145 | .put("label", label) | 145 | .put("label", label) |
146 | .put("group", group) | 146 | .put("group", group) |
147 | .put("online", isOnline); | 147 | .put("online", isOnline); |
... | @@ -202,7 +202,7 @@ public class TopologyResource extends BaseResource { | ... | @@ -202,7 +202,7 @@ public class TopologyResource extends BaseResource { |
202 | // Returns a formatted string for the element associated with the given | 202 | // Returns a formatted string for the element associated with the given |
203 | // connection point. | 203 | // connection point. |
204 | private static String id(ConnectPoint cp) { | 204 | private static String id(ConnectPoint cp) { |
205 | - return cp.elementId().uri().toString(); | 205 | + return cp.elementId().toString(); |
206 | } | 206 | } |
207 | 207 | ||
208 | } | 208 | } | ... | ... |
... | @@ -21,14 +21,14 @@ public final class Comparators { | ... | @@ -21,14 +21,14 @@ public final class Comparators { |
21 | public static final Comparator<ElementId> ELEMENT_ID_COMPARATOR = new Comparator<ElementId>() { | 21 | public static final Comparator<ElementId> ELEMENT_ID_COMPARATOR = new Comparator<ElementId>() { |
22 | @Override | 22 | @Override |
23 | public int compare(ElementId id1, ElementId id2) { | 23 | public int compare(ElementId id1, ElementId id2) { |
24 | - return id1.uri().toString().compareTo(id2.uri().toString()); | 24 | + return id1.toString().compareTo(id2.toString()); |
25 | } | 25 | } |
26 | }; | 26 | }; |
27 | 27 | ||
28 | public static final Comparator<Element> ELEMENT_COMPARATOR = new Comparator<Element>() { | 28 | public static final Comparator<Element> ELEMENT_COMPARATOR = new Comparator<Element>() { |
29 | @Override | 29 | @Override |
30 | public int compare(Element e1, Element e2) { | 30 | public int compare(Element e1, Element e2) { |
31 | - return e1.id().uri().toString().compareTo(e2.id().uri().toString()); | 31 | + return e1.id().toString().compareTo(e2.id().toString()); |
32 | } | 32 | } |
33 | }; | 33 | }; |
34 | 34 | ... | ... |
1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
2 | 2 | ||
3 | import java.net.URI; | 3 | import java.net.URI; |
4 | +import java.util.Objects; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * Immutable representation of a device identity. | 7 | * Immutable representation of a device identity. |
7 | */ | 8 | */ |
8 | public final class DeviceId extends ElementId { | 9 | public final class DeviceId extends ElementId { |
9 | 10 | ||
11 | + /** | ||
12 | + * Represents either no device, or an unspecified device. | ||
13 | + */ | ||
14 | + public static final DeviceId NONE = deviceId("none:none"); | ||
15 | + | ||
16 | + private final URI uri; | ||
17 | + private final String str; | ||
18 | + | ||
10 | // Public construction is prohibited | 19 | // Public construction is prohibited |
11 | private DeviceId(URI uri) { | 20 | private DeviceId(URI uri) { |
12 | - super(uri); | 21 | + this.uri = uri; |
22 | + this.str = uri.toString(); | ||
23 | + } | ||
24 | + | ||
25 | + | ||
26 | + // Default constructor for serialization | ||
27 | + protected DeviceId() { | ||
28 | + this.uri = null; | ||
29 | + this.str = null; | ||
13 | } | 30 | } |
14 | 31 | ||
15 | /** | 32 | /** |
... | @@ -30,4 +47,36 @@ public final class DeviceId extends ElementId { | ... | @@ -30,4 +47,36 @@ public final class DeviceId extends ElementId { |
30 | return deviceId(URI.create(string)); | 47 | return deviceId(URI.create(string)); |
31 | } | 48 | } |
32 | 49 | ||
50 | + /** | ||
51 | + * Returns the backing URI. | ||
52 | + * | ||
53 | + * @return backing URI | ||
54 | + */ | ||
55 | + public URI uri() { | ||
56 | + return uri; | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int hashCode() { | ||
61 | + return Objects.hash(str); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public boolean equals(Object obj) { | ||
66 | + if (this == obj) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + if (obj instanceof DeviceId) { | ||
70 | + final DeviceId that = (DeviceId) obj; | ||
71 | + return this.getClass() == that.getClass() && | ||
72 | + Objects.equals(this.str, that.str); | ||
73 | + } | ||
74 | + return false; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public String toString() { | ||
79 | + return str; | ||
80 | + } | ||
81 | + | ||
33 | } | 82 | } | ... | ... |
1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
2 | 2 | ||
3 | -import java.net.URI; | ||
4 | -import java.util.Objects; | ||
5 | - | ||
6 | /** | 3 | /** |
7 | * Immutable representation of a network element identity. | 4 | * Immutable representation of a network element identity. |
8 | */ | 5 | */ |
9 | public abstract class ElementId { | 6 | public abstract class ElementId { |
10 | - | ||
11 | - private final URI uri; | ||
12 | - private final String str; | ||
13 | - | ||
14 | - // Default constructor for serialization | ||
15 | - protected ElementId() { | ||
16 | - this.uri = null; | ||
17 | - this.str = null; | ||
18 | - } | ||
19 | - | ||
20 | - /** | ||
21 | - * Creates an element identifier using the supplied URI. | ||
22 | - * | ||
23 | - * @param uri backing URI | ||
24 | - */ | ||
25 | - protected ElementId(URI uri) { | ||
26 | - this.uri = uri; | ||
27 | - this.str = uri.toString(); | ||
28 | - } | ||
29 | - | ||
30 | - /** | ||
31 | - * Returns the backing URI. | ||
32 | - * | ||
33 | - * @return backing URI | ||
34 | - */ | ||
35 | - public URI uri() { | ||
36 | - return uri; | ||
37 | - } | ||
38 | - | ||
39 | - @Override | ||
40 | - public int hashCode() { | ||
41 | - return Objects.hash(str); | ||
42 | - } | ||
43 | - | ||
44 | - @Override | ||
45 | - public boolean equals(Object obj) { | ||
46 | - if (this == obj) { | ||
47 | - return true; | ||
48 | - } | ||
49 | - if (obj instanceof ElementId) { | ||
50 | - final ElementId that = (ElementId) obj; | ||
51 | - return this.getClass() == that.getClass() && | ||
52 | - Objects.equals(this.str, that.str); | ||
53 | - } | ||
54 | - return false; | ||
55 | - } | ||
56 | - | ||
57 | - @Override | ||
58 | - public String toString() { | ||
59 | - return str; | ||
60 | - } | ||
61 | - | ||
62 | } | 7 | } | ... | ... |
... | @@ -3,44 +3,69 @@ package org.onlab.onos.net; | ... | @@ -3,44 +3,69 @@ package org.onlab.onos.net; |
3 | import org.onlab.packet.MacAddress; | 3 | import org.onlab.packet.MacAddress; |
4 | import org.onlab.packet.VlanId; | 4 | import org.onlab.packet.VlanId; |
5 | 5 | ||
6 | -import java.net.URI; | 6 | +import java.util.Objects; |
7 | + | ||
8 | +import static com.google.common.base.Preconditions.checkArgument; | ||
7 | 9 | ||
8 | /** | 10 | /** |
9 | * Immutable representation of a host identity. | 11 | * Immutable representation of a host identity. |
10 | */ | 12 | */ |
11 | public final class HostId extends ElementId { | 13 | public final class HostId extends ElementId { |
12 | 14 | ||
13 | - private static final String NIC = "nic"; | ||
14 | - | ||
15 | /** | 15 | /** |
16 | * Represents either no host, or an unspecified host; used for creating | 16 | * Represents either no host, or an unspecified host; used for creating |
17 | * open ingress/egress edge links. | 17 | * open ingress/egress edge links. |
18 | */ | 18 | */ |
19 | - public static final HostId NONE = hostId(NIC + ":none-0"); | 19 | + public static final HostId NONE = new HostId(MacAddress.ZERO, VlanId.NONE); |
20 | + | ||
21 | + private static final int MAC_LENGTH = 17; | ||
22 | + private static final int MIN_ID_LENGTH = 19; | ||
23 | + | ||
24 | + private final MacAddress mac; | ||
25 | + private final VlanId vlanId; | ||
20 | 26 | ||
21 | // Public construction is prohibited | 27 | // Public construction is prohibited |
22 | - private HostId(URI uri) { | 28 | + private HostId(MacAddress mac, VlanId vlanId) { |
23 | - super(uri); | 29 | + this.mac = mac; |
30 | + this.vlanId = vlanId; | ||
31 | + } | ||
32 | + | ||
33 | + // Default constructor for serialization | ||
34 | + private HostId() { | ||
35 | + this.mac = null; | ||
36 | + this.vlanId = null; | ||
24 | } | 37 | } |
25 | 38 | ||
26 | /** | 39 | /** |
27 | - * Creates a device id using the supplied URI. | 40 | + * Returns the host MAC address. |
28 | * | 41 | * |
29 | - * @param uri device URI | 42 | + * @return MAC address |
30 | - * @return host identifier | 43 | + */ |
44 | + public MacAddress mac() { | ||
45 | + return mac; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Returns the host MAC address. | ||
50 | + * | ||
51 | + * @return MAC address | ||
31 | */ | 52 | */ |
32 | - public static HostId hostId(URI uri) { | 53 | + public VlanId vlanId() { |
33 | - return new HostId(uri); | 54 | + return vlanId; |
34 | } | 55 | } |
35 | 56 | ||
36 | /** | 57 | /** |
37 | - * Creates a device id using the supplied URI string. | 58 | + * Creates a device id using the supplied ID string. |
38 | * | 59 | * |
39 | * @param string device URI string | 60 | * @param string device URI string |
40 | * @return host identifier | 61 | * @return host identifier |
41 | */ | 62 | */ |
42 | public static HostId hostId(String string) { | 63 | public static HostId hostId(String string) { |
43 | - return hostId(URI.create(string)); | 64 | + checkArgument(string.length() >= MIN_ID_LENGTH, |
65 | + "Host ID must be at least %s characters", MIN_ID_LENGTH); | ||
66 | + MacAddress mac = MacAddress.valueOf(string.substring(0, MAC_LENGTH)); | ||
67 | + VlanId vlanId = VlanId.vlanId(Short.parseShort(string.substring(MAC_LENGTH + 1))); | ||
68 | + return new HostId(mac, vlanId); | ||
44 | } | 69 | } |
45 | 70 | ||
46 | /** | 71 | /** |
... | @@ -51,7 +76,7 @@ public final class HostId extends ElementId { | ... | @@ -51,7 +76,7 @@ public final class HostId extends ElementId { |
51 | * @return host identifier | 76 | * @return host identifier |
52 | */ | 77 | */ |
53 | public static HostId hostId(MacAddress mac, VlanId vlanId) { | 78 | public static HostId hostId(MacAddress mac, VlanId vlanId) { |
54 | - return hostId(NIC + ":" + mac + "-" + vlanId); | 79 | + return new HostId(mac, vlanId); |
55 | } | 80 | } |
56 | 81 | ||
57 | /** | 82 | /** |
... | @@ -64,4 +89,26 @@ public final class HostId extends ElementId { | ... | @@ -64,4 +89,26 @@ public final class HostId extends ElementId { |
64 | return hostId(mac, VlanId.vlanId(VlanId.UNTAGGED)); | 89 | return hostId(mac, VlanId.vlanId(VlanId.UNTAGGED)); |
65 | } | 90 | } |
66 | 91 | ||
92 | + public String toString() { | ||
93 | + return mac + "/" + vlanId; | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public int hashCode() { | ||
98 | + return Objects.hash(mac, vlanId); | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public boolean equals(Object obj) { | ||
103 | + if (this == obj) { | ||
104 | + return true; | ||
105 | + } | ||
106 | + if (obj instanceof HostId) { | ||
107 | + final HostId other = (HostId) obj; | ||
108 | + return Objects.equals(this.mac, other.mac) && | ||
109 | + Objects.equals(this.vlanId, other.vlanId); | ||
110 | + } | ||
111 | + return false; | ||
112 | + } | ||
113 | + | ||
67 | } | 114 | } | ... | ... |
1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
2 | 2 | ||
3 | +import static org.onlab.onos.net.PortNumber.P0; | ||
4 | + | ||
3 | /** | 5 | /** |
4 | * Representation of a network edge location where an end-station host is | 6 | * Representation of a network edge location where an end-station host is |
5 | * connected. | 7 | * connected. |
6 | */ | 8 | */ |
7 | public class HostLocation extends ConnectPoint { | 9 | public class HostLocation extends ConnectPoint { |
8 | 10 | ||
11 | + /** | ||
12 | + * Represents a no location or an unknown location. | ||
13 | + */ | ||
14 | + public static final HostLocation NONE = new HostLocation(DeviceId.NONE, P0, 0L); | ||
15 | + | ||
9 | // Note that time is explicitly excluded from the notion of equality. | 16 | // Note that time is explicitly excluded from the notion of equality. |
10 | private final long time; | 17 | private final long time; |
11 | 18 | ... | ... |
... | @@ -18,8 +18,8 @@ public class DefaultEdgeLinkTest { | ... | @@ -18,8 +18,8 @@ public class DefaultEdgeLinkTest { |
18 | 18 | ||
19 | private static final ProviderId PID = new ProviderId("of", "foo"); | 19 | private static final ProviderId PID = new ProviderId("of", "foo"); |
20 | private static final DeviceId DID1 = deviceId("of:foo"); | 20 | private static final DeviceId DID1 = deviceId("of:foo"); |
21 | - private static final HostId HID1 = hostId("nic:foobar"); | 21 | + private static final HostId HID1 = hostId("00:00:00:00:00:01/-1"); |
22 | - private static final HostId HID2 = hostId("nic:barfoo"); | 22 | + private static final HostId HID2 = hostId("00:00:00:00:00:01/-1"); |
23 | private static final PortNumber P0 = portNumber(0); | 23 | private static final PortNumber P0 = portNumber(0); |
24 | private static final PortNumber P1 = portNumber(1); | 24 | private static final PortNumber P1 = portNumber(1); |
25 | 25 | ||
... | @@ -35,12 +35,8 @@ public class DefaultEdgeLinkTest { | ... | @@ -35,12 +35,8 @@ public class DefaultEdgeLinkTest { |
35 | EdgeLink l4 = new DefaultEdgeLink(PID, cp(HID2, P0), | 35 | EdgeLink l4 = new DefaultEdgeLink(PID, cp(HID2, P0), |
36 | new HostLocation(DID1, P1, 123L), false); | 36 | new HostLocation(DID1, P1, 123L), false); |
37 | 37 | ||
38 | - EdgeLink l5 = new DefaultEdgeLink(PID, cp(HID1, P0), | ||
39 | - new HostLocation(DID1, P1, 123L), false); | ||
40 | - | ||
41 | new EqualsTester().addEqualityGroup(l1, l2) | 38 | new EqualsTester().addEqualityGroup(l1, l2) |
42 | .addEqualityGroup(l3, l4) | 39 | .addEqualityGroup(l3, l4) |
43 | - .addEqualityGroup(l5) | ||
44 | .testEquals(); | 40 | .testEquals(); |
45 | } | 41 | } |
46 | 42 | ... | ... |
... | @@ -8,7 +8,7 @@ import static org.onlab.onos.net.DeviceId.deviceId; | ... | @@ -8,7 +8,7 @@ import static org.onlab.onos.net.DeviceId.deviceId; |
8 | /** | 8 | /** |
9 | * Test of the device identifier. | 9 | * Test of the device identifier. |
10 | */ | 10 | */ |
11 | -public class DeviceIdTest extends ElementIdTest { | 11 | +public class DeviceIdTest { |
12 | 12 | ||
13 | @Test | 13 | @Test |
14 | public void basics() { | 14 | public void basics() { | ... | ... |
1 | -package org.onlab.onos.net; | ||
2 | - | ||
3 | -import com.google.common.testing.EqualsTester; | ||
4 | -import org.junit.Test; | ||
5 | - | ||
6 | -import java.net.URI; | ||
7 | - | ||
8 | -import static org.junit.Assert.assertEquals; | ||
9 | - | ||
10 | -/** | ||
11 | - * Test of the network element identifier. | ||
12 | - */ | ||
13 | -public class ElementIdTest { | ||
14 | - | ||
15 | - private static class FooId extends ElementId { | ||
16 | - public FooId(URI uri) { | ||
17 | - super(uri); | ||
18 | - } | ||
19 | - } | ||
20 | - | ||
21 | - public static URI uri(String str) { | ||
22 | - return URI.create(str); | ||
23 | - } | ||
24 | - | ||
25 | - @Test | ||
26 | - public void basics() { | ||
27 | - new EqualsTester() | ||
28 | - .addEqualityGroup(new FooId(uri("of:foo")), | ||
29 | - new FooId(uri("of:foo"))) | ||
30 | - .addEqualityGroup(new FooId(uri("of:bar"))) | ||
31 | - .testEquals(); | ||
32 | - assertEquals("wrong uri", uri("ofcfg:foo"), | ||
33 | - new FooId(uri("ofcfg:foo")).uri()); | ||
34 | - } | ||
35 | - | ||
36 | -} |
... | @@ -11,20 +11,18 @@ import static org.onlab.onos.net.HostId.hostId; | ... | @@ -11,20 +11,18 @@ import static org.onlab.onos.net.HostId.hostId; |
11 | /** | 11 | /** |
12 | * Test for the host identifier. | 12 | * Test for the host identifier. |
13 | */ | 13 | */ |
14 | -public class HostIdTest extends ElementIdTest { | 14 | +public class HostIdTest { |
15 | 15 | ||
16 | private static final MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01"); | 16 | private static final MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01"); |
17 | private static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02"); | 17 | private static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02"); |
18 | private static final VlanId VLAN1 = VlanId.vlanId((short) 11); | 18 | private static final VlanId VLAN1 = VlanId.vlanId((short) 11); |
19 | private static final VlanId VLAN2 = VlanId.vlanId((short) 22); | 19 | private static final VlanId VLAN2 = VlanId.vlanId((short) 22); |
20 | 20 | ||
21 | - @Override | ||
22 | @Test | 21 | @Test |
23 | public void basics() { | 22 | public void basics() { |
24 | new EqualsTester() | 23 | new EqualsTester() |
25 | - .addEqualityGroup(hostId("nic:00:11:00:00:00:01-11"), | 24 | + .addEqualityGroup(hostId(MAC1, VLAN1), hostId(MAC1, VLAN1)) |
26 | - hostId(MAC1, VLAN1)) | 25 | + .addEqualityGroup(hostId(MAC2, VLAN2), hostId(MAC2, VLAN2)) |
27 | - .addEqualityGroup(hostId(MAC2, VLAN2)) | ||
28 | .testEquals(); | 26 | .testEquals(); |
29 | } | 27 | } |
30 | 28 | ... | ... |
... | @@ -31,7 +31,7 @@ public final class NetTestTools { | ... | @@ -31,7 +31,7 @@ public final class NetTestTools { |
31 | 31 | ||
32 | // Short-hand for producing a host id from a string | 32 | // Short-hand for producing a host id from a string |
33 | public static HostId hid(String id) { | 33 | public static HostId hid(String id) { |
34 | - return hostId("nic:" + id); | 34 | + return hostId(id); |
35 | } | 35 | } |
36 | 36 | ||
37 | // Crates a new device with the specified id | 37 | // Crates a new device with the specified id | ... | ... |
... | @@ -10,9 +10,8 @@ import com.google.common.testing.EqualsTester; | ... | @@ -10,9 +10,8 @@ import com.google.common.testing.EqualsTester; |
10 | /** | 10 | /** |
11 | * Test of the port number. | 11 | * Test of the port number. |
12 | */ | 12 | */ |
13 | -public class PortNumberTest extends ElementIdTest { | 13 | +public class PortNumberTest { |
14 | 14 | ||
15 | - @Override | ||
16 | @Test | 15 | @Test |
17 | public void basics() { | 16 | public void basics() { |
18 | new EqualsTester() | 17 | new EqualsTester() | ... | ... |
... | @@ -22,9 +22,9 @@ import org.onlab.onos.net.Link; | ... | @@ -22,9 +22,9 @@ import org.onlab.onos.net.Link; |
22 | import org.onlab.onos.net.Path; | 22 | import org.onlab.onos.net.Path; |
23 | import org.onlab.onos.net.PortNumber; | 23 | import org.onlab.onos.net.PortNumber; |
24 | import org.onlab.onos.net.host.HostService; | 24 | import org.onlab.onos.net.host.HostService; |
25 | -import org.onlab.onos.net.topology.PathService; | ||
26 | import org.onlab.onos.net.provider.ProviderId; | 25 | import org.onlab.onos.net.provider.ProviderId; |
27 | import org.onlab.onos.net.topology.LinkWeight; | 26 | import org.onlab.onos.net.topology.LinkWeight; |
27 | +import org.onlab.onos.net.topology.PathService; | ||
28 | import org.onlab.onos.net.topology.Topology; | 28 | import org.onlab.onos.net.topology.Topology; |
29 | import org.onlab.onos.net.topology.TopologyService; | 29 | import org.onlab.onos.net.topology.TopologyService; |
30 | import org.slf4j.Logger; | 30 | import org.slf4j.Logger; |
... | @@ -33,7 +33,6 @@ import java.util.List; | ... | @@ -33,7 +33,6 @@ import java.util.List; |
33 | import java.util.Set; | 33 | import java.util.Set; |
34 | 34 | ||
35 | import static com.google.common.base.Preconditions.checkNotNull; | 35 | import static com.google.common.base.Preconditions.checkNotNull; |
36 | -import static org.onlab.onos.net.DeviceId.deviceId; | ||
37 | import static org.slf4j.LoggerFactory.getLogger; | 36 | import static org.slf4j.LoggerFactory.getLogger; |
38 | 37 | ||
39 | /** | 38 | /** |
... | @@ -162,8 +161,8 @@ public class PathManager implements PathService { | ... | @@ -162,8 +161,8 @@ public class PathManager implements PathService { |
162 | // edge link since the src or dst are really an infrastructure device. | 161 | // edge link since the src or dst are really an infrastructure device. |
163 | private static class NotHost extends DefaultEdgeLink implements EdgeLink { | 162 | private static class NotHost extends DefaultEdgeLink implements EdgeLink { |
164 | NotHost() { | 163 | NotHost() { |
165 | - super(PID, new ConnectPoint(HostId.hostId("nic:none"), P0), | 164 | + super(PID, new ConnectPoint(HostId.NONE, P0), |
166 | - new HostLocation(deviceId("none:none"), P0, 0L), false); | 165 | + new HostLocation(DeviceId.NONE, P0, 0L), false); |
167 | } | 166 | } |
168 | } | 167 | } |
169 | } | 168 | } | ... | ... |
... | @@ -65,47 +65,48 @@ public class PathManagerTest { | ... | @@ -65,47 +65,48 @@ public class PathManagerTest { |
65 | @Test | 65 | @Test |
66 | public void infraToEdge() { | 66 | public void infraToEdge() { |
67 | DeviceId src = did("src"); | 67 | DeviceId src = did("src"); |
68 | - HostId dst = hid("dst"); | 68 | + HostId dst = hid("12:34:56:78:90:ab/1"); |
69 | fakeTopoMgr.paths.add(createPath("src", "middle", "edge")); | 69 | fakeTopoMgr.paths.add(createPath("src", "middle", "edge")); |
70 | - fakeHostMgr.hosts.put(dst, host("dst", "edge")); | 70 | + fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ab/1", "edge")); |
71 | Set<Path> paths = service.getPaths(src, dst); | 71 | Set<Path> paths = service.getPaths(src, dst); |
72 | validatePaths(paths, 1, 3, src, dst); | 72 | validatePaths(paths, 1, 3, src, dst); |
73 | } | 73 | } |
74 | 74 | ||
75 | @Test | 75 | @Test |
76 | public void edgeToInfra() { | 76 | public void edgeToInfra() { |
77 | - HostId src = hid("src"); | 77 | + HostId src = hid("12:34:56:78:90:ab/1"); |
78 | DeviceId dst = did("dst"); | 78 | DeviceId dst = did("dst"); |
79 | fakeTopoMgr.paths.add(createPath("edge", "middle", "dst")); | 79 | fakeTopoMgr.paths.add(createPath("edge", "middle", "dst")); |
80 | - fakeHostMgr.hosts.put(src, host("src", "edge")); | 80 | + fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge")); |
81 | Set<Path> paths = service.getPaths(src, dst); | 81 | Set<Path> paths = service.getPaths(src, dst); |
82 | validatePaths(paths, 1, 3, src, dst); | 82 | validatePaths(paths, 1, 3, src, dst); |
83 | } | 83 | } |
84 | 84 | ||
85 | @Test | 85 | @Test |
86 | public void edgeToEdge() { | 86 | public void edgeToEdge() { |
87 | - HostId src = hid("src"); | 87 | + HostId src = hid("12:34:56:78:90:ab/1"); |
88 | - HostId dst = hid("dst"); | 88 | + HostId dst = hid("12:34:56:78:90:ef/1"); |
89 | fakeTopoMgr.paths.add(createPath("srcEdge", "middle", "dstEdge")); | 89 | fakeTopoMgr.paths.add(createPath("srcEdge", "middle", "dstEdge")); |
90 | - fakeHostMgr.hosts.put(src, host("src", "srcEdge")); | 90 | + fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "srcEdge")); |
91 | - fakeHostMgr.hosts.put(dst, host("dst", "dstEdge")); | 91 | + fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "dstEdge")); |
92 | Set<Path> paths = service.getPaths(src, dst); | 92 | Set<Path> paths = service.getPaths(src, dst); |
93 | validatePaths(paths, 1, 4, src, dst); | 93 | validatePaths(paths, 1, 4, src, dst); |
94 | } | 94 | } |
95 | 95 | ||
96 | @Test | 96 | @Test |
97 | public void edgeToEdgeDirect() { | 97 | public void edgeToEdgeDirect() { |
98 | - HostId src = hid("src"); | 98 | + HostId src = hid("12:34:56:78:90:ab/1"); |
99 | - HostId dst = hid("dst"); | 99 | + HostId dst = hid("12:34:56:78:90:ef/1"); |
100 | - fakeHostMgr.hosts.put(src, host("src", "edge")); | 100 | + fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge")); |
101 | - fakeHostMgr.hosts.put(dst, host("dst", "edge")); | 101 | + fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "edge")); |
102 | Set<Path> paths = service.getPaths(src, dst); | 102 | Set<Path> paths = service.getPaths(src, dst); |
103 | validatePaths(paths, 1, 2, src, dst); | 103 | validatePaths(paths, 1, 2, src, dst); |
104 | } | 104 | } |
105 | 105 | ||
106 | @Test | 106 | @Test |
107 | public void noEdge() { | 107 | public void noEdge() { |
108 | - Set<Path> paths = service.getPaths(hid("src"), hid("dst")); | 108 | + Set<Path> paths = service.getPaths(hid("12:34:56:78:90:ab/1"), |
109 | + hid("12:34:56:78:90:ef/1")); | ||
109 | assertTrue("there should be no paths", paths.isEmpty()); | 110 | assertTrue("there should be no paths", paths.isEmpty()); |
110 | } | 111 | } |
111 | 112 | ... | ... |
... | @@ -22,11 +22,12 @@ import java.util.Arrays; | ... | @@ -22,11 +22,12 @@ import java.util.Arrays; |
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | public class MacAddress { | 24 | public class MacAddress { |
25 | - public static final byte[] ZERO_MAC_ADDRESS = | ||
26 | - MacAddress.valueOf("00:00:00:00:00:00").getAddress(); | ||
27 | 25 | ||
28 | - public static final byte[] BROADCAST_MAC = | 26 | + public static final MacAddress ZERO = valueOf("00:00:00:00:00:00"); |
29 | - MacAddress.valueOf("ff:ff:ff:ff:ff:ff").getAddress(); | 27 | + public static final MacAddress BROADCAST = valueOf("ff:ff:ff:ff:ff:ff"); |
28 | + | ||
29 | + public static final byte[] ZERO_MAC_ADDRESS = ZERO.getAddress(); | ||
30 | + public static final byte[] BROADCAST_MAC = BROADCAST.getAddress(); | ||
30 | 31 | ||
31 | public static final int MAC_ADDRESS_LENGTH = 6; | 32 | public static final int MAC_ADDRESS_LENGTH = 6; |
32 | private byte[] address = new byte[MacAddress.MAC_ADDRESS_LENGTH]; | 33 | private byte[] address = new byte[MacAddress.MAC_ADDRESS_LENGTH]; | ... | ... |
... | @@ -3,12 +3,15 @@ package org.onlab.packet; | ... | @@ -3,12 +3,15 @@ package org.onlab.packet; |
3 | /** | 3 | /** |
4 | * Representation of a VLAN ID. | 4 | * Representation of a VLAN ID. |
5 | */ | 5 | */ |
6 | -// FIXME: This will end-up looking like a constant; we should name it 'VlanId', 'IpAddress', 'MacAddress'. | ||
7 | public class VlanId { | 6 | public class VlanId { |
8 | 7 | ||
9 | private final short value; | 8 | private final short value; |
9 | + | ||
10 | // Based on convention used elsewhere? Check and change if needed | 10 | // Based on convention used elsewhere? Check and change if needed |
11 | public static final short UNTAGGED = (short) 0xffff; | 11 | public static final short UNTAGGED = (short) 0xffff; |
12 | + | ||
13 | + public static final VlanId NONE = VlanId.vlanId(UNTAGGED); | ||
14 | + | ||
12 | // A VLAN ID is actually 12 bits of a VLAN tag. | 15 | // A VLAN ID is actually 12 bits of a VLAN tag. |
13 | public static final short MAX_VLAN = 4095; | 16 | public static final short MAX_VLAN = 4095; |
14 | 17 | ... | ... |
-
Please register or login to post a comment