⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckudia.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
  the modem too.  Unfortunately, many versions of UNIX only allow RTS/CTS  to be set outside of Kermit (e.g. by selecting a special device name).  In that case, Kermit doesn't know that it should set RTS/CTS on the modem,  in which case the user can add the appropriate Telebit command with  SET DIAL DIAL-COMMAND.*/	    if (flow == FLO_RTSC) {	/* RTS/CTS active in Kermit */		sprintf(tbcmdbuf,			"ATS7=%d S48=%d S50=0 S58=2 S68=255\015",			mdmwait, parity ? 0 : 1);	    } else	      sprintf(tbcmdbuf,		/* Otherwise, don't touch modem's */		      "ATS7=%d S48=%d S50=0 S68=255\015", /* flow control */		      mdmwait, parity ? 0 : 1);		  /* setting. */	    s = tbcmdbuf;	    debug(F110,"ckdial Telebit init step 2",s,0);	    for (tries = 4; tries > 0; tries--) {		ttslow(s,pmdminf->wake_rate);		mdmstat = getok(5,1);		if (mdmstat) break;		msleep(500);		ttflui();	    }	    if (mdmstat < 1) {		n1 = F_minit;		longjmp( sjbuf, F_minit ); /* Failed. */	    }/*  Model-dependent items, but constant per model.*/	    switch(tbmodel) {	      case TB_BLAZ:	      case TB_PLUS: 		/* TrailBlazer-Plus */	      case TB_1000:		/* T1000 */	      case TB_2000:		/* T2000 */	      case TB_2500:		/* T2500 */#ifdef COMMENT/* Code from edit 183 told modem to follow RS-232 wrt CD and DTR */		/* DTR, CD, follow RS-232, pass BREAK */		sprintf(tbcmdbuf,"ATS52=1 S53=4 S54=3\015");#else/* But everybody agreed we should not touch modem's CD and DTR settings. */		/* Just pass BREAK */		sprintf(tbcmdbuf,"ATS54=3\015");#endif /* COMMENT */		break;	      case TB_1600:		/* T1600 */	      case TB_3000:		/* T3000 */	      case TB_WBLA:		/* WorldBlazer */	      case TB_QBLA:		/* Qblazer */#ifdef COMMENT/* Code from edit 183 */		/* Follow RS-232, No CONNECT suffix, pass BREAK */		sprintf(tbcmdbuf,"AT&C1&D2&Q0 S59=0 S61=0 S63=0\015");#else/* Everybody agrees we should not touch modem's CD and DTR settings. *//* Also no more &Q0, no more S59=0 (doesn't matter, so don't touch). *//* So this section now deals only with treatment of BREAK. *//* Here we also raise the result code from X1 to X2, which allows *//* the T1600, T3000, and WB to supply NO DIALTONE, BUSY, RRING, and DIALING. *//* X2 means something else on the other models. */		/* Transmit BREAK in sequence, raise result code. */		sprintf(tbcmdbuf,"ATX2 S61=0 S63=0\015");#endif /* COMMENT */		break;	      default:			/* Others, do nothing */		tbcmdbuf[0] = NUL;		break;	    }	    s = tbcmdbuf;	    if (*s) {		debug(F110,"ckdial Telebit init step 3",s,0);		for (tries = 4; tries > 0; tries--) {		    ttslow(s,pmdminf->wake_rate);		    mdmstat = getok(5,1);		    if (mdmstat) break;		    msleep(500);		    ttflui();		}		if (mdmstat < 1) {		    n1 = F_minit;		    longjmp( sjbuf, F_minit ); /* Failed. */		}	    } else debug(F100,"ckdial Telebit init step 3 skipped","",0);/* Error correction, MNP or V.42 */	    if (augmdmtyp & DIAL_V42) { /* User wants V.42 */		switch (tbmodel) {	/* which implies fallback to MNP. */		  case TB_PLUS:		/* BC7.00 and up firmware */		  case TB_2000:		/* now really the same as TB+ ? */		  case TB_2500:		/* LAPM+compress->MNP->direct */		    mnpstr = "S50=0 S95=2 S97=1 S98=3 S106=1";		    break;		  case TB_1600:		  case TB_3000:		  case TB_WBLA:		  case TB_QBLA:#ifdef COMMENT		    mnpstr = "S180=2 S181=0"; /* V.42, fallback = lock speed */#else/* Better not to mess with S181, let it be used however user has it set. *//* S180=2 allows fallback to MNP, S180=1 disallows fallback to MNP. */		    mnpstr = "S180=2";	/* V.42 */#endif /* COMMENT */		    break;		  default:		    if (dialdpy)		      printf("V.42 not supported by this Telebit model\n");		}	    } else {			/* Handle DIAL MNP-ENABLE setting */		switch (tbmodel) {		  case TB_BLAZ:		/* TrailBlazer */		  case TB_PLUS:		/* TrailBlazer-Plus */		  case TB_1000:		/* T1000 */		  case TB_2000:		/* T2000 */		  case TB_2500:		/* T2500 */		    mnpstr = dialmnp ? "S95=2" : "S95=0"; /* ON, OFF */		    break;		  case TB_1600:		/* T1600 */		  case TB_3000:		/* T3000 */		  case TB_WBLA:		/* WorldBlazer */		  case TB_QBLA:		/* Qblazer */		    mnpstr = dialmnp ? "S180=3" : "S180=0"; /* ON, OFF */		    /* (Leave S181 fallback method alone) */		    break;		  default:		    mnpstr = "";		}	    }/* Dialing protocol */	    dprstr = "";	/* Initialize dialing protocol string */	    p = "";		/* and message string */	    switch (augmdmtyp) {	      case n_TELEBIT:		/* Start at highest and work down */              case n_TBNV:       		p = "standard";		switch (tbmodel) {	/* First group starts with PEP */		  case TB_BLAZ:		/* TrailBlazer */		  case TB_PLUS:		/* TrailBlazer-Plus */		  case TB_1000:		/* T1000 */		  case TB_2000:		/* T2000 */		  case TB_2500:		/* T2500 */		    dprstr = "S50=0 S110=1"; /* PEP, compression allowed. */		    break;		  case TB_WBLA:		/* WorldBlazer has PEP */		    dprstr = "S50=0 S190=1 S191=7"; /* PEP, */		    break;			    /* compression allowed. */		  case TB_1600:		/* T1600 doesn't have PEP */		  case TB_3000:		/* T3000 doesn't */		  case TB_QBLA:		/* Qblazer doesn't*/		  default:		    dprstr = "S50=0";	/* No PEP available */		    break;		}		break;	      case n_TBS:		/* Telebit up to 2400 Baud */	      case n_TBSNV:		/* i.e. "Slow mode". */		p = "300/1200/2400 Baud"; /* Leave S90 alone assuming it is */		dprstr = "S50=3";	  /* already set for V.22 vs 212A */		break;	      case n_TB3:		/* Telebit V.32 */	      case n_TB3NV:		if (tbmodel == TB_3000 || tbmodel == TB_1600 ||		    tbmodel == TB_2500 || tbmodel == TB_WBLA) {		    p = "V.32";		    /* Note: we don't touch S51 (interface speed) here. */		    /* We're already talking to the modem, and the modem */		    /* SHOULD be able to make a V.32 call no matter what */		    /* its interface speed is.  (In practice, however, */		    /* that is not always true.) */		    dprstr = "S50=6";		} else if (dialdpy)		  printf("V.32 not supported by this Telebit model.\n");		break;	      case n_TBPEP:		/* Force PEP Protocol */              case n_TBPNV:		if (tbmodel != TB_1600 && /* Models that don't support PEP */		    tbmodel != TB_3000 &&		    tbmodel != TB_QBLA) {		    p = "PEP";		    if (tbmodel == TB_WBLA) /* WorldBlazer */		      dprstr = "S50=255 S190=1 S191=7";		    else if (tbmodel != TB_1000)		      dprstr = "S50=255 S110=1"; /* TrailBlazer, etc. */		    else dprstr = "S50=255"; /* T1000, no compression */		} else if (dialdpy)		  printf("PEP not supported by this Telebit model.\n");		break;	    }/* Kermit Spoof */	    if (dialksp) {		p = "Kermit Spoof";		switch (parity) {	/* S111 value depends on parity */		  case 'e': S111 = 12; break;		  case 'm': S111 = 13; break;		  case 'o': S111 = 11; break;		  case 's': S111 = 14; break;		  case 0:		  default:  S111 = 10; break;		}#ifdef COMMENT/*  This code forced the use of PEP mode if DIAL KERMIT-SPOOF was ON, which  prevented successful connection if the other modem did not support PEP.*/		if (tbmodel == TB_BLAZ || /* Must force PEP on old models */		    tbmodel == TB_PLUS ||		    tbmodel == TB_1000 ||		    tbmodel == TB_2000 ||		    tbmodel == TB_2500)		  sprintf(tbcmdbuf,"AT%s %s S50=255 S111=%d S112=%d\015",			  mnpstr,dprstr,S111,stchr);		/* PEP is not required on T1500, T1600, T3000, and WB */		/* (but MNP is, but that is user's responsibility).   */		else#endif /* COMMENT */		  if (tbmodel != TB_QBLA)		  sprintf(tbcmdbuf,"AT%s %s S111=%d S112=%d\015",			  mnpstr,dprstr,S111,stchr);		else {			/* Qblazer has no Kermit spoof */		    sprintf(tbcmdbuf,"AT%s %s\015", mnpstr,dprstr);		    p = "No Kermit Spoof";		    if (dialdpy)		      printf("Kermit Spoof not supported by Qblazer\n");		}	    } else {			/* No Kermit spoof */		p = "No Kermit Spoof";		sprintf(tbcmdbuf,"AT%s %s %s\015",			mnpstr, dprstr,			(tbmodel == TB_QBLA) ? "" : "S111=0 S112=0");	    }	    s = tbcmdbuf;	    debug(F111,"ckdial Telebit config",p,speed);	    debug(F110,"ckdial Telebit init step 4",s,0);	    if (*s) {		for (tries = 4; tries > 0; tries--) {		    ttslow(s,pmdminf->wake_rate);		    mdmstat = getok(5,1);		    if (mdmstat) break;		    msleep(500);		    ttflui();		}		debug(F101,"ckdial telebit init mdmstat","",mdmstat);		if (mdmstat < 1) {		    n1 = F_minit;		    longjmp(sjbuf, F_minit);		}	    }	}	/* Done with Telebit protocols, remove bits from modem type */	/* Except nonverbal bit */	augmdmtyp &= ~(DIAL_PEP|DIAL_V32|DIAL_V42|DIAL_SLO);	debug(F101,"ckdial Telebit augmdmtyp","",augmdmtyp);	break;    }    case n_MICROCOM:			/* Interdigit waits for tone dial */        {	    jmp_buf savejmp;	    alarm(0);	    savalrm = signal(SIGALRM,dialtime); /* Set alarm handler. */	    xcpy((char *)savejmp, (char *)sjbuf, sizeof savejmp);	    if (setjmp(sjbuf)) {	    	/* try the autobaud sequence */		xcpy((char *)sjbuf, (char *)savejmp, sizeof savejmp);		alarm(5);	        ttslow("44445", MICROCOM.wake_rate);		waitfor(MICROCOM.wake_str);	    } else {		alarm(2);		ws = dialini ? dialini : MICROCOM.wake_str;		ttslow(ws, MICROCOM.wake_rate);	    	waitfor(ws);#ifdef COMMENT/*  Kermit spoof for Microcom modems.  Untested.  This is reportedly the way to do it for QX/3296c, QX/4232hs, QX/4232bis,  and QX/9624c.  The effect on other models is unknown.*/		ws = dialksp ? "APM1\015" : "APM0\015";	/* Kermit spoof */		ttslow(ws, MICROCOM.wake_rate);	    	waitfor(ws);#endif /* COMMENT */		alarm(0);		signal(SIGALRM,savalrm); /* Set alarm handler. */		xcpy((char *)sjbuf, (char *)savejmp, sizeof savejmp);	    }	}	break;    case n_ATTDTDM:		/* DTDM requires BREAK to wake up */	ttsndb();		/* Send BREAK */	break;			/* ttsndb() defined in ckutio.c */#endif /* MINIDIAL */    default:			/* Place modem into command mode */	ws = dialini ? dialini : pmdminf->wake_str;	if (ws && (int)strlen(ws) > 0) {	    debug(F111,"ckdial default, wake string", ws, pmdminf->wake_rate);	    ttslow(ws, pmdminf->wake_rate);	} else debug(F100,"ckdial no wake_str","",0);	if (pmdminf->wake_prompt && (int)strlen(pmdminf->wake_prompt) > 0) {	    debug(F110,"ckdial default, waiting for wake_prompt",		  pmdminf->wake_prompt,0);	    savalrm = signal(SIGALRM,dialtime);	    alarm(10);	    waitfor(pmdminf->wake_prompt);	} else debug(F100,"ckdial no wake_prompt","",0);	break;    }    alarm(0);				/* Turn off alarm */    signal(SIGALRM,savalrm);		/* Restore alarm handler. */    debug(F100,"ckdial got wake prompt","",0);    msleep(500);			/* Allow settling time */#ifndef MINIDIAL/* Enable/disable MNP (Telebit already done above) */    switch (augmdmtyp) {      case n_HST:	if (dialmnp)	  ttslow("AT&K2\015",pmdminf->wake_rate);	else	  ttslow("AT&K0\015",pmdminf->wake_rate);	getok(5,1);			/* Get response */	break;     /* Add others here ... */      default:	break;    }#endif /* MINIDIAL *//* Put modem into dialing mode, if the modem requires it. */    if (pmdminf->dmode_str && *(pmdminf->dmode_str)) {	ttslow(pmdminf->dmode_str, pmdminf->dial_rate);	savalrm = signal(SIGALRM,dialtime);	alarm(10);	if (pmdminf->dmode_prompt) { /* Wait for prompt, if any expected */	    waitfor(pmdminf->dmode_prompt);	    msleep(300);	}	alarm(0);		 /* Turn off alarm on dialing prompts */	signal(SIGALRM,savalrm); /* Restore alarm */	ttflui();		 /* Clear out stuff from waking modem up */    }/* Dial the number.  First form the dialing string. */    sprintf(lbuf, dialcmd ? dialcmd : pmdminf->dial_str, telnbr);    debug(F110,"dialing",lbuf,0);    ttslow(lbuf,pmdminf->dial_rate);	/* Send the dialing string */    savalrm = signal(SIGALRM,dialtime);	/* Time to allow for connecting */    x = alarm(waitct);			/* This much time... */    debug(F101,"ckdial old alarm","",x);    debug(F101,"ckdial waitct","",waitct);#ifndef MINIDIAL    switch (augmdmtyp) {    case n_RACAL: 	   /* Acknowledge printout of dialing string */      sleep(3);      ttflui();      ttoc('\015');      break;    case n_VENTEL:      waitfor("\012\012"); /* Ignore the first two strings */      break;    default:      break;    }#endif /* MINIDIAL *//* Check for connection */    mdmstat = 0;			/* No status yet */    strcpy(lbuf,"No Connection");	/* Default reason for failure */    debug(F101,"dial awaiting response, augmdmtyp","",augmdmtyp);    while (mdmstat == 0) {	switch (augmdmtyp) {	  default:	    for (n = -1; n < LBUFL-1; ) { /* Accumulate response */		c2 = ddinc(0);		/* Read a character, blocking */		if (c2 == 0 || c2 == -1) /* Ignore NULs and errors */		  continue;		/* (Timeout will handle errors) */		else			/* Real character, keep it */		  lbuf[++n] = c2 & 0177;		dialoc(lbuf[n]);	/* Maybe echo it  */                if (augmdmtyp == n_CCITT) { /* V.25 bis dialing... *//*  This assumes that V.25bis indications are all at least 3 characters long  and are terminated by either CRLF or LFCR.*/		    if (n < 3) continue;		    if ((lbuf[n] == CR) && (lbuf[n-1] == LF)) break;		    if ((lbuf[n] == LF) && (lbuf[n-1] == CR)) break;		}#ifndef MINIDIAL		  else if (augmdmtyp == n_DIGITEL) {		    if ((lbuf[n] == CR) && (lbuf[n-1] == LF) ||			(lbuf[n] == LF) && (lbuf[n-1] == CR))		      break;		    else		      continue;		}#endif /* MINIDIAL */		  e

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -