Class: SDN::Message::UnknownMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/sdn/message.rb

Overview

Fallback wrapper for frames whose opcode is unknown to the library.

Messages after this point were decoded from UAI+ communication and may be named wrong.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = []) ⇒ UnknownMessage

Creates a message wrapper for an unrecognized protocol opcode.

Parameters:

  • params (<Integer>) (defaults to: [])

    raw unparsed parameter bytes



294
295
296
297
# File 'lib/sdn/message.rb', line 294

def initialize(params = [], **)
  super(**)
  self.params = params
end

Instance Attribute Details

#msgInteger?

Unknown protocol opcode captured for this message.

Returns:

  • (Integer, nil)


284
285
286
# File 'lib/sdn/message.rb', line 284

def msg
  @msg
end

#params<Integer>?

Raw undecoded parameter bytes for this message.

Returns:

  • (<Integer>, nil)


289
290
291
# File 'lib/sdn/message.rb', line 289

def params
  @params
end

Instance Method Details

#class_inspectString?

Returns the protocol-specific portion of the inspection string.

Returns:

  • (String, nil)


314
315
316
317
318
319
320
321
322
323
# File 'lib/sdn/message.rb', line 314

def class_inspect
  result = if instance_of?(UnknownMessage)
             format(", @msg=%02xh", msg)
           else
             super || ""
           end
  return result if params.empty?

  result << ", @params=#{params.map { |b| format("%02x", b) }.join(" ")}"
end

#serializeString

Serializes an unknown message only when raw parameters are present.

Returns:

  • (String)

    binary protocol frame

Raises:

  • (NotImplementedError)

    when parameters are unavailable



306
307
308
309
310
311
# File 'lib/sdn/message.rb', line 306

def serialize
  # prevent serializing something we don't know
  raise NotImplementedError unless params

  super
end