Factor all routing stuff into router.c.