📄 ospreauthreq.c
字号:
len = OSPM_STRLEN((const char *)ospvReauthReq->ospmReauthReqComponentId); OSPM_MALLOC(componentstring, unsigned char, len + 1); OSPM_MEMSET(componentstring, 0, len + 1); OSPM_MEMCPY(componentstring, ospvReauthReq->ospmReauthReqComponentId, len); } return componentstring;}#endif /* OSPC_DEBUG *//**//*-----------------------------------------------------------------------* * OSPPReauthReqSetCallId() - sets the call ID for a reauthorisation *-----------------------------------------------------------------------*/void /* nothing returned */OSPPReauthReqSetCallId( OSPTREAUTHREQ *ospvReauthReq, /* authorisation request */ OSPTCALLID *ospvCallId /* call ID to set */){ if (ospvReauthReq != OSPC_OSNULL) { if ((ospvCallId) != OSPC_OSNULL) { if ((ospvReauthReq)->ospmReauthReqCallId != OSPC_OSNULL) { OSPPCallIdDelete(&((ospvReauthReq)->ospmReauthReqCallId)); } (ospvReauthReq)->ospmReauthReqCallId = OSPPCallIdNew((ospvCallId)->ospmCallIdLen, (ospvCallId)->ospmCallIdVal); } }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqAddSourceAlt() - add a source alternate to an * authorisation request *-----------------------------------------------------------------------*/void OSPPReauthReqAddSourceAlt( OSPTREAUTHREQ *ospvReauthReq, /* authorisation request */ OSPTALTINFO *ospvAltInfo /* altinfo to add */ ){ if ((ospvReauthReq != OSPC_OSNULL) && (ospvAltInfo != OSPC_OSNULL)) { OSPPListAppend(&(ospvReauthReq->ospmReauthReqSourceAlternate), (ospvAltInfo)); } return;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasSourceAlt() - does an authorisation request have a * Source Alternate? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if exists */OSPPReauthReqHasSourceAlt( OSPTREAUTHREQ *ospvReauthReq /* authorisation request */){ unsigned ospvHasSourceAlt = OSPC_FALSE; if (ospvReauthReq != OSPC_OSNULL) { ospvHasSourceAlt = (OSPPReauthReqFirstSourceAlt(ospvReauthReq) != OSPC_OSNULL); } return(ospvHasSourceAlt);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqFirstSourceAlt() - gets the First Source alternate for an * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO * /* returns alt info pointer */ OSPPReauthReqFirstSourceAlt( OSPTREAUTHREQ *ospvReauthReq /* authorisation request */ ){ OSPTALTINFO *ospvAltInfo = OSPC_OSNULL; if (ospvReauthReq != OSPC_OSNULL) { ospvAltInfo = (OSPTALTINFO *)OSPPListFirst(&((ospvReauthReq)->ospmReauthReqSourceAlternate)); } return(ospvAltInfo);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqNextSourceAlt() - gets the next source alternate for an * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO * /* returns alt info pointer */ OSPPReauthReqNextSourceAlt( OSPTREAUTHREQ *ospvReauthReq, /* authorisation request */ OSPTALTINFO *ospvAltInfo ){ OSPTALTINFO *altinfo = OSPC_OSNULL; if (ospvReauthReq != OSPC_OSNULL) { altinfo = (OSPTALTINFO *)OSPPListNext(&((ospvReauthReq)->ospmReauthReqSourceAlternate), ospvAltInfo); } return(altinfo);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqAddDestinationAlt() - add a destination alternate to an * authorisation request *-----------------------------------------------------------------------*/void OSPPReauthReqAddDestinationAlt( OSPTREAUTHREQ *ospvReauthReq, /* authorisation request */ OSPTALTINFO *ospvAltInfo /* altinfo struct */ ){ if ((ospvReauthReq != OSPC_OSNULL) && (ospvAltInfo != OSPC_OSNULL)) { OSPPListAppend(&(ospvReauthReq->ospmReauthReqDestinationAlternate), (ospvAltInfo)); } return;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasDestinationAlt() - does an authorisation request have a * Destination Alternate? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if exists */OSPPReauthReqHasDestinationAlt( OSPTREAUTHREQ *ospvReauthReq /* authorisation request */){ unsigned ospvHasDestinationAlt = OSPC_FALSE; if (ospvReauthReq != OSPC_OSNULL) { ospvHasDestinationAlt = (OSPPReauthReqFirstDestinationAlt(ospvReauthReq) != OSPC_OSNULL); } return(ospvHasDestinationAlt);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqFirstDestinationAlt() - gets the First Destination alternate for an * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO * /* returns alt info pointer */ OSPPReauthReqFirstDestinationAlt( OSPTREAUTHREQ *ospvReauthReq /* authorisation request */ ){ OSPTALTINFO *ospvAltInfo = OSPC_OSNULL; if (ospvReauthReq != OSPC_OSNULL) { ospvAltInfo = (OSPTALTINFO *)OSPPListFirst(&((ospvReauthReq)->ospmReauthReqDestinationAlternate)); } return(ospvAltInfo);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqNextDestinationAlt() - gets the next Destination alternate for an * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO * /* returns alt info pointer */ OSPPReauthReqNextDestinationAlt( OSPTREAUTHREQ *ospvReauthReq, /* authorisation request */ OSPTALTINFO *ospvAltInfo ){ OSPTALTINFO *altinfo = OSPC_OSNULL; if (ospvReauthReq != OSPC_OSNULL) { altinfo = (OSPTALTINFO *)OSPPListNext(&((ospvReauthReq)->ospmReauthReqDestinationAlternate), ospvAltInfo); } return(altinfo);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetDestinationAltValue() - gets the Destination alternate value for * an authorisation request *-----------------------------------------------------------------------*/unsigned char * /* returns alt info value */ OSPPReauthReqGetDestinationAltValue( OSPTALTINFO *ospvAltInfo /* Alt info ptr */ ){ unsigned char *ospvAltInfoValue = OSPC_OSNULL; if (ospvAltInfo != OSPC_OSNULL) { ospvAltInfoValue = (unsigned char *)OSPPAltInfoGetValue(ospvAltInfo); } return(ospvAltInfoValue);}/*-----------------------------------------------------------------------* * OSPPReauthReqDelete() - deletes an authorisation request structure *-----------------------------------------------------------------------*/void OSPPReauthReqDelete(OSPTREAUTHREQ **ospvReauthReq){ OSPTALTINFO *altinfo = OSPC_OSNULL; OSPTTOKEN *token = OSPC_OSNULL; if (*ospvReauthReq) { if((*ospvReauthReq)->ospmReauthReqCallId != OSPC_OSNULL) { OSPPCallIdDelete(&((*ospvReauthReq)->ospmReauthReqCallId)); } while(!OSPPListEmpty(&((*ospvReauthReq)->ospmReauthReqSourceAlternate))) { altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvReauthReq)->ospmReauthReqSourceAlternate)); if(altinfo != OSPC_OSNULL) { OSPM_FREE(altinfo); altinfo = OSPC_OSNULL; } } OSPPListDelete(&((*ospvReauthReq)->ospmReauthReqSourceAlternate)); while(!OSPPListEmpty(&((*ospvReauthReq)->ospmReauthReqDestinationAlternate))) { altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvReauthReq)->ospmReauthReqDestinationAlternate)); if(altinfo != OSPC_OSNULL) { OSPM_FREE(altinfo); altinfo = OSPC_OSNULL; } } OSPPListDelete(&((*ospvReauthReq)->ospmReauthReqDestinationAlternate)); while(!OSPPListEmpty(&((*ospvReauthReq)->ospmReauthReqTokens))) { token = (OSPTTOKEN *)OSPPListRemove(&((*ospvReauthReq)->ospmReauthReqTokens)); if(token != OSPC_OSNULL) { OSPPTokenDelete(&token); } } if(OSPPReauthReqHasMessageId(*ospvReauthReq)) { OSPM_FREE((*ospvReauthReq)->ospmReauthReqMessageId); } if(OSPPReauthReqHasComponentId(*ospvReauthReq)) { OSPM_FREE((*ospvReauthReq)->ospmReauthReqComponentId); } OSPPListDelete(&((*ospvReauthReq)->ospmReauthReqTokens)); OSPM_FREE(*ospvReauthReq); *ospvReauthReq = OSPC_OSNULL; } return;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqNew() - creates a new (empty) authorisation request *-----------------------------------------------------------------------*/OSPTREAUTHREQ * /* returns pointer or NULL */ OSPPReauthReqNew(){ OSPTREAUTHREQ *ospvReauthReq = OSPC_OSNULL; OSPM_MALLOC(ospvReauthReq, OSPTREAUTHREQ,sizeof(OSPTREAUTHREQ)); if (ospvReauthReq != OSPC_OSNULL) { ospvReauthReq->ospmReauthReqTimestamp = OSPC_TIMEMIN; ospvReauthReq->ospmReauthReqHasRole = OSPC_FALSE; ospvReauthReq->ospmReauthReqCallId = OSPC_OSNULL; ospvReauthReq->ospmReauthReqSourceNumber[0] = '\0'; ospvReauthReq->ospmReauthReqDestNumber[0] = '\0'; OSPPListNew(&ospvReauthReq->ospmReauthReqSourceAlternate); OSPPListNew(&ospvReauthReq->ospmReauthReqDestinationAlternate); ospvReauthReq->ospmReauthReqTrxId = 0; ospvReauthReq->ospmReauthReqDuration = -1; OSPPListNew(&ospvReauthReq->ospmReauthReqTokens); ospvReauthReq->ospmReauthReqTNCustId = 0; ospvReauthReq->ospmReauthReqTNDeviceId = 0; ospvReauthReq->ospmReauthReqComponentId = OSPC_OSNULL; ospvReauthReq->ospmReauthReqMessageId = OSPC_OSNULL; } return(ospvReauthReq);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqToElement() - create an XML element from a reauthorisation * request *-----------------------------------------------------------------------*/int /* returns error code */OSPPReauthReqToElement( OSPTREAUTHREQ *ospvReauthReq, /* authorisation request value */ OSPTXMLELEM **ospvElem /* where to put XML element pointer */){ int ospvErrCode = OSPC_ERR_NO_ERROR; OSPTXMLELEM *elem = OSPC_OSNULL, *reauthelem = OSPC_OSNULL; OSPTXMLATTR *attr = OSPC_OSNULL; OSPTTOKEN *token = OSPC_OSNULL; OSPTTRXID trxid = 0L; OSPTALTINFO *altinfo = OSPC_OSNULL; char random[OSPC_MAX_RANDOM]; OSPTBOOL isbase64 = OSPC_TRUE; OSPM_MEMSET(random, 0, OSPC_MAX_RANDOM); if (ospvElem == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_NO_ELEMENT; } else { *ospvElem = OSPC_OSNULL; } if (ospvReauthReq == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_DATA_NO_REAUTHREQ; } if(ospvErrCode == OSPC_ERR_NO_ERROR) { /* create the "Message" element as the parent */ *ospvElem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemMessage), ""); if(*ospvElem == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_NO_ELEMENT; } else { attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrMessageId), (OSPPReauthReqHasMessageId(ospvReauthReq))?(const unsigned char *)(ospvReauthReq->ospmReauthReqMessageId): (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) { /* now the message type element */ reauthelem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemReauthReq), ""); if (*ospvElem == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_NO_ELEMENT; } } /* now add the attributes to the type element -- in this case the component id * */ if (ospvErrCode == OSPC_ERR_NO_ERROR) { attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrComponentId), (OSPPReauthReqHasComponentId(ospvReauthReq))?(const unsigned char *)(ospvReauthReq->ospmReauthReqComponentId): (const unsigned char *)"NULL"); if (attr == OSPC_OSNULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -