provide netmask in NetworkInterface

This commit is contained in:
Christian Ulrich 2020-07-21 23:53:28 +02:00
parent 02a96ac412
commit 44cc3955b5
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 2 additions and 0 deletions

View File

@ -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