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

📄 gatepstn.c

📁 dialogic voip 测试代码
💻 C
📖 第 1 页 / 共 2 页
字号:


		   } /* end for index */

      

           break; /* end GATE_T1, GATE_E1: case  */

				 

	    default:

           printf("%s"," ***** Default telephone card not set. ***** \n");

           break;

   }  /* end switch on front end type */



   return(FUNCSUCCESS);  

   

} /* Function pstnOpenFrontEnd */		   

				   







/*****FUNCTION***************************************************

*        NAME : pstnListen

* DESCRIPTION : Listen to a given timeslot

*       INPUT : channel  

*               unsigned short timeslot 

*      OUTPUT : None

*     RETURNS : 1 - success, 0 - fail

*    CAUTIONS : None

****************************************************************/

int pstnListen(unsigned int channel, unsigned short timeslot)

{

   int         rc; 

   SC_TSINFO   tsInfo;

   unsigned long       tsArray[1];





   /* Set the timeslot */

   tsArray[0] = timeslot;



   /* Set SC structure to point to timeslot */

   tsInfo.sc_tsarrayp = tsArray;

   tsInfo.sc_numts = 1;



   gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\t   In pstnListen function on channel %d\n",channel));



   



   /* Set SC structure to point to timeslot */

   tsInfo.sc_tsarrayp = tsArray;

   tsInfo.sc_numts = 1;

   

   /* switch on front end */

   switch(frontEnd) {



     case GATE_LEGACY_ANALOG:



		 if ((rc = ag_unlisten(Session[channel].pstnParams.VoiceH)) == -1 ) {

             gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError UnListening on pstn channel %d\n",channel));

		     return(FUNCFAIL);

		 }

      

         /* Listen */

         if ( (rc = ag_listen(Session[channel].pstnParams.VoiceH,&tsInfo)) == -1) {

            gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError in ag_Listen on channel %d\n",channel));

			return FUNCFAIL;

         }

         

         break;



     case GATE_T1:

     case GATE_E1:

      

         if ( (rc = dt_listen(Session[channel].pstnParams.NetwH,&tsInfo)) == -1) {      

            gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError in dt_listen on channel %d. \n\tError message: *** %s *** \n",channel,ATDV_ERRMSGP(Session[channel].pstnParams.NetwH)));

            return FUNCFAIL;

         }

   

         break;



     default:

		 gateERROR(channel,_logLevel,Session[channel].LogFile, (Session[channel].LogFile,"\t   pstnListen was failed (Unknown Front End) on channel %d\n",channel));

         return FUNCFAIL;

         break;



   } /* end switch(frontEnd) */

   

   gateTRACE(channel,_logLevel,Session[channel].LogFile, (Session[channel].LogFile,"\t   End of pstnListen function on channel %d\n",channel));          



   return(FUNCSUCCESS);



} /* Function pstnListen */





/*****FUNCTION***************************************************

*        NAME : pstnUnListen

* DESCRIPTION : UnListen on a given channel, and relisten to default

*       INPUT : channel

*      OUTPUT : None

*     RETURNS : 1 - success, 0 -fail

*    CAUTIONS : None

****************************************************************/

int pstnUnListen(unsigned int channel)

