@@ -51,6 +51,8 @@ def route_cmd
51
51
end
52
52
53
53
# Run Method for when run command is issued
54
+ #
55
+ # @return [void] A useful return value is not expected here
54
56
def run
55
57
return unless session_good?
56
58
@@ -170,8 +172,12 @@ def print_routes
170
172
end
171
173
end
172
174
175
+ # Validation check on an IPv4 address
176
+ #
173
177
# Yet another IP validator. I'm sure there's some Rex
174
178
# function that can just do this.
179
+ #
180
+ # @return [string class] IPv4 subnet
175
181
def check_ip ( ip = nil )
176
182
return false if ( ip . nil? || ip . strip . empty? )
177
183
begin
@@ -182,11 +188,17 @@ def check_ip(ip=nil)
182
188
end
183
189
end
184
190
191
+ # Converts a CIDR value to a netmask
192
+ #
193
+ # @return [string class] IPv4 netmask
185
194
def cidr_to_netmask ( cidr )
186
195
int = cidr . gsub ( /\x2f / , "" ) . to_i
187
196
Rex ::Socket . addr_ctoa ( int )
188
197
end
189
198
199
+ # Validates the user input 'NETMASK'
200
+ #
201
+ # @return [string class] IPv4 netmask
190
202
def netmask
191
203
case datastore [ 'NETMASK' ]
192
204
when /^\x2f [0-9]{1,2}/
@@ -432,6 +444,9 @@ def interface_compatible?
432
444
end
433
445
434
446
# Validates the command options
447
+ #
448
+ # @return [true class] Everything is good
449
+ # @return [false class] Not so much
435
450
def validate_cmd ( subnet = nil , netmask = nil )
436
451
if subnet . nil?
437
452
print_error "Missing subnet option"
0 commit comments