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

📄 ospauthreq.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 3 页
字号:
    if(*ospvElem == OSPC_OSNULL)    {        ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;    }    else    {        attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrMessageId),             (OSPPAuthReqHasMessageId(ospvAuthReq))?(const unsigned char *)(ospvAuthReq->ospmAuthReqMessageId): (const unsigned char *)"NULL");        if (attr != OSPC_OSNULL)         {            OSPPXMLElemAddAttr(*ospvElem, attr);            attr = OSPC_OSNULL;        }        else        {            ospvErrCode = OSPC_ERR_XML_NO_ATTR;        }        /* random */        if((OSPPUtilGetRandom(random, 0) > 0) &&            (ospvErrCode == OSPC_ERR_NO_ERROR))        {            attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrRandom),                (const unsigned char *)random);            if (attr != OSPC_OSNULL)             {                OSPPXMLElemAddAttr(*ospvElem, attr);                attr = OSPC_OSNULL;            }            else            {                ospvErrCode = OSPC_ERR_XML_NO_ATTR;            }        }    }    if (ospvErrCode == OSPC_ERR_NO_ERROR)    {        /* create the authreq element */        authreqelem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemAuthReq), "");        if (authreqelem == OSPC_OSNULL)        {            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;        }        /* now add the attributes to the parent -- in this case the component id         *         */        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrComponentId),                 (OSPPAuthReqHasComponentId(ospvAuthReq))?(const unsigned char *)(ospvAuthReq->ospmAuthReqComponentId): (const unsigned char *)"NULL");            if (attr == OSPC_OSNULL)            {                ospvErrCode = OSPC_ERR_XML_NO_ATTR;            }        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            OSPPXMLElemAddAttr(authreqelem, attr);            attr = OSPC_OSNULL;        }        /* now add the children */        /* add timestamp  */        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPAuthReqHasTimestamp(ospvAuthReq))        {            ospvErrCode = OSPPMsgTimeToElement(OSPPAuthReqGetTimestamp(ospvAuthReq),                (const unsigned char *)OSPPMsgGetElemName(ospeElemTimestamp), &elem);            if (ospvErrCode == OSPC_ERR_NO_ERROR)            {                OSPPXMLElemAddChild(authreqelem, elem);                elem = OSPC_OSNULL;            }        }        /* add the call ID */        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPAuthReqHasCallId(ospvAuthReq))        {            for (callid = OSPPAuthReqFirstCallId(ospvAuthReq);                ((callid != OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR));                callid = OSPPAuthReqNextCallId(ospvAuthReq, callid))            {                ospvErrCode = OSPPCallIdToElement(callid, &elem, isbase64);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                    OSPPXMLElemAddChild(authreqelem, elem);                    elem = OSPC_OSNULL;                }            }        }        /* add the source number */        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemSrcInfo),                (const char *)OSPPAuthReqGetSourceNumber(ospvAuthReq));            if (elem == OSPC_OSNULL)            {                ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;            }        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),                (const unsigned char *)"e164");            if (attr == OSPC_OSNULL)            {                ospvErrCode = OSPC_ERR_XML_NO_ATTR;            }        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            OSPPXMLElemAddAttr(elem, attr);            attr = OSPC_OSNULL;        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            OSPPXMLElemAddChild(authreqelem, elem);            elem = OSPC_OSNULL;        }        /* add the source alternates */        if ((ospvErrCode == OSPC_ERR_NO_ERROR) &&             OSPPAuthReqHasSourceAlt(ospvAuthReq))        {            for (altinfo = (OSPTALTINFO *)OSPPAuthReqFirstSourceAlt(ospvAuthReq);                ((altinfo != (OSPTALTINFO *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR));                altinfo = (OSPTALTINFO *)OSPPAuthReqNextSourceAlt(ospvAuthReq, altinfo))            {                ospvErrCode = OSPPAltInfoToElement(altinfo, &elem, ospeElemSrcAlt);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                    OSPPXMLElemAddChild(authreqelem, elem);                    elem = OSPC_OSNULL;                }            }        }        /* add the dest number */        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemDestInfo),                (const char *)OSPPAuthReqGetDestNumber(ospvAuthReq));            if (elem == OSPC_OSNULL)            {                ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;            }        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),                (const unsigned char *)"e164");            if (attr == OSPC_OSNULL)            {                ospvErrCode = OSPC_ERR_XML_NO_ATTR;            }        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            OSPPXMLElemAddAttr(elem, attr);            attr = OSPC_OSNULL;            OSPPXMLElemAddChild(authreqelem, elem);            elem = OSPC_OSNULL;        }        /* add the destination alternates */        if ((ospvErrCode == OSPC_ERR_NO_ERROR) &&             OSPPAuthReqHasDestinationAlt(ospvAuthReq))        {            altinfo = OSPC_OSNULL;            for (altinfo = (OSPTALTINFO *)OSPPAuthReqFirstDestinationAlt(ospvAuthReq);                ((altinfo != (OSPTALTINFO *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR));                altinfo = (OSPTALTINFO *)OSPPAuthReqNextDestinationAlt(ospvAuthReq, altinfo))            {                ospvErrCode = OSPPAltInfoToElement(altinfo, &elem, ospeElemDestAlt);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                    OSPPXMLElemAddChild(authreqelem, elem);                    elem = OSPC_OSNULL;                }            }        }        /* now add the service */        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemService),"");            if (elem == OSPC_OSNULL)            {                ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;            }        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            OSPPXMLElemAddChild(authreqelem, elem);            elem = OSPC_OSNULL;        }        /* now add the max destinations */        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            ospvErrCode = OSPPMsgNumToElement(                 OSPPAuthReqGetMaxDest(ospvAuthReq),                (const unsigned char *)OSPPMsgGetElemName(ospeElemMaxDest),                &elem);        }        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            OSPPXMLElemAddChild(authreqelem, elem);            elem = OSPC_OSNULL;        }        /* now add the transnexus extentions (if available) */        if (ospvErrCode == OSPC_ERR_NO_ERROR)        {            if (OSPPAuthReqHasTNCustId(ospvAuthReq))            {                ospvErrCode = OSPPMsgNumToElement(                     OSPPAuthReqGetTNCustId(ospvAuthReq),                    (const unsigned char *) OSPPMsgGetElemName(ospeElemTNCustId),                    &elem);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                   attr = OSPPXMLAttrNew(                        (const unsigned char *)OSPPMsgGetAttrName(ospeAttrCritical),                        (const unsigned char *)"False");                    if (attr != OSPC_OSNULL)                    {                        OSPPXMLElemAddAttr(elem, attr);                        attr = OSPC_OSNULL;                    }                    else                    {                        ospvErrCode = OSPC_ERR_XML_NO_ATTR;                    }                    if (ospvErrCode == OSPC_ERR_NO_ERROR)                    {                        OSPPXMLElemAddChild(authreqelem, elem);                        elem = OSPC_OSNULL;                    }                    if (OSPPAuthReqHasTNDeviceId(ospvAuthReq) && ospvErrCode == OSPC_ERR_NO_ERROR)                    {                        ospvErrCode = OSPPMsgNumToElement(                             OSPPAuthReqGetTNDeviceId(ospvAuthReq),                            (const unsigned char *) OSPPMsgGetElemName(ospeElemTNDeviceId),                            &elem);                        if (ospvErrCode == OSPC_ERR_NO_ERROR)                        {                            attr = OSPPXMLAttrNew(                                (const unsigned char *)OSPPMsgGetAttrName(ospeAttrCritical),                                (const unsigned char *)"False");                            if (attr != OSPC_OSNULL)                            {                                OSPPXMLElemAddAttr(elem, attr);                                attr = OSPC_OSNULL;                            }                            else                            {                                ospvErrCode = OSPC_ERR_XML_NO_ATTR;                            }                            if (ospvErrCode == OSPC_ERR_NO_ERROR)                            {                                OSPPXMLElemAddChild(authreqelem, elem);                                elem = OSPC_OSNULL;                            }                                                }                    }                }            }        }        if(ospvErrCode == OSPC_ERR_NO_ERROR)        {            /* Now add the authreqelem to the main elem */            OSPPXMLElemAddChild(*ospvElem, authreqelem);            authreqelem = OSPC_OSNULL;        }        /* if for any reason we found an error - destroy any elements created */        if (ospvErrCode != OSPC_ERR_NO_ERROR)        {            if(elem != OSPC_OSNULL)            {                OSPPXMLElemDelete(&elem);            }            if(authreqelem != OSPC_OSNULL)            {                OSPPXMLElemDelete(&authreqelem);            }            if(attr != OSPC_OSNULL)            {                OSPPXMLAttrDelete(&attr);            }            if(*ospvElem != OSPC_OSNULL)            {                OSPPXMLElemDelete(ospvElem);            }        }    }    return(ospvErrCode);}/*-----------------------------------------------------------------------* * OSPPAuthReqHasMessageId() - is the message id set ? *-----------------------------------------------------------------------*/unsigned                   /* returns non-zero if message id is set */OSPPAuthReqHasMessageId(    OSPTAUTHREQ *ospvAuthReq){  return (ospvAuthReq->ospmAuthReqMessageId != OSPC_OSNULL);}

⌨️ 快捷键说明

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