1af57ed9fSAtsushi Murai /* 2af57ed9fSAtsushi Murai * PPP Compression Control Protocol (CCP) Module 3af57ed9fSAtsushi Murai * 4af57ed9fSAtsushi Murai * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5af57ed9fSAtsushi Murai * 6af57ed9fSAtsushi Murai * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd. 7af57ed9fSAtsushi Murai * 8af57ed9fSAtsushi Murai * Redistribution and use in source and binary forms are permitted 9af57ed9fSAtsushi Murai * provided that the above copyright notice and this paragraph are 10af57ed9fSAtsushi Murai * duplicated in all such forms and that any documentation, 11af57ed9fSAtsushi Murai * advertising materials, and other materials related to such 12af57ed9fSAtsushi Murai * distribution and use acknowledge that the software was developed 13af57ed9fSAtsushi Murai * by the Internet Initiative Japan, Inc. The name of the 14af57ed9fSAtsushi Murai * IIJ may not be used to endorse or promote products derived 15af57ed9fSAtsushi Murai * from this software without specific prior written permission. 16af57ed9fSAtsushi Murai * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17af57ed9fSAtsushi Murai * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18af57ed9fSAtsushi Murai * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19af57ed9fSAtsushi Murai * 2079d1bdaeSBrian Somers * $Id: ccp.c,v 1.26 1997/12/24 09:28:52 brian Exp $ 21af57ed9fSAtsushi Murai * 22af57ed9fSAtsushi Murai * TODO: 23af57ed9fSAtsushi Murai * o Support other compression protocols 24af57ed9fSAtsushi Murai */ 2575240ed1SBrian Somers #include <sys/param.h> 2675240ed1SBrian Somers #include <netinet/in.h> 2775240ed1SBrian Somers 2875240ed1SBrian Somers #include <stdio.h> 2975240ed1SBrian Somers #include <string.h> 3075240ed1SBrian Somers 31b6e82f33SBrian Somers #include "command.h" 3275240ed1SBrian Somers #include "mbuf.h" 3375240ed1SBrian Somers #include "log.h" 3475240ed1SBrian Somers #include "defs.h" 3575240ed1SBrian Somers #include "timer.h" 36af57ed9fSAtsushi Murai #include "fsm.h" 37af57ed9fSAtsushi Murai #include "lcpproto.h" 38af57ed9fSAtsushi Murai #include "lcp.h" 39af57ed9fSAtsushi Murai #include "ccp.h" 40af57ed9fSAtsushi Murai #include "phase.h" 416ed9fb2fSBrian Somers #include "loadalias.h" 42af57ed9fSAtsushi Murai #include "vars.h" 43ed6a16c1SPoul-Henning Kamp #include "pred.h" 440053cc58SBrian Somers #include "deflate.h" 45af57ed9fSAtsushi Murai 4679d1bdaeSBrian Somers struct ccpstate CcpInfo = { -1, -1 }; 47af57ed9fSAtsushi Murai 48927145beSBrian Somers static void CcpSendConfigReq(struct fsm *); 4975240ed1SBrian Somers static void CcpSendTerminateReq(struct fsm *); 5075240ed1SBrian Somers static void CcpSendTerminateAck(struct fsm *); 5175240ed1SBrian Somers static void CcpDecodeConfig(u_char *, int, int); 52927145beSBrian Somers static void CcpLayerStart(struct fsm *); 53927145beSBrian Somers static void CcpLayerFinish(struct fsm *); 54927145beSBrian Somers static void CcpLayerUp(struct fsm *); 55927145beSBrian Somers static void CcpLayerDown(struct fsm *); 56927145beSBrian Somers static void CcpInitRestartCounter(struct fsm *); 57af57ed9fSAtsushi Murai 58af57ed9fSAtsushi Murai struct fsm CcpFsm = { 59af57ed9fSAtsushi Murai "CCP", 60af57ed9fSAtsushi Murai PROTO_CCP, 61af57ed9fSAtsushi Murai CCP_MAXCODE, 62af57ed9fSAtsushi Murai OPEN_ACTIVE, 63af57ed9fSAtsushi Murai ST_INITIAL, 64af57ed9fSAtsushi Murai 0, 0, 0, 65af57ed9fSAtsushi Murai 0, 66af57ed9fSAtsushi Murai {0, 0, 0, NULL, NULL, NULL}, 67cb611434SBrian Somers {0, 0, 0, NULL, NULL, NULL}, 68cb611434SBrian Somers LogCCP, 69af57ed9fSAtsushi Murai 70af57ed9fSAtsushi Murai CcpLayerUp, 71af57ed9fSAtsushi Murai CcpLayerDown, 72af57ed9fSAtsushi Murai CcpLayerStart, 73af57ed9fSAtsushi Murai CcpLayerFinish, 74af57ed9fSAtsushi Murai CcpInitRestartCounter, 75af57ed9fSAtsushi Murai CcpSendConfigReq, 76af57ed9fSAtsushi Murai CcpSendTerminateReq, 77af57ed9fSAtsushi Murai CcpSendTerminateAck, 78af57ed9fSAtsushi Murai CcpDecodeConfig, 79af57ed9fSAtsushi Murai }; 80af57ed9fSAtsushi Murai 81e53374eaSPoul-Henning Kamp static char const *cftypes[] = { 829e836af5SBrian Somers /* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */ 839e836af5SBrian Somers "OUI", /* 0: OUI */ 849e836af5SBrian Somers "PRED1", /* 1: Predictor type 1 */ 859e836af5SBrian Somers "PRED2", /* 2: Predictor type 2 */ 869e836af5SBrian Somers "PUDDLE", /* 3: Puddle Jumber */ 879e836af5SBrian Somers "???", "???", "???", "???", "???", "???", 889e836af5SBrian Somers "???", "???", "???", "???", "???", "???", 899e836af5SBrian Somers "HWPPC", /* 16: Hewlett-Packard PPC */ 904bc84b8cSBrian Somers "STAC", /* 17: Stac Electronics LZS (rfc1974) */ 919e836af5SBrian Somers "MSPPC", /* 18: Microsoft PPC */ 924bc84b8cSBrian Somers "GAND", /* 19: Gandalf FZA (rfc1993) */ 93b6e82f33SBrian Somers "V42BIS", /* 20: ARG->DATA.42bis compression */ 940053cc58SBrian Somers "BSD", /* 21: BSD LZW Compress */ 950053cc58SBrian Somers "???", 964bc84b8cSBrian Somers "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */ 974bc84b8cSBrian Somers "MAGNALINK/DEFLATE", /* 24: Magnalink Variable Resource (rfc1975) */ 984bc84b8cSBrian Somers /* 24: Deflate (according to pppd-2.3.1) */ 994bc84b8cSBrian Somers "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */ 1004bc84b8cSBrian Somers "DEFLATE", /* 26: Deflate (rfc1979) */ 101af57ed9fSAtsushi Murai }; 102af57ed9fSAtsushi Murai 10370ee81ffSBrian Somers #define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) 1049e836af5SBrian Somers 1050053cc58SBrian Somers static const char * 1060053cc58SBrian Somers protoname(int proto) 1070053cc58SBrian Somers { 1080053cc58SBrian Somers if (proto < 0 || proto > NCFTYPES) 1090053cc58SBrian Somers return "none"; 1100053cc58SBrian Somers return cftypes[proto]; 1110053cc58SBrian Somers } 1120053cc58SBrian Somers 1134bc84b8cSBrian Somers /* We support these algorithms, and Req them in the given order */ 1140053cc58SBrian Somers static const struct ccp_algorithm *algorithm[] = { 1154bc84b8cSBrian Somers &DeflateAlgorithm, 1160053cc58SBrian Somers &Pred1Algorithm, 1174bc84b8cSBrian Somers &PppdDeflateAlgorithm 1180053cc58SBrian Somers }; 1190053cc58SBrian Somers 1200053cc58SBrian Somers static int in_algorithm = -1; 1210053cc58SBrian Somers static int out_algorithm = -1; 12270ee81ffSBrian Somers #define NALGORITHMS (sizeof algorithm/sizeof algorithm[0]) 1230053cc58SBrian Somers 124274e766cSBrian Somers int 125b6e82f33SBrian Somers ReportCcpStatus(struct cmdargs const *arg) 126af57ed9fSAtsushi Murai { 127927145beSBrian Somers if (VarTerm) { 128ea661041SBrian Somers fprintf(VarTerm, "%s [%s]\n", CcpFsm.name, StateNames[CcpFsm.state]); 1290053cc58SBrian Somers fprintf(VarTerm, "My protocol = %s, His protocol = %s\n", 130ea661041SBrian Somers protoname(CcpInfo.my_proto), protoname(CcpInfo.his_proto)); 1310053cc58SBrian Somers fprintf(VarTerm, "Output: %ld --> %ld, Input: %ld --> %ld\n", 132ea661041SBrian Somers CcpInfo.uncompout, CcpInfo.compout, 133ea661041SBrian Somers CcpInfo.compin, CcpInfo.uncompin); 134927145beSBrian Somers } 135274e766cSBrian Somers return 0; 136af57ed9fSAtsushi Murai } 137af57ed9fSAtsushi Murai 138ea661041SBrian Somers static void 139ea661041SBrian Somers ccpstateInit(void) 140af57ed9fSAtsushi Murai { 14179d1bdaeSBrian Somers if (CcpInfo.in_init) 14279d1bdaeSBrian Somers (*algorithm[in_algorithm]->i.Term)(); 14379d1bdaeSBrian Somers if (CcpInfo.out_init) 14479d1bdaeSBrian Somers (*algorithm[out_algorithm]->o.Term)(); 14579d1bdaeSBrian Somers in_algorithm = -1; 14679d1bdaeSBrian Somers out_algorithm = -1; 14770ee81ffSBrian Somers memset(&CcpInfo, '\0', sizeof CcpInfo); 148ea661041SBrian Somers CcpInfo.his_proto = CcpInfo.my_proto = -1; 149ea661041SBrian Somers } 150ea661041SBrian Somers 151ea661041SBrian Somers void 152ea661041SBrian Somers CcpInit() 153ea661041SBrian Somers { 154ea661041SBrian Somers FsmInit(&CcpFsm); 155ea661041SBrian Somers ccpstateInit(); 156af57ed9fSAtsushi Murai CcpFsm.maxconfig = 10; 157af57ed9fSAtsushi Murai } 158af57ed9fSAtsushi Murai 159af57ed9fSAtsushi Murai static void 160944f7098SBrian Somers CcpInitRestartCounter(struct fsm *fp) 161af57ed9fSAtsushi Murai { 16253c9f6c0SAtsushi Murai fp->FsmTimer.load = VarRetryTimeout * SECTICKS; 163af57ed9fSAtsushi Murai fp->restart = 5; 164af57ed9fSAtsushi Murai } 165af57ed9fSAtsushi Murai 166af57ed9fSAtsushi Murai static void 167944f7098SBrian Somers CcpSendConfigReq(struct fsm *fp) 168af57ed9fSAtsushi Murai { 169af57ed9fSAtsushi Murai u_char *cp; 1700053cc58SBrian Somers int f; 171af57ed9fSAtsushi Murai 172cb611434SBrian Somers LogPrintf(LogCCP, "CcpSendConfigReq\n"); 1730053cc58SBrian Somers cp = ReqBuff; 1740053cc58SBrian Somers CcpInfo.my_proto = -1; 1750053cc58SBrian Somers out_algorithm = -1; 1760053cc58SBrian Somers for (f = 0; f < NALGORITHMS; f++) 177ea661041SBrian Somers if (Enabled(algorithm[f]->Conf) && !REJECTED(&CcpInfo, algorithm[f]->id)) { 1780053cc58SBrian Somers struct lcp_opt o; 1790053cc58SBrian Somers 1800053cc58SBrian Somers (*algorithm[f]->o.Get)(&o); 1810053cc58SBrian Somers cp += LcpPutConf(LogCCP, cp, &o, cftypes[o.id], 1820053cc58SBrian Somers (*algorithm[f]->Disp)(&o)); 1830053cc58SBrian Somers CcpInfo.my_proto = o.id; 1840053cc58SBrian Somers out_algorithm = f; 185af57ed9fSAtsushi Murai } 186af57ed9fSAtsushi Murai FsmOutput(fp, CODE_CONFIGREQ, fp->reqid++, ReqBuff, cp - ReqBuff); 187af57ed9fSAtsushi Murai } 188af57ed9fSAtsushi Murai 189af57ed9fSAtsushi Murai void 190944f7098SBrian Somers CcpSendResetReq(struct fsm *fp) 191af57ed9fSAtsushi Murai { 192cb611434SBrian Somers LogPrintf(LogCCP, "CcpSendResetReq\n"); 193af57ed9fSAtsushi Murai FsmOutput(fp, CODE_RESETREQ, fp->reqid, NULL, 0); 194af57ed9fSAtsushi Murai } 195af57ed9fSAtsushi Murai 196af57ed9fSAtsushi Murai static void 197944f7098SBrian Somers CcpSendTerminateReq(struct fsm *fp) 198af57ed9fSAtsushi Murai { 199af57ed9fSAtsushi Murai /* XXX: No code yet */ 200af57ed9fSAtsushi Murai } 201af57ed9fSAtsushi Murai 202af57ed9fSAtsushi Murai static void 203944f7098SBrian Somers CcpSendTerminateAck(struct fsm *fp) 204af57ed9fSAtsushi Murai { 205cb611434SBrian Somers LogPrintf(LogCCP, "CcpSendTerminateAck\n"); 206af57ed9fSAtsushi Murai FsmOutput(fp, CODE_TERMACK, fp->reqid++, NULL, 0); 207af57ed9fSAtsushi Murai } 208af57ed9fSAtsushi Murai 209af57ed9fSAtsushi Murai void 210944f7098SBrian Somers CcpRecvResetReq(struct fsm *fp) 211af57ed9fSAtsushi Murai { 2120053cc58SBrian Somers if (out_algorithm >= 0 && out_algorithm < NALGORITHMS) 2130053cc58SBrian Somers (*algorithm[out_algorithm]->o.Reset)(); 214af57ed9fSAtsushi Murai } 215af57ed9fSAtsushi Murai 216af57ed9fSAtsushi Murai static void 217944f7098SBrian Somers CcpLayerStart(struct fsm *fp) 218af57ed9fSAtsushi Murai { 219cb611434SBrian Somers LogPrintf(LogCCP, "CcpLayerStart.\n"); 220af57ed9fSAtsushi Murai } 221af57ed9fSAtsushi Murai 222af57ed9fSAtsushi Murai static void 223944f7098SBrian Somers CcpLayerFinish(struct fsm *fp) 224af57ed9fSAtsushi Murai { 225cb611434SBrian Somers LogPrintf(LogCCP, "CcpLayerFinish.\n"); 226ea661041SBrian Somers ccpstateInit(); 227af57ed9fSAtsushi Murai } 228af57ed9fSAtsushi Murai 229af57ed9fSAtsushi Murai static void 230944f7098SBrian Somers CcpLayerDown(struct fsm *fp) 231af57ed9fSAtsushi Murai { 232cb611434SBrian Somers LogPrintf(LogCCP, "CcpLayerDown.\n"); 233ea661041SBrian Somers ccpstateInit(); 234af57ed9fSAtsushi Murai } 235af57ed9fSAtsushi Murai 236af57ed9fSAtsushi Murai /* 2370053cc58SBrian Somers * Called when CCP has reached the OPEN state 238af57ed9fSAtsushi Murai */ 239af57ed9fSAtsushi Murai static void 240944f7098SBrian Somers CcpLayerUp(struct fsm *fp) 241af57ed9fSAtsushi Murai { 242cb611434SBrian Somers LogPrintf(LogCCP, "CcpLayerUp(%d).\n", fp->state); 2430053cc58SBrian Somers LogPrintf(LogCCP, "Out = %s[%d], In = %s[%d]\n", 2440053cc58SBrian Somers protoname(CcpInfo.my_proto), CcpInfo.my_proto, 2450053cc58SBrian Somers protoname(CcpInfo.his_proto), CcpInfo.his_proto); 24679d1bdaeSBrian Somers if (!CcpInfo.in_init && in_algorithm >= 0 && in_algorithm < NALGORITHMS) { 2470053cc58SBrian Somers (*algorithm[in_algorithm]->i.Init)(); 24879d1bdaeSBrian Somers CcpInfo.in_init = 1; 24979d1bdaeSBrian Somers } 25079d1bdaeSBrian Somers if (!CcpInfo.out_init && out_algorithm >= 0 && out_algorithm < NALGORITHMS) { 2510053cc58SBrian Somers (*algorithm[out_algorithm]->o.Init)(); 25279d1bdaeSBrian Somers CcpInfo.out_init = 1; 25379d1bdaeSBrian Somers } 254af57ed9fSAtsushi Murai } 255af57ed9fSAtsushi Murai 256af57ed9fSAtsushi Murai void 257af57ed9fSAtsushi Murai CcpUp() 258af57ed9fSAtsushi Murai { 259af57ed9fSAtsushi Murai FsmUp(&CcpFsm); 260cb611434SBrian Somers LogPrintf(LogCCP, "CCP Up event!!\n"); 261af57ed9fSAtsushi Murai } 262af57ed9fSAtsushi Murai 263af57ed9fSAtsushi Murai void 264af57ed9fSAtsushi Murai CcpOpen() 265af57ed9fSAtsushi Murai { 2660053cc58SBrian Somers int f; 2670053cc58SBrian Somers 2680053cc58SBrian Somers for (f = 0; f < NALGORITHMS; f++) 2690053cc58SBrian Somers if (Enabled(algorithm[f]->Conf)) { 2700053cc58SBrian Somers CcpFsm.open_mode = OPEN_ACTIVE; 271af57ed9fSAtsushi Murai FsmOpen(&CcpFsm); 2720053cc58SBrian Somers break; 2730053cc58SBrian Somers } 2740053cc58SBrian Somers 2750053cc58SBrian Somers if (f == NALGORITHMS) 2760053cc58SBrian Somers for (f = 0; f < NALGORITHMS; f++) 2770053cc58SBrian Somers if (Acceptable(algorithm[f]->Conf)) { 2780053cc58SBrian Somers CcpFsm.open_mode = OPEN_PASSIVE; 2790053cc58SBrian Somers FsmOpen(&CcpFsm); 2800053cc58SBrian Somers break; 2810053cc58SBrian Somers } 282af57ed9fSAtsushi Murai } 283af57ed9fSAtsushi Murai 284af57ed9fSAtsushi Murai static void 2859780ef31SBrian Somers CcpDecodeConfig(u_char *cp, int plen, int mode_type) 286af57ed9fSAtsushi Murai { 28753c9f6c0SAtsushi Murai int type, length; 2880053cc58SBrian Somers int f; 289af57ed9fSAtsushi Murai 290af57ed9fSAtsushi Murai ackp = AckBuff; 291af57ed9fSAtsushi Murai nakp = NakBuff; 292af57ed9fSAtsushi Murai rejp = RejBuff; 293af57ed9fSAtsushi Murai 294af57ed9fSAtsushi Murai while (plen >= sizeof(struct fsmconfig)) { 295af57ed9fSAtsushi Murai type = *cp; 296af57ed9fSAtsushi Murai length = cp[1]; 2979e836af5SBrian Somers if (type < NCFTYPES) 2980053cc58SBrian Somers LogPrintf(LogCCP, " %s[%d]\n", cftypes[type], length); 299af57ed9fSAtsushi Murai else 3000053cc58SBrian Somers LogPrintf(LogCCP, " ???[%d]\n", length); 301af57ed9fSAtsushi Murai 3020053cc58SBrian Somers for (f = NALGORITHMS-1; f > -1; f--) 3030053cc58SBrian Somers if (algorithm[f]->id == type) 3040053cc58SBrian Somers break; 305af57ed9fSAtsushi Murai 3060053cc58SBrian Somers if (f == -1) { 3070053cc58SBrian Somers /* Don't understand that :-( */ 3080053cc58SBrian Somers if (mode_type == MODE_REQ) { 3090053cc58SBrian Somers CcpInfo.my_reject |= (1 << type); 3100053cc58SBrian Somers memcpy(rejp, cp, length); 3110053cc58SBrian Somers rejp += length; 3120053cc58SBrian Somers } 3130053cc58SBrian Somers } else { 3140053cc58SBrian Somers struct lcp_opt o; 3150053cc58SBrian Somers 3169780ef31SBrian Somers switch (mode_type) { 317af57ed9fSAtsushi Murai case MODE_REQ: 3180053cc58SBrian Somers if (Acceptable(algorithm[f]->Conf) && in_algorithm == -1) { 3190053cc58SBrian Somers memcpy(&o, cp, length); 3200053cc58SBrian Somers switch ((*algorithm[f]->i.Set)(&o)) { 3210053cc58SBrian Somers case MODE_REJ: 3220053cc58SBrian Somers memcpy(rejp, &o, o.len); 3230053cc58SBrian Somers rejp += o.len; 3240053cc58SBrian Somers break; 3250053cc58SBrian Somers case MODE_NAK: 3260053cc58SBrian Somers memcpy(nakp, &o, o.len); 3270053cc58SBrian Somers nakp += o.len; 3280053cc58SBrian Somers break; 3290053cc58SBrian Somers case MODE_ACK: 33075240ed1SBrian Somers memcpy(ackp, cp, length); 331af57ed9fSAtsushi Murai ackp += length; 332af57ed9fSAtsushi Murai CcpInfo.his_proto = type; 3330053cc58SBrian Somers in_algorithm = f; /* This one'll do ! */ 3340053cc58SBrian Somers break; 3350053cc58SBrian Somers } 336af57ed9fSAtsushi Murai } else { 33775240ed1SBrian Somers memcpy(rejp, cp, length); 338af57ed9fSAtsushi Murai rejp += length; 339af57ed9fSAtsushi Murai } 340af57ed9fSAtsushi Murai break; 341af57ed9fSAtsushi Murai case MODE_NAK: 3420053cc58SBrian Somers memcpy(&o, cp, length); 3430053cc58SBrian Somers if ((*algorithm[f]->o.Set)(&o) == MODE_ACK) 3440053cc58SBrian Somers CcpInfo.my_proto = algorithm[f]->id; 3450053cc58SBrian Somers else { 3460053cc58SBrian Somers CcpInfo.his_reject |= (1 << type); 3470053cc58SBrian Somers CcpInfo.my_proto = -1; 3480053cc58SBrian Somers } 3490053cc58SBrian Somers break; 350af57ed9fSAtsushi Murai case MODE_REJ: 351af57ed9fSAtsushi Murai CcpInfo.his_reject |= (1 << type); 3520053cc58SBrian Somers CcpInfo.my_proto = -1; 353af57ed9fSAtsushi Murai break; 354af57ed9fSAtsushi Murai } 355af57ed9fSAtsushi Murai } 3560053cc58SBrian Somers 357af57ed9fSAtsushi Murai plen -= length; 358af57ed9fSAtsushi Murai cp += length; 359af57ed9fSAtsushi Murai } 3600053cc58SBrian Somers 3610053cc58SBrian Somers if (rejp != RejBuff) { 3620053cc58SBrian Somers ackp = AckBuff; /* let's not send both ! */ 3630053cc58SBrian Somers CcpInfo.his_proto = -1; 3640053cc58SBrian Somers in_algorithm = -1; 3650053cc58SBrian Somers } 366af57ed9fSAtsushi Murai } 367af57ed9fSAtsushi Murai 368af57ed9fSAtsushi Murai void 369af57ed9fSAtsushi Murai CcpInput(struct mbuf *bp) 370af57ed9fSAtsushi Murai { 371af57ed9fSAtsushi Murai if (phase == PHASE_NETWORK) 372af57ed9fSAtsushi Murai FsmInput(&CcpFsm, bp); 373af57ed9fSAtsushi Murai else { 37429a6597cSBrian Somers if (phase > PHASE_NETWORK) 375bcc332bdSBrian Somers LogPrintf(LogCCP, "Error: Unexpected CCP in phase %d\n", phase); 376af57ed9fSAtsushi Murai pfree(bp); 377af57ed9fSAtsushi Murai } 378af57ed9fSAtsushi Murai } 3790053cc58SBrian Somers 3800053cc58SBrian Somers void 3810053cc58SBrian Somers CcpResetInput() 3820053cc58SBrian Somers { 3830053cc58SBrian Somers if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) 3840053cc58SBrian Somers (*algorithm[in_algorithm]->i.Reset)(); 3850053cc58SBrian Somers } 3860053cc58SBrian Somers 3870053cc58SBrian Somers int 3880053cc58SBrian Somers CcpOutput(int pri, u_short proto, struct mbuf *m) 3890053cc58SBrian Somers { 3900053cc58SBrian Somers if (out_algorithm >= 0 && out_algorithm < NALGORITHMS) 3910053cc58SBrian Somers return (*algorithm[out_algorithm]->o.Write)(pri, proto, m); 3920053cc58SBrian Somers return 0; 3930053cc58SBrian Somers } 3940053cc58SBrian Somers 3950053cc58SBrian Somers struct mbuf * 3960053cc58SBrian Somers CompdInput(u_short *proto, struct mbuf *m) 3970053cc58SBrian Somers { 3980053cc58SBrian Somers if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) 3990053cc58SBrian Somers return (*algorithm[in_algorithm]->i.Read)(proto, m); 4000053cc58SBrian Somers return NULL; 4010053cc58SBrian Somers } 4020053cc58SBrian Somers 4030053cc58SBrian Somers void 4040053cc58SBrian Somers CcpDictSetup(u_short proto, struct mbuf *m) 4050053cc58SBrian Somers { 4060053cc58SBrian Somers if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) 4070053cc58SBrian Somers (*algorithm[in_algorithm]->i.DictSetup)(proto, m); 4080053cc58SBrian Somers } 409