From 79d1bdaedb83960e20e1f36ec0376cd2c2d14b69 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Sun, 4 Jan 1998 20:25:41 +0000 Subject: Initialize CcpInfo protocols to -1 (none, not OUI). Don't Call Term() for an algorithm that hasn't been Init()d. --- usr.sbin/ppp/ccp.c | 26 ++++++++++++++------------ usr.sbin/ppp/ccp.h | 5 ++++- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index aa92ba33856c..e49cf3a3a591 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 diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h index e6ff2c5fcafd..840e2daf9608 100644 --- a/usr.sbin/ppp/ccp.h +++ b/usr.sbin/ppp/ccp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.h,v 1.10 1997/12/03 10:23:45 brian Exp $ + * $Id: ccp.h,v 1.11 1997/12/03 23:27:55 brian Exp $ * * TODO: */ @@ -42,6 +42,9 @@ struct ccpstate { u_long his_reject; /* Request codes rejected by peer */ u_long my_reject; /* Request codes I have rejected */ + int out_init; /* Init called for out algorithm */ + int in_init; /* Init called for in algorithm */ + u_long uncompout, compout; u_long uncompin, compin; }; -- cgit v1.2.3