|
17 | 17 | LIST_ENTRY FIBListHead; |
18 | 18 | KSPIN_LOCK FIBLock; |
19 | 19 |
|
20 | | -void RouterDumpRoutes() { |
| 20 | +UINT |
| 21 | +ProcessAutoMetric( |
| 22 | + _In_ PIP_INTERFACE Interface) |
| 23 | +{ |
| 24 | + if (Interface == Loopback) |
| 25 | + return 1; |
| 26 | + |
| 27 | + if (Interface->Metric != 0) |
| 28 | + return Interface->Metric; |
| 29 | + |
| 30 | + /* Auto metric */ |
| 31 | + if (Interface->Speed > 2000000000) |
| 32 | + return 5; |
| 33 | + else if (Interface->Speed > 200000000) |
| 34 | + return 10; |
| 35 | + else if (Interface->Speed > 80000000) |
| 36 | + return 20; |
| 37 | + else if (Interface->Speed > 20000000) |
| 38 | + return 25; |
| 39 | + else if (Interface->Speed > 4000000) |
| 40 | + return 30; |
| 41 | + else if (Interface->Speed > 500000) |
| 42 | + return 40; |
| 43 | + else |
| 44 | + return 50; |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +VOID |
| 49 | +RouterDumpRoutes(VOID) |
| 50 | +{ |
21 | 51 | PLIST_ENTRY CurrentEntry; |
22 | 52 | PLIST_ENTRY NextEntry; |
23 | 53 | PFIB_ENTRY Current; |
@@ -422,16 +452,14 @@ PFIB_ENTRY RouterCreateRoute( |
422 | 452 | PIP_ADDRESS NetworkAddress, |
423 | 453 | PIP_ADDRESS Netmask, |
424 | 454 | PIP_ADDRESS RouterAddress, |
425 | | - PIP_INTERFACE Interface, |
426 | | - UINT Metric) |
| 455 | + PIP_INTERFACE Interface) |
427 | 456 | /* |
428 | 457 | * FUNCTION: Creates a route with IPv4 addresses as parameters |
429 | 458 | * ARGUMENTS: |
430 | 459 | * NetworkAddress = Address of network |
431 | 460 | * Netmask = Netmask of network |
432 | 461 | * RouterAddress = Address of router to use |
433 | | - * NTE = Pointer to NTE to use |
434 | | - * Metric = Cost of this route |
| 462 | + * Interface = Network interface |
435 | 463 | * RETURNS: |
436 | 464 | * Pointer to FIB entry if the route was created, NULL if not. |
437 | 465 | * The FIB entry references the NTE. The caller is responsible |
@@ -475,7 +503,7 @@ PFIB_ENTRY RouterCreateRoute( |
475 | 503 | return NULL; |
476 | 504 | } |
477 | 505 |
|
478 | | - return RouterAddRoute(NetworkAddress, Netmask, NCE, Metric); |
| 506 | + return RouterAddRoute(NetworkAddress, Netmask, NCE, ProcessAutoMetric(Interface)); |
479 | 507 | } |
480 | 508 |
|
481 | 509 |
|
|
0 commit comments