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
Brian O'Connor
2014-10-03 19:46:23 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
958d381a16c9d7cb77164fb302bacf048b08ef20
958d381a
1 parent
a4cab073
Updating Reactive forwarding to output unicast packet and added intents to wipe-out command
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
View file @
958d381
package
org
.
onlab
.
onos
.
ifwd
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -17,7 +19,9 @@ import org.onlab.onos.net.host.HostService;
import
org.onlab.onos.net.intent.HostToHostIntent
;
import
org.onlab.onos.net.intent.IntentId
;
import
org.onlab.onos.net.intent.IntentService
;
import
org.onlab.onos.net.packet.DefaultOutboundPacket
;
import
org.onlab.onos.net.packet.InboundPacket
;
import
org.onlab.onos.net.packet.OutboundPacket
;
import
org.onlab.onos.net.packet.PacketContext
;
import
org.onlab.onos.net.packet.PacketProcessor
;
import
org.onlab.onos.net.packet.PacketService
;
...
...
@@ -25,17 +29,12 @@ import org.onlab.onos.net.topology.TopologyService;
import
org.onlab.packet.Ethernet
;
import
org.slf4j.Logger
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
*/
@Component
(
immediate
=
true
)
public
class
IntentReactiveForwarding
{
private
static
final
int
TIMEOUT
=
10
;
private
static
final
int
PRIORITY
=
10
;
private
final
Logger
log
=
getLogger
(
getClass
());
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
...
...
@@ -98,6 +97,7 @@ public class IntentReactiveForwarding {
// Otherwise forward and be done with it.
setUpConnectivity
(
context
,
srcId
,
dstId
);
forwardPacketToDst
(
context
,
dst
);
}
}
...
...
@@ -117,6 +117,14 @@ public class IntentReactiveForwarding {
context
.
send
();
}
private
void
forwardPacketToDst
(
PacketContext
context
,
Host
dst
)
{
TrafficTreatment
treatment
=
DefaultTrafficTreatment
.
builder
().
setOutput
(
dst
.
location
().
port
()).
build
();
OutboundPacket
packet
=
new
DefaultOutboundPacket
(
dst
.
location
().
deviceId
(),
treatment
,
context
.
inPacket
().
unparsed
());
packetService
.
emit
(
packet
);
log
.
info
(
"sending packet: {}"
,
packet
);
}
// Install a rule forwarding the packet to the specified port.
private
void
setUpConnectivity
(
PacketContext
context
,
HostId
srcId
,
HostId
dstId
)
{
TrafficSelector
selector
=
DefaultTrafficSelector
.
builder
().
build
();
...
...
cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
View file @
958d381
...
...
@@ -7,6 +7,9 @@ import org.onlab.onos.net.device.DeviceAdminService;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.host.HostAdminService
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.intent.Intent
;
import
org.onlab.onos.net.intent.IntentService
;
import
org.onlab.onos.net.intent.IntentState
;
/**
* Wipes-out the entire network information base, i.e. devices, links, hosts.
...
...
@@ -28,7 +31,12 @@ public class WipeOutCommand extends ClustersListCommand {
for
(
Host
host
:
hostService
.
getHosts
())
{
hostAdminService
.
removeHost
(
host
.
id
());
}
}
IntentService
intentService
=
get
(
IntentService
.
class
);
for
(
Intent
intent
:
intentService
.
getIntents
())
{
if
(
intentService
.
getIntentState
(
intent
.
getId
())
==
IntentState
.
INSTALLED
)
{
intentService
.
withdraw
(
intent
);
}
}
}
}
...
...
Please
register
or
login
to post a comment