📄 transacmng.c
字号:
&pMgcpRsp->dwTransacId, FindMgcpCmdOutByTranID) != NULL) { pTranCmdOut = SListGetCurData(&pTransacMng->MsgList.CmdSentPiggybackList); /* Check if the incoming response is a provisional response*/ if (pMgcpRsp->wRspCode >= RSP_PROVISIONAL_MIN && pMgcpRsp->wRspCode <= RSP_PROVISIONAL_MAX) { /* Stretch the RTO to be the LONGTRAN-TIMER */ pTranCmdOut->dwRTO = pTransacMng->dwTimerLongTR; } else { /* Remove the command from the piggybacking command out list */ SListDelCurNode(&pTransacMng->MsgList.CmdSentPiggybackList); bRspNeedProcess = TRUE; } } /* Command associated this response found and need further process ? */ if (bRspNeedProcess && pTranCmdOut != NULL) { /* Firstly check if this response need ack, if yes, send Ack response */ if (pTransacMng->bUseProvisionalRspProcedure && pMgcpRsp->ParamLineList.pResponseAck != NULL && pMgcpRsp->ParamLineList.pResponseAck->wNum == 0) { TRANSAC_RSPACK_OUT *pRspAck = (TRANSAC_RSPACK_OUT*)calloc(1, sizeof(TRANSAC_RSPACK_OUT)); Assert(pRspAck); pRspAck->dwTransacId = pMgcpRsp->dwTransacId; Assert(pRspAck->dwTransacId == pTranCmdOut->dwTransacId); /* Add the Transaction response ack into RSP ACK list */ SListAppend(&pTransacMng->MsgList.AckRspSentList, pRspAck); /* Send out response ack */ SendMgcpRspAckOut(pTransacMng, pMgcpRsp->dwTransacId); } /* Check if the piggybacking commands/responses piggybacked the command associated to this incoming response, if yes, remove the command ID from the piggybacking CmdID table */ RemovePiggyBackingCmdID(pTranCmdOut->pCmdOut->dwCmdId, &pTransacMng->MsgList); /* Create the mgcp response message */ pRspIn = (MGCP_RSP_IN*)calloc(1, sizeof(MGCP_RSP_IN)); Assert(pRspIn); pRspIn->wRspCode = pMgcpRsp->wRspCode; pRspIn->dwCmdId = pTranCmdOut->pCmdOut->dwCmdId; pRspIn->hEndpointHandle = pTranCmdOut->pCmdOut->hEndpointHandle; Assert(pRspIn->hEndpointHandle); /* Recompute deviation of Round Trip delay (RTT). NOTE: This is only done if the response is not to a retransmission to avoid "Retransmission ambiguity problem" mentioned in (TCP/IP standard) */ if (pTranCmdOut->wRetranCounter == 0) pRspIn->dwRTTDelay = pTranCmdOut->dwTimeDuration; /* Fill response message data */ switch(pTranCmdOut->pCmdOut->eType) { case MGCP_CMD_RSIP: pRspIn->eType = MGCP_RSP_RSIP; pRspIn->u.pRsipRsp = (MGCP_RSIP_RSP*)calloc(1, sizeof(MGCP_RSIP_RSP)); Assert(pRspIn->u.pRsipRsp); if (pMgcpRsp->ParamLineList.pNotifiedEntity != NULL) { pRspIn->u.pRsipRsp->pNotifiedEntity = pMgcpRsp->ParamLineList.pNotifiedEntity; pMgcpRsp->ParamLineList.pNotifiedEntity = NULL; } CopyExperimentalParameters(&pRspIn->u.pRsipRsp->ExperiParamList, &pMgcpRsp->ParamLineList.ExperiParamList); break; case MGCP_CMD_NTFY: pRspIn->eType = MGCP_RSP_NTFY; pRspIn->u.pNtfyRsp = (MGCP_NTFY_RSP*)calloc(1, sizeof(MGCP_NTFY_RSP)); Assert(pRspIn->u.pNtfyRsp); CopyExperimentalParameters(&pRspIn->u.pNtfyRsp->ExperiParamList, &pMgcpRsp->ParamLineList.ExperiParamList); break; case MGCP_CMD_DLCX: pRspIn->eType = MGCP_RSP_DLCX; pRspIn->u.pDlcxRsp = (MGCP_DLCX_RSP*)calloc(1, sizeof(MGCP_DLCX_RSP)); Assert(pRspIn->u.pDlcxRsp); CopyExperimentalParameters(&pRspIn->u.pDlcxRsp->ExperiParamList, &pMgcpRsp->ParamLineList.ExperiParamList); break; default: Assert(0); DEBUG(LogMSG(LOG_ERROR, "\nUnSupported Incoming response for MG!");); return; } /* Construct a message and send to EndpointCtrl */ memset(&Msg, 0, sizeof(MGCP_STACK_MSG)); Msg.eMsgCode = M_INCOMING_RSP; Msg.pMsgData = pRspIn; SendMsgToEndpointCtrl((H_MGCP_ENDPOINT_CONTROL) pTransacMng->pStack->pEndpointCtl, &Msg); /* Clear this responsed MGCP command */ ClearTranCmdOut(pTranCmdOut); free(pTranCmdOut); }}/****************************************************************************** * Function : ProcessOutGoingMgcpCmd * * Description : Process the Mgcp outgoing command requested by * EndpointCtrl; construct a transaction outgoing command * and send out. * * Input parameters : pTransacMng - TransactionManager handle * pCmdOut - Pointer to outgoing Mgcp command sent by * EndpointCtrl * * Output parameters : * * Return value : None * * Comments : * * History : * 2005/09/05 : Creation * * Date : Sep 05 2005, Frank ZHANG ******************************************************************************/void ProcessOutGoingMgcpCmd(H_MGCP_TRANSAC_MANAGER pTransacMng, MGCP_CMD_OUT *pCmdOut){ TRANSAC_CMD_OUT *pTranCmdOut = NULL; Assert(pTransacMng); Assert(pCmdOut); pTranCmdOut = (TRANSAC_CMD_OUT*)calloc(1, sizeof(TRANSAC_CMD_OUT)); Assert(pTranCmdOut); /* Transaction ID of the outgoing command */ pTranCmdOut->dwTransacId = GetNewTransacID(pTransacMng); /* RTO value of the outgoing command */ pTranCmdOut->dwRTO = pCmdOut->dwInitRTO; /* Command data */ pTranCmdOut->pCmdOut = pCmdOut; /* Add this outgoing command into cmd send list */ if (pCmdOut->wPiggyCmdNum > 0) SListAppend(&pTransacMng->MsgList.CmdSentPiggybackList, pTranCmdOut); else SListAppend(&pTransacMng->MsgList.CmdSentList, pTranCmdOut); /* Send the command out */ SendMgcpCmdOut(pTransacMng, pTranCmdOut);}/****************************************************************************** * Function : ProcessOutGoingMgcpRsp * * Description : Process the Mgcp outgoing response requested by * EndpointCtrl; if find the incoming command associated with * this response, construct a transaction outgoing response * and send out. * * Input parameters : pTransacMng - TransactionManager handle * pRspOut - Pointer to outgoing Mgcp response sent by * EndpointCtrl * * Output parameters : * * Return value : None * * Comments : * * History : * 2005/09/07 : Creation * * Date : Sep 07 2005, Frank ZHANG ******************************************************************************/void ProcessOutGoingMgcpRsp(H_MGCP_TRANSAC_MANAGER pTransacMng, MGCP_RSP_OUT *pRspOut){ TRANSAC_CMD_IN *pTranCmdIn = NULL; Assert(pTransacMng); Assert(pRspOut); /* Find the incoming transaction command associated with this response */ if (SListFind(&pTransacMng->MsgList.CmdInProcessList, &pRspOut->dwTransacId, FindMgcpCmdInByTranID) != NULL) { pTranCmdIn = SListGetCurData(&pTransacMng->MsgList.CmdInProcessList); /* Check if the outgoing rsp need ack */ if (pTranCmdIn->bProvisionalRspOut && pTransacMng->bUseProvisionalRspProcedure) { /* Provisional response to this incoming command has been sent out, so this response need ack */ TRANSAC_RSP_WAIT_ACK *pTranPiggyRspOut = (TRANSAC_RSP_WAIT_ACK*)calloc(1, sizeof(TRANSAC_RSP_WAIT_ACK)); Assert(pTranPiggyRspOut); /* Calculate RTO */ pTranPiggyRspOut->dwRTO = RTO_DEFAULT; /* Response data */ pTranPiggyRspOut->pRspOut = pRspOut; /* Add this outgoing response into RspSendWaitAck list */ if (pRspOut->wPiggyCmdNum > 0) SListAppend(&pTransacMng->MsgList.RspSentPiggyWaitAckList, pTranPiggyRspOut); else SListAppend(&pTransacMng->MsgList.RspSentWaitAckList, pTranPiggyRspOut); /* Send the response out */ SendMgcpRspOut(pTransacMng, pRspOut, TRUE); } else { TRANSAC_RSP_OUT *pTranRspOut = (TRANSAC_RSP_OUT*)calloc(1, sizeof(TRANSAC_RSP_OUT)); Assert(pTranRspOut); /* Response data */ pTranRspOut->pRspOut = pRspOut; /* Add this outgoing response into Rspsend list */ if (pRspOut->wPiggyCmdNum > 0) SListAppend(&pTransacMng->MsgList.RspSentPiggybackList, pTranRspOut); else SListAppend(&pTransacMng->MsgList.RspSentList, pTranRspOut); } /* Free the memory allocated for the incoming transaction command */ free(pTranCmdIn); /* Remove the incoming transaction command from the command list*/ SListDelCurNode(&pTransacMng->MsgList.CmdInProcessList); /* Check if the command list is bellow the low water mark */ if (pTransacMng->MsgList.CmdInProcessList.count <= pTransacMng->MsgList.wLowWaterMark) pTransacMng->MsgList.bQueueIsFull = FALSE; /* Send the response out */ SendMgcpRspOut(pTransacMng, pRspOut, FALSE); } else { Assert(0); DEBUG(LogMSG(LOG_ERROR, "\nCannot find the outgoing response's associate command!");); }}/****************************************************************************** * Function : ProcessUpdataNotifiedEntityMsg * * Description : Process the NotifiedEntity updata message requested by * EndpointCtrl; According to RFC3435, if NE is update, all * the outgoing commands need retransmission. * * Input parameters : pTransacMng - TransactionManager handle * pRspOut - Pointer to M_UPDATE_NE message data sent by * EndpointCtrl. * * Output parameters : * * Return value : None * * Comments : * * History : * 2005/09/10 : Creation * * Date : Sep 10 2005, Frank ZHANG ******************************************************************************/void ProcessUpdataNotifiedEntityMsg(H_MGCP_TRANSAC_MANAGER pTransacMng, MSG_DATA_UPDATE_NE *pMsgData){ TRANSAC_CMD_OUT *pTranCmdOut; Assert(pTransacMng); Assert(pMsgData); /* Find the outgoing commands and resend to the new NE address */ SListReset(&pTransacMng->MsgList.CmdSentList); while ((pTranCmdOut = SListGetCurData(&pTransacMng->MsgList.CmdSentList)) != NULL) { /* If the time duration no more than the T-MAX ? */ if (pTranCmdOut->pCmdOut->hEndpointHandle == pMsgData->hEndpoint && pTranCmdOut->dwTimeDuration <= pTransacMng->dwTimerMax) { /* Change the NE to be the new */ ClearNotifiedEntity(&pTranCmdOut->pCmdOut->NotifiedEntity); CopyNotifiedEntity(&pTranCmdOut->pCmdOut->NotifiedEntity, &pMsgData->NewNotifiedEntity); /* Resend the command to the new NE */ SendMgcpCmdOut(pTransacMng, pTranCmdOut); /* Reset the retransmissiont couter */ pTranCmdOut->wRetranCounter = 0; } SListNextNode(&pTransacMng->MsgList.CmdSentList); } /* Find the outgoing piggybacking commands and resend to the new NE address */ SListReset(&pTransacMng->MsgList.CmdSentPiggybackList); while ((pTranCmdOut = SListGetCurData(&pTransacMng->MsgList.CmdSentPiggybackList)) != NULL) { /* If the time duration no more than the T-MAX ? */ if (pTranCmdOut->pCmdOut->hEndpointHandle == pMsgData->hEndpoint && pTranCmdOut->dwTimeDuration <= pTransacMng->dwTimerMax) { /* Change the NE to be the new */ ClearNotifiedEntity(&pTranCmdOut->pCmdOut->NotifiedEntity); CopyNotifiedEntity(&pTranCmdOut->pCmdOut->NotifiedEntity, &pMsgData->NewNotifiedEntity); /* Resend the command to the new NE */ SendMgcpCmdOut(pTransacMng, pTranCmdOut); /* Reset the retransmissiont couter */ pTranCmdOut->wRetranCounter = 0; } SListNextNode(&pTransacMng->MsgList.CmdSentPiggybackList); } /* Free the message data */ ClearNotifiedEntity(&pMsgData->NewNotifiedEntity); free(pMsgData);}/****************************************************************************** * Function : ProcessResponseOutTimeOut * * Description : Check if every Mgcp outgoing transaction response in the * response list is expired, if yes, remove it from the * response list, otherwise update the elapse time. * * Input parameters : pTransacMng - TransactionManager handle * pRspOutList - Pointer to outgoing Mgcp response list * * Output parameters : * * Return value : None * * Comments : * * History : * 2005/09/10 : Creation * * Date : Sep 10 2005, Frank ZHANG ******************************************************************************/void ProcessResponseOutTimeOut(H_MGCP_TRANSAC_MANAGER pTransacMng, SLIST *pRspOutList){ TRANSAC_RSP_OUT *pRspOut;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -