openflow-protocol 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/messages/echo_reply.rb +6 -0
  3. data/lib/openflow-protocol/version.rb +5 -0
  4. data/spec/actions/action_enqueue_spec.rb +30 -0
  5. data/spec/actions/action_output_spec.rb +29 -0
  6. data/spec/actions/action_set_destination_port_spec.rb +26 -0
  7. data/spec/actions/action_set_ip_destination_spec.rb +25 -0
  8. data/spec/actions/action_set_ip_source_spec.rb +25 -0
  9. data/spec/actions/action_set_ip_tos_spec.rb +26 -0
  10. data/spec/actions/action_set_mac_destination_spec.rb +26 -0
  11. data/spec/actions/action_set_mac_source_spec.rb +26 -0
  12. data/spec/actions/action_set_source_port_spec.rb +26 -0
  13. data/spec/actions/action_set_vlan_id_spec.rb +26 -0
  14. data/spec/actions/action_set_vlan_pcp_spec.rb +26 -0
  15. data/spec/actions/action_strip_vlan_spec.rb +17 -0
  16. data/spec/actions/action_vendor_spec.rb +25 -0
  17. data/spec/actions/actions_spec.rb +33 -0
  18. data/spec/messages/barrier_reply_spec.rb +25 -0
  19. data/spec/messages/barrier_request_spec.rb +25 -0
  20. data/spec/messages/echo_reply_spec.rb +44 -0
  21. data/spec/messages/echo_request_spec.rb +53 -0
  22. data/spec/messages/error_spec.rb +56 -0
  23. data/spec/messages/features_reply_spec.rb +204 -0
  24. data/spec/messages/features_request_spec.rb +25 -0
  25. data/spec/messages/flow_mod_spec.rb +139 -0
  26. data/spec/messages/flow_removed_spec.rb +109 -0
  27. data/spec/messages/get_config_reply_spec.rb +39 -0
  28. data/spec/messages/get_config_request_spec.rb +25 -0
  29. data/spec/messages/hello_spec.rb +25 -0
  30. data/spec/messages/packet_in_spec.rb +76 -0
  31. data/spec/messages/packet_out_spec.rb +56 -0
  32. data/spec/messages/parser_spec.rb +43 -0
  33. data/spec/messages/port_mod_spec.rb +64 -0
  34. data/spec/messages/port_status_spec.rb +52 -0
  35. data/spec/messages/set_config_spec.rb +39 -0
  36. data/spec/messages/statistics_reply_spec.rb +411 -0
  37. data/spec/messages/statistics_request_spec.rb +355 -0
  38. data/spec/messages/vendor_spec.rb +56 -0
  39. data/spec/spec_helper.rb +7 -0
  40. data/spec/statistics/aggregate_statistics_reply_spec.rb +31 -0
  41. data/spec/statistics/aggregate_statistics_request_spec.rb +46 -0
  42. data/spec/statistics/description_statistics_spec.rb +38 -0
  43. data/spec/statistics/flow_statistics_reply_spec.rb +74 -0
  44. data/spec/statistics/flow_statistics_request_spec.rb +46 -0
  45. data/spec/statistics/port_statistics_reply_spec.rb +81 -0
  46. data/spec/statistics/port_statistics_request_spec.rb +19 -0
  47. data/spec/statistics/queue_statistics_reply_spec.rb +42 -0
  48. data/spec/statistics/queue_statistics_request_spec.rb +26 -0
  49. data/spec/statistics/table_statistics_spec.rb +54 -0
  50. data/spec/statistics/vendor_statistics_spec.rb +25 -0
  51. data/spec/structs/match_spec.rb +143 -0
  52. data/spec/structs/physical_port_spec.rb +63 -0
  53. data/spec/structs/port_number_spec.rb +19 -0
  54. metadata +109 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28435d32c26d648a016d60341a62edf94bf8f8ec
4
- data.tar.gz: 0429c85f80b866858be757db79de732cd6782106
3
+ metadata.gz: f0efcfc19372c5ff81c76eef6c74912c9ddfccaf
4
+ data.tar.gz: 02a45e643b2ea6c53f877dfac8cffcdc680c1711
5
5
  SHA512:
