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-05 09:31:31 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a14f364e0b53cfb81e466f7ec6400fab30e5e9ca
a14f364e
1 parent
3034a38f
portStatusChanged implemented
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
7 deletions
of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchListener.java
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchListener.java
View file @
a14f364
package
org
.
onlab
.
onos
.
of
.
controller
;
import
org.projectfloodlight.openflow.protocol.OFPortStatus
;
/**
* Allows for providers interested in Switch events to be notified.
*/
...
...
@@ -17,4 +19,10 @@ public interface OpenFlowSwitchListener {
*/
public
void
switchRemoved
(
Dpid
dpid
);
/**
* Notify that a port has changed.
* @param dpid the switch on which the change happened.
* @param status the new state of the port.
*/
public
void
portChanged
(
Dpid
dpid
,
OFPortStatus
status
);
}
...
...
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
a14f364
...
...
@@ -33,6 +33,7 @@ import org.onlab.onos.of.controller.RoleState;
import
org.projectfloodlight.openflow.protocol.OFPortConfig
;
import
org.projectfloodlight.openflow.protocol.OFPortDesc
;
import
org.projectfloodlight.openflow.protocol.OFPortState
;
import
org.projectfloodlight.openflow.protocol.OFPortStatus
;
import
org.slf4j.Logger
;
/**
...
...
@@ -130,6 +131,18 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
providerService
.
deviceDisconnected
(
deviceId
(
uri
));
}
@Override
public
void
portChanged
(
Dpid
dpid
,
OFPortStatus
status
)
{
final
PortDescription
portDescription
=
buildPortDescription
(
status
.
getDesc
());
final
URI
uri
=
buildURI
(
dpid
);
providerService
.
portStatusChanged
(
deviceId
(
uri
),
portDescription
);
}
/**
* Given a dpid builds a URI for the device.
* @param dpid the dpid to build the uri from
* @return returns a uri of the form of:<dpidHexForm>
*/
private
URI
buildURI
(
Dpid
dpid
)
{
URI
uri
=
null
;
try
{
...
...
@@ -140,21 +153,31 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
return
uri
;
}
/**
* Builds a list of port descriptions for a given list of ports.
* @param ports the list of ports
* @return list of portdescriptions
*/
private
List
<
PortDescription
>
buildPortDescriptions
(
List
<
OFPortDesc
>
ports
)
{
final
List
<
PortDescription
>
portDescs
=
new
ArrayList
<
PortDescription
>();
PortNumber
portNo
;
boolean
enabled
;
for
(
OFPortDesc
port
:
ports
)
{
portNo
=
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
());
enabled
=
!
port
.
getState
().
contains
(
OFPortState
.
LINK_DOWN
)
&&
!
port
.
getConfig
().
contains
(
OFPortConfig
.
PORT_DOWN
);
portDescs
.
add
(
new
DefaultPortDescription
(
portNo
,
enabled
));
portDescs
.
add
(
buildPortDescription
(
port
));
}
return
portDescs
;
}
/**
* Build a portDescription from a given port.
* @param port the port to build from.
* @return portDescription for the port.
*/
private
PortDescription
buildPortDescription
(
OFPortDesc
port
)
{
final
PortNumber
portNo
=
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
());
final
boolean
enabled
=
!
port
.
getState
().
contains
(
OFPortState
.
LINK_DOWN
)
&&
!
port
.
getConfig
().
contains
(
OFPortConfig
.
PORT_DOWN
);
return
new
DefaultPortDescription
(
portNo
,
enabled
);
}
}
}
...
...
Please
register
or
login
to post a comment