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

📄 gatestat.c

📁 ipt网关源码
💻 C
📖 第 1 页 / 共 5 页
字号:
          IPTResetSession(channel,FALSE);
         break;
   
		  /* Case of Offering from LAN  */
      case TSC_EvtCallState_Type_Offered: 
   
		 chanInfo[channel].callsOffered++;
         Session[channel].resetNow = 3;

         rBool = Dm3TscRejectCall(lpTsc,      /* pointer to DM3TSC structure */
                                  /* reason for rejecting the call */
                                  TSC_MsgRejectCall_Reason_Busy);   

         if(rBool==DM3FAIL) {
            gateFATAL(channel,(Session[channel].LogFile,"\tError rejecting Call channel %d\n", channel));
            return(DM3FAIL);
         } 
      	 gateTRACE(channel,(Session[channel].LogFile,"\tRejecting call on channel %d, Didn't get on_hook Cmplt yet\n",channel));
		 chanInfo[channel].callsRejected++;
   		 gateUpdate(pCamelSession,GATE_WAIT_DONE);
   		 break;
   
      /* Case of Exit Notification */
      case TSC_EvtChanState_Type_OutOfService:
   
         gateTRACE(channel,(Session[channel].LogFile,"Channel %d OutOfService.\n",channel));
         gateExit(CHAN_OUT_OF_SERVICE,channel);
         break;
   
      default:
   
         gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x)  on channel %d in PstnRelease\n",
                   gateEventStr(event),event,channel));
         break;

   } /* end switch(event) */

   return (DM3SUCCESS);

} /* Function gatePstnRelease */

/*****FUNCTION***************************************************
*        NAME : gateWaitDone
* DESCRIPTION : Still waiting for on hook from PSTN, 
*               Idle from NetTSC to release the call
*               and Null to reset session structure
*
*       INPUT : LPDM3NetTSC  lpNetTsc   -  pointer to NetTsc structure
*               LONG         event      -  the recieved event
*  				 void         *pEvtData  -  the data recieved
*      OUTPUT : None
*     RETURNS : Success or fail
*    CAUTIONS : None.
****************************************************************/
USHORT gateWaitDone(LPDM3NetTSC  lpNetTsc, 
                          LONG         event,
					           void         *pEvtData)

{
   BOOL            rBool;
   LPDM3TSC        lpTsc;
   GateSession     *pCamelSession;
   USHORT          channel;


   pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
   channel = pCamelSession->sessionNumber;
   lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);


   gateTRACE(channel,(Session[channel].LogFile,"In GATE_WAIT_DONE on channel %d\n\t got event %s (0x%x)\n", 
               channel,gateEventStr(event), event));

   switch(event) {

		  /* Case of Offering from LAN  */
      case TSC_EvtCallState_Type_Offered: 
         Session[channel].resetNow += 2;
		 chanInfo[channel].callsOffered++;

         rBool = Dm3TscRejectCall(lpTsc,      /* pointer to DM3TSC structure */
                                  /* reason for rejecting the call */
                                  TSC_MsgRejectCall_Reason_Busy);   

         if(rBool==DM3FAIL) {
            gateFATAL(channel,(Session[channel].LogFile,"\tError rejecting Call channel %d\n", channel));
            return(DM3FAIL);
         } 
      	 gateTRACE(channel,(Session[channel].LogFile,"\tRejecting call on channel %d, Didn't get on_hook Cmplt yet\n",channel));
		 chanInfo[channel].callsRejected++;
   		 break;
   
      case DIGITAL_ONHOOK:
          Session[channel].resetNow--;
		  if(Session[channel].resetNow == 0) {
			  /* Reset session */
              IPTResetSession(channel,FALSE);
		  }
		  break;
   
      case TSC_EvtCallState_Type_Idle:
          Session[channel].resetNow--;
		  chanInfo[channel].callsIdle++;
          /* Releasing call */
          rBool = Dm3TscReleaseCall(lpTsc,     /* pointer to DM3TSC structure */
                                    /* reason for releasing call */
                                  TSC_MsgRejectCall_Reason_Busy);
          if(rBool==DM3FAIL) {
             gateFATAL(channel,(Session[channel].LogFile,"\tError releasing Call channel %d \n", channel));
             return(DM3FAIL);
         
          } 
		  break; /* End of TSC_EvtCallState_Type_Idle case */
   
	   /* Got null event */
      case TSC_EvtCallState_Type_Null:
          Session[channel].resetNow--;
		  chanInfo[channel].callsNull++;
		  if(Session[channel].resetNow == 0) {
			  /* Reset session */
              IPTResetSession(channel,FALSE);
		  }
         break;
   
      /* Case of Exit Notification */
      case TSC_EvtChanState_Type_OutOfService:
   
         gateTRACE(channel,(Session[channel].LogFile,"Channel %d OutOfService.\n",channel));
         gateExit(CHAN_OUT_OF_SERVICE,channel);
         break;
   
      default:
   
         gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x)  on channel %d in gateWaitDone\n",
                   gateEventStr(event),event,channel));
         break;

   } /* end switch(event) */

   return (DM3SUCCESS);

} /* Function gateWaitDone */

