diff options
Diffstat (limited to 'obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change')
-rw-r--r-- | obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change b/obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change new file mode 100644 index 000000000..cca5a0e67 --- /dev/null +++ b/obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change @@ -0,0 +1,78 @@ +--- ppp/pppd/plugins/rp-pppoe/plugin.c.orig 2003-04-07 02:09:05.000000000 +0200 ++++ ppp/pppd/plugins/rp-pppoe/plugin.c 2003-12-03 22:15:07.000000000 +0100 +@@ -114,6 +114,57 @@ + return 1; + } + ++/* from <linux/if.h> */ ++#define IFF_UP 0x1 ++#define IFF_RUNNING 0x40 ++ ++static short ifrflags_old; ++ ++static int interface_change(const char* ifname, int up) ++{ ++ int fd; ++ struct ifreq ifr; ++ ++ if (!up && ifrflags_old != 0) { ++ return 0; ++ } ++ ++ fd = socket(AF_INET, SOCK_DGRAM, 0); ++ if (fd < 0) { ++ warn("socket(AF_INET, SOCK_DGRAM, 0): %s", strerror(errno)); ++ return -1; ++ } ++ ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ); ++ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { ++ warn("%s: unknown interface: %s", ifname, strerror(errno)); ++ return -1; ++ } ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ); ++ if (up) { ++ ifrflags_old = ifr.ifr_flags & (IFF_UP | IFF_RUNNING); ++ ifr.ifr_flags |= (IFF_UP | IFF_RUNNING); ++ } else { ++ ifr.ifr_flags &= ~(IFF_UP | IFF_RUNNING); ++ } ++ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { ++ warn("SIOCSIFFLAGS: %s", strerror(errno)); ++ return -1; ++ } ++ close(fd); ++ return 0; ++} ++ ++static int interface_up (const char *ifname) ++{ ++ return interface_change(ifname,1); ++} ++ ++static int interface_down (const char* ifname) ++{ ++ return interface_change(ifname,0); ++} ++ + /********************************************************************** + * %FUNCTION: PPPOEConnectDevice + * %ARGUMENTS: +@@ -142,6 +193,8 @@ + conn->peerEth[i] = (unsigned char) mac[i]; + } + } else { ++ if (interface_up(conn->ifName) < 0) ++ return -1; + discovery(conn); + if (conn->discoveryState != STATE_SESSION) { + fatal("Unable to complete PPPoE Discovery"); +@@ -243,6 +296,8 @@ + return; + } + close(conn->sessionSocket); ++ if (interface_down(conn->ifName) < 0) ++ warn("We brought %s up but failed to take it down",conn->ifName); + } + + static void |