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
tom
2014-09-30 10:38:40 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
770218a0cc8e9f611812e362f8b2798c648a6c75
770218a0
2 parents
28e1fa21
3f8ebbeb
Merge remote-tracking branch 'origin/master'
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
View file @
770218a
...
...
@@ -28,7 +28,7 @@ import com.google.common.collect.Lists;
/**
* Sample
reactive forwarding application
.
* Sample
mobility application. Cleans up flowmods when a host moves
.
*/
@Component
(
immediate
=
true
)
public
class
HostMobility
{
...
...
@@ -82,6 +82,10 @@ public class HostMobility {
}
/**
* For a given host, remove any flow rule which references it's addresses.
* @param host the host to clean up for
*/
private
void
cleanup
(
Host
host
)
{
Iterable
<
Device
>
devices
=
deviceService
.
getDevices
();
List
<
FlowRule
>
flowRules
=
Lists
.
newLinkedList
();
...
...
@@ -102,7 +106,6 @@ public class HostMobility {
EthCriterion
eth
=
(
EthCriterion
)
c
;
if
(
eth
.
mac
().
equals
(
mac
))
{
flowRules
.
add
(
rule
);
break
;
}
}
}
...
...
providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
View file @
770218a
...
...
@@ -31,6 +31,7 @@ import org.onlab.onos.openflow.controller.OpenFlowPacketContext;
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.IpPrefix
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
...
...
@@ -92,8 +93,6 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
public
void
handlePacket
(
OpenFlowPacketContext
pktCtx
)
{
Ethernet
eth
=
pktCtx
.
parsed
();
// Potentially a new or moved host
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
VlanId
vlan
=
VlanId
.
vlanId
(
eth
.
getVlanID
());
ConnectPoint
heardOn
=
new
ConnectPoint
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()));
...
...
@@ -107,14 +106,24 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
HostLocation
hloc
=
new
HostLocation
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()),
System
.
currentTimeMillis
());
HostId
hid
=
HostId
.
hostId
(
eth
.
getSourceMAC
(),
vlan
);
// Potentially a new or moved host
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
ARP
arp
=
(
ARP
)
eth
.
getPayload
();
Set
<
IpPrefix
>
ips
=
newHashSet
(
IpPrefix
.
valueOf
(
arp
.
getSenderProtocolAddress
()));
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ips
);
providerService
.
hostDetected
(
hid
,
hdescr
);
}
else
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_IPV4
)
{
IPv4
ip
=
(
IPv4
)
eth
.
getPayload
();
Set
<
IpPrefix
>
ips
=
newHashSet
(
IpPrefix
.
valueOf
(
ip
.
getSourceAddress
()));
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ips
);
providerService
.
hostDetected
(
hid
,
hdescr
);
}
// TODO: Use DHCP packets as well later...
...
...
Please
register
or
login
to post a comment