#include <lwip/tcp.h>
#include <lwip/pbuf.h>
#include <lwip/ip_addr.h>
#include <tcpip.h>
Go to the source code of this file.
|
| NTSTATUS | LibTCPGetDataFromConnectionQueue (PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received) |
| |
| void | TCPConnectEventHandler (void *arg, const err_t err) |
| |
| void | TCPAcceptEventHandler (void *arg, PTCP_PCB newpcb) |
| |
| void | TCPSendEventHandler (void *arg, const u16_t space) |
| |
| void | TCPFinEventHandler (void *arg, const err_t err) |
| |
| void | TCPRecvEventHandler (void *arg) |
| |
| PTCP_PCB | LibTCPSocket (void *arg) |
| |
| VOID | LibTCPFreeSocket (PTCP_PCB pcb) |
| |
| err_t | LibTCPBind (PCONNECTION_ENDPOINT Connection, ip4_addr_t *const ipaddr, const u16_t port) |
| |
| PTCP_PCB | LibTCPListen (PCONNECTION_ENDPOINT Connection, const u8_t backlog) |
| |
| err_t | LibTCPSend (PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, ULONG *sent, const int safe) |
| |
| err_t | LibTCPConnect (PCONNECTION_ENDPOINT Connection, ip4_addr_t *const ipaddr, const u16_t port) |
| |
| err_t | LibTCPShutdown (PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx) |
| |
| err_t | LibTCPClose (PCONNECTION_ENDPOINT Connection, const int safe, const int callback) |
| |
| err_t | LibTCPGetPeerName (PTCP_PCB pcb, ip4_addr_t *const ipaddr, u16_t *const port) |
| |
| err_t | LibTCPGetHostName (PTCP_PCB pcb, ip4_addr_t *const ipaddr, u16_t *const port) |
| |
| void | LibTCPAccept (PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg) |
| |
| void | LibTCPSetNoDelay (PTCP_PCB pcb, BOOLEAN Set) |
| |
| void | LibTCPGetSocketStatus (PTCP_PCB pcb, PULONG State) |
| |
| void | LibIPInsertPacket (void *ifarg, const void *const data, const u32_t size) |
| |
| void | LibIPInitialize (void) |
| |
| void | LibIPShutdown (void) |
| |
◆ LWIP_MESSAGE_TAG
| #define LWIP_MESSAGE_TAG 'sMwl' |
◆ LWIP_QUEUE_TAG
◆ LWIP_TAG
◆ PQUEUE_ENTRY
◆ PTCP_PCB
◆ QUEUE_ENTRY
◆ LibIPInitialize()
Definition at line 33 of file ip.c.
34{
35
37}
void tcpip_init(tcpip_init_done_fn initfunc, void *arg)
Referenced by TCPStartup().
◆ LibIPInsertPacket()
Definition at line 10 of file ip.c.
13{
15
19
22 {
25
27
29 }
30}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
#define RtlCopyMemory(Destination, Source, Length)
Referenced by TCPReceive().
◆ LibIPShutdown()
◆ LibTCPAccept()
Definition at line 830 of file tcp.c.
831{
833
839
840 tcp_accepted(listen_pcb);
841}
STREAM tcp_recv(STREAM s, uint32 length)
static err_t InternalRecvEventHandler(void *arg, PTCP_PCB pcb, struct pbuf *p, const err_t err)
static err_t InternalSendEventHandler(void *arg, PTCP_PCB pcb, const u16_t space)
static void InternalErrorEventHandler(void *arg, const err_t err)
Referenced by TCPAcceptEventHandler().
◆ LibTCPBind()
Definition at line 415 of file tcp.c.
416{
419
422 {
425 msg->Input.Bind.IpAddress = ipaddr;
427
429
431 ret =
msg->Output.Bind.Error;
432 else
434
436
438 }
439
441}
static void LibTCPBindCallback(void *arg)
NPAGED_LOOKASIDE_LIST MessageLookasideList
static BOOLEAN WaitForEventSafely(PRKEVENT Event)
#define KeInitializeEvent(pEvt, foo, foo2)
#define tcpip_callback_with_block(function, ctx, block)
PCONNECTION_ENDPOINT Connection
Referenced by TCPConnect(), and TCPListen().
◆ LibTCPClose()
Definition at line 798 of file tcp.c.
799{
802
805 {
807
810
811 if (safe)
813 else
815
817 ret =
msg->Output.Close.Error;
818 else
820
822
824 }
825
827}
static void LibTCPCloseCallback(void *arg)
static IPrintDialogCallback callback
Referenced by TCPAcceptEventHandler(), and TCPClose().
◆ LibTCPConnect()
◆ LibTCPFreeSocket()
Definition at line 375 of file tcp.c.
376{
378
380 msg.Input.FreeSocket.pcb =
pcb;
381
383
385}
static void LibTCPFreeSocketCallback(void *arg)
◆ LibTCPGetDataFromConnectionQueue()
Definition at line 100 of file tcp.c.
101{
106
107 (*Received) = 0;
108
110
112 {
114 {
116
117
121
122
126 {
127
131 }
132
135
136
140
142 {
143
145
147 }
148 else
149 {
150
152 }
153
156
157 if (!RecvLen)
158 break;
159 }
160 }
161 else
162 {
165 else
167 }
168
170
172}
NPAGED_LOOKASIDE_LIST QueueEntryLookasideList
PQUEUE_ENTRY LibTCPDequeuePacket(PCONNECTION_ENDPOINT Connection)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
u16_t pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
_In_ ULONG _In_ ULONG Offset
NTSTATUS ReceiveShutdownStatus
err_t pbuf_free_callback(struct pbuf *p)
#define UnlockObject(Object)
#define LockObject(Object)
_In_ PVOID _In_ ULONG _In_ PVOID _In_ ULONG PayloadLength
Referenced by TCPReceiveData(), and TCPRecvEventHandler().
◆ LibTCPGetHostName()
◆ LibTCPGetPeerName()
◆ LibTCPGetSocketStatus()
◆ LibTCPListen()
Definition at line 469 of file tcp.c.
470{
473
476 {
479 msg->Input.Listen.Backlog = backlog;
480
482
484 ret =
msg->Output.Listen.NewPcb;
485 else
487
489
491 }
492
494}
static void LibTCPListenCallback(void *arg)
struct tcp_pcb * PTCP_PCB
Referenced by TCPListen().
◆ LibTCPSend()
Definition at line 557 of file tcp.c.
558{
561
564 {
568 msg->Input.Send.DataLength =
len;
569
570 if (safe)
572 else
574
576 ret =
msg->Output.Send.Error;
577 else
579
581 *
sent =
msg->Output.Send.Information;
582 else
584
586
588 }
589
591}
static void LibTCPSendCallback(void *arg)
int const JOCTET * dataptr
Referenced by TCPSendData(), and TCPSendEventHandler().
◆ LibTCPSetNoDelay()
Definition at line 868 of file tcp.c.
871{
873 pcb->flags |= TF_NODELAY;
874 else
875 pcb->flags &= ~TF_NODELAY;
876}
Referenced by TCPSetNoDelay().
◆ LibTCPShutdown()
Definition at line 717 of file tcp.c.
718{
721
724 {
726
730
732
734 ret =
msg->Output.Shutdown.Error;
735 else
737
739
741 }
742
744}
static void LibTCPShutdownCallback(void *arg)
Referenced by DisconnectWorker(), and TCPDisconnect().
◆ LibTCPSocket()
Definition at line 336 of file tcp.c.
337{
340
342 {
344 msg->Input.Socket.Arg =
arg;
345
347
349 ret =
msg->Output.Socket.NewPcb;
350 else
352
354
356 }
357
359}
static void LibTCPSocketCallback(void *arg)
Referenced by TCPSocket().
◆ TCPAcceptEventHandler()
Definition at line 231 of file event.c.
232{
238
240
242 {
244
246
248
251
253
256
258
261
263 {
265
266
268
269
271
272
274
276
278 }
279
281
283
285 {
286 break;
287 }
288 }
289
291}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PIO_STACK_LOCATION IrpSp
#define TI_DbgPrint(_t_, _x_)
VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, const BOOLEAN Synchronous)
#define RemoveHeadList(ListHead)
NTSTATUS TCPCheckPeerForAccept(PVOID Context, PTDI_REQUEST_KERNEL Request)
err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback)
void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg)
union _IO_STACK_LOCATION::@1670 Parameters
struct _CONNECTION_ENDPOINT * AssociatedEndpoint
#define DereferenceObject(Object)
struct _CONNECTION_ENDPOINT * PCONNECTION_ENDPOINT
#define CONTAINING_RECORD(address, type, field)
Referenced by InternalAcceptEventHandler().
◆ TCPConnectEventHandler()
Definition at line 420 of file event.c.
421{
425
427
429 {
431
433
436
438 }
439
441}
NTSTATUS TCPTranslateError(const INT8 err)
LIST_ENTRY ConnectRequest
Referenced by InternalConnectEventHandler().
◆ TCPFinEventHandler()
Definition at line 182 of file event.c.
183{
186
190
192
193
195
197
198
200 {
203 }
205 {
208 }
209 else
210 {
212 while (LastConnection->Next != Connection && LastConnection->Next !=
NULL)
213 LastConnection = LastConnection->
Next;
214 if (LastConnection->Next == Connection)
215 {
216 LastConnection->Next = Connection->
Next;
218 }
219 }
220
222
223
226
228}
VOID FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
struct _CONNECTION_ENDPOINT * Connection
struct _CONNECTION_ENDPOINT * Listener
PADDRESS_FILE AddressFile
struct _CONNECTION_ENDPOINT * Next
Referenced by InternalErrorEventHandler(), InternalRecvEventHandler(), LibTCPCloseCallback(), and LibTCPShutdownCallback().
◆ TCPRecvEventHandler()
Definition at line 380 of file event.c.
381{
391
393
395 {
398
401
403
406 {
408 break;
409 }
410
413
415 }
417}
NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received)
#define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length)
LIST_ENTRY ReceiveRequest
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
Referenced by InternalErrorEventHandler(), and InternalRecvEventHandler().
◆ TCPSendEventHandler()
Definition at line 294 of file event.c.
295{
303
306
308 {
310 PVOID SendBuffer = 0;
311
313
315
317
320
322 (
"Getting the user buffer from %x\n",
Mdl));
323
325
327 ("Writing %d bytes to %x\n", SendLen, SendBuffer));
328
332 ("Connection->SocketContext: %x\n",
334
336 SendBuffer,
337 SendLen, &BytesSent,
TRUE));
338
340
342 {
345 break;
346 }
347 else
348 {
350 ("Completing Send request: %x %x\n",
352
355
357 }
358
360 }
361
362
363
365 {
367
369 {
371 }
372 }
373
375
377}
VOID FlushShutdownQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
err_t LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, ULONG *sent, const int safe)
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
#define ReferenceObject(Object)
Referenced by InternalSendEventHandler().