diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index f7c79760..45001336 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -194,7 +194,7 @@ void link_terminated(int unit) if (logged_in) logout(); lcp_phase[unit] = PHASE_DEAD; - ppp_trace(LOG_NOTICE, "Connection terminated.\n"); + AUTHDEBUG((LOG_NOTICE, "Connection terminated.\n")); pppMainWakeup(unit); } @@ -257,7 +257,7 @@ void link_established(int unit) * of "" and a password of "". If that's not OK, boot it out. */ if (!wo->neg_upap || !null_login(unit)) { - ppp_trace(LOG_WARNING, "peer refused to authenticate\n"); + AUTHDEBUG((LOG_WARNING, "peer refused to authenticate\n")); lcp_close(unit, "peer refused to authenticate"); return; } @@ -294,7 +294,7 @@ void link_established(int unit) if (ppp_settings.passwd[0] == 0) { passwd_from_file = 1; if (!get_pap_passwd(unit, ppp_settings.user, ppp_settings.passwd)) - ppp_trace(LOG_ERR, "No secret found for PAP login\n"); + AUTHDEBUG((LOG_ERR, "No secret found for PAP login\n")); } upap_authwithpeer(unit, ppp_settings.user, ppp_settings.passwd); auth |= PAP_WITHPEER; @@ -337,8 +337,8 @@ void auth_peer_success(int unit, u16_t protocol, char *name, int namelen) pbit = PAP_PEER; break; default: - ppp_trace(LOG_WARNING, "auth_peer_success: unknown protocol %x\n", - protocol); + AUTHDEBUG((LOG_WARNING, "auth_peer_success: unknown protocol %x\n", + protocol)); return; } @@ -400,8 +400,8 @@ void auth_withpeer_success(int unit, u16_t protocol) pbit = PAP_WITHPEER; break; default: - ppp_trace(LOG_WARNING, "auth_peer_success: unknown protocol %x\n", - protocol); + AUTHDEBUG((LOG_WARNING, "auth_peer_success: unknown protocol %x\n", + protocol)); pbit = 0; } @@ -541,7 +541,7 @@ int check_passwd( * On 10'th, drop the connection. */ if (attempts++ >= 10) { - ppp_trace(LOG_WARNING, "%d LOGIN FAILURES BY %s\n", attempts, user); + AUTHDEBUG((LOG_WARNING, "%d LOGIN FAILURES BY %s\n", attempts, user)); /*ppp_panic("Excess Bad Logins");*/ } if (attempts > 3) { @@ -616,7 +616,7 @@ int get_secret( len = strlen(ppp_settings.passwd); if (len > MAXSECRETLEN) { - ppp_trace(LOG_ERR, "Secret for %s on %s is too long\n", client, server); + AUTHDEBUG((LOG_ERR, "Secret for %s on %s is too long\n", client, server)); len = MAXSECRETLEN; } BCOPY(ppp_settings.passwd, secret, len); @@ -640,7 +640,7 @@ int get_secret( len = strlen(secbuf); if (len > MAXSECRETLEN) { - ppp_trace(LOG_ERR, "Secret for %s on %s is too long\n", client, server); + AUTHDEBUG((LOG_ERR, "Secret for %s on %s is too long\n", client, server)); len = MAXSECRETLEN; } BCOPY(secbuf, secret, len); @@ -753,7 +753,7 @@ static void check_idle(void *arg) itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); if (itime >= ppp_settings.idle_time_limit) { /* link is idle: shut it down. */ - ppp_trace(LOG_INFO, "Terminating connection due to lack of activity.\n"); + AUTHDEBUG((LOG_INFO, "Terminating connection due to lack of activity.\n")); lcp_close(0, "Link inactive"); } else { TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit - itime); @@ -767,7 +767,7 @@ static void connect_time_expired(void *arg) { (void)arg; - ppp_trace(LOG_INFO, "Connect time expired\n"); + AUTHDEBUG((LOG_INFO, "Connect time expired\n")); lcp_close(0, "Connect time expired"); /* Close connection */ } diff --git a/src/netif/ppp/chap.c b/src/netif/ppp/chap.c index 3860b671..4d1dc0d2 100644 --- a/src/netif/ppp/chap.c +++ b/src/netif/ppp/chap.c @@ -245,7 +245,7 @@ static void ChapChallengeTimeout(void *arg) if (cstate->chal_transmits >= cstate->max_transmits) { /* give up on peer */ - ppp_trace(LOG_ERR, "Peer failed to respond to CHAP challenge\n"); + CHAPDEBUG((LOG_ERR, "Peer failed to respond to CHAP challenge\n")); cstate->serverstate = CHAPSS_BADAUTH; auth_peer_fail(cstate->unit, PPP_CHAP); return; @@ -405,7 +405,7 @@ static void ChapInput(int unit, u_char *inpacket, int packet_len) break; default: /* Need code reject? */ - ppp_trace(LOG_WARNING, "Unknown CHAP code (%d) received.\n", code); + CHAPDEBUG((LOG_WARNING, "Unknown CHAP code (%d) received.\n", code)); break; } } @@ -466,7 +466,7 @@ static void ChapReceiveChallenge(chap_state *cstate, u_char *inp, int id, int le if (!get_secret(cstate->unit, cstate->resp_name, rhostname, secret, &secret_len, 0)) { secret_len = 0; /* assume null secret if can't find one */ - ppp_trace(LOG_WARNING, "No CHAP secret found for authenticating us to %s\n", rhostname); + CHAPDEBUG((LOG_WARNING, "No CHAP secret found for authenticating us to %s\n", rhostname)); } /* cancel response send timeout if necessary */ @@ -576,8 +576,8 @@ static void ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len if (!get_secret(cstate->unit, rhostname, cstate->chal_name, secret, &secret_len, 1)) { /* CHAPDEBUG((LOG_WARNING, TL_CHAP, "No CHAP secret found for authenticating %s\n", rhostname)); */ - ppp_trace(LOG_WARNING, "No CHAP secret found for authenticating %s\n", - rhostname); + CHAPDEBUG((LOG_WARNING, "No CHAP secret found for authenticating %s\n", + rhostname)); } else { /* generate MD based on negotiated type */ @@ -614,7 +614,7 @@ static void ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len if (cstate->chal_interval != 0) TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval); } else { - ppp_trace(LOG_ERR, "CHAP peer authentication failed\n"); + CHAPDEBUG((LOG_ERR, "CHAP peer authentication failed\n")); cstate->serverstate = CHAPSS_BADAUTH; auth_peer_fail(cstate->unit, PPP_CHAP); } @@ -675,7 +675,7 @@ static void ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int l if (len > 0) PRINTMSG(inp, len); - ppp_trace(LOG_ERR, "CHAP authentication failed\n"); + CHAPDEBUG((LOG_ERR, "CHAP authentication failed\n")); auth_withpeer_fail(cstate->unit, PPP_CHAP); } diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index 59f84447..67c2061b 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -1192,12 +1192,12 @@ static void ipcp_up(fsm *f) ho->hisaddr = wo->hisaddr; if (ho->hisaddr == 0) { - ppp_trace(LOG_ERR, "Could not determine remote IP address\n"); + IPCPDEBUG((LOG_ERR, "Could not determine remote IP address\n")); ipcp_close(f->unit, "Could not determine remote IP address"); return; } if (go->ouraddr == 0) { - ppp_trace(LOG_ERR, "Could not determine local IP address\n"); + IPCPDEBUG((LOG_ERR, "Could not determine local IP address\n")); ipcp_close(f->unit, "Could not determine local IP address"); return; } @@ -1210,8 +1210,8 @@ static void ipcp_up(fsm *f) * Check that the peer is allowed to use the IP address it wants. */ if (!auth_ip_addr(f->unit, ho->hisaddr)) { - ppp_trace(LOG_ERR, "Peer is not authorized to use remote address %s\n", - inet_ntoa(ho->hisaddr)); + IPCPDEBUG((LOG_ERR, "Peer is not authorized to use remote address %s\n", + inet_ntoa(ho->hisaddr))); ipcp_close(f->unit, "Unauthorized remote IP address"); return; } diff --git a/src/netif/ppp/pap.c b/src/netif/ppp/pap.c index 1edf1c1e..23e438ff 100644 --- a/src/netif/ppp/pap.c +++ b/src/netif/ppp/pap.c @@ -216,7 +216,7 @@ static void upap_timeout(void *arg) if (u->us_transmits >= u->us_maxtransmits) { /* give up in disgust */ - ppp_trace(LOG_ERR, "No response to PAP authenticate-requests\n"); + UPAPDEBUG((LOG_ERR, "No response to PAP authenticate-requests\n")); u->us_clientstate = UPAPCS_BADAUTH; auth_withpeer_fail(u->us_unit, PPP_PAP); return; @@ -299,11 +299,11 @@ static void upap_protrej(int unit) upap_state *u = &upap[unit]; if (u->us_clientstate == UPAPCS_AUTHREQ) { - ppp_trace(LOG_ERR, "PAP authentication failed due to protocol-reject\n"); + UPAPDEBUG((LOG_ERR, "PAP authentication failed due to protocol-reject\n")); auth_withpeer_fail(unit, PPP_PAP); } if (u->us_serverstate == UPAPSS_LISTEN) { - ppp_trace(LOG_ERR, "PAP authentication of peer failed (protocol-reject)\n"); + UPAPDEBUG((LOG_ERR, "PAP authentication of peer failed (protocol-reject)\n")); auth_peer_fail(unit, PPP_PAP); } upap_lowerdown(unit); @@ -518,7 +518,7 @@ static void upap_rauthnak( u->us_clientstate = UPAPCS_BADAUTH; - ppp_trace(LOG_ERR, "PAP authentication failed\n"); + UPAPDEBUG((LOG_ERR, "PAP authentication failed\n")); auth_withpeer_fail(u->us_unit, PPP_PAP); } diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 9fa06168..dbe12171 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -208,8 +208,11 @@ enum NPmode { #define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l)) #define BCOPY(s, d, l) memcpy((d), (s), (l)) #define BZERO(s, n) memset(s, 0, n) - +#if PPP_DEBUG #define PRINTMSG(m, l) { m[l] = '\0'; ppp_trace(LOG_INFO, "Remote message: %s\n", m); } +#else +#define PRINTMSG(m, l) +#endif /* * MAKEHEADER - Add PPP Header fields to a packet.