Author: fmueller
Date: Fri Jul 2 01:17:11 2010
New Revision: 8923
URL: http://svn.slimdevices.com/jive?rev=8923&view=rev
Log:
Bug: n/a
Description: Get rid of another 'ifconfig' shell call and use new C method to
get ip address.
Modified:
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupSSH/SetupSSHApplet.lua
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
Modified:
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupSSH/SetupSSHApplet.lua
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupSSH/SetupSSHApplet.lua?rev=8923&r1=8922&r2=8923&view=diff
==============================================================================
---
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupSSH/SetupSSHApplet.lua
(original)
+++
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupSSH/SetupSSHApplet.lua
Fri Jul 2 01:17:11 2010
@@ -100,14 +100,14 @@
function _getIPAddress()
- local ipaddr
+ local ip_address, ip_subnet
local ifObj = Networking:activeInterface()
if ifObj then
- ipaddr = Networking:getIP(ifObj)
- end
-
- return ipaddr or "?.?.?.?"
+ ip_address, ip_subnet = ifObj:getIPAddressAndSubnet()
+ end
+
+ return ip_address or "?.?.?.?"
end
Modified:
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua?rev=8923&r1=8922&r2=8923&view=diff
==============================================================================
---
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
(original)
+++
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
Fri Jul 2 01:17:11 2010
@@ -354,24 +354,23 @@
--[[
-=head2 networking:getIP(self, interface)
-
-Returns the ip address, if any, of the object I<interface>
-
-=cut
---]]
-
-function getIP(self, interfaceObj)
- local ipaddr
- local cmd = io.popen("/sbin/ifconfig " .. interfaceObj.interface)
- for line in cmd:lines() do
- ipaddr = string.match(line, "inet addr:([%d%.]+)")
- if ipaddr ~= nil then
- break
- end
- end
- cmd:close()
- return ipaddr
+=head2 networking:getIPAddressAndSubnet(self)
+
+Returns the ip address and subnet, if any
+
+=cut
+--]]
+
+function getIPAddressAndSubnet(self)
+ local ip_address, ip_subnet
+
+ local ifdata = self.t_sock:getIfConfig()
+ if ifdata ~= nil then
+ ip_address = ifdata[1]
+ ip_subnet = ifdata[2]
+ end
+
+ return ip_address, ip_subnet
end
@@ -719,11 +718,11 @@
return status
end
- -- Get ip address and net mask
- local ifdata = self.t_sock:getIfConfig()
- if ifdata ~= nil then
- status.ip_address = ifdata[1]
- status.ip_subnet = ifdata[2]
+ local ip_address, ip_subnet = self:getIPAddressAndSubnet()
+
+ if ip_address and ip_subnet then
+ status.ip_address = ip_address
+ status.ip_subnet = ip_subnet
end
-- exit early if we do not have an ip address
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins