📄 ospreauthrsp.c
字号:
ospvErrCode = OSPC_ERR_DATA_NO_REAUTHRSP; } else { /* Have to get ComponentId here */ if(OSPPMsgGetElemPart(OSPPXMLElemGetName(ospvElem)) == ospeElemReauthReq) { OSPPReauthRspComponentIdFromElement(ospvElem, &compid); if(compid != OSPC_OSNULL) { OSPPReauthRspSetComponentId(reauthrsp, compid); } } } } /* * The Reauthorisation Response element should consist of several * child elements. We'll run through what's there and pick out * the information we need. */ if (ospvErrCode == OSPC_ERR_NO_ERROR) { for ( elem = (OSPTXMLELEM *)OSPPXMLElemFirstChild(ospvElem); (elem != (OSPTXMLELEM *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR); elem = (OSPTXMLELEM *)OSPPXMLElemNextChild(ospvElem, elem) ) { switch (OSPPMsgGetElemPart(OSPPXMLElemGetName(elem))) { case ospeElemMessage: if(messageId != OSPC_OSNULL) { OSPPReauthRspSetMessageId(reauthrsp, messageId); } break; case ospeElemReauthReq: if(compid != OSPC_OSNULL) { OSPPReauthRspSetComponentId(reauthrsp, compid); } break; case ospeElemTimestamp: ospvErrCode = OSPPMsgTimeFromElement(elem, &t); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPReauthRspSetTimestamp(reauthrsp,t); } break; case ospeElemStatus: if(reauthrsp->ospmReauthRspStatus == OSPC_OSNULL) { ospvErrCode = OSPPStatusFromElement(elem, &(reauthrsp->ospmReauthRspStatus)); } break; case ospeElemTransId: ospvErrCode = OSPPMsgTXFromElement(elem, &transid); OSPPReauthRspSetTrxId(reauthrsp, transid); break; case ospeElemTNAudit: ospvErrCode = OSPPTNAuditFromElement(elem, &(reauthrsp->ospmReauthRspTNAudit)); break; case ospeElemDest: ospvErrCode = OSPPDestFromElement(elem, &dest); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPReauthRspSetDest(reauthrsp,dest); } break; default: /* * This is an element we don't understand. If it's * critical, then we have to report an error. * Otherwise we can ignore it. */ if (OSPPMsgElemIsCritical(elem)) { ospvErrCode = OSPC_ERR_XML_BAD_ELEMENT; } break; } } if(ospvParent != OSPC_OSNULL) { ospvElem = ospvParent; } } if (ospvErrCode != OSPC_ERR_DATA_NO_REAUTHRSP) { *ospvReauthRsp = reauthrsp; } return(ospvErrCode);}/*-----------------------------------------------------------------------* * OSPPReauthRspDelete() - deletes a reauthorisation response structure *-----------------------------------------------------------------------*/void OSPPReauthRspDelete( OSPTREAUTHRSP **ospvReauthRsp){ if (*ospvReauthRsp != OSPC_OSNULL) { /* first remove the status */ if ((*ospvReauthRsp)->ospmReauthRspStatus != OSPC_OSNULL) { OSPPStatusDelete(&((*ospvReauthRsp)->ospmReauthRspStatus)); } /* now remove dest */ if(OSPPReauthRspHasDest(*ospvReauthRsp)) { OSPPDestDelete(&((*ospvReauthRsp)->ospmReauthRspDest)); } /* delete ComponentId and MessageId */ if(OSPPReauthRspHasComponentId(*ospvReauthRsp)) { OSPM_FREE((*ospvReauthRsp)->ospmReauthRspComponentId); (*ospvReauthRsp)->ospmReauthRspComponentId = OSPC_OSNULL; } if(OSPPReauthRspHasMessageId(*ospvReauthRsp)) { OSPM_FREE((*ospvReauthRsp)->ospmReauthRspMessageId); (*ospvReauthRsp)->ospmReauthRspMessageId = OSPC_OSNULL; } /* now delete the authrsp itself */ OSPM_FREE(*ospvReauthRsp); *ospvReauthRsp = OSPC_OSNULL; }}/*-----------------------------------------------------------------------* * OSPPReauthRspHasMessageId() - is the message id set ? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if message id is set */OSPPReauthRspHasMessageId( OSPTREAUTHRSP *ospvReauthRsp){ return (ospvReauthRsp->ospmReauthRspMessageId != OSPC_OSNULL);}/*-----------------------------------------------------------------------* * OSPPReauthRspSetMessageId() - creates space and copies in the string. *-----------------------------------------------------------------------*/void OSPPReauthRspSetMessageId( OSPTREAUTHRSP *ospvReauthRsp, /* In - pointer to Usage Indication struct */ unsigned char *ospvMessageId /* In - pointer to message id string */ ){ int len = OSPM_STRLEN((const char *)ospvMessageId); if(ospvReauthRsp != OSPC_OSNULL) { if(ospvReauthRsp->ospmReauthRspMessageId != OSPC_OSNULL) { OSPM_FREE(ospvReauthRsp->ospmReauthRspMessageId); } OSPM_MALLOC(ospvReauthRsp->ospmReauthRspMessageId, unsigned char, len + 1); OSPM_MEMSET(ospvReauthRsp->ospmReauthRspMessageId, 0, len + 1); OSPM_MEMCPY(ospvReauthRsp->ospmReauthRspMessageId, ospvMessageId, len); } return;}/* -----------------------------------------------------------------------------* * OSPPReauthRspMessageIdFromElement() - Get message id attribute from element. * -----------------------------------------------------------------------------*/void OSPPReauthRspMessageIdFromElement( OSPTXMLELEM *ospvElemIn, unsigned char **ospvMessageId){ OSPTXMLATTR *attr = (OSPTXMLATTR *)OSPC_OSNULL; /* look for the message id attribute */ for (attr = (OSPTXMLATTR *)OSPPXMLElemFirstAttr(ospvElemIn); (attr != (OSPTXMLATTR *)OSPC_OSNULL); attr = (OSPTXMLATTR *)OSPPXMLElemNextAttr(ospvElemIn, attr)) { if (OSPPMsgGetAttrPart(OSPPXMLAttrGetName(attr)) == ospeAttrMessageId) { /* we found the message attribute. Get the value */ *ospvMessageId = (unsigned char *)OSPPXMLAttrGetValue(attr); break; } }}/* -----------------------------------------------------------------------------* * OSPPReauthRspComponentIdFromElement() - Get component id attribute from element. * -----------------------------------------------------------------------------*/void OSPPReauthRspComponentIdFromElement( OSPTXMLELEM *ospvElemIn, unsigned char **ospvComponentId){ OSPTXMLATTR *attr = (OSPTXMLATTR *)OSPC_OSNULL; /* look for the component id attribute */ for (attr = (OSPTXMLATTR *)OSPPXMLElemFirstAttr(ospvElemIn); (attr != (OSPTXMLATTR *)OSPC_OSNULL); attr = (OSPTXMLATTR *)OSPPXMLElemNextAttr(ospvElemIn, attr)) { if (OSPPMsgGetAttrPart(OSPPXMLAttrGetName(attr)) == ospeAttrComponentId) { /* we found the component attribute. Get the value */ *ospvComponentId = (unsigned char *)OSPPXMLAttrGetValue(attr); break; } }}/**//*-----------------------------------------------------------------------* * OSPPReauthRspSetComponentId() - creates space and copies in the string. *-----------------------------------------------------------------------*/void OSPPReauthRspSetComponentId( OSPTREAUTHRSP *ospvReauthRsp, /* In - pointer to Usage Indication struct */ unsigned char *ospvComponentId /* In - pointer to component id string */ ){ int len = OSPM_STRLEN((const char *)ospvComponentId); if(ospvReauthRsp != OSPC_OSNULL) { if(ospvReauthRsp->ospmReauthRspComponentId != OSPC_OSNULL) { OSPM_FREE(ospvReauthRsp->ospmReauthRspComponentId); } OSPM_MALLOC(ospvReauthRsp->ospmReauthRspComponentId, unsigned char, len + 1); OSPM_MEMSET(ospvReauthRsp->ospmReauthRspComponentId, 0, len + 1); OSPM_MEMCPY(ospvReauthRsp->ospmReauthRspComponentId, ospvComponentId, len); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -