Lines Matching +full:sw +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()
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
211 ProcessArgs(int argc, char **argv, struct switches *sw) in ProcessArgs() argument
217 memset(sw, '\0', sizeof *sw); in ProcessArgs()
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()
230 sw->nat = 1; in ProcessArgs()
232 optc--; /* this option isn't exclusive */ 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()
292 if (mode == PHYS_DIRECT) in CheckLabel()
293 log_Printf(LogWARN, "Label %s rejected -direct connection: %s\n", in CheckLabel()
310 struct switches sw; in main() local
320 if ((holdfd[0] = open(_PATH_DEVNULL, O_RDWR)) == -1) { in main()
333 label = ProcessArgs(argc, argv, &sw); 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()
350 /* Allow output for the moment (except in direct mode) */ in main()
351 if (sw.mode == PHYS_DIRECT) 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()
381 if (!sw.quiet) 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()
391 if (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()
430 if (!sw.quiet) 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()
436 if (!sw.fg) { in main()
440 if (sw.mode == PHYS_BACKGROUND && pipe(bgpipe)) { in main()
446 if (bgpid == -1) { in main()
455 if (sw.mode == PHYS_BACKGROUND) { in main()
468 if (!sw.quiet) { in main()
474 if (!sw.quiet) in main()
478 if (!sw.quiet) 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()
510 if (!sw.fg) 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()
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()