const struct nls_table *nls_codepage) 
const struct nls_table *nls_codepage, int remap) 
CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,		const unsigned char *searchName,		unsigned char **targetUNCs,		unsigned int *number_of_UNC_in_array,		const struct nls_table *nls_codepage){/* TRANS2_GET_DFS_REFERRAL */	TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL;	TRANSACTION2_GET_DFS_REFER_RSP *pSMBr = NULL;	struct dfs_referral_level_3 * referrals = NULL;	int rc = 0;	int bytes_returned;	int name_len;	unsigned int i;	char * temp;	__u16 params, byte_count;	*number_of_UNC_in_array = 0;	*targetUNCs = NULL;	cFYI(1, ("In GetDFSRefer the path %s", searchName));	if (ses == NULL)		return -ENODEV;getDFSRetry:	rc = smb_init(SMB_COM_TRANSACTION2, 15, NULL, (void **) &pSMB,		      (void **) &pSMBr);	if (rc)		return rc;	pSMB->hdr.Tid = ses->ipc_tid;	pSMB->hdr.Uid = ses->Suid;	if (ses->capabilities & CAP_STATUS32) {		pSMB->hdr.Flags2 |= SMBFLG2_ERR_STATUS;	}	if (ses->capabilities & CAP_DFS) {		pSMB->hdr.Flags2 |= SMBFLG2_DFS;	}	if (ses->capabilities & CAP_UNICODE) {		pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;		name_len =		    cifs_strtoUCS((wchar_t *) pSMB->RequestFileName,				  searchName, PATH_MAX				  /* find define for this maxpathcomponent */				  , nls_codepage);		name_len++;	/* trailing null */		name_len *= 2;	} else {		/* BB improve the check for buffer overruns BB */		name_len = strnlen(searchName, PATH_MAX);		name_len++;	/* trailing null */		strncpy(pSMB->RequestFileName, searchName, name_len);	}	params = 2 /* level */  + name_len /*includes null */ ;	pSMB->TotalDataCount = 0;	pSMB->DataCount = 0;	pSMB->DataOffset = 0;	pSMB->MaxParameterCount = 0;	pSMB->MaxDataCount = cpu_to_le16(4000);	/* BB find exact max SMB PDU from sess structure BB */	pSMB->MaxSetupCount = 0;	pSMB->Reserved = 0;	pSMB->Flags = 0;	pSMB->Timeout = 0;	pSMB->Reserved2 = 0;	pSMB->ParameterOffset = cpu_to_le16(offsetof(        struct smb_com_transaction2_get_dfs_refer_req, MaxReferralLevel) - 4);	pSMB->SetupCount = 1;	pSMB->Reserved3 = 0;	pSMB->SubCommand = cpu_to_le16(TRANS2_GET_DFS_REFERRAL);	byte_count = params + 3 /* pad */ ;	pSMB->ParameterCount = cpu_to_le16(params);	pSMB->TotalParameterCount = pSMB->ParameterCount;	pSMB->MaxReferralLevel = cpu_to_le16(3);	pSMB->hdr.smb_buf_length += byte_count;	pSMB->ByteCount = cpu_to_le16(byte_count);	rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB,			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);	if (rc) {		cFYI(1, ("Send error in GetDFSRefer = %d", rc));	} else {		/* decode response *//* BB Add logic to parse referrals here */		rc = validate_t2((struct smb_t2_rsp *)pSMBr);		if (rc || (pSMBr->ByteCount < 17))      /* BB also check enough total bytes returned */			rc = -EIO;      /* bad smb */		else {			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 			__u16 data_count = le16_to_cpu(pSMBr->t2.DataCount);			cFYI(1,			     ("Decoding GetDFSRefer response.  BCC: %d  Offset %d",			      pSMBr->ByteCount, data_offset));			referrals = 			    (struct dfs_referral_level_3 *) 					(8 /* sizeof start of data block */ +					data_offset +					(char *) &pSMBr->hdr.Protocol); 			cFYI(1,("num_referrals: %d dfs flags: 0x%x ... \nfor referral one refer size: 0x%x srv type: 0x%x refer flags: 0x%x ttl: 0x%x",				le16_to_cpu(pSMBr->NumberOfReferrals),le16_to_cpu(pSMBr->DFSFlags), le16_to_cpu(referrals->ReferralSize),le16_to_cpu(referrals->ServerType),le16_to_cpu(referrals->ReferralFlags),le16_to_cpu(referrals->TimeToLive)));			/* BB This field is actually two bytes in from start of			   data block so we could do safety check that DataBlock			   begins at address of pSMBr->NumberOfReferrals */			*number_of_UNC_in_array = le16_to_cpu(pSMBr->NumberOfReferrals);			/* BB Fix below so can return more than one referral */			if(*number_of_UNC_in_array > 1)				*number_of_UNC_in_array = 1;			/* get the length of the strings describing refs */			name_len = 0;			for(i=0;i<*number_of_UNC_in_array;i++) {				/* make sure that DfsPathOffset not past end */				__u16 offset = le16_to_cpu(referrals->DfsPathOffset);				if (offset > data_count) {					/* if invalid referral, stop here and do 					not try to copy any more */					*number_of_UNC_in_array = i;					break;				} 				temp = ((char *)referrals) + offset;				if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {					name_len += UniStrnlen((wchar_t *)temp,data_count);				} else {					name_len += strnlen(temp,data_count);				}				referrals++;				/* BB add check that referral pointer does not fall off end PDU */							}			/* BB add check for name_len bigger than bcc */			*targetUNCs = 				kmalloc(name_len+1+ (*number_of_UNC_in_array),GFP_KERNEL);			if(*targetUNCs == NULL) {				rc = -ENOMEM;				goto GetDFSRefExit;			}			/* copy the ref strings */			referrals =  			    (struct dfs_referral_level_3 *) 					(8 /* sizeof data hdr */ +					data_offset + 					(char *) &pSMBr->hdr.Protocol);			for(i=0;i<*number_of_UNC_in_array;i++) {				temp = ((char *)referrals) + le16_to_cpu(referrals->DfsPathOffset);				if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {					cifs_strfromUCS_le(*targetUNCs,						(wchar_t *) temp, name_len, nls_codepage);				} else {					strncpy(*targetUNCs,temp,name_len);				}				/*  BB update target_uncs pointers */				referrals++;			}			temp = *targetUNCs;			temp[name_len] = 0;		}	}GetDFSRefExit:	if (pSMB)		cifs_buf_release(pSMB);	if (rc == -EAGAIN)		goto getDFSRetry;	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/737b758c965a9b223ac1243ab38d9e507ac86c64/cifssmb.c/clean/fs/cifs/cifssmb.c