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

📄 endpointctrl.h

📁 mgcp协议源代码和测试程序,还有一个编译器
💻 H
字号:
/******************************************************************************
  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               :  
*
*
*      Date of creation          :  09/07/2005
*
*
*      History                   :
*      2005/09/07 Frank ZHANG    : - Creation
******************************************************************************/
#ifndef __ENDPOINT_CTRL_H__
#define __ENDPOINT_CTRL_H__

#ifdef __cplusplus
extern "C" {#endif
#define MAX_HIERARCHICAL_LEVEL 10

#define WILDCARD_CUR           "$"
#define WILDCARD_ALL           "*"

/* Get a new ID of the new connection, the connection ID must not
   be 0, because 0 connection ID is invalid */
#define MAX_CONNECTION_ID 0x0FFFFFFF
#define GetNewConnectionID(pEndpnt) ((++pEndpnt->dwCurConnecID) % MAX_CONNECTION_ID +1)

/* Get the the EndpointCtrl handle of the endpoint */
#define ENDPOINT_CTRL_HANDLE(pEndpoint) \
  ((H_MGCP_ENDPOINT_CONTROL)(pEndpoint->pEndpointCtrl))

/* Get the stack handle of the endpoint */
#define STACK_HANDLE(pEndpoint) \
  (((H_MGCP_ENDPOINT_CONTROL)(pEndpoint->pEndpointCtrl))->pStack)

/* Get the TransactionMng handle of the endpoint */
#define TRANSAC_MANAGER_HANDLE(pEndpoint) \
  ((H_MGCP_TRANSAC_MANAGER) \
   (((H_MGCP_ENDPOINT_CONTROL)(pEndpoint->pEndpointCtrl))->pStack->pTransacMng))

/* Initialize the restart wait delay of the endpoint */
#define  InitRestartWaitDelay(pEndpoint) \
  (((DWORD)rand() % 10000) % (ENDPOINT_CTRL_HANDLE(pEndpoint)->dwMWD)+1)

/* Initialize the disconnect wait delay of the endpoint */  
#define  InitDisconnectWaitDelay(pEndpoint) \
  (((DWORD)rand()) % (ENDPOINT_CTRL_HANDLE(pEndpoint)->dwTdinit)+1)

/* Get a command ID of the new command */
#define GetNewCommandID(pEndpnt) (++(ENDPOINT_CTRL_HANDLE(pEndpnt)->dwCommandID))

/* Local name of endpoint */
typedef struct
{
  WORD wHierarchicalNum;                   /* Hierarchical level number */
  char* SubNames[MAX_HIERARCHICAL_LEVEL];  /* Current hierarchical name */
} ENDPOINT_LOCAL_NAME;

LONG ConvertIpAddress(DWORD *pDesIpAddress, char *pcSrcAddress);
DWORD CalculateRTOInitValue(H_MGCP_ENDPOINT pEndpoint);
void EndpointUpdataRTO(H_MGCP_ENDPOINT pEndpoint, DWORD dwTimeDelay);
LONG ParseEventRange(char *pcEventName, MGCP_EVENT_RANGE *pEventRange, E_MGCP_PACKAGE ePackageType);
void EndpointNotifyApplicationLinkState(H_MGCP_ENDPOINT pEndpoint, MGCP_CBK_LINK_STATE Linkstate);
void ClearEndpointLocalName(ENDPOINT_LOCAL_NAME *pName);
LONG CheckValidityOfEndpointName(ENDPOINT_LOCAL_NAME *pName);
LONG ParseEndpointName(char *pcSrcName, ENDPOINT_LOCAL_NAME *pLocalName);
int FindEndpointNodeByHierarchicalName(void *EndpointTreeNode, void *pcPathName);
BOOL FindEndpointNodeByName(ENDPOINT_LOCAL_NAME *pName, WORD wNameLevel,
                            SLIST *pNodeList, SLIST *pFoundEndpointList);
LONG AddEndpointIntoEndpointTree(H_MGCP_ENDPOINT pEndpnt, MGCP_ENDPOINT_TREE *pEndpntTree);
BOOL FindEndpointByName(char *pcName, MGCP_ENDPOINT_TREE *pEndpntTree, SLIST *pFoundEndpointList);
BOOL RemoveEndpointFromEnpointTree(H_MGCP_ENDPOINT pEndpoint, MGCP_ENDPOINT_TREE *pEndpointTree);
void ClearEndpointTreeNode(MGCP_ENDPOINT_TREE_NODE *pNode);
void ClearEndpointTree(MGCP_ENDPOINT_TREE *pEndpointTree);
void MgcpEndpointSendRsipCmdOut(H_MGCP_ENDPOINT pEndpoint, RESTART_METHOD *pRestartMethod,
                             DWORD dwRestartDelay, WORD wReasonCode, EXPERIMENTAL_PARAMS *pExperiParamList);
void MgcpEndpointSendNtfyCmdOut(H_MGCP_ENDPOINT pEndpoint, SLIST *pEventList);
void FillPiggybackCmdIDS(WORD *pwCmdNum, DWORD *pdwCmdIdTable, SLIST *pSrc);
void MgcpEndpointCtrlSendRspOut(H_MGCP_ENDPOINT_CONTROL pEndpntCtrl, WORD wRspCode, char *pcRspString,
                                DWORD dwTranID, DWORD dwDesIpAddr, WORD wDesPort, E_MGCP_RSP eRspType,
                                void *pRspData);
void EndpointReturnSupportedPackages(H_MGCP_ENDPOINT pEndpoint, PACKAGE_LIST **ppPkgList);
void MgcpEndpointSendRspOut(H_MGCP_ENDPOINT pEndpoint, WORD wRspCode, char *pcRspString, DWORD dwTranID,
                            DWORD dwDesIpAddr, WORD wDesPort, E_MGCP_RSP eRspType, void *pRspData);
LONG EndpointCheckExperimentalParams(H_MGCP_ENDPOINT pEndpoint, EXPERIMENTAL_PARAMS *pExperiParams,
                              WORD *pRspCode);
LONG EndpointProcessEncapEpcf(H_MGCP_ENDPOINT pEndpoint, ENCAPSULATED_EPCF *pEncapEpcf, WORD *pRspCode);
void MgcpEndpointProcessEpcfCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
LONG EndpointParseMgcpEventName(H_MGCP_ENDPOINT pEndpoint, EVENT_NAME *pEventName,
                                MGCP_EVENT_NAME *pMgcpEventName, WORD *pwErrorCode);
BOOL FindMgcpCallByID(SLIST *pCallList, char *pcCallID, MGCP_CALL **ppCall);
BOOL FindMgcpConnectionByID(SLIST *pConnecList, char *pcConnectionID, MGCP_CONNECTION **ppConnection);
LONG ParseMgcpConnectionID(char *pcConnectionId, SLIST *pCallList, MGCP_CONNEC_ID *pConnection);
LONG EndpointParseRequestedSignals(H_MGCP_ENDPOINT pEndpoint, SLIST *pSigList,
                                   SIGNAL_REQUESTS *pSigReq, DWORD *pdwCurConnecID,
                                   BOOL bEmbeddedRqnt, WORD *pwErrorCode);
LONG EndpointParseEventActions(H_MGCP_ENDPOINT pEndpoint, SLIST *pActionList,
                               EVENT_ACTIONS *pSrcActions, DWORD *pdwCurConnecID,
                               BOOL bDigitEmpty, BOOL bLoopQuarantineHandling,
                               WORD *pwErrorCode);
BOOL EndpointCheckPackageIsSupported(H_MGCP_ENDPOINT pEndpoint, E_MGCP_PACKAGE ePkgID);
LONG EndpointParseRequestedEvents(H_MGCP_ENDPOINT pEndpoint, SLIST *pEventList,
                                  MGCP_RQNT_CMD *pRqntCmd, DWORD *pdwCurConnecID,
                                  WORD *pwErrorCode);
LONG EndpointParseEmbeddedRequestedEvents(H_MGCP_ENDPOINT pEndpoint, SLIST *pEventList,
                                          EMBEDDED_REQUEST *pRqntCmd, DWORD *pdwCurConnecID,
                                          BOOL bDigitEmpty, BOOL bLoopQuarantineHandling, WORD *pwErrorCode);
LONG EndpointParseDetectEvents(H_MGCP_ENDPOINT pEndpoint, SLIST *pEventList,
                               DETECT_EVENTS *pDetectEvents, DWORD *pdwCurConnecID,
                               WORD *pwErrorCode);
LONG EndpointParseRqntParameters(H_MGCP_ENDPOINT pEndpoint,
                                 MGCP_RQNT_CMD *pRqntCmd, DWORD *pdwCurConnecID,
                                 SLIST *pReqEvents, SLIST *pReqSignals,
                                 SLIST *pDetEvents, WORD *pwRspCode);
BOOL ObservedEventIsPersistent(H_MGCP_ENDPOINT pEndpoint, MGCP_OBSERVED_EVENT *pEvent);
BOOL ObservedEventIsRequested(H_MGCP_ENDPOINT pEndpoint, MGCP_OBSERVED_EVENT *pObserEvent,
                              MGCP_REQUESTED_EVENT **ppReqEvent);
BOOL ObservedEventIsNeedDetect(H_MGCP_ENDPOINT pEndpoint, MGCP_OBSERVED_EVENT *pObserEvent,
                               MGCP_DETECT_EVENT **ppDetEvent);
void EndpointProcessQaurantinedEvents(H_MGCP_ENDPOINT pEndpoint, BOOL *pbNtfySent);
void EndpointProcessRequestedSignals(H_MGCP_ENDPOINT pEndpoint, SLIST *pSigList, WORD *pwRspCode);
void EndpointUpdateNotifiedEntity(H_MGCP_ENDPOINT pEndpoint,NOTIFIED_ENTITY *pNotifiedEntity);
void ParseRangeInDigitString(char **ppcDigitStrList, char *pcStartPnt,char *pcEndpnt);
void ParseDigitString(DIGIT_STRING *pDesDigitStr, char *pSrcDigitStr);
LONG CheckMatch(DIGIT_STRING *pDigitMapStr, WORD wStrIndex, char *pcDialStr);
LONG CheckDialStringMatchDigitMap(MGCP_DIGIT_MAP *pDigitMap, char *pcDialString);
void EndpointUpdateDigitMap(H_MGCP_ENDPOINT pEndpoint, DIGIT_MAP *pDigitMap);
void MgcpEndpointProcessRqntParams(H_MGCP_ENDPOINT pEndpoint, char *pcRequestIdentifier,
                                   SLIST *pReqEvents, SLIST *pReqSignals, 
                                   SLIST *pDetEvents, DIGIT_MAP *pDigitMap,
                                   QUARANTINE_HANDLING *pQuarantineHandling,
                                   WORD *pwRspCode);
void MgcpEndpointProcessRqntCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
void MgcpEndpointProcessCrcxCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
void MgcpEndpointProcessMdcxCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
void DeletePendingConnectionCmds(H_MGCP_ENDPOINT pEndpoint, SLIST *pPendingCmds, char *pcCallID,
                                 char *pcConnecID);
void MgcpEndpointProcessDlcxCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
LONG TranslateMgcpEventName(EVENT_NAME *pEventName, E_MGCP_PACKAGE ePkgID,
                            MGCP_EVENT_ID *pEventID, MGCP_CONNEC_ID *pConnectionID);
BOOL CheckEventIsIncludedInEventID(E_MGCP_EVENT eEvent, MGCP_EVENT_ID *pEventID);
void FillAuepRequestedEvents(REQUESTED_EVENTS *pReqEvents, SLIST *pReqEventList,
                             SLIST *pPersisEventList);
void FillAuepRequestedSignals(SIGNAL_REQUESTS *pReqSignals, SLIST *pMgcpSigList);
void FillAuepObservedEvents(OBSERVED_EVENTS *pObservedEvents, SLIST *pEvents);
void FillAuepDetectEvents(DETECT_EVENTS *pDetEvents, SLIST *pMgcpDetEvents,
                          SLIST *pPersisEvents);
void FillAuepSupportedPkgList(PACKAGE_LIST *pDesPkgList, SLIST *pEndpntPkgList);
void FillAuepConnectionIDs(CONNECTION_IDS *pConnecIDs, SLIST *pCallList);
void FillAuepCapabilities(CAPABILITIES *pCap, MGCP_CAPABILITIES *pMgcpCaps);
void MgcpEndpointProcessAuepCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
void MgcpEndpointProcessAucxCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn);
LONG CheckEndpointNameValidityOfCmd(MGCP_CMD_IN *pCmdIn);
void MgcpEndpointCtrlProcessCmdIn(H_MGCP_ENDPOINT_CONTROL pEndpntCtrl, MGCP_CMD_IN *pCmdIn);
LONG MgcpEndpointDelPendingCmdID(H_MGCP_ENDPOINT pEndpoint, DWORD dwCmdID);
void MgcpEndpointProcessRspIn(H_MGCP_ENDPOINT pEndpoint, MGCP_RSP_IN *pRspIn);
void MgcpEndpointProcessDisconnectedMsg(H_MGCP_ENDPOINT pEndpoint, E_MGCP_CMD eCmdType);
void EndpointSwitchOffToSignals(H_MGCP_ENDPOINT pEndpoint);
void EndpointProcessObservedEvent(H_MGCP_ENDPOINT pEndpoint, MGCP_OBSERVED_EVENT *pEvent,
                                  BOOL *pbNeedNotify, BOOL *pbEmbeddedRqntActive);
