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[] = "$FreeBSD$";
36 #include <sys/types.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
42 #include <pcap-int.h> /* XXX: To get struct pcap */
46 #include "pathnames.h"
47 #include "patchlevel.h"
60 #endif /* IPX_CHANGE */
62 #include <net/ppp_comp.h>
67 #if defined(ultrix) || defined(NeXT)
68 char *strdup __P((char *));
72 #define GIDSET_TYPE gid_t
76 * Option variables and default values.
79 int dflag = 0; /* Tell libpcap we want debugging */
81 int debug = 0; /* Debug flag */
82 int kdebugflag = 0; /* Tell kernel to print debug messages */
83 int default_device = 1; /* Using /dev/tty or equivalent */
84 char devnam[MAXPATHLEN] = _PATH_TTY; /* Device name */
85 int crtscts = 0; /* Use hardware flow control */
86 int modem = 1; /* Use modem control lines */
87 int inspeed = 0; /* Input/Output speed requested */
88 u_int32_t netmask = 0; /* IP netmask to set on interface */
89 int lockflag = 0; /* Create lock file to lock the serial dev */
90 int nodetach = 0; /* Don't detach from controlling tty */
91 char *connector = NULL; /* Script to establish physical link */
92 char *disconnector = NULL; /* Script to disestablish physical link */
93 char *welcomer = NULL; /* Script to run after phys link estab. */
94 int max_con_attempts = 0; /* Maximum connect tries in non-demand mode */
95 int maxconnect = 0; /* Maximum connect time */
96 char user[MAXNAMELEN]; /* Username for PAP */
97 char passwd[MAXSECRETLEN]; /* Password for PAP */
98 int auth_required = 0; /* Peer is required to authenticate */
99 int defaultroute = 0; /* assign default route through interface */
100 int proxyarp = 0; /* Set up proxy ARP entry for peer */
101 int persist = 0; /* Reopen link after it goes down */
102 int uselogin = 0; /* Use /etc/passwd for checking PAP */
103 int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
104 int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
105 char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
106 char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
107 int explicit_remote = 0; /* User specified explicit remote name */
108 int usehostname = 0; /* Use hostname for our_name */
109 int disable_defaultip = 0; /* Don't use hostname for default IP adrs */
110 int demand = 0; /* do dial-on-demand */
111 char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
112 int cryptpap; /* Passwords in pap-secrets are encrypted */
113 int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
114 int holdoff = 30; /* # seconds to pause before reconnecting */
115 int refuse_pap = 0; /* Set to say we won't do PAP */
116 int refuse_chap = 0; /* Set to say we won't do CHAP */
119 int ms_lanman = 0; /* Nonzero if use LanMan password instead of NT */
120 /* Has meaning only with MS-CHAP challenges */
123 struct option_info auth_req_info;
124 struct option_info connector_info;
125 struct option_info disconnector_info;
126 struct option_info welcomer_info;
127 struct option_info devnam_info;
129 struct bpf_program pass_filter;/* Filter program for packets to pass */
130 struct bpf_program active_filter; /* Filter program for link-active pkts */
131 pcap_t pc; /* Fake struct pcap so we can compile expr */
137 static int setdevname __P((char *, int));
138 static int setspeed __P((char *));
139 static int setdebug __P((char **));
140 static int setkdebug __P((char **));
141 static int setpassive __P((char **));
142 static int setsilent __P((char **));
143 static int noopt __P((char **));
144 static int setnovj __P((char **));
145 static int setnovjccomp __P((char **));
146 static int setvjslots __P((char **));
147 static int reqpap __P((char **));
148 static int nopap __P((char **));
150 static int setupapfile __P((char **));
152 static int nochap __P((char **));
153 static int reqchap __P((char **));
154 static int noaccomp __P((char **));
155 static int noasyncmap __P((char **));
156 static int noip __P((char **));
157 static int nomagicnumber __P((char **));
158 static int setasyncmap __P((char **));
159 static int setescape __P((char **));
160 static int setmru __P((char **));
161 static int setmtu __P((char **));
163 static int setcbcp __P((char **));
165 static int nomru __P((char **));
166 static int nopcomp __P((char **));
167 static int setconnector __P((char **));
168 static int setdisconnector __P((char **));
169 static int setwelcomer __P((char **));
170 static int setmaxcon __P((char **));
171 static int setmaxconnect __P((char **));
172 static int setdomain __P((char **));
173 static int setnetmask __P((char **));
174 static int setcrtscts __P((char **));
175 static int setnocrtscts __P((char **));
176 static int setxonxoff __P((char **));
177 static int setnodetach __P((char **));
178 static int setupdetach __P((char **));
179 static int setmodem __P((char **));
180 static int setlocal __P((char **));
181 static int setlock __P((char **));
182 static int setname __P((char **));
183 static int setuser __P((char **));
184 static int setremote __P((char **));
185 static int setauth __P((char **));
186 static int setnoauth __P((char **));
187 static int readfile __P((char **));
188 static int callfile __P((char **));
189 static int setdefaultroute __P((char **));
190 static int setnodefaultroute __P((char **));
191 static int setproxyarp __P((char **));
192 static int setnoproxyarp __P((char **));
193 static int setpersist __P((char **));
194 static int setnopersist __P((char **));
195 static int setdologin __P((char **));
196 static int setusehostname __P((char **));
197 static int setnoipdflt __P((char **));
198 static int setlcptimeout __P((char **));
199 static int setlcpterm __P((char **));
200 static int setlcpconf __P((char **));
201 static int setlcpfails __P((char **));
202 static int setipcptimeout __P((char **));
203 static int setipcpterm __P((char **));
204 static int setipcpconf __P((char **));
205 static int setipcpfails __P((char **));
206 static int setpaptimeout __P((char **));
207 static int setpapreqs __P((char **));
208 static int setpapreqtime __P((char **));
209 static int setchaptimeout __P((char **));
210 static int setchapchal __P((char **));
211 static int setchapintv __P((char **));
212 static int setipcpaccl __P((char **));
213 static int setipcpaccr __P((char **));
214 static int setlcpechointv __P((char **));
215 static int setlcpechofails __P((char **));
216 static int noccp __P((char **));
217 static int setbsdcomp __P((char **));
218 static int setnobsdcomp __P((char **));
219 static int setdeflate __P((char **));
220 static int setnodeflate __P((char **));
221 static int setnodeflatedraft __P((char **));
222 static int setdemand __P((char **));
223 static int setpred1comp __P((char **));
224 static int setnopred1comp __P((char **));
225 static int setipparam __P((char **));
226 static int setpapcrypt __P((char **));
227 static int setidle __P((char **));
228 static int setholdoff __P((char **));
229 static int setdnsaddr __P((char **));
230 static int resetipxproto __P((char **));
231 static int setwinsaddr __P((char **));
232 static int showversion __P((char **));
233 static int showhelp __P((char **));
236 static int setpdebug __P((char **));
237 static int setpassfilter __P((char **));
238 static int setactivefilter __P((char **));
242 static int setipxproto __P((char **));
243 static int setipxanet __P((char **));
244 static int setipxalcl __P((char **));
245 static int setipxarmt __P((char **));
246 static int setipxnetwork __P((char **));
247 static int setipxnode __P((char **));
248 static int setipxrouter __P((char **));
249 static int setipxname __P((char **));
250 static int setipxcptimeout __P((char **));
251 static int setipxcpterm __P((char **));
252 static int setipxcpconf __P((char **));
253 static int setipxcpfails __P((char **));
254 #endif /* IPX_CHANGE */
257 static int setmslanman __P((char **));
260 static int number_option __P((char *, u_int32_t *, int));
261 static int int_option __P((char *, int *));
262 static int readable __P((int fd));
270 int (*cmd_func) __P((char **));
272 {"-all", 0, noopt}, /* Don't request/allow any options (useless) */
273 {"noaccomp", 0, noaccomp}, /* Disable Address/Control compression */
274 {"-ac", 0, noaccomp}, /* Disable Address/Control compress */
275 {"default-asyncmap", 0, noasyncmap}, /* Disable asyncmap negoatiation */
276 {"-am", 0, noasyncmap}, /* Disable asyncmap negotiation */
277 {"-as", 1, setasyncmap}, /* set the desired async map */
278 {"-d", 0, setdebug}, /* Increase debugging level */
279 {"nodetach", 0, setnodetach}, /* Don't detach from controlling tty */
280 {"-detach", 0, setnodetach}, /* don't fork */
281 {"updetach", 0, setupdetach}, /* Detach once an NP has come up */
282 {"noip", 0, noip}, /* Disable IP and IPCP */
283 {"-ip", 0, noip}, /* Disable IP and IPCP */
284 {"nomagic", 0, nomagicnumber}, /* Disable magic number negotiation */
285 {"-mn", 0, nomagicnumber}, /* Disable magic number negotiation */
286 {"default-mru", 0, nomru}, /* Disable MRU negotiation */
287 {"-mru", 0, nomru}, /* Disable mru negotiation */
288 {"-p", 0, setpassive}, /* Set passive mode */
289 {"nopcomp", 0, nopcomp}, /* Disable protocol field compression */
290 {"-pc", 0, nopcomp}, /* Disable protocol field compress */
292 {"+ua", 1, setupapfile}, /* Get PAP user and password from file */
294 {"require-pap", 0, reqpap}, /* Require PAP authentication from peer */
295 {"+pap", 0, reqpap}, /* Require PAP auth from peer */
296 {"refuse-pap", 0, nopap}, /* Don't agree to auth to peer with PAP */
297 {"-pap", 0, nopap}, /* Don't allow UPAP authentication with peer */
298 {"require-chap", 0, reqchap}, /* Require CHAP authentication from peer */
299 {"+chap", 0, reqchap}, /* Require CHAP authentication from peer */
300 {"refuse-chap", 0, nochap}, /* Don't agree to auth to peer with CHAP */
301 {"-chap", 0, nochap}, /* Don't allow CHAP authentication with peer */
302 {"novj", 0, setnovj}, /* Disable VJ compression */
303 {"-vj", 0, setnovj}, /* disable VJ compression */
304 {"novjccomp", 0, setnovjccomp}, /* disable VJ connection-ID compression */
305 {"-vjccomp", 0, setnovjccomp}, /* disable VJ connection-ID compression */
306 {"vj-max-slots", 1, setvjslots}, /* Set maximum VJ header slots */
307 {"asyncmap", 1, setasyncmap}, /* set the desired async map */
308 {"escape", 1, setescape}, /* set chars to escape on transmission */
309 {"connect", 1, setconnector}, /* A program to set up a connection */
310 {"disconnect", 1, setdisconnector}, /* program to disconnect serial dev. */
311 {"welcome", 1, setwelcomer},/* Script to welcome client */
312 {"connect-max-attempts", 1, setmaxcon}, /* maximum # connect attempts */
313 {"maxconnect", 1, setmaxconnect}, /* specify a maximum connect time */
314 {"crtscts", 0, setcrtscts}, /* set h/w flow control */
315 {"nocrtscts", 0, setnocrtscts}, /* clear h/w flow control */
316 {"-crtscts", 0, setnocrtscts}, /* clear h/w flow control */
317 {"xonxoff", 0, setxonxoff}, /* set s/w flow control */
318 {"debug", 0, setdebug}, /* Increase debugging level */
319 {"kdebug", 1, setkdebug}, /* Enable kernel-level debugging */
320 {"domain", 1, setdomain}, /* Add given domain name to hostname*/
321 {"mru", 1, setmru}, /* Set MRU value for negotiation */
322 {"mtu", 1, setmtu}, /* Set our MTU */
324 {"callback", 1, setcbcp}, /* Ask for callback */
326 {"netmask", 1, setnetmask}, /* set netmask */
327 {"passive", 0, setpassive}, /* Set passive mode */
328 {"silent", 0, setsilent}, /* Set silent mode */
329 {"modem", 0, setmodem}, /* Use modem control lines */
330 {"local", 0, setlocal}, /* Don't use modem control lines */
331 {"lock", 0, setlock}, /* Lock serial device (with lock file) */
332 {"name", 1, setname}, /* Set local name for authentication */
333 {"user", 1, setuser}, /* Set name for auth with peer */
334 {"usehostname", 0, setusehostname}, /* Must use hostname for auth. */
335 {"remotename", 1, setremote}, /* Set remote name for authentication */
336 {"auth", 0, setauth}, /* Require authentication from peer */
337 {"noauth", 0, setnoauth}, /* Don't require peer to authenticate */
338 {"file", 1, readfile}, /* Take options from a file */
339 {"call", 1, callfile}, /* Take options from a privileged file */
340 {"defaultroute", 0, setdefaultroute}, /* Add default route */
341 {"nodefaultroute", 0, setnodefaultroute}, /* disable defaultroute option */
342 {"-defaultroute", 0, setnodefaultroute}, /* disable defaultroute option */
343 {"proxyarp", 0, setproxyarp}, /* Add proxy ARP entry */
344 {"noproxyarp", 0, setnoproxyarp}, /* disable proxyarp option */
345 {"-proxyarp", 0, setnoproxyarp}, /* disable proxyarp option */
346 {"persist", 0, setpersist}, /* Keep on reopening connection after close */
347 {"nopersist", 0, setnopersist}, /* Turn off persist option */
348 {"demand", 0, setdemand}, /* Dial on demand */
349 {"login", 0, setdologin}, /* Use system password database for UPAP */
350 {"noipdefault", 0, setnoipdflt}, /* Don't use name for default IP adrs */
351 {"lcp-echo-failure", 1, setlcpechofails}, /* consecutive echo failures */
352 {"lcp-echo-interval", 1, setlcpechointv}, /* time for lcp echo events */
353 {"lcp-restart", 1, setlcptimeout}, /* Set timeout for LCP */
354 {"lcp-max-terminate", 1, setlcpterm}, /* Set max #xmits for term-reqs */
355 {"lcp-max-configure", 1, setlcpconf}, /* Set max #xmits for conf-reqs */
356 {"lcp-max-failure", 1, setlcpfails}, /* Set max #conf-naks for LCP */
357 {"ipcp-restart", 1, setipcptimeout}, /* Set timeout for IPCP */
358 {"ipcp-max-terminate", 1, setipcpterm}, /* Set max #xmits for term-reqs */
359 {"ipcp-max-configure", 1, setipcpconf}, /* Set max #xmits for conf-reqs */
360 {"ipcp-max-failure", 1, setipcpfails}, /* Set max #conf-naks for IPCP */
361 {"pap-restart", 1, setpaptimeout}, /* Set retransmit timeout for PAP */
362 {"pap-max-authreq", 1, setpapreqs}, /* Set max #xmits for auth-reqs */
363 {"pap-timeout", 1, setpapreqtime}, /* Set time limit for peer PAP auth. */
364 {"chap-restart", 1, setchaptimeout}, /* Set timeout for CHAP */
365 {"chap-max-challenge", 1, setchapchal}, /* Set max #xmits for challenge */
366 {"chap-interval", 1, setchapintv}, /* Set interval for rechallenge */
367 {"ipcp-accept-local", 0, setipcpaccl}, /* Accept peer's address for us */
368 {"ipcp-accept-remote", 0, setipcpaccr}, /* Accept peer's address for it */
369 {"noccp", 0, noccp}, /* Disable CCP negotiation */
370 {"-ccp", 0, noccp}, /* Disable CCP negotiation */
371 {"bsdcomp", 1, setbsdcomp}, /* request BSD-Compress */
372 {"nobsdcomp", 0, setnobsdcomp}, /* don't allow BSD-Compress */
373 {"-bsdcomp", 0, setnobsdcomp}, /* don't allow BSD-Compress */
374 {"deflate", 1, setdeflate}, /* request Deflate compression */
375 {"nodeflate", 0, setnodeflate}, /* don't allow Deflate compression */
376 {"-deflate", 0, setnodeflate}, /* don't allow Deflate compression */
377 {"nodeflatedraft", 0, setnodeflatedraft}, /* don't use draft deflate # */
378 {"predictor1", 0, setpred1comp}, /* request Predictor-1 */
379 {"nopredictor1", 0, setnopred1comp},/* don't allow Predictor-1 */
380 {"-predictor1", 0, setnopred1comp}, /* don't allow Predictor-1 */
381 {"ipparam", 1, setipparam}, /* set ip script parameter */
382 {"papcrypt", 0, setpapcrypt}, /* PAP passwords encrypted */
383 {"idle", 1, setidle}, /* idle time limit (seconds) */
384 {"holdoff", 1, setholdoff}, /* set holdoff time (seconds) */
385 /* backwards compat hack */
386 {"dns1", 1, setdnsaddr}, /* DNS address for the peer's use */
387 {"dns2", 1, setdnsaddr}, /* DNS address for the peer's use */
388 /* end compat hack */
389 {"ms-dns", 1, setdnsaddr}, /* DNS address for the peer's use */
390 {"ms-wins", 1, setwinsaddr}, /* Nameserver for SMB over TCP/IP for peer */
391 {"noipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
392 {"-ipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
393 {"--version", 0, showversion}, /* Show version number */
394 {"--help", 0, showhelp}, /* Show brief listing of options */
395 {"-h", 0, showhelp}, /* ditto */
398 {"pdebug", 1, setpdebug}, /* libpcap debugging */
399 {"pass-filter", 1, setpassfilter}, /* set filter for packets to pass */
400 {"active-filter", 1, setactivefilter}, /* set filter for active pkts */
404 {"ipx-network", 1, setipxnetwork}, /* IPX network number */
405 {"ipxcp-accept-network", 0, setipxanet}, /* Accept peer netowrk */
406 {"ipx-node", 1, setipxnode}, /* IPX node number */
407 {"ipxcp-accept-local", 0, setipxalcl}, /* Accept our address */
408 {"ipxcp-accept-remote", 0, setipxarmt}, /* Accept peer's address */
409 {"ipx-routing", 1, setipxrouter}, /* IPX routing proto number */
410 {"ipx-router-name", 1, setipxname}, /* IPX router name */
411 {"ipxcp-restart", 1, setipxcptimeout}, /* Set timeout for IPXCP */
412 {"ipxcp-max-terminate", 1, setipxcpterm}, /* max #xmits for term-reqs */
413 {"ipxcp-max-configure", 1, setipxcpconf}, /* max #xmits for conf-reqs */
414 {"ipxcp-max-failure", 1, setipxcpfails}, /* max #conf-naks for IPXCP */
416 {"ipx-compression", 1, setipxcompression}, /* IPX compression number */
418 {"ipx", 0, setipxproto}, /* Enable IPXCP (and IPX) */
419 {"+ipx", 0, setipxproto}, /* Enable IPXCP (and IPX) */
420 #endif /* IPX_CHANGE */
423 {"ms-lanman", 0, setmslanman}, /* Use LanMan psswd when using MS-CHAP */
430 #ifndef IMPLEMENTATION
431 #define IMPLEMENTATION ""
434 static const char usage_string[] = "\
435 pppd version %s patch level %d%s\n\
436 Usage: %s [ options ], where options are:\n\
437 <device> Communicate over the named device\n\
438 <speed> Set the baud rate to <speed>\n\
439 <loc>:<rem> Set the local and/or remote interface IP\n\
440 addresses. Either one may be omitted.\n\
441 asyncmap <n> Set the desired async map to hex <n>\n\
442 auth Require authentication from peer\n\
443 connect <p> Invoke shell command <p> to set up the serial line\n\
444 crtscts Use hardware RTS/CTS flow control\n\
445 defaultroute Add default route through interface\n\
446 file <f> Take options from file <f>\n\
447 modem Use modem control lines\n\
448 mru <n> Set MRU value to <n> for negotiation\n\
449 See pppd(8) for more options.\n\
452 static char *current_option; /* the name of the option being parsed */
453 static int privileged_option; /* set iff the current option came from root */
454 static char *option_source; /* string saying where the option came from */
457 * parse_args - parse a string of arguments from the command line.
460 parse_args(argc, argv)
468 privileged_option = privileged;
469 option_source = "command line";
475 * First see if it's a command.
477 for (cmdp = cmds; cmdp->cmd_name; cmdp++)
478 if (!strcmp(arg, cmdp->cmd_name))
481 if (cmdp->cmd_name != NULL) {
482 if (argc < cmdp->num_args) {
483 option_error("too few parameters for option %s", arg);
486 current_option = arg;
487 if (!(*cmdp->cmd_func)(argv))
489 argc -= cmdp->num_args;
490 argv += cmdp->num_args;
494 * Maybe a tty name, speed or IP address?
496 if ((ret = setdevname(arg, 0)) == 0
497 && (ret = setspeed(arg)) == 0
498 && (ret = setipaddr(arg)) == 0) {
499 option_error("unrecognized option '%s'", arg);
503 if (ret < 0) /* error */
511 * scan_args - scan the command line arguments to get the tty name,
515 scan_args(argc, argv)
526 /* Skip options and their arguments */
527 for (cmdp = cmds; cmdp->cmd_name; cmdp++)
528 if (!strcmp(arg, cmdp->cmd_name))
531 if (cmdp->cmd_name != NULL) {
532 argc -= cmdp->num_args;
533 argv += cmdp->num_args;
537 /* Check if it's a tty name and copy it if so */
538 (void) setdevname(arg, 1);
543 * usage - print out a message telling how to use the program.
548 if (phase == PHASE_INITIALIZE)
549 fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION,
554 * showhelp - print out usage message and exit.
560 if (phase == PHASE_INITIALIZE) {
568 * showversion - print out the version number and exit.
574 if (phase == PHASE_INITIALIZE) {
575 fprintf(stderr, "pppd version %s patch level %d%s\n",
576 VERSION, PATCHLEVEL, IMPLEMENTATION);
583 * options_from_file - Read a string of options from a file,
584 * and interpret them.
587 options_from_file(filename, must_exist, check_prot, priv)
598 char args[MAXARGS][MAXWORDLEN];
599 char cmd[MAXWORDLEN];
601 if ((f = fopen(filename, "r")) == NULL) {
602 if (!must_exist && errno == ENOENT)
604 option_error("Can't open options file %s: %m", filename);
607 if (check_prot && !readable(fileno(f))) {
608 option_error("Can't open options file %s: access denied", filename);
613 oldpriv = privileged_option;
614 privileged_option = priv;
616 while (getword(f, cmd, &newline, filename)) {
618 * First see if it's a command.
620 for (cmdp = cmds; cmdp->cmd_name; cmdp++)
621 if (!strcmp(cmd, cmdp->cmd_name))
624 if (cmdp->cmd_name != NULL) {
625 for (i = 0; i < cmdp->num_args; ++i) {
626 if (!getword(f, args[i], &newline, filename)) {
628 "In file %s: too few parameters for option '%s'",
634 current_option = cmd;
635 if (!(*cmdp->cmd_func)(argv))
640 * Maybe a tty name, speed or IP address?
642 if ((i = setdevname(cmd, 0)) == 0
643 && (i = setspeed(cmd)) == 0
644 && (i = setipaddr(cmd)) == 0) {
645 option_error("In file %s: unrecognized option '%s'",
649 if (i < 0) /* error */
657 privileged_option = oldpriv;
662 * options_from_user - See if the use has a ~/.ppprc file,
663 * and if so, interpret options from it.
668 char *user, *path, *file;
672 pw = getpwuid(getuid());
673 if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
675 file = _PATH_USEROPT;
676 path = malloc(strlen(user) + strlen(file) + 2);
678 novm("init file name");
682 ret = options_from_file(path, 0, 1, privileged);
688 * options_for_tty - See if an options file exists for the serial
689 * device, and if so, interpret options from it.
694 char *dev, *path, *p;
698 if (strncmp(dev, _PATH_DEV, sizeof _PATH_DEV - 1) == 0)
700 if (strcmp(dev, "tty") == 0)
701 return 1; /* don't look for /etc/ppp/options.tty */
702 path = malloc(strlen(_PATH_TTYOPT) + strlen(dev) + 1);
704 novm("tty init file name");
705 strcpy(path, _PATH_TTYOPT);
706 /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */
707 for (p = path + strlen(path); *dev != 0; ++dev)
708 *p++ = (*dev == '/'? '.': *dev);
710 ret = options_from_file(path, 0, 0, 1);
716 * option_error - print a message about an error in an option.
717 * The message is logged, and also sent to
718 * stderr if phase == PHASE_INITIALIZE.
721 option_error __V((char *fmt, ...))
731 fmt = va_arg(args, char *);
733 vfmtmsg(buf, sizeof(buf), fmt, args);
735 if (phase == PHASE_INITIALIZE)
736 fprintf(stderr, "%s: %s\n", progname, buf);
737 syslog(LOG_ERR, "%s", buf);
741 * readable - check if a file is readable by the real user.
750 GIDSET_TYPE groups[NGROUPS_MAX];
755 if (fstat(fd, &sbuf) != 0)
757 if (sbuf.st_uid == uid)
758 return sbuf.st_mode & S_IRUSR;
759 if (sbuf.st_gid == getgid())
760 return sbuf.st_mode & S_IRGRP;
761 ngroups = getgroups(NGROUPS_MAX, groups);
762 for (i = 0; i < ngroups; ++i)
763 if (sbuf.st_gid == groups[i])
764 return sbuf.st_mode & S_IRGRP;
765 return sbuf.st_mode & S_IROTH;
769 * Read a word from a file.
770 * Words are delimited by white-space or by quotes (" or ').
771 * Quotes, white-space and \ may be escaped with \.
772 * \<newline> is ignored.
775 getword(f, word, newlinep, filename)
783 int value, digit, got, n;
785 #define isoctal(c) ((c) >= '0' && (c) < '8')
793 * First skip white-space and comments.
801 * A newline means the end of a comment; backslash-newline
802 * is ignored. Note that we cannot have escape && comment.
814 * Ignore characters other than newline in a comment.
820 * If this character is escaped, we have a word start.
826 * If this is the escape character, look at the next character.
834 * If this is the start of a comment, ignore the rest of the line.
842 * A non-whitespace character is the start of a word.
849 * Save the delimiter for quoted strings.
851 if (!escape && (c == '"' || c == '\'')) {
858 * Process characters until the end of the word.
863 * This character is escaped: backslash-newline is ignored,
864 * various other characters indicate particular values
865 * as for C backslash-escapes.
900 * \ddd octal sequence
903 for (n = 0; n < 3 && isoctal(c); ++n) {
904 value = (value << 3) + (c & 07);
913 * \x<hex_string> sequence
917 for (n = 0; n < 2 && isxdigit(c); ++n) {
918 digit = toupper(c) - '0';
920 digit += '0' + 10 - 'A';
921 value = (value << 4) + digit;
929 * Otherwise the character stands for itself.
936 * Store the resulting character for the escape sequence.
938 if (len < MAXWORDLEN-1)
949 * Not escaped: see if we've reached the end of the word.
955 if (isspace(c) || c == '#') {
962 * Backslash starts an escape sequence.
971 * An ordinary character: store it in the word and get another.
973 if (len < MAXWORDLEN-1)
981 * End of the word: check for errors.
987 option_error("Error reading %s: %m", filename);
991 * If len is zero, then we didn't find a word before the
999 * Warn if the word was too long, and append a terminating null.
1001 if (len >= MAXWORDLEN) {
1002 option_error("warning: word in file %s too long (%.20s...)",
1004 len = MAXWORDLEN - 1;
1015 * number_option - parse an unsigned numeric parameter for an option.
1018 number_option(str, valp, base)
1025 *valp = strtoul(str, &ptr, base);
1027 option_error("invalid numeric parameter '%s' for %s option",
1028 str, current_option);
1036 * int_option - like number_option, but valp is int *,
1037 * the base is assumed to be 0, and *valp is not changed
1038 * if there is an error.
1041 int_option(str, valp)
1047 if (!number_option(str, &v, 0))
1055 * The following procedures parse options.
1059 * readfile - take commands from a file.
1065 return options_from_file(*argv, 1, 1, privileged_option);
1069 * callfile - take commands from /etc/ppp/peers/<name>.
1070 * Name may not contain /../, start with / or ../, or end in /..
1076 char *fname, *arg, *p;
1081 if (arg[0] == '/' || arg[0] == 0)
1084 for (p = arg; *p != 0; ) {
1085 if (p[0] == '.' && p[1] == '.' && (p[2] == '/' || p[2] == 0)) {
1089 while (*p != '/' && *p != 0)
1096 option_error("call option value may not contain .. or start with /");
1100 l = strlen(arg) + strlen(_PATH_PEERFILES) + 1;
1101 if ((fname = (char *) malloc(l)) == NULL)
1102 novm("call file name");
1103 strcpy(fname, _PATH_PEERFILES);
1106 ok = options_from_file(fname, 1, 1, 1);
1114 * setdebug - Set debug (command line argument).
1125 * setkdebug - Set kernel debugging level.
1131 return int_option(*argv, &kdebugflag);
1136 * setpdebug - Set libpcap debugging level.
1142 return int_option(*argv, &dflag);
1146 * setpassfilter - Set the pass filter for packets
1152 pc.linktype = DLT_PPP;
1153 pc.snapshot = PPP_HDRLEN;
1155 if (pcap_compile(&pc, &pass_filter, *argv, 1, netmask) == 0)
1157 option_error("error in pass-filter expression: %s\n", pcap_geterr(&pc));
1162 * setactivefilter - Set the active filter for packets
1165 setactivefilter(argv)
1168 pc.linktype = DLT_PPP;
1169 pc.snapshot = PPP_HDRLEN;
1171 if (pcap_compile(&pc, &active_filter, *argv, 1, netmask) == 0)
1173 option_error("error in active-filter expression: %s\n", pcap_geterr(&pc));
1179 * noopt - Disable all options.
1185 BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
1186 BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
1187 BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
1188 BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
1191 BZERO((char *) &ipxcp_wantoptions[0], sizeof (struct ipxcp_options));
1192 BZERO((char *) &ipxcp_allowoptions[0], sizeof (struct ipxcp_options));
1193 #endif /* IPX_CHANGE */
1199 * noaccomp - Disable Address/Control field compression negotiation.
1205 lcp_wantoptions[0].neg_accompression = 0;
1206 lcp_allowoptions[0].neg_accompression = 0;
1212 * noasyncmap - Disable async map negotiation.
1218 lcp_wantoptions[0].neg_asyncmap = 0;
1219 lcp_allowoptions[0].neg_asyncmap = 0;
1225 * noip - Disable IP and IPCP.
1231 ipcp_protent.enabled_flag = 0;
1237 * nomagicnumber - Disable magic number negotiation.
1243 lcp_wantoptions[0].neg_magicnumber = 0;
1244 lcp_allowoptions[0].neg_magicnumber = 0;
1250 * nomru - Disable mru negotiation.
1256 lcp_wantoptions[0].neg_mru = 0;
1257 lcp_allowoptions[0].neg_mru = 0;
1263 * setmru - Set MRU for negotiation.
1271 if (!number_option(*argv, &mru, 0))
1273 lcp_wantoptions[0].mru = mru;
1274 lcp_wantoptions[0].neg_mru = 1;
1280 * setmru - Set the largest MTU we'll use.
1288 if (!number_option(*argv, &mtu, 0))
1290 if (mtu < MINMRU || mtu > MAXMRU) {
1291 option_error("mtu option value of %u is too %s", mtu,
1292 (mtu < MINMRU? "small": "large"));
1295 lcp_allowoptions[0].mru = mtu;
1304 lcp_wantoptions[0].neg_cbcp = 1;
1305 cbcp_protent.enabled_flag = 1;
1306 cbcp[0].us_number = strdup(*argv);
1307 if (cbcp[0].us_number == 0)
1308 novm("callback number");
1309 cbcp[0].us_type |= (1 << CB_CONF_USER);
1310 cbcp[0].us_type |= (1 << CB_CONF_ADMIN);
1316 * nopcomp - Disable Protocol field compression negotiation.
1322 lcp_wantoptions[0].neg_pcompression = 0;
1323 lcp_allowoptions[0].neg_pcompression = 0;
1329 * setpassive - Set passive mode (don't give up if we time out sending
1330 * LCP configure-requests).
1336 lcp_wantoptions[0].passive = 1;
1342 * setsilent - Set silent mode (don't start sending LCP configure-requests
1343 * until we get one from the peer).
1349 lcp_wantoptions[0].silent = 1;
1355 * nopap - Disable PAP authentication with peer.
1367 * reqpap - Require PAP authentication from peer.
1373 lcp_wantoptions[0].neg_upap = 1;
1380 * setupapfile - specifies UPAP info for authenticating with peer.
1389 lcp_allowoptions[0].neg_upap = 1;
1391 /* open user info file */
1392 if ((ufile = fopen(*argv, "r")) == NULL) {
1393 option_error("unable to open user login data file %s", *argv);
1396 if (!readable(fileno(ufile))) {
1397 option_error("%s: access denied", *argv);
1400 check_access(ufile, *argv);
1403 if (fgets(user, MAXNAMELEN - 1, ufile) == NULL
1404 || fgets(passwd, MAXSECRETLEN - 1, ufile) == NULL){
1405 option_error("unable to read user login data file %s", *argv);
1410 /* get rid of newlines */
1412 if (l > 0 && user[l-1] == '\n')
1415 if (l > 0 && passwd[l-1] == '\n')
1423 * nochap - Disable CHAP authentication with peer.
1435 * reqchap - Require CHAP authentication from peer.
1441 lcp_wantoptions[0].neg_chap = 1;
1448 * setnovj - disable vj compression
1454 ipcp_wantoptions[0].neg_vj = 0;
1455 ipcp_allowoptions[0].neg_vj = 0;
1461 * setnovjccomp - disable VJ connection-ID compression
1467 ipcp_wantoptions[0].cflag = 0;
1468 ipcp_allowoptions[0].cflag = 0;
1474 * setvjslots - set maximum number of connection slots for VJ compression
1482 if (!int_option(*argv, &value))
1484 if (value < 2 || value > 16) {
1485 option_error("vj-max-slots value must be between 2 and 16");
1488 ipcp_wantoptions [0].maxslotindex =
1489 ipcp_allowoptions[0].maxslotindex = value - 1;
1495 * setconnector - Set a program to connect to a serial line
1501 connector = strdup(*argv);
1502 if (connector == NULL)
1503 novm("connect script");
1504 connector_info.priv = privileged_option;
1505 connector_info.source = option_source;
1511 * setdisconnector - Set a program to disconnect from the serial line
1514 setdisconnector(argv)
1517 disconnector = strdup(*argv);
1518 if (disconnector == NULL)
1519 novm("disconnect script");
1520 disconnector_info.priv = privileged_option;
1521 disconnector_info.source = option_source;
1527 * setwelcomer - Set a program to welcome a client after connection
1533 welcomer = strdup(*argv);
1534 if (welcomer == NULL)
1535 novm("welcome script");
1536 welcomer_info.priv = privileged_option;
1537 welcomer_info.source = option_source;
1546 return int_option(*argv, &max_con_attempts);
1550 * setmaxconnect - Set the maximum connect time
1558 if (!int_option(*argv, &value))
1561 option_error("maxconnect time must be positive");
1564 if (maxconnect > 0 && (value == 0 || value > maxconnect)) {
1565 option_error("maxconnect time cannot be increased");
1573 * setdomain - Set domain name to append to hostname
1579 if (!privileged_option) {
1580 option_error("using the domain option requires root privilege");
1583 gethostname(hostname, MAXNAMELEN);
1586 strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
1587 strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
1589 hostname[MAXNAMELEN-1] = 0;
1595 * setasyncmap - add bits to asyncmap (what we request peer to escape).
1603 if (!number_option(*argv, &asyncmap, 16))
1605 lcp_wantoptions[0].asyncmap |= asyncmap;
1606 lcp_wantoptions[0].neg_asyncmap = 1;
1612 * setescape - add chars to the set we escape on transmission.
1624 n = strtol(p, &endp, 16);
1626 option_error("escape parameter contains invalid hex number '%s'",
1631 if (n < 0 || (0x20 <= n && n <= 0x3F) || n == 0x5E || n > 0xFF) {
1632 option_error("can't escape character 0x%x", n);
1635 xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
1636 while (*p == ',' || *p == ' ')
1644 * setspeed - Set the speed.
1653 spd = strtol(arg, &ptr, 0);
1654 if (ptr == arg || *ptr != 0 || spd == 0)
1662 * setdevname - Set the device name.
1665 setdevname(cp, quiet)
1669 struct stat statbuf;
1670 char dev[MAXPATHLEN];
1675 if (strncmp(_PATH_DEV, cp, sizeof _PATH_DEV - 1) != 0) {
1676 strcpy(dev, _PATH_DEV);
1677 strncat(dev, cp, MAXPATHLEN - sizeof _PATH_DEV - 1);
1678 dev[MAXPATHLEN-1] = 0;
1683 * Check if there is a device by this name.
1685 if (stat(cp, &statbuf) < 0) {
1686 if (errno == ENOENT || quiet)
1688 option_error("Couldn't stat %s: %m", cp);
1692 (void) strncpy(devnam, cp, MAXPATHLEN);
1693 devnam[MAXPATHLEN-1] = 0;
1694 default_device = FALSE;
1695 devnam_info.priv = privileged_option;
1696 devnam_info.source = option_source;
1703 * setipaddr - Set the IP address
1711 u_int32_t local, remote;
1712 ipcp_options *wo = &ipcp_wantoptions[0];
1715 * IP address pair separated by ":".
1717 if ((colon = strchr(arg, ':')) == NULL)
1721 * If colon first character, then no local addr.
1725 if ((local = inet_addr(arg)) == -1) {
1726 if ((hp = gethostbyname(arg)) == NULL) {
1727 option_error("unknown host: %s", arg);
1730 local = *(u_int32_t *)hp->h_addr;
1733 if (bad_ip_adrs(local)) {
1734 option_error("bad local IP address %s", ip_ntoa(local));
1738 wo->ouraddr = local;
1743 * If colon last character, then no remote addr.
1745 if (*++colon != '\0') {
1746 if ((remote = inet_addr(colon)) == -1) {
1747 if ((hp = gethostbyname(colon)) == NULL) {
1748 option_error("unknown host: %s", colon);
1751 remote = *(u_int32_t *)hp->h_addr;
1752 if (remote_name[0] == 0) {
1753 strncpy(remote_name, colon, MAXNAMELEN);
1754 remote_name[MAXNAMELEN-1] = 0;
1758 if (bad_ip_adrs(remote)) {
1759 option_error("bad remote IP address %s", ip_ntoa(remote));
1763 wo->hisaddr = remote;
1771 * setnoipdflt - disable setipdefault()
1777 disable_defaultip = 1;
1783 * setipcpaccl - accept peer's idea of our address
1789 ipcp_wantoptions[0].accept_local = 1;
1795 * setipcpaccr - accept peer's idea of its address
1801 ipcp_wantoptions[0].accept_remote = 1;
1807 * setnetmask - set the netmask to be used on the interface.
1813 struct in_addr mask;
1815 if ((inet_aton(*argv, &mask)) == -1 || (netmask & ~mask.s_addr)) {
1816 fprintf(stderr, "Invalid netmask %s\n", *argv);
1820 netmask = mask.s_addr;
1844 lcp_wantoptions[0].asyncmap |= 0x000A0000; /* escape ^S and ^Q */
1845 lcp_wantoptions[0].neg_asyncmap = 1;
1901 setusehostname(argv)
1912 if (!privileged_option) {
1913 option_error("using the name option requires root privilege");
1916 strncpy(our_name, argv[0], MAXNAMELEN);
1917 our_name[MAXNAMELEN-1] = 0;
1925 strncpy(user, argv[0], MAXNAMELEN);
1926 user[MAXNAMELEN-1] = 0;
1934 strncpy(remote_name, argv[0], MAXNAMELEN);
1935 remote_name[MAXNAMELEN-1] = 0;
1944 if (privileged_option > auth_req_info.priv) {
1945 auth_req_info.priv = privileged_option;
1946 auth_req_info.source = option_source;
1955 if (auth_required && privileged_option < auth_req_info.priv) {
1956 option_error("cannot override auth option set by %s",
1957 auth_req_info.source);
1965 setdefaultroute(argv)
1968 if (!ipcp_allowoptions[0].default_route) {
1969 option_error("defaultroute option is disabled");
1972 ipcp_wantoptions[0].default_route = 1;
1977 setnodefaultroute(argv)
1980 ipcp_allowoptions[0].default_route = 0;
1981 ipcp_wantoptions[0].default_route = 0;
1989 if (!ipcp_allowoptions[0].proxy_arp) {
1990 option_error("proxyarp option is disabled");
1993 ipcp_wantoptions[0].proxy_arp = 1;
2001 ipcp_wantoptions[0].proxy_arp = 0;
2002 ipcp_allowoptions[0].proxy_arp = 0;
2031 * Functions to set the echo interval for modem-less monitors
2035 setlcpechointv(argv)
2038 return int_option(*argv, &lcp_echo_interval);
2042 setlcpechofails(argv)
2045 return int_option(*argv, &lcp_echo_fails);
2049 * Functions to set timeouts, max transmits, etc.
2055 return int_option(*argv, &lcp_fsm[0].timeouttime);
2062 return int_option(*argv, &lcp_fsm[0].maxtermtransmits);
2069 return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits);
2076 return int_option(*argv, &lcp_fsm[0].maxnakloops);
2080 setipcptimeout(argv)
2083 return int_option(*argv, &ipcp_fsm[0].timeouttime);
2090 return int_option(*argv, &ipcp_fsm[0].maxtermtransmits);
2097 return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits);
2104 return int_option(*argv, &lcp_fsm[0].maxnakloops);
2111 return int_option(*argv, &upap[0].us_timeouttime);
2118 return int_option(*argv, &upap[0].us_reqtimeout);
2125 return int_option(*argv, &upap[0].us_maxtransmits);
2129 setchaptimeout(argv)
2132 return int_option(*argv, &chap[0].timeouttime);
2139 return int_option(*argv, &chap[0].max_transmits);
2146 return int_option(*argv, &chap[0].chal_interval);
2153 ccp_protent.enabled_flag = 0;
2165 abits = rbits = strtol(str, &endp, 0);
2166 if (endp != str && *endp == ',') {
2168 abits = strtol(str, &endp, 0);
2170 if (*endp != 0 || endp == str) {
2171 option_error("invalid parameter '%s' for bsdcomp option", *argv);
2174 if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS))
2175 || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) {
2176 option_error("bsdcomp option values must be 0 or %d .. %d",
2177 BSD_MIN_BITS, BSD_MAX_BITS);
2181 ccp_wantoptions[0].bsd_compress = 1;
2182 ccp_wantoptions[0].bsd_bits = rbits;
2184 ccp_wantoptions[0].bsd_compress = 0;
2186 ccp_allowoptions[0].bsd_compress = 1;
2187 ccp_allowoptions[0].bsd_bits = abits;
2189 ccp_allowoptions[0].bsd_compress = 0;
2197 ccp_wantoptions[0].bsd_compress = 0;
2198 ccp_allowoptions[0].bsd_compress = 0;
2210 abits = rbits = strtol(str, &endp, 0);
2211 if (endp != str && *endp == ',') {
2213 abits = strtol(str, &endp, 0);
2215 if (*endp != 0 || endp == str) {
2216 option_error("invalid parameter '%s' for deflate option", *argv);
2219 if ((rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE))
2220 || (abits != 0 && (abits < DEFLATE_MIN_SIZE
2221 || abits > DEFLATE_MAX_SIZE))) {
2222 option_error("deflate option values must be 0 or %d .. %d",
2223 DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE);
2227 ccp_wantoptions[0].deflate = 1;
2228 ccp_wantoptions[0].deflate_size = rbits;
2230 ccp_wantoptions[0].deflate = 0;
2232 ccp_allowoptions[0].deflate = 1;
2233 ccp_allowoptions[0].deflate_size = abits;
2235 ccp_allowoptions[0].deflate = 0;
2237 /* XXX copy over settings for switch compatibility */
2238 ccp_wantoptions[0].baddeflate = ccp_wantoptions[0].deflate;
2239 ccp_wantoptions[0].baddeflate_size = ccp_wantoptions[0].deflate_size;
2240 ccp_allowoptions[0].baddeflate = ccp_allowoptions[0].deflate;
2241 ccp_allowoptions[0].baddeflate_size = ccp_allowoptions[0].deflate_size;
2250 ccp_wantoptions[0].deflate = 0;
2251 ccp_allowoptions[0].deflate = 0;
2256 setnodeflatedraft(argv)
2259 ccp_wantoptions[0].deflate_draft = 0;
2260 ccp_allowoptions[0].deflate_draft = 0;
2268 ccp_wantoptions[0].predictor_1 = 1;
2269 ccp_allowoptions[0].predictor_1 = 1;
2274 setnopred1comp(argv)
2277 ccp_wantoptions[0].predictor_1 = 0;
2278 ccp_allowoptions[0].predictor_1 = 0;
2286 ipparam = strdup(*argv);
2287 if (ipparam == NULL)
2288 novm("ipparam string");
2305 return int_option(*argv, &idle_time_limit);
2312 return int_option(*argv, &holdoff);
2316 * setdnsaddr - set the dns address(es)
2325 dns = inet_addr(*argv);
2327 if ((hp = gethostbyname(*argv)) == NULL) {
2328 option_error("invalid address parameter '%s' for ms-dns option",
2332 dns = *(u_int32_t *)hp->h_addr;
2335 /* if there is no primary then update it. */
2336 if (ipcp_allowoptions[0].dnsaddr[0] == 0)
2337 ipcp_allowoptions[0].dnsaddr[0] = dns;
2339 /* always set the secondary address value to the same value. */
2340 ipcp_allowoptions[0].dnsaddr[1] = dns;
2346 * setwinsaddr - set the wins address(es)
2347 * This is primrarly used with the Samba package under UNIX or for pointing
2348 * the caller to the existing WINS server on a Windows NT platform.
2357 wins = inet_addr(*argv);
2359 if ((hp = gethostbyname(*argv)) == NULL) {
2360 option_error("invalid address parameter '%s' for ms-wins option",
2364 wins = *(u_int32_t *)hp->h_addr;
2367 /* if there is no primary then update it. */
2368 if (ipcp_allowoptions[0].winsaddr[0] == 0)
2369 ipcp_allowoptions[0].winsaddr[0] = wins;
2371 /* always set the secondary address value to the same value. */
2372 ipcp_allowoptions[0].winsaddr[1] = wins;
2382 ipxcp_wantoptions[0].neg_router = 1;
2383 ipxcp_allowoptions[0].neg_router = 1;
2384 return int_option(*argv, &ipxcp_wantoptions[0].router);
2391 char *dest = ipxcp_wantoptions[0].name;
2396 ipxcp_wantoptions[0].neg_name = 1;
2397 ipxcp_allowoptions[0].neg_name = 1;
2398 memset (dest, '\0', sizeof (ipxcp_wantoptions[0].name));
2403 if (! isalnum (ch) && ch != '_') {
2404 option_error("IPX router name must be alphanumeric or _");
2408 if (count >= sizeof (ipxcp_wantoptions[0].name)) {
2409 option_error("IPX router name is limited to %d characters",
2410 sizeof (ipxcp_wantoptions[0].name) - 1);
2414 dest[count++] = toupper (ch);
2421 setipxcptimeout (argv)
2424 return int_option(*argv, &ipxcp_fsm[0].timeouttime);
2431 return int_option(*argv, &ipxcp_fsm[0].maxtermtransmits);
2438 return int_option(*argv, &ipxcp_fsm[0].maxconfreqtransmits);
2442 setipxcpfails (argv)
2445 return int_option(*argv, &ipxcp_fsm[0].maxnakloops);
2454 if (!number_option(*argv, &v, 16))
2457 ipxcp_wantoptions[0].our_network = (int) v;
2458 ipxcp_wantoptions[0].neg_nn = 1;
2466 ipxcp_wantoptions[0].accept_network = 1;
2467 ipxcp_allowoptions[0].accept_network = 1;
2475 ipxcp_wantoptions[0].accept_local = 1;
2476 ipxcp_allowoptions[0].accept_local = 1;
2484 ipxcp_wantoptions[0].accept_remote = 1;
2485 ipxcp_allowoptions[0].accept_remote = 1;
2490 setipxnodevalue(src,dst)
2497 if (!isxdigit (*src))
2500 for (indx = 0; indx < 5; ++indx) {
2502 dst[indx] |= (dst[indx + 1] >> 4) & 0x0F;
2505 item = toupper (*src) - '0';
2509 dst[5] = (dst[5] << 4) | item;
2521 memset (&ipxcp_wantoptions[0].our_node[0], 0, 6);
2522 memset (&ipxcp_wantoptions[0].his_node[0], 0, 6);
2524 end = setipxnodevalue (*argv, &ipxcp_wantoptions[0].our_node[0]);
2526 end = setipxnodevalue (++end, &ipxcp_wantoptions[0].his_node[0]);
2529 ipxcp_wantoptions[0].neg_node = 1;
2533 option_error("invalid parameter '%s' for ipx-node option", *argv);
2541 ipxcp_protent.enabled_flag = 1;
2549 ipxcp_protent.enabled_flag = 0;
2560 #endif /* IPX_CHANGE */