Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
f1d6413c
Commit
f1d6413c
authored
12 years ago
by
Andreas Wundsam
Browse files
Options
Downloads
Patches
Plain Diff
openflowj/Wildcards: more descriptive names
parent
8455fd5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/openflow/protocol/Wildcards.java
+11
-7
11 additions, 7 deletions
src/main/java/org/openflow/protocol/Wildcards.java
src/test/java/org/openflow/protocol/WildcardsTest.java
+25
-25
25 additions, 25 deletions
src/test/java/org/openflow/protocol/WildcardsTest.java
with
36 additions
and
32 deletions
src/main/java/org/openflow/protocol/Wildcards.java
+
11
−
7
View file @
f1d6413c
...
...
@@ -39,15 +39,19 @@ import com.google.common.base.Joiner;
*/
public
class
Wildcards
{
public
final
static
Wildcards
A
LL
=
new
Wildcards
(
OFMatch
.
OFPFW_ALL_SANITIZED
);
public
final
static
Wildcards
NONE
=
new
Wildcards
(
0
);
public
final
static
Wildcards
FU
LL
=
new
Wildcards
(
OFMatch
.
OFPFW_ALL_SANITIZED
);
public
final
static
Wildcards
EXACT
=
new
Wildcards
(
0
);
// floodlight common case: matches on inport + l2
public
final
static
int
INT_INPORT_L2_MATCH
=
0x3820e0
;
public
final
static
Wildcards
INPORT_L2_MATCH
=
new
Wildcards
(
INT_INPORT_L2_MATCH
);
/**
* enum type for the binary flags that can be set in the wildcards field of
* an OFMatch. Replaces the unwieldy c-ish int constants in OFMatch.
*/
public
static
enum
Flag
{
IN_PORT
(
OFMatch
.
OFPFW_IN_PORT
),
/* Switch input port. */
DL_VLAN
(
OFMatch
.
OFPFW_DL_VLAN
),
/* VLAN id. */
...
...
@@ -85,10 +89,10 @@ public class Wildcards {
public
static
Wildcards
of
(
int
flags
)
{
switch
(
flags
)
{
case
0x0000
:
return
NONE
;
return
EXACT
;
case
OFMatch
.
OFPFW_ALL
:
case
OFMatch
.
OFPFW_ALL_SANITIZED
:
return
A
LL
;
return
FU
LL
;
case
INT_INPORT_L2_MATCH:
return
INPORT_L2_MATCH
;
default
:
...
...
@@ -371,12 +375,12 @@ public class Wildcards {
* is this a wildcard set that has all flags set + and full (/0) nw_src and
* nw_dst wildcarding ?
*/
public
boolean
is
A
ll
()
{
public
boolean
is
Fu
ll
()
{
return
flags
==
OFMatch
.
OFPFW_ALL
||
flags
==
OFMatch
.
OFPFW_ALL_SANITIZED
;
}
/** is this a wildcard of an exact match */
public
boolean
is
None
()
{
public
boolean
is
Exact
()
{
return
flags
==
0
;
}
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/openflow/protocol/WildcardsTest.java
+
25
−
25
View file @
f1d6413c
...
...
@@ -25,63 +25,63 @@ public class WildcardsTest {
public
void
testAllSanitize
()
{
Wildcards
w
=
Wildcards
.
of
(
OFMatch
.
OFPFW_ALL
);
assertEquals
(
OFMatch
.
OFPFW_ALL_SANITIZED
,
w
.
getInt
());
assertTrue
(
w
.
is
A
ll
());
assertFalse
(
w
.
is
None
());
assertTrue
(
w
.
is
Fu
ll
());
assertFalse
(
w
.
is
Exact
());
}
@Test
public
void
testAll
()
{
Wildcards
all
=
Wildcards
.
A
LL
;
assertTrue
(
all
.
is
A
ll
());
assertFalse
(
all
.
is
None
());
Wildcards
all
=
Wildcards
.
FU
LL
;
assertTrue
(
all
.
is
Fu
ll
());
assertFalse
(
all
.
is
Exact
());
assertEquals
(
0
,
all
.
getNwDstMask
());
assertEquals
(
0
,
all
.
getNwSrcMask
());
// unsetting flags from NONE is a no-op
Wildcards
stillAll
=
all
.
set
(
Flag
.
IN_PORT
);
assertTrue
(
stillAll
.
is
A
ll
());
assertTrue
(
stillAll
.
is
Fu
ll
());
assertEquals
(
all
,
stillAll
);
// so is setting a >= 32 netmask
stillAll
=
all
.
setNwSrcMask
(
0
);
assertTrue
(
stillAll
.
is
A
ll
());
assertTrue
(
stillAll
.
is
Fu
ll
());
assertEquals
(
all
,
stillAll
);
stillAll
=
all
.
setNwDstMask
(
0
);
assertTrue
(
stillAll
.
is
A
ll
());
assertTrue
(
stillAll
.
is
Fu
ll
());
assertEquals
(
all
,
stillAll
);
}
@Test
public
void
testNone
()
{
Wildcards
none
=
Wildcards
.
NONE
;
assertTrue
(
none
.
is
None
());
Wildcards
none
=
Wildcards
.
EXACT
;
assertTrue
(
none
.
is
Exact
());
assertEquals
(
32
,
none
.
getNwDstMask
());
assertEquals
(
32
,
none
.
getNwSrcMask
());
// unsetting flags from NONE is a no-op
Wildcards
stillNone
=
none
.
unset
(
Flag
.
IN_PORT
);
assertTrue
(
stillNone
.
is
None
());
assertTrue
(
stillNone
.
is
Exact
());
assertEquals
(
none
,
stillNone
);
// so is setting a >= 32 netmask
stillNone
=
none
.
setNwSrcMask
(
32
);
assertTrue
(
stillNone
.
is
None
());
assertTrue
(
stillNone
.
is
Exact
());
assertEquals
(
none
,
stillNone
);
stillNone
=
none
.
setNwDstMask
(
32
);
assertTrue
(
stillNone
.
is
None
());
assertTrue
(
stillNone
.
is
Exact
());
assertEquals
(
none
,
stillNone
);
}
@Test
public
void
testSetOneFlag
()
{
Wildcards
none
=
Wildcards
.
NONE
;
assertTrue
(
none
.
is
None
());
Wildcards
none
=
Wildcards
.
EXACT
;
assertTrue
(
none
.
is
Exact
());
assertFalse
(
none
.
hasFlag
(
Flag
.
DL_SRC
));
Wildcards
one
=
none
.
set
(
Flag
.
DL_SRC
);
assertFalse
(
one
.
is
None
());
assertFalse
(
one
.
is
Exact
());
assertTrue
(
one
.
hasFlag
(
Flag
.
DL_SRC
));
assertEquals
(
OFMatch
.
OFPFW_DL_SRC
,
one
.
getInt
());
assertEquals
(
EnumSet
.
of
(
Flag
.
DL_SRC
),
one
.
getFlags
());
...
...
@@ -89,11 +89,11 @@ public class WildcardsTest {
@Test
public
void
testSetTwoFlags
()
{
Wildcards
none
=
Wildcards
.
NONE
;
Wildcards
none
=
Wildcards
.
EXACT
;
// set two flags
Wildcards
two
=
none
.
set
(
Flag
.
DL_SRC
,
Flag
.
DL_DST
);
assertFalse
(
two
.
is
None
());
assertFalse
(
two
.
is
Exact
());
assertTrue
(
two
.
hasFlag
(
Flag
.
DL_SRC
));
assertTrue
(
two
.
hasFlag
(
Flag
.
DL_DST
));
assertEquals
(
OFMatch
.
OFPFW_DL_SRC
|
OFMatch
.
OFPFW_DL_DST
,
two
.
getInt
());
...
...
@@ -101,7 +101,7 @@ public class WildcardsTest {
// unset dl_dst
Wildcards
gone
=
two
.
unset
(
Flag
.
DL_DST
);
assertFalse
(
gone
.
is
None
());
assertFalse
(
gone
.
is
Exact
());
assertTrue
(
gone
.
hasFlag
(
Flag
.
DL_SRC
));
assertFalse
(
gone
.
hasFlag
(
Flag
.
DL_DST
));
assertEquals
(
OFMatch
.
OFPFW_DL_SRC
,
gone
.
getInt
());
...
...
@@ -110,12 +110,12 @@ public class WildcardsTest {
@Test
public
void
testSetNwSrc
()
{
Wildcards
none
=
Wildcards
.
NONE
;
Wildcards
none
=
Wildcards
.
EXACT
;
assertEquals
(
32
,
none
.
getNwSrcMask
());
// unsetting flags from NONE is a no-op
Wildcards
nwSet
=
none
.
setNwSrcMask
(
8
);
assertFalse
(
nwSet
.
is
None
());
assertFalse
(
nwSet
.
is
Exact
());
assertEquals
(
EnumSet
.
noneOf
(
Flag
.
class
),
nwSet
.
getFlags
());
assertEquals
(
8
,
nwSet
.
getNwSrcMask
());
assertEquals
((
32
-
8
)
<<
OFMatch
.
OFPFW_NW_SRC_SHIFT
,
nwSet
.
getInt
());
...
...
@@ -123,12 +123,12 @@ public class WildcardsTest {
@Test
public
void
testSetNwDst
()
{
Wildcards
none
=
Wildcards
.
NONE
;
Wildcards
none
=
Wildcards
.
EXACT
;
assertEquals
(
32
,
none
.
getNwDstMask
());
// unsetting flags from NONE is a no-op
Wildcards
nwSet
=
none
.
setNwDstMask
(
8
);
assertFalse
(
nwSet
.
is
None
());
assertFalse
(
nwSet
.
is
Exact
());
assertEquals
(
EnumSet
.
noneOf
(
Flag
.
class
),
nwSet
.
getFlags
());
assertEquals
(
8
,
nwSet
.
getNwDstMask
());
assertEquals
((
32
-
8
)
<<
OFMatch
.
OFPFW_NW_DST_SHIFT
,
nwSet
.
getInt
());
...
...
@@ -136,14 +136,14 @@ public class WildcardsTest {
@Test
public
void
testToString
()
{
String
s
=
Wildcards
.
A
LL
.
toString
();
String
s
=
Wildcards
.
FU
LL
.
toString
();
assertNotNull
(
s
);
assertTrue
(
s
.
length
()
>
0
);
}
@Test
public
void
testInvert
()
{
assertEquals
(
Wildcards
.
A
LL
,
Wildcards
.
NONE
.
inverted
());
assertEquals
(
Wildcards
.
FU
LL
,
Wildcards
.
EXACT
.
inverted
());
Wildcards
some
=
Wildcards
.
of
(
Flag
.
DL_VLAN
,
Flag
.
DL_VLAN_PCP
);
Wildcards
inv
=
some
.
inverted
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment