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.



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

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.



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

def comm
  @comm
end

#netmaskObject

Returns the value of attribute netmask.



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

def netmask
  @netmask
end

#netmask_nboObject

Returns the value of attribute netmask_nbo.



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

def netmask_nbo
  @netmask_nbo
end

#subnetObject

Returns the value of attribute subnet.



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

def subnet
  @subnet
end

#subnet_nboObject

Returns the value of attribute subnet_nbo.



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

def subnet_nbo
  @subnet_nbo
end

Instance Method Details

#<=>(other) ⇒ Object

Sort according to bitmask



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

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

#bitmaskObject

Convert the netmask to a bitmask and cache it.



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

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