64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/freewifi/cisco/iwag/iwag_telnet_connector.rb', line 64
def return_iwag_access_interface_1(ipaddress)
host_iwag = iwag1_host
username_iwag = iwag_username
password_iwag = iwag_password
answer =""
dump =""
begin
connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*#/) {|str| print str}
connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
connection.cmd("show ip dhcp binding #{ipaddress}") {
|c|
dump << c
}
connection.close
as = dump.split("\n")
if as[4] != nil && as[3] != ""
access_interface = as[4].gsub!(" ", "").split(" ").last
return access_interface
else
answer ="false"
return answer
end
rescue
begin
connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*#/) {|str| print str}
connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
connection.cmd("show ip dhcp binding #{ipaddress}") {
|c|
dump << c
}
connection.close
as = dump.split("\n")
if as[4] != nil && as[3] != ""
access_interface = as[4].gsub!(" ", "").split(" ").last
return access_interface
else
answer ="false"
return answer
end
rescue
return "unknown"
end
end
end
|