Skip to content

Commit

Permalink
Merge pull request #143 from trema/feature/dest_to_destination
Browse files Browse the repository at this point in the history
Rename dst -> destination.
  • Loading branch information
yasuhito committed Apr 15, 2015
2 parents b0799e5 + d229153 commit 4bd8258
Show file tree
Hide file tree
Showing 20 changed files with 445 additions and 440 deletions.
56 changes: 28 additions & 28 deletions features/open_flow10/exact_match.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ Feature: Exact Match
Scenario: parse #1
When I create an exact match from "packet_in_arp_request.raw"
And the message have the following fields and values:
| field | value |
| wildcards | {} |
| in_port | 1 |
| ether_source_addr | ac:5d:10:31:37:79 |
| ether_dst_addr | ff:ff:ff:ff:ff:ff |
| dl_vlan | 65535 |
| dl_vlan_pcp | 0 |
| ether_type | 2054 |
| nw_tos | 0 |
| nw_proto | 1 |
| nw_source | 192.168.2.254 |
| nw_dst | 192.168.2.5 |
| tp_source | 0 |
| tp_dst | 0 |
| field | value |
| wildcards | {} |
| in_port | 1 |
| ether_source_addr | ac:5d:10:31:37:79 |
| ether_destination_addr | ff:ff:ff:ff:ff:ff |
| dl_vlan | 65535 |
| dl_vlan_pcp | 0 |
| ether_type | 2054 |
| nw_tos | 0 |
| nw_proto | 1 |
| nw_source | 192.168.2.254 |
| nw_destination | 192.168.2.5 |
| tp_source | 0 |
| tp_destination | 0 |

Scenario: parse #2
When I create an exact match from "packet_in_cbench.raw"
And the message have the following fields and values:
| field | value |
| wildcards | {} |
| in_port | 1 |
| ether_source_addr | 00:00:00:00:00:01 |
| ether_dst_addr | 80:00:00:00:00:01 |
| dl_vlan | 65535 |
| dl_vlan_pcp | 0 |
| ether_type | 2048 |
| nw_tos | 0 |
| nw_proto | 255 |
| nw_source | 192.168.0.40 |
| nw_dst | 192.168.1.40 |
| tp_source | 31256 |
| tp_dst | 22635 |
| field | value |
| wildcards | {} |
| in_port | 1 |
| ether_source_addr | 00:00:00:00:00:01 |
| ether_destination_addr | 80:00:00:00:00:01 |
| dl_vlan | 65535 |
| dl_vlan_pcp | 0 |
| ether_type | 2048 |
| nw_tos | 0 |
| nw_proto | 255 |
| nw_source | 192.168.0.40 |
| nw_destination | 192.168.1.40 |
| tp_source | 31256 |
| tp_destination | 22635 |
132 changes: 66 additions & 66 deletions features/open_flow10/features_reply.feature

Large diffs are not rendered by default.

312 changes: 156 additions & 156 deletions features/open_flow10/flow_mod.feature

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/pio/exact_match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ def initialize(packet_in)
options = {
in_port: packet_in.in_port,
ether_source_addr: packet_in.source_mac,
ether_dst_addr: packet_in.destination_mac,
ether_destination_addr: packet_in.destination_mac,
dl_vlan: data.vlan_vid,
dl_vlan_pcp: data.vlan_pcp,
ether_type: data.ether_type,
nw_tos: data.ip_type_of_service,
nw_proto: data.ip_protocol,
nw_source: data.ip_source_address,
nw_dst: data.ip_destination_address,
nw_destination: data.ip_destination_address,
tp_source: data.transport_source_port,
tp_dst: data.transport_destination_port
tp_destination: data.transport_destination_port
}
when Arp::Request
options = {
in_port: packet_in.in_port,
ether_source_addr: packet_in.source_mac,
ether_dst_addr: packet_in.destination_mac,
ether_destination_addr: packet_in.destination_mac,
dl_vlan: data.vlan_vid,
dl_vlan_pcp: data.vlan_pcp,
ether_type: data.ether_type,
nw_tos: 0,
nw_proto: data.operation,
nw_source: data.sender_protocol_address,
nw_dst: data.target_protocol_address,
nw_destination: data.target_protocol_address,
tp_source: 0,
tp_dst: 0
tp_destination: 0
}
end
@match = Pio::Match.new(options)
Expand Down
6 changes: 3 additions & 3 deletions lib/pio/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class Body < BinData::Record
:set_vlan_pcp,
:strip_vlan,
:set_dl_source,
:set_dl_dst,
:set_dl_destination,
:set_nw_source,
:set_nw_dst,
:set_nw_destination,
:set_nw_tos,
:set_tp_source,
:set_tp_dst,
:set_tp_destination,
:enqueue]

