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-07 19:09:28 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
289652c591f7ed0ae8b460ae781bb63f685ed818
289652c5
1 parent
638dc71f
started adding link discovery
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
18 deletions
of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
utils/misc/pom.xml
utils/misc/src/main/java/org/onlab/packet/OVXLLDP.java → utils/misc/src/main/java/org/onlab/packet/ONLabLddp.java
of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
View file @
289652c
package
org
.
onlab
.
onos
.
of
.
controller
;
import
java.util.Collections
;
import
org.onlab.packet.Ethernet
;
import
org.projectfloodlight.openflow.protocol.OFPacketIn
;
import
org.projectfloodlight.openflow.protocol.OFPacketOut
;
import
org.projectfloodlight.openflow.protocol.action.OFAction
;
import
org.projectfloodlight.openflow.types.OFBufferId
;
import
org.projectfloodlight.openflow.types.OFPort
;
public
final
class
DefaultPacketContext
implements
PacketContext
{
...
...
@@ -11,7 +15,7 @@ public final class DefaultPacketContext implements PacketContext {
private
boolean
isBuilt
=
false
;
private
final
OpenFlowSwitch
sw
;
private
final
OFPacketIn
pktin
;
private
final
OFPacketOut
pktout
=
null
;
private
OFPacketOut
pktout
=
null
;
private
DefaultPacketContext
(
OpenFlowSwitch
s
,
OFPacketIn
pkt
)
{
this
.
sw
=
s
;
...
...
@@ -39,20 +43,32 @@ public final class DefaultPacketContext implements PacketContext {
@Override
public
void
build
(
Ethernet
ethFrame
,
OFPort
outPort
)
{
// TODO Auto-generated method stub
if
(
isBuilt
)
{
return
;
}
OFPacketOut
.
Builder
builder
=
sw
.
factory
().
buildPacketOut
();
OFAction
act
=
sw
.
factory
().
actions
()
.
buildOutput
()
.
setPort
(
OFPort
.
of
(
outPort
.
getPortNumber
()))
.
build
();
pktout
=
builder
.
setXid
(
pktin
.
getXid
())
.
setBufferId
(
OFBufferId
.
NO_BUFFER
)
.
setActions
(
Collections
.
singletonList
(
act
))
.
setData
(
ethFrame
.
serialize
())
.
build
();
isBuilt
=
true
;
}
@Override
public
Ethernet
parsed
()
{
// TODO Auto-generated method stub
return
null
;
Ethernet
eth
=
new
Ethernet
();
eth
.
deserialize
(
pktin
.
getData
(),
0
,
pktin
.
getTotalLen
());
return
eth
;
}
@Override
public
Dpid
dpid
()
{
// TODO Auto-generated method stub
return
null
;
return
new
Dpid
(
sw
.
getId
());
}
public
static
PacketContext
packetContextFromPacketIn
(
OpenFlowSwitch
s
,
OFPacketIn
pkt
)
{
...
...
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
View file @
289652c
...
...
@@ -12,9 +12,12 @@ import org.onlab.onos.net.link.LinkProviderRegistry;
import
org.onlab.onos.net.link.LinkProviderService
;
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.OpenFlowSwitchListener
;
import
org.onlab.onos.of.controller.PacketContext
;
import
org.onlab.onos.of.controller.PacketListener
;
import
org.projectfloodlight.openflow.protocol.OFPortStatus
;
import
org.slf4j.Logger
;
/**
...
...
@@ -34,7 +37,7 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
private
LinkProviderService
providerService
;
private
final
PacketListen
er
listener
=
new
InternalLinkProvider
();
private
final
InternalLinkProvid
er
listener
=
new
InternalLinkProvider
();
/**
* Creates an OpenFlow link provider.
...
...
@@ -46,6 +49,7 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
@Activate
public
void
activate
()
{
providerService
=
providerRegistry
.
register
(
this
);
controller
.
addListener
(
listener
);
controller
.
addPacketListener
(
0
,
listener
);
log
.
info
(
"Started"
);
}
...
...
@@ -53,19 +57,38 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
@Deactivate
public
void
deactivate
()
{
providerRegistry
.
unregister
(
this
);
controller
.
removeListener
(
listener
);
controller
.
removePacketListener
(
listener
);
providerService
=
null
;
log
.
info
(
"Stopped"
);
}
private
class
InternalLinkProvider
implements
PacketListener
{
private
class
InternalLinkProvider
implements
PacketListener
,
OpenFlowSwitchListener
{
@Override
public
void
handlePacket
(
PacketContext
pktCtx
)
{
}
@Override
public
void
switchAdded
(
Dpid
dpid
)
{
// TODO Auto-generated method stub
}
@Override
public
void
switchRemoved
(
Dpid
dpid
)
{
// TODO Auto-generated method stub
}
@Override
public
void
portChanged
(
Dpid
dpid
,
OFPortStatus
status
)
{
// TODO Auto-generated method stub
}
}
}
...
...
utils/misc/pom.xml
View file @
289652c
...
...
@@ -23,6 +23,11 @@
<version>
17.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty
</artifactId>
<version>
3.9.0.Final
</version>
</dependency>
</dependencies>
</project>
...
...
utils/misc/src/main/java/org/onlab/packet/O
VXLLDP
.java
→
utils/misc/src/main/java/org/onlab/packet/O
NLabLddp
.java
View file @
289652c
...
...
@@ -29,7 +29,7 @@ import org.apache.commons.lang.ArrayUtils;
*
*/
@SuppressWarnings
(
"rawtypes"
)
public
class
O
VXLLDP
extends
LLDP
{
public
class
O
NLabLddp
extends
LLDP
{
// ON.Lab OUI and OVX name for organizationally specific TLVs
public
static
final
byte
[]
ONLAB_OUI
=
{(
byte
)
0xa4
,
0x23
,
0x05
};
...
...
@@ -58,7 +58,7 @@ public class OVXLLDP extends LLDP {
private
static
final
byte
NAME_TLV_TYPE
=
127
;
// 4 = OUI (3) + subtype (1)
private
static
final
byte
NAME_TLV_SIZE
=
(
byte
)
(
4
+
O
VXLLDP
.
OVX_NAME
.
length
());
private
static
final
byte
NAME_TLV_SIZE
=
(
byte
)
(
4
+
O
NLabLddp
.
OVX_NAME
.
length
());
private
static
final
byte
NAME_TLV_SUBTYPE
=
1
;
private
static
final
short
NAME_TLV_OFFSET
=
32
;
private
static
final
short
NAME_TLV_HEADER
=
(
short
)
((
NAME_TLV_TYPE
<<
9
)
|
NAME_TLV_SIZE
);
...
...
@@ -119,7 +119,7 @@ public class OVXLLDP extends LLDP {
/**
* Instantiates a new OVX LDDP message.
*/
public
O
VXLLDP
()
{
public
O
NLabLddp
()
{
// Create TLVs
this
.
chassisTLV
=
new
LLDPTLV
();
this
.
portTLV
=
new
LLDPTLV
();
...
...
@@ -140,7 +140,7 @@ public class OVXLLDP extends LLDP {
this
.
setChassisTLV
(
DEFAULT_DPID
);
this
.
setPortTLV
(
DEFAULT_PORT
);
this
.
setTTLTLV
(
DEFAULT_TTL
);
this
.
setOUIName
(
O
VXLLDP
.
OVX_NAME
);
this
.
setOUIName
(
O
NLabLddp
.
OVX_NAME
);
this
.
setOUIDpid
(
DEFAULT_DPID
);
}
...
...
@@ -198,7 +198,7 @@ public class OVXLLDP extends LLDP {
*/
private
void
setOUIName
(
final
String
name
)
{
this
.
bb
=
ByteBuffer
.
wrap
(
ouiName
);
this
.
bb
.
put
(
O
VXLLDP
.
ONLAB_OUI
);
this
.
bb
.
put
(
O
NLabLddp
.
ONLAB_OUI
);
this
.
bb
.
put
(
NAME_TLV_SUBTYPE
);
this
.
bb
.
put
(
name
.
getBytes
());
...
...
@@ -214,7 +214,7 @@ public class OVXLLDP extends LLDP {
*/
private
void
setOUIDpid
(
final
byte
[]
dpid
)
{
this
.
bb
=
ByteBuffer
.
wrap
(
ouiDpid
);
this
.
bb
.
put
(
O
VXLLDP
.
ONLAB_OUI
);
this
.
bb
.
put
(
O
NLabLddp
.
ONLAB_OUI
);
this
.
bb
.
put
(
DPID_TLV_SUBTYPE
);
this
.
bb
.
put
(
dpid
);
...
...
@@ -272,9 +272,9 @@ public class OVXLLDP extends LLDP {
final
byte
[]
dst
=
new
byte
[
6
];
bb
.
get
(
dst
);
if
(!(
Arrays
.
equals
(
dst
,
O
VXLLDP
.
LLDP_NICIRA
)
||
Arrays
.
equals
(
dst
,
O
VXLLDP
.
LLDP_MULTICAST
)
||
Arrays
.
equals
(
dst
,
O
VXLLDP
.
BDDP_MULTICAST
)))
{
if
(!(
Arrays
.
equals
(
dst
,
O
NLabLddp
.
LLDP_NICIRA
)
||
Arrays
.
equals
(
dst
,
O
NLabLddp
.
LLDP_MULTICAST
)
||
Arrays
.
equals
(
dst
,
O
NLabLddp
.
BDDP_MULTICAST
)))
{
return
false
;
}
...
...
Please
register
or
login
to post a comment