Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

786 lines
19 KiB

  1. /*
  2. Copyright (c) 1998, Microsoft Corporation, all rights reserved
  3. Description:
  4. History:
  5. */
  6. #include "rastcp_.h"
  7. /*
  8. Returns:
  9. Description:
  10. */
  11. IPADDR
  12. RasTcpDeriveMask(
  13. IN IPADDR nboIpAddr
  14. )
  15. {
  16. IPADDR nboMask = 0;
  17. IPADDR hboMask = 0;
  18. if (CLASSA_NBO_ADDR(nboIpAddr))
  19. {
  20. hboMask = CLASSA_HBO_ADDR_MASK;
  21. }
  22. else if (CLASSB_NBO_ADDR(nboIpAddr))
  23. {
  24. hboMask = CLASSB_HBO_ADDR_MASK;
  25. }
  26. else if (CLASSC_NBO_ADDR(nboIpAddr))
  27. {
  28. hboMask = CLASSC_HBO_ADDR_MASK;
  29. }
  30. nboMask = htonl(hboMask);
  31. return(nboMask);
  32. }
  33. /*
  34. Returns:
  35. VOID
  36. Description:
  37. Sets the ip address for proxy arp"ing" on all lan interfaces.
  38. */
  39. VOID
  40. RasTcpSetProxyArp(
  41. IN IPADDR nboIpAddr,
  42. IN BOOL fAddAddress
  43. )
  44. {
  45. MIB_IPADDRTABLE* pIpAddrTable = NULL;
  46. HANDLE hHeap = NULL;
  47. DWORD dwNboIpAddr;
  48. DWORD dwNboMask;
  49. DWORD dw;
  50. DWORD dwErr = NO_ERROR;
  51. extern IPADDR RasSrvrNboServerIpAddress;
  52. TraceHlp("RasTcpSetProxyArp(IP Addr: 0x%x, fAddAddress: %s)",
  53. nboIpAddr, fAddAddress ? "TRUE" : "FALSE");
  54. hHeap = GetProcessHeap();
  55. if (NULL == hHeap)
  56. {
  57. dwErr = GetLastError();
  58. TraceHlp("GetProcessHeap failed and returned %d", dwErr);
  59. goto LDone;
  60. }
  61. dwErr = PAllocateAndGetIpAddrTableFromStack(&pIpAddrTable,
  62. FALSE /* bOrder */, hHeap, LPTR);
  63. if (NO_ERROR != dwErr)
  64. {
  65. TraceHlp("AllocateAndGetIpAddrTableFromStack failed and returned %d",
  66. dwErr);
  67. goto LDone;
  68. }
  69. for (dw = 0; dw < pIpAddrTable->dwNumEntries; dw++)
  70. {
  71. dwNboIpAddr = pIpAddrTable->table[dw].dwAddr;
  72. dwNboMask = pIpAddrTable->table[dw].dwMask;
  73. if ( (ALL_NETWORKS_ROUTE == dwNboIpAddr)
  74. || (HOST_MASK == dwNboIpAddr)
  75. || (RasSrvrNboServerIpAddress == dwNboIpAddr))
  76. {
  77. continue;
  78. }
  79. if ((nboIpAddr & dwNboMask) != (dwNboIpAddr & dwNboMask))
  80. {
  81. continue;
  82. }
  83. dwErr = PSetProxyArpEntryToStack(nboIpAddr, HOST_MASK,
  84. pIpAddrTable->table[dw].dwIndex,
  85. fAddAddress, FALSE);
  86. if (NO_ERROR != dwErr)
  87. {
  88. TraceHlp("SetProxyArpEntryToStack on NIC with address 0x%x failed "
  89. "and returned 0x%x", dwNboIpAddr, dwErr);
  90. dwErr = PSetProxyArpEntryToStack(nboIpAddr, HOST_MASK,
  91. pIpAddrTable->table[dw].dwIndex,
  92. fAddAddress, TRUE);
  93. TraceHlp("SetProxyArpEntryToStack: 0x%x", dwErr);
  94. }
  95. }
  96. LDone:
  97. if ( (NULL != hHeap)
  98. && (NULL != pIpAddrTable))
  99. {
  100. HeapFree(hHeap, 0, pIpAddrTable);
  101. }
  102. return;
  103. }
  104. /*
  105. Returns:
  106. VOID
  107. Description:
  108. */
  109. VOID
  110. RasTcpSetRoute(
  111. IN IPADDR nboDestAddr,
  112. IN IPADDR nboNextHopAddr,
  113. IN IPADDR nboIpMask,
  114. IN IPADDR nboLocalAddr,
  115. IN BOOL fAddAddress,
  116. IN DWORD dwMetric,
  117. IN BOOL fSetToStack
  118. )
  119. {
  120. MIB_IPADDRTABLE* pIpAddrTable = NULL;
  121. MIB_IPFORWARDROW IpForwardRow;
  122. HANDLE hHeap = NULL;
  123. DWORD dw;
  124. DWORD dwErr = NO_ERROR;
  125. TraceHlp("RasTcpSetRoute(Dest: 0x%x, Mask: 0x%x, NextHop: 0x%x, "
  126. "Intf: 0x%x, %d, %s, %s)",
  127. nboDestAddr, nboIpMask, nboNextHopAddr, nboLocalAddr, dwMetric,
  128. fAddAddress ? "Add" : "Del",
  129. fSetToStack ? "Stack" : "Rtr");
  130. ZeroMemory(&IpForwardRow, sizeof(IpForwardRow));
  131. hHeap = GetProcessHeap();
  132. if (NULL == hHeap)
  133. {
  134. dwErr = GetLastError();
  135. TraceHlp("GetProcessHeap failed and returned %d", dwErr);
  136. goto LDone;
  137. }
  138. dwErr = PAllocateAndGetIpAddrTableFromStack(&pIpAddrTable,
  139. FALSE /* bOrder */, hHeap, LPTR);
  140. if (NO_ERROR != dwErr)
  141. {
  142. TraceHlp("AllocateAndGetIpAddrTableFromStack failed and returned %d",
  143. dwErr);
  144. goto LDone;
  145. }
  146. for (dw = 0; dw < pIpAddrTable->dwNumEntries; dw++)
  147. {
  148. if (nboLocalAddr == pIpAddrTable->table[dw].dwAddr)
  149. {
  150. IpForwardRow.dwForwardDest = nboDestAddr;
  151. IpForwardRow.dwForwardMask = nboIpMask;
  152. IpForwardRow.dwForwardPolicy = 0;
  153. IpForwardRow.dwForwardNextHop = nboNextHopAddr;
  154. IpForwardRow.dwForwardIfIndex = pIpAddrTable->table[dw].dwIndex;
  155. IpForwardRow.dwForwardProto = IRE_PROTO_NETMGMT;
  156. IpForwardRow.dwForwardAge = (DWORD)-1;
  157. IpForwardRow.dwForwardNextHopAS = 0;
  158. IpForwardRow.dwForwardMetric1 = dwMetric;
  159. IpForwardRow.dwForwardMetric2 = (DWORD)-1;
  160. IpForwardRow.dwForwardMetric3 = (DWORD)-1;
  161. IpForwardRow.dwForwardMetric4 = (DWORD)-1;
  162. IpForwardRow.dwForwardMetric5 = (DWORD)-1;
  163. IpForwardRow.dwForwardType = (fAddAddress ?
  164. IRE_TYPE_DIRECT : IRE_TYPE_INVALID);
  165. if (fSetToStack)
  166. {
  167. dwErr = PSetIpForwardEntryToStack(&IpForwardRow);
  168. }
  169. else
  170. {
  171. if (fAddAddress)
  172. {
  173. dwErr = PSetIpForwardEntry(&IpForwardRow);
  174. }
  175. else
  176. {
  177. dwErr = PDeleteIpForwardEntry(&IpForwardRow);
  178. }
  179. }
  180. if (NO_ERROR != dwErr)
  181. {
  182. TraceHlp("SetIpForwardEntry%s failed and returned 0x%x",
  183. fSetToStack ? "ToStack" : "", dwErr);
  184. }
  185. break;
  186. }
  187. }
  188. LDone:
  189. if ( (NULL != hHeap)
  190. && (NULL != pIpAddrTable))
  191. {
  192. HeapFree(hHeap, 0, pIpAddrTable);
  193. }
  194. return;
  195. }
  196. VOID
  197. RasTcpSetRouteEx(
  198. IN IPADDR nboDestAddr,
  199. IN IPADDR nboNextHopAddr,
  200. IN IPADDR nboIpMask,
  201. IN IPADDR nboLocalAddr,
  202. IN BOOL fAddAddress,
  203. IN DWORD dwMetric,
  204. IN BOOL fSetToStack,
  205. IN GUID *pIfGuid
  206. )
  207. {
  208. DWORD dwErr = NO_ERROR;
  209. HANDLE hHeap = NULL;
  210. IP_INTERFACE_NAME_INFO *pTable = NULL;
  211. DWORD dw;
  212. DWORD dwCount;
  213. MIB_IPFORWARDROW IpForwardRow;
  214. TraceHlp("RasTcpSetRouteEx(Dest: 0x%x, Mask: 0x%x, NextHop: 0x%x, "
  215. "Intf: 0x%x, %d, %s, %s)",
  216. nboDestAddr, nboIpMask, nboNextHopAddr, nboLocalAddr, dwMetric,
  217. fAddAddress ? "Add" : "Del",
  218. fSetToStack ? "Stack" : "Rtr");
  219. hHeap = GetProcessHeap();
  220. if(NULL == hHeap)
  221. {
  222. dwErr = GetLastError();
  223. TraceHlp("GetPRocessHeap failed and returned %d", dwErr);
  224. goto LDone;
  225. }
  226. ZeroMemory(&IpForwardRow, sizeof(MIB_IPFORWARDROW));
  227. dwErr = PNhpAllocateAndGetInterfaceInfoFromStack(&pTable, &dwCount,
  228. FALSE /* bOrder */, hHeap, LPTR);
  229. for(dw = 0; dw < dwCount; dw++)
  230. {
  231. if(0 == memcmp(&pTable[dw].DeviceGuid,
  232. pIfGuid,
  233. sizeof(GUID)))
  234. {
  235. break;
  236. }
  237. }
  238. if(dw == dwCount)
  239. {
  240. dwErr = ERROR_INVALID_PARAMETER;
  241. goto LDone;
  242. }
  243. IpForwardRow.dwForwardDest = nboDestAddr;
  244. IpForwardRow.dwForwardMask = nboIpMask;
  245. IpForwardRow.dwForwardPolicy = 0;
  246. if(nboDestAddr != ALL_NETWORKS_ROUTE)
  247. {
  248. IpForwardRow.dwForwardNextHop = nboNextHopAddr;
  249. }
  250. else
  251. {
  252. IpForwardRow.dwForwardNextHop = 0;
  253. }
  254. IpForwardRow.dwForwardIfIndex = pTable[dw].Index;
  255. IpForwardRow.dwForwardProto = IRE_PROTO_NETMGMT;
  256. IpForwardRow.dwForwardAge = (DWORD)-1;
  257. IpForwardRow.dwForwardNextHopAS = 0;
  258. IpForwardRow.dwForwardMetric1 = dwMetric;
  259. IpForwardRow.dwForwardMetric2 = (DWORD)-1;
  260. IpForwardRow.dwForwardMetric3 = (DWORD)-1;
  261. IpForwardRow.dwForwardMetric4 = (DWORD)-1;
  262. IpForwardRow.dwForwardMetric5 = (DWORD)-1;
  263. IpForwardRow.dwForwardType = (fAddAddress ?
  264. IRE_TYPE_DIRECT : IRE_TYPE_INVALID);
  265. if (fSetToStack)
  266. {
  267. dwErr = PSetIpForwardEntryToStack(&IpForwardRow);
  268. }
  269. else
  270. {
  271. if (fAddAddress)
  272. {
  273. dwErr = PSetIpForwardEntry(&IpForwardRow);
  274. }
  275. else
  276. {
  277. dwErr = PDeleteIpForwardEntry(&IpForwardRow);
  278. }
  279. }
  280. if (NO_ERROR != dwErr)
  281. {
  282. TraceHlp("SetIpForwardEntry%s failed and returned 0x%x",
  283. fSetToStack ? "ToStack" : "", dwErr);
  284. }
  285. LDone:
  286. if(NULL != pTable)
  287. {
  288. HeapFree(hHeap, 0, pTable);
  289. }
  290. }
  291. /*
  292. Returns:
  293. VOID
  294. Description:
  295. */
  296. #if 0
  297. VOID
  298. RasTcpSetRoutesForNameServers(
  299. BOOL fSet
  300. )
  301. {
  302. HANDLE hHeap = NULL;
  303. IP_INTERFACE_NAME_INFO* pTable = NULL;
  304. DWORD dw;
  305. DWORD dwCount;
  306. IPADDR nboIpAddress;
  307. IPADDR nboDNS1;
  308. IPADDR nboDNS2;
  309. IPADDR nboWINS1;
  310. IPADDR nboWINS2;
  311. IPADDR nboGateway;
  312. DWORD dwErr = NO_ERROR;
  313. TraceHlp("RasTcpSetRoutesForNameServers. fSet=%d", fSet);
  314. hHeap = GetProcessHeap();
  315. if (NULL == hHeap)
  316. {
  317. dwErr = GetLastError();
  318. TraceHlp("GetProcessHeap failed and returned %d", dwErr);
  319. goto LDone;
  320. }
  321. dwErr = PNhpAllocateAndGetInterfaceInfoFromStack(&pTable, &dwCount,
  322. FALSE /* bOrder */, hHeap, LPTR);
  323. if (NO_ERROR != dwErr)
  324. {
  325. TraceHlp("NhpAllocateAndGetInterfaceInfoFromStack failed and "
  326. "returned %d", dwErr);
  327. goto LDone;
  328. }
  329. for (dw = 0; dw < dwCount; dw++)
  330. {
  331. dwErr = GetAdapterInfo(
  332. pTable[dw].Index,
  333. &nboIpAddress,
  334. &nboDNS1, &nboDNS2,
  335. &nboWINS1, &nboWINS2,
  336. &nboGateway,
  337. NULL);
  338. if (NO_ERROR != dwErr)
  339. {
  340. dwErr = NO_ERROR;
  341. continue;
  342. }
  343. if (0 != nboDNS1)
  344. {
  345. RasTcpSetRoute(nboDNS1, nboGateway, HOST_MASK, nboIpAddress,
  346. fSet, 1, TRUE);
  347. }
  348. if (0 != nboDNS2)
  349. {
  350. RasTcpSetRoute(nboDNS2, nboGateway, HOST_MASK, nboIpAddress,
  351. fSet, 1, TRUE);
  352. }
  353. if (0 != nboWINS1)
  354. {
  355. RasTcpSetRoute(nboWINS1, nboGateway, HOST_MASK, nboIpAddress,
  356. fSet, 1, TRUE);
  357. }
  358. if (0 != nboWINS2)
  359. {
  360. RasTcpSetRoute(nboWINS2, nboGateway, HOST_MASK, nboIpAddress,
  361. fSet, 1, TRUE);
  362. }
  363. }
  364. LDone:
  365. if (NULL != pTable)
  366. {
  367. HeapFree(hHeap, 0, pTable);
  368. }
  369. }
  370. #endif
  371. //
  372. //Bump up the metric of all the routes or reduce the metric
  373. //of all multicase routes by 1
  374. //
  375. DWORD
  376. RasTcpAdjustMulticastRouteMetric (
  377. IN IPADDR nboIpAddr,
  378. IN BOOL fSet
  379. )
  380. {
  381. MIB_IPFORWARDTABLE* pIpForwardTable = NULL;
  382. MIB_IPFORWARDROW* pIpForwardRow;
  383. HANDLE hHeap = NULL;
  384. DWORD dw;
  385. DWORD dwErr = NO_ERROR;
  386. TraceHlp("RasTcpAdjustMulticastRouteMetric(IP Addr: 0x%x, Set: %s)", nboIpAddr,
  387. fSet ? "TRUE" : "FALSE");
  388. hHeap = GetProcessHeap();
  389. if (NULL == hHeap)
  390. {
  391. dwErr = GetLastError();
  392. TraceHlp("GetProcessHeap failed and returned %d", dwErr);
  393. goto LDone;
  394. }
  395. dwErr = PAllocateAndGetIpForwardTableFromStack(&pIpForwardTable,
  396. FALSE /* bOrder */, hHeap, LPTR);
  397. if (NO_ERROR != dwErr)
  398. {
  399. TraceHlp("AllocateAndGetIpAddrTableFromStack failed and returned %d",
  400. dwErr);
  401. goto LDone;
  402. }
  403. //
  404. //Steps to follow:
  405. // 1. Check to see if we have a default route for the interface with
  406. // the ip address passed in.
  407. // 2. If we do then bump up the metric for all interfaces with 0xE0
  408. // as the forward dest.
  409. // Else
  410. // we have nothing to do.
  411. // 3. Add an E0 route with a metric of 1.
  412. for (dw = 0; dw < pIpForwardTable->dwNumEntries; dw++)
  413. {
  414. pIpForwardRow = pIpForwardTable->table + dw;
  415. if ( 0 == pIpForwardRow->dwForwardDest ) //default route
  416. {
  417. IPADDR nboIpIfIpAddr;
  418. //
  419. //get the adapter information
  420. //to see if the ip address matches
  421. //
  422. dwErr = GetAdapterInfo ( pIpForwardRow->dwForwardIfIndex,
  423. &nboIpIfIpAddr,
  424. NULL,
  425. NULL,
  426. NULL,
  427. NULL,
  428. NULL,
  429. NULL
  430. );
  431. if ( NO_ERROR != dwErr )
  432. {
  433. TraceHlp("GetAdapterInfo failed and returned %d",
  434. dwErr);
  435. goto LDone;
  436. }
  437. if ( nboIpAddr == nboIpIfIpAddr )
  438. {
  439. DWORD dw1 = 0;
  440. MIB_IPFORWARDROW * pIpForwardRow1 = NULL;
  441. //
  442. //This means that we have a default route. So we need to bump up the metric of
  443. //all the E0 by 1
  444. for ( dw1 = 0; dw1 < pIpForwardTable->dwNumEntries; dw1 ++ )
  445. {
  446. pIpForwardRow1 = pIpForwardTable->table + dw1;
  447. if (0xE0 == pIpForwardRow1->dwForwardDest /* multicast route */)
  448. {
  449. if (fSet)
  450. {
  451. // Bump up metric (hop count)
  452. pIpForwardRow1->dwForwardMetric1++;
  453. }
  454. else if (pIpForwardRow1->dwForwardMetric1 > 1) // Never make it 0!
  455. {
  456. // Bump down metric
  457. pIpForwardRow1->dwForwardMetric1--;
  458. }
  459. dwErr = PSetIpForwardEntryToStack(pIpForwardRow1);
  460. if (NO_ERROR != dwErr)
  461. {
  462. TraceHlp("SetIpForwardEntryToStack failed and returned 0x%x"
  463. "dest=0x%x, nexthop=0x%x, mask=0x%x",
  464. dwErr,
  465. pIpForwardRow->dwForwardDest,
  466. pIpForwardRow->dwForwardNextHop,
  467. pIpForwardRow->dwForwardMask);
  468. dwErr = NO_ERROR;
  469. }
  470. }
  471. }
  472. if ( fSet )
  473. {
  474. //
  475. //Set the multicast route metric on this interface
  476. //to 1
  477. RasTcpSetRoute( 0xE0,
  478. nboIpAddr,
  479. 0xF0,
  480. nboIpAddr,
  481. TRUE,
  482. 1,
  483. TRUE
  484. );
  485. }
  486. break;
  487. }
  488. }
  489. }
  490. LDone:
  491. if ( (NULL != hHeap)
  492. && (NULL != pIpForwardTable))
  493. {
  494. HeapFree(hHeap, 0, pIpForwardTable);
  495. }
  496. return(dwErr);
  497. }
  498. /*
  499. Returns:
  500. Error codes from TCPConfig (your basic nt codes)
  501. Description:
  502. fSet: If TRUE means set existing routes to higher metrics and add OVERRIDE
  503. routes.
  504. If FALSE means mark existing routes to lower metrics.
  505. */
  506. DWORD
  507. RasTcpAdjustRouteMetrics(
  508. IN IPADDR nboIpAddr,
  509. IN BOOL fSet
  510. )
  511. {
  512. MIB_IPFORWARDTABLE* pIpForwardTable = NULL;
  513. MIB_IPFORWARDROW* pIpForwardRow;
  514. HANDLE hHeap = NULL;
  515. DWORD dw;
  516. DWORD dwErr = NO_ERROR;
  517. TraceHlp("RasTcpAdjustRouteMetrics(IP Addr: 0x%x, Set: %s)", nboIpAddr,
  518. fSet ? "TRUE" : "FALSE");
  519. hHeap = GetProcessHeap();
  520. if (NULL == hHeap)
  521. {
  522. dwErr = GetLastError();
  523. TraceHlp("GetProcessHeap failed and returned %d", dwErr);
  524. goto LDone;
  525. }
  526. dwErr = PAllocateAndGetIpForwardTableFromStack(&pIpForwardTable,
  527. FALSE /* bOrder */, hHeap, LPTR);
  528. if (NO_ERROR != dwErr)
  529. {
  530. TraceHlp("AllocateAndGetIpAddrTableFromStack failed and returned %d",
  531. dwErr);
  532. goto LDone;
  533. }
  534. for (dw = 0; dw < pIpForwardTable->dwNumEntries; dw++)
  535. {
  536. pIpForwardRow = pIpForwardTable->table + dw;
  537. if (0 == pIpForwardRow->dwForwardDest /* default route */)
  538. {
  539. if (fSet)
  540. {
  541. // Bump up metric (hop count)
  542. pIpForwardRow->dwForwardMetric1++;
  543. }
  544. else if (pIpForwardRow->dwForwardMetric1 > 1) // Never make it 0!
  545. {
  546. // Bump down metric
  547. pIpForwardRow->dwForwardMetric1--;
  548. }
  549. dwErr = PSetIpForwardEntryToStack(pIpForwardRow);
  550. if (NO_ERROR != dwErr)
  551. {
  552. TraceHlp("SetIpForwardEntryToStack failed and returned 0x%x"
  553. "dest=0x%x, nexthop=0x%x, mask=0x%x",
  554. dwErr,
  555. pIpForwardRow->dwForwardDest,
  556. pIpForwardRow->dwForwardNextHop,
  557. pIpForwardRow->dwForwardMask);
  558. dwErr = NO_ERROR;
  559. }
  560. }
  561. }
  562. LDone:
  563. if ( (NULL != hHeap)
  564. && (NULL != pIpForwardTable))
  565. {
  566. HeapFree(hHeap, 0, pIpForwardTable);
  567. }
  568. return(dwErr);
  569. }
  570. VOID
  571. RasTcpSetDhcpRoutes ( PBYTE pbRouteInfo, IPADDR ipAddrLocal, BOOL fSet )
  572. {
  573. //parse the byte stream and decode destination descriptors to get the subnet number and subnet mask.
  574. //The format of the stream is as follows
  575. //+------------------------------------------------------------------------------------
  576. //+Code | Len | d1 | ... | dn | r1 | r2 | r3 | r4 | d1 | ... | dn | r1 | r2 | r3 | r4 |
  577. //+------------------------------------------------------------------------------------
  578. //length of code = 1 octet
  579. //length of Len = 1 octet
  580. //Length of each d1 ... dn - 1 octet
  581. //Length of each r1 - r4 = 1 octet.
  582. BYTE dwAddrMaskLookup [] = {0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF };
  583. PBYTE pbRover = pbRouteInfo + 1;
  584. BYTE bLen = pbRouteInfo[0];
  585. TraceHlp ( "RasTcpSetDhcpRoutes Begin");
  586. while ( pbRover < pbRouteInfo + 1 + bLen )
  587. {
  588. unsigned char ipszdest[5] = {0};
  589. unsigned char ipszsnetmask[5] = {0};
  590. unsigned char ipsznexthop[5] = {0};
  591. IPADDR ipdest = 0;
  592. IPADDR ipmask = 0;
  593. IPADDR ipnexthop = 0;
  594. if ( *pbRover > 32 )
  595. {
  596. //Error. We cannot have more than 32 1's in the mask
  597. TraceHlp("RasTcpSetDhcpRoutes: invalid destination descriptor first byte %d",
  598. *pbRover);
  599. goto done;
  600. }
  601. else
  602. { //set the subnet mask first
  603. int n1 = (int)((*pbRover) / 8);
  604. int n2 = (int)((*pbRover) % 8 );
  605. int i;
  606. for ( i = 0; i < n1; i++)
  607. {
  608. ipszsnetmask[i] = (BYTE)0xFF;
  609. }
  610. //set the final byte
  611. if ( n2 ) ipszsnetmask[3] = dwAddrMaskLookup[n2];
  612. pbRover ++;
  613. //now for the ip address
  614. if ( n2 ) n1 ++;
  615. for ( i = 0; i < n1; i ++ )
  616. {
  617. ipszdest[i] = *pbRover;
  618. pbRover++;
  619. }
  620. TraceHlp ( "RasTcpSetDhcpRoutes: Got route dest addr = %d.%d.%d.%d subnet mask = %d.%d.%d.%d route = %d.%d.%d.%d\n",
  621. ipszdest[0],ipszdest[1],ipszdest[2],ipszdest[3],
  622. ipszsnetmask[0],ipszsnetmask[1],ipszsnetmask[2],ipszsnetmask[3],
  623. *pbRover, *(pbRover+1),*(pbRover+2),*(pbRover+3)
  624. );
  625. CopyMemory ( ipsznexthop, pbRover, 4 );
  626. /*
  627. //now set the route
  628. ipdest = inet_addr ((const char FAR *)ipszdest);
  629. ipmask = inet_addr ((const char FAR *)ipszsnetmask);
  630. ipnexthop = inet_addr ((const char FAR *)ipsznexthop);
  631. */
  632. ipdest = *((ULONG *)ipszdest);
  633. ipmask = *((ULONG *)ipszsnetmask);
  634. ipnexthop = *((ULONG *)ipsznexthop);
  635. RasTcpSetRoute( ipdest,
  636. ipAddrLocal,
  637. ipmask,
  638. ipAddrLocal,
  639. fSet,
  640. 1,
  641. TRUE
  642. );
  643. pbRover +=4;
  644. }
  645. }
  646. done:
  647. TraceHlp ( "RasTcpSetDhcpRoutes End");
  648. return;
  649. }