/**** End of File: GateState.c *****/

/*****FUNCTION***************************************************
*        NAME : gateWaitForOffhookCmplt
* DESCRIPTION : 等待摘机操作完成,播放欢迎语音文件
*               add by xuzq 98.6.10
*       INPUT : LPDM3NetTSC  lpNetTsc   -  pointer to NetTsc structure
*               LONG         event      -  the recieved event
*  				 void         *pEvtData  -  the data recieved
*      OUTPUT : None
*     RETURNS : Success or fail
*    CAUTIONS : None.
****************************************************************/
USHORT gateWaitForOffhookCmplt(LPDM3NetTSC  lpNetTsc, 
                              LONG         event,
					               void         *pEvtData)
{
   BOOL            rBool;
   LPDM3TSC        lpTsc;
   GateSession     *pCamelSession;
   USHORT          channel;


   pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
   channel = pCamelSession->sessionNumber;
   lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);

      switch(event) {

		
	  case DX_OFFHOOK:			//摘机成功
				if ((handle[channel] = dx_fileopen("vox\\welcome.vox", O_RDONLY|O_BINARY)) == -1) { //出错
                     /* process error */
	                 gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_Offhook state\n",
                        channel));
					 gateExit(OPEN_VOXFILE_ERROR,channel);
	                 return(DM3FAIL);
				  }
				if (play(channel,handle[channel])==-1) { //播放文件出错
					gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_Offhook state\n",
                        channel));
					 gateExit(PLAY_VOXFILE_ERROR,channel);
	                 return(DM3FAIL);
				}
				gateUpdate(pCamelSession,GATE_WAIT_WELCOME_CMPLT);
				break;
	
	  /* Can happen if the user made call and hang up before connection */
	  //用户中途突然挂机
      case DE_LCOFF:
      case DE_TONEON:
      case DIGITAL_ONHOOK:

             Session[channel].waitOnHook = FALSE;
   	         gateTRACE(channel,(Session[channel].LogFile,"PSTN Disconnect on channel %d\n",
                        channel));

         /* Unlisten both sides */
         if(lpNetTsc->fIsInbound != TRUE) {
			    gateUnRoute(channel);
         }

      lpTsc->fBusy=FALSE;
	  user_onhook(channel); //用户挂机处理函数

       
         break;
		   case DX_ONHOOK:
	    gateUpdate(pCamelSession,GATE_WAIT_CALL);
	  break;
	  
	   default:
   
         gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x)  on channel %d in Gate_Wait_For_Offhook\n",
                   gateEventStr(event),event,channel));
         break;
	  }// End of Switch(event)
		return(DM3SUCCESS);
}// end of function gateWaitForOffhookCmplt

