[asterisk-commits] transnexus: branch 1.4 r86438 - /branches/1.4/apps/app_osplookup.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Oct 18 20:45:54 CDT 2007
Author: transnexus
Date: Thu Oct 18 20:45:53 2007
New Revision: 86438
URL: http://svn.digium.com/view/asterisk?view=rev&rev=86438
Log:
Fixed OSP module did not report source/devinfo IP in correct format.
Modified:
branches/1.4/apps/app_osplookup.c
Modified: branches/1.4/apps/app_osplookup.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_osplookup.c?view=diff&rev=86438&r1=86437&r2=86438
==============================================================================
--- branches/1.4/apps/app_osplookup.c (original)
+++ branches/1.4/apps/app_osplookup.c Thu Oct 18 20:45:53 2007
@@ -398,6 +398,26 @@
}
/*!
+ * \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 @@
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 @@
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 @@
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");
More information about the asterisk-commits
mailing list