ReactOS  0.4.14-dev-554-g2f8d847
buffer.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS NDIS library
4  * FILE: ndis/buffer.c
5  * PURPOSE: Buffer management routines
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  * REVISIONS:
8  * CSH 01/08-2000 Created
9  */
10 
11 #include <ndissys.h>
12 
15  IN UINT Offset,
16  IN OUT PUCHAR *Data,
17  IN OUT PUINT Size)
18 /*
19  * FUNCTION: Skips Offset bytes into a buffer chain
20  * ARGUMENTS:
21  * Buffer = Pointer to NDIS buffer
22  * Offset = Number of bytes to skip
23  * Data = Address of a pointer that on return will contain the
24  * address of the offset in the buffer
25  * Size = Address of a pointer that on return will contain the
26  * size of the destination buffer
27  * RETURNS:
28  * Offset into buffer, -1 if buffer chain was smaller than Offset bytes
29  * NOTES:
30  * Buffer may be NULL
31  */
32 {
33  for (;;) {
34 
35  if (!Buffer)
36  return 0xFFFFFFFF;
37 
39 
40  if (Offset < *Size) {
41  *Data = (PUCHAR) ((ULONG_PTR) *Data + Offset);
42  *Size -= Offset;
43  break;
44  }
45 
46  Offset -= *Size;
47 
49  }
50 
51  return Offset;
52 }
53 
55  PNDIS_BUFFER DstBuffer,
56  UINT DstOffset,
57  PUCHAR SrcData,
58  UINT Length)
59 /*
60  * FUNCTION: Copies data from a buffer to an NDIS buffer chain
61  * ARGUMENTS:
62  * DstBuffer = Pointer to destination NDIS buffer
63  * DstOffset = Destination start offset
64  * SrcData = Pointer to source buffer
65  * Length = Number of bytes to copy
66  * RETURNS:
67  * Number of bytes copied to destination buffer
68  * NOTES:
69  * The number of bytes copied may be limited by the destination
70  * buffer size
71  */
72 {
73  UINT BytesCopied, BytesToCopy, DstSize;
74  PUCHAR DstData;
75 
76  NDIS_DbgPrint(MAX_TRACE, ("DstBuffer (0x%X) DstOffset (0x%X) SrcData (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcData, Length));
77 
78  /* Skip DstOffset bytes in the destination buffer chain */
79  if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == 0xFFFFFFFF)
80  return 0;
81 
82  /* Start copying the data */
83  BytesCopied = 0;
84  for (;;) {
85  BytesToCopy = MIN(DstSize, Length);
86 
87  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
89  SrcData = (PUCHAR) ((ULONG_PTR) SrcData + BytesToCopy);
90 
92  if (Length == 0)
93  break;
94 
95  DstSize -= BytesToCopy;
96  if (DstSize == 0) {
97  /* No more bytes in destination buffer. Proceed to
98  the next buffer in the destination buffer chain */
99  NdisGetNextBuffer(DstBuffer, &DstBuffer);
100  if (!DstBuffer)
101  break;
102 
103  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
104  }
105  }
106 
107  return BytesCopied;
108 }
109 
110 
112  PUCHAR DstData,
113  PNDIS_BUFFER SrcBuffer,
114  UINT SrcOffset,
115  UINT Length)
116 /*
117  * FUNCTION: Copies data from an NDIS buffer chain to a buffer
118  * ARGUMENTS:
119  * DstData = Pointer to destination buffer
120  * SrcBuffer = Pointer to source NDIS buffer
121  * SrcOffset = Source start offset
122  * Length = Number of bytes to copy
123  * RETURNS:
124  * Number of bytes copied to destination buffer
125  * NOTES:
126  * The number of bytes copied may be limited by the source
127  * buffer size
128  */
129 {
130  UINT BytesCopied, BytesToCopy, SrcSize;
131  PUCHAR SrcData;
132 
133  NDIS_DbgPrint(MAX_TRACE, ("DstData 0x%X SrcBuffer 0x%X SrcOffset 0x%X Length %d\n",DstData,SrcBuffer, SrcOffset, Length));
134 
135  /* Skip SrcOffset bytes in the source buffer chain */
136  if (SkipToOffset(SrcBuffer, SrcOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
137  return 0;
138 
139  /* Start copying the data */
140  BytesCopied = 0;
141  for (;;) {
142  BytesToCopy = MIN(SrcSize, Length);
143 
144  NDIS_DbgPrint(MAX_TRACE, ("Copying (%d) bytes from 0x%X to 0x%X\n", BytesToCopy, SrcData, DstData));
145 
146  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
148  DstData = (PUCHAR)((ULONG_PTR) DstData + BytesToCopy);
149 
150  Length -= BytesToCopy;
151  if (Length == 0)
152  break;
153 
154  SrcSize -= BytesToCopy;
155  if (SrcSize == 0) {
156  /* No more bytes in source buffer. Proceed to
157  the next buffer in the source buffer chain */
158  NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
159  if (!SrcBuffer)
160  break;
161 
162  NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
163  }
164  }
165 
166  return BytesCopied;
167 }
168 
169 
171  PUCHAR DstData,
172  PNDIS_PACKET SrcPacket,
173  UINT SrcOffset,
174  UINT Length)
175 /*
176  * FUNCTION: Copies data from an NDIS packet to a buffer
177  * ARGUMENTS:
178  * DstData = Pointer to destination buffer
179  * SrcPacket = Pointer to source NDIS packet
180  * SrcOffset = Source start offset
181  * Length = Number of bytes to copy
182  * RETURNS:
183  * Number of bytes copied to destination buffer
184  * NOTES:
185  * The number of bytes copied may be limited by the source
186  * buffer size
187  */
188 {
189  PNDIS_BUFFER FirstBuffer;
190  PVOID Address;
191  UINT FirstLength;
193 
194  NDIS_DbgPrint(MAX_TRACE, ("DstData (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstData, SrcPacket, SrcOffset, Length));
195 
197  &FirstBuffer,
198  &Address,
199  &FirstLength,
200  &TotalLength);
201 
202  return CopyBufferChainToBuffer(DstData, FirstBuffer, SrcOffset, Length);
203 }
204 
205 
207  PNDIS_BUFFER DstBuffer,
208  UINT DstOffset,
209  PNDIS_PACKET SrcPacket,
210  UINT SrcOffset,
211  UINT Length)
212 /*
213  * FUNCTION: Copies data from an NDIS packet to an NDIS buffer chain
214  * ARGUMENTS:
215  * DstBuffer = Pointer to destination NDIS buffer
216  * DstOffset = Destination start offset
217  * SrcPacket = Pointer to source NDIS packet
218  * SrcOffset = Source start offset
219  * Length = Number of bytes to copy
220  * RETURNS:
221  * Number of bytes copied to destination buffer
222  * NOTES:
223  * The number of bytes copied may be limited by the source and
224  * destination buffer sizes
225  */
226 {
227  PNDIS_BUFFER SrcBuffer;
228  PUCHAR DstData, SrcData;
229  UINT DstSize, SrcSize;
230  UINT Count, Total;
231 
232  NDIS_DbgPrint(MAX_TRACE, ("DstBuffer (0x%X) DstOffset (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcPacket, SrcOffset, Length));
233 
234  /* Skip DstOffset bytes in the destination buffer chain */
235  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
236  if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == 0xFFFFFFFF)
237  return 0;
238  /* Skip SrcOffset bytes in the source packet */
239  NdisGetFirstBufferFromPacket(SrcPacket, &SrcBuffer, (PVOID*)&SrcData, &SrcSize, &Total);
240  if (SkipToOffset(SrcBuffer, SrcOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
241  return 0;
242  /* Copy the data */
243  for (Total = 0;;) {
244  /* Find out how many bytes we can copy at one time */
245  if (Length < SrcSize)
246  Count = Length;
247  else
248  Count = SrcSize;
249  if (DstSize < Count)
250  Count = DstSize;
251 
252  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, Count);
253 
254  Total += Count;
255  Length -= Count;
256  if (Length == 0)
257  break;
258 
259  DstSize -= Count;
260  if (DstSize == 0) {
261  /* No more bytes in destination buffer. Proceed to
262  the next buffer in the destination buffer chain */
263  NdisGetNextBuffer(DstBuffer, &DstBuffer);
264  if (!DstBuffer)
265  break;
266 
267  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
268  }
269 
270  SrcSize -= Count;
271  if (SrcSize == 0) {
272  /* No more bytes in source buffer. Proceed to
273  the next buffer in the source buffer chain */
274  NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
275  if (!SrcBuffer)
276  break;
277 
278  NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
279  }
280  }
281 
282  return Total;
283 }
284 
285 
286 /*
287  * @implemented
288  */
289 #undef NdisAdjustBufferLength
290 VOID
291 EXPORT
294  IN UINT Length)
295 /*
296  * FUNCTION: Modifies the length of an NDIS buffer
297  * ARGUMENTS:
298  * Buffer = Pointer to NDIS buffer descriptor
299  * Length = New size of buffer
300  */
301 {
302  Buffer->ByteCount = Length;
303 }
304 
305 
306 /*
307  * @implemented
308  */
309 #undef NDIS_BUFFER_TO_SPAN_PAGES
310 ULONG
311 EXPORT
314 /*
315  * FUNCTION: Determines how many physical pages a buffer is made of
316  * ARGUMENTS:
317  * Buffer = Pointer to NDIS buffer descriptor
318  */
319 {
320  if (MmGetMdlByteCount(Buffer) == 0)
321  return 1;
322 
326 }
327 
328 
329 /*
330  * @implemented
331  */
332 VOID
333 EXPORT
339  IN UINT Length)
340 /*
341  * FUNCTION: Allocates an NDIS buffer descriptor
342  * ARGUMENTS:
343  * Status = Address of buffer for status
344  * Buffer = Address of buffer for NDIS buffer descriptor
345  * PoolHandle = Handle returned by NdisAllocateBufferPool
346  * VirtualAddress = Pointer to virtual address of data buffer
347  * Length = Number of bytes in data buffer
348  */
349 {
351  ASSERT(Length > 0);
352 
354  if (*Buffer != NULL) {
356  (*Buffer)->Next = NULL;
358  } else {
359  NDIS_DbgPrint(MIN_TRACE, ("IoAllocateMdl failed (%x, %lx)\n", VirtualAddress, Length));
361  }
362 }
363 
364 
365 /*
366  * @implemented
367  */
368 VOID
369 EXPORT
374 /*
375  * FUNCTION: Allocates storage for an NDIS buffer pool
376  * ARGUMENTS:
377  * Status = Address of buffer for status
378  * PoolHandle = Address of buffer for pool handle
379  * NumberOfDescriptors = Size of buffer pool in number of descriptors
380  */
381 {
383  *PoolHandle = 0;
384 }
385 
386 
387 /*
388  * @implemented
389  */
390 VOID
391 EXPORT
396 /*
397  * FUNCTION: Allocates an NDIS packet descriptor
398  * ARGUMENTS:
399  * Status = Address of buffer for status
400  * Packet = Address of buffer for packet descriptor
401  * PoolHandle = Handle returned by NdisAllocatePacketPool
402  */
403 {
405 
406  KeAcquireSpinLock(&Pool->SpinLock.SpinLock, &Pool->SpinLock.OldIrql);
408  Packet,
409  PoolHandle);
410  KeReleaseSpinLock(&Pool->SpinLock.SpinLock, Pool->SpinLock.OldIrql);
411 }
412 
413 
414 /*
415  * @implemented
416  */
417 VOID
418 EXPORT
424 /*
425  * FUNCTION: Allocates storage for an NDIS packet pool
426  * ARGUMENTS:
427  * Status = Address of buffer for status
428  * PoolHandle = Address of buffer for pool handle
429  * NumberOfDescriptors = Size of packet pool in number of descriptors
430  * ProtocolReservedLength = Size of protocol reserved area in bytes
431  */
432 {
434  Status,
435  PoolHandle,
437  0,
439 }
440 
441 
442 /*
443  * @implemented
444  */
445 VOID
446 EXPORT
453 /*
454  * FUNCTION:
455  * ARGUMENTS:
456  * NOTES:
457  * NDIS 5.0
458  */
459 {
461  UINT Size, Length, i;
462  PNDIS_PACKET Packet, NextPacket;
463 
464  NDIS_DbgPrint(MAX_TRACE, ("Status (0x%X) PoolHandle (0x%X) "
465  "NumberOfDescriptors (%d) ProtocolReservedLength (%d).\n",
467 
468  *PoolHandle = NULL;
469 
470  if (NumberOfDescriptors > 0xffff)
471  {
472  NDIS_DbgPrint(MIN_TRACE, ("Invalid number of descriptors (%lx)\n", NumberOfDescriptors))
474  }
475  else
476  {
478  if (NumberOfDescriptors > 0xffff)
479  {
480  NDIS_DbgPrint(MIN_TRACE, ("Total number of descriptors > 0xffff (%lx)\n", NumberOfDescriptors));
481  NumberOfDescriptors = 0xffff;
482  }
483 
484  Length = sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) +
487 
489  if (Pool)
490  {
491  KeInitializeSpinLock(&Pool->SpinLock.SpinLock);
492  Pool->PacketLength = Length;
493 
494  if (NumberOfDescriptors > 0)
495  {
496  Packet = (PNDIS_PACKET)&Pool->Buffer;
497  Pool->FreeList = Packet;
498 
499  NextPacket = (PNDIS_PACKET)((ULONG_PTR)Packet + Length);
500  for (i = 1; i < NumberOfDescriptors; i++)
501  {
502  Packet->Reserved[0] = (ULONG_PTR)NextPacket;
503  Packet = NextPacket;
504  NextPacket = (PNDIS_PACKET)((ULONG_PTR)Packet + Length);
505  }
506  Packet->Reserved[0] = 0;
507  }
508  else {
509  NDIS_DbgPrint(MIN_TRACE, ("Attempted to allocate a packet pool with 0 descriptors\n"));
510  Pool->FreeList = NULL;
511  }
512 
515  } else {
517  }
518  }
519 }
520 
521 
522 /*
523  * @implemented
524  */
525 #undef NdisBufferLength
526 ULONG
527 EXPORT
530 /*
531  * FUNCTION: Modifies the length of an NDIS buffer
532  * ARGUMENTS:
533  * Buffer = Pointer to NDIS buffer descriptor
534  * Length = New size of buffer
535  * NOTES:
536  * NDIS 5.0
537  * RETURNS:
538  * Length of NDIS buffer
539  */
540 {
541  return MmGetMdlByteCount(Buffer);
542 }
543 
544 
545 /*
546  * @implemented
547  */
548 #undef NdisBufferVirtualAddress
549 PVOID
550 EXPORT
553 /*
554  * FUNCTION:
555  * ARGUMENTS:
556  * NOTES:
557  * NDIS 5.0
558  */
559 {
561 }
562 
563 
564 /*
565  * @implemented
566  */
567 VOID
568 EXPORT
576 /*
577  * FUNCTION: Copies data from one packet to another
578  * ARGUMENTS:
579  * Destination = Pointer to packet to copy data to
580  * DestinationOffset = Offset in destination packet to copy data to
581  * BytesToCopy = Number of bytes to copy
582  * Source = Pointer to packet descriptor to copy from
583  * SourceOffset = Offset in source packet to start copying from
584  * BytesCopied = Address of buffer to place number of bytes copied
585  */
586 {
587  PNDIS_BUFFER SrcBuffer;
588  PNDIS_BUFFER DstBuffer;
589  PUCHAR DstData, SrcData;
590  UINT DstSize, SrcSize;
591  UINT Count, Total;
592 
593  *BytesCopied = 0;
594 
595  /* Skip DestinationOffset bytes in the destination packet */
596  NdisGetFirstBufferFromPacket(Destination, &DstBuffer, (PVOID*)&DstData, &DstSize, &Total);
597  if (SkipToOffset(DstBuffer, DestinationOffset, &DstData, &DstSize) == 0xFFFFFFFF)
598  return;
599 
600  /* Skip SourceOffset bytes in the source packet */
601  NdisGetFirstBufferFromPacket(Source, &SrcBuffer, (PVOID*)&SrcData, &SrcSize, &Total);
602  if (SkipToOffset(SrcBuffer, SourceOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
603  return;
604 
605  /* Copy the data */
606  for (Total = 0;;) {
607  /* Find out how many bytes we can copy at one time */
608  if (BytesToCopy < SrcSize)
609  Count = BytesToCopy;
610  else
611  Count = SrcSize;
612  if (DstSize < Count)
613  Count = DstSize;
614 
615  RtlCopyMemory(DstData, SrcData, Count);
616 
617  Total += Count;
618  BytesToCopy -= Count;
619  if (BytesToCopy == 0)
620  break;
621 
622  DstSize -= Count;
623  if (DstSize == 0) {
624  /* No more bytes in destination buffer. Proceed to
625  the next buffer in the destination buffer chain */
626  NdisGetNextBuffer(DstBuffer, &DstBuffer);
627  if (!DstBuffer)
628  break;
629 
630  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
631  }
632 
633  SrcSize -= Count;
634  if (SrcSize == 0) {
635  /* No more bytes in source buffer. Proceed to
636  the next buffer in the source buffer chain */
637  NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
638  if (!SrcBuffer)
639  break;
640 
641  NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
642  }
643  }
644 
645  *BytesCopied = Total;
646 }
647 
648 
649 /*
650  * @implemented
651  */
652 VOID
653 EXPORT
658 /*
659  * FUNCTION: Allocates a packet at IRQL DISPATCH_LEVEL
660  * ARGUMENTS:
661  * Status = Address of buffer to place status of operation
662  * Packet = Address of buffer to place a pointer to a packet descriptor
663  * PoolHandle = Handle returned by NdisAllocatePacketPool
664  */
665 {
667 
668  KeAcquireSpinLockAtDpcLevel(&Pool->SpinLock.SpinLock);
670  Packet,
671  PoolHandle);
672  KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
673 }
674 
675 
676 /*
677  * @implemented
678  */
679 VOID
680 EXPORT
685 /*
686  * FUNCTION: Allocates a packet at IRQL DISPATCH_LEVEL (w/o synchronization)
687  * ARGUMENTS:
688  * Status = Address of buffer to place status of operation
689  * Packet = Address of buffer to place a pointer to a packet descriptor
690  * PoolHandle = Handle returned by NdisAllocatePacketPool
691  */
692 {
693  PNDIS_PACKET Temp;
695 
696  NDIS_DbgPrint(MAX_TRACE, ("Status (0x%X) Packet (0x%X) PoolHandle (0x%X).\n",
698 
699  *Packet = NULL;
700 
701  if (Pool == NULL)
702  {
704  NDIS_DbgPrint(MIN_TRACE, ("Called passed a bad pool handle\n"));
705  return;
706  }
707 
708  if (Pool->FreeList) {
709  Temp = Pool->FreeList;
710  Pool->FreeList = (PNDIS_PACKET)Temp->Reserved[0];
711 
712  RtlZeroMemory(Temp, Pool->PacketLength);
713  Temp->Private.Pool = Pool;
714  Temp->Private.ValidCounts = TRUE;
716  Temp->Private.NdisPacketOobOffset = Pool->PacketLength -
717  (sizeof(NDIS_PACKET_OOB_DATA) +
718  sizeof(NDIS_PACKET_EXTENSION));
719 
720  *Packet = Temp;
722  } else {
723  NDIS_DbgPrint(MIN_TRACE, ("No more free descriptors\n"));
725  }
726 }
727 
728 
729 /*
730  * @implemented
731  */
732 VOID
733 EXPORT
736 /*
737  * FUNCTION: Frees a packet at IRQL DISPATCH_LEVEL
738  * ARGUMENTS:
739  * Packet = Pointer to packet to free
740  */
741 {
743 
744  KeAcquireSpinLockAtDpcLevel(&Pool->SpinLock.SpinLock);
746  KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
747 }
748 
749 
750 /*
751  * @implemented
752  */
753 VOID
754 EXPORT
757 /*
758  * FUNCTION: Frees a packet at IRQL DISPATCH_LEVEL (w/o synchronization)
759  * ARGUMENTS:
760  * Packet = Pointer to packet to free
761  */
762 {
763  NDIS_DbgPrint(MAX_TRACE, ("Packet (0x%X).\n", Packet));
764 
765  Packet->Reserved[0] = (ULONG_PTR)((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList;
766  ((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList = Packet;
767 }
768 
769 
770 /*
771  * @implemented
772  */
773 VOID
774 EXPORT
777 /*
778  * FUNCTION: Frees storage allocated for an NDIS buffer pool
779  * ARGUMENTS:
780  * PoolHandle = Handle returned by NdisAllocateBufferPool
781  */
782 {
783 }
784 
785 
786 /*
787  * @implemented
788  */
789 VOID
790 EXPORT
793 /*
794  * FUNCTION: Frees storage allocated for an NDIS packet pool
795  * ARGUMENTS:
796  * PoolHandle = Handle returned by NdisAllocatePacketPool
797  */
798 {
800 }
801 
802 
803 /*
804  * @implemented
805  */
806 #undef NdisFreeBuffer
807 VOID
808 EXPORT
811 /*
812  * FUNCTION: Puts an NDIS buffer descriptor back in it's pool
813  * ARGUMENTS:
814  * Buffer = Pointer to buffer descriptor
815  */
816 {
817  IoFreeMdl(Buffer);
818 }
819 
820 
821 /*
822  * @implemented
823  */
824 VOID
825 EXPORT
828 /*
829  * FUNCTION: Puts an NDIS packet descriptor back in it's pool
830  * ARGUMENTS:
831  * Packet = Pointer to packet descriptor
832  */
833 {
835 
836  KeAcquireSpinLock(&Pool->SpinLock.SpinLock, &Pool->SpinLock.OldIrql);
838  KeReleaseSpinLock(&Pool->SpinLock.SpinLock, Pool->SpinLock.OldIrql);
839 }
840 
841 
842 /*
843  * @implemented
844  */
845 #undef NdisGetBufferPhysicalArraySize
846 VOID
847 EXPORT
850  OUT PUINT ArraySize)
851 /*
852  * FUNCTION: Returns number of discontiguous physical blocks backing a buffer
853  * ARGUMENTS:
854  * Buffer = Pointer to buffer descriptor
855  * ArraySize = Address of buffer to place number of physical blocks
856  */
857 {
859  ASSERT(Buffer && ArraySize);
860 
861  *ArraySize = NDIS_BUFFER_TO_SPAN_PAGES(Buffer);
862 }
863 
864 
865 /*
866  * @implemented
867  */
868 #undef NdisGetFirstBufferFromPacket
869 VOID
870 EXPORT
873  OUT PNDIS_BUFFER *_FirstBuffer,
874  OUT PVOID *_FirstBufferVA,
875  OUT PUINT _FirstBufferLength,
876  OUT PUINT _TotalBufferLength)
877 /*
878  * FUNCTION: Retrieves information about an NDIS packet
879  * ARGUMENTS:
880  * _Packet = Pointer to NDIS packet
881  * _FirstBuffer = Address of buffer for pointer to first NDIS buffer
882  * _FirstBufferVA = Address of buffer for address of first NDIS buffer
883  * _FirstBufferLength = Address of buffer for length of first buffer
884  * _TotalBufferLength = Address of buffer for total length of packet
885  */
886 {
888 
889  Buffer = _Packet->Private.Head;
890  *_FirstBuffer = Buffer;
891 
892  if (Buffer != NULL) {
893  *_FirstBufferLength = MmGetMdlByteCount(Buffer);
894  *_FirstBufferVA = MmGetSystemAddressForMdl(Buffer);
895  Buffer = Buffer->Next;
896  } else {
897  NDIS_DbgPrint(MID_TRACE, ("No buffers linked to this packet\n"));
898  *_FirstBufferLength = 0;
899  *_FirstBufferVA = NULL;
900  }
901 
902  *_TotalBufferLength = *_FirstBufferLength;
903 
904  while (Buffer != NULL) {
905  *_TotalBufferLength += MmGetMdlByteCount(Buffer);
906  Buffer = Buffer->Next;
907  }
908 }
909 
910 #undef NdisGetFirstBufferFromPacketSafe
911 /*
912  * @implemented
913  */
914 VOID
915 EXPORT
918  OUT PNDIS_BUFFER *_FirstBuffer,
919  OUT PVOID *_FirstBufferVA,
920  OUT PUINT _FirstBufferLength,
921  OUT PUINT _TotalBufferLength,
923 {
925 
926  Buffer = _Packet->Private.Head;
927  *_FirstBuffer = Buffer;
928 
929  if (Buffer != NULL) {
930  *_FirstBufferLength = MmGetMdlByteCount(Buffer);
931  *_FirstBufferVA = MmGetSystemAddressForMdlSafe(Buffer, Priority);
932  Buffer = Buffer->Next;
933  } else {
934  NDIS_DbgPrint(MID_TRACE, ("No buffers linked to this packet\n"));
935  *_FirstBufferLength = 0;
936  *_FirstBufferVA = NULL;
937  }
938 
939  *_TotalBufferLength = *_FirstBufferLength;
940 
941  while (Buffer != NULL) {
942  *_TotalBufferLength += MmGetMdlByteCount(Buffer);
943  Buffer = Buffer->Next;
944  }
945 }
946 
947 /*
948  * @implemented
949  */
950 #undef NdisQueryBuffer
951 VOID
952 EXPORT
956  OUT PUINT Length)
957 /*
958  * FUNCTION:
959  * Queries an NDIS buffer for information
960  * ARGUMENTS:
961  * Buffer = Pointer to NDIS buffer to query
962  * VirtualAddress = Address of buffer to place virtual address
963  * Length = Address of buffer to place length of buffer
964  */
965 {
966  if (VirtualAddress != NULL)
968 
970 }
971 
972 
973 /*
974  * @implemented
975  */
976 #undef NdisQueryBufferSafe
977 VOID
978 EXPORT
982  OUT PUINT Length,
983  IN UINT Priority)
984 /*
985  * FUNCTION:
986  * ARGUMENTS:
987  * NOTES:
988  * NDIS 5.0
989  */
990 {
991  if (VirtualAddress != NULL)
994 }
995 
996 
997 /*
998  * @implemented
999  */
1000 #undef NdisQueryBufferOffset
1001 VOID
1002 EXPORT
1005  OUT PUINT Offset,
1006  OUT PUINT Length)
1007 {
1010 }
1011 
1012 
1013 /*
1014  * @implemented
1015  */
1016 VOID
1017 EXPORT
1021 /*
1022  * FUNCTION:
1023  * Removes the last buffer in a packet
1024  * ARGUMENTS:
1025  * Packet = Pointer to NDIS packet
1026  * Buffer = Address of buffer to place pointer to removed NDIS buffer
1027  */
1028 {
1029  PNDIS_BUFFER NdisBuffer, Previous;
1030 
1032  NULL,
1033  NULL,
1034  &NdisBuffer,
1035  NULL);
1036  if (!NdisBuffer) {
1037  NDIS_DbgPrint(MID_TRACE, ("No buffer to unchain\n"));
1038  *Buffer = NULL;
1039  return;
1040  }
1041 
1042  Previous = NULL;
1043  while (NdisBuffer->Next) {
1044  Previous = NdisBuffer;
1045  NdisBuffer = NdisBuffer->Next;
1046  }
1047 
1048  if (Previous) {
1049  Previous->Next = NULL;
1050  Packet->Private.Tail = Previous;
1051  } else {
1052  Packet->Private.Head = NULL;
1053  Packet->Private.Tail = NULL;
1054  }
1055 
1056  Packet->Private.ValidCounts = FALSE;
1057 
1058  *Buffer = NdisBuffer;
1059 }
1060 
1061 
1062 /*
1063  * @implemented
1064  */
1065 VOID
1066 EXPORT
1070 /*
1071  * FUNCTION:
1072  * Removes the first buffer in a packet
1073  * ARGUMENTS:
1074  * Packet = Pointer to NDIS packet
1075  * Buffer = Address of buffer to place pointer to removed NDIS buffer
1076  */
1077 {
1078  PNDIS_BUFFER NdisBuffer;
1079 
1081  NULL,
1082  NULL,
1083  &NdisBuffer,
1084  NULL);
1085  if (!NdisBuffer) {
1086  NDIS_DbgPrint(MID_TRACE, ("No buffer to unchain\n"));
1087  *Buffer = NULL;
1088  return;
1089  }
1090 
1091  Packet->Private.Head = NdisBuffer->Next;
1092 
1093  if (!NdisBuffer->Next)
1094  Packet->Private.Tail = NULL;
1095 
1096  NdisBuffer->Next = NULL;
1097 
1098  Packet->Private.ValidCounts = FALSE;
1099 
1100  *Buffer = NdisBuffer;
1101 }
1102 
1103 /*
1104  * @implemented
1105  */
1106 VOID
1107 EXPORT
1113  IN UINT Offset,
1114  IN UINT Length)
1115 /*
1116  * FUNCTION: Returns a new buffer descriptor for a (partial) buffer
1117  * ARGUMENTS:
1118  * Status = Address of a buffer to place status of operation
1119  * Buffer = Address of a buffer to place new buffer descriptor
1120  * PoolHandle = Handle returned by NdisAllocateBufferPool
1121  * MemoryDescriptor = Pointer to a memory descriptor (possibly NDIS_BUFFER)
1122  * Offset = Offset in buffer to start copying
1123  * Length = Number of bytes to copy
1124  */
1125 {
1127 
1128  NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
1129 
1130  *Buffer = IoAllocateMdl(CurrentVa, Length, FALSE, FALSE, NULL);
1131  if (!*Buffer)
1132  {
1133  NDIS_DbgPrint(MIN_TRACE, ("IoAllocateMdl failed (%x, %lx)\n", CurrentVa, Length));
1135  return;
1136  }
1137 
1139  *Buffer,
1140  CurrentVa,
1141  Length);
1142 
1143  (*Buffer)->Next = NULL;
1145 }
1146 
1147 /*
1148  * @implemented
1149  */
1151 EXPORT
1154 {
1155  return Packet->Private.Pool;
1156 }
1157 
1158 /*
1159  * @implemented
1160  */
1161 UINT
1162 EXPORT
1164  IN UINT ProtocolReservedSize)
1165 {
1166  return sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) +
1167  sizeof(NDIS_PACKET_EXTENSION) + ProtocolReservedSize;
1168 }
1169 
1170 /*
1171  * @implemented
1172  */
1173 #undef NdisGetPacketCancelId
1174 PVOID
1175 EXPORT
1178 {
1180 }
1181 
1182 /*
1183  * @implemented
1184  */
1185 #undef NdisSetPacketCancelId
1186 VOID
1187 EXPORT
1190  IN PVOID CancelId)
1191 {
1193 }
1194 
1195 /*
1196  * @implemented
1197  */
1198 VOID
1199 EXPORT
1208 {
1209  PNDIS_BUFFER SrcBuffer;
1210  PNDIS_BUFFER DstBuffer;
1211  PUCHAR DstData, SrcData;
1212  UINT DstSize, SrcSize;
1213  UINT Count, Total;
1214 
1215  *BytesCopied = 0;
1216 
1217  /* Skip DestinationOffset bytes in the destination packet */
1218  NdisGetFirstBufferFromPacketSafe(Destination, &DstBuffer, (PVOID*)&DstData, &DstSize, &Total, Priority);
1219  if (!DstData || SkipToOffset(DstBuffer, DestinationOffset, &DstData, &DstSize) == 0xFFFFFFFF)
1220  return;
1221 
1222  /* Skip SourceOffset bytes in the source packet */
1223  NdisGetFirstBufferFromPacketSafe(Source, &SrcBuffer, (PVOID*)&SrcData, &SrcSize, &Total, Priority);
1224  if (!SrcData || SkipToOffset(SrcBuffer, SourceOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
1225  return;
1226 
1227  /* Copy the data */
1228  for (Total = 0;;) {
1229  /* Find out how many bytes we can copy at one time */
1230  if (BytesToCopy < SrcSize)
1231  Count = BytesToCopy;
1232  else
1233  Count = SrcSize;
1234  if (DstSize < Count)
1235  Count = DstSize;
1236 
1237  RtlCopyMemory(DstData, SrcData, Count);
1238 
1239  Total += Count;
1240  BytesToCopy -= Count;
1241  if (BytesToCopy == 0)
1242  break;
1243 
1244  DstSize -= Count;
1245  if (DstSize == 0) {
1246  /* No more bytes in destination buffer. Proceed to
1247  the next buffer in the destination buffer chain */
1248  NdisGetNextBuffer(DstBuffer, &DstBuffer);
1249  if (!DstBuffer)
1250  break;
1251 
1252  NdisQueryBufferSafe(DstBuffer, (PVOID)&DstData, &DstSize, Priority);
1253  if (!DstData)
1254  break;
1255  }
1256 
1257  SrcSize -= Count;
1258  if (SrcSize == 0) {
1259  /* No more bytes in source buffer. Proceed to
1260  the next buffer in the source buffer chain */
1261  NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
1262  if (!SrcBuffer)
1263  break;
1264 
1265  NdisQueryBufferSafe(SrcBuffer, (PVOID)&SrcData, &SrcSize, Priority);
1266  if (!SrcData)
1267  break;
1268  }
1269  }
1270 
1271  *BytesCopied = Total;
1272 }
1273 
1274 /*
1275  * @implemented
1276  */
1277 VOID
1278 EXPORT
1280  IN PNDIS_PACKET DstPacket,
1281  IN PNDIS_PACKET SrcPacket)
1282 /*
1283  * FUNCTION:
1284  * ARGUMENTS:
1285  * NOTES:
1286  * NDIS 5.0
1287  */
1288 {
1289  /* FIXME: What is the difference between NdisIMCopySendPerPacketInfo and
1290  * NdisIMCopySendCompletePerPacketInfo?
1291  */
1292 
1293  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1294 
1297  sizeof(NDIS_PACKET_EXTENSION));
1298 }
1299 
1300 
1301 /*
1302  * @implemented
1303  */
1304 VOID
1305 EXPORT
1307  IN PNDIS_PACKET DstPacket,
1308  IN PNDIS_PACKET SrcPacket)
1309 /*
1310  * FUNCTION:
1311  * ARGUMENTS:
1312  * NOTES:
1313  * NDIS 5.0
1314  */
1315 {
1316  /* FIXME: What is the difference between NdisIMCopySendPerPacketInfo and
1317  * NdisIMCopySendCompletePerPacketInfo?
1318  */
1319 
1320  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1321 
1324  sizeof(NDIS_PACKET_EXTENSION));
1325 }
1326 
1327 /* EOF */
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG EXPORT NdisBufferLength(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:528
#define IN
Definition: typedefs.h:38
VOID EXPORT NdisAllocatePacketPool(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors, IN UINT ProtocolReservedLength)
Definition: buffer.c:419
VOID EXPORT NdisAllocatePacket(OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:392
VOID EXPORT NdisDprAllocatePacketNonInterlocked(OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:681
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define MID_TRACE
Definition: debug.h:15
VOID EXPORT NdisDprFreePacketNonInterlocked(IN PNDIS_PACKET Packet)
Definition: buffer.c:755
_Out_ PNDIS_BUFFER _In_ NDIS_HANDLE _In_ PVOID MemoryDescriptor
Definition: ndis.h:3270
_Out_ PNDIS_HANDLE _In_ UINT _In_ UINT ProtocolReservedLength
Definition: ndis.h:2903
VOID EXPORT NdisCopyFromPacketToPacketSafe(IN PNDIS_PACKET Destination, IN UINT DestinationOffset, IN UINT BytesToCopy, IN PNDIS_PACKET Source, IN UINT SourceOffset, OUT PUINT BytesCopied, IN MM_PAGE_PRIORITY Priority)
Definition: buffer.c:1200
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
VOID EXPORT NdisDprFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:734
VOID EXPORT NdisGetBufferPhysicalArraySize(IN PNDIS_BUFFER Buffer, OUT PUINT ArraySize)
Definition: buffer.c:848
VOID EXPORT NdisCopyFromPacketToPacket(IN PNDIS_PACKET Destination, IN UINT DestinationOffset, IN UINT BytesToCopy, IN PNDIS_PACKET Source, IN UINT SourceOffset, OUT PUINT BytesCopied)
Definition: buffer.c:569
#define MmGetMdlVirtualAddress(_Mdl)
MDL * PNDIS_BUFFER
Definition: ndis.h:343
BOOLEAN ValidCounts
Definition: ndis.h:729
unsigned char * PUCHAR
Definition: retypes.h:3
enum _MM_PAGE_PRIORITY MM_PAGE_PRIORITY
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:428
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
_Out_ PNDIS_HANDLE _In_ UINT _In_ UINT NumberOfOverflowDescriptors
Definition: ndis.h:2913
* PNDIS_STATUS
Definition: ndis.h:45
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
VOID EXPORT NdisAdjustBufferLength(IN PNDIS_BUFFER Buffer, IN UINT Length)
Definition: buffer.c:292
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
VOID EXPORT NdisQueryBufferOffset(IN PNDIS_BUFFER Buffer, OUT PUINT Offset, OUT PUINT Length)
Definition: buffer.c:1003
VOID EXPORT NdisFreeBuffer(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:809
VOID EXPORT NdisDprAllocatePacket(OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:654
_In_ ULONG TotalLength
Definition: usbdlib.h:145
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
LONG CancelId
Definition: main.c:23
struct _NDIS_PACKET_OOB_DATA NDIS_PACKET_OOB_DATA
_Out_ PNDIS_HANDLE _In_ UINT NumberOfDescriptors
Definition: ndis.h:2878
UINT EXPORT NdisPacketSize(IN UINT ProtocolReservedSize)
Definition: buffer.c:1163
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3167
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
NDIS_PACKET_PRIVATE Private
Definition: ndis.h:735
uint32_t ULONG_PTR
Definition: typedefs.h:63
T MIN(T a, T b)
Definition: polytest.cpp:79
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
Definition: iomdl.c:96
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Out_ PNDIS_BUFFER _In_opt_ NDIS_HANDLE PoolHandle
Definition: ndis.h:2867
USHORT NdisPacketOobOffset
Definition: ndis.h:731
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define NDIS_SET_PACKET_CANCEL_ID(Packet, CancelId)
Definition: ndis.h:1370
struct _NDISI_PACKET_POOL * PNDISI_PACKET_POOL
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3167
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
PNDIS_PACKET_POOL Pool
Definition: ndis.h:726
VOID EXPORT NdisAllocateBuffer(OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, IN NDIS_HANDLE PoolHandle, IN PVOID VirtualAddress, IN UINT Length)
Definition: buffer.c:334
UINT CopyPacketToBuffer(PUCHAR DstData, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
Definition: buffer.c:170
VOID EXPORT NdisGetFirstBufferFromPacket(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength)
Definition: buffer.c:871
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
VOID EXPORT NdisUnchainBufferAtBack(IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer)
Definition: buffer.c:1018
UINT CopyPacketToBufferChain(PNDIS_BUFFER DstBuffer, UINT DstOffset, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
Definition: buffer.c:206
VOID EXPORT NdisGetFirstBufferFromPacketSafe(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength, IN MM_PAGE_PRIORITY Priority)
Definition: buffer.c:916
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:826
static UCHAR _Packet[1024]
Definition: pxe.c:34
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
Definition: bufpool.h:50
struct _NDIS_PACKET_EXTENSION NDIS_PACKET_EXTENSION
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define fPACKET_ALLOCATED_BY_NDIS
Definition: ndis.h:702
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
struct _NDIS_PACKET NDIS_PACKET
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG_PTR Reserved[2]
Definition: ndis.h:749
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
VOID EXPORT NdisQueryBufferSafe(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length, IN UINT Priority)
Definition: buffer.c:979
MmuFreePage * FreeList
Definition: mmuobject.c:60
__inline ULONG SkipToOffset(IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, IN OUT PUINT Size)
Definition: buffer.c:13
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT SourceOffset
Definition: ndis.h:3167
_In_ UINT DestinationOffset
Definition: ndis.h:3167
UCHAR NdisPacketFlags
Definition: ndis.h:730
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
UINT CopyBufferToBufferChain(PNDIS_BUFFER DstBuffer, UINT DstOffset, PUCHAR SrcData, UINT Length)
Definition: buffer.c:54
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define MAX_TRACE
Definition: debug.h:16
VOID EXPORT NdisIMCopySendPerPacketInfo(IN PNDIS_PACKET DstPacket, IN PNDIS_PACKET SrcPacket)
Definition: buffer.c:1306
#define MmGetMdlByteCount(_Mdl)
VOID EXPORT NdisFreeBufferPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:775
unsigned int UINT
Definition: ndis.h:50
VOID EXPORT NdisUnchainBufferAtFront(IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer)
Definition: buffer.c:1067
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
VOID EXPORT NdisSetPacketCancelId(IN PNDIS_PACKET Packet, IN PVOID CancelId)
Definition: buffer.c:1188
VOID EXPORT NdisAllocatePacketPoolEx(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors, IN UINT NumberOfOverflowDescriptors, IN UINT ProtocolReservedLength)
Definition: buffer.c:447
VOID EXPORT NdisFreePacketPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:791
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3593
ULONG EXPORT NDIS_BUFFER_TO_SPAN_PAGES(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:312
#define NDIS_GET_PACKET_CANCEL_ID(Packet)
Definition: ndis.h:1333
struct _NDIS_PACKET * PNDIS_PACKET
VOID EXPORT NdisCopyBuffer(OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, IN NDIS_HANDLE PoolHandle, IN PVOID MemoryDescriptor, IN UINT Offset, IN UINT Length)
Definition: buffer.c:1108
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953
#define OUT
Definition: typedefs.h:39
struct _NDISI_PACKET_POOL NDISI_PACKET_POOL
PVOID EXPORT NdisBufferVirtualAddress(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:551
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define MmGetSystemAddressForMdl(Mdl)
PVOID * PNDIS_HANDLE
Definition: ndis.h:338
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
#define ULONG_PTR
Definition: config.h:101
#define MmGetMdlByteOffset(_Mdl)
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PVOID EXPORT NdisGetPacketCancelId(IN PNDIS_PACKET Packet)
Definition: buffer.c:1176
#define NDIS_PACKET_EXTENSION_FROM_PACKET(Packet)
Definition: ndis.h:1341
NDIS_HANDLE EXPORT NdisGetPoolFromPacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:1152
VOID EXPORT NdisAllocateBufferPool(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors)
Definition: buffer.c:370
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
unsigned int * PUINT
Definition: ndis.h:50
UINT CopyBufferChainToBuffer(PUCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
Definition: buffer.c:111
VOID EXPORT NdisIMCopySendCompletePerPacketInfo(IN PNDIS_PACKET DstPacket, IN PNDIS_PACKET SrcPacket)
Definition: buffer.c:1279
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68