I am writing a daemon running on an embedded platform that needs to change the default route of the device according to which interface it is connecting on at a given time.
Check out SIOCADDRT/SIOCDELRT ioctls (Stevens' "Unix Network Programming" would be a good reference.)