void MgcpEndpointProcessEventNotify(H_MGCP_ENDPOINT pEndpoint, ENDPOINT_EVENT *pCmdData);
void MgcpEndpointProcessDelcxRequest(H_MGCP_ENDPOINT pEndpoint, ENDPOINT_DLCX *pCmdData);
void MgcpEndpointProcessAcceptCRCX(H_MGCP_ENDPOINT pEndpoint, ENDPOINT_CONNECTION_OK *pCmdData);
void MgcpEndpointProcessAcceptMDCX(H_MGCP_ENDPOINT pEndpoint, ENDPOINT_CONNECTION_OK *pCmdData);
void MgcpEndpointProcessRejectCRCX(H_MGCP_ENDPOINT pEndpoint, ENDPOINT_CONNECTION_FAIL *pCmdData);
void MgcpEndpointProcessRejectMDCX(H_MGCP_ENDPOINT pEndpoint, ENDPOINT_CONNECTION_FAIL *pCmdData);
void MgcpEndpointCtrlProcessApplicationMsg(H_MGCP_ENDPOINT_CONTROL pEndpntCtrl, MGCP_ENDPOINT_MSG *pMsg);
void MgcpEndpointCtrlProcessTimeout(H_MGCP_ENDPOINT_CONTROL pEndpntCtrl);
void* EndpointCtrlTask(void *pArg);
void EndpointCtrlTimeOutCbk(void *pArg);
LONG EndpointControlCreate(H_MGCP_ENDPOINT_CONTROL *ppEndpointCtrl, H_MGCP_STACK pStack);
void EndpointControlDestroy(H_MGCP_ENDPOINT_CONTROL pEndpointCtrl);
LONG EndpointControlStart(H_MGCP_ENDPOINT_CONTROL pEndpointCtrl);
LONG EndpointControlRegisterEndpoint(H_MGCP_ENDPOINT_CONTROL pEndpointCtrl, H_MGCP_ENDPOINT pEndpnt);
LONG SendMsgToEndpointCtrl(H_MGCP_ENDPOINT_CONTROL hEndpointCtrl, MGCP_STACK_MSG *pMSG);

#ifdef __cplusplus}#endif

#endif

⌨️ 快捷键说明

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