ReactOS 0.4.15-dev-8119-g4fb2fdb
buffer.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _NETWORK_HEADER
 
struct  _NDIS_BUFFER_POOL
 
struct  _NDISI_PACKET_POOL
 

Typedefs

typedef struct _NETWORK_HEADER NETWORK_HEADER
 
typedef struct _NETWORK_HEADERPNETWORK_HEADER
 
typedef struct _NDIS_BUFFER_POOL NDIS_BUFFER_POOL
 
typedef struct _NDIS_BUFFER_POOLPNDIS_BUFFER_POOL
 
typedef struct _NDISI_PACKET_POOL NDISI_PACKET_POOL
 
typedef struct _NDISI_PACKET_POOLPNDISI_PACKET_POOL
 

Functions

UINT CopyBufferToBufferChain (PNDIS_BUFFER DstBuffer, UINT DstOffset, PUCHAR SrcData, UINT Length)
 
UINT CopyBufferChainToBuffer (PUCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
 
UINT CopyPacketToBuffer (PUCHAR DstData, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
 
UINT CopyPacketToBufferChain (PNDIS_BUFFER DstBuffer, UINT DstOffset, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
 

Typedef Documentation

◆ NDIS_BUFFER_POOL

◆ NDISI_PACKET_POOL

◆ NETWORK_HEADER

◆ PNDIS_BUFFER_POOL

◆ PNDISI_PACKET_POOL

◆ PNETWORK_HEADER

Function Documentation

◆ CopyBufferChainToBuffer()

UINT CopyBufferChainToBuffer ( PUCHAR  DstData,
PNDIS_BUFFER  SrcBuffer,
UINT  SrcOffset,
UINT  Length 
)

Definition at line 113 of file buffer.c.

131{
132 UINT BytesCopied, BytesToCopy, SrcSize;
133 PUCHAR SrcData;
134
135 NDIS_DbgPrint(MAX_TRACE, ("DstData 0x%X SrcBuffer 0x%X SrcOffset 0x%X Length %d\n",DstData,SrcBuffer, SrcOffset, Length));
136
137 /* Skip SrcOffset bytes in the source buffer chain */
138 if (SkipToOffset(SrcBuffer, SrcOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
139 return 0;
140
141 /* Start copying the data */
142 BytesCopied = 0;
143 for (;;) {
144 BytesToCopy = MIN(SrcSize, Length);
145
146 NDIS_DbgPrint(MAX_TRACE, ("Copying (%d) bytes from 0x%X to 0x%X\n", BytesToCopy, SrcData, DstData));
147
148 RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
150 DstData = (PUCHAR)((ULONG_PTR) DstData + BytesToCopy);
151
153 if (Length == 0)
154 break;
155
156 SrcSize -= BytesToCopy;
157 if (SrcSize == 0) {
158 /* No more bytes in source buffer. Proceed to
159 the next buffer in the source buffer chain */
160 NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
161 if (!SrcBuffer)
162 break;
163
164 NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
165 }
166 }
167
168 return BytesCopied;
169}
#define MIN(x, y)
Definition: rdesktop.h:171
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
FORCEINLINE ULONG SkipToOffset(IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, IN OUT PUINT Size)
Definition: buffer.c:15
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
unsigned int UINT
Definition: ndis.h:50
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3171
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
#define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length)
Definition: ndis.h:3029
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by CopyPacketToBuffer(), and MiniIndicateReceivePacket().

◆ CopyBufferToBufferChain()

UINT CopyBufferToBufferChain ( PNDIS_BUFFER  DstBuffer,
UINT  DstOffset,
PUCHAR  SrcData,
UINT  Length 
)

Definition at line 56 of file buffer.c.

74{
76 PUCHAR DstData;
77
78 NDIS_DbgPrint(MAX_TRACE, ("DstBuffer (0x%X) DstOffset (0x%X) SrcData (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcData, Length));
79
80 /* Skip DstOffset bytes in the destination buffer chain */
81 if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == 0xFFFFFFFF)
82 return 0;
83
84 /* Start copying the data */
85 BytesCopied = 0;
86 for (;;) {
87 BytesToCopy = MIN(DstSize, Length);
88
89 RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
91 SrcData = (PUCHAR) ((ULONG_PTR) SrcData + BytesToCopy);
92
94 if (Length == 0)
95 break;
96
97 DstSize -= BytesToCopy;
98 if (DstSize == 0) {
99 /* No more bytes in destination buffer. Proceed to
100 the next buffer in the destination buffer chain */
101 NdisGetNextBuffer(DstBuffer, &DstBuffer);
102 if (!DstBuffer)
103 break;
104
105 NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
106 }
107 }
108
109 return BytesCopied;
110}

Referenced by DispTdiQueryInformationExComplete(), InfoCopyOut(), and InfoTdiQueryListEntities().

◆ CopyPacketToBuffer()

UINT CopyPacketToBuffer ( PUCHAR  DstData,
PNDIS_PACKET  SrcPacket,
UINT  SrcOffset,
UINT  Length 
)

Definition at line 172 of file buffer.c.

190{
191 PNDIS_BUFFER FirstBuffer;
193 UINT FirstLength;
195
196 NDIS_DbgPrint(MAX_TRACE, ("DstData (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstData, SrcPacket, SrcOffset, Length));
197
199 &FirstBuffer,
200 &Address,
201 &FirstLength,
202 &TotalLength);
203
204 return CopyBufferChainToBuffer(DstData, FirstBuffer, SrcOffset, Length);
205}
UINT CopyBufferChainToBuffer(PUCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
Definition: buffer.c:113
VOID EXPORT NdisGetFirstBufferFromPacket(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength)
Definition: buffer.c:873
MDL * PNDIS_BUFFER
Definition: ndis.h:343
static WCHAR Address[46]
Definition: ping.c:68
_In_ ULONG TotalLength
Definition: usbdlib.h:158

Referenced by ARPReceive(), GetPacketTypeFromNdisPacket(), IPReceive(), IPv4Receive(), ProIndicatePacket(), and ReassembleDatagram().

◆ CopyPacketToBufferChain()

UINT CopyPacketToBufferChain ( PNDIS_BUFFER  DstBuffer,
UINT  DstOffset,
PNDIS_PACKET  SrcPacket,
UINT  SrcOffset,
UINT  Length 
)

Definition at line 208 of file buffer.c.

228{
229 PNDIS_BUFFER SrcBuffer;
230 PUCHAR DstData, SrcData;
231 UINT DstSize, SrcSize;
232 UINT Count, Total;
233
234 NDIS_DbgPrint(MAX_TRACE, ("DstBuffer (0x%X) DstOffset (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcPacket, SrcOffset, Length));
235
236 /* Skip DstOffset bytes in the destination buffer chain */
237 NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
238 if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == 0xFFFFFFFF)
239 return 0;
240 /* Skip SrcOffset bytes in the source packet */
241 NdisGetFirstBufferFromPacket(SrcPacket, &SrcBuffer, (PVOID*)&SrcData, &SrcSize, &Total);
242 if (SkipToOffset(SrcBuffer, SrcOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
243 return 0;
244 /* Copy the data */
245 for (Total = 0;;) {
246 /* Find out how many bytes we can copy at one time */
247 if (Length < SrcSize)
248 Count = Length;
249 else
250 Count = SrcSize;
251 if (DstSize < Count)
252 Count = DstSize;
253
254 RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, Count);
255
256 Total += Count;
257 Length -= Count;
258 if (Length == 0)
259 break;
260
261 DstSize -= Count;
262 if (DstSize == 0) {
263 /* No more bytes in destination buffer. Proceed to
264 the next buffer in the destination buffer chain */
265 NdisGetNextBuffer(DstBuffer, &DstBuffer);
266 if (!DstBuffer)
267 break;
268
269 NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
270 }
271
272 SrcSize -= Count;
273 if (SrcSize == 0) {
274 /* No more bytes in source buffer. Proceed to
275 the next buffer in the source buffer chain */
276 NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
277 if (!SrcBuffer)
278 break;
279
280 NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
281 }
282 }
283
284 return Total;
285}
int Count
Definition: noreturn.cpp:7