Deleted Added
full compact
main.c (23598) main.c (23840)
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.36 1997/03/09 20:03:39 ache Exp $
20 * $Id: main.c,v 1.37 1997/03/10 06:21:01 ache Exp $
21 *
22 * TODO:
23 * o Add commands for traffic summary, version display, etc.
24 * o Add signal handler for misc controls.
25 */
26#include "fsm.h"
27#include <fcntl.h>
28#include <paths.h>

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

44#include "lcp.h"
45#include "ipcp.h"
46#include "vars.h"
47#include "auth.h"
48#include "filter.h"
49#include "systems.h"
50#include "ip.h"
51#include "alias.h"
21 *
22 * TODO:
23 * o Add commands for traffic summary, version display, etc.
24 * o Add signal handler for misc controls.
25 */
26#include "fsm.h"
27#include <fcntl.h>
28#include <paths.h>

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

44#include "lcp.h"
45#include "ipcp.h"
46#include "vars.h"
47#include "auth.h"
48#include "filter.h"
49#include "systems.h"
50#include "ip.h"
51#include "alias.h"
52#include "sig.h"
52
53#define LAUTH_M1 "Warning: No password entry for this host in ppp.secret\n"
54#define LAUTH_M2 "Warning: All manipulation is allowed by anyone in the world\n"
55
56#ifndef O_NONBLOCK
57#ifdef O_NDELAY
58#define O_NONBLOCK O_NDELAY
59#endif

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

