pio 0.10.1 → 0.11.0

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +33 -2
  4. data/examples/echo_read.rb +1 -1
  5. data/examples/features_read.rb +1 -1
  6. data/examples/flow_mod_new.rb +13 -0
  7. data/examples/flow_mod_read.rb +6 -0
  8. data/features/echo_read.feature +27 -3
  9. data/features/features_read.feature +46 -2
  10. data/features/flow_mod_read.feature +186 -0
  11. data/features/hello_read.feature +9 -0
  12. data/features/packet_data/flow_mod_add.raw +0 -0
  13. data/features/packet_data/flow_mod_delete.raw +0 -0
  14. data/features/packet_data/flow_mod_delete_strict.raw +0 -0
  15. data/features/packet_data/flow_mod_modify.raw +0 -0
  16. data/features/packet_data/flow_mod_modify_strict.raw +0 -0
  17. data/features/packet_in_read.feature +13 -0
  18. data/features/packet_out_read.feature +16 -0
  19. data/features/step_definitions/packet_data_steps.rb +10 -1
  20. data/lib/pio.rb +1 -0
  21. data/lib/pio/echo.rb +10 -8
  22. data/lib/pio/enqueue.rb +1 -1
  23. data/lib/pio/features.rb +64 -7
  24. data/lib/pio/flow_mod.rb +86 -0
  25. data/lib/pio/hello.rb +4 -74
  26. data/lib/pio/ipv4_address.rb +1 -1
  27. data/lib/pio/match.rb +167 -0
  28. data/lib/pio/open_flow.rb +1 -0
  29. data/lib/pio/open_flow/actions.rb +65 -0
  30. data/lib/pio/open_flow/flags.rb +12 -9
  31. data/lib/pio/open_flow/message.rb +105 -21
  32. data/lib/pio/open_flow/phy_port.rb +31 -27
  33. data/lib/pio/open_flow/type.rb +1 -0
  34. data/lib/pio/packet_in.rb +2 -12
  35. data/lib/pio/packet_out.rb +4 -74
  36. data/lib/pio/send_out_port.rb +1 -0
  37. data/lib/pio/type/ip_address.rb +2 -7
  38. data/lib/pio/version.rb +1 -1
  39. data/pio.gemspec +8 -8
  40. data/spec/pio/echo/reply_spec.rb +61 -6
  41. data/spec/pio/echo/request_spec.rb +61 -6
  42. data/spec/pio/features/reply_spec.rb +81 -4
  43. data/spec/pio/features/request_spec.rb +88 -41
  44. data/spec/pio/flow_mod_spec.rb +151 -0
  45. data/spec/pio/hello_spec.rb +73 -56
  46. data/spec/pio/match_spec.rb +194 -0
  47. data/spec/pio/packet_in_spec.rb +35 -38
  48. data/spec/pio/packet_out_spec.rb +243 -182
  49. data/spec/pio/wildcards_spec.rb +115 -0
  50. metadata +37 -30
  51. data/features/packet_data/echo.raw +0 -0
  52. data/lib/pio/echo/message.rb +0 -49
  53. data/lib/pio/echo/reply.rb +0 -41
  54. data/lib/pio/echo/request.rb +0 -43
  55. data/lib/pio/features/reply.rb +0 -88
  56. data/lib/pio/features/request.rb +0 -68
  57. data/lib/pio/open_flow/parser.rb +0 -22
  58. data/spec/pio/echo_spec.rb +0 -49
  59. data/spec/pio/features_spec.rb +0 -96
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83d7de827392e1205ebc738b0f64a580896c1dfe
4
- data.tar.gz: be008400a4a153f01e08359f6f678e37768b0c5e
3
+ metadata.gz: c327a8b9d5983e25574403cbe3f1e5ddfad54633
4
+ data.tar.gz: 1c8395383b9ceaebbda9cfa5cf3a1e1201f4aab4
5
5
  SHA512:
