openflow-protocol 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openflow-protocol.rb +2 -1
  3. data/lib/openflow-protocol/actions/action.rb +30 -0
  4. data/lib/openflow-protocol/actions/action_enqueue.rb +16 -0
  5. data/lib/openflow-protocol/actions/action_output.rb +14 -0
  6. data/lib/openflow-protocol/actions/action_set_destination_port.rb +7 -0
  7. data/lib/openflow-protocol/actions/action_set_ip_destination.rb +7 -0
  8. data/lib/openflow-protocol/actions/action_set_ip_source.rb +13 -0
  9. data/lib/openflow-protocol/actions/action_set_ip_tos.rb +15 -0
  10. data/lib/openflow-protocol/actions/action_set_mac_destination.rb +7 -0
  11. data/lib/openflow-protocol/actions/action_set_mac_source.rb +15 -0
  12. data/lib/openflow-protocol/actions/action_set_source_port.rb +15 -0
  13. data/lib/openflow-protocol/actions/action_set_vlan_id.rb +15 -0
  14. data/lib/openflow-protocol/actions/action_set_vlan_pcp.rb +15 -0
  15. data/lib/openflow-protocol/actions/action_strip_vlan.rb +14 -0
  16. data/lib/openflow-protocol/actions/action_vendor.rb +13 -0
  17. data/lib/openflow-protocol/actions/actions.rb +9 -0
  18. data/lib/openflow-protocol/helpers/array_of_subclasses.rb +42 -0
  19. data/lib/openflow-protocol/helpers/superclass_base.rb +26 -0
  20. data/lib/openflow-protocol/messages/barrier_reply.rb +7 -0
  21. data/lib/openflow-protocol/messages/barrier_request.rb +7 -0
  22. data/lib/openflow-protocol/messages/echo_reply.rb +13 -0
  23. data/lib/openflow-protocol/messages/echo_request.rb +13 -0
  24. data/lib/openflow-protocol/messages/error.rb +69 -0
  25. data/lib/openflow-protocol/messages/features_reply.rb +44 -0
  26. data/lib/openflow-protocol/messages/features_request.rb +7 -0
  27. data/lib/openflow-protocol/messages/flow_mod.rb +24 -0
  28. data/lib/openflow-protocol/messages/flow_removed.rb +27 -0
  29. data/lib/openflow-protocol/messages/get_config_reply.rb +16 -0
  30. data/lib/openflow-protocol/messages/get_config_request.rb +7 -0
  31. data/lib/openflow-protocol/messages/hello.rb +7 -0
  32. data/lib/openflow-protocol/messages/message.rb +49 -0
  33. data/lib/openflow-protocol/messages/packet_in.rb +27 -0
  34. data/lib/openflow-protocol/messages/packet_out.rb +17 -0
  35. data/lib/openflow-protocol/messages/parser.rb +26 -0
  36. data/lib/openflow-protocol/messages/port_mod.rb +19 -0
  37. data/lib/openflow-protocol/messages/port_status.rb +18 -0
  38. data/lib/openflow-protocol/messages/queue_get_config_reply.rb +18 -0
  39. data/lib/openflow-protocol/messages/queue_get_config_request.rb +15 -0
  40. data/lib/openflow-protocol/messages/set_config.rb +7 -0
  41. data/lib/openflow-protocol/messages/statistics.rb +28 -0
  42. data/lib/openflow-protocol/messages/statistics/aggregate_statistics_reply.rb +14 -0
  43. data/lib/openflow-protocol/messages/statistics/aggregate_statistics_request.rb +7 -0
  44. data/lib/openflow-protocol/messages/statistics/description_statistics.rb +32 -0
  45. data/lib/openflow-protocol/messages/statistics/flow_statistics_reply.rb +25 -0
  46. data/lib/openflow-protocol/messages/statistics/flow_statistics_request.rb +14 -0
  47. data/lib/openflow-protocol/messages/statistics/port_statistics_reply.rb +24 -0
  48. data/lib/openflow-protocol/messages/statistics/port_statistics_request.rb +12 -0
  49. data/lib/openflow-protocol/messages/statistics/queue_statistics_reply.rb +16 -0
  50. data/lib/openflow-protocol/messages/statistics/queue_statistics_request.rb +13 -0
  51. data/lib/openflow-protocol/messages/statistics/table_statistics.rb +20 -0
  52. data/lib/openflow-protocol/messages/statistics/vendor_statistics.rb +11 -0
  53. data/lib/openflow-protocol/messages/statistics_reply.rb +26 -0
  54. data/lib/openflow-protocol/messages/statistics_request.rb +18 -0
  55. data/lib/openflow-protocol/messages/vendor.rb +14 -0
  56. data/lib/openflow-protocol/structs/match.rb +106 -0
  57. data/lib/openflow-protocol/structs/packet_queue.rb +14 -0
  58. data/lib/openflow-protocol/structs/physical_port.rb +50 -0
  59. data/lib/openflow-protocol/structs/port_number.rb +49 -0
  60. data/lib/openflow-protocol/structs/queue_properties/queue_properties.rb +9 -0
  61. data/lib/openflow-protocol/structs/queue_properties/queue_property.rb +20 -0
  62. data/lib/openflow-protocol/structs/queue_properties/queue_property_min_rate.rb +30 -0
  63. data/lib/openflow-protocol/structs/queue_properties/queue_property_none.rb +7 -0
  64. data/lib/openflow-protocol/version.rb +1 -1
  65. data/spec/actions/action_enqueue_spec.rb +4 -6
  66. data/spec/actions/action_output_spec.rb +4 -6
  67. data/spec/actions/action_set_destination_port_spec.rb +4 -6
  68. data/spec/actions/action_set_ip_destination_spec.rb +4 -6
  69. data/spec/actions/action_set_ip_source_spec.rb +4 -6
  70. data/spec/actions/action_set_ip_tos_spec.rb +4 -6
  71. data/spec/actions/action_set_mac_destination_spec.rb +4 -6
  72. data/spec/actions/action_set_mac_source_spec.rb +4 -6
  73. data/spec/actions/action_set_source_port_spec.rb +4 -6
  74. data/spec/actions/action_set_vlan_id_spec.rb +4 -6
  75. data/spec/actions/action_set_vlan_pcp_spec.rb +4 -6
  76. data/spec/actions/action_strip_vlan_spec.rb +3 -5
  77. data/spec/actions/action_vendor_spec.rb +4 -6
  78. data/spec/actions/actions_spec.rb +6 -8
  79. data/spec/messages/barrier_reply_spec.rb +9 -11
  80. data/spec/messages/barrier_request_spec.rb +9 -11
  81. data/spec/messages/echo_reply_spec.rb +13 -15
  82. data/spec/messages/echo_request_spec.rb +16 -18
  83. data/spec/messages/error_spec.rb +23 -20
  84. data/spec/messages/features_reply_spec.rb +11 -13
  85. data/spec/messages/features_request_spec.rb +9 -11
  86. data/spec/messages/flow_mod_spec.rb +12 -14
  87. data/spec/messages/flow_removed_spec.rb +9 -11
  88. data/spec/messages/get_config_reply_spec.rb +9 -11
  89. data/spec/messages/get_config_request_spec.rb +9 -11
  90. data/spec/messages/hello_spec.rb +9 -11
  91. data/spec/messages/packet_in_spec.rb +9 -11
  92. data/spec/messages/packet_out_spec.rb +10 -12
  93. data/spec/messages/parser_spec.rb +7 -9
  94. data/spec/messages/port_mod_spec.rb +9 -11
  95. data/spec/messages/port_status_spec.rb +10 -12
  96. data/spec/messages/queue_get_config_reply_spec.rb +9 -11
  97. data/spec/messages/queue_get_config_request_spec.rb +9 -11
  98. data/spec/messages/set_config_spec.rb +9 -11
  99. data/spec/messages/statistics/aggregate_statistics_reply_spec.rb +4 -6
  100. data/spec/messages/statistics/aggregate_statistics_request_spec.rb +4 -6
  101. data/spec/messages/statistics/description_statistics_spec.rb +11 -9
  102. data/spec/messages/statistics/flow_statistics_reply_spec.rb +4 -6
  103. data/spec/messages/statistics/flow_statistics_request_spec.rb +4 -6
  104. data/spec/messages/statistics/port_statistics_reply_spec.rb +4 -6
  105. data/spec/messages/statistics/port_statistics_request_spec.rb +4 -6
  106. data/spec/messages/statistics/queue_statistics_reply_spec.rb +4 -6
  107. data/spec/messages/statistics/queue_statistics_request_spec.rb +4 -6
  108. data/spec/messages/statistics/table_statistics_spec.rb +4 -6
  109. data/spec/messages/statistics/vendor_statistics_spec.rb +4 -6
  110. data/spec/messages/statistics_reply_spec.rb +62 -64
  111. data/spec/messages/statistics_request_spec.rb +45 -47
  112. data/spec/messages/vendor_spec.rb +13 -15
  113. data/spec/spec_helper.rb +1 -1
  114. data/spec/structs/match_spec.rb +7 -9
  115. data/spec/structs/packet_queue_spec.rb +5 -7
  116. data/spec/structs/physical_port_spec.rb +16 -18
  117. data/spec/structs/port_number_spec.rb +11 -13
  118. data/spec/structs/queue_properties/queue_properties_spec.rb +5 -7
  119. data/spec/structs/queue_properties/queue_property_min_rate_spec.rb +5 -7
  120. data/spec/structs/queue_properties/queue_property_none_spec.rb +3 -5
  121. metadata +78 -64
  122. data/lib/actions/action.rb +0 -26
  123. data/lib/actions/action_enqueue.rb +0 -12
  124. data/lib/actions/action_output.rb +0 -10
  125. data/lib/actions/action_set_destination_port.rb +0 -3
  126. data/lib/actions/action_set_ip_destination.rb +0 -3
  127. data/lib/actions/action_set_ip_source.rb +0 -9
  128. data/lib/actions/action_set_ip_tos.rb +0 -11
  129. data/lib/actions/action_set_mac_destination.rb +0 -3
  130. data/lib/actions/action_set_mac_source.rb +0 -11
  131. data/lib/actions/action_set_source_port.rb +0 -11
  132. data/lib/actions/action_set_vlan_id.rb +0 -11
  133. data/lib/actions/action_set_vlan_pcp.rb +0 -11
  134. data/lib/actions/action_strip_vlan.rb +0 -10
  135. data/lib/actions/action_vendor.rb +0 -9
  136. data/lib/actions/actions.rb +0 -5
  137. data/lib/helpers/array_of_subclasses.rb +0 -38
  138. data/lib/helpers/superclass_base.rb +0 -24
  139. data/lib/messages/barrier_reply.rb +0 -3
  140. data/lib/messages/barrier_request.rb +0 -3
  141. data/lib/messages/echo_reply.rb +0 -9
  142. data/lib/messages/echo_request.rb +0 -9
  143. data/lib/messages/error.rb +0 -61
  144. data/lib/messages/features_reply.rb +0 -40
  145. data/lib/messages/features_request.rb +0 -3
  146. data/lib/messages/flow_mod.rb +0 -20
  147. data/lib/messages/flow_removed.rb +0 -23
  148. data/lib/messages/get_config_reply.rb +0 -12
  149. data/lib/messages/get_config_request.rb +0 -3
  150. data/lib/messages/hello.rb +0 -3
  151. data/lib/messages/message.rb +0 -45
  152. data/lib/messages/packet_in.rb +0 -23
  153. data/lib/messages/packet_out.rb +0 -13
  154. data/lib/messages/parser.rb +0 -22
  155. data/lib/messages/port_mod.rb +0 -15
  156. data/lib/messages/port_status.rb +0 -14
  157. data/lib/messages/queue_get_config_reply.rb +0 -14
  158. data/lib/messages/queue_get_config_request.rb +0 -11
  159. data/lib/messages/set_config.rb +0 -3
  160. data/lib/messages/statistics.rb +0 -24
  161. data/lib/messages/statistics/aggregate_statistics_reply.rb +0 -10
  162. data/lib/messages/statistics/aggregate_statistics_request.rb +0 -3
  163. data/lib/messages/statistics/description_statistics.rb +0 -28
  164. data/lib/messages/statistics/flow_statistics_reply.rb +0 -21
  165. data/lib/messages/statistics/flow_statistics_request.rb +0 -10
  166. data/lib/messages/statistics/port_statistics_reply.rb +0 -20
  167. data/lib/messages/statistics/port_statistics_request.rb +0 -8
  168. data/lib/messages/statistics/queue_statistics_reply.rb +0 -12
  169. data/lib/messages/statistics/queue_statistics_request.rb +0 -9
  170. data/lib/messages/statistics/table_statistics.rb +0 -16
  171. data/lib/messages/statistics/vendor_statistics.rb +0 -7
  172. data/lib/messages/statistics_reply.rb +0 -22
  173. data/lib/messages/statistics_request.rb +0 -14
  174. data/lib/messages/vendor.rb +0 -10
  175. data/lib/structs/match.rb +0 -102
  176. data/lib/structs/packet_queue.rb +0 -10
  177. data/lib/structs/physical_port.rb +0 -46
  178. data/lib/structs/port_number.rb +0 -45
  179. data/lib/structs/queue_properties/queue_properties.rb +0 -5
  180. data/lib/structs/queue_properties/queue_property.rb +0 -16
  181. data/lib/structs/queue_properties/queue_property_min_rate.rb +0 -26
  182. data/lib/structs/queue_properties/queue_property_none.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b787a021c7be6ba96d78b7f71f9d93676c709bd7
