freetdm: convert ftmod_libpri (+ libpri_spans) to use new ftdm_configure_span_signaling() interface.
This fixes several issues with parameter handling (e.g. default alaw/ulaw selection being totally useless). Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
This commit is contained in:
parent
dc2a28c27c
commit
78eff1d821
|
@ -3087,85 +3087,44 @@ static switch_status_t load_config(void)
|
|||
|
||||
if ((spans = switch_xml_child(cfg, "libpri_spans"))) {
|
||||
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
|
||||
char *id = (char *) switch_xml_attr(myspan, "id");
|
||||
char *name = (char *) switch_xml_attr(myspan, "name");
|
||||
ftdm_conf_parameter_t spanparameters[10];
|
||||
ftdm_status_t zstatus = FTDM_FAIL;
|
||||
const char *context = "default";
|
||||
const char *context = "default";
|
||||
const char *dialplan = "XML";
|
||||
|
||||
const char *o_node = "cpe";
|
||||
const char *o_switch = "dms100";
|
||||
const char *o_dp = "unknown";
|
||||
const char *o_l1 = "ulaw";
|
||||
const char *o_debug = "none";
|
||||
const char* opts = "none";
|
||||
|
||||
uint32_t span_id = 0;
|
||||
unsigned paramindex = 0;
|
||||
ftdm_span_t *span = NULL;
|
||||
uint32_t span_id = 0;
|
||||
|
||||
|
||||
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
||||
if (!name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required attribute 'name'\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
for (param = switch_xml_child(myspan, "param"); param && paramindex < 10; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "node")) {
|
||||
o_node = val;
|
||||
} else if (!strcasecmp(var, "switch")) {
|
||||
o_switch = val;
|
||||
} else if (!strcasecmp(var, "dp")) {
|
||||
o_dp = val;
|
||||
} else if (!strcasecmp(var, "l1")) {
|
||||
o_l1 = val;
|
||||
} else if (!strcasecmp(var, "debug")) {
|
||||
o_debug = val;
|
||||
} else if (!strcasecmp(var, "context")) {
|
||||
if (!strcasecmp(var, "context")) {
|
||||
context = val;
|
||||
} else if (!strcasecmp(var, "opts")) {
|
||||
opts = val;
|
||||
} else if (!strcasecmp(var, "dialplan")) {
|
||||
dialplan = val;
|
||||
}
|
||||
}
|
||||
|
||||
if (!id && !name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required param 'id'\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
zstatus = ftdm_span_find_by_name(name, &span);
|
||||
} else {
|
||||
if (switch_is_number(id)) {
|
||||
span_id = atoi(id);
|
||||
zstatus = ftdm_span_find(span_id, &span);
|
||||
}
|
||||
|
||||
if (zstatus != FTDM_SUCCESS) {
|
||||
zstatus = ftdm_span_find_by_name(id, &span);
|
||||
} else {
|
||||
spanparameters[paramindex].var = var;
|
||||
spanparameters[paramindex].val = val;
|
||||
paramindex++;
|
||||
}
|
||||
}
|
||||
|
||||
zstatus = ftdm_span_find_by_name(name, &span);
|
||||
if (zstatus != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name));
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span %s\n", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!span_id) {
|
||||
span_id = ftdm_span_get_id(span);
|
||||
}
|
||||
|
||||
|
||||
if (ftdm_configure_span(span, "libpri", on_clear_channel_signal,
|
||||
"node", o_node,
|
||||
"switch", o_switch,
|
||||
"dp", o_dp,
|
||||
"l1", o_l1,
|
||||
"debug", o_debug,
|
||||
"opts", opts,
|
||||
FTDM_TAG_END) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error starting FreeTDM span %d node: %s switch: %s dp: %s l1: %s debug: %s error: %s\n",
|
||||
span_id, switch_str_nil(o_node), switch_str_nil(o_switch), switch_str_nil(o_dp), switch_str_nil(o_l1), switch_str_nil(o_debug),
|
||||
ftdm_span_get_last_error(span));
|
||||
span_id = ftdm_span_get_id(span);
|
||||
if (ftdm_configure_span_signaling(span, "libpri", on_clear_channel_signal, spanparameters) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM span %s\n", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1367,15 +1367,16 @@ static uint32_t parse_opts(const char *in)
|
|||
* \brief Initialises a libpri span from configuration variables
|
||||
* \param span Span to configure
|
||||
* \param sig_cb Callback function for event signals
|
||||
* \param ap List of configuration variables
|
||||
* \param ftdm_parameters List of configuration variables
|
||||
* \return Success or failure
|
||||
*/
|
||||
static FIO_SIG_CONFIGURE_FUNCTION(ftdm_libpri_configure_span)
|
||||
static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span)
|
||||
{
|
||||
uint32_t i, x = 0;
|
||||
uint32_t paramindex = 0;
|
||||
//ftdm_channel_t *dchans[2] = {0};
|
||||
ftdm_libpri_data_t *isdn_data;
|
||||
char *var, *val;
|
||||
const char *var, *val;
|
||||
|
||||
if (ftdm_span_get_trunk_type(span) >= FTDM_TRUNK_NONE) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Invalid trunk type '%s' defaulting to T1.\n", ftdm_trunk_type2str(ftdm_span_get_trunk_type(span)));
|
||||
|
@ -1427,8 +1428,9 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_libpri_configure_span)
|
|||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
while ((var = va_arg(ap, char *))) {
|
||||
val = va_arg(ap, char *);
|
||||
for (paramindex = 0; paramindex < 10 && ftdm_parameters[paramindex].var; paramindex++) {
|
||||
var = ftdm_parameters[paramindex].var;
|
||||
val = ftdm_parameters[paramindex].val;
|
||||
|
||||
if (!val) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Parameter '%s' has no value\n", var);
|
||||
|
@ -1497,8 +1499,9 @@ ftdm_module_t ftdm_module = {
|
|||
ftdm_libpri_io_init,
|
||||
ftdm_libpri_unload,
|
||||
ftdm_libpri_init,
|
||||
ftdm_libpri_configure_span,
|
||||
NULL
|
||||
NULL,
|
||||
NULL,
|
||||
ftdm_libpri_configure_span
|
||||
};
|
||||
|
||||
/* For Emacs:
|
||||
|
|
Loading…
Reference in New Issue