208 LcpClose();
209 Cleanup(EX_TERM);
210 }
211}
212
213static void
214TerminalCont()
215{
53
54#define LAUTH_M1 "Warning: No password entry for this host in ppp.secret\n"
55#define LAUTH_M2 "Warning: All manipulation is allowed by anyone in the world\n"
56
57#ifndef O_NONBLOCK
58#ifdef O_NDELAY
59#define O_NONBLOCK O_NDELAY
60#endif

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

209 LcpClose();
210 Cleanup(EX_TERM);
211 }
212}
213
214static void
215TerminalCont()
216{
216 (void)signal(SIGCONT, SIG_DFL);
217 (void)signal(SIGTSTP, TerminalStop);
217 pending_signal(SIGCONT, SIG_DFL);
218 pending_signal(SIGTSTP, TerminalStop);
218 TtyCommandMode(getpgrp() == tcgetpgrp(0));
219}
220
221static void
222TerminalStop(signo)
223int signo;
224{
219 TtyCommandMode(getpgrp() == tcgetpgrp(0));
220}
221
222static void
223TerminalStop(signo)
224int signo;
225{
225 (void)signal(SIGCONT, TerminalCont);
226 pending_signal(SIGCONT, TerminalCont);
226 TtyOldMode();
227 TtyOldMode();
227 signal(SIGTSTP, SIG_DFL);
228 pending_signal(SIGTSTP, SIG_DFL);
228 kill(getpid(), signo);
229}
230
231
232void
233Usage()
234{
235 fprintf(stderr,

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

344 fprintf(stderr, "Destination system must be specified in background mode.\n");
345 exit(EX_START);
346 }
347 }
348
349 tcgetattr(0, &oldtio); /* Save original tty mode */
350
351 signal(SIGHUP, Hangup);
229 kill(getpid(), signo);
230}
231
232
233void
234Usage()
235{
236 fprintf(stderr,

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

345 fprintf(stderr, "Destination system must be specified in background mode.\n");
346 exit(EX_START);
347 }
348 }
349
350 tcgetattr(0, &oldtio); /* Save original tty mode */
351
352 signal(SIGHUP, Hangup);
352 signal(SIGTERM, CloseSession);
353 signal(SIGINT, CloseSession);
354 signal(SIGQUIT, CloseSession);
353 pending_signal(SIGTERM, CloseSession);
354 pending_signal(SIGINT, CloseSession);
355 pending_signal(SIGQUIT, CloseSession);
355#ifdef SIGSEGV
356 signal(SIGSEGV, Hangup);
357#endif
358#ifdef SIGPIPE
359 signal(SIGPIPE, Hangup);
360#endif
361#ifdef SIGALRM
356#ifdef SIGSEGV
357 signal(SIGSEGV, Hangup);
358#endif
359#ifdef SIGPIPE
360 signal(SIGPIPE, Hangup);
361#endif
362#ifdef SIGALRM
362 signal(SIGALRM, SIG_IGN);
363 pending_signal(SIGALRM, SIG_IGN);
363#endif
364 if(mode & MODE_INTER)
365 {
366#ifdef SIGTSTP
364#endif
365 if(mode & MODE_INTER)
366 {
367#ifdef SIGTSTP
367 signal(SIGTSTP, TerminalStop);
368 pending_signal(SIGTSTP, TerminalStop);
368#endif
369#ifdef SIGTTIN
369#endif
370#ifdef SIGTTIN
370 signal(SIGTTIN, TerminalStop);
371 pending_signal(SIGTTIN, TerminalStop);
371#endif
372#ifdef SIGTTOU
372#endif
373#ifdef SIGTTOU
373 signal(SIGTTOU, SIG_IGN);
374 pending_signal(SIGTTOU, SIG_IGN);
374#endif
375 }
376
377 if (dstsystem) {
378 if (SelectSystem(dstsystem, CONFFILE) < 0) {
379 fprintf(stderr, "Destination system not found in conf file.\n");
380 Cleanup(EX_START);
381 }

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

791 * CPU is serviced every TICKUNIT micro seconds.
792 * This value must be chosen with great care. If this values is
793 * too big, it results loss of characters from modem and poor responce.
794 * If this values is too small, ppp process eats many CPU time.
795 */
796#ifndef SIGALRM
797 usleep(TICKUNIT);
798 TimerService();
375#endif
376 }
377
378 if (dstsystem) {
379 if (SelectSystem(dstsystem, CONFFILE) < 0) {
380 fprintf(stderr, "Destination system not found in conf file.\n");
381 Cleanup(EX_START);
382 }

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

792 * CPU is serviced every TICKUNIT micro seconds.
793 * This value must be chosen with great care. If this values is
794 * too big, it results loss of characters from modem and poor responce.
795 * If this values is too small, ppp process eats many CPU time.
796 */
797#ifndef SIGALRM
798 usleep(TICKUNIT);
799 TimerService();
800#else
801 handle_signals();
799#endif
800
801 /* If there are aren't many packets queued, look for some more. */
802 if (qlen < 20 && tun_in >= 0) {
803 if (tun_in + 1 > nfds)
804 nfds = tun_in + 1;
805 FD_SET(tun_in, &rfds);
806 }

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

831#endif
832
833 if ( i == 0 ) {
834 continue;
835 }
836
837 if ( i < 0 ) {
838 if ( errno == EINTR ) {
802#endif
803
804 /* If there are aren't many packets queued, look for some more. */
805 if (qlen < 20 && tun_in >= 0) {
806 if (tun_in + 1 > nfds)
807 nfds = tun_in + 1;
808 FD_SET(tun_in, &rfds);
809 }

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

834#endif
835
836 if ( i == 0 ) {
837 continue;
838 }
839
840 if ( i < 0 ) {
841 if ( errno == EINTR ) {
839 continue; /* Got a signal - should have been dealt with */
842 handle_signals();
843 continue;
840 }
841 perror("select");
842 break;
843 }
844
845 if ((netfd >= 0 && FD_ISSET(netfd, &efds)) || (modem >= 0 && FD_ISSET(modem, &efds))) {
846 logprintf("Exception detected.\n");
847 break;

--- 116 unchanged lines hidden ---
844 }
845 perror("select");
846 break;
847 }
848
849 if ((netfd >= 0 && FD_ISSET(netfd, &efds)) || (modem >= 0 && FD_ISSET(modem, &efds))) {
850 logprintf("Exception detected.\n");
851 break;

--- 116 unchanged lines hidden ---