aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_osplookup.c
diff options
context:
space:
mode:
authortransnexus <transnexus@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-19 01:45:53 +0000
committertransnexus <transnexus@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-19 01:45:53 +0000
commit1684706bc59923cef8199a85a3221f5fc86b759b (patch)
treedf22c188758ea9557fc15bc830c5147fc5b2c647 /apps/app_osplookup.c
parent70689cf7a12d1f2dd84f3eaf39b5f9d8ef65ad55 (diff)
Fixed OSP module did not report source/devinfo IP in correct format.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@86438 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_osplookup.c')
-rw-r--r--apps/app_osplookup.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index ec7eecf39..ad2ce5065 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -398,6 +398,26 @@ static int osp_create_transaction(const char* provider, int* transaction, unsign
}
/*!
+ * \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
* \param transaction OSP transaction handle
* \param source Source of inbound call
@@ -413,14 +433,18 @@ static int osp_validate_token(int transaction, const char* source, const char* d
int res;
int tokenlen;
unsigned char tokenstr[OSP_TOKSTR_SIZE];
+ char src[OSP_NORSTR_SIZE];
+ char dst[OSP_NORSTR_SIZE];
unsigned int authorised;
unsigned int dummy = 0;
int error;
tokenlen = ast_base64decode(tokenstr, token, strlen(token));
+ osp_convert_address(source, src, sizeof(src));
+ osp_convert_address(dest, dst, sizeof(dst));
error = OSPPTransactionValidateAuthorisation(
transaction,
- source, dest, NULL, NULL,
+ src, dst, NULL, NULL,
calling ? calling : "", OSPC_E164,
called, OSPC_E164,
0, NULL,
@@ -622,6 +646,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
char destination[OSP_NORSTR_SIZE];
unsigned int tokenlen;
char token[OSP_TOKSTR_SIZE];
+ char src[OSP_NORSTR_SIZE];
+ char dev[OSP_NORSTR_SIZE];
unsigned int dummy = 0;
enum OSPEFAILREASON reason;
int error;
@@ -643,8 +669,10 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
return -1;
}
+ osp_convert_address(source, src, sizeof(src));
+ osp_convert_address(srcdev, dev, sizeof(dev));
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);
if (error != OSPC_ERR_NO_ERROR) {
ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");