xref: /reactos/drivers/network/ndisuio/ndisuio.h (revision 98e8827a)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS NDIS User I/O driver
4  * FILE:        ndisuio.h
5  * PURPOSE:     NDISUIO definitions
6  */
7 
8 #ifndef __NDISUIO_H
9 #define __NDISUIO_H
10 
11 #include <ndis.h>
12 #include <nuiouser.h>
13 
14 extern PDEVICE_OBJECT GlobalDeviceObject;
15 extern NDIS_HANDLE GlobalProtocolHandle;
16 extern LIST_ENTRY GlobalAdapterList;
17 extern KSPIN_LOCK GlobalAdapterListLock;
18 
19 typedef struct _NDISUIO_ADAPTER_CONTEXT
20 {
21     /* Asynchronous completion */
22     NDIS_STATUS AsyncStatus;
23     KEVENT AsyncEvent;
24 
25     /* NDIS binding information */
26     NDIS_HANDLE BindingHandle;
27 
28     /* Reference count information */
29     ULONG OpenCount;
30     LIST_ENTRY OpenEntryList;
31 
32     /* NDIS pools */
33     NDIS_HANDLE PacketPoolHandle;
34     NDIS_HANDLE BufferPoolHandle;
35 
36     /* Receive packet list */
37     LIST_ENTRY PacketList;
38     KEVENT PacketReadEvent;
39 
40     /* Mac options */
41     ULONG MacOptions;
42 
43     /* Device name */
44     UNICODE_STRING DeviceName;
45 
46     /* Global list entry */
47     LIST_ENTRY ListEntry;
48 
49     /* Spin lock */
50     KSPIN_LOCK Spinlock;
51 } NDISUIO_ADAPTER_CONTEXT, *PNDISUIO_ADAPTER_CONTEXT;
52 
53 typedef struct _NDISUIO_OPEN_ENTRY
54 {
55     /* File object */
56     PFILE_OBJECT FileObject;
57 
58     /* Tracks how this adapter was opened (write-only or read-write) */
59     BOOLEAN WriteOnly;
60 
61     /* List entry */
62     LIST_ENTRY ListEntry;
63 } NDISUIO_OPEN_ENTRY, *PNDISUIO_OPEN_ENTRY;
64 
65 typedef struct _NDISUIO_PACKET_ENTRY
66 {
67     /* Length of data at the end of the struct */
68     ULONG PacketLength;
69 
70     /* Entry on the packet list */
71     LIST_ENTRY ListEntry;
72 
73     /* Packet data */
74     UCHAR PacketData[1];
75 } NDISUIO_PACKET_ENTRY, *PNDISUIO_PACKET_ENTRY;
76 
77 /* NDIS version info */
78 #define NDIS_MAJOR_VERSION 5
79 #define NDIS_MINOR_VERSION 0
80 
81 /* createclose.c */
82 NTSTATUS
83 NTAPI
84 NduDispatchCreate(PDEVICE_OBJECT DeviceObject,
85                   PIRP Irp);
86 
87 NTSTATUS
88 NTAPI
89 NduDispatchClose(PDEVICE_OBJECT DeviceObject,
90                  PIRP Irp);
91 
92 /* ioctl.c */
93 NTSTATUS
94 NTAPI
95 NduDispatchDeviceControl(PDEVICE_OBJECT DeviceObject,
96                          PIRP Irp);
97 
98 /* misc.c */
99 NDIS_STATUS
100 AllocateAndChainBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext,
101                        PNDIS_PACKET Packet,
102                        PVOID Buffer,
103                        ULONG BufferSize,
104                        BOOLEAN Front);
105 
106 PNDIS_PACKET
107 CreatePacketFromPoolBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext,
108                            PVOID Buffer,
109                            ULONG BufferSize);
110 
111 VOID
112 CleanupAndFreePacket(PNDIS_PACKET Packet,
113                      BOOLEAN FreePool);
114 
115 PNDISUIO_ADAPTER_CONTEXT
116 FindAdapterContextByName(PNDIS_STRING DeviceName);
117 
118 VOID
119 ReferenceAdapterContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext);
120 
121 VOID
122 DereferenceAdapterContextWithOpenEntry(PNDISUIO_ADAPTER_CONTEXT AdapterContext,
123                                        PNDISUIO_OPEN_ENTRY OpenEntry);
124 
125 /* protocol.c */
126 VOID
127 NTAPI
128 NduOpenAdapterComplete(NDIS_HANDLE ProtocolBindingContext,
129                        NDIS_STATUS Status,
130                        NDIS_STATUS OpenStatus);
131 
132 VOID
133 NTAPI
134 NduCloseAdapterComplete(NDIS_HANDLE ProtocolBindingContext,
135                         NDIS_STATUS Status);
136 
137 NDIS_STATUS
138 NTAPI
139 NduNetPnPEvent(NDIS_HANDLE ProtocolBindingContext,
140                PNET_PNP_EVENT NetPnPEvent);
141 
142 VOID
143 NTAPI
144 NduSendComplete(NDIS_HANDLE ProtocolBindingContext,
145                 PNDIS_PACKET Packet,
146                 NDIS_STATUS Status);
147 
148 VOID
149 NTAPI
150 NduTransferDataComplete(NDIS_HANDLE ProtocolBindingContext,
151                         PNDIS_PACKET Packet,
152                         NDIS_STATUS Status,
153                         UINT BytesTransferred);
154 
155 VOID
156 NTAPI
157 NduResetComplete(NDIS_HANDLE ProtocolBindingContext,
158                  NDIS_STATUS Status);
159 
160 VOID
161 NTAPI
162 NduRequestComplete(NDIS_HANDLE ProtocolBindingContext,
163                    PNDIS_REQUEST NdisRequest,
164                    NDIS_STATUS Status);
165 
166 NDIS_STATUS
167 NTAPI
168 NduReceive(NDIS_HANDLE ProtocolBindingContext,
169            NDIS_HANDLE MacReceiveContext,
170            PVOID HeaderBuffer,
171            UINT HeaderBufferSize,
172            PVOID LookAheadBuffer,
173            UINT LookaheadBufferSize,
174            UINT PacketSize);
175 
176 VOID
177 NTAPI
178 NduReceiveComplete(NDIS_HANDLE ProtocolBindingContext);
179 
180 VOID
181 NTAPI
182 NduStatus(NDIS_HANDLE ProtocolBindingContext,
183           NDIS_STATUS GeneralStatus,
184           PVOID StatusBuffer,
185           UINT StatusBufferSize);
186 
187 VOID
188 NTAPI
189 NduStatusComplete(NDIS_HANDLE ProtocolBindingContext);
190 
191 VOID
192 NTAPI
193 NduBindAdapter(PNDIS_STATUS Status,
194                NDIS_HANDLE BindContext,
195                PNDIS_STRING DeviceName,
196                PVOID SystemSpecific1,
197                PVOID SystemSpecific2);
198 
199 VOID
200 NTAPI
201 NduUnbindAdapter(PNDIS_STATUS Status,
202                  NDIS_HANDLE ProtocolBindingContext,
203                  NDIS_HANDLE UnbindContext);
204 
205 /* readwrite.c */
206 NTSTATUS
207 NTAPI
208 NduDispatchRead(PDEVICE_OBJECT DeviceObject,
209                 PIRP Irp);
210 
211 NTSTATUS
212 NTAPI
213 NduDispatchWrite(PDEVICE_OBJECT DeviceObject,
214                  PIRP Irp);
215 
216 #endif /* __NDISUIO_H */
217