diff options
author | brian <brian@FreeBSD.org> | 2000-04-07 23:46:14 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-04-07 23:46:14 +0000 |
commit | 825b93bffd6e24aedc951459cd4f3fd890118b64 (patch) | |
tree | ea7329a1f2b203bb128cf3ce1a068c54cd932824 /usr.sbin/ppp/main.c | |
parent | 179ce7c01c501ff60341a7cafa0ff07204800e61 (diff) | |
download | FreeBSD-src-825b93bffd6e24aedc951459cd4f3fd890118b64.zip FreeBSD-src-825b93bffd6e24aedc951459cd4f3fd890118b64.tar.gz |
When running ppp -background, show comfort messages showing
when we're redialing/reconnecting.
While we're here, log redial, reconnect and phone number
announcements to LogCHAT, and reduce some other logging to
LogDEBUG.
Diffstat (limited to 'usr.sbin/ppp/main.c')
-rw-r--r-- | usr.sbin/ppp/main.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 2374991..21f0787 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -94,7 +94,6 @@ static void DoLoop(struct bundle *); static void TerminalStop(int); -static const char *ex_desc(int); static struct bundle *SignalBundle; static struct prompt *SignalPrompt; @@ -166,21 +165,6 @@ BringDownServer(int signo) server_Close(SignalBundle); } -static const char * -ex_desc(int ex) -{ - static char num[12]; /* Used immediately if returned */ - static const char * const desc[] = { - "normal", "start", "sock", "modem", "dial", "dead", "done", - "reboot", "errdead", "hangup", "term", "nodial", "nologin" - }; - - if (ex >= 0 && ex < sizeof desc / sizeof *desc) - return desc[ex]; - snprintf(num, sizeof num, "%d", ex); - return num; -} - static void Usage(void) { @@ -436,6 +420,7 @@ main(int argc, char **argv) if (bgpid) { char c = EX_NORMAL; + int ret; if (sw.mode == PHYS_BACKGROUND) { close(bgpipe[1]); @@ -447,16 +432,30 @@ main(int argc, char **argv) signal(SIGQUIT, KillChild); /* Wait for our child to close its pipe before we exit */ - if (read(bgpipe[0], &c, 1) != 1) { + while ((ret = read(bgpipe[0], &c, 1)) == 1) { + switch (c) { + case EX_NORMAL: + prompt_Printf(prompt, "PPP enabled\n"); + log_Printf(LogPHASE, "Parent: PPP enabled\n"); + case EX_REDIAL: + if (!sw.quiet) + prompt_Printf(prompt, "Attempting redial\n"); + continue; + case EX_RECONNECT: + if (!sw.quiet) + prompt_Printf(prompt, "Attempting reconnect\n"); + continue; + default: + prompt_Printf(prompt, "Child failed (%s)\n", + ex_desc((int)c)); + log_Printf(LogPHASE, "Parent: Child failed (%s)\n", + ex_desc((int) c)); + } + break; + } + if (ret != 1) { prompt_Printf(prompt, "Child exit, no status.\n"); log_Printf(LogPHASE, "Parent: Child exit, no status.\n"); - } else if (c == EX_NORMAL) { - prompt_Printf(prompt, "PPP enabled.\n"); - log_Printf(LogPHASE, "Parent: PPP enabled.\n"); - } else { - prompt_Printf(prompt, "Child failed (%s).\n", ex_desc((int) c)); - log_Printf(LogPHASE, "Parent: Child failed (%s).\n", - ex_desc((int) c)); } close(bgpipe[0]); } |