📄 ospreauthreq.c
字号:
{ ospvErrCode = OSPC_ERR_XML_NO_ATTR; } } if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddAttr(reauthelem, attr); } /* now add the children */ /* add timestamp */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasTimestamp(ospvReauthReq)) { ospvErrCode = OSPPMsgTimeToElement(OSPPReauthReqGetTimestamp(ospvReauthReq), (const unsigned char *)OSPPMsgGetElemName(ospeElemTimestamp), &elem); } if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } /* add role */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasRole(ospvReauthReq)) { ospvErrCode = OSPPMsgRoleToElement(OSPPReauthReqGetRole(ospvReauthReq), (const unsigned char *) OSPPMsgGetElemName(ospeElemRole), &elem); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); elem = OSPC_OSNULL; } } /* add the call ID */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasCallId(ospvReauthReq)) { ospvErrCode = OSPPCallIdToElement(OSPPReauthReqGetCallId(ospvReauthReq), &elem, isbase64); } if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } /* add the source number */ if (ospvErrCode == OSPC_ERR_NO_ERROR) { elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemSrcInfo), (const char *)OSPPReauthReqGetSourceNumber(ospvReauthReq)); 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); } if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } /* add the source alternates */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasSourceAlt(ospvReauthReq)) { for (altinfo = OSPPReauthReqFirstSourceAlt(ospvReauthReq); ((altinfo != OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR)); altinfo = OSPPReauthReqNextSourceAlt(ospvReauthReq, altinfo)) { ospvErrCode = OSPPAltInfoToElement(altinfo, &elem, ospeElemSrcAlt); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); elem = OSPC_OSNULL; } } } /* add the dest number */ if (ospvErrCode == OSPC_ERR_NO_ERROR) { elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemDestInfo), (const char *)OSPPReauthReqGetDestNumber(ospvReauthReq)); 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); } if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } /* add the destination alternates */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasDestinationAlt(ospvReauthReq)) { for (altinfo = OSPPReauthReqFirstDestinationAlt(ospvReauthReq); ((altinfo != OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR)); altinfo = OSPPReauthReqNextDestinationAlt(ospvReauthReq, altinfo)) { ospvErrCode = OSPPAltInfoToElement(altinfo, &elem, ospeElemDestAlt); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); elem = OSPC_OSNULL; } } } /* add the transaction ID */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasTrxId(ospvReauthReq)) { trxid = OSPPReauthReqGetTrxId(ospvReauthReq); ospvErrCode = OSPPMsgTXToElement( trxid, (const unsigned char *)OSPPMsgGetElemName(ospeElemTransId), &elem); } if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } /* add usage detail (if appropriate) */ if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPReauthReqHasDuration(ospvReauthReq)) { ospvErrCode = OSPPUsageToElement( (unsigned)OSPPReauthReqGetDuration(ospvReauthReq), &elem); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* add any tokens */ for (token = (OSPTTOKEN *)OSPPReauthReqFirstToken(ospvReauthReq); ((token != (OSPTTOKEN *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR)); token = (OSPTTOKEN *)OSPPReauthReqNextToken(ospvReauthReq, token)) { ospvErrCode = OSPPTokenToElement(token, &elem); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); } } } /* now add the transnexus extensions (if available) */ if (ospvErrCode == OSPC_ERR_NO_ERROR) { if (OSPPReauthReqHasTNCustId(ospvReauthReq)) { ospvErrCode = OSPPMsgNumToElement( OSPPReauthReqGetTNCustId(ospvReauthReq), (const unsigned char *)OSPPMsgGetElemName(ospeElemTNCustId), &elem); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); elem = OSPC_OSNULL; if (OSPPReauthReqHasTNDeviceId(ospvReauthReq)) { ospvErrCode = OSPPMsgNumToElement( OSPPReauthReqGetTNDeviceId(ospvReauthReq), (const unsigned char *)OSPPMsgGetElemName(ospeElemTNDeviceId), &elem); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPXMLElemAddChild(reauthelem, elem); elem = OSPC_OSNULL; } } } } } if(ospvErrCode == OSPC_ERR_NO_ERROR) { /* Now add the reauthelem to the main elem */ OSPPXMLElemAddChild(*ospvElem, reauthelem); reauthelem = OSPC_OSNULL; } /* if for any reason we found an error - destroy any elements created */ if (ospvErrCode != OSPC_ERR_NO_ERROR) { if(*ospvElem != OSPC_OSNULL) { OSPPXMLElemDelete(ospvElem); } } if(elem != OSPC_OSNULL) { OSPPXMLElemDelete(&elem); } if(reauthelem != OSPC_OSNULL) { OSPPXMLElemDelete(&reauthelem); } if(attr != OSPC_OSNULL) { OSPPXMLAttrDelete(&attr); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasRole() - Does reauthrequest have role set? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if time */OSPPReauthReqHasRole( OSPTREAUTHREQ *ospvReauthReq /* reauth request in question */){ unsigned ospvHasRole = OSPC_FALSE; if (ospvReauthReq != OSPC_OSNULL) { ospvHasRole = ((ospvReauthReq)->ospmReauthReqHasRole != OSPC_FALSE); } return(ospvHasRole);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetRole() - returns role for an reauth request *-----------------------------------------------------------------------*/OSPE_MSG_ROLETYPES /* returns the role (OGW/TGW) */ OSPPReauthReqGetRole( OSPTREAUTHREQ *ospvReauthReq /* reauth request */ ){ OSPE_MSG_ROLETYPES ospvRole = OSPC_UNDEFINED_ROLE; if (ospvReauthReq != OSPC_OSNULL) { ospvRole = (OSPE_MSG_ROLETYPES)ospvReauthReq->ospmReauthReqRole; } return(ospvRole);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetRole() - sets value for role in reauthorisation request *-----------------------------------------------------------------------*/void OSPPReauthReqSetRole( OSPTREAUTHREQ *ospvReauthReq, OSPE_MSG_ROLETYPES ospvRole){ if (ospvReauthReq != OSPC_OSNULL) { ospvReauthReq->ospmReauthReqHasRole = OSPC_TRUE; ospvReauthReq->ospmReauthReqRole = ospvRole; } return;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasTNCustId() - Does reauthreq have a TransNexus Customer Id? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if true */OSPPReauthReqHasTNCustId( OSPTREAUTHREQ *ospvReauthReq /* reauthreq in question */){ unsigned ospvHasTNCustId = OSPC_FALSE; if (ospvReauthReq != OSPC_OSNULL) { ospvHasTNCustId = ((ospvReauthReq)->ospmReauthReqTNCustId != 0L); } return(ospvHasTNCustId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetTNCustId() - Set TransNexus Customer Id *-----------------------------------------------------------------------*/void /* nothing returned */OSPPReauthReqSetTNCustId( OSPTREAUTHREQ *ospvReauthReq, unsigned long ospvTNCustId){ if (ospvReauthReq != OSPC_OSNULL) { (ospvReauthReq)->ospmReauthReqTNCustId = (ospvTNCustId); }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetTNCustId() - returns TN Customer Id for a reauthreq *-----------------------------------------------------------------------*/unsigned long /* returns the cust id */ OSPPReauthReqGetTNCustId( OSPTREAUTHREQ *ospvReauthReq /* usage request */ ){ unsigned long ospvTNCustId = 0L; if (ospvReauthReq != OSPC_OSNULL) { ospvTNCustId = (ospvReauthReq)->ospmReauthReqTNCustId; } return(ospvTNCustId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasTNDeviceId() - Does request have a TransNexus Device Id? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if true */OSPPReauthReqHasTNDeviceId( OSPTREAUTHREQ *ospvReauthReq /* reauthrequest in question */){ unsigned ospvHasTNDeviceId = OSPC_FALSE; if (ospvReauthReq != OSPC_OSNULL) { ospvHasTNDeviceId = ((ospvReauthReq)->ospmReauthReqTNDeviceId != 0L); } return(ospvHasTNDeviceId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetTNDeviceId() - Set TransNexus Device Id *-----------------------------------------------------------------------*/void /* nothing returned */OSPPReauthReqSetTNDeviceId( OSPTREAUTHREQ *ospvReauthReq, unsigned long ospvTNDeviceId){ if (ospvReauthReq != OSPC_OSNULL) { (ospvReauthReq)->ospmReauthReqTNDeviceId = (ospvTNDeviceId); }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetTNDeviceId() - returns TN Device Id for an reauth request *-----------------------------------------------------------------------*/unsigned long /* returns the device id */ OSPPReauthReqGetTNDeviceId( OSPTREAUTHREQ *ospvReauthReq /* reauth request */ ){ unsigned long ospvTNDeviceId = 0L; if (ospvReauthReq != OSPC_OSNULL) { ospvTNDeviceId = (ospvReauthReq)->ospmReauthReqTNDeviceId; } return(ospvTNDeviceId);}/*-----------------------------------------------------------------------* * OSPPReauthReqHasMessageId() - is the message id set ? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if message id is set */OSPPReauthReqHasMessageId( OSPTREAUTHREQ *ospvReauthReq){ return (ospvReauthReq->ospmReauthReqMessageId != OSPC_OSNULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -