Sha256: c443d8b9bb7da574f2efd6258dd03aa17251aa69b35206609030106b1cbeb25a

Contents?: true

Size: 1.79 KB

Versions: 19

Compression:

Stored size: 1.79 KB

Contents

#
# Copyright (C) 2008-2013 NEC Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


require "trema/openflow-switch"


module Trema
  #
  # Hardware switch that supports OpenFlow protocol.
  #
  class HardwareSwitch
    #
    # The name of this switch
    #
    # @example
    #   switch.name #=> "My expensive OpenFlow switch"
    #
    # @return [String]
    #
    attr_reader :name


    #
    # Creates a new HardwareSwitch from {DSL::Switch}
    #
    # @example
    #   switch = Trema::HardwareSwitch.new( stanza )
    #
    # @return [HardwareSwitch]
    #
    def initialize stanza
      stanza.validate
      @name = stanza.name
      @stanza = stanza
      OpenflowSwitch.add self
    end


    #
    # Returns datapath id in long format
    #
    # @example
    #   switch.dpid_long #=> "0000000000000abc"
    #
    # @return [String]
    #
    def dpid_long
      @stanza.fetch :dpid_long
    end


    #
    # Returns datapath id prefixed with "0x"
    #
    # @example
    #   switch.dpid_short #=> "0xabc"
    #
    # @return [String]
    #
    def dpid_short
      @stanza.fetch :dpid_short
    end
  end
end


### Local variables:
### mode: Ruby
### coding: utf-8-unix
### indent-tabs-mode: nil
### End:

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
trema-0.4.6 ruby/trema/hardware-switch.rb
trema-0.4.5 ruby/trema/hardware-switch.rb
trema-0.4.4 ruby/trema/hardware-switch.rb
trema-0.4.3 ruby/trema/hardware-switch.rb
trema-0.4.2 ruby/trema/hardware-switch.rb
trema-0.4.1 ruby/trema/hardware-switch.rb
trema-0.4.0 ruby/trema/hardware-switch.rb
trema-0.3.21 ruby/trema/hardware-switch.rb
trema-0.3.20 ruby/trema/hardware-switch.rb
trema-0.3.19 ruby/trema/hardware-switch.rb
trema-0.3.18 ruby/trema/hardware-switch.rb
trema-0.3.17 ruby/trema/hardware-switch.rb
trema-0.3.16 ruby/trema/hardware-switch.rb
trema-0.3.15 ruby/trema/hardware-switch.rb
trema-0.3.14 ruby/trema/hardware-switch.rb
trema-0.3.13 ruby/trema/hardware-switch.rb
trema-0.3.12 ruby/trema/hardware-switch.rb
trema-0.3.11 ruby/trema/hardware-switch.rb
trema-0.3.10 ruby/trema/hardware-switch.rb