summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/ccp.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1998-01-04 20:25:41 +0000
committerbrian <brian@FreeBSD.org>1998-01-04 20:25:41 +0000
commit97d6e021bf076ca180eefdf6dbbb7d2c42b1a50c (patch)
tree6491af06ce3b51abac087d0951abc11cfcfc1f9c /usr.sbin/ppp/ccp.c
parent656b2e5431f28568380a2cfee11c1da47900076b (diff)
downloadFreeBSD-src-97d6e021bf076ca180eefdf6dbbb7d2c42b1a50c.zip
FreeBSD-src-97d6e021bf076ca180eefdf6dbbb7d2c42b1a50c.tar.gz
Initialize CcpInfo protocols to -1 (none, not OUI).
Don't Call Term() for an algorithm that hasn't been Init()d.
Diffstat (limited to 'usr.sbin/ppp/ccp.c')
-rw-r--r--usr.sbin/ppp/ccp.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index aa92ba3..e49cf3a 100644
--- a/usr.sbin/ppp/ccp.c
+++ b/usr.sbin/ppp/ccp.c
@@ -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.25 1997/12/17 21:21:53 brian Exp $
+ * $Id: ccp.c,v 1.26 1997/12/24 09:28:52 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -43,7 +43,7 @@
#include "pred.h"
#include "deflate.h"
-struct ccpstate CcpInfo;
+struct ccpstate CcpInfo = { -1, -1 };
static void CcpSendConfigReq(struct fsm *);
static void CcpSendTerminateReq(struct fsm *);
@@ -138,16 +138,14 @@ ReportCcpStatus(struct cmdargs const *arg)
static void
ccpstateInit(void)
{
- memset(&CcpInfo, '\0', sizeof CcpInfo);
- CcpInfo.his_proto = CcpInfo.my_proto = -1;
- if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) {
+ if (CcpInfo.in_init)
(*algorithm[in_algorithm]->i.Term)();
- in_algorithm = -1;
- }
- if (out_algorithm >= 0 && out_algorithm < NALGORITHMS) {
+ if (CcpInfo.out_init)
(*algorithm[out_algorithm]->o.Term)();
- out_algorithm = -1;
- }
+ in_algorithm = -1;
+ out_algorithm = -1;
+ memset(&CcpInfo, '\0', sizeof CcpInfo);
+ CcpInfo.his_proto = CcpInfo.my_proto = -1;
}
void
@@ -245,10 +243,14 @@ CcpLayerUp(struct fsm *fp)
LogPrintf(LogCCP, "Out = %s[%d], In = %s[%d]\n",
protoname(CcpInfo.my_proto), CcpInfo.my_proto,
protoname(CcpInfo.his_proto), CcpInfo.his_proto);
- if (in_algorithm >= 0 && in_algorithm < NALGORITHMS)
+ if (!CcpInfo.in_init && in_algorithm >= 0 && in_algorithm < NALGORITHMS) {
(*algorithm[in_algorithm]->i.Init)();
- if (out_algorithm >= 0 && out_algorithm < NALGORITHMS)
+ CcpInfo.in_init = 1;
+ }
+ if (!CcpInfo.out_init && out_algorithm >= 0 && out_algorithm < NALGORITHMS) {
(*algorithm[out_algorithm]->o.Init)();
+ CcpInfo.out_init = 1;
+ }
}
void
OpenPOWER on IntegriCloud