I made NDIS 6 network filter driver and am reading the packet. When I use Intel I350 NIC, 'MmGetMdlByteCount' returns '9014'bytes. This value is the same as the MTU size, so I can read the data at once. However, when using the x540 NIC, 'MmGetMdlByteCount' is returned to '2048'bytes. So I have to read the MDL over and over again. Why is this happening? Is there a way to read data at once on the X540 NIC? I want to reduce repetition because I think the consumption time will be longer if I bring the data several times.
1
There are 1 best solutions below
Related Questions in NDIS
- Coding drivers to support different modes on chipsets
- WMI MSNdis_80211_BSSIList requires a survey
- NDIS LWF questions
- The problem of FwpsCalloutRegister function registration failure in WPF driver
- Suspending a NDIS LWF
- What is Microsoft's nm3.sys (Netmon Lightweight Filter Driver) in the NDIS network stack?
- Is WFP in Windows kernel implemented using a NDIS LWF driver?
- NDIS 6 Filter Driver with cloned Net Buffer List running extremely slowly
- Fatal Error : C1083: Cannot open include file: 'ndis.h': No such file or directory
- DPC_WATCHDOG_VIOLATION (133/1) Potentially related to NdisFIndicateReceiveNetBufferLists?
- Is there a way to read the NET_BUFFER at once?
- Is it possible to change our NDIS LWF's altitude on the LWF stack?
- KERNEL_SECURITY_CHECK_FAILURE bsod after using NdisFreeNetBufferList?
- HCK has 0 tests for our NDIS LWF? And HLK doesn't include NDIS Test 6.5 LWF Logo tests?
- Filtering NDIS-Protocoldrivers with WFP
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
What you're seeing is a result of how the NIC hardware physically works. Different hardware will use different buffer layout strategies. NDIS does not attempt to force every NIC to use the same strategy, since that would reduce performance on some NICs. Unfortunately for you, that means the complexity of dealing with different buffers gets pushed upwards into NDIS filter & protocol drivers.
You can use
NdisGetDataBufferto do some of this work for you. Internally,NdisGetDataBufferworks like this:So you can use
NdisGetDataBufferto obtain a contiguous view of the payload. The simplest way to use it is this:But this can have a double-copy in some cases. (Exercise to test your understanding: when would there be a double-copy?) For slightly better performance, you can avoid the double-copy with this trick:
You haven't included a complete code sample, but I suspect there may be some bugs in your code. I don't see any attempt to handle NetBuffer->CurrentMdlOffset. While this is usually zero, it's not always zero, so your code would not always be correct.
Similarly, it looks like the copy isn't correctly constrained by ulDataLength. You would need a
ulDataLength -= ulBytesToCopyin there somewhere to fix this.I'm very sympathetic to how tricky it is to navigate NBLs, NBs, and MDLs -- my first NIC driver included a nasty bug in calculating MDL offsets. I have some MDL-handling code internally -- I will try to clean it up a bit and publish it at https://github.com/microsoft/ndis-driver-library/ in the next few days. I'll update this post if I get it published. I think there's clearly a need for some nice, reusable and well-documented sample code to just copy (subsets of) an MDL chain into a flat buffer, or vice-versa.
Update: Refer to
MdlCopyMdlChainAtOffsetToFlatBufferin mdl.h