added method standard_dec for dialing out on groups, to avoid conflicts, which caused issues with some ISDN providers

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@58849 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2
Christian Richter 19 years ago
parent 7158b80498
commit 3b2e8feab4

@ -2526,6 +2526,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
char *tokb=NULL, *p=NULL; char *tokb=NULL, *p=NULL;
int channel=0, port=0; int channel=0, port=0;
struct misdn_bchannel *newbc = NULL; struct misdn_bchannel *newbc = NULL;
int dec=0;
struct chan_list *cl=init_chan_list(ORG_AST); struct chan_list *cl=init_chan_list(ORG_AST);
@ -2554,23 +2555,27 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
else { else {
port = atoi(port_str); port = atoi(port_str);
} }
} else { } else {
ast_log(LOG_WARNING, " --> ! IND : CALL dad:%s WITHOUT PORT/Group, check extension.conf\n",ext); ast_log(LOG_WARNING, " --> ! IND : CALL dad:%s WITHOUT PORT/Group, check extension.conf\n",ext);
return NULL; return NULL;
} }
if (misdn_cfg_is_group_method(group, METHOD_STANDARD_DEC)) {
chan_misdn_log(0, port, " --> STARTING STANDARDDEC...\n");
dec=1;
}
if (!ast_strlen_zero(group)) { if (!ast_strlen_zero(group)) {
char cfg_group[BUFFERSIZE+1]; char cfg_group[BUFFERSIZE+1];
struct robin_list *rr = NULL; struct robin_list *rr = NULL;
if (misdn_cfg_is_group_method(group, METHOD_ROUND_ROBIN)) { if (misdn_cfg_is_group_method(group, METHOD_ROUND_ROBIN)) {
chan_misdn_log(4, port, " --> STARTING ROUND ROBIN..."); chan_misdn_log(4, port, " --> STARTING ROUND ROBIN...\n");
rr = get_robin_position(group); rr = get_robin_position(group);
} }
if (rr) { if (rr) {
int robin_channel = rr->channel; int robin_channel = rr->channel;
int port_start; int port_start;
@ -2612,7 +2617,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
if ( port_up>0 ) { if ( port_up>0 ) {
newbc = misdn_lib_get_free_bc(port, robin_channel,0); newbc = misdn_lib_get_free_bc(port, robin_channel,0, 0);
if (newbc) { if (newbc) {
chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel); chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
if (port_up) if (port_up)
@ -2628,9 +2633,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
if (!newbc) if (!newbc)
chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group); chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group);
} } else {
else {
for (port=misdn_cfg_get_next_port(0); port > 0; for (port=misdn_cfg_get_next_port(0); port > 0;
port=misdn_cfg_get_next_port(port)) { port=misdn_cfg_get_next_port(port)) {
@ -2646,18 +2649,17 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
chan_misdn_log(4, port, "portup:%d\n", port_up); chan_misdn_log(4, port, "portup:%d\n", port_up);
if ( port_up>0 ) { if ( port_up>0 ) {
newbc = misdn_lib_get_free_bc(port, 0, 0); newbc = misdn_lib_get_free_bc(port, 0, 0, dec);
if (newbc) if (newbc)
break; break;
} }
} }
} }
} }
} else { } else {
if (channel) if (channel)
chan_misdn_log(1, port," --> preselected_channel: %d\n",channel); chan_misdn_log(1, port," --> preselected_channel: %d\n",channel);
newbc = misdn_lib_get_free_bc(port, channel, 0); newbc = misdn_lib_get_free_bc(port, channel, 0, dec);
} }
if (!newbc) { if (!newbc) {

@ -81,7 +81,8 @@ enum misdn_cfg_elements {
enum misdn_cfg_method { enum misdn_cfg_method {
METHOD_STANDARD = 0, METHOD_STANDARD = 0,
METHOD_ROUND_ROBIN METHOD_ROUND_ROBIN,
METHOD_STANDARD_DEC
}; };
/* you must call misdn_cfg_init before any other function of this header file */ /* you must call misdn_cfg_init before any other function of this header file */

@ -417,7 +417,7 @@ void dump_chan_list(struct misdn_stack *stack)
static int find_free_chan_in_stack(struct misdn_stack *stack, int channel) static int find_free_chan_in_stack(struct misdn_stack *stack, int channel, int dec)
{ {
int i; int i;
@ -429,12 +429,23 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, int channel)
} }
channel--; channel--;
for (i = 0; i < stack->b_num; i++) { if (dec) {
if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */ for (i = stack->b_num-1; i >=0; i--) {
if (!stack->channels[i]) { if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1); if (!stack->channels[i]) {
return i+1; cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
return i+1;
}
}
}
} else {
for (i = 0; i < stack->b_num; i++) {
if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
if (!stack->channels[i]) {
cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
return i+1;
}
} }
} }
} }
@ -525,6 +536,7 @@ void empty_bc(struct misdn_bchannel *bc)
bc->in_use= 0; bc->in_use= 0;
bc->cw= 0; bc->cw= 0;
bc->dec=0;
bc->channel = 0; bc->channel = 0;
bc->sending_complete = 0; bc->sending_complete = 0;
@ -671,7 +683,7 @@ int set_chan_in_stack(struct misdn_stack *stack, int channel)
if (!stack->channels[channel-1]) if (!stack->channels[channel-1])
stack->channels[channel-1] = 1; stack->channels[channel-1] = 1;
else { else {
cb_log(0,stack->port,"channel already in use:%d\n", channel ); cb_log(4,stack->port,"channel already in use:%d\n", channel );
return -1; return -1;
} }
} else { } else {
@ -818,7 +830,7 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
int free_chan; int free_chan;
if (stack->nt) { if (stack->nt) {
free_chan = find_free_chan_in_stack(stack, bc->channel_preselected?bc->channel:0); free_chan = find_free_chan_in_stack(stack, bc->channel_preselected?bc->channel:0, 0);
if (!free_chan) return -1; if (!free_chan) return -1;
bc->channel=free_chan; bc->channel=free_chan;
@ -850,7 +862,7 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
} else { } else {
if (stack->ptp || bc->te_choose_channel) { if (stack->ptp || bc->te_choose_channel) {
/* we know exactly which channels are in use */ /* we know exactly which channels are in use */
free_chan = find_free_chan_in_stack(stack, bc->channel_preselected?bc->channel:0); free_chan = find_free_chan_in_stack(stack, bc->channel_preselected?bc->channel:0, bc->dec);
if (!free_chan) return -1; if (!free_chan) return -1;
bc->channel=free_chan; bc->channel=free_chan;
cb_log(2,stack->port, " --> found channel: %d\n",free_chan); cb_log(2,stack->port, " --> found channel: %d\n",free_chan);
@ -1480,7 +1492,7 @@ int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm)
case EVENT_SETUP: case EVENT_SETUP:
{ {
if (bc->channel == 0xff) { if (bc->channel == 0xff) {
bc->channel=find_free_chan_in_stack(stack, 0); bc->channel=find_free_chan_in_stack(stack, 0, 0);
if (!bc->channel) { if (!bc->channel) {
cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n"); cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
bc->out_cause=34; bc->out_cause=34;
@ -1531,7 +1543,7 @@ int handle_cr ( struct misdn_stack *stack, iframe_t *frm)
case CC_NEW_CR|INDICATION: case CC_NEW_CR|INDICATION:
cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo); cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1); struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
if (!bc) { if (!bc) {
cb_log(0, stack->port, " --> !! lib: No free channel!\n"); cb_log(0, stack->port, " --> !! lib: No free channel!\n");
return -1; return -1;
@ -1787,7 +1799,7 @@ handle_event_nt(void *dat, void *arg)
case CC_SETUP|INDICATION: case CC_SETUP|INDICATION:
{ {
struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1); struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
if (!bc) if (!bc)
ERR_NO_CHANNEL: ERR_NO_CHANNEL:
{ {
@ -2032,7 +2044,7 @@ handle_event_nt(void *dat, void *arg)
switch (event) { switch (event) {
case EVENT_SETUP: case EVENT_SETUP:
if (bc->channel<=0 || bc->channel==0xff) { if (bc->channel<=0 || bc->channel==0xff) {
bc->channel=find_free_chan_in_stack(stack,0); bc->channel=find_free_chan_in_stack(stack,0,0);
if (bc->channel<=0) if (bc->channel<=0)
goto ERR_NO_CHANNEL; goto ERR_NO_CHANNEL;
@ -3031,7 +3043,7 @@ void prepare_bc(struct misdn_bchannel*bc, int channel)
#endif #endif
} }
struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout) struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec)
{ {
struct misdn_stack *stack; struct misdn_stack *stack;
int i; int i;
@ -3064,14 +3076,29 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout)
} }
int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num; int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
for (i = 0; i <maxnum; i++) {
if (!stack->bc[i].in_use) { if (dec) {
/* 3. channel on bri means CW*/ for (i = maxnum-1; i>=0; i--) {
if (!stack->pri && i==stack->b_num) if (!stack->bc[i].in_use) {
stack->bc[i].cw=1; /* 3. channel on bri means CW*/
if (!stack->pri && i==stack->b_num)
prepare_bc(&stack->bc[i], channel); stack->bc[i].cw=1;
return &stack->bc[i];
prepare_bc(&stack->bc[i], channel);
stack->bc[i].dec=1;
return &stack->bc[i];
}
}
} else {
for (i = 0; i <maxnum; i++) {
if (!stack->bc[i].in_use) {
/* 3. channel on bri means CW*/
if (!stack->pri && i==stack->b_num)
stack->bc[i].cw=1;
prepare_bc(&stack->bc[i], channel);
return &stack->bc[i];
}
} }
} }
@ -3193,7 +3220,7 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
if (stack->nt) { if (stack->nt) {
if (bc->channel <=0 ) { /* else we have the channel already */ if (bc->channel <=0 ) { /* else we have the channel already */
bc->channel = find_free_chan_in_stack(stack, 0); bc->channel = find_free_chan_in_stack(stack, 0, 0);
if (!bc->channel) { if (!bc->channel) {
cb_log(0, stack->port, " No free channel at the moment\n"); cb_log(0, stack->port, " No free channel at the moment\n");
/*FIXME: add disconnect*/ /*FIXME: add disconnect*/

@ -228,6 +228,7 @@ struct misdn_bchannel {
int need_release; int need_release;
int need_release_complete; int need_release_complete;
int dec;
/** var stuff**/ /** var stuff**/
int l3_id; int l3_id;
int pid; int pid;
@ -402,7 +403,7 @@ char *manager_isdn_get_info(enum event_e event);
void misdn_lib_transfer(struct misdn_bchannel* holded_bc); void misdn_lib_transfer(struct misdn_bchannel* holded_bc);
struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout); struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec);
void manager_bchannel_activate(struct misdn_bchannel *bc); void manager_bchannel_activate(struct misdn_bchannel *bc);
void manager_bchannel_deactivate(struct misdn_bchannel * bc); void manager_bchannel_deactivate(struct misdn_bchannel * bc);

@ -349,9 +349,12 @@ int misdn_cfg_is_port_valid (int port)
int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth) int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth)
{ {
int i, re = 0; int i, re = 0;
char *method = NULL; char *method ;
misdn_cfg_lock(); misdn_cfg_lock();
method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
for (i = 1; i <= max_ports; i++) { for (i = 1; i <= max_ports; i++) {
if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
@ -359,12 +362,15 @@ int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth)
port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
} }
} }
if (method) { if (method) {
switch (meth) { switch (meth) {
case METHOD_STANDARD: re = !strcasecmp(method, "standard"); case METHOD_STANDARD: re = !strcasecmp(method, "standard");
break; break;
case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin");
break; break;
case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec");
break;
} }
} }
misdn_cfg_unlock(); misdn_cfg_unlock();

Loading…
Cancel
Save