Fixed OSP module did not report source/devinfo IP in correct format.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@86438 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
TransNexus OSP Development
2007-10-19 01:45:53 +00:00
parent 1e9e35c081
commit 36ffd8e75b

View File

@@ -397,6 +397,26 @@ static int osp_create_transaction(const char* provider, int* transaction, unsign
return res; return res;
} }
/*!
* \brief Convert address to "[x.x.x.x]" or "host.domain" format
* \param src Source address string
* \param dst Destination address string
* \param buffersize Size of dst buffer
*/
static void osp_convert_address(
const char* src,
char* dst,
int buffersize)
{
struct in_addr inp;
if (inet_aton(src, &inp) != 0) {
snprintf(dst, buffersize, "[%s]", src);
} else {
snprintf(dst, buffersize, "%s", src);
}
}
/*! /*!
* \brief Validate OSP token of inbound call * \brief Validate OSP token of inbound call
* \param transaction OSP transaction handle * \param transaction OSP transaction handle
@@ -413,14 +433,18 @@ static int osp_validate_token(int transaction, const char* source, const char* d
int res; int res;
int tokenlen; int tokenlen;
unsigned char tokenstr[OSP_TOKSTR_SIZE]; unsigned char tokenstr[OSP_TOKSTR_SIZE];
char src[OSP_NORSTR_SIZE];
char dst[OSP_NORSTR_SIZE];
unsigned int authorised; unsigned int authorised;
unsigned int dummy = 0; unsigned int dummy = 0;
int error; int error;
tokenlen = ast_base64decode(tokenstr, token, strlen(token)); tokenlen = ast_base64decode(tokenstr, token, strlen(token));
osp_convert_address(source, src, sizeof(src));
osp_convert_address(dest, dst, sizeof(dst));
error = OSPPTransactionValidateAuthorisation( error = OSPPTransactionValidateAuthorisation(
transaction, transaction,
source, dest, NULL, NULL, src, dst, NULL, NULL,
calling ? calling : "", OSPC_E164, calling ? calling : "", OSPC_E164,
called, OSPC_E164, called, OSPC_E164,
0, NULL, 0, NULL,
@@ -622,6 +646,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
char destination[OSP_NORSTR_SIZE]; char destination[OSP_NORSTR_SIZE];
unsigned int tokenlen; unsigned int tokenlen;
char token[OSP_TOKSTR_SIZE]; char token[OSP_TOKSTR_SIZE];
char src[OSP_NORSTR_SIZE];
char dev[OSP_NORSTR_SIZE];
unsigned int dummy = 0; unsigned int dummy = 0;
enum OSPEFAILREASON reason; enum OSPEFAILREASON reason;
int error; int error;
@@ -643,8 +669,10 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
return -1; return -1;
} }
osp_convert_address(source, src, sizeof(src));
osp_convert_address(srcdev, dev, sizeof(dev));
result->numresults = OSP_DEF_DESTINATIONS; result->numresults = OSP_DEF_DESTINATIONS;
error = OSPPTransactionRequestAuthorisation(result->outhandle, source, srcdev, calling ? calling : "", error = OSPPTransactionRequestAuthorisation(result->outhandle, src, dev, calling ? calling : "",
OSPC_E164, called, OSPC_E164, NULL, 0, NULL, NULL, &result->numresults, &dummy, NULL); OSPC_E164, called, OSPC_E164, NULL, 0, NULL, NULL, &result->numresults, &dummy, NULL);
if (error != OSPC_ERR_NO_ERROR) { if (error != OSPC_ERR_NO_ERROR) {
ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n"); ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");