summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-07-14 01:41:35 +0000
committerbrian <brian@FreeBSD.org>1997-07-14 01:41:35 +0000
commite3faa34d53e70df949da831b848a9c199c0d4cde (patch)
tree6b1eb482a86ab87deaa738693a3f5365440256be /usr.sbin
parent9ba2a5db74b2ac32478082f8ff0c19b6a328fe2f (diff)
downloadFreeBSD-src-e3faa34d53e70df949da831b848a9c199c0d4cde.zip
FreeBSD-src-e3faa34d53e70df949da831b848a9c199c0d4cde.tar.gz
Allow a "hangup" capability.
You can now "ATZ" your modem when it's closed. Submitted by: peter@citylink.dinoex.sub.org (Peter Much)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/chat.c5
-rw-r--r--usr.sbin/ppp/command.c9
-rw-r--r--usr.sbin/ppp/modem.c20
-rw-r--r--usr.sbin/ppp/ppp.87
-rw-r--r--usr.sbin/ppp/ppp.8.m47
-rw-r--r--usr.sbin/ppp/vars.h4
6 files changed, 43 insertions, 9 deletions
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index e1e14e7..ff5922f 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -18,7 +18,7 @@
* Columbus, OH 43221
* (614)451-1883
*
- * $Id: chat.c,v 1.27 1997/06/23 23:10:05 brian Exp $
+ * $Id: chat.c,v 1.28 1997/07/01 21:31:21 brian Exp $
*
* TODO:
* o Support more UUCP compatible control sequences.
@@ -569,6 +569,9 @@ DoChat(char *script)
char **argv;
int argc, n, state;
+ if (!script || !*script)
+ return MATCH;
+
/* While we're chatting, we want an INT to fail us */
if (setjmp(ChatEnv)) {
signal(SIGINT, oint);
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 2158947..23125bae 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.65 1997/06/30 03:03:29 brian Exp $
+ * $Id: command.c,v 1.66 1997/07/12 19:22:34 brian Exp $
*
*/
#include <sys/types.h>
@@ -1149,6 +1149,7 @@ char **argv;
#define VAR_DEVICE 4
#define VAR_ACCMAP 5
#define VAR_PHONE 6
+#define VAR_HANGUP 7
static int
SetVariable(list, argc, argv, param)
@@ -1199,6 +1200,10 @@ int param;
strcpy(VarPhoneCopy, VarPhoneList);
VarNextPhone = VarPhoneCopy;
break;
+ case VAR_HANGUP:
+ strncpy(VarHangupScript, arg, sizeof(VarHangupScript)-1);
+ VarHangupScript[sizeof(VarHangupScript)-1] = '\0';
+ break;
}
return 0;
}
@@ -1259,6 +1264,8 @@ struct cmdtab const SetCommands[] = {
"Set dialing script", "set dial chat-script", (void *)VAR_DIAL},
{ "escape", NULL, SetEscape, LOCAL_AUTH,
"Set escape characters", "set escape hex-digit ..."},
+ { "hangup", NULL, SetVariable, LOCAL_AUTH,
+ "Set hangup script", "set hangup chat-script", (void *)VAR_HANGUP},
{ "ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH,
"Set destination address", "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"},
{ "ifilter", NULL, SetIfilter, LOCAL_AUTH,
diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c
index 4625483..9345903 100644
--- a/usr.sbin/ppp/modem.c
+++ b/usr.sbin/ppp/modem.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: modem.c,v 1.43 1997/06/11 03:57:50 brian Exp $
+ * $Id: modem.c,v 1.44 1997/06/23 23:10:13 brian Exp $
*
* TODO:
*/
@@ -206,10 +206,14 @@ static time_t uptime;
void
DownConnection()
{
+ char ScriptBuffer[200];
+
LogPrintf(LogPHASE, "Disconnected!\n");
if (uptime)
LogPrintf(LogPHASE, "Connect time: %d secs\n", time(NULL) - uptime);
uptime = 0;
+ strcpy(ScriptBuffer, VarHangupScript); /* arrays are the same size */
+ DoChat(ScriptBuffer);
if (!TermMode) {
CloseModem();
LcpDown();
@@ -572,13 +576,19 @@ int flag;
*/
if (modem >= 0)
{
- tcflush(modem, TCIOFLUSH);
- UnrawModem(modem);
- close(modem);
+ char ScriptBuffer[200];
+
+ strcpy(ScriptBuffer, VarHangupScript); /* arrays are the same size */
+ DoChat(ScriptBuffer);
+ tcflush(modem, TCIOFLUSH);
+ UnrawModem(modem);
+ close(modem);
}
modem = -1; /* Mark as modem has closed */
(void) uu_unlock(VarBaseDevice);
} else if (modem >= 0) {
+ char ScriptBuffer[200];
+
mbits |= TIOCM_DTR;
#ifndef notyet
ioctl(modem, TIOCMSET, &mbits);
@@ -587,6 +597,8 @@ int flag;
cfsetspeed(&ts, IntToSpeed(VarSpeed));
tcsetattr(modem, TCSADRAIN, &ts);
#endif
+ strcpy(ScriptBuffer, VarHangupScript); /* arrays are the same size */
+ DoChat(ScriptBuffer);
}
}
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index 96fd1c3..d831ade 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.43 1997/06/30 03:03:35 brian Exp $
+.\" $Id: ppp.8,v 1.44 1997/07/01 21:31:28 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -1559,6 +1559,11 @@ below) and the string \\\\P will be replaced with the password (see
.Dq set key
above).
+.It set hangup chat-script
+This specifies the chat script that will be used to reset the modem
+before it is closed. It should not normally be necessary, but can
+be used for devices that fail to reset themselves properly on close.
+
.It set escape value...
This option is similar to the
.Dq set accmap
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index 96fd1c3..d831ade 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.43 1997/06/30 03:03:35 brian Exp $
+.\" $Id: ppp.8,v 1.44 1997/07/01 21:31:28 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -1559,6 +1559,11 @@ below) and the string \\\\P will be replaced with the password (see
.Dq set key
above).
+.It set hangup chat-script
+This specifies the chat script that will be used to reset the modem
+before it is closed. It should not normally be necessary, but can
+be used for devices that fail to reset themselves properly on close.
+
.It set escape value...
This option is similar to the
.Dq set accmap
diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h
index 64f9b81..c80bf7f 100644
--- a/usr.sbin/ppp/vars.h
+++ b/usr.sbin/ppp/vars.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vars.h,v 1.18 1997/06/09 03:27:42 brian Exp $
+ * $Id: vars.h,v 1.19 1997/06/11 03:57:51 brian Exp $
*
* TODO:
*/
@@ -85,6 +85,7 @@ struct pppvars {
char phone_copy[200]; /* copy for strsep() */
char *next_phone; /* Next phone from the list */
char shostname[MAXHOSTNAMELEN];/* Local short Host Name */
+ char hangup_script[200]; /* Hangup script before modem is closed */
struct aliasHandlers handler; /* Alias function pointers */
};
@@ -99,6 +100,7 @@ struct pppvars {
#define VarOpenMode pppVars.open_mode
#define VarLocalAuth pppVars.lauth
#define VarDialScript pppVars.dial_script
+#define VarHangupScript pppVars.hangup_script
#define VarLoginScript pppVars.login_script
#define VarIdleTimeout pppVars.idle_timeout
#define VarLqrTimeout pppVars.lqr_timeout
OpenPOWER on IntegriCloud