Ejemplo n.º 1
0
void CDlg_H323::AdmissionRequest()
{
	H225AdmissionRequest *admRequest;
	OOCTXT *pctxt;
	H225TransportAddress_ipAddress *IpAddr;
	int addr_seg1,addr_seg2,addr_seg3,addr_seg4;
	char hexIp[20];
	H225AliasAddress *alias,*Alias1,*Alias2;
	int ret;
	int nCharNum;

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

	pctxt = myContext->outgoingRas->pctxt;
	admRequest = myContext->outgoingRas->RasMsg.u.admissionRequest;
	admRequest->requestSeqNum = (myContext->seqNumber++) % 65536;
	admRequest->callType.t = T_H225CallType_pointToPoint;
	
	//endpoint identifier
	nCharNum = admRequest->endpointIdentifier.nchars = myContext->epIdentifier.nchars;
	admRequest->endpointIdentifier.data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,nCharNum * sizeof(ASN116BITCHAR));
	memcpy(admRequest->endpointIdentifier.data,myContext->epIdentifier.data,nCharNum * sizeof(ASN116BITCHAR));

	//followed is destinationInfo or destCallSignalAddress
	if(m_bAsCaller)	//作为主叫方
	{
		//dest info
		admRequest->m.destinationInfoPresent = 1;
		dListInit(&(admRequest->destinationInfo));
		alias = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
		memset(alias,0,sizeof(H225AliasAddress));
		if(m_nDestStrType == 1)	//目标字串是号码
		{
			alias->t = T_H225AliasAddress_dialedDigits;
			alias->u.dialedDigits = LPCTSTR(m_strCalled);
		}
		else	//目标字串是账户名称
		{
			alias->t = T_H225AliasAddress_h323_ID;
			int nCount = m_strCalled.GetLength();
			alias->u.h323_ID.nchars = nCount;
			alias->u.h323_ID.data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,sizeof(ASN116BITCHAR) * nCount);
			memset(alias->u.h323_ID.data,0,sizeof(ASN116BITCHAR) * nCount);
			for(int i = 0; i < nCount; i++)	//这里需要进一步转换成16进制吗?
			   alias->u.h323_ID.data[i] = (ASN116BITCHAR)m_strCalled.GetAt(i);
		}
	    dListAppend(pctxt,&(admRequest->destinationInfo),alias);
		
		//srcInfo
		dListInit(&(admRequest->srcInfo));
		if(m_bNumber)
		{
			Alias1 = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
			memset(Alias1,0,sizeof(H225AliasAddress));
			Alias1->t = T_H225AliasAddress_dialedDigits;
			Alias1->u.dialedDigits = LPCTSTR(m_strNumber);
			dListAppend(pctxt,&(admRequest->srcInfo),Alias1);
		}
		if(m_bName)
		{
			Alias2 = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
			memset(Alias2,0,sizeof(H225AliasAddress));
			Alias2->t = T_H225AliasAddress_h323_ID;
			int nCount = m_strName.GetLength();
			Alias2->u.h323_ID.data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,sizeof(ASN116BITCHAR) * nCount);
			for(int i = 0; i < nCount; i++)
				Alias2->u.h323_ID.data[i] = (ASN116BITCHAR)m_strName.GetAt(i);
			Alias2->u.h323_ID.nchars = nCount;
			dListAppend(pctxt,&(admRequest->srcInfo),Alias2);
		}

		//call reference
		myContext->callReference = ooGenerateCallReference();

		//conference ID
		ooGenerateGUID(myContext->conferenceId.data);
		myContext->conferenceId.numocts = 16;

		//callIdentifier
		ooGenerateGUID(myContext->callIdentifier.guid.data);
		myContext->callIdentifier.guid.numocts = 16;
	}
	else	//作为被叫方
	{
		//destination alias
		admRequest->m.destinationInfoPresent = 1;
		dListInit(&(admRequest->destinationInfo));
		if(m_bNumber)
		{
			Alias1 = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
			memset(Alias1,0,sizeof(H225AliasAddress));
			Alias1->t = T_H225AliasAddress_dialedDigits;
			Alias1->u.dialedDigits = LPCTSTR(m_strNumber);
			dListAppend(pctxt,&(admRequest->destinationInfo),Alias1);
		}
		if(m_bName)
		{
			Alias2 = (H225AliasAddress*)ASN1MALLOC(pctxt,sizeof(H225AliasAddress));
			memset(Alias2,0,sizeof(H225AliasAddress));
			Alias2->t = T_H225AliasAddress_h323_ID;
			int nCount = m_strName.GetLength();
			Alias2->u.h323_ID.data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,sizeof(ASN116BITCHAR) * nCount);
			for(int i = 0; i < nCount; i++)
				Alias2->u.h323_ID.data[i] = (ASN116BITCHAR)m_strName.GetAt(i);
			Alias2->u.h323_ID.nchars = nCount;
			dListAppend(pctxt,&(admRequest->destinationInfo),Alias2);
		}

		//destination signaling address
		admRequest->m.destCallSignalAddressPresent = 1;
		admRequest->destCallSignalAddress.t = T_H225TransportAddress_ipAddress;
		IpAddr = (H225TransportAddress_ipAddress*)ASN1MALLOC(pctxt,sizeof(H225TransportAddress_ipAddress));
		memset(IpAddr,0,sizeof(H225TransportAddress_ipAddress));
		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",&IpAddr->ip.data[0],&IpAddr->ip.data[1], &IpAddr->ip.data[2],
			&IpAddr->ip.data[3]);
		IpAddr->ip.numocts = 4;
		IpAddr->port = 1720;
		admRequest->destCallSignalAddress.u.ipAddress = IpAddr;
	}

	admRequest->callReferenceValue = myContext->callReference;

	admRequest->bandWidth = 1;
	myContext->callReference = ooGenerateCallReference();
	admRequest->callReferenceValue = myContext->callReference;
	
	admRequest->conferenceID.numocts = myContext->conferenceId.numocts;
	memcpy(admRequest->conferenceID.data,myContext->conferenceId.data,myContext->conferenceId.numocts);

	admRequest->activeMC = FALSE;
	admRequest->answerCall = FALSE;
	admRequest->canMapAlias = FALSE;
	admRequest->m.canMapAliasPresent = TRUE;

	admRequest->m.callIdentifierPresent = TRUE;
	admRequest->callIdentifier.guid.numocts = myContext->callIdentifier.guid.numocts;
	memcpy(admRequest->callIdentifier.guid.data,myContext->callIdentifier.guid.data,
		myContext->callIdentifier.guid.numocts);

	admRequest->willSupplyUUIEs = FALSE;
	admRequest->m.willSupplyUUIEsPresent = TRUE;

	ooSendRasMsg(myContext);
	OOTRACEINFO2(myContext, "Sending admission request message");
}
Ejemplo n.º 2
0
void CDlg_H323::UnregistrationRequest()
{
	H225UnregistrationRequest *UnregRequest;
	OOCTXT *pctxt;
	H225TransportAddress *CallSignalAddress;
	H225TransportAddress_ipAddress *IpAddr1;
	int addr_seg1,addr_seg2,addr_seg3,addr_seg4;
	char hexIp[20];
	H225AliasAddress *alias1,*alias2;
	int ret;
	int iCharNum;

	ret = ooCreateRasMessage(myContext,T_H225RasMessage_unregistrationRequest);
	if(ret == OO_FAILED)
	{
		OOTRACEERR2(myContext,"Error:Failed to create Ras message");
		return;
	}
	myContext->outgoingRas->msgType = OOUnregistrationRequest;
	UnregRequest = myContext->outgoingRas->RasMsg.u.unregistrationRequest;
	pctxt = myContext->outgoingRas->pctxt;
	
	//requestSeqNum
	UnregRequest->requestSeqNum = (myContext->seqNumber++) % 65536;

	//CallSignalAddress
	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));
	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(&(UnregRequest->callSignalAddress));
	dListAppend(pctxt,&(UnregRequest->callSignalAddress),CallSignalAddress);	

	//endpointAlias
	if(m_bName || m_bNumber)
	{
		UnregRequest->m.endpointAliasPresent = 1;
		dListInit(&(UnregRequest->endpointAlias));
	}
	else
		UnregRequest->m.endpointAliasPresent = 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++)
		   str->data[i] = (ASN116BITCHAR)m_strName.GetAt(i);
	   dListAppend(pctxt,&(UnregRequest->endpointAlias),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,&(UnregRequest->endpointAlias),alias2);
	}	

	//endpointIdentifier
	UnregRequest->m.endpointIdentifierPresent = TRUE;
	iCharNum = UnregRequest->endpointIdentifier.nchars = myContext->epIdentifier.nchars;
	UnregRequest->endpointIdentifier.data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,iCharNum * sizeof(ASN116BITCHAR));
	memcpy(UnregRequest->endpointIdentifier.data,myContext->epIdentifier.data,iCharNum * sizeof(ASN116BITCHAR));

	ooSendRasMsg(myContext);
	OOTRACEINFO2(myContext, "Sending registration request message");	
}
Ejemplo n.º 3
0
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");
}
Ejemplo n.º 4
0
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消息则退出
	}
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
OOH323CallData* ooCreateCall(char* type, char*callToken)
{
   OOH323CallData *call=NULL;
   OOCTXT *pctxt=NULL;

   pctxt = newContext();
   if(!pctxt)
   {
      OOTRACEERR1("ERROR:Failed to create OOCTXT for new call\n");
      return NULL;
   }
   call = (OOH323CallData*)memAlloc(pctxt, sizeof(OOH323CallData));
   if(!call)
   {
      OOTRACEERR1("ERROR:Memory - ooCreateCall - call\n");
      return NULL;
   } 
   /*   memset(call, 0, sizeof(OOH323CallData));*/
   call->pctxt = pctxt;
   call->callMode = gH323ep.callMode;
   sprintf(call->callToken, "%s", callToken);
   sprintf(call->callType, "%s", type);
   call->callReference = 0;
   if(gH323ep.callerid) {
     strncpy(call->ourCallerId, gH323ep.callerid, sizeof(call->ourCallerId)-1);
     call->ourCallerId[sizeof(call->ourCallerId)-1] = '\0';
   }
   else {
      call->ourCallerId[0] = '\0';
   }
   
   memset(&call->callIdentifier, 0, sizeof(H225CallIdentifier));
   memset(&call->confIdentifier, 0, sizeof(H225ConferenceIdentifier));

   call->flags = 0;
   if (OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING))
      OO_SETFLAG (call->flags, OO_M_TUNNELING);

   if(gH323ep.gkClient)
   {
      if(OO_TESTFLAG(gH323ep.flags, OO_M_GKROUTED))
      {
         OO_SETFLAG(call->flags, OO_M_GKROUTED);
      }
   }

   if (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART))
      OO_SETFLAG (call->flags, OO_M_FASTSTART);

   if (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN))
      OO_SETFLAG (call->flags, OO_M_MEDIAWAITFORCONN);
   
   call->callState = OO_CALL_CREATED;
   call->callEndReason = OO_REASON_UNKNOWN;
   call->pCallFwdData = NULL;

   if(!strcmp(call->callType, "incoming"))
   {
      call->callingPartyNumber = NULL;
   }
   else{      
      if(ooUtilsIsStrEmpty(gH323ep.callingPartyNumber))
      {
         call->callingPartyNumber = NULL;
      }
      else{
         call->callingPartyNumber = (char*) memAlloc(call->pctxt, 
                                         strlen(gH323ep.callingPartyNumber)+1);
         if(call->callingPartyNumber)
         {
            strcpy(call->callingPartyNumber, gH323ep.callingPartyNumber);
         }
         else{
            OOTRACEERR3("Error:Memory - ooCreateCall - callingPartyNumber"
                        ".(%s, %s)\n", call->callType, call->callToken);
            freeContext(pctxt);
            return NULL;
         }
      }
   }

   call->calledPartyNumber = NULL;
   call->h245ConnectionAttempts = 0;
   call->h245SessionState = OO_H245SESSION_IDLE;
   call->dtmfmode = gH323ep.dtmfmode;
   call->mediaInfo = NULL;
   strcpy(call->localIP, gH323ep.signallingIP);
   call->pH225Channel = NULL;
   call->pH245Channel = NULL;
   call->h245listener = NULL;
   call->h245listenport = NULL;
   call->remoteIP[0] = '\0';
   call->remotePort = 0;
   call->remoteH245Port = 0;
   call->remoteDisplayName = NULL;
   call->remoteAliases = NULL;
   call->ourAliases = NULL;
   call->masterSlaveState = OO_MasterSlave_Idle;
   call->statusDeterminationNumber = 0;
   call->localTermCapState = OO_LocalTermCapExchange_Idle;
   call->remoteTermCapState = OO_RemoteTermCapExchange_Idle; 
   call->ourCaps = NULL;
   call->remoteCaps = NULL;
   call->jointCaps = NULL;
   dListInit(&call->remoteFastStartOLCs);
   call->remoteTermCapSeqNo =0;
   call->localTermCapSeqNo = 0;
   memcpy(&call->capPrefs, &gH323ep.capPrefs, sizeof(OOCapPrefs));    
   call->logicalChans = NULL;
   call->noOfLogicalChannels = 0;
   call->logicalChanNoBase = 1001;
   call->logicalChanNoMax = 1100;
   call->logicalChanNoCur = 1001;
   call->nextSessionID = 4; /* 1,2,3 are reserved for audio, video and data */
   dListInit(&call->timerList);
   call->msdRetries = 0;
   call->pFastStartRes = NULL;
   call->usrData = NULL;
   OOTRACEINFO3("Created a new call (%s, %s)\n", call->callType, 
                 call->callToken);
   /* Add new call to calllist */
   ooAddCallToList (call);
   if(gH323ep.h323Callbacks.onNewCallCreated)
     gH323ep.h323Callbacks.onNewCallCreated(call);
   return call;
}