Issue #6899 - remove OSP support code from chan_sip.c and app_dial.c

- implement all functions through internal APIs in res_osp.c and app_osplookup.c
(homesick)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@18369 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Olle Johansson 20 years ago
parent fd54f36509
commit 7089dc1341

@ -29,6 +29,8 @@ Applications:
"noanswer" will not work. Use s or n. Also there is a new feature i, for
using indication tones, so typing in skip would give you unexpected results.
* OSPAuth is added to authenticate OSP tokens in in_bound call setup messages.
Variables:
* The builtin variables ${CALLERID}, ${CALLERIDNAME}, ${CALLERIDNUM},
@ -40,6 +42,10 @@ Variables:
* The CDR-CSV variables uniqueid, userfield, and basing time on GMT are now
adjustable from cdr.conf, instead of recompiling.
* OSP applications exports several new variables, ${OSPINHANDLE},
${OSPOUTHANDLE}, ${OSPINTOKEN}, ${OSPOUTTOKEN}, ${OSPCALLING},
${OSPINTIMELIMIT}, and ${OSPOUTTIMELIMIT}
Functions:
* The function ${CHECK_MD5()} has been deprecated in favor of using an
@ -66,6 +72,10 @@ The SIP channel:
* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.
* OSP support code is removed from SIP channel to OSP applications. ospauth
option in sip.conf is removed to osp.conf as authpolicy. allowguest option
in sip.conf cannot be set as osp anymore.
Installation:
* On BSD systems, the installation directories have changed to more "FreeBSDish" directories. On startup, Asterisk will look for the main configuration in /usr/local/etc/asterisk/asterisk.conf

