Hi,
I am using evc++ 4.0 with K-Jam for changing metric value of the
adapter which i am
loading dynamically and assign IP. The code i am using is as follows:
{
BOOL bRet = FALSE;
PMIB_IPFORWARDTABLE pBuffer = NULL;
DWORD dwSize = 0;
UINT k = 0;
DWORD dwAdapIndx = 0;
DWORD dwError = 0;
do
{
if (GetAdapterIndex(VPN_VIRTUAL_ADAPTER,&dwAdapIndx) != NO_ERROR)
{
break;
}
dwError = GetIpForwardTable(NULL,&dwSize,TRUE);
if (ERROR_INSUFFICIENT_BUFFER == dwError || ERROR_BUFFER_OVERFLOW ==
dwError)
{
pBuffer = (PMIB_IPFORWARDTABLE)malloc(dwSize);
if (pBuffer)
{
if(NO_ERROR == GetIpForwardTable(pBuffer,&dwSize,0))
{
for (k = 0; k < pBuffer->dwNumEntries; k++)
{
if ( pBuffer->table[k].dwForwardIfIndex ==
dwAdapIndx )
{
if ( pBuffer->table[k].dwForwardMetric1
> 1 )
{
pBuffer->table[k].dwForwardMetric1 = pBuffer-
>table[k].dwForwardMetric1 - 1;
}
if( NO_ERROR == SetIpForwardEntry(
&(pBuffer->table[k]) ) )
{
bRet = TRUE;
/*Success condition*/
}
else
{
/*Failing condition*/
}
}
else
{
msgloop_CB_printf(NULL, "Entry is not
found");
}
}
}
}
}
} while(FALSE);
if (pBuffer)
{
free(pBuffer);
pBuffer = NULL;
}
return bRet;
}
I tested all the possible error paths, everything works fine. Using
above code i am able
to change the metric value of the default route (0.0.0.0) for newely
created adapter. But for
rest of the route entries for newly created adapter, SetIpForwardEntry
API returning error 87
(Invalid parameters). I have also tested this applcation in standalone
mode but the result is
the same. Is there any constrain that only default route metric value
can be changed
programmatically, not other routes? Any suggession on the behavior of
PPC routing table.
Regards
Rajat
Omar [MS] - 28 Feb 2007 02:54 GMT
What exactly are the values in the buffer being passed into
SetIpForwardEntry?

Signature
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send
email directly to this alias. This alias is for newsgroup purposes only.
> Hi,
>
[quoted text clipped - 97 lines]
> Regards
> Rajat
Rajat - 05 Mar 2007 06:39 GMT
> What exactly are the values in the buffer being passed intoSetIpForwardEntry?
>
[quoted text clipped - 110 lines]
>
> - Show quoted text -
Hi Omar,
Thanks for reply. The new metric value is current metric value - 1.
Rest of the variables of structure remains unchanged.
Regards
Rajat