blob: 9fdf54c7a8c1d63e8e845bfd051edb4bf3af78ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#include "clisrv.h"
typedef struct _BTHECHOSAMPLE_SERVER_CONTEXT
{
//
// Context common to client and server
//
BTHECHOSAMPLE_DEVICE_CONTEXT_HEADER Header;
//
// Our Data PSM
//
USHORT Psm;
//
// Handle to published SDP record
//
HANDLE_SDP SdpRecordHandle;
//
// Handle obtained by registering L2CAP server
//
L2CAP_SERVER_HANDLE L2CAPServerHandle;
//
// BRB used for server and PSM register and unregister
//
// Server and PSM register and unregister must be done
// sequentially since access to this brb is not
// synchronized.
//
struct _BRB RegisterUnregisterBrb;
//
// Connection List lock
//
WDFSPINLOCK ConnectionListLock;
//
// Outstanding open connections
//
LIST_ENTRY ConnectionList;
} BTHECHOSAMPLE_SERVER_CONTEXT, *PBTHECHOSAMPLE_SERVER_CONTEXT;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(BTHECHOSAMPLE_SERVER_CONTEXT, GetServerDeviceContext)
NTSTATUS
FORCEINLINE
BthEchoSampleServerContextInit(
PBTHECHOSAMPLE_SERVER_CONTEXT Context,
WDFDEVICE Device
)
{
NTSTATUS status;
WDF_OBJECT_ATTRIBUTES attributes;
status = BthEchoSharedDeviceContextHeaderInit(&Context->Header, Device);
if (!NT_SUCCESS(status))
{
goto exit;
}
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = Device;
status = WdfSpinLockCreate(
&attributes,
&Context->ConnectionListLock
);
if (!NT_SUCCESS(status))
{
goto exit;
}
InitializeListHead(&Context->ConnectionList);
exit:
return status;
}
EVT_WDF_DRIVER_DEVICE_ADD BthEchoSrvEvtDriverDeviceAdd;
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT BthEchoSrvEvtDeviceSelfManagedIoInit;
EVT_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP BthEchoSrvEvtDeviceSelfManagedIoCleanup;
//////////////////////////////////////////////////////
// Device specific functionality invoked by server.c
//////////////////////////////////////////////////////
_IRQL_requires_max_(DISPATCH_LEVEL)
NTSTATUS
BthEchoSrvConnectionStateConnected(
WDFOBJECT ConnectionObject
);
////////////////////////////////////////////////////////////////////
// Continuous reader callbacks (invoked by common/lib/connection.c)
////////////////////////////////////////////////////////////////////
_IRQL_requires_max_(DISPATCH_LEVEL)
VOID
BthEchoSrvConnectionObjectContReaderReadCompletedCallback(
_In_ PBTHECHOSAMPLE_DEVICE_CONTEXT_HEADER DevCtxHdr,
_In_ PBTHECHO_CONNECTION Connection,
_In_ PVOID Buffer,
_In_ size_t BufferLength
);
_IRQL_requires_max_(DISPATCH_LEVEL)
VOID
BthEchoSrvConnectionObjectContReaderFailedCallback(
_In_ PBTHECHOSAMPLE_DEVICE_CONTEXT_HEADER DevCtxHdr,
_In_ PBTHECHO_CONNECTION Connection
);
|