Class: OpenFlow::Controller::Switch

Inherits:
Object
  • Object
show all
Includes:
Protocol
Defined in:
lib/openflow-controller/switch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, socket) ⇒ Switch

Returns a new instance of Switch.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/openflow-controller/switch.rb', line 10

def initialize(controller, socket)
  @controller = controller
  @socket     = socket
  begin
    exchange_hello_messages
    exchange_echo_messages
    exchange_features_messages
  rescue => exception
    controller.logger.debug "Switch error: #{exception}."
    raise exception
  end
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



8
9
10
# File 'lib/openflow-controller/switch.rb', line 8

def controller
  @controller
end

#features_replyObject (readonly)

Returns the value of attribute features_reply.



8
9
10
# File 'lib/openflow-controller/switch.rb', line 8

def features_reply
  @features_reply
end

Instance Method Details

#datapath_idObject



31
32
33
# File 'lib/openflow-controller/switch.rb', line 31

def datapath_id
  @features_reply.datapath_id
end

#receiveObject



27
28
29
# File 'lib/openflow-controller/switch.rb', line 27

def receive
  Parser.read @socket
end

#send(msg) ⇒ Object



23
24
25
# File 'lib/openflow-controller/switch.rb', line 23

def send(msg)
  @socket.write msg.to_binary_s
end