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

📄 endpointctrl.c

📁 内容正如其名
💻 C
📖 第 1 页 / 共 5 页
字号:
 * Comments          :  * * History           : *  2005/09/20       : Creation * * Date              : Sep 20 2005, Frank ZHANG ******************************************************************************/void FillPiggybackCmdIDS(WORD *pwCmdNum, DWORD *pdwCmdIdTable, SLIST *pSrc){  DWORD *pdwCmdID;    Assert(pwCmdNum);  Assert(pdwCmdIdTable);  Assert(pSrc);  Assert(*pwCmdNum == 0);  if (pSrc != NULL && pSrc->count > 0)  {    SListReset(pSrc);    while ((pdwCmdID = SListGetCurData(pSrc)) != NULL)    {      pdwCmdIdTable[*pwCmdNum] = *pdwCmdID;      (*pwCmdNum)++;            /* Check if piggybacking command number reach upper limit */      if ((*pwCmdNum) >= MAX_PIGGY_MSG_NUM)        break;      SListNextNode(pSrc);    }  }}/****************************************************************************** * Function          : MgcpEndpointCtrlSendRspOut * * Description       : Construct a MGCP response message and send it to *                     TransacMng. This function is only used when EndpointCtrl *                     receive a invalid MGCP command and no need to transfer it *                     it specific endpoint for further process. *                      * Input parameters  : pEndpntCtrl - EndpointCtrl handle. *                     wRspCode - Response code of the MGCP response. *                     pcRspString - Descripting string of the MGCP response. *                     dwTranID - Transaction ID of the MGCP response. *                     dwDesIpAddr - Destination IP address of the response. *                     wDesPort - Destination port of the response. *                     eRspType - Response type. *                     pRspData - Pointer to the response data. * * Output parameters :  * * Return value      : None * * Comments          :  * * History           : *  2005/09/21       : Creation * * Date              : Sep 21 2005, Frank ZHANG ******************************************************************************/void MgcpEndpointCtrlSendRspOut(H_MGCP_ENDPOINT_CONTROL pEndpntCtrl,                                WORD wRspCode, char *pcRspString,                                DWORD dwTranID, DWORD dwDesIpAddr,                                WORD wDesPort, E_MGCP_RSP eRspType,                                void *pRspData){  MGCP_STACK_MSG Msg;  MGCP_RSP_OUT *pRsp = (MGCP_RSP_OUT*)calloc(1, sizeof(MGCP_RSP_OUT));  Assert(pRsp);  /* Response code */  pRsp->wRspCode = wRspCode;  /* Response string */  if (pcRspString != NULL)    StrClone(&pRsp->pcRspString, pcRspString);  else    StrClone(&pRsp->pcRspString, FindRspStringByCode(pRsp->wRspCode));  /* Transaction ID */  pRsp->dwTransacId = dwTranID;  /* Destination address */  pRsp->dwDesIpAddr = dwDesIpAddr;  pRsp->wDesPort = wDesPort;  pRsp->eType = eRspType;  pRsp->u.pEpcfRsp = pRspData;  Msg.eMsgCode = M_OUTGOING_RSP;  Msg.pMsgData = pRsp;    SendMsgToTransationManager((H_MGCP_TRANSAC_MANAGER)                              pEndpntCtrl->pStack->pTransacMng, &Msg);      }/****************************************************************************** * Function          : EndpointReturnSupportedPackages * * Description       : Copy the SupportedPackages of the endpoint into the *                     PackageList and return. *                      * Input parameters  : pEndpoint - Endpoint handle  * * Output parameters : ppPkgList - Pointer to the SupportedPackages of the *                                 endpoint. * * Return value      : None * * Comments          :  * * History           : *  2005/09/21       : Creation * * Date              : Sep 21 2005, Frank ZHANG ******************************************************************************/void EndpointReturnSupportedPackages(H_MGCP_ENDPOINT pEndpoint, PACKAGE_LIST **ppPkgList){  PACKAGE_LIST *pTmpPkgList = NULL;  E_MGCP_PACKAGE *pPkgID;  MGCP_PACKAGE Package;  WORD i = 0;  Assert(pEndpoint->CapabilityList.SupportedPackages.count > 0);  /* Allocate momeries */  pTmpPkgList = (PACKAGE_LIST*)calloc(1, sizeof(PACKAGE_LIST));  Assert(pTmpPkgList);  pTmpPkgList->wNum = (WORD)pEndpoint->CapabilityList.SupportedPackages.count;  pTmpPkgList->pPackageList  = (PKG_NAME_AND_VERS*)calloc(pTmpPkgList->wNum,                                                    sizeof(PKG_NAME_AND_VERS));  Assert(pTmpPkgList->pPackageList);  /* Fill supported packages */  SListReset(&pEndpoint->CapabilityList.SupportedPackages);  while((pPkgID = SListGetCurData(&pEndpoint->CapabilityList.SupportedPackages)) != NULL)  {    memset(&Package, 0, sizeof(Package));    if (FindMgcpPackageByID(&Package, *pPkgID) == OK)    {      StrClone(&pTmpPkgList->pPackageList[i].pcPackageName, Package.Name);      pTmpPkgList->pPackageList[i].dwVersion = Package.dwPackageVersion;    }    i++;    SListNextNode(&pEndpoint->CapabilityList.SupportedPackages);  }  Assert(i == pTmpPkgList->wNum);  *ppPkgList = pTmpPkgList;}/****************************************************************************** * Function          : MgcpEndpointSendRspOut * * Description       : Construct a MGCP response message and send it to *                     TransacMng. *                      * Input parameters  : pEndpoint - Endpoint handle. *                     wRspCode - Response code of the MGCP response. *                     pcRspString - Descripting string of the MGCP response. *                     dwTranID - Transaction ID of the MGCP response. *                     dwDesIpAddr - Destination IP address of the response. *                     wDesPort - Destination port of the response. *                     eRspType - Response type. *                     pRspData - Response data. * * Output parameters :  * * Return value      : None * * Comments          :  * * History           : *  2005/09/22       : Creation * * Date              : Sep 22 2005, Frank ZHANG ******************************************************************************/void MgcpEndpointSendRspOut(H_MGCP_ENDPOINT pEndpoint, WORD wRspCode,                            char *pcRspString, DWORD dwTranID,                            DWORD dwDesIpAddr, WORD wDesPort,                            E_MGCP_RSP eRspType, void *pRspData){  MGCP_STACK_MSG Msg;  MGCP_RSP_OUT *pRsp = (MGCP_RSP_OUT*)calloc(1, sizeof(MGCP_RSP_OUT));  Assert(pRsp);  /* Response code */  pRsp->wRspCode = wRspCode;  /* Response string */  if (pcRspString != NULL)    StrClone(&pRsp->pcRspString, pcRspString);  else    StrClone(&pRsp->pcRspString, FindRspStringByCode(pRsp->wRspCode));  /* Transaction ID */  pRsp->dwTransacId = dwTranID;  /* Piggybacking commands */  FillPiggybackCmdIDS(&pRsp->wPiggyCmdNum, pRsp->PiggybackCmdIDTable,                      &pEndpoint->PendingCmdOutList);    /* Destination address */  pRsp->dwDesIpAddr = dwDesIpAddr;  pRsp->wDesPort = wDesPort;  pRsp->eType = eRspType;  pRsp->u.pEpcfRsp = pRspData;  /* Check if need add the supported package list in the response; if Response     data is NULL, firstly allocate a new response data */  if (wRspCode == RSP_UNSUPPORTED_PACKAGE      && ENDPOINT_CTRL_HANDLE(pEndpoint)->bReturnPackageList)  {    switch (pRsp->eType)    {      case MGCP_RSP_EPCF:                if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pEpcfRsp = (MGCP_EPCF_RSP*)calloc(1, sizeof(MGCP_EPCF_RSP));        Assert(pRsp->u.pEpcfRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pEpcfRsp->pPackageList);      break;      case MGCP_RSP_RQNT:        if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pRqntRsp = (MGCP_RQNT_RSP*)calloc(1, sizeof(MGCP_RQNT_RSP));        Assert(pRsp->u.pRqntRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pRqntRsp->pPackageList);      break;      case MGCP_RSP_CRCX:        if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pCrcxRsp = (MGCP_CRCX_RSP*)calloc(1, sizeof(MGCP_CRCX_RSP));                Assert(pRsp->u.pCrcxRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pCrcxRsp->pPackageList);      break;      case MGCP_RSP_MDCX:        if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pMdcxRsp = (MGCP_MDCX_RSP*)calloc(1, sizeof(MGCP_MDCX_RSP));        Assert(pRsp->u.pMdcxRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pMdcxRsp->pPackageList);      break;      case MGCP_RSP_DLCX:        if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pDlcxRsp = (MGCP_DLCX_RSP*)calloc(1, sizeof(MGCP_DLCX_RSP));        Assert(pRsp->u.pDlcxRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pDlcxRsp->pPackageList);      break;      case MGCP_RSP_AUEP:        if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pAuepRsp = (MGCP_AUEP_RSP*)calloc(1, sizeof(MGCP_AUEP_RSP));        Assert(pRsp->u.pAuepRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pAuepRsp->pPackageList);      break;      case MGCP_RSP_AUCX:        if (pRsp->u.pEpcfRsp == NULL)          pRsp->u.pAucxRsp = (MGCP_AUCX_RSP*)calloc(1, sizeof(MGCP_AUCX_RSP));        Assert(pRsp->u.pAucxRsp);        EndpointReturnSupportedPackages(pEndpoint, &pRsp->u.pAucxRsp->pPackageList);      break;      case MGCP_RSP_COMM:        /* Common Response, need no process! */      break;      default:        Assert(0);    }  }  Msg.eMsgCode = M_OUTGOING_RSP;  Msg.pMsgData = pRsp;  SendMsgToTransationManager(TRANSAC_MANAGER_HANDLE(pEndpoint), &Msg);}/****************************************************************************** * Function          : EndpointCheckExperimentalParams * * Description       : Using callback function to Notify the application *                     to check the experimental parameters in an incoming *                     MGCP message. If the experimental parameters are optional *                     or are supported by the application, the function should *                     return OK, if the experimental parameters are mandatory *                     and are not supported by the application, a FAIL should *                     return. *                      * Input parameters  : pEndpoint - Endpoint handle. *                     pExperiParams - Pointer to experimental parameters. * * Output parameters : pRspCode - Pointer to the check result code returned *                                from application. * * Return value      : OK - If application support the experimental parameters *                          or they are optional. *                     FAIL - If application cannot support the experimental *                            parameters which are mandatory. * * Comments          :  * * History           : *  2005/09/22       : Creation * * Date              : Sep 22 2005, Frank ZHANG ******************************************************************************/LONG EndpointCheckExperimentalParams(H_MGCP_ENDPOINT pEndpoint,                              EXPERIMENTAL_PARAMS *pExperiParams,                              WORD *pRspCode){  MGCP_CBK_MSG CbkMsg;  Assert(pExperiParams);  Assert(STACK_HANDLE(pEndpoint)->pCbkNotfyApp);    if (pExperiParams == NULL && STACK_HANDLE(pEndpoint)->pCbkNotfyApp == NULL)    return FAIL;  CbkMsg.eType = MGCP_CBK_MSG_EXPERIMENTAL_PARM;  CbkMsg.u.CbkExperiParam.pExperiParamList = pExperiParams;  return STACK_HANDLE(pEndpoint)->pCbkNotfyApp((H_ENDPOINT)pEndpoint, &CbkMsg, pRspCode);}/****************************************************************************** * Function          : EndpointProcessEncapEpcf * * Description       : Process the encapsulated EPCF parameters. *                      * Input parameters  : pEndpoint - Endpoint handle  *                     pEncapEpcf - Pointer to EPCF parameters * * Output parameters : pRspCode - Pointer to result code returned * * Return value      : Return OK if the encapsulate EPCF command is process *                     successfully, otherwise return FAIL. * * Comments          :  * * History           : *  2005/09/25       : Creation * * Date              : Sep 25 2005, Frank ZHANG ******************************************************************************/LONG EndpointProcessEncapEpcf(H_MGCP_ENDPOINT pEndpoint,                              ENCAPSULATED_EPCF *pEncapEpcf, WORD *pRspCode){  Assert(pEndpoint);  Assert(pRspCode);  if (pEncapEpcf->pBearerInfo != NULL)  {    MGCP_CBK_MSG CbkMsg;    memset(&CbkMsg, 0, sizeof(MGCP_CBK_MSG));        CbkMsg.eType = MGCP_CBK_MSG_CONFIG_ENDPOINT;    CbkMsg.u.CbkConfigEndpoint.pBearerInfo = pEncapEpcf->pBearerInfo;        Assert(STACK_HANDLE(pEndpoint)->pCbkNotfyApp);      if (STACK_HANDLE(pEndpoint)->pCbkNotfyApp != NULL)      return STACK_HANDLE(pEndpoint)->pCbkNotfyApp((H_ENDPOINT)pEndpoint, &CbkMsg, pRspCode);    else      return FAIL;  }  return OK;}/****************************************************************************** * Function          : MgcpEndpointProcessEpcfCmd * * Description       : Process incoming MGCP EPCF command. *                      * Input parameters  : pEndpoint - Endpoint handle  *                     pCmdIn - Pointer to incoming EPCF command * * Output parameters :  * * Return value      : None * * Comments          :  * * History           : *  2005/09/25       : Creation * * Date              : Sep 25 2005, Frank ZHANG

⌨️ 快捷键说明

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