main.c (85602e5267f413a849370d3c6fe3d0a87cdd5b49) main.c (565e35e50e2cdac423588a3d18742544bde128b0)
1/*
2 * User Process PPP
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * User Process PPP
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: main.c,v 1.121.2.46 1998/04/07 00:54:07 brian Exp $
20 * $Id: main.c,v 1.121.2.47 1998/04/07 23:46:02 brian Exp $
21 *
22 * TODO:
23 */
24
25#include <sys/param.h>
26#include <netinet/in.h>
27#include <netinet/in_systm.h>
28#include <netinet/ip.h>
21 *
22 * TODO:
23 */
24
25#include <sys/param.h>
26#include <netinet/in.h>
27#include <netinet/in_systm.h>
28#include <netinet/ip.h>
29#include <sys/un.h>
29
30#include <errno.h>
31#include <fcntl.h>
32#include <paths.h>
33#include <signal.h>
34#include <stdio.h>
35#include <string.h>
36#include <termios.h>

--- 156 unchanged lines hidden (view full) ---

193#ifndef NOALIAS
194 " [ -alias ]"
195#endif
196 " [system]\n");
197 exit(EX_START);
198}
199
200static char *
30
31#include <errno.h>
32#include <fcntl.h>
33#include <paths.h>
34#include <signal.h>
35#include <stdio.h>
36#include <string.h>
37#include <termios.h>

--- 156 unchanged lines hidden (view full) ---

