⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transacmng.c

📁 内容正如其名
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************  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.  ******************************************************************************   If you want to distribute this software with modifications under any terms  other than the GPL or distribute the software linked with proprietary  applications that are not distributed in full compliance with the GNU Public  License, a Commercial License is needed.    Commercial licensing and support of this software are available at a fee. For  more information, See http://www.openmgcp.org  ******************************************************************************//*******************************************************************************      Authors                   :  Frank ZHANG*      Description               :  Transaction Manager module***      Date of creation          :  08/20/2005***      History                   :*      2005/08/20 Frank ZHANG    : - Creation******************************************************************************/#include <stdlib.h>#include <stdio.h>#include <string.h>#include "typedef.h"#include "debg.h"#include "misc.h"#include "list.h"#include "abnf.h"#include "posix.h"#include "mgcpdef.h"#include "stackcb.h"#include "mgcpmsgtran.h"#include "transacmng.h"extern LONG SendMsgToEndpointCtrl(MGCP_ENDPOINT_CONTROL*, MGCP_STACK_MSG*);/*****************************************************************************//* Get a new transaction ID */#define GetNewTransacID(pTransacMng) (++pTransacMng->dwTransactionId)/****************************************************************************** * Function          : FindMgcpCmdOutByTranID * * Description       : Compare the transaction ID of the command with the target *                     transaction ID. *                      * Input parameters  : pTranCmdOut - Pointer to  outgoing command  *                     pTransacID - Pointer to the target transaction ID * * Output parameters :  * * Return value      : If the transaction ID of the command is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpCmdOutByTranID(void *pTranCmdOut, void *pTransacID){  Assert(pTranCmdOut);  Assert(pTransacID);  return (*((DWORD*)pTransacID)-((TRANSAC_CMD_OUT*)pTranCmdOut)->dwTransacId);}/****************************************************************************** * Function          : FindMgcpRspAckOutByTranID * * Description       : Compare the transaction ID of the response with the *                     target transaction ID. *                      * Input parameters  : pRspAckOut - Pointer to  outgoing response  *                     pTransacID - Pointer to the target transaction ID * * Output parameters :  * * Return value      : If the transaction ID of the response is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpRspAckOutByTranID(void *pRspAckOut, void *pTransacID){  Assert(pRspAckOut);  Assert(pTransacID);  return (*((DWORD*)pTransacID)-((TRANSAC_RSPACK_OUT*)pRspAckOut)->dwTransacId);}/****************************************************************************** * Function          : FindMgcpCmdInByTranID * * Description       : Compare the transaction ID of the incoming command with *                     the target transaction ID. *                      * Input parameters  : pCmdIn - Pointer to  incoming command  *                     pTransacID - Pointer to the target transaction ID * * Output parameters :  * * Return value      : If the transaction ID of the command is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpCmdInByTranID(void *pCmdIn, void *pTransacID){  Assert(pCmdIn);  Assert(pTransacID);  return (*((DWORD*)pTransacID)-((TRANSAC_CMD_IN*)pCmdIn)->dwTransacId);}/****************************************************************************** * Function          : FindMgcpRspOutByTranID * * Description       : Compare the transaction ID of the outgoing response with *                     the target transaction ID. *                      * Input parameters  : pRspOut - Pointer to outgoing response  *                     pTransacID - Pointer to the target transaction ID * * Output parameters :  * * Return value      : If the transaction ID of the response is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpRspOutByTranID(void *pRspOut, void *pTransacID){  Assert(pRspOut);  Assert(pTransacID);  return (*((DWORD*)pTransacID)-((TRANSAC_RSP_OUT*)pRspOut)->pRspOut->dwTransacId);}/****************************************************************************** * Function          : FindMgcpRspOutWaitAckByTranID * * Description       : Compare the transaction ID of the outgoing response *                     waiting ack with the target transaction ID. *                      * Input parameters  : pRspOut - Pointer to outgoing response waiting ack  *                     pTransacID - Pointer to the target transaction ID * * Output parameters :  * * Return value      : If the transaction ID of the response is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpRspOutWaitAckByTranID(void *pRspOut, void *pTransacID){  Assert(pRspOut);  Assert(pTransacID);  return (*((DWORD*)pTransacID)-((TRANSAC_RSP_WAIT_ACK*)pRspOut)->pRspOut->dwTransacId);}/****************************************************************************** * Function          : FindMgcpRspACKByTranID * * Description       : Compare the transaction ID of the outgoing response ack *                     with the target transaction ID. *                      * Input parameters  : pRspAck - Pointer to outgoing response ack  *                     pTransacID - Pointer to the target transaction ID * * Output parameters :  * * Return value      : If the transaction ID of the response ack is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpRspACKByTranID(void *pRspAck, void *pTransacID){  Assert(pRspAck);  Assert(pTransacID);  return (*((DWORD*)pTransacID)-((TRANSAC_RSP_ACKED*)pRspAck)->dwTransacId);}/****************************************************************************** * Function          : FindMgcpCmdOutByCmdID * * Description       : Compare the transaction ID of the outgoing command with *                     the target command ID. *                      * Input parameters  : pCmdOut - Pointer to outgoing command  *                     pCommandID - Pointer to the target command ID * * Output parameters :  * * Return value      : If the transaction ID of the command is equal to the *                     target transaction ID, return 0; otherwise return none 0 * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/int FindMgcpCmdOutByCmdID(void *pCmdOut, void *pCommandID){  DWORD *pCmdId = (DWORD*)pCommandID;  MGCP_CMD_OUT *pCmd = ((TRANSAC_CMD_OUT*)pCmdOut)->pCmdOut;  Assert(pCommandID);  Assert(pCmdOut);  return (*pCmdId - pCmd->dwCmdId);}/****************************************************************************** * Function          : BuildPiggybackedCommands * * Description       : Fill the Abnf MGCP commands with the piggybacking *                     commands *                      * Input parameters  : pTransacMng - Handle of the TransacMng  *                     pMsgList - Pointer to Mgcp outgoing command list of the *                                transaction manager *                     wNum - Number of the commands need piggybacking *                     pCmdID - Command ID table of the piggybacking command * * Output parameters : pAbnfMsgList - Abnf MGCP messages * * Return value      : None * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/void BuildPiggybackedCommands(H_MGCP_TRANSAC_MANAGER pTransacMng,                              TMGCPMsgList *pAbnfMsgList,                              MGCP_MSG_LIST *pMsgList,                              WORD wNum, DWORD *pCmdID){  int i;  TRANSAC_CMD_OUT *pTranCmdOut;  TMGCPMessage *pAbnfMsg;    Assert(pTransacMng);  Assert(pAbnfMsgList);  Assert(pMsgList);    /* Find the commands need piggyback with this command */    for (i = 0; i < wNum; i++)  {    /* Find the command need piggyback in cmdsend list ? */    if (SListFind(&pMsgList->CmdSentList, pCmdID+i, FindMgcpCmdOutByCmdID) != NULL)      pTranCmdOut = SListGetCurData(&pMsgList->CmdSentList);    else if (SListFind(&pMsgList->CmdSentPiggybackList,                       &pCmdID[i], FindMgcpCmdOutByCmdID) != NULL)      pTranCmdOut = SListGetCurData(&pMsgList->CmdSentPiggybackList);    else    {      /* In some case, the piggyback commands maybe have been removed by         TransacMng for receiving response or timeout, so if not found, continue         to find the next */      continue;    }    pAbnfMsgList->MGCPMessage.pNode      = realloc(pAbnfMsgList->MGCPMessage.pNode,                ((WORD)pAbnfMsgList->MGCPMessage.iNum+1)*sizeof(TMGCPMessage));    Assert(pAbnfMsgList->MGCPMessage.pNode);    pAbnfMsg = ((TMGCPMessage*)pAbnfMsgList->MGCPMessage.pNode)               + pAbnfMsgList->MGCPMessage.iNum;    memset(pAbnfMsg, 0, sizeof(TMGCPMessage));        pAbnfMsgList->MGCPMessage.iNum++;        pAbnfMsg->iType = MGCPMessage_MGCPCommand;    FillAbnfMgcpCommand(&pAbnfMsg->u.MGCPCommand,                        pTranCmdOut->pCmdOut->eType,                        pTranCmdOut->pCmdOut->u.pRsipCmd,                        pTranCmdOut->dwTransacId,                        pTranCmdOut->pCmdOut->hEndpointHandle->pcEndpointName,                        pTransacMng->pcDomainName,                        pTransacMng->pStack->pcMgcpVersion,                        pTransacMng->pStack->pcProfileName);  }}/****************************************************************************** * Function          : FillAbnfMgcpCmdOut * * Description       : Fill the Abnf commands *                      * Input parameters  : pTransacMng - Handle of the TransacMng  *                     pTranMgcpCmdOut - Pointer to Mgcp transaction outgoing *                                       command data * * Output parameters : pAbnfMsgList - Abnf MGCP command data * * Return value      : None * * Comments          :  * * History           : *  2005/09/04       : Creation * * Date              : Sep 04 2005, Frank ZHANG ******************************************************************************/void FillAbnfMgcpCmdOut(H_MGCP_TRANSAC_MANAGER pTransacMng,                        TMGCPMsgList *pAbnfMsgList,                        TRANSAC_CMD_OUT *pTranMgcpCmdOut){  TMGCPMessage *pAbnfMgcpMsg = NULL;  Assert(pTransacMng);  Assert(pAbnfMsgList);  Assert(pTranMgcpCmdOut);  Assert(pTranMgcpCmdOut->pCmdOut);      /* First check if need piggyback other commands */  if (pTranMgcpCmdOut->pCmdOut->wPiggyCmdNum > 0)  {    BuildPiggybackedCommands(pTransacMng, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -