Another task that requires communicating with the kernel is adding
and removing IP routes.
Again the ioctl system-call is what we need, and again a look at the
source code of standard Unix tools can be of benefit. In this case,
taking a look at the source of the route command can be good
advice.
The source code for the actual kernel route updates can be found in
src/linux/kernel_routes.c.
The header-file bits/ioctls.h declares the ioctl commands needed
to manipulate kernel routes, while the net/route.h header-file
conditions the data-structures needed to pass the route information to
the kernel.