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-04 17:15:08 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4680bb6c5a9e4ba7a8812f9ea4e8ddbec4628d9e
4680bb6c
1 parent
cb4c7ef6
updateports functional
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
29 deletions
net/api/src/main/java/org/onlab/onos/net/PortNumber.java
net/api/src/test/java/org/onlab/onos/net/PortNumberTest.java
of/ctl/src/main/java/org/onlab/onos/of/drivers/impl/OFSwitchImplOVS10.java
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
net/api/src/main/java/org/onlab/onos/net/PortNumber.java
View file @
4680bb6
package
org
.
onlab
.
onos
.
net
;
import
com.google.common.primitives.UnsignedLongs
;
import
java.util.Objects
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
import
com.google.common.primitives.UnsignedLongs
;
/**
* Representation of a port number.
...
...
@@ -17,9 +15,6 @@ public final class PortNumber {
// Public creation is prohibited
private
PortNumber
(
long
number
)
{
checkArgument
(
number
>=
0
&&
number
<
MAX_NUMBER
,
"Port number %d is outside the supported range [0, %d)"
,
number
,
MAX_NUMBER
);
this
.
number
=
number
;
}
...
...
net/api/src/test/java/org/onlab/onos/net/PortNumberTest.java
View file @
4680bb6
package
org
.
onlab
.
onos
.
net
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
import
org.junit.Test
;
import
com.google.common.testing.EqualsTester
;
/**
* Test of the port number.
*/
public
class
PortNumberTest
extends
ElementIdTest
{
@Override
@Test
public
void
basics
()
{
new
EqualsTester
()
...
...
@@ -25,13 +27,5 @@ public class PortNumberTest extends ElementIdTest {
assertEquals
(
"incorrect long value"
,
12345
,
portNumber
(
12345
).
toLong
());
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
negative
()
{
portNumber
(-
1
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
tooBig
()
{
portNumber
((
2L
*
Integer
.
MAX_VALUE
)
+
2
);
}
}
...
...
of/ctl/src/main/java/org/onlab/onos/of/drivers/impl/OFSwitchImplOVS10.java
View file @
4680bb6
package
org
.
onlab
.
onos
.
of
.
drivers
.
impl
;
import
java.util.Collections
;
import
java.util.List
;
import
org.onlab.onos.of.controller.Dpid
;
import
org.onlab.onos.of.controller.driver.AbstractOpenFlowSwitch
;
import
org.projectfloodlight.openflow.protocol.OFDescStatsReply
;
import
org.projectfloodlight.openflow.protocol.OFMessage
;
import
org.projectfloodlight.openflow.protocol.OFPortDesc
;
/**
* OFDescriptionStatistics Vendor (Manufacturer Desc.): Nicira, Inc. Make
...
...
@@ -56,4 +58,11 @@ public class OFSwitchImplOVS10 extends AbstractOpenFlowSwitch {
public
void
write
(
List
<
OFMessage
>
msgs
)
{
channel
.
write
(
msgs
);
}
@Override
public
List
<
OFPortDesc
>
getPorts
()
{
return
Collections
.
unmodifiableList
(
features
.
getPorts
());
}
}
...
...
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
4680bb6
...
...
@@ -30,7 +30,9 @@ import org.onlab.onos.of.controller.OpenFlowController;
import
org.onlab.onos.of.controller.OpenFlowSwitch
;
import
org.onlab.onos.of.controller.OpenFlowSwitchListener
;
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.slf4j.Logger
;
/**
...
...
@@ -50,7 +52,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
private
DeviceProviderService
providerService
;
private
OpenFlowSwitchListener
listener
=
new
InternalDeviceProvider
();
private
final
OpenFlowSwitchListener
listener
=
new
InternalDeviceProvider
();
/**
* Creates an OpenFlow device provider.
...
...
@@ -119,17 +121,6 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
providerService
.
updatePorts
(
deviceId
(
uri
),
buildPortDescriptions
(
sw
.
getPorts
()));
}
private
List
<
PortDescription
>
buildPortDescriptions
(
List
<
OFPortDesc
>
ports
)
{
List
<
PortDescription
>
portDescs
=
new
ArrayList
<
PortDescription
>();
for
(
OFPortDesc
port
:
ports
)
{
PortNumber
portNo
=
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
());
portDescs
.
add
(
new
DefaultPortDescription
(
portNo
,
port
.
getState
()));
}
}
@Override
public
void
switchRemoved
(
Dpid
dpid
)
{
if
(
providerService
==
null
)
{
...
...
@@ -149,6 +140,21 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
return
uri
;
}
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
));
}
return
portDescs
;
}
}
}
...
...
Please
register
or
login
to post a comment