home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / slipwarp.zip / cris.txt < prev    next >
Text File  |  1994-12-10  |  38KB  |  1,255 lines

  1.  
  2.  
  3.  
  4.  
  5.                   OS/2 Warp, CRIS, SLIP, the Internet and You!
  6.                   --------------------------------------------
  7.  
  8.                          Dave Fisher, dfisher@cris.com
  9.                              1:170/110@fidonet.org
  10.                                40:4372/0 (ibmNET)
  11.                               81:202/201 (OS2NET)
  12.  
  13.                         Revision 1.22, December 10, 1994
  14.  
  15.      This document helps describe the journey involved in setting up an
  16.      Internet provider (other than IBM) using OS/2 Warp's Internet
  17.      Connection Software, specifically for CRIS (Concentric Research
  18.      Internet Services).  Please consider this a document "in the making".
  19.      Since there is no documentation as to the procedure necessary to add a
  20.      non-IBM Internet Provider, I have had to do things by trial-and-error.
  21.      Quite frankly, it would also appear that the Internet software on Warp
  22.      is also "in the making", as a few things did not quite work
  23.      correctly... :-)  Hopefully, this document will help set those things
  24.      right and find a working solution to setting up a third-party Internet
  25.      Provider.
  26.  
  27.      Many thank to Obie (obie@cris.com) for performing most of the
  28.      preliminary research for IP addresses and other esoteric information
  29.      necessary to make these scripts work!
  30.  
  31.      And many thanks to Gary Hammer (ghammer@cris.com), who provided a
  32.      couple of the missing peices which were driving me nuts! :)  His notes
  33.      and implementation (file CRIS_OS2.ZIP) is included in the archive
  34.      SLIPWARP.ZIP.  Note how he raises DTR by calling ALTPRO.CMD file
  35.      instead of SLIPPM.EXE.  This is now done automatically in
  36.      LOGNCRIS.CMD, but as an on/off DTR toggle.
  37.  
  38.      Note:  If you are cut-n-pasting examples out of this document, please
  39.      be sure to ignore the page numbers and cut-n-paste them out of your
  40.      cut-n-paste operation.  :-)
  41.  
  42.      Now...
  43.  
  44.      First, you will have to define all the provider information for the
  45.      Internet software.  To do this, click on the "Internet Utilities" icon
  46.      and then the "Dial Other Internet Providers" icon.  Select the "Add
  47.      Provider" option from the menu, and then fill in the following
  48.      information at the relevant prompts:
  49.  
  50.                   Provider Name: CRIS
  51.                        Login ID: (not needed)
  52.                        Password: (not needed)
  53.                        Nickname: CRIS
  54.                    Phone Number: (not needed)
  55.                    Login Script: logncris.cmd <phone> <loginid> <password>
  56.                                     <comportname> <ipaddr> <destipaddr>
  57.                                     (all on one line)
  58.                 Connection Type: SLIP
  59.  
  60.                 Your IP address: 192.0.2.1
  61.          Destination IP address: 199.3.12.9
  62.                        Net Mask: 0.0.0.0
  63.                        MTU Size: 1500
  64.              Domain Name Server: 199.3.12.3
  65.                                        1
  66.  
  67.  
  68.  
  69.  
  70.  
  71.                  Your Host Name: voyager
  72.                Your Domain Name: cris.com
  73.  
  74.                     News Server: deathstar.cris.com
  75.                   Gohper Server: deathstar.cris.com
  76.                      WWW Server: deathstar.cris.com
  77.  
  78.                 POP Mail Server: deathstar.cris.com
  79.                    Reply Domain: cris.com
  80.                   Reply mail ID: [your account name]
  81.                    POP Login ID: [your login user id]
  82.                    POP Password: [your password]
  83.  
  84.      The following is an example setup for my account using the above
  85.      information:
  86.  
  87.                   Provider Name: CRIS
  88.                        Login ID:
  89.                        Password:
  90.                        Nickname: CRIS
  91.                    Phone Number:
  92.                    Login Script: logncris.cmd 8350324 dfisher@slip xxxxxxx
  93.                                      com2 192.0.2.1 199.3.12.9
  94.                                      (all on one line)
  95.                 Connection Type: SLIP
  96.  
  97.                 Your IP address: 192.0.2.1
  98.          Destination IP address: 199.3.12.9
  99.                        Net Mask: 0.0.0.0
  100.                        MTU Size: 1500
  101.              Domain Name Server: 199.3.12.3
  102.                  Your Host Name: voyager
  103.                Your Domain Name: cris.com
  104.  
  105.                     News Server: deathstar.cris.com
  106.                   Gohper Server: deathstar.cris.com
  107.                      WWW Server: deathstar.cris.com
  108.  
  109.                 POP Mail Server: deathstar.cris.com
  110.                    Reply Domain: cris.com
  111.                   Reply mail ID: dfisher
  112.                    POP Login ID: dfisher
  113.                    POP Password: xxxxxxxx
  114.  
  115.  
  116.                       Comments on the "Login Script" field
  117.                       ------------------------------------
  118.  
  119.      There are two types of scripts which can be used: an ASCII response
  120.      file (*.RSP), or a REXX command procedure (*.CMD).  I was not able to
  121.      get a response file to work correctly.  While this is easier to setup,
  122.      it would simply stop executing at various points during the login
  123.      process.  When I implemented the REXX procedure, the login worked
  124.      without fail each time.
  125.  
  126.      The response file, if used, should be located in \tcpip\etc.  The REXX
  127.      command procedure, if used, should be located in \tcpip\bin.
  128.  
  129.      Also, if the software detects a response file (*.RSP) in the "Login
  130.      Script" field, then you will have to enter in the following fields:
  131.                                        2
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.                 Your IP address: 192.0.2.1
  139.          Destination IP address: 199.3.12.9
  140.                        Net Mask: 0.0.0.0
  141.  
  142.      If the software detects a REXX command procedure (*.CMD), the above
  143.      fields will be inaccessible (i.e., they will be "greyed out"), and
  144.      data cannot be entered into them.  It would appear that the Warp IAK
  145.      (Internet Access Kit) is expecting the REXX procedure to set up the IP
  146.      addresses (using the programs 'ifconfig' and 'route').
  147.  
  148.      Arguments to LOGNCRIS.CMD procedure:
  149.  
  150.      There are several arguments to the REXX procedure which must be
  151.      defined if using SLIPPM.EXE.
  152.  
  153.      <phone>      :  This is your local access phone number into CRIS.
  154.  
  155.      <loginid>    :  This is your account login in name with "@slip"
  156.                      appended to the end of it.  Thus, if your account
  157.                      name is dfisher, then you would put "dfisher@slip".
  158.  
  159.      <password>   :  This is your login password.
  160.  
  161.      <comportname>:  This is your COM port used to make the SLIP
  162.                      connection.  It is used to toggle DTR and set a
  163.                      few other necessary port settings.
  164.  
  165.      <ipaddr>     :  Your Internet Provider's IP Address
  166.  
  167.      <destipaddr> :  Your Internet Provider's Destination IP Address
  168.  
  169.  
  170.                         Establishing the SLIP connection
  171.                         --------------------------------
  172.  
  173.      The normal intended way to establish a connection to a third party
  174.      Internet Provider is via the dialing GUI program SLIPPM.EXE.  This is
  175.      the same program which was used above to define the provider.
  176.      However, I have not been able to get this to successfully work with a
  177.      response file (*.RSP), although it appears to work with the REXX
  178.      command procedure (*.CMD).
  179.  
  180.      But before I was able to get it to successfully run with SLIPPM, I
  181.      resorted to dropping back to the base SLIP program (SLIP.EXE) in a
  182.      Full Screen OS/2 Session.  (SLIPPM.EXE also calls this program in
  183.      order to establish a connection, and displays the results in the small
  184.      window labeled "Status").
  185.  
  186.      Choose which method you like the most.  By using SLIP.EXE directly,
  187.      you reduce system overhead (GUI programs are horrible resource hogs).
  188.      And yet, this is kind of a "backdoor" method, and may cause trouble as
  189.      IBM fleshes out the IAK programs.  Many of the IAK programs will also
  190.      ask if you want to invoke SLIPPM if a connection has not already been
  191.      established, which is a nice touch.  Thus, there are pros and cons to
  192.      both to methods.
  193.  
  194.      To use SLIP.EXE directly to establish the connection, simply run the
  195.      batch file GOCRIS in an OS/2 full screen or windowed session.
  196.  
  197.                                        3
  198.  
  199.  
  200.  
  201.  
  202.  
  203.      GOCRIS.CMD is as follows (which has been broken into several lines for
  204.      readability):
  205.  
  206.      @echo off
  207.  
  208.      rem ------------------------------------------------------------------
  209.      rem Simple batch file to invoke SLIP from an OS/2 session instead of
  210.      rem using the GUI program SLIPPM.
  211.      rem
  212.      rem SLIP.EXE is in \tcpip\bin.
  213.      rem ------------------------------------------------------------------
  214.  
  215.      slip -com2 -exit 0 -speed 57600 -mtu 1500 -nocfg -notify -rtscts
  216.           -ifconfig 192.0.2.1 199.3.12.9 +defaultroute -idle 15
  217.           -connect "logncris.cmd 8350324 dfisher@slip * com2"
  218.                                  <phone> <account>      <portname>
  219.  
  220.      You will have to modify GOCRIS.CMD for your personal information in
  221.      the "-connect" qualifier, where <phone> is your local or 1-800 access
  222.      phone number to CRIS, <account> is your base account name with "@slip"
  223.      appended (i.e., no @domain appended), and <com> is the COM port name.
  224.      My port is locked at 57600, but yours may be different.  However,
  225.      since this is a 14.4k connection, I wouldn't go below 19200.
  226.  
  227.      Note that you do NOT have to pass the IP address or Destination IP
  228.      address on the "-connect" statement since it was specified on the SLIP
  229.      command using "-ifconfig".
  230.  
  231.      ADDENDUM:  CRIS have made changes to their systems where you will now
  232.      not know which machine you are calling into (and consquently you will
  233.      not know the IP address of that machine).  Apparently this does not
  234.      matter in that I have passed the gateway address (i.e. "destination IP
  235.      address", 199.3.12.9) in lieu of the IP address and this works fine.
  236.  
  237.      You will probably want to create an Icon which then calls GOCRIS.CMD
  238.      when invoked.  This will make starting and ending the SLIP session
  239.      quick and easy.  Simply drag-and-drop the Program Template Icon to the
  240.      Desktop and you will be prompted for the needed information.
  241.  
  242.      Otherwise, use the PM Dialer (SLIPPM) and ignore the above. :-)
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.                                        4
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.                          REXX Command Procedure LOGNCRIS.CMD
  271.                          -----------------------------------
  272. /*--------------------------------------------------------------------------*
  273.  *                                                                          *
  274.  * LOGNCRIS.CMD                                                             *
  275.  *                                                                          *
  276.  * This script will perform the login procedures to access the Internet     *
  277.  * via CRIS (Concentric Research Internet Services) using SLIP (Serial      *
  278.  * Line Internet Protocol).  It can probably be easily modified for other   *
  279.  * Internet Providers.                                                      *
  280.  *                                                                          *
  281.  * Once SLIP is active on OS/2, all the Internet programs may be used.      *
  282.  *                                                                          *
  283.  * Portions of this script were based on ANNEX.CMD, an example REXX         *
  284.  * procedure distributed with Warp OS/2.                                    *
  285.  *                                                                          *
  286.  * There are two ways to use invoke this script--via SLIP.EXE or            *
  287.  * SLIPPM.EXE.  SLIPPM.EXE is simply a GUI program which calls SLIP.EXE.    *
  288.  * Thus, for reasons of overhead, it may be more prudent to simply invoke   *
  289.  * SLIP.EXE as a background process and save some computer resources for    *
  290.  * more important things like telnet and ftp... :-)                         *
  291.  *                                                                          *
  292.  * Calling convention (all on one line):                                    *
  293.  *                                                                          *
  294.  *     LOGNCRIS.CMD <phone number> <login_id> <password> <comportname>      *
  295.  *                  <ipaddr> <destipaddr>                                   *
  296.  *                                                                          *
  297.  * Using this script with SLIP.EXE with a Windowed or Full Screen Session:  *
  298.  *                                                                          *
  299.  *      If any of the parameters are omitted, or are specified as an        *
  300.  *      asterick (*), the script will prompt for them.  This is most useful *
  301.  *      with the password parameter to avoid storing the password in a text *
  302.  *      file on the disk.                                                   *
  303.  *                                                                          *
  304.  *      For example, the following might be used with SLIP's "-connect"     *
  305.  *      parameter:                                                          *
  306.  *              -connect "logncris.cmd 999-9999 loginid * COM2"             *
  307.  *                                                                          *
  308.  *      which would cause logncris.cmd to initially prompt for the password.*
  309.  *      It would then feed the "999-9999" command to the modem, and when    *
  310.  *      CRIS answered, it would use "loginid" as a username and the password*
  311.  *      which was specified at the prompt.                                  *
  312.  *                                                                          *
  313.  * Using this script with SLIPPM.EXE in a GUI session:                      *
  314.  *                                                                          *
  315.  *      You may not omit any parameters using the asterick (*).  Doing so   *
  316.  *      will probably lock the keyboard/mouse interface.  Make sure that    *
  317.  *      all parameters are specified in the "Login Script" field, such as:  *
  318.  *                                                                          *
  319.  *              logncris.cmd 999-9999 loginid password COM2 ip_addr ip_gate *
  320.  *                                                                          *
  321.  *      SLIPPM will then pass this information on to SLIP.                  *
  322.  *                                                                          *
  323.  *            - - - - - - - - - - - - - - - - - - - - - - - - -             *
  324.  *                                                                          *
  325.  * When the script runs, it is automatically passed the interface name for  *
  326.  * the interface it is running on as the first argument, followed by the    *
  327.  * user arguments.  This script will keep trying to dial (up to 30 times)   *
  328.  * until a successful connection is established.                            *
  329.                                           5
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  *                                                                          *
  336.  *            - - - - - - - - - - - - - - - - - - - - - - - - -             *
  337.  *                                                                          *
  338.  *                         D I S C L A I M E R                              *
  339.  *                                                                          *
  340.  * Doncha just hate to have these things?  :-]                              *
  341.  *                                                                          *
  342.  * I make no warranties as to the accuracy of this script or information.   *
  343.  * Your use of this script and information is at your own risk.  I also     *
  344.  * do not represent the views of CRIS or am affiliated with CRIS in any     *
  345.  * other way than a subscriber to their service.  For more information on   *
  346.  * Concentric Research Internet Services, their voice number is             *
  347.  * 1-800-745-2747 or 1-517-895-0500.  At the writing of this script, their  *
  348.  * service rate was $30/month for unlimited access to the Internet using    *
  349.  * a shell account and/or SLIP.                                             *
  350.  *                                                                          *
  351.  *            - - - - - - - - - - - - - - - - - - - - - - - - -             *
  352.  *                                                                          *
  353.  * Author: Dave Fisher, dfisher@cris.com, 1:170/110@fidonet.org)            *
  354.  *                      40:4372/0 (ibmNET), 81:202/201 (OS2NET)             *
  355.  * Date: 30-Nov-1994                                                        *
  356.  *                                                                          *
  357.  *--------------------------------------------------------------------------*/
  358.  
  359. parse arg interface, dialcmd username password comport ip_address ip_gateway_address
  360.  
  361. /*--------------------------------------------------------------------------*
  362.  *                   Initialization and Main Script Code                    *
  363.  *--------------------------------------------------------------------------*/
  364.  
  365. /* trace results */
  366.  
  367. /*
  368.  * Global definitions and variables
  369.  */
  370.  
  371. call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
  372.  
  373. cr = '0d'x
  374. lf = '0a'x
  375.  
  376. TRUE = 1
  377. FALSE = 0
  378.  
  379. SUCCESS = 0
  380. FAILURE = 1
  381. FATAL_ERROR = 2
  382.  
  383. modem_input_buffer = '' /* all characters from the COM line are put */
  384.                         /* into this common buffer */
  385.  
  386. /*
  387.  * Default to my personal setup for CRIS -- you can change this to
  388.  * your own information if you do not want to pass this information
  389.  * to the script.
  390.  */
  391.  
  392. /*
  393. if ( ip_address = '' ) then
  394.     ip_address = '199.3.12.9'
  395.                                           6
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402. if ( ip_gateway_address = '' ) then
  403.     ip_gateway_address = '192.0.2.1'
  404. */
  405.  
  406. if ( comport = '' ) then
  407.     comport = 'com2'
  408.  
  409. say ''
  410. say 'SLIP Connection Script for CRIS (using interface' interface' on 'comport':)'
  411. say ''
  412.  
  413. /*
  414.  * Prompt for missing information
  415.  */
  416.  
  417. if ( dialcmd = '' ) then
  418.     do
  419.     call charout, 'Dial Command: '
  420.     parse pull dialcmd
  421.     end
  422.  
  423. if ( username = '' | username = '*' ) then
  424.     do
  425.     call charout, 'User Name: '
  426.     parse pull username
  427.     end
  428. else
  429.     say 'User:' username
  430.  
  431. if ( password = '' | password = '*' ) then
  432.     do
  433.     call charout, 'Password: '
  434.     password = readpass()
  435.     end
  436.  
  437. /*
  438.  * Try to connect to the provider until we finally DO connect!
  439.  */
  440.  
  441. call com_flush_receive(FALSE)    /* clean out COMM/input buffer */
  442.  
  443. do cnt = 1 to 30
  444.  
  445.     say ''
  446.     say 'Connection trial number' cnt
  447.     say ''
  448.  
  449.     status = connect_to_provider()
  450.  
  451.     if ( status == SUCCESS ) then
  452.         leave                       /* yeah--we got in! */
  453.  
  454.     call com_flush_receive(TRUE)    /* clean out COMM/input buffer */
  455. end
  456.  
  457. /*
  458.  * Configure any necessary routes, etc for SLIP connection
  459.  */
  460.  
  461.                                           7
  462.  
  463.  
  464.  
  465.  
  466.  
  467. call configure_slip_connection
  468.  
  469. exit( status )
  470.  
  471.  
  472. /*-------------------------------------------------------------------------*
  473.  * connect_to_provider                                                     *
  474.  *                                                                         *
  475.  *-------------------------------------------------------------------------*/
  476.  
  477. connect_to_provider:
  478.  
  479.     /******** NOTE ********** NOTE *********** NOTE ********* NOTE *********
  480.      *
  481.      * Make sure modem is on-hook and that buffers are flushed and
  482.      * reset modem.
  483.      *
  484.      * You may need to customize this for your modem make and model and
  485.      * COM port configuration (port baud rate, etc.)
  486.      *
  487.      ******** NOTE ********** NOTE *********** NOTE ********* NOTE *********/
  488.  
  489.     say 'Resetting modem...'
  490.  
  491.     /* Toggle DTR and make sure hardware handshaking is enabled */
  492.  
  493.     mode comport':,n,8,1,RTS=ON,XON=OFF,DTR=OFF'
  494.  
  495.     call SysSleep 1
  496.  
  497.     mode comport':DTR=ON'
  498.  
  499.     /* get modem's attention */
  500.  
  501.     call com_send '+++'
  502.  
  503.     call SysSleep 2
  504.  
  505.     call com_send 'ATH' || cr
  506.  
  507.     if ( com_waitfor( 'OK', 5 ) \= SUCCESS ) then
  508.         do
  509.         say 'Modem not responding'
  510.         return( FAILURE )
  511.         end
  512.  
  513.     call com_flush_receive(TRUE)
  514.  
  515.     call com_send 'ATZ' || cr
  516.  
  517.     if ( com_waitfor( 'OK', 5 ) \= SUCCESS ) then
  518.         do
  519.         say 'Modem not responding'
  520.         return( FAILURE )
  521.         end
  522.  
  523.     call com_flush_receive(TRUE)
  524.  
  525.     /*
  526.      * Dial the remote server and wait for connection
  527.                                           8
  528.  
  529.  
  530.  
  531.  
  532.  
  533.      */
  534.  
  535.     call charout, 'Now Dialing... '
  536.  
  537.     call com_send( 'ATDT' || dialcmd || cr )
  538.  
  539.     ring_cnt = 0
  540.  
  541.     connect = FALSE
  542.  
  543.     line = ''
  544.  
  545.     do FOREVER
  546.  
  547.         status = com_get_line( 60, line )   /* get <CR> terminated line */
  548.  
  549.         if ( status \= SUCCESS ) then
  550.             leave
  551.  
  552.         /*
  553.          * Keep track of responses from modem
  554.          */
  555.  
  556.         if ( (line = 'NO DIAL TONE') | (line = 'RING') ) then
  557.             do                  /* someone trying to call in */
  558.             call SysSleep 2     /* wait a couple of seconds before retry */
  559.             leave
  560.             end
  561.  
  562.         if ( (line = 'RINGING') | (line = 'BUSY') ) then
  563.             ring_cnt = ring_cnt + 1
  564.  
  565.         if ( ring_cnt >= 4 ) then
  566.             do
  567.             say ''
  568.             say 'Remote site not answering phone'
  569.             say ''
  570.             leave
  571.             end
  572.  
  573.         if ( pos( 'CONNECT', line ) > 0 ) then
  574.             do
  575.             connect = TRUE
  576.             leave
  577.             end
  578.     end
  579.  
  580.     if ( connect = FALSE ) then
  581.         do
  582.         say ''
  583.         say 'No connection established'
  584.         say ''
  585.         return( FAILURE )       /* exit script with error */
  586.         end
  587.  
  588.     /*
  589.      * Handle login process
  590.      */
  591.  
  592.     if ( com_waitfor( 'if new user:', 60 ) \= SUCCESS ) then
  593.                                           9
  594.  
  595.  
  596.  
  597.  
  598.  
  599.         do
  600.         say ''
  601.         say 'No connection established'
  602.         say ''
  603.         return( FAILURE )       /* exit script with error */
  604.         end
  605.  
  606.     call com_flush_receive(TRUE)
  607.  
  608.     call com_send( username || cr )
  609.  
  610.     if ( com_waitfor( 'Password:', 45 ) \= SUCCESS ) then
  611.         do
  612.         say ''
  613.         say 'No connection established'
  614.         say ''
  615.         return( FAILURE )       /* exit script with error */
  616.         end
  617.  
  618.     call com_flush_receive(TRUE)
  619.  
  620.     call com_send( password || cr )
  621.  
  622.     if ( com_waitfor( 'SLIP software.', 15 ) \= SUCCESS ) then
  623.         do
  624.         say ''
  625.         say 'No connection established'
  626.         say ''
  627.         return( FAILURE )       /* exit script with error */
  628.         end
  629.  
  630.     call com_flush_receive(TRUE)
  631.  
  632.     say ''
  633.     say 'Connection Established to SLIP server'
  634.     say ''
  635.  
  636. return( SUCCESS )
  637.  
  638.  
  639. /*-------------------------------------------------------------------------*
  640.  * configure_slip_connection                                               *
  641.  *                                                                         *
  642.  *-------------------------------------------------------------------------*/
  643.  
  644. configure_slip_connection:
  645.  
  646.     /*
  647.      * Now configure this host for the appropriate addresses and routing
  648.      *
  649.      * When using the PM Dialer (SLIPPM), these statements are mandatory.
  650.      * If you do not do it here, all of the IAK software does not
  651.      * recognize the link.
  652.      *
  653.      * If you call SLIP.EXE directly using GOCRIS.CMD, then these statements
  654.      * are probably not necessary since SLIP calls 'ifconfig' and 'route'
  655.      * itself and consequently takes care of "clean-up" and deletes them on
  656.      * exit.
  657.      */
  658.  
  659.                                          10
  660.  
  661.  
  662.  
  663.  
  664.  
  665.     if ( ip_address \= '' ) then
  666.         do
  667.         say 'IP address =' ip_address
  668.         say 'Gateway IP address =' ip_gateway_address
  669.         'ifconfig sl0' ip_address ip_gateway_address 'netmask 0.0.0.0'
  670.         'route add default' ip_gateway_address '1'
  671.         end
  672.  
  673. return( SUCCESS )
  674.  
  675. /*--------------------------------------------------------------------------*
  676.  * com_send                                                                 *
  677.  *                                                                          *
  678.  * Routine to send a character string off to the modem.                     *
  679.  *                                                                          *
  680.  *--------------------------------------------------------------------------*/
  681.  
  682. com_send:
  683.  
  684.     sendstring = arg(1)
  685.  
  686.     call slip_com_output interface, sendstring
  687.  
  688. return( SUCCESS )
  689.  
  690.  
  691. /*-------------------------------------------------------------------------*
  692.  * com_get_line                                                            *
  693.  *                                                                         *
  694.  * Get a CR terminated line from the COM port                              *
  695.  *                                                                         *
  696.  *     Arg 1 : number of seconds to wait until giving up (timeout)         *
  697.  *     Arg 2 : returned line (without the CR)                              *
  698.  *                                                                         *
  699.  *-------------------------------------------------------------------------*/
  700.  
  701. com_get_line:
  702.  
  703.     timeout = arg(1)
  704.     modem_input_line = arg(2)
  705.  
  706.     if timeout = '' then
  707.         timeout = 5000      /* long delay if not specified */
  708.  
  709.     modem_input_line = ''
  710.  
  711.     loop_status = -1
  712.  
  713.     reset_time = time('R')  /* reset the clock timer to zero */
  714.  
  715.     do while( loop_status = -1 )
  716.         /*
  717.          * Stay in loop until we get a CR terminated line, or we
  718.          * timeout
  719.          */
  720.  
  721.         status = com_get_input()
  722.  
  723.         if ( status = FATAL_ERROR ) then
  724.             return(FAILURE)
  725.                                          11
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.         if ( status = SUCCESS ) then
  733.             do
  734.             /* extract line from buffer if there */
  735.  
  736.             status = extract_line( 'modem_input_line' )
  737.  
  738.             if ( status = SUCCESS ) then
  739.                 do
  740.                 loop_status = SUCCESS
  741.                 leave       /* get out of while loop */
  742.                 end
  743.             end
  744.  
  745.         if ( time('E') >= timeout ) then
  746.             do
  747.             say 'Timeout waiting for line from modem'
  748.             loop_status = FAILURE
  749.             end
  750.  
  751.         end     /* while loop_status... */
  752.  
  753. return( loop_status )
  754.  
  755. /*--------------------------------------------------------------------------*
  756.  * com_waitfor                                                              *
  757.  *                                                                          *
  758.  * Waits for the supplied string to show up in the COM input.               *
  759.  *                                                                          *
  760.  *     Arg 1 : number of seconds to wait until giving up (timeout)          *
  761.  *                                                                          *
  762.  * Return: FAILURE or SUCCESS                                               *
  763.  *                                                                          *
  764.  *--------------------------------------------------------------------------*/
  765.  
  766. com_waitfor:
  767.  
  768.     parse arg waitfor_string, timeout
  769.  
  770.     if timeout = '' then
  771.         timeout = 5000      /* long delay if not specified */
  772.  
  773.     reset_time = time('R')  /* reset the clock timer to zero */
  774.  
  775.     exit_status = FAILURE
  776.  
  777.     do FOREVER
  778.         /*
  779.          * Stay in loop until matched string or timeout
  780.          */
  781.  
  782.         status = com_get_input()
  783.  
  784.         if ( status = FATAL_ERROR ) then
  785.             return(FAILURE)
  786.  
  787.         if ( status = SUCCESS ) then
  788.             do
  789.             /* if we have a match, extract it from input COM buffer */
  790.  
  791.                                          12
  792.  
  793.  
  794.  
  795.  
  796.  
  797.             status = extract_match( waitfor_string )
  798.  
  799.             if ( status = SUCCESS ) then
  800.                 do
  801.                 exit_status = SUCCESS
  802.                 leave       /* get out of while loop */
  803.                 end
  804.             end
  805.  
  806.         if ( time('E') >= timeout ) then
  807.             do
  808.             say 'Timed out waiting for string "'waitfor_string'"'
  809.             leave   /* get out of while loop */
  810.             end
  811.  
  812.         end     /* while loop_status... */
  813.  
  814. return( exit_status )
  815.  
  816.  
  817. /*--------------------------------------------------------------------------*
  818.  * readpass                                                                 *
  819.  *                                                                          *
  820.  * Routine used to read a password from the user without echoing the        *
  821.  * password to the screen.                                                  *
  822.  *                                                                          *
  823.  * Return: string entered                                                   *
  824.  *                                                                          *
  825.  *--------------------------------------------------------------------------*/
  826.  
  827. readpass:
  828.  
  829.     answer = ''
  830.  
  831.     do until( key = cr )
  832.         key = slip_getch()
  833.  
  834.         if ( key \= cr ) then
  835.             do
  836.             answer = answer || key
  837.             end
  838.     end
  839.  
  840.     say ''
  841.  
  842. return( answer )
  843.  
  844.  
  845. /*--------------------------------------------------------------------------*
  846.  * com_flush_receive                                                        *
  847.  *                                                                          *
  848.  * Routine to flush any pending characters to be read from the COM port.    *
  849.  * Reads everything it can until nothing new shows up for 100ms, at which   *
  850.  * point it returns.                                                        *
  851.  *                                                                          *
  852.  *   Arg 1 : TRUE=echo to output, FALSE=no echo                             *
  853.  *                                                                          *
  854.  *--------------------------------------------------------------------------*/
  855.  
  856. com_flush_receive:
  857.                                          13
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.     echo = arg(1)
  865.  
  866.     modem_input_buffer = ''     /* this has already been echo'ed on read */
  867.  
  868.     /*
  869.      * Eat anything left in the modem or COM buffers and stop when
  870.      * nothing new appears for 100ms
  871.      */
  872.  
  873.     do until( line = '' )
  874.         line = slip_com_input( interface, , 100 )
  875.         if ( echo = TRUE) then
  876.             call charout, line
  877.         end
  878.  
  879. return( SUCCESS )
  880.  
  881.  
  882. /*--------------------------------------------------------------------------*
  883.  * display_mem                                                              *
  884.  *                                                                          *
  885.  * Bascially for debugging, display characters to output.  If characters    *
  886.  * are unprintable, display as hexidecimal values.                          *
  887.  *                                                                          *
  888.  *   Arg 1 : memory segment to display                                      *
  889.  *   Arg 2 : leading prompt before display                                  *
  890.  *                                                                          *
  891.  *--------------------------------------------------------------------------*/
  892.  
  893. display_mem:
  894.  
  895.     mem = arg(1)
  896.     prompt = arg(2)
  897.  
  898.     do curpos = 1 to length(prompt)
  899.         call charout, substr( prompt, curpos, 1 )
  900.         end
  901.  
  902.     call charout, '"'
  903.  
  904.     do curpos = 1 to length(mem)
  905.  
  906.         ch = substr( mem, curpos, 1 )
  907.  
  908.         if ( (c2d(ch) < 32) | (c2d(ch) > 126) ) then
  909.             call charout, '(0x'c2x(ch)')'
  910.         else
  911.             call charout, ch
  912.  
  913.         end
  914.  
  915.     say '"'
  916.  
  917. return( SUCCESS )
  918.  
  919.  
  920. /*--------------------------------------------------------------------------*
  921.  * extract_line                                                             *
  922.  *                                                                          *
  923.                                          14
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  * Checks 'modem_input_bufffer' for a CR terminated line.  If found, the    *
  930.  * line will be extracted from the buffer.  If not, no change to buffer.    *
  931.  *                                                                          *
  932.  *   Arg 1 : returned CR terminated line (without the CR)                   *
  933.  *                                                                          *
  934.  *--------------------------------------------------------------------------*/
  935.  
  936. extract_line:
  937.  
  938.     line_var_name = arg(1)          /* passed by reference */
  939.  
  940.     buff = modem_input_buffer       /* use temp variable so we do not */
  941.                                     /* modify the input buffer until we want to */
  942.  
  943.     x = VALUE( line_var_name, '' )  /* initialize passed variable to nothing */
  944.                                     /* discard return to unused var 'x' */
  945.     line = ''
  946.  
  947.     got_cr = FALSE
  948.  
  949.     do buffpos = 1 to length(buff)
  950.  
  951.         ch = substr( buff, buffpos, 1 )
  952.  
  953.         if ( ch = lf ) then
  954.             nop             /* ignore line feeds */
  955.         else
  956.         if ( ch = cr ) then
  957.             do
  958.             /* x = display_mem( buff, 'before buff = ' ) */
  959.  
  960.             buff = substr( buff, buffpos+1, length(buff) - buffpos )
  961.  
  962.             /* x = display_mem( buff, 'after buff = ' ) */
  963.  
  964.             got_cr = TRUE
  965.             leave
  966.             end
  967.         else
  968.             do
  969.             line = line || ch
  970.             end
  971.         end
  972.  
  973.     if ( got_cr = FALSE ) then
  974.         return( FAILURE )
  975.  
  976.     modem_input_buffer = buff           /* update input buffer */
  977.  
  978.     x = VALUE( line_var_name, line )    /* return new value of extracted line */
  979.  
  980. return( SUCCESS )
  981.  
  982.  
  983. /*--------------------------------------------------------------------------*
  984.  * extract_match                                                            *
  985.  *                                                                          *
  986.  * Checks 'modem_input_bufffer' for a matching string.  If found, the       *
  987.  * match will be extracted from the buffer.  If not, no change to buffer.   *
  988.  *                                                                          *
  989.                                          15
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  *   Arg 1 : pattern to match in input buffer                               *
  996.  *                                                                          *
  997.  *--------------------------------------------------------------------------*/
  998.  
  999. extract_match:
  1000.  
  1001.     matchstr = arg(1)
  1002.  
  1003.     index = pos( matchstr, modem_input_buffer )
  1004.  
  1005.     if ( index > 0 ) then
  1006.         do
  1007.         /*
  1008.          * Extract matched string from the COM input buffer and reset
  1009.          * the input buffer to any remaining characters
  1010.          */
  1011.  
  1012.         index = index + length(matchstr)
  1013.         len = length(modem_input_buffer) - index + 1
  1014.  
  1015.         /* x = display_mem( modem_input_buff, 'before buff = ' ) */
  1016.  
  1017.         if ( len = 0 ) then
  1018.             modem_input_buffer = ''
  1019.         else
  1020.             modem_input_buffer = substr( modem_input_buffer, index, len )
  1021.  
  1022.         /* x = display_mem( modem_input_buffer, 'after buff = ' ) */
  1023.  
  1024.         return(SUCCESS)
  1025.         end
  1026.  
  1027. return(FAILURE)
  1028.  
  1029.  
  1030. /*--------------------------------------------------------------------------*
  1031.  * com_get_input                                                            *
  1032.  *                                                                          *
  1033.  * Get any input from the COM port and store in 'modem_input_buffer'.  Echo *
  1034.  * input received to the output device.                                     *
  1035.  *                                                                          *
  1036.  *--------------------------------------------------------------------------*/
  1037.  
  1038. com_get_input:
  1039.  
  1040.     line = slip_com_input( interface, , 10 )
  1041.  
  1042.     if ( line \= '' ) then
  1043.         do
  1044.         call charout, line
  1045.  
  1046.         modem_input_buffer = modem_input_buffer || line
  1047.  
  1048.         /*
  1049.          * Check input stream for "garbage characters".  This would
  1050.          * indicate that something is wrong with the connection (parity,
  1051.          * baud rate, remote site failure, etc.)
  1052.          */
  1053.  
  1054.         do curpos = 1 to length(line)
  1055.                                          16
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.             ch = substr( line, curpos, 1 )
  1062.  
  1063.             if ( c2d(ch) > 126 ) then
  1064.                 do
  1065.                 say ''
  1066.                 say 'Garbage characters detected in stream'
  1067.                 say ''
  1068.                 modem_input_buffer = ''
  1069.                 return( FATAL_ERROR )
  1070.                 end
  1071.             end
  1072.  
  1073.         return( SUCCESS )
  1074.         end
  1075.  
  1076. return(FAILURE)
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.                                          17
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.                     Example Response File LOGNCRIS.RSP
  1131.                     ----------------------------------
  1132.  
  1133. atz\r
  1134. OK
  1135. atdt<access phone number>\r
  1136. CONNECT
  1137. if new user:
  1138. <login account name>@slip\r
  1139. Password:
  1140. <password>\r
  1141. SLIP software.
  1142. \r
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.                                     18
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.