📄 gatestate.c
字号:
if (gc_DropCall(Session[channel].pstnParams.currentCRN, GC_NORMAL_CLEARING, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to PSTN on channel %d\n", channel));
}
if (gc_DropCall(Session[channel].ipParams.glareCRN, GC_CALL_REJECTED, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel );
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(glareCRN) to IP on channel %d\n", channel));
}
Session[channel].NumOfDropExpected = 2;
chanInfoIP[channel].callsRejected++;
gateUpdate(&(Session[channel]),GATE_DROP);
break;
case GCEV_ACCEPT:
case GCEV_PROCEEDING:
break;
/* Got Connected from ip, send get call info to ip and answer call to pstn */
case GCEV_CONNECTED:
chanInfoIP[channel].callsConnected++;
if (gc_util_insert_parm_val(&gcParmBlk,IPSET_CALLINFO, IPPARM_DISPLAY,
sizeof(int),1) < 0){
printGCError("gc_util_insert_parm_val",channel,Session[channel].LogFile,_logLevel);
}
/* send a gc_Extension message instead of GatCallInfo */
if (gc_Extension(GCTGT_GCLIB_CRN,
Session[channel].ipParams.currentCRN,
IPEXTID_GETINFO,
gcParmBlk,NULL,EV_ASYNC)<0){
printGCError("gc_Extention",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send a gc_Extension message instead of GetCallInfo to IP on channel %d\n", channel));
}
gc_util_delete_parm_blk(gcParmBlk);
/* Set the timeslot */
tsArray[0] = Session[channel].pstnParams.TxTSlot;
/* Set SC structure to point to timeslot */
tsInfo.sc_tsarrayp = tsArray;
tsInfo.sc_numts = 1;
/* Listen to pstn */
if(gc_Listen(Session[channel].ipParams.linedev,
&tsInfo,EV_SYNC) == -1) {
gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError in gc_Listen on channel %d\n",channel));
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Make IP listen to PSTN on channel %d\n", channel));
}
/* Listen to ip */
rBool = pstnListen(channel,Session[channel].ipParams.TxTSlot);
if(rBool != FUNCSUCCESS) {
gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"PSTN can't listen to IP.\n"));
return(FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Make PSTN listen to IP on channel %d\n", channel));
}
Session[channel].pstnIsListen = 1;
/* Send Answer call to PSTN */
if (gc_AnswerCall(Session[channel].pstnParams.currentCRN, 0, EV_ASYNC)<0) {
printGCError("gc_AnswerCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Sending Answer call to PSTN on channel %d\n", channel));
}
gateUpdate(&(Session[channel]),IP_CONNECTED);
break;
case GCEV_DISCONNECTED:
case GCEV_TASKFAIL:
if (gc_DropCall(Session[channel].pstnParams.currentCRN, GC_NORMAL_CLEARING, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to PSTN on channel %d\n", channel));
}
if (gc_DropCall(Session[channel].ipParams.currentCRN, GC_NORMAL_CLEARING, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to IP on channel %d\n", channel));
}
Session[channel].NumOfDropExpected = 2;
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Drop call on channel %d",channel));
switch (compKey){
case IP:
chanInfoIP[channel].callsFailed++;
break;
case PSTN:
chanInfoPSTN[channel].callsFailed++;
break;
}
gateUpdate(&(Session[channel]),GATE_DROP);
break;
default:
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in gatePSTNOffered from %s\n",
gateEventStr(event),event,channel,gateKeyStr(compKey)));
break;
} /* end switch(event) */
return (FUNCSUCCESS);
} /* End of Function gatePSTNOffered */
/*****FUNCTION***************************************************
* NAME : gateIPConnected
* DESCRIPTION : The function waits for connected or answered from
* PSTN after IP connected.
*
* INPUT : unsigned int channel - channel which got the event
* COMP_KEY compKey - name of the component
* that got the event
* long event - the recieved event
* void *pEvtData - the data recieved
* OUTPUT : None
* RETURNS : Success or fail
* CAUTIONS : None.
****************************************************************/
unsigned short gateIPConnected(unsigned int channel, COMP_KEY compKey, long event,void * EvtData)
{
int rBool;
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"In IP_CONNECTED State on channel %d\n\t got event %s (0x%x) from %s\n",
channel,gateEventStr(event), event, gateKeyStr(compKey)));
/* Switch on event */
switch(event) {
case GCEV_ACCEPT:
break;
/* Got call information */
case GCEV_EXTENSION:
break;
case GCEV_ALERTING:
break;
case GCEV_PROCEEDING:
break;
/* Got offered from pstn */
case GCEV_OFFERED :
case GCEV_DETECTED:
chanInfoPSTN[channel].callsOffered++;
Session[channel].pstnParams.glareCRN = Session[channel].pstnParams.nextCRN;
Session[channel].pstnParams.nextCRN = 0;
if (gc_DropCall(Session[channel].pstnParams.glareCRN, GC_NORMAL_CLEARING, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(glareCRN) to PSTN on channel %d\n", channel));
}
if (gc_DropCall(Session[channel].ipParams.currentCRN, GC_NORMAL_CLEARING, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to IP on channel %d\n", channel));
}
if (gc_DropCall(Session[channel].pstnParams.currentCRN, GC_CALL_REJECTED, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel );
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to PSTN on channel %d\n", channel));
}
Session[channel].NumOfDropExpected = 3;
chanInfoPSTN[channel].callsRejected++;
gateUpdate(&(Session[channel]),GATE_DROP);
break;
case GCEV_CONNECTED:
chanInfoPSTN[channel].callsConnected++;
/* Listen to ip */
rBool = pstnListen(channel,Session[channel].ipParams.TxTSlot);
if(rBool != FUNCSUCCESS) {
gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"PSTN can't listen to IP.\n"));
return(FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Make PSTN listen to IP on channel %d\n", channel));
}
gateUpdate(&(Session[channel]),GATE_CONNECTED);
break;
case GCEV_ANSWERED:
chanInfoPSTN[channel].callsConnected++;
gateUpdate(&(Session[channel]),GATE_CONNECTED);
break;
/* A drop from the IP/PSTN or some error */
case GCEV_DISCONNECTED:
case GCEV_TASKFAIL:
case GCEV_CALLSTATUS:
/* UnListen to pstn */
if (gc_UnListen(Session[channel].ipParams.linedev, EV_SYNC) == -1) {
gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError in gc_UnListen on channel %d\n",channel));
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Make PSTN Unlisten to IP on channel %d\n", channel));
}
if (gc_DropCall(Session[channel].pstnParams.currentCRN, GC_CHANNEL_UNACCEPTABLE, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to PSTN on channel %d\n", channel));
}
if (gc_DropCall(Session[channel].ipParams.currentCRN, GC_CHANNEL_UNACCEPTABLE, EV_ASYNC)<0){
printGCError("gc_DropCall",channel,Session[channel].LogFile,_logLevel);
return (FUNCFAIL);
}else{
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Send Drop Call(currentCRN) to IP on channel %d\n", channel));
}
Session[channel].NumOfDropExpected = 2;
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"Drop call on channel %d",channel));
switch (compKey){
case IP:
chanInfoIP[channel].callsFailed++;
break;
case PSTN:
chanInfoPSTN[channel].callsFailed++;
break;
}
gateUpdate(&(Session[channel]),GATE_DROP);
break;
default:
gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in IP_CONNECTED from %s\n",
gateEventStr(event),event,channel,gateKeyStr(compKey)));
break;
} /* end switch(event) */
return (FUNCSUCCESS);
} /* End of Function gateIPConnected */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -