From 945f2912a7dd12e15a15f0c90b9f8f7c0a3fe388 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 9 Jun 2012 15:09:00 +0200 Subject: [PATCH] using PPP_DEBUG instead of debug global variable --- src/netif/ppp/ipcp.c | 20 ++++++++++++-------- src/netif/ppp/ppp.c | 27 ++++++++++++--------------- src/netif/ppp/utils.c | 8 ++------ 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index 29cbccff..bb7eaf58 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -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) - warn("Interface configuration failed"); +#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) - warn("Interface configuration failed"); +#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) - warn("Interface failed to come up"); +#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) - warn("Interface configuration failed"); +#if PPP_DEBUG + warn("Interface configuration failed"); +#endif /* PPP_DEBUG */ ipcp_close(f->unit, "Interface configuration failed"); return; } diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index bae0784d..1d5c501a 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -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 */ @@ -266,14 +265,14 @@ typedef struct ppp_control_s { struct netif *ethif; struct pppoe_softc *pppoe_sc; #endif /* PPPOE_SUPPORT */ - int if_up; /* True when the interface is up. */ + int if_up; /* True when the interface is up. */ int err_code; /* Code indicating why interface is down. */ #if PPPOS_SUPPORT - sio_fd_t fd; /* File device ID of port. */ + sio_fd_t fd; /* File device ID of port. */ #endif /* PPPOS_SUPPORT */ - u16_t mtu; /* Peer's mru */ - int pcomp; /* Does peer accept protocol compression? */ - int accomp; /* Does peer accept addr/ctl compression? */ + u16_t mtu; /* Peer's mru */ + int pcomp; /* Does peer accept protocol compression? */ + int accomp; /* Does peer accept addr/ctl compression? */ u_long last_xmit; /* Time of last transmission. */ #if PPPOS_SUPPORT ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ @@ -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,15 +840,15 @@ 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) - warn("Unsupported protocol '%s' (0x%x) received", pname, protocol); - else + const char *pname = protocol_name(protocol); + if (pname != NULL) + warn("Unsupported protocol '%s' (0x%x) received", pname, protocol); + else #endif /* PPP_PROTOCOLNAME */ - warn("Unsupported protocol 0x%x received", protocol); - } + 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; diff --git a/src/netif/ppp/utils.c b/src/netif/ppp/utils.c index fe07e4fb..1bdae379 100644 --- a/src/netif/ppp/utils.c +++ b/src/netif/ppp/utils.c @@ -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];