{

   SC_TSINFO   tsInfo;

   long        tsArray;

   int rc;

  

   gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\t   In pstnUnListen function on channel %d\n",channel));



   /* Set the timeslot */

   tsInfo.sc_numts = 1;

   tsInfo.sc_tsarrayp = &tsArray;



    

   /* switch on front end */



   switch(frontEnd) {

   

   case GATE_LEGACY_ANALOG:

      

      /* UnListen */

      if ((rc = ag_unlisten(Session[channel].pstnParams.VoiceH)) == -1 ) {

         gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError UnListening on pstn channel %d\n",channel));

		   return(FUNCFAIL);

	   }

  

      /* Get voice xmit line */

      if ( (rc = dx_getxmitslot(Session[channel].pstnParams.VoiceH,&tsInfo)) == -1) {

         gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError in dx_getxmitslot on channel %d %s\n",channel,ATDV_ERRMSGP(Session[channel].pstnParams.VoiceH)));

		   return(FUNCFAIL);

	   }



      /* Listen to this again */

      if ( (rc =ag_listen(Session[channel].pstnParams.VoiceH,&tsInfo)) == -1) {



         gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError in ag_listen on channel %d\n",channel));

		   return(FUNCFAIL);

	  }



      break;

   

   case GATE_T1:

   case GATE_E1:

      

	   /* UnListen */

      if ( (rc = dt_unlisten(Session[channel].pstnParams.NetwH) ) == -1) {

		  gateFATAL(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tError 0x%x in dt_unlisten on channel %d\n",channel));

		  return(FUNCFAIL);

	   }



      break;



   default:

	    gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\t   pstnUnListen was failed (Unknown Front End) on channel %d\n",channel));

        return FUNCFAIL;

      break;



   } /* end switch(frontEnd) */

   

   gateTRACE(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\t   End of pstnUnListen function on channel %d\n",channel));

  

 return(FUNCSUCCESS);

}





/*****FUNCTION***************************************************

*        NAME : pstnGetEvent

* DESCRIPTION : First process of ip events

*       INPUT : None

*      OUTPUT : None

*     RETURNS : 1 - success, 0 - fail

*    CAUTIONS : None

****************************************************************/

int pstnGetEvent(METAEVENT *metaevt,unsigned int Channel)

{

   int         cclibid;    /* cclib id for gc_ErrorValue() */ 

   char        *msg_error; /* points to the error message string */

   int   gc_result;

   long  cclib_result;



   gateTRACE(Channel,_logLevel,Session[Channel].LogFile, (Session[Channel].LogFile,"\t   In pstnGetEvent function on channel %d\n",Channel));



   switch(metaevt->evttype){

		 

         case GCEV_ACCEPT:

		 case GCEV_ANSWERED:

		 case GCEV_DROPCALL:

		 case GCEV_CONNECTED:

         case GCEV_RESETLINEDEV:

         case GCEV_UNBLOCKED:

		 case GCEV_ALERTING:

		 case GCEV_PROCEEDING:

		  

			 break;



		 case GCEV_DETECTED:

			 if(Session[Channel].pstnParams.currentCRN == 0){

				    Session[Channel].pstnParams.currentCRN = metaevt->crn;

			 }

			 else { 

					 /* Here we don't know if this CRN is next CRN or glare CRN,

					    it will be decided in the state machine */

				    Session[Channel].pstnParams.nextCRN = metaevt->crn;

			 }

			 break;



         case GCEV_OFFERED:



			 if(Session[Channel].pstnParams.currentCRN == 0){

				    Session[Channel].pstnParams.currentCRN = metaevt->crn;

			 }

			 else { 

					 /* Here we don't know if this CRN is next CRN or glare CRN,

					    it will be decided in the state machine */

				    Session[Channel].pstnParams.nextCRN = metaevt->crn;

			 }

             if (DnisEnable){

				 if (gc_GetDNIS(Session[Channel].pstnParams.currentCRN,Session[Channel].DNIS)<0) {

				    gateERROR(Channel,_logLevel,Session[Channel].LogFile, (Session[Channel].LogFile, "Failed to get DNIS\n"));

				 }

			 }



			 break;

		   



		 case GCEV_DISCONNECTED:

			  /* Get the reason of Disconnecting */

	         gc_ResultValue(metaevt, &gc_result, &cclibid, &cclib_result);

			 if (gc_ResultMsg(cclibid, cclib_result, &msg_error)==0) {

				   gateTRACE(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile, "Got GCEV_DISCONNECTED. Reason: %s ",msg_error));

			 }

             break;



		 case GCEV_TASKFAIL:

 			 gc_ResultValue(metaevt, &gc_result, &cclibid, &cclib_result);

			 if (gc_ResultMsg(cclibid, cclib_result, &msg_error)==0) {

				   gateFATAL(Channel,_logLevel,Session[Channel].LogFile, (Session[Channel].LogFile, "Got GCEV_TASKFAIL. Reason: %s ",msg_error));

			 }

			 break;



         case GCEV_CALLSTATUS:

 			 gc_ResultValue(metaevt, &gc_result, &cclibid, &cclib_result);

				if (gc_ResultMsg(cclibid, cclib_result, &msg_error)==0) {

				   gateFATAL(Channel,_logLevel,Session[Channel].LogFile, (Session[Channel].LogFile, "Got GCEV_CALLSTATUS. Reason: %s ",msg_error));

				}

			 break;

		 default:

			 gateWARNING(Channel,_logLevel,Session[Channel].LogFile, (Session[Channel].LogFile, "UnKnown GC event (0x%x)\n",metaevt->evttype));

			 return(FUNCFAIL);

			 break;



      } /* End  of switch(metaevt.evttype) */



	     /* We have an event run the state machine function for this channel  */

	  if((*(Session[Channel].stateFxn))(Channel,PSTN,metaevt->evttype,NULL) != FUNCSUCCESS) {

		  return(FUNCFAIL);

	  }

      else{ 

		  return FUNCSUCCESS;

	  }

	  gateTRACE(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\t   End of pstnGetEvent function on channel %d\n",Channel));

} /* Function pstnGetEvent */







⌨️ 快捷键说明

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