Lines 209-215
Link Here
|
209 |
static unsigned char inbuf[512]; /* buffer for chars read from loopback */ |
209 |
static unsigned char inbuf[512]; /* buffer for chars read from loopback */ |
210 |
|
210 |
|
211 |
static int if_is_up; /* Interface has been marked up */ |
211 |
static int if_is_up; /* Interface has been marked up */ |
212 |
static int have_default_route; /* Gateway for default route added */ |
212 |
static u_int32_t default_route_gateway; /* Gateway for default route added */ |
213 |
static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ |
213 |
static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ |
214 |
static char proxy_arp_dev[16]; /* Device for proxy arp entry */ |
214 |
static char proxy_arp_dev[16]; /* Device for proxy arp entry */ |
215 |
static u_int32_t our_old_addr; /* for detecting address changes */ |
215 |
static u_int32_t our_old_addr; /* for detecting address changes */ |
Lines 346-353
Link Here
|
346 |
/* |
346 |
/* |
347 |
* Delete any routes through the device. |
347 |
* Delete any routes through the device. |
348 |
*/ |
348 |
*/ |
349 |
if (have_default_route) |
349 |
if (default_route_gateway != 0) |
350 |
cifdefaultroute(0, 0, 0); |
350 |
cifdefaultroute(0, 0, default_route_gateway); |
351 |
|
351 |
|
352 |
if (has_proxy_arp) |
352 |
if (has_proxy_arp) |
353 |
cifproxyarp(0, proxy_arp_addr); |
353 |
cifproxyarp(0, proxy_arp_addr); |
Lines 1615-1631
Link Here
|
1615 |
struct rtentry rt; |
1615 |
struct rtentry rt; |
1616 |
|
1616 |
|
1617 |
if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) { |
1617 |
if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) { |
1618 |
if (rt.rt_flags & RTF_GATEWAY) |
1618 |
u_int32_t old_gateway = SIN_ADDR(rt.rt_gateway); |
1619 |
error("not replacing existing default route via %I", |
1619 |
|
1620 |
SIN_ADDR(rt.rt_gateway)); |
1620 |
if (old_gateway != gateway) |
1621 |
else |
1621 |
error("not replacing existing default route to %s [%I]", |
1622 |
error("not replacing existing default route through %s", |
1622 |
rt.rt_dev, old_gateway); |
1623 |
rt.rt_dev); |
|
|
1624 |
return 0; |
1623 |
return 0; |
1625 |
} |
1624 |
} |
1626 |
|
1625 |
|
1627 |
memset (&rt, 0, sizeof (rt)); |
1626 |
memset (&rt, '\0', sizeof (rt)); |
1628 |
SET_SA_FAMILY (rt.rt_dst, AF_INET); |
1627 |
SET_SA_FAMILY (rt.rt_dst, AF_INET); |
|
|
1628 |
SET_SA_FAMILY (rt.rt_gateway, AF_INET); |
1629 |
|
1629 |
|
1630 |
rt.rt_dev = ifname; |
1630 |
rt.rt_dev = ifname; |
1631 |
|
1631 |
|
Lines 1634-1647
Link Here
|
1634 |
SIN_ADDR(rt.rt_genmask) = 0L; |
1634 |
SIN_ADDR(rt.rt_genmask) = 0L; |
1635 |
} |
1635 |
} |
1636 |
|
1636 |
|
1637 |
rt.rt_flags = RTF_UP; |
1637 |
SIN_ADDR(rt.rt_gateway) = gateway; |
|
|
1638 |
|
1639 |
rt.rt_flags = RTF_UP | RTF_GATEWAY; |
1638 |
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { |
1640 |
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { |
1639 |
if ( ! ok_error ( errno )) |
1641 |
if ( ! ok_error ( errno )) |
1640 |
error("default route ioctl(SIOCADDRT): %m"); |
1642 |
error("default route ioctl(SIOCADDRT): %m"); |
1641 |
return 0; |
1643 |
return 0; |
1642 |
} |
1644 |
} |
1643 |
|
1645 |
|
1644 |
have_default_route = 1; |
1646 |
default_route_gateway = gateway; |
1645 |
return 1; |
1647 |
return 1; |
1646 |
} |
1648 |
} |
1647 |
|
1649 |
|
Lines 1654-1660
Link Here
|
1654 |
{ |
1656 |
{ |
1655 |
struct rtentry rt; |
1657 |
struct rtentry rt; |
1656 |
|
1658 |
|
1657 |
have_default_route = 0; |
1659 |
default_route_gateway = 0; |
1658 |
|
1660 |
|
1659 |
memset (&rt, '\0', sizeof (rt)); |
1661 |
memset (&rt, '\0', sizeof (rt)); |
1660 |
SET_SA_FAMILY (rt.rt_dst, AF_INET); |
1662 |
SET_SA_FAMILY (rt.rt_dst, AF_INET); |
Lines 1665-1671
Link Here
|
1665 |
SIN_ADDR(rt.rt_genmask) = 0L; |
1667 |
SIN_ADDR(rt.rt_genmask) = 0L; |
1666 |
} |
1668 |
} |
1667 |
|
1669 |
|
1668 |
rt.rt_flags = RTF_UP; |
1670 |
SIN_ADDR(rt.rt_gateway) = gateway; |
|
|
1671 |
|
1672 |
rt.rt_flags = RTF_UP | RTF_GATEWAY; |
1669 |
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { |
1673 |
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { |
1670 |
if (still_ppp()) { |
1674 |
if (still_ppp()) { |
1671 |
if ( ! ok_error ( errno )) |
1675 |
if ( ! ok_error ( errno )) |