Skip to content
Advertisement

Redirecting packets to user space TCP stack without modifying application

I’m using a user space TCP stack based on the Linux stack running under Linux. Unfortunately it requires applications to specifically call its own modified versions of the normal sockets API functions and then just grabs incoming packets it receives in response using libpcap.

Now my question is whether there is any way to redirect packets from an application to this TCP stack without having to modify the application itself. To put it differently, I am looking for a way to intercept calls to the sockets API and redirect them to the user space equivalent.

Hope it is more or less clear what I mean.

Advertisement

Answer

Two ideas (untested, first google them to see if somebody has done it before):

  1. Set a replacement stdlib which uses the TCP lib instead of syscalls. then use ld.so to override it at loadtime.

  2. Set a tun net device, make the apps talk on this, and write another task that connects the other side of the tun to the userspace TCP lib.

I’d guess the first one performs better and could be less fragile. It needs some delicate stdlib knowledge, thought. Also, the tun device seems to only give you IP packets.

Your best bet is to search other users of the TCP library, it’s quite possible there’s already some kind of ‘loader’ that do exactly that.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement