[IP][LWIP][TCPIP] Move ip and lwip libraries to drivers/network/tcpip
[reactos.git] / drivers / network / tcpip / lwip / src / rosip.c
diff --git a/drivers/network/tcpip/lwip/src/rosip.c b/drivers/network/tcpip/lwip/src/rosip.c
new file mode 100644 (file)
index 0000000..3770077
--- /dev/null
@@ -0,0 +1,46 @@
+#include "lwip/sys.h"
+#include "lwip/netif.h"
+#include "lwip/tcpip.h"
+
+#include "rosip.h"
+
+#include <debug.h>
+
+typedef struct netif* PNETIF;
+
+void
+LibIPInsertPacket(void *ifarg,
+                  const void *const data,
+                  const u32_t size)
+{
+    struct pbuf *p;
+
+    ASSERT(ifarg);
+    ASSERT(data);
+    ASSERT(size > 0);
+
+    p = pbuf_alloc(PBUF_RAW, size, PBUF_RAM);
+    if (p)
+    {
+        ASSERT(p->tot_len == p->len);
+        ASSERT(p->len == size);
+
+        RtlCopyMemory(p->payload, data, p->len);
+
+        ((PNETIF)ifarg)->input(p, (PNETIF)ifarg);
+    }
+}
+
+void
+LibIPInitialize(void)
+{
+    /* This completes asynchronously */
+    tcpip_init(NULL, NULL);
+}
+
+void
+LibIPShutdown(void)
+{
+    /* This is synchronous */
+    sys_shutdown();
+}
\ No newline at end of file