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
alshabib
2014-09-13 17:14:53 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d58d3521094eab0cf0ea1c1b0c0dcb796f4bd56a
d58d3521
1 parent
5717f39f
receiving packet ins
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
17 deletions
core/trivial/src/main/java/org/onlab/onos/net/trivial/packet/impl/SimplePacketManager.java
features/features.xml
of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java
of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/packet/impl/SimplePacketManager.java
View file @
d58d352
...
...
@@ -2,7 +2,8 @@ package org.onlab.onos.net.trivial.packet.impl;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
...
...
@@ -39,7 +40,7 @@ implements PacketService, PacketProviderRegistry {
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
private
DeviceService
deviceService
;
private
final
ArrayList
<
PacketProcessor
>
processors
=
new
ArrayList
<>();
private
final
Map
<
Integer
,
PacketProcessor
>
processors
=
new
TreeMap
<>();
private
final
PacketProcessor
reactiveProcessor
=
new
ReactivePacketProcessor
();
...
...
@@ -57,12 +58,12 @@ implements PacketService, PacketProviderRegistry {
@Override
public
void
addProcessor
(
PacketProcessor
processor
,
int
priority
)
{
processors
.
add
(
priority
,
processor
);
processors
.
put
(
priority
,
processor
);
}
@Override
public
void
removeProcessor
(
PacketProcessor
processor
)
{
processors
.
remove
(
processor
);
processors
.
values
().
remove
(
processor
);
}
@Override
...
...
@@ -89,7 +90,7 @@ implements PacketService, PacketProviderRegistry {
@Override
public
void
processPacket
(
PacketContext
context
)
{
for
(
PacketProcessor
processor
:
processors
)
{
for
(
PacketProcessor
processor
:
processors
.
values
()
)
{
processor
.
process
(
context
);
}
}
...
...
features/features.xml
View file @
d58d352
...
...
@@ -68,6 +68,8 @@
<bundle>
mvn:org.onlab.onos/onos-of-provider-device/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onos-of-provider-link/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onos-of-provider-host/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onos-of-provider-packet/1.0.0-SNAPSHOT
</bundle>
</feature>
<feature
name=
"onos-app-tvue"
version=
"1.0.0"
...
...
of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java
View file @
d58d352
...
...
@@ -33,8 +33,8 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
public
void
send
()
{
if
(
free
&&
isBuilt
)
{
sw
.
sendMsg
(
pktout
);
block
();
}
}
@Override
...
...
of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
View file @
d58d352
package
org
.
onlab
.
onos
.
of
.
controller
.
impl
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.
List
;
import
java.util.
Map
;
import
java.util.Set
;
import
java.util.TreeMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.ReentrantLock
;
...
...
@@ -43,7 +43,7 @@ public class OpenFlowControllerImpl implements OpenFlowController {
protected
OpenFlowSwitchAgent
agent
=
new
OpenFlowSwitchAgent
();
protected
Set
<
OpenFlowSwitchListener
>
ofEventListener
=
new
HashSet
<>();
protected
List
<
PacketListener
>
ofPacketListener
=
new
ArrayList
<>();
protected
Map
<
Integer
,
PacketListener
>
ofPacketListener
=
new
TreeMap
<>();
private
final
Controller
ctrl
=
new
Controller
();
...
...
@@ -101,7 +101,7 @@ public class OpenFlowControllerImpl implements OpenFlowController {
@Override
public
void
addPacketListener
(
int
priority
,
PacketListener
listener
)
{
ofPacketListener
.
add
(
priority
,
listener
);
ofPacketListener
.
put
(
priority
,
listener
);
}
@Override
...
...
@@ -123,7 +123,7 @@ public class OpenFlowControllerImpl implements OpenFlowController {
}
break
;
case
PACKET_IN:
for
(
PacketListener
p
:
ofPacketListener
)
{
for
(
PacketListener
p
:
ofPacketListener
.
values
()
)
{
p
.
handlePacket
(
DefaultOpenFlowPacketContext
.
packetContextFromPacketIn
(
this
.
getSwitch
(
dpid
),
(
OFPacketIn
)
msg
));
...
...
providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
View file @
d58d352
...
...
@@ -2,17 +2,24 @@ package org.onlab.onos.provider.of.packet.impl;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.nio.ByteBuffer
;
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.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.packet.DefaultInboundPacket
;
import
org.onlab.onos.net.packet.OutboundPacket
;
import
org.onlab.onos.net.packet.PacketProvider
;
import
org.onlab.onos.net.packet.PacketProviderRegistry
;
import
org.onlab.onos.net.packet.PacketProviderService
;
import
org.onlab.onos.net.provider.AbstractProvider
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.of.controller.Dpid
;
import
org.onlab.onos.of.controller.OpenFlowController
;
import
org.onlab.onos.of.controller.OpenFlowPacketContext
;
import
org.onlab.onos.of.controller.PacketListener
;
...
...
@@ -35,12 +42,8 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
private
PacketProviderService
providerService
;
private
final
boolean
useBDDP
=
true
;
private
final
InternalPacketProvider
listener
=
new
InternalPacketProvider
();
/**
* Creates an OpenFlow link provider.
*/
...
...
@@ -51,7 +54,7 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
@Activate
public
void
activate
()
{
providerService
=
providerRegistry
.
register
(
this
);
controller
.
addPacketListener
(
0
,
listener
);
controller
.
addPacketListener
(
1
,
listener
);
log
.
info
(
"Started"
);
}
...
...
@@ -65,18 +68,29 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
@Override
public
void
emit
(
OutboundPacket
packet
)
{
// TODO Auto-generated method stub
}
/**
* Internal Packet Provider implementation.
*
*/
private
class
InternalPacketProvider
implements
PacketListener
{
@Override
public
void
handlePacket
(
OpenFlowPacketContext
pktCtx
)
{
DeviceId
id
=
DeviceId
.
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
().
value
()));
DefaultInboundPacket
inPkt
=
new
DefaultInboundPacket
(
new
ConnectPoint
(
id
,
PortNumber
.
portNumber
(
pktCtx
.
inPort
())),
pktCtx
.
parsed
(),
ByteBuffer
.
wrap
(
pktCtx
.
unparsed
()));
OpenFlowCorePacketContext
corePktCtx
=
new
OpenFlowCorePacketContext
(
0
,
inPkt
,
null
,
false
,
pktCtx
,
controller
.
getSwitch
(
pktCtx
.
dpid
()));
providerService
.
processPacket
(
corePktCtx
);
}
}
...
...
Please
register
or
login
to post a comment