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

📄 mgcpmsgtran.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               :  MGCP message and MGCP Abnf message*                                   translation functions***      Date of creation          :  08/15/2005***      History                   :*      2005/08/15 Frank ZHANG    : - Creation******************************************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>#include "typedef.h"#include "misc.h"#include "debg.h"#include "list.h"#include "mgcpdef.h"#include "abnf.h"#include "mgcpmsgtran.h"/******************************************************************************* * Function          : FillParameterLines * * Description       : Fill the internal mgcp parameter lines from the decoded *                     abnf parameter lines. *                      * Input parameters  : pSrcData - Pointer to the decoded MGCP abnf parameter *                                lines * * Output parameters : pDesData - Pointer to The internal filled MGCP parameter *                                lines * * Return value      : None * * Comments          :  * * History           : *  2005/08/16       : Creation * * Date              : Aug 16 2005, Frank ZHANG ******************************************************************************/void FillParameterLines(MGCP_PARAMETERS *pDesData, TList *pSrcData){  int i = 0;  TMGCPParameter *pSrcParam = NULL;    Assert(pDesData);  Assert(pSrcData);  /* Fill every parameter */  for(i = 0; i < pSrcData->iNum; i++)  {    pSrcParam = (TMGCPParameter*)pSrcData->pNode + i;        switch (pSrcParam->iType)    {      case MGCPParameter_ParamResponseAck:        pDesData->pResponseAck = (RESPONSE_ACK*)calloc(1, sizeof(RESPONSE_ACK));        if (pSrcParam->u.ParamResponseAck.ResponseAck.flag)          FillResponseAck(pDesData->pResponseAck,            (TResponseAck*)pSrcParam->u.ParamResponseAck.ResponseAck.pRuleData);      break;        case MGCPParameter_ParamBearerInformation:        pDesData->pBearerInformation= (BEARER_INFO*)calloc(1, sizeof(BEARER_INFO));        if (pSrcParam->u.ParamBearerInformation.BearerInformation.flag)          FillBearerInfo(pDesData->pBearerInformation,           (TBearerInformation*)pSrcParam->u.ParamBearerInformation.BearerInformation.pRuleData);      break;        case MGCPParameter_ParamCallId:        StrClone(&pDesData->pcCallId, pSrcParam->u.ParamCallId.CallId);      break;        case MGCPParameter_ParamConnectionId:        pDesData->pConnectionIds = (CONNECTION_IDS*)calloc(1, sizeof(CONNECTION_IDS));                if (pSrcParam->u.ParamConnectionId.ConnectionId.flag)          FillConnectionIDS(pDesData->pConnectionIds,            (TConnectionId*)pSrcParam->u.ParamConnectionId.ConnectionId.pRuleData);      break;        case MGCPParameter_ParamNotifiedEntity:        pDesData->pNotifiedEntity = (NOTIFIED_ENTITY*)calloc(1, sizeof(NOTIFIED_ENTITY));        if (pSrcParam->u.ParamNotifiedEntity.NotifiedEntity.flag)          FillNotifiedEntity(pDesData->pNotifiedEntity,           (TNotifiedEntity*)pSrcParam->u.ParamNotifiedEntity.NotifiedEntity.pRuleData);      break;        case MGCPParameter_ParamRequestIdentifier:        if (pSrcParam->u.ParamRequestIdentifier.RequestIdentifier.flag)          StrClone(&pDesData->pcRequestIdentifier,           (char*)pSrcParam->u.ParamRequestIdentifier.RequestIdentifier.pRuleData);      break;        case MGCPParameter_ParamLocalConnectionOptions:        pDesData->pLocalConnectionOptions          = (LOCAL_CONNEC_OPTS*)calloc(1, sizeof(LOCAL_CONNEC_OPTS));        if (pSrcParam->u.ParamLocalConnectionOptions.LocalConnectionOptions.flag)          FillLocalConnectionOpts(pDesData->pLocalConnectionOptions,           (TLocalConnectionOptions*)pSrcParam->u.ParamLocalConnectionOptions.LocalConnectionOptions.pRuleData);      break;        case MGCPParameter_ParamConnectionMode:        pDesData->pConnectionMode= (CONNECTION_MODE*)calloc(1, sizeof(CONNECTION_MODE));        FillConnectionMode(pDesData->pConnectionMode,                           &pSrcParam->u.ParamConnectionMode.ConnectionMode);      break;        case MGCPParameter_ParamRequestedEvents:        pDesData->pRequestedEvents          = (REQUESTED_EVENTS*)calloc(1, sizeof(REQUESTED_EVENTS));        if (pSrcParam->u.ParamRequestedEvents.RequestedEvents.flag)          FillRequestEvents(pDesData->pRequestedEvents,            (TRequestedEvents*)pSrcParam->u.ParamRequestedEvents.RequestedEvents.pRuleData);      break;        case MGCPParameter_ParamSignalRequests:        pDesData->pSignalRequests          = (SIGNAL_REQUESTS*)calloc(1, sizeof(SIGNAL_REQUESTS));        if (pSrcParam->u.ParamSignalRequests.SignalRequests.flag)          FillSignalRequests(pDesData->pSignalRequests,           (TSignalRequests*)pSrcParam->u.ParamSignalRequests.SignalRequests.pRuleData);      break;        case MGCPParameter_ParamDigitMap:        pDesData->pDigitMap= (DIGIT_MAP*)calloc(1, sizeof(DIGIT_MAP));        if (pSrcParam->u.ParamDigitMap.DigitMap.flag)          FillDigitMap(pDesData->pDigitMap,                       (TDigitMap*)pSrcParam->u.ParamDigitMap.DigitMap.pRuleData);      break;          case MGCPParameter_ParamConnectionParameters:        pDesData->pConnectionParameters= (CONNECTION_PARAMETERS*)calloc(1, sizeof(CONNECTION_PARAMETERS));        if (pSrcParam->u.ParamConnectionParameters.ConnectionParameters.flag)          FillConnectionParameters(pDesData->pConnectionParameters,             (TConnectionParameters*)pSrcParam->u.ParamConnectionParameters.ConnectionParameters.pRuleData);      break;        case MGCPParameter_ParamReasonCode:        pDesData->pReasonCode = (REASON_CODE*)calloc(1, sizeof(REASON_CODE));        FillReasonCode(pDesData->pReasonCode, &pSrcParam->u.ParamReasonCode.ReasonCode);      break;        case MGCPParameter_ParamSpecificEndpointID:        if (pSrcParam->u.ParamSpecificEndpointID.SpecificEndpointID.flag)        {          pDesData->pSpecificEndpointID            = (ENDPOINT_NAME*)calloc(1, sizeof(ENDPOINT_NAME));          FillEndpointName(pDesData->pSpecificEndpointID,            (TEndpointName*)pSrcParam->u.ParamSpecificEndpointID.SpecificEndpointID.pRuleData);        }      break;              case MGCPParameter_ParamSecondEndpointID:        pDesData->pSecondEndpointID = (ENDPOINT_NAME*)calloc(1, sizeof(ENDPOINT_NAME));        FillEndpointName(pDesData->pSecondEndpointID,         &pSrcParam->u.ParamSecondEndpointID.SecondEndpointID);      break;              case MGCPParameter_ParamSecondConnectionID:        if (pSrcParam->u.ParamSecondConnectionID.SecondConnectionID.ConnectionIdValue.iNum)          StrClone(&pDesData->pcSecondConnectionID,           (char*)pSrcParam->u.ParamSecondConnectionID.SecondConnectionID.ConnectionIdValue.pNode);      break;        case MGCPParameter_ParamRequestedInfo:        pDesData->pRequestedInfo= (REQUESTED_INFO*)calloc(1, sizeof(REQUESTED_INFO));        if (pSrcParam->u.ParamRequestedInfo.RequestedInfo.flag)          FillReqestedInfo(pDesData->pRequestedInfo,           (TRequestedInfo*)pSrcParam->u.ParamRequestedInfo.RequestedInfo.pRuleData);      break;        case MGCPParameter_ParamQuarantineHandling:        pDesData->pQuarantineHandling          = (QUARANTINE_HANDLING*)calloc(1, sizeof(QUARANTINE_HANDLING));        FillQuarantineHandling(pDesData->pQuarantineHandling,                       &pSrcParam->u.ParamQuarantineHandling.QuarantineHandling);      break;        case MGCPParameter_ParamDetectEvents:        pDesData->pDetectEvents = (DETECT_EVENTS*)calloc(1, sizeof(DETECT_EVENTS));        if (pSrcParam->u.ParamDetectEvents.DetectEvents.flag)          FillDetectEvents(pDesData->pDetectEvents,           (TSignalRequests*)pSrcParam->u.ParamDetectEvents.DetectEvents.pRuleData);      break;        case MGCPParameter_ParamRestartMethod:        pDesData->pRestartMethod           = (RESTART_METHOD*)calloc(1, sizeof(RESTART_METHOD));        FillRestartMethod(pDesData->pRestartMethod,                           &pSrcParam->u.ParamRestartMethod.RestartMethod);      break;        case MGCPParameter_ParamRestartDelay:        pDesData->pRestartDelay = (DWORD*)calloc(1, sizeof(DWORD));        *pDesData->pRestartDelay          = (DWORD)atoi(pSrcParam->u.ParamRestartDelay.RestartDelay);      break;        case MGCPParameter_ParamCapabilities:        pDesData->pCapabilities = (CAPABILITIES*)calloc(1, sizeof(CAPABILITIES));                if (pSrcParam->u.ParamCapabilities.Capabilities.flag)          FillCapabilities(pDesData->pCapabilities,           (TCapabilities*)pSrcParam->u.ParamCapabilities.Capabilities.pRuleData);              break;        case MGCPParameter_ParamEventStates:        pDesData->pEventStates= (EVENT_STATES*)calloc(1, sizeof(EVENT_STATES));                if (pSrcParam->u.ParamEventStates.EventStates.flag)          FillEventStates(pDesData->pEventStates,            (TSignalRequests*)pSrcParam->u.ParamEventStates.EventStates.pRuleData);      break;        case MGCPParameter_ParamPackageList:        pDesData->pPackageList= (PACKAGE_LIST*)calloc(1, sizeof(PACKAGE_LIST));                if (pSrcParam->u.ParamPackageList.PackageList.flag)          FillPackageList(pDesData->pPackageList,            (TPackageList*)pSrcParam->u.ParamPackageList.PackageList.pRuleData);      break;        case MGCPParameter_ParamMaxMGCPDatagram:        pDesData->pMaxMGCPDatagram = (DWORD*)calloc(1, sizeof(DWORD));        *pDesData->pMaxMGCPDatagram          = (DWORD)atoi(pSrcParam->u.ParamMaxMGCPDatagram.MaxMGCPDatagram);      break;        case MGCPParameter_ExtendedParameter:        FillExperimentalParameters(&pDesData->ExperiParamList,                                   &pSrcParam->u.ExtendedParameter);      break;        default:        Assert(0);    }  }}/******************************************************************************* * Function          : AppendNewParameter * * Description       : Append a new MGCP parameter into the parameter lines. *                      * Input parameters  : pData - Pointer to the original MGCP parameter lines *                     wNum - The current number of the parameters in the *                            parameter line * * Output parameters : pData - The new MGCP parameter lines with a new *                             parameters appended * * Return value      : Return the Pointer of the new MGCP parameter lines * * Comments          :  * * History           : *  2005/08/16       : Creation * * Date              : Aug 16 2005, Frank ZHANG ******************************************************************************/TMGCPParameter* AppendNewParameter(TMGCPParameter *pData, WORD wNum){  pData = (TMGCPParameter*)realloc(pData, (wNum+1)*sizeof(TMGCPParameter));  Assert(pData);  if (pData != NULL)    memset(pData+wNum, 0, sizeof(TMGCPParameter));  return pData;}/******************************************************************************* * Function          : FillAbnfParameterLines * * Description       : Fill the abnf mgcp parameter lines from the internal *                     MGCP parameters *                      * Input parameters  : pSrcData - Pointer to the internal MGCP parameter lines * * Output parameters : pDesData - Pointer to the filled abnf MGCP parameter *                                lines * * Return value      : None * * Comments          :  * * History           : *  2005/08/16       : Creation * * Date              : Aug 16 2005, Frank ZHANG ******************************************************************************/void FillAbnfParameterLines(TList *pDesData, MGCP_PARAMETERS*pSrcData){  TMGCPParameter *pDesParam = NULL;  WORD wNum = 0;    Assert(pSrcData);  Assert(pSrcData);      /* Response ack */  if (pSrcData->pResponseAck != NULL)  {    pDesParam = AppendNewParameter(pDesParam, wNum);    Assert(pDesParam);        if (pDesParam != NULL)    {      FillAbnfParamResponseAck(pDesParam+wNum, pSrcData->pResponseAck);       wNum++;    }  }    /* BearerInfo */  if (pSrcData->pBearerInformation != NULL)  {    pDesParam = AppendNewParameter(pDesParam, wNum);    Assert(pDesParam);    if (pDesParam != NULL)    {        FillAbnfParamBearerInfo(pDesParam+wNum, pSrcData->pBearerInformation);            wNum++;    }  }  /* Call ID */  if (pSrcData->pcCallId != NULL)  {    pDesParam = AppendNewParameter(pDesParam, wNum);    Assert(pDesParam);        if (pDesParam != NULL)    {      pDesParam[wNum].iType = MGCPParameter_ParamCallId;      StrClone(&pDesParam[wNum].u.ParamCallId.CallId, pSrcData->pcCallId);      wNum++;    }  }  /* Connection ID */  if (pSrcData->pConnectionIds != NULL)  {    pDesParam = AppendNewParameter(pDesParam, wNum);    Assert(pDesParam);

⌨️ 快捷键说明

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