CreateUnicastIP timeout

Assign Unicast IP Status Text
This commit is contained in:
ChsBuffer
2021-11-13 14:32:22 +08:00
parent 3264a33e5b
commit 8be7e13aa4
2 changed files with 9 additions and 4 deletions

View File

@@ -91,6 +91,7 @@ public class TUNController : Guard, IModeController
var tunIndex = _tunNetworkInterface.GetIndex();
_tun = NetRoute.TemplateBuilder(_tunConfig.Gateway, tunIndex);
Global.MainForm.StatusText(i18N.Translate("Assign Unicast IP"));
if (!RouteHelper.CreateUnicastIP(AddressFamily.InterNetwork,
_tunConfig.Address,
(byte)Utils.Utils.SubnetToCidr(_tunConfig.Netmask),

View File

@@ -49,11 +49,10 @@ public static unsafe class RouteHelper
{
if (type != MIB_NOTIFICATION_TYPE.MibInitialNotification)
{
// TODO pass error
NTSTATUS state;
if ((state = GetUnicastIpAddressEntry(row)) != 0)
{
Log.Error("CreateUnicastIpAddressEntry failed: {0}", state);
Log.Error("GetUnicastIpAddressEntry failed: {State}", state.Value);
return;
}
@@ -79,11 +78,16 @@ public static unsafe class RouteHelper
NTSTATUS state;
if ((state = CreateUnicastIpAddressEntry(&addr)) != 0)
{
Log.Error("CreateUnicastIpAddressEntry failed: {0}", state);
Log.Error("CreateUnicastIpAddressEntry failed: {State}", state.Value);
return false;
}
if (!obj.WaitOne(TimeSpan.FromSeconds(10)))
{
Log.Error("Wait unicast IP usable timeout");
return false;
}
obj.WaitOne();
return true;
}
finally