/** * initializing mppe context. * - reading configuration. */ void mppe_init(mppe *_this, npppd_ppp *ppp) { struct tunnconf *conf; MPPE_ASSERT(ppp != NULL); MPPE_ASSERT(_this != NULL); memset(_this, 0, sizeof(mppe)); _this->ppp = ppp; _this->mode_auto = 1; _this->mode_stateless = 0; conf = ppp_get_tunnconf(ppp); _this->enabled = conf->mppe_yesno; if (_this->enabled == 0) goto mppe_config_done; _this->required = conf->mppe_required; if (conf->mppe_keystate == (NPPPD_MPPE_STATEFUL|NPPPD_MPPE_STATELESS)) { /* no need to change from default. */ } else if (conf->mppe_keystate == NPPPD_MPPE_STATELESS) { _this->mode_auto = 0; _this->mode_stateless = 1; } else if (conf->mppe_keystate == NPPPD_MPPE_STATEFUL) { _this->mode_auto = 0; _this->mode_stateless = 0; } _this->keylenbits = 0; if ((conf->mppe_keylen & NPPPD_MPPE_40BIT) != 0) _this->keylenbits |= CCP_MPPE_NT_40bit; if ((conf->mppe_keylen & NPPPD_MPPE_56BIT) != 0) _this->keylenbits |= CCP_MPPE_NT_56bit; if ((conf->mppe_keylen & NPPPD_MPPE_128BIT) != 0) _this->keylenbits |= CCP_MPPE_NT_128bit; mppe_config_done: /* nothing */; }
/** Initialize the context for ccp */ void ccp_init(ccp *_this, npppd_ppp *ppp) { struct tunnconf *conf; memset(_this, 0, sizeof(ccp)); _this->ppp = ppp; _this->fsm.callbacks = &ccp_callbacks; _this->fsm.protocol = PPP_PROTO_NCP | NCP_CCP; _this->fsm.ppp = ppp; fsm_init(&_this->fsm); conf = ppp_get_tunnconf(ppp); PPP_FSM_CONFIG(&_this->fsm, timeouttime, conf->ccp_timeout); PPP_FSM_CONFIG(&_this->fsm, maxconfreqtransmits, conf->ccp_max_configure); PPP_FSM_CONFIG(&_this->fsm, maxtermtransmits, conf->ccp_max_terminate); PPP_FSM_CONFIG(&_this->fsm, maxnakloops, conf->ccp_max_nak_loop); }
/** Initialize the CHAP */ void chap_init(chap *_this, npppd_ppp *ppp) { struct tunnconf *conf; CHAP_ASSERT(ppp != NULL); CHAP_ASSERT(_this != NULL); memset(_this, 0, sizeof(chap)); _this->ppp = ppp; conf = ppp_get_tunnconf(ppp); if (conf->chap_name == NULL) gethostname(_this->myname, sizeof(_this->myname)); else strlcpy(_this->myname, conf->chap_name, sizeof(_this->myname)); _this->timerctx.ctx = _this; _this->state = CHAP_STATE_INITIAL; _this->ntry = CHAP_RETRY; }