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-09 14:45:14 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9ee681721cba0dae0ee46e6280a1189ff26272d2
9ee68172
1 parent
484ac5cf
link discovery no longer need a parsed packet
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
25 deletions
of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java
of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.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 @
9ee6817
...
...
@@ -80,4 +80,9 @@ public final class DefaultPacketContext implements PacketContext {
return
pktin
.
getInPort
().
getPortNumber
();
}
@Override
public
byte
[]
unparsed
()
{
return
pktin
.
getData
().
clone
();
}
}
...
...
of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java
View file @
9ee6817
...
...
@@ -44,6 +44,12 @@ public interface PacketContext {
public
Ethernet
parsed
();
/**
* Provide an unparsed copy of the data.
* @return the unparsed form of the payload.
*/
public
byte
[]
unparsed
();
/**
* Provide the dpid of the switch where the packet in arrived.
* @return the dpid of the switch.
*/
...
...
of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
View file @
9ee6817
This diff is collapsed. Click to expand it.
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
View file @
9ee6817
...
...
@@ -21,9 +21,9 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -85,6 +85,7 @@ public class LinkDiscovery implements TimerTask {
private
final
boolean
useBDDP
;
private
final
OpenFlowController
ctrl
;
private
final
LinkProviderService
linkProvider
;
private
final
Map
<
Integer
,
OFPortDesc
>
ports
;
/**
* Instantiates discovery manager for the given physical switch. Creates a
...
...
@@ -103,6 +104,7 @@ public class LinkDiscovery implements TimerTask {
this
.
linkProvider
=
providerService
;
this
.
slowPorts
=
Collections
.
synchronizedSet
(
new
HashSet
<
Integer
>());
this
.
fastPorts
=
Collections
.
synchronizedSet
(
new
HashSet
<
Integer
>());
this
.
ports
=
new
ConcurrentHashMap
<>();
this
.
portProbeCount
=
new
HashMap
<
Integer
,
AtomicInteger
>();
this
.
lldpPacket
=
new
ONLabLddp
();
this
.
lldpPacket
.
setSwitch
(
this
.
sw
.
getId
());
...
...
@@ -140,7 +142,7 @@ public class LinkDiscovery implements TimerTask {
*/
public
void
addPort
(
final
OFPortDesc
port
)
{
// Ignore ports that are not on this switch, or already booted. */
this
.
ports
.
put
(
port
.
getPortNo
().
getPortNumber
(),
port
);
synchronized
(
this
)
{
this
.
log
.
debug
(
"sending init probe to port {}"
,
port
.
getPortNo
().
getPortNumber
());
...
...
@@ -274,12 +276,10 @@ public class LinkDiscovery implements TimerTask {
* Handles an incoming LLDP packet. Creates link in topology and sends ACK
* to port where LLDP originated.
*/
@SuppressWarnings
(
"rawtypes"
)
public
void
handleLLDP
(
final
Ethernet
eth
,
Integer
inPort
)
{
final
byte
[]
pkt
=
eth
.
serialize
();
public
void
handleLLDP
(
final
byte
[]
pkt
,
Integer
inPort
)
{
if
(
ONLabLddp
.
isOVXLLDP
(
pkt
))
{
short
ethType
=
ONLabLddp
.
isOVXLLDP
(
pkt
);
if
(
ethType
==
Ethernet
.
TYPE_LLDP
||
ethType
==
Ethernet
.
TYPE_BSN
)
{
final
Integer
dstPort
=
inPort
;
final
DPIDandPort
dp
=
ONLabLddp
.
parseLLDP
(
pkt
);
final
OpenFlowSwitch
srcSwitch
=
ctrl
.
getSwitch
(
new
Dpid
(
dp
.
getDpid
()));
...
...
@@ -296,7 +296,7 @@ public class LinkDiscovery implements TimerTask {
DeviceId
.
deviceId
(
"of:"
+
Long
.
toHexString
(
sw
.
getId
())),
PortNumber
.
portNumber
(
dstPort
));
LinkDescription
ld
;
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_BSN
)
{
if
(
eth
Type
==
Ethernet
.
TYPE_BSN
)
{
ld
=
new
DefaultLinkDescription
(
src
,
dst
,
Type
.
INDIRECT
);
}
else
{
ld
=
new
DefaultLinkDescription
(
src
,
dst
,
Type
.
DIRECT
);
...
...
@@ -307,13 +307,8 @@ public class LinkDiscovery implements TimerTask {
}
}
private
OFPortDesc
findPort
(
List
<
OFPortDesc
>
ports
,
Integer
inPort
)
{
for
(
OFPortDesc
p
:
ports
)
{
if
(
p
.
getPortNo
().
getPortNumber
()
==
inPort
)
{
return
p
;
}
}
return
null
;
private
OFPortDesc
findPort
(
Integer
inPort
)
{
return
ports
.
get
(
inPort
);
}
/**
...
...
@@ -333,7 +328,7 @@ public class LinkDiscovery implements TimerTask {
final
Integer
portNumber
=
fastIterator
.
next
();
final
int
probeCount
=
this
.
portProbeCount
.
get
(
portNumber
)
.
getAndIncrement
();
OFPortDesc
port
=
findPort
(
this
.
sw
.
getPorts
(),
portNumber
);
OFPortDesc
port
=
findPort
(
portNumber
);
if
(
probeCount
<
LinkDiscovery
.
MAX_PROBE_COUNT
)
{
this
.
log
.
debug
(
"sending fast probe to port"
);
...
...
@@ -368,7 +363,7 @@ public class LinkDiscovery implements TimerTask {
if
(
this
.
slowIterator
.
hasNext
())
{
final
int
portNumber
=
this
.
slowIterator
.
next
();
this
.
log
.
debug
(
"sending slow probe to port {}"
,
portNumber
);
OFPortDesc
port
=
findPort
(
this
.
sw
.
getPorts
(),
portNumber
);
OFPortDesc
port
=
findPort
(
portNumber
);
OFPacketOut
pkt
=
this
.
createLLDPPacketOut
(
port
);
this
.
sendMsg
(
pkt
);
...
...
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
View file @
9ee6817
...
...
@@ -87,7 +87,7 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
if
(
ld
==
null
)
{
return
;
}
ld
.
handleLLDP
(
pktCtx
.
parsed
(),
ld
.
handleLLDP
(
pktCtx
.
un
parsed
(),
pktCtx
.
inPort
());
}
...
...
utils/misc/src/main/java/org/onlab/packet/ONLabLddp.java
View file @
9ee6817
...
...
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory;
* Refer to IEEE Std 802.1ABTM-2009 for more information.
*
*/
@SuppressWarnings
(
"rawtypes"
)
public
class
ONLabLddp
extends
LLDP
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ONLabLddp
.
class
);
...
...
@@ -308,28 +307,34 @@ public class ONLabLddp extends LLDP {
* @param packet
* @return
*/
public
static
boolean
isOVXLLDP
(
byte
[]
packet
)
{
public
static
short
isOVXLLDP
(
byte
[]
packet
)
{
if
(
packet
.
length
<
OVX_LLDP_SIZE
)
{
return
false
;
return
-
1
;
}
// Extra offset due to VLAN tag
final
ByteBuffer
bb
=
ByteBuffer
.
wrap
(
packet
);
int
offset
=
0
;
if
(
bb
.
getShort
(
ETHERTYPE_OFFSET
)
!=
Ethernet
.
TYPE_LLDP
&&
bb
.
getShort
(
ETHERTYPE_OFFSET
)
!=
Ethernet
.
TYPE_BSN
)
{
short
ethType
=
bb
.
getShort
(
ETHERTYPE_OFFSET
);
if
(
ethType
!=
Ethernet
.
TYPE_LLDP
&&
ethType
!=
Ethernet
.
TYPE_BSN
)
{
offset
=
4
;
ethType
=
bb
.
getShort
(
ETHERTYPE_OFFSET
+
offset
);
if
(
ethType
!=
Ethernet
.
TYPE_LLDP
&&
ethType
!=
Ethernet
.
TYPE_BSN
)
{
return
-
1
;
}
}
// Compare packet's organizationally specific TLVs to the expected
// values
for
(
int
i
=
0
;
i
<
OUI_TLV
.
length
;
i
++)
{
if
(
packet
[
NAME_TLV_OFFSET
+
offset
+
i
]
!=
OUI_TLV
[
i
])
{
return
false
;
return
-
1
;
}
}
return
tru
e
;
return
ethTyp
e
;
}
/**
...
...
Please
register
or
login
to post a comment