Prevent exceptions with a 'Success' message when there is a problem with permissions...
authorSimon Rozsival <simon@rozsival.com>
Wed, 30 Nov 2022 14:20:38 +0000 (15:20 +0100)
committerGitHub <noreply@github.com>
Wed, 30 Nov 2022 14:20:38 +0000 (15:20 +0100)
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.NetworkChange.cs

index 52b3653..cb237ff 100644 (file)
@@ -52,7 +52,7 @@ internal static partial class Interop
         [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_EnumerateGatewayAddressesForInterface")]
         public static unsafe partial int EnumerateGatewayAddressesForInterface(void* context, uint interfaceIndex, delegate* unmanaged<void*, IpAddressInfo*, void> onGatewayFound);
 
-        [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNetworkInterfaces")]
+        [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNetworkInterfaces", SetLastError = true)]
         public static unsafe partial int GetNetworkInterfaces(int* count, NetworkInterfaceInfo** addrs, int* addressCount, IpAddressInfo** aa);
 
     }
index d4dd7ee..85d0401 100644 (file)
@@ -16,7 +16,7 @@ internal static partial class Interop
             AvailabilityChanged = 2
         }
 
-        [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateNetworkChangeListenerSocket")]
+        [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateNetworkChangeListenerSocket", SetLastError = true)]
         public static unsafe partial Error CreateNetworkChangeListenerSocket(IntPtr* socket);
 
         [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadEvents")]