rto, pto & eto line parameters (timeouts) - See README.COMMADPT

git-svn-id: file:///home/jj/hercules.svn/trunk@1331 956126f8-22a0-4046-8f4a-272fa8102e63
This commit is contained in:
Ivan Warren
2003-04-18 12:16:26 +00:00
parent 88ae9f934b
commit c92c494b74
3 changed files with 84 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ Only allows Point to Point connection.
Hercules device statement :
CCUU 2703 lport=port lhost=host rhost=host rport=port dial=IN|OUT|INOUT|NO
[pto=nnn|0|-1] [rto=nnn|0|-1] [eto=nnn|0|-1]
lport : the local TCP port number or service name on which the line will listen
for incoming TCP calls
@@ -33,6 +34,30 @@ rport : the remote port number or service name
This parameter is irrelevant and is ignored for DIAL=IN
for DIAL=OUT|INOUT|NO, this parameter is mandatory
rto, pto, eto : Read, Poll and Enable Timeout values in miliseconds.
specifying 0 means No Timeout (infinite wait). -1 Means immediate
timeout.
The read timeout is how long the handler will wait for an ending
character after the last character was received or the I/O initiated.
The read timeout default is 3000 Miliseconds (3 Seconds)
The poll timeout is how long the handler will wait for a polled
station to respond to a poll request.
The poll timeout default is 3000 Miliseconds (3 Seconds)
The enable timeout is how long the handler will wait for the TCP
connection to be established.
The enable timeout default is 10000 Miliseconds (10 Seconds), except
if DIAL=NO is also specified, in which case the enable timeout defaults
to 0.
Note : the ETO parameter is ignored if DIAL=NO is not specified.
for a dialed line, there is no enable timeout. If the eto
parameter is specified and DIAL is not "NO", then a warning message
is issued and the parameter is ignored.
dial=IN|OUT|INOUT|NO
Indicate call direction (if any).
This parameter also modifies the behaviour of certain CCWS

View File

