Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 7774 - Patch to make chat work with busy phone numbers / networks
Summary: Patch to make chat work with busy phone numbers / networks
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: ppp
Version: 6.1
Hardware: i386
OS: Linux
medium
low
Target Milestone: ---
Assignee: Michael K. Johnson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-12-13 00:35 UTC by Michael McConnell
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 1999-12-13 16:47:53 UTC


Attachments (Terms of Use)

Description Michael McConnell 1999-12-13 00:35:08 UTC
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@eridani.co.uk>
+ *
  *     22-May-99 added environment substitutuion, enabled with -E switch.
  *     Andreas Arens <andras@cityweb.de>.
  *
@@ -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) {

Comment 1 Michael K. Johnson 1999-12-13 16:47:59 UTC
Instead of sending this to us, I suggest sending it to the ppp maintainer,
Paul MacKerras <paulus@linuxcare.com> who can integrate it if he chooses.
It doesn't make much sense for us to maintain such a patch separately.


Note You need to log in before you can comment on or make changes to this bug.