PPP, CORE, don't use ppp_ioctl() from PPP core, assign pcb->err_code instead

Removed useless calls to ppp_ioctl(pcb, PPPCTLS_ERRCODE, …), we now assign
pcb->err_code directly instead. ppp_ioctl() is not linked anymore if user
application don't use it.
This commit is contained in:
Sylvain Rochet 2015-02-21 21:42:59 +01:00
parent dc2e700057
commit c4d1354c54
2 changed files with 7 additions and 15 deletions

View File

@ -728,7 +728,6 @@ void link_established(ppp_pcb *pcb) {
#if PPP_AUTH_SUPPORT #if PPP_AUTH_SUPPORT
int auth; int auth;
#if PPP_SERVER #if PPP_SERVER
int errcode;
lcp_options *wo = &pcb->lcp_wantoptions; lcp_options *wo = &pcb->lcp_wantoptions;
lcp_options *go = &pcb->lcp_gotoptions; lcp_options *go = &pcb->lcp_gotoptions;
#endif /* PPP_SERVER */ #endif /* PPP_SERVER */
@ -783,8 +782,7 @@ void link_established(ppp_pcb *pcb) {
#if 0 /* UNUSED */ #if 0 /* UNUSED */
status = EXIT_PEER_AUTH_FAILED; status = EXIT_PEER_AUTH_FAILED;
#endif /* UNUSED */ #endif /* UNUSED */
errcode = PPPERR_AUTHFAIL; pcb->err_code = PPPERR_AUTHFAIL;
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
lcp_close(pcb, "peer refused to authenticate"); lcp_close(pcb, "peer refused to authenticate");
return; return;
} }
@ -1001,7 +999,6 @@ void continue_networks(ppp_pcb *pcb) {
* The peer has failed to authenticate himself using `protocol'. * The peer has failed to authenticate himself using `protocol'.
*/ */
void auth_peer_fail(ppp_pcb *pcb, int protocol) { void auth_peer_fail(ppp_pcb *pcb, int protocol) {
int errcode = PPPERR_AUTHFAIL;
LWIP_UNUSED_ARG(protocol); LWIP_UNUSED_ARG(protocol);
/* /*
* Authentication failure: take the link down * Authentication failure: take the link down
@ -1009,7 +1006,7 @@ void auth_peer_fail(ppp_pcb *pcb, int protocol) {
#if 0 /* UNUSED */ #if 0 /* UNUSED */
status = EXIT_PEER_AUTH_FAILED; status = EXIT_PEER_AUTH_FAILED;
#endif /* UNUSED */ #endif /* UNUSED */
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); pcb->err_code = PPPERR_AUTHFAIL;
lcp_close(pcb, "Authentication failed"); lcp_close(pcb, "Authentication failed");
} }
@ -1083,7 +1080,6 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char *
* We have failed to authenticate ourselves to the peer using `protocol'. * We have failed to authenticate ourselves to the peer using `protocol'.
*/ */
void auth_withpeer_fail(ppp_pcb *pcb, int protocol) { void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
int errcode = PPPERR_AUTHFAIL;
LWIP_UNUSED_ARG(protocol); LWIP_UNUSED_ARG(protocol);
/* /*
* We've failed to authenticate ourselves to our peer. * We've failed to authenticate ourselves to our peer.
@ -1095,7 +1091,7 @@ void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
* He'll probably take the link down, and there's not much * He'll probably take the link down, and there's not much
* we can do except wait for that. * we can do except wait for that.
*/ */
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); pcb->err_code = PPPERR_AUTHFAIL;
lcp_close(pcb, "Failed to authenticate ourselves to peer"); lcp_close(pcb, "Failed to authenticate ourselves to peer");
} }
@ -1306,10 +1302,9 @@ static void check_idle(void *arg) {
} }
#endif /* UNUSED */ #endif /* UNUSED */
if (tlim <= 0) { if (tlim <= 0) {
int errcode = PPPERR_IDLETIMEOUT;
/* link is idle: shut it down. */ /* link is idle: shut it down. */
ppp_notice("Terminating connection due to lack of activity."); ppp_notice("Terminating connection due to lack of activity.");
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); pcb->err_code = PPPERR_IDLETIMEOUT;
lcp_close(pcb, "Link inactive"); lcp_close(pcb, "Link inactive");
#if 0 /* UNUSED */ #if 0 /* UNUSED */
need_holdoff = 0; need_holdoff = 0;
@ -1325,10 +1320,9 @@ static void check_idle(void *arg) {
* connect_time_expired - log a message and close the connection. * connect_time_expired - log a message and close the connection.
*/ */
static void connect_time_expired(void *arg) { static void connect_time_expired(void *arg) {
int errcode = PPPERR_CONNECTTIME;
ppp_pcb *pcb = (ppp_pcb*)arg; ppp_pcb *pcb = (ppp_pcb*)arg;
ppp_info("Connect time expired"); ppp_info("Connect time expired");
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); pcb->err_code = PPPERR_CONNECTTIME;
lcp_close(pcb, "Connect time expired"); /* Close connection */ lcp_close(pcb, "Connect time expired"); /* Close connection */
} }
#endif /* PPP_MAXCONNECT */ #endif /* PPP_MAXCONNECT */

View File

@ -1467,9 +1467,8 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
if (f->state != PPP_FSM_OPENED) { if (f->state != PPP_FSM_OPENED) {
if (looped_back) { if (looped_back) {
if (++try_.numloops >= pcb->settings.lcp_loopbackfail) { if (++try_.numloops >= pcb->settings.lcp_loopbackfail) {
int errcode = PPPERR_LOOPBACK;
ppp_notice("Serial line is looped back."); ppp_notice("Serial line is looped back.");
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); pcb->err_code = PPPERR_LOOPBACK;
lcp_close(f->pcb, "Loopback detected"); lcp_close(f->pcb, "Loopback detected");
} }
} else } else
@ -2547,10 +2546,9 @@ static int lcp_printpkt(u_char *p, int plen,
static void LcpLinkFailure(fsm *f) { static void LcpLinkFailure(fsm *f) {
ppp_pcb *pcb = f->pcb; ppp_pcb *pcb = f->pcb;
if (f->state == PPP_FSM_OPENED) { if (f->state == PPP_FSM_OPENED) {
int errcode = PPPERR_PEERDEAD;
ppp_info("No response to %d echo-requests", pcb->lcp_echos_pending); ppp_info("No response to %d echo-requests", pcb->lcp_echos_pending);
ppp_notice("Serial link appears to be disconnected."); ppp_notice("Serial link appears to be disconnected.");
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); pcb->err_code = PPPERR_PEERDEAD;
lcp_close(pcb, "Peer not responding"); lcp_close(pcb, "Peer not responding");
} }
} }