Example #1
0
OOH323CallData* ooFindCallByToken(char *callToken)
{
   OOH323CallData *call;
   if(!callToken)
   {
      OOTRACEERR1("ERROR:Invalid call token passed - ooFindCallByToken\n");
      return NULL;
   }
   if(!gH323ep.callList)
   {
      OOTRACEERR1("ERROR: Empty calllist - ooFindCallByToken failed\n");
      return NULL;
   }
   call = gH323ep.callList;
   while(call)
   {
      if(!strcmp(call->callToken, callToken))
         break;
      else
         call = call->next;
   }
   
   if(!call)
   {
      OOTRACEERR2("ERROR:Call with token %s not found\n", callToken);
      return NULL;
   }
   return call;
}
Example #2
0
int ooSocketBind (OOSOCKET socket, OOIPADDR addr, int port) 
{
   struct ast_sockaddr m_addr;

   memset(&m_addr, 0, sizeof(m_addr));


   if (socket == OOSOCKET_INVALID)
   { 
      OOTRACEERR1("Error:Invalid socket passed to bind\n");
      return ASN_E_INVSOCKET;
   }

   ast_sockaddr_copy(&m_addr, &addr);
   ast_sockaddr_set_port(&m_addr, port);

   if (ast_bind(socket, &m_addr) < 0) {
      if (errno != EADDRINUSE) {
      	perror ("bind");
      	OOTRACEERR2("Error:Bind failed, error: %d\n", errno);
      }
      return ASN_E_INVSOCKET;
   }

   return ASN_OK;
}
Example #3
0
int ooSocketBind (OOSOCKET socket, OOIPADDR addr, int port) 
{
   struct sockaddr_in m_addr;

   if (socket == OOSOCKET_INVALID)
   { 
      OOTRACEERR1("Error:Invalid socket passed to bind\n");
      return ASN_E_INVSOCKET;
   }

   memset (&m_addr, 0, sizeof (m_addr));
   m_addr.sin_family = AF_INET;
   m_addr.sin_addr.s_addr = (addr == 0) ? INADDR_ANY : htonl (addr);
   m_addr.sin_port = htons ((unsigned short)port);

   if (bind (socket, (struct sockaddr *) (void*) &m_addr,
                     sizeof (m_addr)) == -1)
   {
      if (errno != EADDRINUSE) {
      	perror ("bind");
      	OOTRACEERR2("Error:Bind failed, error: %d\n", errno);
      }
      return ASN_E_INVSOCKET;
   }

   return ASN_OK;
}
Example #4
0
int ooRTPShutDown(struct ooAppContext* context)
{
   int ret = 0;
   ret = ooCloseTransmitRTPChannel(context);
   if(ret != 0)
   {
      OOTRACEERR2(context, "ERROR: Closing Transmit RTP Channel");
      return OO_FAILED;
   }
   ret = ooCloseReceiveRTPChannel(context);
   if(ret != 0)
   {
      OOTRACEERR2(context, "ERROR: Closing Receive RTP Channel");
      return OO_FAILED;
   }
   return OO_OK;
}
Example #5
0
void CDlg_H323::DisengageRequest()
{
	int iCharNum;
	int ret;

	H225DisengageRequest *DisengageRequest;
	OOCTXT *pctxt;

	//build and send RAS disengageRequest message
	ret = ooCreateRasMessage(myContext,T_H225RasMessage_disengageRequest);
	if(ret == OO_FAILED)
	{
	  OOTRACEERR2(myContext,"Error:Failed to create Ras message");
	  return;
	}
	myContext->outgoingRas->msgType = OODisengageRequest;
	pctxt = myContext->outgoingRas->pctxt;
	DisengageRequest = myContext->outgoingRas->RasMsg.u.disengageRequest;
	DisengageRequest->requestSeqNum = (myContext->seqNumber++) % 65536;
	
	//endpointIdentifier
	iCharNum = DisengageRequest->endpointIdentifier.nchars = myContext->epIdentifier.nchars;
	DisengageRequest->endpointIdentifier.data = (ASN116BITCHAR*)ASN1MALLOC(pctxt,iCharNum * sizeof(ASN116BITCHAR));
	memcpy(DisengageRequest->endpointIdentifier.data,myContext->epIdentifier.data,iCharNum * sizeof(ASN116BITCHAR));

	//ConferenceID
	DisengageRequest->conferenceID.numocts = myContext->conferenceId.numocts;
	memcpy(DisengageRequest->conferenceID.data,myContext->conferenceId.data,myContext->conferenceId.numocts);
	
	//CallReferenceValue
	DisengageRequest->callReferenceValue = myContext->callReference;
	DisengageRequest->disengageReason.t = T_H225DisengageReason_normalDrop;

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

	ooSendRasMsg(myContext);
	OOTRACEINFO2(myContext, "Sending disengage request message");
}
Example #6
0
OOH323CallData* ooFindCallByToken(const char *callToken)
{
   OOH323CallData *call;
   if(!callToken)
   {
      OOTRACEERR1("ERROR:Invalid call token passed - ooFindCallByToken\n");
      return NULL;
   }

   ast_mutex_lock(&callListLock);

   if(!gH323ep.callList)
   {
      OOTRACEERR1("ERROR: Empty calllist - ooFindCallByToken failed\n");
      ast_mutex_unlock(&callListLock);
      return NULL;
   }
   call = gH323ep.callList;
   while(call)
   {
      if(!strcmp(call->callToken, callToken))
         break;
      else
         call = call->next;
   }
   
   if(!call)
   {
      OOTRACEERR2("ERROR:Call with token %s not found\n", callToken);
      ast_mutex_unlock(&callListLock);
      return NULL;
   }

   ast_mutex_unlock(&callListLock);

   OOTRACEINFO3("INFO: FinCall returned %lx for call: %s\n", call, callToken);

   return call;
}
Example #7
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");
}
Example #8
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");	
}
Example #9
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");
}
Example #10
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消息则退出
	}
}
Example #11
0
int ooSocketGetInterfaceList(OOCTXT *pctxt, OOInterface **ifList)
{
   OOSOCKET sock;
   struct ifconf ifc;
   int ifNum;
   OOInterface *pIf=NULL;
   struct sockaddr_in sin;

   OOTRACEDBGA1("Retrieving local interfaces\n");
   if(ooSocketCreateUDP(&sock, 4)!= ASN_OK)
   {
      OOTRACEERR1("Error:Failed to create udp socket - "
                  "ooSocketGetInterfaceList\n");   
      return -1;
   }
#ifdef SIOCGIFNUM
   if(ioctl(sock, SIOCGIFNUM, &ifNum) >= 0)
   {
      OOTRACEERR1("Error: ioctl for ifNum failed\n");
      return -1;
   }
#else
   ifNum = 50;
#endif
 
   ifc.ifc_len = ifNum * sizeof(struct ifreq);
   ifc.ifc_req = (struct ifreq *)memAlloc(pctxt, ifNum *sizeof(struct ifreq));
   if(!ifc.ifc_req)
   {
      OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - ifc.ifc_req\n");
      return -1;
   }

   if (ioctl(sock, SIOCGIFCONF, &ifc) >= 0) {
      void * ifEndList = (char *)ifc.ifc_req + ifc.ifc_len;
      struct ifreq *ifName;
      struct ifreq ifReq;
      int flags;
      for (ifName = ifc.ifc_req; (void*)ifName < ifEndList; ifName++) {
         char *pName=NULL;
         char addr[50];
#ifdef ifr_netmask
	char mask[50];
#endif
         
         pIf = (struct OOInterface*)memAlloc(pctxt, sizeof(struct OOInterface));
         pName = (char*)memAlloc(pctxt, strlen(ifName->ifr_name)+1);
         if(!pIf)
         {
            OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - "
                        "pIf/pName\n");
            return -1;
         }
         OOTRACEDBGA2("\tInterface name: %s\n", ifName->ifr_name);
         
         
         strcpy(ifReq.ifr_name, ifName->ifr_name);
         strcpy(pName, ifName->ifr_name);
         pIf->name = pName;

         /* Check whether the interface is up*/
         if (ioctl(sock, SIOCGIFFLAGS, &ifReq) < 0) {
            OOTRACEERR2("Error:Unable to determine status of interface %s\n", 
                        pName);
            memFreePtr(pctxt, pIf->name);
            memFreePtr(pctxt, pIf);
            continue;
         }
         flags = ifReq.ifr_flags;
         if (!(flags & IFF_UP)) {
            OOTRACEWARN2("Warn:Interface %s is not up\n", pName);
            memFreePtr(pctxt, pIf->name);
            memFreePtr(pctxt, pIf);
            continue;
         }

         /* Retrieve interface address */
         if (ioctl(sock, SIOCGIFADDR, &ifReq) < 0) 
         {
            OOTRACEWARN2("Warn:Unable to determine address of interface %s\n", 
                          pName);
            memFreePtr(pctxt, pIf->name);
            memFreePtr(pctxt, pIf);
            continue;
         }
	 memcpy(&sin, &ifReq.ifr_addr, sizeof(struct sockaddr_in));
	 strcpy(addr, ast_inet_ntoa(sin.sin_addr));
         OOTRACEDBGA2("\tIP address is %s\n", addr);
         pIf->addr = (char*)memAlloc(pctxt, strlen(addr)+1);
         if(!pIf->addr)
         {
            OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - "
                        "pIf->addr\n");
            memFreePtr(pctxt, pIf->name);
            memFreePtr(pctxt, pIf);
            return -1;
         }
         strcpy(pIf->addr, addr);
         
#ifdef ifr_netmask
         if (ioctl(sock, SIOCGIFNETMASK, &ifReq) < 0) 
         {
            OOTRACEWARN2("Warn:Unable to determine mask for interface %s\n", 
                          pName);
            memFreePtr(pctxt, pIf->name);
            memFreePtr(pctxt, pIf->addr);
            memFreePtr(pctxt, pIf);
            continue;
         }
	 memcpy(&sin, &ifReq.ifr_netmask, sizeof(struct sockaddr_in));
	 strcpy(mask, ast_inet_ntoa(sin.sin_addr));
         OOTRACEDBGA2("\tMask is %s\n", mask);
         pIf->mask = (char*)memAlloc(pctxt, strlen(mask)+1);
         if(!pIf->mask)
         {
            OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - "
                        "pIf->mask\n");
            memFreePtr(pctxt, pIf->name);
            memFreePtr(pctxt, pIf->addr);
            memFreePtr(pctxt, pIf);
            return -1;
         }
         strcpy(pIf->mask, mask);
