I need to queue all tcp packets
sent out from the local device programmatically so that the application I implemented using libnetfilter_queue
and libpcap
would start capturing packets within the queue. But the current solution I have is to manually type in,
sudo iptables -A OUTPUT -p tcp -j NFQUEUE
In the terminal before I run my application which is not acceptable as the application should queue all tcp packets and capture and show them automatically.
I would be really grateful if you experts could provide a solution so that sudo iptables -A OUTPUT -p tcp -j NFQUEUE
coud be done within the application itself without the need of user typing it in the terminal every time the program is run.
Thank you :)
EDIT
Reason I am seekiing a solution to this programatically is because : until I type in iptables -F
the device will hold on to the data without releasing. I want to capture the packets, which is happening now, modify it and send it without it being held in the queue :) the current code modifies the packets but it is kept in the queue until the -F command is given. I want the modified packets to be sent out to its destination without being held in the queue :)