views:

26

answers:

1

A call CreateIpForwardEntry returns ERROR_INVALID_PARAMETER. The PSDK documentation describes this error as:

The pRoute parameter is NULL, SetIpForwardEntry is unable to read from the memory pointed to by pRoute, or one of the members of the MIB_IPFORWARDROW structure is invalid.

I know for certain that pRoute is not NULL and that no call to SetIpForwardEntry is involved, which leaves the only cause for the error as "one of the members of the MIB_IPFORWARDROW structure is invalid."

How do I know which of the members of MIB_IPFORWARDROW is invalid?

To further clarify my question: I know exactly what value each of these members has (I log them). At this point however, I can't tell which one is incorrect. They all look valid to me. It would be nice to know why one of the members is invalid. But for that I first need to know which of them is invalid.

For example, in one of the test cases (which produce the aforementioned error) I have:

dwForwardDest = 199.239.136.200
dwForwardMask = 255.255.255.255
dwForwardPolicy = 0
dwForwardNextHop = 127.0.0.1
dwForwardIfIndex = 1
dwForwardType = 0
dwForwardProto = 0X2
dwForwardAge = 0
dwForwardNextHopAS = 0
dwForwardMetric1 =  1
dwForwardMetric2 =  -1
dwForwardMetric3 = -1
dwForwardMetric4 = -1
dwForwardMetric5 = 0

Any idea why CreateIpForwardEntry() wouldn't agree to accept the above parameters?

Update: The tips provided below were very helpful but didn't really provide a method how to tell which member in MIB_IPFORWARDROW structure is invalid. I did correct the two members mentioned, but the problem persists:

Dest = 199.239.136.200
Mask = 255.255.255.255
Policy = 0
NextHop = 127.0.0.1
IfIndex = 1
Type = 0X3
Proto = 0X3
Age = 0
NextHopAS = 0
Metric1 = 1
Metric2 = -1
Metric3 = -1
Metric4 = -1
Metric5 = -1

Any idea why CreateIpForwardEntry() wouldn't agree to accept the above parameters?

Tips, ideas, insights would be greatly appreciated.

Thanks.

+1  A: 

I don't know anything about IP routing, but the documentation for MIB_IPFORWARDROW doesn't list 0 as a valid value for dwForwardType. Also, the documentation for CreateIpForwardEntry indicates that dwForwardProto must be 3 (MIB_IPPROTO_NETMGMT).

Luke
Android Eve
Update: I just checked the PSDK Server 2003 R2 documentation: (1) I indeed missed the dwForwardType requirement which is mentioned in the older documentation. (2) MIB_IPPROTO_NETMGMT is nowhere to be found. I will try the implied code fixes and report back.
Android Eve