mgcpmsgtran.c
来自「mgcp协议源代码和测试程序,还有一个编译器」· C语言 代码 · 共 1,868 行 · 第 1/5 页
C
1,868 行
* * Comments : * * History : * 2005/08/17 : Creation * * Date : Aug 17 2005, Frank Zhang ******************************************************************************/LONG FillEPCFCommand(MGCP_EPCF_CMD *pDesData, WORD wNum, TMGCPParameter *pSrcData) { int i = 0; TMGCPParameter *pParam = NULL; Assert(pDesData); /* Fill every parameter in the list */ for(i = 0; i < wNum; i++) { pParam = pSrcData + i; switch (pParam->iType) { /* Optional parameters */ /* Response ack */ case MGCPParameter_ParamResponseAck: pDesData->pRspAck = (RESPONSE_ACK*)calloc(1, sizeof(RESPONSE_ACK)); Assert(pDesData->pRspAck); // memset(pDesData->pRspAck, 0, sizeof(RESPONSE_ACK)); if (pSrcData->u.ParamResponseAck.ResponseAck.flag) FillResponseAck(pDesData->pRspAck, (TResponseAck*)pParam->u.ParamResponseAck.ResponseAck.pRuleData); break; /* Bearer info */ case MGCPParameter_ParamBearerInformation: pDesData->pBearerInfo = (BEARER_INFO*)calloc(1, sizeof(BEARER_INFO)); Assert(pDesData->pBearerInfo); // memset(pDesData->pBearerInfo, 0, sizeof(BEARER_INFO)); if (pParam->u.ParamBearerInformation.BearerInformation.flag) FillBearerInfo(pDesData->pBearerInfo, (TBearerInformation*)pParam->u.ParamBearerInformation.BearerInformation.pRuleData); break; /* Forbidden parameters */ case MGCPParameter_ParamCallId: case MGCPParameter_ParamConnectionId: case MGCPParameter_ParamNotifiedEntity: case MGCPParameter_ParamRequestIdentifier: case MGCPParameter_ParamLocalConnectionOptions: case MGCPParameter_ParamConnectionMode: case MGCPParameter_ParamRequestedEvents: case MGCPParameter_ParamSignalRequests: case MGCPParameter_ParamDigitMap: case MGCPParameter_ParamObservedEvents: case MGCPParameter_ParamConnectionParameters: case MGCPParameter_ParamReasonCode: case MGCPParameter_ParamSpecificEndpointID: case MGCPParameter_ParamSecondEndpointID: case MGCPParameter_ParamSecondConnectionID: case MGCPParameter_ParamRequestedInfo: case MGCPParameter_ParamQuarantineHandling: case MGCPParameter_ParamDetectEvents: case MGCPParameter_ParamRestartMethod: case MGCPParameter_ParamRestartDelay: case MGCPParameter_ParamCapabilities: case MGCPParameter_ParamEventStates: case MGCPParameter_ParamPackageList: case MGCPParameter_ParamMaxMGCPDatagram: DEBUG(LogMSG(LOG_ERROR, "\nForbidden parameter line in EPCF command!");); return FAIL; break; case MGCPParameter_ExtendedParameter: FillExperimentalParameters(&pDesData->ExperiParamList, &pParam->u.ExtendedParameter); break; default: Assert(0); return FAIL; } } return OK;}/******************************************************************************* * Function : FillCRCXCommand * * Description : Fill the mgcp CRCX command according to the MGCP abnf * parameter lines * * Input parameters : wNum - Number of the parameters in the abnf parameter * line * pSrcData - Pointer to the abnf parameter lines * * Output parameters : pDesData - Pointer to the filled MGCP CRCX command * * Return value : Return OK if all the parameters are valid, otherwise * return FAIL. * * Comments : * * History : * 2005/08/17 : Creation * * Date : Aug 17 2005, Frank Zhang ******************************************************************************/LONG FillCRCXCommand(MGCP_CRCX_CMD *pDesData, WORD wNum, TMGCPParameter *pSrcData) { int i = 0; TMGCPParameter *pParam = NULL; /* Default contain no enccap rqnt */ BOOL bEncapRqnt = FALSE; /* Mandatory parameter number */ WORD wManParamNum = 0; Assert(pDesData); /* Fill every parameter in the list */ for(i = 0; i < wNum; i++) { pParam = pSrcData + i; switch (pParam->iType) { /* Mandatory parameters */ case MGCPParameter_ParamCallId: wManParamNum++; StrClone(&pDesData->pcCallId, pParam->u.ParamCallId.CallId); break; case MGCPParameter_ParamConnectionMode: wManParamNum++; pDesData->pMode = (CONNECTION_MODE*)calloc(1, sizeof(CONNECTION_MODE)); Assert(pDesData->pMode); // memset(pDesData->pMode, 0, sizeof(CONNECTION_MODE)); FillConnectionMode(pDesData->pMode, &pParam->u.ParamConnectionMode.ConnectionMode); break; /* Optional parameters */ case MGCPParameter_ParamBearerInformation: pDesData->pEncapEpcf = (ENCAPSULATED_EPCF*)calloc(1, sizeof(ENCAPSULATED_EPCF)); Assert(pDesData->pEncapEpcf); memset(pDesData->pEncapEpcf, 0, sizeof(ENCAPSULATED_EPCF)); pDesData->pEncapEpcf->pBearerInfo = (BEARER_INFO*)calloc(1, sizeof(BEARER_INFO)); Assert(pDesData->pEncapEpcf->pBearerInfo); // memset(pDesData->pEncapEpcf->pBearerInfo, 0, sizeof(BEARER_INFO)); if (pParam->u.ParamBearerInformation.BearerInformation.flag) FillBearerInfo(pDesData->pEncapEpcf->pBearerInfo, (TBearerInformation*)pParam->u.ParamBearerInformation.BearerInformation.pRuleData); break; case MGCPParameter_ParamDetectEvents: if (!bEncapRqnt) { pDesData->pEncapRqnf = (ENCAPSULATED_RQNT*)calloc(1, sizeof(ENCAPSULATED_RQNT)); Assert(pDesData->pEncapRqnf); // memset(pDesData->pEncapRqnf, 0, sizeof(ENCAPSULATED_RQNT)); bEncapRqnt = TRUE; } pDesData->pEncapRqnf->pDetectEvents = (DETECT_EVENTS*)calloc(1, sizeof(DETECT_EVENTS)); Assert(pDesData->pEncapRqnf->pDetectEvents); // memset(pDesData->pEncapRqnf->pDetectEvents, 0, sizeof(DETECT_EVENTS)); if (pParam->u.ParamDetectEvents.DetectEvents.flag) FillDetectEvents(pDesData->pEncapRqnf->pDetectEvents, (TSignalRequests*)pParam->u.ParamDetectEvents.DetectEvents.pRuleData); break; case MGCPParameter_ParamDigitMap: if (!bEncapRqnt) { pDesData->pEncapRqnf = (ENCAPSULATED_RQNT*)calloc(1, sizeof(ENCAPSULATED_RQNT)); Assert(pDesData->pEncapRqnf); // memset(pDesData->pEncapRqnf, 0, sizeof(ENCAPSULATED_RQNT)); bEncapRqnt = TRUE; } pDesData->pEncapRqnf->pDigitMap= (DIGIT_MAP*)calloc(1, sizeof(DIGIT_MAP)); Assert(pDesData->pEncapRqnf->pDigitMap); // memset(pDesData->pEncapRqnf->pDigitMap, 0, sizeof(DIGIT_MAP)); if (pParam->u.ParamDigitMap.DigitMap.flag) FillDigitMap(pDesData->pEncapRqnf->pDigitMap, (TDigitMap*)pParam->u.ParamDigitMap.DigitMap.pRuleData); break; case MGCPParameter_ParamLocalConnectionOptions: pDesData->pLocalConnecOpt = (LOCAL_CONNEC_OPTS*)calloc(1, sizeof(LOCAL_CONNEC_OPTS)); Assert(pDesData->pLocalConnecOpt); memset(pDesData->pLocalConnecOpt, 0, sizeof(LOCAL_CONNEC_OPTS)); if (pParam->u.ParamLocalConnectionOptions.LocalConnectionOptions.flag) FillLocalConnectionOpts(pDesData->pLocalConnecOpt, (TLocalConnectionOptions*)pParam->u.ParamLocalConnectionOptions.LocalConnectionOptions.pRuleData); break; case MGCPParameter_ParamNotifiedEntity: pDesData->pNotifiedEntity = (NOTIFIED_ENTITY*)calloc(1, sizeof(NOTIFIED_ENTITY)); Assert(pDesData->pNotifiedEntity); // memset(pDesData->pNotifiedEntity, 0, sizeof(NOTIFIED_ENTITY)); if (pParam->u.ParamNotifiedEntity.NotifiedEntity.flag) FillNotifiedEntity(pDesData->pNotifiedEntity, (TNotifiedEntity*)pParam->u.ParamNotifiedEntity.NotifiedEntity.pRuleData); break; case MGCPParameter_ParamQuarantineHandling: if (!bEncapRqnt) { pDesData->pEncapRqnf = (ENCAPSULATED_RQNT*)calloc(1, sizeof(ENCAPSULATED_RQNT)); Assert(pDesData->pEncapRqnf); // memset(pDesData->pEncapRqnf, 0, sizeof(ENCAPSULATED_RQNT)); bEncapRqnt = TRUE; } pDesData->pEncapRqnf->pQuarantineHandling = (QUARANTINE_HANDLING*)calloc(1, sizeof(QUARANTINE_HANDLING)); Assert(pDesData->pEncapRqnf->pQuarantineHandling); // memset(pDesData->pEncapRqnf->pQuarantineHandling, 0, sizeof(QUARANTINE_HANDLING)); FillQuarantineHandling(pDesData->pEncapRqnf->pQuarantineHandling, &pParam->u.ParamQuarantineHandling.QuarantineHandling); break; case MGCPParameter_ParamRequestedEvents: if (!bEncapRqnt) { pDesData->pEncapRqnf = (ENCAPSULATED_RQNT*)calloc(1, sizeof(ENCAPSULATED_RQNT)); Assert(pDesData->pEncapRqnf); // memset(pDesData->pEncapRqnf, 0, sizeof(ENCAPSULATED_RQNT)); bEncapRqnt = TRUE; } pDesData->pEncapRqnf->pRequestedEvents = (REQUESTED_EVENTS*)calloc(1, sizeof(REQUESTED_EVENTS)); Assert(pDesData->pEncapRqnf->pRequestedEvents); // memset(pDesData->pEncapRqnf->pRequestedEvents, 0, sizeof(REQUESTED_EVENTS)); if (pParam->u.ParamRequestedEvents.RequestedEvents.flag) FillRequestEvents(pDesData->pEncapRqnf->pRequestedEvents, (TRequestedEvents*)pParam->u.ParamRequestedEvents.RequestedEvents.pRuleData); break; case MGCPParameter_ParamRequestIdentifier: if (!bEncapRqnt) { pDesData->pEncapRqnf = (ENCAPSULATED_RQNT*)calloc(1, sizeof(ENCAPSULATED_RQNT)); Assert(pDesData->pEncapRqnf); // memset(pDesData->pEncapRqnf, 0, sizeof(ENCAPSULATED_RQNT)); bEncapRqnt = TRUE; } if (pParam->u.ParamRequestIdentifier.RequestIdentifier.flag) StrClone(&pDesData->pEncapRqnf->pcRequestIdentifier, (char*)pParam->u.ParamRequestIdentifier.RequestIdentifier.pRuleData); break; case MGCPParameter_ParamResponseAck: pDesData->pRspAck = (RESPONSE_ACK*)calloc(1, sizeof(RESPONSE_ACK)); Assert(pDesData->pRspAck); // memset(pDesData->pRspAck, 0, sizeof(RESPONSE_ACK)); if (pParam->u.ParamResponseAck.ResponseAck.flag) FillResponseAck(pDesData->pRspAck, (TResponseAck*)pParam->u.ParamResponseAck.ResponseAck.pRuleData); break; case MGCPParameter_ParamSecondEndpointID: pDesData->pSecondEndpointId = (ENDPOINT_NAME*)calloc(1, sizeof(ENDPOINT_NAME)); Assert(pDesData->pSecondEndpointId); // memset(pDesData->pSecondEndpointId, 0, sizeof(ENDPOINT_NAME)); FillEndpointName(pDesData->pSecondEndpointId, &pParam->u.ParamSecondEndpointID.SecondEndpointID); break; case MGCPParameter_ParamSignalRequests: if (!bEncapRqnt) { pDesData->pEncapRqnf = (ENCAPSULATED_RQNT*)calloc(1, sizeof(ENCAPSULATED_RQNT)); Assert(pDesData->pEncapRqnf); // memset(pDesData->pEncapRqnf, 0, sizeof(ENCAPSULATED_RQNT)); bEncapRqnt = TRUE; } pDesData->pEncapRqnf->pSignalRequests = (SIGNAL_REQUESTS*)calloc(1, sizeof(SIGNAL_REQUESTS)); Assert(pDesData->pEncapRqnf->pSignalRequests); // memset(pDesData->pEncapRqnf->pSignalRequests, 0, sizeof(SIGNAL_REQUESTS)); if (pParam->u.ParamSignalRequests.SignalRequests.flag) FillSignalRequests(pDesData->pEncapRqnf->pSignalRequests, (TSignalRequests*)pParam->u.ParamSignalRequests.SignalRequests.pRuleData); break; /* Forbidden parameters */ case MGCPParameter_ParamCapabilities: case MGCPParameter_ParamConnectionId: case MGCPParameter_ParamConnectionParameters: case MGCPParameter_ParamEventStates: case MGCPParameter_ParamMaxMGCPDatagram: case MGCPParameter_ParamObservedEvents: case MGCPParameter_ParamPackageList: case MGCPParameter_ParamReasonCode: case MGCPParameter_ParamRequestedInfo: case MGCPParameter_ParamRestartDelay: case MGCPParameter_ParamRestartMethod: case MGCPParameter_ParamSecondConnectionID: case MGCPParameter_ParamSpecificEndpointID: DEBUG(LogMSG(LOG_ERROR, "\nForbidden parameter line in CRCX command!");); return FAIL; break; case MGCPParameter_ExtendedParameter: FillExperimentalParameters(&pDesData->ExperiParamList, &pParam->u.ExtendedParameter); break; default: Assert(0); return FAIL; } } if (wManParamNum != MGCP_CRCX_CMD_MAN_NUMBER) { DEBUG(LogMSG(LOG_ERROR, "\nMissing mandatory parameter line in CRCX command!");); return FAIL; } return OK;}/******************************************************************************* * Function : FillMDCXCommand * * Description : Fill the mgcp MDCX command according to the MGCP abnf * parameter lines * * Input parameters : wNum - Number of the parameters in the abnf parameter * line * pSrcData - Pointer to the abnf parameter lines * * Output parameters : pDesData - Pointer to the filled MGCP MDCX command * * Return value : Return OK if all the parameters are valid, otherwise * return FAIL. * * Comments : * * History : * 2005/08/17 : Creation * * Date : Aug 17 2005, Frank Zhang ******************************************************************************/LONG FillMDCXCommand(MGCP_MDCX_CMD *pDesData, WORD wNum, TMGCPParameter *pSrcData) { int i = 0; TMGCPParameter *pParam = NULL; /* Default contain no enccap rqnt */ BOOL bEncapRqnt = FALSE; /* Mandatory parameter number */ WORD wManParamNum = 0;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?