📄 endpointctrl.c
字号:
******************************************************************************/void MgcpEndpointProcessEpcfCmd(H_MGCP_ENDPOINT pEndpoint, MGCP_CMD_IN *pCmdIn){ WORD wRspCode = 0; LONG iRet = OK; MGCP_CBK_MSG CbkMsg; Assert(pEndpoint); Assert(pCmdIn); Assert(pCmdIn->u.pEpcfCmd); Assert(pCmdIn->eType == MGCP_CMD_EPCF); switch (pEndpoint->eState) { case SM_NOTIFY: case SM_NOTIFY_PIGGYBACK: case SM_STEP_LOCK: case SM_DISCONNECTED: case SM_NORMAL: { /* Check if the BearerInfo parameter is missing, according to RFC3435, if Extension Parameters (vendor, package or other) are not used, the BearerInformation parameter is REQUIRED */ if (pCmdIn->u.pEpcfCmd->pBearerInfo == NULL) { iRet = FAIL; wRspCode = RSP_PROTOCOL_ERROR; } else { memset(&CbkMsg, 0, sizeof(MGCP_CBK_MSG)); CbkMsg.eType = MGCP_CBK_MSG_CONFIG_ENDPOINT; CbkMsg.u.CbkConfigEndpoint.pBearerInfo = pCmdIn->u.pEpcfCmd->pBearerInfo; CbkMsg.u.CbkConfigEndpoint.pExperiParamList = &pCmdIn->u.pEpcfCmd->ExperiParamList; Assert(STACK_HANDLE(pEndpoint)->pCbkNotfyApp); if (STACK_HANDLE(pEndpoint)->pCbkNotfyApp != NULL) iRet = STACK_HANDLE(pEndpoint)->pCbkNotfyApp((H_ENDPOINT)pEndpoint, &CbkMsg, &wRspCode); } if (iRet != OK) { MgcpEndpointSendRspOut(pEndpoint, wRspCode, NULL, pCmdIn->dwTransacId, pCmdIn->dwSrcIpAddr, pCmdIn->wSrcPort, MGCP_RSP_COMM, NULL); } else { MgcpEndpointSendRspOut(pEndpoint, RSP_TRANSACTION_SUCCEED, NULL, pCmdIn->dwTransacId, pCmdIn->dwSrcIpAddr, pCmdIn->wSrcPort, MGCP_RSP_COMM, NULL); /* Save the BearerInfo of this endpoint */ ClearBearerInfo(&pEndpoint->BearerInfo); CopyBearerInfo(&pEndpoint->BearerInfo, pCmdIn->u.pEpcfCmd->pBearerInfo); } } break; /* Below states must be impossible */ case SM_INIT: case SM_RESTART_WAIT_CMD: case SM_RESTART: case SM_RESTART_NOTIFY: case SM_WAIT_DISCONNECTED: case SM_DISCONNECTED_WAIT_CMD: Assert(0); break; } }/****************************************************************************** * Function : EndpointParseMgcpEventName * * Description : Check the validity of the event name and translate it * to be the MGCP Event format. The checking includes: * 1) If the package type is supported by endpoint. * 2) If event type is supported by the stack. * 3) If the connection ID is valid to endpoint. * * Input parameters : pEndpoint - Endpoint handle * pEventName - Pointer to EventName to be parsed * * Output parameters : pMgcpEventName - Store the parsed MGCP EventName. If fail * to parse, the content in this struct is * cleared. * pwErrorCode - Error code. * * Return value : OK - If event name is parsed successfully. * FAIL - If fail to parse the event name. * * Comments : * * History : * 2005/09/26 : Creation * * Date : Sep 26 2005, Frank ZHANG ******************************************************************************/LONG EndpointParseMgcpEventName(H_MGCP_ENDPOINT pEndpoint, EVENT_NAME *pEventName, MGCP_EVENT_NAME *pMgcpEventName, WORD *pwErrorCode){ MGCP_PACKAGE Package; MGCP_PKG_EVENT Event; Assert(pEndpoint); Assert(pEventName); Assert(pMgcpEventName); Assert(pwErrorCode); /* If package name is NULL, use the default package; else if fail to find the package ID in the package table, terminate check */ if (pEventName->pcPackageName == NULL) { E_MGCP_PACKAGE* pDefaultPackage; /* Get default package of this endpoint */ SListReset(&pEndpoint->CapabilityList.SupportedPackages); pDefaultPackage = SListGetCurData(&pEndpoint->CapabilityList.SupportedPackages); Package.ePackageType = *pDefaultPackage; } else if (FindMgcpPackageByName(&Package, pEventName->pcPackageName) != OK) { *pwErrorCode = RSP_UNSUPPORTED_PACKAGE; return FAIL; } /* Check whether the package is supported by this endpoint */ if (!EndpointCheckPackageIsSupported(pEndpoint, Package.ePackageType)) { *pwErrorCode = RSP_UNSUPPORTED_PACKAGE; return FAIL; } /* Parse the connection ID */ if (pEventName->pcConnectionId != NULL && ParseMgcpConnectionID(pEventName->pcConnectionId, &pEndpoint->CallList, &pMgcpEventName->ConnectionId) != OK) { *pwErrorCode = RSP_INCORRECT_CONNECTION_ID; return FAIL; } /* Save the package ID */ pMgcpEventName->ePkgID = Package.ePackageType; /* Parser the Event_ID */ switch (pEventName->eType) { case EVENT_ID: if (FindMgcpPkgEventByName(&Event, pEventName->pcEventIDName, Package.ePackageType) != OK) { *pwErrorCode = RSP_NO_SUCH_EVENT_SIGNAL; return FAIL; } pMgcpEventName->EventID.eEventIdType = MGCP_EVENT_ID_SPECI; pMgcpEventName->EventID.u.eEventID = Event.eEventID; break; case EVENT_ALL: pMgcpEventName->EventID.eEventIdType = MGCP_EVENT_ID_SPECI; pMgcpEventName->EventID.u.eEventID = MGCP_EVT_ALL; break; case EVENT_DTMF_ASTERISK: /* Package of "*" Event must be DTMF Package */ if (Package.ePackageType != MGCP_PKG_DTMF) { *pwErrorCode = RSP_NO_SUCH_EVENT_SIGNAL; return FAIL; } pMgcpEventName->EventID.eEventIdType = MGCP_EVENT_ID_SPECI; pMgcpEventName->EventID.u.eEventID = D_DTMF_ASTERISK; break; case EVENT_DTMF_POUND: /* Package of "#" Event must be DTMF Package */ if (Package.ePackageType != MGCP_PKG_DTMF) { *pwErrorCode = RSP_NO_SUCH_EVENT_SIGNAL; return FAIL; } pMgcpEventName->EventID.eEventIdType = MGCP_EVENT_ID_SPECI; pMgcpEventName->EventID.u.eEventID = D_DTMF_POUND; break; case EVENT_RANGE: /* Package of EventRange must be DTMF Package */ if (Package.ePackageType != MGCP_PKG_DTMF) { *pwErrorCode = RSP_NO_SUCH_EVENT_SIGNAL; return FAIL; } pMgcpEventName->EventID.eEventIdType = MGCP_EVENT_ID_RANGE; pMgcpEventName->EventID.u.pEventRange = (MGCP_EVENT_RANGE*)calloc(1, sizeof(MGCP_EVENT_RANGE)); Assert(pMgcpEventName->EventID.u.pEventRange); if (ParseEventRange(pEventName->pcEventIDName, pMgcpEventName->EventID.u.pEventRange, Package.ePackageType) != OK) { ClearMgcpEventName(pMgcpEventName); *pwErrorCode = RSP_NO_SUCH_EVENT_SIGNAL; return FAIL; } break; default: Assert(0); } return OK;}/****************************************************************************** * Function : FindMgcpCallByID * * Description : Find the MGCP call by the call ID. * * Input parameters : pCallList - Pointer to the call list. * pcCallID - Pointer to the call ID. * * Output parameters : ppCall - Store the found call pointer. if it's NULL, no * need to store. * * Return value : TRUE - If call is found. * FALSE - If call is not found. * * Comments : * * History : * 2005/09/27 : Creation * * Date : Sep 27 2005, Frank ZHANG ******************************************************************************/BOOL FindMgcpCallByID(SLIST *pCallList, char *pcCallID, MGCP_CALL **ppCall){ MGCP_CALL *pMgcpCall; Assert(pCallList); Assert(pcCallID); SListReset(pCallList); while((pMgcpCall = SListGetCurData(pCallList)) != NULL) { if (StrCaseCmp(pMgcpCall->pcCallId, pcCallID) == 0) { if (ppCall) *ppCall = pMgcpCall; return TRUE; } SListNextNode(pCallList); } return FALSE;}/****************************************************************************** * Function : FindMgcpConnectionByID * * Description : Find the MGCP connection by the connection ID and return * it. * * Input parameters : pConnecList - Pointer to the connection list. * pcConnectionID - Pointer to the connection ID. * * Output parameters : ppConnection - Store the found connection pointer. * if it's NULL, no need to store. * * Return value : TRUE - If connection is found. * FALSE - If connection is not found. * * Comments : * * History : * 2005/09/27 : Creation * * Date : Sep 27 2005, Frank ZHANG ******************************************************************************/BOOL FindMgcpConnectionByID(SLIST *pConnecList, char *pcConnectionID, MGCP_CONNECTION **ppConnection){ MGCP_CONNECTION *pMgcpConn; Assert(pConnecList); Assert(pcConnectionID); SListReset(pConnecList); while((pMgcpConn = SListGetCurData(pConnecList)) != NULL) { if (StrCaseCmp(Ultoa(pMgcpConn->dwConnectionID), pcConnectionID) == 0) { if (ppConnection) *ppConnection = pMgcpConn; return TRUE; } SListNextNode(pConnecList); } return FALSE;}/****************************************************************************** * Function : ParseMgcpConnectionID * * Description : Parse the connection ID to be MGCP connection type. * * Input parameters : pcConnectionId - Pointer to connection ID. * pCallList - Pointer to MGCP call list. * * Output parameters : pConnection - Store the parsed MGCP connection info. * * Return value : OK - If connection is parsed successfully. * FAIL - If fail to parse the connection. * * Comments : * * History : * 2005/09/29 : Creation * * Date : Sep 29 2005, Frank ZHANG ******************************************************************************/LONG ParseMgcpConnectionID(char *pcConnectionId, SLIST *pCallList, MGCP_CONNEC_ID *pConnection){ MGCP_CALL *pCall; Assert(pcConnectionId); Assert(pCallList); Assert(pConnection); if (pcConnectionId != NULL) { if (StrCaseCmp(pcConnectionId, WILDCARD_ALL) == 0) { /* All connection */ pConnection->eConnecType = CONNEC_ALL; return OK; } else if (StrCaseCmp(pcConnectionId, WILDCARD_CUR) == 0) { /* Current connection */ pConnection->eConnecType = CONNEC_CURRENT; return OK; } else /* Specific connection */ { /* Get the connection ID */ SListReset(pCallList); while ((pCall = SListGetCurData(pCallList)) != NULL) { MGCP_CONNECTION *pMgcpConnection; if (FindMgcpConnectionByID(&pCall->ConnectionList, pcConnectionId, &pMgcpConnection)) { pConnection->eConnecType = CONNEC_SPECIFIC; pConnection->dwConnecID = pMgcpConnection->dwConnectionID; return OK; } SListNextNode(pCallList); } } } return FAIL;}/****************************************************************************** * Function : EndpointParseRequestedSignals * * Description : Calculate the RTO of the endpoint * * Input parameters : pEndpoint - Endpoint handle * pSigReq - Pointer to requested signals. * bEmbeddedRqnt - If the requested signals are in embedded RQNT. * Output parameters : pSigList - List to store the parsed Mgcp Signals * pwErrorCode - Error code if fail to parse. * * Return value : Return OK if succeed to parse the requested signals; * otherwise return FAIL. * * Comments : * * History
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -