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.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: bundle.c,v 1.35 2000/04/06 10:09:57 brian Exp $
+ * $OpenBSD: bundle.c,v 1.36 2000/04/07 23:46:39 brian Exp $
*/
#include <sys/param.h>
}
-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));
}
}
{
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);
}
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) {
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 */
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: bundle.h,v 1.13 2000/03/19 10:33:32 brian Exp $
+ * $OpenBSD: bundle.h,v 1.14 2000/04/07 23:46:39 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
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);
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: datalink.c,v 1.29 2000/04/02 01:36:22 brian Exp $
+ * $OpenBSD: datalink.c,v 1.30 2000/04/07 23:46:39 brian Exp $
*/
#include <sys/param.h>
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
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);
}
}
}
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;
}
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);
}
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: defs.c,v 1.11 2000/03/28 15:14:14 brian Exp $
+ * $OpenBSD: defs.c,v 1.12 2000/04/07 23:46:39 brian Exp $
*/
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;
+}
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: defs.h,v 1.13 2000/02/27 01:38:25 brian Exp $
+ * $OpenBSD: defs.h,v 1.14 2000/04/07 23:46:39 brian Exp $
*
* TODO:
*/
#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
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);
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: main.c,v 1.19 2000/04/02 01:36:22 brian Exp $
+ * $OpenBSD: main.c,v 1.20 2000/04/07 23:46:39 brian Exp $
*
* TODO:
*/
static void DoLoop(struct bundle *);
static void TerminalStop(int);
-static const char *ex_desc(int);
static struct bundle *SignalBundle;
static struct prompt *SignalPrompt;
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)
{
if (bgpid) {
char c = EX_NORMAL;
+ int ret;
if (sw.mode == PHYS_BACKGROUND) {
close(bgpipe[1]);
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]);
}