Dialer

Jump to: navigation, search

Table of Contents >> Optional Protocols


Treck PPP or SLIP includes a module to facilitate dialing a remote host (most likely, an ISP). Dialing occurs prior to the establishment of a PPP connection and is triggered by calling tfOpenInterface(). Prior to this call, the user would first enable the dialer, and then set up how the dialer will behave. This is done with a series of 'send-expect' pairs, where the local client sends a string to the remote host and waits for its response. 'Expect-send' pairs behave in the opposite manner. This is similar to the method used in many UNIX scripted dialers.

Each 'send-expect' or 'expect-send' pairs have an error string associated with them. When this string is received, it triggers an error inside the dialer. The default behavior is simply to move to the next state (i.e., the next 'send-expect' pair). If TM_DIALER_FAIL_ON_ERROR is set and this error string is received, the entire dialing session will be aborted with an error.

Every 'send-expect' pair has a time-out value and a retry value associated with it. This allows, for instance, a dialer to attempt to dial a phone number a finite number of times, and if it still fails, to abort the session.

When the dialer has finished, either through completion or error, the user is notified through a notification function which is passed in when the dialer is enabled.


Example

Here is an example of a device dialing and logging in to and ISP:

Local: Remote:
ATDT5551212
CONNECT14400
Login:
username
Password:
password
Welcome!

This session could be accomplished with the following code:

/* Initialize the dialer */
tfUseDialer(interfaceHandle, dialerNotify);
 
/* 
 * client: send 'ATDT5551212' -> server: send 'CONNECT14400'
 * 30 second time-out, 5 retries, fail if 'ERROR' returned.
 */ 
tfDialerAddSendExpect(interfaceHandle,
                      "ATDT5551212",
                      "CONNECT14400",
                      "ERROR",
                      5,
                      30,
                      TM_DIALER_FAIL_ON_ERROR);
 
/* server: send 'Login:' -> client: send 'username' */
 
tfDialerAddExpectSend(interfaceHandle,
                      "username",
                      "Login:",
                      (char *) 0,
                      0,
                      60,
                      0);
 
/* server: send 'Password:' -> client: send 'password' */
tfDialerAddExpectSend(interfaceHandle,
                      "password",
                      "Password:",
                      (char *) 0,
                      0,
                      60,
                      0);
 
/* 
 * server: send 'Welcome' -> client: send nothing (successful) 
 * server: send 'Invalid Login' -> client: send nothing (failure)
 */
tfDialerAddExpectSend(interfaceHandle,
                      "",
                      "Welcome",
                      "Invalid Login",
                      0,
                      60,
                      TM_DIALER_FAIL_ON_ERROR);
 
/* Dialing starts now*/
tfOpenInterface(interfaceHandle, ...);


Function Calls


Table of Contents >> Optional Protocols