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.
- checksums.yaml +4 -4
- data/lib/openflow-protocol.rb +2 -1
- data/lib/openflow-protocol/actions/action.rb +30 -0
- data/lib/openflow-protocol/actions/action_enqueue.rb +16 -0
- data/lib/openflow-protocol/actions/action_output.rb +14 -0
- data/lib/openflow-protocol/actions/action_set_destination_port.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_ip_destination.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_ip_source.rb +13 -0
- data/lib/openflow-protocol/actions/action_set_ip_tos.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_mac_destination.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_mac_source.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_source_port.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_vlan_id.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_vlan_pcp.rb +15 -0
- data/lib/openflow-protocol/actions/action_strip_vlan.rb +14 -0
- data/lib/openflow-protocol/actions/action_vendor.rb +13 -0
- data/lib/openflow-protocol/actions/actions.rb +9 -0
- data/lib/openflow-protocol/helpers/array_of_subclasses.rb +42 -0
- data/lib/openflow-protocol/helpers/superclass_base.rb +26 -0
- data/lib/openflow-protocol/messages/barrier_reply.rb +7 -0
- data/lib/openflow-protocol/messages/barrier_request.rb +7 -0
- data/lib/openflow-protocol/messages/echo_reply.rb +13 -0
- data/lib/openflow-protocol/messages/echo_request.rb +13 -0
- data/lib/openflow-protocol/messages/error.rb +69 -0
- data/lib/openflow-protocol/messages/features_reply.rb +44 -0
- data/lib/openflow-protocol/messages/features_request.rb +7 -0
- data/lib/openflow-protocol/messages/flow_mod.rb +24 -0
- data/lib/openflow-protocol/messages/flow_removed.rb +27 -0
- data/lib/openflow-protocol/messages/get_config_reply.rb +16 -0
- data/lib/openflow-protocol/messages/get_config_request.rb +7 -0
- data/lib/openflow-protocol/messages/hello.rb +7 -0
- data/lib/openflow-protocol/messages/message.rb +49 -0
- data/lib/openflow-protocol/messages/packet_in.rb +27 -0
- data/lib/openflow-protocol/messages/packet_out.rb +17 -0
- data/lib/openflow-protocol/messages/parser.rb +26 -0
- data/lib/openflow-protocol/messages/port_mod.rb +19 -0
- data/lib/openflow-protocol/messages/port_status.rb +18 -0
- data/lib/openflow-protocol/messages/queue_get_config_reply.rb +18 -0
- data/lib/openflow-protocol/messages/queue_get_config_request.rb +15 -0
- data/lib/openflow-protocol/messages/set_config.rb +7 -0
- data/lib/openflow-protocol/messages/statistics.rb +28 -0
- data/lib/openflow-protocol/messages/statistics/aggregate_statistics_reply.rb +14 -0
- data/lib/openflow-protocol/messages/statistics/aggregate_statistics_request.rb +7 -0
- data/lib/openflow-protocol/messages/statistics/description_statistics.rb +32 -0
- data/lib/openflow-protocol/messages/statistics/flow_statistics_reply.rb +25 -0
- data/lib/openflow-protocol/messages/statistics/flow_statistics_request.rb +14 -0
- data/lib/openflow-protocol/messages/statistics/port_statistics_reply.rb +24 -0
- data/lib/openflow-protocol/messages/statistics/port_statistics_request.rb +12 -0
- data/lib/openflow-protocol/messages/statistics/queue_statistics_reply.rb +16 -0
- data/lib/openflow-protocol/messages/statistics/queue_statistics_request.rb +13 -0
- data/lib/openflow-protocol/messages/statistics/table_statistics.rb +20 -0
- data/lib/openflow-protocol/messages/statistics/vendor_statistics.rb +11 -0
- data/lib/openflow-protocol/messages/statistics_reply.rb +26 -0
- data/lib/openflow-protocol/messages/statistics_request.rb +18 -0
- data/lib/openflow-protocol/messages/vendor.rb +14 -0
- data/lib/openflow-protocol/structs/match.rb +106 -0
- data/lib/openflow-protocol/structs/packet_queue.rb +14 -0
- data/lib/openflow-protocol/structs/physical_port.rb +50 -0
- data/lib/openflow-protocol/structs/port_number.rb +49 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_properties.rb +9 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property.rb +20 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property_min_rate.rb +30 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property_none.rb +7 -0
- data/lib/openflow-protocol/version.rb +1 -1
- data/spec/actions/action_enqueue_spec.rb +4 -6
- data/spec/actions/action_output_spec.rb +4 -6
- data/spec/actions/action_set_destination_port_spec.rb +4 -6
- data/spec/actions/action_set_ip_destination_spec.rb +4 -6
- data/spec/actions/action_set_ip_source_spec.rb +4 -6
- data/spec/actions/action_set_ip_tos_spec.rb +4 -6
- data/spec/actions/action_set_mac_destination_spec.rb +4 -6
- data/spec/actions/action_set_mac_source_spec.rb +4 -6
- data/spec/actions/action_set_source_port_spec.rb +4 -6
- data/spec/actions/action_set_vlan_id_spec.rb +4 -6
- data/spec/actions/action_set_vlan_pcp_spec.rb +4 -6
- data/spec/actions/action_strip_vlan_spec.rb +3 -5
- data/spec/actions/action_vendor_spec.rb +4 -6
- data/spec/actions/actions_spec.rb +6 -8
- data/spec/messages/barrier_reply_spec.rb +9 -11
- data/spec/messages/barrier_request_spec.rb +9 -11
- data/spec/messages/echo_reply_spec.rb +13 -15
- data/spec/messages/echo_request_spec.rb +16 -18
- data/spec/messages/error_spec.rb +23 -20
- data/spec/messages/features_reply_spec.rb +11 -13
- data/spec/messages/features_request_spec.rb +9 -11
- data/spec/messages/flow_mod_spec.rb +12 -14
- data/spec/messages/flow_removed_spec.rb +9 -11
- data/spec/messages/get_config_reply_spec.rb +9 -11
- data/spec/messages/get_config_request_spec.rb +9 -11
- data/spec/messages/hello_spec.rb +9 -11
- data/spec/messages/packet_in_spec.rb +9 -11
- data/spec/messages/packet_out_spec.rb +10 -12
- data/spec/messages/parser_spec.rb +7 -9
- data/spec/messages/port_mod_spec.rb +9 -11
- data/spec/messages/port_status_spec.rb +10 -12
- data/spec/messages/queue_get_config_reply_spec.rb +9 -11
- data/spec/messages/queue_get_config_request_spec.rb +9 -11
- data/spec/messages/set_config_spec.rb +9 -11
- data/spec/messages/statistics/aggregate_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/aggregate_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/description_statistics_spec.rb +11 -9
- data/spec/messages/statistics/flow_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/flow_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/port_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/port_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/queue_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/queue_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/table_statistics_spec.rb +4 -6
- data/spec/messages/statistics/vendor_statistics_spec.rb +4 -6
- data/spec/messages/statistics_reply_spec.rb +62 -64
- data/spec/messages/statistics_request_spec.rb +45 -47
- data/spec/messages/vendor_spec.rb +13 -15
- data/spec/spec_helper.rb +1 -1
- data/spec/structs/match_spec.rb +7 -9
- data/spec/structs/packet_queue_spec.rb +5 -7
- data/spec/structs/physical_port_spec.rb +16 -18
- data/spec/structs/port_number_spec.rb +11 -13
- data/spec/structs/queue_properties/queue_properties_spec.rb +5 -7
- data/spec/structs/queue_properties/queue_property_min_rate_spec.rb +5 -7
- data/spec/structs/queue_properties/queue_property_none_spec.rb +3 -5
- metadata +78 -64
- data/lib/actions/action.rb +0 -26
- data/lib/actions/action_enqueue.rb +0 -12
- data/lib/actions/action_output.rb +0 -10
- data/lib/actions/action_set_destination_port.rb +0 -3
- data/lib/actions/action_set_ip_destination.rb +0 -3
- data/lib/actions/action_set_ip_source.rb +0 -9
- data/lib/actions/action_set_ip_tos.rb +0 -11
- data/lib/actions/action_set_mac_destination.rb +0 -3
- data/lib/actions/action_set_mac_source.rb +0 -11
- data/lib/actions/action_set_source_port.rb +0 -11
- data/lib/actions/action_set_vlan_id.rb +0 -11
- data/lib/actions/action_set_vlan_pcp.rb +0 -11
- data/lib/actions/action_strip_vlan.rb +0 -10
- data/lib/actions/action_vendor.rb +0 -9
- data/lib/actions/actions.rb +0 -5
- data/lib/helpers/array_of_subclasses.rb +0 -38
- data/lib/helpers/superclass_base.rb +0 -24
- data/lib/messages/barrier_reply.rb +0 -3
- data/lib/messages/barrier_request.rb +0 -3
- data/lib/messages/echo_reply.rb +0 -9
- data/lib/messages/echo_request.rb +0 -9
- data/lib/messages/error.rb +0 -61
- data/lib/messages/features_reply.rb +0 -40
- data/lib/messages/features_request.rb +0 -3
- data/lib/messages/flow_mod.rb +0 -20
- data/lib/messages/flow_removed.rb +0 -23
- data/lib/messages/get_config_reply.rb +0 -12
- data/lib/messages/get_config_request.rb +0 -3
- data/lib/messages/hello.rb +0 -3
- data/lib/messages/message.rb +0 -45
- data/lib/messages/packet_in.rb +0 -23
- data/lib/messages/packet_out.rb +0 -13
- data/lib/messages/parser.rb +0 -22
- data/lib/messages/port_mod.rb +0 -15
- data/lib/messages/port_status.rb +0 -14
- data/lib/messages/queue_get_config_reply.rb +0 -14
- data/lib/messages/queue_get_config_request.rb +0 -11
- data/lib/messages/set_config.rb +0 -3
- data/lib/messages/statistics.rb +0 -24
- data/lib/messages/statistics/aggregate_statistics_reply.rb +0 -10
- data/lib/messages/statistics/aggregate_statistics_request.rb +0 -3
- data/lib/messages/statistics/description_statistics.rb +0 -28
- data/lib/messages/statistics/flow_statistics_reply.rb +0 -21
- data/lib/messages/statistics/flow_statistics_request.rb +0 -10
- data/lib/messages/statistics/port_statistics_reply.rb +0 -20
- data/lib/messages/statistics/port_statistics_request.rb +0 -8
- data/lib/messages/statistics/queue_statistics_reply.rb +0 -12
- data/lib/messages/statistics/queue_statistics_request.rb +0 -9
- data/lib/messages/statistics/table_statistics.rb +0 -16
- data/lib/messages/statistics/vendor_statistics.rb +0 -7
- data/lib/messages/statistics_reply.rb +0 -22
- data/lib/messages/statistics_request.rb +0 -14
- data/lib/messages/vendor.rb +0 -10
- data/lib/structs/match.rb +0 -102
- data/lib/structs/packet_queue.rb +0 -10
- data/lib/structs/physical_port.rb +0 -46
- data/lib/structs/port_number.rb +0 -45
- data/lib/structs/queue_properties/queue_properties.rb +0 -5
- data/lib/structs/queue_properties/queue_property.rb +0 -16
- data/lib/structs/queue_properties/queue_property_min_rate.rb +0 -26
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b01ffc73397a6ba7679ac349cf7f32d7a9a790f0
|
4
|
+
data.tar.gz: 51c39851e3ee81bf59879c4dfa76b4260144b2bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51bc3a9d20999dab830ad19ed61a1c76be940eddea2fd11edcfef446f34e8ad3ab5ed8c3eacd9b8569c032527603d245ee6e08d82699e844f157407731e580f5
|
7
|
+
data.tar.gz: 4395f5da25e3339799305a8d791f84fb842fbbadfb06a5a075bf9fe08b11144e6b48166ce750cee13fa7251bf527f8619129e4120107ffc6b3bf3ad0cfad558b
|
data/lib/openflow-protocol.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
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,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,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
|