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.50 1999/03/08 05:34:44 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>
59 #if defined(ultrix) || defined(NeXT)
60 char *strdup __P((char *));
64 #define GIDSET_TYPE gid_t
68 * Option variables and default values.
71 int dflag = 0; /* Tell libpcap we want debugging */
73 int debug = 0; /* Debug flag */
74 int kdebugflag = 0; /* Tell kernel to print debug messages */
75 int default_device = 1; /* Using /dev/tty or equivalent */
76 char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */
77 int crtscts = 0; /* Use hardware flow control */
78 bool modem = 1; /* Use modem control lines */
79 int inspeed = 0; /* Input/Output speed requested */
80 u_int32_t netmask = 0; /* IP netmask to set on interface */
81 bool lockflag = 0; /* Create lock file to lock the serial dev */
82 bool nodetach = 0; /* Don't detach from controlling tty */
83 bool updetach = 0; /* Detach once link is up */
84 char *connector = NULL; /* Script to establish physical link */
85 char *disconnector = NULL; /* Script to disestablish physical link */
86 char *welcomer = NULL; /* Script to run after phys link estab. */
87 int maxconnect = 0; /* Maximum connect time */
88 char user[MAXNAMELEN]; /* Username for PAP */
89 char passwd[MAXSECRETLEN]; /* Password for PAP */
90 bool persist = 0; /* Reopen link after it goes down */
91 char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
92 char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
93 int explicit_remote = 0; /* User specified explicit remote name */
94 bool demand = 0; /* do dial-on-demand */
95 char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
96 int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
97 int holdoff = 30; /* # seconds to pause before reconnecting */
99 extern option_t auth_options[];
101 struct option_info connector_info;
102 struct option_info disconnector_info;
103 struct option_info welcomer_info;
104 struct option_info devnam_info;
107 struct bpf_program pass_filter;/* Filter program for packets to pass */
108 struct bpf_program active_filter; /* Filter program for link-active pkts */
109 pcap_t pc; /* Fake struct pcap so we can compile expr */
115 static int setdevname __P((char *, int));
116 static int setipaddr __P((char *));
117 static int setspeed __P((char *));
118 static int noopt __P((char **));
119 static int setdomain __P((char **));
120 static int setnetmask __P((char **));
121 static int setxonxoff __P((char **));
122 static int readfile __P((char **));
123 static int callfile __P((char **));
124 static int showversion __P((char **));
125 static int showhelp __P((char **));
128 static int setpassfilter __P((char **));
129 static int setactivefilter __P((char **));
133 static option_t *find_option __P((char *name));
134 static int process_option __P((option_t *, char **));
135 static int n_arguments __P((option_t *));
140 option_t general_options[] = {
141 { "debug", o_int, &debug,
142 "Increase debugging level", OPT_INC|OPT_NOARG|1 },
143 { "-d", o_int, &debug,
144 "Increase debugging level", OPT_INC|OPT_NOARG|1 },
145 { "kdebug", o_int, &kdebugflag,
146 "Set kernel driver debug level" },
147 { "nodetach", o_bool, &nodetach,
148 "Don't detach from controlling tty", 1 },
149 { "-detach", o_bool, &nodetach,
150 "Don't detach from controlling tty", 1 },
151 { "updetach", o_bool, &updetach,
152 "Detach from controlling tty once link is up", 1 },
153 { "holdoff", o_int, &holdoff,
154 "Set time in seconds before retrying connection" },
155 { "idle", o_int, &idle_time_limit,
156 "Set time in seconds before disconnecting idle link" },
157 { "lock", o_bool, &lockflag,
158 "Lock serial device with UUCP-style lock file", 1 },
159 { "-all", o_special_noarg, noopt,
160 "Don't request/allow any LCP or IPCP options (useless)" },
161 { "connect", o_string, &connector,
162 "A program to set up a connection", OPT_A2INFO, &connector_info },
163 { "disconnect", o_string, &disconnector,
164 "Program to disconnect serial device", OPT_A2INFO, &disconnector_info },
165 { "welcome", o_string, &welcomer,
166 "Script to welcome client", OPT_A2INFO, &welcomer_info },
167 { "maxconnect", o_int, &maxconnect,
168 "Set connection time limit", OPT_LLIMIT|OPT_NOINCR|OPT_ZEROINF },
169 { "crtscts", o_int, &crtscts,
170 "Set hardware (RTS/CTS) flow control", OPT_NOARG|OPT_VAL(1) },
171 { "nocrtscts", o_int, &crtscts,
172 "Disable hardware flow control", OPT_NOARG|OPT_VAL(-1) },
173 { "-crtscts", o_int, &crtscts,
174 "Disable hardware flow control", OPT_NOARG|OPT_VAL(-1) },
175 { "cdtrcts", o_int, &crtscts,
176 "Set alternate hardware (DTR/CTS) flow control", OPT_NOARG|OPT_VAL(2) },
177 { "nocdtrcts", o_int, &crtscts,
178 "Disable hardware flow control", OPT_NOARG|OPT_VAL(-1) },
179 { "xonxoff", o_special_noarg, setxonxoff,
180 "Set software (XON/XOFF) flow control" },
181 { "domain", o_special, setdomain,
182 "Add given domain name to hostname" },
183 { "mtu", o_int, &lcp_allowoptions[0].mru,
184 "Set our MTU", OPT_LIMITS, NULL, MAXMRU, MINMRU },
185 { "netmask", o_special, setnetmask,
187 { "modem", o_bool, &modem,
188 "Use modem control lines", 1 },
189 { "local", o_bool, &modem,
190 "Don't use modem control lines" },
191 { "file", o_special, readfile,
192 "Take options from a file" },
193 { "call", o_special, callfile,
194 "Take options from a privileged file" },
195 { "persist", o_bool, &persist,
196 "Keep on reopening connection after close", 1 },
197 { "nopersist", o_bool, &persist,
198 "Turn off persist option" },
199 { "demand", o_bool, &demand,
200 "Dial on demand", 1, &persist },
201 { "--version", o_special_noarg, showversion,
202 "Show version number" },
203 { "--help", o_special_noarg, showhelp,
204 "Show brief listing of options" },
205 { "-h", o_special_noarg, showhelp,
206 "Show brief listing of options" },
209 { "pdebug", o_int, &dflag,
210 "libpcap debugging" },
211 { "pass-filter", 1, setpassfilter,
212 "set filter for packets to pass" },
213 { "active-filter", 1, setactivefilter,
214 "set filter for active pkts" },
220 #ifndef IMPLEMENTATION
221 #define IMPLEMENTATION ""
224 static char *usage_string = "\
225 pppd version %s.%d%s\n\
226 Usage: %s [ options ], where options are:\n\
227 <device> Communicate over the named device\n\
228 <speed> Set the baud rate to <speed>\n\
229 <loc>:<rem> Set the local and/or remote interface IP\n\
230 addresses. Either one may be omitted.\n\
231 asyncmap <n> Set the desired async map to hex <n>\n\
232 auth Require authentication from peer\n\
233 connect <p> Invoke shell command <p> to set up the serial line\n\
234 crtscts Use hardware RTS/CTS flow control\n\
235 defaultroute Add default route through interface\n\
236 file <f> Take options from file <f>\n\
237 modem Use modem control lines\n\
238 mru <n> Set MRU value to <n> for negotiation\n\
239 See pppd(8) for more options.\n\
243 * parse_args - parse a string of arguments from the command line.
246 parse_args(argc, argv)
254 privileged_option = privileged;
255 option_source = "command line";
261 * First see if it's an option in the new option list.
263 opt = find_option(arg);
265 int n = n_arguments(opt);
267 option_error("too few parameters for option %s", arg);
270 current_option = arg;
271 if (!process_option(opt, argv))
279 * Maybe a tty name, speed or IP address?
281 if ((ret = setdevname(arg, 0)) == 0
282 && (ret = setspeed(arg)) == 0
283 && (ret = setipaddr(arg)) == 0) {
284 option_error("unrecognized option '%s'", arg);
288 if (ret < 0) /* error */
295 * scan_args - scan the command line arguments to get the tty name,
299 scan_args(argc, argv)
306 privileged_option = privileged;
311 /* Skip options and their arguments */
312 opt = find_option(arg);
314 int n = n_arguments(opt);
320 /* Check if it's a tty name and copy it if so */
321 (void) setdevname(arg, 1);
326 * options_from_file - Read a string of options from a file,
327 * and interpret them.
330 options_from_file(filename, must_exist, check_prot, priv)
342 char args[MAXARGS][MAXWORDLEN];
343 char cmd[MAXWORDLEN];
347 f = fopen(filename, "r");
351 if (!must_exist && errno == ENOENT)
353 option_error("Can't open options file %s: %m", filename);
356 #if 0 /* check done by setting effective UID above */
357 if (check_prot && !readable(fileno(f))) {
358 option_error("Can't open options file %s: access denied", filename);
364 oldpriv = privileged_option;
365 privileged_option = priv;
366 oldsource = option_source;
367 option_source = strdup(filename);
368 if (option_source == NULL)
369 option_source = "file";
371 while (getword(f, cmd, &newline, filename)) {
373 * First see if it's a command.
375 opt = find_option(cmd);
377 int n = n_arguments(opt);
378 for (i = 0; i < n; ++i) {
379 if (!getword(f, args[i], &newline, filename)) {
381 "In file %s: too few parameters for option '%s'",
387 current_option = cmd;
388 if (!process_option(opt, argv))
394 * Maybe a tty name, speed or IP address?
396 if ((i = setdevname(cmd, 0)) == 0
397 && (i = setspeed(cmd)) == 0
398 && (i = setipaddr(cmd)) == 0) {
399 option_error("In file %s: unrecognized option '%s'",
403 if (i < 0) /* error */
410 privileged_option = oldpriv;
411 option_source = oldsource;
416 * options_from_user - See if the use has a ~/.ppprc file,
417 * and if so, interpret options from it.
422 char *user, *path, *file;
426 pw = getpwuid(getuid());
427 if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
429 file = _PATH_USEROPT;
430 path = malloc(strlen(user) + strlen(file) + 2);
432 novm("init file name");
436 ret = options_from_file(path, 0, 1, privileged);
442 * options_for_tty - See if an options file exists for the serial
443 * device, and if so, interpret options from it.
448 char *dev, *path, *p;
452 if (strncmp(dev, "/dev/", 5) == 0)
454 if (strcmp(dev, "tty") == 0)
455 return 1; /* don't look for /etc/ppp/options.tty */
456 path = malloc(strlen(_PATH_TTYOPT) + strlen(dev) + 1);
458 novm("tty init file name");
459 strcpy(path, _PATH_TTYOPT);
460 /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */
461 for (p = path + strlen(path); *dev != 0; ++dev)
462 *p++ = (*dev == '/'? '.': *dev);
464 ret = options_from_file(path, 0, 0, 1);
470 * find_option - scan the option lists for the various protocols
471 * looking for an entry with the given name.
472 * This could be optimized by using a hash table.
481 for (opt = general_options; opt->name != NULL; ++opt)
482 if (strcmp(name, opt->name) == 0)
484 for (opt = auth_options; opt->name != NULL; ++opt)
485 if (strcmp(name, opt->name) == 0)
487 for (i = 0; protocols[i] != NULL; ++i)
488 if ((opt = protocols[i]->options) != NULL)
489 for (; opt->name != NULL; ++opt)
490 if (strcmp(name, opt->name) == 0)
496 * process_option - process one new-style option.
499 process_option(opt, argv)
506 int (*parser) __P((char **));
508 if ((opt->flags & OPT_PRIV) && !privileged_option) {
509 option_error("using the %s option requires root privilege", opt->name);
512 if ((opt->flags & OPT_ENABLE) && *(bool *)(opt->addr2) == 0) {
513 option_error("%s option is disabled", opt->name);
519 v = opt->flags & OPT_VALUE;
520 *(bool *)(opt->addr) = v;
521 if (opt->addr2 && (opt->flags & OPT_A2COPY))
522 *(bool *)(opt->addr2) = v;
527 if ((opt->flags & OPT_NOARG) == 0) {
528 if (!int_option(*argv, &iv))
530 if ((((opt->flags & OPT_LLIMIT) && iv < opt->lower_limit)
531 || ((opt->flags & OPT_ULIMIT) && iv > opt->upper_limit))
532 && !((opt->flags & OPT_ZEROOK && iv == 0))) {
533 char *zok = (opt->flags & OPT_ZEROOK)? " zero or": "";
534 switch (opt->flags & OPT_LIMITS) {
536 option_error("%s value must be%s >= %d",
537 opt->name, zok, opt->lower_limit);
540 option_error("%s value must be%s <= %d",
541 opt->name, zok, opt->upper_limit);
544 option_error("%s value must be%s between %d and %d",
545 opt->name, opt->lower_limit, opt->upper_limit);
551 a = opt->flags & OPT_VALUE;
553 a -= 256; /* sign extend */
555 if (opt->flags & OPT_INC)
556 iv += *(int *)(opt->addr);
557 if ((opt->flags & OPT_NOINCR) && !privileged_option) {
558 int oldv = *(int *)(opt->addr);
559 if ((opt->flags & OPT_ZEROINF) ?
560 (oldv != 0 && (iv == 0 || iv > oldv)) : (iv > oldv)) {
561 option_error("%s value cannot be increased", opt->name);
565 *(int *)(opt->addr) = iv;
566 if (opt->addr2 && (opt->flags & OPT_A2COPY))
567 *(int *)(opt->addr2) = iv;
571 if (opt->flags & OPT_NOARG) {
572 v = opt->flags & OPT_VALUE;
573 } else if (!number_option(*argv, &v, 16))
575 if (opt->flags & OPT_OR)
576 v |= *(u_int32_t *)(opt->addr);
577 *(u_int32_t *)(opt->addr) = v;
578 if (opt->addr2 && (opt->flags & OPT_A2COPY))
579 *(u_int32_t *)(opt->addr2) = v;
583 if (opt->flags & OPT_STATIC) {
584 if (opt->upper_limit) {
585 strncpy((char *)(opt->addr), *argv, opt->upper_limit);
586 ((char *)(opt->addr))[opt->upper_limit-1] = 0;
588 strcpy((char *)(opt->addr), *argv);
592 novm("option argument");
593 *(char **)(opt->addr) = sv;
597 case o_special_noarg:
599 parser = (int (*) __P((char **))) opt->addr;
600 if (!(*parser)(argv))
606 if (opt->flags & OPT_A2INFO) {
607 struct option_info *ip = (struct option_info *) opt->addr2;
608 ip->priv = privileged_option;
609 ip->source = option_source;
610 } else if ((opt->flags & (OPT_A2COPY|OPT_ENABLE)) == 0)
611 *(bool *)(opt->addr2) = 1;
618 * n_arguments - tell how many arguments an option takes
624 return (opt->type == o_bool || opt->type == o_special_noarg
625 || (opt->flags & OPT_NOARG))? 0: 1;
629 * usage - print out a message telling how to use the program.
634 if (phase == PHASE_INITIALIZE)
635 fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION,
640 * showhelp - print out usage message and exit.
646 if (phase == PHASE_INITIALIZE) {
654 * showversion - print out the version number and exit.
660 if (phase == PHASE_INITIALIZE) {
661 fprintf(stderr, "pppd version %s.%d%s\n",
662 VERSION, PATCHLEVEL, IMPLEMENTATION);
669 * option_error - print a message about an error in an option.
670 * The message is logged, and also sent to
671 * stderr if phase == PHASE_INITIALIZE.
674 option_error __V((char *fmt, ...))
684 fmt = va_arg(args, char *);
686 vfmtmsg(buf, sizeof(buf), fmt, args);
688 if (phase == PHASE_INITIALIZE)
689 fprintf(stderr, "%s: %s\n", progname, buf);
690 syslog(LOG_ERR, "%s", buf);
694 * readable - check if a file is readable by the real user.
703 GIDSET_TYPE groups[NGROUPS_MAX];
708 if (fstat(fd, &sbuf) != 0)
710 if (sbuf.st_uid == uid)
711 return sbuf.st_mode & S_IRUSR;
712 if (sbuf.st_gid == getgid())
713 return sbuf.st_mode & S_IRGRP;
714 ngroups = getgroups(NGROUPS_MAX, groups);
715 for (i = 0; i < ngroups; ++i)
716 if (sbuf.st_gid == groups[i])
717 return sbuf.st_mode & S_IRGRP;
718 return sbuf.st_mode & S_IROTH;
722 * Read a word from a file.
723 * Words are delimited by white-space or by quotes (" or ').
724 * Quotes, white-space and \ may be escaped with \.
725 * \<newline> is ignored.
728 getword(f, word, newlinep, filename)
736 int value, digit, got, n;
738 #define isoctal(c) ((c) >= '0' && (c) < '8')
746 * First skip white-space and comments.
754 * A newline means the end of a comment; backslash-newline
755 * is ignored. Note that we cannot have escape && comment.
767 * Ignore characters other than newline in a comment.
773 * If this character is escaped, we have a word start.
779 * If this is the escape character, look at the next character.
787 * If this is the start of a comment, ignore the rest of the line.
795 * A non-whitespace character is the start of a word.
802 * Save the delimiter for quoted strings.
804 if (!escape && (c == '"' || c == '\'')) {
811 * Process characters until the end of the word.
816 * This character is escaped: backslash-newline is ignored,
817 * various other characters indicate particular values
818 * as for C backslash-escapes.
853 * \ddd octal sequence
856 for (n = 0; n < 3 && isoctal(c); ++n) {
857 value = (value << 3) + (c & 07);
866 * \x<hex_string> sequence
870 for (n = 0; n < 2 && isxdigit(c); ++n) {
871 digit = toupper(c) - '0';
873 digit += '0' + 10 - 'A';
874 value = (value << 4) + digit;
882 * Otherwise the character stands for itself.
889 * Store the resulting character for the escape sequence.
891 if (len < MAXWORDLEN-1)
902 * Not escaped: see if we've reached the end of the word.
908 if (isspace(c) || c == '#') {
915 * Backslash starts an escape sequence.
924 * An ordinary character: store it in the word and get another.
926 if (len < MAXWORDLEN-1)
934 * End of the word: check for errors.
940 option_error("Error reading %s: %m", filename);
944 * If len is zero, then we didn't find a word before the
952 * Warn if the word was too long, and append a terminating null.
954 if (len >= MAXWORDLEN) {
955 option_error("warning: word in file %s too long (%.20s...)",
957 len = MAXWORDLEN - 1;
968 * number_option - parse an unsigned numeric parameter for an option.
971 number_option(str, valp, base)
978 *valp = strtoul(str, &ptr, base);
980 option_error("invalid numeric parameter '%s' for %s option",
981 str, current_option);
989 * int_option - like number_option, but valp is int *,
990 * the base is assumed to be 0, and *valp is not changed
991 * if there is an error.
994 int_option(str, valp)
1000 if (!number_option(str, &v, 0))
1008 * The following procedures parse options.
1012 * readfile - take commands from a file.
1018 return options_from_file(*argv, 1, 1, privileged_option);
1022 * callfile - take commands from /etc/ppp/peers/<name>.
1023 * Name may not contain /../, start with / or ../, or end in /..
1029 char *fname, *arg, *p;
1034 if (arg[0] == '/' || arg[0] == 0)
1037 for (p = arg; *p != 0; ) {
1038 if (p[0] == '.' && p[1] == '.' && (p[2] == '/' || p[2] == 0)) {
1042 while (*p != '/' && *p != 0)
1049 option_error("call option value may not contain .. or start with /");
1053 l = strlen(arg) + strlen(_PATH_PEERFILES) + 1;
1054 if ((fname = (char *) malloc(l)) == NULL)
1055 novm("call file name");
1056 strcpy(fname, _PATH_PEERFILES);
1059 ok = options_from_file(fname, 1, 1, 1);
1067 * setpdebug - Set libpcap debugging level.
1073 return int_option(*argv, &dflag);
1077 * setpassfilter - Set the pass filter for packets
1083 pc.linktype = DLT_PPP;
1084 pc.snapshot = PPP_HDRLEN;
1086 if (pcap_compile(&pc, &pass_filter, *argv, 1, netmask) == 0)
1088 option_error("error in pass-filter expression: %s\n", pcap_geterr(&pc));
1093 * setactivefilter - Set the active filter for packets
1096 setactivefilter(argv)
1099 pc.linktype = DLT_PPP;
1100 pc.snapshot = PPP_HDRLEN;
1102 if (pcap_compile(&pc, &active_filter, *argv, 1, netmask) == 0)
1104 option_error("error in active-filter expression: %s\n", pcap_geterr(&pc));
1110 * noopt - Disable all options.
1116 BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
1117 BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
1118 BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
1119 BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
1125 * setdomain - Set domain name to append to hostname
1131 if (!privileged_option) {
1132 option_error("using the domain option requires root privilege");
1135 gethostname(hostname, MAXNAMELEN);
1138 strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
1139 strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
1141 hostname[MAXNAMELEN-1] = 0;
1147 * setspeed - Set the speed.
1156 spd = strtol(arg, &ptr, 0);
1157 if (ptr == arg || *ptr != 0 || spd == 0)
1165 * setdevname - Set the device name.
1168 setdevname(cp, quiet)
1172 struct stat statbuf;
1173 char dev[MAXPATHLEN];
1178 if (strncmp("/dev/", cp, 5) != 0) {
1179 strcpy(dev, "/dev/");
1180 strncat(dev, cp, MAXPATHLEN - 5);
1181 dev[MAXPATHLEN-1] = 0;
1186 * Check if there is a device by this name.
1188 if (stat(cp, &statbuf) < 0) {
1189 if (errno == ENOENT || quiet)
1191 option_error("Couldn't stat %s: %m", cp);
1195 (void) strncpy(devnam, cp, MAXPATHLEN);
1196 devnam[MAXPATHLEN-1] = 0;
1197 default_device = FALSE;
1198 devnam_info.priv = privileged_option;
1199 devnam_info.source = option_source;
1206 * setipaddr - Set the IP address
1214 u_int32_t local, remote;
1215 ipcp_options *wo = &ipcp_wantoptions[0];
1218 * IP address pair separated by ":".
1220 if ((colon = strchr(arg, ':')) == NULL)
1224 * If colon first character, then no local addr.
1228 if ((local = inet_addr(arg)) == -1) {
1229 if ((hp = gethostbyname(arg)) == NULL) {
1230 option_error("unknown host: %s", arg);
1233 local = *(u_int32_t *)hp->h_addr;
1236 if (bad_ip_adrs(local)) {
1237 option_error("bad local IP address %s", ip_ntoa(local));
1241 wo->ouraddr = local;
1246 * If colon last character, then no remote addr.
1248 if (*++colon != '\0') {
1249 if ((remote = inet_addr(colon)) == -1) {
1250 if ((hp = gethostbyname(colon)) == NULL) {
1251 option_error("unknown host: %s", colon);
1254 remote = *(u_int32_t *)hp->h_addr;
1255 if (remote_name[0] == 0) {
1256 strncpy(remote_name, colon, MAXNAMELEN);
1257 remote_name[MAXNAMELEN-1] = 0;
1261 if (bad_ip_adrs(remote)) {
1262 option_error("bad remote IP address %s", ip_ntoa(remote));
1266 wo->hisaddr = remote;
1274 * setnetmask - set the netmask to be used on the interface.
1285 * Unfortunately, if we use inet_addr, we can't tell whether
1286 * a result of all 1s is an error or a valid 255.255.255.255.
1292 b = strtoul(p, &endp, 0);
1295 if (b < 0 || b > 255) {
1297 /* accept e.g. 0xffffff00 */
1303 mask |= b << (n * 8);
1305 if (*p != '.' || n == 0)
1312 if (*p != 0 || (netmask & ~mask) != 0) {
1313 option_error("invalid netmask value '%s'", *argv);
1325 lcp_wantoptions[0].asyncmap |= 0x000A0000; /* escape ^S and ^Q */
1326 lcp_wantoptions[0].neg_asyncmap = 1;