This isn't really a bug as such, but something I've needed since going online via Orange (a UK cellular network). The patch below adds a retry function to chat.. It's built against the latest ppp SRPM. How to use: RETRY <expect string, e.g. BUSY> RETRCMD <command, e.g. ATDT08450798666> RETREXP <expect string to carry on as normal> If on retrying the RETRY expect string is encountered, it'll try again... Patch begins (patch for man page omitted, available on request): --- ppp-2.3.10/chat/chat.c.old Mon Sep 6 06:10:23 1999 +++ ppp-2.3.10/chat/chat.c Sat Dec 4 03:42:45 1999 @@ -14,6 +14,10 @@ * This software is in the public domain. * * ----------------- + * 04-Dec-99 added RETRY support. A really horrible hack. Vaguely + * documented in the man page. It probably could be better... + * Michael McConnell <soruk.uk> + * * 22-May-99 added environment substitutuion, enabled with -E switch. * Andreas Arens <andras>. * @@ -201,6 +205,8 @@ fail_buffer[50]; int n_aborts = 0, abort_next = 0, timeout_next = 0, echo_next = 0; int clear_abort_next = 0; +int retry_next = 0, retry_set = 0, retry_cmd_next = 0, retry_exp_next = 0; +char retry_string[32], retry_cmd[256], retry_exp[32]; char *report_string[MAX_REPORTS] ; char report_buffer[50] ; @@ -909,6 +920,21 @@ return; } + if (strcmp(s, "RETRY") == 0) { + ++retry_next; + return; + } + + if (strcmp(s, "RETRCMD") == 0) { + ++retry_cmd_next; + return; + } + + if (strcmp(s, "RETREXP") == 0) { + ++retry_exp_next; + return; + } + if (strcmp(s, "CLR_ABORT") == 0) { ++clear_abort_next; return; @@ -1147,6 +1173,37 @@ return; } + if (retry_next) { + retry_next = 0; + strcpy(retry_string, s); + retry_set = 1; + + if (verbose) + logf("Retry string set to %s", retry_string); + + return; + } + + if (retry_exp_next) { + retry_exp_next = 0; + strcpy(retry_exp, s); + + if (verbose) + logf("Retry expect string set to %s", retry_exp); + + return; + } + + if (retry_cmd_next) { + retry_cmd_next = 0; + strcpy(retry_cmd, s); + + if (verbose) + logf("Retry command set to %s", retry_cmd); + + return; + } + /* * The syntax @filename means read the string to send from the * file `filename'. @@ -1379,7 +1436,7 @@ alarmed = 0; while ( ! alarmed && (c = get_char()) >= 0) { - int n, abort_len, report_len; + int n, retry_len, abort_len, report_len; if (echo) echo_stderr(c); @@ -1446,6 +1503,19 @@ alarm(0); alarmed = 0; return (1); + } + + if (s - temp >= (retry_len = strlen(retry_string)) && retry_set && + strncmp(s - retry_len, retry_string, retry_len-2) == 0) { + if (verbose) { + if (1) + logf("[%s]", retry_string); + logf(" -- Retrying"); + } + /* Bung in here the commands to send retry_cmd */ + put_string(retry_cmd); + get_string(retry_exp); + return(1); } for (n = 0; n < n_aborts; ++n) {
Instead of sending this to us, I suggest sending it to the ppp maintainer, Paul MacKerras <paulus> who can integrate it if he chooses. It doesn't make much sense for us to maintain such a patch separately.