📄 osptrans.c
字号:
if (transctxt == (OSPTTRANS *)OSPC_OSNULL) { *ospvError = OSPC_ERR_TRAN_TRANSACTION_NOT_FOUND; OSPM_DBGERRORLOG(*ospvError, "transaction not found."); } } return transctxt;}/* * determine if delete is allowed or not depending on transaction state. * * returns void. */voidOSPPTransactionGetDeleteAllowed( OSPTTRANS *ospvTrans, /* In - Pointer to transaction */ OSPTBOOL *ospvDeleteAllowed) /* Out - Indicates permission to delete */{#ifdef OSPC_GK_SIM extern char *OSPVDeleteAllowed; if (OSPVDeleteAllowed != OSPC_OSNULL) { *ospvDeleteAllowed = OSPC_TRUE; return; }#endif /* If NO_DELETE_CHECK is defined, delete will always be allowed */#ifndef OSP_NO_DELETE_CHECK switch(ospvTrans->State) { case OSPC_TRANSNEW: case OSPC_AUTH_REQUEST_FAIL: case OSPC_AUTH_REQUEST_SUCCESS: case OSPC_GET_DEST_FAIL: case OSPC_REPORT_USAGE_BLOCK: case OSPC_REPORT_USAGE_SUCCESS: case OSPC_VALIDATE_AUTH_FAIL: case OSPC_INITIALIZE_FAIL: case OSPC_REINITIALIZE_FAIL: case OSPC_REPORT_USAGE_FAIL: *ospvDeleteAllowed = OSPC_TRUE; break; case OSPC_AUTH_REQUEST_BLOCK: case OSPC_VALIDATE_AUTH_SUCCESS: case OSPC_GET_DEST_SUCCESS: case OSPC_INITIALIZE_SUCCESS: case OSPC_REINITIALIZE_SUCCESS: case OSPC_ACCUMULATE_SUCCESS: case OSPC_ACCUMULATE_FAIL: *ospvDeleteAllowed = OSPC_FALSE; break; default: /* unknown state */ *ospvDeleteAllowed = OSPC_FALSE; }#else *ospvDeleteAllowed = OSPC_TRUE;#endif /* OSP_NO_DELETE_CHECK */ return;}/* Dests only available in approved states */int OSPPTransactionGetDestAllowed( OSPTTRANS *ospvTrans){ int errorcode = OSPC_ERR_NO_ERROR; switch(ospvTrans->State) { case OSPC_AUTH_REQUEST_SUCCESS: case OSPC_GET_DEST_FAIL: case OSPC_GET_DEST_SUCCESS: case OSPC_ACCUMULATE_FAIL: break; case OSPC_TRANSNEW: case OSPC_INVALID_STATE: case OSPC_AUTH_REQUEST_BLOCK: case OSPC_AUTH_REQUEST_FAIL: case OSPC_INITIALIZE_SUCCESS: case OSPC_INITIALIZE_FAIL: case OSPC_REINITIALIZE_SUCCESS: case OSPC_REINITIALIZE_FAIL: case OSPC_VALIDATE_AUTH_SUCCESS: case OSPC_VALIDATE_AUTH_FAIL: case OSPC_REPORT_USAGE_BLOCK: case OSPC_REPORT_USAGE_FAIL: case OSPC_REPORT_USAGE_SUCCESS: case OSPC_ACCUMULATE_SUCCESS: errorcode = OSPC_ERR_TRAN_GET_DEST_NOT_ALLOWED; break; default: /* unknown state */ errorcode = OSPC_ERR_TRAN_GET_DEST_NOT_ALLOWED; } return errorcode;}intOSPPTransactionGetDestination( OSPTTRANS *ospvTrans, /* In - Transaction pointer */ enum OSPEFAILREASON ospvFailureReason, /* In - Failure Reason for prev dest req */ unsigned ospvSizeOfTimestamp, /* In - Max size for timestamp string */ char *ospvValidAfter, /* Out - Valid After time in string format */ char *ospvValidUntil, /* Out - Valid Until time in string format */ unsigned *ospvTimeLimit, /* Out - Number of seconds call is authorised for */ unsigned *ospvSizeOfCallId, /* In/Out - Max size for CallId string \ Actual size of CallId string */ void *ospvCallId, /* Out - Call Id string */ unsigned ospvSizeOfCalledNumber, /* In - Max size of called number */ char *ospvCalledNumber, /* Out - Called number string */ unsigned ospvSizeOfDestination, /* In - Max size of destination string */ char *ospvDestination, /* Out - Destination string */ unsigned ospvSizeOfDestinationDevice, /* In - Max size of destination device string */ char *ospvDestinationDevice, /* Out - DestinationDevice string */ unsigned *ospvSizeOfToken, /* In/Out - Max size of token string Actual size of token string */ void *ospvToken) /* Out - Token string */{ int errorcode = OSPC_ERR_NO_ERROR, timeflag = OSPC_TRUE; OSPTCALLID *callid = OSPC_OSNULL; OSPTDEST *dest = OSPC_OSNULL; OSPTSTATUS *status = OSPC_OSNULL; OSPTTIME validtime = 0; unsigned char *destnum = OSPC_OSNULL, *sigaddr = OSPC_OSNULL; OSPTTOKEN *token = OSPC_OSNULL; /* Make sure there is enough space for the timestamp * copies. */ if(ospvSizeOfTimestamp == 0) { timeflag = OSPC_FALSE; } else if(ospvSizeOfTimestamp < OSPC_TIMESTRINGSIZE) { errorcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY; OSPM_DBGERRORLOG(errorcode, "Not enough space for timestrings."); } /* We set this in getFirst and check it in getNext, so if it gets * here, it IS getFirst calling */ if ((ospvFailureReason == OSPC_FAIL_NONE) && (errorcode == OSPC_ERR_NO_ERROR)) { /* * Get the status code for first time calls. If the status code < 200 or > 299 * then there is no use in continuing. */ if (OSPPAuthRspHasStatus(ospvTrans->AuthRsp) == OSPC_FALSE) { errorcode = OSPC_ERR_TRAN_STATUS_INVALID; OSPM_DBGERRORLOG(errorcode, "status not found"); } else { status = OSPPAuthRspGetStatus(ospvTrans->AuthRsp); if(status != (OSPTSTATUS *)OSPC_OSNULL) { if (!OSPM_STATUSCODE_SUCCESSFUL(status->ospmStatusCode)) { errorcode = status->ospmStatusCode; OSPM_DBGERRORLOG(errorcode, "server returned a status error"); } } else { errorcode = OSPC_ERR_TRAN_STATUS_NOT_FOUND; OSPM_DBGERRORLOG(errorcode, "status not found"); } } if (errorcode == OSPC_ERR_NO_ERROR) { dest = (OSPTDEST *)OSPPAuthRspFirstDest(ospvTrans->AuthRsp); ospvTrans->CurrentDest = dest; } } else { /* * looking for next destination */ if(ospvTrans->CurrentDest != OSPC_OSNULL) { dest = (OSPTDEST *)OSPPAuthRspNextDest(ospvTrans->AuthRsp, ospvTrans->CurrentDest); /* are we at the end? */ if(dest != OSPC_OSNULL) { /* put the failure reason into the destination failure code field * and move current destination pointer to next dest */ OSPPDestSetTNFailReason(ospvTrans->CurrentDest, ospvFailureReason); ospvTrans->CurrentDest = dest; } } } /* * if no errors have occurred, get the destination information */ if ((dest == (OSPTDEST *)OSPC_OSNULL) && (errorcode == OSPC_ERR_NO_ERROR)) { errorcode = OSPC_ERR_TRAN_DEST_INVALID; OSPM_DBGERRORLOG(errorcode, "destination not found"); } else { if ((errorcode == OSPC_ERR_NO_ERROR) && (timeflag == OSPC_TRUE)) { if(OSPPDestHasValidAfter(dest)) { validtime = OSPPDestGetValidAfter(dest); errorcode = OSPPOSTimeCalToString(validtime, ospvValidAfter); } else { validtime = OSPC_TIMEMIN; errorcode = OSPPOSTimeCalToString(validtime, ospvValidAfter); } } if ((errorcode == OSPC_ERR_NO_ERROR) && (timeflag == OSPC_TRUE)) { if(OSPPDestHasValidUntil(dest)) { validtime = OSPPDestGetValidUntil(dest); errorcode = OSPPOSTimeCalToString(validtime, ospvValidUntil); } else { validtime = OSPC_TIMEMAX; errorcode = OSPPOSTimeCalToString(validtime, ospvValidUntil); } } if(errorcode == OSPC_ERR_NO_ERROR) { /* Is time limit required ? */ if(OSPPDestHasLimit(dest)) { *ospvTimeLimit = OSPPDestGetLimit(dest); } if (!OSPPDestHasCallId(dest)) { errorcode = OSPC_ERR_TRAN_CALL_ID_INVALID; OSPM_DBGERRORLOG(errorcode, "null pointer for callid"); } else { callid = OSPPDestGetCallId(dest); if (OSPPCallIdGetSize(callid) > *ospvSizeOfCallId) { errorcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY; OSPM_DBGERRORLOG(errorcode, "not enough space for callid"); } else { /* * Get call id */ OSPM_MEMCPY(ospvCallId, OSPPCallIdGetValue(callid), OSPPCallIdGetSize(callid)); } *ospvSizeOfCallId = OSPPCallIdGetSize(callid); } } if (errorcode == OSPC_ERR_NO_ERROR) { if (!OSPPDestHasNumber(dest)) { /* get dest number from authreq */ if(OSPPAuthReqHasDestNumber(ospvTrans->AuthReq)) { destnum = OSPPAuthReqGetDestNumber(ospvTrans->AuthReq); } } else { destnum = OSPPDestGetNumber(dest); } if (destnum == OSPC_OSNULL) { errorcode = OSPC_ERR_TRAN_DEST_INVALID; OSPM_DBGERRORLOG(errorcode, "null pointer for dest number."); } else { if (ospvSizeOfCalledNumber < strlen((const char *)destnum)+1) { errorcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY; OSPM_DBGERRORLOG(errorcode, "not enough space for called number"); } else { /* * Get the destination number */ OSPM_MEMCPY(ospvCalledNumber, destnum, strlen((const char *)destnum)+1); } } } if (errorcode == OSPC_ERR_NO_ERROR) { if (!OSPPDestHasAddr(dest)) { errorcode = OSPC_ERR_TRAN_SIGADDR_INVALID; OSPM_DBGERRORLOG(errorcode, "null pointer for signal address."); } else { sigaddr = OSPPDestGetAddr(dest); if (sigaddr == OSPC_OSNULL) { errorcode = OSPC_ERR_TRAN_SIGADDR_INVALID; OSPM_DBGERRORLOG(errorcode, "null pointer for signal address."); } else { if (ospvSizeOfDestination < strlen((const char *)sigaddr)+1) { errorcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY; OSPM_DBGERRORLOG(errorcode, "not enough space for signal addr"); } else { /* * Get the signal address (Destination) */ OSPM_MEMCPY(ospvDestination, sigaddr, strlen((const char *)sigaddr)+1); } } } } if (errorcode == OSPC_ERR_NO_ERROR) { if (OSPPDestDevHasAddr(dest)) { sigaddr = OSPC_OSNULL; sigaddr = OSPPDestDevGetAddr(dest); if (sigaddr == OSPC_OSNULL) { errorcode = OSPC_ERR_TRAN_SIGADDR_INVALID; OSPM_DBGERRORLOG(errorcode, "null pointer for device address."); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -