ReactOS 0.4.16-dev-136-g52192f1
bind.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/net/afd/afd/bind.c
5 * PURPOSE: Ancillary functions driver
6 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net)
7 * UPDATE HISTORY:
8 * 20040708 Created
9 */
10
11#include "afd.h"
12
15
16 AFD_DbgPrint(MID_TRACE,("Called (AF %u)\n",
17 FCB->LocalAddress->Address[0].AddressType));
18
19 if( !FCB->TdiDeviceName.Length || !FCB->TdiDeviceName.Buffer ) {
20 AFD_DbgPrint(MIN_TRACE,("Null Device\n"));
22 }
23 if( !FCB->LocalAddress ) {
24 AFD_DbgPrint(MIN_TRACE,("No local address\n"));
26 }
27
28 Status = TdiOpenAddressFile(&FCB->TdiDeviceName,
29 FCB->LocalAddress,
30 ShareType,
31 &FCB->AddressFile.Handle,
32 &FCB->AddressFile.Object );
33 if (!NT_SUCCESS(Status))
34 return Status;
35
37 {
38 if (!FCB->Recv.Size)
39 {
40 Status = TdiQueryMaxDatagramLength(FCB->AddressFile.Object,
41 &FCB->Recv.Size);
42 }
43
44 if (NT_SUCCESS(Status) && !FCB->Recv.Window)
45 {
46 FCB->Recv.Window = ExAllocatePoolWithTag(PagedPool,
47 FCB->Recv.Size,
49
50 if (!FCB->Recv.Window)
52 }
53
54 if (NT_SUCCESS(Status) && FCB->Recv.Content < FCB->Recv.Size)
55 {
56 Status = TdiReceiveDatagram(&FCB->ReceiveIrp.InFlightRequest,
57 FCB->AddressFile.Object,
58 0,
59 FCB->Recv.Window,
60 FCB->Recv.Size,
61 FCB->AddressFrom,
63 FCB);
64
65 /* We don't want to wait for this read to complete. */
67 }
68 }
69
70 AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
71
72 return Status;
73}
74
80 PAFD_FCB FCB = FileObject->FsContext;
81 PAFD_BIND_DATA BindReq;
82 HANDLE UserHandle = NULL;
83
85
86 AFD_DbgPrint(MID_TRACE,("Called\n"));
87
88 if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
89 if( !(BindReq = LockRequest( Irp, IrpSp, FALSE, NULL )) )
91 Irp, 0 );
92
93 if (FCB->LocalAddress)
94 {
96 }
97
98 FCB->LocalAddress = TaCopyTransportAddress( &BindReq->Address );
99
100 if( FCB->LocalAddress )
101 Status = TdiBuildConnectionInfo( &FCB->AddressFrom,
102 FCB->LocalAddress );
103
104 if( NT_SUCCESS(Status) )
105 Status = WarmSocketForBind( FCB, BindReq->ShareType );
106 AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
107
108 if (NT_SUCCESS(Status))
109 {
110 Status = ObOpenObjectByPointer(FCB->AddressFile.Object,
111 0,
112 NULL,
115 Irp->RequestorMode,
116 &UserHandle);
117 if (NT_SUCCESS(Status))
118 FCB->State = SOCKET_STATE_BOUND;
119 }
120
121 /* MSAFD relies on us returning the address file handle in the IOSB */
123 (ULONG_PTR)UserHandle);
124}
IO_COMPLETION_ROUTINE PacketSocketRecvComplete
Definition: afd.h:310
#define SOCKET_STATE_BOUND
Definition: afd.h:74
#define TAG_AFD_DATA_BUFFER
Definition: afd.h:38
#define TAG_AFD_TRANSPORT_ADDRESS
Definition: afd.h:39
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS WarmSocketForBind(PAFD_FCB FCB, ULONG ShareType)
Definition: bind.c:13
NTSTATUS NTAPI AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: bind.c:76
PVOID LockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Output, KPROCESSOR_MODE *LockMode)
Definition: lock.c:24
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
NTSTATUS TdiQueryMaxDatagramLength(PFILE_OBJECT FileObject, PUINT MaxDatagramLength)
Definition: tdi.c:226
NTSTATUS TdiReceiveDatagram(PIRP *Irp, PFILE_OBJECT TransportObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PTDI_CONNECTION_INFORMATION Addr, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
Definition: tdi.c:1058
NTSTATUS TdiOpenAddressFile(PUNICODE_STRING DeviceName, PTRANSPORT_ADDRESS Name, ULONG ShareType, PHANDLE AddressHandle, PFILE_OBJECT *AddressObject)
Definition: tdi.c:170
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2742
#define AFD_ENDPOINT_CONNECTIONLESS
Definition: shared.h:153
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG ShareType
Definition: shared.h:39
TRANSPORT_ADDRESS Address
Definition: shared.h:40
Definition: afd.h:159
Definition: cdstruc.h:902
ULONG Flags
Definition: ntfs.h:536
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
NTSTATUS TdiBuildConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:237
PTRANSPORT_ADDRESS TaCopyTransportAddress(PTRANSPORT_ADDRESS OtherAddress)
Definition: tdiconn.c:80
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998