Skip to content

Commit

Permalink
Add OpenFlow13::SetDestinationMacAddress class
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Nov 7, 2015
1 parent 19f775e commit b9a713a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Rakefile
@@ -1,7 +1,7 @@
require 'bundler/gem_tasks'

RELISH_PROJECT = 'trema/pio'
FLAY_THRESHOLD = 1098
FLAY_THRESHOLD = 1196

task default: :travis
task test: [:spec, :cucumber]
Expand Down
14 changes: 14 additions & 0 deletions features/open_flow13/set_destination_mac_address.feature
@@ -0,0 +1,14 @@
@open_flow13
Feature: Pio::SetDestinationMacAddress

Scenario: new('11:22:33:44:55:66')
When I try to create an OpenFlow action with:
"""
Pio::SetDestinationMacAddress.new('11:22:33:44:55:66')
"""
Then it should finish successfully
And the action has the following fields and values:
| field | value |
| action_type | 25 |
| action_length | 16 |
| mac_address | 11:22:33:44:55:66 |
1 change: 1 addition & 0 deletions lib/pio/open_flow13.rb
Expand Up @@ -14,6 +14,7 @@

# Actions
require 'pio/open_flow13/send_out_port'
require 'pio/open_flow13/set_destination_mac_address'
require 'pio/open_flow13/set_source_mac_address'

# Instructions
Expand Down
23 changes: 23 additions & 0 deletions lib/pio/open_flow13/set_destination_mac_address.rb
@@ -0,0 +1,23 @@
require 'pio/open_flow/action'
require 'pio/open_flow13/match'

module Pio
module OpenFlow13
# Set a header field.
class SetDestinationMacAddress < OpenFlow::Action
action_header action_type: 25, action_length: 16

uint16 :oxm_class, value: Match::OXM_CLASS_OPENFLOW_BASIC
bit7 :oxm_field, value: Match::DestinationMacAddress::OXM_FIELD
bit1 :oxm_hasmask, value: 0
uint8 :oxm_length, value: 6
mac_address :mac_address
string :padding, length: 2
hide :padding

def initialize(mac_address)
super mac_address: mac_address
end
end
end
end

0 comments on commit b9a713a

Please sign in to comment.