endian :big
Expand Down
37 changes: 19 additions & 18 deletions lib/pio/match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ class Wildcards < BinData::Primitive
in_port: 1 << 0,
dl_vlan: 1 << 1,
ether_source_addr: 1 << 2,
ether_dst_addr: 1 << 3,
ether_destination_addr: 1 << 3,
ether_type: 1 << 4,
nw_proto: 1 << 5,
tp_source: 1 << 6,
tp_dst: 1 << 7,
tp_destination: 1 << 7,
nw_source: 0,
nw_source0: 1 << 8,
nw_source1: 1 << 9,
nw_source2: 1 << 10,
nw_source3: 1 << 11,
nw_source4: 1 << 12,
nw_source_all: 1 << 13,
nw_dst: 0,
nw_dst0: 1 << 14,
nw_dst1: 1 << 15,
nw_dst2: 1 << 16,
nw_dst3: 1 << 17,
nw_dst4: 1 << 18,
nw_dst_all: 1 << 19,
nw_destination: 0,
nw_destination0: 1 << 14,
nw_destination1: 1 << 15,
nw_destination2: 1 << 16,
nw_destination3: 1 << 17,
nw_destination4: 1 << 18,
nw_destination_all: 1 << 19,
dl_vlan_pcp: 1 << 20,
nw_tos: 1 << 21
}
NW_FLAGS = [:nw_source, :nw_dst]
FLAGS = BITS.keys.select { |each| !(/^nw_(source|dst)/=~ each) }
NW_FLAGS = [:nw_source, :nw_destination]
FLAGS = BITS.keys.select { |each| !(/^nw_(source|destination)/=~ each) }

endian :big

Expand All @@ -46,7 +46,7 @@ class Wildcards < BinData::Primitive
def get
BITS.each_with_object(Hash.new(0)) do |(key, bit), memo|
next if flags & bit == 0
if /(nw_source|nw_dst)(\d)/=~ key
if /(nw_source|nw_destination)(\d)/=~ key
memo[$LAST_MATCH_INFO[1].intern] |= 1 << $LAST_MATCH_INFO[2].to_i
else
memo[key] = true
Expand All @@ -57,7 +57,7 @@ def get
def set(params)
self.flags = params.inject(0) do |memo, (key, val)|
memo | case key
when :nw_source, :nw_dst
when :nw_source, :nw_destination
(params.fetch(key) & 31) << (key == :nw_source ? 8 : 14)
else
val ? BITS.fetch(key) : 0
Expand All @@ -71,8 +71,8 @@ def nw_source
0
end

def nw_dst
get.fetch(:nw_dst)
def nw_destination
get.fetch(:nw_destination)
rescue KeyError
0
end
Expand Down Expand Up @@ -106,7 +106,7 @@ class MatchFormat < BinData::Record
wildcards :wildcards
uint16 :in_port
mac_address :ether_source_addr
mac_address :ether_dst_addr
mac_address :ether_destination_addr
uint16 :dl_vlan
uint8 :dl_vlan_pcp
uint8 :padding1
Expand All @@ -117,9 +117,10 @@ class MatchFormat < BinData::Record
uint16 :padding2
hide :padding2
match_ip_address :nw_source, bitcount: -> { wildcards.nw_source }
match_ip_address :nw_dst, bitcount: -> { wildcards.nw_dst }
match_ip_address :nw_destination,
bitcount: -> { wildcards.nw_destination }
uint16 :tp_source
uint16 :tp_dst
uint16 :tp_destination
end

def self.read(binary)
Expand Down
6 changes: 3 additions & 3 deletions lib/pio/open_flow/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class Actions < BinData::Primitive
2 => Pio::SetVlanPriority,
3 => Pio::StripVlanHeader,
4 => Pio::SetEtherSourceAddr,
5 => Pio::SetEtherDstAddr,
5 => Pio::SetEtherDestinationAddr,
6 => Pio::SetIpSourceAddr,
7 => Pio::SetIpDstAddr,
7 => Pio::SetIpDestinationAddr,
8 => Pio::SetIpTos,
9 => Pio::SetTransportSourcePort,
10 => Pio::SetTransportDstPort,
10 => Pio::SetTransportDestinationPort,
11 => Pio::Enqueue
}

