Class: Rex::Socket::SwitchBoard::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/socket/switch_board.rb

Overview

This class represents a logical switch board route. TODO: Enable this to work with IPv6 addresses

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subnet, netmask, comm) ⇒ Route

Returns a new instance of Route.



37
38
39
40
41
42
43
# File 'lib/rex/socket/switch_board.rb', line 37

def initialize(subnet, netmask, comm)
  self.subnet      = subnet
  self.netmask     = netmask
  self.comm        = comm
  self.subnet_nbo  = Socket.resolv_nbo_i(subnet)
  self.netmask_nbo = Socket.resolv_nbo_i(netmask)
end

Instance Attribute Details

#commObject

Returns the value of attribute comm.



60
61
62
# File 'lib/rex/socket/switch_board.rb', line 60

def comm
  @comm
end

#netmaskObject

Returns the value of attribute netmask.



60
61
62
# File 'lib/rex/socket/switch_board.rb', line 60

def netmask
  @netmask
end

#netmask_nboObject

Returns the value of attribute netmask_nbo.



61
62
63
# File 'lib/rex/socket/switch_board.rb', line 61

def netmask_nbo
  @netmask_nbo
end

#subnetObject

Returns the value of attribute subnet.



60
61
62
# File 'lib/rex/socket/switch_board.rb', line 60

def subnet
  @subnet
end

#subnet_nboObject

Returns the value of attribute subnet_nbo.



61
62
63
# File 'lib/rex/socket/switch_board.rb', line 61

def subnet_nbo
  @subnet_nbo
end

Instance Method Details

#<=>(other) ⇒ Object

Sort according to bitmask



48
49
50
# File 'lib/rex/socket/switch_board.rb', line 48

def <=>(other)
  self.bitmask <=> other.bitmask
end

#bitmaskObject

Convert the netmask to a bitmask and cache it.



55
56
57
58
# File 'lib/rex/socket/switch_board.rb', line 55

def bitmask
  @_bitmask = Socket.net2bitmask(self.netmask) if (@_bitmask == nil)
  @_bitmask
end