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
Toshio Koide
2014-10-09 11:44:36 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9c44c9a91672875a84b12a013839cf8852bce871
9c44c9a9
1 parent
d32809be
Add TCP src/dst port traffic selection criteria to TrafficSelector
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
View file @
9c44c9a
...
...
@@ -140,6 +140,16 @@ public final class DefaultTrafficSelector implements TrafficSelector {
}
@Override
public
Builder
matchTcpSrc
(
Short
tcpPort
)
{
return
add
(
Criteria
.
matchTcpSrc
(
tcpPort
));
}
@Override
public
Builder
matchTcpDst
(
Short
tcpPort
)
{
return
add
(
Criteria
.
matchTcpDst
(
tcpPort
));
}
@Override
public
TrafficSelector
build
()
{
return
new
DefaultTrafficSelector
(
ImmutableSet
.
copyOf
(
selector
.
values
()));
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
View file @
9c44c9a
...
...
@@ -98,6 +98,20 @@ public interface TrafficSelector {
public
Builder
matchIPDst
(
IpPrefix
ip
);
/**
* Matches a TCP source port number.
* @param tcpPort a TCP source port number
* @return a selection builder
*/
public
Builder
matchTcpSrc
(
Short
tcpPort
);
/**
* Matches a TCP destination port number.
* @param tcpPort a TCP destination port number
* @return a selection builder
*/
public
Builder
matchTcpDst
(
Short
tcpPort
);
/**
* Builds an immutable traffic selector.
*
* @return traffic selector
...
...
core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
View file @
9c44c9a
...
...
@@ -113,6 +113,25 @@ public final class Criteria {
return
new
IPCriterion
(
ip
,
Type
.
IPV4_DST
);
}
/**
* Creates a match on TCP source port field using the specified value.
*
* @param tcpPort
* @return match criterion
*/
public
static
Criterion
matchTcpSrc
(
Short
tcpPort
)
{
return
new
TcpPortCriterion
(
tcpPort
,
Type
.
TCP_SRC
);
}
/**
* Creates a match on TCP destination port field using the specified value.
*
* @param tcpPort
* @return match criterion
*/
public
static
Criterion
matchTcpDst
(
Short
tcpPort
)
{
return
new
TcpPortCriterion
(
tcpPort
,
Type
.
TCP_DST
);
}
/*
* Implementations of criteria.
...
...
@@ -437,4 +456,49 @@ public final class Criteria {
}
public
static
final
class
TcpPortCriterion
implements
Criterion
{
private
final
Short
tcpPort
;
private
final
Type
type
;
public
TcpPortCriterion
(
Short
tcpPort
,
Type
type
)
{
this
.
tcpPort
=
tcpPort
;
this
.
type
=
type
;
}
@Override
public
Type
type
()
{
return
this
.
type
;
}
public
Short
tcpPort
()
{
return
this
.
tcpPort
;
}
@Override
public
String
toString
()
{
return
toStringHelper
(
type
().
toString
())
.
add
(
"tcpPort"
,
tcpPort
).
toString
();
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
tcpPort
,
type
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
instanceof
TcpPortCriterion
)
{
TcpPortCriterion
that
=
(
TcpPortCriterion
)
obj
;
return
Objects
.
equals
(
tcpPort
,
that
.
tcpPort
)
&&
Objects
.
equals
(
type
,
that
.
type
);
}
return
false
;
}
}
}
...
...
Please
register
or
login
to post a comment