summaryrefslogtreecommitdiff
path: root/obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change
diff options
context:
space:
mode:
authormbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2004-08-24 23:50:14 +0000
committermbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2004-08-24 23:50:14 +0000
commit097635b79bc6ddd6066a8369db6e298a25daa96e (patch)
treedb8218863c9124ae287832ccd846ad4d96c2e05e /obsolete-buildroot/sources/openwrt/patches/ppp/057_pppoe-interface-change
parent54da0f9e4ba892d2613d4f0d0c4bf4eecdcfd0a4 (diff)
massive changes
- sstrip cleanup from mjn3 - various patches from nico and others: http://openwrt.org/forum/viewtopic.php?t=368 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@145 3c298f89-4303-0410-b956-a3cf2f4a3e73
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-change78
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 0000000000..cca5a0e67e
--- /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