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
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class FlowMod < Message
|
6
|
+
match :match
|
7
|
+
uint64 :cookie, initial_value: 0
|
8
|
+
enum16 :command, list: [:add, :modify, :modify_strict, :delete, :delete_strict]
|
9
|
+
uint16 :idle_timeout, initial_value: 0
|
10
|
+
uint16 :hard_timeout, initial_value: 0
|
11
|
+
uint16 :priority, initial_value: 0
|
12
|
+
enum32 :buffer_id, list: {none: 0xffffffff}, initial_value: -> { :none }
|
13
|
+
port_number :out_port, initial_value: (lambda do
|
14
|
+
/^delete/ =~ command.to_s ? :none : 0
|
15
|
+
end)
|
16
|
+
flags16 :flags, list: [:send_flow_removed, :check_overlapping, :emergency]
|
17
|
+
actions :actions, length: -> { len - actions.rel_offset }
|
18
|
+
|
19
|
+
def body_length
|
20
|
+
64 + actions.to_binary_s.length
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class FlowRemoved < Message
|
6
|
+
REASONS = [:idle_timeout, :hard_timeout, :delete]
|
7
|
+
|
8
|
+
match :match
|
9
|
+
uint64 :cookie, initial_value: 0
|
10
|
+
uint16 :priority, initial_value: 0
|
11
|
+
enum8 :reason, list: REASONS
|
12
|
+
uint8 :padding
|
13
|
+
hide :padding
|
14
|
+
uint32 :duration_seconds, initial_value: 0
|
15
|
+
uint32 :duration_nanoseconds, initial_value: 0
|
16
|
+
uint16 :idle_timeout, initial_value: 0
|
17
|
+
uint16 :padding2
|
18
|
+
hide :padding2
|
19
|
+
uint64 :packet_count, initial_value: 0
|
20
|
+
uint64 :byte_count, initial_value: 0
|
21
|
+
|
22
|
+
def body_length
|
23
|
+
80
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class GetConfigReply < Message
|
6
|
+
FLAGS = [:fragments_normal, :fragments_drop, :fragments_reassemble]
|
7
|
+
|
8
|
+
enum16 :flags, list: FLAGS
|
9
|
+
uint16 :miss_send_length, initial_value: 0
|
10
|
+
|
11
|
+
def body_length
|
12
|
+
4
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
(Dir[File.expand_path '../../helpers/**/*.rb', __FILE__] +
|
2
|
+
Dir[File.expand_path '../../structs/**/*.rb', __FILE__] +
|
3
|
+
Dir[File.expand_path '../../actions/**/*.rb', __FILE__] +
|
4
|
+
Dir[File.expand_path '../statistics/**/*.rb', __FILE__]).each do |file|
|
5
|
+
require file
|
6
|
+
end
|
7
|
+
|
8
|
+
# TODO: use OFPT_, OFPP_, OFPQ_, ... in place of Symbols?
|
9
|
+
# check: https://github.com/noxrepo/pox/blob/carp/pox/openflow/libopenflow_01.py
|
10
|
+
# -> see decorators
|
11
|
+
# ruby decorators: https://github.com/fredwu/ruby_decorators
|
12
|
+
|
13
|
+
module OpenFlow
|
14
|
+
module Protocol
|
15
|
+
class Message < SuperclassBase
|
16
|
+
OFP_VERSION = 0x1
|
17
|
+
HEADER_LENGTH = 8
|
18
|
+
TYPES = [
|
19
|
+
:hello,
|
20
|
+
:error,
|
21
|
+
:echo_request,
|
22
|
+
:echo_reply,
|
23
|
+
:vendor,
|
24
|
+
:features_request,
|
25
|
+
:features_reply,
|
26
|
+
:get_config_request,
|
27
|
+
:get_config_reply,
|
28
|
+
:set_config,
|
29
|
+
:packet_in,
|
30
|
+
:flow_removed,
|
31
|
+
:port_status,
|
32
|
+
:packet_out,
|
33
|
+
:flow_mod,
|
34
|
+
:port_mod,
|
35
|
+
:statistics_request,
|
36
|
+
:statistics_reply,
|
37
|
+
:barrier_request,
|
38
|
+
:barrier_reply,
|
39
|
+
:queue_get_config_request,
|
40
|
+
:queue_get_config_reply
|
41
|
+
]
|
42
|
+
|
43
|
+
uint8 :version, asserted_value: OFP_VERSION
|
44
|
+
enum8 :type, list: TYPES, asserted_value: -> { type_str.to_sym }
|
45
|
+
uint16 :len, value: -> { HEADER_LENGTH + body_length }
|
46
|
+
uint32 :xid, initial_value: 0
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'packet-protocols'
|
2
|
+
require 'openflow-protocol/messages/message'
|
3
|
+
|
4
|
+
module OpenFlow
|
5
|
+
module Protocol
|
6
|
+
class PacketIn < Message
|
7
|
+
REASONS = [:no_match, :action]
|
8
|
+
|
9
|
+
enum32 :buffer_id, list: {none: 0xffffffff}, initial_value: -> { :none }
|
10
|
+
uint16 :total_length, value: -> { data.length }
|
11
|
+
port_number :in_port
|
12
|
+
enum8 :reason, list: REASONS
|
13
|
+
uint8 :padding
|
14
|
+
hide :padding
|
15
|
+
string :data, read_length: :total_length
|
16
|
+
|
17
|
+
def body_length
|
18
|
+
10 + data.length
|
19
|
+
end
|
20
|
+
|
21
|
+
def parsed_data
|
22
|
+
@parsed_data ||= Ethernet.read(data)
|
23
|
+
@parsed_data
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class PacketOut < Message
|
6
|
+
enum32 :buffer_id, list: {none: 0xffffffff}, initial_value: -> { :none }
|
7
|
+
port_number :in_port
|
8
|
+
uint16 :actions_length, value: -> { actions.to_binary_s.length }
|
9
|
+
actions :actions, length: -> { actions_length }
|
10
|
+
string :data, read_length: -> { len - data.rel_offset }
|
11
|
+
|
12
|
+
def body_length
|
13
|
+
8 + actions_length + data.length
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
Dir[File.expand_path '../*.rb', __FILE__].each do |file|
|
4
|
+
require file
|
5
|
+
end
|
6
|
+
|
7
|
+
module OpenFlow
|
8
|
+
module Protocol
|
9
|
+
class Parser
|
10
|
+
def self.read(io)
|
11
|
+
io = StringIO.new(io) if io.is_a?(String)
|
12
|
+
|
13
|
+
header = io.readpartial(Message::HEADER_LENGTH)
|
14
|
+
|
15
|
+
type = Message::TYPES[header[1].unpack('C')[0].to_i]
|
16
|
+
klass_name = type.to_s.split('_').map(&:capitalize).join
|
17
|
+
klass = OpenFlow::Protocol.const_get(klass_name)
|
18
|
+
length = header[2..3].unpack('S>')[0].to_i
|
19
|
+
|
20
|
+
body = io.readpartial(length - Message::HEADER_LENGTH)
|
21
|
+
|
22
|
+
klass.read(header + body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class PortMod < Message
|
6
|
+
port_number :port_number
|
7
|
+
mac_address :hardware_address
|
8
|
+
flags32 :config, list: PhysicalPort::CONFIG
|
9
|
+
flags32 :mask, list: PhysicalPort::CONFIG
|
10
|
+
flags32 :advertise, list: PhysicalPort::FEATURES
|
11
|
+
uint32 :padding
|
12
|
+
hide :padding
|
13
|
+
|
14
|
+
def body_length
|
15
|
+
24
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class PortStatus < Message
|
6
|
+
REASONS = [:add, :delete, :modify]
|
7
|
+
|
8
|
+
enum8 :reason, list: REASONS
|
9
|
+
uint56 :padding
|
10
|
+
hide :padding
|
11
|
+
physical_port :desc
|
12
|
+
|
13
|
+
def body_length
|
14
|
+
56
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class QueueGetConfigReply < Message
|
6
|
+
port_number_strict :port
|
7
|
+
uint48 :padding
|
8
|
+
hide :padding
|
9
|
+
array :queues,
|
10
|
+
type: :packet_queue,
|
11
|
+
read_until: :eof
|
12
|
+
|
13
|
+
def body_length
|
14
|
+
8 + queues.to_binary_s.length
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'openflow-protocol/messages/message'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class Statistics < Message
|
6
|
+
STATISTICS_TYPES = [
|
7
|
+
:description,
|
8
|
+
:flow,
|
9
|
+
:aggregate,
|
10
|
+
:table,
|
11
|
+
:port,
|
12
|
+
:queue
|
13
|
+
]
|
14
|
+
STATISTICS_TYPES[0xffff] = :vendor
|
15
|
+
|
16
|
+
def flags_list
|
17
|
+
self.class.const_get(:FLAGS)
|
18
|
+
end
|
19
|
+
|
20
|
+
enum16 :statistic_type, list: STATISTICS_TYPES
|
21
|
+
flags16 :flags, list: -> { flags_list }
|
22
|
+
|
23
|
+
def body_length
|
24
|
+
4 + statistics.to_binary_s.length
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bindata'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class AggregateStatisticsReply < BinData::Record
|
6
|
+
endian :big
|
7
|
+
uint64 :packet_count, initial_value: 0
|
8
|
+
uint64 :byte_count, initial_value: 0
|
9
|
+
uint32 :flow_count, initial_value: 0
|
10
|
+
uint32 :padding
|
11
|
+
hide :padding
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'bindata'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class DescriptionStatistics < BinData::Record
|
6
|
+
DESCRIPTION_LENGTH = 256
|
7
|
+
SERIAL_NUMBER_LENGTH = 32
|
8
|
+
|
9
|
+
endian :big
|
10
|
+
string :manufacturer_description,
|
11
|
+
length: DESCRIPTION_LENGTH,
|
12
|
+
trim_padding: true,
|
13
|
+
initial_value: ''
|
14
|
+
string :hardware_description,
|
15
|
+
length: DESCRIPTION_LENGTH,
|
16
|
+
trim_padding: true,
|
17
|
+
initial_value: ''
|
18
|
+
string :software_description,
|
19
|
+
length: DESCRIPTION_LENGTH,
|
20
|
+
trim_padding: true,
|
21
|
+
initial_value: ''
|
22
|
+
string :serial_number,
|
23
|
+
length: SERIAL_NUMBER_LENGTH,
|
24
|
+
trim_padding: true,
|
25
|
+
initial_value: ''
|
26
|
+
string :datapath_description,
|
27
|
+
length: DESCRIPTION_LENGTH,
|
28
|
+
trim_padding: true,
|
29
|
+
initial_value: ''
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'openflow-protocol/messages/statistics/table_statistics'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class FlowStatisticsReply < BinData::Record
|
6
|
+
endian :big
|
7
|
+
uint16 :len, initial_value: -> { 88 + actions.to_binary_s.length }
|
8
|
+
enum8 :table_id, list: TableStatistics::TABLE_IDS, initial_value: -> { :all }
|
9
|
+
uint8 :padding
|
10
|
+
hide :padding
|
11
|
+
match :match
|
12
|
+
uint32 :duration_seconds, initial_value: 0
|
13
|
+
uint32 :duration_nanoseconds, initial_value: 0
|
14
|
+
uint16 :priority, initial_value: 0
|
15
|
+
uint16 :idle_timeout, initial_value: 0
|
16
|
+
uint16 :hard_timeout, initial_value: 0
|
17
|
+
uint48 :padding2
|
18
|
+
hide :padding2
|
19
|
+
uint64 :cookie, initial_value: 0
|
20
|
+
uint64 :packet_count, initial_value: 0
|
21
|
+
uint64 :byte_count, initial_value: 0
|
22
|
+
actions :actions, length: -> { len - actions.rel_offset }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'openflow-protocol/messages/statistics/table_statistics'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class FlowStatisticsRequest < BinData::Record
|
6
|
+
endian :big
|
7
|
+
match :match
|
8
|
+
enum8 :table_id, list: TableStatistics::TABLE_IDS, initial_value: -> { :all }
|
9
|
+
uint8 :padding
|
10
|
+
hide :padding
|
11
|
+
port_number :out_port, initial_value: -> { :none }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'openflow-protocol/structs/port_number'
|
2
|
+
|
3
|
+
module OpenFlow
|
4
|
+
module Protocol
|
5
|
+
class PortStatisticsReply < BinData::Record
|
6
|
+
endian :big
|
7
|
+
port_number :port_number, initial_value: 0
|
8
|
+
uint48 :padding
|
9
|
+
hide :padding
|
10
|
+
uint64 :receive_packets, initial_value: 0
|
11
|
+
uint64 :transmit_packets, initial_value: 0
|
12
|
+
uint64 :receive_bytes, initial_value: 0
|
13
|
+
uint64 :transmit_bytes, initial_value: 0
|
14
|
+
uint64 :receive_dropped, initial_value: 0
|
15
|
+
uint64 :transmit_dropped, initial_value: 0
|
16
|
+
uint64 :receive_errors, initial_value: 0
|
17
|
+
uint64 :transmit_errors, initial_value: 0
|
18
|
+
uint64 :receive_frame_errors, initial_value: 0
|
19
|
+
uint64 :receive_overrun_errors, initial_value: 0
|
20
|
+
uint64 :receive_crc_errors, initial_value: 0
|
21
|
+
uint64 :collisions, initial_value: 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|