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

📄 gateip.c

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

* 

* $ProjectName: X:/SIPROJ/VOIP/HOST/WIN_NT/DEMOS/Samples.rel5/Dm3/Iplink/project.pj $

* $ProjectRevision: 1.5 $

* $Label$

* $Revision: 1.10.2.1 $ - $Date: 2002/01/16 09:57:04 $

* 

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



#define  _GATEIP_C               





/* The IPT H files are needed in this order: */

#include <libdbg.h>

#include "gateip.h"             

#include "gatestrc.h"             

#include "gatevars.h"

#include "incfile.h"





/******************Local Function Area*********************/

static void * util_malloc( long size, int init_val, unsigned int Channel);





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

*        NAME : ipGetChannels

* DESCRIPTION : Gets the number of IP channels available

*               in the system

*       INPUT : None

*      OUTPUT : None

*     RETURNS : Number of Voice channels

*    CAUTIONS : None

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

unsigned int ipGetChannels()			

{

    int       boardNum = 0;

	LINEDEV     boardDev;

	int       index;

	int       channel = 1; 

	int       channelNum = 0;

	char      brdname[64]; 

	int		  NumChannlesOnBoard = 0;

	if(PDLsr_getboardcnt(&boardNum,ipProtocol,1) == -1) {

	    printf("%s"," ***** Error: PDLsr_getboardcnt failed to get IPT boards *****\n");

	}

	else{

		

		printf("\n<<Number of IPT boards found: %d >>\n",boardNum);



		for ( index = 1; index <= boardNum; index++) {

			sprintf(brdname, ":N_iptB%d:P_%s:M_ipmB%d", index, ipProtocol, index);

			if (gc_Open(&boardDev,brdname, 0) < 0){

				printf("%s"," ***** Error: gc_Open failed to get DM3 IP board handle *****\n");

			}

			else{

				

				/* Find Num channels per board */

				NumChannlesOnBoard = ATDV_SUBDEVS(boardDev);

						

				/* Add the num channels on the board to total PSTN channels */

				channelNum += NumChannlesOnBoard;

					

				channel = 1;

				while (channel <= NumChannlesOnBoard){

					Session[channelNum - NumChannlesOnBoard + channel].ipParams.BoardNum = index;

                    Session[channelNum - NumChannlesOnBoard + channel].ipParams.ChanNum = channel;

					channel++;

				}

				if(gc_Close(boardDev) <0){

					printf("%s"," ***** Error: failed to call gc_Close*****\n");

				}

			} 

		}

	}

    	

    IPNumOfBoards = boardNum;

	return((unsigned int) (channelNum));  

	

} /* Function ipGetChannels */









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

*        NAME : ipOpenDevices

* DESCRIPTION : Initialize IP

*       INPUT : None

*      OUTPUT : None

*     RETURNS : success or fail

*    CAUTIONS : None

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

int ipOpenDevices()			

{

   unsigned short    index;

   unsigned short    brd; 

   unsigned int      chan;

   char      devname[50];

   SC_TSINFO tsInfo;

   unsigned long	 tsArray[1];

   int      rBool = 1;

   tsInfo.sc_tsarrayp = tsArray;

   tsInfo.sc_numts = 1;



   

   /* For every channel  */

   for ( index = 1; index <= gateChannels; index++) {



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

	  

	   brd = Session[index].ipParams.BoardNum;

	   chan = Session[index].ipParams.ChanNum;



	   sprintf(devname, ":N_iptB%dT%d:P_%s:M_ipmB%dC%d", brd, chan, ipProtocol, brd, chan);

	   if (gc_OpenEx(&(Session[index].ipParams.linedev), devname, 0,(void *)&Session[index])<0) {

			printGCError("gc_OpenEx",index,Session[index].LogFile,_logLevel); 

			return FUNCFAIL;

	   }     



	 /* Get the TX timeslot of the ip voice device and store it in the demo Session structure. */

       if (gc_GetXmitSlot(Session[index].ipParams.linedev, &tsInfo) == -1) {

		   printGCError("gc_GetXmitSlot",index,Session[index].LogFile,_logLevel);

	   }else {

		   Session[index].ipParams.TxTSlot = (unsigned short)tsArray[0];

	   }

   

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

   } /* end for index */   

   

   return(FUNCSUCCESS);  

} /* Function ipOpenDevices */		   

				   

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

*        NAME : ipMakeCall

* DESCRIPTION : Fill the structures of makecall and send 

*                    gc_MakeCall to ip

*       INPUT : Channel

*      OUTPUT : None

*     RETURNS : 1 - success, 0 - fail

*    CAUTIONS : None

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

int ipMakeCall(unsigned int Channel)