#endif
         pIf->next = NULL;

         /* Add to the list */
         if(!*ifList)
         {
            *ifList = pIf;
            pIf = NULL;
         }
         else{
            pIf->next = *ifList;
            *ifList = pIf;
            pIf=NULL;
         }
/*
#if defined(OO_FREEBSD) || defined(OO_OPENBSD) || defined(OO_NETBSD) || defined(OO_MACOSX) || defined(OO_VXWORKS) || defined(OO_RTEMS) || defined(OO_QNX)
#ifndef _SIZEOF_ADDR_IFREQ
#define _SIZEOF_ADDR_IFREQ(ifr) \
        ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
         (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
          (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
#endif
      ifName = (struct ifreq *)((char *)ifName + _SIZEOF_ADDR_IFREQ(*ifName));
#else
      ifName++;
*/
      }

   }  
   return ASN_OK;
}
Example #12
0
int ooLoadSndRTPPlugin(struct ooAppContext* context, char * name)
{
   media = 0;
   /* Load the plugin library */
#ifdef _WIN32
   media = LoadLibrary(name);
#else
   media = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
#endif
   if(media == 0)
   {
      OOTRACEERR3(context, "ERROR:Failed to load plug-in library %s", name);
      return OO_FAILED;
   }
   
   /* Retrieve addreses of the plugin interface functions */
#ifdef _WIN32
   FuncPtr_InitializePlugin = (MediaAPI_InitializePlugin) GetProcAddress(media,
                                                         "ooInitializePlugin");
#else
   FuncPtr_InitializePlugin = (MediaAPI_InitializePlugin) dlsym(media, 
                                                         "ooInitializePlugin");
#endif
   if(FuncPtr_InitializePlugin == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooInitializePlugin");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_CreateTxRTPChan = (MediaAPI_CreateTxRTPChan) GetProcAddress(media, 
                                                 "ooCreateTransmitRTPChannel");
#else
   FuncPtr_CreateTxRTPChan = (MediaAPI_CreateTxRTPChan) dlsym(media, 
                                                 "ooCreateTransmitRTPChannel");
#endif
   if(FuncPtr_CreateTxRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCreateTransmitRTPChannel");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_CloseTxRTPChan = (MediaAPI_CloseTxRTPChan) GetProcAddress(media, 
                                                 "ooCloseTransmitRTPChannel");
#else
   FuncPtr_CloseTxRTPChan = (MediaAPI_CloseTxRTPChan) dlsym(media, 
                                                 "ooCloseTransmitRTPChannel");
#endif
   if(FuncPtr_CloseTxRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCloseTransmitRTPChannel");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_CreateRecvRTPChan = (MediaAPI_CreateRecvRTPChan) GetProcAddress
                                          (media, "ooCreateReceiveRTPChannel");
#else
   FuncPtr_CreateRecvRTPChan = (MediaAPI_CreateRecvRTPChan) dlsym(media, 
                                                 "ooCreateReceiveRTPChannel");
#endif
   if(FuncPtr_CreateRecvRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCreateReceiveRTPChannel");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_CloseRecvRTPChan = (MediaAPI_CloseRecvRTPChan)GetProcAddress(media, 
                                                 "ooCloseReceiveRTPChannel");
#else
   FuncPtr_CloseRecvRTPChan = (MediaAPI_CloseRecvRTPChan) dlsym(media, 
                                                 "ooCloseReceiveRTPChannel");
#endif
   if(FuncPtr_CloseRecvRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCloseReceiveRTPChannel");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StartTxWaveFile = (MediaAPI_StartTxWaveFile) GetProcAddress(media, 
                                                  "ooStartTransmitWaveFile");
#else
   FuncPtr_StartTxWaveFile = (MediaAPI_StartTxWaveFile) dlsym(media, 
                                                 "ooStartTransmitWaveFile");
#endif
   if(FuncPtr_StartTxWaveFile == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStartTransmitWaveFile");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_StopTxWaveFile = (MediaAPI_StopTxWaveFile) GetProcAddress(media, 
                                                  "ooStopTransmitWaveFile");
#else
   FuncPtr_StopTxWaveFile = (MediaAPI_StopTxWaveFile) dlsym(media, 
                                                 "ooStopTransmitWaveFile");
#endif

   if(FuncPtr_StopTxWaveFile == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStopTransmitWaveFile");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StartTxMic = (MediaAPI_StartTxMic) GetProcAddress(media, 
                                                  "ooStartTransmitMic");
#else
   FuncPtr_StartTxMic = (MediaAPI_StartTxMic) dlsym(media, 
                                                 "ooStartTransmitMic");
#endif
   if(FuncPtr_StartTxMic == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStartTransmitMic");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_StopTxMic = (MediaAPI_StopTxMic) GetProcAddress(media, 
                                                  "ooStopTransmitMic");
#else
   FuncPtr_StopTxMic = (MediaAPI_StopTxMic) dlsym(media, 
                                                 "ooStopTransmitMic");
#endif
   if(FuncPtr_StopTxMic == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStopTransmitMic");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StartRecvAndPlayback =(MediaAPI_StartRecvAndPlayback)GetProcAddress
                                     (media, "ooStartReceiveAudioAndPlayback");
#else
   FuncPtr_StartRecvAndPlayback = (MediaAPI_StartRecvAndPlayback) dlsym(media, 
                                             "ooStartReceiveAudioAndPlayback");
#endif
   if(FuncPtr_StartRecvAndPlayback == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStartReceiveAudioAndPlayback");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StopRecvAndPlayback = (MediaAPI_StopRecvAndPlayback) GetProcAddress
                                      (media, "ooStopReceiveAudioAndPlayback");
#else
   FuncPtr_StopRecvAndPlayback = (MediaAPI_StopRecvAndPlayback) dlsym(media, 
                                              "ooStopReceiveAudioAndPlayback");
#endif

   if(FuncPtr_StopRecvAndPlayback == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStopRecvAndPlayback");
      return OO_FAILED;
   }
   
   /* Initialize the plugin */
   FuncPtr_InitializePlugin();

   return OO_OK;
}
Example #13
0
int ooReadAndProcessStackCommand()
{
   OOH323CallData *pCall = NULL;   
   unsigned char buffer[MAXMSGLEN];
   int i, recvLen = 0;
   OOStackCommand cmd;
   memset(&cmd, 0, sizeof(OOStackCommand));
   ast_mutex_lock(&gCmdChanLock);
   recvLen = read(gH323ep.cmdSock, buffer, MAXMSGLEN);
   ast_mutex_unlock(&gCmdChanLock);
   if(recvLen <= 0)
   {
      OOTRACEERR1("Error:Failed to read CMD message\n");
      return OO_FAILED;
   }

   for(i=0; (int)(i+sizeof(OOStackCommand)) <= recvLen; i += sizeof(OOStackCommand))
   {
      memcpy(&cmd, buffer+i, sizeof(OOStackCommand));

      if(cmd.type == OO_CMD_NOOP)
         continue;

      if(gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered && cmd.type != OO_CMD_STOPMONITOR)
      {
         OOTRACEINFO1("Ignoring stack command as Gk Client is not registered"
                      " yet\n");
      }
      else {
         switch(cmd.type) {
            case OO_CMD_MAKECALL: 
               OOTRACEINFO2("Processing MakeCall command %s\n", 
                                    (char*)cmd.param2);
 
               ooH323NewCall ((char*)cmd.param2);
               break;

            case OO_CMD_MANUALPROGRESS:
                pCall = ooFindCallByToken((char*)cmd.param1);
                if(!pCall) {
                   OOTRACEINFO2("Call \"%s\" does not exist\n",
                                (char*)cmd.param1);
                   OOTRACEINFO1("Call migth be cleared/closed\n");
                }
                else {
                     ooSendProgress(ooFindCallByToken((char*)cmd.param1));
                }
               break;

            case OO_CMD_MANUALRINGBACK:
               if(OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK))
               {
                  pCall = ooFindCallByToken((char*)cmd.param1);
                  if(!pCall) {
                     OOTRACEINFO2("Call \"%s\" does not exist\n",
                                  (char*)cmd.param1);
                     OOTRACEINFO1("Call migth be cleared/closed\n");
                  }
                  else {
                     ooSendAlerting(ooFindCallByToken((char*)cmd.param1));
                     if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) {
                        ooSendConnect(ooFindCallByToken((char*)cmd.param1));
                     }
                  }
               }
               break;
 
            case OO_CMD_ANSCALL:
               pCall = ooFindCallByToken((char*)cmd.param1);
               if(!pCall) {
                  OOTRACEINFO2("Call \"%s\" does not exist\n",
                               (char*)cmd.param1);
                  OOTRACEINFO1("Call might be cleared/closed\n");
               }
               else {
                  OOTRACEINFO2("Processing Answer Call command for %s\n",
                               (char*)cmd.param1);
                  ooSendConnect(pCall);
               }
               break;

            case OO_CMD_FWDCALL:
               OOTRACEINFO3("Forwarding call %s to %s\n", (char*)cmd.param1,
                                                          (char*)cmd.param2);
               ooH323ForwardCall((char*)cmd.param1, (char*)cmd.param2);
               break;

            case OO_CMD_HANGCALL: 
               OOTRACEINFO3("Processing Hang call command %s with q931 cause %d\n", 
                             (char*)cmd.param1, *(int *) cmd.param3);
               ooH323HangCall((char*)cmd.param1, 
                              *(OOCallClearReason*)cmd.param2, *(int *) cmd.param3);
               break;
          
            case OO_CMD_SENDDIGIT:
               pCall = ooFindCallByToken((char*)cmd.param1);
               if(!pCall) {
                  OOTRACEERR2("ERROR:Invalid calltoken %s\n",
                              (char*)cmd.param1);
                  break;
               }
               if(pCall->jointDtmfMode & OO_CAP_DTMF_H245_alphanumeric) {
                  ooSendH245UserInputIndication_alphanumeric(
                     pCall, (const char*)cmd.param2);
               }
               else if(pCall->jointDtmfMode & OO_CAP_DTMF_H245_signal) {
                  ooSendH245UserInputIndication_signal(
                     pCall, (const char*)cmd.param2);
               }
               else {
                  ooQ931SendDTMFAsKeyPadIE(pCall, (const char*)cmd.param2);
               }

               break;

            case OO_CMD_STOPMONITOR: 
               OOTRACEINFO1("Processing StopMonitor command\n");
               ooStopMonitorCalls();
               break;

            default: OOTRACEERR1("ERROR:Unknown command\n");
         }
      }
      if(cmd.param1) free(cmd.param1);
      if(cmd.param2) free(cmd.param2);
      if(cmd.param3) free(cmd.param3);
   }


   return OO_OK;
}