Merged revisions 49313 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines

Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line

changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line

added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line

removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line

when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line

when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line

added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE. 
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines

* Added check for bridging in misdn_call to avoid setting echocancellation
  when 2 mISDN channels are involved and when bridging is set. That lead
  to a kernel panic before under different situations, because we switched 
  about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
  work again
* fixed typo


........

................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Christian Richter 19 years ago
parent f4cf6c6339
commit 1fe0e3d192

@ -132,7 +132,6 @@ enum misdn_chan_state {
/* misdn_hangup */
MISDN_HOLDED, /*!< if this chan is holded */
MISDN_HOLD_DISCONNECT, /*!< if this chan is holded */
MISDN_FIXUP/*!< if this chan is holded */
};
@ -778,6 +777,20 @@ static int misdn_restart_port (int fd, int argc, char *argv[])
return 0;
}
static int misdn_restart_pid (int fd, int argc, char *argv[])
{
int pid;
if (argc != 4)
return RESULT_SHOWUSAGE;
pid = atoi(argv[3]);
misdn_lib_pid_restart(pid);
return 0;
}
static int misdn_port_up (int fd, int argc, char *argv[])
{
int port;
@ -933,7 +946,6 @@ static struct state_struct state_array[] = {
{MISDN_HUNGUP_FROM_MISDN,"HUNGUP_FROM_MISDN"}, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
{MISDN_HOLDED,"HOLDED"}, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
{MISDN_HOLD_DISCONNECT,"HOLD_DISCONNECT"}, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
{MISDN_FIXUP,"FIXUP"}, /**/
{MISDN_HUNGUP_FROM_AST,"HUNGUP_FROM_AST"} /* when DISCONNECT/RELEASE/REL_COMP came out of */
/* misdn_hangup */
};
@ -1411,6 +1423,8 @@ static struct ast_cli_entry chan_misdn_clis[] = {
"Usage: misdn port unblock\n" },
{ {"misdn","restart","port", NULL}, misdn_restart_port, "Restarts the given port",
"Usage: misdn restart port\n" },
{ {"misdn","restart","pid", NULL}, misdn_restart_pid, "Restarts the given pid",
"Usage: misdn restart pid\n" },
{ {"misdn","port","up", NULL}, misdn_port_up, "Tries to establish L1 on the given port",
"Usage: misdn port up <port>\n" },
{ {"misdn","port","down", NULL}, misdn_port_down, "Tries to deacivate the L1 on the given port",
@ -1427,7 +1441,6 @@ static struct ast_cli_entry chan_misdn_clis[] = {
"Usage: misdn set crypt debug <level>\n" }
};
static int update_config (struct chan_list *ch, int orig)
{
if (!ch) {
@ -1951,6 +1964,15 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
misdn_set_opt_exec(ast,opts);
else
chan_misdn_log(2,port,"NO OPTS GIVEN\n");
/*check for bridging*/
int bridging;
misdn_cfg_get( 0, MISDN_GEN_BRIDGING, &bridging, sizeof(int));
if (bridging && ch->other_ch) {
chan_misdn_log(0, port, "Disabling EC on both Sides\n");
ch->bc->ec_enable=0;
ch->other_ch->bc->ec_enable=0;
}
r=misdn_lib_send_event( newbc, EVENT_SETUP );
@ -2026,7 +2048,6 @@ static int misdn_answer(struct ast_channel *ast)
}
p->state = MISDN_CONNECTED;
misdn_lib_echo(p->bc,0);
stop_indicate(p);
if ( ast_strlen_zero(p->bc->cad) ) {
@ -2113,7 +2134,6 @@ static int misdn_fixup(struct ast_channel *oldast, struct ast_channel *ast)
chan_misdn_log(1, p->bc?p->bc->port:0, "* IND: Got Fixup State:%s L3id:%x\n", misdn_get_ch_state(p), p->l3id);
p->ast = ast ;
p->state=MISDN_FIXUP;
return 0;
}
@ -2248,7 +2268,7 @@ static int misdn_indication(struct ast_channel *ast, int cond, const void *data,
chan_misdn_log(1, p->bc->port, " --> *\tUNHOLD pid:%d\n",p->bc?p->bc->pid:-1);
break;
default:
ast_log(LOG_NOTICE, " --> * Unknown Indication:%d pid:%d\n",cond,p->bc?p->bc->pid:-1);
chan_misdn_log(1, p->bc->port, " --> * Unknown Indication:%d pid:%d\n",cond,p->bc?p->bc->pid:-1);
}
return 0;
@ -2281,7 +2301,6 @@ static int misdn_hangup(struct ast_channel *ast)
if (ast->_state == AST_STATE_RESERVED ||
p->state == MISDN_NOTHING ||
p->state == MISDN_HOLDED ||
p->state == MISDN_FIXUP ||
p->state == MISDN_HOLD_DISCONNECT ) {
CLEAN_CH:
@ -2676,29 +2695,12 @@ static enum ast_bridge_result misdn_bridge (struct ast_channel *c0,
if (ch1 && ch2 ) ;
else
return -1;
int bridging;
misdn_cfg_get( 0, MISDN_GEN_BRIDGING, &bridging, sizeof(int));
if (bridging) {
int ecwb, ec;
misdn_cfg_get( ch1->bc->port, MISDN_CFG_ECHOCANCELWHENBRIDGED, &ecwb, sizeof(int));
misdn_cfg_get( ch1->bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
if ( !ecwb && ec ) {
chan_misdn_log(2, ch1->bc->port, "Disabling Echo Cancellor when Bridged\n");
ch1->bc->ec_enable=0;
manager_ec_disable(ch1->bc);
}
misdn_cfg_get( ch2->bc->port, MISDN_CFG_ECHOCANCELWHENBRIDGED, &ecwb, sizeof(int));
misdn_cfg_get( ch2->bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
if ( !ecwb && ec) {
chan_misdn_log(2, ch2->bc->port, "Disabling Echo Cancellor when Bridged\n");
ch2->bc->ec_enable=0;
manager_ec_disable(ch2->bc);
}
/* trying to make a mISDN_dsp conference */
chan_misdn_log(1, ch1->bc->port, "I SEND: Making conference with Number:%d\n", ch1->bc->pid +1);
misdn_lib_bridge(ch1->bc,ch2->bc);
}
@ -2777,6 +2779,10 @@ static int dialtone_indicate(struct chan_list *cl)
const struct ind_tone_zone_sound *ts= NULL;
struct ast_channel *ast=cl->ast;
if (!ast) {
chan_misdn_log(0,cl->bc->port,"No Ast in dialtone_indicate\n");
return -1;
}
int nd=0;
misdn_cfg_get( cl->bc->port, MISDN_CFG_NODIALTONE, &nd, sizeof(nd));
@ -2810,6 +2816,12 @@ static int hanguptone_indicate(struct chan_list *cl)
static int stop_indicate(struct chan_list *cl)
{
struct ast_channel *ast=cl->ast;
if (!ast) {
chan_misdn_log(0,cl->bc->port,"No Ast in stop_indicate\n");
return -1;
}
chan_misdn_log(3,cl->bc->port," --> None\n");
misdn_lib_tone_generator_stop(cl->bc);
ast_playtones_stop(ast);
@ -3553,6 +3565,11 @@ void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_
if (ch->other_ch) ch->other_ch->other_ch=ch;
}
}
tmp=pbx_builtin_getvar_helper(chan,"MISDN_ADDRESS_COMPLETE");
if (tmp && (atoi(tmp) == 1)) {
bc->sending_complete=1;
}
}
void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
@ -3561,6 +3578,16 @@ void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_
chan_misdn_log(3,bc->port," --> EXPORT_PID: pid:%d\n",bc->pid);
sprintf(tmp,"%d",bc->pid);
pbx_builtin_setvar_helper(chan,"_MISDN_PID",tmp);
if (bc->sending_complete) {
sprintf(tmp,"%d",bc->sending_complete);
pbx_builtin_setvar_helper(chan,"MISDN_ADDRESS_COMPLETE",tmp);
}
if (bc->urate) {
sprintf(tmp,"%d",bc->urate);
pbx_builtin_setvar_helper(chan,"MISDN_URATE",tmp);
}
}
int add_in_calls(int port)
@ -3608,7 +3635,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /* Debug Only Non-Bchan */
int debuglevel=1;
if ( event==EVENT_CLEANUP && !user_data)
debuglevel=5;
@ -4191,8 +4217,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE);
struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
misdn_lib_echo(bc,0);
stop_indicate(ch);
if (bridged && !strcasecmp(bridged->tech->type,"mISDN")) {
@ -4378,7 +4402,11 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
int ret=write(ch->pipe[1], bc->bframe, bc->bframe_len);
if (ret<=0) {
chan_misdn_log(-1, bc->port, "Write returned <=0 (err=%s)\n",strerror(errno));
chan_misdn_log(-1, bc->port, "Write returned <=0 (err=%s) --> hanging up channel\n",strerror(errno));
stop_bc_tones(ch);
hangup_chan(ch);
release_chan(bc);
}
} else {
chan_misdn_log(1, bc->port, "Wripe Pipe full!\n");
@ -4547,7 +4575,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
break;
default:
ast_log(LOG_NOTICE, "Got Unknown Event\n");
chan_misdn_log(1,0, "Got Unknown Event\n");
break;
}
@ -4773,7 +4801,7 @@ static int misdn_facility_exec(struct ast_channel *chan, void *data)
strncpy((char *)ch->bc->fac_out.u.CDeflection.DeflectedToNumber, tok, sizeof(ch->bc->fac_out.u.CDeflection.DeflectedToNumber));
misdn_lib_send_event(ch->bc, EVENT_FACILITY);
} else {
ast_log(LOG_WARNING, "Unknown Facility: %s\n",tok);
chan_misdn_log(1, ch->bc->port, "Unknown Facility: %s\n",tok);
}
return 0;

@ -43,7 +43,6 @@ static void strnncpy(char *dest, char *src, int len, int dst_len)
/* IE_COMPLETE */
#if 0
static void enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete, int nt, struct misdn_bchannel *bc)
{
unsigned char *p;
@ -70,7 +69,6 @@ static void enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete, in
p[0] = IE_COMPLETE;
}
}
#endif
static void dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete, int nt, struct misdn_bchannel *bc)
{

@ -193,6 +193,7 @@ int setup_bc(struct misdn_bchannel *bc);
int manager_isdn_handler(iframe_t *frm ,msg_t *msg);
int misdn_lib_port_restart(int port);
int misdn_lib_pid_restart(int pid);
extern struct isdn_msg msgs_g[];
@ -447,7 +448,6 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan
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);
stack->channels[i] = 1;
bc->channel=i+1;
cb_event(EVENT_NEW_CHANNEL, bc, NULL);
return i+1;
@ -463,8 +463,8 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan
static int empty_chan_in_stack(struct misdn_stack *stack, int channel)
{
if (channel<=0) {
cb_log(0,stack?stack->port:0, "empty_chan_inst_stack: cannot empty channel %d\n",channel);
if (channel<=0 || channel>=MAX_BCHANS) {
cb_log(0,stack?stack->port:0, "empty_chan_in_stack: cannot empty channel %d\n",channel);
return -1;
}
@ -682,10 +682,17 @@ static int set_chan_in_stack(struct misdn_stack *stack, int channel)
{
cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel);
if (channel >=1 ) {
stack->channels[channel-1] = 1;
dump_chan_list(stack);
if (channel >=1 && channel <= MAX_BCHANS) {
if (!stack->channels[channel-1])
stack->channels[channel-1] = 1;
else {
cb_log(0,stack->port,"channel already in use:%d\n", channel );
return -1;
}
} else {
cb_log(0,stack->port,"couldn't set channel %d in\n", channel );
return -1;
}
return 0;
@ -831,6 +838,8 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0))
return -1;
/*bc->channel=free_chan;*/
if (set_chan_in_stack(stack ,bc->channel)<0) return -1;
cb_log(4,stack->port, " --> found channel: %d\n", bc->channel);
@ -862,6 +871,7 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
return -1;
/*bc->channel=free_chan;*/
cb_log(2,stack->port, " --> found channel: %d\n", bc->channel);
if (set_chan_in_stack(stack ,bc->channel)<0) return -1;
} else {
/* other phones could have made a call also on this port (ptmp) */
bc->channel=0xff;
@ -1494,26 +1504,26 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_
setup_bc(bc);
case EVENT_SETUP:
{
if (bc->channel == 0xff) {
if (!find_free_chan_in_stack(stack, bc, 0)) {
cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
break;
bc->out_cause=34;
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
return -1;
}
}
}
if (bc->channel >0 && bc->channel<255) {
set_chan_in_stack(stack ,bc->channel);
}
#if 0
int ret=setup_bc(bc);
if (ret == -EINVAL){
cb_log(0,bc->port,"handle_event: setup_bc failed\n");
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
int ret=set_chan_in_stack(stack ,bc->channel);
if (event == EVENT_SETUP && ret<0){
/* empty bchannel */
bc->channel=0;
bc->out_cause=44;
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
return -1;
}
}
#endif
}
break;
@ -1795,11 +1805,6 @@ handle_event_nt(void *dat, void *arg)
cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo);
bc->l3_id=hh->dinfo;
if (bc->channel<=0) {
if (!find_free_chan_in_stack(stack, bc, 0))
goto ERR_NO_CHANNEL;
}
}
break;
@ -2027,32 +2032,22 @@ handle_event_nt(void *dat, void *arg)
switch (event) {
case EVENT_SETUP:
if (bc->channel>0 && bc->channel<255) {
if (stack->ptp)
set_chan_in_stack(stack, bc->channel);
else
cb_log(3,stack->port," --> PTMP but channel requested\n");
} else {
if (!find_free_chan_in_stack(stack, bc, 0)) {
cb_log(0, stack->port, " No free channel at the moment\n");
msg_t *dmsg;
cb_log(0, stack->port, "Releaseing call %x (No free Chan for you..)\n", hh->dinfo);
dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
stack->nst.manager_l3(&stack->nst, dmsg);
free_msg(msg);
return 0;
}
}
#if 0
setup_bc(bc);
#endif
if (bc->channel<=0 || bc->channel==0xff) {
bc->channel=find_free_chan_in_stack(stack,bc, 0);
if (bc->channel<=0)
goto ERR_NO_CHANNEL;
} else if (!stack->ptp)
cb_log(3,stack->port," --> PTMP but channel requested\n");
int ret=set_chan_in_stack(stack, bc->channel);
if (event==EVENT_SETUP && ret<0){
/* empty bchannel */
bc->channel=0;
bc->out_cause=44;
goto ERR_NO_CHANNEL;
}
break;
case EVENT_RELEASE:
case EVENT_RELEASE_COMPLETE:
@ -2597,7 +2592,12 @@ handle_frm_bc:
isdn_msg_parse_event(msgs_g,msg,bc, 0);
/** Preprocess some Events **/
handle_event(bc, event, frm);
int ret=handle_event(bc, event, frm);
if (ret<0) {
cb_log(0,stack->port,"couldn't handle event\n");
free_msg(msg);
return 1;
}
/* shoot up event to App: */
cb_log(5, stack->port, "lib Got Prim: Addr %x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
@ -3227,7 +3227,13 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
if (bc->channel <=0 ) { /* else we have the channel already */
if (!find_free_chan_in_stack(stack, bc, 0)) {
cb_log(0, stack->port, " No free channel at the moment\n");
/*FIXME: add disconnect*/
err=-ENOCHAN;
goto ERR;
}
if (set_chan_in_stack(stack ,bc->channel)<0) {
/*FIXME: add disconnect*/
err=-ENOCHAN;
goto ERR;
}
@ -3324,6 +3330,16 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
bc->need_disconnect=0;
bc->need_release=0;
bc->need_release_complete=0;
if (!stack->nt) {
/*create clenaup in TE*/
if (bc->channel>0)
empty_chan_in_stack(stack,bc->channel);
int tmpcause=bc->cause;
empty_bc(bc);
bc->cause=tmpcause;
clean_up_bc(bc);
}
break;
case EVENT_CONNECT_ACKNOWLEDGE:
@ -3577,6 +3593,16 @@ int queue_cleanup_bc(struct misdn_bchannel *bc)
}
int misdn_lib_pid_restart(int pid)
{
struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);
if (bc) {
manager_clean_bc(bc);
}
return 0;
}
int misdn_lib_port_restart(int port)
{
struct misdn_stack *stack=find_stack_by_port(port);
@ -4074,7 +4100,7 @@ void manager_clean_bc(struct misdn_bchannel *bc )
empty_chan_in_stack(stack, bc->channel);
empty_bc(bc);
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
cb_event(EVENT_CLEANUP, bc, NULL);
}

@ -408,6 +408,8 @@ void isdn_lib_update_ec (struct misdn_bchannel *bc);
void isdn_lib_stop_dtmf (struct misdn_bchannel *bc);
int misdn_lib_port_restart(int port);
int misdn_lib_pid_restart(int pid);
int misdn_lib_get_port_info(int port);
int misdn_lib_is_port_blocked(int port);

@ -326,6 +326,10 @@ static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, in
enc_ie_bearer(&setup->BEARER, msg, coding, capability, mode, rate, -1, user, nt,bc);
}
if (bc->sending_complete) {
enc_ie_complete(&setup->BEARER,msg, bc->sending_complete, nt, bc);
}
#if DEBUG
printf("Building SETUP Msg\n");

