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-10 11:26:38 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
3988db04d3820bc9c852d22eb92b6fc7cfd1d6d8
3988db04
2 parents
7235d098
74a23922
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
183 additions
and
3 deletions
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/host/DefaultHostDescription.java
core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
core/api/src/main/java/org/onlab/onos/net/DefaultHost.java
0 → 100644
View file @
3988db0
package
org
.
onlab
.
onos
.
net
;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IPv4
;
import
org.onlab.packet.MACAddress
;
public
class
DefaultHost
extends
AbstractElement
implements
Host
{
private
final
MACAddress
mac
;
private
final
short
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
IPv4
>
ips
;
protected
DefaultHost
(
ProviderId
providerId
,
ElementId
id
,
MACAddress
mac
,
short
vlan
,
HostLocation
loc
,
Set
<
IPv4
>
ips
)
{
super
(
providerId
,
id
);
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
IPv4
>(
ips
);
}
@Override
public
HostId
id
()
{
return
(
HostId
)
super
.
id
();
}
@Override
public
MACAddress
mac
()
{
return
mac
;
}
@Override
public
Set
<
IPv4
>
ipAddresses
()
{
return
Collections
.
unmodifiableSet
(
ips
);
}
@Override
public
HostLocation
location
()
{
return
location
;
}
@Override
public
short
vlan
()
{
return
vlan
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
,
mac
,
vlan
,
location
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
DefaultHost
)
{
final
DefaultHost
other
=
(
DefaultHost
)
obj
;
return
Objects
.
equals
(
this
.
id
,
other
.
id
)
&&
Objects
.
equals
(
this
.
mac
,
other
.
mac
)
&&
Objects
.
equals
(
this
.
vlan
,
other
.
vlan
)
&&
Objects
.
equals
(
this
.
location
,
other
.
location
);
}
return
false
;
}
@Override
public
String
toString
()
{
return
toStringHelper
(
this
)
.
add
(
"id"
,
id
)
.
add
(
"mac"
,
mac
)
.
add
(
"vlan"
,
vlan
)
.
add
(
"location"
,
location
)
.
add
(
"ipAddresses"
,
ips
)
.
toString
();
}
}
core/api/src/main/java/org/onlab/onos/net/Host.java
View file @
3988db0
...
...
@@ -25,6 +25,13 @@ public interface Host extends Element {
MACAddress
mac
();
/**
* Returns the VLAN ID tied to this host.
*
* @return VLAN ID value
*/
short
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
...
...
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
0 → 100644
View file @
3988db0
package
org
.
onlab
.
onos
.
net
.
host
;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.IPv4
;
import
org.onlab.packet.MACAddress
;
public
class
DefaultHostDescription
implements
HostDescription
{
private
final
MACAddress
mac
;
private
final
short
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
IPv4
>
ips
;
public
DefaultHostDescription
(
MACAddress
mac
,
short
vlan
,
HostLocation
loc
,
Set
<
IPv4
>
ips
)
{
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
IPv4
>(
ips
);
}
@Override
public
MACAddress
hwAddress
()
{
return
mac
;
}
@Override
public
short
vlan
()
{
return
vlan
;
}
@Override
public
HostLocation
location
()
{
return
location
;
}
@Override
public
Set
<
IPv4
>
ipAddresses
()
{
return
Collections
.
unmodifiableSet
(
ips
);
}
@Override
public
String
toString
()
{
return
toStringHelper
(
this
)
.
add
(
"mac"
,
mac
)
.
add
(
"vlan"
,
vlan
)
.
add
(
"location"
,
location
)
.
add
(
"ipAddresses"
,
ips
)
.
toString
();
}
}
core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
View file @
3988db0
package
org
.
onlab
.
onos
.
net
.
host
;
import
java.util.Set
;
import
org.onlab.onos.net.Description
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.IPv4
;
import
org.onlab.packet.MACAddress
;
/**
* Information describing host and its location.
*/
public
interface
HostDescription
{
public
interface
HostDescription
extends
Description
{
// IP, MAC, VLAN-ID, HostLocation -> (ConnectionPoint + timestamp)
/**
* Returns the MAC address associated with this host (NIC).
*
* @return the MAC address of this host
*/
MACAddress
hwAddress
();
}
/**
* Returns the VLAN associated with this host.
*
* @return the VLAN ID value
*/
short
vlan
();
/**
* Returns the location of the host on the network edge.
*
* @return the network location
*/
HostLocation
location
();
/**
* Returns zero or more IP address(es) associated with this host's MAC.
*
* @return a set of IP addresses.
*/
Set
<
IPv4
>
ipAddresses
();
}
...
...
Please
register
or
login
to post a comment