provide netmask in NetworkInterface
This commit is contained in:
parent
02a96ac412
commit
44cc3955b5
|
@ -4,6 +4,7 @@ from posix import SockAddr, Sockaddr_in, inet_ntoa, AF_INET
|
||||||
type
|
type
|
||||||
NetworkInterface* = object
|
NetworkInterface* = object
|
||||||
ipAddress*: string
|
ipAddress*: string
|
||||||
|
netMask*: string
|
||||||
name*: string
|
name*: string
|
||||||
index*: cint
|
index*: cint
|
||||||
flags*: cuint
|
flags*: cuint
|
||||||
|
@ -34,6 +35,7 @@ proc fromIpAddress*(address: string): NetworkInterface =
|
||||||
it.ifa_addr.sa_family.cint == AF_INET and
|
it.ifa_addr.sa_family.cint == AF_INET and
|
||||||
it.ifa_addr.getAddrString() == address:
|
it.ifa_addr.getAddrString() == address:
|
||||||
result.ipAddress = address
|
result.ipAddress = address
|
||||||
|
result.netMask = it.ifa_netmask.getAddrString()
|
||||||
result.name = $it.ifa_name
|
result.name = $it.ifa_name
|
||||||
result.index = if_nametoindex(result.name).cint
|
result.index = if_nametoindex(result.name).cint
|
||||||
result.flags = it.ifa_flags
|
result.flags = it.ifa_flags
|
||||||
|
|
Loading…
Reference in New Issue