using PPP_DEBUG instead of debug global variable

This commit is contained in:
Sylvain Rochet 2012-06-09 15:09:00 +02:00
parent 1ccf516c5e
commit 945f2912a7
3 changed files with 26 additions and 29 deletions

View File

@ -1893,8 +1893,9 @@ ipcp_up(f)
/* Set the interface to the new addresses */
mask = get_mask(go->ouraddr);
if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
if (debug)
#if PPP_DEBUG
warn("Interface configuration failed");
#endif /* PPP_DEBUG */
ipcp_close(f->unit, "Interface configuration failed");
return;
}
@ -1924,8 +1925,9 @@ ipcp_up(f)
#if !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
if (debug)
#if PPP_DEBUG
warn("Interface configuration failed");
#endif /* PPP_DEBUG */
ipcp_close(f->unit, "Interface configuration failed");
return;
}
@ -1933,16 +1935,18 @@ ipcp_up(f)
/* bring the interface up for IP */
if (!sifup(f->unit)) {
if (debug)
#if PPP_DEBUG
warn("Interface failed to come up");
#endif /* PPP_DEBUG */
ipcp_close(f->unit, "Interface configuration failed");
return;
}
#if (defined(SVR4) && (defined(SNI) || defined(__USLC__)))
if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
if (debug)
#if PPP_DEBUG
warn("Interface configuration failed");
#endif /* PPP_DEBUG */
ipcp_close(f->unit, "Interface configuration failed");
return;
}

View File

@ -150,7 +150,6 @@
*/
/* FIXME: global variables per PPP session */
/* FIXME: clean global variables */
int debug = 0; /* Debug flag */
int phase; /* where the link is at */
int error_count; /* # of times error() has been called */
int unsuccess; /* # unsuccessful connection attempts */
@ -357,8 +356,6 @@ int ppp_init(void) {
int i;
struct protent *protp;
debug = 1;
new_phase(PHASE_INITIALIZE);
error_count = 0;
unsuccess = 0;
@ -843,7 +840,7 @@ static void ppp_input(void *arg) {
#endif /* UNUSED */
}
if (debug) {
#if PPP_DEBUG
#if PPP_PROTOCOLNAME
const char *pname = protocol_name(protocol);
if (pname != NULL)
@ -851,7 +848,7 @@ static void ppp_input(void *arg) {
else
#endif /* PPP_PROTOCOLNAME */
warn("Unsupported protocol 0x%x received", protocol);
}
#endif /* PPP_DEBUG */
if (pbuf_header(nb, sizeof(protocol))) {
LWIP_ASSERT("pbuf_header failed\n", 0);
goto drop;

View File

@ -760,9 +760,6 @@ dump_packet(const char *tag, unsigned char *p, int len)
{
int proto;
if (!debug)
return;
/*
* don't print IPv4 and IPv6 packets.
*/
@ -775,10 +772,9 @@ dump_packet(const char *tag, unsigned char *p, int len)
#endif
/*
* don't print LCP echo request/reply packets if debug <= 1
* and the link is up.
* don't print LCP echo request/reply packets if the link is up.
*/
if (debug <= 1 && unsuccess == 0 && proto == PPP_LCP
if (unsuccess == 0 && proto == PPP_LCP
&& len >= 2 + HEADERLEN) {
unsigned char *lcp = p + 2;
int l = (lcp[2] << 8) + lcp[3];