194#ifndef NOALIAS
195 " [ -alias ]"
196#endif
197 " [system]\n");
198 exit(EX_START);
199}
200
201static char *
201ProcessArgs(int argc, char **argv)
202ProcessArgs(int argc, char **argv, int *mode)
202{
203{
203 int optc;
204 int optc, labelrequired;
204 char *cp;
205
205 char *cp;
206
206 optc = 0;
207 mode = MODE_INTER;
207 optc = labelrequired = 0;
208 *mode = PHYS_MANUAL;
208 while (argc > 0 && **argv == '-') {
209 cp = *argv + 1;
210 if (strcmp(cp, "auto") == 0) {
209 while (argc > 0 && **argv == '-') {
210 cp = *argv + 1;
211 if (strcmp(cp, "auto") == 0) {
211 mode |= MODE_AUTO;
212 mode &= ~MODE_INTER;
212 *mode = PHYS_DEMAND;
213 labelrequired = 1;
213 } else if (strcmp(cp, "background") == 0) {
214 } else if (strcmp(cp, "background") == 0) {
214 mode |= MODE_BACKGROUND;
215 mode &= ~MODE_INTER;
216 } else if (strcmp(cp, "direct") == 0) {
217 mode |= MODE_DIRECT;
218 mode &= ~MODE_INTER;
219 } else if (strcmp(cp, "dedicated") == 0) {
220 mode |= MODE_DEDICATED;
221 mode &= ~MODE_INTER;
222 } else if (strcmp(cp, "ddial") == 0) {
223 mode |= MODE_DDIAL;
224 mode &= ~MODE_INTER;
225#ifndef NOALIAS
215 *mode = PHYS_1OFF;
216 labelrequired = 1;
217 } else if (strcmp(cp, "direct") == 0)
218 *mode = PHYS_STDIN;
219 else if (strcmp(cp, "dedicated") == 0)
220 *mode = PHYS_DEDICATED;
221 else if (strcmp(cp, "ddial") == 0) {
222 *mode = PHYS_PERM;
223 labelrequired = 1;
226 } else if (strcmp(cp, "alias") == 0) {
224 } else if (strcmp(cp, "alias") == 0) {
225#ifndef NOALIAS
227 if (loadAliasHandlers() != 0)
226 if (loadAliasHandlers() != 0)
227#endif
228 LogPrintf(LogWARN, "Cannot load alias library\n");
229 optc--; /* this option isn't exclusive */
228 LogPrintf(LogWARN, "Cannot load alias library\n");
229 optc--; /* this option isn't exclusive */
230#endif
231 } else
232 Usage();
233 optc++;
234 argv++;
235 argc--;
236 }
237 if (argc > 1) {
238 fprintf(stderr, "You may specify only one system label.\n");
239 exit(EX_START);
240 }
241
242 if (optc > 1) {
243 fprintf(stderr, "You may specify only one mode.\n");
244 exit(EX_START);
245 }
246
230 } else
231 Usage();
232 optc++;
233 argv++;
234 argc--;
235 }
236 if (argc > 1) {
237 fprintf(stderr, "You may specify only one system label.\n");
238 exit(EX_START);
239 }
240
241 if (optc > 1) {
242 fprintf(stderr, "You may specify only one mode.\n");
243 exit(EX_START);
244 }
245
246 if (labelrequired && argc != 1) {
247 fprintf(stderr, "Destination system must be specified in"
248 " auto, background or ddial mode.\n");
249 exit(EX_START);
250 }
251
247 return argc == 1 ? *argv : NULL; /* Don't SetLabel yet ! */
248}
249
250int
251main(int argc, char **argv)
252{
253 FILE *lockfile;
254 char *name, *label;
252 return argc == 1 ? *argv : NULL; /* Don't SetLabel yet ! */
253}
254
255int
256main(int argc, char **argv)
257{
258 FILE *lockfile;
259 char *name, *label;
255 int nfds;
260 int nfds, mode;
256 struct bundle *bundle;
257 struct prompt *prompt;
258
259 nfds = getdtablesize();
260 if (nfds >= FD_SETSIZE)
261 /*
262 * If we've got loads of file descriptors, make sure they're all
263 * closed. If they aren't, we may end up with a seg fault when our
264 * `fd_set's get too big when select()ing !
265 */
266 while (--nfds > 2)
267 close(nfds);
268
269 name = strrchr(argv[0], '/');
270 LogOpen(name ? name + 1 : argv[0]);
271
272 argc--;
273 argv++;
261 struct bundle *bundle;
262 struct prompt *prompt;
263
264 nfds = getdtablesize();
265 if (nfds >= FD_SETSIZE)
266 /*
267 * If we've got loads of file descriptors, make sure they're all
268 * closed. If they aren't, we may end up with a seg fault when our
269 * `fd_set's get too big when select()ing !
270 */
271 while (--nfds > 2)
272 close(nfds);
273
274 name = strrchr(argv[0], '/');
275 LogOpen(name ? name + 1 : argv[0]);
276
277 argc--;
278 argv++;
274 label = ProcessArgs(argc, argv);
279 label = ProcessArgs(argc, argv, &mode);
275
276#ifdef __FreeBSD__
277 /*
278 * A FreeBSD hack to dodge a bug in the tty driver that drops output
279 * occasionally.... I must find the real reason some time. To display
280 * the dodgy behaviour, comment out this bit, make yourself a large
281 * routing table and then run ppp in interactive mode. The `show route'
282 * command will drop chunks of data !!!
283 */
280
281#ifdef __FreeBSD__
282 /*
283 * A FreeBSD hack to dodge a bug in the tty driver that drops output
284 * occasionally.... I must find the real reason some time. To display
285 * the dodgy behaviour, comment out this bit, make yourself a large
286 * routing table and then run ppp in interactive mode. The `show route'
287 * command will drop chunks of data !!!
288 */
284 if (mode & MODE_INTER) {
289 if (mode == PHYS_MANUAL) {
285 close(STDIN_FILENO);
286 if (open(_PATH_TTY, O_RDONLY) != STDIN_FILENO) {
287 fprintf(stderr, "Cannot open %s for input !\n", _PATH_TTY);
288 return 2;
289 }
290 }
291#endif
292
293 /* Allow output for the moment (except in direct mode) */
290 close(STDIN_FILENO);
291 if (open(_PATH_TTY, O_RDONLY) != STDIN_FILENO) {
292 fprintf(stderr, "Cannot open %s for input !\n", _PATH_TTY);
293 return 2;
294 }
295 }
296#endif
297
298 /* Allow output for the moment (except in direct mode) */
294 if (mode & MODE_DIRECT)
299 if (mode == PHYS_STDIN)
295 prompt = NULL;
296 else {
297 const char *m;
298
299 SignalPrompt = prompt = prompt_Create(NULL, NULL, PROMPT_STD);
300 prompt = NULL;
301 else {
302 const char *m;
303
304 SignalPrompt = prompt = prompt_Create(NULL, NULL, PROMPT_STD);
300 if (mode & MODE_DDIAL)
305 if (mode == PHYS_PERM)
301 m = "direct dial";
306 m = "direct dial";
302 else if (mode & MODE_BACKGROUND)
307 else if (mode & PHYS_1OFF)
303 m = "background";
308 m = "background";
304 else if (mode & MODE_AUTO)
309 else if (mode & PHYS_DEMAND)
305 m = "auto";
310 m = "auto";
306 else if (mode & MODE_DEDICATED)
311 else if (mode & PHYS_DEDICATED)
307 m = "dedicated";
312 m = "dedicated";
308 else if (mode & MODE_INTER)
313 else if (mode & PHYS_MANUAL)
309 m = "interactive";
310 else
311 m = NULL;
312
313 if (m)
314 prompt_Printf(prompt, "Working in %s mode\n", m);
315 }
316

--- 8 unchanged lines hidden (view full) ---

325 return -1;
326 }
327 ptr = conf + strlen(conf)-2;
328 while (ptr > conf && *ptr != '/')
329 *ptr-- = '\0';
330 } while (ptr >= conf);
331 }
332
314 m = "interactive";
315 else
316 m = NULL;
317
318 if (m)
319 prompt_Printf(prompt, "Working in %s mode\n", m);
320 }
321

