- for _, info in ipairs(nixio.getifaddrs()) do
- local name = info.name:match("[^:]+")
- if name == dev then
- if info.family == "packet" then
- data.flags = info.flags
- data.stats = info.data
- data.macaddr = info.addr
- data.ifname = name
- elseif info.family == "inet" then
- data.ipaddrs = data.ipaddrs or { }
- data.ipaddrs[#data.ipaddrs+1] = {
- addr = info.addr,
- broadaddr = info.broadaddr,
- dstaddr = info.dstaddr,
- netmask = info.netmask,
- prefix = info.prefix
- }
- elseif info.family == "inet6" then
- data.ip6addrs = data.ip6addrs or { }
- data.ip6addrs[#data.ip6addrs+1] = {
- addr = info.addr,
- netmask = info.netmask,
- prefix = info.prefix
- }
- end
- end
+
+ local _, a
+ for _, a in ipairs(device:ipaddrs()) do
+ data.ipaddrs[#data.ipaddrs+1] = {
+ addr = a:host():string(),
+ netmask = a:mask():string(),
+ prefix = a:prefix()
+ }
+ end
+ for _, a in ipairs(device:ip6addrs()) do
+ data.ip6addrs[#data.ip6addrs+1] = {
+ addr = a:host():string(),
+ netmask = a:mask():string(),
+ prefix = a:prefix()
+ }