2 * options.c - handles option processing for PPP.
4 * Copyright (c) 1989 Carnegie Mellon University.
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by Carnegie Mellon University. The name of the
13 * University may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 static char rcsid[] = "$Id: options.c,v 1.9 1994/05/25 06:25:48 paulus Exp $";
34 #include <sys/types.h>
36 #include <netinet/in.h>
40 #include "pathnames.h"
41 #include "patchlevel.h"
52 char *strdup __ARGS((char *));
56 #define GIDSET_TYPE int
62 static int setdebug __ARGS((void));
63 static int setkdebug __ARGS((char **));
64 static int setpassive __ARGS((void));
65 static int setsilent __ARGS((void));
66 static int noopt __ARGS((void));
67 static int setnovj __ARGS((void));
68 static int setnovjccomp __ARGS((void));
69 static int setvjslots __ARGS((char **));
70 static int reqpap __ARGS((void));
71 static int nopap __ARGS((void));
72 static int setupapfile __ARGS((char **));
73 static int nochap __ARGS((void));
74 static int reqchap __ARGS((void));
75 static int setspeed __ARGS((char *));
76 static int noaccomp __ARGS((void));
77 static int noasyncmap __ARGS((void));
78 static int noipaddr __ARGS((void));
79 static int nomagicnumber __ARGS((void));
80 static int setasyncmap __ARGS((char **));
81 static int setescape __ARGS((char **));
82 static int setmru __ARGS((char **));
83 static int setmtu __ARGS((char **));
84 static int nomru __ARGS((void));
85 static int nopcomp __ARGS((void));
86 static int setconnector __ARGS((char **));
87 static int setdisconnector __ARGS((char **));
88 static int setdomain __ARGS((char **));
89 static int setnetmask __ARGS((char **));
90 static int setcrtscts __ARGS((void));
91 static int setxonxoff __ARGS((void));
92 static int setnodetach __ARGS((void));
93 static int setmodem __ARGS((void));
94 static int setlocal __ARGS((void));
95 static int setlock __ARGS((void));
96 static int setname __ARGS((char **));
97 static int setuser __ARGS((char **));
98 static int setremote __ARGS((char **));
99 static int setauth __ARGS((void));
100 static int readfile __ARGS((char **));
101 static int setdefaultroute __ARGS((void));
102 static int setproxyarp __ARGS((void));
103 static int setpersist __ARGS((void));
104 static int setdologin __ARGS((void));
105 static int setusehostname __ARGS((void));
106 static int setnoipdflt __ARGS((void));
107 static int setlcptimeout __ARGS((char **));
108 static int setlcpterm __ARGS((char **));
109 static int setlcpconf __ARGS((char **));
110 static int setlcpfails __ARGS((char **));
111 static int setipcptimeout __ARGS((char **));
112 static int setipcpterm __ARGS((char **));
113 static int setipcpconf __ARGS((char **));
114 static int setipcpfails __ARGS((char **));
115 static int setpaptimeout __ARGS((char **));
116 static int setpapreqs __ARGS((char **));
117 static int setchaptimeout __ARGS((char **));
118 static int setchapchal __ARGS((char **));
119 static int setchapintv __ARGS((char **));
120 static int setipcpaccl __ARGS((void));
121 static int setipcpaccr __ARGS((void));
122 static int setlcpechointv __ARGS((char **));
123 static int setlcpechofails __ARGS((char **));
125 static int number_option __ARGS((char *, long *, int));
126 static int readable __ARGS((int fd));
131 extern char *progname;
133 extern int kdebugflag;
138 extern char *connector;
139 extern char *disconnector;
141 extern char devname[];
142 extern int default_device;
143 extern u_long netmask;
146 extern char passwd[];
147 extern int auth_required;
151 extern u_long lcp_echo_interval;
152 extern u_long lcp_echo_fails;
153 extern char our_name[];
154 extern char remote_name[];
156 int disable_defaultip;
166 {"-all", 0, noopt}, /* Don't request/allow any options */
167 {"-ac", 0, noaccomp}, /* Disable Address/Control compress */
168 {"-am", 0, noasyncmap}, /* Disable asyncmap negotiation */
169 {"-as", 1, setasyncmap}, /* set the desired async map */
170 {"-d", 0, setdebug}, /* Increase debugging level */
171 {"-detach", 0, setnodetach}, /* don't fork */
172 {"-ip", 0, noipaddr}, /* Disable IP address negotiation */
173 {"-mn", 0, nomagicnumber}, /* Disable magic number negotiation */
174 {"-mru", 0, nomru}, /* Disable mru negotiation */
175 {"-p", 0, setpassive}, /* Set passive mode */
176 {"-pc", 0, nopcomp}, /* Disable protocol field compress */
177 {"+ua", 1, setupapfile}, /* Get PAP user and password from file */
178 {"+pap", 0, reqpap}, /* Require PAP auth from peer */
179 {"-pap", 0, nopap}, /* Don't allow UPAP authentication with peer */
180 {"+chap", 0, reqchap}, /* Require CHAP authentication from peer */
181 {"-chap", 0, nochap}, /* Don't allow CHAP authentication with peer */
182 {"-vj", 0, setnovj}, /* disable VJ compression */
183 {"-vjccomp", 0, setnovjccomp}, /* disable VJ connection-ID compression */
184 {"vj-max-slots", 1, setvjslots}, /* Set maximum VJ header slots */
185 {"asyncmap", 1, setasyncmap}, /* set the desired async map */
186 {"escape", 1, setescape}, /* set chars to escape on transmission */
187 {"connect", 1, setconnector}, /* A program to set up a connection */
188 {"disconnect", 1, setdisconnector}, /* program to disconnect serial dev. */
189 {"crtscts", 0, setcrtscts}, /* set h/w flow control */
190 {"xonxoff", 0, setxonxoff}, /* set s/w flow control */
191 {"-crtscts", 0, setxonxoff}, /* another name for xonxoff */
192 {"debug", 0, setdebug}, /* Increase debugging level */
193 {"kdebug", 1, setkdebug}, /* Enable kernel-level debugging */
194 {"domain", 1, setdomain}, /* Add given domain name to hostname*/
195 {"mru", 1, setmru}, /* Set MRU value for negotiation */
196 {"mtu", 1, setmtu}, /* Set our MTU */
197 {"netmask", 1, setnetmask}, /* set netmask */
198 {"passive", 0, setpassive}, /* Set passive mode */
199 {"silent", 0, setsilent}, /* Set silent mode */
200 {"modem", 0, setmodem}, /* Use modem control lines */
201 {"local", 0, setlocal}, /* Don't use modem control lines */
202 {"lock", 0, setlock}, /* Lock serial device (with lock file) */
203 {"name", 1, setname}, /* Set local name for authentication */
204 {"user", 1, setuser}, /* Set username for PAP auth with peer */
205 {"usehostname", 0, setusehostname}, /* Must use hostname for auth. */
206 {"remotename", 1, setremote}, /* Set remote name for authentication */
207 {"auth", 0, setauth}, /* Require authentication from peer */
208 {"file", 1, readfile}, /* Take options from a file */
209 {"defaultroute", 0, setdefaultroute}, /* Add default route */
210 {"proxyarp", 0, setproxyarp}, /* Add proxy ARP entry */
211 {"persist", 0, setpersist}, /* Keep on reopening connection after close */
212 {"login", 0, setdologin}, /* Use system password database for UPAP */
213 {"noipdefault", 0, setnoipdflt}, /* Don't use name for default IP adrs */
214 {"lcp-echo-failure", 1, setlcpechofails}, /* consecutive echo failures */
215 {"lcp-echo-interval", 1, setlcpechointv}, /* time for lcp echo events */
216 {"lcp-restart", 1, setlcptimeout}, /* Set timeout for LCP */
217 {"lcp-max-terminate", 1, setlcpterm}, /* Set max #xmits for term-reqs */
218 {"lcp-max-configure", 1, setlcpconf}, /* Set max #xmits for conf-reqs */
219 {"lcp-max-failure", 1, setlcpfails}, /* Set max #conf-naks for LCP */
220 {"ipcp-restart", 1, setipcptimeout}, /* Set timeout for IPCP */
221 {"ipcp-max-terminate", 1, setipcpterm}, /* Set max #xmits for term-reqs */
222 {"ipcp-max-configure", 1, setipcpconf}, /* Set max #xmits for conf-reqs */
223 {"ipcp-max-failure", 1, setipcpfails}, /* Set max #conf-naks for IPCP */
224 {"pap-restart", 1, setpaptimeout}, /* Set timeout for UPAP */
225 {"pap-max-authreq", 1, setpapreqs}, /* Set max #xmits for auth-reqs */
226 {"chap-restart", 1, setchaptimeout}, /* Set timeout for CHAP */
227 {"chap-max-challenge", 1, setchapchal}, /* Set max #xmits for challenge */
228 {"chap-interval", 1, setchapintv}, /* Set interval for rechallenge */
229 {"ipcp-accept-local", 0, setipcpaccl}, /* Accept peer's address for us */
230 {"ipcp-accept-remote", 0, setipcpaccr}, /* Accept peer's address for it */
235 #ifndef IMPLEMENTATION
236 #define IMPLEMENTATION ""
239 static char *usage_string = "\
240 pppd version %s patch level %d%s\n\
241 Usage: %s [ arguments ], where arguments are:\n\
242 <device> Communicate over the named device\n\
243 <speed> Set the baud rate to <speed>\n\
244 <loc>:<rem> Set the local and/or remote interface IP\n\
245 addresses. Either one may be omitted.\n\
246 asyncmap <n> Set the desired async map to hex <n>\n\
247 auth Require authentication from peer\n\
248 connect <p> Invoke shell command <p> to set up the serial line\n\
249 crtscts Use hardware RTS/CTS flow control\n\
250 defaultroute Add default route through interface\n\
251 file <f> Take options from file <f>\n\
252 modem Use modem control lines\n\
253 mru <n> Set MRU value to <n> for negotiation\n\
254 netmask <n> Set interface netmask to <n>\n\
255 See pppd(8) for more options.\n\
260 * parse_args - parse a string of arguments, from the command
261 * line or from a file.
264 parse_args(argc, argv)
277 * First see if it's a command.
279 for (cmdp = cmds; cmdp->cmd_name; cmdp++)
280 if (!strcmp(arg, cmdp->cmd_name))
283 if (cmdp->cmd_name != NULL) {
284 if (argc < cmdp->num_args) {
285 fprintf(stderr, "Too few parameters for command %s\n", arg);
288 if (!(*cmdp->cmd_func)(argv))
290 argc -= cmdp->num_args;
291 argv += cmdp->num_args;
295 * Maybe a tty name, speed or IP address?
297 if ((ret = setdevname(arg)) == 0
298 && (ret = setspeed(arg)) == 0
299 && (ret = setipaddr(arg)) == 0) {
300 fprintf(stderr, "%s: unrecognized command\n", arg);
304 if (ret < 0) /* error */
312 * usage - print out a message telling how to use the program.
316 fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION,
321 * options_from_file - Read a string of options from a file,
322 * and interpret them.
325 options_from_file(filename, must_exist, check_prot)
334 char args[MAXARGS][MAXWORDLEN];
335 char cmd[MAXWORDLEN];
337 if ((f = fopen(filename, "r")) == NULL) {
338 if (!must_exist && errno == ENOENT)
343 if (check_prot && !readable(fileno(f))) {
344 fprintf(stderr, "%s: access denied\n", filename);
349 while (getword(f, cmd, &newline, filename)) {
351 * First see if it's a command.
353 for (cmdp = cmds; cmdp->cmd_name; cmdp++)
354 if (!strcmp(cmd, cmdp->cmd_name))
357 if (cmdp->cmd_name != NULL) {
358 for (i = 0; i < cmdp->num_args; ++i) {
359 if (!getword(f, args[i], &newline, filename)) {
361 "In file %s: too few parameters for command %s\n",
368 if (!(*cmdp->cmd_func)(argv)) {
375 * Maybe a tty name, speed or IP address?
377 if ((ret = setdevname(cmd)) == 0
378 && (ret = setspeed(cmd)) == 0
379 && (ret = setipaddr(cmd)) == 0) {
380 fprintf(stderr, "In file %s: unrecognized command %s\n",
385 if (ret < 0) /* error */
393 * options_from_user - See if the use has a ~/.ppprc file,
394 * and if so, interpret options from it.
399 char *user, *path, *file;
403 pw = getpwuid(getuid());
404 if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
406 file = _PATH_USEROPT;
407 path = malloc(strlen(user) + strlen(file) + 2);
409 novm("init file name");
413 ret = options_from_file(path, 0, 1);
419 * options_for_tty - See if an options file exists for the serial
420 * device, and if so, interpret options from it.
428 dev = strrchr(devname, '/');
433 if (strcmp(dev, "tty") == 0)
434 return 1; /* don't look for /etc/ppp/options.tty */
435 path = malloc(strlen(_PATH_TTYOPT) + strlen(dev) + 1);
437 novm("tty init file name");
438 strcpy(path, _PATH_TTYOPT);
440 ret = options_from_file(path, 0, 0);
446 * readable - check if a file is readable by the real user.
455 GIDSET_TYPE groups[NGROUPS_MAX];
460 if (fstat(fd, &sbuf) != 0)
462 if (sbuf.st_uid == uid)
463 return sbuf.st_mode & S_IRUSR;
464 if (sbuf.st_gid == getgid())
465 return sbuf.st_mode & S_IRGRP;
466 ngroups = getgroups(NGROUPS_MAX, groups);
467 for (i = 0; i < ngroups; ++i)
468 if (sbuf.st_gid == groups[i])
469 return sbuf.st_mode & S_IRGRP;
470 return sbuf.st_mode & S_IROTH;
474 * Read a word from a file.
475 * Words are delimited by white-space or by quotes (").
476 * Quotes, white-space and \ may be escaped with \.
477 * \<newline> is ignored.
480 getword(f, word, newlinep, filename)
495 * First skip white-space and comments
497 while ((c = getc(f)) != EOF) {
500 * \<newline> is ignored; \ followed by anything else
503 if ((c = getc(f)) == '\n')
510 *newlinep = 1; /* next word starts a line */
512 /* comment - ignore until EOF or \n */
513 while ((c = getc(f)) != EOF && c != '\n')
518 } else if (!isspace(c))
523 * End of file or error - fail
535 * Is this character escaped by \ ?
539 --len; /* ignore \<newline> */
540 else if (c == '"' || isspace(c) || c == '\\')
541 word[len-1] = c; /* put special char in word */
543 if (len < MAXWORDLEN-1)
548 } else if (c == '"') {
550 } else if (!quoted && (isspace(c) || c == '#')) {
554 if (len < MAXWORDLEN-1)
560 if ((c = getc(f)) == EOF)
569 if (len >= MAXWORDLEN) {
570 word[MAXWORDLEN-1] = 0;
571 fprintf(stderr, "%s: warning: word in file %s too long (%.20s...)\n",
572 progname, filename, word);
580 * number_option - parse a numeric parameter for an option
583 number_option(str, valp, base)
590 *valp = strtol(str, &ptr, base);
592 fprintf(stderr, "%s: invalid number: %s\n", progname, str);
600 * int_option - like number_option, but valp is int *,
601 * the base is assumed to be 0, and *valp is not changed
602 * if there is an error.
605 int_option(str, valp)
611 if (!number_option(str, &v, 0))
619 * The following procedures execute commands.
623 * readfile - take commands from a file.
629 return options_from_file(*argv, 1, 1);
633 * setdebug - Set debug (command line argument).
643 * setkdebug - Set kernel debugging level.
649 return int_option(*argv, &kdebugflag);
653 * noopt - Disable all options.
658 BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
659 BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
660 BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
661 BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
666 * noaccomp - Disable Address/Control field compression negotiation.
671 lcp_wantoptions[0].neg_accompression = 0;
672 lcp_allowoptions[0].neg_accompression = 0;
678 * noasyncmap - Disable async map negotiation.
683 lcp_wantoptions[0].neg_asyncmap = 0;
684 lcp_allowoptions[0].neg_asyncmap = 0;
690 * noipaddr - Disable IP address negotiation.
695 ipcp_wantoptions[0].neg_addr = 0;
696 ipcp_allowoptions[0].neg_addr = 0;
702 * nomagicnumber - Disable magic number negotiation.
707 lcp_wantoptions[0].neg_magicnumber = 0;
708 lcp_allowoptions[0].neg_magicnumber = 0;
714 * nomru - Disable mru negotiation.
719 lcp_wantoptions[0].neg_mru = 0;
720 lcp_allowoptions[0].neg_mru = 0;
726 * setmru - Set MRU for negotiation.
734 if (!number_option(*argv, &mru, 0))
736 lcp_wantoptions[0].mru = mru;
737 lcp_wantoptions[0].neg_mru = 1;
743 * setmru - Set the largest MTU we'll use.
751 if (!number_option(*argv, &mtu, 0))
753 if (mtu < MINMRU || mtu > MAXMRU) {
754 fprintf(stderr, "mtu option value of %d is too %s\n", mtu,
755 (mtu < MINMRU? "small": "large"));
758 lcp_allowoptions[0].mru = mtu;
764 * nopcomp - Disable Protocol field compression negotiation.
769 lcp_wantoptions[0].neg_pcompression = 0;
770 lcp_allowoptions[0].neg_pcompression = 0;
776 * setpassive - Set passive mode (don't give up if we time out sending
777 * LCP configure-requests).
782 lcp_wantoptions[0].passive = 1;
788 * setsilent - Set silent mode (don't start sending LCP configure-requests
789 * until we get one from the peer).
794 lcp_wantoptions[0].silent = 1;
800 * nopap - Disable PAP authentication with peer.
805 lcp_allowoptions[0].neg_upap = 0;
811 * reqpap - Require PAP authentication from peer.
816 lcp_wantoptions[0].neg_upap = 1;
822 * setupapfile - specifies UPAP info for authenticating with peer.
831 lcp_allowoptions[0].neg_upap = 1;
833 /* open user info file */
834 if ((ufile = fopen(*argv, "r")) == NULL) {
835 fprintf(stderr, "unable to open user login data file %s\n", *argv);
838 check_access(ufile, *argv);
841 if (fgets(user, MAXNAMELEN - 1, ufile) == NULL
842 || fgets(passwd, MAXSECRETLEN - 1, ufile) == NULL){
843 fprintf(stderr, "Unable to read user login data file %s.\n", *argv);
848 /* get rid of newlines */
850 if (l > 0 && user[l-1] == '\n')
853 if (l > 0 && passwd[l-1] == '\n')
861 * nochap - Disable CHAP authentication with peer.
866 lcp_allowoptions[0].neg_chap = 0;
872 * reqchap - Require CHAP authentication from peer.
877 lcp_wantoptions[0].neg_chap = 1;
884 * setnovj - disable vj compression
889 ipcp_wantoptions[0].neg_vj = 0;
890 ipcp_allowoptions[0].neg_vj = 0;
896 * setnovjccomp - disable VJ connection-ID compression
901 ipcp_wantoptions[0].cflag = 0;
902 ipcp_allowoptions[0].cflag = 0;
907 * setvjslots - set maximum number of connection slots for VJ compression
915 if (!int_option(*argv, &value))
917 if (value < 2 || value > 16) {
918 fprintf(stderr, "pppd: vj-max-slots value must be between 2 and 16\n");
921 ipcp_wantoptions [0].maxslotindex =
922 ipcp_allowoptions[0].maxslotindex = value - 1;
928 * setconnector - Set a program to connect to a serial line
934 connector = strdup(*argv);
935 if (connector == NULL)
936 novm("connector string");
942 * setdisconnector - Set a program to disconnect from the serial line
945 setdisconnector(argv)
948 disconnector = strdup(*argv);
949 if (disconnector == NULL)
950 novm("disconnector string");
957 * setdomain - Set domain name to append to hostname
963 strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
964 hostname[MAXNAMELEN-1] = 0;
970 * setasyncmap - add bits to asyncmap (what we request peer to escape).
978 if (!number_option(*argv, &asyncmap, 16))
980 lcp_wantoptions[0].asyncmap |= asyncmap;
981 lcp_wantoptions[0].neg_asyncmap = 1;
987 * setescape - add chars to the set we escape on transmission.
999 n = strtol(p, &endp, 16);
1001 fprintf(stderr, "%s: invalid hex number: %s\n", progname, p);
1005 if (n < 0 || 0x20 <= n && n <= 0x3F || n == 0x5E || n > 0xFF) {
1006 fprintf(stderr, "%s: can't escape character 0x%x\n", n);
1009 xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
1010 while (*p == ',' || *p == ' ')
1018 * setspeed - Set the speed.
1027 spd = strtol(arg, &ptr, 0);
1028 if (ptr == arg || *ptr != 0 || spd == 0)
1036 * setdevname - Set the device name.
1042 struct stat statbuf;
1043 char *tty, *ttyname();
1044 char dev[MAXPATHLEN];
1046 if (strncmp("/dev/", cp, 5) != 0) {
1047 strcpy(dev, "/dev/");
1048 strncat(dev, cp, MAXPATHLEN - 5);
1049 dev[MAXPATHLEN-1] = 0;
1054 * Check if there is a device by this name.
1056 if (stat(cp, &statbuf) < 0) {
1057 if (errno == ENOENT)
1059 syslog(LOG_ERR, cp);
1063 (void) strncpy(devname, cp, MAXPATHLEN);
1064 devname[MAXPATHLEN-1] = 0;
1065 default_device = FALSE;
1072 * setipaddr - Set the IP address
1079 char *colon, *index();
1080 u_long local, remote;
1081 ipcp_options *wo = &ipcp_wantoptions[0];
1084 * IP address pair separated by ":".
1086 if ((colon = index(arg, ':')) == NULL)
1090 * If colon first character, then no local addr.
1094 if ((local = inet_addr(arg)) == -1) {
1095 if ((hp = gethostbyname(arg)) == NULL) {
1096 fprintf(stderr, "unknown host: %s\n", arg);
1099 local = *(long *)hp->h_addr;
1100 if (our_name[0] == 0) {
1101 strncpy(our_name, arg, MAXNAMELEN);
1102 our_name[MAXNAMELEN-1] = 0;
1106 if (bad_ip_adrs(local)) {
1107 fprintf(stderr, "bad local IP address %s\n", ip_ntoa(local));
1111 wo->ouraddr = local;
1116 * If colon last character, then no remote addr.
1118 if (*++colon != '\0') {
1119 if ((remote = inet_addr(colon)) == -1) {
1120 if ((hp = gethostbyname(colon)) == NULL) {
1121 fprintf(stderr, "unknown host: %s\n", colon);
1124 remote = *(long *)hp->h_addr;
1125 if (remote_name[0] == 0) {
1126 strncpy(remote_name, colon, MAXNAMELEN);
1127 remote_name[MAXNAMELEN-1] = 0;
1131 if (bad_ip_adrs(remote)) {
1132 fprintf(stderr, "bad remote IP address %s\n", ip_ntoa(remote));
1136 wo->hisaddr = remote;
1144 * setnoipdflt - disable setipdefault()
1149 disable_defaultip = 1;
1155 * setipcpaccl - accept peer's idea of our address
1160 ipcp_wantoptions[0].accept_local = 1;
1166 * setipcpaccr - accept peer's idea of its address
1171 ipcp_wantoptions[0].accept_remote = 1;
1177 * setipdefault - default our local IP address based on our hostname.
1184 ipcp_options *wo = &ipcp_wantoptions[0];
1187 * If local IP address already given, don't bother.
1189 if (wo->ouraddr != 0 || disable_defaultip)
1193 * Look up our hostname (possibly with domain name appended)
1194 * and take the first IP address as our local IP address.
1195 * If there isn't an IP address for our hostname, too bad.
1197 wo->accept_local = 1; /* don't insist on this default value */
1198 if ((hp = gethostbyname(hostname)) == NULL)
1200 local = *(long *)hp->h_addr;
1201 if (local != 0 && !bad_ip_adrs(local))
1202 wo->ouraddr = local;
1207 * setnetmask - set the netmask to be used on the interface.
1215 if ((mask = inet_addr(*argv)) == -1 || (netmask & ~mask) != 0) {
1216 fprintf(stderr, "Invalid netmask %s\n", *argv);
1225 * Return user specified netmask. A value of zero means no netmask has
1290 if (our_name[0] == 0) {
1291 strncpy(our_name, argv[0], MAXNAMELEN);
1292 our_name[MAXNAMELEN-1] = 0;
1301 strncpy(user, argv[0], MAXNAMELEN);
1302 user[MAXNAMELEN-1] = 0;
1310 strncpy(remote_name, argv[0], MAXNAMELEN);
1311 remote_name[MAXNAMELEN-1] = 0;
1325 ipcp_wantoptions[0].default_route = 1;
1332 ipcp_wantoptions[0].proxy_arp = 1;
1351 * Functions to set the echo interval for modem-less monitors
1355 setlcpechointv(argv)
1358 return int_option(*argv, &lcp_echo_interval);
1362 setlcpechofails(argv)
1365 return int_option(*argv, &lcp_echo_fails);
1369 * Functions to set timeouts, max transmits, etc.
1375 return int_option(*argv, &lcp_fsm[0].timeouttime);
1378 static int setlcpterm(argv)
1381 return int_option(*argv, &lcp_fsm[0].maxtermtransmits);
1384 static int setlcpconf(argv)
1387 return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits);
1390 static int setlcpfails(argv)
1393 return int_option(*argv, &lcp_fsm[0].maxnakloops);
1396 static int setipcptimeout(argv)
1399 return int_option(*argv, &ipcp_fsm[0].timeouttime);
1402 static int setipcpterm(argv)
1405 return int_option(*argv, &ipcp_fsm[0].maxtermtransmits);
1408 static int setipcpconf(argv)
1411 return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits);
1414 static int setipcpfails(argv)
1417 return int_option(*argv, &lcp_fsm[0].maxnakloops);
1420 static int setpaptimeout(argv)
1423 return int_option(*argv, &upap[0].us_timeouttime);
1426 static int setpapreqs(argv)
1429 return int_option(*argv, &upap[0].us_maxtransmits);
1432 static int setchaptimeout(argv)
1435 return int_option(*argv, &chap[0].timeouttime);
1438 static int setchapchal(argv)
1441 return int_option(*argv, &chap[0].max_transmits);
1444 static int setchapintv(argv)
1447 return int_option(*argv, &chap[0].chal_interval);