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

📄 osptrans.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
    {        if(incomingsignature != OSPC_OSNULL)        {            errorcode = OSPPTransactionGetProvider(ospvTrans, &provider);            if (errorcode == OSPC_ERR_NO_ERROR)            {                errorcode = OSPPProviderGetSecurity(provider, &security);            }            errorcode = OSPPSecSignatureVerify( security,                &incomingmsg, &sizeofmsg,                incomingsignature, sizeofsig, OSPC_SEC_SIGNATURE_ONLY);        }        else        {            errorcode = OSPC_ERR_TRAN_VALUE_NOT_FOUND;        }    }#endif    if (errorcode == OSPC_ERR_NO_ERROR)    {        /*         * Send the XML message doc to the XML parser         */        errorcode = OSPPXMLMessageParse(incomingmsg, sizeofmsg,            &resultrsp, &msgtype);        if (errorcode == OSPC_ERR_NO_ERROR)        {            OSPPAuditCheck(audit, resultrsp, msgtype);                        switch (msgtype)            {                /*                 * Authorization Response received                 */                case OSPC_MSG_ARESP:                ospvTrans->AuthRsp = (OSPTAUTHRSP*)resultrsp;                ospvTrans->TransactionID = ospvTrans->AuthRsp->ospmAuthRspTrxId;                ospvTrans->HasTransactionID = OSPC_TRUE;                break;                /*                 * Usage Confirmation received                 */                case OSPC_MSG_UCNF:               for((usagecnf = (OSPTUSAGECNF *)OSPPListFirst((OSPTLIST *)&(resultrsp)));                    (usagecnf != OSPC_OSNULL);                    (usagecnf = (OSPTUSAGECNF *)OSPPListNext((OSPTLIST *)&(resultrsp), usagecnf)))                {                    errorcode = OSPPTransactionVerifyUsageCnf(usagecnf);                }                break;                /*                 * Authorization Confirmation received                 */                case OSPC_MSG_ACNF:                errorcode = OSPPTransactionVerifyAuthCnf((OSPTAUTHCNF *)resultrsp);                if (resultrsp != OSPC_OSNULL)                    OSPPAuthCnfDelete((OSPTAUTHCNF **)&resultrsp);                break;                /*                 * Reauthorization Response received                 */                case OSPC_MSG_REARESP:                ospvTrans->ReauthRsp = (OSPTREAUTHRSP*)resultrsp;                ospvTrans->TransactionID = ospvTrans->ReauthRsp->ospmReauthRspTrxId;                ospvTrans->HasTransactionID = OSPC_TRUE;                break;                /*                 * The Unknown received                 */                default:                errorcode = OSPC_ERR_DATA_INVALID_TYPE;                break;            }        }    }        /*        ** Delete the usage confirmations        */    if(msgtype == OSPC_MSG_UCNF)    {        if((OSPTLIST *)&(resultrsp) != OSPC_OSNULL)        {            while(!OSPPListEmpty((OSPTLIST *)&(resultrsp)))            {                usagecnf = (OSPTUSAGECNF *)OSPPListRemove((OSPTLIST *)&(resultrsp));                if(usagecnf != OSPC_OSNULL)                {                    OSPPUsageCnfDelete(&(usagecnf));                }            }              OSPPListDelete((OSPTLIST *)&(resultrsp));        }    }    if (usagecnf != OSPC_OSNULL)    {        OSPPUsageCnfDelete(&usagecnf);    }    if (incomingmsg != (unsigned char *)OSPC_OSNULL)    {        OSPM_FREE(incomingmsg);        incomingmsg = OSPC_OSNULL;    }    if (incomingsignature != (unsigned char *)OSPC_OSNULL)    {        OSPM_FREE(incomingsignature);        incomingsignature = OSPC_OSNULL;    }    return errorcode;}/* * create space and load request information. * * Check and store incoming data * * returns OSPC_ERR_NO_ERROR if successful, otherwise error code. */intOSPPTransactionRequestNew(    OSPTTRANS   *ospvTrans,                 /* In - Transaction Pointer */    const char  *ospvSource,                /* In - Source of call      */    const char  *ospvSourceDevice,          /* In - SourceDevice of call*/    const char  *ospvCallingNumber,         /* In - Calling number      */    const char  *ospvCalledNumber,          /* In - Called number       */    const char  *ospvUser,                  /* In - End user (optional) */    unsigned    ospvNumberOfCallIds,                 /* In - Number of call identifiers */    OSPTCALLID  *ospvCallIds[],                             /* In - List of call identifiers */    const char  *ospvPreferredDestinations[],                /* In - List of preferred destinations for call */    unsigned    *ospvNumberOfDestinations,                  /* In\Out - Max number of destinations \                            Actual number of dests authorised */    unsigned    *ospvSizeOfDetailLog,                 /* In\Out - Max size of detail log \                           Actual size of detail log */    void        *ospvDetailLog)   /* In\Out - Location of detail log storage */{    int         errorcode       = OSPC_ERR_NO_ERROR,                numbytesrandom  = 0,                numbytescounter = 0;    unsigned    i               = 0;    OSPTTIME    timestamp       = 0;    OSPTALTINFO *altinfo        = OSPC_OSNULL;    OSPTCALLID  *callid         = OSPC_OSNULL;    char         random[OSPC_MAX_RANDOM];    char         counter[OSPC_MAX_RANDOM];    OSPM_MEMSET(random, 0, OSPC_MAX_RANDOM);    OSPM_MEMSET(counter, 0, OSPC_MAX_RANDOM);    ospvTrans->SizeOfDetailLog = *ospvSizeOfDetailLog;    ospvTrans->DetailLog       = ospvDetailLog;    /* so far no error */    errorcode = OSPC_ERR_NO_ERROR;    /*     * create the authorisation request object     */    ospvTrans->AuthReq = OSPPAuthReqNew();    if (ospvTrans->AuthReq == OSPC_OSNULL)    {        errorcode = OSPC_ERR_DATA_NO_AUTHREQ;        OSPM_DBGERRORLOG(errorcode, "AuthReq struct not created.");    }    else    {        if (errorcode == OSPC_ERR_NO_ERROR)        {            /*             * Fill in the AuthReq structure             */            /* ----------------------------------             * ospmAuthReqTimestamp (Timestamp)             * ----------------------------------             */            timestamp = time(NULL);            OSPPAuthReqSetTimestamp(ospvTrans->AuthReq, timestamp);            /* ----------------------------------             * ospmAuthReqCallId (CallId)             * ----------------------------------             */            /* call ids - create a linked list */            OSPPListNew((OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqCallId));            /* now append each requested call id to the list */            for (i = 0; i < ospvNumberOfCallIds; i++)            {                callid = OSPPCallIdNew(ospvCallIds[i]->ospmCallIdLen,                    ospvCallIds[i]->ospmCallIdVal);                if(callid != OSPC_OSNULL)                {                    OSPPListAppend((OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqCallId),                        (void *)callid);                    callid = OSPC_OSNULL;                }            }            /* --------------------------------------           * ospmAuthReqSourceNumber (SourceInfo)           * --------------------------------------           */            OSPPAuthReqSetSourceNumber(ospvTrans->AuthReq, (const unsigned char *)ospvCallingNumber);            /* --------------------------------------             * ospmAuthReqSourceAlternate (SourceAlternate)             * --------------------------------------             */            if((ospvSource != OSPC_OSNULL) ||                (ospvSourceDevice != OSPC_OSNULL) ||                (ospvUser != OSPC_OSNULL))            {                /* source alternates - create a linked list */                OSPPListNew((OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqSourceAlternate));                if(ospvSource != OSPC_OSNULL)                {                    altinfo = OSPPAltInfoNew(strlen(ospvSource),                         (const unsigned char *)ospvSource,                        ospeTransport);                    if(altinfo != OSPC_OSNULL)                    {                        OSPPListAppend(                            (OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqSourceAlternate),                            (void *)altinfo);                    }                }                altinfo = OSPC_OSNULL;                if(ospvUser != OSPC_OSNULL)                {                    altinfo = OSPPAltInfoNew(strlen(ospvUser),                        (const unsigned char *)ospvUser,                        ospeSubscriber);                    if (altinfo != OSPC_OSNULL)                    {                        OSPPListAppend(                            (OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqSourceAlternate),                            (void *)altinfo);                    }                }                altinfo = OSPC_OSNULL;                if(ospvSourceDevice != OSPC_OSNULL)                {                    altinfo = OSPPAltInfoNew(strlen(ospvSourceDevice),                        (const unsigned char *)ospvSourceDevice,                        ospeH323);                    if(altinfo != OSPC_OSNULL)                    {                        OSPPListAppend(                            (OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqSourceAlternate),                            (void *)altinfo);                    }                }            }            else            {                errorcode = OSPC_ERR_TRAN_SOURCE_INVALID;            }            /* ----------------------------------------             * ospmAuthReqDestNumber (DestinationInfo)             * ----------------------------------------             */            OSPPAuthReqSetDestNumber(ospvTrans->AuthReq, (const unsigned char *)ospvCalledNumber);            /* -------------------------------------------             * ospmAuthReqDestAlt (DestinationAlternative)             * --------------------------------------------             * Preferred destination list.             */            altinfo = OSPC_OSNULL;            if(ospvPreferredDestinations != OSPC_OSNULL)            {                /* destination alternates - create a linked list */                OSPPListNew((OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqDestinationAlternate));                i = 0;                while(ospvPreferredDestinations[i] != OSPC_OSNULL)                {                    if(*(ospvPreferredDestinations[i]) != '\0')                    {                        altinfo = OSPPAltInfoNew(strlen(ospvPreferredDestinations[i]),                             (const unsigned char *)ospvPreferredDestinations[i],                            ospeTransport);                        if(altinfo != OSPC_OSNULL)                        {                            OSPPListAppend(                                (OSPTLIST *)&(ospvTrans->AuthReq->ospmAuthReqDestinationAlternate),                                (void *)altinfo);                        }                    }                    else                    {                        /* we're done */                        break;                    }                    i++;                    altinfo = OSPC_OSNULL;                }            }            /* -------------------------------------------             * ospmAuthReqService (Service)             * --------------------------------------------             * Default (Basic Internet telephony service)             */            /* -----------------------------------------             * ospmAuthReqMaxDest (MaximumDestinations)             * -----------------------------------------             */            OSPPAuthReqSetMaxDest(ospvTrans->AuthReq, *ospvNumberOfDestinations);            /* !!!TK added following lines */            /* -----------------------------------------             * ospmAuthReqTNCustId (TransNexus Customer Id)             * -----------------------------------------             */            OSPPAuthReqSetTNCustId(ospvTrans->AuthReq,                 OSPPProviderGetTNCustId(ospvTrans->Provider));            /* -----------------------------------------            * ospmAuthReqTNDeviceId (TransNexus Device Id)            * -----------------------------------------            */            OSPPAuthReqSetTNDeviceId(ospvTrans->AuthReq,                 OSPPProviderGetTNDeviceId(ospvTrans->Provider));            /* Set ComponentID. We have to use the random generator               because there is no transaction id yet.            */            numbytesrandom = OSPPUtilGetRandom(random, 0);            numbytescounter = OSPM_SPRINTF(counter, "%d", OSPPTransactionGetCounter(ospvTrans));            OSPM_MALLOC((ospvTrans->AuthReq)->ospmAuthReqComponentId,                         unsigned char,                         numbytesrandom + numbytescounter +1);            OSPM_MEMSET((ospvTrans->AuthReq)->ospmAuthReqComponentId,                         0,                         numbytesrandom + numbytescounter +1);            OSPM_MEMCPY((ospvTrans->AuthReq)->ospmAuthReqComponentId,                         random,                         numbytesrandom);            OSPM_MEMCPY(((ospvTrans->AuthReq)->ospmAuthReqComponentId + numbytesrandom),                         counter,                         numbytescounter);            /* Update the componentId Unique counter */            OSPPTransactionUpdateCounter(ospvTrans);            /* Set MessageId. The reasons are the same as for componentId */            numbytesrandom = OSPPUtilGetRandom(random, 0);            numbytescounter = OSPM_SPRINTF(counter, "%d", OSPPTransactionGetCounter(ospvTrans));            OSPM

⌨️ 快捷键说明

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