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
tom
2014-09-16 14:17:45 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8539ee2853d4b5eb7ed302c75304f5aa507042bc
8539ee28
2 parents
cbefa239
498052f5
Merge remote-tracking branch 'origin/master'
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
193 additions
and
12 deletions
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/Criteria.java → core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
core/api/src/main/java/org/onlab/onos/net/flow/Criterion.java → core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criterion.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instruction.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L3ModificationInstruction.java
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
View file @
8539ee2
...
...
@@ -2,6 +2,8 @@ package org.onlab.onos.net.flow;
import
java.util.List
;
import
org.onlab.onos.net.flow.criteria.Criterion
;
/**
* Abstraction of a slice of network traffic.
*/
...
...
core/api/src/main/java/org/onlab/onos/net/flow/Criteria.java
→
core/api/src/main/java/org/onlab/onos/net/flow/
criteria/
Criteria.java
View file @
8539ee2
package
org
.
onlab
.
onos
.
net
.
flow
;
package
org
.
onlab
.
onos
.
net
.
flow
.
criteria
;
/**
* Factory class to create various traffic selection criteria.
...
...
core/api/src/main/java/org/onlab/onos/net/flow/Criterion.java
→
core/api/src/main/java/org/onlab/onos/net/flow/
criteria/
Criterion.java
View file @
8539ee2
package
org
.
onlab
.
onos
.
net
.
flow
;
package
org
.
onlab
.
onos
.
net
.
flow
.
criteria
;
/**
* Representation of a single header field selection.
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instruction.java
View file @
8539ee2
...
...
@@ -5,6 +5,12 @@ package org.onlab.onos.net.flow.instructions;
*/
public
interface
Instruction
{
interface
SubType
{
}
public
enum
NoneSubType
implements
SubType
{
NONE
;
}
/**
* Represents the type of traffic treatment.
*/
...
...
@@ -39,4 +45,10 @@ public interface Instruction {
*/
public
Type
type
();
/**
* Returns the subtype of the modification instruction.
* @return type of instruction
*/
public
SubType
subtype
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java
View file @
8539ee2
...
...
@@ -3,8 +3,12 @@ package org.onlab.onos.net.flow.instructions;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType
;
import
org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction
;
import
org.onlab.onos.net.flow.instructions.L2ModificationInstruction.SubType
;
import
org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType
;
import
org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction
;
import
org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPProtoInstruction
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
/**
* Factory class for creating various traffic treatment instructions.
...
...
@@ -42,7 +46,7 @@ public final class Instructions {
*/
public
static
L2ModificationInstruction
modL2Src
(
MACAddress
addr
)
{
checkNotNull
(
addr
,
"Src l2 address cannot be null"
);
return
new
ModEtherInstruction
(
SubType
.
L2_SRC
,
addr
);
return
new
ModEtherInstruction
(
L2
SubType
.
L2_SRC
,
addr
);
}
/**
...
...
@@ -52,7 +56,7 @@ public final class Instructions {
*/
public
static
L2ModificationInstruction
modL2Dst
(
MACAddress
addr
)
{
checkNotNull
(
addr
,
"Dst l2 address cannot be null"
);
return
new
L2ModificationInstruction
.
ModEtherInstruction
(
SubType
.
L2_DST
,
addr
);
return
new
L2ModificationInstruction
.
ModEtherInstruction
(
L2
SubType
.
L2_DST
,
addr
);
}
/**
...
...
@@ -65,11 +69,56 @@ public final class Instructions {
return
new
L2ModificationInstruction
.
ModEtherTypeInstruction
(
l2Type
);
}
/**
* Creates a Vlan id modification.
* @param vlanId the vlan id to modify to.
* @return a L2 modification
*/
public
static
L2ModificationInstruction
modVlanId
(
Short
vlanId
)
{
checkNotNull
(
vlanId
,
"VLAN id cannot be null"
);
return
new
L2ModificationInstruction
.
ModVlanIdInstruction
(
vlanId
);
}
/**
* Creates a Vlan pcp modification.
* @param vlanPcp the pcp to modify to.
* @return a L2 modification
*/
public
static
L2ModificationInstruction
modVlanPcp
(
Byte
vlanPcp
)
{
checkNotNull
(
vlanPcp
,
"VLAN Pcp cannot be null"
);
return
new
L2ModificationInstruction
.
ModVlanPcpInstruction
(
vlanPcp
);
}
/**
* Creates a L3 src modification.
* @param addr the ip address to modify to.
* @return a L3 modification
*/
public
static
L3ModificationInstruction
modL3Src
(
IPAddress
addr
)
{
checkNotNull
(
addr
,
"Src l3 address cannot be null"
);
return
new
ModIPInstruction
(
L3SubType
.
L3_SRC
,
addr
);
}
/**
* Creates a L3 dst modification.
* @param addr the ip address to modify to.
* @return a L3 modification
*/
public
static
L3ModificationInstruction
modL3Dst
(
IPAddress
addr
)
{
checkNotNull
(
addr
,
"Dst l3 address cannot be null"
);
return
new
ModIPInstruction
(
L3SubType
.
L3_DST
,
addr
);
}
/**
* Creates an L3 protocol modification.
* @param proto the protocol to change to
* @return a L3 modification
*/
public
static
L3ModificationInstruction
modIPProto
(
Byte
proto
)
{
checkNotNull
(
proto
,
"IP protocol cannot be null"
);
return
new
ModIPProtoInstruction
(
proto
);
}
/*
* Output instructions
*/
...
...
@@ -79,6 +128,11 @@ public final class Instructions {
public
Type
type
()
{
return
Type
.
DROP
;
}
@Override
public
SubType
subtype
()
{
return
NoneSubType
.
NONE
;
}
}
...
...
@@ -97,6 +151,11 @@ public final class Instructions {
public
Type
type
()
{
return
Type
.
OUTPUT
;
}
@Override
public
SubType
subtype
()
{
return
NoneSubType
.
NONE
;
}
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java
View file @
8539ee2
...
...
@@ -11,7 +11,7 @@ public abstract class L2ModificationInstruction implements Instruction {
/**
* Represents the type of traffic treatment.
*/
public
enum
SubType
{
public
enum
L2SubType
implements
SubType
{
/**
* Ether src modification.
*/
...
...
@@ -41,10 +41,7 @@ public abstract class L2ModificationInstruction implements Instruction {
// TODO: Create factory class 'Instructions' that will have various factory
// to create specific instructions.
/**
* Returns the subtype of the modification instruction.
* @return type of instruction
*/
@Override
public
abstract
SubType
subtype
();
@Override
...
...
@@ -89,7 +86,7 @@ public abstract class L2ModificationInstruction implements Instruction {
@Override
public
SubType
subtype
()
{
return
SubType
.
L2_TYPE
;
return
L2
SubType
.
L2_TYPE
;
}
public
short
l2Type
()
{
...
...
@@ -111,7 +108,7 @@ public abstract class L2ModificationInstruction implements Instruction {
@Override
public
SubType
subtype
()
{
return
SubType
.
VLAN_ID
;
return
L2
SubType
.
VLAN_ID
;
}
public
Short
vlanId
()
{
...
...
@@ -120,5 +117,27 @@ public abstract class L2ModificationInstruction implements Instruction {
}
/**
* Represents a VLAN PCP modification instruction.
*/
public
static
final
class
ModVlanPcpInstruction
extends
L2ModificationInstruction
{
public
final
Byte
vlanPcp
;
public
ModVlanPcpInstruction
(
Byte
vlanPcp
)
{
this
.
vlanPcp
=
vlanPcp
;
}
@Override
public
SubType
subtype
()
{
return
L2SubType
.
VLAN_PCP
;
}
public
Byte
vlanPcp
()
{
return
this
.
vlanPcp
;
}
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L3ModificationInstruction.java
0 → 100644
View file @
8539ee2
package
org
.
onlab
.
onos
.
net
.
flow
.
instructions
;
import
org.onlab.packet.IPAddress
;
/**
* Abstraction of a single traffic treatment step.
* @param <T> the type parameter for the instruction
*/
public
abstract
class
L3ModificationInstruction
implements
Instruction
{
/**
* Represents the type of traffic treatment.
*/
public
enum
L3SubType
implements
SubType
{
/**
* Ether src modification.
*/
L3_SRC
,
/**
* Ether dst modification.
*/
L3_DST
,
/**
* Ethertype modification.
*/
L3_PROTO
,
//TODO: remaining types
}
/**
* Returns the subtype of the modification instruction.
* @return type of instruction
*/
public
abstract
SubType
subtype
();
@Override
public
Type
type
()
{
return
Type
.
MODIFICATION
;
}
/**
* Represents a L3 src/dst modification instruction.
*/
public
static
final
class
ModIPInstruction
extends
L3ModificationInstruction
{
private
final
SubType
subtype
;
private
final
IPAddress
ip
;
public
ModIPInstruction
(
SubType
subType
,
IPAddress
addr
)
{
this
.
subtype
=
subType
;
this
.
ip
=
addr
;
}
@Override
public
SubType
subtype
()
{
return
this
.
subtype
;
}
public
IPAddress
ip
()
{
return
this
.
ip
;
}
}
/**
* Represents a L3 proto modification instruction.
*/
public
static
final
class
ModIPProtoInstruction
extends
L3ModificationInstruction
{
public
final
Byte
proto
;
public
ModIPProtoInstruction
(
Byte
proto
)
{
this
.
proto
=
proto
;
}
@Override
public
SubType
subtype
()
{
return
L3SubType
.
L3_PROTO
;
}
public
short
proto
()
{
return
this
.
proto
;
}
}
}
Please
register
or
login
to post a comment