RtnInstallStaticRoute
RtnInstallStaticRoute installs a static IPv4 or IPv6 route in the RTX64 TCP/IP stack’s routing table.
Syntax
INT RtnInstallStaticRoute( CHAR *pDevName, const CHAR *pDestination, INT prefixLen, const CHAR *pNextHop, INT metric );
Parameters
pDevName
A pointer to an ASCII device name.
pDestination
String representation of target IPv4 or IPv6 address.
prefixLen
The prefix length (length of the IP mask) for the destination route. The length must be less than or equal to 32 for an IPv4 route or less than or equal to 128 for an IPv6 route.
pNextHop
String representation of next-hop router (gateway) for the route.
Metric
A metric used to rank routing entries. An entry with lower hops has a higher priority. This is typically the number of routers between the source and destination.
Return Value
0 (zero) if the function succeeds, a non-zero value if the function fails.
Possible error codes:
Error Code | Meaning |
---|---|
WSASYSNOTREADY |
The TCP/IP Stack has not been started. |
WSAEACCES | The function is called from the TCP/IP stack process context (possibly from the filter driver). |
WSAEINVAL | The function was handed a null pointer, invalid metric value, invalid prefix length, or invalid IP address format. |
WSAHOST_NOT_FOUND | There is no interface with the specified name, and/or the target/next hop address is incorrect. |
WSAEAFNOSUPPORT | The target and next hop address family doesn't match. |
WSAEALREADY | The route is already in the routing table. |
WSAEHOSTUNREACH | The destination is unreachable. |
WSA_NOT_ENOUGH_MEMORY | There is not enough memory available to perform the operation. |
WSAENOBUFS | There is not enough memory available to perform the operation. |
Examples
NOTE: The addresses used in the following examples are for demonstrative purposes only.
Example | Diagram | Syntax | Description |
---|---|---|---|
IPv4 |
|
In order to reach the destination IP addresses matching the 192.168.1.X pattern, use the router at 192.168.5.200. NOTE: The “metric” parameter is set to 1 because there is 1 router to cross to reach that destination. NOTE: In this example, this command is executed on the IP host at address 102.168.5.100 |
|
IPv6 |
|
In order to reach the destination IPv6 addresses matching the FC00:12:12:12:W:X:Y:Z pattern from Dev1, use the router at FC00:11:11:11::1/64. |
Requirements
Minimum Supported Version |
RTX64 2013 API CHANGES FOR RTX64 4.4 Renamed the parameter:
|
Header | rtnapi.h |
Library | RtTcpip.lib |