@ -1189,10 +1189,6 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
}
if (peer) {
time(&answer_time);
#ifdef OSP_SUPPORT
/* Once call is answered, ditch the OSP Handle */
pbx_builtin_setvar_helper(chan, "_OSPHANDLE", "");
#endif
strcpy(status, "ANSWER");
/* Ah ha! Someone answered within the desired timeframe. Of course after this
we will always return with -1 so that it is hung up properly after the

@ -16,9 +16,9 @@
* at the top of the source tree.
*/
/*! \file
*
* \brief Open Settlement Protocol Lookup
/*!
* \file
* \brief Open Settlement Protocol Applications
*
* \author Mark Spencer <markster@digium.com>
*
@ -49,44 +49,55 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/options.h"
static char *tdesc = "OSP Lookup";
static char *app = "OSPLookup";
static char *app2 = "OSPNext";
static char *app3 = "OSPFinish";
static char *synopsis = "Lookup number in OSP";
static char *synopsis2 = "Lookup next OSP entry";
static char *synopsis3 = "Record OSP entry";
static char *app1= "OSPAuth";
static char *synopsis1 = "OSP authentication";
static char *descrip1 =
" OSPAuth([provider[|options]]): Authenticate a SIP INVITE by OSP and sets\n"
"the variables:\n"
" ${OSPINHANDLE}: The in_bound call transaction handle\n"
" ${OSPINTIMELIMIT}: The in_bound call duration limit in seconds\n"
"\n"
"The option string may contain the following character:\n"
" 'j' -- jump to n+101 priority if the authentication was NOT successful\n"
"This application sets the following channel variable upon completion:\n"
" OSPAUTHSTATUS The status of the OSP Auth attempt as a text string, one of\n"
" SUCCESS | FAILED | ERROR\n";
static char *descrip =
static char *app2= "OSPLookup";
static char *synopsis2 = "Lookup destination by OSP";
static char *descrip2 =
" OSPLookup(exten[|provider[|options]]): Looks up an extension via OSP and sets\n"
"the variables, where 'n' is the number of the result beginning with 1:\n"
" ${OSPTECH}: The technology to use for the call\n"
" ${OSPDEST}: The destination to use for the call\n"
" ${OSPTOKEN}: The actual OSP token as a string\n"
" ${OSPHANDLE}: The OSP Handle for anything remaining\n"
" ${OSPRESULTS}: The number of OSP results total remaining\n"
" ${OSPOUTHANDLE}: The OSP Handle for anything remaining\n"
" ${OSPTECH}: The technology to use for the call\n"
" ${OSPDEST}: The destination to use for the call\n"
" ${OSPCALLING}: The calling number to use for the call\n"
" ${OSPOUTTOKEN}: The actual OSP token as a string\n"
" ${OSPOUTTIMELIMIT}: The out_bound call duration limit in seconds\n"
" ${OSPRESULTS}: The number of OSP results total remaining\n"
"\n"
"The option string may contain the following character:\n"
" 'j' -- jump to n+101 priority if the lookup was NOT successful\n"
"This application sets the following channel variable upon completion:\n"
" OSPLOOKUPSTATUS The status of the OSP Lookup attempt as a text string, one of\n"
" SUCCESS | FAILED \n";
" SUCCESS | FAILED | ERROR\n";
static char *descrip2 =
" OSPNext(cause[|options]): Looks up the next OSP Destination for ${OSPHANDLE}\n"
static char *app3 = "OSPNext";
static char *synopsis3 = "Lookup next destination by OSP";
static char *descrip3 =
" OSPNext(cause[|options]): Looks up the next OSP Destination for ${OSPOUTHANDLE}\n"
"See OSPLookup for more information\n"
"\n"
"The option string may contain the following character:\n"
" 'j' -- jump to n+101 priority if the lookup was NOT successful\n"
"This application sets the following channel variable upon completion:\n"
" OSPNEXTSTATUS The status of the OSP Next attempt as a text string, one of\n"
" SUCCESS | FAILED \n";
" SUCCESS | FAILED |ERROR\n";
static char *descrip3 =
" OSPFinish(status[|options]): Records call state for ${OSPHANDLE}, according to\n"
static char *app4 = "OSPFinish";
static char *synopsis4 = "Record OSP entry";
static char *descrip4 =
" OSPFinish([status[|options]]): Records call state for ${OSPINHANDLE}, according to\n"
"status, which should be one of BUSY, CONGESTION, ANSWER, NOANSWER, or CHANUNAVAIL\n"
"or coincidentally, just what the Dial application stores in its ${DIALSTATUS}.\n"
"\n"
@ -94,278 +105,546 @@ static char *descrip3 =
" 'j' -- jump to n+101 priority if the finish attempt was NOT successful\n"
"This application sets the following channel variable upon completion:\n"
" OSPFINISHSTATUS The status of the OSP Finish attempt as a text string, one of\n"
" SUCCESS | FAILED \n";
" SUCCESS | FAILED |ERROR \n";
LOCAL_USER_DECL;
static int str2cause(char *cause)
static int ospauth_exec(struct ast_channel *chan, void *data)
{
if (!strcasecmp(cause, "BUSY"))
return AST_CAUSE_BUSY;
if (!strcasecmp(cause, "CONGESTION"))
return AST_CAUSE_CONGESTION;
if (!strcasecmp(cause, "ANSWER"))
return AST_CAUSE_NORMAL;
if (!strcasecmp(cause, "CANCEL"))
return AST_CAUSE_NORMAL;
if (!strcasecmp(cause, "NOANSWER"))
return AST_CAUSE_NOANSWER;
if (!strcasecmp(cause, "NOCHANAVAIL"))
return AST_CAUSE_CONGESTION;
ast_log(LOG_WARNING, "Unknown cause '%s', using NORMAL\n", cause);
return AST_CAUSE_NORMAL;
int res = 0;
struct localuser* u;
char* provider = OSP_DEF_PROVIDER;
int priority_jump = 0;
struct varshead* headp;
struct ast_var_t* current;
const char* source = "";
const char* token = "";
int handle;
unsigned int timelimit;
char* tmp;
char buffer[OSP_INTSTR_SIZE];
char* status;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(provider);
AST_APP_ARG(options);
);
LOCAL_USER_ADD(u);
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return(-1);
}
AST_STANDARD_APP_ARGS(args, tmp);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
if (args.options) {
if (strchr(args.options, 'j')) {
priority_jump = 1;
}
}
ast_log(LOG_DEBUG, "OSPAuth: priority jump '%d'\n", priority_jump);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
if (!strcasecmp(ast_var_name(current), "OSPPEERIP")) {
source = ast_var_value(current);
} else if (!strcasecmp(ast_var_name(current), "OSPINTOKEN")) {
token = ast_var_value(current);
}
}
ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
ast_log(LOG_DEBUG, "OSPAuth: token size '%d'\n", strlen(token));
res = ast_osp_auth(provider, &handle, source, chan->cid.cid_num, chan->exten, token, &timelimit);
if (res > 0) {
status = OSP_APP_SUCCESS;
} else {
timelimit = OSP_DEF_TIMELIMIT;
if (!res) {
status = OSP_APP_FAILED;
} else {
handle = OSP_INVALID_HANDLE;
status = OSP_APP_ERROR;
}
}
snprintf(buffer, sizeof(buffer), "%d", handle);
pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", timelimit);
pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer);
ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status);
ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
if(!res) {
if (priority_jump || ast_opt_priority_jumping) {
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else {
res = -1;
}
} else if (res > 0) {
res = 0;
}
LOCAL_USER_REMOVE(u);
return(res);
}
static int osplookup_exec(struct ast_channel *chan, void *data)
{
int res=0;
struct localuser *u;
char *temp;
struct ast_osp_result result;
int res = 0;
struct localuser* u;
char* provider = OSP_DEF_PROVIDER;
int priority_jump = 0;
struct varshead* headp;
struct ast_var_t* current;
const char* srcdev = "";
char* tmp;
char buffer[OSP_TOKSTR_SIZE];
struct ast_osp_result result;
char* status;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(extension);
AST_APP_ARG(exten);
AST_APP_ARG(provider);
AST_APP_ARG(options);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "OSPLookup requires an argument OSPLookup(exten[|provider[|options]])\n");
return -1;
ast_log(LOG_WARNING, "OSPLookup: Arg required, OSPLookup(exten[|provider[|options]])\n");
return(-1);
}
LOCAL_USER_ADD(u);
if (!(temp = ast_strdupa(data))) {
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
return(-1);
}
AST_STANDARD_APP_ARGS(args, temp);
AST_STANDARD_APP_ARGS(args, tmp);
ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
if (args.options) {
if (strchr(args.options, 'j'))
if (strchr(args.options, 'j')) {
priority_jump = 1;
}
}
ast_log(LOG_DEBUG, "OSPLookup: priority jump '%d'\n", priority_jump);
result.inhandle = OSP_INVALID_HANDLE;
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
if (!strcasecmp(ast_var_name(current), "OSPINHANDLE")) {
if (sscanf(ast_var_value(current), "%d", &result.inhandle) != 1) {
result.inhandle = OSP_INVALID_HANDLE;
}
} else if (!strcasecmp(ast_var_name(current), "OSPINTIMELIMIT")) {
if (sscanf(ast_var_value(current), "%d", &result.intimelimit) != 1) {
result.intimelimit = OSP_DEF_TIMELIMIT;
}
} else if (!strcasecmp(ast_var_name(current), "OSPPEERIP")) {
srcdev = ast_var_value(current);
}
}
ast_log(LOG_DEBUG, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle);
ast_log(LOG_DEBUG, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit);
ast_log(LOG_DEBUG, "OSPLookup: source device '%s'\n", srcdev);
ast_log(LOG_DEBUG, "Whoo hoo, looking up OSP on '%s' via '%s'\n", args.extension, args.provider ? args.provider : "<default>");
if ((res = ast_osp_lookup(chan, args.provider, args.extension, 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);
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "_OSPRESULTS", tmp);
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", "SUCCESS");
res = ast_osp_lookup(provider, srcdev, chan->cid.cid_num, args.exten, &result);
if (res > 0) {
status = OSP_APP_SUCCESS;
} else {
result.tech[0] = '\0';
result.dest[0] = '\0';
result.calling[0] = '\0';
result.token[0] = '\0';
result.numresults = 0;
result.outtimelimit = OSP_DEF_TIMELIMIT;
if (!res) {
ast_log(LOG_NOTICE, "OSP Lookup failed for '%s' (provider '%s')\n", args.extension, args.provider ? args.provider : "<default>");
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", "FAILED");
} else
ast_log(LOG_DEBUG, "Got hangup on '%s' while doing OSP Lookup for '%s' (provider '%s')!\n", chan->name, args.extension, args.provider ? args.provider : "<default>" );
status = OSP_APP_FAILED;
} else {
result.outhandle = OSP_INVALID_HANDLE;
status = OSP_APP_ERROR;
}
}
snprintf(buffer, sizeof(buffer), "%d", result.outhandle);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%d'\n", strlen(result.token));
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "P-OSP-Auth-Token: %s", result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%d'\n", strlen(buffer));
}
if (!res) {
/* Look for a "busy" place */
if (priority_jump || ast_opt_priority_jumping)
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status);
ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
if(!res) {
if (priority_jump || ast_opt_priority_jumping) {
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
} else {
res = -1;
}
} else if (res > 0) {
res = 0;
}
LOCAL_USER_REMOVE(u);
return res;
return(res);
}
static int str2cause(char *str)
{
int cause = AST_CAUSE_NORMAL;
if (ast_strlen_zero(str)) {
cause = AST_CAUSE_NOTDEFINED;
} else if (!strcasecmp(str, "BUSY")) {
cause = AST_CAUSE_BUSY;
} else if (!strcasecmp(str, "CONGESTION")) {
cause = AST_CAUSE_CONGESTION;
} else if (!strcasecmp(str, "ANSWER")) {
cause = AST_CAUSE_NORMAL;
} else if (!strcasecmp(str, "CANCEL")) {
cause = AST_CAUSE_NORMAL;
} else if (!strcasecmp(str, "NOANSWER")) {
cause = AST_CAUSE_NOANSWER;
} else if (!strcasecmp(str, "NOCHANAVAIL")) {
cause = AST_CAUSE_CONGESTION;
} else {
ast_log(LOG_WARNING, "OSP: Unknown cause '%s', using NORMAL\n", str);
}
return(cause);
}
static int ospnext_exec(struct ast_channel *chan, void *data)
{
int res=0;
struct localuser *u;
char *temp;
const char *val;
int priority_jump = 0;
int cause;
struct varshead* headp;
struct ast_var_t* current;
struct ast_osp_result result;
int priority_jump = 0;
char *tmp;
char buffer[OSP_TOKSTR_SIZE];
char* status;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(cause);
AST_APP_ARG(options);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "OSPNext should have an argument (cause[|options])\n");
return -1;
ast_log(LOG_WARNING, "OSPNext: Arg required, OSPNext(cause[|options])\n");
return(-1);
}
LOCAL_USER_ADD(u);
if (!(temp = ast_strdupa(data))) {
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
return(-1);
}
AST_STANDARD_APP_ARGS(args, temp);
AST_STANDARD_APP_ARGS(args, tmp);
cause = str2cause(args.cause);
ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
if (args.options) {
if (strchr(args.options, 'j'))
priority_jump = 1;
}
cause = str2cause(args.cause);
val = pbx_builtin_getvar_helper(chan, "OSPHANDLE");
result.handle = -1;
if (!ast_strlen_zero(val) && (sscanf(val, "%d", &result.handle) == 1) && (result.handle > -1)) {
val = pbx_builtin_getvar_helper(chan, "OSPRESULTS");
if (ast_strlen_zero(val) || (sscanf(val, "%d", &result.numresults) != 1)) {
result.numresults = 0;
}
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);
snprintf(tmp, sizeof(tmp), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "_OSPRESULTS", tmp);
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", "SUCCESS");
ast_log(LOG_DEBUG, "OSPNext: priority jump '%d'\n", priority_jump);
result.inhandle = OSP_INVALID_HANDLE;
result.outhandle = OSP_INVALID_HANDLE;
result.numresults = 0;
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
if (!strcasecmp(ast_var_name(current), "OSPINHANDLE")) {
if (sscanf(ast_var_value(current), "%d", &result.inhandle) != 1) {
result.inhandle = OSP_INVALID_HANDLE;
}
} else if (!strcasecmp(ast_var_name(current), "OSPOUTHANDLE")) {
if (sscanf(ast_var_value(current), "%d", &result.outhandle) != 1) {
result.outhandle = OSP_INVALID_HANDLE;
}
} else if (!strcasecmp(ast_var_name(current), "OSPINTIMEOUT")) {
if (sscanf(ast_var_value(current), "%d", &result.intimelimit) != 1) {
result.intimelimit = OSP_DEF_TIMELIMIT;
}
} else if (!strcasecmp(ast_var_name(current), "OSPRESULTS")) {
if (sscanf(ast_var_value(current), "%d", &result.numresults) != 1) {
result.numresults = 0;
}
}
}
ast_log(LOG_DEBUG, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle);
ast_log(LOG_DEBUG, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle);
ast_log(LOG_DEBUG, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit);
ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%d'\n", result.numresults);
if ((res = ast_osp_next(cause, &result)) > 0) {
status = OSP_APP_SUCCESS;
} else {
result.tech[0] = '\0';
result.dest[0] = '\0';
result.calling[0] = '\0';
result.token[0] = '\0';
result.numresults = 0;
result.outtimelimit = OSP_DEF_TIMELIMIT;
if (!res) {
if (result.handle < 0)
ast_log(LOG_NOTICE, "OSP Lookup Next failed for handle '%d'\n", result.handle);
else
ast_log(LOG_DEBUG, "No OSP handle specified\n");
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", "FAILED");
} else
ast_log(LOG_DEBUG, "Got hangup on '%s' while doing OSP Next!\n", chan->name);
status = OSP_APP_FAILED;
} else {
result.outhandle = OSP_INVALID_HANDLE;
status = OSP_APP_ERROR;
}
}
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%d'\n", strlen(result.token));
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "P-OSP-Auth-Token: %s", result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
ast_log(LOG_DEBUG, "OSPNext: SIPADDHEADER size '%d'\n", strlen(buffer));
}
if (!res) {
/* Look for a "busy" place */
if (priority_jump || ast_opt_priority_jumping)
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status);
ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
if(!res) {
if (priority_jump || ast_opt_priority_jumping) {
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
} else {
res = -1;
}
} else if (res > 0) {
res = 0;
}
LOCAL_USER_REMOVE(u);
return res;
return(res);
}
static int ospfinished_exec(struct ast_channel *chan, void *data)
{
int res=0;
struct localuser *u;
char *temp;
const char *val;
int cause;
time_t start=0, duration=0;
struct ast_osp_result result;
int res = 1;
struct localuser* u;
int priority_jump = 0;
int cause;
struct varshead* headp;
struct ast_var_t* current;
int inhandle = OSP_INVALID_HANDLE;
int outhandle = OSP_INVALID_HANDLE;
int recorded = 0;
time_t start, connect, end;
char* tmp;
char* str = "";
char buffer[OSP_INTSTR_SIZE];
char* status;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(status);
AST_APP_ARG(options);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "OSPFinish should have an argument (status[|options])\n");
return -1;
}
LOCAL_USER_ADD(u);
if (!(temp = ast_strdupa(data))) {
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
return(-1);
}
AST_STANDARD_APP_ARGS(args, temp);
AST_STANDARD_APP_ARGS(args, tmp);
if (args.options) {
if (strchr(args.options, 'j'))
priority_jump = 1;
}
ast_log(LOG_DEBUG, "OSPFinish: priority jump '%d'\n", priority_jump);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
if (!strcasecmp(ast_var_name(current), "OSPINHANDLE")) {
if (sscanf(ast_var_value(current), "%d", &inhandle) != 1) {
inhandle = OSP_INVALID_HANDLE;
}
} else if (!strcasecmp(ast_var_name(current), "OSPOUTHANDLE")) {
if (sscanf(ast_var_value(current), "%d", &outhandle) != 1) {
outhandle = OSP_INVALID_HANDLE;
}
} else if (!recorded &&
(!strcasecmp(ast_var_name(current), "OSPAUTHSTATUS") ||
!strcasecmp(ast_var_name(current), "OSPLOOKUPSTATUS") ||
!strcasecmp(ast_var_name(current), "OSPNEXTSTATUS")))
{
if (strcasecmp(ast_var_value(current), OSP_APP_SUCCESS)) {
recorded = 1;
}
}
}
ast_log(LOG_DEBUG, "OSPFinish: OSPINHANDLE '%d'\n", inhandle);
ast_log(LOG_DEBUG, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
ast_log(LOG_DEBUG, "OSPFinish: recorded '%d'\n", recorded);
if (!recorded) {
str = args.status;
}
cause = str2cause(str);
ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
if (chan->cdr) {
start = chan->cdr->answer.tv_sec;
if (start)
duration = time(NULL) - start;
else
duration = 0;
} else
ast_log(LOG_WARNING, "OSPFinish called on channel '%s' with no CDR!\n", chan->name);
cause = str2cause(args.status);
val = pbx_builtin_getvar_helper(chan, "OSPHANDLE");
result.handle = -1;
if (!ast_strlen_zero(val) && (sscanf(val, "%d", &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, "OSPFINISHSTATUS", "SUCCESS");
res = 1;
start = chan->cdr->start.tv_sec;
connect = chan->cdr->answer.tv_sec;
if (connect) {
end = time(NULL);
} else {
end = connect;
}
} else {
if (!res) {
if (result.handle > -1)
ast_log(LOG_NOTICE, "OSP Finish failed for handle '%d'\n", result.handle);
else
ast_log(LOG_DEBUG, "No OSP handle specified\n");
pbx_builtin_setvar_helper(chan, "OSPFINISHSTATUS", "FAILED");
} else
ast_log(LOG_DEBUG, "Got hangup on '%s' while doing OSP Terminate!\n", chan->name);
start = 0;
connect = 0;
end = 0;
}
ast_log(LOG_DEBUG, "OSPFinish: start '%ld'\n", start);
ast_log(LOG_DEBUG, "OSPFinish: connect '%ld'\n", connect);
ast_log(LOG_DEBUG, "OSPFinish: end '%ld'\n", end);
if (ast_osp_finish(outhandle, cause, start, connect, end) <= 0) {
ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for out_bound call\n");
}
if (ast_osp_finish(inhandle, cause, start, connect, end) <= 0) {
ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for in_bound call\n");
}
snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
if (res > 0) {
status = OSP_APP_SUCCESS;
} else if (!res) {
status = OSP_APP_FAILED;
} else {
status = OSP_APP_ERROR;
}
if (!res) {
/* Look for a "busy" place */
if (priority_jump || ast_opt_priority_jumping)
pbx_builtin_setvar_helper(chan, "OSPFINISHSTATUS", status);
if(!res) {
if (priority_jump || ast_opt_priority_jumping) {
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
} else if (res > 0)
} else {
res = -1;
}
} else if (res > 0) {
res = 0;
}
LOCAL_USER_REMOVE(u);
return res;
}
return(res);
}
int unload_module(void)
int load_module(void)
{
int res;
res = ast_unregister_application(app3);
res |= ast_unregister_application(app2);
res |= ast_unregister_application(app);
ast_osp_adduse();
STANDARD_HANGUP_LOCALUSERS;
res = ast_register_application(app1, ospauth_exec, synopsis1, descrip1);
res |= ast_register_application(app2, osplookup_exec, synopsis2, descrip2);
res |= ast_register_application(app3, ospnext_exec, synopsis3, descrip3);
res |= ast_register_application(app4, ospfinished_exec, synopsis4, descrip4);
return res;
return(res);
}
int load_module(void)
int unload_module(void)
{
int res;
res = ast_register_application(app, osplookup_exec, synopsis, descrip);
res |= ast_register_application(app2, ospnext_exec, synopsis2, descrip2);
res |= ast_register_application(app3, ospfinished_exec, synopsis3, descrip3);
return res;
res = ast_unregister_application(app4);
res |= ast_unregister_application(app3);
res |= ast_unregister_application(app2);
res |= ast_unregister_application(app1);
STANDARD_HANGUP_LOCALUSERS;
ast_osp_deluse();
return(res);
}
int reload(void)
{
return 0;
return(0);
}
char *description(void)
{
return tdesc;
return("Open Settlement Protocol Applications");
}
int usecount(void)
{
int res;
STANDARD_USECOUNT(res);
return res;
return(res);
}
char *key()
{
return ASTERISK_GPL_KEY;
return(ASTERISK_GPL_KEY);
}

