Route(dgram, table)
{
IPn = network(dest(dgram));
route = search(IPn, table);
if( type(route) == DIR )
{
sendphys(dgram, interface(route));
}
else if( route != NIL )
{
send( dgram, gateway(route) );
}
else if( (route=search(default, table)) != NIL )
{
send( dgram, gateway(route) );
}
else
error("network unreachable");
}