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.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> |
38#include <netinet/in_systm.h> 39#include <netinet/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" |
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, |
220 "Usage: ppp [-auto | -direct | -dedicated | -ddial ] [ -alias ] [system]\n"); |
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 } |
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(); |
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 } |
887 IpEnqueue(pri, rbuff, n); |
888 dial_up = TRUE; /* XXX */ |
889 } 890 continue; 891 } 892 pri = PacketCheck(rbuff, n, FL_OUT); |
893 if (pri >= 0) { 894 if (mode & MODE_ALIAS) { 895 PacketAliasOut(rbuff); 896 n = ntohs(((struct ip *) rbuff)->ip_len); 897 } |
898 IpEnqueue(pri, rbuff, n); |
899 } |
900 } 901 } 902 logprintf("job done.\n"); 903} |