Module: Havox::FieldParser
- Included in:
- OpenFlow10::OVS::Actions, OpenFlow10::OVS::Matches, OpenFlow10::RouteFlow::Actions, OpenFlow10::RouteFlow::Matches, OpenFlow10::Trema::Actions, OpenFlow10::Trema::Matches
- Defined in:
- lib/havox/modules/field_parser.rb
Instance Method Summary collapse
- #basic_action(action, arg_a = nil, arg_b = nil) ⇒ Object
- #parsed_ipv4(ip_integer) ⇒ Object
- #raise_unknown_action(obj) ⇒ Object
Instance Method Details
#basic_action(action, arg_a = nil, arg_b = nil) ⇒ Object
11 12 13 |
# File 'lib/havox/modules/field_parser.rb', line 11 def basic_action(action, arg_a = nil, arg_b = nil) { action: action, arg_a: arg_a, arg_b: arg_b } end |
#parsed_ipv4(ip_integer) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/havox/modules/field_parser.rb', line 3 def parsed_ipv4(ip_integer) ip_integer = ip_integer.to_i value = ip_integer.positive? ? ip_integer : (2**32 - ip_integer.abs) # Handles two's complement integers. bits = value.to_s(2).rjust(32, '0') # Transforms the string number into a 32-bit sequence. octets = bits.scan(/\d{8}/).map { |octet_bits| octet_bits.to_i(2) } # Splits the sequence into decimal octets. octets.join('.') # Returns the joined octets. end |
#raise_unknown_action(obj) ⇒ Object
15 16 17 18 19 |
# File 'lib/havox/modules/field_parser.rb', line 15 def raise_unknown_action(obj) raise Havox::UnknownAction, "Unable to translate action #{obj[:action]} with arguments A:" \ " #{obj[:arg_a]} and B: #{obj[:arg_b]}, respectively" end |