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
Ayaka Koshibe
2014-09-11 14:31:29 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
04a1a4e4fb4e0da3b43f24e802a3075650266031
04a1a4e4
1 parent
491fdb5d
added VLANID construct
Change-Id: Ia58abb268d52639215f289052bbf8802992f98a6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
62 additions
and
14 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/host/HostService.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
utils/misc/src/main/java/org/onlab/packet/IPAddress.java
utils/misc/src/main/java/org/onlab/packet/VLANID.java
core/api/src/main/java/org/onlab/onos/net/DefaultHost.java
View file @
04a1a4e
...
...
@@ -10,6 +10,7 @@ import java.util.Set;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
/**
* A basic implementation of a Host.
...
...
@@ -17,12 +18,12 @@ import org.onlab.packet.MACAddress;
public
class
DefaultHost
extends
AbstractElement
implements
Host
{
private
final
MACAddress
mac
;
private
final
short
vlan
;
private
final
VLANID
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
IPAddress
>
ips
;
public
DefaultHost
(
ProviderId
providerId
,
Elemen
tId
id
,
MACAddress
mac
,
short
vlan
,
HostLocation
loc
,
Set
<
IPAddress
>
ips
)
{
public
DefaultHost
(
ProviderId
providerId
,
Hos
tId
id
,
MACAddress
mac
,
VLANID
vlan
,
HostLocation
loc
,
Set
<
IPAddress
>
ips
)
{
super
(
providerId
,
id
);
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
...
...
@@ -51,7 +52,7 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public
short
vlan
()
{
public
VLANID
vlan
()
{
return
vlan
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/Host.java
View file @
04a1a4e
...
...
@@ -2,6 +2,7 @@ package org.onlab.onos.net;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
java.util.Set
;
...
...
@@ -30,7 +31,7 @@ public interface Host extends Element {
*
* @return VLAN ID value
*/
short
vlan
();
VLANID
vlan
();
/**
* Returns set of IP addresses currently bound to the host MAC address.
...
...
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
View file @
04a1a4e
...
...
@@ -8,17 +8,18 @@ import java.util.Set;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
com.google.common.collect.ImmutableSet
;
public
class
DefaultHostDescription
implements
HostDescription
{
private
final
MACAddress
mac
;
private
final
short
vlan
;
private
final
VLANID
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
IPAddress
>
ips
;
public
DefaultHostDescription
(
MACAddress
mac
,
short
vlan
,
public
DefaultHostDescription
(
MACAddress
mac
,
VLANID
vlan
,
HostLocation
loc
,
Set
<
IPAddress
>
ips
)
{
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
...
...
@@ -32,7 +33,7 @@ public class DefaultHostDescription implements HostDescription {
}
@Override
public
short
vlan
()
{
public
VLANID
vlan
()
{
return
vlan
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
View file @
04a1a4e
...
...
@@ -6,6 +6,7 @@ import org.onlab.onos.net.Description;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
/**
* Information describing host and its location.
...
...
@@ -24,7 +25,7 @@ public interface HostDescription extends Description {
*
* @return the VLAN ID value
*/
short
vlan
();
VLANID
vlan
();
/**
* Returns the location of the host on the network edge.
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostService.java
View file @
04a1a4e
...
...
@@ -6,6 +6,7 @@ import org.onlab.onos.net.Host;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
java.util.Set
;
...
...
@@ -43,7 +44,7 @@ public interface HostService {
* @return set of hosts in the given vlan id
*/
// FIXME: change long to VLanId
Set
<
Host
>
getHostsByVlan
(
long
vlanId
);
Set
<
Host
>
getHostsByVlan
(
VLANID
vlanId
);
/**
* Returns the set of hosts that have the specified MAC address.
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManager.java
View file @
04a1a4e
...
...
@@ -23,6 +23,7 @@ import org.onlab.onos.net.provider.AbstractProviderRegistry;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
org.slf4j.Logger
;
import
java.util.Set
;
...
...
@@ -85,7 +86,7 @@ public class SimpleHostManager
}
@Override
public
Set
<
Host
>
getHostsByVlan
(
long
vlanId
)
{
public
Set
<
Host
>
getHostsByVlan
(
VLANID
vlanId
)
{
return
store
.
getHosts
(
vlanId
);
}
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java
View file @
04a1a4e
...
...
@@ -21,6 +21,7 @@ import org.onlab.onos.net.host.HostEvent;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.ImmutableSet
;
...
...
@@ -149,10 +150,10 @@ public class SimpleHostStore {
* @param vlanId vlan id
* @return set of hosts in the vlan
*/
Set
<
Host
>
getHosts
(
long
vlanId
)
{
Set
<
Host
>
getHosts
(
VLANID
vlanId
)
{
Set
<
Host
>
vlanset
=
new
HashSet
<
Host
>();
for
(
Host
h
:
hosts
.
values
())
{
if
(
h
.
vlan
()
==
vlanId
)
{
if
(
h
.
vlan
()
.
equals
(
vlanId
)
)
{
vlanset
.
add
(
h
);
}
}
...
...
utils/misc/src/main/java/org/onlab/packet/IPAddress.java
View file @
04a1a4e
...
...
@@ -10,7 +10,7 @@ public class IPAddress {
//IP Versions
public
enum
Version
{
INET
,
INET6
};
//lengths of address
es
, in bytes
//lengths of address, in bytes
public
static
final
int
INET_LEN
=
4
;
public
static
final
int
INET6_LEN
=
6
;
...
...
utils/misc/src/main/java/org/onlab/packet/VLANID.java
0 → 100644
View file @
04a1a4e
package
org
.
onlab
.
packet
;
/**
* Representation of a VLAN ID.
*/
public
class
VLANID
{
// A VLAN ID is 12 bits, short is close
private
final
short
value
;
public
VLANID
(
short
value
)
{
this
.
value
=
value
;
}
public
short
toShort
()
{
return
this
.
value
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
instanceof
VLANID
)
{
return
true
;
}
VLANID
other
=
(
VLANID
)
obj
;
if
(
this
.
value
==
other
.
value
)
{
return
true
;
}
return
false
;
}
@Override
public
int
hashCode
()
{
return
this
.
value
;
}
}
Please
register
or
login
to post a comment