/*****FUNCTION***************************************************
*        NAME : gateWaitForWelcomeCmplt
* DESCRIPTION : 等待播放欢迎语音完成,获取用户名按键
*               add by xuzq 98.6.10
*       INPUT : LPDM3NetTSC  lpNetTsc   -  pointer to NetTsc structure
*               LONG         event      -  the recieved event
*  				 void         *pEvtData  -  the data recieved
*      OUTPUT : None
*     RETURNS : Success or fail
*    CAUTIONS : None.
****************************************************************/
USHORT gateWaitForWelcomeCmplt(LPDM3NetTSC  lpNetTsc, 
                              LONG         event,
					               void         *pEvtData)
{
   BOOL            rBool;
   LPDM3TSC        lpTsc;
   GateSession     *pCamelSession;
   USHORT          channel;


   pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
   channel = pCamelSession->sessionNumber;
   lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);

      switch(event) {
	  case TM_EOD:			//播放完毕
	  case TM_MAXDTMF:      //用户按键
		   if (dx_fileclose(handle[channel]) == -1) {
                    /* process error */
				     gateTRACE(channel,(Session[channel].LogFile,"Error in closing VOX file in channel %d on Gate_wait_for_welcome_cmplt state\n",
                        channel));
				}
		   if (getdigs(channel,10)==-1){ //出错
					
			    gateTRACE(channel,(Session[channel].LogFile,"Error in getting digitals in channel %d on Gate_wait_for_Offhook state\n",
                        channel));
				gateExit(GET_DIGITALS_ERROR,channel);
	                 return(DM3FAIL);
					
				}
           gateUpdate(pCamelSession,GATE_WAIT_GETUSERNAME_CMPLT);
			break;
      //用户中途突然挂机
      case DE_LCOFF:
      case DE_TONEON:
      case DIGITAL_ONHOOK:

             Session[channel].waitOnHook = FALSE;
   	         gateTRACE(channel,(Session[channel].LogFile,"PSTN Disconnect on channel %d\n",
                        channel));

         /* Unlisten both sides */
         if(lpNetTsc->fIsInbound != TRUE) {
			    gateUnRoute(channel);
         }
       lpTsc->fBusy=FALSE;
	    user_onhook(channel); //用户挂机处理函数
		
         
         break;
	  case DX_ONHOOK:
	    gateUpdate(pCamelSession,GATE_WAIT_CALL);
	  break;
	  default:
   
        gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x)  on channel %d in Gate_Wait_For_Welcome_cmplt\n",
                   gateEventStr(event),event,channel));
         break;



	  }//end of switch event!
      return(DM3SUCCESS);
}// end of function gateWaitForWelcomeCmplt

/*****FUNCTION***************************************************
*        NAME : gateWaitForGetUsernameCmplt
* DESCRIPTION : 等待获取用户名按键完成,提示输入用户密码!
*               add by xuzq 98.6.10
*       INPUT : LPDM3NetTSC  lpNetTsc   -  pointer to NetTsc structure
*               LONG         event      -  the recieved event
*  				 void         *pEvtData  -  the data recieved
*      OUTPUT : None
*     RETURNS : Success or fail
*    CAUTIONS : None.
****************************************************************/
USHORT gateWaitForGetUsernameCmplt(LPDM3NetTSC  lpNetTsc, 
                              LONG         event,
					               void         *pEvtData)
{
   BOOL            rBool;
   LPDM3TSC        lpTsc;
   GateSession     *pCamelSession;
   USHORT          channel;


   pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
   channel = pCamelSession->sessionNumber;
   lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);

      switch(event) {
	  case TM_DIGIT:		//按键结束。以“#”终止
							//保存用户按键
		  if (strlen(digp[channel].dg_value)>NUM_USERNAME) { //用户名超长
			  if ((handle[channel] = dx_fileopen("vox\\again.vox", O_RDONLY|O_BINARY)) == -1) { 
						//出错
						gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getpasswd_cmplt state\n",
                                   channel));
					 gateExit(OPEN_VOXFILE_ERROR,channel);
	                 return(DM3FAIL);

					}
					gateUpdate(pCamelSession,GATE_WAIT_NOTMATCH_CMPLT);
					if (play(channel,handle[channel])==-1) { //播放文件出错
					     gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getusername_cmplt state\n",
                            channel));
					        gateExit(PLAY_VOXFILE_ERROR,channel);
	                        return(DM3FAIL);
					}
			  break;	
		  }
				
              
		  
	
	
				strcpy(username[channel],digp[channel].dg_value);
				if ((handle[channel] = dx_fileopen("vox\\passwd.vox", O_RDONLY|O_BINARY)) == -1) { 
					   //出错
	                 gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getusername_cmplt state\n",
                                   channel));
					 gateExit(OPEN_VOXFILE_ERROR,channel);
	                 return(DM3FAIL);
				  }
				if (play(channel,handle[channel])==-1) { 
					//播放文件出错
					gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getusername_cmplt state\n",
                        channel));
					 gateExit(PLAY_VOXFILE_ERROR,channel);
	                 return(DM3FAIL);

⌨️ 快捷键说明

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