Class: OFSwitch

Inherits:
Object
  • Object
show all
Defined in:
lib/switch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, socket) ⇒ OFSwitch

Returns a new instance of OFSwitch.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/switch.rb', line 6

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.



4
5
6
# File 'lib/switch.rb', line 4

def controller
  @controller
end

Instance Method Details

#datapath_idObject



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

def datapath_id
  @features_reply.datapath_id
end

#receiveObject



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

def receive
  OFParser.read @socket
end

#send(msg) ⇒ Object



19
20
21
# File 'lib/switch.rb', line 19

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