mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
STABLE14-remove-find-lana-by-name-20070227
commit the rest of the patch that didn't pullup from STABLE14-remove-find-lana-by-name-20070219
This commit is contained in:
parent
9bab97f839
commit
f53e52b9f7
@ -519,107 +519,123 @@ extern "C" BOOL lana_IsLoopback(lana_number_t lana)
|
||||
// LANA_NETBIOS_NAME_FULL : Return full netbios name
|
||||
extern "C" long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int * pIsGateway, int flags) {
|
||||
HKEY hkConfig;
|
||||
DWORD dummyLen;
|
||||
LONG rv;
|
||||
int regLana;
|
||||
int regGateway, regNoFindLanaByName;
|
||||
TCHAR regNbName[MAX_NB_NAME_LENGTH];
|
||||
TCHAR nbName[MAX_NB_NAME_LENGTH];
|
||||
TCHAR hostname[MAX_COMPUTERNAME_LENGTH+1];
|
||||
DWORD dummyLen;
|
||||
LONG rv;
|
||||
int regLana;
|
||||
int regGateway;
|
||||
#ifdef USE_FINDLANABYNAME
|
||||
int regNoFindLanaByName;
|
||||
#endif
|
||||
TCHAR regNbName[MAX_NB_NAME_LENGTH] = "AFS";
|
||||
TCHAR nbName[MAX_NB_NAME_LENGTH];
|
||||
TCHAR hostname[MAX_COMPUTERNAME_LENGTH+1];
|
||||
|
||||
rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,AFSREG_CLT_SVC_PARAM_SUBKEY,0,KEY_READ,&hkConfig);
|
||||
if(rv == ERROR_SUCCESS) {
|
||||
if(!(flags & LANA_NETBIOS_NAME_IN) || !pLana) {
|
||||
dummyLen = sizeof(regLana);
|
||||
rv = RegQueryValueEx(hkConfig, szLanAdapterValue, NULL, NULL, (LPBYTE) ®Lana, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS) regLana = -1;
|
||||
} else
|
||||
regLana = *pLana;
|
||||
rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,AFSREG_CLT_SVC_PARAM_SUBKEY,0,KEY_READ,&hkConfig);
|
||||
if(rv == ERROR_SUCCESS) {
|
||||
if(!(flags & LANA_NETBIOS_NAME_IN) || !pLana) {
|
||||
dummyLen = sizeof(regLana);
|
||||
rv = RegQueryValueEx(hkConfig, szLanAdapterValue, NULL, NULL, (LPBYTE) ®Lana, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS)
|
||||
regLana = -1;
|
||||
} else
|
||||
regLana = *pLana;
|
||||
|
||||
if(!(flags & LANA_NETBIOS_NAME_IN) || !pIsGateway) {
|
||||
dummyLen = sizeof(regGateway);
|
||||
rv = RegQueryValueEx(hkConfig, szIsGatewayValue, NULL, NULL, (LPBYTE) ®Gateway, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS) regGateway = 0;
|
||||
} else
|
||||
regGateway = *pIsGateway;
|
||||
if(!(flags & LANA_NETBIOS_NAME_IN) || !pIsGateway) {
|
||||
dummyLen = sizeof(regGateway);
|
||||
rv = RegQueryValueEx(hkConfig, szIsGatewayValue, NULL, NULL, (LPBYTE) ®Gateway, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS)
|
||||
regGateway = 0;
|
||||
} else
|
||||
regGateway = *pIsGateway;
|
||||
|
||||
dummyLen = sizeof(regNoFindLanaByName);
|
||||
rv = RegQueryValueEx(hkConfig, szNoFindLanaByName, NULL, NULL, (LPBYTE) ®NoFindLanaByName, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS) regNoFindLanaByName = 0;
|
||||
#ifdef USE_FINDLANABYNAME
|
||||
dummyLen = sizeof(regNoFindLanaByName);
|
||||
rv = RegQueryValueEx(hkConfig, szNoFindLanaByName, NULL, NULL, (LPBYTE) ®NoFindLanaByName, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS)
|
||||
regNoFindLanaByName = 0;
|
||||
#endif
|
||||
// Do not care if the call fails for insufficient buffer size. We are not interested
|
||||
// in netbios names over 15 chars.
|
||||
dummyLen = sizeof(regNbName);
|
||||
rv = RegQueryValueEx(hkConfig, szNetbiosNameValue, NULL, NULL, (LPBYTE) ®NbName, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS)
|
||||
strcpy(regNbName, "AFS");
|
||||
else
|
||||
regNbName[15] = 0;
|
||||
|
||||
// Do not care if the call fails for insufficient buffer size. We are not interested
|
||||
// in netbios names over 15 chars.
|
||||
dummyLen = sizeof(regNbName);
|
||||
rv = RegQueryValueEx(hkConfig, szNetbiosNameValue, NULL, NULL, (LPBYTE) ®NbName, &dummyLen);
|
||||
if(rv != ERROR_SUCCESS) regNbName[0] = 0;
|
||||
else regNbName[15] = 0;
|
||||
|
||||
RegCloseKey(hkConfig);
|
||||
RegCloseKey(hkConfig);
|
||||
} else {
|
||||
if(flags & LANA_NETBIOS_NAME_IN) {
|
||||
regLana = (pLana)? *pLana: -1;
|
||||
regGateway = (pIsGateway)? *pIsGateway: 0;
|
||||
} else {
|
||||
if(flags & LANA_NETBIOS_NAME_IN) {
|
||||
regLana = (pLana)? *pLana: -1;
|
||||
regGateway = (pIsGateway)? *pIsGateway: 0;
|
||||
} else {
|
||||
regLana = -1;
|
||||
regGateway = 0;
|
||||
}
|
||||
regNoFindLanaByName = 0;
|
||||
regNbName[0] = 0;
|
||||
regLana = -1;
|
||||
regGateway = 0;
|
||||
}
|
||||
#ifdef USE_FINDLANABYNAME
|
||||
regNoFindLanaByName = 0;
|
||||
#endif
|
||||
strcpy(regNbName, "AFS");
|
||||
}
|
||||
|
||||
if(regLana < 0 || regLana > MAX_LANA)
|
||||
regLana = -1;
|
||||
|
||||
if(regLana == -1) {
|
||||
LANAINFO *lanaInfo = NULL;
|
||||
if(regLana == -1) {
|
||||
LANAINFO *lanaInfo = NULL;
|
||||
int nLana = LANA_INVALID;
|
||||
|
||||
#ifdef USE_FINDLANABYNAME
|
||||
if (!regNoFindLanaByName)
|
||||
lanaInfo = lana_FindLanaByName("AFS");
|
||||
if(lanaInfo != NULL) {
|
||||
#endif
|
||||
if(lanaInfo != NULL) {
|
||||
nLana = lanaInfo[0].lana_number;
|
||||
free(lanaInfo);
|
||||
} else
|
||||
nLana = LANA_INVALID;
|
||||
free(lanaInfo);
|
||||
} else
|
||||
nLana = LANA_INVALID;
|
||||
|
||||
if(nLana == LANA_INVALID && !regGateway) {
|
||||
nLana = lana_FindLoopback();
|
||||
}
|
||||
if(nLana != LANA_INVALID)
|
||||
regLana = nLana;
|
||||
if(nLana == LANA_INVALID && !regGateway) {
|
||||
nLana = lana_FindLoopback();
|
||||
}
|
||||
if(nLana != LANA_INVALID)
|
||||
regLana = nLana;
|
||||
}
|
||||
|
||||
if(regNbName[0] &&
|
||||
(regLana >=0 && lana_IsLoopback((lana_number_t) regLana))) {
|
||||
if(regNbName[0] &&
|
||||
(regLana >=0 && lana_IsLoopback((lana_number_t) regLana)))
|
||||
{
|
||||
strncpy(nbName,regNbName,15);
|
||||
nbName[16] = 0;
|
||||
strupr(nbName);
|
||||
} else {
|
||||
char * dot;
|
||||
|
||||
if(flags & LANA_NETBIOS_NAME_SUFFIX) {
|
||||
strcpy(nbName,"-AFS");
|
||||
} else {
|
||||
char * dot;
|
||||
|
||||
if(flags & LANA_NETBIOS_NAME_SUFFIX) {
|
||||
strcpy(nbName,"-AFS");
|
||||
} else {
|
||||
dummyLen = sizeof(hostname);
|
||||
// assume we are not a cluster.
|
||||
rv = GetComputerName(hostname, &dummyLen);
|
||||
if(!SUCCEEDED(rv)) { // should not happen, but...
|
||||
return rv;
|
||||
}
|
||||
strncpy(nbName, hostname, 11);
|
||||
nbName[11] = 0;
|
||||
if(dot = strchr(nbName,'.'))
|
||||
*dot = 0;
|
||||
strcat(nbName,"-AFS");
|
||||
}
|
||||
dummyLen = sizeof(hostname);
|
||||
// assume we are not a cluster.
|
||||
rv = GetComputerName(hostname, &dummyLen);
|
||||
if(!SUCCEEDED(rv)) { // should not happen, but...
|
||||
return rv;
|
||||
}
|
||||
strncpy(nbName, hostname, 11);
|
||||
nbName[11] = 0;
|
||||
if(dot = strchr(nbName,'.'))
|
||||
*dot = 0;
|
||||
strcat(nbName,"-AFS");
|
||||
}
|
||||
}
|
||||
|
||||
if(pLana) *pLana = regLana;
|
||||
if(pIsGateway) *pIsGateway = regGateway;
|
||||
if(pLana)
|
||||
*pLana = regLana;
|
||||
if(pIsGateway)
|
||||
*pIsGateway = regGateway;
|
||||
|
||||
strcpy(buffer, nbName);
|
||||
strcpy(buffer, nbName);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
extern "C" void lana_GetUncServerNameDynamic(int lanaNumber, BOOL isGateway, TCHAR *name, int type) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user