Author: cgutman
Date: Thu Jan 12 03:12:49 2012
New Revision: 54917
URL:
http://svn.reactos.org/svn/reactos?rev=54917&view=rev
Log:
- Merge 54895, 54896, 54899, 54912, 54913, 54915, and 54916 from wlan-bringup
Modified:
trunk/reactos/ (props changed)
trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c
trunk/reactos/dll/win32/dhcpcsvc/dhcp/api.c
trunk/reactos/dll/win32/dhcpcsvc/dhcp/dispatch.c
trunk/reactos/drivers/network/dd/pcnet/requests.c
trunk/reactos/drivers/network/ndis/ndis/time.c
trunk/reactos/drivers/network/tcpip/datalink/lan.c
trunk/reactos/lib/drivers/ip/network/interface.c
Propchange: trunk/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 12 03:12:49 2012
@@ -10,3 +10,4 @@
/branches/ros-amd64-bringup/reactos:34711-34712,34741,34743,34770,34780-34782,34803,34812,34839,34842,34864,34870,34874,34877,34908-34909,34917,34965,35323-35324,35347-35348,35361,35436,35509,35515,35588,35655,35683,35739,35746,35762,35771,35777,35781,35789,35805,35823,35827,35902,35904-35906,35942,35947-35949,35952-35953,35966,36011-36013,36172,36360,36380,36388-36389,36393,36397,36443,36445,36475,36502-36503,36505,36570,36614,36852,36898-36899,36930,36936,36949,36951,36958,36961,36964,36969,36972,36987-36988,36990,36992,37019,37322-37323,37333-37334,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38092,38100,38148-38151,38264-38265,38268,38355,39151,39333,39335,39345,39639,40120,40122-40123,40125,40127-40128,40155,40247,40324,40608,40753,40926-40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41030,41044-41045,41047-41050,41052,41070,41082-41086,41097-41098,41101,41449,41479-41480,41483-41485,41499-41500,41502,41531,41536,41540,41546-41547,41549,43080,43426,43451,43454,43506,43566,43574,43598,43600-43602,43604-43605,43677,43682,43757,43775,43836,43838-43840,43852,43857-43858,43860,43905-43907,43952,43954,43965,43969,43979,43981,43992,44002,44036-44037,44039-44040,44044-44045,44053,44065,44095,44123,44143-44144,44205,44238,44257,44259,44294,44338-44339,44385,44389,44391,44426,44460,44467-44468,44470-44471,44499,44501,44503-44504,44506,44510-44512,44521,44523-44526,44530,44540,44601,44634,44639,44772,44818,45124,45126-45127,45430,46394,46404,46478,46511,46523-46524,46526,46534-46535,46537-46539,46589,46805,46868,47472,47846-47847,47878,47882
/branches/shell32_new-bringup:51893-53652,53661,53700
/branches/tcp-rewrite-branch:48720,48840-48841,49424-49426,49454
+/branches/wlan-bringup:54895-54896,54899,54912-54913,54915-54916
Modified: trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/dhcp/ad…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/dhcp/adapter.c [iso-8859-1] Thu Jan 12 03:12:49 2012
@@ -1,6 +1,6 @@
#include "rosdhcp.h"
-static SOCKET DhcpSocket = INVALID_SOCKET;
+SOCKET DhcpSocket = INVALID_SOCKET;
static LIST_ENTRY AdapterList;
static WSADATA wsd;
@@ -209,6 +209,7 @@
PDHCP_ADAPTER Adapter = NULL;
HANDLE AdapterStateChangedEvent = (HANDLE)Context;
struct interface_info *ifi = NULL;
+ struct protocol *proto;
int i, AdapterCount = 0, Broadcast;
/* FIXME: Kill this thread when the service is stopped */
@@ -245,6 +246,10 @@
/* We're still active so we stay in the list */
ifi = &Adapter->DhclientInfo;
} else {
+ proto = find_protocol_by_adapter(&Adapter->DhclientInfo);
+ if (proto)
+ remove_protocol(proto);
+
/* We've lost our link so out we go */
RemoveEntryList(&Adapter->ListEntry);
free(Adapter);
@@ -330,7 +335,7 @@
Adapter->DhclientInfo.rfdesc,
got_one, &Adapter->DhclientInfo);
- state_init(&Adapter->DhclientInfo);
+ state_init(&Adapter->DhclientInfo);
}
ApiLock();
@@ -345,15 +350,12 @@
DH_DbgPrint(MID_TRACE,("Adapter %d was rejected\n",
Table->table[i].dwIndex));
}
+#if 0
Error = NotifyAddrChange(NULL, NULL);
-#if 0
if (Error != NO_ERROR)
break;
#else
- if (AdapterCount)
- break;
- else
- Sleep(3000);
+ Sleep(3000);
#endif
} while (TRUE);
@@ -364,14 +366,13 @@
}
HANDLE StartAdapterDiscovery(VOID) {
- HANDLE /* ThreadHandle, */ EventHandle;
+ HANDLE ThreadHandle, EventHandle;
EventHandle = CreateEvent(NULL,
FALSE,
FALSE,
NULL);
-#if 0
ThreadHandle = CreateThread(NULL,
0,
AdapterDiscoveryThread,
@@ -383,9 +384,6 @@
return NULL;
CloseHandle(ThreadHandle);
-#else
- AdapterDiscoveryThread((LPVOID)EventHandle);
-#endif
return EventHandle;
}
Modified: trunk/reactos/dll/win32/dhcpcsvc/dhcp/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/dhcp/ap…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/dhcp/api.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/dhcp/api.c [iso-8859-1] Thu Jan 12 03:12:49 2012
@@ -14,6 +14,8 @@
static CRITICAL_SECTION ApiCriticalSection;
+extern HANDLE AdapterStateChangedEvent;
+
VOID ApiInit() {
InitializeCriticalSection( &ApiCriticalSection );
}
@@ -35,19 +37,28 @@
DWORD DSLeaseIpAddress( PipeSendFunc Send, COMM_DHCP_REQ *Req ) {
COMM_DHCP_REPLY Reply;
PDHCP_ADAPTER Adapter;
-
- ApiLock();
-
- Adapter = AdapterFindIndex( Req->AdapterIndex );
-
- Reply.Reply = Adapter ? 1 : 0;
-
- if( Adapter ) {
+ struct protocol* proto;
+
+ ApiLock();
+
+ Adapter = AdapterFindIndex( Req->AdapterIndex );
+
+ Reply.Reply = Adapter ? 1 : 0;
+
+ if( Adapter ) {
+ proto = find_protocol_by_adapter( &Adapter->DhclientInfo );
+ if (proto)
+ remove_protocol(proto);
+
add_protocol( Adapter->DhclientInfo.name,
Adapter->DhclientInfo.rfdesc, got_one,
&Adapter->DhclientInfo );
- Adapter->DhclientInfo.client->state = S_INIT;
- state_reboot(&Adapter->DhclientInfo);
+
+ Adapter->DhclientInfo.client->state = S_INIT;
+ state_reboot(&Adapter->DhclientInfo);
+
+ if (AdapterStateChangedEvent != NULL)
+ SetEvent(AdapterStateChangedEvent);
}
ApiUnlock();
@@ -91,10 +102,18 @@
if( Adapter ) {
if (Adapter->NteContext)
DeleteIPAddress( Adapter->NteContext );
+ if (Adapter->RouterMib.dwForwardNextHop)
+ DeleteIpForwardEntry( &Adapter->RouterMib );
proto = find_protocol_by_adapter( &Adapter->DhclientInfo );
if (proto)
remove_protocol(proto);
+
+ Adapter->DhclientInfo.client->active = NULL;
+ Adapter->DhclientInfo.client->state = S_INIT;
+
+ if (AdapterStateChangedEvent != NULL)
+ SetEvent(AdapterStateChangedEvent);
}
ApiUnlock();
@@ -105,6 +124,7 @@
DWORD DSRenewIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req ) {
COMM_DHCP_REPLY Reply;
PDHCP_ADAPTER Adapter;
+ struct protocol* proto;
ApiLock();
@@ -118,12 +138,20 @@
Reply.Reply = 1;
+ proto = find_protocol_by_adapter( &Adapter->DhclientInfo );
+ if (proto)
+ remove_protocol(proto);
+
add_protocol( Adapter->DhclientInfo.name,
Adapter->DhclientInfo.rfdesc, got_one,
&Adapter->DhclientInfo );
+
Adapter->DhclientInfo.client->state = S_INIT;
state_reboot(&Adapter->DhclientInfo);
+ if (AdapterStateChangedEvent != NULL)
+ SetEvent(AdapterStateChangedEvent);
+
ApiUnlock();
return Send( &Reply );
@@ -144,6 +172,9 @@
if( Adapter ) {
if (Adapter->NteContext)
DeleteIPAddress( Adapter->NteContext );
+ if (Adapter->RouterMib.dwForwardNextHop)
+ DeleteIpForwardEntry( &Adapter->RouterMib );
+
Adapter->DhclientState.state = S_STATIC;
proto = find_protocol_by_adapter( &Adapter->DhclientInfo );
if (proto)
@@ -154,6 +185,9 @@
&Adapter->NteContext,
&Adapter->NteInstance );
Reply.Reply = NT_SUCCESS(Status);
+
+ if (AdapterStateChangedEvent != NULL)
+ SetEvent(AdapterStateChangedEvent);
}
ApiUnlock();
Modified: trunk/reactos/dll/win32/dhcpcsvc/dhcp/dispatch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/dhcp/di…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/dhcp/dispatch.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/dhcp/dispatch.c [iso-8859-1] Thu Jan 12 03:12:49
2012
@@ -47,6 +47,8 @@
//#include <ifaddrs.h>
//#include <poll.h>
+extern SOCKET DhcpSocket;
+HANDLE AdapterStateChangedEvent = NULL;
struct protocol *protocols = NULL;
struct timeout *timeouts = NULL;
static struct timeout *free_timeouts = NULL;
@@ -63,17 +65,19 @@
void
dispatch(void)
{
- int count, to_msec, err;
+ int count, to_msec;
struct protocol *l;
- fd_set fds;
time_t howlong, cur_time;
- struct timeval timeval;
- HANDLE AdapterStateChangedEvent;
-
- AdapterStateChangedEvent = StartAdapterDiscovery();
- if (!AdapterStateChangedEvent)
+ HANDLE Events[2];
+ int EventCount = 1;
+
+ Events[0] = StartAdapterDiscovery();
+ if (!Events[0])
return;
-
+ AdapterStateChangedEvent = Events[0];
+
+ Events[1] = WSA_INVALID_EVENT;
+
ApiLock();
do {
@@ -83,7 +87,8 @@
*/
time(&cur_time);
- if (timeouts) {
+ if (timeouts)
+ {
struct timeout *t;
if (timeouts->when <= cur_time) {
@@ -105,55 +110,75 @@
if (howlong > INT_MAX / 1000)
howlong = INT_MAX / 1000;
to_msec = howlong * 1000;
-
- /* Set up the descriptors to be polled. */
- FD_ZERO(&fds);
-
- for (l = protocols; l; l = l->next)
- FD_SET(l->fd, &fds);
-
- /* Wait for a packet or a timeout... XXX */
- timeval.tv_sec = to_msec / 1000;
- timeval.tv_usec = to_msec % 1000;
-
- ApiUnlock();
-
- count = select(0, &fds, NULL, NULL, &timeval);
-
- ApiLock();
}
else
{
- ApiUnlock();
- WaitForSingleObject(AdapterStateChangedEvent, INFINITE);
- ApiLock();
-
+ to_msec = INFINITE;
+ }
+
+ if (Events[1] == WSA_INVALID_EVENT && DhcpSocket != INVALID_SOCKET)
+ {
+ Events[1] = WSACreateEvent();
+ if (Events[1] != WSA_INVALID_EVENT)
+ {
+ count = WSAEventSelect(DhcpSocket, Events[1], FD_READ | FD_CLOSE);
+ if (count != NO_ERROR)
+ {
+ WSACloseEvent(Events[1]);
+ Events[1] = WSA_INVALID_EVENT;
+ }
+ else
+ {
+ EventCount = 2;
+ }
+ }
+ }
+ else if (Events[1] != WSA_INVALID_EVENT && DhcpSocket == INVALID_SOCKET)
+ {
+ WSACloseEvent(Events[1]);
+ Events[1] = WSA_INVALID_EVENT;
+
+ EventCount = 1;
+ }
+
+ ApiUnlock();
+ count = WaitForMultipleObjects(EventCount,
+ Events,
+ FALSE,
+ to_msec);
+ ApiLock();
+ if (count == WAIT_OBJECT_0)
+ {
+ /* Adapter state change */
continue;
}
-
- DH_DbgPrint(MID_TRACE,("Select: %d\n", count));
-
- /* Not likely to be transitory... */
- if (count == SOCKET_ERROR) {
- err = WSAGetLastError();
- error("poll: %d", err);
- break;
+ else if (count == WAIT_OBJECT_0 + 1)
+ {
+ /* Packet received */
+
+ /* WSA events are manual reset events */
+ WSAResetEvent(Events[1]);
+ }
+ else
+ {
+ /* Timeout */
+ continue;
}
for (l = protocols; l; l = l->next) {
struct interface_info *ip;
ip = l->local;
- if (FD_ISSET(l->fd, &fds)) {
- if (ip && (l->handler != got_one ||
- !ip->dead)) {
- DH_DbgPrint(MID_TRACE,("Handling %x\n", l));
- (*(l->handler))(l);
- }
+ if (ip && (l->handler != got_one ||
+ !ip->dead)) {
+ DH_DbgPrint(MID_TRACE,("Handling %x\n", l));
+ (*(l->handler))(l);
}
}
} while (1);
- CloseHandle(AdapterStateChangedEvent);
+ AdapterStateChangedEvent = NULL;
+ CloseHandle(Events[0]);
+ WSACloseEvent(Events[1]);
ApiUnlock();
}
@@ -327,6 +352,41 @@
remove_protocol(struct protocol *proto)
{
struct protocol *p, *next, *prev;
+ struct interface_info *ip = proto->local;
+ struct timeout *t, *q, *u;
+
+ t = NULL;
+ q = timeouts;
+ while (q != NULL)
+ {
+ /* Remove all timeouts for this protocol */
+ if (q->what == ip)
+ {
+ /* Unlink the timeout from previous */
+ if (t)
+ t->next = q->next;
+ else
+ timeouts = q->next;
+
+ /* Advance to the next timeout */
+ u = q->next;
+
+ /* Add it to the free list */
+ q->next = free_timeouts;
+ free_timeouts = q;
+ }
+ else
+ {
+ /* Advance to the next timeout */
+ u = q->next;
+
+ /* Update the previous pointer */
+ t = q;
+ }
+
+ /* Advance */
+ q = u;
+ }
prev = NULL;
for (p = protocols; p; p = next) {
Modified: trunk/reactos/drivers/network/dd/pcnet/requests.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/r…
==============================================================================
--- trunk/reactos/drivers/network/dd/pcnet/requests.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/pcnet/requests.c [iso-8859-1] Thu Jan 12 03:12:49
2012
@@ -266,7 +266,7 @@
case OID_GEN_MEDIA_CONNECT_STATUS:
{
- GenericULONG = Adapter->MediaState;
+ GenericULONG = (ULONG)NdisMediaStateConnected; /* Adapter->MediaState */
break;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/time.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/time.c [iso-8859-1] Thu Jan 12 03:12:49 2012
@@ -57,10 +57,9 @@
* ARGUMENTS:
* pSystemTime: pointer to the returned system time
* NOTES:
- * - call at IRQL <= DISPATCH_LEVEL
- */
-{
- ASSERT_IRQL(DISPATCH_LEVEL);
+ * - call at any IRQL
+ */
+{
ASSERT(pSystemTime);
KeQuerySystemTime (pSystemTime);
Modified: trunk/reactos/drivers/network/tcpip/datalink/lan.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/data…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Thu Jan 12 03:12:49
2012
@@ -185,7 +185,9 @@
case OID_GEN_HARDWARE_STATUS:
*Result = NdisHardwareStatusReady;
return STATUS_SUCCESS;
-
+ case OID_GEN_MEDIA_CONNECT_STATUS:
+ *Result = NdisMediaStateConnected;
+ return STATUS_SUCCESS;
default:
return STATUS_INVALID_PARAMETER;
}
Modified: trunk/reactos/lib/drivers/ip/network/interface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/int…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] Thu Jan 12 03:12:49
2012
@@ -196,27 +196,26 @@
return NULL;
}
-NTSTATUS GetInterfaceConnectionStatus
-( PIP_INTERFACE Interface, PULONG Result ) {
- NTSTATUS Status = TcpipLanGetDwordOid
- ( Interface, OID_GEN_HARDWARE_STATUS, Result );
- if( NT_SUCCESS(Status) ) switch( *Result ) {
- case NdisHardwareStatusReady:
+NTSTATUS GetInterfaceConnectionStatus(PIP_INTERFACE Interface, PULONG Result)
+{
+ NTSTATUS Status;
+
+ /* Query OID_GEN_MEDIA_CONNECT_STATUS for connection status information */
+ Status = TcpipLanGetDwordOid(Interface, OID_GEN_MEDIA_CONNECT_STATUS, Result);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Translate the result into MIB_IF_OPER_STATUS_XXX */
+ if (*Result == NdisMediaStateConnected)
+ {
+ /* Up and running */
*Result = MIB_IF_OPER_STATUS_OPERATIONAL;
- break;
- case NdisHardwareStatusInitializing:
- *Result = MIB_IF_OPER_STATUS_CONNECTING;
- break;
- case NdisHardwareStatusReset:
+ }
+ else
+ {
+ /* Down */
*Result = MIB_IF_OPER_STATUS_DISCONNECTED;
- break;
- case NdisHardwareStatusNotReady:
- *Result = MIB_IF_OPER_STATUS_DISCONNECTED;
- break;
- case NdisHardwareStatusClosing:
- default:
- *Result = MIB_IF_OPER_STATUS_NON_OPERATIONAL;
- break;
- }
- return Status;
-}
+ }
+
+ return STATUS_SUCCESS;
+}