1 --- ppp/pppd/plugins/rp-pppoe/plugin.c.orig 2003-04-07 02:09:05.000000000 +0200
2 +++ ppp/pppd/plugins/rp-pppoe/plugin.c 2003-12-03 22:15:07.000000000 +0100
7 +/* from <linux/if.h> */
9 +#define IFF_RUNNING 0x40
11 +static short ifrflags_old;
13 +static int interface_change(const char* ifname, int up)
18 + if (!up && ifrflags_old != 0) {
22 + fd = socket(AF_INET, SOCK_DGRAM, 0);
24 + warn("socket(AF_INET, SOCK_DGRAM, 0): %s", strerror(errno));
28 + strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
29 + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
30 + warn("%s: unknown interface: %s", ifname, strerror(errno));
33 + strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
35 + ifrflags_old = ifr.ifr_flags & (IFF_UP | IFF_RUNNING);
36 + ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
38 + ifr.ifr_flags &= ~(IFF_UP | IFF_RUNNING);
40 + if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
41 + warn("SIOCSIFFLAGS: %s", strerror(errno));
48 +static int interface_up (const char *ifname)
50 + return interface_change(ifname,1);
53 +static int interface_down (const char* ifname)
55 + return interface_change(ifname,0);
58 /**********************************************************************
59 * %FUNCTION: PPPOEConnectDevice
62 conn->peerEth[i] = (unsigned char) mac[i];
65 + if (interface_up(conn->ifName) < 0)
68 if (conn->discoveryState != STATE_SESSION) {
69 fatal("Unable to complete PPPoE Discovery");
73 close(conn->sessionSocket);
74 + if (interface_down(conn->ifName) < 0)
75 + warn("We brought %s up but failed to take it down",conn->ifName);