📄 cmcallhighlevel.c
字号:
/***********************************************************************
Copyright (c) 2002 RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Ltd.. No part of this document may be reproduced in any
form whatsoever without written prior approval by RADVISION Ltd..
RADVISION Ltd. reserve the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
***********************************************************************/
#include "rvinternal.h"
#include <stdlib.h>
#include "rvstdio.h"
#include "cm.h"
#include "stkutils.h"
#include "cmdebprn.h"
#include "q931asn1.h"
#include "cmAutoRasCall.h"
#include "cmCall.h"
#include "strutils.h"
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************
* stringToCoreAddress
* purpose: Convert a string into an core address
* input : string - String to convert
* output : addr - Address struct constructed from string
* return : RV_OK on success, or negative value on failure
************************************************************************/
static RvStatus stringToCoreAddress(IN RvChar* string, OUT RvAddress* addr)
{
RvStatus res;
RvChar* colonPos;
RvAddressConstruct(addr, RV_ADDRESS_TYPE_IPV4);
colonPos = (char*)strchr(string, ':');
if (colonPos != NULL)
*colonPos = 0;
if (RvAddressSetString(addr, string) != NULL)
res = RV_OK;
else
res = RV_ERROR_UNKNOWN;
if (colonPos != NULL)
{
*colonPos = ':';
if (res == RV_OK)
{
/* Handle port number as well... */
RvAddressSetIpPort(addr, (RvUint16)atoi(colonPos+1));
}
}
RvAddressDestruct(addr);
return res;
}
/************************************************************************
* insertAlias
* purpose: Convert a string into an alias struct
* input : numPtr - Pointer to the string to convert
* output : alias - Alias representaiton of the string
* bmpStr - String value of the alias
* return : Non-negative value on success
* Negative value on failure
************************************************************************/
static int insertAlias(IN char **numPtr, OUT cmAlias * alias, OUT char* bmpStr)
{
RvChar* ptr;
if (!strncmp("TEL:",*numPtr,4))
{
/* e164 alias type */
*numPtr+=4;
alias->string=*numPtr;
alias->length=(RvUint16)strlen(alias->string);
alias->type=cmAliasTypeE164;
}
else if (!strncmp("URL:",*numPtr,4))
{
/* URL */
*numPtr+=4;
alias->string=*numPtr;
alias->length=(RvUint16)strlen(alias->string);
alias->type=cmAliasTypeURLID;
}
else if (!strncmp("EMAIL:",*numPtr,6))
{
/* eMail */
*numPtr+=6;
alias->string=*numPtr;
alias->length=(RvUint16)strlen(alias->string);
alias->type=cmAliasTypeEMailID;
}
else if (!strncmp("PN:",*numPtr,3))
{
/* partyNumber */
*numPtr+=3;
alias->string=*numPtr;
alias->type=cmAliasTypePartyNumber;
alias->pnType=(cmPartyNumberType )cmPartyNumberPublicUnknown;
if ((ptr=(RvChar*)strchr(*numPtr,'$'))!=NULL)
{
switch(ptr[1])
{
case 'P':
switch(ptr[2])
{
case 'U':
switch(ptr[3])
{
case 'U':alias->pnType=cmPartyNumberPublicUnknown;break;
case 'I':alias->pnType=cmPartyNumberPublicInternationalNumber;break;
case 'N':
switch(ptr[4])
{
case 0:alias->pnType=cmPartyNumberPublicNationalNumber;break;
case 'S':alias->pnType=cmPartyNumberPublicNetworkSpecificNumber;break;
}
break;
case 'S':alias->pnType=cmPartyNumberPublicSubscriberNumber;break;
case 'A':alias->pnType=cmPartyNumberPublicAbbreviatedNumber;break;
}
break;
case 'R':
switch(ptr[3])
{
case 'U':alias->pnType=cmPartyNumberPrivateUnknown;break;
case 'L':
switch(ptr[4])
{
case '2':alias->pnType=cmPartyNumberPrivateLevel2RegionalNumber;break;
case '1':alias->pnType=cmPartyNumberPrivateLevel1RegionalNumber;break;
case 0:alias->pnType=cmPartyNumberPrivateLocalNumber;break;
}
break;
case 'P':alias->pnType=cmPartyNumberPrivatePISNSpecificNumber;break;
case 'A':alias->pnType=cmPartyNumberPrivateAbbreviatedNumber;break;
}
break;
}
break;
case 'D':alias->pnType=cmPartyNumberDataPartyNumber;break;
case 'T':alias->pnType=cmPartyNumberTelexPartyNumber;break;
case 'N':alias->pnType=cmPartyNumberNationalStandardPartyNumber;break;
}
if (alias->pnType<0)
alias->pnType=(cmPartyNumberType )atoi(ptr+1);
*ptr=0;
}
alias->length=(RvUint16)strlen(alias->string);
}
else if (!strncmp("TNAME:",*numPtr,6))
{
/* transport address */
RvAddress addr;
*numPtr+=6;
if (stringToCoreAddress(*numPtr, &addr) != RV_OK)
return RV_ERROR_UNKNOWN;
if (RvH323CoreToCmAddress(&addr, &alias->transport) != RV_OK)
return RV_ERROR_UNKNOWN;
alias->type = cmAliasTypeTransportAddress;
alias->transport;
alias->string = NULL;
alias->length = 0;
}
else if (!strncmp("NAME:",*numPtr,5))
{
/* h323ID */
*numPtr+=5;
alias->type=cmAliasTypeH323ID;
alias->length=(RvUint16)utlChr2Bmp(*numPtr, (RvUint8*)bmpStr);
alias->string=bmpStr;
}
else return RV_ERROR_UNKNOWN;
return 0;
}
/************************************************************************
* cmCallMake
* purpose: Starts a new call setup with the given parameters
* input : hsCall - Stack handle for the new call
* maxRate - Maximum rate allowed for the new call
* minRate - Minimum rate allowed for the new call.
* This parameter is not currently in use, so set it to zero (0).
* destAddress - Called party address list
* srcAddress - Calling party address list
* display - String representing display information for reporting
* to the called party
* userUser - String representing user-to-user information for reporting
* to the called party
* userUserSize- Length of the string representing user-to-user information
* to report to the called party
* output : none
* return : Non-negative value on success
* Negative value on failure
************************************************************************/
RVAPI
int RVCALLCONV cmCallMake(
IN HCALL hsCall,
IN RvUint32 maxRate,
IN RvUint32 minRate,
IN char* destAddress,
IN char* srcAddress,
IN char* display,
IN char* userUser,
IN int userUserSize)
{
RvBool fta,eta,wasTA=RV_FALSE,wasETA=RV_FALSE,firstETA=RV_FALSE;
HAPP hApp;
RvChar bmpStr[512];
RvChar destA[512];
RvChar srcA[512];
RvChar* numPtr=NULL;
RvChar* nextPtr=NULL;
int id=0,i, ret;
RvBool namedID=RV_TRUE;
RvChar delimiter;
hApp=cmGetAHandle((HPROTOCOL)hsCall);
if (!hApp || !hsCall) return RV_ERROR_UNKNOWN;
cmiAPIEnter(hApp,"cmCallMake(hsCall=0x%p,maxRate=%ld,minRate=%ld,destAddr=%.100s,srcAddr=%.100s,display=%.100s,userUser=%.100s,userUserSize=%d)",
hsCall,maxRate,minRate,nprn(destAddress),nprn(srcAddress),nprn(display),nprn(userUser),userUserSize);
delimiter=cmGetDelimiter(hApp);
/* Set the source addresses */
if (srcAddress && srcAddress[0])
{
strncpy(srcA,srcAddress,sizeof(srcA));
numPtr=srcA;
while(numPtr)
{
int iDelimiter = delimiter;
nextPtr=(RvChar*) strchr(numPtr,iDelimiter);
{
cmAlias alias;
while(isspace((int)*numPtr)) numPtr++;
if (nextPtr)
{
*nextPtr=0;
nextPtr++;
}
if (insertAlias(&numPtr,&alias, bmpStr) >= 0)
cmCallSetParam(hsCall,cmParamSourceAddress,id++,0,(char *)&alias);
else
{
/* No specific type - take as e164 */
alias.string=numPtr;
alias.length=(RvUint16)strlen(alias.string);
alias.type=cmAliasTypeE164;
cmCallSetParam(hsCall,cmParamCallingPartyNumber,0,0,(char *)&alias);
break;
}
}
numPtr=nextPtr;
}
}
/* Set destination address parameters */
if (destAddress && destAddress[0])
{
strncpy(destA,destAddress,sizeof(destA));
numPtr=destA;
id=0;
while(numPtr&&namedID)
{
int iDelimiter = delimiter;
namedID=RV_TRUE;
fta=0;
nextPtr=(RvChar*) strchr(numPtr,iDelimiter);
{
cmAlias alias;
while(isspace((int)*numPtr)) numPtr++;
if (nextPtr)
{
*nextPtr=0;
nextPtr++;
}
if (insertAlias(&numPtr,&alias,bmpStr) >= 0)
cmCallSetParam(hsCall,cmParamDestinationAddress,id++,0,(char *)&alias);
else if (!strncmp("SUB:",numPtr,4))
{
numPtr+=4;
alias.string=numPtr;
alias.length=(RvUint16)strlen(alias.string);
alias.type=cmAliasTypeE164;
cmCallSetParam(hsCall,cmParamCalledPartySubAddress,0,0,(char *)&alias);
}
else if (!strncmp("EXT:",numPtr,4))
{
numPtr+=4;
alias.string=numPtr;
alias.length=(RvUint16)strlen(alias.string);
alias.type=cmAliasTypeE164;
cmCallSetParam(hsCall,cmParamExtension,0,0,(char *)&alias);
}
else if (!strncmp("EXTID:",numPtr,6))
{
numPtr+=6;
alias.type=cmAliasTypeH323ID;
alias.length=(RvUint16)utlChr2Bmp(numPtr, (RvUint8*)bmpStr);
alias.string=bmpStr;
cmCallSetParam(hsCall,cmParamExtension,0,0,(char *)&alias);
}
else if (!strncmp("TA:",numPtr,3) || !strncmp("ETA:",numPtr,3) || !strncmp("FTA:",numPtr,3))
{
cmTransportAddress qAddress;
RvAddress addr;
memset(&qAddress, 0, sizeof(qAddress));
fta=(strncmp("FTA:",numPtr,4)==0);
eta=(strncmp("ETA:",numPtr,4)==0);
numPtr+=3+(fta||eta);
if (stringToCoreAddress(numPtr, &addr) == RV_OK)
{
RvH323CoreToCmAddress(&addr, &qAddress);
RvAddressDestruct(&addr);
if (eta && !wasTA) firstETA=RV_TRUE;
if (eta) wasETA=RV_TRUE;
if (!eta && !fta) wasTA=RV_TRUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -