mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 11:22:58 +00:00
[IP]
- Do a better job of selecting an interface to use when none was specified - Fix build svn path=/trunk/; revision=59633
This commit is contained in:
parent
9f567f9c79
commit
49bffeb3fe
1 changed files with 31 additions and 1 deletions
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
|
ULONG NextDefaultAdapter = 0;
|
||||||
|
|
||||||
NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
|
NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
|
||||||
ULONG TargetType,
|
ULONG TargetType,
|
||||||
PULONG Address ) {
|
PULONG Address ) {
|
||||||
|
@ -143,18 +145,46 @@ BOOLEAN HasPrefix(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PIP_INTERFACE GetDefaultInterface(VOID)
|
PIP_INTERFACE GetDefaultInterface(VOID)
|
||||||
{
|
{
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
ULONG Index = 0;
|
||||||
|
|
||||||
IF_LIST_ITER(CurrentIF);
|
IF_LIST_ITER(CurrentIF);
|
||||||
|
|
||||||
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
||||||
|
/* DHCP hack: Always return the adapter without an IP address */
|
||||||
ForEachInterface(CurrentIF) {
|
ForEachInterface(CurrentIF) {
|
||||||
if (CurrentIF->Context) {
|
if (CurrentIF->Context) {
|
||||||
|
if (AddrIsUnspecified(&CurrentIF->Unicast)) {
|
||||||
|
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||||
|
return CurrentIF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} EndFor(CurrentIF);
|
||||||
|
|
||||||
|
/* Try to continue from the next adapter */
|
||||||
|
ForEachInterface(CurrentIF) {
|
||||||
|
if (CurrentIF->Context) {
|
||||||
|
if (Index++ == NextDefaultAdapter) {
|
||||||
|
NextDefaultAdapter++;
|
||||||
|
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||||
|
return CurrentIF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} EndFor(CurrentIF);
|
||||||
|
|
||||||
|
/* No luck, so we'll choose the first adapter this time */
|
||||||
|
ForEachInterface(CurrentIF) {
|
||||||
|
if (CurrentIF->Context) {
|
||||||
|
NextDefaultAdapter = 1;
|
||||||
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||||
return CurrentIF;
|
return CurrentIF;
|
||||||
}
|
}
|
||||||
} EndFor(CurrentIF);
|
} EndFor(CurrentIF);
|
||||||
|
|
||||||
|
/* Even that didn't work, so we'll just go with loopback */
|
||||||
|
NextDefaultAdapter = 0;
|
||||||
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||||
|
|
||||||
/* There are no physical interfaces on the system
|
/* There are no physical interfaces on the system
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue