diff --git a/src/WINNT/afsd/lanahelper.cpp b/src/WINNT/afsd/lanahelper.cpp index 36b53595d2..77d2207d78 100644 --- a/src/WINNT/afsd/lanahelper.cpp +++ b/src/WINNT/afsd/lanahelper.cpp @@ -365,7 +365,7 @@ extern "C" LANAINFO * lana_FindLanaByName(const char *LanaName) return lanainfo; } -extern "C" lana_number_t lana_FindLoopback(void) +extern "C" lana_number_t lana_FindLoopback(BOOL reset) { NCB ncb; LANA_ENUM lana_list; @@ -384,7 +384,7 @@ extern "C" lana_number_t lana_FindLoopback(void) return LANA_INVALID; } for (i = 0; i < lana_list.length; i++) { - if (lana_IsLoopback(lana_list.lana[i],TRUE)) { + if (lana_IsLoopback(lana_list.lana[i], reset)) { // Found one, return it. #ifndef NOLOGGING afsi_log("lana_FindLoopback: Found LAN adapter %d", @@ -528,6 +528,7 @@ extern "C" BOOL lana_IsLoopback(lana_number_t lana, BOOL reset) // LANA_NETBIOS_NAME_IN : Use the values of *pLana and *pIsGateway as [in] parameters. // LANA_NETBIOS_NAME_SUFFIX : Only return the suffix of netbios name // LANA_NETBIOS_NAME_FULL : Return full netbios name +// LANA_NETBIOS_NO_RESET : Do not reset the netbios adapter state when finding the loopback extern "C" long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int * pIsGateway, int flags) { HKEY hkConfig; DWORD dummyLen; @@ -610,14 +611,14 @@ extern "C" long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int nLana = LANA_INVALID; if(nLana == LANA_INVALID && !regGateway) { - nLana = lana_FindLoopback(); + nLana = lana_FindLoopback(!(flags & LANA_NETBIOS_NO_RESET)); } if(nLana != LANA_INVALID) regLana = nLana; - } + } if(regNbName[0] && - (regLana >=0 && lana_IsLoopback((lana_number_t) regLana,FALSE))) + (regLana >=0 && lana_IsLoopback((lana_number_t) regLana, FALSE))) { strncpy(nbName,regNbName,14); nbName[14] = 0; diff --git a/src/WINNT/afsd/lanahelper.h b/src/WINNT/afsd/lanahelper.h index e161532c78..2ef44df8c8 100644 --- a/src/WINNT/afsd/lanahelper.h +++ b/src/WINNT/afsd/lanahelper.h @@ -49,11 +49,13 @@ extern "C" { #define LANA_NETBIOS_NAME_IN 2 +#define LANA_NETBIOS_NO_RESET 4 + int lana_GetNameFromGuid(char *Guid, char **Name); struct LANAINFO * lana_FindLanaByName(const char *LanaName); - lana_number_t lana_FindLoopback(void); + lana_number_t lana_FindLoopback(BOOL reset); BOOL lana_OnlyLoopback(void); diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index 9384c81242..4b940bb4ce 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -10331,7 +10331,7 @@ void smb_LanAdapterChange(int locked) { if (!powerStateSuspended && SUCCEEDED(lana_GetUncServerNameEx(NetbiosName, &lanaNum, &bGateway, - LANA_NETBIOS_NAME_FULL)) && + LANA_NETBIOS_NAME_FULL | LANA_NETBIOS_NO_RESET)) && lanaNum != LANA_INVALID && smb_LANadapter != lanaNum) { if ( isGateway != bGateway ) { afsi_log("Lan Adapter Change detected (%d != %d): gateway %d != %d", @@ -10399,7 +10399,10 @@ int smb_NetbiosInit(int locked) /* setup the NCB system */ ncbp = smb_GetNCB(); - /* Call lanahelper to get Netbios name, lan adapter number and gateway flag */ + /* + * Call lanahelper to get Netbios name, lan adapter number and gateway flag + * This will reset all of the network adapter's netbios state. + */ if (SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) { smb_LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;