Thankyou for your reply.
No I wished to be able to add my own ip headers to tcp packets and then send them out through the physical interface.
ICMP is not the scenario I am looking for.
The raw socket create call returns with -1.
I am getting ip packets out of the virtual utun0 interface to my packettunnelprovider, and I wished to send these original packets out through the physical interface, changing the src from virtual ip to actual ip, without encapsulating them.
If the original socket that created these packets were bound to both the virtual and main interface, the return packets will be delivered to it.
And for that I needed raw sockets.
Now I am trying a different approach . I will reassemble the underlying tcp packets that I get from utun0 to get the original data. I will send out the original data on a new tcp connection.
And when I get the reply back on this new connection - I will create tcp packets of it again, add virtual ip header and send it to the virtual utun0 iterface.
I know its complex, will have to take care of tcp sequence numbers and all, but I am looking forward for it to work.
Thanking You,
Anant Sah