{

	

	CallParameters      CFGParm;

	GC_PARM_BLKP        gcParmBlk = NULL;

    GC_MAKECALL_BLK     *gcMakeCallBlk = NULL;

	char                destAddr[128];

    

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



    CFGParm = Session[Channel].ConfigFileParm; 



	/* Fill gcParmBlk structure */

	if (gc_util_insert_parm_ref(&gcParmBlk,IPSET_NONSTANDARDDATA, IPPARM_NONSTANDARDDATA_DATA,

		(char)(sizeof(CFGParm.NonStdData)),CFGParm.NonStdData) < 0){

		printGCError("gc_util_insert_parm_val",Channel,Session[Channel].LogFile,_logLevel); 

		

	}



	if (gc_util_insert_parm_ref(&gcParmBlk,IPSET_NONSTANDARDDATA, IPPARM_NONSTANDARDDATA_OBJID,

		(char)(sizeof(CFGParm.NonStdObjID)),CFGParm.NonStdObjID) < 0){

		printGCError("gc_util_insert_parm_val",Channel,Session[Channel].LogFile,_logLevel); 

		

	}



	if (gc_util_insert_parm_ref(&gcParmBlk,IPSET_VENDORINFO, IPPARM_H221NONSTD,

		sizeof(IP_H221NONSTANDARD),	&(CFGParm.H221NonStd)) < 0){

		printGCError("gc_util_insert_parm_val",Channel,Session[Channel].LogFile,_logLevel); 

		

	}

    /* Initialize the makecall block */

    gcMakeCallBlk = (GC_MAKECALL_BLKP)util_malloc(sizeof(GC_MAKECALL_BLK),0,Channel);

    

    gcMakeCallBlk->cclib = NULL;

    

    gcMakeCallBlk->gclib = (GCLIB_MAKECALL_BLKP)util_malloc((sizeof(GCLIB_MAKECALL_BLK)+

									gcParmBlk->parm_data_size),0x0,Channel);



    gcMakeCallBlk->gclib->ext_datap = (GC_PARM_BLKP)util_malloc((sizeof(GC_PARM_BLKP)+

									gcParmBlk->parm_data_size),GCMKCALLBLK_DEFAULT,Channel);

	

	gcMakeCallBlk->gclib->ext_datap->parm_data_size = gcParmBlk->parm_data_size;

    memcpy((void *)gcMakeCallBlk->gclib->ext_datap->parm_data_buf,(const void *) gcParmBlk->parm_data_buf, \

			    gcParmBlk->parm_data_size);

    

    gc_util_delete_parm_blk(gcParmBlk);

	



	if (DnisEnable){

	   	strcpy(destAddr,Session[Channel].DNIS);

	}

	else{

		strcpy(destAddr,Session[Channel].ConfigFileParm.destAddr);

	}		

	

    /* Send make call to ip */

	if (gc_MakeCall(Session[Channel].ipParams.linedev, 

		  &(Session[Channel].ipParams.currentCRN),

		  destAddr,

	      gcMakeCallBlk,

		  TIMEOUT, 

		  EV_ASYNC)<0) {

		printGCError("gc_MakeCall",Channel,Session[Channel].LogFile,_logLevel ); 

		/* free makecall block */

		free((void *)gcMakeCallBlk->gclib);

        free((void *)gcMakeCallBlk);

        return (FUNCFAIL);  

	}



    /* free makecall block */

	free((void *)gcMakeCallBlk->gclib);

    free((void *)gcMakeCallBlk);



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



	return (FUNCSUCCESS);



}/* ipMakeCall function */





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

*        NAME : OnExtension

* DESCRIPTION : Get the call information and update the CallParameters

*               structure. 

*       INPUT : parmBlk- pointer to GC_PARM_BLK structure

*               Channel- the channel which got the event

*      OUTPUT : None

*     RETURNS : None

*    CAUTIONS : None

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

void OnExtension(GC_PARM_BLKP parm_blk,unsigned int Channel)

{

	

    GC_PARM_DATA        *parmp = NULL;

	

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







	while (parmp = gc_util_next_parm(parm_blk,parmp))

    {



		switch (parmp->set_ID)

		{

		case IPSET_CALLINFO:

			switch (parmp->parm_ID)

			{

			case IPPARM_CONNECTIONMETHOD:

				if(parmp->value_size != 0){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data IPPARM_CONNECTIONMETHOD: 0x%x\n",(*(int *)(parmp->value_buf))));

				}

                break;



			case IPPARM_H245TUNNELING:

				if(parmp->value_size != 0){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data IPPARM_H245TUNNELING: 0x%x\n",(*(int *)(parmp->value_buf))));

				}

                break;



			case IPPARM_DISPLAY:

				if(parmp->value_size != 0){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data DISPLAY: %s\n",parmp->value_buf));

				}

				break;



            case IPPARM_USERUSER_INFO:

				if(parmp->value_size != 0){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data UUI: %s\n",parmp->value_buf));

				}

				break;



            case IPPARM_PHONELIST:

				if(parmp->value_size != 0){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data PHONELIST: %s\n",parmp->value_buf));

				}

				break;



            case IPPARM_CALLDURATION:

				if(parmp->value_size != 0){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data CALLDURATION: %d\n",(unsigned int)(*(parmp->value_buf))));

				}

                break;



			 case IPPARM_RTCPINFO:

				if(parmp->value_size == sizeof(IP_RTCPINFO)){

					gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data RTCPINFO:timestamp %d,tx_packets %d,tx_octets %d send_indication %d\n",

					          ((IP_RTCPINFO *)(parmp->value_buf))->remote.sender.timestamp,

							  ((IP_RTCPINFO *)(parmp->value_buf))->remote.sender.tx_packets,

                              ((IP_RTCPINFO *)(parmp->value_buf))->remote.sender.tx_octets,

                              ((IP_RTCPINFO *)(parmp->value_buf))->remote.sender.send_indication));

				}

    			break;

 

			default:

				gateWARNING(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot unknown CALLINFO extension parmID %d\n",parmp->parm_ID)); 

				

				break;

			}/* end switch (parmp->parm_ID) for IPSET_CALLINFO */

			break;





        case GCSET_CHAN_CAPABILITY:

			{

				IP_CAPABILITY *IPCapability;

				if (parmp->parm_ID == IPPARM_LOCAL_CAPABILITY)

				{   

                    if(parmp->value_size == sizeof(IP_CAPABILITY)){

						IPCapability = (IP_CAPABILITY *)(&(parmp->value_buf));

				        gateINFO(Channel,_logLevel,Session[Channel].LogFile,(Session[Channel].LogFile,"\tGot extension data CAPABILITY: capability %d,type %d, direction %d\n",

⌨️ 快捷键说明

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