📄 osptransapi.c
字号:
* ospvSizeOfDestinationDevice: size of the character string (including the * terminating '\0') in which the function should store the destination * device identity. If the value is not large enough to accommodate the * destination device identity, then an error is indicated and no * destination is returned. * ospvDestinationDevice: character string in which to store the identity of * the destination device in a protocol specific manner (e.g. H.323 * Identifier); this value is optional and, if it is not present, the * returned string is empty. * ospvSizeOfToken: pointer to a variable which, on input, contains the size * of the memory buffer in which the function should store the * authorisation token for the destination. If the value is not large * enough to accommodate the token, then an error is indicated and no * destination is returned. On output this variable is updated to indicate * the actual size of the authorisation token. * ospvToken: memory location in which to store the authorisation token for * this destination. In general, tokens are opaque, binary objects. * The SDK library is able to perform this function without network * interaction, and, therefore, does not block for network input or output * during its execution. * The function returns an error code or zero (if the operation was successful). * Specific error codes and their meanings can be found in the osperrno.h file. */intOSPPTransactionGetFirstDestination( OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */ 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 dest device string */ char *ospvDestinationDevice, /* Out - Dest device 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; OSPTTRANS *trans = OSPC_OSNULL; trans = OSPPTransactionGetContext(ospvTransaction, &errorcode); if((trans != (OSPTTRANS *)NULL) && (errorcode == OSPC_ERR_NO_ERROR)) { errorcode = OSPPTransactionGetDestAllowed(trans); } if (errorcode == OSPC_ERR_NO_ERROR) { /* * Make sure we have a response */ if (trans->AuthRsp == (OSPTAUTHRSP *)NULL) errorcode = OSPC_ERR_TRAN_RESPONSE_NOT_FOUND; if(errorcode == OSPC_ERR_NO_ERROR) { /* * if no errors have occurred, get the destination information */ if ((errorcode == OSPC_ERR_NO_ERROR) && OSPPAuthRspHasDest(trans->AuthRsp) == OSPC_FALSE) { errorcode = OSPC_ERR_TRAN_DEST_INVALID; OSPM_DBGERRORLOG(errorcode, "destination not found"); } else { errorcode = OSPPTransactionGetDestination(trans, OSPC_FAIL_NONE, ospvSizeOfTimestamp, ospvValidAfter, ospvValidUntil, ospvTimeLimit, ospvSizeOfCallId, ospvCallId, ospvSizeOfCalledNumber, ospvCalledNumber, ospvSizeOfDestination, ospvDestination, ospvSizeOfDestinationDevice, ospvDestinationDevice, ospvSizeOfToken, ospvToken); } /* Set transaction state */ if (errorcode == OSPC_ERR_NO_ERROR) { OSPPTransactionSetState(trans, OSPC_GET_DEST_SUCCESS); } else { OSPPTransactionSetState(trans, OSPC_GET_DEST_FAIL); } } } return errorcode;}/* * OSPPTransactionGetNextDestination() * * The OSPPTransactionGetNextDestination function returns the identity of the * next authorised destination for a call. Applications may use this function * when attempts to use previously identified authorised destinations (starting * with the first destination) fail. The SDK library obtains the necessary * information for this function during its execution of the * OSPPTransactionRequestAuthorisation. The parameters to this function consist * of the following: * ospvTransaction: handle of the transaction object. * ospvFailureReason: the reason that attempts to use the previously * identified destination failed; values for this parameter are listed in * the ospfail.h file. * ospvSizeOfTimestamp: size of the character strings (including the * terminating '\0') in which the function should store validity times for * the destination. If this value is zero, then validity times are not * returned. If this size is non-zero but not large enough to store either * validity time, then an error is indicated and no destination is * returned. * ospvValidAfter: character string in which to store the earliest time for * which the call is authorised to the destination. The format for the * string is the same as indicated in the OSP protocol specification. * For example, 3:03 P.M. on May 2, 1997, Eastern Daylight Time in the * United States is represented as "1997-05-02T19:03:00Z". * ospvValidUntil: character string in which to store the latest time for * which the call is authorised to the destination. The format for the * string is the same as for the ospvValidAfter parameter. * ospvTimeLimit: pointer to a variable in which to place the number of * seconds for which the call is initially authorised. A value of zero * indicates that no limit exists. Note that the initial time limit may * be extended during the call by either party. * ospvSizeOfCallId: pointer to a variable which, on input, contains the size * of the memory buffer in which the function should place the H.323 call * identifier for the destination. If the value is not large enough to * accommodate the call identifier, then an error is indicated and no * destination is returned. On output this variable is updated to indicate * the actual size of the call identifier. * ospvCallId: memory location in which to store the H.323 call identifier for * the destination. The call identifier returned here is the same format * as the call identifier passed to the OSPPTransactionRequestAuthorisation * function. * ospvSizeOfCalledNumber: size of the character string (including the * terminating '\0') in which the function should store the called number. * If the value is not large enough to accommodate the called number, then * an error is indicated and no destination is returned. * ospvCalledNumber: character string in which to store the called number. In * general, the called number returned here will be the same as the called * number that the application passed to the * OSPPTransactionRequestAuthorisation function; however, the settlement * service provider may perform a number translation on the called number, * resulting in a new called number that should be signaled to the peer * gateway. * ospvSizeOfDestination: size of the character string (including the * terminating '\0') in which the function should store the destination * information. If the value is not large enough to accommodate the destination, * then an error is indicated and no destination is returned. * ospvDestination: character string in which to store the identity of the * destination. The value is expressed as either a DNS name or an IP * address enclosed in square brackets, followed by an optional colon * and TCP port number. * Examples of valid destinations include "gateway1.carrier.com" and * "[172.16.1.2]:112". * ospvSizeOfDestinationDevice: size of the character string (including the * terminating '\0') in which the function should store the destination * device identity. If the value is not large enough to accommodate the * destination device identity, then an error is indicated and no * destination is returned. * ospvDestinationDevice: character string in which to store the identity * of the destination device in a protocol specific manner (e.g. H.323 * Identifier); this value is optional and, if it is not present, the * returned string is empty. * ospvSizeOfToken: pointer to a variable which, on input, contains the size * of the memory buffer in which the function should store the * authorisation token for the destination. If the value is not large * enough to accommodate the token, then an error is indicated and no * destination is returned. On output this variable is updated to indicate * the actual size of the authorisation token. * ospvToken: memory location in which to store the authorisation token for * this destination. In general, tokens are opaque, binary objects. * The SDK library is able to perform this function without network * interaction, and, therefore, does not block for network input or output * during its execution. * The function returns an error code or zero (if the operation was successful). * Specific error codes and their meanings can be found in the osperrno.h file. */intOSPPTransactionGetNextDestination( OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */ enum OSPEFAILREASON ospvFailureReason, /* In - Failure code */ unsigned ospvSizeOfTimestamp, /* In - Max size of timestamp string */ char *ospvValidAfter, /* Out - Valid after time string */ char *ospvValidUntil, /* Out - Valid until time string */ unsigned *ospvTimeLimit, /* Out - Number of seconds call is authorised for */ unsigned *ospvSizeOfCallId, /* In - Max size of call id 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 dest device string */ char *ospvDestinationDevice, /* Out - Dest device 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; OSPTTRANS *trans = NULL; trans = OSPPTransactionGetContext(ospvTransaction, &errorcode); if(errorcode == OSPC_ERR_NO_ERROR) { errorcode = OSPPTransactionGetDestAllowed(trans); } if(errorcode == OSPC_ERR_NO_ERROR) { if (ospvFailureReason == OSPC_FAIL_NONE) { errorcode = OSPC_ERR_TRAN_INVALID_FAILURE_CODE; OSPM_DBGERRORLOG(errorcode, "failure code invalid"); } /* Now check for acceptable failure code */ if(errorcode == OSPC_ERR_NO_ERROR) { errorcode = OSPPFailReasonFind(ospvFailureReason); } if(errorcode == OSPC_ERR_NO_ERROR) { if (trans->CurrentDest == (OSPTDEST *)OSPC_OSNULL) { errorcode = OSPC_ERR_TRAN_NO_MORE_RESPONSES; OSPM_DBGERRORLOG(errorcode, "No more destinations."); } } if ((errorcode == OSPC_ERR_NO_ERROR) && (trans != (OSPTTRANS *)NULL)) { errorcode = OSPPTransactionGetDestination(trans, ospvFailureReason, ospvSizeOfTimestamp, ospvValidAfter, ospvValidUntil, ospvTimeLimit, ospvSizeOfCallId, ospvCallId, ospvSizeOfCalledNumber, ospvCalledNumber, ospvSizeOfDestination, ospvDestination, ospvSizeOfDestinationDevice, ospvDestinationDevice, ospvSizeOfToken, ospvToken); } /* Set transaction state */ if (errorcode == OSPC_ERR_NO_ERROR) { OSPPTransactionSetState(trans, OSPC_GET_DEST_SUCCESS); } else { OSPPTransactionSetState(trans, OSPC_GET_DEST_FAIL); } if (errorcode == OSPC_ERR_TRAN_DEST_INVALID) { errorcode = OSPC_ERR_TRAN_NO_MORE_RESPONSES; } } return errorcode;}/* * OSPPTransactionInitializeAtDevice() * * The OSPPTransactionInitializeAtDevice function initializes a (newly created) * transaction object. Applications can use this with a distributed * architecture in which the systems requesting and validating authorisation * (e.g. H.323 gatekeepers) are different than the systems that ultimately * report usage information (e.g. H.323 gateways). As such, this function is * (in a source device) an alternative to the combination of the * OSPPTransactionRequestAuthorisation function (to initiate a call) and the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -