Hello Matt.
During the last days we have been working on this issue and fortunately we came up with a valid solution. Here we detail the new processing flow and some related questions.
Solution for the Pause-Resume issue
We moved the asynchronous analysis starting point from C to Swift, as follows:
Process the Pause action in a method following the next steps:
Enqueue a task in an asynchronous global dispatch queue, passing a closure as a responseHandler that will be called at the end of the task execution.
Implement the closure that will manage the final action. This closure captures the local NEFilterFlow, which is required to perform the resumeFlow (similar to the one implemented in the SimpleFirewall example).
The dispatch queue processes the task, which:
Calls the C code section to perform the analysis.
When the analysis is finished the responseHandler closure is executed.
Finally, from the closure we call resumeFlow with the required verdict.
Do you have any comment about this processing? Nevertheless, the problem from the original question remains unsolved and this new processing flow rise some new questions and other problems.
Pause-Resume Related questions
Can we request more data after resuming a paused flow? That is, not resuming with a final allow or drop action but asking for more data to analyze (“NEFilterDataVerdict.init(passBytes: passBytesCount, peekBytes: Int.max)”): Pause ---> Resume(MoreDataRequired) ---> Allow/Drop
If so, can we make several pause-resume cycles for the same flow?
HandleDataComplete Callback Issue
This is very likely related to our management of the pause-resume cycle, but in both handleInboundDataComplete and handleOubtoundDataComplete methods, most of the times the NEFilterFlow parameter comes with a nil value.
Moreover, we have tested the same pause-resume mechanism implemented in the SimpleFirewall sample but moved to the handleInboundData and handleOutboundData callbacks, and the nil parameter issue does not occur.
Any idea why is this happening?
Thanks a lot for your help. Regards,
Rodrigo Ortega