@ -93,10 +93,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/stringfields.h"
#include "asterisk/monitor.h"
#ifdef OSP_SUPPORT
#include "asterisk/astosp.h"
#endif
#ifndef FALSE
#define FALSE 0
#endif
@ -506,7 +502,6 @@ struct sip_pkt;
/*! \brief Parameters to the transmit_invite function */
struct sip_invite_param {
const char *distinctive_ring; /*!< Distinctive ring header */
const char *osptoken; /*!< OSP token for this call */
int addsipheaders; /*!< Add extra SIP headers */
const char *uri_options; /*!< URI options to add to the URI */
const char *vxml_url; /*!< VXML url for Cisco phones */
@ -596,20 +591,14 @@ struct sip_auth {
#define SIP_PROG_INBAND_NEVER (0 << 24)
#define SIP_PROG_INBAND_NO (1 << 24)
#define SIP_PROG_INBAND_YES (2 << 24)
/* Open Settlement Protocol authentication */
#define SIP_OSPAUTH (3 << 26) /*!< four settings, uses two bits */
#define SIP_OSPAUTH_NO (0 << 26)
#define SIP_OSPAUTH_GATEWAY (1 << 26)
#define SIP_OSPAUTH_PROXY (2 << 26)
#define SIP_OSPAUTH_EXCLUSIVE (3 << 26)
#define SIP_CALL_ONHOLD (1 << 28) /*!< Call states */
#define SIP_CALL_LIMIT (1 << 29) /*!< Call limit enforced for this call */
#define SIP_SENDRPID (1 << 30) /*!< Remote Party-ID Support */
#define SIP_INC_COUNT (1 << 31) /*!< Did this connection increment the counter of in-use calls? */
#define SIP_CALL_ONHOLD (1 << 26) /*!< Call states */
#define SIP_CALL_LIMIT (1 << 27) /*!< Call limit enforced for this call */
#define SIP_SENDRPID (1 << 28) /*!< Remote Party-ID Support */
#define SIP_INC_COUNT (1 << 29) /*!< Did this connection increment the counter of in-use calls? */
#define SIP_FLAGS_TO_COPY \
(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
SIP_PROG_INBAND | SIP_OSPAUTH | SIP_USECLIENTCODE | SIP_NAT | \
SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT | \
SIP_USEREQPHONE | SIP_INSECURE_PORT | SIP_INSECURE_INVITE)
/* a new page of flags for peers */
@ -721,11 +710,6 @@ static struct sip_pvt {
char lastmsg[256]; /*!< Last Message sent/received */
int amaflags; /*!< AMA Flags */
int pendinginvite; /*!< Any pending invite */
#ifdef OSP_SUPPORT
int osphandle; /*!< OSP Handle for call */
time_t ospstart; /*!< OSP Start time */
unsigned int osptimelimit; /*!< OSP call duration limit */
#endif
struct sip_request initreq; /*!< Initial request that opened the SIP dialog */
int maxtime; /*!< Max time for first response */
@ -2066,9 +2050,6 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
{
int res;
struct sip_pvt *p;
#ifdef OSP_SUPPORT
const char *osphandle = NULL;
#endif
struct varshead *headp;
struct ast_var_t *current;
@ -2093,29 +2074,10 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
/* Check whether there is a variable with a name starting with SIPADDHEADER */
p->options->addsipheaders = 1;
}
#ifdef OSP_SUPPORT
else if (!p->options->osptoken && !strcasecmp(ast_var_name(current), "OSPTOKEN")) {
p->options->osptoken = ast_var_value(current);
} else if (!osphandle && !strcasecmp(ast_var_name(current), "OSPHANDLE")) {
osphandle = ast_var_value(current);
}
#endif
}
res = 0;
ast_set_flag(&p->flags[0], SIP_OUTGOING);
#ifdef OSP_SUPPORT
if (!p->options->osptoken || !osphandle || (sscanf(osphandle, "%d", &p->osphandle) != 1)) {
/* Force Disable OSP support */
if (option_debug)
ast_log(LOG_DEBUG, "Disabling OSP support for this call. osptoken = %s, osphandle = %s\n", p->options->osptoken, osphandle);
p->options->osptoken = NULL;
osphandle = NULL;
p->osphandle = -1;
}
#endif
ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username);
res = update_call_counter(p, INC_CALL_LIMIT);
if ( res != -1 ) {
@ -2530,11 +2492,6 @@ static int sip_hangup(struct ast_channel *ast)
ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
ast_mutex_lock(&p->lock);
#ifdef OSP_SUPPORT
if ((p->osphandle > -1) && (ast->_state == AST_STATE_UP)) {
ast_osp_terminate(p->osphandle, AST_CAUSE_NORMAL, p->ospstart, time(NULL) - p->ospstart);
}
#endif
if (option_debug && sipdebug)
ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
@ -2638,9 +2595,6 @@ static int sip_answer(struct ast_channel *ast)
ast_mutex_lock(&p->lock);
if (ast->_state != AST_STATE_UP) {
#ifdef OSP_SUPPORT
time(&p->ospstart);
#endif
try_suggested_sip_codec(p);
ast_setstate(ast, AST_STATE_UP);
@ -2868,10 +2822,6 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
struct ast_variable *v = NULL;
int fmt;
int what;
#ifdef OSP_SUPPORT
char iabuf[INET_ADDRSTRLEN];
char peer[MAXHOSTNAMELEN];
#endif
ast_mutex_unlock(&i->lock);
/* Don't hold a sip pvt lock while we allocate a channel */
@ -2961,10 +2911,6 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
if (!ast_strlen_zero(i->callid)) {
pbx_builtin_setvar_helper(tmp, "SIPCALLID", i->callid);
}
#ifdef OSP_SUPPORT
snprintf(peer, sizeof(peer), "[%s]:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), i->sa.sin_addr), ntohs(i->sa.sin_port));
pbx_builtin_setvar_helper(tmp, "OSPPEER", peer);
#endif
ast_setstate(tmp, state);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
@ -3212,10 +3158,6 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
if (intended_method != SIP_OPTIONS) /* Peerpoke has it's own system */
p->timer_t1 = 500; /* Default SIP retransmission timer T1 (RFC 3261) */
#ifdef OSP_SUPPORT
p->osphandle = -1;
p->osptimelimit = 0;
#endif
if (sin) {
p->sa = *sin;
if (ast_sip_ouraddrfor(&p->sa.sin_addr,&p->ourip))
@ -5076,12 +5018,6 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
if (!ast_strlen_zero(p->referred_by))
add_header(&req, "Referred-By", p->referred_by);
}
#ifdef OSP_SUPPORT
if ((req.method != SIP_OPTIONS) && p->options && !ast_strlen_zero(p->options->osptoken)) {
ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", p->options->osptoken);
add_header(&req, "P-OSP-Auth-Token", p->options->osptoken);
}
#endif
if (p->options && !ast_strlen_zero(p->options->distinctive_ring))
{
add_header(&req, "Alert-Info", p->options->distinctive_ring);
@ -6286,21 +6222,6 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
list_route(p->route);
}
#ifdef OSP_SUPPORT
/*! \brief Validate OSP token for user authorization */
static int check_osptoken (struct sip_pvt *p, char *token)
{
char tmp[80];
if (ast_osp_validate (NULL, token, &p->osphandle, &p->osptimelimit, p->cid_num, p->sa.sin_addr, p->exten) < 1) {
return -1;
} else {
snprintf (tmp, sizeof (tmp), "%d", p->osphandle);
pbx_builtin_setvar_helper (p->owner, "_OSPHANDLE", tmp);
return 0;
}
}
#endif
/*! \brief Check user authorization from peer definition
Some actions, like REGISTER and INVITEs from peers require
@ -6318,12 +6239,7 @@ static int check_auth(struct sip_pvt *p, struct sip_request *req, const char *us
const char *authtoken;
/* Always OK if no secret */
if (ast_strlen_zero(secret) && ast_strlen_zero(md5secret)
#ifdef OSP_SUPPORT
&& !ast_test_flag(&p->flags[0], SIP_OSPAUTH)
&& global_allowguest != 2
#endif
)
if (ast_strlen_zero(secret) && ast_strlen_zero(md5secret))
return 0;
if (sipmethod == SIP_REGISTER || sipmethod == SIP_SUBSCRIBE) {
/* On a REGISTER, we have to use 401 and its family of headers instead of 407 and its family
@ -6333,38 +6249,6 @@ static int check_auth(struct sip_pvt *p, struct sip_request *req, const char *us
reqheader = "Authorization";
respheader = "WWW-Authenticate";
}
#ifdef OSP_SUPPORT
else {
char *osptoken;
if (option_debug)
ast_log (LOG_DEBUG, "Checking OSP Authentication!\n");
osptoken = get_header (req, "P-OSP-Auth-Token");
switch (ast_test_flag(&p->flags[0], SIP_OSPAUTH)) {
case SIP_OSPAUTH_NO:
break;
case SIP_OSPAUTH_GATEWAY:
if (ast_strlen_zero(osptoken)) {
if (ast_strlen_zero(secret) && ast_strlen_zero (md5secret))
return 0;
} else {
return check_osptoken(p, osptoken);
}
break;
case SIP_OSPAUTH_PROXY:
if (ast_strlen_zero(osptoken))
return 0;
return check_osptoken(p, osptoken);
break;
case SIP_OSPAUTH_EXCLUSIVE:
if (ast_strlen_zero(osptoken))
return -1;
return check_osptoken(p, osptoken);
break;
default:
return -1;
}
}
#endif
authtoken = get_header(req, reqheader);
if (ignore && !ast_strlen_zero(p->randdata) && ast_strlen_zero(authtoken)) {
/* This is a retransmitted invite/register/etc, don't reconstruct authentication
@ -7447,12 +7331,6 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
/* 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->flags[0], &global_flags[0], SIP_OSPAUTH);
res = check_auth(p, req, "", "", "", sipmethod, uri, reliable, ignore);
}
#endif
}
}
@ -8456,11 +8334,6 @@ static int sip_show_settings(int fd, int argc, char *argv[])
ast_cli(fd, " IP ToS SIP: %s\n", ast_tos2str(global_tos_sip));
ast_cli(fd, " IP ToS RTP audio: %s\n", ast_tos2str(global_tos_audio));
ast_cli(fd, " IP ToS RTP video: %s\n", ast_tos2str(global_tos_video));
#ifdef OSP_SUPPORT
ast_cli(fd, " OSP Support: Yes\n");
#else
ast_cli(fd, " OSP Support: No\n");
#endif
if (!realtimepeers && !realtimeusers)
ast_cli(fd, " SIP realtime: Disabled\n" );
else
@ -9777,9 +9650,6 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
if (!ignore && p->owner) {
if (p->owner->_state != AST_STATE_UP) {
#ifdef OSP_SUPPORT
time(&p->ospstart);
#endif
ast_queue_control(p->owner, AST_CONTROL_ANSWER);
} else { /* RE-invite */
ast_queue_frame(p->owner, &ast_null_frame);
@ -10926,9 +10796,6 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!ignore && p)
p->lastinvite = seqno;
if (c) {
#ifdef OSP_SUPPORT
ast_channel_setwhentohangup (c, p->osptimelimit);
#endif
switch(c->_state) {
case AST_STATE_DOWN:
transmit_response(p, "100 Trying", req);
@ -12281,26 +12148,10 @@ static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask
else if (strcasecmp(v->value, "never"))
ast_set_flag(&flags[0], SIP_PROG_INBAND_NO);
} else if (!strcasecmp(v->name, "allowguest")) {
#ifdef OSP_SUPPORT
if (!strcasecmp(v->value, "osp"))
global_allowguest = 2;
else
#endif
if (ast_true(v->value))
global_allowguest = 1;
else
global_allowguest = 0;
#ifdef OSP_SUPPORT
} else if (!strcasecmp(v->name, "ospauth")) {
ast_set_flag(&mask[0], SIP_OSPAUTH);
ast_clear_flag(&flags[0], SIP_OSPAUTH);
if (!strcasecmp(v->value, "proxy"))
ast_set_flag(&flags[0], SIP_OSPAUTH_PROXY);
else if (!strcasecmp(v->value, "gateway"))
ast_set_flag(&flags[0], SIP_OSPAUTH_GATEWAY);
else if(!strcasecmp (v->value, "exclusive"))
ast_set_flag(&flags[0], SIP_OSPAUTH_EXCLUSIVE);
#endif
} else if (!strcasecmp(v->name, "promiscredir")) {
ast_set_flag(&mask[0], SIP_PROMISCREDIR);
ast_set2_flag(&flags[0], ast_true(v->value), SIP_PROMISCREDIR);

@ -62,3 +62,11 @@
; Set the "source" for requesting authorization
;
;source=foo
;
; Set the authentication policy.
; 0 - NO
; 1 - YES
; 2 - EXCLUSIVE
; Default is 1, validate token but allow no token.
;
;authpolicy=1

@ -612,6 +612,7 @@ ${DBGETSTATUS} * dbget()
${ENUMSTATUS} * enumlookup()
${HASVMSTATUS} * hasnewvoicemail()
${LOOKUPBLSTATUS} * lookupblacklist()
${OSPAUTHSTATUS} * ospauth()
${OSPLOOKUPSTATUS} * osplookup()
${OSPNEXTSTATUS} * ospnext()
${OSPFINISHSTATUS} * ospfinish()
@ -754,14 +755,17 @@ ${MACRO_CONTEXT} * The calling context
${MACRO_PRIORITY} * The calling priority
${MACRO_OFFSET} Offset to add to priority at return from macro
If you compile with OSP support in the SIP channel, these
variables are used:
If you compile with OSP support, these variables are used:
---------------------------------------------------------
${OSPHANDLE} Handle from the OSP Library
${OSPTECH} OSP Technology from Library
${OSPDEST} OSP Destination from Library
${OSPTOKEN} OSP Token to use for call from Library
${OSPRESULTS} Number of OSP results
${OSPINHANDLE} OSP handle of in_bound call
${OSPINTIMELIMIT} Duration limit for in_bound call
${OSPOUTHANDLE} OSP handle of out_bound call
${OSPTECH} OSP technology
${OSPDEST} OSP destination
${OSPCALLING} OSP calling number
${OSPOUTTOKEN} OSP token to use for out_bound call
${OSPOUTTIMELIMIT} Duration limit for out_bound call
${OSPRESULTS} Number of remained destinations
____________________________________
CDR Variables

@ -16,33 +16,111 @@
* at the top of the source tree.
*/
/*! \file
/*!
* \file
* \brief OSP support (Open Settlement Protocol)
*/
#ifndef _ASTERISK_OSP_H
#define _ASTERISK_OSP_H
#include "asterisk/channel.h"
#include <netinet/in.h>
#include <time.h>
#include <netinet/in.h>
struct ast_osp_result {
int handle;
int numresults;
char tech[20];
char dest[256];
char token[4096];
};
#include "asterisk/channel.h"
/* Note: Channel will be auto-serviced if specified. Returns -1 on hangup,
0 if nothing found, or 1 if something is found */
int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, char *callerid, struct ast_osp_result *result);
#define OSP_DEF_PROVIDER ((char*)"default") /* Default provider context name */
#define OSP_INVALID_HANDLE ((int)-1) /* Invalid OSP handle, provider, transaction etc. */
#define OSP_DEF_TIMELIMIT ((unsigned int)0) /* Default duration limit, no limit */
int ast_osp_next(struct ast_osp_result *result, int cause);
#define OSP_INTSTR_SIZE ((unsigned int)16) /* Signed/unsigned int string buffer size */
#define OSP_NORSTR_SIZE ((unsigned int)256) /* Normal string buffer size */
#define OSP_TOKSTR_SIZE ((unsigned int)4096) /* Token string buffer size */
int ast_osp_terminate(int handle, int cause, time_t start, time_t duration);
#define OSP_APP_SUCCESS ((char*)"SUCCESS") /* Return status, success */
#define OSP_APP_FAILED ((char*)"FAILED") /* Return status, failed */
#define OSP_APP_ERROR ((char*)"ERROR") /* Return status, error */
int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *timeout, const char *callerid, struct in_addr addr, const char *extension);
struct ast_osp_result {
int inhandle;
int outhandle;
unsigned int intimelimit;
unsigned int outtimelimit;
char tech[20];
char dest[OSP_NORSTR_SIZE];
char calling[OSP_NORSTR_SIZE];
char token[OSP_TOKSTR_SIZE];
int numresults;
};
/*!
* \brief OSP Increase Use Count function
*/
void ast_osp_adduse(void);
/*!
* \brief OSP Decrease Use Count function
*/
void ast_osp_deluse(void);
/*!
* \brief OSP Authentication function
* \param provider OSP provider context name
* \param transaction OSP transaction handle, output
* \param source Source of in_bound call
* \param calling Calling number
* \param called Called number
* \param token OSP token, may be empty
* \param timelimit Call duration limit, output
* \return 1 Authenricated, 0 Unauthenticated, -1 Error
*/
int ast_osp_auth(
const char* provider, /* OSP provider context name */
int* transaction, /* OSP transaction handle, output */
const char* source, /* Source of in_bound call */
const char* calling, /* Calling number */
const char* called, /* Called number */
const char* token, /* OSP token, may be empty */
unsigned int* timelimit /* Call duration limit, output */
);
/*!
* \brief OSP Lookup function
* \param provider OSP provider context name
* \param srcdev Source device of out_bound call
* \param calling Calling number
* \param called Called number
* \param result Lookup results
* \return 1 Found , 0 No route, -1 Error
*/
int ast_osp_lookup(
const char* provider, /* OSP provider conttext name */
const char* srcdev, /* Source device of out_bound call */
const char* calling, /* Calling number */
const char* called, /* Called number */
struct ast_osp_result* result /* OSP lookup results, in/output */
);
/*!
* \brief OSP Next function
* \param reason Last destination failure reason
* \param result Lookup results, in/output
* \return 1 Found , 0 No route, -1 Error
*/
int ast_osp_next(
int reason, /* Last destination failure reason */
struct ast_osp_result *result /* OSP lookup results, in/output */
);
/*!
* \brief OSP Finish function
* \param handle OSP in/out_bound transaction handle
* \param reason Last destination failure reason
* \param start Call start time
* \param duration Call duration
* \return 1 Success, 0 Failed, -1 Error
*/
int ast_osp_finish(
int handle, /* OSP in/out_bound transaction handle */
int reason, /* Last destination failure reason */
time_t start, /* Call start time */
time_t connect, /* Call connect time */
time_t end /* Call end time */
);
#endif /* _ASTERISK_OSP_H */

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save