diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-04-26 17:30:05 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-04-26 17:30:05 +0000 |
commit | f149d6a767cd12ee75e64032903a0e80f9e233fa (patch) | |
tree | bdbdf87ab0e1d2ea805572651e8b62730f7fc559 | |
parent | 26c10af9e2e87e7892dce677f6b38511545a370b (diff) | |
download | drakx-f149d6a767cd12ee75e64032903a0e80f9e233fa.tar drakx-f149d6a767cd12ee75e64032903a0e80f9e233fa.tar.gz drakx-f149d6a767cd12ee75e64032903a0e80f9e233fa.tar.bz2 drakx-f149d6a767cd12ee75e64032903a0e80f9e233fa.tar.xz drakx-f149d6a767cd12ee75e64032903a0e80f9e233fa.zip |
detect IP address from DSL connection
-rw-r--r-- | mdk-stage1/adsl.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mdk-stage1/adsl.c b/mdk-stage1/adsl.c index ed0df52a2..595b3fae0 100644 --- a/mdk-stage1/adsl.c +++ b/mdk-stage1/adsl.c @@ -38,7 +38,7 @@ #include "adsl.h" -static enum return_type adsl_connect(char * net_device, char * username, char * password, char * acname) +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,7 +51,7 @@ 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 "); @@ -89,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) { @@ -152,12 +158,12 @@ enum return_type perform_adsl(struct interface_info * intf) wait_message("Waiting for ADSL connection to show up..."); my_insmod("ppp_generic", ANY_DRIVER_TYPE, NULL, 1); my_insmod("ppp_async", ANY_DRIVER_TYPE, NULL, 1); - results = adsl_connect(intf->device, answers[0], answers[1], answers[2]); + 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], answers[2]); + results = adsl_connect(intf, answers[0], answers[1], answers[2]); remove_wait_message(); } else { intf->user = strdup(answers[0]); |