mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 11:16:11 +00:00
- Renew the IP address of all adapters when using /renew
- Leave the critical section in failure case - Check for NULL adapter (CID 499) - Implement IpRenewAddress and IpReleaseAddress - Fixes ipconfig /release and ipconfig /renew svn path=/trunk/; revision=41955
This commit is contained in:
parent
45a41f9932
commit
c7364bef38
6 changed files with 75 additions and 38 deletions
|
@ -573,6 +573,7 @@ VOID Release(LPTSTR Index)
|
||||||
VOID Renew(LPTSTR Index)
|
VOID Renew(LPTSTR Index)
|
||||||
{
|
{
|
||||||
IP_ADAPTER_INDEX_MAP AdapterInfo;
|
IP_ADAPTER_INDEX_MAP AdapterInfo;
|
||||||
|
DWORD i;
|
||||||
|
|
||||||
/* if interface is not given, query GetInterfaceInfo */
|
/* if interface is not given, query GetInterfaceInfo */
|
||||||
if (Index == NULL)
|
if (Index == NULL)
|
||||||
|
@ -603,8 +604,19 @@ VOID Renew(LPTSTR Index)
|
||||||
/* Make a second call to GetInterfaceInfo to get the actual data we want */
|
/* Make a second call to GetInterfaceInfo to get the actual data we want */
|
||||||
if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
|
if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
|
||||||
{
|
{
|
||||||
CopyMemory(&AdapterInfo, &pInfo->Adapter[0], sizeof(IP_ADAPTER_INDEX_MAP));
|
for (i = 0; i < pInfo->NumAdapters; i++)
|
||||||
_tprintf(_T("name - %S\n"), pInfo->Adapter[0].Name);
|
{
|
||||||
|
CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
|
||||||
|
_tprintf(_T("name - %S\n"), pInfo->Adapter[i].Name);
|
||||||
|
|
||||||
|
|
||||||
|
/* Call IpRenewAddress to renew the IP address on the specified adapter. */
|
||||||
|
if (IpRenewAddress(&AdapterInfo) != NO_ERROR)
|
||||||
|
{
|
||||||
|
_tprintf(_T("\nAn error occured while renew interface %s : "), _T("*name*"));
|
||||||
|
DoFormatMessage(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -623,14 +635,6 @@ VOID Renew(LPTSTR Index)
|
||||||
* ipconfig /renew *con* will renew all cards with 'con' in their name
|
* ipconfig /renew *con* will renew all cards with 'con' in their name
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Call IpRenewAddress to renew the IP address on the specified adapter. */
|
|
||||||
if (IpRenewAddress(&AdapterInfo) != NO_ERROR)
|
|
||||||
{
|
|
||||||
_tprintf(_T("\nAn error occured while renew interface %s : "), _T("*name*"));
|
|
||||||
DoFormatMessage(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,14 @@ DWORD DSQueryHWInfo( PipeSendFunc Send, COMM_DHCP_REQ *Req ) {
|
||||||
|
|
||||||
Adapter = AdapterFindIndex( Req->AdapterIndex );
|
Adapter = AdapterFindIndex( Req->AdapterIndex );
|
||||||
|
|
||||||
Reply.QueryHWInfo.AdapterIndex = Req->AdapterIndex;
|
Reply.Reply = Adapter ? 1 : 0;
|
||||||
Reply.QueryHWInfo.MediaType = Adapter->IfMib.dwType;
|
|
||||||
Reply.QueryHWInfo.Mtu = Adapter->IfMib.dwMtu;
|
if (Adapter) {
|
||||||
Reply.QueryHWInfo.Speed = Adapter->IfMib.dwSpeed;
|
Reply.QueryHWInfo.AdapterIndex = Req->AdapterIndex;
|
||||||
|
Reply.QueryHWInfo.MediaType = Adapter->IfMib.dwType;
|
||||||
|
Reply.QueryHWInfo.Mtu = Adapter->IfMib.dwMtu;
|
||||||
|
Reply.QueryHWInfo.Speed = Adapter->IfMib.dwSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
ApiUnlock();
|
ApiUnlock();
|
||||||
|
|
||||||
|
@ -99,14 +103,13 @@ DWORD DSRenewIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req ) {
|
||||||
|
|
||||||
Adapter = AdapterFindIndex( Req->AdapterIndex );
|
Adapter = AdapterFindIndex( Req->AdapterIndex );
|
||||||
|
|
||||||
Reply.Reply = Adapter ? 1 : 0;
|
|
||||||
|
|
||||||
if( !Adapter || Adapter->DhclientState.state != S_BOUND ) {
|
if( !Adapter || Adapter->DhclientState.state != S_BOUND ) {
|
||||||
Reply.Reply = 0;
|
Reply.Reply = 0;
|
||||||
|
ApiUnlock();
|
||||||
return Send( &Reply );
|
return Send( &Reply );
|
||||||
}
|
}
|
||||||
|
|
||||||
Adapter->DhclientState.state = S_BOUND;
|
Reply.Reply = 1;
|
||||||
|
|
||||||
send_discover( &Adapter->DhclientInfo );
|
send_discover( &Adapter->DhclientInfo );
|
||||||
state_bound( &Adapter->DhclientInfo );
|
state_bound( &Adapter->DhclientInfo );
|
||||||
|
|
|
@ -89,7 +89,7 @@ DWORD WINAPI PipeThreadProc( LPVOID Parameter ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE PipeInit() {
|
HANDLE PipeInit() {
|
||||||
CommPipe = CreateNamedPipe
|
CommPipe = CreateNamedPipeW
|
||||||
( DHCP_PIPE_NAME,
|
( DHCP_PIPE_NAME,
|
||||||
PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE,
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE,
|
||||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<importlibrary definition="iphlpapi.spec" />
|
<importlibrary definition="iphlpapi.spec" />
|
||||||
<include base="iphlpapi">.</include>
|
<include base="iphlpapi">.</include>
|
||||||
<include base="ReactOS">include/reactos/wine</include>
|
<include base="ReactOS">include/reactos/wine</include>
|
||||||
|
<include base="dhcp">include</include>
|
||||||
<library>wine</library>
|
<library>wine</library>
|
||||||
<library>ntdll</library>
|
<library>ntdll</library>
|
||||||
<library>kernel32</library>
|
<library>kernel32</library>
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
#include "resinfo.h"
|
#include "resinfo.h"
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
#include "dhcpcsdk.h"
|
||||||
|
#include "dhcp/rosdhcp_public.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
||||||
|
|
||||||
|
@ -1880,19 +1882,33 @@ DWORD WINAPI GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIP
|
||||||
* Success: NO_ERROR
|
* Success: NO_ERROR
|
||||||
* Failure: error code from winerror.h
|
* Failure: error code from winerror.h
|
||||||
*
|
*
|
||||||
* NOTES
|
|
||||||
* Since GetAdaptersInfo never returns adapters that have DHCP enabled,
|
|
||||||
* this function does nothing.
|
|
||||||
*
|
|
||||||
* FIXME
|
|
||||||
* Stub, returns ERROR_NOT_SUPPORTED.
|
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
||||||
{
|
{
|
||||||
|
COMM_DHCP_REPLY Reply;
|
||||||
|
COMM_DHCP_REQ Request;
|
||||||
|
DWORD BytesRead;
|
||||||
|
|
||||||
|
Request.AdapterIndex = AdapterInfo->Index;
|
||||||
|
Request.Type = DhcpReqReleaseIpAddress;
|
||||||
|
|
||||||
TRACE("AdapterInfo %p\n", AdapterInfo);
|
TRACE("AdapterInfo %p\n", AdapterInfo);
|
||||||
/* not a stub, never going to support this (and I never mark an adapter as
|
|
||||||
DHCP enabled, see GetAdaptersInfo, so this should never get called) */
|
if (CallNamedPipe(DHCP_PIPE_NAME,
|
||||||
return ERROR_NOT_SUPPORTED;
|
&Request,
|
||||||
|
sizeof(Request),
|
||||||
|
&Reply,
|
||||||
|
sizeof(Reply),
|
||||||
|
&BytesRead,
|
||||||
|
NMPWAIT_USE_DEFAULT_WAIT))
|
||||||
|
{
|
||||||
|
if (Reply.Reply)
|
||||||
|
return NO_ERROR;
|
||||||
|
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_PROC_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1907,20 +1923,33 @@ DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: NO_ERROR
|
* Success: NO_ERROR
|
||||||
* Failure: error code from winerror.h
|
* Failure: error code from winerror.h
|
||||||
*
|
|
||||||
* NOTES
|
|
||||||
* Since GetAdaptersInfo never returns adapters that have DHCP enabled,
|
|
||||||
* this function does nothing.
|
|
||||||
*
|
|
||||||
* FIXME
|
|
||||||
* Stub, returns ERROR_NOT_SUPPORTED.
|
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
||||||
{
|
{
|
||||||
|
COMM_DHCP_REPLY Reply;
|
||||||
|
COMM_DHCP_REQ Request;
|
||||||
|
DWORD BytesRead;
|
||||||
|
|
||||||
|
Request.AdapterIndex = AdapterInfo->Index;
|
||||||
|
Request.Type = DhcpReqRenewIpAddress;
|
||||||
|
|
||||||
TRACE("AdapterInfo %p\n", AdapterInfo);
|
TRACE("AdapterInfo %p\n", AdapterInfo);
|
||||||
/* not a stub, never going to support this (and I never mark an adapter as
|
|
||||||
DHCP enabled, see GetAdaptersInfo, so this should never get called) */
|
if (CallNamedPipe(DHCP_PIPE_NAME,
|
||||||
return ERROR_NOT_SUPPORTED;
|
&Request,
|
||||||
|
sizeof(Request),
|
||||||
|
&Reply,
|
||||||
|
sizeof(Reply),
|
||||||
|
&BytesRead,
|
||||||
|
NMPWAIT_USE_DEFAULT_WAIT))
|
||||||
|
{
|
||||||
|
if (Reply.Reply)
|
||||||
|
return NO_ERROR;
|
||||||
|
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_PROC_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,6 @@ typedef union _COMM_DHCP_REPLY {
|
||||||
} GetAdapterInfo;
|
} GetAdapterInfo;
|
||||||
} COMM_DHCP_REPLY;
|
} COMM_DHCP_REPLY;
|
||||||
|
|
||||||
#define DHCP_PIPE_NAME "\\\\.\\pipe\\dhcpclient"
|
#define DHCP_PIPE_NAME L"\\\\.\\pipe\\dhcpclient"
|
||||||
|
|
||||||
#endif/*ROSDHCP_PUBLIC_H*/
|
#endif/*ROSDHCP_PUBLIC_H*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue