I have just finished building a userspace daemon for sending/receiving (non-IP) datagrams over some wireless hardware (this daemon is called the "exchange"). Furthermore, to aid in the development process, I've implemented a POSIX socket API lookalike that allows server or client software to create virtual sockets which bind to the exchange daemon. This all works fine, though it requires clients/servers to link directly to the exchange software libraries.
What I'd eventually like to do is to hook into the socket
system call such that any program can easily communicate through the exchange daemon by simply passing the correct domain, type, and protocol args, while still allowing the exchange to own the socket's lifecycle. An example of what I'd like to achieve is demonstrated by the BlueZ library (e.g. creating an RFCOMM server socket).
From my (limited) knowledge of how the socket
call works, my first inclination is to use some aspects of the AF_NETLINK
domain in combination with the SOCK_DGRAM
and potentially NETLINK_USERSOCK
to allow the call to be passed to a kernel module interface.
Furthermore, I've looked into using TUN/TAP and IPTABLES to hook into this functionality, but these both seem to be specifically for IP-based network traffic and the exchange datagrams aren't IP-based.
Does anyone have any examples of such an implementation or can anyone share more clues as to where to look to achieve this kind of interoperability?