Lines 1441-1447
Link Here
|
1441 |
FILE *route_fd = (FILE *) 0; |
1441 |
FILE *route_fd = (FILE *) 0; |
1442 |
static char route_buffer[512]; |
1442 |
static char route_buffer[512]; |
1443 |
static int route_dev_col, route_dest_col, route_gw_col; |
1443 |
static int route_dev_col, route_dest_col, route_gw_col; |
1444 |
static int route_flags_col, route_mask_col; |
1444 |
static int route_flags_col, route_mask_col, route_metric_col; |
1445 |
static int route_num_cols; |
1445 |
static int route_num_cols; |
1446 |
|
1446 |
|
1447 |
static int open_route_table (void); |
1447 |
static int open_route_table (void); |
Lines 1484-1489
Link Here
|
1484 |
route_dest_col = 1; |
1484 |
route_dest_col = 1; |
1485 |
route_gw_col = 2; |
1485 |
route_gw_col = 2; |
1486 |
route_flags_col = 3; |
1486 |
route_flags_col = 3; |
|
|
1487 |
route_metric_col = 6; |
1487 |
route_mask_col = 7; |
1488 |
route_mask_col = 7; |
1488 |
route_num_cols = 8; |
1489 |
route_num_cols = 8; |
1489 |
|
1490 |
|
Lines 1503-1508
Link Here
|
1503 |
route_gw_col = col; |
1504 |
route_gw_col = col; |
1504 |
else if (strcasecmp(q, "flags") == 0) |
1505 |
else if (strcasecmp(q, "flags") == 0) |
1505 |
route_flags_col = col; |
1506 |
route_flags_col = col; |
|
|
1507 |
else if (strcasecmp(q, "metric") == 0) |
1508 |
route_metric_col = col; |
1506 |
else if (strcasecmp(q, "mask") == 0) |
1509 |
else if (strcasecmp(q, "mask") == 0) |
1507 |
route_mask_col = col; |
1510 |
route_mask_col = col; |
1508 |
else |
1511 |
else |
Lines 1545-1550
Link Here
|
1545 |
|
1548 |
|
1546 |
rt->rt_flags = (short) strtoul(cols[route_flags_col], NULL, 16); |
1549 |
rt->rt_flags = (short) strtoul(cols[route_flags_col], NULL, 16); |
1547 |
rt->rt_dev = cols[route_dev_col]; |
1550 |
rt->rt_dev = cols[route_dev_col]; |
|
|
1551 |
rt->rt_metric = (short) strtoul(cols[route_metric_col], NULL, 16); |
1548 |
|
1552 |
|
1549 |
return 1; |
1553 |
return 1; |
1550 |
} |
1554 |
} |
Lines 1567-1572
Link Here
|
1567 |
|
1571 |
|
1568 |
if (kernel_version > KVERSION(2,1,0) && SIN_ADDR(rt->rt_genmask) != 0) |
1572 |
if (kernel_version > KVERSION(2,1,0) && SIN_ADDR(rt->rt_genmask) != 0) |
1569 |
continue; |
1573 |
continue; |
|
|
1574 |
if (rt->rt_metric != defaultmetric) /* consider only routes with the same metric */ |
1575 |
continue; |
1570 |
if (SIN_ADDR(rt->rt_dst) == 0L) { |
1576 |
if (SIN_ADDR(rt->rt_dst) == 0L) { |
1571 |
result = 1; |
1577 |
result = 1; |
1572 |
break; |
1578 |
break; |
Lines 1637-1642
Link Here
|
1637 |
SIN_ADDR(rt.rt_gateway) = gateway; |
1643 |
SIN_ADDR(rt.rt_gateway) = gateway; |
1638 |
|
1644 |
|
1639 |
rt.rt_flags = RTF_UP | RTF_GATEWAY; |
1645 |
rt.rt_flags = RTF_UP | RTF_GATEWAY; |
|
|
1646 |
rt.rt_metric = defaultmetric + 1; /* +1 for binary compatibility */ |
1640 |
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { |
1647 |
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { |
1641 |
if ( ! ok_error ( errno )) |
1648 |
if ( ! ok_error ( errno )) |
1642 |
error("default route ioctl(SIOCADDRT): %m"); |
1649 |
error("default route ioctl(SIOCADDRT): %m"); |
Lines 1670-1675
Link Here
|
1670 |
SIN_ADDR(rt.rt_gateway) = gateway; |
1677 |
SIN_ADDR(rt.rt_gateway) = gateway; |
1671 |
|
1678 |
|
1672 |
rt.rt_flags = RTF_UP | RTF_GATEWAY; |
1679 |
rt.rt_flags = RTF_UP | RTF_GATEWAY; |
|
|
1680 |
rt.rt_metric = defaultmetric + 1; /* +1 for binary compatibility */ |
1673 |
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { |
1681 |
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { |
1674 |
if (still_ppp()) { |
1682 |
if (still_ppp()) { |
1675 |
if ( ! ok_error ( errno )) |
1683 |
if ( ! ok_error ( errno )) |