send the correct Call-ID when using OSP (issue #5095)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6490 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-09-01 21:53:52 +00:00
parent 253e6537df
commit 06e4ba227d

View File

@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h" #include "asterisk/lock.h"
#include "asterisk/causes.h" #include "asterisk/causes.h"
#include "asterisk/callerid.h" #include "asterisk/callerid.h"
#include "asterisk/pbx.h"
#define MAX_CERTS 10 #define MAX_CERTS 10
#define MAX_SERVICEPOINTS 10 #define MAX_SERVICEPOINTS 10
@@ -493,10 +494,11 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
int tokenlen; int tokenlen;
unsigned int dummy=0; unsigned int dummy=0;
unsigned int timelimit; unsigned int timelimit;
char* sipcallid;
unsigned int callidlen; unsigned int callidlen;
char callidstr[OSPC_CALLID_MAXSIZE] = "";
struct osp_provider *osp; struct osp_provider *osp;
char source[OSP_MAX] = ""; /* Same length as osp->source */ char source[OSP_MAX] = ""; /* Same length as osp->source */
char uniqueid[32] = "";
char callednum[2048]=""; char callednum[2048]="";
char callingnum[2048]=""; char callingnum[2048]="";
char destination[2048]=""; char destination[2048]="";
@@ -528,7 +530,8 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
callerid = l; callerid = l;
if (chan) { if (chan) {
ast_copy_string(uniqueid, chan->uniqueid, sizeof(uniqueid)); sipcallid = pbx_builtin_getvar_helper (chan, "SIPCALLID");
ast_copy_string(callidstr, sipcallid, sizeof(callidstr));
cres = ast_autoservice_start(chan); cres = ast_autoservice_start(chan);
if (cres < 0) if (cres < 0)
return cres; return cres;
@@ -550,18 +553,18 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
ast_mutex_unlock(&osplock); ast_mutex_unlock(&osplock);
if (res) { if (res) {
res = 0; res = 0;
callid = OSPPCallIdNew(strlen(uniqueid), uniqueid); callid = OSPPCallIdNew(strlen(callidstr), callidstr);
if (callid) { if (callid) {
/* No more than 10 back */ /* No more than 10 back */
counts = 10; counts = 10;
dummy = 0; dummy = 0;
callidlen = sizeof(uniqueid); callidlen = sizeof(callidstr);
if (!OSPPTransactionRequestAuthorisation(result->handle, source, "", if (!OSPPTransactionRequestAuthorisation(result->handle, source, "",
callerid,OSPC_E164, extension, OSPC_E164, NULL, 1, &callid, NULL, &counts, &dummy, NULL)) { callerid,OSPC_E164, extension, OSPC_E164, NULL, 1, &callid, NULL, &counts, &dummy, NULL)) {
if (counts) { if (counts) {
tokenlen = sizeof(token); tokenlen = sizeof(token);
result->numresults = counts - 1; result->numresults = counts - 1;
if (!OSPPTransactionGetFirstDestination(result->handle, 0, NULL, NULL, &timelimit, &callidlen, uniqueid, if (!OSPPTransactionGetFirstDestination(result->handle, 0, NULL, NULL, &timelimit, &callidlen, callidstr,
sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) { sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
ast_log(LOG_DEBUG, "Got destination '%s' and called: '%s' calling: '%s' for '%s' (provider '%s')\n", ast_log(LOG_DEBUG, "Got destination '%s' and called: '%s' calling: '%s' for '%s' (provider '%s')\n",
destination, callednum, callingnum, extension, provider); destination, callednum, callingnum, extension, provider);
@@ -590,7 +593,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
} }
if (!res && result->numresults) { if (!res && result->numresults) {
result->numresults--; result->numresults--;
if (OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, uniqueid, if (OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, callidstr,
sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) { sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
break; break;
} }
@@ -629,7 +632,7 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
unsigned int dummy=0; unsigned int dummy=0;
unsigned int timelimit; unsigned int timelimit;
unsigned int callidlen; unsigned int callidlen;
char uniqueid[32] = ""; char callidstr[OSPC_CALLID_MAXSIZE] = "";
char callednum[2048]=""; char callednum[2048]="";
char callingnum[2048]=""; char callingnum[2048]="";
char destination[2048]=""; char destination[2048]="";
@@ -642,12 +645,12 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
if (result->handle > -1) { if (result->handle > -1) {
dummy = 0; dummy = 0;
callidlen = sizeof(uniqueid); callidlen = sizeof(callidstr);
if (result->numresults) { if (result->numresults) {
tokenlen = sizeof(token); tokenlen = sizeof(token);
while(!res && result->numresults) { while(!res && result->numresults) {
result->numresults--; result->numresults--;
if (!OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, uniqueid, if (!OSPPTransactionGetNextDestination(result->handle, OSPC_FAIL_INCOMPATIBLE_DEST, 0, NULL, NULL, &timelimit, &callidlen, callidstr,
sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) { sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
ast_base64encode(result->token, token, tokenlen, sizeof(result->token) - 1); ast_base64encode(result->token, token, tokenlen, sizeof(result->token) - 1);
if ((strlen(destination) > 2) && !OSPPTransactionGetDestProtocol(result->handle, &prot)) { if ((strlen(destination) > 2) && !OSPPTransactionGetDestProtocol(result->handle, &prot)) {