Skip to content

Commit d4c2fd5

Browse files
authored
Merge pull request #12195 from mikaleppanen/ppp_trace_disable
Corrected PPP debug trace flagging
2 parents fab9e3b + 9e41f1f commit d4c2fd5

File tree

8 files changed

+58
-14
lines changed

8 files changed

+58
-14
lines changed

features/netsocket/ppp/include/ppp_impl.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,8 @@ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
648648
#define multilink_master 0
649649
#endif
650650

651+
#if PPP_DEBUG
652+
651653
/* Procedures exported from utils.c. */
652654
void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */
653655
int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */
@@ -665,6 +667,22 @@ void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len);
665667
/* dump packet to debug log if interesting */
666668
#endif /* PRINTPKT_SUPPORT */
667669

670+
#else
671+
672+
#define ppp_print_string(...)
673+
#define ppp_slprintf(...)
674+
#define ppp_vslprintf(...)
675+
#define ppp_strlcpy(...)
676+
#define ppp_strlcat(...)
677+
#define ppp_dbglog(...)
678+
#define ppp_info(...)
679+
#define ppp_notice(...)
680+
#define ppp_warn(...)
681+
#define ppp_error(...)
682+
#define ppp_fatal(...)
683+
684+
#endif /* PPP_DEBUG */
685+
668686
/*
669687
* Number of necessary timers analysis.
670688
*

features/netsocket/ppp/source/auth.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,13 @@ void link_terminated(ppp_pcb *pcb) {
630630
#endif /* UNUSED */
631631

632632
if (!doing_multilink) {
633-
ppp_notice("Connection terminated.");
633+
ppp_notice("Connection terminated.");
634634
#if PPP_STATS_SUPPORT
635-
print_link_stats();
635+
print_link_stats();
636636
#endif /* PPP_STATS_SUPPORT */
637-
} else
638-
ppp_notice("Link terminated.");
637+
} else {
638+
ppp_notice("Link terminated.");
639+
}
639640

640641
lcp_lowerdown(pcb);
641642

@@ -1131,13 +1132,17 @@ void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
11311132
*/
11321133
void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
11331134
int bit;
1135+
#if PPP_DEBUG
11341136
const char *prot = "";
1137+
#endif
11351138

