Lines Matching +full:s +full:- +full:mode

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
5 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
115 SignalBundle->CleaningUp = 1; in Cleanup()
124 log_Printf(LogPHASE, "PPP Terminated (%s).\n", ex_desc(excode)); in AbortProgram()
138 log_Printf(LogPHASE, "Caught signal %d, abort connection(s)\n", signo); in CloseConnection()
186 /* Drops all child prompts and re-opens the socket */ in RestartServer()
193 fprintf(stderr, "usage: ppp [-auto | -foreground | -background | -direct |" in Usage()
194 " -dedicated | -ddial | -interactive]" in Usage()
196 " [-nat]" in Usage()
198 " [-quiet] [-unit N] [system ...]\n"); in Usage()
206 int mode; member
218 sw->mode = PHYS_INTERACTIVE; in ProcessArgs()
219 sw->unit = -1; in ProcessArgs()
221 for (arg = 1; arg < argc && *argv[arg] == '-'; arg++, optc++) { in ProcessArgs()
228 log_Printf(LogWARN, "%s ignored: NAT is compiled out\n", argv[arg]); in ProcessArgs()
230 sw->nat = 1; in ProcessArgs()
232 optc--; /* this option isn't exclusive */ in ProcessArgs()
235 log_Printf(LogWARN, "%s ignored: NAT is compiled out\n", argv[arg]); in ProcessArgs()
236 fprintf(stderr, "%s ignored: NAT is compiled out\n", argv[arg]); in ProcessArgs()
238 log_Printf(LogWARN, "%s is deprecated\n", argv[arg]); in ProcessArgs()
239 fprintf(stderr, "%s is deprecated\n", argv[arg]); in ProcessArgs()
240 sw->nat = 1; in ProcessArgs()
242 optc--; /* this option isn't exclusive */ in ProcessArgs()
244 optc--; /* this option isn't exclusive */ in ProcessArgs()
246 optc--; /* nor is the argument */ in ProcessArgs()
248 fprintf(stderr, "-unit: Expected unit number\n"); in ProcessArgs()
251 sw->unit = atoi(argv[arg]); in ProcessArgs()
253 sw->unit = atoi(cp + 4); in ProcessArgs()
255 sw->quiet = 1; in ProcessArgs()
256 optc--; /* this option isn't exclusive */ in ProcessArgs()
266 sw->mode = newmode; in ProcessArgs()
268 sw->fg = 1; in ProcessArgs()
273 fprintf(stderr, "You may specify only one mode.\n"); in ProcessArgs()
277 if (sw->mode == PHYS_AUTO && arg == argc) { in ProcessArgs()
278 fprintf(stderr, "A system must be specified in auto mode.\n"); in ProcessArgs()
286 CheckLabel(const char *label, struct prompt *prompt, int mode) in CheckLabel() argument
290 if ((err = system_IsValid(label, prompt, mode)) != NULL) { in CheckLabel()
291 fprintf(stderr, "%s: %s\n", label, err); in CheckLabel()
292 if (mode == PHYS_DIRECT) in CheckLabel()
293 log_Printf(LogWARN, "Label %s rejected -direct connection: %s\n", in CheckLabel()
320 if ((holdfd[0] = open(_PATH_DEVNULL, O_RDWR)) == -1) { in main()
321 fprintf(stderr, "Cannot open %s !\n", _PATH_DEVNULL); in main()
339 * routing table and then run ppp in interactive mode. The `show route' in main()
342 if (sw.mode == PHYS_INTERACTIVE) { in main()
345 fprintf(stderr, "Cannot open %s for input !\n", _PATH_TTY); in main()
350 /* Allow output for the moment (except in direct mode) */ in main()
351 if (sw.mode == PHYS_DIRECT) in main()
360 snprintf(conf, sizeof conf, "%s/%s", PPP_CONFDIR, CONFFILE); in main()
365 log_Printf(LogALERT, "ppp: Access violation: Please protect %s\n", in main()
367 return -1; in main()
369 ptr = conf + strlen(conf)-2; in main()
371 *ptr-- = '\0'; in main()
377 CheckLabel(argv[arg], prompt, sw.mode); in main()
379 CheckLabel("default", prompt, sw.mode); in main()
382 prompt_Printf(prompt, "Working in %s mode\n", mode2Nam(sw.mode)); in main()
384 if ((bundle = bundle_Create(TUN_PREFIX, sw.mode, sw.unit)) == NULL) in main()
390 bundle->NatEnabled = sw.nat; in main()
404 if (sw.mode == PHYS_INTERACTIVE) in main()
410 lastlabel = argv[argc - 1]; in main()
421 if (sw.mode == PHYS_AUTO && in main()
422 ncprange_family(&bundle->ncp.ipcp.cfg.peer_range) == AF_UNSPEC) { in main()
424 "in auto mode.\n"); in main()
429 prompt->bundle = bundle; /* couldn't do it earlier */ in main()
431 prompt_Printf(prompt, "Using interface: %s\n", bundle->iface->name); in main()
434 if (sw.mode != PHYS_INTERACTIVE) { in main()
435 if (sw.mode != PHYS_DIRECT) { in main()
440 if (sw.mode == PHYS_BACKGROUND && pipe(bgpipe)) { in main()
441 log_Printf(LogERROR, "pipe: %s\n", strerror(errno)); in main()
446 if (bgpid == -1) { in main()
447 log_Printf(LogERROR, "fork: %s\n", strerror(errno)); in main()
455 if (sw.mode == PHYS_BACKGROUND) { in main()
482 prompt_Printf(prompt, "Child failed (%s)\n", in main()
484 log_Printf(LogPHASE, "Parent: Child failed (%s)\n", in main()
496 } else if (sw.mode == PHYS_BACKGROUND) { in main()
498 bundle->notify.fd = bgpipe[1]; in main()
505 /* -auto, -dedicated, -ddial, -foreground & -background */ in main()
514 * -direct - STDIN_FILENO gets used by physical_Open. STDOUT_FILENO in main()
515 * *may* get used in exec/pipe mode. in main()
521 /* -interactive */ in main()
532 log_Printf(LogPHASE, "PPP Started (%s mode).\n", mode2Nam(sw.mode)); in main()
570 descriptor_UpdateSet(&bundle->desc, rfds, wfds, efds, &nfds); in DoLoop()
577 /* Don't select - we'll be here forever */ in DoLoop()
581 * It's possible that we've had a signal since we last checked. If in DoLoop()
594 log_Printf(LogERROR, "DoLoop: select(): %s\n", strerror(errno)); in DoLoop()
603 if (select(nfds, rfds, wfds, efds, &t) != -1) { in DoLoop()
612 if (select(nfds, rfds, wfds, efds, &t) != -1) { in DoLoop()
621 if (select(nfds, rfds, wfds, efds, &t) != -1) { in DoLoop()
658 if (descriptor_IsSet(&bundle->desc, rfds)) { in DoLoop()
659 descriptor_Read(&bundle->desc, bundle, rfds); in DoLoop()
663 if (descriptor_IsSet(&bundle->desc, wfds)) in DoLoop()
664 if (descriptor_Write(&bundle->desc, bundle, wfds) <= 0 && nothing_done) { in DoLoop()
667 * writable, and all our write()s have failed. Rather than in DoLoop()
668 * going back immediately to do our UpdateSet()s and select(), in DoLoop()