Dhcpv6RequestPrefix() always returns ERROR_INVALID_PARAMETER?
- From: GlenGG <GlenGG@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 10 Jun 2010 11:23:16 -0700
I'm trying to use the Dhcpv6RequestPrefix() api on Windows 7 Ultimate to
request a prefix from the DHCPv6 server.
The first call to this api returns ERROR_MORE_DATA as expected because the
first call does not provide memory for the prefixes and the serverid.
After following the instructions from the MSDN documentation -
"The caller must follow these considerations when assigning the values of
the nPrefixes, iaid, and ServerIdLen members of the
DHCPV6PrefixLeaseInformation structure. Based on these values, memory must
also be properly allocated to the ServerId and PrefixArray members before the
Dhcpv6RequestPrefix function is called."
The subsequent call to Dhcpv6RequestPrefix() returns ERROR_INVALID_PARAMETER.
MSDN states -
"Returned if one of the following conditions are true:
AdapterName is NULL.
prefixleaseInfo is NULL.
pdwTimeToWait is NULL.
The iaid member of the prefixleaseInfo is zero."
I have verified that the adaptername is not NULL. Memory for prefixleaseInfo
is allocated(i.e. not NULL). pdwTimeToWait is not NULL. iaid is not zero.
Please see code snippet below. Is there something I missed? Is
DHCPV6CAPI_CLASSID a required parameter?
I also verified that the DHCPv6 client and DHCPv6 server have completed the
prefix request change.
i.e. the packet trace shows DHCPv6 Solicit, Advertise, Request, Reply
Any help is appreciated.
-glen
--- Start Code Snippet ----
DWORD dwError, dwTimeout = 0xFFFFFFFF;
int dw, iNumPrefixes = 1;
DWORD dwServerIdLen = 128;
WCHAR wszAdapter[260];
WCHAR wszDescription[512];
PDHCPV6PrefixLeaseInformation pPrefixInfo = NULL;
pPrefixInfo =
(PDHCPV6PrefixLeaseInformation)malloc(sizeof(DHCPV6PrefixLeaseInformation));
memset(pPrefixInfo, 0, sizeof(DHCPV6PrefixLeaseInformation));
pPrefixInfo->iaid = 1;
CString strTemp;
strTemp = pApp->m_pAdapterInfo[i].szMacDeviceID;
dw = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strTemp, -1, wszAdapter, 0);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strTemp, -1, wszAdapter, dw);
strTemp = pApp->m_pAdapterInfo[i].szDescription;
dw = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strTemp, -1,
wszDescription, 0);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strTemp, -1, wszDescription, dw);
dwError = Dhcpv6RequestPrefix(wszAdapter,
NULL, // no class id
pPrefixInfo,
&dwTimeout);
if(dwError == ERROR_MORE_DATA){
// The value of the nPrefixes or the ServerIdLen member specified
// is less than the number of prefixes available from the server
// or the available server ID length. Increase the nPrefixes or
// the ServerIdLen member and make sure the corresponding
memory
// has been allocated properly before calling the Dhcpv6RequestPrefix
// function again.
iNumPrefixes = 1;
pPrefixInfo->prefixArray =
(LPDHCPV6Prefix)malloc(iNumPrefixes*sizeof(DHCPV6Prefix));
memset(pPrefixInfo->prefixArray, 0, iNumPrefixes*sizeof(DHCPV6Prefix));
pPrefixInfo->ServerId = (LPBYTE)malloc(dwServerIdLen);
memset(pPrefixInfo->ServerId, 0, dwServerIdLen);
pPrefixInfo->ServerIdLen = dwServerIdLen;
dwError =Dhcpv6RequestPrefix(wszAdapter,
NULL, // no class id
pPrefixInfo,
&dwTimeout);
}
if(pPrefixInfo->prefixArray) free(pPrefixInfo->prefixArray);
if(pPrefixInfo->ServerId) free(pPrefixInfo->ServerId);
if(pPrefixInfo) free(pPrefixInfo);;
--- End Code snippet ---
.
- Prev by Date: Bad NetBios name query bringing down network
- Next by Date: Re: Bad NetBios name query bringing down network
- Previous by thread: Bad NetBios name query bringing down network
- Next by thread: RE: NET USE command And Network Provider interface.
- Index(es):