summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/command.c
diff options
context:
space:
mode:
authoramurai <amurai@FreeBSD.org>1995-10-08 14:57:32 +0000
committeramurai <amurai@FreeBSD.org>1995-10-08 14:57:32 +0000
commitc3dd7bc8c4ca398805d9de9926b5c543e1583de2 (patch)
tree6191ac0c05a48855f47ca8021db27f90e9e9df2b /usr.sbin/ppp/command.c
parent99a5efe547ff58ca59949ed56537d97e3c60180e (diff)
downloadFreeBSD-src-c3dd7bc8c4ca398805d9de9926b5c543e1583de2.zip
FreeBSD-src-c3dd7bc8c4ca398805d9de9926b5c543e1583de2.tar.gz
1. Add a settable redial timer and logging of the process id in a file.
A settable redial timer helps to avoid the problem where both ends of a link want to dial at the same time and the line winds up busy for both ends. The process id is logged in /var/run/PPP.system where system is the name of the called system. When both ends of a link are running in demand dial mode, you need an easy way to get the pid of the ppp on the called end so it can be killed and re-started with -direct or pppd started to handle the incoming ppp session. 2. Add secret description for "set timeout" to man. Reviewed by: Atsushi Murai <amurai@spec.co.jp> Submitted by: John Capo <jc@irbs.com>
Diffstat (limited to 'usr.sbin/ppp/command.c')
-rw-r--r--usr.sbin/ppp/command.c98
1 files changed, 86 insertions, 12 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index e7c005a..4a21bb6 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.7 1995/07/08 08:28:00 amurai Exp $
+ * $Id: command.c,v 1.9 1995/09/02 17:20:50 amurai Exp $
*
*/
#include <ctype.h>
@@ -114,6 +114,8 @@ struct cmdtab *cmdlist;
int argc;
char **argv;
{
+ int tries;
+
if (LcpFsm.state > ST_CLOSED) {
printf("LCP state is [%s]\n", StateNames[LcpFsm.state]);
return(1);
@@ -126,17 +128,22 @@ char **argv;
return(1);
}
}
- modem = OpenModem(mode);
- if (modem < 0) {
- printf("failed to open modem.\n");
- modem = 0;
- return(1);
- }
- if (DialModem()) {
- sleep(1);
- ModemTimeout();
- PacketMode();
- }
+ tries = 0;
+ do {
+ printf("Dial attempt %u\n", ++tries);
+ modem = OpenModem(mode);
+ if (modem < 0) {
+ printf("failed to open modem.\n");
+ modem = 0;
+ break;
+ }
+ if (DialModem()) {
+ sleep(1);
+ ModemTimeout();
+ PacketMode();
+ break;
+ }
+ } while (VarDialTries == 0 || tries < VarDialTries);
return(1);
}
@@ -321,6 +328,26 @@ static int ShowLogList()
return(1);
}
+static int ShowRedial()
+{
+ printf(" Redial Timer: ");
+
+ if (VarRedialTimeout >= 0) {
+ printf(" %d seconds, ", VarRedialTimeout);
+ }
+ else {
+ printf(" Random 0 - %d seconds, ", REDIAL_PERIOD);
+ }
+
+ if (VarDialTries)
+ printf("%d dial tries", VarDialTries);
+
+ printf("\n");
+
+ return(1);
+}
+
+
extern int ShowIfilter(), ShowOfilter(), ShowDfilter(), ShowAfilter();
struct cmdtab ShowCommands[] = {
@@ -360,6 +387,8 @@ struct cmdtab ShowCommands[] = {
"Show routing table", StrNull},
{ "timeout", NULL, ShowTimeout, LOCAL_AUTH,
"Show Idle timeout value", StrNull},
+ { "redial", NULL, ShowRedial, LOCAL_AUTH,
+ "Show Redial timeout value", StrNull},
{ "version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH,
"Show version string", StrNull},
{ "help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH,
@@ -556,6 +585,49 @@ char **argv;
return(1);
}
+static int SetRedialTimeout(list, argc, argv)
+struct cmdtab *list;
+int argc;
+char **argv;
+{
+ int timeout;
+ int tries;
+
+ if (argc == 1 || argc == 2 ) {
+ if (strcasecmp(argv[0], "random") == 0) {
+ VarRedialTimeout = -1;
+ printf("Using random redial timeout.\n");
+ srandom(time(0));
+ }
+ else {
+ timeout = atoi(argv[0]);
+
+ if (timeout >= 0) {
+ VarRedialTimeout = timeout;
+ }
+ else {
+ printf("invalid redial timeout\n");
+ printf("Usage: %s %s\n", list->name, list->syntax);
+ }
+ }
+ if (argc == 2) {
+ tries = atoi(argv[1]);
+
+ if (tries >= 0) {
+ VarDialTries = tries;
+ }
+ else {
+ printf("invalid retry value\n");
+ printf("Usage: %s %s\n", list->name, list->syntax);
+ }
+ }
+ }
+ else {
+ printf("Usage: %s %s\n", list->name, list->syntax);
+ }
+ return(1);
+}
+
static int SetModemParity(list, argc, argv)
struct cmdtab *list;
int argc;
@@ -830,6 +902,8 @@ struct cmdtab SetCommands[] = {
"Set modem speed", "speed"},
{ "timeout", NULL, SetIdleTimeout, LOCAL_AUTH,
"Set Idle timeout", StrValue},
+ { "redial", NULL, SetRedialTimeout, LOCAL_AUTH,
+ "Set Redial timeout", "value|random [dial_attempts]"},
{ "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
"Display this message", StrNull, (void *)SetCommands},
{ NULL, NULL, NULL },
OpenPOWER on IntegriCloud