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

📄 mgcpdef.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 sturcture definition.***      Date of creation          :  07/12/2005***      History                   :*      2005/07/12 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 "mgcpdef.h"/* Response code table */static DWORD RspCodeTable[] ={  RSP_TRANSACTION_IN_PROGRESS,            (DWORD)"Transaction in progress",  RSP_TRANSACTION_QUEUED,                 (DWORD)"Transaction has been queued for execution",  RSP_TRANSACTION_SUCCEED,                (DWORD)"Transaction executed normally",  RSP_CONNECTION_DELETED,                 (DWORD)"The connection was deleted",  RSP_UNSPECIFIED_TRANSIENT_ERROR,        (DWORD)"Unspecified transient error",  RSP_PHONE_OFF_HOOK,                     (DWORD)"The phone is already off-hook",  RSP_PHONE_ON_HOOK,                      (DWORD)"The phone is already on-hook",  RSP_INSUFFICIENT_RESOURCES,             (DWORD)"Insufficient resources available at this time",  RSP_INSUFFICIENT_BANDWIDTH,             (DWORD)"Insufficient bandwidth at this time",  RSP_ENDPOINT_IS_RESTARTING,             (DWORD)"Endpoint is restarting",  RSP_TRANSACTION_TIMEOUT,                (DWORD)"Transaction Timeout",  RSP_TRANSACTION_ABORTED,                (DWORD)"Transaction aborted by some external action",  RSP_INTERNAL_OVERLOAD,                  (DWORD)"Internal overload",  RSP_ENDPOINT_UNAVAILABLE,               (DWORD)"No endpoint available",  RSP_ENDPOINT_UNKNOWN,                   (DWORD)"Endpoint unknown",  RSP_ENDPOINT_OUT_OF_SERVICE,            (DWORD)"Endpoint is not ready or is out of service",  RSP_INSUFFICIENT_RESOURCES_PERMANENT,   (DWORD)"Insufficient resources (permanent)",  RSP_WILDCARD_TOO_COMPLICATED,           (DWORD)"All of wildcard too complicated",  RSP_UNSUPPORTED_COMMAND,                (DWORD)"Unknown or unsupported command",  RSP_UNSUPPORTED_CONNEC_DESCRIPTOR,      (DWORD)"Unsupported remote connection descriptor",  RSP_UNSATISFIED_CONNECTION_OPTION,      (DWORD)"Unsatisfied local connection options and remote connection descriptor simultaneously",  RSP_UNSUPPORTED_FUNCTIONALITY,          (DWORD)"Unsupported Functionality",  RSP_UNSUPPORTED_QUARANTINE_HANDLING,    (DWORD)"Unknown or unsupported quarantine handling",  RSP_ERROR_REMOTECONNECDESCRIPTOR,       (DWORD)"Error in RemoteConnectionDescriptor",  RSP_PROTOCOL_ERROR,                     (DWORD)"Protocol error",  RSP_UNRECOGNIZED_PARAMETER_EXTENSION,   (DWORD)"Unrecognized parameter extension",  RSP_UNEQUIPPED_DETECT_EVENTS,           (DWORD)"Gateway not equipped to detect one of the requested events",  RSP_UNEQUIPPED_GENERATE_SIGNALS,        (DWORD)"Gateway is not equipped to generate one of the requested signals",  RSP_UNSUPPORTED_ANNOUNCEMENT,           (DWORD)"The gateway cannot send the specified announcement",  RSP_INCORRECT_CONNECTION_ID,            (DWORD)"Incorrect connection-id",  RSP_UNKNOWN_CALL_ID,                    (DWORD)"Unknown or incorrect call-id",  RSP_INVALID_MODE,                       (DWORD)"Invalid or unsupported mode",  RSP_UNSUPPORTED_PACKAGE,                (DWORD)"Unsupported or unknown package",  RSP_DIGIT_MAP_IS_NULL,                  (DWORD)"Endpoint does not have a digit map",  RSP_REDIRECT_CA,                        (DWORD)"Endpoint re-directed to another Call Agent",  RSP_NO_SUCH_EVENT_SIGNAL,               (DWORD)"No such event or signal",  RSP_UNKNOWN_OR_ILLEGAL_COMBIN_ACTIONS,  (DWORD)"Unknown action or illegal combination of actions",  RSP_INCONSISTENCY_LOCAL_CONNEC_OPTIONS, (DWORD)"Internal inconsistency in Local Connection Options",  RSP_UNKNOWN_CONNEC_OPTIONS_EXTENSION,   (DWORD)"Unknown extension in Local Connection Options",  RSP_INSUFFICIENT_BANDWIDTH,             (DWORD)"Insufficient bandwidth",  RSP_MISSING_REMOTE_CONNEC_DESCRIPTOR,   (DWORD)"Missing RemoteConnectionDescriptor",  RSP_INCOMPATIBLE_PROTOCOL_VERSION,      (DWORD)"Incompatible protocol version",  RSP_INTERNAL_HARDWARE_ERROR,            (DWORD)"Internal Hardware Error",  RSP_CAS_SIGNALING_ERROR,                (DWORD)"CAS Signaling Protocol Error",  RSP_FAILURE_GROUPING_TRUNKS,            (DWORD)"Failure of a grouping of trunks",  RSP_UNSUPPORTED_LOCAL_CONNEC_OPT_VALUE, (DWORD)"Unsupported value in Local Connection Options",  RSP_RESPONSE_TOO_LARGE,                 (DWORD)"Response too large",  RSP_CODEC_NEGOTIATION_FAILURE,          (DWORD)"Codec negotiation failure",  RSP_UNSUPPORTED_PACKETIZATION_PERIOD,   (DWORD)"Packetization period not supported",  RSP_UNKNOWN_RESTART_METHOD,             (DWORD)"Unknown or unsupported Restart Method",  RSP_UNKNOWN_DIGIT_MAP_EXTENSION,        (DWORD)"Unknown or unsupported digit map extension",  RSP_EVENT_SIGNAL_PARAMETER_ERROR,       (DWORD)"Event/signal parameter error",  RSP_UNSUPPORTED_COMMAND_PARAMETER,      (DWORD)"Invalid or unsupported command parameter",  RSP_REACH_ENDPOINT_CONNECTION_LIMIT,    (DWORD)"Per endpoint connection limit exceeded",  RSP_UNSUPPORTED_LOCAL_CONNEC_OPTIONS,   (DWORD)"Invalid or unsupported Local Connection Options",  TABLE_END};/******************************************************************************* * Function          : FindRspStringByCode * * Description       : Find the response string according to the response code *                      * Input parameters  : dwRspCode - Response code * * Output parameters :  * * Return value      : If response code is valid, return the response string, *                     otherwise return NULL. * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/char* FindRspStringByCode(DWORD dwRspCode){  DWORD *pRspElem = RspCodeTable;  Assert(RspCodeTable);  while (*pRspElem != TABLE_END)  {    if (*pRspElem == dwRspCode)      return (char*)(*(pRspElem+1));    else pRspElem += 2;  }  return NULL;}/******************************************************************************* * Function          : ClearSdpConnectionField * * Description       : Clear the Sdp Connection Field *                      * Input parameters  : pData - Pointer to the data to be cleared * * Output parameters :  * * Return value      :  * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void ClearSdpConnectionField(CONNECTION_FIELD *pData){  if (pData != NULL)  {    if (pData->pcNetType != NULL)    {      free(pData->pcNetType);      pData->pcNetType = NULL;    }    if (pData->pcAddrType != NULL)    {      free(pData->pcAddrType);      pData->pcAddrType = NULL;    }    if (pData->ConnectionAddress.pcAddress != NULL)    {      free(pData->ConnectionAddress.pcAddress);      pData->ConnectionAddress.pcAddress = NULL;      pData->ConnectionAddress.eType = 0;    }  }}/******************************************************************************* * Function          : CopySdpConnectionField * * Description       : Copy the Sdp Connection Field *                      * Input parameters  : pDesData - Pointer to the destination data be copied into *                     pSrcData - Pointer to the source data to be copied * * Output parameters :  * * Return value      :  * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void CopySdpConnectionField(CONNECTION_FIELD *pDesData, CONNECTION_FIELD *pSrcData){  Assert(pDesData);  if (pSrcData != NULL)  {    StrClone(&pDesData->pcNetType, pSrcData->pcNetType);    StrClone(&pDesData->pcAddrType, pSrcData->pcAddrType);    pDesData->ConnectionAddress.eType = pSrcData->ConnectionAddress.eType;    StrClone(&pDesData->ConnectionAddress.pcAddress,             pSrcData->ConnectionAddress.pcAddress);  }}/******************************************************************************* * Function          : ClearSdpMediaField * * Description       : Clear Sdp Media Field  *                      * Input parameters  : pData - Pointer to the data to be cleared * * Output parameters :  * * Return value      :  * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void ClearSdpMediaField(MEDIA_FIELD *pData){  if (pData != NULL)  {    if (pData->pcMedia != NULL)    {      free(pData->pcMedia);      pData->pcMedia = NULL;    }        if (pData->pcPort != NULL)    {      free(pData->pcPort);      pData->pcPort = NULL;    }        if (pData->pcInteger != NULL)    {      free(pData->pcInteger);      pData->pcInteger = NULL;    }    if (pData->Protocol.pcOtherProtocol != NULL)    {      free(pData->Protocol.pcOtherProtocol);      pData->Protocol.pcOtherProtocol = NULL;      pData->Protocol.eType = 0;    }    if (pData->wNum > 0)    {      while (pData->wNum-- > 0)        free(pData->ppcFormat[pData->wNum]);            pData->wNum = 0;      free(pData->ppcFormat);      pData->ppcFormat = NULL;    }  }}/******************************************************************************* * Function          : CopySdpMediaField * * Description       : Copy the Sdp Media Field *                      * Input parameters  : pDesData - Pointer to the destination data be copied into *                     pSrcData - Pointer to the source data to be copied * * Output parameters :  * * Return value      :  * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void CopySdpMediaField(MEDIA_FIELD *pDesData, MEDIA_FIELD *pSrcData){  Assert(pDesData);  if (pSrcData != NULL)  {    StrClone(&pDesData->pcMedia, pSrcData->pcMedia);    StrClone(&pDesData->pcPort, pSrcData->pcPort);    StrClone(&pDesData->pcInteger, pSrcData->pcInteger);    pDesData->Protocol.eType = pSrcData->Protocol.eType;    StrClone(&pDesData->Protocol.pcOtherProtocol,             pSrcData->Protocol.pcOtherProtocol);    pDesData->wNum = pSrcData->wNum;    if (pDesData->wNum > 0)    {      WORD i;      pDesData->ppcFormat = (char**)calloc(pDesData->wNum, sizeof(char*));      for (i = 0; i < pDesData->wNum; i++)        StrClone(pDesData->ppcFormat+i, pSrcData->ppcFormat[i]);    }  }}/******************************************************************************* * Function          : ClearSdpAttributeField * * Description       : Clear the Sdp Attribute Field  *                      * Input parameters  : pData - Pointer to the data to be cleared * * Output parameters :  * * Return value      :  * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void ClearSdpAttributeField(ATTRIBUTE_FIELD *pData){  if (pData != NULL)  {    if (pData->pcAttibuteName)    {      free(pData->pcAttibuteName);      pData->pcAttibuteName = NULL;    }    if (pData->pcAttibuteValue)    {      free(pData->pcAttibuteValue);      pData->pcAttibuteValue = NULL;    }      }}/******************************************************************************* * Function          : CopySdpAttributeField * * Description       : Copy the sdp attribute field *                      * Input parameters  : pDesData - Pointer to the destination data be copied into *                     pSrcData - Pointer to the source data to be copied * * Output parameters :  * * Return value      :  * * Comments          :  * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void CopySdpAttributeField(ATTRIBUTE_FIELD *pDesData, ATTRIBUTE_FIELD *pSrcData){  Assert(pDesData);    if (pSrcData != NULL)  {    if (pSrcData->pcAttibuteName)    {      StrClone(&pSrcData->pcAttibuteName, pSrcData->pcAttibuteName);    }    if (pSrcData->pcAttibuteValue)    {      StrClone(&pSrcData->pcAttibuteName, pSrcData->pcAttibuteValue);    }      }}/******************************************************************************* * Function          : ClearSdpMediaDescriptions * * Description       : Clear the Sdp Media Descriptions  *                      * Input parameters  : pData - Pointer to the data to be cleared * * Output parameters :  * * Return value      :  * * Comments          :  * * History           : *  2005/07/12       : Creation * * Date              : July 12 2005, Frank ZHANG ******************************************************************************/void ClearSdpMediaDescriptions(MEDIA_DESCRIPTIONS *pData){  if (pData != NULL)  {    ClearSdpMediaField(&pData->MediaField);    if (pData->wNum > 0)    {      while(pData->wNum-- >0)        ClearSdpAttributeField(pData->pAttributeFields+pData->wNum);      pData->wNum = 0;      free(pData->pAttributeFields);      pData->pAttributeFields = NULL;    }  }}/******************************************************************************* * Function          : CopySdpMediaDescriptions * * Description       : Copy the Sdp medial Descriptions *                      * Input parameters  : pDesData - Pointer to the destination data be copied into *                     pSrcData - Pointer to the source data to be copied * * Output parameters : 

⌨️ 快捷键说明

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