Author: cgutman
Date: Tue Nov 2 04:57:37 2010
New Revision: 49426
URL:
http://svn.reactos.org/svn/reactos?rev=49426&view=rev
Log:
[LWIP]
- Fix build and a few implementation bugs
Modified:
branches/tcp-rewrite-branch/lib/drivers/lwip/lwip.rbuild
branches/tcp-rewrite-branch/lib/drivers/lwip/src/api/tcpip.c
branches/tcp-rewrite-branch/lib/drivers/lwip/src/include/arch/sys_arch.h
branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c
Modified: branches/tcp-rewrite-branch/lib/drivers/lwip/lwip.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/tcp-rewrite-branch/lib/drivers/…
==============================================================================
--- branches/tcp-rewrite-branch/lib/drivers/lwip/lwip.rbuild [iso-8859-1] (original)
+++ branches/tcp-rewrite-branch/lib/drivers/lwip/lwip.rbuild [iso-8859-1] Tue Nov 2
04:57:37 2010
@@ -45,12 +45,12 @@
<file>ip_addr.c</file>
<file>ip_frag.c</file>
</directory>
- <directory name="ipv6">
+ <!--directory name="ipv6">
<file>icmp6.c</file>
<file>inet6.c</file>
<file>ip6_addr.c</file>
<file>ip6.c</file>
- </directory>
+ </directory-->
<directory name="snmp">
<file>asn1_dec.c</file>
<file>asn1_enc.c</file>
Modified: branches/tcp-rewrite-branch/lib/drivers/lwip/src/api/tcpip.c
URL:
http://svn.reactos.org/svn/reactos/branches/tcp-rewrite-branch/lib/drivers/…
==============================================================================
--- branches/tcp-rewrite-branch/lib/drivers/lwip/src/api/tcpip.c [iso-8859-1] (original)
+++ branches/tcp-rewrite-branch/lib/drivers/lwip/src/api/tcpip.c [iso-8859-1] Tue Nov 2
04:57:37 2010
@@ -46,6 +46,7 @@
#include "lwip/pbuf.h"
#include "lwip/tcpip.h"
#include "lwip/init.h"
+#include "lwip/ip.h"
#include "netif/etharp.h"
#include "netif/ppp_oe.h"
Modified: branches/tcp-rewrite-branch/lib/drivers/lwip/src/include/arch/sys_arch.h
URL:
http://svn.reactos.org/svn/reactos/branches/tcp-rewrite-branch/lib/drivers/…
==============================================================================
--- branches/tcp-rewrite-branch/lib/drivers/lwip/src/include/arch/sys_arch.h [iso-8859-1]
(original)
+++ branches/tcp-rewrite-branch/lib/drivers/lwip/src/include/arch/sys_arch.h [iso-8859-1]
Tue Nov 2 04:57:37 2010
@@ -1,20 +1,21 @@
/* ReactOS-Specific lwIP binding header - by Cameron Gutman */
/* Implmentation specific structs */
-typedef KEVENT sys_sem_t;
+typedef struct _sys_sem_t
+{
+ KEVENT Event;
+ int Valid;
+} sys_sem_t;
typedef struct _sys_mbox_t
{
KSPIN_LOCK Lock;
LIST_ENTRY ListHead;
KEVENT Event;
+ int Valid;
} sys_mbox_t;
-typedef struct _sys_prot_t
-{
- KSPIN_LOCK Lock;
- KIRQL OldIrql;
-} sys_prot_t;
+typedef KIRQL sys_prot_t;
typedef u32_t sys_thread_t;
@@ -35,10 +36,7 @@
sys_arch_protect(sys_prot_t *lev);
void
-sys_arch_unprotect(sys_prot_t *lev);
-
-void
-sys_arch_decl_protect(sys_prot_t *lev);
+sys_arch_unprotect(sys_prot_t lev);
void
sys_shutdown(void);
Modified: branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c
URL:
http://svn.reactos.org/svn/reactos/branches/tcp-rewrite-branch/lib/drivers/…
==============================================================================
--- branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] (original)
+++ branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] Tue Nov 2
04:57:37 2010
@@ -15,13 +15,10 @@
typedef struct _thread_t
{
- PVOID ThreadId;
HANDLE Handle;
- struct sys_timeouts Timeouts;
void (* ThreadFunction)(void *arg);
void *ThreadContext;
LIST_ENTRY ListEntry;
- char Name[1];
} *thread_t;
u32_t sys_now(void)
@@ -36,23 +33,14 @@
void
sys_arch_protect(sys_prot_t *lev)
{
- KIRQL OldIrql;
-
- KeAcquireSpinLock(&lev->Lock, &OldIrql);
-
- lev->OldIrql = OldIrql;
-}
-
-void
-sys_arch_unprotect(sys_prot_t *lev)
-{
- KeReleaseSpinLock(&lev->Lock, lev->OldIrql);
-}
-
-void
-sys_arch_decl_protect(sys_prot_t *lev)
-{
- KeInitializeSpinLock(&lev->Lock);
+ /* Preempt the dispatcher */
+ KeRaiseIrql(DISPATCH_LEVEL, lev);
+}
+
+void
+sys_arch_unprotect(sys_prot_t lev)
+{
+ KeLowerIrql(lev);
}
err_t
@@ -64,21 +52,35 @@
* so I optimize for this case by using a synchronization event and setting its
initial state
* to signalled for a lock and non-signalled for a completion event */
- KeInitializeEvent(sem, SynchronizationEvent, count);
+ KeInitializeEvent(&sem->Event, SynchronizationEvent, count);
+
+ sem->Valid = 1;
return ERR_OK;
}
+int sys_sem_valid(sys_sem_t *sem)
+{
+ return sem->Valid;
+}
+
+void sys_sem_set_invalid(sys_sem_t *sem)
+{
+ sem->Valid = 0;
+}
+
void
sys_sem_free(sys_sem_t* sem)
{
/* No op (allocated in stack) */
+
+ sys_sem_set_invalid(sem);
}
void
sys_sem_signal(sys_sem_t* sem)
{
- KeSetEvent(sem, IO_NO_INCREMENT, FALSE);
+ KeSetEvent(&sem->Event, IO_NO_INCREMENT, FALSE);
}
u32_t
@@ -87,7 +89,7 @@
LARGE_INTEGER LargeTimeout, PreWaitTime, PostWaitTime;
UINT64 TimeDiff;
NTSTATUS Status;
- PVOID WaitObjects[] = {sem, &TerminationEvent};
+ PVOID WaitObjects[] = {&sem->Event, &TerminationEvent};
LargeTimeout.QuadPart = Int32x32To64(timeout, -10000);
@@ -131,15 +133,27 @@
KeInitializeEvent(&mbox->Event, NotificationEvent, FALSE);
+ mbox->Valid = 1;
+
return ERR_OK;
}
+int sys_mbox_valid(sys_mbox_t *mbox)
+{
+ return mbox->Valid;
+}
+
+void sys_mbox_set_invalid(sys_mbox_t *mbox)
+{
+ mbox->Valid = 0;
+}
+
void
sys_mbox_free(sys_mbox_t *mbox)
{
ASSERT(IsListEmpty(&mbox->ListHead));
- /* No op (allocated on stack) */
+ sys_mbox_set_invalid(mbox);
}
void
@@ -236,43 +250,6 @@
return ERR_OK;
}
-struct sys_timeouts *sys_arch_timeouts(void)
-{
- KIRQL OldIrql;
- PLIST_ENTRY CurrentEntry;
- thread_t Container;
-
- KeAcquireSpinLock(&ThreadListLock, &OldIrql);
- CurrentEntry = ThreadListHead.Flink;
- while (CurrentEntry != &ThreadListHead)
- {
- Container = CONTAINING_RECORD(CurrentEntry, struct _thread_t, ListEntry);
-
- if (Container->ThreadId == KeGetCurrentThread())
- {
- KeReleaseSpinLock(&ThreadListLock, OldIrql);
- return &Container->Timeouts;
- }
-
- CurrentEntry = CurrentEntry->Flink;
- }
- KeReleaseSpinLock(&ThreadListLock, OldIrql);
-
- Container = ExAllocatePool(NonPagedPool, sizeof(*Container));
- if (!Container)
- return SYS_ARCH_NULL;
-
- Container->Name[0] = ANSI_NULL;
- Container->ThreadFunction = NULL;
- Container->ThreadContext = NULL;
- Container->Timeouts.next = NULL;
- Container->ThreadId = KeGetCurrentThread();
-
- ExInterlockedInsertHeadList(&ThreadListHead, &Container->ListEntry,
&ThreadListLock);
-
- return &Container->Timeouts;
-}
-
VOID
NTAPI
LwipThreadMain(PVOID Context)
@@ -280,8 +257,6 @@
thread_t Container = Context;
KIRQL OldIrql;
- Container->ThreadId = KeGetCurrentThread();
-
ExInterlockedInsertHeadList(&ThreadListHead, &Container->ListEntry,
&ThreadListLock);
Container->ThreadFunction(Container->ThreadContext);
@@ -301,14 +276,12 @@
thread_t Container;
NTSTATUS Status;
- Container = ExAllocatePool(NonPagedPool, strlen(name) + sizeof(*Container));
+ Container = ExAllocatePool(NonPagedPool, sizeof(*Container));
if (!Container)
return 0;
- strcpy(Container->Name, name);
Container->ThreadFunction = thread;
Container->ThreadContext = arg;
- Container->Timeouts.next = NULL;
Status = PsCreateSystemThread(&Container->Handle,
THREAD_ALL_ACCESS,