Class: Port

Inherits:
Object
  • Object
show all
Defined in:
rlib/port.rb

Overview

Port class, for holding port status, and characteristics for the switches in the Switch class.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Port) initialize(port_number)

Create instance of Port

Parameters:

  • port_number (String)

    Port number on the switch.



11
12
13
14
15
# File 'rlib/port.rb', line 11

def initialize(port_number)
  @port_number = port_number
  @bridge_port = false
  @port_arp = [] #Array of MAC addresses seen on this port
end

Instance Attribute Details

- (Object) bridge_port

Returns the value of attribute bridge_port



3
4
5
# File 'rlib/port.rb', line 3

def bridge_port
  @bridge_port
end

- (Object) expected_remote_mac

Returns the value of attribute expected_remote_mac



4
5
6
# File 'rlib/port.rb', line 4

def expected_remote_mac
  @expected_remote_mac
end

- (Object) expected_remote_port_name

Returns the value of attribute expected_remote_port_name



4
5
6
# File 'rlib/port.rb', line 4

def expected_remote_port_name
  @expected_remote_port_name
end

- (Object) expected_remote_port_number

Returns the value of attribute expected_remote_port_number



4
5
6
# File 'rlib/port.rb', line 4

def expected_remote_port_number
  @expected_remote_port_number
end

- (Object) expected_remote_switch_name

Returns the value of attribute expected_remote_switch_name



4
5
6
# File 'rlib/port.rb', line 4

def expected_remote_switch_name
  @expected_remote_switch_name
end

- (Object) port_arp

Returns the value of attribute port_arp



6
7
8
# File 'rlib/port.rb', line 6

def port_arp
  @port_arp
end

- (Object) port_name

Returns the value of attribute port_name



3
4
5
# File 'rlib/port.rb', line 3

def port_name
  @port_name
end

- (Object) port_number

Returns the value of attribute port_number



3
4
5
# File 'rlib/port.rb', line 3

def port_number
  @port_number
end

- (Object) remote_mac

Returns the value of attribute remote_mac



3
4
5
# File 'rlib/port.rb', line 3

def remote_mac
  @remote_mac
end

- (Object) remote_port_name

Returns the value of attribute remote_port_name



3
4
5
# File 'rlib/port.rb', line 3

def remote_port_name
  @remote_port_name
end

- (Object) remote_port_number

Returns the value of attribute remote_port_number



3
4
5
# File 'rlib/port.rb', line 3

def remote_port_number
  @remote_port_number
end

- (Object) remote_switch_name

Returns the value of attribute remote_switch_name



3
4
5
# File 'rlib/port.rb', line 3

def remote_switch_name
  @remote_switch_name
end

- (Object) up

Returns the value of attribute up



5
6
7
# File 'rlib/port.rb', line 5

def up
  @up
end

Instance Method Details

- (String) to_s

Return key attributes as a string (Primary use is debugging)

Returns:

  • (String)


19
20
21
22
23
24
25
# File 'rlib/port.rb', line 19

def to_s
  if @bridge_port == true
    "Bridge: [#{@port_name}, #{@remote_switch_name}, #{@remote_port_name}, #{@remote_port_number}]"
  else
    "Std Port: [#{@port_name}, [ #{@port_arp.join(',')} ] ]"
  end
end