X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Foptions.c;h=4520f2df4fc07a16e6067b570416d6f924d0c11b;hb=a4c901e0dc4f257d1661eb7a990c73370556112d;hp=2661fa4d26d141204505e0fb7df3a22c1f423393;hpb=0b63a24d54ba4708c88e31bdd74b0145956c1478;p=ppp.git diff --git a/pppd/options.c b/pppd/options.c index 2661fa4..4520f2d 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: options.c,v 1.1 1993/11/11 03:54:25 paulus Exp $"; +static char rcsid[] = "$Id: options.c,v 1.4 1994/02/08 23:48:50 paulus Exp $"; #endif #include @@ -85,6 +85,7 @@ static int setproxyarp __ARGS((void)); static int setpersist __ARGS((void)); static int setdologin __ARGS((void)); static int setusehostname __ARGS((void)); +static int setnoipdflt __ARGS((void)); static int setlcptimeout __ARGS((char **)); static int setlcpterm __ARGS((char **)); static int setlcpconf __ARGS((char **)); @@ -98,6 +99,8 @@ static int setpapreqs __ARGS((char **)); static int setchaptimeout __ARGS((char **)); static int setchapchal __ARGS((char **)); static int setchapintv __ARGS((char **)); +static int setipcpaccl __ARGS((void)); +static int setipcpaccr __ARGS((void)); static int number_option __ARGS((char *, long *, int)); @@ -125,6 +128,7 @@ extern int uselogin; extern char our_name[]; extern char remote_name[]; int usehostname; +int disable_defaultip; /* * Valid arguments. @@ -172,6 +176,7 @@ static struct cmd { "proxyarp", 0, setproxyarp, /* Add proxy ARP entry */ "persist", 0, setpersist, /* Keep on reopening connection after close */ "login", 0, setdologin, /* Use system password database for UPAP */ + "noipdefault", 0, setnoipdflt, /* Don't use name for default IP adrs */ "lcp-restart", 1, setlcptimeout, /* Set timeout for LCP */ "lcp-max-terminate", 1, setlcpterm, /* Set max #xmits for term-reqs */ "lcp-max-configure", 1, setlcpconf, /* Set max #xmits for conf-reqs */ @@ -185,6 +190,8 @@ static struct cmd { "chap-restart", 1, setchaptimeout, /* Set timeout for CHAP */ "chap-max-challenge", 1, setchapchal, /* Set max #xmits for challenge */ "chap-interval", 1, setchapintv, /* Set interval for rechallenge */ + "ipcp-accept-local", 0, setipcpaccl, /* Accept peer's address for us */ + "ipcp-accept-remote", 0, setipcpaccr, /* Accept peer's address for it */ NULL }; @@ -297,8 +304,9 @@ usage() * and interpret them. */ int -options_from_file(filename) +options_from_file(filename, must_exist) char *filename; + int must_exist; { FILE *f; int i, newline; @@ -308,7 +316,7 @@ options_from_file(filename) char cmd[MAXWORDLEN]; if ((f = fopen(filename, "r")) == NULL) { - if (errno == ENOENT) + if (!must_exist && errno == ENOENT) return 1; perror(filename); exit(1); @@ -370,7 +378,7 @@ options_from_user() novm("init file name"); strcpy(path, user); strcat(path, file); - ret = options_from_file(path); + ret = options_from_file(path, 0); free(path); return ret; } @@ -460,7 +468,7 @@ getword(f, word, newlinep, filename) word[len] = c; ++len; if (c == '\\') - quoted = 1; + escape = 1; } if ((c = getc(f)) == EOF) break; @@ -531,7 +539,7 @@ static int readfile(argv) char **argv; { - return options_from_file(*argv); + return options_from_file(*argv, 1); } /* @@ -924,6 +932,39 @@ setipaddr(arg) } +/* + * setnoipdflt - disable setipdefault() + */ +static int +setnoipdflt() +{ + disable_defaultip = 1; + return 1; +} + + +/* + * setipcpaccl - accept peer's idea of our address + */ +static int +setipcpaccl() +{ + ipcp_wantoptions[0].accept_local = 1; + return 1; +} + + +/* + * setipcpaccr - accept peer's idea of its address + */ +static int +setipcpaccr() +{ + ipcp_wantoptions[0].accept_remote = 1; + return 1; +} + + /* * setipdefault - default our local IP address based on our hostname. */ @@ -937,7 +978,7 @@ setipdefault() /* * If local IP address already given, don't bother. */ - if (wo->ouraddr != 0) + if (wo->ouraddr != 0 || disable_defaultip) return; /* @@ -945,6 +986,7 @@ setipdefault() * and take the first IP address as our local IP address. * If there isn't an IP address for our hostname, too bad. */ + wo->accept_local = 1; /* don't insist on this default value */ if ((hp = gethostbyname(hostname)) == NULL) return; local = *(long *)hp->h_addr;