Make `close lcp' just close the LCP layer and not hangup. This is
useful for slirp users that wish to get their shell back after the ppp session. `close' with no args still hangs up as expected. Required by: jmz
This commit is contained in:
parent
6ab2c9633b
commit
9c81b87d1e
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.c,v 1.14 1998/06/07 00:16:37 brian Exp $
|
||||
* $Id: bundle.c,v 1.15 1998/06/12 17:45:03 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -226,7 +226,7 @@ bundle_AutoLoadTimeout(void *v)
|
||||
last = dl;
|
||||
|
||||
if (last)
|
||||
datalink_Close(last, 1);
|
||||
datalink_Close(last, CLOSE_STAYDOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ bundle_LayerFinish(void *v, struct fsm *fp)
|
||||
if (bundle_Phase(bundle) != PHASE_DEAD)
|
||||
bundle_NewPhase(bundle, PHASE_TERMINATE);
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
datalink_Close(dl, 0);
|
||||
datalink_Close(dl, CLOSE_NORMAL);
|
||||
fsm_Down(fp);
|
||||
fsm_Close(fp);
|
||||
} else if (fp->proto == PROTO_LCP) {
|
||||
@ -454,7 +454,7 @@ bundle_LinkIsUp(const struct bundle *bundle)
|
||||
}
|
||||
|
||||
void
|
||||
bundle_Close(struct bundle *bundle, const char *name, int staydown)
|
||||
bundle_Close(struct bundle *bundle, const char *name, int how)
|
||||
{
|
||||
/*
|
||||
* Please close the given datalink.
|
||||
@ -476,8 +476,14 @@ bundle_Close(struct bundle *bundle, const char *name, int staydown)
|
||||
if (name && !strcasecmp(name, dl->name))
|
||||
this_dl = dl;
|
||||
if (name == NULL || this_dl == dl) {
|
||||
if (staydown)
|
||||
datalink_StayDown(dl);
|
||||
switch (how) {
|
||||
case CLOSE_LCP:
|
||||
datalink_DontHangup(dl);
|
||||
/* fall through */
|
||||
case CLOSE_STAYDOWN:
|
||||
datalink_StayDown(dl);
|
||||
break;
|
||||
}
|
||||
} else if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP)
|
||||
others_active++;
|
||||
}
|
||||
@ -499,11 +505,11 @@ bundle_Close(struct bundle *bundle, const char *name, int staydown)
|
||||
fsm_Down(&bundle->ncp.ipcp.fsm);
|
||||
}
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
datalink_Close(dl, staydown);
|
||||
datalink_Close(dl, how);
|
||||
}
|
||||
} else if (this_dl && this_dl->state != DATALINK_CLOSED &&
|
||||
this_dl->state != DATALINK_HANGUP)
|
||||
datalink_Close(this_dl, staydown);
|
||||
datalink_Close(this_dl, how);
|
||||
}
|
||||
|
||||
void
|
||||
@ -512,7 +518,7 @@ bundle_Down(struct bundle *bundle)
|
||||
struct datalink *dl;
|
||||
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
datalink_Down(dl, 1);
|
||||
datalink_Down(dl, CLOSE_STAYDOWN);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1254,7 +1260,7 @@ bundle_IdleTimeout(void *v)
|
||||
|
||||
log_Printf(LogPHASE, "Idle timer expired.\n");
|
||||
bundle_StopIdleTimer(bundle);
|
||||
bundle_Close(bundle, NULL, 1);
|
||||
bundle_Close(bundle, NULL, CLOSE_STAYDOWN);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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.140 1998/06/12 17:45:08 brian Exp $
|
||||
* $Id: command.c,v 1.141 1998/06/12 20:12:25 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -124,7 +124,7 @@
|
||||
#define NEG_DNS 50
|
||||
|
||||
const char Version[] = "2.0-beta";
|
||||
const char VersionDate[] = "$Date: 1998/06/12 17:45:08 $";
|
||||
const char VersionDate[] = "$Date: 1998/06/12 20:12:25 $";
|
||||
|
||||
static int ShowCommand(struct cmdargs const *);
|
||||
static int TerminalCommand(struct cmdargs const *);
|
||||
@ -872,26 +872,29 @@ OpenCommand(struct cmdargs const *arg)
|
||||
static int
|
||||
CloseCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc == arg->argn ||
|
||||
(arg->argc == arg->argn+1 && !strcasecmp(arg->argv[arg->argn], "lcp")))
|
||||
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, 1);
|
||||
else if (arg->argc == arg->argn+1 &&
|
||||
(!strcasecmp(arg->argv[arg->argn], "ccp") ||
|
||||
!strcasecmp(arg->argv[arg->argn], "ccp!"))) {
|
||||
struct link *l;
|
||||
struct fsm *fp;
|
||||
if (arg->argc == arg->argn)
|
||||
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, CLOSE_STAYDOWN);
|
||||
else if (arg->argc == arg->argn + 1) {
|
||||
if (!strcasecmp(arg->argv[arg->argn], "lcp"))
|
||||
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, CLOSE_LCP);
|
||||
else if (!strcasecmp(arg->argv[arg->argn], "ccp") ||
|
||||
!strcasecmp(arg->argv[arg->argn], "ccp!")) {
|
||||
struct link *l;
|
||||
struct fsm *fp;
|
||||
|
||||
if (!(l = command_ChooseLink(arg)))
|
||||
if (!(l = command_ChooseLink(arg)))
|
||||
return -1;
|
||||
fp = &l->ccp.fsm;
|
||||
|
||||
if (fp->state == ST_OPENED) {
|
||||
fsm_Close(fp);
|
||||
if (arg->argv[arg->argn][3] == '!')
|
||||
fp->open_mode = 0; /* Stay ST_CLOSED */
|
||||
else
|
||||
fp->open_mode = OPEN_PASSIVE; /* Wait for the peer to start */
|
||||
}
|
||||
} else
|
||||
return -1;
|
||||
fp = &l->ccp.fsm;
|
||||
|
||||
if (fp->state == ST_OPENED) {
|
||||
fsm_Close(fp);
|
||||
if (arg->argv[arg->argn][3] == '!')
|
||||
fp->open_mode = 0; /* Stay ST_CLOSED */
|
||||
else
|
||||
fp->open_mode = OPEN_PASSIVE; /* Wait for the peer to start */
|
||||
}
|
||||
} else
|
||||
return -1;
|
||||
|
||||
@ -904,7 +907,7 @@ DownCommand(struct cmdargs const *arg)
|
||||
if (arg->argc == arg->argn ||
|
||||
(arg->argc == arg->argn+1 && !strcasecmp(arg->argv[arg->argn], "lcp"))) {
|
||||
if (arg->cx)
|
||||
datalink_Down(arg->cx, 1);
|
||||
datalink_Down(arg->cx, CLOSE_STAYDOWN);
|
||||
else
|
||||
bundle_Down(arg->bundle);
|
||||
} else if (arg->argc == arg->argn+1 &&
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.c,v 1.7 1998/05/29 18:32:10 brian Exp $
|
||||
* $Id: datalink.c,v 1.8 1998/06/12 17:45:09 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -389,14 +389,19 @@ datalink_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
}
|
||||
|
||||
static void
|
||||
datalink_ComeDown(struct datalink *dl, int stay)
|
||||
datalink_ComeDown(struct datalink *dl, int how)
|
||||
{
|
||||
if (stay) {
|
||||
if (how != CLOSE_NORMAL) {
|
||||
dl->dial_tries = -1;
|
||||
dl->reconnect_tries = 0;
|
||||
if (how == CLOSE_LCP)
|
||||
dl->stayonline = 1;
|
||||
}
|
||||
|
||||
if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) {
|
||||
if (dl->stayonline) {
|
||||
dl->stayonline = 0;
|
||||
datalink_NewState(dl, DATALINK_READY);
|
||||
} else if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) {
|
||||
modem_Offline(dl->physical);
|
||||
if (dl->script.run && dl->state != DATALINK_OPENING) {
|
||||
datalink_NewState(dl, DATALINK_HANGUP);
|
||||
@ -532,7 +537,7 @@ datalink_LayerFinish(void *v, struct fsm *fp)
|
||||
fsm_Close(fp); /* back to CLOSED */
|
||||
fsm_Down(fp); /* Bring us to INITIAL or STARTING */
|
||||
(*dl->parent->LayerFinish)(dl->parent->object, fp);
|
||||
datalink_ComeDown(dl, 0);
|
||||
datalink_ComeDown(dl, CLOSE_NORMAL);
|
||||
} else if (fp->state == ST_CLOSED && fp->open_mode == OPEN_PASSIVE)
|
||||
fsm_Open(fp); /* CCP goes to ST_STOPPED */
|
||||
}
|
||||
@ -562,6 +567,7 @@ datalink_Create(const char *name, struct bundle *bundle, int type)
|
||||
dl->phone.next = NULL;
|
||||
dl->phone.alt = NULL;
|
||||
dl->phone.chosen = "N/A";
|
||||
dl->stayonline = 0;
|
||||
dl->script.run = 1;
|
||||
dl->script.packetmode = 1;
|
||||
mp_linkInit(&dl->mp);
|
||||
@ -728,7 +734,7 @@ datalink_Up(struct datalink *dl, int runscripts, int packetmode)
|
||||
}
|
||||
|
||||
void
|
||||
datalink_Close(struct datalink *dl, int stay)
|
||||
datalink_Close(struct datalink *dl, int how)
|
||||
{
|
||||
/* Please close */
|
||||
switch (dl->state) {
|
||||
@ -741,19 +747,21 @@ datalink_Close(struct datalink *dl, int stay)
|
||||
case DATALINK_AUTH:
|
||||
case DATALINK_LCP:
|
||||
fsm_Close(&dl->physical->link.lcp.fsm);
|
||||
if (stay) {
|
||||
if (how != CLOSE_NORMAL) {
|
||||
dl->dial_tries = -1;
|
||||
dl->reconnect_tries = 0;
|
||||
if (how == CLOSE_LCP)
|
||||
dl->stayonline = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
datalink_ComeDown(dl, stay);
|
||||
datalink_ComeDown(dl, how);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
datalink_Down(struct datalink *dl, int stay)
|
||||
datalink_Down(struct datalink *dl, int how)
|
||||
{
|
||||
/* Carrier is lost */
|
||||
switch (dl->state) {
|
||||
@ -768,14 +776,14 @@ datalink_Down(struct datalink *dl, int stay)
|
||||
if (dl->physical->link.lcp.fsm.state == ST_STOPPED)
|
||||
fsm_Close(&dl->physical->link.lcp.fsm); /* back to CLOSED */
|
||||
fsm_Down(&dl->physical->link.lcp.fsm);
|
||||
if (stay)
|
||||
if (how != CLOSE_NORMAL)
|
||||
fsm_Close(&dl->physical->link.lcp.fsm);
|
||||
else
|
||||
fsm_Open(&dl->physical->link.ccp.fsm);
|
||||
/* fall through */
|
||||
|
||||
default:
|
||||
datalink_ComeDown(dl, stay);
|
||||
datalink_ComeDown(dl, how);
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,6 +793,12 @@ datalink_StayDown(struct datalink *dl)
|
||||
dl->reconnect_tries = 0;
|
||||
}
|
||||
|
||||
void
|
||||
datalink_DontHangup(struct datalink *dl)
|
||||
{
|
||||
dl->stayonline = 1;
|
||||
}
|
||||
|
||||
int
|
||||
datalink_Show(struct cmdargs const *arg)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.h,v 1.2 1998/05/21 21:44:57 brian Exp $
|
||||
* $Id: datalink.h,v 1.3 1998/05/28 23:15:35 brian Exp $
|
||||
*/
|
||||
|
||||
#define DATALINK_CLOSED (0)
|
||||
@ -36,7 +36,12 @@
|
||||
#define DATALINK_AUTH (7)
|
||||
#define DATALINK_OPEN (8)
|
||||
|
||||
#define DATALINK_MAXNAME (20)
|
||||
#define DATALINK_MAXNAME (20) /* Maximum datalink::name length */
|
||||
|
||||
/* How to close the link */
|
||||
#define CLOSE_NORMAL 0
|
||||
#define CLOSE_STAYDOWN 1
|
||||
#define CLOSE_LCP 2
|
||||
|
||||
struct iovec;
|
||||
struct prompt;
|
||||
@ -50,6 +55,7 @@ struct datalink {
|
||||
|
||||
struct chat chat; /* For bringing the link up & down */
|
||||
|
||||
unsigned stayonline : 1; /* stay online when LCP is closed ? */
|
||||
struct {
|
||||
unsigned run : 1; /* run scripts ? */
|
||||
unsigned packetmode : 1; /* Go into packet mode after login ? */
|
||||
@ -117,6 +123,7 @@ extern void datalink_Up(struct datalink *, int, int);
|
||||
extern void datalink_Close(struct datalink *, int);
|
||||
extern void datalink_Down(struct datalink *, int);
|
||||
extern void datalink_StayDown(struct datalink *);
|
||||
extern void datalink_DontHangup(struct datalink *);
|
||||
extern void datalink_AuthOk(struct datalink *);
|
||||
extern void datalink_AuthNotOk(struct datalink *);
|
||||
extern int datalink_Show(struct cmdargs const *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lqr.c,v 1.22.2.30 1998/05/08 01:15:08 brian Exp $
|
||||
* $Id: lqr.c,v 1.25 1998/05/21 21:46:33 brian Exp $
|
||||
*
|
||||
* o LQR based on RFC1333
|
||||
*
|
||||
@ -136,7 +136,7 @@ SendLqrReport(void *v)
|
||||
log_Printf(LogLQM, "%s: Too many LQR packets lost\n",
|
||||
lcp->fsm.link->name);
|
||||
p->hdlc.lqm.method = 0;
|
||||
datalink_Down(p->dl, 0);
|
||||
datalink_Down(p->dl, CLOSE_NORMAL);
|
||||
} else {
|
||||
SendLqrData(lcp);
|
||||
p->hdlc.lqm.lqr.resent++;
|
||||
@ -151,7 +151,7 @@ SendLqrReport(void *v)
|
||||
log_Printf(LogLQM, "%s: Too many ECHO LQR packets lost\n",
|
||||
lcp->fsm.link->name);
|
||||
p->hdlc.lqm.method = 0;
|
||||
datalink_Down(p->dl, 0);
|
||||
datalink_Down(p->dl, CLOSE_NORMAL);
|
||||
} else
|
||||
SendEchoReq(lcp);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.129 1998/05/29 18:33:09 brian Exp $
|
||||
* $Id: main.c,v 1.130 1998/06/06 20:50:57 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -90,7 +90,7 @@ Cleanup(int excode)
|
||||
{
|
||||
SignalBundle->CleaningUp = 1;
|
||||
if (bundle_Phase(SignalBundle) != PHASE_DEAD)
|
||||
bundle_Close(SignalBundle, NULL, 1);
|
||||
bundle_Close(SignalBundle, NULL, CLOSE_STAYDOWN);
|
||||
}
|
||||
|
||||
void
|
||||
@ -98,7 +98,7 @@ AbortProgram(int excode)
|
||||
{
|
||||
server_Close(SignalBundle);
|
||||
log_Printf(LogPHASE, "PPP Terminated (%s).\n", ex_desc(excode));
|
||||
bundle_Close(SignalBundle, NULL, 1);
|
||||
bundle_Close(SignalBundle, NULL, CLOSE_STAYDOWN);
|
||||
bundle_Destroy(SignalBundle);
|
||||
log_Close();
|
||||
exit(excode);
|
||||
|
@ -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.87 1998/05/28 23:17:51 brian Exp $
|
||||
* $Id: modem.c,v 1.88 1998/05/29 18:33:09 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -281,7 +281,7 @@ modem_Timeout(void *data)
|
||||
if (ioctl(modem->fd, TIOCMGET, &modem->mbits) < 0) {
|
||||
log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", modem->link.name,
|
||||
strerror(errno));
|
||||
datalink_Down(modem->dl, 0);
|
||||
datalink_Down(modem->dl, CLOSE_NORMAL);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
@ -293,7 +293,7 @@ modem_Timeout(void *data)
|
||||
else {
|
||||
log_Printf(LogDEBUG, "%s: online -> offline\n", modem->link.name);
|
||||
log_Printf(LogPHASE, "%s: Carrier lost\n", modem->link.name);
|
||||
datalink_Down(modem->dl, 0);
|
||||
datalink_Down(modem->dl, CLOSE_NORMAL);
|
||||
}
|
||||
} else
|
||||
log_Printf(LogDEBUG, "%s: Still %sline\n", modem->link.name,
|
||||
@ -855,7 +855,7 @@ modem_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
|
||||
if (errno != EAGAIN) {
|
||||
log_Printf(LogPHASE, "%s: write (%d): %s\n", modem->link.name,
|
||||
modem->fd, strerror(errno));
|
||||
datalink_Down(modem->dl, 0);
|
||||
datalink_Down(modem->dl, CLOSE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -951,7 +951,7 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
else
|
||||
log_Printf(LogPHASE, "%s: read (%d): Got zero bytes\n",
|
||||
p->link.name, p->fd);
|
||||
datalink_Down(p->dl, 0);
|
||||
datalink_Down(p->dl, CLOSE_NORMAL);
|
||||
return;
|
||||
}
|
||||
log_DumpBuff(LogASYNC, "ReadFromModem", rbuff, n);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.103 1998/06/12 17:45:26 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.104 1998/06/12 20:12:26 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -2321,9 +2321,17 @@ command below.
|
||||
The default link name is
|
||||
.Dq deflink .
|
||||
.It close Op lcp|ccp[!]
|
||||
If no arguments are given, or if
|
||||
If no arguments are given, the relevant protocol layers will be brought
|
||||
down and the link will be closed. If
|
||||
.Dq lcp
|
||||
is specified, the link will be closed. If
|
||||
is specified, the LCP layer is brought down, but
|
||||
.Nm
|
||||
will not bring the link offline. It is subsequently possible to use
|
||||
.Dq term
|
||||
.Pq see below
|
||||
to talk to the peer machine if, for example, something like
|
||||
.Dq slirp
|
||||
is being used. If
|
||||
.Dq ccp
|
||||
is specified, only the relevant compression layer is closed. If the
|
||||
.Dq \&!
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.103 1998/06/12 17:45:26 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.104 1998/06/12 20:12:26 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -2321,9 +2321,17 @@ command below.
|
||||
The default link name is
|
||||
.Dq deflink .
|
||||
.It close Op lcp|ccp[!]
|
||||
If no arguments are given, or if
|
||||
If no arguments are given, the relevant protocol layers will be brought
|
||||
down and the link will be closed. If
|
||||
.Dq lcp
|
||||
is specified, the link will be closed. If
|
||||
is specified, the LCP layer is brought down, but
|
||||
.Nm
|
||||
will not bring the link offline. It is subsequently possible to use
|
||||
.Dq term
|
||||
.Pq see below
|
||||
to talk to the peer machine if, for example, something like
|
||||
.Dq slirp
|
||||
is being used. If
|
||||
.Dq ccp
|
||||
is specified, only the relevant compression layer is closed. If the
|
||||
.Dq \&!
|
||||
|
Loading…
x
Reference in New Issue
Block a user