ReactOS 0.4.15-dev-7924-g5949c20
accept.c File Reference
#include "precomp.h"
#include <lwip_glue/lwip_glue.h>
Include dependency graph for accept.c:

Go to the source code of this file.

Functions

NTSTATUS TCPCheckPeerForAccept (PVOID Context, PTDI_REQUEST_KERNEL Request)
 
NTSTATUS TCPListen (PCONNECTION_ENDPOINT Connection, UINT Backlog)
 
BOOLEAN TCPAbortListenForSocket (PCONNECTION_ENDPOINT Listener, PCONNECTION_ENDPOINT Connection)
 
NTSTATUS TCPAccept (PTDI_REQUEST Request, PCONNECTION_ENDPOINT Listener, PCONNECTION_ENDPOINT Connection, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
 

Variables

NPAGED_LOOKASIDE_LIST TdiBucketLookasideList
 

Function Documentation

◆ TCPAbortListenForSocket()

BOOLEAN TCPAbortListenForSocket ( PCONNECTION_ENDPOINT  Listener,
PCONNECTION_ENDPOINT  Connection 
)

Definition at line 107 of file accept.c.

110{
111 PLIST_ENTRY ListEntry;
112 PTDI_BUCKET Bucket;
114
115 LockObject(Listener);
116
117 ListEntry = Listener->ListenRequest.Flink;
118 while (ListEntry != &Listener->ListenRequest)
119 {
120 Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
121
122 if (Bucket->AssociatedEndpoint == Connection)
123 {
125 RemoveEntryList( &Bucket->Entry );
126 ExFreeToNPagedLookasideList(&TdiBucketLookasideList, Bucket);
127 Found = TRUE;
128 break;
129 }
130
131 ListEntry = ListEntry->Flink;
132 }
133
134 UnlockObject(Listener);
135
136 return Found;
137}
unsigned char BOOLEAN
NPAGED_LOOKASIDE_LIST TdiBucketLookasideList
Definition: tcp.c:26
return Found
Definition: dirsup.c:1270
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
base of all file and directory entries
Definition: entries.h:83
LIST_ENTRY ListenRequest
Definition: titypes.h:251
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY Entry
Definition: titypes.h:230
struct _CONNECTION_ENDPOINT * AssociatedEndpoint
Definition: titypes.h:231
#define UnlockObject(Object)
Definition: titypes.h:44
#define LockObject(Object)
Definition: titypes.h:34
#define DereferenceObject(Object)
Definition: titypes.h:24
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by DispCancelListenRequest().

◆ TCPAccept()

NTSTATUS TCPAccept ( PTDI_REQUEST  Request,
PCONNECTION_ENDPOINT  Listener,
PCONNECTION_ENDPOINT  Connection,
PTCP_COMPLETION_ROUTINE  Complete,
PVOID  Context 
)

Definition at line 139 of file accept.c.

144{
146 PTDI_BUCKET Bucket;
147
148 LockObject(Listener);
149
150 Bucket = ExAllocateFromNPagedLookasideList(&TdiBucketLookasideList);
151
152 if (Bucket)
153 {
154 Bucket->AssociatedEndpoint = Connection;
156
159 InsertTailList( &Listener->ListenRequest, &Bucket->Entry );
161 }
162 else
164
165 UnlockObject(Listener);
166
167 return Status;
168}
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
pRequest Complete(RequestStatus)
Status
Definition: gdiplustypes.h:25
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
TDI_REQUEST Request
Definition: titypes.h:232
PVOID RequestContext
Definition: tdi.h:55
PVOID RequestNotifyObject
Definition: tdi.h:54
#define ReferenceObject(Object)
Definition: titypes.h:14

Referenced by DispTdiListen().

◆ TCPCheckPeerForAccept()

NTSTATUS TCPCheckPeerForAccept ( PVOID  Context,
PTDI_REQUEST_KERNEL  Request 
)

Definition at line 17 of file accept.c.

19{
20 struct tcp_pcb *newpcb = (struct tcp_pcb*)Context;
22 PTDI_CONNECTION_INFORMATION WhoIsConnecting;
24 struct ip_addr ipaddr;
25
26 if (Request->RequestFlags & TDI_QUERY_ACCEPT)
27 DbgPrint("TDI_QUERY_ACCEPT NOT SUPPORTED!!!\n");
28
29 WhoIsConnecting = (PTDI_CONNECTION_INFORMATION)Request->ReturnConnectionInformation;
30 RemoteAddress = (PTA_IP_ADDRESS)WhoIsConnecting->RemoteAddress;
31
32 RemoteAddress->TAAddressCount = 1;
33 RemoteAddress->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
34 RemoteAddress->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
35
37 &ipaddr,
38 &RemoteAddress->Address[0].Address[0].sin_port));
39
40 RemoteAddress->Address[0].Address[0].in_addr = ipaddr.addr;
41
42 return Status;
43}
#define DbgPrint
Definition: hal.h:12
NTSTATUS TCPTranslateError(const INT8 err)
Definition: tcp.c:267
err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port)
Definition: tcp.c:856
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
#define TDI_QUERY_ACCEPT
Definition: tdi.h:132
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR RemoteAddress
Definition: wsk.h:172

