mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge OSP updates from matt nicholson (with changes)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4674 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1017,7 +1017,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
|||||||
time(&answer_time);
|
time(&answer_time);
|
||||||
#ifdef OSP_SUPPORT
|
#ifdef OSP_SUPPORT
|
||||||
/* Once call is answered, ditch the OSP Handle */
|
/* Once call is answered, ditch the OSP Handle */
|
||||||
pbx_builtin_setvar_helper(chan, "OSPHANDLE", "");
|
pbx_builtin_setvar_helper(chan, "_OSPHANDLE", "");
|
||||||
#endif
|
#endif
|
||||||
strncpy(status, "ANSWER", sizeof(status) - 1);
|
strncpy(status, "ANSWER", sizeof(status) - 1);
|
||||||
/* Ah ha! Someone answered within the desired timeframe. Of course after this
|
/* Ah ha! Someone answered within the desired timeframe. Of course after this
|
||||||
|
@@ -113,12 +113,13 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
|
|||||||
if ((res = ast_osp_lookup(chan, provider, temp, chan->cid.cid_num, &result)) > 0) {
|
if ((res = ast_osp_lookup(chan, provider, temp, chan->cid.cid_num, &result)) > 0) {
|
||||||
char tmp[80];
|
char tmp[80];
|
||||||
snprintf(tmp, sizeof(tmp), "%d", result.handle);
|
snprintf(tmp, sizeof(tmp), "%d", result.handle);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPHANDLE", tmp);
|
pbx_builtin_setvar_helper(chan, "_OSPHANDLE", tmp);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
|
pbx_builtin_setvar_helper(chan, "_OSPTECH", result.tech);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
|
pbx_builtin_setvar_helper(chan, "_OSPDEST", result.dest);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPTOKEN", result.token);
|
pbx_builtin_setvar_helper(chan, "_OSPTOKEN", result.token);
|
||||||
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
|
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPRESULTS", tmp);
|
pbx_builtin_setvar_helper(chan, "_OSPRESULTS", tmp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!res)
|
if (!res)
|
||||||
ast_log(LOG_NOTICE, "OSP Lookup failed for '%s' (provider '%s')\n", temp, provider ? provider : "<default>");
|
ast_log(LOG_NOTICE, "OSP Lookup failed for '%s' (provider '%s')\n", temp, provider ? provider : "<default>");
|
||||||
@@ -153,12 +154,12 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
|
|||||||
if ((res = ast_osp_next(&result, cause)) > 0) {
|
if ((res = ast_osp_next(&result, cause)) > 0) {
|
||||||
char tmp[80];
|
char tmp[80];
|
||||||
snprintf(tmp, sizeof(tmp), "%d", result.handle);
|
snprintf(tmp, sizeof(tmp), "%d", result.handle);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPHANDLE", tmp);
|
pbx_builtin_setvar_helper(chan, "_OSPHANDLE", tmp);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
|
pbx_builtin_setvar_helper(chan, "_OSPTECH", result.tech);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
|
pbx_builtin_setvar_helper(chan, "_OSPDEST", result.dest);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPTOKEN", result.token);
|
pbx_builtin_setvar_helper(chan, "_OSPTOKEN", result.token);
|
||||||
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
|
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
|
||||||
pbx_builtin_setvar_helper(chan, "OSPRESULTS", tmp);
|
pbx_builtin_setvar_helper(chan, "_OSPRESULTS", tmp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
@@ -204,7 +205,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
|
|||||||
result.handle = -1;
|
result.handle = -1;
|
||||||
if (temp && strlen(temp) && (sscanf(temp, "%i", &result.handle) == 1) && (result.handle > -1)) {
|
if (temp && strlen(temp) && (sscanf(temp, "%i", &result.handle) == 1) && (result.handle > -1)) {
|
||||||
if (!ast_osp_terminate(result.handle, cause, start, duration)) {
|
if (!ast_osp_terminate(result.handle, cause, start, duration)) {
|
||||||
pbx_builtin_setvar_helper(chan, "OSPHANDLE", "");
|
pbx_builtin_setvar_helper(chan, "_OSPHANDLE", "");
|
||||||
res = 1;
|
res = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -161,6 +161,8 @@ static int rpeerobjs = 0;
|
|||||||
static int apeerobjs = 0;
|
static int apeerobjs = 0;
|
||||||
static int regobjs = 0;
|
static int regobjs = 0;
|
||||||
|
|
||||||
|
static int global_allowguest = 0; /* allow unathuncated peers to connect? */
|
||||||
|
|
||||||
#define DEFAULT_MWITIME 10
|
#define DEFAULT_MWITIME 10
|
||||||
static int global_mwitime = DEFAULT_MWITIME; /* Time between MWI checks for peers */
|
static int global_mwitime = DEFAULT_MWITIME; /* Time between MWI checks for peers */
|
||||||
|
|
||||||
@@ -1444,6 +1446,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
|
|||||||
#ifdef OSP_SUPPORT
|
#ifdef OSP_SUPPORT
|
||||||
if (!osptoken || !osphandle || (sscanf(osphandle, "%i", &p->osphandle) != 1)) {
|
if (!osptoken || !osphandle || (sscanf(osphandle, "%i", &p->osphandle) != 1)) {
|
||||||
/* Force Disable OSP support */
|
/* Force Disable OSP support */
|
||||||
|
ast_log(LOG_DEBUG, "Disabling OSP support for this call. osptoken = %s, osphandle = %s\n", osptoken, osphandle);
|
||||||
osptoken = NULL;
|
osptoken = NULL;
|
||||||
osphandle = NULL;
|
osphandle = NULL;
|
||||||
p->osphandle = -1;
|
p->osphandle = -1;
|
||||||
@@ -3799,8 +3802,13 @@ static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, ch
|
|||||||
}
|
}
|
||||||
#ifdef OSP_SUPPORT
|
#ifdef OSP_SUPPORT
|
||||||
if (osptoken && !ast_strlen_zero(osptoken)) {
|
if (osptoken && !ast_strlen_zero(osptoken)) {
|
||||||
|
ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", osptoken);
|
||||||
add_header(&req, "P-OSP-Auth-Token", osptoken);
|
add_header(&req, "P-OSP-Auth-Token", osptoken);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ast_log(LOG_DEBUG,"NOT Adding OSP Token\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (distinctive_ring && !ast_strlen_zero(distinctive_ring))
|
if (distinctive_ring && !ast_strlen_zero(distinctive_ring))
|
||||||
{
|
{
|
||||||
@@ -4864,7 +4872,8 @@ static int check_auth(struct sip_pvt *p, struct sip_request *req, char *randdata
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%d", p->osphandle);
|
snprintf(tmp, sizeof(tmp), "%d", p->osphandle);
|
||||||
pbx_builtin_setvar_helper(p->owner, "OSPHANDLE", tmp);
|
pbx_builtin_setvar_helper(p->owner, "_OSPHANDLE", tmp);
|
||||||
|
|
||||||
|
|
||||||
/* If ospauth is 'exclusive' don't require further authentication */
|
/* If ospauth is 'exclusive' don't require further authentication */
|
||||||
if ((ast_test_flag(p, SIP_OSPAUTH) == SIP_OSPAUTH_EXCLUSIVE) ||
|
if ((ast_test_flag(p, SIP_OSPAUTH) == SIP_OSPAUTH_EXCLUSIVE) ||
|
||||||
@@ -5669,8 +5678,21 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, char *cmd
|
|||||||
p->noncodeccapability &= ~AST_RTP_DTMF;
|
p->noncodeccapability &= ~AST_RTP_DTMF;
|
||||||
}
|
}
|
||||||
ASTOBJ_UNREF(peer,sip_destroy_peer);
|
ASTOBJ_UNREF(peer,sip_destroy_peer);
|
||||||
} else if (debug)
|
} else {
|
||||||
ast_verbose("Found no matching peer or user for '%s:%d'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
if (debug)
|
||||||
|
ast_verbose("Found no matching peer or user for '%s:%d'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||||
|
|
||||||
|
/* do we allow guests? */
|
||||||
|
if (!global_allowguest)
|
||||||
|
res = -1; /* we don't want any guests, authentication will fail */
|
||||||
|
#ifdef OSP_SUPPORT
|
||||||
|
else if (global_allowguest == 2) {
|
||||||
|
ast_copy_flags(p, &global_flags, SIP_OSPAUTH);
|
||||||
|
res = check_auth(p, req, p->randdata, sizeof(p->randdata), "", "", "", cmd, uri, reliable, ignore);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
@@ -8924,6 +8946,7 @@ static int reload_config(void)
|
|||||||
regcontext[0] = '\0';
|
regcontext[0] = '\0';
|
||||||
tos = 0;
|
tos = 0;
|
||||||
expiry = DEFAULT_EXPIRY;
|
expiry = DEFAULT_EXPIRY;
|
||||||
|
global_allowguest = 1;
|
||||||
|
|
||||||
/* Read the [general] config section of sip.conf (or from realtime config) */
|
/* Read the [general] config section of sip.conf (or from realtime config) */
|
||||||
v = ast_variable_browse(cfg, "general");
|
v = ast_variable_browse(cfg, "general");
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
[general]
|
[general]
|
||||||
context=default ; Default context for incoming calls
|
context=default ; Default context for incoming calls
|
||||||
|
;allowguest=no ; Allow or reject guest calls (default is yes, this can also be set to 'osp'
|
||||||
|
; if asterisk was compiled with OSP support.
|
||||||
;recordhistory=yes ; Record SIP history by default
|
;recordhistory=yes ; Record SIP history by default
|
||||||
; (see sip history / sip no history)
|
; (see sip history / sip no history)
|
||||||
;realm=mydomain.tld ; Realm for digest authentication
|
;realm=mydomain.tld ; Realm for digest authentication
|
||||||
|
@@ -496,6 +496,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
|||||||
char source[OSP_MAX] = ""; /* Same length as osp->source */
|
char source[OSP_MAX] = ""; /* Same length as osp->source */
|
||||||
char uniqueid[32] = "";
|
char uniqueid[32] = "";
|
||||||
char callednum[2048]="";
|
char callednum[2048]="";
|
||||||
|
char callingnum[2048]="";
|
||||||
char destination[2048]="";
|
char destination[2048]="";
|
||||||
char token[2000];
|
char token[2000];
|
||||||
char tmp[256]="", *l, *n;
|
char tmp[256]="", *l, *n;
|
||||||
@@ -559,9 +560,9 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
|||||||
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, uniqueid,
|
||||||
sizeof(callednum), callednum, 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 '%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, extension, provider);
|
destination, callednum, callingnum, extension, provider);
|
||||||
do {
|
do {
|
||||||
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)) {
|
||||||
@@ -577,6 +578,10 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
|
|||||||
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
|
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
|
||||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||||
break;
|
break;
|
||||||
|
case OSPE_DEST_PROT_IAX:
|
||||||
|
strncpy(result->tech, "IAX", sizeof(result->tech) - 1);
|
||||||
|
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
|
ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
|
||||||
res = 0;
|
res = 0;
|
||||||
@@ -584,7 +589,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, uniqueid,
|
||||||
sizeof(callednum), callednum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
|
sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -624,6 +629,7 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
|
|||||||
unsigned int callidlen;
|
unsigned int callidlen;
|
||||||
char uniqueid[32] = "";
|
char uniqueid[32] = "";
|
||||||
char callednum[2048]="";
|
char callednum[2048]="";
|
||||||
|
char callingnum[2048]="";
|
||||||
char destination[2048]="";
|
char destination[2048]="";
|
||||||
char token[2000];
|
char token[2000];
|
||||||
OSPE_DEST_PROT prot;
|
OSPE_DEST_PROT prot;
|
||||||
@@ -640,7 +646,7 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
|
|||||||
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, uniqueid,
|
||||||
sizeof(callednum), callednum, 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)) {
|
||||||
res = 1;
|
res = 1;
|
||||||
@@ -655,6 +661,10 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
|
|||||||
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
|
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
|
||||||
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||||
break;
|
break;
|
||||||
|
case OSPE_DEST_PROT_IAX:
|
||||||
|
strncpy(result->tech, "IAX", sizeof(result->tech) - 1);
|
||||||
|
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
|
ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
|
||||||
res = 0;
|
res = 0;
|
||||||
@@ -700,10 +710,21 @@ int ast_osp_terminate(int handle, int cause, time_t start, time_t duration)
|
|||||||
unsigned int dummy = 0;
|
unsigned int dummy = 0;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
enum OSPEFAILREASON reason;
|
enum OSPEFAILREASON reason;
|
||||||
|
|
||||||
|
time_t endTime = 0;
|
||||||
|
time_t alertTime = 0;
|
||||||
|
time_t connectTime = 0;
|
||||||
|
unsigned isPddInfoPresent = 0;
|
||||||
|
unsigned pdd = 0;
|
||||||
|
unsigned releaseSource = 0;
|
||||||
|
unsigned char *confId = "";
|
||||||
|
|
||||||
reason = cause2reason(cause);
|
reason = cause2reason(cause);
|
||||||
if (OSPPTransactionRecordFailure(handle, reason))
|
if (OSPPTransactionRecordFailure(handle, reason))
|
||||||
ast_log(LOG_WARNING, "Failed to record call termination for handle %d\n", handle);
|
ast_log(LOG_WARNING, "Failed to record call termination for handle %d\n", handle);
|
||||||
else if (OSPPTransactionReportUsage(handle, duration, start, 0, 0, 0, 0, &dummy, NULL))
|
else if (OSPPTransactionReportUsage(handle, duration, start,
|
||||||
|
endTime,alertTime,connectTime,isPddInfoPresent,pdd,releaseSource,confId,
|
||||||
|
0, 0, 0, 0, &dummy, NULL))
|
||||||
ast_log(LOG_WARNING, "Failed to report duration for handle %d\n", handle);
|
ast_log(LOG_WARNING, "Failed to report duration for handle %d\n", handle);
|
||||||
else {
|
else {
|
||||||
ast_log(LOG_DEBUG, "Completed recording handle %d\n", handle);
|
ast_log(LOG_DEBUG, "Completed recording handle %d\n", handle);
|
||||||
|
Reference in New Issue
Block a user