home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / misc / 3955 < prev    next >
Encoding:
Text File  |  1992-09-14  |  57.2 KB  |  1,811 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  4. Subject:  v32i063:  ecu - ECU Asynchronous Communications v3.20, Part28/40
  5. Message-ID: <1992Sep14.144910.22312@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 5f1d2be75371825ee3348f83c2fbca6b
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v32i036=ecu.141245@sparky.IMD.Sterling.COM>
  11. Date: Mon, 14 Sep 1992 14:49:10 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1796
  14.  
  15. Submitted-by: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  16. Posting-number: Volume 32, Issue 63
  17. Archive-name: ecu/part28
  18. Environment: SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses
  19. Supersedes: ecu: Volume 21, Issue 53-89
  20.  
  21. ---- Cut Here and feed the following to sh ----
  22. #!/bin/sh
  23. # this is ecu320.28 (part 28 of ecu320)
  24. # do not concatenate these parts, unpack them in order with /bin/sh
  25. # file gendial/dceHA24.c continued
  26. #
  27. if test ! -r _shar_seq_.tmp; then
  28.     echo 'Please unpack part 1 first!'
  29.     exit 1
  30. fi
  31. (read Scheck
  32.  if test "$Scheck" != 28; then
  33.     echo Please unpack part "$Scheck" next!
  34.     exit 1
  35.  else
  36.     exit 0
  37.  fi
  38. ) < _shar_seq_.tmp || exit 1
  39. if test ! -f _shar_wnt_.tmp; then
  40.     echo 'x - still skipping gendial/dceHA24.c'
  41. else
  42. echo 'x - continuing file gendial/dceHA24.c'
  43. sed 's/^X//' << 'SHAR_EOF' >> 'gendial/dceHA24.c' &&
  44. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  45. X/*:04-16-1991-18:18-wht@n4hgf-creation from template */
  46. X
  47. X#include "dialer.h"
  48. X
  49. X/*
  50. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  51. X *                    sees the transition; this value may be changed
  52. X *                    as necessary before each call to lflash_DTR(),
  53. X * but, generally, a constant value will do.
  54. X */
  55. Xlong DCE_DTR_low_msec = 750L;
  56. X
  57. X/*
  58. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  59. X *                     DCE may be expected to be ready to be commanded
  60. X */
  61. Xlong DCE_DTR_high_msec = 1500L;
  62. X
  63. X/*
  64. X * DCE_write_pace_msec - milliseconds to pause between each character
  65. X *                       sent to the DCE (zero if streaming I/O is
  66. X *                       permitted); this value may be changed as
  67. X * necessary before each call to lwrite(), but, generally, a constant
  68. X * value will do.  Note that this value is used to feed a value to Nap(),
  69. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  70. X * and .050 seconds on XENIX/86.
  71. X */
  72. Xlong DCE_write_pace_msec = 40;
  73. X
  74. X/*
  75. X * DCE_name     - short name for DCE
  76. X * DCE_revision - revision number for this module
  77. X */
  78. Xchar *DCE_name = "generic AT-cmd 2400";
  79. Xchar *DCE_revision = "1.21";
  80. X
  81. X/*
  82. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  83. X *                    and readying it for dial in access
  84. X *                    (BXXX mask); use a value of zero if the speed
  85. X *                    specified by the invoker is to be used.
  86. X * This value is useful for DCEs such as the early Hayes 2400
  87. X * which are so unfortunately compatible with their 1200 predecessor
  88. X * that they refuse to answer at 2400 baud unless you last spoke to
  89. X * them at that rate. For such bad boys, use B2400 below.
  90. X */
  91. Xint DCE_hangup_CBAUD = B2400;
  92. X
  93. X/*
  94. X * DCE_results - a table of DCE response strings and a token
  95. X *               code for each; when you call lread() or lread_ignore(),
  96. X *               if the read routine detects one of the strings,
  97. X * the appropriate code is returned.  If no string matches, then
  98. X * lread()/lread_ignore examines the DCE result string for a
  99. X * numeric value; if one is found, the numeric value or'd with
  100. X * 0x4000 is returned (in this way, e.g., you can read "modem
  101. X * S registers."  If nothing agrees with this search, lread()
  102. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  103. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  104. X * This module is the only consumer  of the codes, although they
  105. X * are decoded by gendial.c's _lread().
  106. X *
  107. X * If one possible result is an "early substring" of another, like
  108. X * "CONNECT" is of "CONNECT 1200", then put such results later in the
  109. X * table than the larger result.
  110. X *
  111. X */
  112. X#define rfConnect        0x00400000
  113. X#define rfMASK            0x000000FF
  114. X
  115. X#define rOk                0
  116. X#define rNoCarrier        1
  117. X#define rError            2
  118. X#define rNoDialTone        3
  119. X#define rBusy            4
  120. X#define rNoAnswer        5
  121. X#define rConnect300        (7 | rfConnect)
  122. X#define rConnect1200    (8 | rfConnect)
  123. X#define rConnect2400    (9 | rfConnect)
  124. X
  125. XDCE_RESULT DCE_results[] =
  126. X{
  127. X    { "OK",                        rOk,            },
  128. X    { "NO CARRIER",                rNoCarrier,        },
  129. X    { "ERROR",                    rError            },
  130. X    { "NO DIALTONE",            rNoDialTone,    },
  131. X    { "BUSY",                    rBusy            },
  132. X    { "NO ANSWER",                rNoAnswer        },
  133. X    { "CONNECT 1200",            rConnect1200    },
  134. X    { "CONNECT 2400",            rConnect2400    },
  135. X    { "CONNECT",                rConnect300        },
  136. X    { (char *)0,                -1                }        /* end table */
  137. X};
  138. X
  139. X/*+-------------------------------------------------------------------------
  140. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  141. X
  142. X  DCE dependent function must validate baud rates supported by DCE
  143. X  returns baud rate in struct termio c_cflag fashion
  144. X  or terminates program with error
  145. X--------------------------------------------------------------------------*/
  146. Xint
  147. XDCE_baud_to_CBAUD(baud)
  148. Xunsigned int baud;
  149. X{
  150. X    switch(baud)
  151. X    {
  152. X        case 50:   return(B50);        /* delete the ones you dont handle */
  153. X        case 75:   return(B75);
  154. X        case 110:  return(B110);
  155. X        case 134:  return(B134);
  156. X        case 150:  return(B150);
  157. X        case 300:  return(B300);
  158. X        case 1200: return(B1200);
  159. X        case 2400: return(B2400);
  160. X        case 4800: return(B4800);
  161. X        case 9600: return(B9600);
  162. X
  163. X#if defined(B19200)
  164. X        case 19200: return(B19200);
  165. X#else
  166. X#ifdef EXTA
  167. X        case 19200: return(EXTA);
  168. X#endif
  169. X#endif
  170. X
  171. X#if defined(B38400)
  172. X        case 38400: return(B38400);
  173. X#else
  174. X#ifdef EXTB
  175. X        case 38400: return(EXTB);
  176. X#endif
  177. X#endif
  178. X
  179. X    }
  180. X    myexit(RC_FAIL | RCE_SPEED);
  181. X#if defined(OPTIMIZE) || defined(__OPTIMIZE__)    /* don't complain */
  182. X    return(0);    /* keep gcc from complaining about no rtn at end */
  183. X#endif
  184. X}    /* end of DCE_baud_to_CBAUD */
  185. X
  186. X/*+-------------------------------------------------------------------------
  187. X    DCE_hangup() - issue hangup command to DCE
  188. X
  189. XThis function should do whatever is necessary to ensure
  190. X1) any active connection is terminated
  191. X2) the DCE is ready to receive an incoming call if DTR is asserted
  192. X3) the DCE will not accept an incoming call if DTR is false
  193. X
  194. XThe function should return when done.
  195. X
  196. XYou must set any switches necessary to make modem hang up on loss of DTR
  197. X--------------------------------------------------------------------------*/
  198. Xvoid
  199. XDCE_hangup()
  200. X{
  201. Xint itmp;
  202. Xint maxretry = 4;
  203. X
  204. X    DEBUG(1,"--> hanging up %s\n",dce_name);
  205. X
  206. X    lflash_DTR();
  207. X
  208. X    /*
  209. X     * set up modem
  210. X     */
  211. X    for(itmp = 0; itmp < maxretry; itmp++)
  212. X    {
  213. X        lwrite("ATS0=1M0Q0V1X3\r");
  214. X        if(lread(5) == rOk)
  215. X            break;
  216. X    }
  217. X    if(itmp == maxretry)
  218. X    {
  219. X        DEBUG(1,"failed to reset modem\n",0);
  220. X        myexit(RC_FAIL | RCE_TIMOUT);
  221. X    }
  222. X
  223. X    /*
  224. X     * shut up - no result codes
  225. X     */
  226. X    lwrite("ATQ1\r");
  227. X
  228. X}    /* end of DCE_hangup */
  229. X
  230. X/*+-------------------------------------------------------------------------
  231. X    DCE_dial(telno) - dial a remote DCE
  232. X
  233. XThis function should connect to the remote DCE and use any success
  234. Xindication to modify the tty baud rate if necessary before returning.
  235. X
  236. XUpon successful connection, return 0.
  237. X
  238. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  239. XRCE_XXX value from dialer.h.
  240. X
  241. Xlwrite() is used to write to the DCE.
  242. X
  243. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  244. Xfrom calling lread() will result automatically in the proper error
  245. Xtermination of the program.  Read timeouts from calling lread_ignore()
  246. Xreturn -1; you handle the execption here.
  247. X
  248. XAny necessary coding of phone numbers, switch settings or other
  249. Xconfiguration necessary for this function to succeed should be
  250. Xdocumented at the top of the module.
  251. X--------------------------------------------------------------------------*/
  252. Xint
  253. XDCE_dial(telno_str)
  254. Xchar *telno_str;
  255. X{
  256. Xchar cmd[128];
  257. Xchar phone[50];
  258. Xint timeout;
  259. Xint result;
  260. Xchar *cptr;
  261. Xchar *dialout_default = "ATS0=0S7=40S2=43Q0V1E0X3\r";
  262. X#define MDVALID     "0123456789NnSs*#,!/()-"
  263. Xint itmp;
  264. Xint maxretry = 4;
  265. X
  266. X    translate("=,-,",telno_str);
  267. X    if(strspn(telno_str,MDVALID) != strlen(telno_str))
  268. X    {
  269. X        DEBUG(1,"phone number has invalid characters\n",0);
  270. X        return(RC_FAIL | RCE_PHNO);
  271. X    }
  272. X    if(decode_phone_number(telno_str,phone,sizeof(phone)))
  273. X    {
  274. X        DEBUG(1,"phone number too long\n",0);
  275. X        return(RC_FAIL | RCE_PHNO);
  276. X    }
  277. X
  278. X    /*
  279. X     * wake up modem
  280. X     */
  281. X    DEBUG(6,"--> waking up modem\n",0);
  282. X    for(itmp = 0; itmp < maxretry; itmp++)
  283. X    {
  284. X        lwrite(dialout_default);
  285. X        if(lread(5) == rOk)
  286. X            break;
  287. X    }
  288. X    if(itmp == maxretry)
  289. X    {
  290. X        DEBUG(1,"DIAL INIT FAILED\n",0);
  291. X        myexit(RC_FAIL | RCE_TIMOUT);
  292. X    }
  293. X
  294. X    /*
  295. X     * calculate a timeout for the connect
  296. X     * allow a minimum of 40 seconds
  297. X     * if long distance (North American calculation here)
  298. X     * make it 132 (S7 is calculated as timeout * .9)
  299. X     */
  300. X    timeout = 40;
  301. X    if((phone[0] == '1') && (phone[0] != '0'))
  302. X        timeout = 132;
  303. X    if((timeout < 90) && (dialer_codes['V' - 'A'] || dialer_codes['P' - 'A']))
  304. X        timeout = 90;
  305. X    for(cptr = phone; cptr = strchr(cptr,','); cptr++)
  306. X        timeout += 2;    /* add extra time for pause characters */
  307. X    DEBUG(6,"wait for connect = %d seconds\n",timeout);
  308. X
  309. X/* indicate non-root should not see DTE->DCE traffic */
  310. X    secure = 1;
  311. X
  312. X/*
  313. X * build and issue the actual dialing command
  314. X * if root, let him see number, otherwise just say "remote system"
  315. X */
  316. X    DEBUG(1,"--> dialing %s\n", (!ecu_calling & uid)
  317. X        ? "remote system" : telno_str);
  318. X#ifdef WHT
  319. X    if(!strncmp(*gargv,"ECU",3))
  320. X        dialer_codes['S' - 'A'] = 1;
  321. X#endif
  322. X    sprintf(cmd,"ATM%dS7=%dDT%s\r",
  323. X        ((dialer_codes['S' - 'A']) && !(dialer_codes['N' - 'A'])) ? 1 : 0,
  324. X        (timeout * 9) / 10,
  325. X        phone);
  326. X
  327. X    /* cmd string can only be 40 characters including "AT" */
  328. X    if(strlen(cmd) > 40)
  329. X    {
  330. X        DEBUG(1,"phone number string too long\n",0);
  331. X        cleanup(RC_FAIL | RCE_PHNO);
  332. X    }
  333. X    lwrite(cmd);
  334. X
  335. X/* indicate non-root can see DTE->DCE traffic */
  336. X    secure = 0;
  337. X
  338. X/* wait for connect */
  339. X    result = lread(timeout);
  340. X    if(!(result & rfConnect))
  341. X    {
  342. X        switch(result & rfMASK)
  343. X        {
  344. X        case rNoCarrier:
  345. X            return(RC_FAIL | RCE_NOCARR);
  346. X        case rNoDialTone:
  347. X            return(RC_FAIL | RCE_NOTONE);
  348. X        case rBusy:
  349. X            return(RC_FAIL | RCE_BUSY);
  350. X        case rNoAnswer:
  351. X            return(RC_FAIL | RCE_ANSWER);
  352. X        case rError:
  353. X        default:
  354. X            return(RC_FAIL | RCE_NULL);
  355. X        }
  356. X    }
  357. X
  358. X/* indicate non-root can see DTE->DCE traffic */
  359. X    secure = 0;
  360. X    return(0);        /* succeeded */
  361. X
  362. X}    /* end of DCE_dial */
  363. X
  364. X/**********************************************************
  365. X*  You probably do not need to modify the code below here *
  366. X**********************************************************/
  367. X
  368. X/*+-------------------------------------------------------------------------
  369. X    DCE_abort(sig) - dial attempt aborted
  370. X
  371. X sig =  0 if non-signal abort (read timeout, most likely)
  372. X     != 0 if non-SIGALRM signal caught
  373. X
  374. X extern int dialing set  1 if dialing request was active,
  375. X                    else 0 if hangup request was active
  376. X
  377. XThis is a chance for the DCE-specific code to do anything it
  378. Xneeds to cl,ean up after a failure.  Note that if a dialing
  379. Xcall fails, it is the responsibility of the higher-level
  380. Xprogram calling the dialer to call it again with a hangup request, so
  381. Xthis function is usually a no-op.
  382. X--------------------------------------------------------------------------*/
  383. Xvoid
  384. XDCE_abort(sig)
  385. Xint sig;
  386. X{
  387. X    DEBUG(10,"DCE_abort(%d);\n",sig);
  388. X}    /* end of DCE_abort */
  389. X
  390. X/*+-------------------------------------------------------------------------
  391. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  392. X
  393. XThe independent portion of the dialer program calls this routine in
  394. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  395. XNormally, this function just passes it's argument to exit(), but
  396. Xany necessary post-processing can be done.  The function must,
  397. Xhowever, eventually call exit(exitcode);
  398. X--------------------------------------------------------------------------*/
  399. Xvoid
  400. XDCE_exit(exitcode)
  401. Xint exitcode;
  402. X{
  403. X    DEBUG(10,"DCE_exit(%d);\n",exitcode);
  404. X    exit(exitcode);
  405. X}    /* end of DCE_exit */
  406. X
  407. X/*+-------------------------------------------------------------------------
  408. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  409. X
  410. XThis hook gives DCE-specific code a chance to look over the entire
  411. Xcommand line, such as for -z Telebit processing.
  412. X
  413. Xargc andf argv are the same values passed to main(),
  414. X
  415. Xoptind is the value of optind at the end of normal getopt processing.
  416. X
  417. Xunrecognized_switches is the count of switches not handled by main().
  418. XSpecifically, -h and -x are standard switches.
  419. X
  420. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  421. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  422. Xthough, you can do anything you need to do here and exit the program.
  423. X
  424. XNote: only simple switches (with no argument) may be used with this
  425. Xfacility if the functrion is to return,' since main()'s getopt() will
  426. Xstop processing switches if it runs into an unrecognized switch with an
  427. Xargument.
  428. X
  429. XIf the function returns a non-zero value, then the value will be passed
  430. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  431. Xof the format expected by dialer program callers, with RC_FAIL set as a
  432. Xminimum.
  433. X--------------------------------------------------------------------------*/
  434. Xint
  435. XDCE_argv_hook(argc,argv,optind,unrecognized_switches)
  436. Xint argc;
  437. Xchar **argv;
  438. Xint optind;
  439. Xint unrecognized_switches;
  440. X{
  441. X    if(unrecognized_switches)
  442. X        return(RC_FAIL | RCE_ARGS);
  443. X    return(0);
  444. X}    /* end of DCE_argv_hook */
  445. X
  446. X/* vi: set tabstop=4 shiftwidth=4: */
  447. SHAR_EOF
  448. echo 'File gendial/dceHA24.c is complete' &&
  449. chmod 0644 gendial/dceHA24.c ||
  450. echo 'restore of gendial/dceHA24.c failed'
  451. Wc_c="`wc -c < 'gendial/dceHA24.c'`"
  452. test 12745 -eq "$Wc_c" ||
  453.     echo 'gendial/dceHA24.c: original size 12745, current size' "$Wc_c"
  454. rm -f _shar_wnt_.tmp
  455. fi
  456. # ============= gendial/dceMC9624.c ==============
  457. if test -f 'gendial/dceMC9624.c' -a X"$1" != X"-c"; then
  458.     echo 'x - skipping gendial/dceMC9624.c (File already exists)'
  459.     rm -f _shar_wnt_.tmp
  460. else
  461. > _shar_wnt_.tmp
  462. echo 'x - extracting gendial/dceMC9624.c (Text)'
  463. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dceMC9624.c' &&
  464. X/* CHK=0xB3C9 */
  465. X/*+-------------------------------------------------------------------------
  466. X    dceMC9624.c - DCE-specific portion of generic SCO UUCP dialer
  467. X    Driver for Microcom AX/9624c (assuming DTMF dialing only)
  468. X    wht@n4hgf.Mt-Park.GA.US
  469. X--------------------------------------------------------------------------*/
  470. X/*+:EDITS:*/
  471. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  472. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  473. X/*:02-02-1992-18:01-root@n4hgf-proper ordering of DCE_result entries */
  474. X/*:01-26-1992-15:30-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
  475. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  476. X/*:03-12-1991-19:11-wht@n4hgf-if ecu dialing, show complete call progress */
  477. X/*:01-05-1991-13:48-root@n4hgf-ATZ during reset - modem is flakey */
  478. X/*:11-29-1990-18:31-r@n4hgf-revision/1st releasable */
  479. X/*:07-24-1990-15:36-wht@n4hgf-add speaker on/off */
  480. X/*:07-20-1990-00:10-wht@n4hgf-creation */
  481. X
  482. X#include "dialer.h"
  483. X
  484. X/*
  485. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  486. X *                    sees the transition; this value may be changed
  487. X *                    as necessary before each call to lflash_DTR(),
  488. X * but, generally, a constant value will do.
  489. X */
  490. Xlong DCE_DTR_low_msec = 500;
  491. X
  492. X/*
  493. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  494. X *                     DCE may be expected to be ready to be commanded
  495. X */
  496. Xlong DCE_DTR_high_msec = 500;
  497. X
  498. X/*
  499. X * DCE_write_pace_msec - milliseconds to pause between each character
  500. X *                       sent to the DCE (zero if streaming I/O is
  501. X *                       permitted); this value may be changed as
  502. X * necessary before each call to lwrite(), but, generally, a constant
  503. X * value will do.  Note that this value is used to feed a value to Nap(),
  504. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  505. X * and .050 seconds on XENIX/86.
  506. X */
  507. Xlong DCE_write_pace_msec = 0;
  508. X
  509. X/*
  510. X * DCE_name     - short name for DCE
  511. X * DCE_revision - revision number for this module
  512. X */
  513. Xchar *DCE_name = "Microcom AX/9624c";
  514. Xchar *DCE_revision = "1.21";
  515. X
  516. X/*
  517. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  518. X *                    and readying it for dial in access
  519. X *                    (BXXX mask); use a value of zero if the speed
  520. X *                    specified by the invoker is to be used.
  521. X * This value is useful for DCEs such as the early Hayes 2400
  522. X * which are so unfortunately compatible with their 1200 predecessor
  523. X * that they refuse to answer at 2400 baud unless you last spoke to
  524. X * them at that rate. For such bad boys, use B2400 below.
  525. X */
  526. Xint DCE_hangup_CBAUD = 0;
  527. X/* int DCE_hangup_CBAUD = B2400; */
  528. X
  529. X/*
  530. X * DCE_results - a table of DCE response strings and a token
  531. X *               code for each; when you call lread() or lread_ignore(),
  532. X *               if the read routine detects one of the strings,
  533. X * the appropriate code is returned.  If no string matches, then
  534. X * lread()/lread_ignore examines the DCE result string for a
  535. X * numeric value; if one is found, the numeric value or'd with
  536. X * 0x40000000 is returned (in this way, e.g., you can read "modem
  537. X * S registers").  If nothing agrees with this search, lread()
  538. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  539. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  540. X * This module is the only consumer  of the codes, although they
  541. X * are decoded by gendial.c's _lread().
  542. X *
  543. X * If one possible result is an "early substring" of another, like
  544. X * "CONNECT" is of "CONNECT 1200", then put such results later in the
  545. X * table than the larger result.
  546. X *
  547. X */
  548. X
  549. X/* flag bits */
  550. X#define rfConnect        0x00800000
  551. X#define rfREL            0x00400000
  552. X#define rfMASK            0x0000FFFF    /* mask off rfBits */
  553. X
  554. X/* unique codes */
  555. X#define rOk                0
  556. X#define rNoCarrier        1
  557. X#define rError            2
  558. X#define rNoDialTone     3
  559. X#define rBusy            4
  560. X#define rNoAnswer        5
  561. X#define rConnect300        (  300  | rfConnect)
  562. X#define rConnect1200    ( 1200  | rfConnect)
  563. X#define rConnect2400    ( 1200  | rfConnect)
  564. X#define rConnect4800    ( 4800  | rfConnect)
  565. X#define rConnect9600    ( 9600  | rfConnect)
  566. X#define rConnect300R    (  300  | rfConnect | rfREL)
  567. X#define rConnect1200R    ( 1200  | rfConnect | rfREL)
  568. X#define rConnect2400R    ( 2400  | rfConnect | rfREL)
  569. X#define rConnect4800R    ( 4800  | rfConnect | rfREL)
  570. X#define rConnect9600R    ( 9600  | rfConnect | rfREL)
  571. X
  572. XDCE_RESULT DCE_results[] =
  573. X{
  574. X    { "OK",                        rOk,            },
  575. X    { "NO CARRIER",                rNoCarrier,        },
  576. X    { "ERROR",                    rError            },
  577. X    { "NO DIALTONE",            rNoDialTone,    },
  578. X    { "BUSY",                    rBusy            },
  579. X    { "NO ANSWER",                rNoAnswer        },
  580. X    { "CONNECT 300/REL",        rConnect300R    },
  581. X    { "CONNECT 1200/REL",        rConnect1200R    },
  582. X    { "CONNECT 2400/REL",        rConnect2400R    },
  583. X    { "CONNECT 4800/REL",        rConnect4800R    },
  584. X    { "CONNECT 9600/REL",        rConnect9600R    },
  585. X    { "CONNECT 300",            rConnect300        },
  586. X    { "CONNECT 1200",            rConnect1200    },
  587. X    { "CONNECT 2400",            rConnect2400    },
  588. X    { "CONNECT 4800",            rConnect4800     },
  589. X    { "CONNECT 9600",            rConnect9600    },
  590. X    { "CONNECT",                rConnect300        },
  591. X    { (char *)0,                -1                }        /* end table */
  592. X};
  593. X
  594. X/*+-------------------------------------------------------------------------
  595. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  596. X
  597. X  DCE dependent function must validate baud rates supported by DCE
  598. X  returns baud rate in struct termio c_cflag fashion
  599. X  or terminates program with error
  600. X--------------------------------------------------------------------------*/
  601. Xint
  602. XDCE_baud_to_CBAUD(baud)
  603. Xunsigned int baud;
  604. X{
  605. X    switch(baud)
  606. X    {
  607. X        case 110:  return(B110);
  608. X        case 300:  return(B300);
  609. X        case 1200: return(B1200);
  610. X        case 2400: return(B2400);
  611. X        case 4800: return(B4800);
  612. X        case 9600: return(B9600);
  613. X
  614. X#if defined(B19200)
  615. X        case 19200: return(B19200);
  616. X#else
  617. X#ifdef EXTA
  618. X        case 19200: return(EXTA);
  619. X#endif
  620. X#endif
  621. X
  622. X    }
  623. X    myexit(RC_FAIL | RCE_SPEED);
  624. X#if defined(OPTIMIZE) || defined(__OPTIMIZE__)    /* don't complain */
  625. X    return(0);    /* keep gcc from complaining about no rtn at end */
  626. X#endif
  627. X}    /* end of DCE_baud_to_CBAUD */
  628. X
  629. X/*+-------------------------------------------------------------------------
  630. X    sync_Microcom() - sync modem with our DTE speed
  631. X--------------------------------------------------------------------------*/
  632. Xvoid
  633. Xsync_Microcom()
  634. X{
  635. Xregister int maxretry = 4;
  636. X
  637. X    while(maxretry--)
  638. X    {
  639. X        lflush();
  640. X        DCE_write_pace_msec = 20;
  641. X        lwrite("ATQ0E1V1\r");
  642. X        DCE_write_pace_msec = 0;
  643. X        if(lread_ignore(5) == rOk)
  644. X            return;
  645. X    }
  646. X
  647. X    DEBUG(1,"Microcom SYNC FAILED\n",0);
  648. X    myexit(RC_FAIL | RCE_TIMOUT);
  649. X
  650. X}    /* end of sync_Microcom */
  651. X
  652. X/*+-------------------------------------------------------------------------
  653. X    DCE_hangup() - issue hangup command to DCE
  654. X
  655. XThis function should do whatever is necessary to ensure
  656. X1) any active connection is terminated
  657. X2) the DCE is ready to receive an incoming call if DTR is asserted
  658. X3) the DCE will not accept an incoming call if DTR is false
  659. X
  660. XThe function should return when done.
  661. X
  662. XAny necessary switch setting or other configuration necessary for this
  663. Xfunction to succeed should be documented at the top of the module.
  664. X--------------------------------------------------------------------------*/
  665. Xvoid
  666. XDCE_hangup()
  667. X{
  668. Xchar *reset_it = "ATZ\r";
  669. Xchar *dialin = "ATS0=1Q1E0M0\\N3\\Q1\\G1%C1%P2\r";
  670. X
  671. X    DEBUG(1,"--> hanging up %s\n",dce_name);
  672. X    lflash_DTR();
  673. X    sync_Microcom();
  674. X    lwrite(reset_it);
  675. X    lread_ignore(5);
  676. X    lwrite(dialin);
  677. X    Nap(500L);
  678. X
  679. X}    /* end of DCE_hangup */
  680. X
  681. X/*+-------------------------------------------------------------------------
  682. X    DCE_dial(telno_str) - dial a remote DCE
  683. X
  684. XThis function should connect to the remote DCE and use any success
  685. Xindication to modify the tty baud rate if necessary before returning.
  686. X
  687. XUpon successful connection, return 0.
  688. X
  689. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  690. XRCE_XXX value from dialer.h.
  691. X
  692. Xlwrite() is used to write to the DCE.
  693. X
  694. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  695. Xfrom calling lread() will result automatically in the proper error
  696. Xtermination of the program.  Read timeouts from calling lread_ignore()
  697. Xreturn -1; you handle the execption here.
  698. X
  699. XAny necessary coding of phone numbers, switch settings or other
  700. Xconfiguration necessary for this function to succeed should be
  701. Xdocumented at the top of the module.
  702. X
  703. XMicrocom Plus-specific comments:
  704. X--------------------------------------------------------------------------*/
  705. Xint
  706. XDCE_dial(telno_str)
  707. Xchar *telno_str;
  708. X{
  709. Xchar cmd[128];
  710. Xint timeout;
  711. Xint result;
  712. Xchar *cptr;
  713. Xchar phone[42];
  714. X#define MDVALID "0123456789NnSs,*#()-"
  715. Xchar *setup      = "ATQ0E1V1X4S0=0&D2&C1%C1%P2";
  716. Xchar *setup_REL  = "\\N3\\Q1\\G1";
  717. Xchar *setup_NORM = "\\N0\\Q0\\G0";
  718. X
  719. X/* preliminary setup */
  720. X    translate("=,-,",telno_str);
  721. X    if(strspn(telno_str,MDVALID) != strlen(telno_str))
  722. X    {
  723. X        DEBUG(1,"phone number has invalid characters\n",0);
  724. X        return(RC_FAIL | RCE_PHNO);
  725. X    }
  726. X    if(decode_phone_number(telno_str,phone,sizeof(phone)))
  727. X    {
  728. X        DEBUG(1,"phone number too long\n",0);
  729. X        return(RC_FAIL | RCE_PHNO);
  730. X    }
  731. X
  732. X/*
  733. X * calculate a timeout for the connect
  734. X * allow a minimum of 40 seconds, if reliable, 50
  735. X * also if long distance (North American calculation here)
  736. X * make it 132
  737. X */
  738. X    timeout = 40;
  739. X    if(hiCBAUD > B2400)
  740. X        timeout = 50;
  741. X    if((phone[0] == '1') && (phone[0] != '0'))
  742. X        timeout = 132;
  743. X    for(cptr = phone; cptr = strchr(cptr,','); cptr++)
  744. X        timeout += 2;    /* add extra time for pause characters */
  745. X    DEBUG(6,"wait for connect = %d seconds\n",timeout);
  746. X
  747. X/*
  748. X * build and issue the dialout setup command
  749. X * 9624's S7 timing is way off (S7 is calculated as timeout * .6)
  750. X */
  751. X    DEBUG(1,"--> issuing setup command\n",0);
  752. X    sprintf(cmd,"%s%sS7=%d\r",
  753. X        setup,
  754. X        (hiCBAUD > B2400) ? setup_REL : setup_NORM,
  755. X        (timeout * 6) / 10);
  756. X
  757. X    sync_Microcom();
  758. X    lwrite(cmd);
  759. X    if(lread(5) != rOk)
  760. X        return(RC_FAIL | RCE_NULL);
  761. X
  762. X/* indicate non-root should not see DTE->DCE traffic */
  763. X    secure = 1;
  764. X
  765. X/*
  766. X * build and issue the actual dialing command
  767. X * if root, let him see number, otherwise just say "remote system"
  768. X */
  769. X#ifdef WHT
  770. X    if(!strncmp(*gargv,"ECU",3))
  771. X        dialer_codes['S' - 'A'] = 1;
  772. X#endif
  773. X    DEBUG(1,"--> dialing %s\n", (!ecu_calling & uid) ? "remote system" : phone);
  774. X    sprintf(cmd,"ATS2=255M%dDT%s\r",
  775. X        ((dialer_codes['S' - 'A']) && !(dialer_codes['N' - 'A'])) ? 1 : 0,
  776. X        phone);
  777. X
  778. X    /* cmd string can only be 40 characters including "AT" */
  779. X    if(strlen(cmd) > 40)
  780. X    {
  781. X        DEBUG(1,"phone number string too long\n",0);
  782. X        cleanup(RC_FAIL | RCE_PHNO);
  783. X    }
  784. X
  785. X    lwrite(cmd);
  786. X
  787. X/* indicate non-root can see DTE->DCE traffic */
  788. X    secure = 0;
  789. X
  790. X/* wait for connect */
  791. X    result = lread(timeout);
  792. X    if(!(result & rfConnect))
  793. X    {
  794. X        switch(result & rfMASK)
  795. X        {
  796. X        case rNoDialTone:
  797. X            return(RC_FAIL | RCE_NOTONE);
  798. X        case rBusy:
  799. X            return(RC_FAIL | RCE_BUSY);
  800. X        case rNoAnswer:
  801. X        case rNoCarrier:    /* with ATX4, NO CARRIER == NO ANSWER
  802. X                             * since BUSY and NO DIAL TONE are reported
  803. X                             */
  804. X            return(RC_FAIL | RCE_ANSWER);
  805. X        default:
  806. X            return(RC_FAIL | RCE_NULL);
  807. X        }
  808. X    }
  809. X
  810. X    return(0);        /* succeeded */
  811. X
  812. X}    /* end of DCE_dial */
  813. X
  814. X/**********************************************************
  815. X*  You probably do not need to modify the code below here *
  816. X**********************************************************/
  817. X
  818. X/*+-------------------------------------------------------------------------
  819. X    DCE_abort(sig) - dial attempt aborted
  820. X
  821. X sig =  0 if non-signal abort (read timeout, most likely)
  822. X     != 0 if non-SIGALRM signal caught
  823. X
  824. X extern int dialing set  1 if dialing request was active,
  825. X                    else 0 if hangup request was active
  826. X
  827. XThis is a chance for the DCE-specific code to do anything it
  828. Xneeds to cl,ean up after a failure.  Note that if a dialing
  829. Xcall fails, it is the responsibility of the higher-level
  830. Xprogram calling the dialer to call it again with a hangup request, so
  831. Xthis function is usually a no-op.
  832. X--------------------------------------------------------------------------*/
  833. Xvoid
  834. XDCE_abort(sig)
  835. Xint sig;
  836. X{
  837. X    DEBUG(10,"DCE_abort(%d);\n",sig);
  838. X}    /* end of DCE_abort */
  839. X
  840. X/*+-------------------------------------------------------------------------
  841. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  842. X
  843. XThe independent portion of the dialer program calls this routine in
  844. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  845. XNormally, this function just passes it's argument to exit(), but
  846. Xany necessary post-processing can be done.  The function must,
  847. Xhowever, eventually call exit(exitcode);
  848. X--------------------------------------------------------------------------*/
  849. Xvoid
  850. XDCE_exit(exitcode)
  851. Xint exitcode;
  852. X{
  853. X    DEBUG(10,"DCE_exit(%d);\n",exitcode);
  854. X    exit(exitcode);
  855. X}    /* end of DCE_exit */
  856. X
  857. X/*+-------------------------------------------------------------------------
  858. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  859. X
  860. XThis hook gives DCE-specific code a chance to look over the entire
  861. Xcommand line, such as for -z processing.
  862. X
  863. Xargc andf argv are the same values passed to main(),
  864. X
  865. Xoptind is the value of optind at the end of normal getopt processing.
  866. X
  867. Xunrecognized_switches is the count of switches not handled by main().
  868. XSpecifically, -h and -x are standard switches.
  869. X
  870. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  871. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  872. Xthough, you can do anything you need to do here and exit the program.
  873. X
  874. XNote: only simple switches (with no argument) may be used with this
  875. Xfacility if the functrion is to return,' since main()'s getopt() will
  876. Xstop processing switches if it runs into an unrecognized switch with an
  877. Xargument.
  878. X
  879. XIf the function returns a non-zero value, then the value will be passed
  880. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  881. Xof the format expected by dialer program callers, with RC_FAIL set as a
  882. Xminimum.
  883. X--------------------------------------------------------------------------*/
  884. Xint
  885. XDCE_argv_hook(argc,argv,optind,unrecognized_switches)
  886. Xint argc;
  887. Xchar **argv;
  888. Xint optind;
  889. Xint unrecognized_switches;
  890. X{
  891. X    if(unrecognized_switches)
  892. X        return(RC_FAIL | RCE_ARGS);
  893. X    return(0);
  894. X}    /* end of DCE_argv_hook */
  895. X
  896. X/* vi: set tabstop=4 shiftwidth=4: */
  897. SHAR_EOF
  898. chmod 0644 gendial/dceMC9624.c ||
  899. echo 'restore of gendial/dceMC9624.c failed'
  900. Wc_c="`wc -c < 'gendial/dceMC9624.c'`"
  901. test 13931 -eq "$Wc_c" ||
  902.     echo 'gendial/dceMC9624.c: original size 13931, current size' "$Wc_c"
  903. rm -f _shar_wnt_.tmp
  904. fi
  905. # ============= gendial/dceMPAD.c ==============
  906. if test -f 'gendial/dceMPAD.c' -a X"$1" != X"-c"; then
  907.     echo 'x - skipping gendial/dceMPAD.c (File already exists)'
  908.     rm -f _shar_wnt_.tmp
  909. else
  910. > _shar_wnt_.tmp
  911. echo 'x - extracting gendial/dceMPAD.c (Text)'
  912. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dceMPAD.c' &&
  913. X/* CHK=0xFF53 */
  914. X/*+-------------------------------------------------------------------------
  915. X    dceMPAD.c - DCE-specific portion of generic SCO UUCP dialer
  916. X    Driver for ATT Tridom MPAD VSAT modem emulation
  917. X    wht@n4hgf.Mt-Park.GA.US
  918. X--------------------------------------------------------------------------*/
  919. X/*+:EDITS:*/
  920. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  921. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  922. X/*:02-02-1992-18:01-root@n4hgf-proper ordering of DCE_result entries */
  923. X/*:01-26-1992-15:30-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
  924. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  925. X/*:03-12-1991-19:11-wht@n4hgf-if ecu dialing, show complete call progress */
  926. X/*:11-29-1990-18:31-r@n4hgf-revision/1st releasable */
  927. X/*:11-29-1990-17:48-wht@n4hgf-creation */
  928. X
  929. X#include "dialer.h"
  930. X
  931. X/*
  932. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  933. X *                    sees the transition; this value may be changed
  934. X *                    as necessary before each call to lflash_DTR(),
  935. X * but, generally, a constant value will do.
  936. X */
  937. Xlong DCE_DTR_low_msec = 50;
  938. X
  939. X/*
  940. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  941. X *                     DCE may be expected to be ready to be commanded
  942. X */
  943. Xlong DCE_DTR_high_msec = 50;
  944. X
  945. X/*
  946. X * DCE_write_pace_msec - milliseconds to pause between each character
  947. X *                       sent to the DCE (zero if streaming I/O is
  948. X *                       permitted); this value may be changed as
  949. X * necessary before each call to lwrite(), but, generally, a constant
  950. X * value will do.  Note that this value is used to feed a value to Nap(),
  951. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  952. X * and .050 seconds on XENIX/86.
  953. X */
  954. Xlong DCE_write_pace_msec = 0;
  955. X
  956. X/*
  957. X * DCE_name     - short name for DCE
  958. X * DCE_revision - revision number for this module
  959. X */
  960. Xchar *DCE_name = "ATT Tridom MPAD";
  961. Xchar *DCE_revision = "1.37";
  962. X
  963. X/*
  964. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  965. X *                    and readying it for dial in access
  966. X *                    (BXXX mask); use a value of zero if the speed
  967. X *                    specified by the invoker is to be used.
  968. X * This value is useful for DCEs such as the early Hayes 2400
  969. X * which are so unfortunately compatible with their 1200 predecessor
  970. X * that they refuse to answer at 2400 baud unless you last spoke to
  971. X * them at that rate. For such bad boys, use B2400 below.
  972. X */
  973. Xint DCE_hangup_CBAUD = 0;
  974. X/* int DCE_hangup_CBAUD = B2400; */
  975. X
  976. X/*
  977. X * DCE_results - a table of DCE response strings and a token
  978. X *               code for each; when you call lread() or lread_ignore(),
  979. X *               if the read routine detects one of the strings,
  980. X * the appropriate code is returned.  If no string matches, then
  981. X * lread()/lread_ignore examines the DCE result string for a
  982. X * numeric value; if one is found, the numeric value or'd with
  983. X * 0x40000000 is returned (in this way, e.g., you can read "modem
  984. X * S registers").  If nothing agrees with this search, lread()
  985. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  986. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  987. X * This module is the only consumer  of the codes, although they
  988. X * are decoded by gendial.c's _lread().
  989. X *
  990. X * If one possible result is an "early substring" of another, like
  991. X * "CONNECT" is of "CONNECT 1200", then put such results later in the
  992. X * table than the larger result.
  993. X *
  994. X */
  995. X
  996. X/* flag bits */
  997. X#define rfConnect        0x00800000
  998. X#define rfMASK            0x0000FFFF    /* mask off rfBits */
  999. X
  1000. X/* unique codes */
  1001. X#define rOk                0
  1002. X#define rNoCarrier        1
  1003. X#define rError            2
  1004. X#define rNoDialTone     3
  1005. X#define rBusy            4
  1006. X#define rNoAnswer        5
  1007. X#define rRring            6
  1008. X#define rConnect300        (  300  | rfConnect)
  1009. X#define rConnect1200    ( 1200  | rfConnect)
  1010. X#define rConnect2400    ( 2400  | rfConnect)
  1011. X#define rConnect4800    ( 4800  | rfConnect)
  1012. X#define rConnect9600    ( 9600  | rfConnect)
  1013. X#define rConnect9600    ( 9600  | rfConnect)
  1014. X#define rConnect19200    (19200  | rfConnect)
  1015. X#define rConnect38400    (38400  | rfConnect)
  1016. X
  1017. XDCE_RESULT DCE_results[] =
  1018. X{
  1019. X    { "OK",                 rOk,            },
  1020. X    { "NO CARRIER",         rNoCarrier,     },
  1021. X    { "ERROR",              rError          },
  1022. X    { "BUSY",               rBusy           },
  1023. X    { "NO ANSWER",          rNoAnswer       },
  1024. X    { "NO DIAL TONE",       rNoDialTone     },
  1025. X    { "KDIR SENDX ERROR",   rNoDialTone     },  /* MPAD software error */
  1026. X    { "KDIR UNRESPONSIVE",  rNoDialTone     },
  1027. X    { "KDIR BUSY",          rBusy           },
  1028. X    { "KDIR BAD REQUEST",   rError          },  /* number 0 or >11 length */
  1029. X    { "NO SUCH NUMBER",     rNoAnswer       },
  1030. X    { "KDIR LOGIC ERROR",   rNoDialTone     },  /* MPAD software error */
  1031. X    { "KDIR NOT AVAIL",     rNoDialTone     },
  1032. X    { "TP4 STATE ERROR",    rNoDialTone     },  /* rain fade */
  1033. X    { "TP4 GIVE UP",        rBusy           },  /* rain fade */
  1034. X    { "TP4 ERROR RESP",     rBusy           },  /* transient problem */
  1035. X    { "NET DEACT",          rNoDialTone     },  /* net op deactivated port */
  1036. X    { "CONNECT 300",        rConnect300     },
  1037. X    { "CONNECT 1200",       rConnect1200    },
  1038. X    { "CONNECT 4800",       rConnect4800    },
  1039. X    { "CONNECT 9600",       rConnect9600    },
  1040. X    { "CONNECT 19200",      rConnect19200   },
  1041. X    { "CONNECT 38400",      rConnect38400   },
  1042. X    { (char *)0,            -1              }       /* end table */
  1043. X};
  1044. X
  1045. X/*+-------------------------------------------------------------------------
  1046. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  1047. X
  1048. X  DCE dependent function must validate baud rates supported by DCE
  1049. X  returns baud rate in struct termio c_cflag fashion
  1050. X  or terminates program with error
  1051. X--------------------------------------------------------------------------*/
  1052. Xint
  1053. XDCE_baud_to_CBAUD(baud)
  1054. Xunsigned int baud;
  1055. X{
  1056. X    switch(baud)
  1057. X    {
  1058. X        case 110:  return(B110);
  1059. X        case 300:  return(B300);
  1060. X        case 1200: return(B1200);
  1061. X        case 2400: return(B2400);
  1062. X        case 9600: return(B9600);
  1063. X
  1064. X#if defined(B19200)
  1065. X        case 19200: return(B19200);
  1066. X#else
  1067. X#ifdef EXTA
  1068. X        case 19200: return(EXTA);
  1069. X#endif
  1070. X#endif
  1071. X
  1072. X#if defined(B38400)
  1073. X        case 38400: return(B38400);
  1074. X#else
  1075. X#ifdef EXTB
  1076. X        case 38400: return(EXTB);
  1077. X#endif
  1078. X#endif
  1079. X
  1080. X    }
  1081. X    myexit(RC_FAIL | RCE_SPEED);
  1082. X#if defined(OPTIMIZE) || defined(__OPTIMIZE__)    /* don't complain */
  1083. X    return(0);    /* keep gcc from complaining about no rtn at end */
  1084. X#endif
  1085. X}    /* end of DCE_baud_to_CBAUD */
  1086. X
  1087. X/*+-------------------------------------------------------------------------
  1088. X    sync_MPAD() - sync modem with our DTE speed
  1089. X--------------------------------------------------------------------------*/
  1090. Xvoid
  1091. Xsync_MPAD()
  1092. X{
  1093. Xregister int maxretry = 8;
  1094. Xregister int count;
  1095. Xunsigned char rdchar;
  1096. X
  1097. X    while(maxretry--)
  1098. X    {
  1099. X        lflush();
  1100. X        write(dce_fd,"a",1);
  1101. X        count = 5;
  1102. X        while(count)    /* wait 50-200 msec for character, depending on HZ */
  1103. X        {
  1104. X            if(rdchk(dce_fd))
  1105. X                break;
  1106. X            Nap(50L);
  1107. X            count--;
  1108. X        }
  1109. X        if(count && (read(dce_fd,&rdchar,1) == 1) && (rdchar == 'a'))
  1110. X            return;
  1111. X        write(dce_fd,"atq0v1e1\r",9);
  1112. X        Nap(500L);
  1113. X    }
  1114. X
  1115. X    DEBUG(1,"MPAD SYNC FAILED\n",0);
  1116. X    myexit(RC_FAIL | RCE_TIMOUT);
  1117. X
  1118. X}    /* end of sync_MPAD */
  1119. X
  1120. X/*+-------------------------------------------------------------------------
  1121. X    init_MPAD() - init MPAD from scratch, assuming nothing
  1122. X--------------------------------------------------------------------------*/
  1123. Xvoid
  1124. Xinit_MPAD()
  1125. X{
  1126. Xregister itmp;
  1127. Xint maxretry = 4;
  1128. Xchar *init0 = "ATE0Q0V1X99S0=1S2=255\r";
  1129. X
  1130. X    DEBUG(1,"--> reseting %s\n",dce_name);
  1131. X    lflash_DTR();
  1132. X    sync_MPAD();
  1133. X
  1134. X    /*
  1135. X     * set to factory default (bless them for this command)
  1136. X     * and a few initial beachhead values
  1137. X     */
  1138. X    for(itmp = 0; itmp < maxretry; itmp++)
  1139. X    {
  1140. X        lwrite(init0);
  1141. X        if(lread(5) == rOk)
  1142. X            break;
  1143. X    }
  1144. X    if(itmp == maxretry)
  1145. X    {
  1146. X        DEBUG(1,"reset failed\n",0);
  1147. X        myexit(RC_FAIL | RCE_TIMOUT);
  1148. X    }
  1149. X
  1150. X}    /* end of init_MPAD */
  1151. X
  1152. X/*+-------------------------------------------------------------------------
  1153. X    DCE_hangup() - issue hangup command to DCE
  1154. X
  1155. XThis function should do whatever is necessary to ensure
  1156. X1) any active connection is terminated
  1157. X2) the DCE is ready to receive an incoming call if DTR is asserted
  1158. X3) the DCE will not accept an incoming call if DTR is false
  1159. X
  1160. XThe function should return when done.
  1161. X
  1162. XAny necessary switch setting or other configuration necessary for this
  1163. Xfunction to succeed should be documented at the top of the module.
  1164. X--------------------------------------------------------------------------*/
  1165. Xvoid
  1166. XDCE_hangup()
  1167. X{
  1168. X    DEBUG(1,"--> hanging up %s\n",dce_name);
  1169. X    lflash_DTR();
  1170. X    init_MPAD();
  1171. X
  1172. X}    /* end of DCE_hangup */
  1173. X
  1174. X/*+-------------------------------------------------------------------------
  1175. X    DCE_dial(telno_str) - dial a remote DCE
  1176. X
  1177. XThis function should connect to the remote DCE and use any success
  1178. Xindication to modify the tty baud rate if necessary before returning.
  1179. X
  1180. XUpon successful connection, return 0.
  1181. X
  1182. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  1183. XRCE_XXX value from dialer.h.
  1184. X
  1185. Xlwrite() is used to write to the DCE.
  1186. X
  1187. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  1188. Xfrom calling lread() will result automatically in the proper error
  1189. Xtermination of the program.  Read timeouts from calling lread_ignore()
  1190. Xreturn -1; you handle the execption here.
  1191. X
  1192. XAny necessary coding of phone numbers, switch settings or other
  1193. Xconfiguration necessary for this function to succeed should be
  1194. Xdocumented at the top of the module.
  1195. X
  1196. XMPAD Plus-specific comments:
  1197. X Q0          do not be quiet
  1198. X E0          do not echo
  1199. X V1          verbal result codes
  1200. X S0=0        dont allow connect while dialing
  1201. X X99         full result codes
  1202. X--------------------------------------------------------------------------*/
  1203. Xint
  1204. XDCE_dial(telno_str)
  1205. Xchar *telno_str;
  1206. X{
  1207. Xchar cmd[128];
  1208. Xchar phone[50];
  1209. Xint timeout;
  1210. Xint result;
  1211. Xchar *cptr;
  1212. Xchar *dialout_default = "ATQ0E0V1E0S0=0X99\r";
  1213. X#define MDVALID     "0123456789NnSs()-"
  1214. X
  1215. X/* preliminary setup */
  1216. X    translate("=,-,",telno_str);
  1217. X    if(strspn(telno_str,MDVALID) != strlen(telno_str))
  1218. X    {
  1219. X        DEBUG(1,"phone number has invalid characters\n",0);
  1220. X        return(RC_FAIL | RCE_PHNO);
  1221. X    }
  1222. X    if(decode_phone_number(telno_str,phone,sizeof(phone)))
  1223. X    {
  1224. X        DEBUG(1,"phone number too long\n",0);
  1225. X        return(RC_FAIL | RCE_PHNO);
  1226. X    }
  1227. X
  1228. X/* walk through dialer codes, doing custom setup */
  1229. X    strcpy(cmd,"AT");
  1230. X    cptr = cmd + strlen(cmd);
  1231. X
  1232. X    DEBUG(1,"--> issuing default setup command\n",0);
  1233. X    sync_MPAD();
  1234. X    lwrite(dialout_default);
  1235. X    if(lread(5) != rOk)
  1236. X    {
  1237. X        DEBUG(1,"default dialout setup failed\n",0);
  1238. X        return(RC_FAIL | RCE_NULL);
  1239. X    }
  1240. X
  1241. X/* issue the custom setup command */
  1242. X    if(*cptr)
  1243. X    {
  1244. X        DEBUG(1,"--> issuing custom setup cmd\n",0);
  1245. X        strcat(cmd,"\r");
  1246. X        sync_MPAD();
  1247. X        lwrite(cmd);
  1248. X        if(lread(5) != rOk)
  1249. X        {
  1250. X            DEBUG(1,"custom modem setup failed\n",0);
  1251. X            return(RC_FAIL | RCE_NULL);
  1252. X        }
  1253. X    }
  1254. X
  1255. X/*
  1256. X * calculate a timeout for the connect
  1257. X */
  1258. X    timeout = 20;
  1259. X    DEBUG(6,"wait for connect = %d seconds\n",timeout);
  1260. X
  1261. X/* indicate non-root should not see DTE->DCE traffic */
  1262. X    secure = 1;
  1263. X
  1264. X/*
  1265. X * build and issue the actual dialing command
  1266. X * if root, let him see number, otherwise just say "remote system"
  1267. X */
  1268. X    DEBUG(1,"--> dialing %s\n", (!ecu_calling & uid) ? "remote system" : phone);
  1269. X    sprintf(cmd,"ATS7=%dDT%s\r",(timeout * 9) / 10,phone);
  1270. X
  1271. X    /* cmd string can only be 40 characters including "AT" */
  1272. X    if(strlen(cmd) > 40)
  1273. X    {
  1274. X        DEBUG(1,"phone number string too long\n",0);
  1275. X        cleanup(RC_FAIL | RCE_PHNO);
  1276. X    }
  1277. X
  1278. X    sync_MPAD();
  1279. X    lwrite(cmd);
  1280. X
  1281. X/* indicate non-root can see DTE->DCE traffic */
  1282. X    secure = 0;
  1283. X
  1284. X/* wait for connect */
  1285. X    result = lread(timeout);
  1286. X    if(!(result & rfConnect))
  1287. X    {
  1288. X        switch(result & rfMASK)
  1289. X        {
  1290. X        case rNoCarrier:
  1291. X            return(RC_FAIL | RCE_NOCARR);
  1292. X        case rNoDialTone:
  1293. X            return(RC_FAIL | RCE_NOTONE);
  1294. X        case rBusy:
  1295. X            return(RC_FAIL | RCE_BUSY);
  1296. X        case rNoAnswer:
  1297. X            return(RC_FAIL | RCE_ANSWER);
  1298. X        case rError:
  1299. X        default:
  1300. X            return(RC_FAIL | RCE_NULL);
  1301. X        }
  1302. X    }
  1303. X
  1304. X    return(0);        /* succeeded */
  1305. X
  1306. X}    /* end of DCE_dial */
  1307. X
  1308. X/**********************************************************
  1309. X*  You probably do not need to modify the code below here *
  1310. X**********************************************************/
  1311. X
  1312. X/*+-------------------------------------------------------------------------
  1313. X    DCE_abort(sig) - dial attempt aborted
  1314. X
  1315. X sig =  0 if non-signal abort (read timeout, most likely)
  1316. X     != 0 if non-SIGALRM signal caught
  1317. X
  1318. X extern int dialing set  1 if dialing request was active,
  1319. X                    else 0 if hangup request was active
  1320. X
  1321. XThis is a chance for the DCE-specific code to do anything it
  1322. Xneeds to cl,ean up after a failure.  Note that if a dialing
  1323. Xcall fails, it is the responsibility of the higher-level
  1324. Xprogram calling the dialer to call it again with a hangup request, so
  1325. Xthis function is usually a no-op.
  1326. X--------------------------------------------------------------------------*/
  1327. Xvoid
  1328. XDCE_abort(sig)
  1329. Xint sig;
  1330. X{
  1331. X    DEBUG(10,"DCE_abort(%d);\n",sig);
  1332. X}    /* end of DCE_abort */
  1333. X
  1334. X/*+-------------------------------------------------------------------------
  1335. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  1336. X
  1337. XThe independent portion of the dialer program calls this routine in
  1338. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  1339. XNormally, this function just passes it's argument to exit(), but
  1340. Xany necessary post-processing can be done.  The function must,
  1341. Xhowever, eventually call exit(exitcode);
  1342. X--------------------------------------------------------------------------*/
  1343. Xvoid
  1344. XDCE_exit(exitcode)
  1345. Xint exitcode;
  1346. X{
  1347. X    DEBUG(10,"DCE_exit(%d);\n",exitcode);
  1348. X    exit(exitcode);
  1349. X}    /* end of DCE_exit */
  1350. X
  1351. X/*+-------------------------------------------------------------------------
  1352. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  1353. X
  1354. XThis hook gives DCE-specific code a chance to look over the entire
  1355. Xcommand line, such as for -z processing.
  1356. X
  1357. Xargc andf argv are the same values passed to main(),
  1358. X
  1359. Xoptind is the value of optind at the end of normal getopt processing.
  1360. X
  1361. Xunrecognized_switches is the count of switches not handled by main().
  1362. XSpecifically, -h and -x are standard switches.
  1363. X
  1364. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  1365. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  1366. Xthough, you can do anything you need to do here and exit the program.
  1367. X
  1368. XNote: only simple switches (with no argument) may be used with this
  1369. Xfacility if the functrion is to return,' since main()'s getopt() will
  1370. Xstop processing switches if it runs into an unrecognized switch with an
  1371. Xargument.
  1372. X
  1373. XIf the function returns a non-zero value, then the value will be passed
  1374. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  1375. Xof the format expected by dialer program callers, with RC_FAIL set as a
  1376. Xminimum.
  1377. X--------------------------------------------------------------------------*/
  1378. Xint
  1379. XDCE_argv_hook(argc,argv,optind,unrecognized_switches)
  1380. Xint argc;
  1381. Xchar **argv;
  1382. Xint optind;
  1383. Xint unrecognized_switches;
  1384. X{
  1385. X    if(unrecognized_switches)
  1386. X        return(RC_FAIL | RCE_ARGS);
  1387. X    return(0);
  1388. X}    /* end of DCE_argv_hook */
  1389. X
  1390. X/* vi: set tabstop=4 shiftwidth=4: */
  1391. SHAR_EOF
  1392. chmod 0644 gendial/dceMPAD.c ||
  1393. echo 'restore of gendial/dceMPAD.c failed'
  1394. Wc_c="`wc -c < 'gendial/dceMPAD.c'`"
  1395. test 14942 -eq "$Wc_c" ||
  1396.     echo 'gendial/dceMPAD.c: original size 14942, current size' "$Wc_c"
  1397. rm -f _shar_wnt_.tmp
  1398. fi
  1399. # ============= gendial/dceT2500.c ==============
  1400. if test -f 'gendial/dceT2500.c' -a X"$1" != X"-c"; then
  1401.     echo 'x - skipping gendial/dceT2500.c (File already exists)'
  1402.     rm -f _shar_wnt_.tmp
  1403. else
  1404. > _shar_wnt_.tmp
  1405. echo 'x - extracting gendial/dceT2500.c (Text)'
  1406. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dceT2500.c' &&
  1407. X/*+-------------------------------------------------------------------------
  1408. X    dceT2500.c - DCE-specific portion of generic SCO UUCP dialer
  1409. X    Driver for Telebit T2500
  1410. X    wht@n4hgf.Mt-Park.GA.US
  1411. X
  1412. Xafter init
  1413. XE0 F1 M0 Q4 P V1 W0 X3 Y0 &P0 &T4     Version GE6.01-T2500
  1414. XS00=001 S01=000 S02:001 S03=013 S04=010 S05=008 S06=002 S07=040 S08=002 S09=006
  1415. XS10=007 S11:050 S12=050 S18=000 S25=005 S26=000 S38=000 
  1416. XS41=000 S45:001 S47=004 S48:001 S49=000 
  1417. XS50=000 S51:252 S52:004 S54:003 S55=000 S56=017 S57=019 S58:002 S59=000 
  1418. XS61=150 S62=003 S63=001 S64:001 S65=000 S66=000 S67=000 S68=255 S69=000 
  1419. XS90=000 S91=000 S92:001 S93=008 S94=001 S95=000 S96=001 S97=000 S98=003 
  1420. XS100=000 S101=000 S102=000 S104=000 S105=001 S106=000 S107=020 
  1421. XS110=255 S111=255 S112=001 
  1422. XS121=000 S130=002 S131:001 
  1423. XS150=000 S151=004 S152=001 S153=001 S154=000 S155=000 
  1424. XS160=010 S161=020 S162=002 S163=003 S164=007 S255=000 
  1425. X--------------------------------------------------------------------------*/
  1426. X/*+:EDITS:*/
  1427. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1428. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1429. X/*:07-27-1992-05:00-wht@n4hgf-no pacing */
  1430. X/*:02-10-1992-21:43-root@n4hgf-made it 1.5 years not setting S131 - then drat */
  1431. X/*:02-10-1992-00:27-wht@n4hgf-improved sync_Telebit */
  1432. X/*:01-26-1992-15:30-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
  1433. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1434. X/*:03-12-1991-19:11-wht@n4hgf-if ecu dialing, show complete call progress */
  1435. X/*:11-29-1990-18:31-r@n4hgf-revision/1st releasable */
  1436. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1437. X
  1438. X#include "dialer.h"
  1439. X
  1440. X/*
  1441. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  1442. X *                    sees the transition; this value may be changed
  1443. X *                    as necessary before each call to lflash_DTR(),
  1444. X * but, generally, a constant value will do.
  1445. X */
  1446. Xlong DCE_DTR_low_msec = 500;
  1447. X
  1448. X/*
  1449. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  1450. X *                     DCE may be expected to be ready to be commanded
  1451. X */
  1452. Xlong DCE_DTR_high_msec = 1000L;
  1453. X
  1454. X/*
  1455. X * DCE_write_pace_msec - milliseconds to pause between each character
  1456. X *                       sent to the DCE (zero if streaming I/O is
  1457. X *                       permitted); this value may be changed as
  1458. X * necessary before each call to lwrite(), but, generally, a constant
  1459. X * value will do.  Note that this value is used to feed a value to Nap(),
  1460. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  1461. X * and .050 seconds on XENIX/86.
  1462. X */
  1463. Xlong DCE_write_pace_msec = 0;
  1464. X
  1465. X/*
  1466. X * DCE_name     - short name for DCE
  1467. X * DCE_revision - revision number for this module
  1468. X */
  1469. Xchar *DCE_name = "Telebit T2500";
  1470. Xchar *DCE_revision = "1.30";
  1471. X
  1472. X/*
  1473. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  1474. X *                    and readying it for dial in access
  1475. X *                    (BXXX mask); use a value of zero if the speed
  1476. X *                    specified by the invoker is to be used.
  1477. X * This value is useful for DCEs such as the early Hayes 2400
  1478. X * which are so unfortunately compatible with their 1200 predecessor
  1479. X * that they refuse to answer at 2400 baud unless you last spoke to
  1480. X * them at that rate. For such bad boys, use B2400 below.
  1481. X */
  1482. Xint DCE_hangup_CBAUD = 0;
  1483. X/* int DCE_hangup_CBAUD = B2400; */
  1484. X
  1485. X/*
  1486. X * DCE_results - a table of DCE response strings and a token
  1487. X *               code for each; when you call lread() or lread_ignore(),
  1488. X *               if the read routine detects one of the strings,
  1489. X * the appropriate code is returned.  If no string matches, then
  1490. X * lread()/lread_ignore examines the DCE result string for a
  1491. X * numeric value; if one is found, the numeric value or'd with
  1492. X * 0x40000000 is returned (in this way, e.g., you can read "modem
  1493. X * S registers").  If nothing agrees with this search, lread()
  1494. X * will abort the program with RC_FAIL|RCE_TIMOUT, lread_ignore()
  1495. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  1496. X * This module is the only consumer  of the codes, although they
  1497. X * are decoded by gendial.c's _lread()
  1498. X */
  1499. X
  1500. X/* flag bits */
  1501. X#define rfConnect        0x00800000
  1502. X#define rfREL            0x00400000
  1503. X#define rfFAST            0x00200000
  1504. X#define rfV32            0x00100000
  1505. X#define rfMASK            0x0000FFFF    /* mask off rfBits */
  1506. X
  1507. X/* unique codes */
  1508. X#define rOk                0
  1509. X#define rNoCarrier        1
  1510. X#define rError            2
  1511. X#define rNoDialTone     3
  1512. X#define rBusy            4
  1513. X#define rNoAnswer        5
  1514. X#define rRring            6
  1515. X#define rConnect300        (  300  | rfConnect)
  1516. X#define rConnect1200    ( 1200  | rfConnect)
  1517. X#define rConnect2400    ( 1200  | rfConnect)
  1518. X#define rConnect300R    (  300  | rfConnect | rfREL)
  1519. X#define rConnect1200R    ( 1200  | rfConnect | rfREL)
  1520. X#define rConnect2400R    ( 2400  | rfConnect | rfREL)
  1521. X#define rConnectFASTK    (19200  | rfConnect | rfFAST)    /* may be 9600 */
  1522. X#define rConnectFASTX    (19200  | rfConnect | rfFAST)
  1523. X#define rConnectFASTU    (19200  | rfConnect | rfFAST)
  1524. X#define rConnectFAST    (19200  | rfConnect | rfFAST)
  1525. X#define rConnect9600    ( 9600  | rfConnect | rfV32)
  1526. X
  1527. XDCE_RESULT DCE_results[] =
  1528. X{
  1529. X    { "OK",                        rOk,            },
  1530. X    { "NO CARRIER",                rNoCarrier,        },
  1531. X    { "ERROR",                    rError            },
  1532. X    { "NO DIALTONE",            rNoDialTone,    },
  1533. X    { "BUSY",                    rBusy            },
  1534. X    { "NO ANSWER",                rNoAnswer        },
  1535. X    { "RRING",                    rRring            },
  1536. X    { "CONNECT 300/REL",        rConnect300R    },
  1537. X    { "CONNECT 1200/REL",        rConnect1200R    },
  1538. X    { "CONNECT 2400/REL",        rConnect2400R    },
  1539. X    { "CONNECT 300",            rConnect300        },
  1540. X    { "CONNECT 1200",            rConnect1200    },
  1541. X    { "CONNECT 2400",            rConnect2400    },
  1542. X    { "CONNECT 9600",            rConnect9600    },
  1543. X    { "CONNECT FAST/KERM",        rConnectFASTK    },
  1544. X    { "CONNECT FAST/XMDM",        rConnectFASTX    },
  1545. X    { "CONNECT FAST/UUCP",        rConnectFASTU    },
  1546. X    { "CONNECT FAST",            rConnectFAST    },
  1547. X    { (char *)0,                -1                }        /* end table */
  1548. X};
  1549. X
  1550. X#include "tbit.sync.h"
  1551. X
  1552. X/*+-------------------------------------------------------------------------
  1553. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  1554. X
  1555. X  DCE dependent function must validate baud rates supported by DCE
  1556. X  returns baud rate in struct termio c_cflag fashion
  1557. X  or terminates program with error
  1558. X--------------------------------------------------------------------------*/
  1559. Xint
  1560. XDCE_baud_to_CBAUD(baud)
  1561. Xunsigned int baud;
  1562. X{
  1563. X    switch(baud)
  1564. X    {
  1565. X        case 110:  return(B110);
  1566. X        case 300:  return(B300);
  1567. X        case 1200: return(B1200);
  1568. X        case 2400: return(B2400);
  1569. X        case 9600: return(B9600);
  1570. X
  1571. X#if defined(B19200)
  1572. X        case 19200: return(B19200);
  1573. X#else
  1574. X#ifdef EXTA
  1575. X        case 19200: return(EXTA);
  1576. X#endif
  1577. X#endif
  1578. X
  1579. X#if defined(B38400)
  1580. X        case 38400: return(B38400);
  1581. X#else
  1582. X#ifdef EXTB
  1583. X        case 38400: return(EXTB);
  1584. X#endif
  1585. X#endif
  1586. X
  1587. X    }
  1588. X    myexit(RC_FAIL | RCE_SPEED);
  1589. X#if defined(OPTIMIZE) || defined(__OPTIMIZE__)    /* don't complain */
  1590. X    return(0);    /* keep gcc from complaining about no rtn at end */
  1591. X#endif
  1592. X}    /* end of DCE_baud_to_CBAUD */
  1593. X
  1594. X/*+-------------------------------------------------------------------------
  1595. X    init_T2500() - init T2500 from scratch, assuming nothing
  1596. X
  1597. X    reset to factory defaults, then set
  1598. X    E0          no local echo in command mode
  1599. X    F1          no local echo in data transfer mode
  1600. X    M0          speaker off
  1601. X    Q4          generate reult codes, but not RING
  1602. X    V1          verbal result codes
  1603. X    X3          extended result codes
  1604. X    S0=1        answer on first ring
  1605. X    S2=255        escape to unusual value
  1606. X    S11=50      50 msec DTMF timing
  1607. X    S45=1       enable remote access
  1608. X    S48=1       all 8 bits are significant
  1609. X    S50=0       use automatic connect speed determination
  1610. X    S51=252     set serial port baud rate automatically (no typeahead)
  1611. X    S52=4       DTR low: drop connection and go into command mode
  1612. X    S54=3       pass BREAK signal to remote modem
  1613. X    S55=0       respond to command escape sequence
  1614. X    S58=2       DTE uses CTS/RTS flow control.
  1615. X    S64=1       ignore characters sent by DTE while answering
  1616. X    S66=0       don't lock interface speed, just go with the flow.
  1617. X    S68=255     DCE uses whatever flow control DTE uses
  1618. X    S92=1       PEP tones at the end of answer sequence
  1619. X    S95=0       no MNP
  1620. X    S110=255    use data compression when the remote modem requests it.
  1621. X    S111=255    accept any protocol
  1622. X    S131=1      DCD follows carrier
  1623. X
  1624. XThe nvram is set to factory + E0 Q0 S52=4 S131=1 S51=252 
  1625. X--------------------------------------------------------------------------*/
  1626. Xvoid
  1627. Xinit_T2500()
  1628. X{
  1629. Xregister itmp;
  1630. Xint maxretry = 4;
  1631. Xchar *init0="AT&F E0 Q0 S52=4 S131=1 S51=252 &w F1 M0 Q4 V1 X3\r";
  1632. Xchar *init1="ATS0=1 S2=255 S11=50 S45=1 S48=1 S50=0 S54=3\r";
  1633. Xchar *init2="ATS55=0 S58=2 S64=1 S66=0 S68=255 S92=1 S95=0 S110=255 S111=255\r";
  1634. X
  1635. X    DEBUG(1,"--> initializing %s on ",DCE_name);
  1636. X    DEBUG(1,"%s\n",dce_name);
  1637. X
  1638. X    lflash_DTR();
  1639. X    sync_Telebit();
  1640. X
  1641. X    /*
  1642. X     * set to factory default (bless them for this command)
  1643. X     * and a few initial beachhead values
  1644. X     */
  1645. X    for(itmp = 0; itmp < maxretry; itmp++)
  1646. X    {
  1647. X        lwrite(init0);
  1648. X        if(lread(5) == rOk)
  1649. X            break;
  1650. X    }
  1651. X    if(itmp == maxretry)
  1652. X    {
  1653. X        DEBUG(1,"INIT FAILED (init0)\n",0);
  1654. X        myexit(RC_FAIL | RCE_TIMOUT);
  1655. X    }
  1656. X
  1657. X    /*
  1658. X     * send initialization string 1
  1659. X     */
  1660. X    for(itmp = 0; itmp < maxretry; itmp++)
  1661. X    {
  1662. X        lwrite(init1);
  1663. X        if(lread(5) == rOk)
  1664. X            break;
  1665. X    }
  1666. X    if(itmp == maxretry)
  1667. X    {
  1668. X        DEBUG(1,"INIT FAILED (init1)\n",0);
  1669. X        myexit(RC_FAIL | RCE_TIMOUT);
  1670. X    }
  1671. X
  1672. X    /*
  1673. X     * send initialization string 2
  1674. X     */
  1675. X    for(itmp = 0; itmp < maxretry; itmp++)
  1676. X    {
  1677. X        lwrite(init2);
  1678. X        if(lread(5) == rOk)
  1679. X            break;
  1680. X    }
  1681. X    if(itmp == maxretry)
  1682. X    {
  1683. X        DEBUG(1,"INIT FAILED (init2)\n",0);
  1684. X        myexit(RC_FAIL | RCE_TIMOUT);
  1685. X    }
  1686. X
  1687. X}    /* end of init_T2500 */
  1688. X
  1689. X/*+-------------------------------------------------------------------------
  1690. X    DCE_hangup() - issue hangup command to DCE
  1691. X
  1692. XThis function should do whatever is necessary to ensure
  1693. X1) any active connection is terminated
  1694. X2) the DCE is ready to receive an incoming call if DTR is asserted
  1695. X3) the DCE will not accept an incoming call if DTR is false
  1696. X
  1697. XThe function should return when done.
  1698. X
  1699. XAny necessary switch setting or other configuration necessary for this
  1700. Xfunction to succeed should be documented at the top of the module.
  1701. X--------------------------------------------------------------------------*/
  1702. Xvoid
  1703. XDCE_hangup()
  1704. X{
  1705. X    DEBUG(4,"--> hanging up %s\n",dce_name);
  1706. X    init_T2500();
  1707. X
  1708. X}    /* end of DCE_hangup */
  1709. X
  1710. X/*+-------------------------------------------------------------------------
  1711. X    DCE_dial(telno_str) - dial a remote DCE
  1712. X
  1713. XThis function should connect to the remote DCE and use any success
  1714. Xindication to modify the tty baud rate if necessary before returning.
  1715. X
  1716. XUpon successful connection, return 0.
  1717. X
  1718. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  1719. XRCE_XXX value from dialer.h.
  1720. X
  1721. Xlwrite() is used to write to the DCE.
  1722. X
  1723. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  1724. Xfrom calling lread() will result automatically in the proper error
  1725. Xtermination of the program.  Read timeouts from calling lread_ignore()
  1726. Xreturn -1; you handle the execption here.
  1727. X
  1728. XAny necessary coding of phone numbers, switch settings or other
  1729. Xconfiguration necessary for this function to succeed should be
  1730. Xdocumented at the top of the module.
  1731. X
  1732. XT2500-specific comments:
  1733. X S0=0        dont allow connect while dialing
  1734. X S54=3       pass BREAK signal to remote modem
  1735. X S64=0       abort dialing if characters sent by DTE
  1736. X S66=1       lock the interface speed
  1737. X S110=0      disable data compression unless requested otherwise
  1738. X--------------------------------------------------------------------------*/
  1739. Xint
  1740. XDCE_dial(telno_str)
  1741. Xchar *telno_str;
  1742. X{
  1743. Xchar cmd[128];
  1744. Xchar phone[50];
  1745. Xint s111_set = 0;
  1746. Xint timeout;
  1747. Xint result;
  1748. Xint rrings = 0;
  1749. Xlong then;
  1750. Xlong now;
  1751. Xchar *cptr;
  1752. Xchar *dialout_default = "ATS0=0S7=40S54=3S64=0S66=1S110=0\r";
  1753. X#define MDVALID     "0123456789CcEeFfKkMmNnPpRrSsUuWwXxVv*#,!/()-"
  1754. X#ifdef WHT
  1755. X#define RRING_MAX 3
  1756. X#else
  1757. X#define RRING_MAX 6
  1758. X#endif
  1759. X
  1760. X/* preliminary setup */
  1761. X    translate("=,-,",telno_str);
  1762. X    if(strspn(telno_str,MDVALID) != strlen(telno_str))
  1763. X    {
  1764. X        DEBUG(1,"phone number has invalid characters\n",0);
  1765. X        return(RC_FAIL | RCE_PHNO);
  1766. X    }
  1767. X    if(decode_phone_number(telno_str,phone,sizeof(phone)))
  1768. X    {
  1769. X        DEBUG(1,"phone number too long\n",0);
  1770. X        return(RC_FAIL | RCE_PHNO);
  1771. X    }
  1772. X
  1773. X/* walk through dialer codes, doing custom setup */
  1774. X    strcpy(cmd,"AT");
  1775. X    cptr = cmd + strlen(cmd);
  1776. X    if(dialer_codes['C' - 'A'])
  1777. X    {
  1778. X        DEBUG(5,"COMPRESSION requested\n",0);
  1779. X        strcat(cmd,"S110=1");
  1780. X    }
  1781. X    if(dialer_codes['E' - 'A'])
  1782. X    {
  1783. X        DEBUG(5,"ECHO SUPPRESSION requested\n",0);
  1784. X        strcat(cmd,"S121=1");
  1785. X    }
  1786. X    if(dialer_codes['F' - 'A'])
  1787. X    {
  1788. X        DEBUG(5,"XON/XOFF FLOW CONTROL requested\n",0);
  1789. X        strcat(cmd,"S58=3");
  1790. X    }
  1791. X    if(dialer_codes['K' - 'A'])
  1792. X    {
  1793. X        DEBUG(5,"KERMIT requested\n",0);
  1794. X        strcat(cmd,"S111=10");
  1795. X        s111_set++;
  1796. X    }
  1797. X    if(dialer_codes['X' - 'A'])
  1798. X    {
  1799. X        DEBUG(5,"XMODEM requested\n",0);
  1800. X        strcat(cmd,"S111=20");
  1801. X        s111_set++;
  1802. SHAR_EOF
  1803. true || echo 'restore of gendial/dceT2500.c failed'
  1804. fi
  1805. echo 'End of ecu320 part 28'
  1806. echo 'File gendial/dceT2500.c is continued in part 29'
  1807. echo 29 > _shar_seq_.tmp
  1808. exit 0
  1809.  
  1810. exit 0 # Just in case...
  1811.