Author: cgutman
Date: Sat Jul 25 21:51:54 2009
New Revision: 42217
URL:
http://svn.reactos.org/svn/reactos?rev=42217&view=rev
Log:
- Make ipconfig /renew work even if we haven't got an address yet
- Fix several potential crashes
- Fix an infinite loop caused by us sending a discover packet without adding a protocol
first (this is exposed by releasing then renewing)
- Fixes bug 4630
Modified:
trunk/reactos/base/services/dhcp/api.c
Modified: trunk/reactos/base/services/dhcp/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/api.c?r…
==============================================================================
--- trunk/reactos/base/services/dhcp/api.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/api.c [iso-8859-1] Sat Jul 25 21:51:54 2009
@@ -78,6 +78,7 @@
DWORD DSReleaseIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req ) {
COMM_DHCP_REPLY Reply;
PDHCP_ADAPTER Adapter;
+ struct protocol* proto;
ApiLock();
@@ -86,8 +87,12 @@
Reply.Reply = Adapter ? 1 : 0;
if( Adapter ) {
- DeleteIPAddress( Adapter->NteContext );
- remove_protocol( find_protocol_by_adapter( &Adapter->DhclientInfo ) );
+ if (Adapter->NteContext)
+ DeleteIPAddress( Adapter->NteContext );
+
+ proto = find_protocol_by_adapter( &Adapter->DhclientInfo );
+ if (proto)
+ remove_protocol(proto);
}
ApiUnlock();
@@ -103,7 +108,7 @@
Adapter = AdapterFindIndex( Req->AdapterIndex );
- if( !Adapter || Adapter->DhclientState.state != S_BOUND ) {
+ if( !Adapter || Adapter->DhclientState.state == S_STATIC ) {
Reply.Reply = 0;
ApiUnlock();
return Send( &Reply );
@@ -111,8 +116,11 @@
Reply.Reply = 1;
- send_discover( &Adapter->DhclientInfo );
- state_bound( &Adapter->DhclientInfo );
+ add_protocol( Adapter->DhclientInfo.name,
+ Adapter->DhclientInfo.rfdesc, got_one,
+ &Adapter->DhclientInfo );
+ Adapter->DhclientInfo.client->state = S_INIT;
+ state_reboot(&Adapter->DhclientInfo);
ApiUnlock();
@@ -123,6 +131,7 @@
NTSTATUS Status;
COMM_DHCP_REPLY Reply;
PDHCP_ADAPTER Adapter;
+ struct protocol* proto;
ApiLock();
@@ -131,9 +140,12 @@
Reply.Reply = Adapter ? 1 : 0;
if( Adapter ) {
- DeleteIPAddress( Adapter->NteContext );
+ if (Adapter->NteContext)
+ DeleteIPAddress( Adapter->NteContext );
Adapter->DhclientState.state = S_STATIC;
- remove_protocol( find_protocol_by_adapter( &Adapter->DhclientInfo ) );
+ proto = find_protocol_by_adapter( &Adapter->DhclientInfo );
+ if (proto)
+ remove_protocol(proto);
Status = AddIPAddress( Req->Body.StaticRefreshParams.IPAddress,
Req->Body.StaticRefreshParams.Netmask,
Req->AdapterIndex,