📄 stackcb.c
字号:
/******************************************************************************
Copyright(C) 2005,2006 Frank ZHANG
All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA.
******************************************************************************
* Authors : Frank ZHANG (openmgcp@gmail.com)
* Description : Utility functions of control block of stack
*
*
* Date of creation : 08/02/2005
*
*
* History :
* 2005/08/02 Frank ZHANG : - Creation
******************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "typedef.h"
#include "debg.h"
#include "list.h"
#include "posix.h"
#include "stackcb.h"
/******************************************************************************
* Function : ClearPendingRqnt
*
* Description : Clear Pending Rqnt
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearPendingRqnt(MGCP_PENDING_RQNT *pData)
{
if (pData != NULL)
{
ClearMgcpSignalList(&pData->PendingSigReq);
ClearMgcpRequestedEventList(&pData->PendingReqEvents);
ClearMgcpDetectEventList(&pData->PendingDetEvents);
if (pData->pcReqID != NULL)
{
free(pData->pcReqID);
}
if (pData->pDigitMap != NULL)
{
ClearDigitMap(pData->pDigitMap);
free(pData->pDigitMap);
}
free(pData->pQuarantineHandling);
memset(pData, 0, sizeof(MGCP_PENDING_RQNT));
}
}
/******************************************************************************
* Function : ClearPendingConnection
*
* Description : Clear Pending Connection
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearPendingConnection(MGCP_PENDING_CONNEC *pData)
{
if (pData != NULL)
{
if (pData->pcCallId)
{
free(pData->pcCallId);
}
if (pData->pConnecMode != NULL)
{
ClearConnectionMode(pData->pConnecMode);
free(pData->pConnecMode);
}
if (pData->pLocalConnecOpt != NULL)
{
ClearLocalConnectionOptions(pData->pLocalConnecOpt);
free(pData->pLocalConnecOpt);
}
if (pData->pRemoteConnecDesc != NULL)
{
ClearSdpConnectionDescriptor(pData->pRemoteConnecDesc);
free(pData->pRemoteConnecDesc);
}
memset(pData, 0, sizeof(MGCP_PENDING_CONNEC));
}
}
/******************************************************************************
* Function : ClearPendingConnectionCmd
*
* Description : ClearP ending Connection Cmd
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearPendingConnectionCmd(MGCP_PENDING_CONNEC_CMD *pData)
{
Assert(pData);
if (pData != NULL)
{
if (pData->pPendingRqnt != NULL)
{
ClearPendingRqnt(pData->pPendingRqnt);
free(pData->pPendingRqnt);
}
ClearPendingConnection(&pData->PendingConn);
memset(pData, 0, sizeof(MGCP_PENDING_CONNEC_CMD));
}
}
/******************************************************************************
* Function : ClearPendingConnectionCmdlist
*
* Description : Clear Pending Connection Cmd list
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearPendingConnectionCmdlist(SLIST *pData)
{
MGCP_PENDING_CONNEC_CMD *pCmd;
if (pData != NULL)
{
SListReset(pData);
while ((pCmd = SListGetCurData(pData)) != NULL)
{
ClearPendingConnectionCmd(pCmd);
free(pCmd);
SListDelCurNode(pData);
}
}
}
/******************************************************************************
* Function : ClearMgcpRspIn
*
* Description : Clear Mgcp incoming Rsp
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearMgcpRspIn(MGCP_RSP_IN* pData)
{
if (pData->u.pRsipRsp != NULL)
{
switch (pData->eType)
{
case MGCP_RSP_RSIP:
{
ClearMgcpRsipResponse(pData->u.pRsipRsp);
break;
}
case MGCP_RSP_NTFY:
{
ClearMgcpNtfyResponse(pData->u.pNtfyRsp);
break;
}
case MGCP_RSP_DLCX:
{
ClearMgcpDlcxResponse(pData->u.pDlcxRsp);
break;
}
default:
{
Assert(0);
}
}
free(pData->u.pRsipRsp);
memset(pData, 0, sizeof(MGCP_RSP_IN));
}
}
/******************************************************************************
* Function : ClearMgcpRspOut
*
* Description : Clear outgoing Mgcp response
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearMgcpRspOut(MGCP_RSP_OUT* pData)
{
Assert(pData);
/* Response string*/
if (pData->pcRspString != NULL)
{
free(pData->pcRspString);
}
if (pData->u.pEpcfRsp != NULL)
{
switch (pData->eType)
{
case MGCP_RSP_EPCF:
{
ClearMgcpEpcfResponse(pData->u.pEpcfRsp);
break;
}
case MGCP_RSP_RQNT:
{
ClearMgcpRqntResponse(pData->u.pRqntRsp);
break;
}
case MGCP_RSP_CRCX:
{
ClearMgcpCrcxResponse(pData->u.pCrcxRsp);
break;
}
case MGCP_RSP_MDCX:
{
ClearMgcpMdcxResponse(pData->u.pMdcxRsp);
break;
}
case MGCP_RSP_DLCX:
{
ClearMgcpDlcxResponse(pData->u.pDlcxRsp);
break;
}
case MGCP_RSP_AUEP:
{
ClearMgcpAuepResponse(pData->u.pAuepRsp);
break;
}
case MGCP_RSP_AUCX:
{
ClearMgcpAucxResponse(pData->u.pAucxRsp);
break;
}
default:
{
Assert(0);
}
}
free(pData->u.pEpcfRsp);
memset(pData, 0, sizeof(MGCP_RSP_OUT));
}
}
/******************************************************************************
* Function : ClearMgcpCmdOut
*
* Description : Clear Mgcp outgoing command
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearMgcpCmdOut(MGCP_CMD_OUT* pData)
{
Assert(pData);
if (pData != NULL)
{
/* Notified entity */
ClearNotifiedEntity(&pData->NotifiedEntity);
if (pData->u.pRsipCmd != NULL)
{
switch (pData->eType)
{
case MGCP_CMD_RSIP:
{
ClearMgcpRsipCommand(pData->u.pRsipCmd);
break;
}
case MGCP_CMD_NTFY:
{
ClearMgcpNtfyCommand(pData->u.pNtfyCmd);
break;
}
case MGCP_CMD_DLCX:
{
ClearMgcpDlcxCommand(pData->u.pDlcxCmd);
break;
}
default:
{
Assert(0);
}
}
free(pData->u.pRsipCmd);
}
}
memset(pData, 0, sizeof(MGCP_CMD_OUT));
}
/******************************************************************************
* Function : ClearMgcpCmdIn
*
* Description : Clear incoming Mgcp command
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
*
* Date : Sep 13 2005, Frank Zhang
******************************************************************************/
void ClearMgcpCmdIn(MGCP_CMD_IN* pData)
{
Assert(pData);
if (pData != NULL)
{
ClearEndpointName(&pData->EndpointName);
if (pData->u.pEpcfCmd != NULL)
{
switch (pData->eType)
{
case MGCP_CMD_EPCF:
{
ClearMgcpEpcfCommand(pData->u.pEpcfCmd);
break;
}
case MGCP_CMD_RQNT:
{
ClearMgcpRqntCommand(pData->u.pRqntCmd);
break;
}
case MGCP_CMD_CRCX:
{
ClearMgcpCrcxCommand(pData->u.pCrcxCmd);
break;
}
case MGCP_CMD_MDCX:
{
ClearMgcpMdcxCommand(pData->u.pMdcxCmd);
break;
}
case MGCP_CMD_DLCX:
{
ClearMgcpDlcxCommand(pData->u.pDlcxCmd);
break;
}
case MGCP_CMD_AUEP:
{
ClearMgcpAuepCommand(pData->u.pAuepCmd);
break;
}
case MGCP_CMD_AUCX:
{
ClearMgcpAucxCommand(pData->u.pAucxCmd);
break;
}
case MGCP_CMD_EXPR:
{
ClearMgcpExprimentalCommand(pData->u.pExprCmd);
break;
}
default:
{
Assert(0);
}
}
free(pData->u.pEpcfCmd);
memset(pData, 0, sizeof(MGCP_CMD_IN));
}
}
}
/******************************************************************************
* Function : ClearTranRspOut
*
* Description : Clear the outgoing transaction response
*
* Input parameters : pData - Pointer to the data to be cleared
*
* Output parameters :
*
* Return value : None
*
* Comments :
*
* History :
* 2005/09/13 : Creation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -