CreateIpForwardEntry
The CreateIpForwardEntry function adds a new entry to the IP routing table.
Syntax
DWORD CreateIpForwardEntry(
[in] PMIB_IPFORWARDROW pRoute
);
Parameters
| Parameter | Description |
|---|---|
pRoute |
A pointer to a MIB_IPFORWARDROW structure that contains information for the new IP route entry.
The structure must specify at least the following members:
|
Return Value
| Return Value | Description |
|---|---|
NO_ERROR |
The route was successfully added to the IP routing table. |
A non-NO_ERROR value |
An error occurred. The value indicates the type of error. Common error codes include:
|
Remarks
To create a static route, set the dwForwardProto member of the MIB_IPFORWARDROW structure to PROTO_IP_STATIC.
The CreateIpForwardEntry function is typically used to programmatically configure routing on a Windows system.
Before calling this function, ensure that the interface specified by dwForwardInterface is valid and that the next hop address specified by dwForwardNextHop is reachable.
MIB_IPFORWARDROW Structure
The MIB_IPFORWARDROW structure represents an entry in the IP routing table. It has the following members:
typedef struct _MIB_IPFORWARDROW {
DWORD dwForwardDest;
DWORD dwForwardMask;
DWORD dwForwardNextHop;
DWORD dwForwardIfIndex;
union {
TYPE_OF_NEXT_HOP dwForwardType;
DWORD dwForwardPolicy;
};
union {
DWORD dwForwardAge;
DWORD dwForwardNextHopAS;
};
union {
DWORD dwForwardMetric1;
DWORD dwForwardMetric2;
DWORD dwForwardMetric3;
DWORD dwForwardMetric4;
DWORD dwForwardMetric5;
};
DWORD dwForwardProto;
DWORD dwForwardAge;
union {
DWORD dwForwardNextHopAS;
DWORD dwForwardRule.dwRoutingProtocols;
};
union {
DWORD dwForwardRule.dwNextHopSubnetMask;
DWORD dwForwardRule.dwRoutingCost;
};
DWORD dwForwardRule.dwBroadcastFlag;
DWORD dwForwardRule.dwForwardFlags;
DWORD dwForwardRule.dwForwardMetric;
} MIB_IPFORWARDROW, *PMIB_IPFORWARDROW;
Refer to the full MSDN documentation for detailed descriptions of each member of the MIB_IPFORWARDROW structure.