6
- metadata.gz: f3161c4bbdd5a4d19838636d169bc71f79e28ab414bbbfdb324c45bda0099939806cf140a2a677cb2f33b67fea34b8e0404f54c8cb76f3623b48973cf19988da
7
- data.tar.gz: d4a109d1b849be78cc8f076d1f2b683cd79e2389992add739ac76198add198a6372390e212e70554611e211f38ce20d5712b72b4fb3c3e76565fc8cd923a806b
6
+ metadata.gz: 77b3a36050c5e976899c07f2a9a8ff4917f8b8e4c5cbce3070ea02b262990f9ba67b2324095edba3b83e160fdcb4bfa7c0c6d171abc0d8cff852f4accbacc1cb
7
+ data.tar.gz: de3deb39ea4a6e6ca09c0fd3a5eeca3769ab1c62d97945990cca0131f6c9db2c0f27eca5f98da8678f2f78bc4f75a1331077a259c50c6f53a09719f33f89168d
@@ -1,3 +1,9 @@
1
1
  require_relative 'echo_request'
2
2
 
3
3
  class OFEchoReply < OFEchoRequest; end
4
+
5
+ class OFEchoRequest
6
+ def to_reply
7
+ OFEchoReply.new(xid: xid, data: data.dup)
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module OpenFlow
2
+ module Protocol
3
+ VERSION = '0.1.6'
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionEnqueue do
4
+ it 'should read binary' do
5
+ action = OFActionEnqueue.read [
6
+ 0, 11, 0, 16, # header
7
+ 0, 1, # port
8
+ 0, 0, 0, 0, 0, 0, # padding
9
+ 0, 0, 0, 1 # queue_id
10
+ ].pack('C*')
11
+ expect(action.type).to eq(:enqueue)
12
+ expect(action.len).to eq(16)
13
+ expect(action.port).to eq(1)
14
+ expect(action.queue_id).to eq(1)
15
+ end
16
+ it 'should initialize with default values' do
17
+ action = OFActionEnqueue.new
18
+ expect(action.type).to eq(:enqueue)
19
+ expect(action.len).to eq(16)
20
+ expect(action.port).to eq(:none)
21
+ expect(action.queue_id).to eq(0)
22
+ end
23
+ it 'should initialize with some values' do
24
+ action = OFActionEnqueue.new(port: 1, queue_id: 1)
25
+ expect(action.type).to eq(:enqueue)
26
+ expect(action.len).to eq(16)
27
+ expect(action.port).to eq(1)
28
+ expect(action.queue_id).to eq(1)
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionOutput do
4
+ it 'should read binary' do
5
+ action = OFActionOutput.read [
6
+ 0, 0, 0, 8, # header
7
+ 0, 1, # port
8
+ 0xff, 0xff # max_length
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:output)
11
+ expect(action.len).to eq(8)
12
+ expect(action.port).to eq(1)
13
+ expect(action.max_length).to eq(0xffff)
14
+ end
15
+ it 'should initialize with default values' do
16
+ action = OFActionOutput.new
17
+ expect(action.type).to eq(:output)
18
+ expect(action.len).to eq(8)
19
+ expect(action.port).to eq(:none)
20
+ expect(action.max_length).to eq(0xffff)
21
+ end
22
+ it 'should initialize with some values' do
23
+ action = OFActionOutput.new(port: 1)
24
+ expect(action.type).to eq(:output)
25
+ expect(action.len).to eq(8)
26
+ expect(action.port).to eq(1)
27
+ expect(action.max_length).to eq(0xffff)
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetDestinationPort do
4
+ it 'should read binary' do
5
+ action = OFActionSetDestinationPort.read [
6
+ 0, 10, 0, 8, # header
7
+ 0, 1, # port
8
+ 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_destination_port)
11
+ expect(action.len).to eq(8)
12
+ expect(action.port).to eq(1)
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetDestinationPort.new
16
+ expect(action.type).to eq(:set_destination_port)
17
+ expect(action.len).to eq(8)
18
+ expect(action.port).to eq(0)
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetDestinationPort.new(port: 1)
22
+ expect(action.type).to eq(:set_destination_port)
23
+ expect(action.len).to eq(8)
24
+ expect(action.port).to eq(1)
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetIpDestination do
4
+ it 'should read binary' do
5
+ action = OFActionSetIpDestination.read [
6
+ 0, 7, 0, 8, # header
7
+ 10, 0, 0, 1 # ip_address
8
+ ].pack('C*')
9
+ expect(action.type).to eq(:set_ip_destination)
10
+ expect(action.len).to eq(8)
11
+ expect(action.ip_address).to eq('10.0.0.1')
12
+ end
13
+ it 'should initialize with default values' do
14
+ action = OFActionSetIpDestination.new
15
+ expect(action.type).to eq(:set_ip_destination)
16
+ expect(action.len).to eq(8)
17
+ expect(action.ip_address).to eq('0.0.0.0')
18
+ end
19
+ it 'should initialize with some values' do
20
+ action = OFActionSetIpDestination.new(ip_address: '10.0.0.1')
21
+ expect(action.type).to eq(:set_ip_destination)
22
+ expect(action.len).to eq(8)
23
+ expect(action.ip_address).to eq('10.0.0.1')
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetIpSource do
4
+ it 'should read binary' do
5
+ action = OFActionSetIpSource.read [
6
+ 0, 6, 0, 8, # header
7
+ 10, 0, 0, 1 # ip_address
8
+ ].pack('C*')
9
+ expect(action.type).to eq(:set_ip_source)
10
+ expect(action.len).to eq(8)
11
+ expect(action.ip_address).to eq('10.0.0.1')
12
+ end
13
+ it 'should initialize with default values' do
14
+ action = OFActionSetIpSource.new
15
+ expect(action.type).to eq(:set_ip_source)
16
+ expect(action.len).to eq(8)
17
+ expect(action.ip_address).to eq('0.0.0.0')
18
+ end
19
+ it 'should initialize with some values' do
20
+ action = OFActionSetIpSource.new(ip_address: '10.0.0.1')
21
+ expect(action.type).to eq(:set_ip_source)
22
+ expect(action.len).to eq(8)
23
+ expect(action.ip_address).to eq('10.0.0.1')
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetIpTos do
4
+ it 'should read binary' do
5
+ action = OFActionSetIpTos.read [
6
+ 0, 8, 0, 8, # header
7
+ 10, # tos
8
+ 0, 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_ip_tos)
11
+ expect(action.len).to eq(8)
12
+ expect(action.tos).to eq(10)
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetIpTos.new
16
+ expect(action.type).to eq(:set_ip_tos)
17
+ expect(action.len).to eq(8)
18
+ expect(action.tos).to eq(0)
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetIpTos.new(tos: 10)
22
+ expect(action.type).to eq(:set_ip_tos)
23
+ expect(action.len).to eq(8)
24
+ expect(action.tos).to eq(10)
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetMacDestination do
4
+ it 'should read binary' do
5
+ action = OFActionSetMacDestination.read [
6
+ 0, 5, 0, 16, # header
7
+ 0, 0, 0, 0, 0, 1, # mac_address
8
+ 0, 0, 0, 0, 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_mac_destination)
11
+ expect(action.len).to eq(16)
12
+ expect(action.mac_address).to eq('00:00:00:00:00:01')
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetMacDestination.new
16
+ expect(action.type).to eq(:set_mac_destination)
17
+ expect(action.len).to eq(16)
18
+ expect(action.mac_address).to eq('00:00:00:00:00:00')
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetMacDestination.new(mac_address: '00:00:00:00:00:01')
22
+ expect(action.type).to eq(:set_mac_destination)
23
+ expect(action.len).to eq(16)
24
+ expect(action.mac_address).to eq('00:00:00:00:00:01')
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetMacSource do
4
+ it 'should read binary' do
5
+ action = OFActionSetMacSource.read [
6
+ 0, 4, 0, 16, # header
7
+ 0, 0, 0, 0, 0, 1, # mac_address
8
+ 0, 0, 0, 0, 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_mac_source)
11
+ expect(action.len).to eq(16)
12
+ expect(action.mac_address).to eq('00:00:00:00:00:01')
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetMacSource.new
16
+ expect(action.type).to eq(:set_mac_source)
17
+ expect(action.len).to eq(16)
18
+ expect(action.mac_address).to eq('00:00:00:00:00:00')
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetMacSource.new(mac_address: '00:00:00:00:00:01')
22
+ expect(action.type).to eq(:set_mac_source)
23
+ expect(action.len).to eq(16)
24
+ expect(action.mac_address).to eq('00:00:00:00:00:01')
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetSourcePort do
4
+ it 'should read binary' do
5
+ action = OFActionSetSourcePort.read [
6
+ 0, 9, 0, 8, # header
7
+ 0, 1, # port
8
+ 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_source_port)
11
+ expect(action.len).to eq(8)
12
+ expect(action.port).to eq(1)
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetSourcePort.new
16
+ expect(action.type).to eq(:set_source_port)
17
+ expect(action.len).to eq(8)
18
+ expect(action.port).to eq(0)
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetSourcePort.new(port: 1)
22
+ expect(action.type).to eq(:set_source_port)
23
+ expect(action.len).to eq(8)
24
+ expect(action.port).to eq(1)
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetVlanId do
4
+ it 'should read binary' do
5
+ action = OFActionSetVlanId.read [
6
+ 0, 1, 0, 8, # header
7
+ 0, 1, # vlan_id
8
+ 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_vlan_id)
11
+ expect(action.len).to eq(8)
12
+ expect(action.vlan_id).to eq(1)
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetVlanId.new
16
+ expect(action.type).to eq(:set_vlan_id)
17
+ expect(action.len).to eq(8)
18
+ expect(action.vlan_id).to eq(0)
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetVlanId.new(vlan_id: 1)
22
+ expect(action.type).to eq(:set_vlan_id)
23
+ expect(action.len).to eq(8)
24
+ expect(action.vlan_id).to eq(1)
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionSetVlanPcp do
4
+ it 'should read binary' do
5
+ action = OFActionSetVlanPcp.read [
6
+ 0, 2, 0, 8, # header
7
+ 1, # vlan_pcp
8
+ 0, 0, 0 # padding
9
+ ].pack('C*')
10
+ expect(action.type).to eq(:set_vlan_pcp)
11
+ expect(action.len).to eq(8)
12
+ expect(action.vlan_pcp).to eq(1)
13
+ end
14
+ it 'should initialize with default values' do
15
+ action = OFActionSetVlanPcp.new
16
+ expect(action.type).to eq(:set_vlan_pcp)
17
+ expect(action.len).to eq(8)
18
+ expect(action.vlan_pcp).to eq(0)
19
+ end
20
+ it 'should initialize with some values' do
21
+ action = OFActionSetVlanPcp.new(vlan_pcp: 1)
22
+ expect(action.type).to eq(:set_vlan_pcp)
23
+ expect(action.len).to eq(8)
24
+ expect(action.vlan_pcp).to eq(1)
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionStripVlan do
4
+ it 'should read binary' do
5
+ action = OFActionStripVlan.read [
6
+ 0, 3, 0, 8, # header
7
+ 0, 0, 0, 0 # padding
8
+ ].pack('C*')
9
+ expect(action.type).to eq(:strip_vlan)
10
+ expect(action.len).to eq(8)
11
+ end
12
+ it 'should initialize with default values' do
13
+ action = OFActionStripVlan.new
14
+ expect(action.type).to eq(:strip_vlan)
15
+ expect(action.len).to eq(8)
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionVendor do
4
+ it 'should read binary' do
5
+ action = OFActionVendor.read [
6
+ 0xff, 0xff, 0, 8, # header
7
+ 0, 0, 0, 1 # vendor
8
+ ].pack('C*')
9
+ expect(action.type).to eq(:vendor)
10
+ expect(action.len).to eq(8)
11
+ expect(action.vendor).to eq(1)
12
+ end
13
+ it 'should initialize with default values' do
14
+ action = OFActionVendor.new
15
+ expect(action.type).to eq(:vendor)
16
+ expect(action.len).to eq(8)
17
+ expect(action.vendor).to eq(0)
18
+ end
19
+ it 'should initialize with some values' do
20
+ action = OFActionVendor.new(vendor: 1)
21
+ expect(action.type).to eq(:vendor)
22
+ expect(action.len).to eq(8)
23
+ expect(action.vendor).to eq(1)
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFActionOutput do
4
+ it 'should read binary' do
5
+ actions = OFActions.read [
6
+ # output
7
+ 0, 0, 0, 8, # header
8
+ 0, 1, # port
9
+ 0xff, 0xff, # max_length
10
+ # enqueue
11
+ 0, 11, 0, 16, # header
12
+ 0, 1, # port
13
+ 0, 0, 0, 0, 0, 0, # padding
14
+ 0, 0, 0, 1 # queue_id
15
+ ].pack('C*'), length: 24
16
+ expect(actions.length).to eq(2)
17
+ expect(actions.first.type).to eq(:output)
18
+ expect(actions.last.type).to eq(:enqueue)
19
+ end
20
+ it 'should initialize with default values' do
21
+ actions = OFActions.new
22
+ expect(actions).to be_empty
23
+ end
24
+ it 'should initialize with some values' do
25
+ actions = OFActions.new([
26
+ OFActionOutput.new(port: 1, max_length: 0xffff),
27
+ OFActionEnqueue.new(port: 1, queue_id: 1)
28
+ ])
29
+ expect(actions.length).to eq(2)
30
+ expect(actions.first.type).to eq(:output)
31
+ expect(actions.last.type).to eq(:enqueue)
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFBarrierReply do
4
+ it 'should read binary' do
5
+ msg = OFBarrierReply.read [1, 19, 0, 8, 0, 0, 0, 1].pack('C*')
6
+ expect(msg.version).to eq(OFMessage::OFP_VERSION)
7
+ expect(msg.type).to eq(:barrier_reply)
8
+ expect(msg.len).to eq(8)
9
+ expect(msg.xid).to eq(1)
10
+ end
11
+ it 'should initialize with default values' do
12
+ msg = OFBarrierReply.new
13
+ expect(msg.version).to eq(OFMessage::OFP_VERSION)
14
+ expect(msg.type).to eq(:barrier_reply)
15
+ expect(msg.len).to eq(8)
16
+ expect(msg.xid).to eq(0)
17
+ end
18
+ it 'should initialize with some values' do
19
+ msg = OFBarrierReply.new(xid: 1)
20
+ expect(msg.version).to eq(OFMessage::OFP_VERSION)
21
+ expect(msg.type).to eq(:barrier_reply)
22
+ expect(msg.len).to eq(8)
23
+ expect(msg.xid).to eq(1)
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OFBarrierRequest do
4
+ it 'should read binary' do
5
+ msg = OFBarrierRequest.read [1, 18, 0, 8, 0, 0, 0, 1].pack('C*')
6
+ expect(msg.version).to eq(OFMessage::OFP_VERSION)
7
+ expect(msg.type).to eq(:barrier_request)
8
+ expect(msg.len).to eq(8)
9
+ expect(msg.xid).to eq(1)
10
+ end
11
+ it 'should initialize with default values' do
12
+ msg = OFBarrierRequest.new
13
+ expect(msg.version).to eq(OFMessage::OFP_VERSION)
14
+ expect(msg.type).to eq(:barrier_request)
15
+ expect(msg.len).to eq(8)
16
+ expect(msg.xid).to eq(0)
17
+ end
18
+ it 'should initialize with some values' do
19
+ msg = OFBarrierRequest.new(xid: 1)
20
+ expect(msg.version).to eq(OFMessage::OFP_VERSION)
21
+ expect(msg.type).to eq(:barrier_request)
22
+ expect(msg.len).to eq(8)
23
+ expect(msg.xid).to eq(1)
24
+ end
25
+ end