2 * options.c - handles option processing for PPP.
4 * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * 3. The name "Carnegie Mellon University" must not be used to
19 * endorse or promote products derived from this software without
20 * prior written permission. For permission or any legal
21 * details, please contact
22 * Office of Technology Transfer
23 * Carnegie Mellon University
25 * Pittsburgh, PA 15213-3890
26 * (412) 268-4387, fax: (412) 268-7395
27 * tech-transfer@andrew.cmu.edu
29 * 4. Redistributions of any form whatsoever must retain the following
31 * "This product includes software developed by Computing Services
32 * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
34 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
35 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
37 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
39 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
40 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
57 #include <sys/param.h>
59 #ifdef PPP_WITH_PLUGINS
63 #ifdef PPP_WITH_FILTER
66 * There have been 3 or 4 different names for this in libpcap CVS, but
67 * this seems to be what they have settled on...
68 * For older versions of libpcap, use DLT_PPP - but that means
69 * we lose the inbound and outbound qualifiers.
72 #ifdef DLT_PPP_WITHDIRECTION
73 #define DLT_PPP_PPPD DLT_PPP_WITHDIRECTION
75 #define DLT_PPP_PPPD DLT_PPP
78 #endif /* PPP_WITH_FILTER */
80 #include "pppd-private.h"
83 #include "pathnames.h"
85 #if defined(ultrix) || defined(NeXT)
91 struct option_value *next;
97 * Option variables and default values.
99 int debug = 0; /* Debug flag */
100 int kdebugflag = 0; /* Tell kernel to print debug messages */
101 int default_device = 1; /* Using /dev/tty or equivalent */
102 bool nodetach = 0; /* Don't detach from controlling tty */
103 bool updetach = 0; /* Detach once link is up */
104 bool master_detach; /* Detach when we're (only) multilink master */
106 bool up_sdnotify = 0; /* Notify systemd once link is up */
108 int maxconnect = 0; /* Maximum connect time */
109 char user[MAXNAMELEN]; /* Username for PAP */
110 char passwd[MAXSECRETLEN]; /* Password for PAP */
111 bool persist = 0; /* Reopen link after it goes down */
112 char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
113 bool demand = 0; /* do dial-on-demand */
114 int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
115 int holdoff = 30; /* # seconds to pause before reconnecting */
116 bool holdoff_specified; /* true if a holdoff value has been given */
117 int log_to_fd = 1; /* send log messages to this fd too */
118 bool log_default = 1; /* log_to_fd is default (stdout) */
119 int maxfail = 10; /* max # of unsuccessful connection attempts */
120 char linkname[MAXPATHLEN]; /* logical name for link */
121 bool tune_kernel; /* may alter kernel settings */
122 int connect_delay = 1000; /* wait this many ms after connect script */
123 int req_unit = -1; /* requested interface unit */
124 char path_net_init[MAXPATHLEN]; /* pathname of net-init script */
125 char path_net_preup[MAXPATHLEN];/* pathname of net-pre-up script */
126 char path_net_down[MAXPATHLEN]; /* pathname of net-down script */
127 char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
128 char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
129 char path_ippreup[MAXPATHLEN]; /* pathname of ip-pre-up script */
130 char req_ifname[IFNAMSIZ]; /* requested interface name */
131 bool multilink = 0; /* Enable multilink operation */
132 char *bundle_name = NULL; /* bundle name for multilink */
133 bool dump_options; /* print out option values */
134 bool show_options; /* print all supported options and exit */
135 bool dryrun; /* print out option values and exit */
136 char *domain; /* domain name set by domain option */
137 int child_wait = 5; /* # seconds to wait for children at exit */
138 struct userenv *userenv_list; /* user environment variables */
139 int dfl_route_metric = -1; /* metric of the default route to set over the PPP link */
141 #ifdef PPP_WITH_IPV6CP
142 char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
143 char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
146 unsigned int maxoctets = 0; /* default - no limit */
147 session_limit_dir_t maxoctets_dir = PPP_OCTETS_DIRECTION_SUM; /* default - sum of traffic */
148 int maxoctets_timeout = 1; /* default 1 second */
151 extern struct option auth_options[];
152 extern struct stat devstat;
154 #ifdef PPP_WITH_FILTER
155 struct bpf_program pass_filter;/* Filter program for packets to pass */
156 struct bpf_program active_filter; /* Filter program for link-active pkts */
159 static struct option *curopt; /* pointer to option being processed */
160 char *current_option; /* the name of the option being parsed */
161 int privileged_option; /* set iff the current option came from root */
162 char *option_source; /* string saying where the option came from */
163 int option_priority = OPRIO_CFGFILE; /* priority of the current options */
164 bool devnam_fixed; /* can no longer change device name */
166 static int logfile_fd = -1; /* fd opened for log file */
167 static char logfile_name[MAXPATHLEN]; /* name of log file */
169 static bool noipx_opt; /* dummy for noipx option */
174 static int setdomain(char **);
175 static int readfile(char **);
176 static int callfile(char **);
177 static int showversion(char **);
178 static int showhelp(char **);
179 static void usage(void);
180 static int setlogfile(char **);
181 #ifdef PPP_WITH_PLUGINS
182 static int loadplugin(char **);
185 #ifdef PPP_WITH_FILTER
186 static int setpassfilter(char **);
187 static int setactivefilter(char **);
190 static int setmodir(char **);
192 static int user_setenv(char **);
193 static void user_setprint(struct option *, printer_func, void *);
194 static int user_unsetenv(char **);
195 static void user_unsetprint(struct option *, printer_func, void *);
197 static struct option *find_option(char *name);
198 static int process_option(struct option *, char *, char **);
199 static int n_arguments(struct option *);
200 static int number_option(char *, u_int32_t *, int);
203 * Structure to store extra lists of options.
206 struct option *options;
207 struct option_list *next;
210 static struct option_list *extra_options = NULL;
215 struct option general_options[] = {
216 { "debug", o_int, &debug,
217 "Increase debugging level", OPT_INC | OPT_NOARG | 1 },
218 { "-d", o_int, &debug,
219 "Increase debugging level",
220 OPT_ALIAS | OPT_INC | OPT_NOARG | 1 },
222 { "kdebug", o_int, &kdebugflag,
223 "Set kernel driver debug level", OPT_PRIO },
225 { "nodetach", o_bool, &nodetach,
226 "Don't detach from controlling tty", OPT_PRIO | 1 },
227 { "-detach", o_bool, &nodetach,
228 "Don't detach from controlling tty", OPT_ALIAS | OPT_PRIOSUB | 1 },
230 { "up_sdnotify", o_bool, &up_sdnotify,
231 "Notify systemd once link is up (implies nodetach)",
232 OPT_PRIOSUB | OPT_A2COPY | 1, &nodetach },
234 { "updetach", o_bool, &updetach,
235 "Detach from controlling tty once link is up",
236 OPT_PRIOSUB | OPT_A2CLR | 1, &nodetach },
238 { "master_detach", o_bool, &master_detach,
239 "Detach when we're multilink master but have no link", 1 },
241 { "holdoff", o_int, &holdoff,
242 "Set time in seconds before retrying connection",
243 OPT_PRIO, &holdoff_specified },
245 { "idle", o_int, &idle_time_limit,
246 "Set time in seconds before disconnecting idle link", OPT_PRIO },
248 { "maxconnect", o_int, &maxconnect,
249 "Set connection time limit",
250 OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF },
252 { "domain", o_special, (void *)setdomain,
253 "Add given domain name to hostname",
254 OPT_PRIO | OPT_PRIV | OPT_A2STRVAL, &domain },
256 { "file", o_special, (void *)readfile,
257 "Take options from a file", OPT_NOPRINT },
258 { "call", o_special, (void *)callfile,
259 "Take options from a privileged file", OPT_NOPRINT },
261 { "persist", o_bool, &persist,
262 "Keep on reopening connection after close", OPT_PRIO | 1 },
263 { "nopersist", o_bool, &persist,
264 "Turn off persist option", OPT_PRIOSUB },
266 { "demand", o_bool, &demand,
267 "Dial on demand", OPT_INITONLY | 1, &persist },
269 { "--version", o_special_noarg, (void *)showversion,
270 "Show version number" },
271 { "-v", o_special_noarg, (void *)showversion,
272 "Show version number" },
273 { "show-options", o_bool, &show_options,
274 "Show all options and exit", 1 },
275 { "--help", o_special_noarg, (void *)showhelp,
276 "Show brief listing of options" },
277 { "-h", o_special_noarg, (void *)showhelp,
278 "Show brief listing of options", OPT_ALIAS },
280 { "logfile", o_special, (void *)setlogfile,
281 "Append log messages to this file",
282 OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, &logfile_name },
283 { "logfd", o_int, &log_to_fd,
284 "Send log messages to this file descriptor",
285 OPT_PRIOSUB | OPT_A2CLR, &log_default },
286 { "nolog", o_int, &log_to_fd,
287 "Don't send log messages to any file",
288 OPT_PRIOSUB | OPT_NOARG | OPT_VAL(-1) },
289 { "nologfd", o_int, &log_to_fd,
290 "Don't send log messages to any file descriptor",
291 OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
293 { "linkname", o_string, linkname,
294 "Set logical name for link",
295 OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN },
297 { "maxfail", o_int, &maxfail,
298 "Maximum number of unsuccessful connection attempts to allow",
301 { "ktune", o_bool, &tune_kernel,
302 "Alter kernel settings as necessary", OPT_PRIO | 1 },
303 { "noktune", o_bool, &tune_kernel,
304 "Don't alter kernel settings", OPT_PRIOSUB },
306 { "connect-delay", o_int, &connect_delay,
307 "Maximum time (in ms) to wait after connect script finishes",
310 { "unit", o_int, &req_unit,
311 "PPP interface unit number to use if possible",
312 OPT_PRIO | OPT_LLIMIT, 0, 0 },
314 { "ifname", o_string, req_ifname,
315 "Set PPP interface name",
316 OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
318 { "dump", o_bool, &dump_options,
319 "Print out option values after parsing all options", 1 },
320 { "dryrun", o_bool, &dryrun,
321 "Stop after parsing, printing, and checking options", 1 },
323 { "child-timeout", o_int, &child_wait,
324 "Number of seconds to wait for child processes at exit",
327 { "set", o_special, (void *)user_setenv,
328 "Set user environment variable",
329 OPT_A2PRINTER | OPT_NOPRINT, (void *)user_setprint },
330 { "unset", o_special, (void *)user_unsetenv,
331 "Unset user environment variable",
332 OPT_A2PRINTER | OPT_NOPRINT, (void *)user_unsetprint },
334 { "defaultroute-metric", o_int, &dfl_route_metric,
335 "Metric to use for the default route (Linux only; -1 for default behavior)",
336 OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 },
338 { "net-init-script", o_string, path_net_init,
339 "Set pathname of net-init script",
340 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
341 { "net-pre-up-script", o_string, path_net_preup,
342 "Set pathname of net-preup script",
343 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
344 { "net-down-script", o_string, path_net_down,
345 "Set pathname of net-down script",
346 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
348 { "ip-up-script", o_string, path_ipup,
349 "Set pathname of ip-up script",
350 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
351 { "ip-down-script", o_string, path_ipdown,
352 "Set pathname of ip-down script",
353 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
354 { "ip-pre-up-script", o_string, path_ippreup,
355 "Set pathname of ip-pre-up script",
356 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
358 #ifdef PPP_WITH_IPV6CP
359 { "ipv6-up-script", o_string, path_ipv6up,
360 "Set pathname of ipv6-up script",
361 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
362 { "ipv6-down-script", o_string, path_ipv6down,
363 "Set pathname of ipv6-down script",
364 OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
367 #ifdef PPP_WITH_MULTILINK
368 { "multilink", o_bool, &multilink,
369 "Enable multilink operation", OPT_PRIO | 1 },
370 { "mp", o_bool, &multilink,
371 "Enable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 1 },
372 { "nomultilink", o_bool, &multilink,
373 "Disable multilink operation", OPT_PRIOSUB | 0 },
374 { "nomp", o_bool, &multilink,
375 "Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 },
377 { "bundle", o_string, &bundle_name,
378 "Bundle name for multilink", OPT_PRIO },
379 #endif /* PPP_WITH_MULTILINK */
381 #ifdef PPP_WITH_PLUGINS
382 { "plugin", o_special, (void *)loadplugin,
383 "Load a plug-in module into pppd", OPT_PRIV | OPT_A2LIST },
386 #ifdef PPP_WITH_FILTER
387 { "pass-filter", o_special, setpassfilter,
388 "set filter for packets to pass", OPT_PRIO },
390 { "active-filter", o_special, setactivefilter,
391 "set filter for active pkts", OPT_PRIO },
394 { "maxoctets", o_int, &maxoctets,
395 "Set connection traffic limit",
396 OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF },
397 { "mo", o_int, &maxoctets,
398 "Set connection traffic limit",
399 OPT_ALIAS | OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF },
400 { "mo-direction", o_special, setmodir,
401 "Set direction for limit traffic (sum,in,out,max)" },
402 { "mo-timeout", o_int, &maxoctets_timeout,
403 "Check for traffic limit every N seconds", OPT_PRIO | OPT_LLIMIT | 1 },
405 /* Dummy option, does nothing */
406 { "noipx", o_bool, &noipx_opt, NULL, OPT_NOPRINT | 1 },
411 #ifndef IMPLEMENTATION
412 #define IMPLEMENTATION ""
416 ppp_get_max_idle_time()
418 return idle_time_limit;
422 ppp_set_max_idle_time(unsigned int max)
424 idle_time_limit = max;
428 ppp_get_max_connect_time()
434 ppp_set_max_connect_time(unsigned int max)
440 ppp_set_session_limit(unsigned int octets)
446 ppp_set_session_limit_dir(unsigned int dir)
449 dir = PPP_OCTETS_DIRECTION_SUM;
450 maxoctets_dir = (session_limit_dir_t) dir;
460 ppp_get_path(ppp_path_t type, char *buf, size_t bufsz)
464 if (buf && bufsz > 0) {
467 path = PPP_PATH_VARLOG;
469 case PPP_DIR_RUNTIME:
470 path = PPP_PATH_VARRUN;
472 #ifdef PPP_WITH_PLUGINS
474 path = PPP_PATH_PLUGIN;
478 path = PPP_PATH_CONFDIR;
481 return strlcpy(buf, path, bufsz);
487 ppp_get_filepath(ppp_path_t type, const char *name, char *buf, size_t bufsz)
491 if (buf && bufsz > 0) {
494 path = PPP_PATH_VARLOG;
496 case PPP_DIR_RUNTIME:
497 path = PPP_PATH_VARRUN;
499 #ifdef PPP_WITH_PLUGINS
501 path = PPP_PATH_PLUGIN;
505 path = PPP_PATH_CONFDIR;
508 return slprintf(buf, bufsz, "%s/%s", path, name);
519 * parse_args - parse a string of arguments from the command line.
522 parse_args(int argc, char **argv)
528 privileged_option = privileged;
529 option_source = "command line";
530 option_priority = OPRIO_CMDLINE;
534 opt = find_option(arg);
536 ppp_option_error("unrecognized option '%s'", arg);
540 n = n_arguments(opt);
542 ppp_option_error("too few parameters for option %s", arg);
545 if (!process_option(opt, arg, argv))
554 * options_from_file - Read a string of options from a file,
555 * and interpret them.
558 ppp_options_from_file(char *filename, int must_exist, int check_prot, int priv)
561 int i, newline, ret, err;
567 char args[MAXARGS][MAXWORDLEN];
568 char cmd[MAXWORDLEN];
571 if (check_prot && seteuid(getuid()) == -1) {
572 ppp_option_error("unable to drop privileges to open %s: %m", filename);
575 f = fopen(filename, "r");
577 if (check_prot && seteuid(euid) == -1)
578 fatal("unable to regain privileges");
582 if (err != ENOENT && err != ENOTDIR)
583 warn("Warning: can't open options file %s: %m", filename);
586 ppp_option_error("Can't open options file %s: %m", filename);
590 oldpriv = privileged_option;
591 privileged_option = priv;
592 oldsource = option_source;
593 option_source = strdup(filename);
594 if (option_source == NULL)
595 option_source = "file";
597 while (getword(f, cmd, &newline, filename)) {
598 opt = find_option(cmd);
600 ppp_option_error("In file %s: unrecognized option '%s'",
604 n = n_arguments(opt);
605 for (i = 0; i < n; ++i) {
606 if (!getword(f, args[i], &newline, filename)) {
608 "In file %s: too few parameters for option '%s'",
614 if (!process_option(opt, cmd, argv))
622 privileged_option = oldpriv;
623 option_source = oldsource;
628 * options_from_user - See if the use has a ~/.ppprc file,
629 * and if so, interpret options from it.
632 options_from_user(void)
634 char *user, *path, *file;
639 pw = getpwuid(getuid());
640 if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
642 file = PPP_PATH_USEROPT;
643 pl = strlen(user) + strlen(file) + 2;
646 novm("init file name");
647 slprintf(path, pl, "%s/%s", user, file);
648 option_priority = OPRIO_CFGFILE;
649 ret = ppp_options_from_file(path, 0, 1, privileged);
655 * options_for_tty - See if an options file exists for the serial
656 * device, and if so, interpret options from it.
657 * We only allow the per-tty options file to override anything from
658 * the command line if it is something that the user can't override
659 * once it has been set by root; this is done by giving configuration
660 * files a lower priority than the command line.
663 options_for_tty(void)
665 char *dev, *path, *p;
670 if ((p = strstr(dev, "/dev/")) != NULL)
672 if (dev[0] == 0 || strcmp(dev, "tty") == 0)
673 return 1; /* don't look for /etc/ppp/options.tty */
674 pl = strlen(PPP_PATH_TTYOPT) + strlen(dev) + 1;
677 novm("tty init file name");
678 slprintf(path, pl, "%s%s", PPP_PATH_TTYOPT, dev);
679 /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */
680 for (p = path + strlen(PPP_PATH_TTYOPT); *p != 0; ++p)
683 option_priority = OPRIO_CFGFILE;
684 ret = ppp_options_from_file(path, 0, 0, 1);
690 * options_from_list - process a string of options in a wordlist.
693 options_from_list(struct wordlist *w, int priv)
700 privileged_option = priv;
701 option_source = "secrets file";
702 option_priority = OPRIO_SECFILE;
705 opt = find_option(w->word);
707 ppp_option_error("In secrets file: unrecognized option '%s'",
711 n = n_arguments(opt);
713 for (i = 0; i < n; ++i) {
717 "In secrets file: too few parameters for option '%s'",
723 if (!process_option(opt, w0->word, argv))
734 * match_option - see if this option matches an option structure.
737 match_option(char *name, struct option *opt, int dowild)
739 int (*match)(char *, char **, int);
741 if (dowild != (opt->type == o_wild))
744 return strcmp(name, opt->name) == 0;
745 match = (int (*)(char *, char **, int)) opt->addr;
746 return (*match)(name, NULL, 0);
750 * find_option - scan the option lists for the various protocols
751 * looking for an entry with the given name.
752 * This could be optimized by using a hash table.
754 static struct option *
755 find_option(char *name)
758 struct option_list *list;
761 for (dowild = 0; dowild <= 1; ++dowild) {
762 for (opt = general_options; opt->name != NULL; ++opt)
763 if (match_option(name, opt, dowild))
765 for (opt = auth_options; opt->name != NULL; ++opt)
766 if (match_option(name, opt, dowild))
768 for (list = extra_options; list != NULL; list = list->next)
769 for (opt = list->options; opt->name != NULL; ++opt)
770 if (match_option(name, opt, dowild))
772 for (opt = the_channel->options; opt->name != NULL; ++opt)
773 if (match_option(name, opt, dowild))
775 for (i = 0; protocols[i] != NULL; ++i)
776 if ((opt = protocols[i]->options) != NULL)
777 for (; opt->name != NULL; ++opt)
778 if (match_option(name, opt, dowild))
785 * process_option - process one new-style option.
788 process_option(struct option *opt, char *cmd, char **argv)
793 int (*parser)(char **);
794 int (*wildp)(char *, char **, int);
795 char *optopt = (opt->type == o_wild)? "": " option";
796 int prio = option_priority;
797 struct option *mainopt = opt;
799 current_option = opt->name;
800 if ((opt->flags & OPT_PRIVFIX) && privileged_option)
802 while (mainopt->flags & OPT_PRIOSUB)
804 if (mainopt->flags & OPT_PRIO) {
805 if (prio < mainopt->priority) {
806 /* new value doesn't override old */
807 if (prio == OPRIO_CMDLINE && mainopt->priority > OPRIO_ROOT) {
808 ppp_option_error("%s%s set in %s cannot be overridden\n",
809 opt->name, optopt, mainopt->source);
814 if (prio > OPRIO_ROOT && mainopt->priority == OPRIO_CMDLINE)
815 warn("%s%s from %s overrides command line",
816 opt->name, optopt, option_source);
819 if ((opt->flags & OPT_INITONLY) && !in_phase(PHASE_INITIALIZE)) {
820 ppp_option_error("%s%s cannot be changed after initialization",
824 if ((opt->flags & OPT_PRIV) && !privileged_option) {
825 ppp_option_error("using the %s%s requires root privilege",
829 if ((opt->flags & OPT_ENABLE) && *(bool *)(opt->addr2) == 0) {
830 ppp_option_error("%s%s is disabled", opt->name, optopt);
833 if ((opt->flags & OPT_DEVEQUIV) && devnam_fixed) {
834 ppp_option_error("the %s%s may not be changed in %s",
835 opt->name, optopt, option_source);
841 v = opt->flags & OPT_VALUE;
842 *(bool *)(opt->addr) = v;
843 if (opt->addr2 && (opt->flags & OPT_A2COPY))
844 *(bool *)(opt->addr2) = v;
845 else if (opt->addr2 && (opt->flags & OPT_A2CLR))
846 *(bool *)(opt->addr2) = 0;
847 else if (opt->addr2 && (opt->flags & OPT_A2CLRB))
848 *(u_char *)(opt->addr2) &= ~v;
849 else if (opt->addr2 && (opt->flags & OPT_A2OR))
850 *(u_char *)(opt->addr2) |= v;
855 if ((opt->flags & OPT_NOARG) == 0) {
856 if (!ppp_int_option(*argv, &iv))
858 if ((((opt->flags & OPT_LLIMIT) && iv < opt->lower_limit)
859 || ((opt->flags & OPT_ULIMIT) && iv > opt->upper_limit))
860 && !((opt->flags & OPT_ZEROOK && iv == 0))) {
861 char *zok = (opt->flags & OPT_ZEROOK)? " zero or": "";
862 switch (opt->flags & OPT_LIMITS) {
864 ppp_option_error("%s value must be%s >= %d",
865 opt->name, zok, opt->lower_limit);
868 ppp_option_error("%s value must be%s <= %d",
869 opt->name, zok, opt->upper_limit);
872 ppp_option_error("%s value must be%s between %d and %d",
873 opt->name, zok, opt->lower_limit, opt->upper_limit);
879 a = opt->flags & OPT_VALUE;
881 a -= 256; /* sign extend */
883 if (opt->flags & OPT_INC)
884 iv += *(int *)(opt->addr);
885 if ((opt->flags & OPT_NOINCR) && !privileged_option) {
886 int oldv = *(int *)(opt->addr);
887 if ((opt->flags & OPT_ZEROINF) ?
888 (oldv != 0 && (iv == 0 || iv > oldv)) : (iv > oldv)) {
889 ppp_option_error("%s value cannot be increased", opt->name);
893 *(int *)(opt->addr) = iv;
894 if (opt->addr2 && (opt->flags & OPT_A2COPY))
895 *(int *)(opt->addr2) = iv;
899 if (opt->flags & OPT_NOARG) {
900 v = opt->flags & OPT_VALUE;
903 } else if (!number_option(*argv, &v, 16))
905 if (opt->flags & OPT_OR)
906 v |= *(u_int32_t *)(opt->addr);
907 *(u_int32_t *)(opt->addr) = v;
908 if (opt->addr2 && (opt->flags & OPT_A2COPY))
909 *(u_int32_t *)(opt->addr2) = v;
913 if (opt->flags & OPT_STATIC) {
914 strlcpy((char *)(opt->addr), *argv, opt->upper_limit);
916 char **optptr = (char **)(opt->addr);
919 novm("option argument");
924 /* obfuscate original argument for things like password */
925 if (opt->flags & OPT_HIDE) {
926 memset(*argv, '?', strlen(*argv));
931 case o_special_noarg:
933 parser = (int (*)(char **)) opt->addr;
935 if (!(*parser)(argv))
937 if (opt->flags & OPT_A2LIST) {
938 struct option_value *ovp, *pp;
940 ovp = malloc(sizeof(*ovp) + strlen(*argv));
942 strcpy(ovp->value, *argv);
943 ovp->source = option_source;
945 if (opt->addr2 == NULL) {
948 for (pp = opt->addr2; pp->next != NULL; pp = pp->next)
957 wildp = (int (*)(char *, char **, int)) opt->addr;
958 if (!(*wildp)(cmd, argv, 1))
964 * If addr2 wasn't used by any flag (OPT_A2COPY, etc.) but is set,
965 * treat it as a bool and set/clear it based on the OPT_A2CLR bit.
967 if (opt->addr2 && (opt->flags & (OPT_A2COPY|OPT_ENABLE
968 |OPT_A2PRINTER|OPT_A2STRVAL|OPT_A2LIST|OPT_A2OR)) == 0)
969 *(bool *)(opt->addr2) = !(opt->flags & OPT_A2CLR);
971 mainopt->source = option_source;
972 mainopt->priority = prio;
973 mainopt->winner = opt - mainopt;
979 * override_value - if the option priorities would permit us to
980 * override the value of option, return 1 and update the priority
981 * and source of the option value. Otherwise returns 0.
984 override_value(char *option, int priority, const char *source)
988 opt = find_option(option);
991 while (opt->flags & OPT_PRIOSUB)
993 if ((opt->flags & OPT_PRIO) && priority < opt->priority)
995 opt->priority = priority;
996 opt->source = source;
1002 * n_arguments - tell how many arguments an option takes
1005 n_arguments(struct option *opt)
1007 return (opt->type == o_bool || opt->type == o_special_noarg
1008 || (opt->flags & OPT_NOARG))? 0: 1;
1012 * add_options - add a list of options to the set we grok.
1015 ppp_add_options(struct option *opt)
1017 struct option_list *list;
1019 list = malloc(sizeof(*list));
1021 novm("option list entry");
1022 list->options = opt;
1023 list->next = extra_options;
1024 extra_options = list;
1028 * check_options - check that options are valid and consistent.
1033 if (logfile_fd >= 0 && logfile_fd != log_to_fd)
1038 * print_option - print out an option and its value
1041 print_option(struct option *opt, struct option *mainopt, printer_func printer, void *arg)
1046 if (opt->flags & OPT_NOPRINT)
1048 switch (opt->type) {
1050 v = opt->flags & OPT_VALUE;
1051 if (*(bool *)opt->addr != v)
1052 /* this can happen legitimately, e.g. lock
1053 option turned off for default device */
1055 printer(arg, "%s", opt->name);
1058 v = opt->flags & OPT_VALUE;
1061 i = *(int *)opt->addr;
1062 if (opt->flags & OPT_NOARG) {
1063 printer(arg, "%s", opt->name);
1065 if (opt->flags & OPT_INC) {
1066 for (; i > v; i -= v)
1067 printer(arg, " %s", opt->name);
1069 printer(arg, " # oops: %d not %d\n",
1073 printer(arg, "%s %d", opt->name, i);
1077 printer(arg, "%s", opt->name);
1078 if ((opt->flags & OPT_NOARG) == 0)
1079 printer(arg, " %x", *(u_int32_t *)opt->addr);
1083 if (opt->flags & OPT_HIDE) {
1086 p = (char *) opt->addr;
1087 if ((opt->flags & OPT_STATIC) == 0)
1090 printer(arg, "%s %q", opt->name, p);
1094 case o_special_noarg:
1096 if (opt->type != o_wild) {
1097 printer(arg, "%s", opt->name);
1098 if (n_arguments(opt) == 0)
1102 if (opt->flags & OPT_A2PRINTER) {
1103 void (*oprt)(struct option *, printer_func, void *);
1104 oprt = (void (*)(struct option *, printer_func, void *))
1106 (*oprt)(opt, printer, arg);
1107 } else if (opt->flags & OPT_A2STRVAL) {
1108 p = (char *) opt->addr2;
1109 if ((opt->flags & OPT_STATIC) == 0)
1111 printer(arg, "%q", p);
1112 } else if (opt->flags & OPT_A2LIST) {
1113 struct option_value *ovp;
1115 ovp = (struct option_value *) opt->addr2;
1117 printer(arg, "%q", ovp->value);
1118 if ((ovp = ovp->next) == NULL)
1120 printer(arg, "\t\t# (from %s)\n%s ",
1121 ovp->source, opt->name);
1124 printer(arg, "xxx # [don't know how to print value]");
1129 printer(arg, "# %s value (type %d\?\?)", opt->name, opt->type);
1132 printer(arg, "\t\t# (from %s)\n", mainopt->source);
1136 * print_option_list - print out options in effect from an
1140 print_option_list(struct option *opt, printer_func printer, void *arg)
1142 while (opt->name != NULL) {
1143 if (opt->priority != OPRIO_DEFAULT
1144 && opt->winner != (short int) -1)
1145 print_option(opt + opt->winner, opt, printer, arg);
1148 } while (opt->flags & OPT_PRIOSUB);
1153 * print_options - print out what options are in effect.
1156 print_options(printer_func printer, void *arg)
1158 struct option_list *list;
1161 printer(arg, "pppd options in effect:\n");
1162 print_option_list(general_options, printer, arg);
1163 print_option_list(auth_options, printer, arg);
1164 for (list = extra_options; list != NULL; list = list->next)
1165 print_option_list(list->options, printer, arg);
1166 print_option_list(the_channel->options, printer, arg);
1167 for (i = 0; protocols[i] != NULL; ++i)
1168 print_option_list(protocols[i]->options, printer, arg);
1172 * usage - print out a message telling how to use the program.
1178 if (in_phase(PHASE_INITIALIZE)) {
1179 fprintf(fp, "%s v%s\n", PACKAGE_NAME, PACKAGE_VERSION);
1180 fprintf(fp, "Copyright (C) 1999-2024 Paul Mackerras, and others. All rights reserved.\n\n");
1183 fprintf(fp, "License BSD: The 3 clause BSD license <https://opensource.org/licenses/BSD-3-Clause>\n");
1184 fprintf(fp, "This is free software: you are free to change and redistribute it.\n");
1185 fprintf(fp, "There is NO WARRANTY, to the extent permitted by law.\n\n");
1187 fprintf(fp, "Report Bugs:\n %s\n\n", PACKAGE_BUGREPORT);
1188 fprintf(fp, "Usage: %s [ options ], where options are:\n", progname);
1189 fprintf(fp, " <device> Communicate over the named device\n");
1190 fprintf(fp, " <speed> Set the baud rate to <speed>\n");
1191 fprintf(fp, " <loc>:<rem> Set the local and/or remote interface IP\n");
1192 fprintf(fp, " addresses. Either one may be omitted.\n");
1193 fprintf(fp, " asyncmap <n> Set the desired async map to hex <n>\n");
1194 fprintf(fp, " auth Require authentication from peer\n");
1195 fprintf(fp, " connect <p> Invoke shell command <p> to set up the serial line\n");
1196 fprintf(fp, " crtscts Use hardware RTS/CTS flow control\n");
1197 fprintf(fp, " defaultroute Add default route through interface\n");
1198 fprintf(fp, " file <f> Take options from file <f>\n");
1199 fprintf(fp, " modem Use modem control lines\n");
1200 fprintf(fp, " mru <n> Set MRU value to <n> for negotiation\n");
1201 fprintf(fp, " show-options Display an extended list of options\n");
1202 fprintf(fp, "See pppd(8) for more options.\n");
1207 * showhelp - print out usage message and exit.
1210 showhelp(char **argv)
1212 if (in_phase(PHASE_INITIALIZE)) {
1220 * showversion - print out the version number and exit.
1223 showversion(char **argv)
1225 if (in_phase(PHASE_INITIALIZE)) {
1226 fprintf(stdout, "pppd version %s\n", VERSION);
1233 * Print a set of options including the name of the group of options
1236 showopts_list(FILE *fp, const char *title, struct option *list, ...)
1238 struct option *opt = list;
1241 if (opt && opt->name) {
1242 va_start(varg, list);
1243 vfprintf(fp, title, varg);
1248 fprintf(fp, " %-22s %s\n", opt->name, opt->description?:"");
1250 } while (opt && opt->name);
1257 * Dumps the list of available options
1262 struct option_list *list;
1266 showopts_list(fp, "General Options",
1269 showopts_list(fp, "Authentication Options",
1272 for (list = extra_options; list != NULL; list = list->next)
1273 showopts_list(fp, "Extra Options", list->options);
1275 showopts_list(fp, "Channel Options",
1276 the_channel->options);
1278 for (i = 0; protocols[i] != NULL; ++i) {
1279 if (protocols[i]->options != NULL) {
1280 showopts_list(fp, "%s Options",
1281 protocols[i]->options,
1282 protocols[i]->name);
1288 * ppp_option_error - print a message about an error in an option.
1289 * The message is logged, and also sent to
1290 * stderr if in_phase(PHASE_INITIALIZE).
1293 ppp_option_error(char *fmt, ...)
1298 va_start(args, fmt);
1299 vslprintf(buf, sizeof(buf), fmt, args);
1301 if (in_phase(PHASE_INITIALIZE))
1302 fprintf(stderr, "%s: %s\n", progname, buf);
1303 syslog(LOG_ERR, "%s", buf);
1308 * readable - check if a file is readable by the real user.
1320 if (fstat(fd, &sbuf) != 0)
1322 if (sbuf.st_uid == uid)
1323 return sbuf.st_mode & S_IRUSR;
1324 if (sbuf.st_gid == getgid())
1325 return sbuf.st_mode & S_IRGRP;
1326 for (i = 0; i < ngroups; ++i)
1327 if (sbuf.st_gid == groups[i])
1328 return sbuf.st_mode & S_IRGRP;
1329 return sbuf.st_mode & S_IROTH;
1334 * Read a word from a file.
1335 * Words are delimited by white-space or by quotes (" or ').
1336 * Quotes, white-space and \ may be escaped with \.
1337 * \<newline> is ignored.
1340 getword(FILE *f, char *word, int *newlinep, char *filename)
1343 int quoted, comment;
1344 int value, digit, got, n;
1346 #define isoctal(c) ((c) >= '0' && (c) < '8')
1355 * First skip white-space and comments.
1363 * A newline means the end of a comment; backslash-newline
1364 * is ignored. Note that we cannot have escape && comment.
1376 * Ignore characters other than newline in a comment.
1382 * If this character is escaped, we have a word start.
1388 * If this is the escape character, look at the next character.
1396 * If this is the start of a comment, ignore the rest of the line.
1404 * A non-whitespace character is the start of a word.
1411 * Process characters until the end of the word.
1416 * This character is escaped: backslash-newline is ignored,
1417 * various other characters indicate particular values
1418 * as for C backslash-escapes.
1453 * \ddd octal sequence
1456 for (n = 0; n < 3 && isoctal(c); ++n) {
1457 value = (value << 3) + (c & 07);
1466 * \x<hex_string> sequence
1470 for (n = 0; n < 2 && isxdigit(c); ++n) {
1471 digit = toupper(c) - '0';
1473 digit += '0' + 10 - 'A';
1474 value = (value << 4) + digit;
1482 * Otherwise the character stands for itself.
1489 * Store the resulting character for the escape sequence.
1491 if (len < MAXWORDLEN) {
1502 * Backslash starts a new escape sequence.
1511 * Not escaped: check for the start or end of a quoted
1512 * section and see if we've reached the end of the word.
1520 } else if (c == '"' || c == '\'') {
1524 } else if (isspace(c) || c == '#') {
1530 * An ordinary character: store it in the word and get another.
1532 if (len < MAXWORDLEN) {
1539 word[MAXWORDLEN-1] = 0; /* make sure word is null-terminated */
1542 * End of the word: check for errors.
1548 ppp_option_error("Error reading %s: %m", filename);
1552 * If len is zero, then we didn't find a word before the
1558 ppp_option_error("warning: quoted word runs to end of file (%.20s...)",
1563 * Warn if the word was too long, and append a terminating null.
1565 if (len >= MAXWORDLEN) {
1566 ppp_option_error("warning: word in file %s too long (%.20s...)",
1568 len = MAXWORDLEN - 1;
1579 * number_option - parse an unsigned numeric parameter for an option.
1582 number_option(char *str, u_int32_t *valp, int base)
1586 *valp = strtoul(str, &ptr, base);
1588 ppp_option_error("invalid numeric parameter '%s' for %s option",
1589 str, current_option);
1597 * int_option - like number_option, but valp is int *,
1598 * the base is assumed to be 0, and *valp is not changed
1599 * if there is an error.
1602 ppp_int_option(char *str, int *valp)
1606 if (!number_option(str, &v, 0))
1614 * The following procedures parse options.
1618 * readfile - take commands from a file.
1621 readfile(char **argv)
1623 return ppp_options_from_file(*argv, 1, 1, privileged_option);
1627 * callfile - take commands from /etc/ppp/peers/<name>.
1628 * Name may not contain /../, start with / or ../, or end in /..
1631 callfile(char **argv)
1633 char *fname, *arg, *p;
1638 if (arg[0] == '/' || arg[0] == 0)
1641 for (p = arg; *p != 0; ) {
1642 if (p[0] == '.' && p[1] == '.' && (p[2] == '/' || p[2] == 0)) {
1646 while (*p != '/' && *p != 0)
1653 ppp_option_error("call option value may not contain .. or start with /");
1657 l = strlen(arg) + strlen(PPP_PATH_PEERFILES) + 1;
1658 if ((fname = (char *) malloc(l)) == NULL)
1659 novm("call file name");
1660 slprintf(fname, l, "%s%s", PPP_PATH_PEERFILES, arg);
1661 ppp_script_setenv("CALL_FILE", arg, 0);
1663 ok = ppp_options_from_file(fname, 1, 1, 1);
1669 #ifdef PPP_WITH_FILTER
1671 * setpassfilter - Set the pass filter for packets
1674 setpassfilter(char **argv)
1679 pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
1680 if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == -1) {
1681 ppp_option_error("error in pass-filter expression: %s\n",
1691 * setactivefilter - Set the active filter for packets
1694 setactivefilter(char **argv)
1699 pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
1700 if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == -1) {
1701 ppp_option_error("error in active-filter expression: %s\n",
1712 * setdomain - Set domain name to append to hostname
1715 setdomain(char **argv)
1717 gethostname(hostname, MAXNAMELEN);
1720 strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
1721 domain = hostname + strlen(hostname);
1722 strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
1724 hostname[MAXNAMELEN-1] = 0;
1729 setlogfile(char **argv)
1735 if (!privileged_option && seteuid(getuid()) == -1) {
1736 ppp_option_error("unable to drop permissions to open %s: %m", *argv);
1739 fd = open(*argv, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0644);
1740 if (fd < 0 && errno == EEXIST)
1741 fd = open(*argv, O_WRONLY | O_APPEND);
1743 if (!privileged_option && seteuid(euid) == -1)
1744 fatal("unable to regain privileges: %m");
1747 ppp_option_error("Can't open log file %s: %m", *argv);
1750 strlcpy(logfile_name, *argv, sizeof(logfile_name));
1751 if (logfile_fd >= 0)
1760 setmodir(char **argv)
1764 if(!strcmp(*argv,"in")) {
1765 maxoctets_dir = PPP_OCTETS_DIRECTION_IN;
1766 } else if (!strcmp(*argv,"out")) {
1767 maxoctets_dir = PPP_OCTETS_DIRECTION_OUT;
1768 } else if (!strcmp(*argv,"max")) {
1769 maxoctets_dir = PPP_OCTETS_DIRECTION_MAXOVERAL;
1771 maxoctets_dir = PPP_OCTETS_DIRECTION_SUM;
1776 #ifdef PPP_WITH_PLUGINS
1778 loadplugin(char **argv)
1787 if (strchr(arg, '/') == 0) {
1788 const char *base = PPP_PATH_PLUGIN;
1789 int l = strlen(base) + strlen(arg) + 2;
1792 novm("plugin file path");
1793 strlcpy(path, base, l);
1794 strlcat(path, "/", l);
1795 strlcat(path, arg, l);
1797 handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW);
1801 ppp_option_error("%s", err);
1802 ppp_option_error("Couldn't load plugin %s", arg);
1805 init = (void (*)(void))dlsym(handle, "plugin_init");
1807 ppp_option_error("%s has no initialization entry point", arg);
1810 vers = (const char *) dlsym(handle, "pppd_version");
1812 warn("Warning: plugin %s has no version information", arg);
1813 } else if (strcmp(vers, VERSION) != 0) {
1814 ppp_option_error("Plugin %s is for pppd version %s, this is %s",
1815 arg, vers, VERSION);
1818 info("Plugin %s loaded.", arg);
1831 #endif /* PPP_WITH_PLUGINS */
1834 * Set an environment variable specified by the user.
1837 user_setenv(char **argv)
1839 char *arg = argv[0];
1841 struct userenv *uep, **insp;
1843 if ((eqp = strchr(arg, '=')) == NULL) {
1844 ppp_option_error("missing = in name=value: %s", arg);
1848 ppp_option_error("missing variable name: %s", arg);
1851 for (uep = userenv_list; uep != NULL; uep = uep->ue_next) {
1852 int nlen = strlen(uep->ue_name);
1853 if (nlen == (eqp - arg) &&
1854 strncmp(arg, uep->ue_name, nlen) == 0)
1857 /* Ignore attempts by unprivileged users to override privileged sources */
1858 if (uep != NULL && !privileged_option && uep->ue_priv)
1860 /* The name never changes, so allocate it with the structure */
1862 uep = malloc(sizeof (*uep) + (eqp-arg));
1864 novm("environment variable");
1867 strncpy(uep->ue_name, arg, eqp-arg);
1868 uep->ue_name[eqp-arg] = '\0';
1869 uep->ue_next = NULL;
1870 insp = &userenv_list;
1871 while (*insp != NULL)
1872 insp = &(*insp)->ue_next;
1875 struct userenv *uep2;
1876 for (uep2 = userenv_list; uep2 != NULL; uep2 = uep2->ue_next) {
1877 if (uep2 != uep && !uep2->ue_isset)
1880 if (uep2 == NULL && !uep->ue_isset)
1881 find_option("unset")->flags |= OPT_NOPRINT;
1882 free(uep->ue_value);
1885 uep->ue_priv = privileged_option;
1886 uep->ue_source = option_source;
1887 uep->ue_value = strdup(eqp + 1);
1888 curopt->flags &= ~OPT_NOPRINT;
1893 user_setprint(struct option *opt, printer_func printer, void *arg)
1895 struct userenv *uep, *uepnext;
1897 uepnext = userenv_list;
1898 while (uepnext != NULL && !uepnext->ue_isset)
1899 uepnext = uepnext->ue_next;
1900 while ((uep = uepnext) != NULL) {
1901 uepnext = uep->ue_next;
1902 while (uepnext != NULL && !uepnext->ue_isset)
1903 uepnext = uepnext->ue_next;
1904 (*printer)(arg, "%s=%s", uep->ue_name, uep->ue_value);
1905 if (uepnext != NULL)
1906 (*printer)(arg, "\t\t# (from %s)\n%s ", uep->ue_source, opt->name);
1908 opt->source = uep->ue_source;
1913 user_unsetenv(char **argv)
1915 struct userenv *uep, **insp;
1916 char *arg = argv[0];
1918 if (strchr(arg, '=') != NULL) {
1919 ppp_option_error("unexpected = in name: %s", arg);
1923 ppp_option_error("missing variable name for unset");
1926 for (uep = userenv_list; uep != NULL; uep = uep->ue_next) {
1927 if (strcmp(arg, uep->ue_name) == 0)
1930 /* Ignore attempts by unprivileged users to override privileged sources */
1931 if (uep != NULL && !privileged_option && uep->ue_priv)
1933 /* The name never changes, so allocate it with the structure */
1935 uep = malloc(sizeof (*uep) + strlen(arg));
1937 novm("environment variable");
1940 strcpy(uep->ue_name, arg);
1941 uep->ue_next = NULL;
1942 insp = &userenv_list;
1943 while (*insp != NULL)
1944 insp = &(*insp)->ue_next;
1947 struct userenv *uep2;
1948 for (uep2 = userenv_list; uep2 != NULL; uep2 = uep2->ue_next) {
1949 if (uep2 != uep && uep2->ue_isset)
1952 if (uep2 == NULL && uep->ue_isset)
1953 find_option("set")->flags |= OPT_NOPRINT;
1954 free(uep->ue_value);
1957 uep->ue_priv = privileged_option;
1958 uep->ue_source = option_source;
1959 uep->ue_value = NULL;
1960 curopt->flags &= ~OPT_NOPRINT;
1965 user_unsetprint(struct option *opt, printer_func printer, void *arg)
1967 struct userenv *uep, *uepnext;
1969 uepnext = userenv_list;
1970 while (uepnext != NULL && uepnext->ue_isset)
1971 uepnext = uepnext->ue_next;
1972 while ((uep = uepnext) != NULL) {
1973 uepnext = uep->ue_next;
1974 while (uepnext != NULL && uepnext->ue_isset)
1975 uepnext = uepnext->ue_next;
1976 (*printer)(arg, "%s", uep->ue_name);
1977 if (uepnext != NULL)
1978 (*printer)(arg, "\t\t# (from %s)\n%s ", uep->ue_source, opt->name);
1980 opt->source = uep->ue_source;