Expand Down
2 changes: 1 addition & 1 deletion lib/pio/set_ether_addr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SetEtherSourceAddr < SetEtherAddr
end

# An action to modify the destination Ethernet address of a packet.
class SetEtherDstAddr < SetEtherAddr
class SetEtherDestinationAddr < SetEtherAddr
def_format 5
end
end
2 changes: 1 addition & 1 deletion lib/pio/set_ip_addr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SetIpSourceAddr < SetIpAddr
end

# An action to modify the IPv4 source address of a packet.
class SetIpDstAddr < SetIpAddr
class SetIpDestinationAddr < SetIpAddr
def_format 7
end
end
2 changes: 1 addition & 1 deletion lib/pio/set_transport_port.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SetTransportSourcePort < SetTransportPort
end

# An action to modify the source TCP/UDP port of a packet.
class SetTransportDstPort < SetTransportPort
class SetTransportDestinationPort < SetTransportPort
def_format 10
end
end
24 changes: 12 additions & 12 deletions spec/pio/flow_mod_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,29 @@
flow_mod.match.wildcards.keys == [
:dl_vlan,
:ether_source_addr,
:ether_dst_addr,
:ether_destination_addr,
:ether_type,
:nw_proto,
:tp_source,
:tp_dst,
:tp_destination,
:nw_source_all,
:nw_dst_all,
:nw_destination_all,
:dl_vlan_pcp,
:nw_tos
]
end
Then { flow_mod.match.in_port == 1 }
Then { flow_mod.match.ether_source_addr == '00:00:00:00:00:00' }
Then { flow_mod.match.ether_dst_addr == '00:00:00:00:00:00' }
Then { flow_mod.match.ether_destination_addr == '00:00:00:00:00:00' }
Then { flow_mod.match.dl_vlan == 0 }
Then { flow_mod.match.dl_vlan_pcp == 0 }
Then { flow_mod.match.ether_type == 0 }
Then { flow_mod.match.nw_tos == 0 }
Then { flow_mod.match.nw_proto == 0 }
Then { flow_mod.match.nw_source == '0.0.0.0' }
Then { flow_mod.match.nw_dst == '0.0.0.0' }
Then { flow_mod.match.nw_destination == '0.0.0.0' }
Then { flow_mod.match.tp_source == 0 }
Then { flow_mod.match.tp_dst == 0 }
Then { flow_mod.match.tp_destination == 0 }
Then { flow_mod.cookie == 1 }
Then { flow_mod.command == :add }
Then { flow_mod.idle_timeout == 0 }
Expand Down Expand Up @@ -106,29 +106,29 @@
flow_mod.match.wildcards.keys == [
:dl_vlan,
:ether_source_addr,
:ether_dst_addr,
:ether_destination_addr,
:ether_type,
:nw_proto,
:tp_source,
:tp_dst,
:tp_destination,
:nw_source_all,
:nw_dst_all,
:nw_destination_all,
:dl_vlan_pcp,
:nw_tos
]
end
Then { flow_mod.match.in_port == 1 }
Then { flow_mod.match.ether_source_addr == '00:00:00:00:00:00' }
Then { flow_mod.match.ether_dst_addr == '00:00:00:00:00:00' }
Then { flow_mod.match.ether_destination_addr == '00:00:00:00:00:00' }
Then { flow_mod.match.dl_vlan == 0 }
Then { flow_mod.match.dl_vlan_pcp == 0 }
Then { flow_mod.match.ether_type == 0 }
Then { flow_mod.match.nw_tos == 0 }
Then { flow_mod.match.nw_proto == 0 }
Then { flow_mod.match.nw_source == '0.0.0.0' }
Then { flow_mod.match.nw_dst == '0.0.0.0' }
Then { flow_mod.match.nw_destination == '0.0.0.0' }
Then { flow_mod.match.tp_source == 0 }
Then { flow_mod.match.tp_dst == 0 }
Then { flow_mod.match.tp_destination == 0 }
Then { flow_mod.cookie == 1 }
Then { flow_mod.command == :add }
Then { flow_mod.idle_timeout == 0 }
Expand Down
Loading

0 comments on commit 4bd8258

Please sign in to comment.