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
Thomas Vachuska
2014-10-27 19:56:22 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
755fb43aea94090b2400ff02270da6186e040a0b
755fb43a
2 parents
18867bf4
33f228af
Merge remote-tracking branch 'origin/master'
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
109 additions
and
121 deletions
apps/sdnip/src/main/java/org/onlab/onos/sdnip/Router.java
apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTest.java
apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTestWithAsyncArp.java
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
cli/src/main/java/org/onlab/onos/cli/net/HostsListCommand.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/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/host/HostStore.java
core/api/src/main/java/org/onlab/onos/net/proxyarp/ProxyArpService.java
core/api/src/test/java/org/onlab/onos/net/NetTestTools.java
core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
core/api/src/test/java/org/onlab/onos/net/host/DefaultHostDecriptionTest.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/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
core/net/src/main/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManager.java
core/net/src/test/java/org/onlab/onos/net/host/impl/HostManagerTest.java
core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
core/net/src/test/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManagerTest.java
core/store/dist/src/main/java/org/onlab/onos/store/host/impl/GossipHostStore.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleHostStore.java
providers/host/src/main/java/org/onlab/onos/provider/host/impl/HostLocationProvider.java
providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
apps/sdnip/src/main/java/org/onlab/onos/sdnip/Router.java
View file @
755fb43
...
...
@@ -520,8 +520,7 @@ public class Router implements RouteListener {
// See if we know the MAC address of the next hop
MacAddress
nextHopMacAddress
=
null
;
Set
<
Host
>
hosts
=
hostService
.
getHostsByIp
(
routeEntry
.
nextHop
().
toPrefix
());
Set
<
Host
>
hosts
=
hostService
.
getHostsByIp
(
routeEntry
.
nextHop
());
if
(!
hosts
.
isEmpty
())
{
// TODO how to handle if multiple hosts are returned?
nextHopMacAddress
=
hosts
.
iterator
().
next
().
mac
();
...
...
@@ -773,8 +772,8 @@ public class Router implements RouteListener {
if
(
event
.
type
()
==
HostEvent
.
Type
.
HOST_ADDED
||
event
.
type
()
==
HostEvent
.
Type
.
HOST_UPDATED
)
{
Host
host
=
event
.
subject
();
for
(
Ip
Prefix
ip
:
host
.
ipAddresses
())
{
updateMac
(
ip
.
toIpAddress
()
,
host
.
mac
());
for
(
Ip
Address
ip
:
host
.
ipAddresses
())
{
updateMac
(
ip
,
host
.
mac
());
}
}
}
...
...
apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTest.java
View file @
755fb43
...
...
@@ -197,27 +197,27 @@ public class RouterTest {
hostService
.
addListener
(
anyObject
(
HostListener
.
class
));
expectLastCall
().
anyTimes
();
Ip
Prefix
host1Address
=
IpPrefix
.
valueOf
(
"192.168.10.1/32
"
);
Ip
Address
host1Address
=
IpAddress
.
valueOf
(
"192.168.10.1
"
);
Host
host1
=
new
DefaultHost
(
ProviderId
.
NONE
,
HostId
.
NONE
,
MacAddress
.
valueOf
(
"00:00:00:00:00:01"
),
VlanId
.
NONE
,
new
HostLocation
(
SW1_ETH1
,
1
),
Sets
.
newHashSet
(
host1Address
));
Sets
.
newHashSet
(
host1Address
));
expect
(
hostService
.
getHostsByIp
(
host1Address
))
.
andReturn
(
Sets
.
newHashSet
(
host1
)).
anyTimes
();
hostService
.
startMonitoringIp
(
host1Address
.
toIpAddress
()
);
hostService
.
startMonitoringIp
(
host1Address
);
expectLastCall
().
anyTimes
();
Ip
Prefix
host2Address
=
IpPrefix
.
valueOf
(
"192.168.20.1/32
"
);
Ip
Address
host2Address
=
IpAddress
.
valueOf
(
"192.168.20.1
"
);
Host
host2
=
new
DefaultHost
(
ProviderId
.
NONE
,
HostId
.
NONE
,
MacAddress
.
valueOf
(
"00:00:00:00:00:02"
),
VlanId
.
NONE
,
new
HostLocation
(
SW2_ETH1
,
1
),
Sets
.
newHashSet
(
host2Address
));
Sets
.
newHashSet
(
host2Address
));
expect
(
hostService
.
getHostsByIp
(
host2Address
))
.
andReturn
(
Sets
.
newHashSet
(
host2
)).
anyTimes
();
hostService
.
startMonitoringIp
(
host2Address
.
toIpAddress
()
);
hostService
.
startMonitoringIp
(
host2Address
);
expectLastCall
().
anyTimes
();
...
...
apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTestWithAsyncArp.java
View file @
755fb43
...
...
@@ -184,7 +184,7 @@ public class RouterTestWithAsyncArp {
// Set up test expectation
reset
(
hostService
);
expect
(
hostService
.
getHostsByIp
(
anyObject
(
Ip
Prefix
.
class
))).
andReturn
(
expect
(
hostService
.
getHostsByIp
(
anyObject
(
Ip
Address
.
class
))).
andReturn
(
new
HashSet
<
Host
>()).
anyTimes
();
hostService
.
startMonitoringIp
(
IpAddress
.
valueOf
(
"192.168.10.1"
));
replay
(
hostService
);
...
...
@@ -203,7 +203,7 @@ public class RouterTestWithAsyncArp {
new
HostLocation
(
SW1_ETH1
.
deviceId
(),
SW1_ETH1
.
port
(),
1
),
Sets
.
newHashSet
(
Ip
Prefix
.
valueOf
(
"192.168.10.1/32
"
)));
Sets
.
newHashSet
(
Ip
Address
.
valueOf
(
"192.168.10.1
"
)));
internalHostListener
.
event
(
new
HostEvent
(
HostEvent
.
Type
.
HOST_ADDED
,
host
));
...
...
@@ -266,7 +266,7 @@ public class RouterTestWithAsyncArp {
// Set up test expectation
reset
(
hostService
);
expect
(
hostService
.
getHostsByIp
(
anyObject
(
Ip
Prefix
.
class
))).
andReturn
(
expect
(
hostService
.
getHostsByIp
(
anyObject
(
Ip
Address
.
class
))).
andReturn
(
new
HashSet
<
Host
>()).
anyTimes
();
hostService
.
startMonitoringIp
(
IpAddress
.
valueOf
(
"192.168.20.1"
));
replay
(
hostService
);
...
...
@@ -286,7 +286,7 @@ public class RouterTestWithAsyncArp {
new
HostLocation
(
SW2_ETH1
.
deviceId
(),
SW2_ETH1
.
port
(),
1
),
Sets
.
newHashSet
(
Ip
Prefix
.
valueOf
(
"192.168.20.1/32
"
)));
Sets
.
newHashSet
(
Ip
Address
.
valueOf
(
"192.168.20.1
"
)));
internalHostListener
.
event
(
new
HostEvent
(
HostEvent
.
Type
.
HOST_ADDED
,
host
));
...
...
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
View file @
755fb43
...
...
@@ -34,7 +34,7 @@ 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.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.rest.BaseResource
;
import
javax.ws.rs.GET
;
...
...
@@ -92,8 +92,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
<
Ip
Prefix
>
ipAddresses
=
host
.
ipAddresses
();
Ip
Prefix
ipAddress
=
ipAddresses
.
isEmpty
()
?
null
:
ipAddresses
.
iterator
().
next
();
Set
<
Ip
Address
>
ipAddresses
=
host
.
ipAddresses
();
Ip
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
))));
...
...
cli/src/main/java/org/onlab/onos/cli/net/HostsListCommand.java
View file @
755fb43
...
...
@@ -27,7 +27,7 @@ import org.onlab.onos.cli.AbstractShellCommand;
import
org.onlab.onos.cli.Comparators
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -71,7 +71,7 @@ public class HostsListCommand extends AbstractShellCommand {
ObjectNode
loc
=
LinksListCommand
.
json
(
mapper
,
host
.
location
())
.
put
(
"time"
,
host
.
location
().
time
());
ArrayNode
ips
=
mapper
.
createArrayNode
();
for
(
Ip
Prefix
ip
:
host
.
ipAddresses
())
{
for
(
Ip
Address
ip
:
host
.
ipAddresses
())
{
ips
.
add
(
ip
.
toString
());
}
ObjectNode
result
=
mapper
.
createObjectNode
()
...
...
core/api/src/main/java/org/onlab/onos/net/DefaultHost.java
View file @
755fb43
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -20,8 +20,7 @@ public class DefaultHost extends AbstractElement implements Host {
private
final
MacAddress
mac
;
private
final
VlanId
vlan
;
private
final
HostLocation
location
;
// FIXME: should be IpAddress
private
final
Set
<
IpPrefix
>
ips
;
private
final
Set
<
IpAddress
>
ips
;
/**
* Creates an end-station host using the supplied information.
...
...
@@ -35,13 +34,13 @@ public class DefaultHost extends AbstractElement implements Host {
* @param annotations optional key/value annotations
*/
public
DefaultHost
(
ProviderId
providerId
,
HostId
id
,
MacAddress
mac
,
VlanId
vlan
,
HostLocation
location
,
Set
<
Ip
Prefix
>
ips
,
VlanId
vlan
,
HostLocation
location
,
Set
<
Ip
Address
>
ips
,
Annotations
...
annotations
)
{
super
(
providerId
,
id
,
annotations
);
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
location
;
this
.
ips
=
new
HashSet
<
IpPrefix
>(
ips
);
this
.
ips
=
new
HashSet
<>(
ips
);
}
@Override
...
...
@@ -55,7 +54,7 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public
Set
<
Ip
Prefix
>
ipAddresses
()
{
public
Set
<
Ip
Address
>
ipAddresses
()
{
return
Collections
.
unmodifiableSet
(
ips
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/Host.java
View file @
755fb43
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -38,8 +38,7 @@ public interface Host extends Element {
*
* @return set of IP addresses; empty if no IP address is bound
*/
// FIXME: Switch to IpAddress
Set
<
IpPrefix
>
ipAddresses
();
Set
<
IpAddress
>
ipAddresses
();
/**
* Returns the most recent host location where the host attaches to the
...
...
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
View file @
755fb43
...
...
@@ -6,7 +6,7 @@ import java.util.Set;
import
org.onlab.onos.net.AbstractDescription
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.onos.net.SparseAnnotations
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -23,7 +23,7 @@ public class DefaultHostDescription extends AbstractDescription
private
final
MacAddress
mac
;
private
final
VlanId
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
Ip
Prefix
>
ip
;
private
final
Set
<
Ip
Address
>
ip
;
/**
* Creates a host description using the supplied information.
...
...
@@ -36,7 +36,8 @@ public class DefaultHostDescription extends AbstractDescription
public
DefaultHostDescription
(
MacAddress
mac
,
VlanId
vlan
,
HostLocation
location
,
SparseAnnotations
...
annotations
)
{
this
(
mac
,
vlan
,
location
,
Collections
.<
IpPrefix
>
emptySet
(),
annotations
);
this
(
mac
,
vlan
,
location
,
Collections
.<
IpAddress
>
emptySet
(),
annotations
);
}
/**
...
...
@@ -49,7 +50,7 @@ public class DefaultHostDescription extends AbstractDescription
* @param annotations optional key/value annotations map
*/
public
DefaultHostDescription
(
MacAddress
mac
,
VlanId
vlan
,
HostLocation
location
,
Ip
Prefix
ip
,
HostLocation
location
,
Ip
Address
ip
,
SparseAnnotations
...
annotations
)
{
this
(
mac
,
vlan
,
location
,
ImmutableSet
.
of
(
ip
),
annotations
);
}
...
...
@@ -64,7 +65,7 @@ public class DefaultHostDescription extends AbstractDescription
* @param annotations optional key/value annotations map
*/
public
DefaultHostDescription
(
MacAddress
mac
,
VlanId
vlan
,
HostLocation
location
,
Set
<
Ip
Prefix
>
ip
,
HostLocation
location
,
Set
<
Ip
Address
>
ip
,
SparseAnnotations
...
annotations
)
{
super
(
annotations
);
this
.
mac
=
mac
;
...
...
@@ -89,7 +90,7 @@ public class DefaultHostDescription extends AbstractDescription
}
@Override
public
Set
<
Ip
Prefix
>
ipAddress
()
{
public
Set
<
Ip
Address
>
ipAddress
()
{
return
ip
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
View file @
755fb43
...
...
@@ -4,7 +4,7 @@ import java.util.Set;
import
org.onlab.onos.net.Description
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -39,7 +39,5 @@ public interface HostDescription extends Description {
*
* @return host IP address
*/
// FIXME: Switch to IpAddress
Set
<
IpPrefix
>
ipAddress
();
Set
<
IpAddress
>
ipAddress
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostService.java
View file @
755fb43
...
...
@@ -7,7 +7,6 @@ import org.onlab.onos.net.DeviceId;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -60,7 +59,7 @@ public interface HostService {
* @param ip ip address
* @return set of hosts with the given IP
*/
Set
<
Host
>
getHostsByIp
(
Ip
Prefix
ip
);
Set
<
Host
>
getHostsByIp
(
Ip
Address
ip
);
// TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
View file @
755fb43
...
...
@@ -6,7 +6,7 @@ import org.onlab.onos.net.Host;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Store
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -82,8 +82,7 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
* @param ip ip address
* @return set of hosts with the given IP
*/
// FIXME: Switch to IpAddress
Set
<
Host
>
getHosts
(
IpPrefix
ip
);
Set
<
Host
>
getHosts
(
IpAddress
ip
);
/**
* Returns the set of hosts whose location falls on the given connection point.
...
...
core/api/src/main/java/org/onlab/onos/net/proxyarp/ProxyArpService.java
View file @
755fb43
...
...
@@ -3,7 +3,7 @@ package org.onlab.onos.net.proxyarp;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.packet.PacketContext
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
/**
* Service for processing arp requests on behalf of applications.
...
...
@@ -17,7 +17,7 @@ public interface ProxyArpService {
* @param addr a ip address
* @return true if know, false otherwise
*/
boolean
known
(
Ip
Prefix
addr
);
boolean
known
(
Ip
Address
addr
);
/**
* Sends a reply for a given request. If the host is not known then the arp
...
...
core/api/src/test/java/org/onlab/onos/net/NetTestTools.java
View file @
755fb43
...
...
@@ -2,7 +2,7 @@ package org.onlab.onos.net;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.ChassisId
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
...
...
@@ -45,7 +45,7 @@ public final class NetTestTools {
public
static
Host
host
(
String
id
,
String
did
)
{
return
new
DefaultHost
(
PID
,
hid
(
id
),
valueOf
(
1234
),
vlanId
((
short
)
2
),
new
HostLocation
(
did
(
did
),
portNumber
(
1
),
321
),
new
HashSet
<
Ip
Prefix
>());
new
HashSet
<
Ip
Address
>());
}
// Short-hand for creating a connection point.
...
...
core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
View file @
755fb43
...
...
@@ -5,7 +5,7 @@ import static org.onlab.onos.net.DeviceId.deviceId;
import
java.util.Set
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -24,9 +24,9 @@ public abstract class TestDeviceParams {
protected
static
final
MacAddress
MAC2
=
MacAddress
.
valueOf
(
"00:22:00:00:00:02"
);
protected
static
final
VlanId
VLAN1
=
VlanId
.
vlanId
((
short
)
11
);
protected
static
final
VlanId
VLAN2
=
VlanId
.
vlanId
((
short
)
22
);
protected
static
final
Ip
Prefix
IP1
=
IpPrefix
.
valueOf
(
"10.0.0.1"
);
protected
static
final
Ip
Prefix
IP2
=
IpPrefix
.
valueOf
(
"10.0.0.2"
);
protected
static
final
Ip
Prefix
IP3
=
IpPrefix
.
valueOf
(
"10.0.0.3"
);
protected
static
final
Ip
Address
IP1
=
IpAddress
.
valueOf
(
"10.0.0.1"
);
protected
static
final
Ip
Address
IP2
=
IpAddress
.
valueOf
(
"10.0.0.2"
);
protected
static
final
Ip
Address
IP3
=
IpAddress
.
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
<
Ip
Prefix
>
IPSET1
=
Sets
.
newHashSet
(
IP1
,
IP2
);
protected
static
final
Set
<
Ip
Prefix
>
IPSET2
=
Sets
.
newHashSet
(
IP1
,
IP3
);
protected
static
final
Set
<
Ip
Address
>
IPSET1
=
Sets
.
newHashSet
(
IP1
,
IP2
);
protected
static
final
Set
<
Ip
Address
>
IPSET2
=
Sets
.
newHashSet
(
IP1
,
IP3
);
}
...
...
core/api/src/test/java/org/onlab/onos/net/host/DefaultHostDecriptionTest.java
View file @
755fb43
...
...
@@ -4,7 +4,7 @@ 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.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -20,7 +20,7 @@ public class DefaultHostDecriptionTest {
private
static
final
MacAddress
MAC
=
MacAddress
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
VlanId
VLAN
=
VlanId
.
vlanId
((
short
)
10
);
private
static
final
Ip
Prefix
IP
=
IpPrefix
.
valueOf
(
"10.0.0.1"
);
private
static
final
Ip
Address
IP
=
IpAddress
.
valueOf
(
"10.0.0.1"
);
private
static
final
HostLocation
LOC
=
new
HostLocation
(
DeviceId
.
deviceId
(
"of:foo"
),
...
...
core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java
View file @
755fb43
...
...
@@ -11,7 +11,7 @@ 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.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -27,9 +27,9 @@ public class HostEventTest extends AbstractEventTest {
PortNumber
.
portNumber
(
100
),
123L
);
Set
<
Ip
Prefix
>
ipset
=
Sets
.
newHashSet
(
Ip
Prefix
.
valueOf
(
"10.0.0.1"
),
Ip
Prefix
.
valueOf
(
"10.0.0.2"
)
Set
<
Ip
Address
>
ipset
=
Sets
.
newHashSet
(
Ip
Address
.
valueOf
(
"10.0.0.1"
),
Ip
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 @
755fb43
...
...
@@ -7,7 +7,6 @@ import org.onlab.onos.net.DeviceId;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -41,7 +40,7 @@ public class HostServiceAdapter implements HostService {
}
@Override
public
Set
<
Host
>
getHostsByIp
(
Ip
Prefix
ip
)
{
public
Set
<
Host
>
getHostsByIp
(
Ip
Address
ip
)
{
return
null
;
}
...
...
core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
View file @
755fb43
...
...
@@ -33,7 +33,6 @@ import org.onlab.onos.net.packet.PacketService;
import
org.onlab.onos.net.provider.AbstractProviderRegistry
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
...
...
@@ -121,7 +120,7 @@ public class HostManager
}
@Override
public
Set
<
Host
>
getHostsByIp
(
Ip
Prefix
ip
)
{
public
Set
<
Host
>
getHostsByIp
(
Ip
Address
ip
)
{
checkNotNull
(
ip
,
"IP address cannot be null"
);
return
store
.
getHosts
(
ip
);
}
...
...
core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
View file @
755fb43
...
...
@@ -129,10 +129,7 @@ public class HostMonitor implements TimerTask {
@Override
public
void
run
(
Timeout
timeout
)
throws
Exception
{
for
(
IpAddress
ip
:
monitoredAddresses
)
{
// TODO have to convert right now because the HostService API uses IpPrefix
IpPrefix
prefix
=
IpPrefix
.
valueOf
(
ip
.
toOctets
());
Set
<
Host
>
hosts
=
hostManager
.
getHostsByIp
(
prefix
);
Set
<
Host
>
hosts
=
hostManager
.
getHostsByIp
(
ip
);
if
(
hosts
.
isEmpty
())
{
sendArpRequest
(
ip
);
...
...
core/net/src/main/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManager.java
View file @
755fb43
...
...
@@ -99,7 +99,7 @@ public class ProxyArpManager implements ProxyArpService {
}
@Override
public
boolean
known
(
Ip
Prefix
addr
)
{
public
boolean
known
(
Ip
Address
addr
)
{
checkNotNull
(
addr
,
MAC_ADDR_NULL
);
Set
<
Host
>
hosts
=
hostService
.
getHostsByIp
(
addr
);
return
!
hosts
.
isEmpty
();
...
...
@@ -150,7 +150,7 @@ public class ProxyArpManager implements ProxyArpService {
// Continue with normal proxy ARP case
VlanId
vlan
=
VlanId
.
vlanId
(
eth
.
getVlanID
());
Set
<
Host
>
hosts
=
hostService
.
getHostsByIp
(
Ip
Prefix
.
valueOf
(
arp
Set
<
Host
>
hosts
=
hostService
.
getHostsByIp
(
Ip
Address
.
valueOf
(
arp
.
getTargetProtocolAddress
()));
Host
dst
=
null
;
...
...
@@ -170,8 +170,7 @@ public class ProxyArpManager implements ProxyArpService {
}
// TODO find the correct IP address
IpAddress
ipAddress
=
dst
.
ipAddresses
().
iterator
().
next
().
toIpAddress
();
IpAddress
ipAddress
=
dst
.
ipAddresses
().
iterator
().
next
();
Ethernet
arpReply
=
buildArpReply
(
ipAddress
,
dst
.
mac
(),
eth
);
// TODO: check send status with host service.
sendTo
(
arpReply
,
src
.
location
());
...
...
core/net/src/test/java/org/onlab/onos/net/host/impl/HostManagerTest.java
View file @
755fb43
...
...
@@ -58,8 +58,8 @@ public class HostManagerTest {
private
static
final
HostId
HID1
=
HostId
.
hostId
(
MAC1
,
VLAN1
);
private
static
final
HostId
HID2
=
HostId
.
hostId
(
MAC2
,
VLAN1
);
private
static
final
Ip
Prefix
IP1
=
IpPrefix
.
valueOf
(
"10.0.0.1"
);
private
static
final
Ip
Prefix
IP2
=
IpPrefix
.
valueOf
(
"10.0.0.2"
);
private
static
final
Ip
Address
IP1
=
IpAddress
.
valueOf
(
"10.0.0.1"
);
private
static
final
Ip
Address
IP2
=
IpAddress
.
valueOf
(
"10.0.0.2"
);
private
static
final
DeviceId
DID1
=
DeviceId
.
deviceId
(
"of:001"
);
private
static
final
DeviceId
DID2
=
DeviceId
.
deviceId
(
"of:002"
);
...
...
@@ -115,7 +115,7 @@ public class HostManagerTest {
}
private
void
detect
(
HostId
hid
,
MacAddress
mac
,
VlanId
vlan
,
HostLocation
loc
,
Ip
Prefix
ip
)
{
HostLocation
loc
,
Ip
Address
ip
)
{
HostDescription
descr
=
new
DefaultHostDescription
(
mac
,
vlan
,
loc
,
ip
);
providerService
.
hostDetected
(
hid
,
descr
);
assertNotNull
(
"host should be found"
,
mgr
.
getHost
(
hid
));
...
...
core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
View file @
755fb43
...
...
@@ -46,9 +46,8 @@ import com.google.common.collect.Multimap;
public
class
HostMonitorTest
{
private
IpAddress
targetIpAddress
=
IpAddress
.
valueOf
(
"10.0.0.1"
);
private
IpPrefix
targetIpPrefix
=
IpPrefix
.
valueOf
(
targetIpAddress
.
toOctets
());
private
static
final
IpAddress
TARGET_IP_ADDR
=
IpAddress
.
valueOf
(
"10.0.0.1"
);
private
static
final
IpAddress
SOURCE_ADDR
=
IpAddress
.
valueOf
(
"10.0.0.99"
);
private
static
final
InterfaceIpAddress
IA1
=
...
...
@@ -71,7 +70,7 @@ public class HostMonitorTest {
replay
(
host
);
HostManager
hostManager
=
createMock
(
HostManager
.
class
);
expect
(
hostManager
.
getHostsByIp
(
targetIpPrefix
))
expect
(
hostManager
.
getHostsByIp
(
TARGET_IP_ADDR
))
.
andReturn
(
Collections
.
singleton
(
host
));
replay
(
hostManager
);
...
...
@@ -84,7 +83,7 @@ public class HostMonitorTest {
hostMonitor
=
new
HostMonitor
(
null
,
null
,
hostManager
);
hostMonitor
.
registerHostProvider
(
hostProvider
);
hostMonitor
.
addMonitoringFor
(
targetIpAddress
);
hostMonitor
.
addMonitoringFor
(
TARGET_IP_ADDR
);
hostMonitor
.
run
(
null
);
...
...
@@ -115,7 +114,7 @@ public class HostMonitorTest {
PortAddresses
pa
=
new
PortAddresses
(
cp
,
Collections
.
singleton
(
IA1
),
sourceMac
);
expect
(
hostManager
.
getHostsByIp
(
targetIpPrefix
))
expect
(
hostManager
.
getHostsByIp
(
TARGET_IP_ADDR
))
.
andReturn
(
Collections
.<
Host
>
emptySet
()).
anyTimes
();
expect
(
hostManager
.
getAddressBindingsForPort
(
cp
))
.
andReturn
(
pa
).
anyTimes
();
...
...
@@ -127,7 +126,7 @@ public class HostMonitorTest {
// Run the test
hostMonitor
=
new
HostMonitor
(
deviceService
,
packetService
,
hostManager
);
hostMonitor
.
addMonitoringFor
(
targetIpAddress
);
hostMonitor
.
addMonitoringFor
(
TARGET_IP_ADDR
);
hostMonitor
.
run
(
null
);
...
...
@@ -150,7 +149,8 @@ public class HostMonitorTest {
assertTrue
(
Arrays
.
equals
(
arp
.
getSenderProtocolAddress
(),
SOURCE_ADDR
.
toOctets
()));
assertTrue
(
Arrays
.
equals
(
arp
.
getSenderHardwareAddress
(),
sourceMac
.
toBytes
()));
assertTrue
(
Arrays
.
equals
(
arp
.
getTargetProtocolAddress
(),
targetIpPrefix
.
toOctets
()));
assertTrue
(
Arrays
.
equals
(
arp
.
getTargetProtocolAddress
(),
TARGET_IP_ADDR
.
toOctets
()));
}
class
TestPacketService
implements
PacketService
{
...
...
core/net/src/test/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManagerTest.java
View file @
755fb43
...
...
@@ -59,8 +59,8 @@ public class ProxyArpManagerTest {
private
static
final
int
NUM_ADDRESS_PORTS
=
NUM_DEVICES
/
2
;
private
static
final
int
NUM_FLOOD_PORTS
=
3
;
private
static
final
Ip
Prefix
IP1
=
IpPrefix
.
valueOf
(
"192.168.1.1/24
"
);
private
static
final
Ip
Prefix
IP2
=
IpPrefix
.
valueOf
(
"192.168.1.2/24
"
);
private
static
final
Ip
Address
IP1
=
IpAddress
.
valueOf
(
"192.168.1.1
"
);
private
static
final
Ip
Address
IP2
=
IpAddress
.
valueOf
(
"192.168.1.2
"
);
private
static
final
ProviderId
PID
=
new
ProviderId
(
"of"
,
"foo"
);
...
...
@@ -214,7 +214,7 @@ public class ProxyArpManagerTest {
}
/**
* Tests {@link ProxyArpManager#known(Ip
Prefix
)} in the case where the
* Tests {@link ProxyArpManager#known(Ip
Address
)} in the case where the
* IP address is not known.
* Verifies the method returns false.
*/
...
...
@@ -227,7 +227,7 @@ public class ProxyArpManagerTest {
}
/**
* Tests {@link ProxyArpManager#known(Ip
Prefix
)} in the case where the
* Tests {@link ProxyArpManager#known(Ip
Address
)} in the case where the
* IP address is known.
* Verifies the method returns true.
*/
...
...
@@ -256,8 +256,8 @@ public class ProxyArpManagerTest {
Host
requestor
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN1
,
getLocation
(
5
),
Collections
.
singleton
(
IP2
));
expect
(
hostService
.
getHostsByIp
(
I
pPrefix
.
valueOf
(
IP1
.
toOctets
())
))
.
andReturn
(
Collections
.
singleton
(
replyer
));
expect
(
hostService
.
getHostsByIp
(
I
P1
))
.
andReturn
(
Collections
.
singleton
(
replyer
));
expect
(
hostService
.
getHost
(
HID2
)).
andReturn
(
requestor
);
replay
(
hostService
);
...
...
@@ -281,7 +281,7 @@ public class ProxyArpManagerTest {
Host
requestor
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN1
,
getLocation
(
5
),
Collections
.
singleton
(
IP2
));
expect
(
hostService
.
getHostsByIp
(
I
pPrefix
.
valueOf
(
IP1
.
toOctets
())
))
expect
(
hostService
.
getHostsByIp
(
I
P1
))
.
andReturn
(
Collections
.<
Host
>
emptySet
());
expect
(
hostService
.
getHost
(
HID2
)).
andReturn
(
requestor
);
...
...
@@ -308,7 +308,7 @@ public class ProxyArpManagerTest {
Host
requestor
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN1
,
getLocation
(
5
),
Collections
.
singleton
(
IP2
));
expect
(
hostService
.
getHostsByIp
(
I
pPrefix
.
valueOf
(
IP1
.
toOctets
())
))
expect
(
hostService
.
getHostsByIp
(
I
P1
))
.
andReturn
(
Collections
.
singleton
(
replyer
));
expect
(
hostService
.
getHost
(
HID2
)).
andReturn
(
requestor
);
...
...
@@ -323,9 +323,9 @@ public class ProxyArpManagerTest {
@Test
public
void
testReplyToRequestForUs
()
{
Ip
Prefix
theirIp
=
IpPrefix
.
valueOf
(
"10.0.1.254/2
4"
);
Ip
Prefix
ourFirstIp
=
IpPrefix
.
valueOf
(
"10.0.1.1/24
"
);
Ip
Prefix
ourSecondIp
=
IpPrefix
.
valueOf
(
"10.0.2.1/24
"
);
Ip
Address
theirIp
=
IpAddress
.
valueOf
(
"10.0.1.25
4"
);
Ip
Address
ourFirstIp
=
IpAddress
.
valueOf
(
"10.0.1.1
"
);
Ip
Address
ourSecondIp
=
IpAddress
.
valueOf
(
"10.0.2.1
"
);
MacAddress
ourMac
=
MacAddress
.
valueOf
(
1L
);
Host
requestor
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN1
,
LOC1
,
...
...
@@ -357,11 +357,11 @@ public class ProxyArpManagerTest {
public
void
testReplyExternalPortBadRequest
()
{
replay
(
hostService
);
// no further host service expectations
Ip
Prefix
theirIp
=
IpPrefix
.
valueOf
(
"10.0.1.254/2
4"
);
Ip
Address
theirIp
=
IpAddress
.
valueOf
(
"10.0.1.25
4"
);
// Request for a valid external IP address but coming in the wrong port
Ethernet
arpRequest
=
buildArp
(
ARP
.
OP_REQUEST
,
MAC1
,
null
,
theirIp
,
Ip
Prefix
.
valueOf
(
"10.0.3.1"
));
Ip
Address
.
valueOf
(
"10.0.3.1"
));
proxyArp
.
reply
(
arpRequest
,
LOC1
);
assertEquals
(
0
,
packetService
.
packets
.
size
());
...
...
@@ -376,9 +376,9 @@ public class ProxyArpManagerTest {
public
void
testReplyToRequestFromUs
()
{
replay
(
hostService
);
// no further host service expectations
Ip
Prefix
ourIp
=
IpPrefix
.
valueOf
(
"10.0.1.1/24
"
);
Ip
Address
ourIp
=
IpAddress
.
valueOf
(
"10.0.1.1
"
);
MacAddress
ourMac
=
MacAddress
.
valueOf
(
1L
);
Ip
Prefix
theirIp
=
IpPrefix
.
valueOf
(
"10.0.1.100/24
"
);
Ip
Address
theirIp
=
IpAddress
.
valueOf
(
"10.0.1.100
"
);
// This is a request from something inside our network (like a BGP
// daemon) to an external host.
...
...
@@ -501,7 +501,7 @@ public class ProxyArpManagerTest {
* @return the ARP packet
*/
private
Ethernet
buildArp
(
short
opcode
,
MacAddress
srcMac
,
MacAddress
dstMac
,
Ip
Prefix
srcIp
,
IpPrefix
dstIp
)
{
Ip
Address
srcIp
,
IpAddress
dstIp
)
{
Ethernet
eth
=
new
Ethernet
();
if
(
dstMac
==
null
)
{
...
...
core/store/dist/src/main/java/org/onlab/onos/store/host/impl/GossipHostStore.java
View file @
755fb43
...
...
@@ -42,7 +42,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject;
import
org.onlab.onos.store.impl.Timestamped
;
import
org.onlab.onos.store.serializers.DistributedStoreSerializers
;
import
org.onlab.onos.store.serializers.KryoSerializer
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
org.onlab.util.KryoNamespace
;
...
...
@@ -221,7 +221,7 @@ public class GossipHostStore
return
null
;
}
Set
<
Ip
Prefix
>
addresses
=
new
HashSet
<>(
host
.
ipAddresses
());
Set
<
Ip
Address
>
addresses
=
new
HashSet
<>(
host
.
ipAddresses
());
addresses
.
addAll
(
descr
.
ipAddress
());
StoredHost
updated
=
new
StoredHost
(
providerId
,
host
.
id
(),
host
.
mac
(),
host
.
vlan
(),
...
...
@@ -300,7 +300,7 @@ public class GossipHostStore
}
@Override
public
Set
<
Host
>
getHosts
(
Ip
Prefix
ip
)
{
public
Set
<
Host
>
getHosts
(
Ip
Address
ip
)
{
Set
<
Host
>
ipset
=
new
HashSet
<>();
for
(
Host
h
:
hosts
.
values
())
{
if
(
h
.
ipAddresses
().
contains
(
ip
))
{
...
...
@@ -418,7 +418,7 @@ public class GossipHostStore
*/
public
StoredHost
(
ProviderId
providerId
,
HostId
id
,
MacAddress
mac
,
VlanId
vlan
,
Timestamped
<
HostLocation
>
location
,
Set
<
Ip
Prefix
>
ips
,
Annotations
...
annotations
)
{
Set
<
Ip
Address
>
ips
,
Annotations
...
annotations
)
{
super
(
providerId
,
id
,
mac
,
vlan
,
location
.
value
(),
ips
,
annotations
);
this
.
location
=
location
;
}
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleHostStore.java
View file @
755fb43
...
...
@@ -23,7 +23,7 @@ import org.onlab.onos.net.host.InterfaceIpAddress;
import
org.onlab.onos.net.host.PortAddresses
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.AbstractStore
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
...
...
@@ -106,7 +106,7 @@ public class SimpleHostStore
return
null
;
}
Set
<
Ip
Prefix
>
addresses
=
new
HashSet
<>(
host
.
ipAddresses
());
Set
<
Ip
Address
>
addresses
=
new
HashSet
<>(
host
.
ipAddresses
());
addresses
.
addAll
(
descr
.
ipAddress
());
StoredHost
updated
=
new
StoredHost
(
providerId
,
host
.
id
(),
host
.
mac
(),
host
.
vlan
(),
...
...
@@ -170,7 +170,7 @@ public class SimpleHostStore
}
@Override
public
Set
<
Host
>
getHosts
(
Ip
Prefix
ip
)
{
public
Set
<
Host
>
getHosts
(
Ip
Address
ip
)
{
Set
<
Host
>
ipset
=
new
HashSet
<>();
for
(
Host
h
:
hosts
.
values
())
{
if
(
h
.
ipAddresses
().
contains
(
ip
))
{
...
...
@@ -288,7 +288,7 @@ public class SimpleHostStore
*/
public
StoredHost
(
ProviderId
providerId
,
HostId
id
,
MacAddress
mac
,
VlanId
vlan
,
HostLocation
location
,
Set
<
Ip
Prefix
>
ips
,
Annotations
...
annotations
)
{
Set
<
Ip
Address
>
ips
,
Annotations
...
annotations
)
{
super
(
providerId
,
id
,
mac
,
vlan
,
location
,
ips
,
annotations
);
this
.
location
=
location
;
}
...
...
providers/host/src/main/java/org/onlab/onos/provider/host/impl/HostLocationProvider.java
View file @
755fb43
...
...
@@ -43,7 +43,7 @@ import org.onlab.onos.net.topology.Topology;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.packet.ARP
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
...
...
@@ -122,8 +122,8 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
// Potentially a new or moved host
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
ARP
arp
=
(
ARP
)
eth
.
getPayload
();
Ip
Prefix
ip
=
IpPrefix
.
valueOf
(
arp
.
getSenderProtocolAddress
(),
IpPrefix
.
MAX_INET_MASK
);
Ip
Address
ip
=
IpAddress
.
valueOf
(
arp
.
getSenderProtocolAddress
()
);
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ip
);
providerService
.
hostDetected
(
hid
,
hdescr
);
...
...
providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
View file @
755fb43
...
...
@@ -47,7 +47,7 @@ import org.onlab.onos.openflow.controller.PacketListener;
import
org.onlab.packet.ARP
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.IPv4
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
...
...
@@ -128,16 +128,16 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
// Potentially a new or moved host
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
ARP
arp
=
(
ARP
)
eth
.
getPayload
();
Ip
Prefix
ip
=
IpPrefix
.
valueOf
(
arp
.
getSenderProtocolAddress
(),
IpPrefix
.
MAX_INET_MASK
);
Ip
Address
ip
=
IpAddress
.
valueOf
(
arp
.
getSenderProtocolAddress
()
);
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ip
);
providerService
.
hostDetected
(
hid
,
hdescr
);
}
else
if
(
ipLearn
&&
eth
.
getEtherType
()
==
Ethernet
.
TYPE_IPV4
)
{
IPv4
pip
=
(
IPv4
)
eth
.
getPayload
();
Ip
Prefix
ip
=
IpPrefix
.
valueOf
(
pip
.
getSourceAddress
(),
IpPrefix
.
MAX_INET_MASK
);
Ip
Address
ip
=
IpAddress
.
valueOf
(
pip
.
getSourceAddress
()
);
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ip
);
providerService
.
hostDetected
(
hid
,
hdescr
);
...
...
web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
View file @
755fb43
...
...
@@ -43,7 +43,7 @@ import org.onlab.onos.net.link.LinkProviderRegistry;
import
org.onlab.onos.net.link.LinkProviderService
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.ChassisId
;
import
org.onlab.packet.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -179,7 +179,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
HostId
hostId
=
HostId
.
hostId
(
mac
,
vlanId
);
SparseAnnotations
annotations
=
annotations
(
node
.
get
(
"annotations"
));
HostLocation
location
=
new
HostLocation
(
connectPoint
(
get
(
node
,
"location"
)),
0
);
Ip
Prefix
ip
=
IpPrefix
.
valueOf
(
get
(
node
,
"ip"
));
Ip
Address
ip
=
IpAddress
.
valueOf
(
get
(
node
,
"ip"
));
DefaultHostDescription
desc
=
new
DefaultHostDescription
(
mac
,
vlanId
,
location
,
ip
,
annotations
);
...
...
web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
View file @
755fb43
...
...
@@ -33,7 +33,7 @@ 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.Ip
Prefix
;
import
org.onlab.packet.Ip
Address
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.rest.BaseResource
;
...
...
@@ -102,8 +102,8 @@ public class TopologyResource extends BaseResource {
private
ArrayNode
getHosts
(
ObjectMapper
mapper
,
HostService
hostService
)
{
ArrayNode
hosts
=
mapper
.
createArrayNode
();
for
(
Host
host
:
hostService
.
getHosts
())
{
Set
<
Ip
Prefix
>
ipAddresses
=
host
.
ipAddresses
();
Ip
Prefix
ipAddress
=
ipAddresses
.
isEmpty
()
?
null
:
ipAddresses
.
iterator
().
next
();
Set
<
Ip
Address
>
ipAddresses
=
host
.
ipAddresses
();
Ip
Address
ipAddress
=
ipAddresses
.
isEmpty
()
?
null
:
ipAddresses
.
iterator
().
next
();
String
label
=
ipAddress
!=
null
?
ipAddress
.
toString
()
:
host
.
mac
().
toString
();
hosts
.
add
(
json
(
mapper
,
host
));
}
...
...
@@ -160,8 +160,8 @@ public class TopologyResource extends BaseResource {
return
json
;
}
private
String
ip
(
Set
<
Ip
Prefix
>
ipPrefix
es
)
{
Iterator
<
Ip
Prefix
>
it
=
ipPrefix
es
.
iterator
();
private
String
ip
(
Set
<
Ip
Address
>
ipAddress
es
)
{
Iterator
<
Ip
Address
>
it
=
ipAddress
es
.
iterator
();
return
it
.
hasNext
()
?
it
.
next
().
toString
()
:
"unknown"
;
}
...
...
Please
register
or
login
to post a comment