Class: Rex::Socket::SwitchBoard::Route
- Inherits:
-
Object
- Object
- Rex::Socket::SwitchBoard::Route
- 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
-
#comm ⇒ Object
readonly
Returns the value of attribute comm.
-
#netmask ⇒ Object
readonly
Returns the value of attribute netmask.
-
#netmask_nbo ⇒ Object
readonly
Returns the value of attribute netmask_nbo.
-
#subnet ⇒ Object
readonly
Returns the value of attribute subnet.
-
#subnet_nbo ⇒ Object
readonly
Returns the value of attribute subnet_nbo.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sort according to bitmask.
-
#bitmask ⇒ Object
Convert the netmask to a bitmask and cache it.
-
#initialize(subnet, netmask, comm) ⇒ Route
constructor
A new instance of Route.
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
#comm ⇒ Object
Returns the value of attribute comm.
60 61 62 |
# File 'lib/rex/socket/switch_board.rb', line 60 def comm @comm end |
#netmask ⇒ Object
Returns the value of attribute netmask.
60 61 62 |
# File 'lib/rex/socket/switch_board.rb', line 60 def netmask @netmask end |
#netmask_nbo ⇒ Object
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 |
#subnet ⇒ Object
Returns the value of attribute subnet.
60 61 62 |
# File 'lib/rex/socket/switch_board.rb', line 60 def subnet @subnet end |
#subnet_nbo ⇒ Object
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 |
#bitmask ⇒ Object
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 |