Prev Previous Post   Next Post Next

Route addition in Vista

Posted: 08-08-2006, 11:40 AM
Hi,

I am using Windows Vista Beta for my network application development under

administrator login(full access). I am trying to add a route to the

existing route table using CreateIpForwardEntry API.

I am getting following error.

"160 - One or more argument are not correct". Same code working in Win2000
and XP.

But From command prompt I was able to add/delete the route using route

command.



If you have idea on solving this issue please let me know.





The source is here



BOOL Add_Route_x( DWORD destination,

DWORD gateway,

DWORD mask,

DWORD metric,

int row_number,

DWORD index,

DWORD fwdType)

{

BOOL bRet = FALSE;

MIB_IPFORWARDROW pfwrow;

DWORD dwStatus;





pfwrow.dwForwardNextHop = gateway;

pfwrow.dwForwardDest = destination;

pfwrow.dwForwardMask = mask;

pfwrow.dwForwardMetric1 = metric;





pfwrow.dwForwardPolicy = 0;

pfwrow.dwForwardType = fwdType;

pfwrow.dwForwardProto = 3;//PROTO_IP_NETMGMT;

pfwrow.dwForwardAge = -1 ;

pfwrow.dwForwardNextHopAS =0;





pfwrow.dwForwardMetric2 = 0xffffffff;

pfwrow.dwForwardMetric3 = 0xffffffff;

pfwrow.dwForwardMetric4 = 0xffffffff;

pfwrow.dwForwardMetric5 = 0xffffffff;

pfwrow.dwForwardIfIndex = index;





LOG("Adding route for following parameters");

LOG("Gateway = %s",print_in_addr_t(ntohl(gateway)));

LOG("Destination = %s",print_in_addr_t(ntohl(destination)));

LOG("Mask = %s",print_in_addr_t(ntohl(mask)));

LOG("Forward Type = %d", fwdType);

LOG("Index = %x",index);

LOG("Metric = %d",metric);





// Create a new route entry for the default gateway.

dwStatus = CreateIpForwardEntry(&pfwrow);

if (dwStatus == NO_ERROR)

{

LOG("Add route successfull");

bRet = TRUE;

}

else

{

LOG("Add route failed. CreateIpForwardEntry returning Error

code = %d", dwStatus);

if(ERROR_INVALID_PARAMETER == dwStatus)

{

LOG("One of the members of the MIB_IPFORWARDROW structure

is invalid.");

}

else if(ERROR_NOT_SUPPORTED == dwStatus)

{

LOG("The IP transport is not configured on the local

computer");

}

bRet = FALSE;

}





return bRet;







} // End of AddRoute()





log file contains following info

================================================== ==========

Routing Table in System...

ForwardDest ForwardMask ForwardNextHop ForwardMetric IfIndex

0.0.0.0 0.0.0.0 172.16.2.1 276
0000000b

127.0.0.0 255.0.0.0 0.0.0.0 306
00000001

127.0.0.1 255.255.255.255 0.0.0.0 306
00000001

127.255.255.255 255.255.255.255 0.0.0.0 306 00000001

172.16.0.0 255.255.0.0 0.0.0.0 276
0000000b

172.16.91.15 255.255.255.255 0.0.0.0 276 0000000b

172.16.255.255 255.255.255.255 0.0.0.0 276 0000000b

224.0.0.0 240.0.0.0 0.0.0.0 306
00000001

224.0.0.0 240.0.0.0 0.0.0.0 276
0000000b

224.0.0.0 240.0.0.0 0.0.0.0 266
0000000f

239.255.255.255 255.255.255.255 0.0.0.0 306 00000001

239.255.255.255 255.255.255.255 0.0.0.0 276 0000000b

239.255.255.255 255.255.255.255 0.0.0.0 266 0000000f

255.255.255.255 255.255.255.255 0.0.0.0 306 00000001

255.255.255.255 255.255.255.255 0.0.0.0 276
0000000b

255.255.255.255 255.255.255.255 0.0.0.0 266
0000000f

Adding route for following parameters

Gateway = 172.16.91.15

Destination = 172.16.100.68

Mask = 255.255.255.255

Forward Type = 3

Index = b

Metric = 1

Add route failed. CreateIpForwardEntry returning Error code = 160



================================================== ==========



If you know how to solve this issue, please let me know. In parallel

I will change other parameter details and try.



I am not getting meaning of

"On Windows Vista and Windows Server "Longhorn", the

CreateIpForwardEntry only works on interfaces with a single

sub-interface (where the interface LUID and subinterface LUID are the

same). The dwForwardIfIndex member of the MIB_IPFORWARDROW structure

specifies the interface. "



in the following link.

http://msdn.microsoft.com/library/de...rwardentry.asp



Please explain me.





-- Jothi




--
JothiKumar
Technical Consultant
Calsoft, Chennai
Reply With Quote

Responses to "Route addition in Vista"

 
LinkBack Thread Tools Display Modes
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Route add doesn't work Luca Windows Vista Networking & Sharing 2 06-15-2006 02:58 PM
Route command doesn't work Luca Windows Vista Networking & Sharing 2 06-14-2006 01:31 PM