Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <ip.h>
4
#include <bio.h>
5
#include <ndb.h>
6
#include "../dhcp.h"
7
#include "ipconfig.h"
8
 
9
void
10
pppbinddev(void)
11
{
12
	int ac, pid;
13
	char *av[12];
14
	Waitmsg *w;
15
 
16
	/* ppp does the binding */
17
 
18
	/* start with an empty config file */
19
	if(nip == 0)
20
		writendb("", 0, 0);
21
 
22
	switch(pid = rfork(RFPROC|RFFDG|RFMEM)){
23
	case -1:
24
		sysfatal("can't start ppp: %r");
25
	case 0:
26
		ac = 0;
27
		av[ac++] = "ppp";
28
		av[ac++] = "-uf";
29
		av[ac++] = "-p";
30
		av[ac++] = conf.dev;
31
		av[ac++] = "-x";
32
		av[ac++] = conf.mpoint;
33
		if(conf.baud != nil){
34
			av[ac++] = "-b";
35
			av[ac++] = conf.baud;
36
		}
37
		av[ac] = nil;
38
		exec("/bin/ip/ppp", av);
39
		exec("/ppp", av);
40
		sysfatal("execing /ppp: %r");
41
	}
42
 
43
	/* wait for ppp to finish connecting and configuring */
44
	while((w = wait()) != nil){
45
		if(w->pid == pid){
46
			if(w->msg[0] != 0)
47
				sysfatal("/ppp exited with status: %s", w->msg);
48
			free(w);
49
			break;
50
		}
51
		free(w);
52
	}
53
	if(w == nil)
54
		sysfatal("/ppp disappeared");
55
 
56
	/* ppp sets up the configuration itself */
57
	noconfig = 1;
58
	getndb();
59
}
60