11361139
switch (protocol) {
11371140
#if CHAP_SUPPORT
11381141
case PPP_CHAP:
11391142
bit = CHAP_WITHPEER;
1143+
#if PPP_DEBUG
11401144
prot = "CHAP";
1145+
#endif
11411146
switch (prot_flavor) {
11421147
case CHAP_MD5:
11431148
bit |= CHAP_MD5_WITHPEER;
@@ -1158,13 +1163,17 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
11581163
#if PAP_SUPPORT
11591164
case PPP_PAP:
11601165
bit = PAP_WITHPEER;
1166+
#if PPP_DEBUG
11611167
prot = "PAP";
1168+
#endif
11621169
break;
11631170
#endif /* PAP_SUPPORT */
11641171
#if EAP_SUPPORT
11651172
case PPP_EAP:
11661173
bit = EAP_WITHPEER;
1174+
#if PPP_DEBUG
11671175
prot = "EAP";
1176+
#endif
11681177
break;
11691178
#endif /* EAP_SUPPORT */
11701179
default:

features/netsocket/ppp/source/chap-new.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@ void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code) {
205205
if (dp->code == digest_code)
206206
break;
207207

208-
if (dp == NULL)
208+
if (dp == NULL) {
209209
ppp_fatal("CHAP digest 0x%x requested but not available",
210210
digest_code);
211+
}
211212

212213
pcb->chap_client.digest = dp;
213214
pcb->chap_client.name = our_name;
@@ -519,10 +520,11 @@ static void chap_handle_status(ppp_pcb *pcb, int code, int id,
519520
msg = "CHAP authentication failed";
520521
}
521522
if (msg) {
522-
if (len > 0)
523+
if (len > 0) {
523524
ppp_info("%s: %.*v", msg, len, pkt);
524-
else
525+
} else {
525526
ppp_info("%s", msg);
527+
}
526528
}
527529
if (code == CHAP_SUCCESS)
528530
auth_withpeer_success(pcb, PPP_CHAP, pcb->chap_client.digest->code);

features/netsocket/ppp/source/fsm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,9 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) {
589589
case PPP_FSM_OPENED:
590590
if (len > 0) {
591591
ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
592-
} else
592+
} else {
593593
ppp_info("%s terminated by peer", PROTO_NAME(f));
594+
}
594595
f->retransmits = 0;
595596
f->state = PPP_FSM_STOPPING;
596597
if (f->callbacks->down)
@@ -643,15 +644,19 @@ static void fsm_rtermack(fsm *f) {
643644
* fsm_rcoderej - Receive an Code-Reject.
644645
*/
645646
static void fsm_rcoderej(fsm *f, u_char *inp, int len) {
647+
#if PPP_DEBUG
646648
u_char code, id;
649+
#endif
647650

648651
if (len < HEADERLEN) {
649652
FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!"));
650653
return;
651654
}
655+
#if PPP_DEBUG
652656
GETCHAR(code, inp);
653657
GETCHAR(id, inp);
654658
ppp_warn("%s: Rcvd Code-Reject for code %d, id %d", PROTO_NAME(f), code, id);
659+
#endif
655660

656661
if( f->state == PPP_FSM_ACKRCVD )
657662
f->state = PPP_FSM_REQSENT;

features/netsocket/ppp/source/ipcp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,16 @@ static void ipcp_up(fsm *f) {
20872087
wo->ouraddr = go->ouraddr;
20882088

20892089
ppp_notice("local IP address %I", go->ouraddr);
2090-
if (ho->hisaddr != 0)
2090+
if (ho->hisaddr != 0) {
20912091
ppp_notice("remote IP address %I", ho->hisaddr);
2092+
}
20922093
#if PPP_DNS
2093-
if (go->dnsaddr[0])
2094+
if (go->dnsaddr[0]) {
20942095
ppp_notice("primary DNS address %I", go->dnsaddr[0]);
2095-
if (go->dnsaddr[1])
2096+
}
2097+
if (go->dnsaddr[1]) {
20962098
ppp_notice("secondary DNS address %I", go->dnsaddr[1]);
2099+
}
20972100
#endif /* PPP_DNS */
20982101
}
20992102

features/netsocket/ppp/source/ipv6cp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ static enum script_state {
328328
static pid_t ipv6cp_script_pid;
329329
#endif /* UNUSED */
330330

331+
#if PPP_DEBUG
331332
static char *llv6_ntoa(eui64_t ifaceid);
333+
#endif
332334

333335
#if PPP_OPTIONS
334336
/*
@@ -409,6 +411,7 @@ printifaceid(opt, printer, arg)
409411
/*
410412
* Make a string representation of a network address.
411413
*/
414+
#if PPP_DEBUG
412415
static char *
413416
llv6_ntoa(eui64_t ifaceid)
414417
{
@@ -420,7 +423,7 @@ llv6_ntoa(eui64_t ifaceid)
420423

421424
return b;
422425
}
423-
426+
#endif
424427

425428
/*
426429
* ipv6cp_init - Initialize IPV6CP.
@@ -1245,6 +1248,7 @@ static void ipv6cp_up(fsm *f) {
12451248
ipv6cp_close(f->pcb, "Interface configuration failed");
12461249
return;
12471250
}
1251+
12481252
#if DEMAND_SUPPORT
12491253
sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS);
12501254
#endif /* DEMAND_SUPPORT */

features/netsocket/ppp/source/lcp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,8 +2664,9 @@ static void LcpEchoCheck(fsm *f) {
26642664
/*
26652665
* Start the timer for the next interval.
26662666
*/
2667-
if (pcb->lcp_echo_timer_running)
2668-
ppp_warn("assertion lcp_echo_timer_running==0 failed");
2667+
if (pcb->lcp_echo_timer_running) {
2668+
ppp_warn("assertion lcp_echo_timer_running==0 failed");
2669+
}
26692670
TIMEOUT (LcpEchoTimeout, f, pcb->settings.lcp_echo_interval);
26702671
pcb->lcp_echo_timer_running = 1;
26712672
}

features/netsocket/ppp/source/utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "ppp_opts.h"
3232
#if PPP_SUPPORT /* don't build if not configured for use in ppp_opts.h */
33+
#if PPP_DEBUG
3334

3435
#if 0 /* UNUSED */
3536
#include <stdio.h>
@@ -955,4 +956,5 @@ unlock()
955956

956957
#endif /* Unused */
957958

959+
#endif /* PPP_DEBUG */
958960
#endif /* PPP_SUPPORT */

0 commit comments

Comments
 (0)