Add ioctl(SIOCGIFxxx) support (#197)

- SIOCGIFCONFIG: reads and enumerate all the network interfaces
- SIOCGIFADDR: reads network address for a given interface
- SIOCGIFFLAGS: reads network flags for a given interface
- SIOCGIFNETMASK: reads network netmask for a given interface
- SIOCGIFBRDADDR: reads network broadcast address for a given interface
- SIOCGIFDSTADDR: reads peer destination address for a given
  interface (not supported for Windows)

This change defines Linux ABI structs for the above interfaces and adds
polyfills to ensure they behave consistently on XNU and Windows.
This commit is contained in:
fabriziobertocci 2021-06-24 13:53:27 -04:00 committed by GitHub
parent 4d8f884e76
commit fd0eefce17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 1531 additions and 4 deletions

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_AddIPAddress,AddIPAddress,0
.text.windows
AddIPAddress:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_AddIPAddress(%rip),%rax
jmp __sysv2nt6
.endfn AddIPAddress,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_AllocateAndGetTcpExTableFromStack,AllocateAndGetTcpExTableFromStack,0
.text.windows
AllocateAndGetTcpExTableFromStack:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_AllocateAndGetTcpExTableFromStack(%rip),%rax
jmp __sysv2nt6
.endfn AllocateAndGetTcpExTableFromStack,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_AllocateAndGetUdpExTableFromStack,AllocateAndGetUdpExTableFromStack,0
.text.windows
AllocateAndGetUdpExTableFromStack:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_AllocateAndGetUdpExTableFromStack(%rip),%rax
jmp __sysv2nt6
.endfn AllocateAndGetUdpExTableFromStack,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CancelIPChangeNotify,CancelIPChangeNotify,0
.text.windows
CancelIPChangeNotify:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_CancelIPChangeNotify(%rip)
leave
ret
.endfn CancelIPChangeNotify,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CaptureInterfaceHardwareCrossTimestamp,CaptureInterfaceHardwareCrossTimestamp,0
.text.windows
CaptureInterfaceHardwareCrossTimestamp:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_CaptureInterfaceHardwareCrossTimestamp(%rip),%rax
jmp __sysv2nt
.endfn CaptureInterfaceHardwareCrossTimestamp,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CreateIpForwardEntry,CreateIpForwardEntry,0
.text.windows
CreateIpForwardEntry:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_CreateIpForwardEntry(%rip)
leave
ret
.endfn CreateIpForwardEntry,globl
.previous

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CreateIpNetEntry,CreateIpNetEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CreatePersistentTcpPortReservation,CreatePersistentTcpPortReservation,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CreatePersistentUdpPortReservation,CreatePersistentUdpPortReservation,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_CreateProxyArpEntry,CreateProxyArpEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DeleteIPAddress,DeleteIPAddress,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DeleteIpForwardEntry,DeleteIpForwardEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DeleteIpNetEntry,DeleteIpNetEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DeletePersistentTcpPortReservation,DeletePersistentTcpPortReservation,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DeletePersistentUdpPortReservation,DeletePersistentUdpPortReservation,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DeleteProxyArpEntry,DeleteProxyArpEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_DisableMediaSense,DisableMediaSense,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_EnableRouter,EnableRouter,0

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_FlushIpNetTable,FlushIpNetTable,0
.text.windows
FlushIpNetTable:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_FlushIpNetTable(%rip)
leave
ret
.endfn FlushIpNetTable,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetAdapterIndex,GetAdapterIndex,0
.text.windows
GetAdapterIndex:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetAdapterIndex(%rip),%rax
jmp __sysv2nt
.endfn GetAdapterIndex,globl
.previous

View file

@ -0,0 +1,14 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetAdapterOrderMap,GetAdapterOrderMap,0
.text.windows
GetAdapterOrderMap:
push %rbp
mov %rsp,%rbp
.profilable
sub $32,%rsp
call *__imp_GetAdapterOrderMap(%rip)
leave
ret
.endfn GetAdapterOrderMap,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetAdaptersAddresses,GetAdaptersAddresses,67
.text.windows
GetAdaptersAddresses:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetAdaptersAddresses(%rip),%rax
jmp __sysv2nt6
.endfn GetAdaptersAddresses,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetAdaptersInfo,GetAdaptersInfo,0
.text.windows
GetAdaptersInfo:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetAdaptersInfo(%rip),%rax
jmp __sysv2nt
.endfn GetAdaptersInfo,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetBestInterface,GetBestInterface,0
.text.windows
GetBestInterface:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetBestInterface(%rip),%rax
jmp __sysv2nt
.endfn GetBestInterface,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetBestInterfaceEx,GetBestInterfaceEx,0
.text.windows
GetBestInterfaceEx:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetBestInterfaceEx(%rip),%rax
jmp __sysv2nt
.endfn GetBestInterfaceEx,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetBestRoute,GetBestRoute,0
.text.windows
GetBestRoute:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetBestRoute(%rip),%rax
jmp __sysv2nt
.endfn GetBestRoute,globl
.previous

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetExtendedTcpTable,GetExtendedTcpTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetExtendedUdpTable,GetExtendedUdpTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetFriendlyIfIndex,GetFriendlyIfIndex,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIcmpStatistics,GetIcmpStatistics,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIcmpStatisticsEx,GetIcmpStatisticsEx,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIfEntry,GetIfEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIfTable,GetIfTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetInterfaceActiveTimestampCapabilities,GetInterfaceActiveTimestampCapabilities,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetInterfaceInfo,GetInterfaceInfo,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetInterfaceSupportedTimestampCapabilities,GetInterfaceSupportedTimestampCapabilities,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIpAddrTable,GetIpAddrTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIpErrorString,GetIpErrorString,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIpForwardTable,GetIpForwardTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIpNetTable,GetIpNetTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIpStatistics,GetIpStatistics,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetIpStatisticsEx,GetIpStatisticsEx,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetNetworkParams,GetNetworkParams,0

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetNumberOfInterfaces,GetNumberOfInterfaces,0
.text.windows
GetNumberOfInterfaces:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_GetNumberOfInterfaces(%rip)
leave
ret
.endfn GetNumberOfInterfaces,globl
.previous

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetOwnerModuleFromTcp6Entry,GetOwnerModuleFromTcp6Entry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetOwnerModuleFromTcpEntry,GetOwnerModuleFromTcpEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetOwnerModuleFromUdp6Entry,GetOwnerModuleFromUdp6Entry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetOwnerModuleFromUdpEntry,GetOwnerModuleFromUdpEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetPerAdapterInfo,GetPerAdapterInfo,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetPerTcp6ConnectionEStats,GetPerTcp6ConnectionEStats,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetPerTcpConnectionEStats,GetPerTcpConnectionEStats,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetRTTAndHopCount,GetRTTAndHopCount,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcp6Table,GetTcp6Table,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcp6Table2,GetTcp6Table2,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcpStatistics,GetTcpStatistics,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcpStatisticsEx,GetTcpStatisticsEx,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcpStatisticsEx2,GetTcpStatisticsEx2,0

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcpTable,GetTcpTable,0
.text.windows
GetTcpTable:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetTcpTable(%rip),%rax
jmp __sysv2nt
.endfn GetTcpTable,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetTcpTable2,GetTcpTable2,0
.text.windows
GetTcpTable2:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_GetTcpTable2(%rip),%rax
jmp __sysv2nt
.endfn GetTcpTable2,globl
.previous

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetUdp6Table,GetUdp6Table,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetUdpStatistics,GetUdpStatistics,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetUdpStatisticsEx,GetUdpStatisticsEx,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetUdpStatisticsEx2,GetUdpStatisticsEx2,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetUdpTable,GetUdpTable,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_GetUniDirectionalAdapterInfo,GetUniDirectionalAdapterInfo,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_IpReleaseAddress,IpReleaseAddress,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_IpRenewAddress,IpRenewAddress,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_LookupPersistentTcpPortReservation,LookupPersistentTcpPortReservation,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_LookupPersistentUdpPortReservation,LookupPersistentUdpPortReservation,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_NhpAllocateAndGetInterfaceInfoFromStack,NhpAllocateAndGetInterfaceInfoFromStack,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_NotifyAddrChange,NotifyAddrChange,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_NotifyRouteChange,NotifyRouteChange,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_ParseNetworkString,ParseNetworkString,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_RegisterInterfaceTimestampConfigChange,RegisterInterfaceTimestampConfigChange,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_ResolveNeighbor,ResolveNeighbor,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_RestoreMediaSense,RestoreMediaSense,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SendARP,SendARP,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetIfEntry,SetIfEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetIpForwardEntry,SetIpForwardEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetIpNetEntry,SetIpNetEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetIpStatistics,SetIpStatistics,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetIpStatisticsEx,SetIpStatisticsEx,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetIpTTL,SetIpTTL,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetPerTcp6ConnectionEStats,SetPerTcp6ConnectionEStats,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetPerTcpConnectionEStats,SetPerTcpConnectionEStats,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_SetTcpEntry,SetTcpEntry,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_UnenableRouter,UnenableRouter,0

View file

@ -0,0 +1,2 @@
.include "o/libc/nt/codegen.inc"
.imp iphlpapi,__imp_UnregisterInterfaceTimestampConfigChange,UnregisterInterfaceTimestampConfigChange,0