static void unidialer_disconnect(void) { int okay, retries; acu_flush (); /* flush any clutter */ unidialer_tty_clocal (TRUE); /* first hang up the modem*/ ioctl (FD, TIOCCDTR, 0); acu_nap (250); ioctl (FD, TIOCSDTR, 0); /* * If AT&D2, then dropping DTR *should* just hangup the modem. But * some modems reset anyway; also, the modem may be programmed to reset * anyway with AT&D3. Play it safe and wait for the full reset time before * proceeding. */ acu_nap (reset_delay); if (!unidialer_waitfor_modem_ready (reset_delay)) { #ifdef DEBUG printf ("unidialer_disconnect: warning CTS low.\r\n"); #endif } /* * If not strapped for DTR control, try to get command mode. */ for (retries = okay = 0; retries < MAXRETRY && !okay; retries++) { int timeout_value; /* flush any clutter */ if (!acu_flush ()) { #ifdef DEBUG printf ("unidialer_disconnect: warning flush failed.\r\n"); #endif } timeout_value = escape_guard_time; timeout_value += (timeout_value * retries / MAXRETRY); acu_nap (timeout_value); acu_flush (); /* flush any clutter */ unidialer_modem_cmd (FD, escape_sequence); acu_nap (timeout_value); unidialer_modem_cmd (FD, hangup_command); okay = unidialer_get_okay (reset_delay); } if (!okay) { logent(value(HOST), "", modem_name, "can't hang up modem"); if (boolean(value(VERBOSE))) printf("hang up failed\n"); } (void) acu_flush (); close (FD); }
void multitech_write (int fd, const char *cp, int n) { acu_flush (); acu_nap (intercharacter_delay); for ( ; n-- ; cp++) { write (fd, cp, 1); acu_flush (); acu_nap (intercharacter_delay); } }
/* * This convoluted piece of code attempts to get * the unidialer in sync. */ static int unidialersync(void) { int already = 0; int len; char buf[40]; while (already++ < MAXRETRY) { acu_nap (intercommand_delay); acu_flush (); /* flush any clutter */ unidialer_write_str (FD, reset_command); /* reset modem */ bzero(buf, sizeof(buf)); acu_nap (reset_delay); ioctl (FD, FIONREAD, &len); if (len) { len = read(FD, buf, sizeof(buf)); #ifdef DEBUG buf [len] = '\0'; printf("unidialersync (%s): (\"%s\")\n\r", modem_name, buf); #endif if (index(buf, '0') || (index(buf, 'O') && index(buf, 'K'))) return(1); } /* * If not strapped for DTR control, * try to get command mode. */ acu_nap (escape_guard_time); unidialer_write_str (FD, escape_sequence); acu_nap (escape_guard_time); unidialer_write_str (FD, hangup_command); /* * Toggle DTR to force anyone off that might have left * the modem connected. */ acu_nap (escape_guard_time); ioctl (FD, TIOCCDTR, 0); acu_nap (1000); ioctl (FD, TIOCSDTR, 0); } acu_nap (intercommand_delay); unidialer_write_str (FD, reset_command); return (0); }
static int unidialer_dialer(char *num, char *acu) { char *cp; char dial_string [80]; #if ACULOG char line [80]; #endif #ifdef DEBUG dumpmodemparms (modem_name); #endif if (lock_baud) { int i; if ((i = speed(number(value(BAUDRATE)))) == 0) return 0; ttysetup (i); } if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); acu_hupcl (); /* * Get in synch. */ if (!unidialersync()) { badsynch: printf("tip: can't synchronize with %s\n", modem_name); #if ACULOG logent(value(HOST), num, modem_name, "can't synch up"); #endif return (0); } unidialer_modem_cmd (FD, echo_off_command); /* turn off echoing */ sleep(1); #ifdef DEBUG if (boolean(value(VERBOSE))) unidialer_verbose_read(); #endif acu_flush (); /* flush any clutter */ unidialer_modem_cmd (FD, init_string); if (!unidialer_get_okay (reset_delay)) goto badsynch; fflush (stdout); for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; (void) sprintf (dial_string, dial_command, num); unidialer_modem_cmd (FD, dial_string); connected = unidialer_connect (); if (connected && hw_flow_control) { acu_hw_flow_control (hw_flow_control); } #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, modem_name, line); } #endif if (timeout) unidialer_disconnect (); return (connected); }
int multitech_dialer (char *num, char *acu) { char *cp; #if ACULOG char line [80]; #endif if (lock_baud) { int i; if ((i = speed(number(value(BAUDRATE)))) == 0) return 0; ttysetup (i); } if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); acu_hupcl (); /* * Get in synch. */ if (!multitechsync()) { badsynch: printf("can't synchronize with multitech\n"); #if ACULOG logent(value(HOST), num, "multitech", "can't synch up"); #endif return (0); } acu_nap (intercommand_delay); multitech_write_str (FD, echo_off_command); /* turn off echoing */ sleep(1); #ifdef DEBUG if (boolean(value(VERBOSE))) multitech_verbose_read(); #endif acu_flush (); acu_nap (intercommand_delay); multitech_write_str (FD, init_string); if (!multitech_swallow ("\r\nOK\r\n")) goto badsynch; fflush (stdout); acu_nap (intercommand_delay); multitech_write_str (FD, dial_command); for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; multitech_write_str (FD, num); multitech_write_str (FD, "\r"); connected = multitech_connect(); #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "multitech", line); } #endif if (timeout) multitech_disconnect (); return (connected); }
int ven_dialer(char *num, char *acu) { char *cp; int connected = 0; char *msg, line[80]; /* * Get in synch with a couple of carriage returns */ if (!vensync(FD)) { printf("can't synchronize with ventel\n"); #if ACULOG logent(value(HOST), num, "ventel", "can't synch up"); #endif return (0); } if (boolean(value(VERBOSE))) printf("\ndialing..."); fflush(stdout); acu_hupcl (); echo("#k$\r$\n$D$I$A$L$:$ "); for (cp = num; *cp; cp++) { delay(1, 10); write(FD, cp, 1); } delay(1, 10); write(FD, "\r", 1); gobble('\n', line); if (gobble('\n', line)) connected = gobble('!', line); acu_flush (); #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "ventel", line); } #endif if (timeout) ven_disconnect(); /* insurance */ if (connected || timeout || !boolean(value(VERBOSE))) return (connected); /* call failed, parse response for user */ cp = index(line, '\r'); if (cp) *cp = '\0'; for (cp = line; (cp = index(cp, ' ')); cp++) if (cp[1] == ' ') break; if (cp) { while (*cp == ' ') cp++; msg = cp; while (*cp) { if (isupper(*cp)) *cp = tolower(*cp); cp++; } printf("%s...", msg); } return (connected); }