@@ -23,6 +23,9 @@ static PARSER ptab[]={
{"rport","%s"},
{"rhost","%s"},
{"dial","%s"},
{"rto","%s"},
{"pto","%s"},
{"eto","%s"},
{"switched","%s"},
{NULL,NULL}
};
@@ -33,6 +36,9 @@ enum {
COMMADPT_KW_RPORT,
COMMADPT_KW_RHOST,
COMMADPT_KW_DIAL,
COMMADPT_KW_READTO,
COMMADPT_KW_POLLTO,
COMMADPT_KW_ENABLETO,
COMMADPT_KW_SWITCHED
} commadpt_kw;
@@ -475,6 +481,28 @@ static void commadpt_read(COMMADPT *ca)
}
}
}
/*-------------------------------------------------------------------*/
/* Communication Thread - Set TimeOut */
/*-------------------------------------------------------------------*/
static struct timeval *commadpt_setto(struct timeval *tv,int tmo)
{
if(tmo!=0)
{
if(tmo<0)
{
tv->tv_sec=0;
tv->tv_usec=1;
}
else
{
tv->tv_sec=tmo/1000;
tv->tv_usec=(tmo%1000)*1000;
}
return(tv);
}
return(NULL);
}
/*-------------------------------------------------------------------*/
/* Communication Thread main loop */
/*-------------------------------------------------------------------*/
@@ -680,9 +708,7 @@ static void commadpt_thread(void *vca)
signal_condition(&ca->ipc);
break;
}
tv.tv_sec=3;
tv.tv_usec=0;
seltv=&tv;
seltv=commadpt_setto(&tv,ca->rto);
FD_SET(ca->sfd,&rfd);
maxfd=maxfd<ca->sfd?ca->sfd:maxfd;
break;
@@ -733,11 +759,9 @@ static void commadpt_thread(void *vca)
}
b=commadpt_ring_pop(&ca->pollbfr);
ca->pollix=b;
/* Prepare to read - 3 secs timeout */
tv.tv_sec=3;
tv.tv_usec=0;
seltv=commadpt_setto(&tv,ca->pto);
}
if(!writecont)
if(!writecont && ca->pto!=0)
{
/* Set tv value (have been set earlier) */
seltv=&tv;
@@ -824,9 +848,7 @@ static void commadpt_thread(void *vca)
/* a tight loop */
if(ca->callissued)
{
tv.tv_sec=3;
tv.tv_usec=0;
seltv=&tv;
seltv=commadpt_setto(&tv,ca->eto);
break;
}
/* Issue a Connect out */
@@ -862,9 +884,7 @@ static void commadpt_thread(void *vca)
/* to prevent OSes from issuing a loop of ENABLES */
else
{
tv.tv_sec=3;
tv.tv_usec=0;
seltv=&tv;
seltv=commadpt_setto(&tv,ca->eto);
}
break;
default:
@@ -1235,6 +1255,7 @@ static int commadpt_init_handler (DEVBLK *dev, int argc, BYTE *argv[])
struct in_addr in_temp;
char *dialt;
char fmtbfr[64];
int etospec; /* ETO= Specified */
union {
int num;
char text[80];
@@ -1270,6 +1291,10 @@ static int commadpt_init_handler (DEVBLK *dev, int argc, BYTE *argv[])
dev->commadpt->rhost=INADDR_NONE;
dev->commadpt->dialin=0;
dev->commadpt->dialout=1;
dev->commadpt->rto=3000; /* Read Time-Out in milis */
dev->commadpt->pto=3000; /* Poll Time-out in milis */
dev->commadpt->eto=10000; /* Enable Time-out in milis */
etospec=0;
for(i=0;i<argc;i++)
{
@@ -1334,6 +1359,16 @@ static int commadpt_init_handler (DEVBLK *dev, int argc, BYTE *argv[])
errcnt++;
}
break;
case COMMADPT_KW_READTO:
dev->commadpt->rto=atoi(res.text);
break;
case COMMADPT_KW_POLLTO:
dev->commadpt->pto=atoi(res.text);
break;
case COMMADPT_KW_ENABLETO:
dev->commadpt->eto=atoi(res.text);
etospec=1;
break;
case COMMADPT_KW_SWITCHED:
case COMMADPT_KW_DIAL:
if(strcasecmp(res.text,"yes")==0 || strcmp(res.text,"1")==0 || strcasecmp(res.text,"inout")==0)
@@ -1407,6 +1442,7 @@ static int commadpt_init_handler (DEVBLK *dev, int argc, BYTE *argv[])
switch(dev->commadpt->dialin+dev->commadpt->dialout*2)
{
case 0: /* DIAL = NO */
dev->commadpt->eto=0;
if(dev->commadpt->lport==0)
{
msg015e(dev,dialt,"LPORT");
@@ -1422,6 +1458,13 @@ static int commadpt_init_handler (DEVBLK *dev, int argc, BYTE *argv[])
msg015e(dev,dialt,"RHOST");
errcnt++;
}
if(etospec)
{
snprintf(fmtbfr,sizeof(fmtbfr),"%d",dev->commadpt->eto);
msg016w017i(dev,dialt,"ETO",fmtbfr);
errcnt++;
}
dev->commadpt->eto=0;
break;
case 1: /* DIAL = IN */
case 3: /* DIAL = INOUT */

View File

@@ -24,6 +24,9 @@ typedef struct _COMMADPT
{
DEVBLK *dev; /* the devblk to which this CA is attched */
BYTE lnctl; /* Line control used */
int rto; /* Read Time-Out */
int pto; /* Poll Time-Out */
int eto; /* Enable Time-Out */
TID cthread; /* Thread used to control the socket */
BYTE curpending; /* Current pending operation */
U16 lport; /* Local listening port */