42 DbgPrint(
"\tRemote: (%d.%d.%d.%d, %d)\n",
230 tcp_recved(pcb,
p->tot_len);
276 if (newpcb->callback_arg)
324 msg->Output.Socket.NewPcb = tcp_new();
326 if (
msg->Output.Socket.NewPcb)
328 tcp_arg(
msg->Output.Socket.NewPcb,
msg->Input.Socket.Arg);
344 msg->Input.Socket.Arg =
arg;
349 ret =
msg->Output.Socket.NewPcb;
380 msg.Input.FreeSocket.pcb =
pcb;
397 if (!
msg->Input.Bind.Connection->SocketContext)
406 msg->Output.Bind.Error = tcp_bind(
pcb,
407 msg->Input.Bind.IpAddress,
425 msg->Input.Bind.IpAddress = ipaddr;
431 ret =
msg->Output.Bind.Error;
451 if (!
msg->Input.Listen.Connection->SocketContext)
453 msg->Output.Listen.NewPcb =
NULL;
457 msg->Output.Listen.NewPcb = tcp_listen_with_backlog((
PTCP_PCB)
msg->Input.Listen.Connection->SocketContext,
msg->Input.Listen.Backlog);
459 if (
msg->Output.Listen.NewPcb)
479 msg->Input.Listen.Backlog = backlog;
484 ret =
msg->Output.Listen.NewPcb;
507 if (!
msg->Input.Send.Connection->SocketContext)
513 if (
msg->Input.Send.Connection->SendShutdown)
519 SendFlags = TCP_WRITE_FLAG_COPY;
520 SendLength =
msg->Input.Send.DataLength;
521 if (tcp_sndbuf(
pcb) == 0)
527 else if (tcp_sndbuf(
pcb) < SendLength)
530 SendLength = tcp_sndbuf(
pcb);
533 SendFlags |= TCP_WRITE_FLAG_MORE;
536 msg->Output.Send.Error = tcp_write(
pcb,
537 msg->Input.Send.Data,
543 tcp_output((
PTCP_PCB)
msg->Input.Send.Connection->SocketContext);
544 msg->Output.Send.Information = SendLength;
568 msg->Input.Send.DataLength =
len;
576 ret =
msg->Output.Send.Error;
581 *
sent =
msg->Output.Send.Information;
602 if (!
msg->Input.Connect.Connection->SocketContext)
632 msg->Input.Connect.IpAddress = ipaddr;
633 msg->Input.Connect.Port =
port;
639 ret =
msg->Output.Connect.Error;
659 if (!
msg->Input.Shutdown.Connection->SocketContext)
671 if (
msg->Input.Shutdown.shut_rx !=
msg->Input.Shutdown.shut_tx) {
672 if (
msg->Input.Shutdown.shut_rx) {
675 if (
msg->Input.Shutdown.shut_tx) {
679 else if (
msg->Input.Shutdown.shut_rx) {
688 DbgPrint(
"Requested socket shutdown(0, 0) !\n");
691 if (!
msg->Output.Shutdown.Error)
693 if (
msg->Input.Shutdown.shut_rx)
695 msg->Input.Shutdown.Connection->ReceiveShutdown =
TRUE;
699 if (
msg->Input.Shutdown.shut_tx)
700 msg->Input.Shutdown.Connection->SendShutdown =
TRUE;
702 if (
msg->Input.Shutdown.Connection->ReceiveShutdown &&
703 msg->Input.Shutdown.Connection->SendShutdown)
706 msg->Input.Shutdown.Connection->SocketContext =
NULL;
734 ret =
msg->Output.Shutdown.Error;
757 if (
msg->Input.Close.Connection->Closing)
764 if (
msg->Input.Close.Callback)
765 msg->Input.Close.Connection->Closing =
TRUE;
768 if (!
msg->Input.Close.Connection->SocketContext)
775 msg->Input.Close.Connection->SocketContext =
NULL;
782 if (
msg->Output.Close.Error)
785 msg->Input.Close.Connection->SocketContext =
pcb;
786 msg->Input.Close.Connection->Closing =
FALSE;
788 else if (
msg->Input.Close.Callback)
817 ret =
msg->Output.Close.Error;
840 tcp_accepted(listen_pcb);
849 *ipaddr =
pcb->local_ip;
861 *ipaddr =
pcb->remote_ip;
873 pcb->flags |= TF_NODELAY;
875 pcb->flags &= ~TF_NODELAY;
STREAM tcp_recv(STREAM s, uint32 length)
RD_BOOL tcp_connect(char *server)
void LibTCPGetSocketStatus(PTCP_PCB pcb, PULONG State)
static void LibTCPSocketCallback(void *arg)
void LibTCPSetNoDelay(PTCP_PCB pcb, BOOLEAN Set)
void LibTCPEnqueuePacket(PCONNECTION_ENDPOINT Connection, struct pbuf *p)
PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog)
static err_t InternalRecvEventHandler(void *arg, PTCP_PCB pcb, struct pbuf *p, const err_t err)
err_t LibTCPGetPeerName(PTCP_PCB pcb, ip_addr_t *const ipaddr, u16_t *const port)
static err_t InternalConnectEventHandler(void *arg, PTCP_PCB pcb, const err_t err)
err_t LibTCPShutdown(PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx)
void LibTCPFreeSocket(PTCP_PCB pcb)
void LibTCPDumpPcb(PVOID SocketContext)
static const char *const tcp_state_str[]
static void LibTCPBindCallback(void *arg)
struct tcp_pcb * LibTCPSocket(void *arg)
static void LibTCPSendCallback(void *arg)
err_t LibTCPConnect(PCONNECTION_ENDPOINT Connection, ip_addr_t *const ipaddr, const u16_t port)
static err_t InternalSendEventHandler(void *arg, PTCP_PCB pcb, const u16_t space)
NTSTATUS TCPTranslateError(const err_t err)
static err_t InternalAcceptEventHandler(void *arg, PTCP_PCB newpcb, const err_t err)
err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, ip4_addr_t *const ipaddr, const u16_t port)
static void LibTCPEmptyQueue(PCONNECTION_ENDPOINT Connection)
NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received)
NPAGED_LOOKASIDE_LIST MessageLookasideList
static void LibTCPConnectCallback(void *arg)
err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback)
void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg)
static void LibTCPShutdownCallback(void *arg)
err_t LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, ULONG *sent, const int safe)
static void LibTCPCloseCallback(void *arg)
static BOOLEAN WaitForEventSafely(PRKEVENT Event)
err_t LibTCPGetHostName(PTCP_PCB pcb, ip_addr_t *const ipaddr, u16_t *const port)
static void LibTCPListenCallback(void *arg)
NPAGED_LOOKASIDE_LIST QueueEntryLookasideList
static void LibTCPFreeSocketCallback(void *arg)
PQUEUE_ENTRY LibTCPDequeuePacket(PCONNECTION_ENDPOINT Connection)
static void InternalErrorEventHandler(void *arg, const err_t err)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define RemoveHeadList(ListHead)
GLenum const GLvoid * addr
#define tcpip_callback_with_block(function, ctx, block)
u8_t pbuf_free(struct pbuf *p)
u16_t pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
int const JOCTET * dataptr
void TCPRecvEventHandler(void *arg)
void TCPConnectEventHandler(void *arg, const err_t err)
void TCPSendEventHandler(void *arg, const u16_t space)
void TCPFinEventHandler(void *arg, const err_t err)
void TCPAcceptEventHandler(void *arg, PTCP_PCB newpcb)
struct _QUEUE_ENTRY * PQUEUE_ENTRY
struct tcp_pcb * PTCP_PCB
static IPrintDialogCallback callback
_In_ ULONG _In_ ULONG Offset
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
#define STATUS_FILE_CLOSED
base of all file and directory entries
NTSTATUS ReceiveShutdownStatus
PCONNECTION_ENDPOINT Connection
void tcp_close(struct sock *sk, long timeout)
struct sock * tcp_accept(struct sock *sk, int flags, int *err)
void tcp_shutdown(struct sock *sk, int how)
err_t pbuf_free_callback(struct pbuf *p)
#define UnlockObject(Object)
#define ReferenceObject(Object)
#define LockObject(Object)
#define DereferenceObject(Object)
#define CONTAINING_RECORD(address, type, field)
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID SocketContext
struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
_In_ PVOID _In_ ULONG _In_ PVOID _In_ ULONG PayloadLength