The routing table is statically allocated. Configuration data is in PNconfig.fth.
#32 constant MAX_IPADDRS \ -- n
No of entries in the routing table (not dynamic yet).
iproute_struct MAX_IPADDRS * equ RT_LEN \ -- n
Size of the routing table.
RT_LEN Buffer: IpRoutes \ -- addr
This is the main routing table.
#7200000 constant ROUTE_LIFE \ -- ms
Two hours in milliseconds.
#1000 constant ROUTE_SAMPLE_MS \ -- ms
How often routes are tested im milliseconds.
variable RouteTicker \ -- addr
Holds the time to sample route expiry next.
create EnetIPMask \ -- addr
IP mask for addresses on Ethernet port.
The data is in network order.
create IPGateway \ -- addr
Gateway attached to Ethernet port.
The data is in network order.
STRUCT iproute_struct \ -- size ; of structure
Routing table entry. The fields have the prefix "IPROUTE_".
create defRoute \ --
IPROUTE structure for the default route.
: SetRouteLife \ ms route --
Set the route's life to end ms from now.
: SetInfLife \ route --
Set the route to have an infinite life.
: ExtendLife \ ms route --
Extend the life of the given route by ms if the life
is not infinite.
: InitRoutes \ --
Initialise routing table.
: (find_route) \ ip -- addr|0
Get routing table entry address (if available).
: AskForRoute \ ip -- addr|0
See if we can make a route.
: ViaGateway? { ip | iptmp *rt -- addr|0 }
Returns gateway route or none.
: CanWeRoute { ip -- addr|0 ; returns route or 0 }
Handles routing via the subnet mask or gateway (if one exists).
: find_route \ ip -- addr|0
Get table entry address (if available)
: empty_route? \ -- addr|0
Get table entry address (if available).
: add_route \ ip -- addr|0
Get table entry address (if available).
: expire_routes? \ --
Decrement the route entry timers and expire any
routes that have timed out.