|
|
|
@ -430,33 +430,36 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline void free_robin_list_r (struct robin_list *r)
|
|
|
|
|
static void free_robin_list(void)
|
|
|
|
|
{
|
|
|
|
|
if (r) {
|
|
|
|
|
if (r->next)
|
|
|
|
|
free_robin_list_r(r->next);
|
|
|
|
|
if (r->group)
|
|
|
|
|
ast_free(r->group);
|
|
|
|
|
struct robin_list *r;
|
|
|
|
|
struct robin_list *next;
|
|
|
|
|
|
|
|
|
|
for (r = robin, robin = NULL; r; r = next) {
|
|
|
|
|
next = r->next;
|
|
|
|
|
ast_free(r->group);
|
|
|
|
|
ast_free(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void free_robin_list ( void )
|
|
|
|
|
{
|
|
|
|
|
free_robin_list_r(robin);
|
|
|
|
|
robin = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct robin_list* get_robin_position (char *group)
|
|
|
|
|
{
|
|
|
|
|
struct robin_list *new;
|
|
|
|
|
struct robin_list *iter = robin;
|
|
|
|
|
for (; iter; iter = iter->next) {
|
|
|
|
|
if (!strcasecmp(iter->group, group))
|
|
|
|
|
if (!strcasecmp(iter->group, group)) {
|
|
|
|
|
return iter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
new = ast_calloc(1, sizeof(*new));
|
|
|
|
|
new->group = strndup(group, strlen(group));
|
|
|
|
|
if (!new) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
new->group = ast_strdup(group);
|
|
|
|
|
if (!new->group) {
|
|
|
|
|
ast_free(new);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
new->channel = 1;
|
|
|
|
|
if (robin) {
|
|
|
|
|
new->next = robin;
|
|
|
|
@ -3386,16 +3389,15 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
|
|
|
|
|
{
|
|
|
|
|
struct ast_channel *tmp = NULL;
|
|
|
|
|
char group[BUFFERSIZE + 1] = "";
|
|
|
|
|
char buf[128];
|
|
|
|
|
char dial_str[128];
|
|
|
|
|
char *buf2 = ast_strdupa(data), *ext = NULL, *port_str;
|
|
|
|
|
char *tokb = NULL, *p = NULL;
|
|
|
|
|
int channel = 0, port = 0;
|
|
|
|
|
struct misdn_bchannel *newbc = NULL;
|
|
|
|
|
int dec = 0;
|
|
|
|
|
struct chan_list *cl;
|
|
|
|
|
|
|
|
|
|
struct chan_list *cl = init_chan_list(ORG_AST);
|
|
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", misdn_type, (char*)data);
|
|
|
|
|
snprintf(dial_str, sizeof(dial_str), "%s/%s", misdn_type, (char*)data);
|
|
|
|
|
|
|
|
|
|
port_str = strtok_r(buf2, "/", &tokb);
|
|
|
|
|
|
|
|
|
@ -3538,10 +3540,16 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* create ast_channel and link all the objects together */
|
|
|
|
|
cl = init_chan_list(ORG_AST);
|
|
|
|
|
if (!cl) {
|
|
|
|
|
ast_log(LOG_ERROR, "Could not create call record for Dial(%s)\n", dial_str);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
cl->bc = newbc;
|
|
|
|
|
|
|
|
|
|
tmp = misdn_new(cl, AST_STATE_RESERVED, ext, NULL, format, port, channel);
|
|
|
|
|
if (!tmp) {
|
|
|
|
|
ast_free(cl);
|
|
|
|
|
ast_log(LOG_ERROR,"Could not create Asterisk object\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -4469,6 +4477,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
chan = misdn_new(ch, AST_STATE_RESERVED, bc->dad, bc->oad, AST_FORMAT_ALAW, bc->port, bc->channel);
|
|
|
|
|
|
|
|
|
|
if (!chan) {
|
|
|
|
|
ast_free(ch);
|
|
|
|
|
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
|
|
|
|
|
ast_log(LOG_ERROR, "cb_events: misdn_new failed !\n");
|
|
|
|
|
return 0;
|
|
|
|
@ -5235,11 +5244,11 @@ static int unload_module(void)
|
|
|
|
|
misdn_cfg_destroy();
|
|
|
|
|
misdn_lib_destroy();
|
|
|
|
|
|
|
|
|
|
if (misdn_debug)
|
|
|
|
|
ast_free(misdn_debug);
|
|
|
|
|
if (misdn_debug_only)
|
|
|
|
|
ast_free(misdn_debug_only);
|
|
|
|
|
ast_free(misdn_ports);
|
|
|
|
|
ast_free(misdn_out_calls);
|
|
|
|
|
ast_free(misdn_in_calls);
|
|
|
|
|
ast_free(misdn_debug_only);
|
|
|
|
|
ast_free(misdn_ports);
|
|
|
|
|
ast_free(misdn_debug);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -5277,6 +5286,7 @@ static int load_module(void)
|
|
|
|
|
}
|
|
|
|
|
misdn_ports = ast_malloc(sizeof(int) * (max_ports + 1));
|
|
|
|
|
if (!misdn_ports) {
|
|
|
|
|
ast_free(misdn_debug);
|
|
|
|
|
ast_log(LOG_ERROR, "Out of memory for misdn_ports\n");
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
@ -5287,13 +5297,34 @@ static int load_module(void)
|
|
|
|
|
}
|
|
|
|
|
*misdn_ports = 0;
|
|
|
|
|
misdn_debug_only = ast_calloc(max_ports + 1, sizeof(int));
|
|
|
|
|
if (!misdn_debug_only) {
|
|
|
|
|
ast_free(misdn_ports);
|
|
|
|
|
ast_free(misdn_debug);
|
|
|
|
|
ast_log(LOG_ERROR, "Out of memory for misdn_debug_only\n");
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
misdn_cfg_get(0, MISDN_GEN_TRACEFILE, tempbuf, sizeof(tempbuf));
|
|
|
|
|
if (!ast_strlen_zero(tempbuf))
|
|
|
|
|
tracing = 1;
|
|
|
|
|
|
|
|
|
|
misdn_in_calls = ast_malloc(sizeof(int) * (max_ports + 1));
|
|
|
|
|
if (!misdn_in_calls) {
|
|
|
|
|
ast_free(misdn_debug_only);
|
|
|
|
|
ast_free(misdn_ports);
|
|
|
|
|
ast_free(misdn_debug);
|
|
|
|
|
ast_log(LOG_ERROR, "Out of memory for misdn_in_calls\n");
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
|
misdn_out_calls = ast_malloc(sizeof(int) * (max_ports + 1));
|
|
|
|
|
if (!misdn_out_calls) {
|
|
|
|
|
ast_free(misdn_in_calls);
|
|
|
|
|
ast_free(misdn_debug_only);
|
|
|
|
|
ast_free(misdn_ports);
|
|
|
|
|
ast_free(misdn_debug);
|
|
|
|
|
ast_log(LOG_ERROR, "Out of memory for misdn_out_calls\n");
|
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 1; i <= max_ports; i++) {
|
|
|
|
|
misdn_in_calls[i] = 0;
|
|
|
|
|