@ -105,7 +105,7 @@ static const struct misdn_cfg_spec port_spec[] = {
"\talso in switzerland this seems to be important." },
{ "far_alerting", MISDN_CFG_FAR_ALERTING, MISDN_CTYPE_BOOL, "no", NONE,
"If we should generate ringing for chan_sip and others." },
{ "pmp_l1_check", MISDN_CFG_PMP_L1_CHECK, MISDN_CTYPE_BOOL, "yes", NONE,
{ "pmp_l1_check", MISDN_CFG_PMP_L1_CHECK, MISDN_CTYPE_BOOL, "no", NONE,
"This option defines, if chan_misdn should check the L1 on a PMP\n"
"\tbefore makeing a group call on it. The L1 may go down for PMP Ports\n"
"\tso we might need this.\n"

@ -198,9 +198,9 @@ te_choose_channel=no
; as well, since chan_misdn has no chance to distinguish if the L1 is down
; because of a lost Link or because the Provider shut it down...
;
; default: yes
; default: no
;
pmp_l1_check=yes
pmp_l1_check=no
pp_l2_check=no

@ -39,6 +39,7 @@ Overview
- Configuration
- Dial and Options String
- misdn cli commands
- mISDN Variables
- Debugging and sending Bugreports
- Examples
- Known Problems
@ -223,6 +224,15 @@ where 1 is the Port of the Card where the phone is plugged in, and 101 is the
msn (callerid) of the Phone to send the text to.
mISDN Variables
---------------
mISDN Exports/Imports a few Variables:
- MISDN_ADDRESS_COMPLETE : Is either set to 1 from the Provider, or you
can set it to 1 to force a sending complete.
Debugging and sending bug reports
---------------------------------

Loading…
Cancel
Save