I am implementing an OOB terminating callout which registers at FWPM_LAYER_DATAGRAM_DATA_V4/V6 (among other layers). As far as my understanding goes at this layer the callout's classifyFn gets the transport payload thru pLayerData parameter and it does not contain the transport header, which makes sense because for the outbound case the transposrt still has not gotten the data. Now I would like to hold on to the data (NET_BUFFER_LIST), perform inspection and at a later point inject the data back to the stream. In order to simplify the discussion lets assume only outbound UDP data.
Questions:
1.
Is it enough to just reference the buffer list and then dereference it when I am done with the injection - FwpsReferenceNetBufferList0/FwpsDereeferenceNetBufferList0 or should I make my own clone via FwpsAllocateCloneNetBufferList0 The reference seems like a faster operation with the downside that it may possibly starve the tcp/ip engine.
2.
Is classifyOut->actionType = FWP_ACTION_BLOCK; enough for setting the status Isnt this going to result in an error returned to the app that is trying to send the data
3.
In order to inject back the data it seems that the only option for outbound UDP is FwpsInjectTransportSendAsync0. Unfortunately to me this sounds like I'll have to create the UDP header myself - compute the checksum, etc. Is this the case Isn't there an API for non-TCP stream data that is similar to FwpsStreamInjectAsync0
Thanks!