diff options
Diffstat (limited to 'mdk-stage1/adsl.c')
-rw-r--r-- | mdk-stage1/adsl.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/mdk-stage1/adsl.c b/mdk-stage1/adsl.c index d542f2f35..70968f50b 100644 --- a/mdk-stage1/adsl.c +++ b/mdk-stage1/adsl.c @@ -1,7 +1,7 @@ /* - * Guillaume Cottenceau (gc@mandrakesoft.com) + * Guillaume Cottenceau (gc) * - * Copyright 2000 MandrakeSoft + * Copyright 2000 Mandriva * * This software may be freely redistributed under the terms of the GNU * public license. @@ -31,14 +31,14 @@ #include "log.h" #include "network.h" #include "modules.h" -#include "tools.h" +#include "utils.h" #include "frontend.h" #include "automatic.h" #include "adsl.h" -static enum return_type adsl_connect(char * net_device, char * username, char * password) +static enum return_type adsl_connect(struct interface_info * intf, char * username, char * password, char * acname) { char pppoe_call[500]; char * pppd_launch[] = { "/sbin/pppd", "pty", pppoe_call, "noipdefault", "noauth", "default-asyncmap", "defaultroute", @@ -51,8 +51,12 @@ static enum return_type adsl_connect(char * net_device, char * username, char * enum return_type status = RETURN_ERROR; pid_t ppp_pid; - snprintf(pppoe_call, sizeof(pppoe_call), "/sbin/pppoe -p /var/run/pppoe.conf-adsl.pid.pppoe -I %s -T 80 -U -m 1412", net_device); + snprintf(pppoe_call, sizeof(pppoe_call), "/sbin/pppoe -p /var/run/pppoe.conf-adsl.pid.pppoe -I %s -T 80 -U -m 1412", intf->device); + if (!streq(acname, "")) { + strcat(pppoe_call, "-C "); + strcat(pppoe_call, acname); + } fd = open(tty_adsl, O_RDWR); if (fd == -1) { @@ -75,7 +79,7 @@ static enum return_type adsl_connect(char * net_device, char * username, char * log_perror("could not set new controlling tty"); printf("\t(exec of pppd)\n"); - execve(pppd_launch[0], pppd_launch, grab_env()); + execv(pppd_launch[0], pppd_launch); log_message("execve of %s failed: %s", pppd_launch[0], strerror(errno)); exit(-1); } @@ -85,10 +89,16 @@ static enum return_type adsl_connect(char * net_device, char * username, char * if ((f = fopen("/var/run/pppd.tdb", "rb"))) { while (1) { char buf[500]; + char *p; if (!fgets(buf, sizeof(buf), f)) break; - if (strstr(buf, "IPLOCAL=")) + p = strstr(buf, "IPLOCAL="); + if (p) { + struct sockaddr_in addr; + if (inet_aton(p + 8, &addr.sin_addr)) + intf->ip = addr.sin_addr; status = RETURN_OK; + } } fclose(f); if (status == RETURN_OK) { @@ -115,8 +125,8 @@ static enum return_type adsl_connect(char * net_device, char * username, char * enum return_type perform_adsl(struct interface_info * intf) { struct in_addr addr; - char * questions[] = { "Username", "Password", NULL }; - char * questions_auto[] = { "adsluser", "adslpass", NULL }; + char * questions[] = { "Username", "Password", "AC Name", NULL }; + char * questions_auto[] = { "adsluser", "adslpass", "adslacname", NULL }; static char ** answers = NULL; enum return_type results; @@ -137,6 +147,7 @@ enum return_type perform_adsl(struct interface_info * intf) } results = ask_from_entries_auto("Please enter the username and password for your ADSL account.\n" + "Leave blank the AC Name field if you don't know what it means.\n" "(Warning! only PPPoE protocol is supported)", questions, &answers, 40, questions_auto, NULL); if (results != RETURN_OK) @@ -145,19 +156,19 @@ enum return_type perform_adsl(struct interface_info * intf) intf->boot_proto = BOOTPROTO_ADSL_PPPOE; wait_message("Waiting for ADSL connection to show up..."); - my_insmod("ppp_generic", ANY_DRIVER_TYPE, NULL); - my_insmod("ppp_async", ANY_DRIVER_TYPE, NULL); - my_insmod("ppp", ANY_DRIVER_TYPE, NULL); - results = adsl_connect(intf->device, answers[0], answers[1]); + my_modprobe("ppp_generic", ANY_DRIVER_TYPE, NULL); + my_modprobe("ppp_async", ANY_DRIVER_TYPE, NULL); + results = adsl_connect(intf, answers[0], answers[1], answers[2]); remove_wait_message(); if (results != RETURN_OK) { wait_message("Retrying the ADSL connection..."); - results = adsl_connect(intf->device, answers[0], answers[1]); + results = adsl_connect(intf, answers[0], answers[1], answers[2]); remove_wait_message(); } else { intf->user = strdup(answers[0]); intf->pass = strdup(answers[1]); + intf->acname = strdup(answers[2]); } if (results != RETURN_OK) { |