Deleted Added
full compact
main.c (20120) main.c (20365)
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.22 1996/10/12 16:20:32 jkh Exp $
20 * $Id: main.c,v 1.23 1996/12/03 21:38:48 nate 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>
29#include <sys/time.h>
30#include <termios.h>
31#include <signal.h>
32#include <sys/wait.h>
33#include <errno.h>
34#include <netdb.h>
35#include <unistd.h>
36#include <sys/socket.h>
37#include <arpa/inet.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>
29#include <sys/time.h>
30#include <termios.h>
31#include <signal.h>
32#include <sys/wait.h>
33#include <errno.h>
34#include <netdb.h>
35#include <unistd.h>
36#include <sys/socket.h>
37#include <arpa/inet.h>
38#include <netinet/in_systm.h>
39#include <netinet/ip.h>
38#include "modem.h"
39#include "os.h"
40#include "hdlc.h"
41#include "ccp.h"
42#include "lcp.h"
43#include "ipcp.h"
44#include "vars.h"
45#include "auth.h"
46#include "filter.h"
47#include "systems.h"
48#include "ip.h"
40#include "modem.h"
41#include "os.h"
42#include "hdlc.h"
43#include "ccp.h"
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"
49
50#define LAUTH_M1 "Warning: No password entry for this host in ppp.secret\n"
51#define LAUTH_M2 "Warning: All manipulation is allowed by anyone in the world\n"
52
53#ifndef O_NONBLOCK
54#ifdef O_NDELAY
55#define O_NONBLOCK O_NDELAY
56#endif

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

209 kill(getpid(), signo);
210}
211
212
213void
214Usage()
215{
216 fprintf(stderr,
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

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

212 kill(getpid(), signo);
213}
214
215
216void
217Usage()
218{
219 fprintf(stderr,
217 "Usage: ppp [-auto | -direct | -dedicated | -ddial ] [system]\n");
220 "Usage: ppp [-auto | -direct | -dedicated | -ddial ] [ -alias ] [system]\n");
218 exit(EX_START);
219}
220
221void
222ProcessArgs(int argc, char **argv)
223{
224 int optc;
225 char *cp;

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

230 if (strcmp(cp, "auto") == 0)
231 mode |= MODE_AUTO;
232 else if (strcmp(cp, "direct") == 0)
233 mode |= MODE_DIRECT;
234 else if (strcmp(cp, "dedicated") == 0)
235 mode |= MODE_DEDICATED;
236 else if (strcmp(cp, "ddial") == 0)
237 mode |= MODE_DDIAL|MODE_AUTO;
221 exit(EX_START);
222}
223
224void
225ProcessArgs(int argc, char **argv)
226{
227 int optc;
228 char *cp;

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

233 if (strcmp(cp, "auto") == 0)
234 mode |= MODE_AUTO;
235 else if (strcmp(cp, "direct") == 0)
236 mode |= MODE_DIRECT;
237 else if (strcmp(cp, "dedicated") == 0)
238 mode |= MODE_DEDICATED;
239 else if (strcmp(cp, "ddial") == 0)
240 mode |= MODE_DDIAL|MODE_AUTO;
241 else if (strcmp(cp, "alias") == 0) {
242 mode |= MODE_ALIAS;
243 optc--; /* this option isn't exclusive */
244 }
238 else
239 Usage();
240 optc++;
241 argv++; argc--;
242 }
243 if (argc > 1) {
244 fprintf(stderr, "specify only one system label.\n");
245 exit(EX_START);

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

269 argc--; argv++;
270
271 mode = MODE_INTER; /* default operation is interactive mode */
272 netfd = -1;
273 ProcessArgs(argc, argv);
274 Greetings();
275 GetUid();
276 IpcpDefAddress();
245 else
246 Usage();
247 optc++;
248 argv++; argc--;
249 }
250 if (argc > 1) {
251 fprintf(stderr, "specify only one system label.\n");
252 exit(EX_START);

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

276 argc--; argv++;
277
278 mode = MODE_INTER; /* default operation is interactive mode */
279 netfd = -1;
280 ProcessArgs(argc, argv);
281 Greetings();
282 GetUid();
283 IpcpDefAddress();
284 InitAlias();
277
278 if (SelectSystem("default", CONFFILE) < 0) {
279 fprintf(stderr, "Warning: No default entry is given in config file.\n");
280 }
281
282 if (LogOpen())
283 exit(EX_START);
284

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

867 }
868 /*
869 * Process on-demand dialup. Output packets are queued within tunnel
870 * device until IPCP is opened.
871 */
872 if (LcpFsm.state <= ST_CLOSED && (mode & MODE_AUTO)) {
873 pri = PacketCheck(rbuff, n, FL_DIAL);
874 if (pri >= 0) {
285
286 if (SelectSystem("default", CONFFILE) < 0) {
287 fprintf(stderr, "Warning: No default entry is given in config file.\n");
288 }
289
290 if (LogOpen())
291 exit(EX_START);
292

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

875 }
876 /*
877 * Process on-demand dialup. Output packets are queued within tunnel
878 * device until IPCP is opened.
879 */
880 if (LcpFsm.state <= ST_CLOSED && (mode & MODE_AUTO)) {
881 pri = PacketCheck(rbuff, n, FL_DIAL);
882 if (pri >= 0) {
883 if (mode & MODE_ALIAS) {
884 PacketAliasOut(rbuff);
885 n = ntohs(((struct ip *) rbuff)->ip_len);
886 }
875 IpEnqueue(pri, rbuff, n);
887 IpEnqueue(pri, rbuff, n);
876 dial_up = TRUE; /* XXX */
888 dial_up = TRUE; /* XXX */
877 }
878 continue;
879 }
880 pri = PacketCheck(rbuff, n, FL_OUT);
889 }
890 continue;
891 }
892 pri = PacketCheck(rbuff, n, FL_OUT);
881 if (pri >= 0)
893 if (pri >= 0) {
894 if (mode & MODE_ALIAS) {
895 PacketAliasOut(rbuff);
896 n = ntohs(((struct ip *) rbuff)->ip_len);
897 }
882 IpEnqueue(pri, rbuff, n);
898 IpEnqueue(pri, rbuff, n);
899 }
883 }
884 }
885 logprintf("job done.\n");
886}
900 }
901 }
902 logprintf("job done.\n");
903}