ReactOS  0.4.15-dev-1018-g0695ecb
accept.c File Reference
#include "precomp.h"
#include "rosip.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 104 of file accept.c.

106 {
107  PLIST_ENTRY ListEntry;
108  PTDI_BUCKET Bucket;
109  KIRQL OldIrql;
110  BOOLEAN Found = FALSE;
111 
112  LockObject(Listener, &OldIrql);
113 
114  ListEntry = Listener->ListenRequest.Flink;
115  while (ListEntry != &Listener->ListenRequest)
116  {
117  Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
118 
119  if (Bucket->AssociatedEndpoint == Connection)
120  {
122  RemoveEntryList( &Bucket->Entry );
123  ExFreeToNPagedLookasideList(&TdiBucketLookasideList, Bucket);
124  Found = TRUE;
125  break;
126  }
127 
128  ListEntry = ListEntry->Flink;
129  }
130 
131  UnlockObject(Listener, OldIrql);
132 
133  return Found;
134 }
#define TRUE
Definition: types.h:120
NPAGED_LOOKASIDE_LIST TdiBucketLookasideList
Definition: tcp.c:26
#define DereferenceObject(Object)
Definition: titypes.h:24
#define LockObject(Object, Irql)
Definition: titypes.h:34
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define UnlockObject(Object, OldIrql)
Definition: titypes.h:54
unsigned char BOOLEAN
return Found
Definition: dirsup.c:1270
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: typedefs.h:119
LIST_ENTRY Entry
Definition: titypes.h:250
struct _CONNECTION_ENDPOINT * AssociatedEndpoint
Definition: titypes.h:251
LIST_ENTRY ListenRequest
Definition: titypes.h:272
base of all file and directory entries
Definition: entries.h:82

Referenced by DispCancelListenRequest().

◆ TCPAccept()

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

Definition at line 136 of file accept.c.

141 {
143  PTDI_BUCKET Bucket;
144  KIRQL OldIrql;
145 
146  LockObject(Listener, &OldIrql);
147 
148  Bucket = ExAllocateFromNPagedLookasideList(&TdiBucketLookasideList);
149 
150  if (Bucket)
151  {
152  Bucket->AssociatedEndpoint = Connection;
154 
155  Bucket->Request.RequestNotifyObject = Complete;
156  Bucket->Request.RequestContext = Context;
157  InsertTailList( &Listener->ListenRequest, &Bucket->Entry );
159  }
160  else
162 
163  UnlockObject(Listener, OldIrql);
164 
165  return Status;
166 }
PVOID RequestContext
Definition: tdi.h:55
LONG NTSTATUS
Definition: precomp.h:26
NPAGED_LOOKASIDE_LIST TdiBucketLookasideList
Definition: tcp.c:26
#define InsertTailList(ListHead, Entry)
#define LockObject(Object, Irql)
Definition: titypes.h:34
UCHAR KIRQL
Definition: env_spec_w32.h:591
PVOID RequestNotifyObject
Definition: tdi.h:54
#define UnlockObject(Object, OldIrql)
Definition: titypes.h:54
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define ReferenceObject(Object)
Definition: titypes.h:14
LIST_ENTRY Entry
Definition: titypes.h:250
struct _CONNECTION_ENDPOINT * AssociatedEndpoint
Definition: titypes.h:251
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
LIST_ENTRY ListenRequest
Definition: titypes.h:272
struct tagContext Context
Definition: acpixf.h:1034
TDI_REQUEST Request
Definition: titypes.h:252

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: loader.c:25
LONG NTSTATUS
Definition: precomp.h:26
err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port)
Definition: rostcp.c:835
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
Status
Definition: gdiplustypes.h:24
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
NTSTATUS TCPTranslateError(const INT8 err)
Definition: tcp.c:242
#define TDI_QUERY_ACCEPT
Definition: tdi.h:132
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR RemoteAddress
Definition: wsk.h:170

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;
51  KIRQL OldIrql;
53 
54  ASSERT(Connection);
55 
56  LockObject(Connection, &OldIrql);
57 
58  ASSERT_KM_POINTER(Connection->AddressFile);
59 
60  TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Called\n"));
61 
62  TI_DbgPrint(DEBUG_TCP, ("Connection->SocketContext %x\n",
63  Connection->SocketContext));
64 
65  AddressToBind.addr = Connection->AddressFile->Address.Address.IPv4Address;
66 
67  Status = TCPTranslateError(LibTCPBind(Connection,
68  &AddressToBind,
69  Connection->AddressFile->Port));
70 
71  if (NT_SUCCESS(Status))
72  {
73  /* Check if we had an unspecified port */
74  if (!Connection->AddressFile->Port)
75  {
76  /* We did, so we need to copy back the port */
78  if (NT_SUCCESS(Status))
79  {
80  /* Allocate the port in the port bitmap */
81  Connection->AddressFile->Port = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
82 
83  /* This should never fail */
84  ASSERT(Connection->AddressFile->Port != 0xFFFF);
85  }
86  }
87  }
88 
89  if (NT_SUCCESS(Status))
90  {
91  Connection->SocketContext = LibTCPListen(Connection, Backlog);
92  if (!Connection->SocketContext)
94  }
95 
96  UnlockObject(Connection, OldIrql);
97 
98  TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Leaving. Status = %x\n", Status));
99 
100  return Status;
101 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
IPv4_RAW_ADDRESS IPv4Address
Definition: ip.h:26
err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port)
Definition: rostcp.c:394
union IP_ADDRESS::@1008 Address
LONG NTSTATUS
Definition: precomp.h:26
#define DEBUG_TCP
Definition: debug.h:28
#define LockObject(Object, Irql)
Definition: titypes.h:34
PADDRESS_FILE AddressFile
Definition: titypes.h:268
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS TCPGetSockAddress(PCONNECTION_ENDPOINT Connection, PTRANSPORT_ADDRESS TransportAddress, BOOLEAN RemoteAddress)
Definition: tcp.c:602
#define FALSE
Definition: types.h:117
#define UnlockObject(Object, OldIrql)
Definition: titypes.h:54
UINT TCPAllocatePort(const UINT HintPort)
Definition: tcp.c:580
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ASSERT_KM_POINTER(_x)
Definition: debug.h:74
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
NTSTATUS TCPTranslateError(const INT8 err)
Definition: tcp.c:242
IP_ADDRESS Address
Definition: titypes.h:136
USHORT Port
Definition: titypes.h:139
return STATUS_SUCCESS
Definition: btrfs.c:3014
PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog)
Definition: rostcp.c:448
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR LocalAddress
Definition: wsk.h:170

Referenced by DispTdiListen().

Variable Documentation

◆ TdiBucketLookasideList

NPAGED_LOOKASIDE_LIST TdiBucketLookasideList

Definition at line 26 of file tcp.c.

Referenced by TCPAbortListenForSocket(), and TCPAccept().