Class: Trema::Switch
Overview
OpenFlow switch.
Defined Under Namespace
Classes: InitError
Constant Summary collapse
- OPENFLOW_HEADER_LENGTH =
8
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
Instance Method Summary collapse
- #datapath_id ⇒ Object (also: #dpid)
- #init ⇒ Object
-
#initialize(socket) ⇒ Switch
constructor
A new instance of Switch.
- #read ⇒ Object
- #write(message) ⇒ Object
- #write_binary(binary) ⇒ Object
Constructor Details
#initialize(socket) ⇒ Switch
Returns a new instance of Switch.
16 17 18 |
# File 'lib/trema/switch.rb', line 16 def initialize(socket) @socket = socket end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
8 9 10 |
# File 'lib/trema/switch.rb', line 8 def @error_message end |
Instance Method Details
#datapath_id ⇒ Object Also known as: dpid
29 30 31 32 |
# File 'lib/trema/switch.rb', line 29 def datapath_id raise 'Switch is not initialized.' unless @features_reply @features_reply.datapath_id end |
#init ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/trema/switch.rb', line 20 def init message_to_send: Hello, message_to_receive: Hello (message_to_send: Echo::Request, message_to_receive: Echo::Reply) @features_reply = (message_to_send: Features::Request, message_to_receive: Features::Reply) self end |
#read ⇒ Object
44 45 46 |
# File 'lib/trema/switch.rb', line 44 def read OpenFlow.read read_openflow_binary end |
#write(message) ⇒ Object
35 36 37 38 |
# File 'lib/trema/switch.rb', line 35 def write() Trema.logger.debug "Sending #{.inspect}" @socket.write .to_binary end |
#write_binary(binary) ⇒ Object
40 41 42 |
# File 'lib/trema/switch.rb', line 40 def write_binary(binary) @socket.write binary end |