int ppp_start(int ttyfd) { //ppp_debug(PPPLVL_NOTE, "start ppp...\n"); printf("start ppp1...\n"); printf("start ppp ttyfd = %d\n",ttyfd); ppp_isup = 0; tty_fd = ttyfd; //printf("establish_ppp succ\n"); printf("start ppp ttyfd = %d\n",ttyfd); if(establish_ppp(ttyfd)) { printf("establish_ppp_fail\n"); return 1; } else { printf("establish_ppp succ\n"); } printf("start ppp2...\n"); lcp_init(); printf("start ppp3...\n"); if(lcp_start()) { ppp_debug(PPPLVL_NOTE, "lcp start fail\n"); goto err_close; } printf("lcp start succ\n"); ppp_debug(PPPLVL_NOTE, "lcp start OK\n"); printf("start ppp4...\n"); if(chap_start()) { ppp_debug(PPPLVL_NOTE, "chap start fail\n"); goto err_close; } ppp_debug(PPPLVL_NOTE, "chap start OK\n"); printf("start ppp5...\n"); ipcp_init(); if(ipcp_start()) { ppp_debug(PPPLVL_NOTE, "ipcp start fail\n"); goto err_close; } printf("start ppp6...\n"); ppp_debug(PPPLVL_NOTE, "ipcp start OK\n"); if(ppp_netup()) { ppp_debug(PPPLVL_NOTE, "ppp up failed!\n"); goto err_close; } ppp_debug(PPPLVL_ALM, "ppp up!\n"); printf("start ppp7...\n"); ppp_isup = 1; return 0; err_close: ppp_end(ttyfd); return 1; }
/** called when the lcp is up */ void ppp_lcp_up(npppd_ppp *_this) { #ifdef USE_NPPPD_MPPE if (MPPE_REQUIRED(_this) && !MPPE_MUST_NEGO(_this)) { ppp_log(_this, LOG_ERR, "MPPE is required, auth protocol must " "be MS-CHAP-V2 or EAP"); ppp_stop(_this, "Encryption required"); return; } #endif /* * Use our MRU value even if the peer insists on larger value. * We set the peer_mtu here, the value will be used as the MTU of the * routing entry. So we will not receive packets larger than the MTU. */ if (_this->peer_mru > _this->mru) _this->peer_mru = _this->mru; if (_this->peer_auth != 0 && _this->auth_runonce == 0) { if (AUTH_IS_PAP(_this)) { pap_start(&_this->pap); _this->auth_runonce = 1; return; } if (AUTH_IS_CHAP(_this)) { chap_start(&_this->chap); _this->auth_runonce = 1; return; } #ifdef USE_NPPPD_EAP_RADIUS if (AUTH_IS_EAP(_this)) { eap_init(&_this->eap, _this); eap_start(&_this->eap); return; } #endif } if (_this->peer_auth == 0) ppp_auth_ok(_this); }