--- 8 unchanged lines hidden (view full) ---

330 return -1;
331 }
332 ptr = conf + strlen(conf)-2;
333 while (ptr > conf && *ptr != '/')
334 *ptr-- = '\0';
335 } while (ptr >= conf);
336 }
337
333 if (!ValidSystem(label, prompt)) {
338 if (!ValidSystem(label, prompt, mode)) {
334 fprintf(stderr, "You may not use ppp in this mode with this label\n");
339 fprintf(stderr, "You may not use ppp in this mode with this label\n");
335 if (mode & MODE_DIRECT) {
340 if (mode == PHYS_STDIN) {
336 const char *l;
337 l = label ? label : "default";
338 LogPrintf(LogWARN, "Label %s rejected -direct connection\n", l);
339 }
340 LogClose();
341 return 1;
342 }
343
341 const char *l;
342 l = label ? label : "default";
343 LogPrintf(LogWARN, "Label %s rejected -direct connection\n", l);
344 }
345 LogClose();
346 return 1;
347 }
348
344 if ((bundle = bundle_Create("/dev/tun", prompt)) == NULL) {
349 if ((bundle = bundle_Create(TUN_PREFIX, prompt, mode)) == NULL) {
345 LogPrintf(LogWARN, "bundle_Create: %s\n", strerror(errno));
346 return EX_START;
347 }
348 SignalBundle = bundle;
349
350 if (SelectSystem(bundle, "default", CONFFILE, prompt) < 0)
350 LogPrintf(LogWARN, "bundle_Create: %s\n", strerror(errno));
351 return EX_START;
352 }
353 SignalBundle = bundle;
354
355 if (SelectSystem(bundle, "default", CONFFILE, prompt) < 0)
351 prompt_Printf(prompt,
352 "Warning: No default entry is given in config file.\n");
356 prompt_Printf(prompt, "Warning: No default entry found in config file.\n");
353
357
354 if ((mode & MODE_OUTGOING_DAEMON) && !(mode & MODE_DEDICATED))
355 if (label == NULL) {
356 prompt_Printf(prompt, "Destination system must be specified in"
357 " auto, background or ddial mode.\n");
358 return EX_START;
359 }
360
361 pending_signal(SIGHUP, CloseSession);
362 pending_signal(SIGTERM, CloseSession);
363 pending_signal(SIGINT, CloseConnection);
364 pending_signal(SIGQUIT, CloseSession);
365 pending_signal(SIGALRM, SIG_IGN);
366 signal(SIGPIPE, SIG_IGN);
358 pending_signal(SIGHUP, CloseSession);
359 pending_signal(SIGTERM, CloseSession);
360 pending_signal(SIGINT, CloseConnection);
361 pending_signal(SIGQUIT, CloseSession);
362 pending_signal(SIGALRM, SIG_IGN);
363 signal(SIGPIPE, SIG_IGN);
367 if (mode & MODE_INTER)
364
365 if (mode == PHYS_MANUAL)
368 pending_signal(SIGTSTP, TerminalStop);
369
370#if 0 /* What's our passwd :-O */
371 pending_signal(SIGUSR1, SetUpServer);
372#endif
373 pending_signal(SIGUSR2, BringDownServer);
374
375 if (label) {
376 if (SelectSystem(bundle, label, CONFFILE, prompt) < 0) {
377 prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
378 AbortProgram(EX_START);
379 }
380 /*
381 * We don't SetLabel() 'till now in case SelectSystem() has an
382 * embeded load "otherlabel" command.
383 */
384 SetLabel(label);
366 pending_signal(SIGTSTP, TerminalStop);
367
368#if 0 /* What's our passwd :-O */
369 pending_signal(SIGUSR1, SetUpServer);
370#endif
371 pending_signal(SIGUSR2, BringDownServer);
372
373 if (label) {
374 if (SelectSystem(bundle, label, CONFFILE, prompt) < 0) {
375 prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
376 AbortProgram(EX_START);
377 }
378 /*
379 * We don't SetLabel() 'till now in case SelectSystem() has an
380 * embeded load "otherlabel" command.
381 */
382 SetLabel(label);
385 if (mode & MODE_AUTO &&
383 if (mode == PHYS_DEMAND &&
386 bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
384 bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
387 prompt_Printf(prompt, "You must \"set ifaddr\" in label %s for "
388 "auto mode.\n", label);
385 prompt_Printf(prompt, "You must \"set ifaddr\" with a peer address "
386 "in label %s for auto mode.\n", label);
389 AbortProgram(EX_START);
390 }
391 }
392
387 AbortProgram(EX_START);
388 }
389 }
390
393 if (mode & MODE_DAEMON) {
394 if (!(mode & MODE_DIRECT)) {
391 if (mode != PHYS_MANUAL) {
392 if (mode != PHYS_STDIN) {
395 int bgpipe[2];
396 pid_t bgpid;
397
393 int bgpipe[2];
394 pid_t bgpid;
395
398 if (mode & MODE_BACKGROUND && pipe(bgpipe)) {
396 if (mode == PHYS_1OFF && pipe(bgpipe)) {
399 LogPrintf(LogERROR, "pipe: %s\n", strerror(errno));
400 AbortProgram(EX_SOCK);
401 }
402
403 bgpid = fork();
404 if (bgpid == -1) {
405 LogPrintf(LogERROR, "fork: %s\n", strerror(errno));
406 AbortProgram(EX_SOCK);
407 }
408
409 if (bgpid) {
410 char c = EX_NORMAL;
411
397 LogPrintf(LogERROR, "pipe: %s\n", strerror(errno));
398 AbortProgram(EX_SOCK);
399 }
400
401 bgpid = fork();
402 if (bgpid == -1) {
403 LogPrintf(LogERROR, "fork: %s\n", strerror(errno));
404 AbortProgram(EX_SOCK);
405 }
406
407 if (bgpid) {
408 char c = EX_NORMAL;
409
412 if (mode & MODE_BACKGROUND) {
410 if (mode == PHYS_1OFF) {
413 close(bgpipe[1]);
414 BGPid = bgpid;
415 /* If we get a signal, kill the child */
416 signal(SIGHUP, KillChild);
417 signal(SIGTERM, KillChild);
418 signal(SIGINT, KillChild);
419 signal(SIGQUIT, KillChild);
420

--- 7 unchanged lines hidden (view full) ---

428 } else {
429 prompt_Printf(prompt, "Child failed (%s).\n", ex_desc((int) c));
430 LogPrintf(LogPHASE, "Parent: Child failed (%s).\n",
431 ex_desc((int) c));
432 }
433 close(bgpipe[0]);
434 }
435 return c;
411 close(bgpipe[1]);
412 BGPid = bgpid;
413 /* If we get a signal, kill the child */
414 signal(SIGHUP, KillChild);
415 signal(SIGTERM, KillChild);
416 signal(SIGINT, KillChild);
417 signal(SIGQUIT, KillChild);
418

--- 7 unchanged lines hidden (view full) ---

426 } else {
427 prompt_Printf(prompt, "Child failed (%s).\n", ex_desc((int) c));
428 LogPrintf(LogPHASE, "Parent: Child failed (%s).\n",
429 ex_desc((int) c));
430 }
431 close(bgpipe[0]);
432 }
433 return c;
436 } else if (mode & MODE_BACKGROUND) {
434 } else if (mode == PHYS_1OFF) {
437 close(bgpipe[0]);
438 bundle->notify.fd = bgpipe[1];
439 }
435 close(bgpipe[0]);
436 bundle->notify.fd = bgpipe[1];
437 }
440 }
441
438
442 if (mode & MODE_DIRECT) {
443 /* STDIN_FILENO gets used by modem_Open in DIRECT mode */
444 prompt = prompt_Create(NULL, bundle, PROMPT_STD);
445 prompt_TtyInit(prompt, PROMPT_DONT_WANT_INT);
446 prompt_DestroyUnclean(prompt);
447 close(STDOUT_FILENO);
448 close(STDERR_FILENO);
449 } else if (mode & MODE_DAEMON) {
439 /* -auto, -dedicated, -ddial & -background */
450 prompt_Destroy(prompt, 0);
451 close(STDOUT_FILENO);
452 close(STDERR_FILENO);
453 close(STDIN_FILENO);
454 setsid();
440 prompt_Destroy(prompt, 0);
441 close(STDOUT_FILENO);
442 close(STDERR_FILENO);
443 close(STDIN_FILENO);
444 setsid();
445 } else {
446 /* -direct: STDIN_FILENO gets used by modem_Open */
447 prompt_TtyInit(NULL);
448 close(STDOUT_FILENO);
449 close(STDERR_FILENO);
455 }
456 } else {
450 }
451 } else {
452 /* Interactive mode */
457 close(STDERR_FILENO);
453 close(STDERR_FILENO);
458 prompt_TtyInit(prompt, PROMPT_WANT_INT);
454 prompt_TtyInit(prompt);
459 prompt_TtyCommandMode(prompt);
460 prompt_Required(prompt);
461 }
462
463 snprintf(pid_filename, sizeof pid_filename, "%stun%d.pid",
464 _PATH_VARRUN, bundle->unit);
465 lockfile = ID0fopen(pid_filename, "w");
466 if (lockfile != NULL) {
467 fprintf(lockfile, "%d\n", (int) getpid());
468 fclose(lockfile);
469 }
470#ifndef RELEASE_CRUNCH
471 else
472 LogPrintf(LogALERT, "Warning: Can't create %s: %s\n",
473 pid_filename, strerror(errno));
474#endif
475
455 prompt_TtyCommandMode(prompt);
456 prompt_Required(prompt);
457 }
458
459 snprintf(pid_filename, sizeof pid_filename, "%stun%d.pid",
460 _PATH_VARRUN, bundle->unit);
461 lockfile = ID0fopen(pid_filename, "w");
462 if (lockfile != NULL) {
463 fprintf(lockfile, "%d\n", (int) getpid());
464 fclose(lockfile);
465 }
466#ifndef RELEASE_CRUNCH
467 else
468 LogPrintf(LogALERT, "Warning: Can't create %s: %s\n",
469 pid_filename, strerror(errno));
470#endif
471
476 LogPrintf(LogPHASE, "PPP Started.\n");
477
478
479 do
480 DoLoop(bundle, prompt);
481 while (mode & MODE_DEDICATED);
482
472 LogPrintf(LogPHASE, "PPP Started (%s mode).\n", mode2Nam(mode));
473 DoLoop(bundle, prompt);
483 AbortProgram(EX_NORMAL);
484
485 return EX_NORMAL;
486}
487
488static void
489DoLoop(struct bundle *bundle, struct prompt *prompt)
490{
491 fd_set rfds, wfds, efds;
492 int pri, i, n, nfds;
493 int qlen;
494 struct tun_data tun;
495
474 AbortProgram(EX_NORMAL);
475
476 return EX_NORMAL;
477}
478
479static void
480DoLoop(struct bundle *bundle, struct prompt *prompt)
481{
482 fd_set rfds, wfds, efds;
483 int pri, i, n, nfds;
484 int qlen;
485 struct tun_data tun;
486
496 if (mode & (MODE_DIRECT|MODE_DEDICATED|MODE_BACKGROUND))
497 bundle_Open(bundle, NULL);
498
499 while (!bundle_IsDead(bundle)) {
487 do {
500 nfds = 0;
501 FD_ZERO(&rfds);
502 FD_ZERO(&wfds);
503 FD_ZERO(&efds);
504
505 qlen = bundle_FillQueues(bundle);
506
507 handle_signals();

--- 83 unchanged lines hidden (view full) ---

591 * Process on-demand dialup. Output packets are queued within tunnel
592 * device until IPCP is opened.
593 */
594 if (bundle_Phase(bundle) == PHASE_DEAD)
595 /*
596 * Note, we must be in AUTO mode :-/ otherwise our interface should
597 * *not* be UP and we can't receive data
598 */
488 nfds = 0;
489 FD_ZERO(&rfds);
490 FD_ZERO(&wfds);
491 FD_ZERO(&efds);
492
493 qlen = bundle_FillQueues(bundle);
494
495 handle_signals();

--- 83 unchanged lines hidden (view full) ---

579 * Process on-demand dialup. Output packets are queued within tunnel
580 * device until IPCP is opened.
581 */
582 if (bundle_Phase(bundle) == PHASE_DEAD)
583 /*
584 * Note, we must be in AUTO mode :-/ otherwise our interface should
585 * *not* be UP and we can't receive data
586 */
599 if ((mode & MODE_AUTO) &&
600 (pri = PacketCheck(bundle, tun.data, n, &bundle->filter.dial)) >= 0)
601 bundle_Open(bundle, NULL);
587 if ((pri = PacketCheck(bundle, tun.data, n, &bundle->filter.dial)) >= 0)
588 bundle_Open(bundle, NULL, PHYS_DEMAND);
602 else
603 /*
604 * Drop the packet. If we were to queue it, we'd just end up with
605 * a pile of timed-out data in our output queue by the time we get
606 * around to actually dialing. We'd also prematurely reach the
607 * threshold at which we stop select()ing to read() the tun
608 * device - breaking auto-dial.
609 */

--- 5 unchanged lines hidden (view full) ---

615 if (AliasEnabled()) {
616 (*PacketAlias.Out)(tun.data, sizeof tun.data);
617 n = ntohs(((struct ip *)tun.data)->ip_len);
618 }
619#endif
620 IpEnqueue(pri, tun.data, n);
621 }
622 }
589 else
590 /*
591 * Drop the packet. If we were to queue it, we'd just end up with
592 * a pile of timed-out data in our output queue by the time we get
593 * around to actually dialing. We'd also prematurely reach the
594 * threshold at which we stop select()ing to read() the tun
595 * device - breaking auto-dial.
596 */

--- 5 unchanged lines hidden (view full) ---

602 if (AliasEnabled()) {
603 (*PacketAlias.Out)(tun.data, sizeof tun.data);
604 n = ntohs(((struct ip *)tun.data)->ip_len);
605 }
606#endif
607 IpEnqueue(pri, tun.data, n);
608 }
609 }
623 }
624 LogPrintf(LogDEBUG, "Job (DoLoop) done.\n");
610 } while (bundle_CleanDatalinks(bundle), !bundle_IsDead(bundle));
611
612 LogPrintf(LogDEBUG, "DoLoop done.\n");
625}
613}