summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-04-07 23:46:14 +0000
committerbrian <brian@FreeBSD.org>2000-04-07 23:46:14 +0000
commit825b93bffd6e24aedc951459cd4f3fd890118b64 (patch)
treeea7329a1f2b203bb128cf3ce1a068c54cd932824 /usr.sbin
parent179ce7c01c501ff60341a7cafa0ff07204800e61 (diff)
downloadFreeBSD-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')
-rw-r--r--usr.sbin/ppp/bundle.c28
-rw-r--r--usr.sbin/ppp/bundle.h1
-rw-r--r--usr.sbin/ppp/datalink.c10
-rw-r--r--usr.sbin/ppp/defs.c16
-rw-r--r--usr.sbin/ppp/defs.h12
-rw-r--r--usr.sbin/ppp/main.c47
6 files changed, 74 insertions, 40 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 7d6583d..938bbea 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -160,17 +160,25 @@ bundle_LayerStart(void *v, struct fsm *fp)
}
-static void
+void
bundle_Notify(struct bundle *bundle, char c)
{
if (bundle->notify.fd != -1) {
- if (write(bundle->notify.fd, &c, 1) == 1)
- log_Printf(LogPHASE, "Parent notified of %s\n",
- c == EX_NORMAL ? "success" : "failure");
+ int ret;
+
+ ret = write(bundle->notify.fd, &c, 1);
+ if (c != EX_REDIAL && c != EX_RECONNECT) {
+ if (ret == 1)
+ log_Printf(LogCHAT, "Parent notified of %s\n",
+ c == EX_NORMAL ? "success" : "failure");
+ else
+ log_Printf(LogERROR, "Failed to notify parent of success\n");
+ close(bundle->notify.fd);
+ bundle->notify.fd = -1;
+ } else if (ret == 1)
+ log_Printf(LogCHAT, "Parent notified of %s\n", ex_desc(c));
else
- log_Printf(LogPHASE, "Failed to notify parent of success.\n");
- close(bundle->notify.fd);
- bundle->notify.fd = -1;
+ log_Printf(LogERROR, "Failed to notify parent of %s\n", ex_desc(c));
}
}
@@ -1220,7 +1228,7 @@ bundle_IdleTimeout(void *v)
{
struct bundle *bundle = (struct bundle *)v;
- log_Printf(LogPHASE, "Idle timer expired.\n");
+ log_Printf(LogPHASE, "Idle timer expired\n");
bundle_StopIdleTimer(bundle);
bundle_Close(bundle, NULL, CLOSE_STAYDOWN);
}
@@ -1643,7 +1651,7 @@ bundle_SendDatalink(struct datalink *dl, int s, struct sockaddr_un *sun)
log_Printf(LogDEBUG, "Received confirmation from pid %d\n",
(int)newpid);
if (lock && (res = ID0uu_lock_txfr(lock, newpid)) != UU_LOCK_OK)
- log_Printf(LogPHASE, "uu_lock_txfr: %s\n", uu_lockerr(res));
+ log_Printf(LogERROR, "uu_lock_txfr: %s\n", uu_lockerr(res));
log_Printf(LogDEBUG, "Transmitting link (%d bytes)\n", expect);
if ((got = writev(reply[0], iov + 1, niov - 1)) != expect) {
@@ -1781,7 +1789,7 @@ bundle_setsid(struct bundle *bundle, int holdsession)
close(fds[0]);
setsid();
bundle_ChangedPID(bundle);
- log_Printf(LogPHASE, "%d -> %d: %s session control\n",
+ log_Printf(LogDEBUG, "%d -> %d: %s session control\n",
(int)orig, (int)getpid(),
holdsession ? "Passed" : "Dropped");
timer_InitService(0); /* Start the Timer Service */
diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h
index 2e53ca2..594045e 100644
--- a/usr.sbin/ppp/bundle.h
+++ b/usr.sbin/ppp/bundle.h
@@ -190,3 +190,4 @@ extern void bundle_CalculateBandwidth(struct bundle *);
extern void bundle_AutoAdjust(struct bundle *, int, int);
extern int bundle_WantAutoloadTimer(struct bundle *);
extern void bundle_ChangedPID(struct bundle *);
+extern void bundle_Notify(struct bundle *, char);
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index 779d622..8a34c60 100644
--- a/usr.sbin/ppp/datalink.c
+++ b/usr.sbin/ppp/datalink.c
@@ -83,7 +83,7 @@ datalink_OpenTimeout(void *v)
timer_Stop(&dl->dial.timer);
if (dl->state == DATALINK_OPENING)
- log_Printf(LogPHASE, "%s: Redial timer expired.\n", dl->name);
+ log_Printf(LogCHAT, "%s: Redial timer expired.\n", dl->name);
}
static int
@@ -170,11 +170,16 @@ datalink_HangupDone(struct datalink *dl)
dl->dial.tries = dl->cfg.dial.max;
dl->dial.incs = 0;
dl->reconnect_tries--;
+ log_Printf(LogCHAT, "%s: Reconnect try %d of %d\n",
+ dl->name, dl->cfg.reconnect.max - dl->reconnect_tries,
+ dl->cfg.reconnect.max);
+ bundle_Notify(dl->bundle, EX_RECONNECT);
} else {
if (dl->phone.next == NULL)
datalink_StartDialTimer(dl, datalink_GetDialTimeout(dl));
else
datalink_StartDialTimer(dl, dl->cfg.dial.next_timeout);
+ bundle_Notify(dl->bundle, EX_REDIAL);
}
}
}
@@ -197,7 +202,7 @@ datalink_ChoosePhoneNumber(struct datalink *dl)
phone = strsep(&dl->phone.alt, "|");
dl->phone.chosen = *phone ? phone : "[NONE]";
if (*phone)
- log_Printf(LogPHASE, "Phone: %s\n", phone);
+ log_Printf(LogCHAT, "Phone: %s\n", phone);
return phone;
}
@@ -309,6 +314,7 @@ datalink_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e,
int timeout;
timeout = datalink_StartDialTimer(dl, datalink_GetDialTimeout(dl));
+ bundle_Notify(dl->bundle, EX_REDIAL);
log_WritePrompts(dl, "Failed to open %s, pause %d seconds\n",
dl->physical->name.full, timeout);
}
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index 4ea017a..c7577c2 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -342,3 +342,19 @@ HexStr(long val, char *buf, size_t sz)
snprintf(buf, sz, "<0x%lx>", val);
return buf;
}
+
+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",
+ "redial", "reconnect"
+ };
+
+ if (ex >= 0 && ex < sizeof desc / sizeof *desc)
+ return desc[ex];
+ snprintf(num, sizeof num, "%d", ex);
+ return num;
+}
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index 4a1ca1f..cb704d8 100644
--- a/usr.sbin/ppp/defs.h
+++ b/usr.sbin/ppp/defs.h
@@ -75,10 +75,13 @@
#define EX_DONE 6
#define EX_REBOOT 7
#define EX_ERRDEAD 8
-#define EX_HANGUP 10
-#define EX_TERM 11
-#define EX_NODIAL 12
-#define EX_NOLOGIN 13
+#define EX_HANGUP 9
+#define EX_TERM 10
+#define EX_NODIAL 11
+#define EX_NOLOGIN 12
+/* return values for -background mode, not really exits */
+#define EX_REDIAL 13
+#define EX_RECONNECT 14
/* physical::type values (OR'd in bundle::phys_type) */
#define PHYS_NONE 0
@@ -109,3 +112,4 @@ extern char *findblank(char *, int);
extern int MakeArgs(char *, char **, int, int);
extern const char *NumStr(long, char *, size_t);
extern const char *HexStr(long, char *, size_t);
+extern const char *ex_desc(int);
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]);
}
OpenPOWER on IntegriCloud