The high level goal is to route the IP packets from accessory device (which connects to iphone
via bluetooth). The accessory will send data as IP packets. Since we can't send raw IP packets
from iPhone, wanted to analyse the IP packet received from the accessory, find if it is TCP/UDP
and construct the corresponding packet and send it to the destination.
How are the IP packets encapsulated over Bluetooth? Is it using something like 6LoWPAN?
I believe that, as you said, you will need to analyse the IP packets received from the accessory. But they rather than just forwarding those packets, you will need some more complex logic that acts as a proxy, I.e. when you see a packet with a TCP SYN, you should open a TCP socket and send an encapsulated ACK back to the accessory over bluetooth.
A fully-general proxy would be quite complicated, but if you know that the accessory uses only a certain subset of the possible functionality then it becomes easier.
Are you the manufacturer of the accessory?