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-12 18:23:41 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
44474095d29adffb73ecdc883ad6ceff39b231fb
44474095
2 parents
e2918e62
01ca3546
Merge remote-tracking branch 'origin/master'
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
212 additions
and
28 deletions
core/api/src/main/java/org/onlab/onos/net/flow/Criteria.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderService.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/TrafficTreatment.java
core/api/src/main/java/org/onlab/onos/net/packet/DefaultPacketContext.java
core/api/src/main/java/org/onlab/onos/net/packet/PacketProcessor.java
core/api/src/main/java/org/onlab/onos/net/packet/PacketProvider.java
core/api/src/main/java/org/onlab/onos/net/packet/PacketProviderRegistry.java
core/api/src/main/java/org/onlab/onos/net/packet/PacketProviderService.java
core/api/src/main/java/org/onlab/onos/net/packet/PacketService.java
core/api/src/test/java/org/onlab/onos/net/DefaultHostTest.java
core/api/src/test/java/org/onlab/onos/net/HostIdTest.java
core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java → of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java
of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java → of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowPacketContext.java
of/api/src/main/java/org/onlab/onos/of/controller/PacketListener.java
of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
utils/misc/src/main/java/org/onlab/packet/IPAddress.java
utils/misc/src/main/java/org/onlab/packet/VLANID.java
core/api/src/main/java/org/onlab/onos/net/flow/Criteria.java
View file @
4447409
...
...
@@ -20,6 +20,18 @@ public final class Criteria {
return
null
;
}
/**
* Creates a match on ETH_DST field using the specified value. This value
* may be a wildcard mask.
*
* @param macValue MAC address value or wildcard mask
* @return match criterion
*/
public
static
Criterion
matchEthDst
(
MACValue
macValue
)
{
return
null
;
}
// Dummy to illustrate the concept for now; delete ASAP
private
static
class
MACValue
{
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
View file @
4447409
...
...
@@ -2,14 +2,14 @@ package org.onlab.onos.net.flow;
import
org.onlab.onos.net.DeviceId
;
import
java.util.List
;
/**
* Represents a generalized match & action pair to be applied to
* an infrastucture device.
*/
public
interface
FlowRule
{
//TODO: build cookie value
/**
* Returns the flow rule priority given in natural order; higher numbers
* mean higher priorities.
...
...
@@ -38,6 +38,6 @@ public interface FlowRule {
*
* @return traffic treatment
*/
List
<
Treatment
>
treatments
();
TrafficTreatment
treatment
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderService.java
View file @
4447409
...
...
@@ -22,4 +22,11 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide
*/
void
flowMissing
(
FlowRule
flowRule
);
/**
* Signals that a flow rule was indeed added.
*
* @param flowRule the added flow rule
*/
void
flowAdded
(
FlowRule
flowRule
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
View file @
4447409
...
...
@@ -26,6 +26,15 @@ public interface FlowRuleService {
void
applyFlowRules
(
FlowRule
...
flowRules
);
/**
* Removes the specified flow rules from their respective devices.
*
* @param flowRules one or more flow rules
* throws SomeKindOfException that indicates which ones were removed and
* which ones failed
*/
void
removeFlowRules
(
FlowRule
...
flowRules
);
/**
* Adds the specified flow rule listener.
*
* @param listener flow rule listener
...
...
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
View file @
4447409
...
...
@@ -24,8 +24,9 @@ public interface TrafficSelector {
* already been added, it will be replaced by this one.
*
* @param criterion new criterion
* @return self
*/
void
add
(
Criterion
criterion
);
Builder
add
(
Criterion
criterion
);
/**
* Builds an immutable traffic selector.
...
...
core/api/src/main/java/org/onlab/onos/net/flow/TrafficTreatment.java
View file @
4447409
...
...
@@ -25,7 +25,7 @@ public interface TrafficTreatment {
*
* @param instruction new instruction
*/
void
add
(
Instruction
instruction
);
Builder
add
(
Instruction
instruction
);
/**
* Builds an immutable traffic treatment descriptor.
...
...
core/api/src/main/java/org/onlab/onos/net/packet/DefaultPacketContext.java
0 → 100644
View file @
4447409
package
org
.
onlab
.
onos
.
net
.
packet
;
public
abstract
class
DefaultPacketContext
implements
PacketContext
{
private
final
long
time
;
private
final
InboundPacket
inPkt
;
private
final
OutboundPacket
outPkt
;
private
boolean
block
=
false
;
protected
DefaultPacketContext
(
long
time
,
InboundPacket
inPkt
,
OutboundPacket
outPkt
,
boolean
block
)
{
super
();
this
.
time
=
time
;
this
.
inPkt
=
inPkt
;
this
.
outPkt
=
outPkt
;
this
.
block
=
block
;
}
@Override
public
long
time
()
{
return
time
;
}
@Override
public
InboundPacket
inPacket
()
{
return
inPkt
;
}
@Override
public
OutboundPacket
outPacket
()
{
return
outPkt
;
}
@Override
public
abstract
void
send
();
@Override
public
void
block
()
{
this
.
block
=
true
;
}
@Override
public
boolean
isHandled
()
{
return
this
.
block
;
}
}
core/api/src/main/java/org/onlab/onos/net/packet/PacketProcessor.java
View file @
4447409
package
org
.
onlab
.
onos
.
net
.
packet
;
/**
* Abstraction of an inbound packet processor.
*/
public
interface
PacketProcessor
{
public
static
final
int
ADVISOR_MAX
=
Integer
.
MAX_VALUE
/
3
;
public
static
final
int
DIRECTOR_MAX
=
(
Integer
.
MAX_VALUE
/
3
)
*
2
;
public
static
final
int
OBSERVER_MAX
=
Integer
.
MAX_VALUE
;
/**
* Processes the inbound packet as specified in the given context.
*
...
...
core/api/src/main/java/org/onlab/onos/net/packet/PacketProvider.java
View file @
4447409
package
org
.
onlab
.
onos
.
net
.
packet
;
import
org.onlab.onos.net.provider.Provider
;
/**
* Abstraction of a packet provider capable of emitting packets.
*/
public
interface
PacketProvider
{
public
interface
PacketProvider
extends
Provider
{
/**
* Emits the specified outbound packet onto the network.
...
...
core/api/src/main/java/org/onlab/onos/net/packet/PacketProviderRegistry.java
0 → 100644
View file @
4447409
package
org
.
onlab
.
onos
.
net
.
packet
;
import
org.onlab.onos.net.provider.ProviderRegistry
;
/**
* Abstraction of an infrastructure packet provider registry.
*/
public
interface
PacketProviderRegistry
extends
ProviderRegistry
<
PacketProvider
,
PacketProviderService
>
{
}
core/api/src/main/java/org/onlab/onos/net/packet/PacketProviderService.java
View file @
4447409
package
org
.
onlab
.
onos
.
net
.
packet
;
import
org.onlab.onos.net.provider.ProviderService
;
/**
* Entity capable of processing inbound packets.
*/
public
interface
PacketProviderService
{
public
interface
PacketProviderService
extends
ProviderService
<
PacketProvider
>
{
/**
* Submits inbound packet context for processing. This processing will be
...
...
core/api/src/main/java/org/onlab/onos/net/packet/PacketService.java
View file @
4447409
...
...
@@ -18,7 +18,7 @@ public interface PacketService {
* @throws java.lang.IllegalArgumentException if a processor with the
* given priority already exists
*/
void
addProcessor
(
PacketProcessor
processor
,
long
priority
);
void
addProcessor
(
PacketProcessor
processor
,
int
priority
);
/**
* Removes the specified processor from the processing pipeline.
...
...
core/api/src/test/java/org/onlab/onos/net/DefaultHostTest.java
0 → 100644
View file @
4447409
package
org
.
onlab
.
onos
.
net
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
com.google.common.testing.EqualsTester
;
public
class
DefaultHostTest
extends
TestDeviceParams
{
@Test
public
void
testEquality
()
{
Host
h1
=
new
DefaultHost
(
PID
,
HID1
,
MAC1
,
VLAN1
,
LOC1
,
IPSET1
);
Host
h2
=
new
DefaultHost
(
PID
,
HID1
,
MAC1
,
VLAN1
,
LOC1
,
IPSET1
);
Host
h3
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN2
,
LOC2
,
IPSET2
);
Host
h4
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN2
,
LOC2
,
IPSET2
);
Host
h5
=
new
DefaultHost
(
PID
,
HID2
,
MAC2
,
VLAN1
,
LOC2
,
IPSET1
);
new
EqualsTester
().
addEqualityGroup
(
h1
,
h2
)
.
addEqualityGroup
(
h3
,
h4
)
.
addEqualityGroup
(
h5
)
.
testEquals
();
}
@Test
public
void
basics
()
{
Host
host
=
new
DefaultHost
(
PID
,
HID1
,
MAC1
,
VLAN1
,
LOC1
,
IPSET1
);
assertEquals
(
"incorrect provider"
,
PID
,
host
.
providerId
());
assertEquals
(
"incorrect id"
,
HID1
,
host
.
id
());
assertEquals
(
"incorrect type"
,
MAC1
,
host
.
mac
());
assertEquals
(
"incorrect VLAN"
,
VLAN1
,
host
.
vlan
());
assertEquals
(
"incorrect location"
,
LOC1
,
host
.
location
());
assertEquals
(
"incorrect IP's"
,
IPSET1
,
host
.
ipAddresses
());
}
}
core/api/src/test/java/org/onlab/onos/net/HostIdTest.java
View file @
4447409
package
org
.
onlab
.
onos
.
net
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
static
org
.
onlab
.
onos
.
net
.
HostId
.
hostId
;
/**
* Test
of
the host identifier.
* Test
for
the host identifier.
*/
public
class
HostIdTest
extends
ElementIdTest
{
private
static
final
MACAddress
MAC1
=
MACAddress
.
valueOf
(
"00:11:00:00:00:01"
);
private
static
final
MACAddress
MAC2
=
MACAddress
.
valueOf
(
"00:22:00:00:00:02"
);
private
static
final
VLANID
VLAN1
=
VLANID
.
vlanId
((
short
)
11
);
private
static
final
VLANID
VLAN2
=
VLANID
.
vlanId
((
short
)
22
);
@Override
@Test
public
void
basics
()
{
new
EqualsTester
()
.
addEqualityGroup
(
hostId
(
"nic:
foo
"
),
hostId
(
"nic:foo"
))
.
addEqualityGroup
(
hostId
(
"nic:bar"
))
.
addEqualityGroup
(
hostId
(
"nic:
00:11:00:00:00:01/11
"
),
hostId
(
MAC1
,
VLAN1
))
.
addEqualityGroup
(
hostId
(
MAC2
,
VLAN2
))
.
testEquals
();
}
...
...
core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
0 → 100644
View file @
4447409
package
org
.
onlab
.
onos
.
net
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
java.util.Set
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
com.google.common.collect.Sets
;
/**
* Provides a set of test DefaultDevice parameters for use with Host-
* related tests.
*/
public
abstract
class
TestDeviceParams
{
protected
static
final
ProviderId
PID
=
new
ProviderId
(
"foo"
);
protected
static
final
DeviceId
DID1
=
deviceId
(
"of:foo"
);
protected
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
protected
static
final
MACAddress
MAC1
=
MACAddress
.
valueOf
(
"00:11:00:00:00:01"
);
protected
static
final
MACAddress
MAC2
=
MACAddress
.
valueOf
(
"00:22:00:00:00:02"
);
protected
static
final
VLANID
VLAN1
=
VLANID
.
vlanId
((
short
)
11
);
protected
static
final
VLANID
VLAN2
=
VLANID
.
vlanId
((
short
)
22
);
protected
static
final
IPAddress
IP1
=
IPAddress
.
valueOf
(
"10.0.0.1"
);
protected
static
final
IPAddress
IP2
=
IPAddress
.
valueOf
(
"10.0.0.2"
);
protected
static
final
IPAddress
IP3
=
IPAddress
.
valueOf
(
"10.0.0.3"
);
protected
static
final
PortNumber
P1
=
PortNumber
.
portNumber
(
100
);
protected
static
final
PortNumber
P2
=
PortNumber
.
portNumber
(
200
);
protected
static
final
HostId
HID1
=
HostId
.
hostId
(
MAC1
,
VLAN1
);
protected
static
final
HostId
HID2
=
HostId
.
hostId
(
MAC2
,
VLAN2
);
protected
static
final
HostLocation
LOC1
=
new
HostLocation
(
DID1
,
P1
,
123L
);
protected
static
final
HostLocation
LOC2
=
new
HostLocation
(
DID2
,
P2
,
123L
);
protected
static
final
Set
<
IPAddress
>
IPSET1
=
Sets
.
newHashSet
(
IP1
,
IP2
);
protected
static
final
Set
<
IPAddress
>
IPSET2
=
Sets
.
newHashSet
(
IP1
,
IP3
);
}
of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
→
of/api/src/main/java/org/onlab/onos/of/controller/Default
OpenFlow
PacketContext.java
View file @
4447409
...
...
@@ -11,7 +11,7 @@ import org.projectfloodlight.openflow.protocol.match.MatchField;
import
org.projectfloodlight.openflow.types.OFBufferId
;
import
org.projectfloodlight.openflow.types.OFPort
;
public
final
class
Default
PacketContext
implements
PacketContext
{
public
final
class
Default
OpenFlowPacketContext
implements
OpenFlow
PacketContext
{
private
boolean
free
=
true
;
private
boolean
isBuilt
=
false
;
...
...
@@ -19,7 +19,7 @@ public final class DefaultPacketContext implements PacketContext {
private
final
OFPacketIn
pktin
;
private
OFPacketOut
pktout
=
null
;
private
DefaultPacketContext
(
OpenFlowSwitch
s
,
OFPacketIn
pkt
)
{
private
Default
OpenFlow
PacketContext
(
OpenFlowSwitch
s
,
OFPacketIn
pkt
)
{
this
.
sw
=
s
;
this
.
pktin
=
pkt
;
}
...
...
@@ -78,8 +78,8 @@ public final class DefaultPacketContext implements PacketContext {
return
new
Dpid
(
sw
.
getId
());
}
public
static
PacketContext
packetContextFromPacketIn
(
OpenFlowSwitch
s
,
OFPacketIn
pkt
)
{
return
new
DefaultPacketContext
(
s
,
pkt
);
public
static
OpenFlow
PacketContext
packetContextFromPacketIn
(
OpenFlowSwitch
s
,
OFPacketIn
pkt
)
{
return
new
Default
OpenFlow
PacketContext
(
s
,
pkt
);
}
@Override
...
...
of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java
→
of/api/src/main/java/org/onlab/onos/of/controller/
OpenFlow
PacketContext.java
View file @
4447409
...
...
@@ -8,7 +8,7 @@ import org.projectfloodlight.openflow.types.OFPort;
* to view the packet in event but may block the response to the
* event if blocked has been called.
*/
public
interface
PacketContext
{
public
interface
OpenFlow
PacketContext
{
//TODO: may want to support sending packet out other switches than
// the one it came in on.
...
...
of/api/src/main/java/org/onlab/onos/of/controller/PacketListener.java
View file @
4447409
...
...
@@ -10,5 +10,5 @@ public interface PacketListener {
*
* @param pktCtx the packet context
*/
public
void
handlePacket
(
PacketContext
pktCtx
);
public
void
handlePacket
(
OpenFlow
PacketContext
pktCtx
);
}
...
...
of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
View file @
4447409
...
...
@@ -12,7 +12,7 @@ import org.apache.felix.scr.annotations.Activate;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.of.controller.DefaultPacketContext
;
import
org.onlab.onos.of.controller.Default
OpenFlow
PacketContext
;
import
org.onlab.onos.of.controller.Dpid
;
import
org.onlab.onos.of.controller.OpenFlowController
;
import
org.onlab.onos.of.controller.OpenFlowSwitch
;
...
...
@@ -124,7 +124,7 @@ public class OpenFlowControllerImpl implements OpenFlowController {
break
;
case
PACKET_IN:
for
(
PacketListener
p
:
ofPacketListener
)
{
p
.
handlePacket
(
DefaultPacketContext
p
.
handlePacket
(
Default
OpenFlow
PacketContext
.
packetContextFromPacketIn
(
this
.
getSwitch
(
dpid
),
(
OFPacketIn
)
msg
));
}
...
...
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
View file @
4447409
...
...
@@ -15,7 +15,7 @@ import org.onlab.onos.of.controller.Dpid;
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.PacketContext
;
import
org.onlab.onos.of.controller.
OpenFlow
PacketContext
;
import
org.onlab.onos.of.controller.PacketListener
;
import
org.projectfloodlight.openflow.protocol.OFPortConfig
;
import
org.projectfloodlight.openflow.protocol.OFPortDesc
;
...
...
@@ -87,7 +87,7 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
@Override
public
void
handlePacket
(
PacketContext
pktCtx
)
{
public
void
handlePacket
(
OpenFlow
PacketContext
pktCtx
)
{
LinkDiscovery
ld
=
discoverers
.
get
(
pktCtx
.
dpid
());
if
(
ld
==
null
)
{
return
;
...
...
utils/misc/src/main/java/org/onlab/packet/IPAddress.java
View file @
4447409
...
...
@@ -57,7 +57,7 @@ public class IPAddress {
* @return an IP address
*/
public
static
IPAddress
valueOf
(
String
address
)
{
final
String
[]
parts
=
address
.
split
(
"."
);
final
String
[]
parts
=
address
.
split
(
"
\\
."
);
if
(
parts
.
length
!=
INET_LEN
)
{
throw
new
IllegalArgumentException
(
"Malformed IP address string; "
+
"Addres must have four decimal values separated by dots (.)"
);
...
...
@@ -119,7 +119,9 @@ public class IPAddress {
return
true
;
}
if
(
obj
instanceof
IPAddress
)
{
IPAddress
other
=
(
IPAddress
)
obj
;
if
(!(
this
.
version
.
equals
(
other
.
version
)))
{
return
false
;
}
...
...
utils/misc/src/main/java/org/onlab/packet/VLANID.java
View file @
4447409
...
...
@@ -37,12 +37,12 @@ public class VLANID {
}
if
(
obj
instanceof
VLANID
)
{
return
true
;
}
VLANID
other
=
(
VLANID
)
obj
;
if
(
this
.
value
==
other
.
value
)
{
return
true
;
VLANID
other
=
(
VLANID
)
obj
;
if
(
this
.
value
==
other
.
value
)
{
return
true
;
}
}
return
false
;
...
...
Please
register
or
login
to post a comment