Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
alshabib
2014-09-16 17:58:36 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
64231f6ab79417e37a10dce55736645c047abeb5
64231f6a
2 parents
35edb1af
210f3f36
flowruleprovider builds flowmods
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
306 additions
and
240 deletions
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
core/api/src/main/java/org/onlab/onos/net/DefaultHost.java
core/api/src/main/java/org/onlab/onos/net/Host.java
core/api/src/main/java/org/onlab/onos/net/HostId.java
core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L3ModificationInstruction.java
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
core/api/src/main/java/org/onlab/onos/net/host/HostService.java
core/api/src/main/java/org/onlab/onos/net/path/PathService.java → core/api/src/main/java/org/onlab/onos/net/topology/PathService.java
core/api/src/test/java/org/onlab/onos/net/HostIdTest.java
core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
core/api/src/test/java/org/onlab/onos/net/host/DefualtHostDecriptionTest.java
core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java
core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
core/api/src/test/java/org/onlab/onos/net/topology/ClusterIdTest.java
core/api/src/test/java/org/onlab/onos/net/topology/DefaultTopologyClusterTest.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManager.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/path/SimplePathManager.java → core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimplePathManager.java
core/trivial/src/test/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManagerTest.java
providers/of/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
providers/of/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
providers/of/host/src/test/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProviderTest.java
utils/misc/src/main/java/org/onlab/packet/Ethernet.java
utils/misc/src/main/java/org/onlab/packet/IPAddress.java → utils/misc/src/main/java/org/onlab/packet/IpAddress.java
utils/misc/src/main/java/org/onlab/packet/MACAddress.java → utils/misc/src/main/java/org/onlab/packet/MacAddress.java
utils/misc/src/main/java/org/onlab/packet/VLANID.java → utils/misc/src/main/java/org/onlab/packet/VlanId.java
utils/misc/src/test/java/org/onlab/packet/IPAddressTest.java
utils/misc/src/test/java/org/onlab/packet/VLANIDTest.java
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
View file @
64231f6
...
...
@@ -11,12 +11,12 @@ import org.onlab.onos.net.Path;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.link.LinkService
;
import
org.onlab.onos.net.
path
.PathService
;
import
org.onlab.onos.net.
topology
.PathService
;
import
org.onlab.onos.net.topology.Topology
;
import
org.onlab.onos.net.topology.TopologyGraph
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.onos.net.topology.TopologyVertex
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.rest.BaseResource
;
import
javax.ws.rs.GET
;
...
...
@@ -74,8 +74,8 @@ public class TopologyResource extends BaseResource {
// Merge the exterior and interior vertexes and inject host links as
// the exterior edges.
for
(
Host
host
:
hostService
.
getHosts
())
{
Set
<
I
P
Address
>
ipAddresses
=
host
.
ipAddresses
();
I
P
Address
ipAddress
=
ipAddresses
.
isEmpty
()
?
null
:
ipAddresses
.
iterator
().
next
();
Set
<
I
p
Address
>
ipAddresses
=
host
.
ipAddresses
();
I
p
Address
ipAddress
=
ipAddresses
.
isEmpty
()
?
null
:
ipAddresses
.
iterator
().
next
();
String
label
=
ipAddress
!=
null
?
ipAddress
.
toString
()
:
host
.
mac
().
toString
();
vertexesNode
.
add
(
json
(
mapper
,
host
.
id
(),
3
,
label
,
true
));
edgesNode
.
add
(
json
(
mapper
,
1
,
host
.
location
(),
new
ConnectPoint
(
host
.
id
(),
portNumber
(-
1
))));
...
...
core/api/src/main/java/org/onlab/onos/net/DefaultHost.java
View file @
64231f6
...
...
@@ -8,27 +8,27 @@ import java.util.Objects;
import
java.util.Set
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
/**
* A basic implementation of a Host.
*/
public
class
DefaultHost
extends
AbstractElement
implements
Host
{
private
final
M
AC
Address
mac
;
private
final
V
LANID
vlan
;
private
final
M
ac
Address
mac
;
private
final
V
lanId
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
I
P
Address
>
ips
;
private
final
Set
<
I
p
Address
>
ips
;
public
DefaultHost
(
ProviderId
providerId
,
HostId
id
,
M
AC
Address
mac
,
V
LANID
vlan
,
HostLocation
loc
,
Set
<
IP
Address
>
ips
)
{
public
DefaultHost
(
ProviderId
providerId
,
HostId
id
,
M
ac
Address
mac
,
V
lanId
vlan
,
HostLocation
loc
,
Set
<
Ip
Address
>
ips
)
{
super
(
providerId
,
id
);
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
I
P
Address
>(
ips
);
this
.
ips
=
new
HashSet
<
I
p
Address
>(
ips
);
}
@Override
...
...
@@ -37,12 +37,12 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public
M
AC
Address
mac
()
{
public
M
ac
Address
mac
()
{
return
mac
;
}
@Override
public
Set
<
I
P
Address
>
ipAddresses
()
{
public
Set
<
I
p
Address
>
ipAddresses
()
{
return
Collections
.
unmodifiableSet
(
ips
);
}
...
...
@@ -52,7 +52,7 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public
V
LANID
vlan
()
{
public
V
lanId
vlan
()
{
return
vlan
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/Host.java
View file @
64231f6
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
java.util.Set
;
...
...
@@ -24,21 +24,21 @@ public interface Host extends Element {
*
* @return mac address
*/
M
AC
Address
mac
();
M
ac
Address
mac
();
/**
* Returns the VLAN ID tied to this host.
*
* @return VLAN ID value
*/
V
LANID
vlan
();
V
lanId
vlan
();
/**
* Returns set of IP addresses currently bound to the host MAC address.
*
* @return set of IP addresses; empty if no IP address is bound
*/
Set
<
I
P
Address
>
ipAddresses
();
Set
<
I
p
Address
>
ipAddresses
();
/**
* Returns the most recent host location where the host attaches to the
...
...
core/api/src/main/java/org/onlab/onos/net/HostId.java
View file @
64231f6
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
java.net.URI
;
...
...
@@ -42,7 +42,7 @@ public final class HostId extends ElementId {
* @param vlanId vlan identifier
* @return host identifier
*/
public
static
HostId
hostId
(
M
ACAddress
mac
,
VLANID
vlanId
)
{
public
static
HostId
hostId
(
M
acAddress
mac
,
VlanId
vlanId
)
{
// FIXME: use more efficient means of encoding
return
hostId
(
"nic"
+
":"
+
mac
+
"-"
+
vlanId
);
}
...
...
@@ -53,8 +53,8 @@ public final class HostId extends ElementId {
* @param mac mac address
* @return host identifier
*/
public
static
HostId
hostId
(
M
AC
Address
mac
)
{
return
hostId
(
mac
,
V
LANID
.
vlanId
(
VLANID
.
UNTAGGED
));
public
static
HostId
hostId
(
M
ac
Address
mac
)
{
return
hostId
(
mac
,
V
lanId
.
vlanId
(
VlanId
.
UNTAGGED
));
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
View file @
64231f6
...
...
@@ -2,9 +2,9 @@ package org.onlab.onos.net.flow.criteria;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.criteria.Criterion.Type
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
/**
* Factory class to create various traffic selection criteria.
...
...
@@ -34,7 +34,7 @@ public final class Criteria {
* @param macValue MAC address value or wildcard mask
* @return match criterion
*/
public
static
Criterion
matchEthSrc
(
M
AC
Address
mac
)
{
public
static
Criterion
matchEthSrc
(
M
ac
Address
mac
)
{
return
new
EthCriterion
(
mac
,
Type
.
ETH_SRC
);
}
...
...
@@ -45,7 +45,7 @@ public final class Criteria {
* @param macValue MAC address value or wildcard mask
* @return match criterion
*/
public
static
Criterion
matchEthDst
(
M
AC
Address
mac
)
{
public
static
Criterion
matchEthDst
(
M
ac
Address
mac
)
{
return
new
EthCriterion
(
mac
,
Type
.
ETH_DST
);
}
...
...
@@ -65,7 +65,7 @@ public final class Criteria {
* @param vlanId vlan id value
* @return match criterion
*/
public
static
Criterion
matchVlanId
(
V
LANID
vlanId
)
{
public
static
Criterion
matchVlanId
(
V
lanId
vlanId
)
{
return
new
VlanIdCriterion
(
vlanId
);
}
...
...
@@ -95,7 +95,7 @@ public final class Criteria {
* @param ip ip src value
* @return match criterion
*/
public
static
Criterion
matchIPSrc
(
I
P
Address
ip
)
{
public
static
Criterion
matchIPSrc
(
I
p
Address
ip
)
{
return
new
IPCriterion
(
ip
,
Type
.
IPV4_SRC
);
}
...
...
@@ -105,7 +105,7 @@ public final class Criteria {
* @param ip ip src value
* @return match criterion
*/
public
static
Criterion
matchIPDst
(
I
P
Address
ip
)
{
public
static
Criterion
matchIPDst
(
I
p
Address
ip
)
{
return
new
IPCriterion
(
ip
,
Type
.
IPV4_DST
);
}
...
...
@@ -133,10 +133,10 @@ public final class Criteria {
public
static
final
class
EthCriterion
implements
Criterion
{
private
final
M
AC
Address
mac
;
private
final
M
ac
Address
mac
;
private
final
Type
type
;
public
EthCriterion
(
M
AC
Address
mac
,
Type
type
)
{
public
EthCriterion
(
M
ac
Address
mac
,
Type
type
)
{
this
.
mac
=
mac
;
this
.
type
=
type
;
}
...
...
@@ -146,7 +146,7 @@ public final class Criteria {
return
this
.
type
;
}
public
M
AC
Address
mac
()
{
public
M
ac
Address
mac
()
{
return
this
.
mac
;
}
}
...
...
@@ -173,10 +173,10 @@ public final class Criteria {
public
static
final
class
IPCriterion
implements
Criterion
{
private
final
I
P
Address
ip
;
private
final
I
p
Address
ip
;
private
final
Type
type
;
public
IPCriterion
(
I
P
Address
ip
,
Type
type
)
{
public
IPCriterion
(
I
p
Address
ip
,
Type
type
)
{
this
.
ip
=
ip
;
this
.
type
=
type
;
}
...
...
@@ -186,7 +186,7 @@ public final class Criteria {
return
this
.
type
;
}
public
I
P
Address
ip
()
{
public
I
p
Address
ip
()
{
return
this
.
ip
;
}
...
...
@@ -237,9 +237,9 @@ public final class Criteria {
public
static
final
class
VlanIdCriterion
implements
Criterion
{
private
final
V
LANID
vlanId
;
private
final
V
lanId
vlanId
;
public
VlanIdCriterion
(
V
LANID
vlanId
)
{
public
VlanIdCriterion
(
V
lanId
vlanId
)
{
this
.
vlanId
=
vlanId
;
}
...
...
@@ -248,7 +248,7 @@ public final class Criteria {
return
Type
.
VLAN_VID
;
}
public
V
LANID
vlanId
()
{
public
V
lanId
vlanId
()
{
return
vlanId
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java
View file @
64231f6
...
...
@@ -7,9 +7,10 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType;
import
org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction
;
import
org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType
;
import
org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
/**
* Factory class for creating various traffic treatment instructions.
*/
...
...
@@ -44,7 +45,7 @@ public final class Instructions {
* @param addr the mac address to modify to.
* @return a l2 modification
*/
public
static
L2ModificationInstruction
modL2Src
(
M
AC
Address
addr
)
{
public
static
L2ModificationInstruction
modL2Src
(
M
ac
Address
addr
)
{
checkNotNull
(
addr
,
"Src l2 address cannot be null"
);
return
new
ModEtherInstruction
(
L2SubType
.
L2_SRC
,
addr
);
}
...
...
@@ -54,7 +55,7 @@ public final class Instructions {
* @param addr the mac address to modify to.
* @return a L2 modification
*/
public
static
L2ModificationInstruction
modL2Dst
(
M
AC
Address
addr
)
{
public
static
L2ModificationInstruction
modL2Dst
(
M
ac
Address
addr
)
{
checkNotNull
(
addr
,
"Dst l2 address cannot be null"
);
return
new
L2ModificationInstruction
.
ModEtherInstruction
(
L2SubType
.
L2_DST
,
addr
);
}
...
...
@@ -64,7 +65,7 @@ public final class Instructions {
* @param vlanId the vlan id to modify to.
* @return a L2 modification
*/
public
static
L2ModificationInstruction
modVlanId
(
V
LANID
vlanId
)
{
public
static
L2ModificationInstruction
modVlanId
(
V
lanId
vlanId
)
{
checkNotNull
(
vlanId
,
"VLAN id cannot be null"
);
return
new
L2ModificationInstruction
.
ModVlanIdInstruction
(
vlanId
);
}
...
...
@@ -84,7 +85,7 @@ public final class Instructions {
* @param addr the ip address to modify to.
* @return a L3 modification
*/
public
static
L3ModificationInstruction
modL3Src
(
I
P
Address
addr
)
{
public
static
L3ModificationInstruction
modL3Src
(
I
p
Address
addr
)
{
checkNotNull
(
addr
,
"Src l3 address cannot be null"
);
return
new
ModIPInstruction
(
L3SubType
.
L3_SRC
,
addr
);
}
...
...
@@ -94,7 +95,7 @@ public final class Instructions {
* @param addr the ip address to modify to.
* @return a L3 modification
*/
public
static
L3ModificationInstruction
modL3Dst
(
I
P
Address
addr
)
{
public
static
L3ModificationInstruction
modL3Dst
(
I
p
Address
addr
)
{
checkNotNull
(
addr
,
"Dst l3 address cannot be null"
);
return
new
ModIPInstruction
(
L3SubType
.
L3_DST
,
addr
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java
View file @
64231f6
package
org
.
onlab
.
onos
.
net
.
flow
.
instructions
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
/**
* Abstraction of a single traffic treatment step.
...
...
@@ -50,9 +50,10 @@ public abstract class L2ModificationInstruction implements Instruction {
public
static
final
class
ModEtherInstruction
extends
L2ModificationInstruction
{
private
final
L2SubType
subtype
;
private
final
MACAddress
mac
;
private
final
MacAddress
mac
;
public
ModEtherInstruction
(
L2SubType
subType
,
MacAddress
addr
)
{
public
ModEtherInstruction
(
L2SubType
subType
,
MACAddress
addr
)
{
this
.
subtype
=
subType
;
this
.
mac
=
addr
;
}
...
...
@@ -62,7 +63,7 @@ public abstract class L2ModificationInstruction implements Instruction {
return
this
.
subtype
;
}
public
M
AC
Address
mac
()
{
public
M
ac
Address
mac
()
{
return
this
.
mac
;
}
...
...
@@ -73,9 +74,9 @@ public abstract class L2ModificationInstruction implements Instruction {
*/
public
static
final
class
ModVlanIdInstruction
extends
L2ModificationInstruction
{
public
final
V
LANID
vlanId
;
public
final
V
lanId
vlanId
;
public
ModVlanIdInstruction
(
V
LANID
vlanId
)
{
public
ModVlanIdInstruction
(
V
lanId
vlanId
)
{
this
.
vlanId
=
vlanId
;
}
...
...
@@ -84,7 +85,7 @@ public abstract class L2ModificationInstruction implements Instruction {
return
L2SubType
.
VLAN_ID
;
}
public
V
LANID
vlanId
()
{
public
V
lanId
vlanId
()
{
return
this
.
vlanId
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L3ModificationInstruction.java
View file @
64231f6
package
org
.
onlab
.
onos
.
net
.
flow
.
instructions
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.I
p
Address
;
/**
* Abstraction of a single traffic treatment step.
...
...
@@ -42,9 +42,10 @@ public abstract class L3ModificationInstruction implements Instruction {
public
static
final
class
ModIPInstruction
extends
L3ModificationInstruction
{
private
final
L3SubType
subtype
;
private
final
IPAddress
ip
;
private
final
IpAddress
ip
;
public
ModIPInstruction
(
L3SubType
subType
,
IpAddress
addr
)
{
public
ModIPInstruction
(
L3SubType
subType
,
IPAddress
addr
)
{
this
.
subtype
=
subType
;
this
.
ip
=
addr
;
}
...
...
@@ -54,7 +55,7 @@ public abstract class L3ModificationInstruction implements Instruction {
return
this
.
subtype
;
}
public
I
P
Address
ip
()
{
public
I
p
Address
ip
()
{
return
this
.
ip
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
View file @
64231f6
...
...
@@ -6,42 +6,42 @@ import java.util.HashSet;
import
java.util.Set
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
com.google.common.collect.ImmutableSet
;
public
class
DefaultHostDescription
implements
HostDescription
{
private
final
M
AC
Address
mac
;
private
final
V
LANID
vlan
;
private
final
M
ac
Address
mac
;
private
final
V
lanId
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
I
P
Address
>
ips
;
private
final
Set
<
I
p
Address
>
ips
;
public
DefaultHostDescription
(
M
ACAddress
mac
,
VLANID
vlan
,
public
DefaultHostDescription
(
M
acAddress
mac
,
VlanId
vlan
,
HostLocation
loc
)
{
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
I
P
Address
>();
this
.
ips
=
new
HashSet
<
I
p
Address
>();
}
public
DefaultHostDescription
(
M
ACAddress
mac
,
VLANID
vlan
,
HostLocation
loc
,
Set
<
I
P
Address
>
ips
)
{
public
DefaultHostDescription
(
M
acAddress
mac
,
VlanId
vlan
,
HostLocation
loc
,
Set
<
I
p
Address
>
ips
)
{
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
I
P
Address
>(
ips
);
this
.
ips
=
new
HashSet
<
I
p
Address
>(
ips
);
}
@Override
public
M
AC
Address
hwAddress
()
{
public
M
ac
Address
hwAddress
()
{
return
mac
;
}
@Override
public
V
LANID
vlan
()
{
public
V
lanId
vlan
()
{
return
vlan
;
}
...
...
@@ -51,7 +51,7 @@ public class DefaultHostDescription implements HostDescription {
}
@Override
public
Set
<
I
P
Address
>
ipAddresses
()
{
public
Set
<
I
p
Address
>
ipAddresses
()
{
return
ImmutableSet
.
copyOf
(
ips
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
View file @
64231f6
...
...
@@ -4,9 +4,9 @@ import java.util.Set;
import
org.onlab.onos.net.Description
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
/**
* Information describing host and its location.
...
...
@@ -18,14 +18,14 @@ public interface HostDescription extends Description {
*
* @return the MAC address of this host
*/
M
AC
Address
hwAddress
();
M
ac
Address
hwAddress
();
/**
* Returns the VLAN associated with this host.
*
* @return the VLAN ID value
*/
V
LANID
vlan
();
V
lanId
vlan
();
/**
* Returns the location of the host on the network edge.
...
...
@@ -39,6 +39,6 @@ public interface HostDescription extends Description {
*
* @return a set of IP addresses.
*/
Set
<
I
P
Address
>
ipAddresses
();
Set
<
I
p
Address
>
ipAddresses
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostService.java
View file @
64231f6
...
...
@@ -4,9 +4,9 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
java.util.Set
;
...
...
@@ -44,7 +44,7 @@ public interface HostService {
* @return set of hosts in the given vlan id
*/
// FIXME: change long to VLanId
Set
<
Host
>
getHostsByVlan
(
V
LANID
vlanId
);
Set
<
Host
>
getHostsByVlan
(
V
lanId
vlanId
);
/**
* Returns the set of hosts that have the specified MAC address.
...
...
@@ -52,7 +52,7 @@ public interface HostService {
* @param mac mac address
* @return set of hosts with the given mac
*/
Set
<
Host
>
getHostsByMac
(
M
AC
Address
mac
);
Set
<
Host
>
getHostsByMac
(
M
ac
Address
mac
);
/**
* Returns the set of hosts that have the specified IP address.
...
...
@@ -60,7 +60,7 @@ public interface HostService {
* @param ip ip address
* @return set of hosts with the given IP
*/
Set
<
Host
>
getHostsByIp
(
I
P
Address
ip
);
Set
<
Host
>
getHostsByIp
(
I
p
Address
ip
);
/**
* Returns the set of hosts whose most recent location is the specified
...
...
core/api/src/main/java/org/onlab/onos/net/
path
/PathService.java
→
core/api/src/main/java/org/onlab/onos/net/
topology
/PathService.java
View file @
64231f6
package
org
.
onlab
.
onos
.
net
.
path
;
package
org
.
onlab
.
onos
.
net
.
topology
;
import
org.onlab.onos.net.ElementId
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.topology.LinkWeight
;
import
java.util.Set
;
...
...
core/api/src/test/java/org/onlab/onos/net/HostIdTest.java
View file @
64231f6
...
...
@@ -3,8 +3,8 @@ package org.onlab.onos.net;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
static
org
.
onlab
.
onos
.
net
.
HostId
.
hostId
;
...
...
@@ -13,10 +13,10 @@ import static org.onlab.onos.net.HostId.hostId;
*/
public
class
HostIdTest
extends
ElementIdTest
{
private
static
final
M
ACAddress
MAC1
=
MAC
Address
.
valueOf
(
"00:11:00:00:00:01"
);
private
static
final
M
ACAddress
MAC2
=
MAC
Address
.
valueOf
(
"00:22:00:00:00:02"
);
private
static
final
V
LANID
VLAN1
=
VLANID
.
vlanId
((
short
)
11
);
private
static
final
V
LANID
VLAN2
=
VLANID
.
vlanId
((
short
)
22
);
private
static
final
M
acAddress
MAC1
=
Mac
Address
.
valueOf
(
"00:11:00:00:00:01"
);
private
static
final
M
acAddress
MAC2
=
Mac
Address
.
valueOf
(
"00:22:00:00:00:02"
);
private
static
final
V
lanId
VLAN1
=
VlanId
.
vlanId
((
short
)
11
);
private
static
final
V
lanId
VLAN2
=
VlanId
.
vlanId
((
short
)
22
);
@Override
@Test
...
...
core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
View file @
64231f6
...
...
@@ -5,9 +5,9 @@ import static org.onlab.onos.net.DeviceId.deviceId;
import
java.util.Set
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
com.google.common.collect.Sets
;
...
...
@@ -20,13 +20,13 @@ public abstract class TestDeviceParams {
protected
static
final
ProviderId
PID
=
new
ProviderId
(
"foo"
);
protected
static
final
DeviceId
DID1
=
deviceId
(
"of:foo"
);
protected
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
protected
static
final
M
ACAddress
MAC1
=
MAC
Address
.
valueOf
(
"00:11:00:00:00:01"
);
protected
static
final
M
ACAddress
MAC2
=
MAC
Address
.
valueOf
(
"00:22:00:00:00:02"
);
protected
static
final
V
LANID
VLAN1
=
VLANID
.
vlanId
((
short
)
11
);
protected
static
final
V
LANID
VLAN2
=
VLANID
.
vlanId
((
short
)
22
);
protected
static
final
I
PAddress
IP1
=
IP
Address
.
valueOf
(
"10.0.0.1"
);
protected
static
final
I
PAddress
IP2
=
IP
Address
.
valueOf
(
"10.0.0.2"
);
protected
static
final
I
PAddress
IP3
=
IP
Address
.
valueOf
(
"10.0.0.3"
);
protected
static
final
M
acAddress
MAC1
=
Mac
Address
.
valueOf
(
"00:11:00:00:00:01"
);
protected
static
final
M
acAddress
MAC2
=
Mac
Address
.
valueOf
(
"00:22:00:00:00:02"
);
protected
static
final
V
lanId
VLAN1
=
VlanId
.
vlanId
((
short
)
11
);
protected
static
final
V
lanId
VLAN2
=
VlanId
.
vlanId
((
short
)
22
);
protected
static
final
I
pAddress
IP1
=
Ip
Address
.
valueOf
(
"10.0.0.1"
);
protected
static
final
I
pAddress
IP2
=
Ip
Address
.
valueOf
(
"10.0.0.2"
);
protected
static
final
I
pAddress
IP3
=
Ip
Address
.
valueOf
(
"10.0.0.3"
);
protected
static
final
PortNumber
P1
=
PortNumber
.
portNumber
(
100
);
protected
static
final
PortNumber
P2
=
PortNumber
.
portNumber
(
200
);
...
...
@@ -34,7 +34,7 @@ public abstract class TestDeviceParams {
protected
static
final
HostId
HID2
=
HostId
.
hostId
(
MAC2
,
VLAN2
);
protected
static
final
HostLocation
LOC1
=
new
HostLocation
(
DID1
,
P1
,
123L
);
protected
static
final
HostLocation
LOC2
=
new
HostLocation
(
DID2
,
P2
,
123L
);
protected
static
final
Set
<
I
P
Address
>
IPSET1
=
Sets
.
newHashSet
(
IP1
,
IP2
);
protected
static
final
Set
<
I
P
Address
>
IPSET2
=
Sets
.
newHashSet
(
IP1
,
IP3
);
protected
static
final
Set
<
I
p
Address
>
IPSET1
=
Sets
.
newHashSet
(
IP1
,
IP2
);
protected
static
final
Set
<
I
p
Address
>
IPSET2
=
Sets
.
newHashSet
(
IP1
,
IP3
);
}
...
...
core/api/src/test/java/org/onlab/onos/net/host/DefualtHostDecriptionTest.java
View file @
64231f6
...
...
@@ -9,9 +9,9 @@ import org.junit.Test;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
com.google.common.collect.Sets
;
...
...
@@ -20,16 +20,16 @@ import com.google.common.collect.Sets;
*/
public
class
DefualtHostDecriptionTest
{
private
static
final
M
ACAddress
MAC
=
MAC
Address
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
V
LANID
VLAN
=
VLANID
.
vlanId
((
short
)
10
);
private
static
final
M
acAddress
MAC
=
Mac
Address
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
V
lanId
VLAN
=
VlanId
.
vlanId
((
short
)
10
);
private
static
final
HostLocation
LOC
=
new
HostLocation
(
DeviceId
.
deviceId
(
"of:foo"
),
PortNumber
.
portNumber
(
100
),
123L
);
private
static
final
Set
<
I
P
Address
>
IPS
=
Sets
.
newHashSet
(
I
P
Address
.
valueOf
(
"10.0.0.1"
),
I
P
Address
.
valueOf
(
"10.0.0.2"
)
private
static
final
Set
<
I
p
Address
>
IPS
=
Sets
.
newHashSet
(
I
p
Address
.
valueOf
(
"10.0.0.1"
),
I
p
Address
.
valueOf
(
"10.0.0.2"
)
);
@Test
...
...
core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java
View file @
64231f6
...
...
@@ -11,25 +11,25 @@ import org.onlab.onos.net.HostId;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
com.google.common.collect.Sets
;
public
class
HostEventTest
extends
AbstractEventTest
{
private
Host
createHost
()
{
M
ACAddress
mac
=
MAC
Address
.
valueOf
(
"00:00:11:00:00:01"
);
V
LANID
vlan
=
VLANID
.
vlanId
((
short
)
10
);
M
acAddress
mac
=
Mac
Address
.
valueOf
(
"00:00:11:00:00:01"
);
V
lanId
vlan
=
VlanId
.
vlanId
((
short
)
10
);
HostLocation
loc
=
new
HostLocation
(
DeviceId
.
deviceId
(
"of:foo"
),
PortNumber
.
portNumber
(
100
),
123L
);
Set
<
I
P
Address
>
ipset
=
Sets
.
newHashSet
(
I
P
Address
.
valueOf
(
"10.0.0.1"
),
I
P
Address
.
valueOf
(
"10.0.0.2"
)
Set
<
I
p
Address
>
ipset
=
Sets
.
newHashSet
(
I
p
Address
.
valueOf
(
"10.0.0.1"
),
I
p
Address
.
valueOf
(
"10.0.0.2"
)
);
HostId
hid
=
HostId
.
hostId
(
mac
,
vlan
);
...
...
core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
View file @
64231f6
...
...
@@ -4,9 +4,9 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
java.util.Set
;
...
...
@@ -30,17 +30,17 @@ public class HostServiceAdapter implements HostService {
}
@Override
public
Set
<
Host
>
getHostsByVlan
(
V
LANID
vlanId
)
{
public
Set
<
Host
>
getHostsByVlan
(
V
lanId
vlanId
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getHostsByMac
(
M
AC
Address
mac
)
{
public
Set
<
Host
>
getHostsByMac
(
M
ac
Address
mac
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getHostsByIp
(
I
P
Address
ip
)
{
public
Set
<
Host
>
getHostsByIp
(
I
p
Address
ip
)
{
return
null
;
}
...
...
core/api/src/test/java/org/onlab/onos/net/topology/ClusterIdTest.java
0 → 100644
View file @
64231f6
package
org
.
onlab
.
onos
.
net
.
topology
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
onlab
.
onos
.
net
.
topology
.
ClusterId
.
clusterId
;
/**
* Test of the cluster ID.
*/
public
class
ClusterIdTest
{
@Test
public
void
testEquals
()
{
new
EqualsTester
()
.
addEqualityGroup
(
clusterId
(
1
),
clusterId
(
1
))
.
addEqualityGroup
(
clusterId
(
3
),
clusterId
(
3
)).
testEquals
();
}
@Test
public
void
basics
()
{
assertEquals
(
"incorrect index"
,
123
,
clusterId
(
123
).
index
());
}
}
\ No newline at end of file
core/api/src/test/java/org/onlab/onos/net/topology/DefaultTopologyClusterTest.java
0 → 100644
View file @
64231f6
package
org
.
onlab
.
onos
.
net
.
topology
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
topology
.
ClusterId
.
clusterId
;
/**
* Test of the default topology cluster implementation.
*/
public
class
DefaultTopologyClusterTest
{
@Test
public
void
testEquals
()
{
new
EqualsTester
()
.
addEqualityGroup
(
cluster
(
3
,
2
,
1
,
"of:1"
),
cluster
(
3
,
2
,
1
,
"of:1"
))
.
addEqualityGroup
(
cluster
(
3
,
2
,
1
,
"of:2"
),
cluster
(
3
,
2
,
1
,
"of:2"
))
.
addEqualityGroup
(
cluster
(
0
,
2
,
1
,
"of:1"
),
cluster
(
0
,
2
,
1
,
"of:1"
))
.
addEqualityGroup
(
cluster
(
3
,
3
,
1
,
"of:1"
),
cluster
(
3
,
3
,
1
,
"of:1"
))
.
testEquals
();
}
@Test
public
void
basics
()
{
TopologyCluster
cluster
=
cluster
(
6
,
5
,
4
,
"of:111"
);
assertEquals
(
"incorrect id"
,
clusterId
(
6
),
cluster
.
id
());
assertEquals
(
"incorrect id"
,
5
,
cluster
.
deviceCount
());
assertEquals
(
"incorrect id"
,
4
,
cluster
.
linkCount
());
assertEquals
(
"incorrect id"
,
deviceId
(
"of:111"
),
cluster
.
root
());
}
private
TopologyCluster
cluster
(
int
id
,
int
dc
,
int
lc
,
String
root
)
{
return
new
DefaultTopologyCluster
(
clusterId
(
id
),
dc
,
lc
,
deviceId
(
root
));
}
}
\ No newline at end of file
core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManager.java
View file @
64231f6
...
...
@@ -22,9 +22,9 @@ import org.onlab.onos.net.host.HostProviderService;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.provider.AbstractProviderRegistry
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
org.slf4j.Logger
;
import
java.util.Set
;
...
...
@@ -87,18 +87,18 @@ public class SimpleHostManager
}
@Override
public
Set
<
Host
>
getHostsByVlan
(
V
LANID
vlanId
)
{
public
Set
<
Host
>
getHostsByVlan
(
V
lanId
vlanId
)
{
return
store
.
getHosts
(
vlanId
);
}
@Override
public
Set
<
Host
>
getHostsByMac
(
M
AC
Address
mac
)
{
public
Set
<
Host
>
getHostsByMac
(
M
ac
Address
mac
)
{
checkNotNull
(
mac
,
"MAC address cannot be null"
);
return
store
.
getHosts
(
mac
);
}
@Override
public
Set
<
Host
>
getHostsByIp
(
I
P
Address
ip
)
{
public
Set
<
Host
>
getHostsByIp
(
I
p
Address
ip
)
{
checkNotNull
(
ip
,
"IP address cannot be null"
);
return
store
.
getHosts
(
ip
);
}
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java
View file @
64231f6
...
...
@@ -19,9 +19,9 @@ import org.onlab.onos.net.HostId;
import
org.onlab.onos.net.host.HostDescription
;
import
org.onlab.onos.net.host.HostEvent
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.ImmutableSet
;
...
...
@@ -153,7 +153,7 @@ public class SimpleHostStore {
* @param vlanId vlan id
* @return set of hosts in the vlan
*/
Set
<
Host
>
getHosts
(
V
LANID
vlanId
)
{
Set
<
Host
>
getHosts
(
V
lanId
vlanId
)
{
Set
<
Host
>
vlanset
=
new
HashSet
<
Host
>();
for
(
Host
h
:
hosts
.
values
())
{
if
(
h
.
vlan
().
equals
(
vlanId
))
{
...
...
@@ -169,7 +169,7 @@ public class SimpleHostStore {
* @param mac mac address
* @return set of hosts with the given mac
*/
Set
<
Host
>
getHosts
(
M
AC
Address
mac
)
{
Set
<
Host
>
getHosts
(
M
ac
Address
mac
)
{
Set
<
Host
>
macset
=
new
HashSet
<>();
for
(
Host
h
:
hosts
.
values
())
{
if
(
h
.
mac
().
equals
(
mac
))
{
...
...
@@ -185,7 +185,7 @@ public class SimpleHostStore {
* @param ip ip address
* @return set of hosts with the given IP
*/
Set
<
Host
>
getHosts
(
I
P
Address
ip
)
{
Set
<
Host
>
getHosts
(
I
p
Address
ip
)
{
Set
<
Host
>
ipset
=
new
HashSet
<>();
for
(
Host
h
:
hosts
.
values
())
{
if
(
h
.
ipAddresses
().
contains
(
ip
))
{
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/
path
/SimplePathManager.java
→
core/trivial/src/main/java/org/onlab/onos/net/trivial/
topology/impl
/SimplePathManager.java
View file @
64231f6
package
org
.
onlab
.
onos
.
net
.
trivial
.
path
;
package
org
.
onlab
.
onos
.
net
.
trivial
.
topology
.
impl
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Sets
;
...
...
@@ -21,7 +21,7 @@ import org.onlab.onos.net.Link;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.
path
.PathService
;
import
org.onlab.onos.net.
topology
.PathService
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.net.topology.LinkWeight
;
import
org.onlab.onos.net.topology.Topology
;
...
...
core/trivial/src/test/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManagerTest.java
View file @
64231f6
...
...
@@ -28,9 +28,9 @@ import org.onlab.onos.net.host.HostProviderRegistry;
import
org.onlab.onos.net.host.HostProviderService
;
import
org.onlab.onos.net.provider.AbstractProvider
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Sets
;
...
...
@@ -44,17 +44,17 @@ public class SimpleHostManagerTest {
private
static
final
ProviderId
PID
=
new
ProviderId
(
"foo"
);
private
static
final
V
LANID
VLAN1
=
VLANID
.
vlanId
((
short
)
1
);
private
static
final
V
LANID
VLAN2
=
VLANID
.
vlanId
((
short
)
2
);
private
static
final
M
ACAddress
MAC1
=
MAC
Address
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
M
ACAddress
MAC2
=
MAC
Address
.
valueOf
(
"00:00:22:00:00:02"
);
private
static
final
V
lanId
VLAN1
=
VlanId
.
vlanId
((
short
)
1
);
private
static
final
V
lanId
VLAN2
=
VlanId
.
vlanId
((
short
)
2
);
private
static
final
M
acAddress
MAC1
=
Mac
Address
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
M
acAddress
MAC2
=
Mac
Address
.
valueOf
(
"00:00:22:00:00:02"
);
private
static
final
HostId
HID1
=
HostId
.
hostId
(
MAC1
,
VLAN1
);
private
static
final
HostId
HID2
=
HostId
.
hostId
(
MAC2
,
VLAN1
);
private
static
final
I
PAddress
IP1
=
IP
Address
.
valueOf
(
"10.0.0.1"
);
private
static
final
I
PAddress
IP2
=
IP
Address
.
valueOf
(
"10.0.0.2"
);
private
static
final
Set
<
I
P
Address
>
IPSET1
=
Sets
.
newHashSet
(
IP1
);
private
static
final
Set
<
I
P
Address
>
IPSET2
=
Sets
.
newHashSet
(
IP2
);
private
static
final
I
pAddress
IP1
=
Ip
Address
.
valueOf
(
"10.0.0.1"
);
private
static
final
I
pAddress
IP2
=
Ip
Address
.
valueOf
(
"10.0.0.2"
);
private
static
final
Set
<
I
p
Address
>
IPSET1
=
Sets
.
newHashSet
(
IP1
);
private
static
final
Set
<
I
p
Address
>
IPSET2
=
Sets
.
newHashSet
(
IP2
);
private
static
final
DeviceId
DID1
=
DeviceId
.
deviceId
(
"of:001"
);
private
static
final
DeviceId
DID2
=
DeviceId
.
deviceId
(
"of:002"
);
...
...
@@ -96,8 +96,8 @@ public class SimpleHostManagerTest {
mgr
.
eventDispatcher
=
null
;
}
private
void
detect
(
HostId
hid
,
M
ACAddress
mac
,
VLANID
vlan
,
HostLocation
loc
,
Set
<
I
P
Address
>
ips
)
{
private
void
detect
(
HostId
hid
,
M
acAddress
mac
,
VlanId
vlan
,
HostLocation
loc
,
Set
<
I
p
Address
>
ips
)
{
HostDescription
descr
=
new
DefaultHostDescription
(
mac
,
vlan
,
loc
,
ips
);
providerService
.
hostDetected
(
hid
,
descr
);
assertNotNull
(
"host should be found"
,
mgr
.
getHost
(
hid
));
...
...
providers/of/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
View file @
64231f6
...
...
@@ -207,11 +207,11 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
mBuilder
.
setExact
(
MatchField
.
ETH_TYPE
,
EthType
.
of
(
ethType
.
ethType
()));
case
IPV4_DST:
ip
=
(
IPCriterion
)
c
;
mBuilder
.
setExact
(
MatchField
.
IPV4_DST
,
IPv4Address
.
of
(
ip
.
ip
().
to
String
()));
mBuilder
.
setExact
(
MatchField
.
IPV4_DST
,
IPv4Address
.
of
(
ip
.
ip
().
to
Int
()));
break
;
case
IPV4_SRC:
ip
=
(
IPCriterion
)
c
;
mBuilder
.
setExact
(
MatchField
.
IPV4_SRC
,
IPv4Address
.
of
(
ip
.
ip
().
to
String
()));
mBuilder
.
setExact
(
MatchField
.
IPV4_SRC
,
IPv4Address
.
of
(
ip
.
ip
().
to
Int
()));
break
;
case
IP_PROTO:
IPProtocolCriterion
p
=
(
IPProtocolCriterion
)
c
;
...
...
providers/of/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
View file @
64231f6
...
...
@@ -31,8 +31,8 @@ import org.onlab.onos.of.controller.OpenFlowPacketContext;
import
org.onlab.onos.of.controller.PacketListener
;
import
org.onlab.packet.ARP
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.I
P
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.I
p
Address
;
import
org.onlab.packet.V
lanId
;
import
org.slf4j.Logger
;
/**
...
...
@@ -94,7 +94,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
// Potentially a new or moved host
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
V
LANID
vlan
=
VLANID
.
vlanId
(
eth
.
getVlanID
());
V
lanId
vlan
=
VlanId
.
vlanId
(
eth
.
getVlanID
());
ConnectPoint
heardOn
=
new
ConnectPoint
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()));
...
...
@@ -110,7 +110,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
HostId
hid
=
HostId
.
hostId
(
eth
.
getSourceMAC
(),
vlan
);
ARP
arp
=
(
ARP
)
eth
.
getPayload
();
Set
<
I
PAddress
>
ips
=
newHashSet
(
IP
Address
.
valueOf
(
arp
.
getSenderProtocolAddress
()));
Set
<
I
pAddress
>
ips
=
newHashSet
(
Ip
Address
.
valueOf
(
arp
.
getSenderProtocolAddress
()));
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ips
);
providerService
.
hostDetected
(
hid
,
hdescr
);
...
...
providers/of/host/src/test/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProviderTest.java
View file @
64231f6
...
...
@@ -19,8 +19,8 @@ import org.onlab.onos.of.controller.OpenflowControllerAdapter;
import
org.onlab.onos.of.controller.PacketListener
;
import
org.onlab.packet.ARP
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.M
AC
Address
;
import
org.onlab.packet.V
LANID
;
import
org.onlab.packet.M
ac
Address
;
import
org.onlab.packet.V
lanId
;
import
org.projectfloodlight.openflow.protocol.OFMessage
;
import
org.projectfloodlight.openflow.types.OFPort
;
...
...
@@ -35,9 +35,9 @@ public class OpenFlowHostProviderTest {
private
static
final
Dpid
DPID2
=
new
Dpid
(
200
);
private
static
final
Dpid
DPID3
=
new
Dpid
(
300
);
private
static
final
V
LANID
VLAN
=
VLANID
.
vlanId
();
private
static
final
M
ACAddress
MAC
=
MAC
Address
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
M
ACAddress
BCMAC
=
MAC
Address
.
valueOf
(
"ff:ff:ff:ff:ff:ff"
);
private
static
final
V
lanId
VLAN
=
VlanId
.
vlanId
();
private
static
final
M
acAddress
MAC
=
Mac
Address
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
M
acAddress
BCMAC
=
Mac
Address
.
valueOf
(
"ff:ff:ff:ff:ff:ff"
);
private
static
final
byte
[]
IP
=
new
byte
[]{
10
,
0
,
0
,
1
};
private
OpenFlowHostProvider
provider
=
new
OpenFlowHostProvider
();
...
...
utils/misc/src/main/java/org/onlab/packet/Ethernet.java
View file @
64231f6
...
...
@@ -60,8 +60,8 @@ public class Ethernet extends BasePacket {
Ethernet
.
etherTypeClassMap
.
put
(
Ethernet
.
TYPE_LLDP
,
LLDP
.
class
);
}
protected
M
AC
Address
destinationMACAddress
;
protected
M
AC
Address
sourceMACAddress
;
protected
M
ac
Address
destinationMACAddress
;
protected
M
ac
Address
sourceMACAddress
;
protected
byte
priorityCode
;
protected
short
vlanID
;
protected
short
etherType
;
...
...
@@ -89,7 +89,7 @@ public class Ethernet extends BasePacket {
*
* @return the destination MAC
*/
public
M
AC
Address
getDestinationMAC
()
{
public
M
ac
Address
getDestinationMAC
()
{
return
this
.
destinationMACAddress
;
}
...
...
@@ -100,7 +100,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public
Ethernet
setDestinationMACAddress
(
final
byte
[]
destMac
)
{
this
.
destinationMACAddress
=
M
AC
Address
.
valueOf
(
destMac
);
this
.
destinationMACAddress
=
M
ac
Address
.
valueOf
(
destMac
);
return
this
;
}
...
...
@@ -111,7 +111,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public
Ethernet
setDestinationMACAddress
(
final
String
destMac
)
{
this
.
destinationMACAddress
=
M
AC
Address
.
valueOf
(
destMac
);
this
.
destinationMACAddress
=
M
ac
Address
.
valueOf
(
destMac
);
return
this
;
}
...
...
@@ -129,7 +129,7 @@ public class Ethernet extends BasePacket {
*
* @return the source MACAddress
*/
public
M
AC
Address
getSourceMAC
()
{
public
M
ac
Address
getSourceMAC
()
{
return
this
.
sourceMACAddress
;
}
...
...
@@ -140,7 +140,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public
Ethernet
setSourceMACAddress
(
final
byte
[]
sourceMac
)
{
this
.
sourceMACAddress
=
M
AC
Address
.
valueOf
(
sourceMac
);
this
.
sourceMACAddress
=
M
ac
Address
.
valueOf
(
sourceMac
);
return
this
;
}
...
...
@@ -151,7 +151,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public
Ethernet
setSourceMACAddress
(
final
String
sourceMac
)
{
this
.
sourceMACAddress
=
M
AC
Address
.
valueOf
(
sourceMac
);
this
.
sourceMACAddress
=
M
ac
Address
.
valueOf
(
sourceMac
);
return
this
;
}
...
...
@@ -288,18 +288,18 @@ public class Ethernet extends BasePacket {
}
final
ByteBuffer
bb
=
ByteBuffer
.
wrap
(
data
,
offset
,
length
);
if
(
this
.
destinationMACAddress
==
null
)
{
this
.
destinationMACAddress
=
M
AC
Address
.
valueOf
(
new
byte
[
6
]);
this
.
destinationMACAddress
=
M
ac
Address
.
valueOf
(
new
byte
[
6
]);
}
final
byte
[]
dstAddr
=
new
byte
[
M
AC
Address
.
MAC_ADDRESS_LENGTH
];
final
byte
[]
dstAddr
=
new
byte
[
M
ac
Address
.
MAC_ADDRESS_LENGTH
];
bb
.
get
(
dstAddr
);
this
.
destinationMACAddress
=
M
AC
Address
.
valueOf
(
dstAddr
);
this
.
destinationMACAddress
=
M
ac
Address
.
valueOf
(
dstAddr
);
if
(
this
.
sourceMACAddress
==
null
)
{
this
.
sourceMACAddress
=
M
AC
Address
.
valueOf
(
new
byte
[
6
]);
this
.
sourceMACAddress
=
M
ac
Address
.
valueOf
(
new
byte
[
6
]);
}
final
byte
[]
srcAddr
=
new
byte
[
M
AC
Address
.
MAC_ADDRESS_LENGTH
];
final
byte
[]
srcAddr
=
new
byte
[
M
ac
Address
.
MAC_ADDRESS_LENGTH
];
bb
.
get
(
srcAddr
);
this
.
sourceMACAddress
=
M
AC
Address
.
valueOf
(
srcAddr
);
this
.
sourceMACAddress
=
M
ac
Address
.
valueOf
(
srcAddr
);
short
ethType
=
bb
.
getShort
();
if
(
ethType
==
(
short
)
0x8100
)
{
...
...
@@ -361,7 +361,7 @@ public class Ethernet extends BasePacket {
* @return The macAddress as a byte array
*/
public
static
byte
[]
toMACAddress
(
final
String
macAddress
)
{
return
M
AC
Address
.
valueOf
(
macAddress
).
toBytes
();
return
M
ac
Address
.
valueOf
(
macAddress
).
toBytes
();
}
/**
...
...
@@ -372,7 +372,7 @@ public class Ethernet extends BasePacket {
* @return a long containing the mac address bytes
*/
public
static
long
toLong
(
final
byte
[]
macAddress
)
{
return
M
AC
Address
.
valueOf
(
macAddress
).
toLong
();
return
M
ac
Address
.
valueOf
(
macAddress
).
toLong
();
}
/**
...
...
@@ -382,7 +382,7 @@ public class Ethernet extends BasePacket {
* @return the bytes of the mac address
*/
public
static
byte
[]
toByteArray
(
final
long
macAddress
)
{
return
M
AC
Address
.
valueOf
(
macAddress
).
toBytes
();
return
M
ac
Address
.
valueOf
(
macAddress
).
toBytes
();
}
/*
...
...
utils/misc/src/main/java/org/onlab/packet/I
P
Address.java
→
utils/misc/src/main/java/org/onlab/packet/I
p
Address.java
View file @
64231f6
...
...
@@ -5,7 +5,7 @@ import java.util.Arrays;
/**
* A class representing an IPv4 address.
*/
public
class
I
P
Address
{
public
class
I
p
Address
{
//IP Versions
public
enum
Version
{
INET
,
INET6
};
...
...
@@ -18,7 +18,7 @@ public class IPAddress {
//does it make more sense to have a integral address?
protected
byte
[]
octets
;
protected
I
P
Address
(
Version
ver
,
byte
[]
octets
)
{
protected
I
p
Address
(
Version
ver
,
byte
[]
octets
)
{
this
.
version
=
ver
;
this
.
octets
=
Arrays
.
copyOf
(
octets
,
INET_LEN
);
}
...
...
@@ -29,8 +29,8 @@ public class IPAddress {
* @param address a byte array
* @return an IP address
*/
public
static
I
P
Address
valueOf
(
byte
[]
address
)
{
return
new
I
P
Address
(
Version
.
INET
,
address
);
public
static
I
p
Address
valueOf
(
byte
[]
address
)
{
return
new
I
p
Address
(
Version
.
INET
,
address
);
}
/**
...
...
@@ -39,13 +39,13 @@ public class IPAddress {
* @param address an integer representing an IP value
* @return an IP address
*/
public
static
I
P
Address
valueOf
(
int
address
)
{
public
static
I
p
Address
valueOf
(
int
address
)
{
byte
[]
bytes
=
new
byte
[
INET_LEN
];
for
(
int
i
=
0
;
i
<
INET_LEN
;
i
++)
{
bytes
[
i
]
=
(
byte
)
((
address
>>
(
INET_LEN
-
(
i
+
1
))
*
8
)
&
0xff
);
}
return
new
I
P
Address
(
Version
.
INET
,
bytes
);
return
new
I
p
Address
(
Version
.
INET
,
bytes
);
}
/**
...
...
@@ -55,7 +55,7 @@ public class IPAddress {
* @param address a string representing an IP address, e.g. "10.0.0.1"
* @return an IP address
*/
public
static
I
P
Address
valueOf
(
String
address
)
{
public
static
I
p
Address
valueOf
(
String
address
)
{
final
String
[]
parts
=
address
.
split
(
"\\."
);
if
(
parts
.
length
!=
INET_LEN
)
{
throw
new
IllegalArgumentException
(
"Malformed IP address string; "
...
...
@@ -65,7 +65,7 @@ public class IPAddress {
for
(
int
i
=
0
;
i
<
INET_LEN
;
i
++)
{
bytes
[
i
]
=
Byte
.
parseByte
(
parts
[
i
],
10
);
}
return
new
I
P
Address
(
Version
.
INET
,
bytes
);
return
new
I
p
Address
(
Version
.
INET
,
bytes
);
}
/**
...
...
@@ -119,8 +119,8 @@ public class IPAddress {
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
I
P
Address
)
{
I
PAddress
other
=
(
IP
Address
)
obj
;
if
(
obj
instanceof
I
p
Address
)
{
I
pAddress
other
=
(
Ip
Address
)
obj
;
if
(
this
.
version
.
equals
(
other
.
version
)
&&
(
Arrays
.
equals
(
this
.
octets
,
other
.
octets
)))
{
...
...
utils/misc/src/main/java/org/onlab/packet/M
AC
Address.java
→
utils/misc/src/main/java/org/onlab/packet/M
ac
Address.java
View file @
64231f6
...
...
@@ -21,12 +21,12 @@ import java.util.Arrays;
* The class representing MAC address.
*
*/
public
class
M
AC
Address
{
public
class
M
ac
Address
{
public
static
final
int
MAC_ADDRESS_LENGTH
=
6
;
private
byte
[]
address
=
new
byte
[
M
AC
Address
.
MAC_ADDRESS_LENGTH
];
private
byte
[]
address
=
new
byte
[
M
ac
Address
.
MAC_ADDRESS_LENGTH
];
public
M
AC
Address
(
final
byte
[]
address
)
{
this
.
address
=
Arrays
.
copyOf
(
address
,
M
AC
Address
.
MAC_ADDRESS_LENGTH
);
public
M
ac
Address
(
final
byte
[]
address
)
{
this
.
address
=
Arrays
.
copyOf
(
address
,
M
ac
Address
.
MAC_ADDRESS_LENGTH
);
}
/**
...
...
@@ -40,21 +40,21 @@ public class MACAddress {
* @throws IllegalArgumentException
* if the string cannot be parsed as a MAC address.
*/
public
static
M
AC
Address
valueOf
(
final
String
address
)
{
public
static
M
ac
Address
valueOf
(
final
String
address
)
{
final
String
[]
elements
=
address
.
split
(
":"
);
if
(
elements
.
length
!=
M
AC
Address
.
MAC_ADDRESS_LENGTH
)
{
if
(
elements
.
length
!=
M
ac
Address
.
MAC_ADDRESS_LENGTH
)
{
throw
new
IllegalArgumentException
(
"Specified MAC Address must contain 12 hex digits"
+
" separated pairwise by :'s."
);
}
final
byte
[]
addressInBytes
=
new
byte
[
M
AC
Address
.
MAC_ADDRESS_LENGTH
];
for
(
int
i
=
0
;
i
<
M
AC
Address
.
MAC_ADDRESS_LENGTH
;
i
++)
{
final
byte
[]
addressInBytes
=
new
byte
[
M
ac
Address
.
MAC_ADDRESS_LENGTH
];
for
(
int
i
=
0
;
i
<
M
ac
Address
.
MAC_ADDRESS_LENGTH
;
i
++)
{
final
String
element
=
elements
[
i
];
addressInBytes
[
i
]
=
(
byte
)
Integer
.
parseInt
(
element
,
16
);
}
return
new
M
AC
Address
(
addressInBytes
);
return
new
M
ac
Address
(
addressInBytes
);
}
/**
...
...
@@ -68,13 +68,13 @@ public class MACAddress {
* @throws IllegalArgumentException
* if the byte array cannot be parsed as a MAC address.
*/
public
static
M
AC
Address
valueOf
(
final
byte
[]
address
)
{
if
(
address
.
length
!=
M
AC
Address
.
MAC_ADDRESS_LENGTH
)
{
public
static
M
ac
Address
valueOf
(
final
byte
[]
address
)
{
if
(
address
.
length
!=
M
ac
Address
.
MAC_ADDRESS_LENGTH
)
{
throw
new
IllegalArgumentException
(
"the length is not "
+
M
AC
Address
.
MAC_ADDRESS_LENGTH
);
+
M
ac
Address
.
MAC_ADDRESS_LENGTH
);
}
return
new
M
AC
Address
(
address
);
return
new
M
ac
Address
(
address
);
}
/**
...
...
@@ -90,13 +90,13 @@ public class MACAddress {
* @throws IllegalArgumentException
* if the long value cannot be parsed as a MAC address.
*/
public
static
M
AC
Address
valueOf
(
final
long
address
)
{
public
static
M
ac
Address
valueOf
(
final
long
address
)
{
final
byte
[]
addressInBytes
=
new
byte
[]
{
(
byte
)
(
address
>>
40
&
0xff
),
(
byte
)
(
address
>>
32
&
0xff
),
(
byte
)
(
address
>>
24
&
0xff
),
(
byte
)
(
address
>>
16
&
0xff
),
(
byte
)
(
address
>>
8
&
0xff
),
(
byte
)
(
address
>>
0
&
0xff
)
};
return
new
M
AC
Address
(
addressInBytes
);
return
new
M
ac
Address
(
addressInBytes
);
}
/**
...
...
@@ -165,11 +165,11 @@ public class MACAddress {
return
true
;
}
if
(!(
o
instanceof
M
AC
Address
))
{
if
(!(
o
instanceof
M
ac
Address
))
{
return
false
;
}
final
M
ACAddress
other
=
(
MAC
Address
)
o
;
final
M
acAddress
other
=
(
Mac
Address
)
o
;
return
Arrays
.
equals
(
this
.
address
,
other
.
address
);
}
...
...
utils/misc/src/main/java/org/onlab/packet/V
LANID
.java
→
utils/misc/src/main/java/org/onlab/packet/V
lanId
.java
View file @
64231f6
...
...
@@ -4,7 +4,7 @@ package org.onlab.packet;
* Representation of a VLAN ID.
*/
// FIXME: This will end-up looking like a constant; we should name it 'VlanId', 'IpAddress', 'MacAddress'.
public
class
V
LANID
{
public
class
V
lanId
{
private
final
short
value
;
// Based on convention used elsewhere? Check and change if needed
...
...
@@ -12,28 +12,28 @@ public class VLANID {
// A VLAN ID is actually 12 bits of a VLAN tag.
public
static
final
short
MAX_VLAN
=
4095
;
protected
V
LANID
()
{
protected
V
lanId
()
{
this
.
value
=
UNTAGGED
;
}
protected
V
LANID
(
short
value
)
{
protected
V
lanId
(
short
value
)
{
this
.
value
=
value
;
}
public
static
V
LANID
vlanId
()
{
return
new
V
LANID
(
UNTAGGED
);
public
static
V
lanId
vlanId
()
{
return
new
V
lanId
(
UNTAGGED
);
}
public
static
V
LANID
vlanId
(
short
value
)
{
public
static
V
lanId
vlanId
(
short
value
)
{
if
(
value
==
UNTAGGED
)
{
return
new
V
LANID
();
return
new
V
lanId
();
}
if
(
value
>
MAX_VLAN
)
{
throw
new
IllegalArgumentException
(
"value exceeds allowed maximum VLAN ID value (4095)"
);
}
return
new
V
LANID
(
value
);
return
new
V
lanId
(
value
);
}
public
short
toShort
()
{
...
...
@@ -46,9 +46,9 @@ public class VLANID {
return
true
;
}
if
(
obj
instanceof
V
LANID
)
{
if
(
obj
instanceof
V
lanId
)
{
V
LANID
other
=
(
VLANID
)
obj
;
V
lanId
other
=
(
VlanId
)
obj
;
if
(
this
.
value
==
other
.
value
)
{
return
true
;
...
...
utils/misc/src/test/java/org/onlab/packet/IPAddressTest.java
View file @
64231f6
...
...
@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import
java.util.Arrays
;
import
org.junit.Test
;
import
org.onlab.packet.I
P
Address.Version
;
import
org.onlab.packet.I
p
Address.Version
;
import
com.google.common.testing.EqualsTester
;
...
...
@@ -19,11 +19,11 @@ public class IPAddressTest {
@Test
public
void
testEquality
()
{
I
PAddress
ip1
=
IP
Address
.
valueOf
(
BYTES1
);
I
PAddress
ip2
=
IP
Address
.
valueOf
(
BYTES2
);
I
PAddress
ip3
=
IP
Address
.
valueOf
(
INTVAL1
);
I
PAddress
ip4
=
IP
Address
.
valueOf
(
INTVAL2
);
I
PAddress
ip5
=
IP
Address
.
valueOf
(
STRVAL
);
I
pAddress
ip1
=
Ip
Address
.
valueOf
(
BYTES1
);
I
pAddress
ip2
=
Ip
Address
.
valueOf
(
BYTES2
);
I
pAddress
ip3
=
Ip
Address
.
valueOf
(
INTVAL1
);
I
pAddress
ip4
=
Ip
Address
.
valueOf
(
INTVAL2
);
I
pAddress
ip5
=
Ip
Address
.
valueOf
(
STRVAL
);
new
EqualsTester
().
addEqualityGroup
(
ip1
,
ip3
)
.
addEqualityGroup
(
ip2
,
ip5
)
...
...
@@ -33,7 +33,7 @@ public class IPAddressTest {
@Test
public
void
basics
()
{
I
PAddress
ip4
=
IP
Address
.
valueOf
(
BYTES1
);
I
pAddress
ip4
=
Ip
Address
.
valueOf
(
BYTES1
);
assertEquals
(
"incorrect IP Version"
,
Version
.
INET
,
ip4
.
version
());
assertEquals
(
"faulty toOctets()"
,
Arrays
.
equals
(
new
byte
[]
{
0x0
,
0x0
,
0x0
,
0xa
},
ip4
.
toOctets
()),
true
);
...
...
utils/misc/src/test/java/org/onlab/packet/VLANIDTest.java
View file @
64231f6
...
...
@@ -11,28 +11,28 @@ public class VLANIDTest {
@Test
public
void
testEquality
()
{
V
LANID
vlan1
=
VLANID
.
vlanId
((
short
)
-
1
);
V
LANID
vlan2
=
VLANID
.
vlanId
((
short
)
100
);
V
LANID
vlan3
=
VLANID
.
vlanId
((
short
)
100
);
V
lanId
vlan1
=
VlanId
.
vlanId
((
short
)
-
1
);
V
lanId
vlan2
=
VlanId
.
vlanId
((
short
)
100
);
V
lanId
vlan3
=
VlanId
.
vlanId
((
short
)
100
);
new
EqualsTester
().
addEqualityGroup
(
V
LANID
.
vlanId
(),
vlan1
)
new
EqualsTester
().
addEqualityGroup
(
V
lanId
.
vlanId
(),
vlan1
)
.
addEqualityGroup
(
vlan2
,
vlan3
)
.
addEqualityGroup
(
V
LANID
.
vlanId
((
short
)
10
));
.
addEqualityGroup
(
V
lanId
.
vlanId
((
short
)
10
));
}
@Test
public
void
basics
()
{
// purposefully create UNTAGGED VLAN
V
LANID
vlan1
=
VLANID
.
vlanId
((
short
)
10
);
V
LANID
vlan2
=
VLANID
.
vlanId
((
short
)
-
1
);
V
lanId
vlan1
=
VlanId
.
vlanId
((
short
)
10
);
V
lanId
vlan2
=
VlanId
.
vlanId
((
short
)
-
1
);
assertEquals
(
"incorrect VLAN value"
,
10
,
vlan1
.
toShort
());
assertEquals
(
"invalid untagged value"
,
V
LANID
.
UNTAGGED
,
vlan2
.
toShort
());
assertEquals
(
"invalid untagged value"
,
V
lanId
.
UNTAGGED
,
vlan2
.
toShort
());
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testIllicitVLAN
()
{
V
LANID
.
vlanId
((
short
)
5000
);
V
lanId
.
vlanId
((
short
)
5000
);
}
}
...
...
Please
register
or
login
to post a comment