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-10-15 18:30:31 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c16656fc67278619a6bf72ced80983ac289f6a50
c16656fc
1 parent
5fa3dc09
Added ability to configure reactive forwarding.
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
5 deletions
apps/fwd/pom.xml
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
pom.xml
apps/fwd/pom.xml
View file @
c16656f
...
...
@@ -16,4 +16,11 @@
<description>
ONOS simple reactive forwarding app
</description>
<dependencies>
<dependency>
<groupId>
org.osgi
</groupId>
<artifactId>
org.osgi.compendium
</artifactId>
</dependency>
</dependencies>
</project>
...
...
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
View file @
c16656f
package
org
.
onlab
.
onos
.
fwd
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Set
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Modified
;
import
org.apache.felix.scr.annotations.Property
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.ApplicationId
;
...
...
@@ -29,8 +27,14 @@ import org.onlab.onos.net.packet.PacketProcessor;
import
org.onlab.onos.net.packet.PacketService
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.packet.Ethernet
;
import
org.osgi.service.component.ComponentContext
;
import
org.slf4j.Logger
;
import
java.util.Dictionary
;
import
java.util.Set
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* Sample reactive forwarding application.
*/
...
...
@@ -61,6 +65,9 @@ public class ReactiveForwarding {
private
ApplicationId
appId
;
@Property
(
name
=
"enabled"
,
boolValue
=
true
,
label
=
"Forwarding enabled"
)
private
boolean
isEnabled
=
true
;
@Activate
public
void
activate
()
{
appId
=
coreService
.
registerApplication
(
"org.onlab.onos.fwd"
);
...
...
@@ -76,6 +83,21 @@ public class ReactiveForwarding {
log
.
info
(
"Stopped"
);
}
@Modified
public
void
modified
(
ComponentContext
context
)
{
Dictionary
properties
=
context
.
getProperties
();
String
flag
=
(
String
)
properties
.
get
(
"enabled"
);
if
(
flag
!=
null
)
{
boolean
enabled
=
flag
.
equals
(
"true"
);
if
(
isEnabled
!=
enabled
)
{
isEnabled
=
enabled
;
if
(!
isEnabled
)
{
flowRuleService
.
removeFlowRulesById
(
appId
);
}
log
.
info
(
"Reconfigured enabled = {}"
,
isEnabled
);
}
}
}
/**
* Packet processor responsible for forwarding packets along their paths.
...
...
@@ -86,7 +108,7 @@ public class ReactiveForwarding {
public
void
process
(
PacketContext
context
)
{
// Stop processing if the packet has been handled, since we
// can't do any more to it.
if
(
context
.
isHandled
())
{
if
(
!
isEnabled
||
context
.
isHandled
())
{
return
;
}
...
...
pom.xml
View file @
c16656f
...
...
@@ -164,6 +164,12 @@
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.osgi
</groupId>
<artifactId>
org.osgi.compendium
</artifactId>
<version>
4.3.1
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.felix
</groupId>
<artifactId>
org.apache.felix.scr.annotations
</artifactId>
<version>
1.9.8
</version>
...
...
Please
register
or
login
to post a comment