none
Injecting fresh new UDP packets from a driver to IP stack. RRS feed

  • Question

  • Hi, I had a few questions and clarifications regarding being able to construct new UDP packets (containing data in a buffer pointed by a MDL) and inject them for sending out:

    1. I understand from browsing the forums that the steps involved would be to pre-end a UDP header on the above buffer, invoke FwpsAllocateNetBufferAndNetBufferList0 with the MDL above to get a NB and a NBL, passing the NBL to FwpsConstructIpHeaderForTransportPacket0 and finally invoking FwpsInjectTransportSendAsync0. Is this correct?

    2. I am a bit confused about how to obtain the EndpointHandle value that FwpsInjectTransportSendAsync0 needs. If I have an app listening at a certain UDP port and I manage to get a ClassifFn invoked by first somehow sending in some dummy packets, can I cache the EndpointHandle from the classifyfn that I receive and use it for sending packets with any src. or dstn. UDP port (via FwpsInjectTransportSendAsync0) as long as the app is alive with it's socket open? Or are there some restrictions on what the src. and dstn. UDP ports can be specified on the packet? Also is the Endpoint Handle per socket and does it stay the same for both sends and receives? 

    3. If strong host model is configured (which is the default in Vista/7), will the src. IP specified in FwpsInjectTransportSendAsync0 ensure that the packet is sent out of the NIC configured with the src. IP address?

    4. If I want to avoid having to specify the endpoint handle, is it okay to directly invoke FwpsInjectNetworkSendAsync0 with the NBL after invoking FwpsAllocateNetBufferAndNetBufferList0 if I can make sure that the ultimate NB's size is lesser than the MTU (i.e. no IP fragmentation is necessary)? Or is there something I end up losing out on or something that the system would outright reject?

    Thanks!

    Tuesday, October 16, 2012 3:07 AM

All replies

  • One slight correction wrt #4 above: meant to ask FwpsConstructIpHeaderForTransportPacket0  instead of FwpsAllocateNetBufferAndNetBufferList0.
    Tuesday, October 16, 2012 3:09 AM