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
Praseed Balakrishnan
2014-10-20 14:21:45 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a22eadf914a7f7072e6ea7e6385d27cbd56ddae3
a22eadf9
1 parent
e90e3583
Discover LINC-OE switch and ports.
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
114 additions
and
30 deletions
core/api/src/main/java/org/onlab/onos/net/Device.java
openflow/api/pom.xml
openflow/api/src/main/java/org/onlab/onos/openflow/controller/OpenFlowSwitch.java
openflow/api/src/main/java/org/onlab/onos/openflow/controller/driver/AbstractOpenFlowSwitch.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/DriverManager.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/OFOpticalSwitchImplLINC13.java
openflow/ctl/src/test/java/org/onlab/onos/openflow/controller/impl/RoleManagerTest.java
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
providers/openflow/device/src/test/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProviderTest.java
providers/openflow/link/src/test/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProviderTest.java
providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
core/api/src/main/java/org/onlab/onos/net/Device.java
View file @
a22eadf
...
...
@@ -9,7 +9,7 @@ public interface Device extends Element {
* Coarse classification of the type of the infrastructure device.
*/
public
enum
Type
{
SWITCH
,
ROUTER
,
FIREWALL
,
BALANCER
,
IPS
,
IDS
,
CONTROLLER
,
OTHER
SWITCH
,
ROUTER
,
ROADM
,
FIREWALL
,
BALANCER
,
IPS
,
IDS
,
CONTROLLER
,
OTHER
}
/**
...
...
openflow/api/pom.xml
View file @
a22eadf
...
...
@@ -30,7 +30,7 @@
<groupId>
org.projectfloodlight
</groupId>
<artifactId>
openflowj
</artifactId>
<!-- FIXME once experimenter gets merged to upstream -->
<version>
0.3.8-optical_experimenter
2
</version>
<version>
0.3.8-optical_experimenter
3
</version>
</dependency>
<dependency>
<groupId>
io.netty
</groupId>
...
...
openflow/api/src/main/java/org/onlab/onos/openflow/controller/OpenFlowSwitch.java
View file @
a22eadf
...
...
@@ -112,4 +112,13 @@ public interface OpenFlowSwitch {
*/
void
returnRoleAssertFailure
(
RoleState
role
);
/**
* Indicates if this switch is optical.
*
* @return true if optical
*/
public
boolean
isOptical
();
}
...
...
openflow/api/src/main/java/org/onlab/onos/openflow/controller/driver/AbstractOpenFlowSwitch.java
View file @
a22eadf
...
...
@@ -374,4 +374,9 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
return
this
.
desc
.
getSerialNum
();
}
@Override
public
boolean
isOptical
()
{
return
false
;
}
}
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
View file @
a22eadf
...
...
@@ -399,12 +399,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
h
.
sw
.
setPortDescReply
(
h
.
portDescReply
);
h
.
sw
.
setConnected
(
true
);
h
.
sw
.
setChannel
(
h
.
channel
);
boolean
success
=
h
.
sw
.
connectSwitch
();
if
(!
success
)
{
disconnectDuplicate
(
h
);
return
;
}
//
boolean success = h.sw.connectSwitch();
//
//
if (!success) {
//
disconnectDuplicate(h);
//
return;
//
}
// set switch information
...
...
@@ -462,6 +462,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
throws
IOException
,
SwitchStateException
{
if
(
m
.
getType
()
==
OFType
.
ECHO_REQUEST
)
{
processOFEchoRequest
(
h
,
(
OFEchoRequest
)
m
);
}
else
if
(
m
.
getType
()
==
OFType
.
ECHO_REPLY
)
{
processOFEchoReply
(
h
,
(
OFEchoReply
)
m
);
}
else
if
(
m
.
getType
()
==
OFType
.
ROLE_REPLY
)
{
h
.
sw
.
handleRole
(
m
);
}
else
if
(
m
.
getType
()
==
OFType
.
ERROR
)
{
...
...
@@ -479,6 +481,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
}
else
{
h
.
sw
.
processDriverHandshakeMessage
(
m
);
if
(
h
.
sw
.
isDriverHandshakeComplete
())
{
boolean
success
=
h
.
sw
.
connectSwitch
();
if
(!
success
)
{
disconnectDuplicate
(
h
);
return
;
}
h
.
setState
(
ACTIVE
);
}
}
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/DriverManager.java
View file @
a22eadf
...
...
@@ -59,7 +59,7 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory {
String
sw
=
desc
.
getSwDesc
();
if
(
sw
.
startsWith
(
"LINC-OE"
))
{
log
.
debug
(
"Optical Emulator LINC-OE with DPID:{} found.."
,
dpid
);
log
.
warn
(
"Optical Emulator LINC-OE with DPID:{} found.."
,
dpid
);
return
new
OFOpticalSwitchImplLINC13
(
dpid
,
desc
);
}
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/OFOpticalSwitchImplLINC13.java
View file @
a22eadf
...
...
@@ -6,6 +6,7 @@ import org.onlab.onos.openflow.controller.driver.SwitchDriverSubHandshakeNotStar
import
org.onlab.onos.openflow.controller.Dpid
;
import
org.onlab.onos.openflow.controller.driver.AbstractOpenFlowSwitch
;
import
org.projectfloodlight.openflow.protocol.OFBarrierRequest
;
import
org.projectfloodlight.openflow.protocol.OFCircuitPortStatus
;
import
org.projectfloodlight.openflow.protocol.OFCircuitPortsReply
;
import
org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest
;
import
org.projectfloodlight.openflow.protocol.OFDescStatsReply
;
...
...
@@ -14,7 +15,10 @@ import org.projectfloodlight.openflow.protocol.OFMatchV3;
import
org.projectfloodlight.openflow.protocol.OFMessage
;
import
org.projectfloodlight.openflow.protocol.OFOxmList
;
import
org.projectfloodlight.openflow.protocol.OFPortDesc
;
import
org.projectfloodlight.openflow.protocol.OFPortDescStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFPortOptical
;
import
org.projectfloodlight.openflow.protocol.OFStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFStatsType
;
import
org.projectfloodlight.openflow.protocol.action.OFAction
;
import
org.projectfloodlight.openflow.protocol.action.OFActionCircuit
;
import
org.projectfloodlight.openflow.protocol.instruction.OFInstruction
;
...
...
@@ -43,12 +47,13 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
private
final
AtomicBoolean
driverHandshakeComplete
;
private
long
barrierXidToWaitFor
=
-
1
;
private
OFPortDescStatsReply
wPorts
;
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
OFOpticalSwitchImplLINC13
.
class
);
OFOpticalSwitchImplLINC13
(
Dpid
dpid
,
OFDescStatsReply
desc
)
{
super
(
dpid
);
//setAttribute("optical", "true");
driverHandshakeComplete
=
new
AtomicBoolean
(
false
);
setSwitchDescription
(
desc
);
}
...
...
@@ -62,7 +67,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
@Override
public
void
startDriverHandshake
()
{
log
.
debug
(
"Starting driver handshake for sw {}"
,
getStringId
());
log
.
warn
(
"Starting driver handshake for sw {}"
,
getStringId
());
if
(
startDriverHandshakeCalled
)
{
throw
new
SwitchDriverSubHandshakeAlreadyStarted
();
}
...
...
@@ -70,6 +75,8 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
try
{
sendHandshakeOFExperimenterPortDescRequest
();
}
catch
(
IOException
e
)
{
log
.
error
(
"LINC-OE exception while sending experimenter port desc:"
,
e
.
getMessage
());
e
.
printStackTrace
();
}
}
...
...
@@ -84,7 +91,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
@Override
public
void
processDriverHandshakeMessage
(
OFMessage
m
)
{
if
(!
startDriverHandshakeCalled
)
{
if
(!
startDriverHandshakeCalled
)
{
throw
new
SwitchDriverSubHandshakeNotStarted
();
}
if
(
driverHandshakeComplete
.
get
())
{
...
...
@@ -109,38 +116,49 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
case
PACKET_IN:
break
;
case
PORT_STATUS:
log
.
warn
(
"****LINC-OE Port Status {} {}"
,
getStringId
(),
m
);
processOFPortStatus
((
OFCircuitPortStatus
)
m
);
break
;
case
QUEUE_GET_CONFIG_REPLY:
break
;
case
ROLE_REPLY:
break
;
case
STATS_REPLY:
log
.
debug
(
"LINC-OE : Received stats reply message {}"
,
m
);
processHandshakeOFExperimenterPortDescRequest
(
(
OFCircuitPortsReply
)
m
);
driverHandshakeComplete
.
set
(
true
);
try
{
OFStatsReply
stats
=
(
OFStatsReply
)
m
;
if
(
stats
.
getStatsType
()
==
OFStatsType
.
EXPERIMENTER
)
{
log
.
warn
(
"LINC-OE : Received stats reply message {}"
,
m
);
processHandshakeOFExperimenterPortDescRequest
(
(
OFCircuitPortsReply
)
m
);
driverHandshakeComplete
.
set
(
true
);
}
/*try {
testMA();
testReverseMA();
} catch (IOException e) {
e.printStackTrace();
}
}
*/
break
;
default
:
log
.
debug
(
"Received message {} during switch-driver "
+
"subhandshake "
+
"from switch {} ... "
+
"Ignoring message"
,
m
,
getStringId
());
log
.
warn
(
"Received message {} during switch-driver "
+
"subhandshake "
+
"from switch {} ... "
+
"Ignoring message"
,
m
,
getStringId
());
}
}
//Todo
public
void
processOFPortStatus
(
OFCircuitPortStatus
ps
)
{
log
.
debug
(
"LINC-OE ..OF Port Status :"
,
ps
);
}
private
void
processHandshakeOFExperimenterPortDescRequest
(
OFCircuitPortsReply
sr
)
{
Collection
<
OFPortOptical
>
entries
=
sr
.
getEntries
();
List
<
OFPortDesc
>
ofPortDescList
=
new
ArrayList
<>(
entries
.
size
());
for
(
OFPortOptical
entry
:
entries
)
{
log
.
warn
(
"LINC:OE port message {}"
,
entry
.
toString
());
ofPortDescList
.
add
(
factory
().
buildPortDesc
().
setPortNo
(
entry
.
getPortNo
())
.
setConfig
(
entry
.
getConfig
())
...
...
@@ -148,11 +166,16 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
.
setHwAddr
(
entry
.
getHwAddr
())
.
setName
(
entry
.
getName
())
.
build
());
}
setPortDescReply
(
factory
().
buildPortDescStatsReply
().
set
Experimenter
PortDescReply
(
factory
().
buildPortDescStatsReply
().
setEntries
(
ofPortDescList
).
build
());
}
private
void
setExperimenterPortDescReply
(
OFPortDescStatsReply
reply
)
{
wPorts
=
reply
;
}
private
void
sendHandshakeOFExperimenterPortDescRequest
()
throws
IOException
{
...
...
@@ -160,11 +183,22 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
OFCircuitPortsRequest
circuitPortsRequest
=
factory
()
.
buildCircuitPortsRequest
().
setXid
(
getNextTransactionId
())
.
build
();
log
.
debug
(
"LINC-OE : Sending experimented circuit port stats "
+
"message "
+
"{}"
,
circuitPortsRequest
.
toString
());
sendMsg
(
Collections
.<
OFMessage
>
singletonList
(
circuitPortsRequest
));
log
.
warn
(
"LINC-OE : Sending experimented circuit port stats "
+
"message "
+
"{}"
,
circuitPortsRequest
.
toString
());
this
.
write
(
Collections
.<
OFMessage
>
singletonList
(
circuitPortsRequest
));
}
@Override
public
List
<
OFPortDesc
>
getPorts
()
{
List
<
OFPortDesc
>
portEntries
=
new
ArrayList
<>();
portEntries
.
addAll
(
ports
.
getEntries
());
if
(
wPorts
!=
null
)
{
portEntries
.
addAll
(
wPorts
.
getEntries
());
}
return
Collections
.
unmodifiableList
(
portEntries
);
}
...
...
@@ -533,7 +567,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
@Override
public
void
write
(
OFMessage
msg
)
{
this
.
sendMsg
(
msg
);
this
.
channel
.
write
(
Collections
.
singletonList
(
msg
)
);
}
@Override
...
...
@@ -546,4 +580,10 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
return
false
;
}
@Override
public
boolean
isOptical
()
{
return
true
;
}
}
...
...
openflow/ctl/src/test/java/org/onlab/onos/openflow/controller/impl/RoleManagerTest.java
View file @
a22eadf
...
...
@@ -165,6 +165,11 @@ public class RoleManagerTest {
}
@Override
public
boolean
isOptical
()
{
return
false
;
}
@Override
public
void
setAgent
(
OpenFlowAgent
agent
)
{
}
...
...
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
a22eadf
...
...
@@ -118,8 +118,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
DeviceId
did
=
deviceId
(
uri
(
dpid
));
OpenFlowSwitch
sw
=
controller
.
getSwitch
(
dpid
);
Device
.
Type
deviceType
=
sw
.
isOptical
()
?
Device
.
Type
.
ROADM
:
Device
.
Type
.
SWITCH
;
DeviceDescription
description
=
new
DefaultDeviceDescription
(
did
.
uri
(),
Device
.
Type
.
SWITCH
,
new
DefaultDeviceDescription
(
did
.
uri
(),
deviceType
,
sw
.
manfacturerDescription
(),
sw
.
hardwareDescription
(),
sw
.
softwareDescription
(),
...
...
providers/openflow/device/src/test/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProviderTest.java
View file @
a22eadf
...
...
@@ -360,6 +360,11 @@ public class OpenFlowDeviceProviderTest {
public
void
returnRoleAssertFailure
(
RoleState
role
)
{
}
@Override
public
boolean
isOptical
()
{
return
false
;
}
}
}
...
...
providers/openflow/link/src/test/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProviderTest.java
View file @
a22eadf
...
...
@@ -467,5 +467,10 @@ public class OpenFlowLinkProviderTest {
public
void
returnRoleAssertFailure
(
RoleState
role
)
{
}
@Override
public
boolean
isOptical
()
{
return
false
;
}
}
}
...
...
providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
View file @
a22eadf
...
...
@@ -398,6 +398,11 @@ public class OpenFlowPacketProviderTest {
public
void
returnRoleAssertFailure
(
RoleState
role
)
{
}
@Override
public
boolean
isOptical
()
{
return
false
;
}
}
}
...
...
Please
register
or
login
to post a comment