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.52 1999/03/19 01:27:43 paulus Exp $";
35 #include <sys/types.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
41 #include <pcap-int.h> /* XXX: To get struct pcap */
45 #include "pathnames.h"
46 #include "patchlevel.h"
54 #include <net/ppp-comp.h>
56 #if defined(ultrix) || defined(NeXT)
57 char *strdup __P((char *));
61 * Option variables and default values.
64 int dflag = 0; /* Tell libpcap we want debugging */
66 int debug = 0; /* Debug flag */
67 int kdebugflag = 0; /* Tell kernel to print debug messages */
68 int default_device = 1; /* Using /dev/tty or equivalent */
69 char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */
70 int crtscts = 0; /* Use hardware flow control */
71 bool modem = 1; /* Use modem control lines */
72 int inspeed = 0; /* Input/Output speed requested */
73 u_int32_t netmask = 0; /* IP netmask to set on interface */
74 bool lockflag = 0; /* Create lock file to lock the serial dev */
75 bool nodetach = 0; /* Don't detach from controlling tty */
76 bool updetach = 0; /* Detach once link is up */
77 char *connector = NULL; /* Script to establish physical link */
78 char *disconnector = NULL; /* Script to disestablish physical link */
79 char *welcomer = NULL; /* Script to run after phys link estab. */
80 int maxconnect = 0; /* Maximum connect time */
81 char user[MAXNAMELEN]; /* Username for PAP */
82 char passwd[MAXSECRETLEN]; /* Password for PAP */
83 bool persist = 0; /* Reopen link after it goes down */
84 char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
85 bool demand = 0; /* do dial-on-demand */
86 char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
87 int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
88 int holdoff = 30; /* # seconds to pause before reconnecting */
90 extern option_t auth_options[];
92 struct option_info connector_info;
93 struct option_info disconnector_info;
94 struct option_info welcomer_info;
95 struct option_info devnam_info;
98 struct bpf_program pass_filter;/* Filter program for packets to pass */
99 struct bpf_program active_filter; /* Filter program for link-active pkts */
100 pcap_t pc; /* Fake struct pcap so we can compile expr */
106 static int setdevname __P((char *, int));
107 static int setipaddr __P((char *));
108 static int setspeed __P((char *));
109 static int noopt __P((char **));
110 static int setdomain __P((char **));
111 static int setnetmask __P((char **));
112 static int setxonxoff __P((char **));
113 static int readfile __P((char **));
114 static int callfile __P((char **));
115 static int showversion __P((char **));
116 static int showhelp __P((char **));
117 static void usage __P((void));
120 static int setpassfilter __P((char **));
121 static int setactivefilter __P((char **));
125 static option_t *find_option __P((char *name));
126 static int process_option __P((option_t *, char **));
127 static int n_arguments __P((option_t *));
128 static int number_option __P((char *, u_int32_t *, int));
133 option_t general_options[] = {
134 { "debug", o_int, &debug,
135 "Increase debugging level", OPT_INC|OPT_NOARG|1 },
136 { "-d", o_int, &debug,
137 "Increase debugging level", OPT_INC|OPT_NOARG|1 },
138 { "kdebug", o_int, &kdebugflag,
139 "Set kernel driver debug level" },
140 { "nodetach", o_bool, &nodetach,
141 "Don't detach from controlling tty", 1 },
142 { "-detach", o_bool, &nodetach,
143 "Don't detach from controlling tty", 1 },
144 { "updetach", o_bool, &updetach,
145 "Detach from controlling tty once link is up", 1 },
146 { "holdoff", o_int, &holdoff,
147 "Set time in seconds before retrying connection" },
148 { "idle", o_int, &idle_time_limit,
149 "Set time in seconds before disconnecting idle link" },
150 { "lock", o_bool, &lockflag,
151 "Lock serial device with UUCP-style lock file", 1 },
152 { "-all", o_special_noarg, noopt,
153 "Don't request/allow any LCP or IPCP options (useless)" },
154 { "connect", o_string, &connector,
155 "A program to set up a connection",
156 OPT_A2INFO | OPT_PRIVFIX, &connector_info },
157 { "disconnect", o_string, &disconnector,
158 "Program to disconnect serial device",
159 OPT_A2INFO | OPT_PRIVFIX, &disconnector_info },
160 { "welcome", o_string, &welcomer,
161 "Script to welcome client",
162 OPT_A2INFO | OPT_PRIVFIX, &welcomer_info },
163 { "maxconnect", o_int, &maxconnect,
164 "Set connection time limit", OPT_LLIMIT|OPT_NOINCR|OPT_ZEROINF },
165 { "crtscts", o_int, &crtscts,
166 "Set hardware (RTS/CTS) flow control", OPT_NOARG|OPT_VAL(1) },
167 { "nocrtscts", o_int, &crtscts,
168 "Disable hardware flow control", OPT_NOARG|OPT_VAL(-1) },
169 { "-crtscts", o_int, &crtscts,
170 "Disable hardware flow control", OPT_NOARG|OPT_VAL(-1) },
171 { "cdtrcts", o_int, &crtscts,
172 "Set alternate hardware (DTR/CTS) flow control", OPT_NOARG|OPT_VAL(2) },
173 { "nocdtrcts", o_int, &crtscts,
174 "Disable hardware flow control", OPT_NOARG|OPT_VAL(-1) },
175 { "xonxoff", o_special_noarg, setxonxoff,
176 "Set software (XON/XOFF) flow control" },
177 { "domain", o_special, setdomain,
178 "Add given domain name to hostname" },
179 { "mtu", o_int, &lcp_allowoptions[0].mru,
180 "Set our MTU", OPT_LIMITS, NULL, MAXMRU, MINMRU },
181 { "netmask", o_special, setnetmask,
183 { "modem", o_bool, &modem,
184 "Use modem control lines", 1 },
185 { "local", o_bool, &modem,
186 "Don't use modem control lines" },
187 { "file", o_special, readfile,
188 "Take options from a file" },
189 { "call", o_special, callfile,
190 "Take options from a privileged file" },
191 { "persist", o_bool, &persist,
192 "Keep on reopening connection after close", 1 },
193 { "nopersist", o_bool, &persist,
194 "Turn off persist option" },
195 { "demand", o_bool, &demand,
196 "Dial on demand", 1, &persist },
197 { "--version", o_special_noarg, showversion,
198 "Show version number" },
199 { "--help", o_special_noarg, showhelp,
200 "Show brief listing of options" },
201 { "-h", o_special_noarg, showhelp,
202 "Show brief listing of options" },
205 { "pdebug", o_int, &dflag,
206 "libpcap debugging" },
207 { "pass-filter", 1, setpassfilter,
208 "set filter for packets to pass" },
209 { "active-filter", 1, setactivefilter,
210 "set filter for active pkts" },
216 #ifndef IMPLEMENTATION
217 #define IMPLEMENTATION ""
220 static char *usage_string = "\
221 pppd version %s.%d%s\n\
222 Usage: %s [ options ], where options are:\n\
223 <device> Communicate over the named device\n\
224 <speed> Set the baud rate to <speed>\n\
225 <loc>:<rem> Set the local and/or remote interface IP\n\
226 addresses. Either one may be omitted.\n\
227 asyncmap <n> Set the desired async map to hex <n>\n\
228 auth Require authentication from peer\n\
229 connect <p> Invoke shell command <p> to set up the serial line\n\
230 crtscts Use hardware RTS/CTS flow control\n\
231 defaultroute Add default route through interface\n\
232 file <f> Take options from file <f>\n\
233 modem Use modem control lines\n\
234 mru <n> Set MRU value to <n> for negotiation\n\
235 See pppd(8) for more options.\n\
239 * parse_args - parse a string of arguments from the command line.
242 parse_args(argc, argv)
250 privileged_option = privileged;
251 option_source = "command line";
257 * First see if it's an option in the new option list.
259 opt = find_option(arg);
261 int n = n_arguments(opt);
263 option_error("too few parameters for option %s", arg);
266 current_option = arg;
267 if (!process_option(opt, argv))
275 * Maybe a tty name, speed or IP address?
277 if ((ret = setdevname(arg, 0)) == 0
278 && (ret = setspeed(arg)) == 0
279 && (ret = setipaddr(arg)) == 0) {
280 option_error("unrecognized option '%s'", arg);
284 if (ret < 0) /* error */
291 * scan_args - scan the command line arguments to get the tty name,
295 scan_args(argc, argv)
302 privileged_option = privileged;
307 /* Skip options and their arguments */
308 opt = find_option(arg);
310 int n = n_arguments(opt);
316 /* Check if it's a tty name and copy it if so */
317 (void) setdevname(arg, 1);
322 * options_from_file - Read a string of options from a file,
323 * and interpret them.
326 options_from_file(filename, must_exist, check_prot, priv)
338 char args[MAXARGS][MAXWORDLEN];
339 char cmd[MAXWORDLEN];
343 f = fopen(filename, "r");
347 if (!must_exist && errno == ENOENT)
349 option_error("Can't open options file %s: %m", filename);
353 oldpriv = privileged_option;
354 privileged_option = priv;
355 oldsource = option_source;
356 option_source = strdup(filename);
357 if (option_source == NULL)
358 option_source = "file";
360 while (getword(f, cmd, &newline, filename)) {
362 * First see if it's a command.
364 opt = find_option(cmd);
366 int n = n_arguments(opt);
367 for (i = 0; i < n; ++i) {
368 if (!getword(f, args[i], &newline, filename)) {
370 "In file %s: too few parameters for option '%s'",
376 current_option = cmd;
377 if (!process_option(opt, argv))
383 * Maybe a tty name, speed or IP address?
385 if ((i = setdevname(cmd, 0)) == 0
386 && (i = setspeed(cmd)) == 0
387 && (i = setipaddr(cmd)) == 0) {
388 option_error("In file %s: unrecognized option '%s'",
392 if (i < 0) /* error */
399 privileged_option = oldpriv;
400 option_source = oldsource;
405 * options_from_user - See if the use has a ~/.ppprc file,
406 * and if so, interpret options from it.
411 char *user, *path, *file;
416 pw = getpwuid(getuid());
417 if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
419 file = _PATH_USEROPT;
420 pl = strlen(user) + strlen(file) + 2;
423 novm("init file name");
424 slprintf(path, pl, "%s/%s", user, file);
425 ret = options_from_file(path, 0, 1, privileged);
431 * options_for_tty - See if an options file exists for the serial
432 * device, and if so, interpret options from it.
437 char *dev, *path, *p;
442 if (strncmp(dev, "/dev/", 5) == 0)
444 if (strcmp(dev, "tty") == 0)
445 return 1; /* don't look for /etc/ppp/options.tty */
446 pl = strlen(_PATH_TTYOPT) + strlen(dev) + 1;
449 novm("tty init file name");
450 slprintf(path, pl, "%s%s", _PATH_TTYOPT, dev);
451 /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */
452 for (p = path + strlen(_PATH_TTYOPT); *p != 0; ++p)
455 ret = options_from_file(path, 0, 0, 1);
461 * find_option - scan the option lists for the various protocols
462 * looking for an entry with the given name.
463 * This could be optimized by using a hash table.
472 for (opt = general_options; opt->name != NULL; ++opt)
473 if (strcmp(name, opt->name) == 0)
475 for (opt = auth_options; opt->name != NULL; ++opt)
476 if (strcmp(name, opt->name) == 0)
478 for (i = 0; protocols[i] != NULL; ++i)
479 if ((opt = protocols[i]->options) != NULL)
480 for (; opt->name != NULL; ++opt)
481 if (strcmp(name, opt->name) == 0)
487 * process_option - process one new-style option.
490 process_option(opt, argv)
497 int (*parser) __P((char **));
499 if ((opt->flags & OPT_PRIV) && !privileged_option) {
500 option_error("using the %s option requires root privilege", opt->name);
503 if ((opt->flags & OPT_ENABLE) && *(bool *)(opt->addr2) == 0) {
504 option_error("%s option is disabled", opt->name);
507 if ((opt->flags & OPT_PRIVFIX) && !privileged_option) {
508 struct option_info *ip = (struct option_info *) opt->addr2;
509 if (ip && ip->priv) {
510 option_error("%s option cannot be overridden", opt->name);
517 v = opt->flags & OPT_VALUE;
518 *(bool *)(opt->addr) = v;
519 if (opt->addr2 && (opt->flags & OPT_A2COPY))
520 *(bool *)(opt->addr2) = v;
525 if ((opt->flags & OPT_NOARG) == 0) {
526 if (!int_option(*argv, &iv))
528 if ((((opt->flags & OPT_LLIMIT) && iv < opt->lower_limit)
529 || ((opt->flags & OPT_ULIMIT) && iv > opt->upper_limit))
530 && !((opt->flags & OPT_ZEROOK && iv == 0))) {
531 char *zok = (opt->flags & OPT_ZEROOK)? " zero or": "";
532 switch (opt->flags & OPT_LIMITS) {
534 option_error("%s value must be%s >= %d",
535 opt->name, zok, opt->lower_limit);
538 option_error("%s value must be%s <= %d",
539 opt->name, zok, opt->upper_limit);
542 option_error("%s value must be%s between %d and %d",
543 opt->name, opt->lower_limit, opt->upper_limit);
549 a = opt->flags & OPT_VALUE;
551 a -= 256; /* sign extend */
553 if (opt->flags & OPT_INC)
554 iv += *(int *)(opt->addr);
555 if ((opt->flags & OPT_NOINCR) && !privileged_option) {
556 int oldv = *(int *)(opt->addr);
557 if ((opt->flags & OPT_ZEROINF) ?
558 (oldv != 0 && (iv == 0 || iv > oldv)) : (iv > oldv)) {
559 option_error("%s value cannot be increased", opt->name);
563 *(int *)(opt->addr) = iv;
564 if (opt->addr2 && (opt->flags & OPT_A2COPY))
565 *(int *)(opt->addr2) = iv;
569 if (opt->flags & OPT_NOARG) {
570 v = opt->flags & OPT_VALUE;
571 } else if (!number_option(*argv, &v, 16))
573 if (opt->flags & OPT_OR)
574 v |= *(u_int32_t *)(opt->addr);
575 *(u_int32_t *)(opt->addr) = v;
576 if (opt->addr2 && (opt->flags & OPT_A2COPY))
577 *(u_int32_t *)(opt->addr2) = v;
581 if (opt->flags & OPT_STATIC) {
582 strlcpy((char *)(opt->addr), *argv, opt->upper_limit);
586 novm("option argument");
587 *(char **)(opt->addr) = sv;
591 case o_special_noarg:
593 parser = (int (*) __P((char **))) opt->addr;
594 if (!(*parser)(argv))
600 if (opt->flags & OPT_A2INFO) {
601 struct option_info *ip = (struct option_info *) opt->addr2;
602 ip->priv = privileged_option;
603 ip->source = option_source;
604 } else if ((opt->flags & (OPT_A2COPY|OPT_ENABLE)) == 0)
605 *(bool *)(opt->addr2) = 1;
612 * n_arguments - tell how many arguments an option takes
618 return (opt->type == o_bool || opt->type == o_special_noarg
619 || (opt->flags & OPT_NOARG))? 0: 1;
623 * usage - print out a message telling how to use the program.
628 if (phase == PHASE_INITIALIZE)
629 fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION,
634 * showhelp - print out usage message and exit.
640 if (phase == PHASE_INITIALIZE) {
648 * showversion - print out the version number and exit.
654 if (phase == PHASE_INITIALIZE) {
655 fprintf(stderr, "pppd version %s.%d%s\n",
656 VERSION, PATCHLEVEL, IMPLEMENTATION);
663 * option_error - print a message about an error in an option.
664 * The message is logged, and also sent to
665 * stderr if phase == PHASE_INITIALIZE.
668 option_error __V((char *fmt, ...))
678 fmt = va_arg(args, char *);
680 vslprintf(buf, sizeof(buf), fmt, args);
682 if (phase == PHASE_INITIALIZE)
683 fprintf(stderr, "%s: %s\n", progname, buf);
684 syslog(LOG_ERR, "%s", buf);
689 * readable - check if a file is readable by the real user.
702 if (fstat(fd, &sbuf) != 0)
704 if (sbuf.st_uid == uid)
705 return sbuf.st_mode & S_IRUSR;
706 if (sbuf.st_gid == getgid())
707 return sbuf.st_mode & S_IRGRP;
708 for (i = 0; i < ngroups; ++i)
709 if (sbuf.st_gid == groups[i])
710 return sbuf.st_mode & S_IRGRP;
711 return sbuf.st_mode & S_IROTH;
716 * Read a word from a file.
717 * Words are delimited by white-space or by quotes (" or ').
718 * Quotes, white-space and \ may be escaped with \.
719 * \<newline> is ignored.
722 getword(f, word, newlinep, filename)
730 int value, digit, got, n;
732 #define isoctal(c) ((c) >= '0' && (c) < '8')
740 * First skip white-space and comments.
748 * A newline means the end of a comment; backslash-newline
749 * is ignored. Note that we cannot have escape && comment.
761 * Ignore characters other than newline in a comment.
767 * If this character is escaped, we have a word start.
773 * If this is the escape character, look at the next character.
781 * If this is the start of a comment, ignore the rest of the line.
789 * A non-whitespace character is the start of a word.
796 * Save the delimiter for quoted strings.
798 if (!escape && (c == '"' || c == '\'')) {
805 * Process characters until the end of the word.
810 * This character is escaped: backslash-newline is ignored,
811 * various other characters indicate particular values
812 * as for C backslash-escapes.
847 * \ddd octal sequence
850 for (n = 0; n < 3 && isoctal(c); ++n) {
851 value = (value << 3) + (c & 07);
860 * \x<hex_string> sequence
864 for (n = 0; n < 2 && isxdigit(c); ++n) {
865 digit = toupper(c) - '0';
867 digit += '0' + 10 - 'A';
868 value = (value << 4) + digit;
876 * Otherwise the character stands for itself.
883 * Store the resulting character for the escape sequence.
885 if (len < MAXWORDLEN-1)
896 * Not escaped: see if we've reached the end of the word.
902 if (isspace(c) || c == '#') {
909 * Backslash starts an escape sequence.
918 * An ordinary character: store it in the word and get another.
920 if (len < MAXWORDLEN-1)
928 * End of the word: check for errors.
934 option_error("Error reading %s: %m", filename);
938 * If len is zero, then we didn't find a word before the
946 * Warn if the word was too long, and append a terminating null.
948 if (len >= MAXWORDLEN) {
949 option_error("warning: word in file %s too long (%.20s...)",
951 len = MAXWORDLEN - 1;
962 * number_option - parse an unsigned numeric parameter for an option.
965 number_option(str, valp, base)
972 *valp = strtoul(str, &ptr, base);
974 option_error("invalid numeric parameter '%s' for %s option",
975 str, current_option);
983 * int_option - like number_option, but valp is int *,
984 * the base is assumed to be 0, and *valp is not changed
985 * if there is an error.
988 int_option(str, valp)
994 if (!number_option(str, &v, 0))
1002 * The following procedures parse options.
1006 * readfile - take commands from a file.
1012 return options_from_file(*argv, 1, 1, privileged_option);
1016 * callfile - take commands from /etc/ppp/peers/<name>.
1017 * Name may not contain /../, start with / or ../, or end in /..
1023 char *fname, *arg, *p;
1028 if (arg[0] == '/' || arg[0] == 0)
1031 for (p = arg; *p != 0; ) {
1032 if (p[0] == '.' && p[1] == '.' && (p[2] == '/' || p[2] == 0)) {
1036 while (*p != '/' && *p != 0)
1043 option_error("call option value may not contain .. or start with /");
1047 l = strlen(arg) + strlen(_PATH_PEERFILES) + 1;
1048 if ((fname = (char *) malloc(l)) == NULL)
1049 novm("call file name");
1050 slprintf(fname, l, "%s%s", _PATH_PEERFILES, arg);
1052 ok = options_from_file(fname, 1, 1, 1);
1060 * setpdebug - Set libpcap debugging level.
1066 return int_option(*argv, &dflag);
1070 * setpassfilter - Set the pass filter for packets
1076 pc.linktype = DLT_PPP;
1077 pc.snapshot = PPP_HDRLEN;
1079 if (pcap_compile(&pc, &pass_filter, *argv, 1, netmask) == 0)
1081 option_error("error in pass-filter expression: %s\n", pcap_geterr(&pc));
1086 * setactivefilter - Set the active filter for packets
1089 setactivefilter(argv)
1092 pc.linktype = DLT_PPP;
1093 pc.snapshot = PPP_HDRLEN;
1095 if (pcap_compile(&pc, &active_filter, *argv, 1, netmask) == 0)
1097 option_error("error in active-filter expression: %s\n", pcap_geterr(&pc));
1103 * noopt - Disable all options.
1109 BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
1110 BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
1111 BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
1112 BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
1118 * setdomain - Set domain name to append to hostname
1124 if (!privileged_option) {
1125 option_error("using the domain option requires root privilege");
1128 gethostname(hostname, MAXNAMELEN);
1131 strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
1132 strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
1134 hostname[MAXNAMELEN-1] = 0;
1140 * setspeed - Set the speed.
1149 spd = strtol(arg, &ptr, 0);
1150 if (ptr == arg || *ptr != 0 || spd == 0)
1158 * setdevname - Set the device name.
1161 setdevname(cp, quiet)
1165 struct stat statbuf;
1166 char dev[MAXPATHLEN];
1171 if (strncmp("/dev/", cp, 5) != 0) {
1172 strlcpy(dev, "/dev/", sizeof(dev));
1173 strlcat(dev, cp, sizeof(dev));
1178 * Check if there is a device by this name.
1180 if (stat(cp, &statbuf) < 0) {
1181 if (errno == ENOENT || quiet)
1183 option_error("Couldn't stat %s: %m", cp);
1187 if (devnam_info.priv && !privileged_option) {
1189 option_error("device name cannot be overridden");
1193 strlcpy(devnam, cp, sizeof(devnam));
1195 devnam_info.priv = privileged_option;
1196 devnam_info.source = option_source;
1203 * setipaddr - Set the IP address
1211 u_int32_t local, remote;
1212 ipcp_options *wo = &ipcp_wantoptions[0];
1215 * IP address pair separated by ":".
1217 if ((colon = strchr(arg, ':')) == NULL)
1221 * If colon first character, then no local addr.
1225 if ((local = inet_addr(arg)) == -1) {
1226 if ((hp = gethostbyname(arg)) == NULL) {
1227 option_error("unknown host: %s", arg);
1230 local = *(u_int32_t *)hp->h_addr;
1233 if (bad_ip_adrs(local)) {
1234 option_error("bad local IP address %s", ip_ntoa(local));
1238 wo->ouraddr = local;
1243 * If colon last character, then no remote addr.
1245 if (*++colon != '\0') {
1246 if ((remote = inet_addr(colon)) == -1) {
1247 if ((hp = gethostbyname(colon)) == NULL) {
1248 option_error("unknown host: %s", colon);
1251 remote = *(u_int32_t *)hp->h_addr;
1252 if (remote_name[0] == 0)
1253 strlcpy(remote_name, colon, sizeof(remote_name));
1256 if (bad_ip_adrs(remote)) {
1257 option_error("bad remote IP address %s", ip_ntoa(remote));
1261 wo->hisaddr = remote;
1269 * setnetmask - set the netmask to be used on the interface.
1280 * Unfortunately, if we use inet_addr, we can't tell whether
1281 * a result of all 1s is an error or a valid 255.255.255.255.
1287 b = strtoul(p, &endp, 0);
1290 if (b < 0 || b > 255) {
1292 /* accept e.g. 0xffffff00 */
1298 mask |= b << (n * 8);
1300 if (*p != '.' || n == 0)
1307 if (*p != 0 || (netmask & ~mask) != 0) {
1308 option_error("invalid netmask value '%s'", *argv);
1320 lcp_wantoptions[0].asyncmap |= 0x000A0000; /* escape ^S and ^Q */
1321 lcp_wantoptions[0].neg_asyncmap = 1;