Referenced by TCPAcceptEventHandler().

◆ TCPListen()

NTSTATUS TCPListen ( PCONNECTION_ENDPOINT  Connection,
UINT  Backlog 
)

Definition at line 47 of file accept.c.

48{
50 struct ip_addr AddressToBind;
52
53 ASSERT(Connection);
54
55 LockObject(Connection);
56
57 ASSERT_KM_POINTER(Connection->AddressFile);
58
59 TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Called\n"));
60
61 TI_DbgPrint(DEBUG_TCP, ("Connection->SocketContext %x\n",
62 Connection->SocketContext));
63
64 AddressToBind.addr = Connection->AddressFile->Address.Address.IPv4Address;
65
67 &AddressToBind,
68 Connection->AddressFile->Port));
69
70 if (NT_SUCCESS(Status))
71 {
72 /* Check if we had an unspecified port */
73 if (!Connection->AddressFile->Port)
74 {
75 /* We did, so we need to copy back the port */
77 if (NT_SUCCESS(Status))
78 {
79 /* Allocate the port in the port bitmap */
80 UINT AllocatedPort = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
81 /* This should never fail unless all ports are in use */
82 if (AllocatedPort == (UINT) -1)
83 {
84 DbgPrint("ERR: No more ports available.\n");
85 UnlockObject(Connection);
87 }
88 Connection->AddressFile->Port = AllocatedPort;
89 }
90 }
91 }
92
93 if (NT_SUCCESS(Status))
94 {
95 Connection->SocketContext = LibTCPListen(Connection, Backlog);
96 if (!Connection->SocketContext)
98 }
99
100 UnlockObject(Connection);
101
102 TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Leaving. Status = %x\n", Status));
103
104 return Status;
105}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DEBUG_TCP
Definition: debug.h:28
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define ASSERT_KM_POINTER(_x)
Definition: debug.h:74
UINT TCPAllocatePort(const UINT HintPort)
Definition: tcp.c:636
NTSTATUS TCPGetSockAddress(PCONNECTION_ENDPOINT Connection, PTRANSPORT_ADDRESS TransportAddress, BOOLEAN RemoteAddress)
Definition: tcp.c:658
PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog)
Definition: tcp.c:469
err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port)
Definition: tcp.c:415
#define ASSERT(a)
Definition: mode.c:44
unsigned int UINT
Definition: ndis.h:50
#define STATUS_TOO_MANY_ADDRESSES
Definition: ntstatus.h:653
#define STATUS_SUCCESS
Definition: shellext.h:65
union IP_ADDRESS::@1005 Address
IPv4_RAW_ADDRESS IPv4Address
Definition: ip.h:26
USHORT Port
Definition: titypes.h:120
IP_ADDRESS Address
Definition: titypes.h:117
PADDRESS_FILE AddressFile
Definition: titypes.h:247
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR LocalAddress
Definition: wsk.h:171

Referenced by DispTdiListen().

Variable Documentation

◆ TdiBucketLookasideList

NPAGED_LOOKASIDE_LIST TdiBucketLookasideList
extern

Definition at line 26 of file tcp.c.

Referenced by TCPAbortListenForSocket(), and TCPAccept().