mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
Added support for indirect work mode.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@275551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -131,6 +131,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
<para>Looks up destination via OSP.</para>
|
<para>Looks up destination via OSP.</para>
|
||||||
<para>Input variables:</para>
|
<para>Input variables:</para>
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
<variable name="OSPINACTUALSRC">
|
||||||
|
<para>The actual source device IP address in indirect mode.</para>
|
||||||
|
</variable>
|
||||||
<variable name="OSPINPEERIP">
|
<variable name="OSPINPEERIP">
|
||||||
<para>The last hop IP address.</para>
|
<para>The last hop IP address.</para>
|
||||||
</variable>
|
</variable>
|
||||||
@@ -461,6 +464,12 @@ enum osp_authpolicy {
|
|||||||
OSP_AUTH_EXC /* Only accept call with valid OSP token */
|
OSP_AUTH_EXC /* Only accept call with valid OSP token */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* OSP Work Mode */
|
||||||
|
enum osp_workmode {
|
||||||
|
OSP_MODE_DIRECT= 0, /* Direct */
|
||||||
|
OSP_MODE_INDIRECT /* Indirect */
|
||||||
|
};
|
||||||
|
|
||||||
/* OSP Service Type */
|
/* OSP Service Type */
|
||||||
enum osp_srvtype {
|
enum osp_srvtype {
|
||||||
OSP_SRV_VOICE = 0, /* Normal voice service */
|
OSP_SRV_VOICE = 0, /* Normal voice service */
|
||||||
@@ -501,6 +510,7 @@ enum osp_srvtype {
|
|||||||
#define OSP_DEF_MAXDESTS ((unsigned int)5) /* OSP default max number of destinations */
|
#define OSP_DEF_MAXDESTS ((unsigned int)5) /* OSP default max number of destinations */
|
||||||
#define OSP_DEF_TIMELIMIT ((unsigned int)0) /* OSP default duration limit, no limit */
|
#define OSP_DEF_TIMELIMIT ((unsigned int)0) /* OSP default duration limit, no limit */
|
||||||
#define OSP_DEF_PROTOCOL OSP_PROT_SIP /* OSP default destination protocol, SIP */
|
#define OSP_DEF_PROTOCOL OSP_PROT_SIP /* OSP default destination protocol, SIP */
|
||||||
|
#define OSP_DEF_WORKMODE OSP_MODE_DIRECT /* OSP default work mode, direct */
|
||||||
#define OSP_DEF_SRVTYPE OSP_SRV_VOICE /* OSP default service type, voice */
|
#define OSP_DEF_SRVTYPE OSP_SRV_VOICE /* OSP default service type, voice */
|
||||||
#define OSP_MAX_CUSTOMINFO ((unsigned int)8) /* OSP max number of custom info */
|
#define OSP_MAX_CUSTOMINFO ((unsigned int)8) /* OSP max number of custom info */
|
||||||
#define OSP_DEF_INTSTATS ((int)-1) /* OSP default int statistic */
|
#define OSP_DEF_INTSTATS ((int)-1) /* OSP default int statistic */
|
||||||
@@ -523,7 +533,8 @@ struct osp_provider {
|
|||||||
char source[OSP_SIZE_NORSTR]; /* IP of self */
|
char source[OSP_SIZE_NORSTR]; /* IP of self */
|
||||||
enum osp_authpolicy authpolicy; /* OSP authentication policy */
|
enum osp_authpolicy authpolicy; /* OSP authentication policy */
|
||||||
const char* defprotocol; /* OSP default destination protocol */
|
const char* defprotocol; /* OSP default destination protocol */
|
||||||
enum osp_srvtype srvtype; /* OSP default service type */
|
enum osp_workmode workmode; /* OSP work mode */
|
||||||
|
enum osp_srvtype srvtype; /* OSP service type */
|
||||||
struct osp_provider* next; /* Pointer to next OSP provider */
|
struct osp_provider* next; /* Pointer to next OSP provider */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -645,6 +656,7 @@ static int osp_create_provider(
|
|||||||
provider->timeout = OSP_DEF_TIMEOUT;
|
provider->timeout = OSP_DEF_TIMEOUT;
|
||||||
provider->authpolicy = OSP_DEF_AUTHPOLICY;
|
provider->authpolicy = OSP_DEF_AUTHPOLICY;
|
||||||
provider->defprotocol = OSP_DEF_PROTOCOL;
|
provider->defprotocol = OSP_DEF_PROTOCOL;
|
||||||
|
provider->workmode = OSP_DEF_WORKMODE;
|
||||||
provider->srvtype = OSP_DEF_SRVTYPE;
|
provider->srvtype = OSP_DEF_SRVTYPE;
|
||||||
|
|
||||||
for (var = ast_variable_browse(cfg, name); var != NULL; var = var->next) {
|
for (var = ast_variable_browse(cfg, name); var != NULL; var = var->next) {
|
||||||
@@ -748,6 +760,14 @@ static int osp_create_provider(
|
|||||||
ast_log(LOG_WARNING, "OSP: default protocol should be %s, %s, %s or %s not '%s' at line %d\n",
|
ast_log(LOG_WARNING, "OSP: default protocol should be %s, %s, %s or %s not '%s' at line %d\n",
|
||||||
OSP_PROT_SIP, OSP_PROT_H323, OSP_PROT_IAX, OSP_PROT_SKYPE, var->value, var->lineno);
|
OSP_PROT_SIP, OSP_PROT_H323, OSP_PROT_IAX, OSP_PROT_SKYPE, var->value, var->lineno);
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var->name, "workmode")) {
|
||||||
|
if ((sscanf(var->value, "%30d", &num) == 1) && ((num == OSP_MODE_DIRECT) || (num == OSP_MODE_INDIRECT))) {
|
||||||
|
provider->workmode = num;
|
||||||
|
ast_debug(1, "OSP: workmode '%d'\n", num);
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "OSP: workmode should be %d or %d, not '%s' at line %d\n",
|
||||||
|
OSP_MODE_DIRECT, OSP_MODE_INDIRECT, var->value, var->lineno);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var->name, "servicetype")) {
|
} else if (!strcasecmp(var->name, "servicetype")) {
|
||||||
if ((sscanf(var->value, "%30d", &num) == 1) && ((num == OSP_SRV_VOICE) || (num == OSP_SRV_NPQUERY))) {
|
if ((sscanf(var->value, "%30d", &num) == 1) && ((num == OSP_SRV_VOICE) || (num == OSP_SRV_NPQUERY))) {
|
||||||
provider->srvtype = num;
|
provider->srvtype = num;
|
||||||
@@ -1443,6 +1463,7 @@ static int osp_create_callid(
|
|||||||
* \brief OSP Lookup function
|
* \brief OSP Lookup function
|
||||||
* \param name OSP provider context name
|
* \param name OSP provider context name
|
||||||
* \param callidtypes Call ID types
|
* \param callidtypes Call ID types
|
||||||
|
* \param actualsrc Actual source device in indirect mode
|
||||||
* \param srcdev Source device of outbound call
|
* \param srcdev Source device of outbound call
|
||||||
* \param calling Calling number
|
* \param calling Calling number
|
||||||
* \param called Called number
|
* \param called Called number
|
||||||
@@ -1456,6 +1477,7 @@ static int osp_create_callid(
|
|||||||
static int osp_lookup(
|
static int osp_lookup(
|
||||||
const char* name,
|
const char* name,
|
||||||
unsigned int callidtypes,
|
unsigned int callidtypes,
|
||||||
|
const char* actualsrc,
|
||||||
const char* srcdev,
|
const char* srcdev,
|
||||||
const char* calling,
|
const char* calling,
|
||||||
const char* called,
|
const char* called,
|
||||||
@@ -1556,8 +1578,18 @@ static int osp_lookup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (provider->workmode == OSP_MODE_INDIRECT) {
|
||||||
|
osp_convert_inout(srcdev, src, sizeof(src));
|
||||||
|
if (ast_strlen_zero(actualsrc)) {
|
||||||
|
osp_convert_inout(srcdev, dev, sizeof(dev));
|
||||||
|
} else {
|
||||||
|
osp_convert_inout(actualsrc, dev, sizeof(dev));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
osp_convert_inout(source, src, sizeof(src));
|
osp_convert_inout(source, src, sizeof(src));
|
||||||
osp_convert_inout(srcdev, dev, sizeof(dev));
|
osp_convert_inout(srcdev, dev, sizeof(dev));
|
||||||
|
}
|
||||||
|
|
||||||
if (provider->srvtype == OSP_SRV_NPQUERY) {
|
if (provider->srvtype == OSP_SRV_NPQUERY) {
|
||||||
OSPPTransactionSetServiceType(results->outhandle, OSPC_SERVICE_NPQUERY);
|
OSPPTransactionSetServiceType(results->outhandle, OSPC_SERVICE_NPQUERY);
|
||||||
if (!ast_strlen_zero(dest)) {
|
if (!ast_strlen_zero(dest)) {
|
||||||
@@ -2269,6 +2301,7 @@ static int osplookup_exec(
|
|||||||
unsigned int callidtypes = OSP_CALLID_UNDEF;
|
unsigned int callidtypes = OSP_CALLID_UNDEF;
|
||||||
struct varshead* headp;
|
struct varshead* headp;
|
||||||
struct ast_var_t* current;
|
struct ast_var_t* current;
|
||||||
|
const char* actualsrc = "";
|
||||||
const char* srcdev = "";
|
const char* srcdev = "";
|
||||||
const char* snetid = "";
|
const char* snetid = "";
|
||||||
struct osp_npdata np;
|
struct osp_npdata np;
|
||||||
@@ -2335,7 +2368,9 @@ static int osplookup_exec(
|
|||||||
|
|
||||||
headp = &chan->varshead;
|
headp = &chan->varshead;
|
||||||
AST_LIST_TRAVERSE(headp, current, entries) {
|
AST_LIST_TRAVERSE(headp, current, entries) {
|
||||||
if (!strcasecmp(ast_var_name(current), "OSPINPEERIP")) {
|
if (!strcasecmp(ast_var_name(current), "OSPINACTUALSRC")) {
|
||||||
|
actualsrc = ast_var_value(current);
|
||||||
|
} else if (!strcasecmp(ast_var_name(current), "OSPINPEERIP")) {
|
||||||
srcdev = ast_var_value(current);
|
srcdev = ast_var_value(current);
|
||||||
} else if (!strcasecmp(ast_var_name(current), "OSPINHANDLE")) {
|
} else if (!strcasecmp(ast_var_name(current), "OSPINHANDLE")) {
|
||||||
if (sscanf(ast_var_value(current), "%30d", &results.inhandle) != 1) {
|
if (sscanf(ast_var_value(current), "%30d", &results.inhandle) != 1) {
|
||||||
@@ -2391,6 +2426,7 @@ static int osplookup_exec(
|
|||||||
cinfo[7] = ast_var_value(current);
|
cinfo[7] = ast_var_value(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ast_debug(1, "OSPLookup: actual source device '%s'\n", actualsrc);
|
||||||
ast_debug(1, "OSPLookup: source device '%s'\n", srcdev);
|
ast_debug(1, "OSPLookup: source device '%s'\n", srcdev);
|
||||||
ast_debug(1, "OSPLookup: OSPINHANDLE '%d'\n", results.inhandle);
|
ast_debug(1, "OSPLookup: OSPINHANDLE '%d'\n", results.inhandle);
|
||||||
ast_debug(1, "OSPLookup: OSPINTIMELIMIT '%d'\n", results.intimelimit);
|
ast_debug(1, "OSPLookup: OSPINTIMELIMIT '%d'\n", results.intimelimit);
|
||||||
@@ -2417,7 +2453,7 @@ static int osplookup_exec(
|
|||||||
return OSP_AST_ERROR;
|
return OSP_AST_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = osp_lookup(provider, callidtypes, srcdev, chan->cid.cid_num, args.exten, snetid, &np, &div, cinfo, &results)) > 0) {
|
if ((res = osp_lookup(provider, callidtypes, actualsrc, srcdev, chan->cid.cid_num, args.exten, snetid, &np, &div, cinfo, &results)) > 0) {
|
||||||
status = AST_OSP_SUCCESS;
|
status = AST_OSP_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
results.tech[0] = '\0';
|
results.tech[0] = '\0';
|
||||||
@@ -3004,6 +3040,7 @@ static char *handle_cli_osp_show(struct ast_cli_entry *e, int cmd, struct ast_cl
|
|||||||
ast_cli(a->fd, "Source: %s\n", strlen(provider->source) ? provider->source : "<unspecified>");
|
ast_cli(a->fd, "Source: %s\n", strlen(provider->source) ? provider->source : "<unspecified>");
|
||||||
ast_cli(a->fd, "Auth Policy %d\n", provider->authpolicy);
|
ast_cli(a->fd, "Auth Policy %d\n", provider->authpolicy);
|
||||||
ast_cli(a->fd, "Default protocol %s\n", provider->defprotocol);
|
ast_cli(a->fd, "Default protocol %s\n", provider->defprotocol);
|
||||||
|
ast_cli(a->fd, "Work mode %d\n", provider->workmode);
|
||||||
ast_cli(a->fd, "Service type %d\n", provider->srvtype);
|
ast_cli(a->fd, "Service type %d\n", provider->srvtype);
|
||||||
ast_cli(a->fd, "OSP Handle: %d\n", provider->handle);
|
ast_cli(a->fd, "OSP Handle: %d\n", provider->handle);
|
||||||
found++;
|
found++;
|
||||||
|
@@ -102,6 +102,13 @@
|
|||||||
;
|
;
|
||||||
;defaultprotocol=SIP
|
;defaultprotocol=SIP
|
||||||
;
|
;
|
||||||
|
; Set the work mode.
|
||||||
|
; 0 - Direct
|
||||||
|
; 1 - Indirect
|
||||||
|
; Default is 0,
|
||||||
|
;
|
||||||
|
;workmode=0
|
||||||
|
;
|
||||||
; Set the service type.
|
; Set the service type.
|
||||||
; 0 - Normal voice service
|
; 0 - Normal voice service
|
||||||
; 1 - Ported number query service
|
; 1 - Ported number query service
|
||||||
|
Reference in New Issue
Block a user