6
- metadata.gz: 130670982b983d7766bcdbc0aa6ed5a414c34b0f104a4e1d4ee0cb7bdef7cd3410a51a65669e29e7db79667c69dd155d881b35c63f2cf610d25df924dceb7253
7
- data.tar.gz: 280c8072f117262fa5a6865a96f42ce1437cddef488e157d8ab6ea7fe1972591774844b0a9f12d873d11be2611a835f13244fd980b07266055fde676896d3ceb
6
+ metadata.gz: efa2dd373e70c0e235b0c004da7b839df4d98031d1ebfebe5c96972f8933bcdcd9b3c70d6a475cb8eabedad9b62a23116905fb2ac68c971b8e7af46435c472d8
7
+ data.tar.gz: 046bf9ac402f5a9cd2ba411efcacff61857c68836b02c02563cb9125fd09f9dbd551deb1e6d69042a691ed0828289cf5f9ededbb9caa920a9a612cdefc24cb25
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 (1/15/2015)
4
+
5
+ ### New features
6
+ * [#108](https://github.com/trema/pio/pull/108): Added new class `Pio::FlowMod` and `Pio::Match`.
7
+
8
+
3
9
  ## 0.10.1 (1/6/2015)
4
10
 
5
11
  ### Bugs fixed
data/README.md CHANGED
@@ -23,6 +23,7 @@ supports the following packet formats:
23
23
  - Features
24
24
  - Packet-In
25
25
  - Packet-Out
26
+ - Flow Mod
26
27
  - (…currently there are just a few formats supported but I'm sure this list will grow)
27
28
 
28
29
  ## Features Overview
@@ -194,7 +195,7 @@ and you can access each field of the parsed Echo message.
194
195
 
195
196
  require 'pio'
196
197
 
197
- echo = Pio::Echo.read(binary_data)
198
+ echo = Pio::Echo::Request.read(binary_data)
198
199
  echo.xid # => 123
199
200
 
200
201
  Also you can use `Pio::Echo::Request#new` or `Pio::Echo::Reply#new` to
@@ -218,7 +219,7 @@ Features message.
218
219
 
219
220
  require 'pio'
220
221
 
221
- features = Pio::Features.read(binary_data)
222
+ features = Pio::Features::Request.read(binary_data)
222
223
  features.xid # => 123
223
224
 
224
225
  Also you can use `Pio::Features::Request#new` or `Pio::Features::Reply#new` to
@@ -320,6 +321,36 @@ like below:
320
321
  data: data_dump)
321
322
  packet_out.to_binary # => Packet-Out message in binary format.
322
323
 
324
+ ### Flow Mod
325
+
326
+ To parse an OpenFlow 1.0 flow mod message, use the API
327
+ `Pio::FlowMod.read` and you can access each field of the parsed
328
+ flow mod message.
329
+
330
+ require 'pio'
331
+
332
+ flow_mod = Pio::FlowMod.read(binary_data)
333
+ flow_mod.match.in_port # => 1
334
+ flow_mod.match.dl_src # => '00:00:00:00:00:0a'
335
+ # ...
336
+
337
+ Also you can use `Pio::FlowMod#new` and `Pio::Match#new` to generate a
338
+ flow mod message like below:
339
+
340
+ require 'pio'
341
+
342
+ flow_mod = Pio::FlowMod.new(transaction_id: 0x15,
343
+ buffer_id: 0xffffffff,
344
+ match: Pio::Match.new(in_port: 1),
345
+ cookie: 1,
346
+ command: :add,
347
+ priority: 0xffff,
348
+ out_port: 2,
349
+ flags: [:send_flow_rem, :check_overwrap],
350
+ actions: Pio::SendOutPort.new(2))
351
+
352
+ flow_mod.to_binary # => Flow mod message in binary format.
353
+
323
354
  ## Installation
324
355
 
325
356
  The simplest way to install Pio is to use [Bundler](http://gembundler.com/).
@@ -1,4 +1,4 @@
1
1
  require 'pio'
2
2
 
3
- echo = Pio::Echo.read(binary_data)
3
+ echo = Pio::Echo::Request.read(binary_data)
4
4
  echo.xid # => 123
@@ -1,4 +1,4 @@
1
1
  require 'pio'
2
2
 
3
- features = Pio::Features.read(binary_data)
3
+ features = Pio::Features::Request.read(binary_data)
4
4
  features.xid # => 123
@@ -0,0 +1,13 @@
1
+ require 'pio'
2
+
3
+ flow_mod = Pio::FlowMod.new(transaction_id: 0x15,
4
+ buffer_id: 0xffffffff,
5
+ match: Pio::Match.new(in_port: 1),
6
+ cookie: 1,
7
+ command: :add,
8
+ priority: 0xffff,
9
+ out_port: 2,
10
+ flags: [:send_flow_rem, :check_overwrap],
11
+ actions: Pio::SendOutPort.new(2))
12
+
13
+ flow_mod.to_binary # => Flow mod message in binary format.
@@ -0,0 +1,6 @@
1
+ require 'pio'
2
+
3
+ flow_mod = Pio::FlowMod.read(binary_data)
4
+ flow_mod.match.in_port # => 1
5
+ flow_mod.match.dl_src # => '00:00:00:00:00:0a'
6
+ # ...
@@ -1,5 +1,29 @@
1
1
  Feature: Pio::Echo.read
2
- Scenario: echo.raw
3
- Given a packet data file "echo.raw"
4
- When I try to parse the file with "Echo" class
2
+ Scenario: echo_request.raw
3
+ Given a packet data file "echo_request.raw"
4
+ When I try to parse the file with "Echo::Request" class
5
5
  Then it should finish successfully
6
+ And the parsed data have the following field and value:
7
+ | field | value |
8
+ | class | Pio::Echo::Request |
9
+ | ofp_version | 1 |
10
+ | message_type | 2 |
11
+ | message_length | 8 |
12
+ | transaction_id | 0 |
13
+ | xid | 0 |
14
+ | body | |
15
+
16
+ Scenario: echo_reply.raw
17
+ Given a packet data file "echo_reply.raw"
18
+ When I try to parse the file with "Echo::Reply" class
19
+ Then it should finish successfully
20
+ And the parsed data have the following field and value:
21
+ | field | value |
22
+ | class | Pio::Echo::Reply |
23
+ | ofp_version | 1 |
24
+ | message_type | 3 |
25
+ | message_length | 8 |
26
+ | transaction_id | 6 |
27
+ | xid | 6 |
28
+ | body | |
29
+
@@ -1,10 +1,54 @@
1
1
  Feature: Pio::Features.read
2
2
  Scenario: features_request.raw
3
3
  Given a packet data file "features_request.raw"
4
- When I try to parse the file with "Features" class
4
+ When I try to parse the file with "Features::Request" class
5
5
  Then it should finish successfully
6
+ And the parsed data have the following field and value:
7
+ | field | value |
8
+ | class | Pio::Features::Request |
9
+ | ofp_version | 1 |
10
+ | message_type | 5 |
11
+ | message_length | 8 |
12
+ | transaction_id | 2 |
13
+ | xid | 2 |
14
+ | body | |
6
15
 
7
16
  Scenario: features_reply.raw
8
17
  Given a packet data file "features_reply.raw"
9
- When I try to parse the file with "Features" class
18
+ When I try to parse the file with "Features::Reply" class
10
19
  Then it should finish successfully
20
+ And the parsed data have the following field and value:
21
+ | field | value |
22
+ | class | Pio::Features::Reply |
23
+ | ofp_version | 1 |
24
+ | message_type | 6 |
25
+ | message_length | 176 |
26
+ | transaction_id | 2 |
27
+ | xid | 2 |
28
+ | datapath_id | 1 |
29
+ | dpid | 1 |
30
+ | n_buffers | 256 |
31
+ | n_tables | 1 |
32
+ | capabilities | [:flow_stats, :table_stats, :port_stats, :arp_match_ip] |
33
+ | actions | [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan, :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst, :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue] |
34
+ | ports.length | 3 |
35
+ | ports.first.port_no | 2 |
36
+ | ports.first.mac_address | 16:7d:a4:37:ba:10 |
37
+ | ports.first.hardware_address | 16:7d:a4:37:ba:10 |
38
+ | ports.first.name | trema0-0 |
39
+ | ports.first.config | [] |
40
+ | ports.first.state | [] |
41
+ | ports.first.curr | [:port_10gb_fd, :port_copper] |
42
+ | ports.first.advertised | [] |
43
+ | ports.first.supported | [] |
44
+ | ports.first.peer | [] |
45
+ | ports.last.port_no | 1 |
46
+ | ports.last.mac_address | 62:94:3a:f6:40:db |
47
+ | ports.last.hardware_address | 62:94:3a:f6:40:db |
48
+ | ports.last.name | trema1-0 |
49
+ | ports.last.config | [] |
50
+ | ports.last.state | [] |
51
+ | ports.last.curr | [:port_10gb_fd, :port_copper] |
52
+ | ports.last.advertised | [] |
53
+ | ports.last.supported | [] |
54
+ | ports.last.peer | [] |
@@ -0,0 +1,186 @@
1
+ Feature: Pio::FlowMod.read
2
+ Scenario: flow_mod_add.raw
3
+ Given a packet data file "flow_mod_add.raw"
4
+ When I try to parse the file with "FlowMod" class
5
+ Then it should finish successfully
6
+ And the parsed data have the following field and value:
7
+ | field | value |
8
+ | ofp_version | 1 |
9
+ | message_type | 14 |
10
+ | message_length | 192 |
11
+ | transaction_id | 0 |
12
+ | xid | 0 |
13
+ | match.wildcards | {:nw_src=>24, :nw_dst=>24} |
14
+ | match.in_port | 1 |
15
+ | match.dl_src | 00:00:00:00:00:0a |
16
+ | match.dl_dst | 00:00:00:00:00:14 |
17
+ | match.dl_vlan | 0 |
18
+ | match.dl_vlan_pcp | 0 |
19
+ | match.dl_type | 2048 |
20
+ | match.nw_tos | 0 |
21
+ | match.nw_proto | 1 |
22
+ | match.nw_src | 10.0.0.0 |
23
+ | match.nw_src.prefixlen | 8 |
24
+ | match.nw_dst | 20.0.0.0 |
25
+ | match.nw_dst.prefixlen | 8 |
26
+ | match.tp_src | 8 |
27
+ | match.tp_dst | 0 |
28
+ | cookie | 0 |
29
+ | command | add |
30
+ | idle_timeout | 0 |
31
+ | hard_timeout | 0 |
32
+ | priority | 65535 |
33
+ | buffer_id | 4294967295 |
34
+ | out_port | 65535 |
35
+ | flags | [:send_flow_rem] |
36
+ | actions.length | 12 |
37
+ | actions.first.class | Pio::SetVlanVid |
38
+ | actions.first.vlan_id | 10 |
39
+
40
+ Scenario: flow_mod_modify.raw
41
+ Given a packet data file "flow_mod_modify.raw"
42
+ When I try to parse the file with "FlowMod" class
43
+ Then it should finish successfully
44
+ And the parsed data have the following field and value:
45
+ | field | value |
46
+ | ofp_version | 1 |
47
+ | message_type | 14 |
48
+ | message_length | 192 |
49
+ | transaction_id | 0 |
50
+ | xid | 0 |
51
+ | match.wildcards | {:nw_src=>24, :nw_dst=>24} |
52
+ | match.in_port | 1 |
53
+ | match.dl_src | 00:00:00:00:00:0a |
54
+ | match.dl_dst | 00:00:00:00:00:14 |
55
+ | match.dl_vlan | 0 |
56
+ | match.dl_vlan_pcp | 0 |
57
+ | match.dl_type | 2048 |
58
+ | match.nw_tos | 0 |
59
+ | match.nw_proto | 1 |
60
+ | match.nw_src | 10.0.0.0 |
61
+ | match.nw_src.prefixlen | 8 |
62
+ | match.nw_dst | 20.0.0.0 |
63
+ | match.nw_dst.prefixlen | 8 |
64
+ | match.tp_src | 8 |
65
+ | match.tp_dst | 0 |
66
+ | cookie | 0 |
67
+ | command | modify |
68
+ | idle_timeout | 0 |
69
+ | hard_timeout | 0 |
70
+ | priority | 65535 |
71
+ | buffer_id | 4294967295 |
72
+ | out_port | 65535 |
73
+ | flags | [:send_flow_rem] |
74
+ | actions.length | 12 |
75
+ | actions.first.class | Pio::SetVlanVid |
76
+ | actions.first.vlan_id | 10 |
77
+
78
+ Scenario: flow_mod_modify_strict.raw
79
+ Given a packet data file "flow_mod_modify_strict.raw"
80
+ When I try to parse the file with "FlowMod" class
81
+ Then it should finish successfully
82
+ And the parsed data have the following field and value:
83
+ | field | value |
84
+ | ofp_version | 1 |
85
+ | message_type | 14 |
86
+ | message_length | 192 |
87
+ | transaction_id | 0 |
88
+ | xid | 0 |
89
+ | match.wildcards | {:nw_src=>24, :nw_dst=>24} |
90
+ | match.in_port | 1 |
91
+ | match.dl_src | 00:00:00:00:00:0a |
92
+ | match.dl_dst | 00:00:00:00:00:14 |
93
+ | match.dl_vlan | 0 |
94
+ | match.dl_vlan_pcp | 0 |
95
+ | match.dl_type | 2048 |
96
+ | match.nw_tos | 0 |
97
+ | match.nw_proto | 1 |
98
+ | match.nw_src | 10.0.0.0 |
99
+ | match.nw_src.prefixlen | 8 |
100
+ | match.nw_dst | 20.0.0.0 |
101
+ | match.nw_dst.prefixlen | 8 |
102
+ | match.tp_src | 8 |
103
+ | match.tp_dst | 0 |
104
+ | cookie | 0 |
105
+ | command | modify_strict |
106
+ | idle_timeout | 0 |
107
+ | hard_timeout | 0 |
108
+ | priority | 65535 |
109
+ | buffer_id | 4294967295 |
110
+ | out_port | 65535 |
111
+ | flags | [:send_flow_rem] |
112
+ | actions.length | 12 |
113
+ | actions.first.class | Pio::SetVlanVid |
114
+ | actions.first.vlan_id | 10 |
115
+
116
+ Scenario: flow_mod_delete.raw
117
+ Given a packet data file "flow_mod_delete.raw"
118
+ When I try to parse the file with "FlowMod" class
119
+ Then it should finish successfully
120
+ And the parsed data have the following field and value:
121
+ | field | value |
122
+ | ofp_version | 1 |
123
+ | message_type | 14 |
124
+ | message_length | 72 |
125
+ | transaction_id | 0 |
126
+ | xid | 0 |
127
+ | match.wildcards | {:nw_src=>24, :nw_dst=>24} |
128
+ | match.in_port | 1 |
129
+ | match.dl_src | 00:00:00:00:00:0a |
130
+ | match.dl_dst | 00:00:00:00:00:00 |
131
+ | match.dl_vlan | 0 |
132
+ | match.dl_vlan_pcp | 0 |
133
+ | match.dl_type | 2048 |
134
+ | match.nw_tos | 0 |
135
+ | match.nw_proto | 1 |
136
+ | match.nw_src | 10.0.0.0 |
137
+ | match.nw_src.prefixlen | 8 |
138
+ | match.nw_dst | 20.0.0.0 |
139
+ | match.nw_dst.prefixlen | 8 |
140
+ | match.tp_src | 8 |
141
+ | match.tp_dst | 0 |
142
+ | cookie | 0 |
143
+ | command | delete |
144
+ | idle_timeout | 0 |
145
+ | hard_timeout | 0 |
146
+ | priority | 65535 |
147
+ | buffer_id | 4294967295 |
148
+ | out_port | 65535 |
149
+ | flags | [] |
150
+ | actions | [] |
151
+
152
+ Scenario: flow_mod_delete_strict.raw
153
+ Given a packet data file "flow_mod_delete_strict.raw"
154
+ When I try to parse the file with "FlowMod" class
155
+ Then it should finish successfully
156
+ And the parsed data have the following field and value:
157
+ | field | value |
158
+ | ofp_version | 1 |
159
+ | message_type | 14 |
160
+ | message_length | 72 |
161
+ | transaction_id | 0 |
162
+ | xid | 0 |
163
+ | match.wildcards | {:nw_src=>24, :nw_dst=>24} |
164
+ | match.in_port | 1 |
165
+ | match.dl_src | 00:00:00:00:00:0a |
166
+ | match.dl_dst | 00:00:00:00:00:14 |
167
+ | match.dl_vlan | 0 |
168
+ | match.dl_vlan_pcp | 0 |
169
+ | match.dl_type | 2048 |
170
+ | match.nw_tos | 0 |
171
+ | match.nw_proto | 1 |
172
+ | match.nw_src | 10.0.0.0 |
173
+ | match.nw_src.prefixlen | 8 |
174
+ | match.nw_dst | 20.0.0.0 |
175
+ | match.nw_dst.prefixlen | 8 |
176
+ | match.tp_src | 8 |
177
+ | match.tp_dst | 0 |
178
+ | cookie | 1 |
179
+ | command | delete_strict |
180
+ | idle_timeout | 0 |
181
+ | hard_timeout | 0 |
182
+ | priority | 65535 |
183
+ | buffer_id | 4294967295 |
184
+ | out_port | 65535 |
185
+ | flags | [] |
186
+ | actions | [] |
@@ -3,3 +3,12 @@ Feature: Pio::Hello.read
3
3
  Given a packet data file "hello.raw"
4
4
  When I try to parse the file with "Hello" class
5
5
  Then it should finish successfully
6
+ And the parsed data have the following field and value:
7
+ | field | value |
8
+ | class | Pio::Hello |
9
+ | ofp_version | 1 |
10
+ | message_type | 0 |
11
+ | message_length | 8 |
12
+ | transaction_id | 23 |
13
+ | xid | 23 |
14
+ | body | |
Binary file
@@ -3,3 +3,16 @@ Feature: Pio::PacketIn.read
3
3
  Given a packet data file "packet_in.raw"
4
4
  When I try to parse the file with "PacketIn" class
5
5
  Then it should finish successfully
6
+ And the parsed data have the following field and value:
7
+ | field | value |
8
+ | class | Pio::PacketIn |
9
+ | ofp_version | 1 |
10
+ | message_type | 10 |
11
+ | message_length | 78 |
12
+ | transaction_id | 0 |
13
+ | xid | 0 |
14
+ | buffer_id | 4294967040 |
15
+ | total_len | 60 |
16
+ | in_port | 1 |
17
+ | reason | no_match |
18
+ | data.length | 60 |