mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
"dial" now may optionally have context.
Tidy up some LcpInfo uses.
This commit is contained in:
parent
5563ebde73
commit
dc0fdb6bc1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=34532
10 changed files with 69 additions and 60 deletions
|
@ -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.1.2.21 1998/03/13 00:43:52 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.22 1998/03/13 00:44:32 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -640,7 +640,6 @@ bundle_Open(struct bundle *bundle, const char *name)
|
|||
if (name != NULL)
|
||||
break;
|
||||
}
|
||||
bundle_NewPhase(bundle, PHASE_ESTABLISH);
|
||||
}
|
||||
|
||||
struct datalink *
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.c,v 1.30.2.17 1998/03/01 01:07:39 brian Exp $
|
||||
* $Id: ccp.c,v 1.30.2.18 1998/03/13 00:43:54 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
|
@ -124,7 +124,7 @@ static const struct ccp_algorithm *algorithm[] = {
|
|||
int
|
||||
ccp_ReportStatus(struct cmdargs const *arg)
|
||||
{
|
||||
struct ccp *ccp = bundle2ccp(arg->bundle, arg->cx ? arg->cx->name : NULL);
|
||||
struct ccp *ccp = arg->cx ? &arg->cx->ccp : bundle2ccp(arg->bundle, NULL);
|
||||
|
||||
prompt_Printf(&prompt, "%s [%s]\n", ccp->fsm.name,
|
||||
StateNames[ccp->fsm.state]);
|
||||
|
|
|
@ -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.131.2.33 1998/03/09 19:26:36 brian Exp $
|
||||
* $Id: command.c,v 1.131.2.34 1998/03/13 00:43:58 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
|
@ -172,12 +172,6 @@ DialCommand(struct cmdargs const *arg)
|
|||
{
|
||||
int res;
|
||||
|
||||
if (LcpInfo.fsm.state > ST_CLOSED) {
|
||||
prompt_Printf(&prompt, "LCP state is [%s]\n",
|
||||
StateNames[LcpInfo.fsm.state]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((mode & MODE_DAEMON) && !(mode & MODE_AUTO)) {
|
||||
LogPrintf(LogWARN,
|
||||
"Manual dial is only available in auto and interactive mode\n");
|
||||
|
@ -187,7 +181,7 @@ DialCommand(struct cmdargs const *arg)
|
|||
if (arg->argc > 0 && (res = LoadCommand(arg)) != 0)
|
||||
return res;
|
||||
|
||||
bundle_Open(arg->bundle, NULL);
|
||||
bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -356,7 +350,7 @@ static struct cmdtab const Commands[] = {
|
|||
"delete a route if it exists", "delete! dest", (void *)1},
|
||||
{"deny", NULL, DenyCommand, LOCAL_AUTH,
|
||||
"Deny option request", "deny option .."},
|
||||
{"dial", "call", DialCommand, LOCAL_AUTH,
|
||||
{"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
||||
"Dial and login", "dial|call [remote]"},
|
||||
{"disable", NULL, DisableCommand, LOCAL_AUTH,
|
||||
"Disable option", "disable option .."},
|
||||
|
@ -583,7 +577,7 @@ static struct cmdtab const ShowCommands[] = {
|
|||
"Show Input filters", "show ifilter option .."},
|
||||
{"ipcp", NULL, ReportIpcpStatus, LOCAL_AUTH,
|
||||
"Show IPCP status", "show ipcp"},
|
||||
{"lcp", NULL, ReportLcpStatus, LOCAL_AUTH,
|
||||
{"lcp", NULL, ReportLcpStatus, LOCAL_AUTH | LOCAL_CX,
|
||||
"Show LCP status", "show lcp"},
|
||||
{"links", "link", bundle_ShowLinks, LOCAL_AUTH,
|
||||
"Show available link names", "show links"},
|
||||
|
@ -827,7 +821,7 @@ QuitCommand(struct cmdargs const *arg)
|
|||
static int
|
||||
CloseCommand(struct cmdargs const *arg)
|
||||
{
|
||||
bundle_Close(LcpInfo.fsm.bundle, arg->cx ? arg->cx->name : NULL, 1);
|
||||
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.1.2.18 1998/03/13 00:43:59 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.19 1998/03/13 00:44:33 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -495,7 +495,7 @@ datalink_Create(const char *name, struct bundle *bundle,
|
|||
dl->cfg.reconnect_timeout = RECONNECT_TIMEOUT;
|
||||
|
||||
dl->name = strdup(name);
|
||||
if ((dl->physical = modem_Create(dl->name)) == NULL) {
|
||||
if ((dl->physical = modem_Create(dl->name, dl)) == NULL) {
|
||||
free(dl->name);
|
||||
free(dl);
|
||||
return NULL;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.c,v 1.27.2.16 1998/02/27 01:22:22 brian Exp $
|
||||
* $Id: fsm.c,v 1.27.2.17 1998/03/13 00:44:02 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Refer loglevel for log output
|
||||
|
@ -50,6 +50,11 @@
|
|||
#include "descriptor.h"
|
||||
#include "physical.h"
|
||||
#include "bundle.h"
|
||||
#include "auth.h"
|
||||
#include "chat.h"
|
||||
#include "chap.h"
|
||||
#include "pap.h"
|
||||
#include "datalink.h"
|
||||
|
||||
u_char AckBuff[200];
|
||||
u_char NakBuff[200];
|
||||
|
@ -710,17 +715,19 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
|||
LogPrintf(LogERROR, "FsmRecvProtoRej: Not a physical link !\n");
|
||||
break;
|
||||
case PROTO_CCP:
|
||||
fp = &bundle2ccp(fp->bundle, fp->link->name)->fsm;
|
||||
(*fp->fn->LayerFinish)(fp);
|
||||
switch (fp->state) {
|
||||
case ST_CLOSED:
|
||||
case ST_CLOSING:
|
||||
NewState(fp, ST_CLOSED);
|
||||
default:
|
||||
NewState(fp, ST_STOPPED);
|
||||
break;
|
||||
if (fp->proto == PROTO_LCP) {
|
||||
fp = &lcp2ccp(fsm2lcp(fp))->fsm;
|
||||
(*fp->fn->LayerFinish)(fp);
|
||||
switch (fp->state) {
|
||||
case ST_CLOSED:
|
||||
case ST_CLOSING:
|
||||
NewState(fp, ST_CLOSED);
|
||||
default:
|
||||
NewState(fp, ST_STOPPED);
|
||||
break;
|
||||
}
|
||||
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
||||
}
|
||||
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
|
@ -729,20 +736,23 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
|||
static void
|
||||
FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
{
|
||||
struct lcp *lcp = fsm2lcp(fp);
|
||||
u_char *cp;
|
||||
u_long *lp, magic;
|
||||
|
||||
cp = MBUF_CTOP(bp);
|
||||
lp = (u_long *) cp;
|
||||
magic = ntohl(*lp);
|
||||
if (magic != LcpInfo.his_magic) {
|
||||
LogPrintf(LogERROR, "RecvEchoReq: his magic is bad!!\n");
|
||||
/* XXX: We should send terminate request */
|
||||
}
|
||||
if (fp->state == ST_OPENED) {
|
||||
*lp = htonl(LcpInfo.want_magic); /* Insert local magic number */
|
||||
LogPrintf(fp->LogLevel, "SendEchoRep(%s)\n", StateNames[fp->state]);
|
||||
FsmOutput(fp, CODE_ECHOREP, lhp->id, cp, plength(bp));
|
||||
if (lcp) {
|
||||
cp = MBUF_CTOP(bp);
|
||||
lp = (u_long *) cp;
|
||||
magic = ntohl(*lp);
|
||||
if (magic != lcp->his_magic) {
|
||||
LogPrintf(LogERROR, "RecvEchoReq: his magic is bad!!\n");
|
||||
/* XXX: We should send terminate request */
|
||||
}
|
||||
if (fp->state == ST_OPENED) {
|
||||
*lp = htonl(lcp->want_magic); /* Insert local magic number */
|
||||
LogPrintf(fp->LogLevel, "SendEchoRep(%s)\n", StateNames[fp->state]);
|
||||
FsmOutput(fp, CODE_ECHOREP, lhp->id, cp, plength(bp));
|
||||
}
|
||||
}
|
||||
pfree(bp);
|
||||
}
|
||||
|
@ -750,21 +760,24 @@ FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
|||
static void
|
||||
FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
{
|
||||
struct lcp *lcp = fsm2lcp(fp);
|
||||
u_long *lp, magic;
|
||||
|
||||
lp = (u_long *) MBUF_CTOP(bp);
|
||||
magic = ntohl(*lp);
|
||||
/* Tolerate echo replies with either magic number */
|
||||
if (magic != 0 && magic != LcpInfo.his_magic && magic != LcpInfo.want_magic) {
|
||||
LogPrintf(LogERROR, "RecvEchoRep: his magic is wrong! expect: %x got: %x\n",
|
||||
LcpInfo.his_magic, magic);
|
||||
|
||||
/*
|
||||
* XXX: We should send terminate request. But poor implementation may die
|
||||
* as a result.
|
||||
*/
|
||||
if (lcp) {
|
||||
lp = (u_long *) MBUF_CTOP(bp);
|
||||
magic = ntohl(*lp);
|
||||
/* Tolerate echo replies with either magic number */
|
||||
if (magic != 0 && magic != lcp->his_magic && magic != lcp->want_magic) {
|
||||
LogPrintf(LogWARN,
|
||||
"RecvEchoRep: Bad magic: expected 0x%08x, got: 0x%08x\n",
|
||||
lcp->his_magic, magic);
|
||||
/*
|
||||
* XXX: We should send terminate request. But poor implementation may die
|
||||
* as a result.
|
||||
*/
|
||||
}
|
||||
RecvEchoLqr(fp, bp);
|
||||
}
|
||||
RecvEchoLqr(fp, bp);
|
||||
pfree(bp);
|
||||
}
|
||||
|
||||
|
@ -836,7 +849,7 @@ static const struct fsmcodedesc {
|
|||
};
|
||||
|
||||
void
|
||||
FsmInput(struct fsm * fp, struct mbuf * bp)
|
||||
FsmInput(struct fsm *fp, struct mbuf * bp)
|
||||
{
|
||||
int len;
|
||||
struct fsmheader *lhp;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: hdlc.c,v 1.28.2.15 1998/03/01 01:07:44 brian Exp $
|
||||
* $Id: hdlc.c,v 1.28.2.16 1998/03/13 00:44:03 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
|
@ -468,7 +468,6 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical)
|
|||
cp = MBUF_CTOP(bp);
|
||||
|
||||
if (!LcpInfo.want_acfcomp) {
|
||||
|
||||
/*
|
||||
* We expect that packet is not compressed.
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.16.2.11 1998/02/21 01:45:17 brian Exp $
|
||||
* $Id: lcp.h,v 1.16.2.12 1998/02/27 01:22:35 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
|
@ -74,6 +74,7 @@ struct physical;
|
|||
extern struct lcp LcpInfo;
|
||||
|
||||
#define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL)
|
||||
#define lcp2ccp(lcp) (&link2physical((lcp)->fsm.link)->dl->ccp)
|
||||
|
||||
extern void lcp_Init(struct lcp *, struct bundle *, struct physical *,
|
||||
const struct fsm_parent *);
|
||||
|
|
|
@ -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.77.2.31 1998/03/11 02:21:59 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.32 1998/03/13 00:44:16 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ static int modem_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *,
|
|||
int *);
|
||||
|
||||
struct physical *
|
||||
modem_Create(const char *name)
|
||||
modem_Create(const char *name, struct datalink *dl)
|
||||
{
|
||||
struct physical *p;
|
||||
|
||||
|
@ -123,6 +123,7 @@ modem_Create(const char *name)
|
|||
p->dev_is_modem = 0;
|
||||
p->out = NULL;
|
||||
p->connect_count = 0;
|
||||
p->dl = dl;
|
||||
|
||||
*p->name.full = '\0';
|
||||
p->name.base = p->name.full;
|
||||
|
|
|
@ -15,16 +15,17 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: modem.h,v 1.16.2.10 1998/02/23 00:38:38 brian Exp $
|
||||
* $Id: modem.h,v 1.16.2.11 1998/03/06 00:34:44 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
|
||||
struct datalink;
|
||||
struct physical;
|
||||
struct ccp;
|
||||
|
||||
extern int modem_Raw(struct physical *, struct bundle *);
|
||||
extern struct physical *modem_Create(const char *);
|
||||
extern struct physical *modem_Create(const char *, struct datalink *);
|
||||
extern int modem_Open(struct physical *, struct bundle *);
|
||||
extern int modem_Speed(struct physical *);
|
||||
extern speed_t IntToSpeed(int);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: physical.h,v 1.1.2.13 1998/03/06 00:34:46 brian Exp $
|
||||
* $Id: physical.h,v 1.1.2.14 1998/03/10 03:05:58 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -35,6 +35,7 @@ struct physical {
|
|||
|
||||
struct mbuf *out; /* mbuf that suffered a short write */
|
||||
int connect_count;
|
||||
struct datalink *dl; /* my owner */
|
||||
|
||||
struct {
|
||||
char full[40];
|
||||
|
|
Loading…
Reference in a new issue