static unsigned char inbuf[512]; /* buffer for chars read from loopback */
static int if_is_up; /* Interface has been marked up */
+static int if6_is_up; /* Interface has been marked up for IPv6, to help differentiate */
static int have_default_route; /* Gateway for default route added */
static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
static char proxy_arp_dev[16]; /* Device for proxy arp entry */
if_is_up = 0;
sifdown(0);
}
+ if (if6_is_up)
+ sif6down(0);
+
/*
* Delete any routes through the device.
*/
SET_SA_FAMILY (rt.rt_dst, AF_INET);
SET_SA_FAMILY (rt.rt_gateway, AF_INET);
+ rt.rt_dev = ifname;
+
if (kernel_version > KVERSION(2,1,0)) {
SET_SA_FAMILY (rt.rt_genmask, AF_INET);
SIN_ADDR(rt.rt_genmask) = 0L;
int ppp_available(void)
{
- int s, ok, fd, err;
+ int s, ok, fd;
struct ifreq ifr;
int size;
int my_version, my_modification, my_patch;
close(fd);
return 1;
}
- err = errno;
if (kernel_version >= KVERSION(2,3,13)) {
error("Couldn't open the /dev/ppp device: %m");
return ok;
}
+#ifndef HAVE_LOGWTMP
/********************************************************************
*
* Update the wtmp file with the appropriate user name and tty device.
}
#endif
}
-
+#endif /* HAVE_LOGWTMP */
/********************************************************************
*
u_int x;
if (vjcomp) {
- if (ioctl(ppp_dev_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0)
+ if (ioctl(ppp_dev_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
error("Couldn't set up TCP header compression: %m");
- vjcomp = 0;
+ vjcomp = 0;
+ }
}
x = (vjcomp? SC_COMP_TCP: 0) | (cidcomp? 0: SC_NO_TCP_CCID);
int sifup(int u)
{
- struct ifreq ifr;
+ int ret;
- memset (&ifr, '\0', sizeof (ifr));
- strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
- if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
- if (! ok_error (errno))
- error("ioctl (SIOCGIFFLAGS): %m (line %d)", __LINE__);
- return 0;
- }
-
- ifr.ifr_flags |= (IFF_UP | IFF_POINTOPOINT);
- if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
- if (! ok_error (errno))
- error("ioctl(SIOCSIFFLAGS): %m (line %d)", __LINE__);
- return 0;
- }
- if_is_up++;
+ if ((ret = setifstate(u, 1)))
+ if_is_up++;
- return 1;
+ return ret;
}
/********************************************************************
int sifdown (int u)
{
- struct ifreq ifr;
-
if (if_is_up && --if_is_up > 0)
return 1;
+#ifdef INET6
+ if (if6_is_up)
+ return 1;
+#endif /* INET6 */
+
+ return setifstate(u, 0);
+}
+
+#ifdef INET6
+/********************************************************************
+ *
+ * sif6up - Config the interface up for IPv6
+ */
+
+int sif6up(int u)
+{
+ int ret;
+
+ if ((ret = setifstate(u, 1)))
+ if6_is_up = 1;
+
+ return ret;
+}
+
+/********************************************************************
+ *
+ * sif6down - Disable the IPv6CP protocol and config the interface
+ * down if there are no remaining protocols.
+ */
+
+int sif6down (int u)
+{
+ if6_is_up = 0;
+
+ if (if_is_up)
+ return 1;
+
+ return setifstate(u, 0);
+}
+#endif /* INET6 */
+
+/********************************************************************
+ *
+ * setifstate - Config the interface up or down
+ */
+
+int setifstate (int u, int state)
+{
+ struct ifreq ifr;
+
memset (&ifr, '\0', sizeof (ifr));
strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
return 0;
}
- ifr.ifr_flags &= ~IFF_UP;
+ if (state)
+ ifr.ifr_flags |= IFF_UP;
+ else
+ ifr.ifr_flags &= ~IFF_UP;
ifr.ifr_flags |= IFF_POINTOPOINT;
if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
if (! ok_error (errno))
/*
* And convert the EUI-48 into EUI-64, per RFC 2472 [sec 4.1]
*/
- ptr = ifr.ifr_hwaddr.sa_data;
+ ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data;
p_eui64->e8[0] = ptr[0] | 0x02;
p_eui64->e8[1] = ptr[1];
p_eui64->e8[2] = ptr[2];