diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/ip/ipconfig/ppp.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/ip/ipconfig/ppp.c')
-rwxr-xr-x | sys/src/cmd/ip/ipconfig/ppp.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sys/src/cmd/ip/ipconfig/ppp.c b/sys/src/cmd/ip/ipconfig/ppp.c new file mode 100755 index 000000000..8d67925a1 --- /dev/null +++ b/sys/src/cmd/ip/ipconfig/ppp.c @@ -0,0 +1,60 @@ +#include <u.h> +#include <libc.h> +#include <ip.h> +#include <bio.h> +#include <ndb.h> +#include "../dhcp.h" +#include "ipconfig.h" + +void +pppbinddev(void) +{ + int ac, pid; + char *av[12]; + Waitmsg *w; + + /* ppp does the binding */ + + /* start with an empty config file */ + if(nip == 0) + writendb("", 0, 0); + + switch(pid = rfork(RFPROC|RFFDG|RFMEM)){ + case -1: + sysfatal("can't start ppp: %r"); + case 0: + ac = 0; + av[ac++] = "ppp"; + av[ac++] = "-uf"; + av[ac++] = "-p"; + av[ac++] = conf.dev; + av[ac++] = "-x"; + av[ac++] = conf.mpoint; + if(conf.baud != nil){ + av[ac++] = "-b"; + av[ac++] = conf.baud; + } + av[ac] = nil; + exec("/bin/ip/ppp", av); + exec("/ppp", av); + sysfatal("execing /ppp: %r"); + } + + /* wait for ppp to finish connecting and configuring */ + while((w = wait()) != nil){ + if(w->pid == pid){ + if(w->msg[0] != 0) + sysfatal("/ppp exited with status: %s", w->msg); + free(w); + break; + } + free(w); + } + if(w == nil) + sysfatal("/ppp disappeared"); + + /* ppp sets up the configuration itself */ + noconfig = 1; + getndb(); +} + |