4
- data.tar.gz: 80ea8bef3b0e8fbd6783d8fdb35fb278032c9d0e
3
+ metadata.gz: b01ffc73397a6ba7679ac349cf7f32d7a9a790f0
4
+ data.tar.gz: 51c39851e3ee81bf59879c4dfa76b4260144b2bf
5
5
  SHA512:
6
- metadata.gz: 842cbdc2c9b75e80d1dbb53d853fa6c578bbc8ec05d3db6bb8450fd7be2017fb8586c1ba435410b717979e6fe95171fb8d776677c9b9a8c4a59e65e4f79ec0dc
7
- data.tar.gz: b1139123757191b1c60e00866e8543c423e324f70f49ea23e4ee8ee02fbc2ed72b13c1ae891255e6487e4c9c8cf8137028235956fed6baaf3f8dd76a5c44e47d
6
+ metadata.gz: 51bc3a9d20999dab830ad19ed61a1c76be940eddea2fd11edcfef446f34e8ad3ab5ed8c3eacd9b8569c032527603d245ee6e08d82699e844f157407731e580f5
7
+ data.tar.gz: 4395f5da25e3339799305a8d791f84fb842fbbadfb06a5a075bf9fe08b11144e6b48166ce750cee13fa7251bf527f8619129e4120107ffc6b3bf3ad0cfad558b
@@ -1 +1,2 @@
1
- require_relative 'messages/parser'
1
+ require 'openflow-protocol/version'
2
+ require 'openflow-protocol/messages/parser'
@@ -0,0 +1,30 @@
1
+ (Dir[File.expand_path '../../helpers/**/*.rb', __FILE__] +
2
+ Dir[File.expand_path '../../structs/**/*.rb', __FILE__]).each do |file|
3
+ require file
4
+ end
5
+
6
+ module OpenFlow
7
+ module Protocol
8
+ class Action < SuperclassBase
9
+ HEADER_LENGTH = 4
10
+ TYPES = [
11
+ :output,
12
+ :set_vlan_id,
13
+ :set_vlan_pcp,
14
+ :strip_vlan,
15
+ :set_mac_source, # set_dl_src
16
+ :set_mac_destination, # set_dl_dst
17
+ :set_ip_source, # set_nw_src
18
+ :set_ip_destination, # set_nw_dst
19
+ :set_ip_tos, # set_nw_tos
20
+ :set_source_port, # set_tp_src
21
+ :set_destination_port, # set_tp_dst
22
+ :enqueue
23
+ ]
24
+ TYPES[0xffff] = :vendor
25
+
26
+ enum16 :type, list: TYPES, asserted_value: -> { type_str.to_sym }
27
+ uint16 :len, value: -> { HEADER_LENGTH + body_length }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionEnqueue < Action
6
+ port_number :port
7
+ uint48 :padding
8
+ hide :padding
9
+ uint32 :queue_id, initial_value: 0
10
+
11
+ def body_length
12
+ 12
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionOutput < Action
6
+ port_number :port
7
+ uint16 :max_length, initial_value: 0xffff
8
+
9
+ def body_length
10
+ 4
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'openflow-protocol/actions/action_set_source_port'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetDestinationPort < ActionSetSourcePort; end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'openflow-protocol/actions/action_set_ip_source'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetIpDestination < ActionSetIpSource; end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetIpSource < Action
6
+ ipv4_address :ip_address
7
+
8
+ def body_length
9
+ 4
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetIpTos < Action
6
+ uint8 :tos
7
+ uint24 :padding
8
+ hide :padding
9
+
10
+ def body_length
11
+ 4
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'openflow-protocol/actions/action_set_mac_source'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetMacDestination < ActionSetMacSource; end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetMacSource < Action
6
+ mac_address :mac_address
7
+ uint48 :padding
8
+ hide :padding
9
+
10
+ def body_length
11
+ 12
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetSourcePort < Action
6
+ uint16 :port, initial_value: 0
7
+ uint16 :padding
8
+ hide :padding
9
+
10
+ def body_length
11
+ 4
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetVlanId < Action
6
+ uint16 :vlan_id, initial_value: 0
7
+ uint16 :padding
8
+ hide :padding
9
+
10
+ def body_length
11
+ 4
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionSetVlanPcp < Action
6
+ uint8 :vlan_pcp, initial_value: 0
7
+ uint24 :padding
8
+ hide :padding
9
+
10
+ def body_length
11
+ 4
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionStripVlan < Action
6
+ uint32 :padding
7
+ hide :padding
8
+
9
+ def body_length
10
+ 4
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'openflow-protocol/actions/action'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ActionVendor < Action
6
+ uint32 :vendor, initial_value: 0
7
+
8
+ def body_length
9
+ 4
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ Dir[File.expand_path '../action_*.rb', __FILE__].each do |file|
2
+ require file
3
+ end
4
+
5
+ module OpenFlow
6
+ module Protocol
7
+ class Actions < ArrayOfSubclasses; end
8
+ end
9
+ end
@@ -0,0 +1,42 @@
1
+ require 'bindata'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class ArrayOfSubclasses < BinData::Primitive
6
+ default_parameter length: 0
7
+ endian :big
8
+ string :binary, read_length: :length
9
+
10
+ def get
11
+ items = []
12
+ tmp = binary
13
+ until tmp.empty?
14
+ type_index = BinData::Uint16be.read(tmp)
15
+ type_str = types.fetch(type_index)
16
+ class_name = name + type_str.to_s.split('_').map(&:capitalize).join
17
+ klass = OpenFlow::Protocol.const_get class_name
18
+ item = klass.read(tmp)
19
+ items << item
20
+ tmp = tmp[item.len..-1]
21
+ end
22
+ items
23
+ end
24
+
25
+ def set(value)
26
+ self.binary = value.map(&:to_binary_s).join
27
+ end
28
+
29
+ private
30
+
31
+ def name
32
+ plural = self.class.to_s
33
+ return plural[0..-4] + 'y' if plural[-3..-1] == 'ies'
34
+ plural[0..-2]
35
+ end
36
+
37
+ def types
38
+ OpenFlow::Protocol.const_get(name + '::TYPES')
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ require 'bindata-contrib'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class SuperclassBase < BinData::Record
6
+ attr_reader :type_str
7
+
8
+ endian :big
9
+
10
+ def initialize_instance
11
+ super
12
+ name = self.class.name.split('::').last
13
+ if name[0..5] == 'Action'
14
+ name = name[6..-1]
15
+ elsif name[0..12] == 'QueueProperty'
16
+ name = name[13..-1]
17
+ end
18
+ @type_str = name.gsub(/([A-Z])/, '_\1')[1..-1].downcase
19
+ end
20
+
21
+ def body_length
22
+ 0
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ require 'openflow-protocol/messages/message'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class BarrierReply < Message; end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'openflow-protocol/messages/message'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class BarrierRequest < Message; end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'openflow-protocol/messages/echo_request'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class EchoReply < EchoRequest; end
6
+
7
+ class EchoRequest
8
+ def to_reply
9
+ EchoReply.new(xid: xid, data: data.dup)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'openflow-protocol/messages/message'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class EchoRequest < Message
6
+ rest :data
7
+
8
+ def body_length
9
+ data.length
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,69 @@
1
+ require 'openflow-protocol/messages/message'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class Error < Message
6
+ TYPES = [
7
+ :hello_failed,
8
+ :bad_request,
9
+ :bad_action,
10
+ :flow_mod_failed,
11
+ :port_mod_failed,
12
+ :queue_op_failed
13
+ ]
14
+ HELLO_FAILED_CODES = [:incompatible, :eperm]
15
+ BAD_REQUEST_CODES = [
16
+ :bad_version,
17
+ :bad_type,
18
+ :bad_stat,
19
+ :bad_vendor,
20
+ :bad_sub_type,
21
+ :eperm,
22
+ :bad_length,
23
+ :buffer_empty,
24
+ :buffer_unknown
25
+ ]
26
+ BAD_ACTION_CODES = [
27
+ :bad_type,
28
+ :bad_length,
29
+ :bad_vendor,
30
+ :bad_vendor_type,
31
+ :bad_out_port,
32
+ :bad_argument,
33
+ :eperm,
34
+ :too_many,
35
+ :bad_queue
36
+ ]
37
+ FLOW_MOD_FAILED_CODES = [
38
+ :all_tables_full,
39
+ :overlap,
40
+ :eperm,
41
+ :bad_emerg_timeout,
42
+ :bad_command,
43
+ :unsupported
44
+ ]
45
+ PORT_MOD_FAILED_CODES = [:bad_port, :bad_hardware_address]
46
+ QUEUE_OP_FAILED_CODES = [:bad_port, :bad_queue, :eperm]
47
+
48
+ enum16 :error_type, list: TYPES
49
+ choice :error_code, selection: -> { error_type.to_s } do
50
+ enum16 'hello_failed', list: HELLO_FAILED_CODES
51
+ enum16 'bad_request', list: BAD_REQUEST_CODES
52
+ enum16 'bad_action', list: BAD_ACTION_CODES
53
+ enum16 'flow_mod_failed', list: FLOW_MOD_FAILED_CODES
54
+ enum16 'port_mod_failed', list: PORT_MOD_FAILED_CODES
55
+ enum16 'queue_op_failed', list: QUEUE_OP_FAILED_CODES
56
+ uint16 :default
57
+ end
58
+ rest :data
59
+
60
+ def body_length
61
+ 4 + data.length
62
+ end
63
+
64
+ def parsed_data
65
+ Parser.read data.to_s
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,44 @@
1
+ require 'openflow-protocol/messages/message'
2
+
3
+ module OpenFlow
4
+ module Protocol
5
+ class FeaturesReply < Message
6
+ uint64 :datapath_id, initial_value: 0
7
+ uint32 :n_buffers, initial_value: 0
8
+ uint8 :n_tables, initial_value: 0
9
+ uint24 :padding
10
+ hide :padding
11
+ flags32 :capabilities, list: [
12
+ :flow_stats,
13
+ :table_stats,
14
+ :port_stats,
15
+ :stp,
16
+ :reserved,
17
+ :ip_reasm,
18
+ :queue_stats,
19
+ :arp_match_ip
20
+ ]
21
+ flags32 :actions, list: [
22
+ :output,
23
+ :set_vlan_vid,
24
+ :set_vlan_pcp,
25
+ :strip_vlan,
26
+ :set_dl_src,
27
+ :set_dl_dst,
28
+ :set_nw_src,
29
+ :set_nw_dst,
30
+ :set_nw_tos,
31
+ :set_tp_src,
32
+ :set_tp_dst,
33
+ :enqueue
34
+ ]
35
+ array :ports,
36
+ type: :physical_port,
37
+ initial_length: -> { (len - ports.rel_offset) / 48 }
38
+
39
+ def body_length
40
+ 24 + ports.to_binary_s.length
41
+ end
42
+ end
43
+ end
44
+ end