Network development: where to start? (userland)

Hello,

I'm new to FreeBSD (or any flavor BSD in that case), and come from a Windows/Linux programming background. Thus, I have never developed anything for FreeBSD.

I have an application implemented on Linux which carries out some tasks related to TUN/TAP devices (basically creates a TUN, gets a file descriptor, adds routes, reads and writes data). There does not seem to be any samples on how to do these, for Linux such examples do exist (maybe I need to get out of the Linux mindset for a while).

I have been having problems with defines and structures. For example, Linux uses TUNSETIFF for ioctl(), but I've not been able to find it on FreeBSD.
<linux/if_tun.h> is (obviously) missing, and it seems that the proper counterpart is <net/if_tun.h> but this misses some defines. Furthermore, some structures like rtentry seem to be implemented differently.

Can anyone direct me to the proper starting place in order to do the above (or rather, port the above) on FreeBSD? Maybe OS sources or whatever, I have not been able to find anything of much help.

Regards,
Armie
 
Check the tun(4) manpage; it's details all of the supported ioctl calls. I think you are looking for the bit about device cloning:

tun devices are created using interface cloning. This is done using the 'ifconfig tunN create' command. This is the preferred method of creating tun devices. The same method allows removal of interfaces. For this, use the 'ifconfig tunN destroy' command.

Check the sources for ifconfig(8) to see how device cloning works.
 
Back
Top