protocalapi.c
来自「mgcp协议源代码和测试程序,还有一个编译器」· C语言 代码 · 共 1,971 行 · 第 1/5 页
C
1,971 行
*
* Description : Set the HIST timer value of the stack.
*
* Input parameters : pStack - Handle of the stack
* wValue - HIST timer value
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpSackSetTimerHIST(H_STACK pStack, WORD wValue)
{
H_MGCP_TRANSAC_MANAGER pTransacMng;
Assert(pStack);
pTransacMng = (H_MGCP_TRANSAC_MANAGER)(((MGCP_STACK*)pStack)->pTransacMng);
Assert(pTransacMng);
if (pTransacMng)
{
pthread_mutex_lock(&pTransacMng->pTranMngMutex);
pTransacMng->dwTimerHIST = wValue;
pthread_mutex_unlock(&pTransacMng->pTranMngMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetMax1LookUp
*
* Description : Set the if need loop up DNS when retries reach Max1
*
* Input parameters : pStack - Handle of the stack
* bOnOff - Whether need loop up DNS flag
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetMax1LookUp(H_STACK pStack, BOOL bOnOff)
{
H_MGCP_TRANSAC_MANAGER pTransacMng;
Assert(pStack);
pTransacMng = (H_MGCP_TRANSAC_MANAGER)(((MGCP_STACK*)pStack)->pTransacMng);
Assert(pTransacMng);
if (pTransacMng)
{
pthread_mutex_lock(&pTransacMng->pTranMngMutex);
pTransacMng->bMax1LookUp = bOnOff;
pthread_mutex_unlock(&pTransacMng->pTranMngMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetMax2LookUp
*
* Description : Set the if need loop up DNS when retries reach Max2
*
* Input parameters : pStack - Handle of the stack
* bOnOff - Whether need loop up DNS flag
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetMax2LookUp(H_STACK pStack, BOOL bOnOff)
{
H_MGCP_TRANSAC_MANAGER pTransacMng;
Assert(pStack);
pTransacMng = (H_MGCP_TRANSAC_MANAGER)(((MGCP_STACK*)pStack)->pTransacMng);
Assert(pTransacMng);
if (pTransacMng)
{
pthread_mutex_lock(&pTransacMng->pTranMngMutex);
pTransacMng->bMax2LookUp = bOnOff;
pthread_mutex_unlock(&pTransacMng->pTranMngMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpSackSetThreeWayHandShake
*
* Description : Set the if use three way handshake procedure of the stack
*
* Input parameters : pStack - Handle of the stack
* bOnOff - Whether use three way handshake procedure flag
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpSackSetThreeWayHandShake(H_STACK pStack, BOOL bOnOff)
{
H_MGCP_TRANSAC_MANAGER pTransacMng;
Assert(pStack);
pTransacMng = (H_MGCP_TRANSAC_MANAGER)(((MGCP_STACK*)pStack)->pTransacMng);
Assert(pTransacMng);
if (pTransacMng)
{
pthread_mutex_lock(&pTransacMng->pTranMngMutex);
pTransacMng->bUseThreeWayHandShake = bOnOff;
pthread_mutex_unlock(&pTransacMng->pTranMngMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetRestartMaxDelay
*
* Description : Set the restart max dealy value of the stack.
*
* Input parameters : pStack - Handle of the stack
* dwMaxDelayValue - restart max dealy value
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetRestartMaxDelay(H_STACK pStack, DWORD dwMaxDelayValue)
{
H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;
Assert(pStack);
pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);
Assert(pEndpntCtrl);
if (pEndpntCtrl)
{
pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);
pEndpntCtrl->dwMWD = dwMaxDelayValue;
pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetDisconnectInitialDelay
*
* Description : Set the disconnect initial dealy value of the stack.
*
* Input parameters : pStack - Handle of the stack
* dwDelayValue - disconnect initial dealy value
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetDisconnectInitialDelay(H_STACK pStack, DWORD dwDelayValue)
{
H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;
Assert(pStack);
pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);
Assert(pEndpntCtrl);
if (pEndpntCtrl)
{
pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);
pEndpntCtrl->dwTdinit = dwDelayValue;
pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetDisconnectMinDelay
*
* Description : Set the disconnect min dealy value of the stack.
*
* Input parameters : pStack - Handle of the stack
* dwDelayValue - Disconnect min dealy value
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetDisconnectMinDelay(H_STACK pStack, DWORD dwDelayValue)
{
H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;
Assert(pStack);
pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);
Assert(pEndpntCtrl);
if (pEndpntCtrl)
{
pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);
pEndpntCtrl->dwTdmin = dwDelayValue;
pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetDisconnectMaxDelay
*
* Description : Set the disconnect max dealy value of the stack.
*
* Input parameters : pStack - Handle of the stack
* dwDelayValue - Disconnect max dealy value
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetDisconnectMaxDelay(H_STACK pStack, DWORD dwDelayValue)
{
H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;
Assert(pStack);
pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);
Assert(pEndpntCtrl);
if (pEndpntCtrl)
{
pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);
pEndpntCtrl->dwTdmax = dwDelayValue;
pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpStackSetRetureUnsupportPackages
*
* Description : Set whether need to return the unsupported mgcp packages
* in the outgoing mgcp response if the response code need
*
* Input parameters : pStack - Handle of the stack
* bOnOff - Flag to indicate return the unsupported mgcp
* packages
*
* Output parameters :
*
* Return value : Return OK if the stack is configured successfylly,
* otherwise return FAIL.
*
* Comments :
*
* History :
* 2005/12/16 : Creation
*
* Date : Dec 16 2005, Frank Zhang
******************************************************************************/
LONG MgcpStackSetRetureUnsupportPackages(H_STACK pStack, BOOL bOnOff)
{
H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;
Assert(pStack);
pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);
Assert(pEndpntCtrl);
if (pEndpntCtrl)
{
pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);
pEndpntCtrl->bReturnPackageList = bOnOff;
pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);
return OK;
}
return FAIL;
}
/******************************************************************************
* Function : MgcpEndpointSetCallAgent
*
* Description : Set the Call Agent of the endpoint. If the CA name is
* dot-decimal format, directly use this address, otherwise
* resolve the domain name into ip addresses.
*
* Input parameters : pEndpoint - Handle of the Endpoint
* pcCaName - Call Agent name
* wPort - Call Agent port
*
* Output parameters :
*
* Return value : Return OK if the CA is set successfully, otherwise
* return FAIL.
*
* Comments :
*
* History :
* 2005/12/13 : Creation
*
* Date : Dec 13 2005, Frank Zhang
******************************************************************************/
LONG MgcpEndpointSetCallAgent(H_ENDPOINT pEndpoint, char *pcCaName, WORD wPort)
{
char *p;
H_MGCP_ENDPOINT pEndpnt = (H_MGCP_ENDPOINT)pEndpoint;
Assert(pEndpoint);
Assert(pcCaName);
if ((p = strchr(pcCaName, '@')) != NULL)
{
/* Call Agent local name */
pEndpnt->NotifiedEntity.pcLocalName
= (char*)calloc((WORD)((p-pcCaName)+1), sizeof(char));
Assert(pEndpnt->NotifiedEntity.pcLocalName);
strncpy(pEndpnt->NotifiedEntity.pcLocalName, pcCaName, (size_t)(p-pcCaName));
/* Domain name */
StrClone(&pEndpnt->NotifiedEntity.pcDomainName, p+1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?