コード例 #1
0
ファイル: Dlg_H323.cpp プロジェクト: tempbottle/TestSet
int CDlg_H323::Listen()
{
	int ret;
	char localip[40];
	struct ooConnectionEP connectionEP;
	ooGetLocalIPAddress(localip); /* Get local ip address to listen on */
	strcpy(connectionEP.ipaddress, localip);
	connectionEP.port = 1720;
	ret=ooCreateH2250Channel(myContext, &CH323MsgHandler::OnReceivedH2250Msg,
								connectionEP, OORECEIVER);
	return ASN_OK;
}
コード例 #2
0
ファイル: oosndrtp.c プロジェクト: tempbottle/TestSet
int ooSetLocalRTPAndRTCPAddrs(struct ooAppContext* context)
{
   int port;
   ooGetLocalIPAddress(context->localIP);
   port = ooGetNextPort(context, OORTP);
   /* Ensures that RTP port is an even one */
   if((port & 1) == 1)
     port = ooGetNextPort(context, OORTP);
   
   context->localRtpPort = port;
   context->localRtcpPort = ooGetNextPort(context, OORTP);
   OOTRACEINFO4(context, "Local RTP port: %d Local RTCP port:%d", 
                          context->localRtpPort, context->localRtcpPort);
   return OO_OK;
}
コード例 #3
0
ファイル: Dlg_H323.cpp プロジェクト: tempbottle/TestSet
void CDlg_H323::RegistrationRequest()
{
	int ret;
	H225RegistrationRequest *regRequest;
	OOCTXT *pctxt;
	H225TransportAddress *CallSignalAddress,*RasAddress;
	H225TransportAddress_ipAddress *IpAddr1,*IpAddr2;
	int addr_seg1,addr_seg2,addr_seg3,addr_seg4;
	char hexIp[20];
	H225AliasAddress *alias1,*alias2;
	int bindPort;

	ret = ooSocketCreateUDP(&myContext->RASChannel);
	if(ret != ASN_OK)
	{
	  OOTRACEERR2(myContext, "ERROR: Creating RAS channel failed...");
	  return;
	}
	
	bindPort = ooBindPort(myContext,OOUDP,myContext->RASChannel);
	if(bindPort == OO_FAILED)
	{
	  OOTRACEERR2(myContext, "ERROR: Bind port failed...");
	  return;
	}

	myContext->RASCallback = &CH323MsgHandler::OnReceivedRasMsg;
	strncpy(myContext->GkIp,LPCTSTR(m_strGatekeeper),20);
	myContext->RasChanPort = 1719;

	//build and send RAS registration message
   ret = ooCreateRasMessage(myContext,T_H225RasMessage_registrationRequest);
   if(ret == OO_FAILED)
   {
      OOTRACEERR2(myContext,"Error:Failed to create Ras message");
      return;
   }

   myContext->outgoingRas->msgType = OORegistrationRequest;
   regRequest = myContext->outgoingRas->RasMsg.u.registrationRequest;
   pctxt = myContext->outgoingRas->pctxt;
   regRequest->requestSeqNum = (myContext->seqNumber++) % 65536;
   regRequest->protocolIdentifier = gRasProtocolID;
   regRequest->discoveryComplete = FALSE;

   CallSignalAddress = (H225TransportAddress*)ASN1MALLOC(pctxt,sizeof(H225TransportAddress));
   memset(CallSignalAddress,0,sizeof(H225TransportAddress));
   CallSignalAddress->t = T_H225TransportAddress_ipAddress;
   IpAddr1 = (H225TransportAddress_ipAddress*)ASN1MALLOC(pctxt,sizeof(H225TransportAddress_ipAddress));
   memset(IpAddr1,0,sizeof(H225TransportAddress_ipAddress));
   ooGetLocalIPAddress(myContext->localIP);
   sscanf(myContext->localIP,"%d.%d.%d.%d",&addr_seg1,&addr_seg2,&addr_seg3,&addr_seg4);
   sprintf(hexIp,"%x %x %x %x",addr_seg1,addr_seg2,addr_seg3,addr_seg4);
   sscanf(hexIp,"%x %x %x %x",&IpAddr1->ip.data[0],&IpAddr1->ip.data[1],
	   &IpAddr1->ip.data[2],&IpAddr1->ip.data[3]);
   IpAddr1->ip.numocts = 4;
   IpAddr1->port = 1720;
   CallSignalAddress->u.ipAddress = IpAddr1;
   dListInit(&(regRequest->callSignalAddress));
   dListAppend(pctxt,&(regRequest->callSignalAddress),CallSignalAddress);
	
   RasAddress = (H225TransportAddress*)ASN1MALLOC(pctxt,sizeof(H225TransportAddress));
   memset(RasAddress,0,sizeof(H225TransportAddress));
   RasAddress->t = T_H225TransportAddress_ipAddress;
   IpAddr2 = (H225TransportAddress_ipAddress*)ASN1MALLOC(pctxt,sizeof(H225TransportAddress_ipAddress));
   memset(IpAddr2,0,sizeof(H225TransportAddress_ipAddress));
   sscanf(/*myContext->GkIp*/myContext->localIP,"%d.%d.%d.%d",&addr_seg1,&addr_seg2,&addr_seg3,&addr_seg4);
   sprintf(hexIp,"%x %x %x %x",addr_seg1,addr_seg2,addr_seg3,addr_seg4);
   sscanf(hexIp,"%x %x %x %x",&IpAddr2->ip.data[0],&IpAddr2->ip.data[1],
	   &IpAddr2->ip.data[2],&IpAddr2->ip.data[3]);
   IpAddr2->ip.numocts = 4;
   IpAddr2->port = bindPort;
   RasAddress->u.ipAddress = IpAddr2;
   dListInit(&(regRequest->rasAddress));
   dListAppend(pctxt,&(regRequest->rasAddress),RasAddress);	

   //terminal type
   regRequest->terminalType.mc = FALSE;
   regRequest->terminalType.undefinedNode = FALSE;
   regRequest->terminalType.terminal.m.nonStandardDataPresent = FALSE;
   regRequest->terminalType.m.terminalPresent = TRUE;
   
   //terminal alias
	if(m_bName || m_bNumber)
	{
		regRequest->m.terminalAliasPresent = 1;
		dListInit(&(regRequest->terminalAlias));
	}
	else
		regRequest->m.terminalAliasPresent = 0;
	
   if(m_bName)
   {
	   alias1 = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
	   memset(alias1,0,sizeof(H225AliasAddress));
	   alias1->t = T_H225AliasAddress_h323_ID;
	   Asn116BitCharString *str = &(alias1->u.h323_ID);
	   int nCount = m_strName.GetLength();
	   str->nchars = nCount;
	   str->data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,sizeof(ASN116BITCHAR) * nCount);
	   memset(str->data,0,sizeof(ASN116BITCHAR) * nCount);
	   for(int i = 0; i < nCount; i++)	//这里需要进一步转换成16进制吗?
		   str->data[i] = (ASN116BITCHAR)m_strName.GetAt(i);
	   dListAppend(pctxt,&(regRequest->terminalAlias),alias1);
   }
   if(m_bNumber)
   {
	   alias2 = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
	   memset(alias2,0,sizeof(H225AliasAddress));
	   alias2->t = T_H225AliasAddress_dialedDigits;
	   alias2->u.dialedDigits = LPCTSTR(m_strNumber);
	   dListAppend(pctxt,&(regRequest->terminalAlias),alias2);
   }

    //endpoint Vendor
	regRequest->endpointVendor.vendor.t35CountryCode = 9;
	regRequest->endpointVendor.vendor.t35Extension = 0;
	regRequest->endpointVendor.vendor.manufacturerCode= 61;
	regRequest->endpointVendor.productId.numocts = ASN1MIN(strlen("GiantVoip"), 
							   sizeof(regRequest->endpointVendor.productId.data));
	strncpy((char*)regRequest->endpointVendor.productId.data, "GiantVoip", 
		   regRequest->endpointVendor.productId.numocts);


	regRequest->endpointVendor.versionId.numocts = ASN1MIN(strlen("Version 1.0"), 
							   sizeof(regRequest->endpointVendor.versionId.data));
	strncpy((char*)regRequest->endpointVendor.versionId.data, "Version 1.0", 
		   regRequest->endpointVendor.versionId.numocts);

	regRequest->endpointVendor.m.productIdPresent=TRUE;
	regRequest->endpointVendor.m.versionIdPresent=TRUE;

	regRequest->keepAlive = FALSE;
	regRequest->willSupplyUUIEs = FALSE;
	regRequest->maintainConnection = FALSE;

    ooSendRasMsg(myContext);
    OOTRACEINFO2(myContext, "Sending registration request message");
}
コード例 #4
0
ファイル: Dlg_H323.cpp プロジェクト: tempbottle/TestSet
void CDlg_H323::CallSetup()
{
	struct ooConnectionEP connectionEP;
	H225Setup_UUIE setup;
	H225TransportAddress_ipAddress destCallSignalIpAddress;
	int addr_part1, addr_part2, addr_part3, addr_part4;
	char hexip[20];
	H225TransportAddress_ipAddress srcCallSignalIpAddress;
	char localip[40];
	int i =0, ret;
	H225H323_UserInformation userInfo;
	H225AliasAddress *alias;
	OOCTXT *pctxt;
	char destip[20];

	if(m_bViaGK)	//通过网守呼叫
	{
		strcpy(destip,myContext->remoteIP);
		strcpy(connectionEP.ipaddress,myContext->remoteIP);
		connectionEP.port = 1720;
	}
	else			//直接呼叫
	{
		if(m_nDestStrType != 0)
		{
			AfxMessageBox("无效的呼叫地址,请重新输入");
			return;
		}
		UpdateData(TRUE);
		strcpy(destip,LPCTSTR(m_strCalled));
		strcpy(connectionEP.ipaddress,LPCTSTR(m_strCalled));
		connectionEP.port = 1720;
	}

	/* This function will create a local socket and make a connect request
	  to the destination IP at port 1720 */
	ret = ooCreateH2250Channel(myContext, &CH323MsgHandler::OnReceivedH2250Msg, 
						  connectionEP, OOTRANSMITTER);

	if(ret !=OO_OK)
	{
		CloseCallingDlg();
		AfxMessageBox("您呼叫的用户无法接受呼叫");
		return;
	}

	/*Create outgoing Q931 message. An outgoing Q931 setup message will be 
	 created for the context.
	*/ 
	ret = ooCreateQ931Message(myContext, Q931SetupMsg);
	if(ret != OO_OK)
	{
	    OOTRACEERR2(myContext, "ERROR: Creating Q931 setup message...");
		CloseCallingDlg();
		return;
	}

	/*Populate the setup UUIE to be passed into the outgoing setup message*/   
	memset (&setup, 0, sizeof(setup));
	setup.protocolIdentifier = gProtocolID;
	setup.sourceInfo.m.vendorPresent=TRUE;
	/* Populate the vendor information */
	setup.sourceInfo.vendor.vendor.t35CountryCode = 9;
	setup.sourceInfo.vendor.vendor.t35Extension = 0;
	setup.sourceInfo.vendor.vendor.manufacturerCode=61;
	setup.sourceInfo.vendor.productId.numocts = ASN1MIN(strlen("GiantVoip"), 
							   sizeof(setup.sourceInfo.vendor.productId.data));
	strncpy((char*)setup.sourceInfo.vendor.productId.data, "GiantVoip", 
		   setup.sourceInfo.vendor.productId.numocts);

  
	setup.sourceInfo.vendor.versionId.numocts = ASN1MIN(strlen("Version 1.0"), 
							   sizeof(setup.sourceInfo.vendor.versionId.data));
	strncpy((char*)setup.sourceInfo.vendor.versionId.data, "Version 1.0", 
		   setup.sourceInfo.vendor.versionId.numocts);

	setup.sourceInfo.vendor.m.productIdPresent=TRUE;
	setup.sourceInfo.vendor.m.versionIdPresent=TRUE;
	setup.sourceInfo.mc = FALSE;
	setup.sourceInfo.m.terminalPresent = TRUE;
	setup.sourceInfo.terminal.m.nonStandardDataPresent = FALSE;
	setup.sourceInfo.undefinedNode = FALSE;
	setup.activeMC=FALSE;

	pctxt = myContext->outgoing->pctxt;
	if(m_bViaGK)
	{
		//destination address(alias)
	   dListInit(&(setup.destinationAddress));
	   if(m_nDestStrType == 1)	//号码
	   {
		   alias = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
		   memset(alias,0,sizeof(H225AliasAddress));
		   alias->t = T_H225AliasAddress_dialedDigits;
		   alias->u.dialedDigits = LPCTSTR(m_strCalled);
		   dListAppend(pctxt,&(setup.destinationAddress),alias);
	   }
	   else/* if(m_nDestStrType == 2)*/	//账号
	   {
		   alias = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
		   memset(alias,0,sizeof(H225AliasAddress));
		   alias->t = T_H225AliasAddress_h323_ID;
		   Asn116BitCharString *str = &(alias->u.h323_ID);
		   int nCount = m_strCalled.GetLength();
		   str->nchars = nCount;
		   str->data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,sizeof(ASN116BITCHAR) * nCount);
		   memset(str->data,0,sizeof(ASN116BITCHAR) * nCount);
		   for(int i = 0; i < nCount; i++)	//这里需要进一步转换成16进制吗?
			   str->data[i] = (ASN116BITCHAR)m_strCalled.GetAt(i);
		   dListAppend(pctxt,&(setup.destinationAddress),alias);
	   }
	   setup.m.destinationAddressPresent = TRUE;

	   //source address (alias)
	   dListInit(&(setup.sourceAddress));
	   if(m_bNumber)	//号码
	   {
		   alias = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
		   memset(alias,0,sizeof(H225AliasAddress));
		   alias->t = T_H225AliasAddress_dialedDigits;
		   alias->u.dialedDigits = LPCTSTR(m_strNumber);
		   dListAppend(pctxt,&(setup.sourceAddress),alias);
	   }
	   if(m_bName)	//账号
	   {
		   alias = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
		   memset(alias,0,sizeof(H225AliasAddress));
		   alias->t = T_H225AliasAddress_h323_ID;
		   Asn116BitCharString *str = &(alias->u.h323_ID);
		   int nCount = m_strName.GetLength();
		   str->nchars = nCount;
		   str->data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,sizeof(ASN116BITCHAR) * nCount);
		   memset(str->data,0,sizeof(ASN116BITCHAR) * nCount);
		   for(int i = 0; i < nCount; i++)	//这里需要进一步转换成16进制吗?
			   str->data[i] = (ASN116BITCHAR)m_strName.GetAt(i);
		   dListAppend(pctxt,&(setup.sourceAddress),alias);
	   }
	   setup.m.sourceAddressPresent = TRUE;
	}
	else
	{
		/* Populate the destination Call Signal Address */
		setup.destCallSignalAddress.t=T_H225TransportAddress_ipAddress;

		sscanf(destip, "%d.%d.%d.%d", &addr_part1, &addr_part2, &addr_part3, 
									 &addr_part4);
		sprintf(hexip, "%x %x %x %x", addr_part1, addr_part2, addr_part3, 
									 addr_part4);
		sscanf(hexip, "%x %x %x %x", &destCallSignalIpAddress.ip.data[0], 
									&destCallSignalIpAddress.ip.data[1],
									&destCallSignalIpAddress.ip.data[2], 
									&destCallSignalIpAddress.ip.data[3]);

		destCallSignalIpAddress.ip.numocts=4;
		destCallSignalIpAddress.port=1720;
		setup.destCallSignalAddress.u.ipAddress = &destCallSignalIpAddress;
		setup.m.destCallSignalAddressPresent=TRUE;

		/* Populate the source Call Signal Address */
		setup.sourceCallSignalAddress.t=T_H225TransportAddress_ipAddress;
		ooGetLocalIPAddress(localip);
		sscanf(localip, "%d.%d.%d.%d", &addr_part1, &addr_part2, &addr_part3,
									  &addr_part4);
		sprintf(hexip, "%x %x %x %x", addr_part1, addr_part2, addr_part3, 
									 addr_part4);
		sscanf(hexip, "%x %x %x %x", &srcCallSignalIpAddress.ip.data[0], 
									&srcCallSignalIpAddress.ip.data[1],
									&srcCallSignalIpAddress.ip.data[2], 
									&srcCallSignalIpAddress.ip.data[3]);

		srcCallSignalIpAddress.ip.numocts=4;
		srcCallSignalIpAddress.port=ooGetH225ChannelPort(myContext);
		setup.sourceCallSignalAddress.u.ipAddress = &srcCallSignalIpAddress;
		setup.m.sourceCallSignalAddressPresent=TRUE;	
	}

	/* No fast start */
	setup.m.fastStartPresent = FALSE;
 
	//modified by tony below 2004.12.13
	/*setup.conferenceID.numocts = 16;
	for (i = 0; i < 16; i++)
	  setup.conferenceID.data[i] = i + 1;*/
	if(myContext->conferenceId.numocts != 16 )
	{
		ooGenerateGUID(myContext->conferenceId.data);
		myContext->conferenceId.numocts = 16;
	}
	setup.conferenceID.numocts = myContext->conferenceId.numocts;
	memcpy(setup.conferenceID.data,myContext->conferenceId.data,myContext->conferenceId.numocts);
	//modified by tony above 2004.12.13

	setup.conferenceGoal.t = T_H225Setup_UUIE_conferenceGoal_create;
	/* H.225 point to point call */
	setup.callType.t = T_H225CallType_pointToPoint;

	/* Populate optional fields */
	setup.m.callIdentifierPresent = TRUE;
	setup.m.mediaWaitForConnectPresent = TRUE;
	setup.m.canOverlapSendPresent = TRUE;

	//modified by tony below 2004.12.13
	/* Dummy call identifier. Need to add a function in stack to generate
	  unique call id */
	/*setup.callIdentifier.guid.numocts = 16;
	for (i = 0; i < 16; i++)
	   setup.callIdentifier.guid.data[i] = i + 1;*/
	if(myContext->callIdentifier.guid.numocts != 16)
	{
		ooGenerateGUID(myContext->callIdentifier.guid.data);
		myContext->callIdentifier.guid.numocts = 16;
	}
	setup.callIdentifier.guid.numocts = myContext->callIdentifier.guid.numocts;
	memcpy(setup.callIdentifier.guid.data,myContext->callIdentifier.guid.data,myContext->callIdentifier.guid.numocts);

	/*Since currently call ID is generated outside stack, application needs to store 
	it in the context field for stack to use.*/
	//memcpy(myContext->callIdentifier.guid.data, setup.callIdentifier.guid.data,16);
	//myContext->callIdentifier.guid.numocts = setup.callIdentifier.guid.numocts;
	//modified by tony above 2004.12.13
	setup.mediaWaitForConnect = FALSE;
	setup.canOverlapSend = FALSE;
	
	/* Populate the userInfo structure with the setup UUIE */ 
	memset (&userInfo, 0, sizeof(userInfo));
	userInfo.h323_uu_pdu.h323_message_body.t = 
		 T_H225H323_UU_PDU_h323_message_body_setup;
	userInfo.h323_uu_pdu.h323_message_body.u.setup = &setup;

	/* Add userinfo to the outgoing q931 setup message */   
	if(ooAddUserUserIE(myContext, &userInfo) != OO_OK)
	{
	  OOTRACEERR2(myContext, "Error: Failed to add UUIE to Q931 message");
	  return;
	}
	else
	{
	  /* This queues the outgoing message into the outgoing message queue.
		 The message will be sent whenever the corresponing channel is ready
		 for send, in other words corresponing socket is available for write.
	  */
 	  OOTRACEINFO2(myContext, "Sending H.225 setup message");
	  ooSendH225Msg(myContext);
	  SetTimer(2006,30000,NULL);	//启动10秒钟定时器,若在此期间无法收到Connect消息则退出
	}
}
コード例 #5
0
ファイル: ooh323ep.c プロジェクト: roramirez/asterisk
int ooH323EpInitialize
   (enum OOCallMode callMode, const char* tracefile)
{

   memset(&gH323ep, 0, sizeof(ooEndPoint));

   initContext(&(gH323ep.ctxt));
   initContext(&(gH323ep.msgctxt));

   if(tracefile)
   {
      if(strlen(tracefile)>= MAXFILENAME)
      {
         printf("Error:File name longer than allowed maximum %d\n",
                 MAXFILENAME-1);
         return OO_FAILED;
      }
      strcpy(gH323ep.traceFile, tracefile);
   }
   else{
      strcpy(gH323ep.traceFile, DEFAULT_TRACEFILE);
   }

   gH323ep.fptraceFile = fopen(gH323ep.traceFile, "a");
   if(gH323ep.fptraceFile == NULL)
   {
      printf("Error:Failed to open trace file %s for write.\n",
                  gH323ep.traceFile);
      return OO_FAILED;
   }

   /* Initialize default port ranges that will be used by stack.
      Apps can override these by explicitely setting port ranges
   */

   gH323ep.tcpPorts.start = TCPPORTSSTART;
   gH323ep.tcpPorts.max = TCPPORTSEND;
   gH323ep.tcpPorts.current=TCPPORTSSTART;

   gH323ep.udpPorts.start = UDPPORTSSTART;
   gH323ep.udpPorts.max = UDPPORTSEND;
   gH323ep.udpPorts.current = UDPPORTSSTART;

   gH323ep.rtpPorts.start = RTPPORTSSTART;
   gH323ep.rtpPorts.max = RTPPORTSEND;
   gH323ep.rtpPorts.current = RTPPORTSSTART;

   OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART);
   OO_SETFLAG(gH323ep.flags, OO_M_TUNNELING);
   OO_SETFLAG(gH323ep.flags, OO_M_AUTOANSWER);
   OO_CLRFLAG(gH323ep.flags, OO_M_GKROUTED);

   gH323ep.aliases = NULL;

   gH323ep.termType = DEFAULT_TERMTYPE;

   gH323ep.t35CountryCode = DEFAULT_T35COUNTRYCODE;

   gH323ep.t35Extension = DEFAULT_T35EXTENSION;

   gH323ep.manufacturerCode = DEFAULT_MANUFACTURERCODE;

   gH323ep.productID = DEFAULT_PRODUCTID;

   gH323ep.versionID = OOH323C_VERSION;

   gH323ep.callType = T_H225CallType_pointToPoint;
   ooGetLocalIPAddress(gH323ep.signallingIP);
   gH323ep.listenPort = DEFAULT_H323PORT;

   gH323ep.listener = NULL;

   ooH323EpSetCallerID(DEFAULT_CALLERID);


   gH323ep.myCaps = NULL;
   gH323ep.noOfCaps = 0;
   gH323ep.callList = NULL;
   ast_mutex_init(&monitorLock);
   ast_mutex_init(&callListLock);
   ast_mutex_init(&newCallLock);
   ast_mutex_init(&bindPortLock);
   gH323ep.dtmfmode = 0;
   gH323ep.callingPartyNumber[0]='\0';
   gH323ep.callMode = callMode;
   gH323ep.isGateway = FALSE;

   dListInit(&g_TimerList);/* This is for test application chansetup only*/

   gH323ep.callEstablishmentTimeout = DEFAULT_CALLESTB_TIMEOUT;

   gH323ep.msdTimeout = DEFAULT_MSD_TIMEOUT;

   gH323ep.tcsTimeout = DEFAULT_TCS_TIMEOUT;

   gH323ep.logicalChannelTimeout = DEFAULT_LOGICALCHAN_TIMEOUT;

   gH323ep.sessionTimeout = DEFAULT_ENDSESSION_TIMEOUT;
   gH323ep.ifList = NULL;

   ooSetTraceThreshold(OOTRCLVLINFO);
   OO_SETFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED);

   gH323ep.cmdSock = 0;
   return OO_OK;
}