*** adsl.c Sun May 11 10:35:05 2003 --- adsl.c.new Sun May 11 10:37:05 2003 *************** *** 16,22 **** # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # --------------------------------------------------------------------------- ! # ADSL4LINUX ADSL MAIN CONTROL BINARY # --------------------------------------------------------------------------- # # $Id: cyberdude47 Exp $ --- 16,22 ---- # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # --------------------------------------------------------------------------- ! # ADSL4LINUX ADSL MAIN CONTROL BINARY # --------------------------------------------------------------------------- # # $Id: cyberdude47 Exp $ *************** *** 60,73 **** if (strcmp(argv[1], "stop") == 0) { return stop(); ! } if (strcmp(argv[1], "version") == 0) { return version(); } if (strcmp(argv[1], "restart") == 0) { ! return restart(); } if (strcmp(argv[1], "status") == 0) --- 60,73 ---- if (strcmp(argv[1], "stop") == 0) { return stop(); ! } if (strcmp(argv[1], "version") == 0) { return version(); } if (strcmp(argv[1], "restart") == 0) { ! return restart(argc, argv[0], argv[2]); } if (strcmp(argv[1], "status") == 0) *************** *** 85,91 **** return startlogging(); } - if (strcmp(argv[1], "stoplog") == 0 && uid == 0) { if ( !isAdslUp() ) --- 85,90 ---- *************** *** 96,117 **** if (strcmp(argv[1], "update") == 0) { ! if ( !isAdslUp() ) return 1; return usagelogging(); ! } ! ! return usage(argv[0]); } int usage(char *programpath) { ! fprintf(stderr,"\nUsage: %s {start|stop|status|version}\n", programpath); fprintf(stderr," Status options:\n"); ! fprintf(stderr,"\tstatus only show counters\n"); ! fprintf(stderr,"\tstartlog start logging (root only)\n"); ! fprintf(stderr,"\tstoplog stop logging (root only)\n"); ! fprintf(stderr,"\tupdate update counters in logging (root only)\n"); return 0; } --- 95,117 ---- if (strcmp(argv[1], "update") == 0) { ! if ( !isAdslUp() ) return 1; return usagelogging(); ! } ! ! return usage(argv[0]); } int usage(char *programpath) { ! fprintf(stderr,"Usage: %s {start|stop|status|version}\n", programpath); fprintf(stderr," Status options:\n"); ! fprintf(stderr,"\tstatus only show counters\n"); ! fprintf(stderr,"\tstartlog start logging (root only)\n"); ! fprintf(stderr,"\tstoplog stop logging (root only)\n"); ! fprintf(stderr,"\tupdate update counters in logging (root only)\n"); ! fprintf(stderr,"\nPlease report bugs to cyberdude47@hotmail.com\n"); return 0; } *************** *** 163,169 **** } else { ! printf("\nUsage: %s start pc\n", name); printf("Example: %s start pc2\n", name); return 1; } --- 163,169 ---- } else { ! printf("Usage: %s start pc\n", name); printf("Example: %s start pc2\n", name); return 1; } *************** *** 188,209 **** } else { ! printf("\nError: connection already available!\n"); return 1; } if (waitforconnection()) { ! printf("\nConnection Established\n"); sleep(5); ! isAdslUp(); startlogging(); return 0; } else { ! printf("\nConnection FAILED!\n"); return 1; } } --- 188,209 ---- } else { ! printf("Error: connection already available!\n"); return 1; } if (waitforconnection()) { ! printf("Connection Established\n"); sleep(5); ! isAdslUp(); startlogging(); return 0; } else { ! printf("Connection FAILED!\n"); return 1; } } *************** *** 239,251 **** if (!kill(ppppid, 0) || isadslrunning() ) { ! printf("FAILED\n"); return 2; } else { ! printf("OK\n"); ! return 0; } } else --- 239,251 ---- if (!kill(ppppid, 0) || isadslrunning() ) { ! printf(" FAILED!\nYou might need to be root to stop the connection.\n"); return 2; } else { ! printf(" OK\n"); ! return 0; } } else *************** *** 257,317 **** return 0; } ! int restart() ! { ! fprintf(stderr, "restart has not yet been implemented.\n"); ! return 1; ! // return !(!stop() && !start(programpath)) ! /* int out; pid_t ppppid; - int j; ! if ( !isadslrunning() ){ ! printf("\nADSL connection already down.\n"); ! return 1;} else { ! ppppid = getpidofconn(STAT_FILE); ! ! out=kill(ppppid, SIGHUP); ! printf("Old pppd shutting down"); ! ! for(j=0; j 1) { ! printf("\nSending SIGTERM to pppd(%d)",ppppid); ! kill(ppppid, SIGTERM); ! for(j=0; j\n", name); ! printf("Example: %s start pc2\n", name); ! return 1; ! } ! ! switch(pc) ! { ! case 1: ! out=system("pppd call adsl"); ! break; ! case 2: ! out=system("pppd call adsl2"); ! break; ! case 3: ! out=system("pppd call adsl3"); ! break; ! case 4: ! out=system("pppd call adsl4"); ! break; ! } ! ! printf("\nEstablishing connection"); ! ! if (waitforconnection()) ! { ! printf("\nConnection Established\n"); ! sleep(5); ! ! isAdslUp(); ! startlogging(); ! return 0; ! } ! else ! { ! printf("\nCouldn't establish connection!\n"); ! return 1; ! } ! ! return 0; ! } } int version(void) *************** *** 383,389 **** int isadslrunning() { struct stat st; - return (stat(STATFILE, &st)>=0); } --- 439,444 ---- *************** *** 401,405 **** return result; } - - --- 456,458 ----