time(&answer_time);
#ifdef OSP_SUPPORT
/* Once call is answered, ditch the OSP Handle */
- pbx_builtin_setvar_helper(chan, "OSPHANDLE", "");
+ pbx_builtin_setvar_helper(chan, "_OSPHANDLE", "");
#endif
strncpy(status, "ANSWER", sizeof(status) - 1);
/* Ah ha! Someone answered within the desired timeframe. Of course after this
if ((res = ast_osp_lookup(chan, provider, temp, chan->cid.cid_num, &result)) > 0) {
char tmp[80];
snprintf(tmp, sizeof(tmp), "%d", result.handle);
- pbx_builtin_setvar_helper(chan, "OSPHANDLE", tmp);
- pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- pbx_builtin_setvar_helper(chan, "OSPTOKEN", result.token);
+ pbx_builtin_setvar_helper(chan, "_OSPHANDLE", tmp);
+ pbx_builtin_setvar_helper(chan, "_OSPTECH", result.tech);
+ pbx_builtin_setvar_helper(chan, "_OSPDEST", result.dest);
+ pbx_builtin_setvar_helper(chan, "_OSPTOKEN", result.token);
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
- pbx_builtin_setvar_helper(chan, "OSPRESULTS", tmp);
+ pbx_builtin_setvar_helper(chan, "_OSPRESULTS", tmp);
+
} else {
if (!res)
ast_log(LOG_NOTICE, "OSP Lookup failed for '%s' (provider '%s')\n", temp, provider ? provider : "<default>");
if ((res = ast_osp_next(&result, cause)) > 0) {
char tmp[80];
snprintf(tmp, sizeof(tmp), "%d", result.handle);
- pbx_builtin_setvar_helper(chan, "OSPHANDLE", tmp);
- pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- pbx_builtin_setvar_helper(chan, "OSPTOKEN", result.token);
+ pbx_builtin_setvar_helper(chan, "_OSPHANDLE", tmp);
+ pbx_builtin_setvar_helper(chan, "_OSPTECH", result.tech);
+ pbx_builtin_setvar_helper(chan, "_OSPDEST", result.dest);
+ pbx_builtin_setvar_helper(chan, "_OSPTOKEN", result.token);
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
- pbx_builtin_setvar_helper(chan, "OSPRESULTS", tmp);
+ pbx_builtin_setvar_helper(chan, "_OSPRESULTS", tmp);
}
} else {
if (!res) {
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)) {
- pbx_builtin_setvar_helper(chan, "OSPHANDLE", "");
+ pbx_builtin_setvar_helper(chan, "_OSPHANDLE", "");
res = 1;
}
} else {
static int apeerobjs = 0;
static int regobjs = 0;
+static int global_allowguest = 0; /* allow unathuncated peers to connect? */
+
#define DEFAULT_MWITIME 10
static int global_mwitime = DEFAULT_MWITIME; /* Time between MWI checks for peers */
#ifdef OSP_SUPPORT
if (!osptoken || !osphandle || (sscanf(osphandle, "%i", &p->osphandle) != 1)) {
/* Force Disable OSP support */
+ ast_log(LOG_DEBUG, "Disabling OSP support for this call. osptoken = %s, osphandle = %s\n", osptoken, osphandle);
osptoken = NULL;
osphandle = NULL;
p->osphandle = -1;
}
#ifdef OSP_SUPPORT
if (osptoken && !ast_strlen_zero(osptoken)) {
+ ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", osptoken);
add_header(&req, "P-OSP-Auth-Token", osptoken);
}
+ else
+ {
+ ast_log(LOG_DEBUG,"NOT Adding OSP Token\n");
+ }
#endif
if (distinctive_ring && !ast_strlen_zero(distinctive_ring))
{
return -1;
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 ((ast_test_flag(p, SIP_OSPAUTH) == SIP_OSPAUTH_EXCLUSIVE) ||
p->noncodeccapability &= ~AST_RTP_DTMF;
}
ASTOBJ_UNREF(peer,sip_destroy_peer);
- } else 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));
+ } else {
+ 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)
regcontext[0] = '\0';
tos = 0;
expiry = DEFAULT_EXPIRY;
+ global_allowguest = 1;
/* Read the [general] config section of sip.conf (or from realtime config) */
v = ast_variable_browse(cfg, "general");
[general]
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
; (see sip history / sip no history)
;realm=mydomain.tld ; Realm for digest authentication
char source[OSP_MAX] = ""; /* Same length as osp->source */
char uniqueid[32] = "";
char callednum[2048]="";
+ char callingnum[2048]="";
char destination[2048]="";
char token[2000];
char tmp[256]="", *l, *n;
tokenlen = sizeof(token);
result->numresults = counts - 1;
if (!OSPPTransactionGetFirstDestination(result->handle, 0, NULL, NULL, &timelimit, &callidlen, uniqueid,
- sizeof(callednum), callednum, sizeof(destination), destination, 0, NULL, &tokenlen, token)) {
- ast_log(LOG_DEBUG, "Got destination '%s' and '%s' for '%s' (provider '%s')\n",
- destination, callednum, extension, provider);
+ 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",
+ destination, callednum, callingnum, extension, provider);
do {
ast_base64encode(result->token, token, tokenlen, sizeof(result->token) - 1);
if ((strlen(destination) > 2) && !OSPPTransactionGetDestProtocol(result->handle, &prot)) {
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
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:
ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
res = 0;
if (!res && result->numresults) {
result->numresults--;
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;
}
}
unsigned int callidlen;
char uniqueid[32] = "";
char callednum[2048]="";
+ char callingnum[2048]="";
char destination[2048]="";
char token[2000];
OSPE_DEST_PROT prot;
while(!res && result->numresults) {
result->numresults--;
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);
if ((strlen(destination) > 2) && !OSPPTransactionGetDestProtocol(result->handle, &prot)) {
res = 1;
strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
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:
ast_log(LOG_DEBUG, "Unknown destination protocol '%d', skipping...\n", prot);
res = 0;
unsigned int dummy = 0;
int res = -1;
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);
if (OSPPTransactionRecordFailure(handle, reason))
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);
else {
ast_log(LOG_DEBUG, "Completed recording handle %d\n", handle);