1: #ifndef lint
   2: static char sccsid[] = "@(#)vmacs.c	4.3 (Berkeley) 10/10/85";
   3: #endif
   4: 
   5: #include "../condevs.h"
   6: #ifdef  VMACS
   7: /*
   8:  * Racal-Vadic 'RV811' MACS system with 831 adaptor.
   9:  *
  10:  * A typical 300 baud L-devices entry is
  11:  *	ACU /dev/tty10 /dev/tty11,48,1200 300 vmacs
  12:  * where tty10 is the communication line (D_Line),
  13:  * tty11 is the dialer line (D_calldev),
  14:  * the '4' is the dialer address + modem type (viz. dialer 0, Bell 103),
  15:  * and the '8' is the communication port
  16:  * (Note: Based on RVMACS version for 820 dialer.  This version
  17:  *  developed by Doug Kingston @ BRL, 13 December 83.)
  18:  */
  19: 
  20: #define SOH 01  /* Abort */
  21: #define STX 02  /* Access Adaptor */
  22: #define ETX 03  /* Transfer to Dialer */
  23: #define SI  017 /* Buffer Empty (end of phone number) */
  24: 
  25: vmacsopn(ph, flds, dev)
  26: char *ph, *flds[];
  27: struct Devices *dev;
  28: {
  29:     register int va, i, child;
  30:     register char *p;
  31:     char c, acu[20], com[20];
  32:     char    modem, dialer;
  33:     int dialspeed;
  34:     char c_STX = STX;
  35:     char c_ETX = ETX;
  36:     char c_SI = SI;
  37:     char c_SOH = SOH;
  38: 
  39:     /* create child to open comm line */
  40:     child = -1;
  41:     sprintf(com, "/dev/%s", dev->D_line);
  42:     if ((child = fork()) == 0) {
  43:         signal(SIGINT, SIG_DFL);
  44:         open(com, 0);
  45:         DEBUG(5, "%s Opened.", com);
  46:         sleep(5);
  47:         exit(1);
  48:     }
  49: 
  50:     if ((p = index(dev->D_calldev, ',')) == NULL) {
  51:         DEBUG(2, "No dialer/modem specification\n", 0);
  52:         goto failret;
  53:     }
  54:     *p++ = '\0';
  55:     if (*p < '0' || *p > '7') {
  56:         logent(p, "Bad dialer address/modem type");
  57:         goto failret;
  58:     }
  59:     dialer = *p++;
  60:     if (*p < '0' || *p > '>') {
  61:         logent(p, "Bad modem address");
  62:         goto failret;
  63:     }
  64:     modem = *p++;
  65:     if (*p++ == ',')
  66:         dialspeed = atoi (p);
  67:     else
  68:         dialspeed = dev->D_speed;
  69:     if (setjmp(Sjbuf)) {
  70:         logent("vmacsopn", "TIMEOUT");
  71:         i = CF_DIAL;
  72:         goto ret;
  73:     }
  74:     DEBUG(4, "STARTING CALL\n", 0);
  75:     sprintf(acu, "/dev/%s", dev->D_calldev);
  76:     getnextfd();
  77:     signal(SIGALRM, alarmtr);
  78:     alarm(60);
  79:     if ((va = open(acu, 2)) < 0) {
  80:         logent(acu, "CAN'T OPEN");
  81:         i = CF_NODEV;
  82:         goto ret;
  83:     }
  84:     DEBUG(5, "ACU %s opened.\n", acu);
  85:     next_fd = -1;
  86:     fixline(va, dialspeed);
  87: 
  88:     write(va, &c_SOH, 1);       /* abort, reset the dialer */
  89:     do {
  90:         if (read (va, &c, 1) != 1) {
  91:             logent ("MACS initialization", _FAILED);
  92:             goto failret;
  93:         }
  94:     } while ((c&0177) != 'B');
  95:     DEBUG(5, "ACU initialized\n", 0);
  96: 
  97:     write(va, &c_STX, 1);       /* start text, access adaptor */
  98:     write(va, &dialer, 1);      /* send dialer address digit */
  99:     write(va, &modem, 1);       /* send modem address digit */
 100:     for (p=ph; *p; p++) {
 101:         if (*p == '=' || (*p >= '0' && *p <= '9'))
 102:             write(va, p, 1);
 103:     }
 104:     write(va, &c_SI, 1);        /* send buffer empty */
 105:     write(va, &c_ETX, 1);       /* end of text, initiate call */
 106: 
 107:     if (read(va, &c, 1) != 1) {
 108:         logent("ACU READ", _FAILED);
 109:         goto failret;
 110:     }
 111:     switch(c) {
 112:     case 'A':
 113:         /* Fine! */
 114:         DEBUG(5, "Call connected\n", 0);
 115:         break;
 116:     case 'B':
 117:         DEBUG(2, "Dialer Timeout or Abort\n", 0);
 118:         goto failret;
 119:     case 'D':
 120:         DEBUG(2, "Dialer format error\n", 0);
 121:         goto failret;
 122:     case 'E':
 123:         DEBUG(2, "Dialer parity error\n", 0);
 124:         goto failret;
 125:     case 'F':
 126:         DEBUG(2, "Phone number too long\n", 0);
 127:         goto failret;
 128:     case 'G':
 129:         DEBUG(2, "Busy signal\n", 0);
 130:         goto failret;
 131:     default:
 132:         DEBUG(2, "Unknown MACS return code '%c'\n", i);
 133:         goto failret;
 134:     }
 135:     /*
 136: 	 * open line - will return on carrier
 137: 	 */
 138:     if ((i = open(com, 2)) < 0) {
 139:         if (errno == EIO)
 140:             logent("carrier", "LOST");
 141:         else
 142:             logent("dialup open", _FAILED);
 143:         goto failret;
 144:     }
 145:     fixline(i, dev->D_speed);
 146:     goto ret;
 147: failret:
 148:     i = CF_DIAL;
 149: ret:
 150:     alarm(0);
 151:     if (child > 1)
 152:         kill(child, SIGKILL);
 153:     close(va);
 154:     sleep(2);
 155:     return i;
 156: }
 157: 
 158: vmacscls(fd)
 159: register int fd;
 160: {
 161:     char c_SOH = SOH;
 162: 
 163:     DEBUG(2, "MACS close %d\n", fd);
 164:     write(fd, &c_SOH, 1);
 165: /*	ioctl(fd, TIOCCDTR, NULL);*/
 166:     close(fd);
 167: }
 168: #endif VMACS

Defined functions

vmacscls defined in line 158; never used
vmacsopn defined in line 25; never used

Defined variables

sccsid defined in line 2; never used

Defined macros

ETX defined in line 22; used 1 times
  • in line 35
SI defined in line 23; used 1 times
  • in line 36
SOH defined in line 20; used 2 times
STX defined in line 21; used 1 times
  • in line 34
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1272
Valid CSS Valid XHTML 1.0 Strict